Geom_inclusion.cpp 3.91 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*******************************************************************************
 * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
 * version 0.1                                                                  *
 * Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg                *
 *                                                                              *
 * 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.           *
 *                                                                              *
 * Web site: https://iggservis.u-strasbg.fr/CGoGN/                              *
 * Contact information: cgogn@unistra.fr                                        *
 *                                                                              *
 *******************************************************************************/

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

using namespace CGoGN;

int main()
{
	typedef Geom::Vec3f VEC3;
33
34
	CGoGNout << "Check Geometry/inclusion.h" << CGoGNendl;
	CGoGNout << "Check Status : PARTIAL" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
35
	
36
	CGoGNout << "Check isPointInTriangle : Start" << CGoGNendl;
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)
	{
48
		CGoGNout << "ERROR : isPointInTriangle : face inclusion" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
49
50
51
52
	}

	if(Geom::isPointInTriangle<VEC3>(pIn2,ta,tb,tc)!=Geom::EDGE_INCLUSION)
	{
53
		CGoGNout << "ERROR : isPointInTriangle : edge inclusion" << CGoGNendl;
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)
	{
58
		CGoGNout << "ERROR : isPointInTriangle : edge inclusion" << CGoGNendl;
Thomas's avatar
Thomas committed
59
60
61
62
	}

	if(Geom::isPointInTriangle<VEC3>(pIn4,ta,tb,tc)!=Geom::EDGE_INCLUSION)
	{
63
		CGoGNout << "ERROR : isPointInTriangle : edge inclusion" << CGoGNendl;
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)
	{
68
		CGoGNout << "ERROR : isPointInTriangle : vertex inclusion" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
69
70
71
72
	}

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

76
	CGoGNout << "Check isPointInTriangle : Done" << CGoGNendl;
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) ;

82
	CGoGNout << "Check arePointsEquals : Start" << CGoGNendl;
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))
	{
89
		CGoGNout << "ERROR : arePointsEquals" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
90
91
	}

92
	CGoGNout << "Check arePointsEquals : Done" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
93
94
95

	return 0;
}