Geom_inclusion.cpp 3.92 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
/*******************************************************************************
 * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
 * version 0.1                                                                  *
4
 * Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *                                                                              *
 * This library is free software; you can redistribute it and/or modify it      *
 * under the terms of the GNU Lesser General Public License as published by the *
 * Free Software Foundation; either version 2.1 of the License, or (at your     *
 * option) any later version.                                                   *
 *                                                                              *
 * This library 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 Lesser General Public License  *
 * for more details.                                                            *
 *                                                                              *
 * You should have received a copy of the GNU Lesser General Public License     *
 * along with this library; if not, write to the Free Software Foundation,      *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
 *                                                                              *
20
 * Web site: http://cgogn.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28 29 30 31 32
 * Contact information: cgogn@unistra.fr                                        *
 *                                                                              *
 *******************************************************************************/

#include <iostream>
#include <Geometry/inclusion.h>

using namespace CGoGN;

int main()
{
	typedef Geom::Vec3f VEC3;
Sylvain Thery's avatar
Sylvain Thery committed
33 34
	std::cout << "Check Geometry/inclusion.h" << std::endl;
	std::cout << "Check Status : PARTIAL" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
35
	
Sylvain Thery's avatar
Sylvain Thery committed
36
	std::cout << "Check isPointInTriangle : Start" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
37 38 39 40 41
	VEC3 ta(0,0,0);
	VEC3 tb(5,0,0);
	VEC3 tc(0,5,0);
	VEC3 pIn1(1,1,0);
	VEC3 pIn2(2,0,0);
Thomas's avatar
Thomas committed
42 43
	VEC3 pIn3 = (tb+tc)/2.0f;
	VEC3 pIn4 = (tc+ta)/2.0f;
Pierre Kraemer's avatar
Pierre Kraemer committed
44 45 46 47
	VEC3 pOut(6,0,0);

	if(Geom::isPointInTriangle<VEC3>(pIn1,ta,tb,tc)!=Geom::FACE_INCLUSION)
	{
Sylvain Thery's avatar
Sylvain Thery committed
48
		std::cout << "ERROR : isPointInTriangle : face inclusion" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
49 50 51 52
	}

	if(Geom::isPointInTriangle<VEC3>(pIn2,ta,tb,tc)!=Geom::EDGE_INCLUSION)
	{
Sylvain Thery's avatar
Sylvain Thery committed
53
		std::cout << "ERROR : isPointInTriangle : edge inclusion" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
54 55
	}

Thomas's avatar
Thomas committed
56 57
	if(Geom::isPointInTriangle<VEC3>(pIn3,ta,tb,tc)!=Geom::EDGE_INCLUSION)
	{
Sylvain Thery's avatar
Sylvain Thery committed
58
		std::cout << "ERROR : isPointInTriangle : edge inclusion" << std::endl;
Thomas's avatar
Thomas committed
59 60 61 62
	}

	if(Geom::isPointInTriangle<VEC3>(pIn4,ta,tb,tc)!=Geom::EDGE_INCLUSION)
	{
Sylvain Thery's avatar
Sylvain Thery committed
63
		std::cout << "ERROR : isPointInTriangle : edge inclusion" << std::endl;
Thomas's avatar
Thomas committed
64 65
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
66 67
	if(Geom::isPointInTriangle<VEC3>(ta,ta,tb,tc)!=Geom::VERTEX_INCLUSION)
	{
Sylvain Thery's avatar
Sylvain Thery committed
68
		std::cout << "ERROR : isPointInTriangle : vertex inclusion" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
69 70 71 72
	}

	if(Geom::isPointInTriangle<VEC3>(pOut,ta,tb,tc)!=Geom::NO_INCLUSION)
	{
Sylvain Thery's avatar
Sylvain Thery committed
73
		std::cout << "ERROR : isPointInTriangle : no inclusion" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
74 75
	}

Sylvain Thery's avatar
Sylvain Thery committed
76
	std::cout << "Check isPointInTriangle : Done" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
77 78 79 80 81

// 	Inclusion isSegmentInTriangle(const VEC3& P1, const VEC3& P2, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, const VEC3& N) ;
// 	bool isPointInTetrahedron(VEC3 points[4], VEC3& point, bool CCW) ;
// 	bool isEdgeInOrIntersectingTetrahedron(VEC3 points[4], VEC3& point1, VEC3& point2, bool CCW) ;

Sylvain Thery's avatar
Sylvain Thery committed
82
	std::cout << "Check arePointsEquals : Start" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
83 84 85 86 87 88

	VEC3 p1(0,0,0);
	VEC3 p2(0.1,0.1,0.1);
	if(!Geom::arePointsEquals<VEC3>(p1,p1) || !Geom::arePointsEquals<VEC3>(p2,p2) 
		|| Geom::arePointsEquals<VEC3>(p1,p2) || Geom::arePointsEquals<VEC3>(p2,p1))
	{
Sylvain Thery's avatar
Sylvain Thery committed
89
		std::cout << "ERROR : arePointsEquals" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
90 91
	}

Sylvain Thery's avatar
Sylvain Thery committed
92
	std::cout << "Check arePointsEquals : Done" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
93 94 95

	return 0;
}