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
David Cazier
CGoGN
Commits
b18a529d
Commit
b18a529d
authored
Jun 10, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajouts divers inclusion / intersection / collector
parent
947fe6a0
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
230 additions
and
163 deletions
+230
-163
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+1
-2
Apps/Examples/viewer.h
Apps/Examples/viewer.h
+0
-1
include/Algo/Decimation/edgeSelector.h
include/Algo/Decimation/edgeSelector.h
+42
-18
include/Algo/Decimation/edgeSelector.hpp
include/Algo/Decimation/edgeSelector.hpp
+14
-14
include/Algo/Decimation/selector.h
include/Algo/Decimation/selector.h
+0
-9
include/Algo/Geometry/centroid.hpp
include/Algo/Geometry/centroid.hpp
+1
-3
include/Algo/Geometry/curvature.h
include/Algo/Geometry/curvature.h
+2
-2
include/Algo/Geometry/curvature.hpp
include/Algo/Geometry/curvature.hpp
+5
-6
include/Algo/Geometry/intersection.h
include/Algo/Geometry/intersection.h
+10
-3
include/Algo/Geometry/intersection.hpp
include/Algo/Geometry/intersection.hpp
+22
-5
include/Algo/Selection/collector.h
include/Algo/Selection/collector.h
+5
-1
include/Algo/Selection/collector.hpp
include/Algo/Selection/collector.hpp
+30
-19
include/Algo/Selection/raySelectFunctor.hpp
include/Algo/Selection/raySelectFunctor.hpp
+10
-11
include/Algo/Selection/raySelector.h
include/Algo/Selection/raySelector.h
+49
-44
include/Geometry/inclusion.h
include/Geometry/inclusion.h
+5
-2
include/Geometry/inclusion.hpp
include/Geometry/inclusion.hpp
+6
-0
include/Geometry/intersection.h
include/Geometry/intersection.h
+3
-0
include/Geometry/intersection.hpp
include/Geometry/intersection.hpp
+23
-20
include/Utils/qtSimple.h
include/Utils/qtSimple.h
+0
-1
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+2
-2
No files found.
Apps/Examples/viewer.cpp
View file @
b18a529d
...
...
@@ -186,7 +186,6 @@ void Viewer::importMesh(std::string& filename)
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
gPosObj
=
bb
.
center
()
;
normalBaseSize
=
bb
.
diagSize
()
/
100.0
f
;
vertexBaseSize
=
normalBaseSize
*
2.0
f
;
...
...
@@ -198,7 +197,7 @@ void Viewer::importMesh(std::string& filename)
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
setParamObject
(
bb
.
maxSize
(),
gPosObj
.
data
())
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
()
.
data
())
;
updateGLMatrices
()
;
}
...
...
Apps/Examples/viewer.h
View file @
b18a529d
...
...
@@ -78,7 +78,6 @@ public:
float
shininess
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
;
Geom
::
Vec3f
gPosObj
;
float
normalBaseSize
;
float
normalScaleFactor
;
float
vertexBaseSize
;
...
...
include/Algo/Decimation/edgeSelector.h
View file @
b18a529d
...
...
@@ -27,6 +27,11 @@
#include "Algo/Decimation/selector.h"
#include "Container/fakeAttribute.h"
#include "Utils/qem.h"
#include "Utils/quadricRGBfunctions.h"
#include "Algo/Geometry/curvature.h"
namespace
CGoGN
{
...
...
@@ -246,12 +251,17 @@ private:
}
CurvatureEdgeInfo
;
typedef
NoMathIOAttribute
<
CurvatureEdgeInfo
>
EdgeInfo
;
Geom
::
BoundingBox
<
VEC3
>
bb
;
REAL
radius
;
typename
PFP
::
TVEC3
normal
;
AttributeHandler
<
EdgeInfo
>
edgeInfo
;
typename
PFP
::
TREAL
k1
;
typename
PFP
::
TREAL
k2
;
typename
PFP
::
TVEC3
K1
;
typename
PFP
::
TVEC3
K2
;
typename
PFP
::
TREAL
edgeangle
;
typename
PFP
::
TREAL
kmax
;
typename
PFP
::
TREAL
kmin
;
typename
PFP
::
TVEC3
Kmax
;
typename
PFP
::
TVEC3
Kmin
;
typename
PFP
::
TVEC3
Knormal
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
...
...
@@ -266,6 +276,9 @@ public:
EdgeSelector_Curvature
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
m
,
pos
)
;
radius
=
bb
.
diagSize
()
*
0.003
;
normal
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"normal"
)
;
if
(
!
normal
.
isValid
())
{
...
...
@@ -273,29 +286,40 @@ public:
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
m
,
pos
,
normal
)
;
}
k1
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"k1"
)
;
k2
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"k2"
)
;
K1
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"K1"
)
;
K2
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"K2"
)
;
edgeangle
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"edgeangle"
)
;
if
(
!
edgeangle
.
isValid
())
{
edgeangle
=
m
.
template
addAttribute
<
REAL
>(
EDGE
,
"edgeangle"
)
;
Algo
::
Geometry
::
computeAnglesBetweenNormalsOnEdges
<
PFP
>
(
m
,
pos
,
edgeangle
)
;
}
kmax
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"kmax"
)
;
kmin
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"kmin"
)
;
Kmax
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"Kmax"
)
;
Kmin
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"Kmin"
)
;
Knormal
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"Knormal"
)
;
// as all these attributes are computed simultaneously by computeCurvatureVertices
// one can assume that if one of them is not valid, the others must be created too
if
(
!
k
1
.
isValid
())
if
(
!
k
max
.
isValid
())
{
k1
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"k1"
)
;
k2
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"k2"
)
;
K1
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"K1"
)
;
K2
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"K2"
)
;
Algo
::
Geometry
::
computeCurvatureVertices
<
PFP
>
(
m
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
kmax
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"kmax"
)
;
kmin
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"kmin"
)
;
Kmax
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"Kmax"
)
;
Kmin
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"Kmin"
)
;
Knormal
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"Knormal"
)
;
Algo
::
Geometry
::
computeCurvatureVertices_NormalCycles
<
PFP
>
(
m
,
radius
,
pos
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
}
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
>(
EDGE
,
"edgeInfo"
)
;
}
~
EdgeSelector_Curvature
()
{
this
->
m_map
.
removeAttribute
(
k1
)
;
this
->
m_map
.
removeAttribute
(
k2
)
;
this
->
m_map
.
removeAttribute
(
K1
)
;
this
->
m_map
.
removeAttribute
(
K2
)
;
this
->
m_map
.
removeAttribute
(
edgeangle
)
;
this
->
m_map
.
removeAttribute
(
kmax
)
;
this
->
m_map
.
removeAttribute
(
kmin
)
;
this
->
m_map
.
removeAttribute
(
Kmax
)
;
this
->
m_map
.
removeAttribute
(
Kmin
)
;
this
->
m_map
.
removeAttribute
(
Knormal
)
;
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_Curvature
;
}
...
...
include/Algo/Decimation/edgeSelector.hpp
View file @
b18a529d
...
...
@@ -795,14 +795,14 @@ void EdgeSelector_Curvature<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
MAP
&
m
=
this
->
m_map
;
normal
[
d2
]
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
m
,
d2
,
this
->
m_position
)
;
Algo
::
Geometry
::
computeCurvatureVertex
<
PFP
>
(
m
,
d2
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
Algo
::
Geometry
::
computeCurvatureVertex
_NormalCycles
<
PFP
>
(
m
,
d2
,
radius
,
this
->
m_position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
Dart
vit
=
d2
;
do
{
Dart
nVert
=
m
.
phi1
(
vit
)
;
normal
[
nVert
]
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
m
,
nVert
,
this
->
m_position
)
;
Algo
::
Geometry
::
computeCurvatureVertex
<
PFP
>
(
m
,
nVert
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
Algo
::
Geometry
::
computeCurvatureVertex
_NormalCycles
<
PFP
>
(
m
,
nVert
,
radius
,
this
->
m_position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
updateEdgeInfo
(
m
.
phi1
(
vit
),
false
)
;
// must recompute some edge infos in the
if
(
vit
==
d2
||
vit
==
dd2
)
// neighborhood of the collapsed edge
...
...
@@ -891,11 +891,11 @@ void EdgeSelector_Curvature<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
// compute things on the coarse version of the mesh
normal
[
newV
]
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
m
,
d2
,
this
->
m_position
)
;
Algo
::
Geometry
::
computeCurvatureVertex
<
PFP
>
(
m
,
d2
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
Algo
::
Geometry
::
computeCurvatureVertex
_NormalCycles
<
PFP
>
(
m
,
d2
,
radius
,
this
->
m_position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
VEC3
norm
=
normal
[
newV
]
;
REAL
mCurv
=
(
k1
[
newV
]
+
k
2
[
newV
]
)
/
REAL
(
2
)
;
VEC3
cDir1
=
K
1
[
newV
]
;
//
VEC3 norm = normal[newV] ;
REAL
mCurv
=
(
kmax
[
newV
]
+
k
min
[
newV
])
/
REAL
(
2
)
;
//
VEC3 cDir1 = K
max
[newV] ;
// vertex split to reset the initial connectivity and embeddings
m
.
insertTrianglePair
(
d
,
d2
,
dd2
)
;
...
...
@@ -904,17 +904,17 @@ void EdgeSelector_Curvature<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
REAL
err
=
0
;
REAL
norm_deviation_1
=
REAL
(
1
)
/
abs
(
norm
*
normal
[
v1
])
;
REAL
norm_deviation_2
=
REAL
(
1
)
/
abs
(
norm
*
normal
[
v2
])
;
err
+=
norm_deviation_1
+
norm_deviation_2
;
//
REAL norm_deviation_1 = REAL(1) / abs(norm * normal[v1]) ;
//
REAL norm_deviation_2 = REAL(1) / abs(norm * normal[v2]) ;
//
err += norm_deviation_1 + norm_deviation_2 ;
REAL
mCurv_deviation_1
=
abs
(
mCurv
-
(
k
1
[
v1
]
+
k
2
[
v1
]
/
REAL
(
2
)))
;
REAL
mCurv_deviation_2
=
abs
(
mCurv
-
(
k
1
[
v2
]
+
k
2
[
v2
]
/
REAL
(
2
)))
;
REAL
mCurv_deviation_1
=
abs
(
mCurv
-
(
k
max
[
v1
]
+
k
min
[
v1
]
/
REAL
(
2
)))
;
REAL
mCurv_deviation_2
=
abs
(
mCurv
-
(
k
max
[
v2
]
+
k
min
[
v2
]
/
REAL
(
2
)))
;
err
+=
mCurv_deviation_1
+
mCurv_deviation_2
;
REAL
cDir1_deviation_1
=
REAL
(
1
)
/
abs
(
cDir1
*
K
1
[
v1
])
;
REAL
cDir1_deviation_2
=
REAL
(
1
)
/
abs
(
cDir1
*
K
1
[
v2
])
;
err
+=
cDir1_deviation_1
+
cDir1_deviation_2
;
//
REAL cDir1_deviation_1 = REAL(1) / abs(cDir1 * K
max
[v1]) ;
//
REAL cDir1_deviation_2 = REAL(1) / abs(cDir1 * K
max
[v2]) ;
//
err += cDir1_deviation_1 + cDir1_deviation_2 ;
einfo
.
it
=
edges
.
insert
(
std
::
make_pair
(
err
,
d
))
;
einfo
.
valid
=
true
;
...
...
include/Algo/Decimation/selector.h
View file @
b18a529d
...
...
@@ -25,11 +25,6 @@
#ifndef __SELECTOR_H__
#define __SELECTOR_H__
#include "Utils/qem.h"
#include "Utils/quadricRGBfunctions.h"
#include "Container/fakeAttribute.h"
#include "Algo/Geometry/curvature.h"
namespace
CGoGN
{
...
...
@@ -39,7 +34,6 @@ namespace Algo
namespace
Decimation
{
enum
SelectorType
{
S_MapOrder
,
...
...
@@ -53,11 +47,9 @@ enum SelectorType
S_hLightfield
}
;
template
<
typename
PFP
>
class
ApproximatorGen
;
template
<
typename
PFP
,
typename
T
>
class
Approximator
;
template
<
typename
PFP
>
class
EdgeSelector
{
...
...
@@ -91,5 +83,4 @@ public:
}
// namespace CGoGN
#endif
include/Algo/Geometry/centroid.hpp
View file @
b18a529d
...
...
@@ -67,11 +67,10 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs)
std
::
vector
<
Dart
>
visitedFaces
;
// Faces that are traversed
visitedFaces
.
reserve
(
100
);
visitedFaces
.
push_back
(
d
);
// Start with the face of d
std
::
vector
<
Dart
>::
iterator
face
;
mark
.
markOrbit
(
VERTEX
,
d
)
;
for
(
face
=
visitedFaces
.
begin
();
face
!=
visitedFaces
.
end
();
++
face
)
for
(
std
::
vector
<
Dart
>::
iterator
face
=
visitedFaces
.
begin
();
face
!=
visitedFaces
.
end
();
++
face
)
{
Dart
e
=
*
face
;
...
...
@@ -90,7 +89,6 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs)
}
while
(
e
!=
*
face
)
;
}
center
/=
double
(
count
)
;
return
center
;
}
...
...
include/Algo/Geometry/curvature.h
View file @
b18a529d
...
...
@@ -95,7 +95,7 @@ void computeCurvatureVertices_NormalCycles(
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angle
s
,
const
typename
PFP
::
TREAL
&
edge
angle
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
...
...
@@ -110,7 +110,7 @@ void computeCurvatureVertex_NormalCycles(
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angle
s
,
const
typename
PFP
::
TREAL
&
edge
angle
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
...
...
include/Algo/Geometry/curvature.hpp
View file @
b18a529d
...
...
@@ -304,7 +304,7 @@ void computeCurvatureVertices_NormalCycles(
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angle
s
,
const
typename
PFP
::
TREAL
&
edge
angle
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
...
...
@@ -318,7 +318,7 @@ void computeCurvatureVertices_NormalCycles(
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
);
computeCurvatureVertex_NormalCycles
<
PFP
>
(
map
,
d
,
radius
,
position
,
normal
,
angle
s
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
computeCurvatureVertex_NormalCycles
<
PFP
>
(
map
,
d
,
radius
,
position
,
normal
,
edge
angle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
}
}
}
...
...
@@ -330,7 +330,7 @@ void computeCurvatureVertex_NormalCycles(
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angle
s
,
const
typename
PFP
::
TREAL
&
edge
angle
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
...
...
@@ -354,16 +354,15 @@ void computeCurvatureVertex_NormalCycles(
for
(
std
::
vector
<
Dart
>::
const_iterator
it
=
vd1
.
begin
();
it
!=
vd1
.
end
();
++
it
)
{
const
VEC3
e
=
position
[
map
.
phi2
(
*
it
)]
-
position
[
*
it
]
;
tensor
+=
Geom
::
transposed_vectors_mult
(
e
,
e
)
*
angle
s
[
*
it
]
*
(
1
/
e
.
norm
())
;
tensor
+=
Geom
::
transposed_vectors_mult
(
e
,
e
)
*
edge
angle
[
*
it
]
*
(
1
/
e
.
norm
())
;
}
// border
const
std
::
vector
<
Dart
>&
vd2
=
neigh
.
getBorder
()
;
for
(
std
::
vector
<
Dart
>::
const_iterator
it
=
vd2
.
begin
();
it
!=
vd2
.
end
();
++
it
)
{
const
VEC3
e
=
position
[
map
.
phi2
(
*
it
)]
-
position
[
*
it
]
;
const
REAL
alpha
=
neigh
.
intersect_SphereEdge
(
*
it
,
map
.
phi2
(
*
it
))
;
tensor
+=
Geom
::
transposed_vectors_mult
(
e
,
e
)
*
angle
s
[
*
it
]
*
(
1
/
e
.
norm
())
*
alpha
;
tensor
+=
Geom
::
transposed_vectors_mult
(
e
,
e
)
*
edge
angle
[
*
it
]
*
(
1
/
e
.
norm
())
*
alpha
;
}
tensor
/=
neigh
.
getArea
()
;
...
...
include/Algo/Geometry/intersection.h
View file @
b18a529d
...
...
@@ -27,6 +27,7 @@
#include "Geometry/basic.h"
#include "Geometry/intersection.h"
#include "Geometry/inclusion.h"
namespace
CGoGN
{
...
...
@@ -75,11 +76,17 @@ bool intersectionSegmentConvexFace(typename PFP::MAP& map, Dart d, const typenam
template
<
typename
PFP
>
bool
areTrianglesInIntersection
(
typename
PFP
::
MAP
&
map
,
Dart
tri1
,
Dart
tri2
,
const
typename
PFP
::
TVEC3
&
positions
)
;
}
/**
*
*/
template
<
typename
PFP
>
bool
intersectionSphereEdge
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
VEC3
&
center
,
typename
PFP
::
REAL
radius
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
positions
,
typename
PFP
::
REAL
&
alpha
)
;
}
// namespace Geometry
}
}
// namespace Algo
}
}
// namespace CGoGN
#include "Algo/Geometry/intersection.hpp"
...
...
include/Algo/Geometry/intersection.hpp
View file @
b18a529d
...
...
@@ -46,10 +46,10 @@ bool intersectionLineConvexFace(typename PFP::MAP& map, Dart d, const typename P
const
float
SMALL_NUM
=
std
::
numeric_limits
<
typename
PFP
::
REAL
>::
min
()
*
5.0
f
;
VEC3
p1
=
positions
[
d
];
VEC3
n
=
faceNormal
<
PFP
>
(
map
,
d
,
positions
);
VEC3
n
=
faceNormal
<
PFP
>
(
map
,
d
,
positions
);
VEC3
w0
=
P
-
p1
;
float
a
=
-
(
n
*
w0
);
float
b
=
n
*
Dir
;
float
a
=
-
(
n
*
w0
);
float
b
=
n
*
Dir
;
if
(
fabs
(
b
)
<
SMALL_NUM
)
return
false
;
...
...
@@ -225,8 +225,25 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Dart tri1, Dart tri2, co
return
intersection
;
}
template
<
typename
PFP
>
bool
intersectionSphereEdge
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
VEC3
&
center
,
typename
PFP
::
REAL
radius
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
positions
,
typename
PFP
::
REAL
&
alpha
)
{
typename
PFP
::
VEC3
&
p1
=
position
[
d
];
typename
PFP
::
VEC3
&
p2
=
position
[
map
.
phi1
(
d
)];
if
(
Geom
::
isPointInSphere
(
p1
,
center
,
radius
)
&&
!
Geom
::
isPointInSphere
(
p2
,
center
,
radius
))
{
VEC3
p
=
p1
-
center
;
VEC3
qminusp
=
p2
-
center
-
p
;
REAL
s
=
p
*
qminusp
;
REAL
n2
=
qminusp
.
norm2
();
alpha
=
(
-
s
+
sqrt
(
s
*
s
+
n2
*
(
radius
*
radius
-
p
.
norm2
())))
/
n2
;
return
true
;
}
return
false
;
}
}
}
// namespace Geometry
}
}
// namespace Algo
}
// namespace CGoGN
include/Algo/Selection/collector.h
View file @
b18a529d
...
...
@@ -42,8 +42,9 @@ namespace Selection
{
/*********************************************************
* Collector
*
Generic
Collector
*********************************************************/
template
<
typename
PFP
>
class
Collector
{
...
...
@@ -69,6 +70,8 @@ public:
virtual
void
collect
()
=
0
;
bool
apply
(
FunctorType
&
f
);
void
sort
()
{
std
::
sort
(
insideVertices
.
begin
(),
insideVertices
.
end
());
...
...
@@ -135,6 +138,7 @@ protected:
typename
PFP
::
REAL
radius_2
;
typename
PFP
::
VEC3
centerPosition
;
typename
PFP
::
REAL
area
;
public:
Collector_WithinSphere
(
typename
PFP
::
MAP
&
mymap
,
const
typename
PFP
::
TVEC3
&
myposition
)
:
Collector
<
PFP
>
(
mymap
,
myposition
)
...
...
include/Algo/Selection/collector.hpp
View file @
b18a529d
...
...
@@ -31,15 +31,25 @@ namespace Algo
namespace
Selection
{
/********************************************
* GENERIC COLLECTOR
********************************************/
/*********************************************************
* Generic Collector
*********************************************************/
template
<
typename
PFP
>
Collector
<
PFP
>::
Collector
(
typename
PFP
::
MAP
&
mymap
,
const
typename
PFP
::
TVEC3
&
myposition
)
:
map
(
mymap
),
position
(
myposition
)
{}
template
<
typename
PFP
>
bool
Collector
<
PFP
>::
apply
(
FunctorType
&
f
)
{
for
(
std
::
vector
<
Dart
>::
iterator
iv
=
insideVertices
.
begin
();
iv
!=
insideVertices
.
end
();
++
iv
)
if
(
f
(
*
iv
))
return
true
;
return
false
;
}
template
<
typename
PPFP
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Collector
<
PPFP
>&
c
)
{
...
...
@@ -121,6 +131,7 @@ void Collector_WithinSphere<PFP>::collect()
vm
.
mark
(
this
->
centerDart
);
unsigned
int
i
=
0
;
// for(std::vector<Dart>::iterator iv = this->insideVertices.begin(); iv != this->insideVertices.end(); ++iv)
while
(
i
<
this
->
insideVertices
.
size
())
{
Dart
end
=
this
->
insideVertices
[
i
];
...
...
@@ -132,7 +143,7 @@ void Collector_WithinSphere<PFP>::collect()
const
Dart
f
=
this
->
map
.
phi1
(
e
);
const
Dart
g
=
this
->
map
.
phi1
(
f
);
if
(
!
this
->
isInside
(
f
))
if
(
!
this
->
isInside
(
f
))
{
this
->
border
.
push_back
(
e
);
// add to border
em
.
mark
(
e
);
...
...
@@ -163,17 +174,17 @@ void Collector_WithinSphere<PFP>::collect()
}
}
template
<
typename
PFP
>
typename
PFP
::
REAL
Collector_WithinSphere
<
PFP
>::
intersect_SphereEdge
(
const
Dart
din
,
const
Dart
dout
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
VEC3
p
=
this
->
position
[
din
]
-
this
->
centerPosition
;
VEC3
qminusp
=
this
->
position
[
dout
]
-
this
->
centerPosition
-
p
;
REAL
s
=
p
*
qminusp
;
REAL
n2
=
qminusp
.
norm2
();
return
(
-
s
+
sqrt
(
s
*
s
+
n2
*
(
this
->
radius_2
-
p
.
norm2
())))
/
(
n2
)
;
}
//
template <typename PFP>
//
typename PFP::REAL Collector_WithinSphere<PFP>::intersect_SphereEdge(const Dart din, const Dart dout)
//
{
//
typedef typename PFP::VEC3 VEC3;
//
typedef typename PFP::REAL REAL;
//
VEC3 p = this->position[din] - this->centerPosition;
//
VEC3 qminusp = this->position[dout] - this->centerPosition - p;
//
REAL s = p
*
qminusp;
//
REAL n2 = qminusp.norm2();
//
return (- s + sqrt(s
*
s + n2
*
(this->radius_2 - p.norm2())))
/
n2;
//
}
template
<
typename
PFP
>
void
Collector_WithinSphere
<
PFP
>::
computeArea
()
...
...
@@ -189,14 +200,14 @@ void Collector_WithinSphere<PFP>::computeArea()
const
Dart
g
=
this
->
map
.
phi1
(
f
);
if
(
this
->
isInside
(
g
))
{
// only f is outside
typename
PFP
::
REAL
alpha
=
this
->
intersect_SphereEdge
(
*
it
,
f
);
typename
PFP
::
REAL
beta
=
this
->
intersect_SphereEdge
(
g
,
f
);
typename
PFP
::
REAL
alpha
=
this
->
intersect_SphereEdge
(
*
it
,
f
);
typename
PFP
::
REAL
beta
=
this
->
intersect_SphereEdge
(
g
,
f
);
this
->
area
+=
(
alpha
+
beta
-
alpha
*
beta
)
*
Algo
::
Geometry
::
triangleArea
<
PFP
>
(
this
->
map
,
*
it
,
this
->
position
);
}
else
{
// f and g are outside
typename
PFP
::
REAL
alpha
=
this
->
intersect_SphereEdge
(
*
it
,
f
);
typename
PFP
::
REAL
beta
=
this
->
intersect_SphereEdge
(
*
it
,
g
);
typename
PFP
::
REAL
alpha
=
this
->
intersect_SphereEdge
(
*
it
,
f
);
typename
PFP
::
REAL
beta
=
this
->
intersect_SphereEdge
(
*
it
,
g
);
this
->
area
+=
alpha
*
beta
*
Algo
::
Geometry
::
triangleArea
<
PFP
>
(
this
->
map
,
*
it
,
this
->
position
);
}
}
...
...
include/Algo/Selection/raySelectFunctor.hpp
View file @
b18a529d
...
...
@@ -44,13 +44,13 @@ 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
typename
PFP
::
TVEC3
&
m_positions
;
public:
/**
* @param map the map
...
...
@@ -64,7 +64,7 @@ public:
bool
operator
()(
Dart
d
)
{
const
typename
PFP
::
VEC3
&
Ta
=
m_positions
[
d
];
//this->m_map.getVertexEmb(d)->getPosition();
const
typename
PFP
::
VEC3
&
Ta
=
m_positions
[
d
];
Dart
dd
=
this
->
m_map
.
phi1
(
d
);
Dart
ddd
=
this
->
m_map
.
phi1
(
dd
);
...
...
@@ -72,13 +72,13 @@ public:
do
{
// get back position of triangle Ta,Tb,Tc
const
typename
PFP
::
VEC3
&
Tb
=
m_positions
[
dd
];
//this->m_map.getVertexEmb(dd)->getPosition();
const
typename
PFP
::
VEC3
&
Tc
=
m_positions
[
ddd
];
//this->m_map.getVertexEmb(ddd)->getPosition();
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
))
{
m_faces
.
push_back
(
d
);
m_Ipoints
.
push_back
(
I
)
;
m_Ipoints
.
push_back
(
I
);
notfound
=
false
;
}
// next triangle if we are in polygon
...
...
@@ -95,7 +95,6 @@ class FuncEdgeInter: public FunctorMap<typename PFP::MAP>
{
typedef
typename
PFP
::
MAP
MAP
;
protected:
std
::
vector
<
Dart
>&
m_edges
;
const
typename
PFP
::
VEC3
&
m_A
;
...
...
@@ -103,6 +102,7 @@ protected:
float
m_AB2
;
float
m_distMax
;
const
typename
PFP
::
TVEC3
&
m_positions
;
public:
/**
* @param map the map
...
...
@@ -119,9 +119,9 @@ public:
bool
operator
()(
Dart
d
)
{
// get back position of segment PQ
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
//this->m_map.getVertexEmb(d)->getPosition();
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
Dart
dd
=
this
->
m_map
.
phi1
(
d
);
const
typename
PFP
::
VEC3
&
Q
=
m_positions
[
dd
];
//this->m_map.getVertexEmb(dd)->getPosition();
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
);
...
...
@@ -161,7 +161,7 @@ public:
bool
operator
()(
Dart
d
)
{
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
//this->m_map.getVertexEmb(d)->getPosition();
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
float
dist
=
Geom
::
squaredDistanceLine2Point
(
m_A
,
m_AB
,
m_AB2
,
P
);
if
(
dist
<
m_distMax
)
{
...
...
@@ -172,7 +172,7 @@ public:
};
/**
* F
o
nctor which store the dart that correspond to the subpart of face
* F
u
nctor which store the dart that correspond to the subpart of face
* that is intersected
* Must be called in foreachface
*/
...
...
@@ -373,7 +373,6 @@ bool distnintOrdering(const std::pair<typename PFP::REAL, unsigned int>& e1, con
return
(
e1
.
first
<
e2
.
first
);
}
}
//namespace Selection
}
//namespace Algo
...
...
include/Algo/Selection/raySelector.h
View file @
b18a529d
...
...
@@ -37,43 +37,44 @@ namespace Algo
namespace
Selection
{