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
Hurstel
CGoGN
Commits
306ac488
Commit
306ac488
authored
Jun 03, 2011
by
Pierre Kraemer
Browse files
ajout Collector
parent
48e27569
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/Algo/Geometry/curvature.h
View file @
306ac488
...
...
@@ -43,30 +43,29 @@ namespace Geometry
typedef
CPULinearSolverTraits
<
SparseMatrix
<
double
>
,
FullVector
<
double
>
>
CPUSolverTraits
;
template
<
typename
PFP
>
void
computeCurvatureVertices
(
void
computeCurvatureVertices
_QuadraticFitting
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
typename
PFP
::
TREAL
&
k
1
,
typename
PFP
::
TREAL
&
k
2
,
typename
PFP
::
TVEC3
&
K
1
,
typename
PFP
::
TVEC3
&
K
2
,
typename
PFP
::
TREAL
&
k
max
,
typename
PFP
::
TREAL
&
k
min
,
typename
PFP
::
TVEC3
&
K
max
,
typename
PFP
::
TVEC3
&
K
min
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
template
<
typename
PFP
>
void
computeCurvatureVertex
(
void
computeCurvatureVertex
_QuadraticFitting
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
typename
PFP
::
TREAL
&
k1
,
typename
PFP
::
TREAL
&
k2
,
typename
PFP
::
TVEC3
&
K1
,
typename
PFP
::
TVEC3
&
K2
)
;
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
typename
PFP
::
TVEC3
&
Kmin
)
;
template
<
typename
PFP
>
void
vertexQuadricFitting
(
void
vertexQuadr
at
icFitting
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
typename
PFP
::
MATRIX33
&
localFrame
,
...
...
@@ -75,10 +74,10 @@ void vertexQuadricFitting(
float
&
a
,
float
&
b
,
float
&
c
,
float
&
d
,
float
&
e
)
;
template
<
typename
PFP
>
void
quadricFittingAddVertexPos
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
;
void
quadr
at
icFittingAddVertexPos
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
;
template
<
typename
PFP
>
void
quadricFittingAddVertexNormal
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
n
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
;
void
quadr
at
icFittingAddVertexNormal
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
n
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
;
/*
template <typename PFP>
void vertexCubicFitting(Dart dart, typename PFP::VEC3& normal, float& a, float& b, float& c, float& d, float& e, float& f, float& g, float& h, float& i) ;
...
...
@@ -90,6 +89,33 @@ template <typename PFP>
void cubicFittingAddVertexNormal(typename PFP::VEC3& v, typename PFP::VEC3& n, typename PFP::VEC3& p, typename PFP::MATRIX33& localFrame) ;
*/
template
<
typename
PFP
>
void
computeCurvatureVertices_NormalCycles
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angles
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
typename
PFP
::
TVEC3
&
Kmin
,
typename
PFP
::
TVEC3
&
Knormal
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
template
<
typename
PFP
>
void
computeCurvatureVertex_NormalCycles
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angles
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
typename
PFP
::
TVEC3
&
Kmin
,
typename
PFP
::
TVEC3
&
Knormal
)
;
}
// namespace Geoemtry
}
// namespace Algo
...
...
include/Algo/Geometry/curvature.hpp
View file @
306ac488
...
...
@@ -25,6 +25,7 @@
#include
"Algo/Geometry/localFrame.h"
#include
"Geometry/matrix.h"
#include
"Topology/generic/cellmarker.h"
#include
"Algo/Selection/collector.h"
extern
"C"
{
...
...
@@ -44,15 +45,15 @@ namespace Geometry
{
template
<
typename
PFP
>
void
computeCurvatureVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
typename
PFP
::
TREAL
&
k
1
,
typename
PFP
::
TREAL
&
k
2
,
typename
PFP
::
TVEC3
&
K
1
,
typename
PFP
::
TVEC3
&
K
2
,
const
FunctorSelect
&
select
)
void
computeCurvatureVertices
_QuadraticFitting
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
typename
PFP
::
TREAL
&
k
max
,
typename
PFP
::
TREAL
&
k
min
,
typename
PFP
::
TVEC3
&
K
max
,
typename
PFP
::
TVEC3
&
K
min
,
const
FunctorSelect
&
select
)
{
CellMarker
marker
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
...
...
@@ -60,61 +61,62 @@ void computeCurvatureVertices(
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
);
computeCurvatureVertex
<
PFP
>
(
map
,
d
,
position
,
normal
,
k
1
,
k2
,
K1
,
K2
)
;
computeCurvatureVertex
_QuadraticFitting
<
PFP
>
(
map
,
d
,
position
,
normal
,
k
max
,
kmin
,
Kmax
,
Kmin
)
;
}
}
}
template
<
typename
PFP
>
void
computeCurvatureVertex
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
typename
PFP
::
TREAL
&
k
1
,
typename
PFP
::
TREAL
&
k
2
,
typename
PFP
::
TVEC3
&
K
1
,
typename
PFP
::
TVEC3
&
K
2
)
void
computeCurvatureVertex
_QuadraticFitting
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
typename
PFP
::
TREAL
&
k
max
,
typename
PFP
::
TREAL
&
k
min
,
typename
PFP
::
TVEC3
&
K
max
,
typename
PFP
::
TVEC3
&
K
min
)
{
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
MATRIX33
MATRIX33
;
VEC3
n
=
normal
[
dart
]
;
MATRIX33
localFrame
=
Algo
::
Geometry
::
vertexLocalFrame
<
PFP
>
(
map
,
dart
,
position
,
n
)
;
MATRIX33
invLocalFrame
;
localFrame
.
invert
(
invLocalFrame
)
;
REAL
a
,
b
,
c
,
d
,
e
;
//vertexCubicFitting(map,dart,localFrame,a,b,c,d,e,f,g,h,i) ;
vertexQuadricFitting
<
PFP
>
(
map
,
dart
,
localFrame
,
position
,
normal
,
a
,
b
,
c
,
d
,
e
)
;
vertexQuadr
at
icFitting
<
PFP
>
(
map
,
dart
,
localFrame
,
position
,
normal
,
a
,
b
,
c
,
d
,
e
)
;
REAL
k
1
_v
,
k
2
_v
,
K
1x
,
K1
y
;
REAL
k
max
_v
,
k
min
_v
,
K
max_x
,
Kmax_
y
;
//int res = slaev2_(&e, &f, &g, &maxC, &minC, &dirX, &dirY) ;
/*int res = */
slaev2_
(
&
a
,
&
b
,
&
c
,
&
k
1
_v
,
&
k
2
_v
,
&
K
1
x
,
&
K
1
y
)
;
/*int res = */
slaev2_
(
&
a
,
&
b
,
&
c
,
&
k
max
_v
,
&
k
min
_v
,
&
K
max_
x
,
&
K
max_
y
)
;
VEC3
K
1
_v
(
K
1x
,
K1
y
,
0.0
f
)
;
K
1
_v
=
invLocalFrame
*
K
1
_v
;
VEC3
K
2
_v
=
n
^
K
1
_v
;
VEC3
K
max
_v
(
K
max_x
,
Kmax_
y
,
0.0
f
)
;
K
max
_v
=
invLocalFrame
*
K
max
_v
;
VEC3
K
min
_v
=
n
^
K
max
_v
;
if
(
k
1
_v
<
k
2
_v
)
if
(
k
max
_v
<
k
min
_v
)
{
k
1
[
dart
]
=
-
k
1
_v
;
k
2
[
dart
]
=
-
k
2
_v
;
K
1
[
dart
]
=
K
1
_v
;
K
2
[
dart
]
=
K
2
_v
;
k
max
[
dart
]
=
-
k
max
_v
;
k
min
[
dart
]
=
-
k
min
_v
;
K
max
[
dart
]
=
K
max
_v
;
K
min
[
dart
]
=
K
min
_v
;
}
else
{
k
1
[
dart
]
=
-
k
2
_v
;
k
2
[
dart
]
=
-
k
1
_v
;
K
1
[
dart
]
=
K
2
_v
;
K
2
[
dart
]
=
K
1
_v
;
k
max
[
dart
]
=
-
k
min
_v
;
k
min
[
dart
]
=
-
k
max
_v
;
K
max
[
dart
]
=
K
min
_v
;
K
min
[
dart
]
=
K
max
_v
;
}
}
template
<
typename
PFP
>
void
vertexQuadricFitting
(
void
vertexQuadr
at
icFitting
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
typename
PFP
::
MATRIX33
&
localFrame
,
...
...
@@ -122,11 +124,7 @@ void vertexQuadricFitting(
const
typename
PFP
::
TVEC3
&
normal
,
float
&
a
,
float
&
b
,
float
&
c
,
float
&
d
,
float
&
e
)
{
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
MATRIX33
MATRIX33
;
VEC3
p
=
position
[
dart
]
;
typename
PFP
::
VEC3
p
=
position
[
dart
]
;
LinearSolver
<
CPUSolverTraits
>
solver
(
5
)
;
solver
.
set_least_squares
(
true
)
;
...
...
@@ -135,10 +133,10 @@ void vertexQuadricFitting(
do
{
// 1-ring vertices
VEC3
v
=
position
[
map
.
phi2
(
it
)]
;
quadricFittingAddVertexPos
<
PFP
>
(
v
,
p
,
localFrame
,
solver
)
;
VEC3
n
=
normal
[
map
.
phi2
(
it
)]
;
quadricFittingAddVertexNormal
<
PFP
>
(
v
,
n
,
p
,
localFrame
,
solver
)
;
typename
PFP
::
VEC3
v
=
position
[
map
.
phi2
(
it
)]
;
quadr
at
icFittingAddVertexPos
<
PFP
>
(
v
,
p
,
localFrame
,
solver
)
;
typename
PFP
::
VEC3
n
=
normal
[
map
.
phi2
(
it
)]
;
quadr
at
icFittingAddVertexNormal
<
PFP
>
(
v
,
n
,
p
,
localFrame
,
solver
)
;
// 2-ring vertices
// Dart d2 = map.phi1(map.phi1(map.phi2(map.phi1(it)))) ;
// VEC3 v2 = position[d2] ;
...
...
@@ -158,7 +156,7 @@ void vertexQuadricFitting(
}
template
<
typename
PFP
>
void
quadricFittingAddVertexPos
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
void
quadr
at
icFittingAddVertexPos
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
{
typename
PFP
::
VEC3
vec
=
v
-
p
;
vec
=
localFrame
*
vec
;
...
...
@@ -175,33 +173,33 @@ void quadricFittingAddVertexPos(typename PFP::VEC3& v, typename PFP::VEC3& p, ty
}
template
<
typename
PFP
>
void
quadricFittingAddVertexNormal
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
n
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
void
quadr
at
icFittingAddVertexNormal
(
typename
PFP
::
VEC3
&
v
,
typename
PFP
::
VEC3
&
n
,
typename
PFP
::
VEC3
&
p
,
typename
PFP
::
MATRIX33
&
localFrame
,
LinearSolver
<
CPUSolverTraits
>&
solver
)
{
typename
PFP
::
VEC3
vec
=
v
-
p
;
vec
=
localFrame
*
vec
;
typename
PFP
::
VEC3
norm
=
localFrame
*
n
;
solver
.
begin_row
()
;
solver
.
add_coefficient
(
0
,
2.0
f
*
vec
[
0
])
;
solver
.
add_coefficient
(
0
,
2.0
f
*
vec
[
0
])
;
solver
.
add_coefficient
(
1
,
vec
[
1
])
;
solver
.
add_coefficient
(
2
,
0
)
;
solver
.
add_coefficient
(
3
,
1.0
f
)
;
solver
.
add_coefficient
(
4
,
0
)
;
solver
.
set_right_hand_side
(
-
1.0
f
*
norm
[
0
]
/
norm
[
2
])
;
solver
.
set_right_hand_side
(
-
1.0
f
*
norm
[
0
]
/
norm
[
2
])
;
solver
.
end_row
()
;
solver
.
begin_row
()
;
solver
.
add_coefficient
(
0
,
0
)
;
solver
.
add_coefficient
(
1
,
vec
[
0
])
;
solver
.
add_coefficient
(
2
,
2.0
f
*
vec
[
1
])
;
solver
.
add_coefficient
(
2
,
2.0
f
*
vec
[
1
])
;
solver
.
add_coefficient
(
3
,
0
)
;
solver
.
add_coefficient
(
4
,
1.0
f
)
;
solver
.
set_right_hand_side
(
-
1.0
f
*
norm
[
1
]
/
norm
[
2
])
;
solver
.
set_right_hand_side
(
-
1.0
f
*
norm
[
1
]
/
norm
[
2
])
;
solver
.
end_row
()
;
}
/*
template <typename PFP>
void
DifferentialProperties<PFP>::
vertexCubicFitting(Dart dart, gmtl::Vec3f& normal, float& a, float& b, float& c, float& d, float& e, float& f, float& g, float& h, float& i)
void vertexCubicFitting(Dart dart, gmtl::Vec3f& normal, float& a, float& b, float& c, float& d, float& e, float& f, float& g, float& h, float& i)
{
gmtl::Matrix33f localFrame, invLocalFrame ;
Algo::Geometry::vertexLocalFrame<PFP>(m_map,dart,normal,localFrame) ;
...
...
@@ -245,7 +243,7 @@ void DifferentialProperties<PFP>::vertexCubicFitting(Dart dart, gmtl::Vec3f& nor
}
template <typename PFP>
void
DifferentialProperties<PFP>::
cubicFittingAddVertexPos(gmtl::Vec3f& v, gmtl::Vec3f& p, gmtl::Matrix33f& localFrame)
void cubicFittingAddVertexPos(gmtl::Vec3f& v, gmtl::Vec3f& p, gmtl::Matrix33f& localFrame)
{
gmtl::Vec3f vec = v - p ;
vec = localFrame * vec ;
...
...
@@ -266,7 +264,7 @@ void DifferentialProperties<PFP>::cubicFittingAddVertexPos(gmtl::Vec3f& v, gmtl:
}
template <typename PFP>
void
DifferentialProperties<PFP>::
cubicFittingAddVertexNormal(gmtl::Vec3f& v, gmtl::Vec3f& n, gmtl::Vec3f& p, gmtl::Matrix33f& localFrame)
void cubicFittingAddVertexNormal(gmtl::Vec3f& v, gmtl::Vec3f& n, gmtl::Vec3f& p, gmtl::Matrix33f& localFrame)
{
gmtl::Vec3f vec = v - p ;
vec = localFrame * vec ;
...
...
@@ -299,6 +297,52 @@ void DifferentialProperties<PFP>::cubicFittingAddVertexNormal(gmtl::Vec3f& v, gm
solverC->end_row() ;
}
*/
template
<
typename
PFP
>
void
computeCurvatureVertices_NormalCycles
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angles
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
typename
PFP
::
TVEC3
&
Kmin
,
typename
PFP
::
TVEC3
&
Knormal
,
const
FunctorSelect
&
select
=
SelectorTrue
())
{
CellMarker
marker
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
{
marker
.
mark
(
d
);
computeCurvatureVertex_NormalCycles
<
PFP
>
(
map
,
d
,
radius
,
position
,
normal
,
angles
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
}
}
}
template
<
typename
PFP
>
void
computeCurvatureVertex_NormalCycles
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angles
,
typename
PFP
::
TREAL
&
kmax
,
typename
PFP
::
TREAL
&
kmin
,
typename
PFP
::
TVEC3
&
Kmax
,
typename
PFP
::
TVEC3
&
Kmin
,
typename
PFP
::
TVEC3
&
Knormal
)
{
Collector_WithinSphere
<
PFP
>
neigh
(
map
,
position
);
neigh
.
init
(
dart
,
radius
)
;
neigh
.
collect
()
;
neigh
.
computeArea
()
;
}
}
// namespace Geometry
}
// namespace Algo
...
...
include/Algo/Selection/collector.h
0 → 100644
View file @
306ac488
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef __COLLECTOR_H__
#define __COLLECTOR_H__
/*****************************************
* Class hierarchy :
* Collector (virtual)
* - Collector_WithinSphere
* - Collector_OneRing
****************************************/
namespace
CGoGN
{
namespace
Selection
{
/*********************************************************
* Collector
*********************************************************/
template
<
typename
PFP
>
class
Collector
{
protected:
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
typename
PFP
::
MAP
&
map
;
const
typename
PFP
::
TVEC3
&
position
;
Dart
centerDart
;
REAL
radius
;
std
::
vector
<
Dart
>
insideVertices
;
std
::
vector
<
Dart
>
insideEdges
;
std
::
vector
<
Dart
>
insideFaces
;
std
::
vector
<
Dart
>
border
;
public:
Collector
(
typename
PFP
::
MAP
&
mymap
,
const
typename
PFP
::
TVEC3
&
myposition
);
virtual
void
init
(
Dart
d
,
REAL
r
=
0
)
=
0
;
virtual
void
collect
()
=
0
;
void
sort
()
{
std
::
sort
(
insideVertices
.
begin
(),
insideVertices
.
end
());
std
::
sort
(
insideEdges
.
begin
(),
insideEdges
.
end
());
std
::
sort
(
insideFaces
.
begin
(),
insideFaces
.
end
());
std
::
sort
(
border
.
begin
(),
border
.
end
());
}
typename
PFP
::
MAP
&
getMap
()
{
return
map
;
}
const
AttributeHandler
<
typename
PFP
::
VEC3
>&
getPosition
()
const
{
return
position
;
}
Dart
getCenter
()
const
{
return
centerDart
;
}
REAL
getRadius
()
const
{
return
radius
;
}
const
std
::
vector
<
Dart
>&
getInsideVertices
()
const
{
return
insideVertices
;
}
const
std
::
vector
<
Dart
>&
getInsideEdges
()
const
{
return
insideEdges
;
}
const
std
::
vector
<
Dart
>&
getInsideFaces
()
const
{
return
insideFaces
;
}
const
std
::
vector
<
Dart
>&
getBorder
()
const
{
return
border
;
}
unsigned
int
getNbInsideVertices
()
const
{
return
insideVertices
.
size
();
}
unsigned
int
getNbInsideEdges
()
const
{
return
insideEdges
.
size
();
}
unsigned
int
getNbInsideFaces
()
const
{
return
insideFaces
.
size
();
}
unsigned
int
getNbBorder
()
const
{
return
border
.
size
();
}
template
<
typename
PPFP
>
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Collector
<
PPFP
>&
c
);
};
/*********************************************************
* Collector One Ring
*********************************************************/
/*
* insideVertices = centerDart
* insideEdges = star (edges incident to centerDart)
* insideFaces = triangles incident to centerDart
* border = vertices of 1-ring
* = edges of 1-ring
*/
template
<
typename
PFP
>
class
Collector_OneRing
:
public
Collector
<
PFP
>
{
public:
Collector_OneRing
(
typename
PFP
::
MAP
&
mymap
,
const
typename
PFP
::
TVEC3
&
myposition
)
:
Collector
<
PFP
>
(
mymap
,
myposition
)
{}
void
init
(
Dart
d
,
typename
PFP
::
REAL
r
=
0
);
void
collect
();
};
/*********************************************************
* Collector Within Sphere
*********************************************************/
/*
* collect all primitives of the connected component containing "centerDart"
* within the sphere of radius "radius" and center "position[centerDart]"
* (hopefully) it defines a 2-manifold (if inserting border-vertices along the border-edges)
*/
template
<
typename
PFP
>
class
Collector_WithinSphere
:
public
Collector
<
PFP
>
{
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
)
{}
void
init
(
Dart
d
,
typename
PFP
::
REAL
r
=
0
);
void
collect
();
bool
isInside
(
Dart
d
)
{
return
(
this
->
position
[
d
]
-
centerPosition
).
norm2
()
<
radius_2
;
}
// alpha = coef d'interpolation dans [0 ,1] tel que v= (1-alpha)*pin + alpha*pout
// est le point d'intersection entre la sphère et le segment [pin, pout]
// avec pin = position[din] à l'intérieur de la sphère
// avec pout = position[dout] à l'extérieur de la sphère
typename
PFP
::
REAL
intersect_SphereEdge
(
const
Dart
din
,
const
Dart
dout
);
void
computeArea
();
typename
PFP
::
REAL
getArea
()
const
{
return
area
;
}
};
}
// namespace Selection
}
// namespace CGoGN
#include
"Algo/Selection/collector.hpp"
#endif
include/Algo/Selection/collector.hpp
0 → 100644
View file @
306ac488
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
namespace
CGoGN
{
namespace
Selection
{
/********************************************
* GENERIC COLLECTOR
********************************************/
template
<
typename
PFP
>
Collector
<
PFP
>::
Collector
(
typename
PFP
::
MAP
&
mymap
,
const
typename
PFP
::
TVEC3
&
myposition
)
:
map
(
mymap
),
position
(
myposition
)
{}
template
<
typename
PPFP
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Collector
<
PPFP
>&
c
)
{
out
<<
"Collector around "
<<
c
.
centerDart
<<
std
::
endl
;
out
<<
"insideVertices ("
<<
c
.
insideVertices
.
size
()
<<
") = {"
;
for
(
unsigned
int
i
=
0
;
i
<
c
.
insideVertices
.
size
();
++
i
)
out
<<
c
.
insideVertices
[
i
]
<<
" "
;
out
<<
"}"
<<
std
::
endl
;
out
<<
"insideEdges ("
<<
c
.
insideEdges
.
size
()
<<
") = {"
;
for
(
unsigned
int
i
=
0
;
i
<
c
.
insideEdges
.
size
();
++
i
)
out
<<
c
.
insideEdges
[
i
]
<<
" "
;
out
<<
"}"
<<
std
::
endl
;
out
<<
"insideFaces ("
<<
c
.
insideFaces
.
size
()
<<
") = {"
;
for
(
unsigned
int
i
=
0
;
i
<
c
.
insideFaces
.
size
();
++
i
)
out
<<
c
.
insideFaces
[
i
]
<<
" "
;
out
<<
"}"
<<
std
::
endl
;
out
<<
"border ("
<<
c
.
border
.
size
()
<<
") = {"
;
for
(
unsigned
int
i
=
0
;
i
<
c
.
border
.
size
();
++
i
)
out
<<
c
.
border
[
i
]
<<
" "
;
out
<<
"}"
<<
std
::
endl
;
return
out
;
}
/*********************************************************
* Collector One Ring
*********************************************************/
template
<
typename
PFP
>
void
Collector_OneRing
<
PFP
>::
init
(
Dart
d
,
typename
PFP
::
REAL
r
)
{
this
->
centerDart
=
d
;
this
->
radius
=
r
;
this
->
insideVertices
.
clear
();
this
->
insideEdges
.
clear
();
this
->
insideFaces
.
clear
();
this
->
border
.
clear
();
}
template
<
typename
PFP
>
void
Collector_OneRing
<
PFP
>::
collect
()
{
const
Dart
end
=
this
->
centerDart
;
this
->
insideVertices
.
push_back
(
end
);
Dart
dd
=
end
;