Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CGoGN
CGoGN
Commits
0470ea57
Commit
0470ea57
authored
Oct 05, 2012
by
Sylvain Thery
Browse files
Merge branch 'VRJ'
parents
c8a95868
bb4982ae
Changes
49
Expand all
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
0470ea57
...
...
@@ -19,6 +19,8 @@ SET ( WITH_NUMERICAL ON CACHE BOOL "build CGoGN with Numerical libs support ")
SET
(
FORCE_MR
"0"
CACHE STRING
"0: normal mode / 1 multires mode"
)
#create one big lib
SET
(
ONELIB OFF CACHE BOOL
"build CGoGN in one lib"
)
SET
(
WITH_GLEWMX OFF CACHE BOOL
"use multi-contex GLEW"
)
IF
(
WIN32
)
set
(
CMAKE_PREFIX_PATH
${
CGoGN_ROOT_DIR
}
/windows_dependencies CACHE STRING
"path to dependencies"
)
...
...
@@ -54,6 +56,15 @@ ELSE (ONELIB)
file
(
WRITE
${
CGoGN_ROOT_DIR
}
/include/cgogn_onelib.h
"0"
)
ENDIF
(
ONELIB
)
IF
(
WITH_GLEWMX
)
file
(
WRITE
${
CGoGN_ROOT_DIR
}
/include/cgogn_gmx.h
"1"
)
ELSE
(
WITH_GLEWMX
)
file
(
WRITE
${
CGoGN_ROOT_DIR
}
/include/cgogn_gmx.h
"0"
)
ENDIF
(
WITH_GLEWMX
)
add_definitions
(
-DSHADERPATH=
"
${
CGoGN_ROOT_DIR
}
/lib/Shaders/"
)
# define includes of external libs
...
...
@@ -100,6 +111,10 @@ IF (WITH_QT)
SET
(
CGoGN_EXT_LIBS
${
CGoGN_EXT_LIBS
}
${
QT_LIBRARIES
}
)
ENDIF
(
WITH_QT
)
IF
(
WITH_GLEWMX
)
ADD_DEFINITIONS
(
-DGLEW_MX
)
ENDIF
(
WITH_GLEWMX
)
#IF (WITH_NUMERICAL)
# add_definitions(-DWITH_NUMERICAL)
# SET (CGoGN_NUMERICAL_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/Numerical ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig)
...
...
Release/CMakeLists.txt
View file @
0470ea57
...
...
@@ -8,7 +8,7 @@ IF(WIN32)
SET
(
LIBRARY_OUTPUT_PATH
${
CGoGN_ROOT_DIR
}
/lib
)
ELSE
(
WIN32
)
SET
(
LIBRARY_OUTPUT_PATH
${
CGoGN_ROOT_DIR
}
/lib/Release
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNOTOPOWARNING
"
)
ADD_DEFINITIONS
(
-DNOTOPOWARNING
)
ENDIF
(
WIN32
)
include_directories
(
...
...
include/Algo/Geometry/boundingbox.h
View file @
0470ea57
...
...
@@ -27,8 +27,10 @@
#include
"Geometry/basic.h"
#include
"Geometry/bounding_box.h"
#include
"Topology/generic/attributeHandler.h"
#include
"Topology/generic/traversorCell.h"
namespace
CGoGN
{
...
...
include/Algo/Render/GL2/topo3Render.h
View file @
0470ea57
...
...
@@ -124,6 +124,9 @@ protected:
*/
DartAttribute
<
unsigned
int
>
m_attIndex
;
Geom
::
Vec3f
*
m_bufferDartPosition
;
/**
* save colors
*/
...
...
@@ -308,6 +311,13 @@ public:
*/
void
svgout2D
(
const
std
::
string
&
filename
,
const
glm
::
mat4
&
model
,
const
glm
::
mat4
&
proj
);
template
<
typename
PFP
>
Dart
coneSelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
angle
,
const
FunctorSelect
&
good
=
allDarts
);
template
<
typename
PFP
>
Dart
raySelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
distmax
,
const
FunctorSelect
&
good
=
allDarts
);
protected:
/**
* update all drawing buffers to render a dual map
...
...
include/Algo/Render/GL2/topo3Render.hpp
View file @
0470ea57
...
...
@@ -33,6 +33,8 @@
#include
"Topology/generic/traversorCell.h"
#include
"Algo/Geometry/centroid.h"
#include
"Geometry/distances.h"
namespace
CGoGN
{
...
...
@@ -349,10 +351,16 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute
GLvoid
*
ColorDartsBuffer
=
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
VEC3
*
colorDartBuf
=
reinterpret_cast
<
VEC3
*>
(
ColorDartsBuffer
);
m_vbo0
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
VEC3
),
0
,
GL_STREAM_DRAW
);
GLvoid
*
PositionDartsBuffer
=
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
VEC3
*
positionDartBuf
=
reinterpret_cast
<
VEC3
*>
(
PositionDartsBuffer
);
if
(
m_bufferDartPosition
!=
NULL
)
delete
m_bufferDartPosition
;
m_bufferDartPosition
=
new
Geom
::
Vec3f
[
2
*
m_nbDarts
];
VEC3
*
positionDartBuf
=
reinterpret_cast
<
VEC3
*>
(
m_bufferDartPosition
);
// m_vbo0->bind();
// glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW);
// GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// VEC3* positionDartBuf = reinterpret_cast<VEC3*>(PositionDartsBuffer);
std
::
vector
<
Dart
>
vecDartFaces
;
vecDartFaces
.
reserve
(
m_nbDarts
/
6
);
...
...
@@ -433,7 +441,9 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute
}
m_vbo0
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
VEC3
),
m_bufferDartPosition
,
GL_STREAM_DRAW
);
// m_vbo0->bind();
// glUnmapBuffer(GL_ARRAY_BUFFER);
m_vbo4
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
...
...
@@ -764,6 +774,123 @@ void Topo3Render::computeDartMiddlePositions(typename PFP::MAP& map, DartAttribu
// glUnmapBuffer(GL_ARRAY_BUFFER);
//}
template
<
typename
PFP
>
Dart
Topo3Render
::
coneSelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
angle
,
const
FunctorSelect
&
good
)
{
float
AB2
=
rayAB
*
rayAB
;
Dart
dFinal
;
double
sin2
=
sin
(
M_PI
/
180.0
*
angle
);
sin2
=
sin2
*
sin2
;
double
dist2
=
std
::
numeric_limits
<
double
>::
max
();
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
// get back position of segment PQ
const
Geom
::
Vec3f
&
P
=
m_bufferDartPosition
[
m_attIndex
[
d
]];
const
Geom
::
Vec3f
&
Q
=
m_bufferDartPosition
[
m_attIndex
[
d
]
+
1
];
float
ld2
=
Geom
::
squaredDistanceLine2Seg
(
rayA
,
rayAB
,
AB2
,
P
,
Q
);
Geom
::
Vec3f
V
=
(
P
+
Q
)
/
2.0
f
-
rayA
;
double
d2
=
double
(
V
*
V
);
double
s2
=
double
(
ld2
)
/
d2
;
if
(
s2
<
sin2
)
{
if
(
d2
<
dist2
)
{
dist2
=
d2
;
dFinal
=
d
;
}
}
}
return
dFinal
;
}
template
<
typename
PFP
>
Dart
Topo3Render
::
raySelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
dmax
,
const
FunctorSelect
&
good
)
{
float
AB2
=
rayAB
*
rayAB
;
Dart
dFinal
;
float
dm2
=
dmax
*
dmax
;
double
dist2
=
std
::
numeric_limits
<
double
>::
max
();
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
// get back position of segment PQ
const
Geom
::
Vec3f
&
P
=
m_bufferDartPosition
[
m_attIndex
[
d
]];
const
Geom
::
Vec3f
&
Q
=
m_bufferDartPosition
[
m_attIndex
[
d
]
+
1
];
float
ld2
=
Geom
::
squaredDistanceLine2Seg
(
rayA
,
rayAB
,
AB2
,
P
,
Q
);
if
(
ld2
<
dm2
)
{
Geom
::
Vec3f
V
=
(
P
+
Q
)
/
2.0
f
-
rayA
;
double
d2
=
double
(
V
*
V
);
if
(
d2
<
dist2
)
{
dist2
=
d2
;
dFinal
=
d
;
}
}
}
return
dFinal
;
}
// DART RAY SELECTION
//template<typename PFP>
//void edgesConeSelection(, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, float angle, std::vector<Dart>& vecEdges, const FunctorSelect& good)
//{
// typename PFP::REAL AB2 = rayAB * rayAB;
//
// double sin2 = sin(M_PI/180.0 * angle);
// sin2 = sin2*sin2;
//
// // recuperation des aretes intersectees
// vecEdges.reserve(256);
// vecEdges.clear();
//
// TraversorE<typename PFP::MAP> trav(map);
// for(Dart d = trav.begin(); d!=trav.end(); d = trav.next())
// {
// // get back position of segment PQ
// const typename PFP::VEC3& P = position[d];
// const typename PFP::VEC3& Q = position[map.phi1(d)];
// // the three distance to P, Q and (PQ) not used here
// float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q);
// typename PFP::VEC3 V = P - rayA;
// double s2 = double(ld2) / double(V*V);
// if (s2 < sin2)
// vecEdges.push_back(d);
// }
//
// typedef std::pair<typename PFP::REAL, Dart> DartDist;
// std::vector<DartDist> distndart;
//
// unsigned int nbi = vecEdges.size();
// distndart.resize(nbi);
//
// // compute all distances to observer for each middle of intersected edge
// // and put them in a vector for sorting
// for (unsigned int i = 0; i < nbi; ++i)
// {
// Dart d = vecEdges[i];
// distndart[i].second = d;
// typename PFP::VEC3 V = (position[d] + position[map.phi1(d)]) / typename PFP::REAL(2);
// V -= rayA;
// distndart[i].first = V.norm2();
// }
//
// // sort the vector of pair dist/dart
// std::sort(distndart.begin(), distndart.end(), distndartOrdering<PFP>);
//
// // store sorted darts in returned vector
// for (unsigned int i = 0; i < nbi; ++i)
// vecEdges[i] = distndart[i].second;
//}
}
//end namespace GL2
}
//end namespace Render
...
...
include/Algo/Render/GL2/topoRender.h
View file @
0470ea57
...
...
@@ -108,6 +108,8 @@ protected:
*/
DartAttribute
<
unsigned
int
>
m_attIndex
;
Geom
::
Vec3f
*
m_bufferDartPosition
;
Utils
::
ShaderSimpleColor
*
m_shader1
;
Utils
::
ShaderColorPerVertex
*
m_shader2
;
...
...
@@ -231,6 +233,15 @@ public:
template
<
typename
PFP
>
Dart
picking
(
typename
PFP
::
MAP
&
map
,
int
x
,
int
y
,
const
FunctorSelect
&
good
=
allDarts
);
template
<
typename
PFP
>
Dart
coneSelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
angle
,
const
FunctorSelect
&
good
=
allDarts
);
template
<
typename
PFP
>
Dart
raySelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
distmax
,
const
FunctorSelect
&
good
=
allDarts
);
template
<
typename
PFP
>
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
=
allDarts
);
...
...
include/Algo/Render/GL2/topoRender.hpp
View file @
0470ea57
...
...
@@ -30,6 +30,8 @@
#include
"Topology/map/embeddedMap2.h"
#include
"Topology/gmap/embeddedGMap2.h"
#include
"Geometry/distances.h"
namespace
CGoGN
{
...
...
@@ -94,10 +96,15 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty
GLvoid
*
ColorDartsBuffer
=
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
VEC3
*
colorDartBuf
=
reinterpret_cast
<
VEC3
*>
(
ColorDartsBuffer
);
m_vbo0
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
VEC3
),
0
,
GL_STREAM_DRAW
);
GLvoid
*
PositionDartsBuffer
=
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
VEC3
*
positionDartBuf
=
reinterpret_cast
<
VEC3
*>
(
PositionDartsBuffer
);
// m_vbo0->bind();
// glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW);
// GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// VEC3* positionDartBuf = reinterpret_cast<VEC3*>(PositionDartsBuffer);
if
(
m_bufferDartPosition
!=
NULL
)
delete
m_bufferDartPosition
;
m_bufferDartPosition
=
new
Geom
::
Vec3f
[
2
*
m_nbDarts
];
VEC3
*
positionDartBuf
=
reinterpret_cast
<
VEC3
*>
(
m_bufferDartPosition
);
std
::
vector
<
VEC3
>
vecPos
;
vecPos
.
reserve
(
16
);
...
...
@@ -158,7 +165,8 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty
}
m_vbo0
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
VEC3
),
m_bufferDartPosition
,
GL_STREAM_DRAW
);
// glUnmapBuffer(GL_ARRAY_BUFFER);
m_vbo3
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
...
...
@@ -411,6 +419,67 @@ Dart TopoRender::picking(typename PFP::MAP& map,int x, int y, const FunctorSelec
}
template
<
typename
PFP
>
Dart
TopoRender
::
coneSelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
angle
,
const
FunctorSelect
&
good
)
{
float
AB2
=
rayAB
*
rayAB
;
Dart
dFinal
;
double
sin2
=
sin
(
M_PI
/
180.0
*
angle
);
sin2
=
sin2
*
sin2
;
double
dist2
=
std
::
numeric_limits
<
double
>::
max
();
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
// get back position of segment PQ
const
Geom
::
Vec3f
&
P
=
m_bufferDartPosition
[
m_attIndex
[
d
]];
const
Geom
::
Vec3f
&
Q
=
m_bufferDartPosition
[
m_attIndex
[
d
]
+
1
];
float
ld2
=
Geom
::
squaredDistanceLine2Seg
(
rayA
,
rayAB
,
AB2
,
P
,
Q
);
Geom
::
Vec3f
V
=
(
P
+
Q
)
/
2.0
f
-
rayA
;
double
d2
=
double
(
V
*
V
);
double
s2
=
double
(
ld2
)
/
d2
;
if
(
s2
<
sin2
)
{
if
(
d2
<
dist2
)
{
dist2
=
d2
;
dFinal
=
d
;
}
}
}
return
dFinal
;
}
template
<
typename
PFP
>
Dart
TopoRender
::
raySelection
(
typename
PFP
::
MAP
&
map
,
const
Geom
::
Vec3f
&
rayA
,
const
Geom
::
Vec3f
&
rayAB
,
float
dmax
,
const
FunctorSelect
&
good
)
{
float
AB2
=
rayAB
*
rayAB
;
Dart
dFinal
;
float
dm2
=
dmax
*
dmax
;
double
dist2
=
std
::
numeric_limits
<
double
>::
max
();
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
// get back position of segment PQ
const
Geom
::
Vec3f
&
P
=
m_bufferDartPosition
[
m_attIndex
[
d
]];
const
Geom
::
Vec3f
&
Q
=
m_bufferDartPosition
[
m_attIndex
[
d
]
+
1
];
float
ld2
=
Geom
::
squaredDistanceLine2Seg
(
rayA
,
rayAB
,
AB2
,
P
,
Q
);
if
(
ld2
<
dm2
)
{
Geom
::
Vec3f
V
=
(
P
+
Q
)
/
2.0
f
-
rayA
;
double
d2
=
double
(
V
*
V
);
if
(
d2
<
dist2
)
{
dist2
=
d2
;
dFinal
=
d
;
}
}
}
return
dFinal
;
}
}
//end namespace GL2
}
//end namespace Algo
...
...
include/Algo/Selection/raySelectFunctor.hpp
View file @
0470ea57
...
...
@@ -38,139 +38,139 @@ namespace Algo
namespace
Selection
{
template
<
typename
PFP
>
class
FuncFaceInter
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
typedef
typename
PFP
::
MAP
MAP
;
protected:
std
::
vector
<
Dart
>&
m_faces
;
std
::
vector
<
typename
PFP
::
VEC3
>&
m_Ipoints
;
const
typename
PFP
::
VEC3
&
m_A
;
const
typename
PFP
::
VEC3
&
m_AB
;
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_positions
;
public:
/**
* @param map the map
* @param f vector of selected darts
* @param A first point of ray
* @param AB direction of ray
*/
FuncFaceInter
(
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
std
::
vector
<
Dart
>&
f
,
std
::
vector
<
typename
PFP
::
VEC3
>&
ip
,
const
typename
PFP
::
VEC3
&
A
,
const
typename
PFP
::
VEC3
&
AB
)
:
FunctorMap
<
typename
PFP
::
MAP
>
(
map
),
m_faces
(
f
),
m_Ipoints
(
ip
),
m_A
(
A
),
m_AB
(
AB
),
m_positions
(
position
)
{}
bool
operator
()(
Dart
d
)
{
const
typename
PFP
::
VEC3
&
Ta
=
m_positions
[
d
];
Dart
dd
=
this
->
m_map
.
phi1
(
d
);
Dart
ddd
=
this
->
m_map
.
phi1
(
dd
);
bool
notfound
=
true
;
do
{
// get back position of triangle Ta,Tb,Tc
const
typename
PFP
::
VEC3
&
Tb
=
m_positions
[
dd
];
const
typename
PFP
::
VEC3
&
Tc
=
m_positions
[
ddd
];
typename
PFP
::
VEC3
I
;
// if (Geom::intersectionLineTriangle<typename PFP::VEC3>(m_A, m_AB, Ta, Tb, Tc, I))
if
(
Geom
::
intersectionRayTriangleOpt
<
typename
PFP
::
VEC3
>
(
m_A
,
m_AB
,
Ta
,
Tb
,
Tc
,
I
))
{
m_faces
.
push_back
(
d
);
m_Ipoints
.
push_back
(
I
);
notfound
=
false
;
}
// next triangle if we are in polygon
dd
=
ddd
;
ddd
=
this
->
m_map
.
phi1
(
dd
);
}
while
((
ddd
!=
d
)
&&
notfound
);
return
false
;
}
};
template
<
typename
PFP
>
class
FuncEdgeInter
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
typedef
typename
PFP
::
MAP
MAP
;
protected:
std
::
vector
<
Dart
>&
m_edges
;
const
typename
PFP
::
VEC3
&
m_A
;
const
typename
PFP
::
VEC3
&
m_AB
;
float
m_AB2
;
float
m_distMax
;
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_positions
;
public:
/**
* @param map the map
* @param e vector of selected darts
* @param A first point of ray
* @param AB direction of ray
* @param AB2 squared length of direction
* @param dm2 max distance from ray squared
*/
FuncEdgeInter
(
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
std
::
vector
<
Dart
>&
e
,
const
typename
PFP
::
VEC3
&
A
,
const
typename
PFP
::
VEC3
&
AB
,
typename
PFP
::
REAL
AB2
,
typename
PFP
::
REAL
dm2
)
:
FunctorMap
<
typename
PFP
::
MAP
>
(
map
),
m_edges
(
e
),
m_A
(
A
),
m_AB
(
AB
),
m_AB2
(
AB2
),
m_distMax
(
dm2
),
m_positions
(
position
)
{}
bool
operator
()(
Dart
d
)
{
// get back position of segment PQ
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
Dart
dd
=
this
->
m_map
.
phi1
(
d
);
const
typename
PFP
::
VEC3
&
Q
=
m_positions
[
dd
];
// the three distance to P, Q and (PQ) not used here
float
dist
=
Geom
::
squaredDistanceLine2Seg
(
m_A
,
m_AB
,
m_AB2
,
P
,
Q
);
if
(
dist
<
m_distMax
)
{
m_edges
.
push_back
(
d
);
}
return
false
;
}
};
template
<
typename
PFP
>
class
FuncVertexInter
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
typedef
typename
PFP
::
MAP
MAP
;
protected:
std
::
vector
<
Dart
>&
m_vertices
;
const
typename
PFP
::
VEC3
&
m_A
;
const
typename
PFP
::
VEC3
&
m_AB
;
float
m_AB2
;
float
m_distMax
;
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_positions
;
public:
/**
* @param map the map
* @param v vector of selected darts
* @param A first point of ray
* @param AB direction of ray
* @param AB2 squared length of direction
* @param dm2 max distance from ray squared
*/
FuncVertexInter
(
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
std
::
vector
<
Dart
>&
v
,
const
typename
PFP
::
VEC3
&
A
,
const
typename
PFP
::
VEC3
&
AB
,
typename
PFP
::
REAL
AB2
,
typename
PFP
::
REAL
dm2
)
:
FunctorMap
<
typename
PFP
::
MAP
>
(
map
),
m_vertices
(
v
),
m_A
(
A
),
m_AB
(
AB
),
m_AB2
(
AB2
),
m_distMax
(
dm2
),
m_positions
(
position
)
{}
bool
operator
()(
Dart
d
)
{
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
float
dist
=
Geom
::
squaredDistanceLine2Point
(
m_A
,
m_AB
,
m_AB2
,
P
);
if
(
dist
<
m_distMax
)
{
m_vertices
.
push_back
(
d
);
}
return
false
;
}
};
//
//
template <typename PFP>
//
class FuncFaceInter: public FunctorMap<typename PFP::MAP>
//
{
//
typedef typename PFP::MAP MAP;
//
//
protected:
//
std::vector<Dart>& m_faces;
//
std::vector<typename PFP::VEC3>& m_Ipoints ;
//
const typename PFP::VEC3& m_A;
//
const typename PFP::VEC3& m_AB;
//
const VertexAttribute<typename PFP::VEC3>& m_positions;
//
//
public:
//
/**
//
* @param map the map
//
* @param f vector of selected darts
//
* @param A first point of ray
//
* @param AB direction of ray
//
*/
//
FuncFaceInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& f, std::vector<typename PFP::VEC3>& ip, const typename PFP::VEC3& A, const typename PFP::VEC3& AB):
//
FunctorMap<typename PFP::MAP>(map), m_faces(f), m_Ipoints(ip), m_A(A), m_AB(AB), m_positions(position)
//
{}
//
//
bool operator()(Dart d)
//
{
//
const typename PFP::VEC3& Ta = m_positions[d];
//
//
Dart dd = this->m_map.phi1(d);
//
Dart ddd = this->m_map.phi1(dd);
//
bool notfound = true;
//
do
//
{
//
// get back position of triangle Ta,Tb,Tc
//
const typename PFP::VEC3& Tb = m_positions[dd];
//
const typename PFP::VEC3& Tc = m_positions[ddd];
//
typename PFP::VEC3 I;
//
// if (Geom::intersectionLineTriangle<typename PFP::VEC3>(m_A, m_AB, Ta, Tb, Tc, I))
//
if (Geom::intersectionRayTriangleOpt<typename PFP::VEC3>(m_A, m_AB, Ta, Tb, Tc, I))
//
{
//
m_faces.push_back(d);
//
m_Ipoints.push_back(I);
//
notfound = false;
//
}
//
// next triangle if we are in polygon
//
dd = ddd;
//
ddd = this->m_map.phi1(dd);
//
} while ((ddd != d) && notfound);
//
return false;
//
}
//
};
//
//
//
template <typename PFP>
//
class FuncEdgeInter: public FunctorMap<typename PFP::MAP>
//
{
//
typedef typename PFP::MAP MAP;
//
//
protected:
//
std::vector<Dart>& m_edges;
//
const typename PFP::VEC3& m_A;
//
const typename PFP::VEC3& m_AB;
//
float m_AB2;
//
float m_distMax;
//
const VertexAttribute<typename PFP::VEC3>& m_positions;
//
//
public:
//
/**
//
* @param map the map
//
* @param e vector of selected darts
//
* @param A first point of ray
//
* @param AB direction of ray
//
* @param AB2 squared length of direction
//
* @param dm2 max distance from ray squared
//
*/
//
FuncEdgeInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& e, const typename PFP::VEC3& A, const typename PFP::VEC3& AB, typename PFP::REAL AB2, typename PFP::REAL dm2):
//
FunctorMap<typename PFP::MAP>(map), m_edges(e), m_A(A), m_AB(AB), m_AB2(AB2), m_distMax(dm2), m_positions(position)
//
{}
//
//
bool operator()(Dart d)
//
{
//
// get back position of segment PQ
//
const typename PFP::VEC3& P = m_positions[d];
//
Dart dd = this->m_map.phi1(d);
//
const typename PFP::VEC3& Q = m_positions[dd];
//
// the three distance to P, Q and (PQ) not used here
//
float dist = Geom::squaredDistanceLine2Seg(m_A, m_AB, m_AB2, P, Q);
//
//
if (dist < m_distMax)