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
David Cazier
CGoGN
Commits
4fa17a33
Commit
4fa17a33
authored
Apr 17, 2014
by
Sylvain Thery
Browse files
testing usage of foreach macros
parent
b1c8dad3
Changes
6
Hide whitespace changes
Inline
Side-by-side
include/Algo/Geometry/area.h
View file @
4fa17a33
...
...
@@ -25,6 +25,8 @@
#ifndef __ALGO_GEOMETRY_AREA_H__
#define __ALGO_GEOMETRY_AREA_H__
#include
"Topology/generic/cells.h"
namespace
CGoGN
{
...
...
@@ -43,7 +45,7 @@ namespace Geometry
//! @param position
//! @return
template
<
typename
PFP
>
typename
PFP
::
REAL
triangleArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
typename
PFP
::
REAL
triangleArea
(
typename
PFP
::
MAP
&
map
,
Face
f
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
//! \brief Compute convex polygonal face area
//! @param map
...
...
@@ -51,7 +53,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttr
//! @param position
//! @return
template
<
typename
PFP
>
typename
PFP
::
REAL
convexFaceArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
typename
PFP
::
REAL
convexFaceArea
(
typename
PFP
::
MAP
&
map
,
Face
f
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
//! \brief Compute the total area of a mesh by summing all face areas.
//! @param map
...
...
@@ -66,25 +68,25 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typen
//! @param position
//! @return
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexOneRingArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
typename
PFP
::
REAL
vertexOneRingArea
(
typename
PFP
::
MAP
&
map
,
Vertex
v
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexBarycentricArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
typename
PFP
::
REAL
vertexBarycentricArea
(
typename
PFP
::
MAP
&
map
,
Vertex
v
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexVoronoiArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
typename
PFP
::
REAL
vertexVoronoiArea
(
typename
PFP
::
MAP
&
map
,
Vertex
v
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
;
template
<
typename
PFP
>
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
face_area
)
;
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
face_area
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
)
;
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeBarycentricAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
)
;
void
computeBarycentricAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
)
;
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
,
unsigned
int
thread
=
0
)
;
}
// namespace Geometry
...
...
include/Algo/Geometry/area.hpp
View file @
4fa17a33
...
...
@@ -24,8 +24,11 @@
#include
"Geometry/basic.h"
#include
"Algo/Geometry/centroid.h"
#include
"Topology/generic/traversorCell.h"
#include
"Topology/generic/traversor2.h"
//#include "Topology/generic/traversorCell.h"
//#include "Topology/generic/traversor2.h"
#include
"Topology/generic/cells.h"
#include
"Topology/generic/autoAttributeHandler.h"
namespace
CGoGN
{
...
...
@@ -40,7 +43,7 @@ namespace Geometry
{
template
<
typename
PFP
>
typename
PFP
::
REAL
triangleArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
typename
PFP
::
REAL
triangleArea
(
typename
PFP
::
MAP
&
map
,
Face
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
{
typename
PFP
::
VEC3
p1
=
position
[
d
]
;
typename
PFP
::
VEC3
p2
=
position
[
map
.
phi1
(
d
)]
;
...
...
@@ -50,7 +53,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttr
}
template
<
typename
PFP
>
typename
PFP
::
REAL
convexFaceArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
typename
PFP
::
REAL
convexFaceArea
(
typename
PFP
::
MAP
&
map
,
Face
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
...
...
@@ -75,38 +78,48 @@ template <typename PFP>
typename
PFP
::
REAL
totalArea
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
unsigned
int
thread
)
{
typename
PFP
::
REAL
area
(
0
)
;
TraversorF
<
typename
PFP
::
MAP
>
t
(
map
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
area
+=
convexFaceArea
<
PFP
>
(
map
,
d
,
position
)
;
// TraversorF<typename PFP::MAP> t(map) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
// area += convexFaceArea<PFP>(map, d, position) ;
foreachCellMT
(
FACE
,
f
,
typename
PFP
::
MAP
,
map
,
thread
)
area
+=
convexFaceArea
<
PFP
>
(
map
,
f
,
position
);
return
area
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexOneRingArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
typename
PFP
::
REAL
vertexOneRingArea
(
typename
PFP
::
MAP
&
map
,
Vertex
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
{
typename
PFP
::
REAL
area
(
0
)
;
Traversor2VF
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
area
+=
convexFaceArea
<
PFP
>
(
map
,
it
,
position
)
;
// Traversor2VF<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachIncident2
(
VERTEX
,
d
,
FACE
,
f
,
typename
PFP
::
MAP
,
map
)
area
+=
convexFaceArea
<
PFP
>
(
map
,
f
,
position
)
;
return
area
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexBarycentricArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
typename
PFP
::
REAL
vertexBarycentricArea
(
typename
PFP
::
MAP
&
map
,
Vertex
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
{
typename
PFP
::
REAL
area
(
0
)
;
Traversor2VF
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
area
+=
convexFaceArea
<
PFP
>
(
map
,
it
,
position
)
/
3
;
// Traversor2VF<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
// area += convexFaceArea<PFP>(map, it, position) / 3 ;
foreachIncident2
(
VERTEX
,
d
,
FACE
,
f
,
typename
PFP
::
MAP
,
map
)
area
+=
convexFaceArea
<
PFP
>
(
map
,
f
,
position
)
/
3
;
return
area
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
vertexVoronoiArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
typename
PFP
::
REAL
vertexVoronoiArea
(
typename
PFP
::
MAP
&
map
,
Vertex
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
)
{
typename
PFP
::
REAL
area
(
0
)
;
Traversor2VF
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
// Traversor2VF<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachIncident2
(
VERTEX
,
d
,
FACE
,
it
,
typename
PFP
::
MAP
,
map
)
{
const
typename
PFP
::
VEC3
&
p1
=
position
[
it
]
;
const
typename
PFP
::
VEC3
&
p2
=
position
[
map
.
phi1
(
it
)]
;
...
...
@@ -130,34 +143,51 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const Verte
}
template
<
typename
PFP
>
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
face_area
)
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
face_area
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
t
(
map
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
face_area
[
d
]
=
convexFaceArea
<
PFP
>
(
map
,
d
,
position
)
;
// TraversorF<typename PFP::MAP> t(map) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
// face_area[d] = convexFaceArea<PFP>(map, d, position) ;
foreachCellMT
(
FACE
,
f
,
typename
PFP
::
MAP
,
map
,
thread
)
face_area
[
f
]
=
convexFaceArea
<
PFP
>
(
map
,
f
,
position
)
;
}
template
<
typename
PFP
>
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
)
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
,
unsigned
int
thread
)
{
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
vertex_area
[
d
]
=
vertexOneRingArea
<
PFP
>
(
map
,
d
,
position
)
;
// TraversorV<typename PFP::MAP> t(map) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
// foreachCell(VERTEX,d,typename PFP::MAP,map,thread)
// vertex_area[d] = vertexOneRingArea<PFP>(map, d, position) ;
FaceAutoAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>
areas
(
map
);
computeAreaFaces
<
PFP
>
(
map
,
position
,
areas
);
foreachCellMT
(
VERTEX
,
v
,
typename
PFP
::
MAP
,
map
,
thread
)
{
vertex_area
[
v
]
=
typename
PFP
::
REAL
(
0
);
foreachIncident2
(
VERTEX
,
v
,
FACE
,
f
,
typename
PFP
::
MAP
,
map
)
vertex_area
[
v
]
+=
areas
[
f
];
}
}
template
<
typename
PFP
>
void
computeBarycentricAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
)
void
computeBarycentricAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
,
unsigned
int
thread
)
{
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorV<typename PFP::MAP> t(map) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
VERTEX
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
vertex_area
[
d
]
=
vertexBarycentricArea
<
PFP
>
(
map
,
d
,
position
)
;
}
template
<
typename
PFP
>
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
)
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
vertex_area
,
unsigned
int
thread
)
{
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorV<typename PFP::MAP> t(map) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
VERTEX
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
vertex_area
[
d
]
=
vertexVoronoiArea
<
PFP
>
(
map
,
d
,
position
)
;
}
...
...
include/Algo/Geometry/centroid.h
View file @
4fa17a33
...
...
@@ -26,6 +26,7 @@
#define __ALGO_GEOMETRY_CENTROID_H__
#include
"Geometry/basic.h"
#include
"Topology/generic/cells.h"
namespace
CGoGN
{
...
...
@@ -50,7 +51,7 @@ namespace Geometry
* @param attributs the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
volumeCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
=
0
);
typename
V_ATT
::
DATA_TYPE
volumeCentroid
(
typename
PFP
::
MAP
&
map
,
Vol
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
=
0
);
/**
* Compute volume centroid weighted by edge length (generic version)
...
...
@@ -63,7 +64,7 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V
* @param attributs the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
volumeCentroidELW
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
=
0
);
typename
V_ATT
::
DATA_TYPE
volumeCentroidELW
(
typename
PFP
::
MAP
&
map
,
Vol
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
=
0
);
/**
* Compute face centroid (generic version)
...
...
@@ -75,7 +76,7 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, cons
* @param attributs the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
faceCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
);
typename
V_ATT
::
DATA_TYPE
faceCentroid
(
typename
PFP
::
MAP
&
map
,
Face
d
,
const
V_ATT
&
attributs
);
/**
* Compute face centroid weighted by edge length (generic version)
...
...
@@ -87,7 +88,7 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_A
* @param attributs the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
faceCentroidELW
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
);
typename
V_ATT
::
DATA_TYPE
faceCentroidELW
(
typename
PFP
::
MAP
&
map
,
Face
d
,
const
V_ATT
&
attributs
);
/**
* Compute vertex neighbours centroid (generic version)
...
...
@@ -99,7 +100,7 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const
* @param position the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
);
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Vertex
d
,
const
V_ATT
&
attributs
);
/**
* Compute centroid of all faces
...
...
@@ -195,7 +196,7 @@ namespace Geometry
* @param position the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
);
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Vertex
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
=
0
);
/**
* compute centroid of all volumes
...
...
include/Algo/Geometry/centroid.hpp
View file @
4fa17a33
...
...
@@ -28,6 +28,7 @@
#include
"Topology/generic/traversorCell.h"
#include
"Topology/generic/traversor3.h"
#include
"Algo/Parallel/parallel_foreach.h"
#include
"Topology/generic/cells.h"
namespace
CGoGN
{
...
...
@@ -42,14 +43,20 @@ namespace Geometry
{
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
volumeCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
)
typename
V_ATT
::
DATA_TYPE
volumeCentroid
(
typename
PFP
::
MAP
&
map
,
Vol
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
)
{
typename
V_ATT
::
DATA_TYPE
center
(
0.0
);
unsigned
int
count
=
0
;
Traversor3WV
<
typename
PFP
::
MAP
>
tra
(
map
,
d
,
false
,
thread
);
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
// Traversor3WV<typename PFP::MAP> tra(map,d,false,thread);
// for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
// {
// center += attributs[d];
// ++count;
// }
foreachIncident3MT
(
VOLUME
,
d
,
VERTEX
,
e
,
typename
PFP
::
MAP
,
map
,
thread
)
{
center
+=
attributs
[
d
];
center
+=
attributs
[
e
];
++
count
;
}
...
...
@@ -58,14 +65,16 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V
}
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
volumeCentroidELW
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
)
typename
V_ATT
::
DATA_TYPE
volumeCentroidELW
(
typename
PFP
::
MAP
&
map
,
Vol
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
)
{
typedef
typename
V_ATT
::
DATA_TYPE
EMB
;
EMB
center
(
0.0
);
double
count
=
0.0
;
Traversor3WE
<
typename
PFP
::
MAP
>
t
(
map
,
d
,
false
,
thread
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
// Traversor3WE<typename PFP::MAP> t(map, d,false,thread) ;
// for(Dart it = t.begin(); it != t.end();it = t.next())
foreachIncident3MT
(
VOLUME
,
d
,
EDGE
,
it
,
typename
PFP
::
MAP
,
map
,
thread
)
{
EMB
e1
=
attributs
[
it
];
EMB
e2
=
attributs
[
map
.
phi1
(
it
)];
...
...
@@ -78,12 +87,14 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, cons
}
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
faceCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
)
typename
V_ATT
::
DATA_TYPE
faceCentroid
(
typename
PFP
::
MAP
&
map
,
Face
d
,
const
V_ATT
&
attributs
)
{
typename
V_ATT
::
DATA_TYPE
center
(
0.0
);
unsigned
int
count
=
0
;
Traversor2FV
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
// Traversor2FV<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachIncident2
(
FACE
,
d
,
VERTEX
,
it
,
typename
PFP
::
MAP
,
map
)
{
center
+=
attributs
[
it
];
++
count
;
...
...
@@ -93,14 +104,16 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_A
}
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
faceCentroidELW
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
)
typename
V_ATT
::
DATA_TYPE
faceCentroidELW
(
typename
PFP
::
MAP
&
map
,
Face
d
,
const
V_ATT
&
attributs
)
{
typedef
typename
V_ATT
::
DATA_TYPE
EMB
;
EMB
center
(
0.0
);
double
count
=
0.0
;
Traversor2FE
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
// Traversor2FE<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachIncident2
(
FACE
,
d
,
EDGE
,
it
,
typename
PFP
::
MAP
,
map
)
{
EMB
e1
=
attributs
[
it
];
EMB
e2
=
attributs
[
map
.
phi1
(
it
)];
...
...
@@ -113,13 +126,14 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const
}
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
)
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Vertex
d
,
const
V_ATT
&
attributs
)
{
typename
V_ATT
::
DATA_TYPE
center
(
0.0
);
unsigned
int
count
=
0
;
Traversor2VVaE
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
// Traversor2VVaE<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachAdjacent2
(
VERTEX
,
EDGE
,
d
,
it
,
typename
PFP
::
MAP
,
map
)
{
center
+=
attributs
[
it
];
++
count
;
...
...
@@ -131,24 +145,27 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dar
template
<
typename
PFP
,
typename
V_ATT
,
typename
F_ATT
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
V_ATT
&
position
,
F_ATT
&
face_centroid
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
t
(
map
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorF<typename PFP::MAP> t(map,thread) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
FACE
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
face_centroid
[
d
]
=
faceCentroid
<
PFP
,
V_ATT
>
(
map
,
d
,
position
)
;
}
template
<
typename
PFP
,
typename
V_ATT
,
typename
F_ATT
>
void
computeCentroidELWFaces
(
typename
PFP
::
MAP
&
map
,
const
V_ATT
&
position
,
F_ATT
&
face_centroid
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
t
(
map
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorF<typename PFP::MAP> t(map,thread) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
FACE
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
face_centroid
[
d
]
=
faceCentroidELW
<
PFP
,
V_ATT
>
(
map
,
d
,
position
)
;
}
template
<
typename
PFP
,
typename
V_ATT
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
V_ATT
&
position
,
V_ATT
&
vertex_centroid
,
unsigned
int
thread
)
{
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorV<typename PFP::MAP> t(map, thread) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
VERTEX
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
vertex_centroid
[
d
]
=
vertexNeighborhoodCentroid
<
PFP
,
V_ATT
>
(
map
,
d
,
position
)
;
}
...
...
@@ -247,12 +264,13 @@ namespace Geometry
{
template
<
typename
PFP
,
typename
V_ATT
>
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
V_ATT
&
attributs
)
typename
V_ATT
::
DATA_TYPE
vertexNeighborhoodCentroid
(
typename
PFP
::
MAP
&
map
,
Vertex
d
,
const
V_ATT
&
attributs
,
unsigned
int
thread
)
{
typename
V_ATT
::
DATA_TYPE
center
(
0.0
);
unsigned
int
count
=
0
;
Traversor3VVaE
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
// Traversor3VVaE<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachAdjacent3MT
(
VERTEX
,
EDGE
,
d
,
it
,
typename
PFP
::
MAP
,
map
,
thread
)
{
center
+=
attributs
[
it
];
++
count
;
...
...
@@ -264,24 +282,27 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dar
template
<
typename
PFP
,
typename
V_ATT
,
typename
W_ATT
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
V_ATT
&
position
,
W_ATT
&
vol_centroid
,
unsigned
int
thread
)
{
TraversorW
<
typename
PFP
::
MAP
>
t
(
map
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorW<typename PFP::MAP> t(map, thread) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
VOLUME
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
vol_centroid
[
d
]
=
Surface
::
Geometry
::
volumeCentroid
<
PFP
,
V_ATT
>
(
map
,
d
,
position
,
thread
)
;
}
template
<
typename
PFP
,
typename
V_ATT
,
typename
W_ATT
>
void
computeCentroidELWVolumes
(
typename
PFP
::
MAP
&
map
,
const
V_ATT
&
position
,
W_ATT
&
vol_centroid
,
unsigned
int
thread
)
{
TraversorW
<
typename
PFP
::
MAP
>
t
(
map
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorW<typename PFP::MAP> t(map,thread) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
VOLUME
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
vol_centroid
[
d
]
=
Surface
::
Geometry
::
volumeCentroidELW
<
PFP
,
V_ATT
>
(
map
,
d
,
position
,
thread
)
;
}
template
<
typename
PFP
,
typename
V_ATT
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
V_ATT
&
position
,
V_ATT
&
vertex_centroid
,
unsigned
int
thread
)
{
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
// TraversorV<typename PFP::MAP> t(map, thread) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT
(
VERTEX
,
d
,
typename
PFP
::
MAP
,
map
,
thread
)
vertex_centroid
[
d
]
=
Volume
::
Geometry
::
vertexNeighborhoodCentroid
<
PFP
,
V_ATT
>
(
map
,
d
,
position
)
;
}
...
...
include/Algo/Render/GL2/explodeVolumeRender.hpp
View file @
4fa17a33
...
...
@@ -170,12 +170,12 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& posi
std
::
vector
<
VEC3
>
vertices
;
vertices
.
reserve
(
20
);
TraversorCell
<
MAP
,
MAP
::
FACE_OF_PARENT
>
traFace
(
map
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
()
)
//
TraversorCell<MAP, MAP::FACE_OF_PARENT> traFace(map);
// for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
for
eachCell
(
MAP
::
FACE_OF_PARENT
,
d
,
MAP
,
map
)
{
// compute normals
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
.
dart
()
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
computeFace
<
PFP
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
...
...
@@ -254,8 +254,9 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& posi
buffer
.
clear
();
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
EDGE_OF_PARENT
>
traEdge
(
map
);
for
(
Dart
d
=
traEdge
.
begin
();
d
!=
traEdge
.
end
();
d
=
traEdge
.
next
())
// TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map);
// for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
foreachCell
(
MAP
::
EDGE_OF_PARENT
,
d
,
MAP
,
map
)
{
buffer
.
push_back
(
PFP
::
toVec3f
(
centerVolumes
[
d
]));
buffer
.
push_back
(
PFP
::
toVec3f
(
positions
[
d
]));
...
...
@@ -305,9 +306,9 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit
std
::
vector
<
VEC3
>
vertices
;
bufferNormals
.
reserve
(
20
);
TraversorCell
<
MAP
,
MAP
::
FACE_OF_PARENT
>
traFace
(
map
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
()
)
//
TraversorCell<MAP, MAP::FACE_OF_PARENT> traFace(map);
// for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
for
eachCell
(
MAP
::
FACE_OF_PARENT
,
d
,
MAP
,
map
)
{
// compute normals
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
...
...
@@ -386,8 +387,9 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit
buffer
.
clear
();
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
EDGE_OF_PARENT
>
traEdge
(
map
);
for
(
Dart
d
=
traEdge
.
begin
();
d
!=
traEdge
.
end
();
d
=
traEdge
.
next
())
// TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map);
// for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
foreachCell
(
MAP
::
EDGE_OF_PARENT
,
d
,
MAP
,
map
)
{
buffer
.
push_back
(
PFP
::
toVec3f
(
centerVolumes
[
d
]));
buffer
.
push_back
(
PFP
::
toVec3f
(
positions
[
d
]));
...
...
@@ -447,11 +449,11 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const V_ATT& positi
bufferColors
.
reserve
(
16384
);
TraversorCell
<
MAP
,
MAP
::
FACE_OF_PARENT
>
traFace
(
map
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
()
)
//
TraversorCell<MAP, MAP::FACE_OF_PARENT> traFace(map);
// for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
for
eachCell
(
MAP
::
FACE_OF_PARENT
,
d
,
MAP
,
map
)
{
VEC3F
centerFace
=
PFP
::
toVec3f
(
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
));
VEC3F
centerFace
=
PFP
::
toVec3f
(
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
.
dart
()
,
positions
));
VEC3F
volColor
=
PFP
::
toVec3f
(
colorPerXXX
[
d
]);
Dart
b
=
d
;
...
...
@@ -509,8 +511,9 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const V_ATT& positi
buffer
.
clear
();
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
EDGE_OF_PARENT
>
traEdge
(
map
);
for
(
Dart
d
=
traEdge
.
begin
();
d
!=
traEdge
.
end
();
d
=
traEdge
.
next
())
// TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map);
// for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
foreachCell
(
MAP
::
EDGE_OF_PARENT
,
d
,
MAP
,
map
)
{
buffer
.
push_back
(
PFP
::
toVec3f
(
centerVolumes
[
d
]));
buffer
.
push_back
(
PFP
::
toVec3f
(
positions
[
d
]));
...
...
@@ -558,9 +561,9 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const EMBV& positio
std
::
vector
<
VEC3F
>
bufferColors
;
bufferColors
.
reserve
(
16384
);
TraversorCell
<
MAP
,
MAP
::
FACE_OF_PARENT
>
traFace
(
map
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
()
)
//
TraversorCell<MAP, MAP::FACE_OF_PARENT> traFace(map);
// for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
for
eachCell
(
MAP
::
FACE_OF_PARENT
,
d
,
MAP
,
map
)
{
VEC3F
centerFace
=
PFP
::
toVec3f
(
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
));
...
...
@@ -620,8 +623,9 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const EMBV& positio
buffer
.
clear
();
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
EDGE_OF_PARENT
>
traEdge
(
map
);
for
(
Dart
d
=
traEdge
.
begin
();
d
!=
traEdge
.
end
();
d
=
traEdge
.
next
())
// TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map);
// for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
foreachCell
(
MAP
::
EDGE_OF_PARENT
,
d
,
MAP
,
map
)
{
buffer
.
push_back
(
PFP
::
toVec3f<