intersection.h 4.34 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-2012, 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.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28 29 30 31 32 33
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __ALGO_GEOMETRY_INTERSECTION_H__
#define __ALGO_GEOMETRY_INTERSECTION_H__

namespace CGoGN
{

namespace Algo
{

Thery Sylvain's avatar
Thery Sylvain committed
34 35 36
namespace Surface
{

Pierre Kraemer's avatar
Pierre Kraemer committed
37 38 39 40 41 42 43 44
namespace Geometry
{

/**
 * test the intersection between a line and a n-sided face (n>=3)
 * (works with triangular faces but not optimized)
 * TODO to test
 * @param map the map
45
 * @param f a n-sided face
Pierre Kraemer's avatar
Pierre Kraemer committed
46 47 48 49 50 51
 * @param PA segment point 1
 * @param Dir a direction for the line
 * @param Inter store the intersection point
 * @return true if segment intersects the face
 */
template <typename PFP>
52
bool intersectionLineConvexFace(typename PFP::MAP& map, Face f, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const typename PFP::VEC3& P, const typename PFP::VEC3& Dir, typename PFP::VEC3& Inter) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
53 54 55 56

/**
 * test the intersection between a segment and a n-sided face (n>=3)
 * (works with triangular faces but not optimized)
57
 * TODO optimize - based on intersectionLineConvexFace - check whether the points are on both sides of the face before computing intersection
Pierre Kraemer's avatar
Pierre Kraemer committed
58
 * @param map the map
59
 * @param f a n-sided face
Pierre Kraemer's avatar
Pierre Kraemer committed
60 61 62 63 64 65
 * @param PA segment point 1
 * @param PB segment point 2
 * @param Inter store the intersection point
 * @return true if segment intersects the face
 */
template <typename PFP>
66
bool intersectionSegmentConvexFace(typename PFP::MAP& map, Face f, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const typename PFP::VEC3& PA, const typename PFP::VEC3& PB, typename PFP::VEC3& Inter) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
67 68 69 70 71

/**
 * test if two triangles intersect
 * (based on the "Faster Triangle-Triangle intersection Tests" by Oliver Deviller and Philippe Guigue)
 * @param the map
72 73
 * @param the first triangle
 * @param the second triangle
Pierre Kraemer's avatar
Pierre Kraemer committed
74 75
 */
template <typename PFP>
76
bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
77

78
/**
79
 * alpha = coef d'interpolation dans [0,1] tel que v = (1-alpha)*pin + alpha*pout
80
 * est le point d'intersection entre la sphère et le segment [pin, pout]
81 82 83
 * avec pin = position[v1] à l'intérieur de la sphère
 * avec pout = position[v2] à l'extérieur de la sphère
 * et v1 et v2 les deux sommets de l'arête
84 85
 */
template <typename PFP>
86
bool intersectionSphereEdge(typename PFP::MAP& map, typename PFP::VEC3& center, typename PFP::REAL radius, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, typename PFP::REAL& alpha) ;
87 88

} // namespace Geometry
Pierre Kraemer's avatar
Pierre Kraemer committed
89

Thery Sylvain's avatar
Thery Sylvain committed
90 91
} // surface

92
} // namespace Algo
Pierre Kraemer's avatar
Pierre Kraemer committed
93

94
} // namespace CGoGN
Pierre Kraemer's avatar
Pierre Kraemer committed
95 96 97 98

#include "Algo/Geometry/intersection.hpp"

#endif