<commit_before>/**
 *   SFCGAL
 *
 *   Copyright (C) 2012-2013 Oslandia <<EMAIL>>
 *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#include <SFCGAL/Triangle.h>
#include <SFCGAL/GeometryVisitor.h>

#include <SFCGAL/Polygon.h>

namespace SFCGAL {

///
///
///
Triangle::Triangle() :
	Surface()
{
	_vertices[0] = Point();
	_vertices[1] = Point();
	_vertices[2] = Point();
}

///
///
///
Triangle::Triangle( const Kernel::Triangle_2 & triangle )
{
	for ( int i = 0; i < 3; i++ ){
		_vertices[i] = triangle.vertex(i) ;
	}
}


///
///
///
Triangle::Triangle( const Kernel::Triangle_3 & triangle )
{
	for ( int i = 0; i < 3; i++ ){
		_vertices[i] = triangle.vertex(i) ;
	}
}

///
///
///
Triangle::Triangle( const Point & p, const Point & q, const Point & r ) :
	Surface()
{
	_vertices[0] = p ;
	_vertices[1] = q ;
	_vertices[2] = r ;
}


///
///
///
Triangle::Triangle( const Triangle & other )
	: Surface()
{
	_vertices[0] = other._vertices[0] ;
	_vertices[1] = other._vertices[1] ;
	_vertices[2] = other._vertices[2] ;
}




///
///
///
Triangle& Triangle::operator = ( const Triangle & other )
{
	_vertices[0] = other._vertices[0] ;
	_vertices[1] = other._vertices[1] ;
	_vertices[2] = other._vertices[2] ;
	return *this ;
}

///
///
///
Triangle::~Triangle()
{

}



///
///
///
Triangle *   Triangle::clone() const
{
	return new Triangle( *this );
}


///
///
///
std::string    Triangle::geometryType() const
{
	return "Triangle" ;
}


///
///
///
GeometryType   Triangle::geometryTypeId() const
{
	return TYPE_TRIANGLE ;
}


///
///
///
int  Triangle::coordinateDimension() const
{
	return _vertices[0].coordinateDimension() ;
}


///
///
///
bool  Triangle::isEmpty() const
{
	return _vertices[0].isEmpty();
}


///
///
///
bool  Triangle::is3D() const
{
	return _vertices[0].is3D() ;
}

///
///
///
bool  Triangle::isMeasured() const
{
	return _vertices[0].isMeasured() ;
}

///
///
///
void  Triangle::reverse()
{
	std::reverse( _vertices, _vertices + 3 );
}


///
///
///
Polygon  Triangle::toPolygon() const<commit_msg>[Triangle::reverse]simplify function and simplify testing (startPoint/endPoint remains unchanged, same as polygon)<commit_after>/**
 *   SFCGAL
 *
 *   Copyright (C) 2012-2013 Oslandia <<EMAIL>>
 *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#include <SFCGAL/Triangle.h>
#include <SFCGAL/GeometryVisitor.h>

#include <SFCGAL/Polygon.h>

namespace SFCGAL {

///
///
///
Triangle::Triangle() :
	Surface()
{
	_vertices[0] = Point();
	_vertices[1] = Point();
	_vertices[2] = Point();
}

///
///
///
Triangle::Triangle( const Kernel::Triangle_2 & triangle )
{
	for ( int i = 0; i < 3; i++ ){
		_vertices[i] = triangle.vertex(i) ;
	}
}


///
///
///
Triangle::Triangle( const Kernel::Triangle_3 & triangle )
{
	for ( int i = 0; i < 3; i++ ){
		_vertices[i] = triangle.vertex(i) ;
	}
}

///
///
///
Triangle::Triangle( const Point & p, const Point & q, const Point & r ) :
	Surface()
{
	_vertices[0] = p ;
	_vertices[1] = q ;
	_vertices[2] = r ;
}


///
///
///
Triangle::Triangle( const Triangle & other )
	: Surface()
{
	_vertices[0] = other._vertices[0] ;
	_vertices[1] = other._vertices[1] ;
	_vertices[2] = other._vertices[2] ;
}




///
///
///
Triangle& Triangle::operator = ( const Triangle & other )
{
	_vertices[0] = other._vertices[0] ;
	_vertices[1] = other._vertices[1] ;
	_vertices[2] = other._vertices[2] ;
	return *this ;
}

///
///
///
Triangle::~Triangle()
{

}



///
///
///
Triangle *   Triangle::clone() const
{
	return new Triangle( *this );
}


///
///
///
std::string    Triangle::geometryType() const
{
	return "Triangle" ;
}


///
///
///
GeometryType   Triangle::geometryTypeId() const
{
	return TYPE_TRIANGLE ;
}


///
///
///
int  Triangle::coordinateDimension() const
{
	return _vertices[0].coordinateDimension() ;
}


///
///
///
bool  Triangle::isEmpty() const
{
	return _vertices[0].isEmpty();
}


///
///
///
bool  Triangle::is3D() const
{
	return _vertices[0].is3D() ;
}

///
///
///
bool  Triangle::isMeasured() const
{
	return _vertices[0].isMeasured() ;
}

///
///
///
void  Triangle::reverse()
{
	//note : first point kept to simplify testing
	std::swap( _vertices[1], _vertices[2] );
}


///
///
///
Polygon  Triangle::toPolygon() const
{'fraction_non_alphanumeric': 0.1806730250134965, 'fraction_numerical': 0.017455461579989204, 'mean_word_length': 2.87857641311933, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4297725', 'n_tokens_mistral': 2119, 'n_tokens_neox': 2028, 'n_words': 497}