Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Pitiot
CGoGN
Commits
089fc32b
Commit
089fc32b
authored
Sep 28, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ray selection on dart of topo
add cone selection on vertex n edge
parent
87367ef4
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
379 additions
and
152 deletions
+379
-152
include/Algo/Render/GL2/topo3Render.h
include/Algo/Render/GL2/topo3Render.h
+10
-0
include/Algo/Render/GL2/topo3Render.hpp
include/Algo/Render/GL2/topo3Render.hpp
+132
-5
include/Algo/Render/GL2/topoRender.h
include/Algo/Render/GL2/topoRender.h
+11
-0
include/Algo/Render/GL2/topoRender.hpp
include/Algo/Render/GL2/topoRender.hpp
+74
-5
include/Algo/Selection/raySelectFunctor.hpp
include/Algo/Selection/raySelectFunctor.hpp
+133
-133
include/Algo/Selection/raySelector.h
include/Algo/Selection/raySelector.h
+2
-2
include/Algo/Selection/raySelector.hpp
include/Algo/Selection/raySelector.hpp
+7
-4
src/Algo/Render/topo3Render.cpp
src/Algo/Render/topo3Render.cpp
+5
-2
src/Algo/Render/topoRender.cpp
src/Algo/Render/topoRender.cpp
+5
-1
No files found.
include/Algo/Render/GL2/topo3Render.h
View file @
089fc32b
...
...
@@ -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 @
089fc32b
...
...
@@ -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.0f - 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.0f - 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 @
089fc32b
...
...
@@ -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 @
089fc32b
...
...
@@ -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 @
089fc32b
...
...
@@ -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)
//
{
//
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;
//
}
//
};
/**
* Functor which store the dart that correspond to the subpart of face
...
...
include/Algo/Selection/raySelector.h
View file @
089fc32b
...
...
@@ -149,7 +149,7 @@ void edgesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename P
*/
template
<
typename
PFP
>
Dart
verticesBubbleSelection
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
typename
PFP
::
VEC3
&
cursor
,
PFP
::
REAL
radiusMax
,
const
typename
PFP
::
VEC3
&
cursor
,
typename
PFP
::
REAL
radiusMax
,
const
FunctorSelect
&
good
=
allDarts
);
...
...
@@ -163,7 +163,7 @@ Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typen
*/
template
<
typename
PFP
>
Dart
edgesBubbleSelection
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
typename
PFP
::
VEC3
&
cursor
,
PFP
::
REAL
radiusMax
,
const
typename
PFP
::
VEC3
&
cursor
,
typename
PFP
::
REAL
radiusMax
,
const
FunctorSelect
&
good
=
allDarts
);
...
...