Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
7e843f10
Commit
7e843f10
authored
Aug 20, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add parallel version of some algorithm (just add Parallel namespace)
Corrections: add some forgotten thread parameter
parent
c5be02f7
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
470 additions
and
44 deletions
+470
-44
include/Algo/Geometry/centroid.h
include/Algo/Geometry/centroid.h
+31
-6
include/Algo/Geometry/centroid.hpp
include/Algo/Geometry/centroid.hpp
+107
-9
include/Algo/Geometry/curvature.h
include/Algo/Geometry/curvature.h
+21
-2
include/Algo/Geometry/curvature.hpp
include/Algo/Geometry/curvature.hpp
+71
-4
include/Algo/Geometry/normal.h
include/Algo/Geometry/normal.h
+16
-0
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+58
-0
include/Algo/Geometry/volume.h
include/Algo/Geometry/volume.h
+10
-2
include/Algo/Geometry/volume.hpp
include/Algo/Geometry/volume.hpp
+61
-7
include/Algo/Modelisation/tetrahedralization.h
include/Algo/Modelisation/tetrahedralization.h
+1
-1
include/Algo/Modelisation/tetrahedralization.hpp
include/Algo/Modelisation/tetrahedralization.hpp
+2
-2
include/Algo/Parallel/cgogn_thread.h
include/Algo/Parallel/cgogn_thread.h
+78
-0
include/Algo/Render/GL2/explodeVolumeRender.hpp
include/Algo/Render/GL2/explodeVolumeRender.hpp
+2
-2
include/Algo/Render/GL2/topo3Render.hpp
include/Algo/Render/GL2/topo3Render.hpp
+3
-2
include/Algo/Selection/collector.h
include/Algo/Selection/collector.h
+4
-2
include/Algo/Selection/collector.hpp
include/Algo/Selection/collector.hpp
+5
-5
No files found.
include/Algo/Geometry/centroid.h
View file @
7e843f10
...
...
@@ -49,7 +49,7 @@ namespace Geometry
* @param attributs the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
volumeCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
);
EMB
volumeCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
,
unsigned
int
thread
=
0
);
/**
* Compute volume centroid
...
...
@@ -59,9 +59,9 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs);
* @param position the vector of attribute
*/
template
<
typename
PFP
>
typename
PFP
::
VEC3
volumeCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
typename
PFP
::
VEC3
volumeCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
unsigned
int
thread
=
0
)
{
return
volumeCentroidGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
);
return
volumeCentroidGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
,
thread
);
}
/**
...
...
@@ -116,13 +116,38 @@ typename PFP::VEC3 vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, co
}
template
<
typename
PFP
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
)
;
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
)
;
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
=
allDarts
)
;
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
namespace
Parallel
{
template
<
typename
PFP
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
}
}
// namespace Geometry
...
...
include/Algo/Geometry/centroid.hpp
View file @
7e843f10
...
...
@@ -27,6 +27,7 @@
#include "Topology/generic/cellmarker.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor3.h"
#include "Algo/Parallel/parallel_foreach.h"
namespace
CGoGN
...
...
@@ -39,12 +40,12 @@ namespace Geometry
{
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
volumeCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
)
EMB
volumeCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
,
unsigned
int
thread
)
{
EMB
center
=
AttribOps
::
zero
<
EMB
,
PFP
>
()
;
unsigned
int
count
=
0
;
Traversor3WV
<
typename
PFP
::
MAP
>
tra
(
map
,
d
);
Traversor3WV
<
typename
PFP
::
MAP
>
tra
(
map
,
d
,
false
,
thread
);
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
{
center
+=
attributs
[
d
];
...
...
@@ -86,29 +87,126 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at
}
template
<
typename
PFP
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
)
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorW
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
TraversorW
<
typename
PFP
::
MAP
>
t
(
map
,
select
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
vol_centroid
[
d
]
=
volumeCentroid
<
PFP
>
(
map
,
d
,
position
)
;
vol_centroid
[
d
]
=
volumeCentroid
<
PFP
>
(
map
,
d
,
position
,
thread
)
;
}
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
)
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
TraversorF
<
typename
PFP
::
MAP
>
t
(
map
,
select
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
face_centroid
[
d
]
=
faceCentroid
<
PFP
>
(
map
,
d
,
position
)
;
}
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
)
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
vertex_centroid
[
d
]
=
vertexNeighborhoodCentroid
<
PFP
>
(
map
,
d
,
position
)
;
}
namespace
Parallel
{
template
<
typename
PFP
>
class
FunctorComputeCentroidVolumes
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
VolumeAttribute
<
typename
PFP
::
VEC3
>&
m_vol_centroid
;
public:
FunctorComputeCentroidVolumes
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_vol_centroid
(
vol_centroid
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
{
m_vol_centroid
[
d
]
=
volumeCentroid
<
PFP
>
(
this
->
m_map
,
d
,
m_position
,
threadID
)
;
}
};
template
<
typename
PFP
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorComputeCentroidVolumes
<
PFP
>
funct
(
map
,
position
,
vol_centroid
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VOLUME
>
(
map
,
funct
,
true
,
nbth
,
true
,
select
,
current_thread
);
}
template
<
typename
PFP
>
class
FunctorComputeCentroidFaces
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
FaceAttribute
<
typename
PFP
::
VEC3
>&
m_fcentroid
;
public:
FunctorComputeCentroidFaces
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
fcentroid
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_fcentroid
(
fcentroid
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
{
m_fcentroid
[
d
]
=
faceCentroid
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorComputeCentroidFaces
<
PFP
>
funct
(
map
,
position
,
face_centroid
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
true
,
nbth
,
false
,
select
,
current_thread
);
}
template
<
typename
PFP
>
class
FunctorComputeNeighborhoodCentroidVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_vcentroid
;
public:
FunctorComputeNeighborhoodCentroidVertices
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vcentroid
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_vcentroid
(
vcentroid
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
{
m_vcentroid
[
d
]
=
vertexNeighborhoodCentroid
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorComputeNeighborhoodCentroidVertices
<
PFP
>
funct
(
map
,
position
,
vertex_centroid
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
true
,
nbth
,
false
,
select
,
current_thread
);
}
}
}
// namespace Geometry
}
// namespace Algo
...
...
include/Algo/Geometry/curvature.h
View file @
7e843f10
...
...
@@ -101,7 +101,7 @@ void computeCurvatureVertices_NormalCycles(
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
const
FunctorSelect
&
select
=
allDarts
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeCurvatureVertex_NormalCycles
(
...
...
@@ -115,10 +115,29 @@ void computeCurvatureVertex_NormalCycles(
VertexAttribute
<
typename
PFP
::
REAL
>&
kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
)
;
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
unsigned
int
thread
=
0
)
;
}
// namespace Geometry
namespace
Parallel
{
template
<
typename
PFP
>
void
computeCurvatureVertices_NormalCycles
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
REAL
radius
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
EdgeAttribute
<
typename
PFP
::
REAL
>&
edgeangle
,
VertexAttribute
<
typename
PFP
::
REAL
>&
kmax
,
VertexAttribute
<
typename
PFP
::
REAL
>&
kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
}
}
// namespace Algo
}
// namespace CGoGN
...
...
include/Algo/Geometry/curvature.hpp
View file @
7e843f10
...
...
@@ -289,11 +289,11 @@ void computeCurvatureVertices_NormalCycles(
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
const
FunctorSelect
&
select
)
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
computeCurvatureVertex_NormalCycles
<
PFP
>
(
map
,
d
,
radius
,
position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
computeCurvatureVertex_NormalCycles
<
PFP
>
(
map
,
d
,
radius
,
position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
,
thread
)
;
}
template
<
typename
PFP
>
...
...
@@ -308,12 +308,12 @@ void computeCurvatureVertex_NormalCycles(
VertexAttribute
<
typename
PFP
::
REAL
>&
kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
)
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
unsigned
int
thread
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
neigh
(
map
,
position
,
radius
)
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
neigh
(
map
,
position
,
radius
,
thread
)
;
neigh
.
collectAll
(
dart
)
;
neigh
.
computeArea
()
;
...
...
@@ -379,6 +379,73 @@ void computeCurvatureVertex_NormalCycles(
dirNormal
*=
-
1
;
// change orientation
}
namespace
Parallel
{
template
<
typename
PFP
>
class
FunctorComputeCurvatureVertices_NormalCycles
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
typename
PFP
::
REAL
m_radius
;
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_normal
;
const
EdgeAttribute
<
typename
PFP
::
REAL
>&
m_edgeangle
;
VertexAttribute
<
typename
PFP
::
REAL
>&
m_kmax
;
VertexAttribute
<
typename
PFP
::
REAL
>&
m_kmin
;
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_Kmax
;
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_Kmin
;
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_Knormal
;
public:
FunctorComputeCurvatureVertices_NormalCycles
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
REAL
radius
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
EdgeAttribute
<
typename
PFP
::
REAL
>&
edgeangle
,
VertexAttribute
<
typename
PFP
::
REAL
>&
kmax
,
VertexAttribute
<
typename
PFP
::
REAL
>&
kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_radius
(
radius
),
m_position
(
position
),
m_normal
(
normal
),
m_edgeangle
(
edgeangle
),
m_kmax
(
kmax
),
m_kmin
(
kmin
),
m_Kmax
(
Kmax
),
m_Kmin
(
Kmin
),
m_Knormal
(
normal
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
{
computeCurvatureVertex_NormalCycles
<
PFP
>
(
map
,
d
,
radius
,
position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
,
threadID
)
;
}
};
template
<
typename
PFP
>
void
computeCurvatureVertices_NormalCycles
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
REAL
radius
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
EdgeAttribute
<
typename
PFP
::
REAL
>&
edgeangle
,
VertexAttribute
<
typename
PFP
::
REAL
>&
kmax
,
VertexAttribute
<
typename
PFP
::
REAL
>&
kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmax
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Kmin
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
Knormal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorComputeCurvatureVertices_NormalCycles
<
PFP
>
funct
(
map
,
radius
,
position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
true
,
nbth
,
true
,
select
,
current_thread
);
}
}
}
// namespace Geometry
}
// namespace Algo
...
...
include/Algo/Geometry/normal.h
View file @
7e843f10
...
...
@@ -27,6 +27,7 @@
#include "Geometry/basic.h"
namespace
CGoGN
{
...
...
@@ -54,6 +55,7 @@ typename PFP::VEC3 vertexBorderNormal(typename PFP::MAP& map, Dart d, const Vert
template
<
typename
PFP
>
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
/**
* compute normals of vertices
* @param map the map on which we work
...
...
@@ -65,12 +67,26 @@ void computeNormalFaces(typename PFP::MAP& map, const VertexAttribute<typename P
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
namespace
Parallel
{
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
template
<
typename
PFP
>
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_normal
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
thread
=
0
)
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
computeAngleBetweenNormalsOnEdge
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
;
template
<
typename
PFP
>
void
computeAnglesBetweenNormalsOnEdges
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
EdgeAttribute
<
typename
PFP
::
REAL
>&
angles
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
}
// namespace Geometry
}
// namespace Algo
...
...
include/Algo/Geometry/normal.hpp
View file @
7e843f10
...
...
@@ -28,6 +28,8 @@
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Algo/Parallel/parallel_foreach.h"
#include <cmath>
namespace
CGoGN
...
...
@@ -163,6 +165,62 @@ void computeNormalVertices(typename PFP::MAP& map, const VertexAttribute<typenam
normal
[
d
]
=
vertexNormal
<
PFP
>
(
map
,
d
,
position
)
;
}
namespace
Parallel
{
template
<
typename
PFP
>
class
FunctorComputeNormalVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_normal
;
public:
FunctorComputeNormalVertices
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_normal
(
normal
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
{
m_normal
[
d
]
=
vertexNormal
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorComputeNormalVertices
<
PFP
>
funct
(
map
,
position
,
normal
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
true
,
nbth
,
false
,
select
,
current_thread
);
}
template
<
typename
PFP
>
class
FunctorComputeNormalFaces
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
FaceAttribute
<
typename
PFP
::
VEC3
>&
m_normal
;
public:
FunctorComputeNormalFaces
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
normal
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_normal
(
normal
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
{
m_normal
[
d
]
=
faceNormal
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorComputeNormalFaces
<
PFP
>
funct
(
map
,
position
,
normal
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
true
,
nbth
,
false
,
select
,
current_thread
);
}
}
template
<
typename
PFP
>
typename
PFP
::
REAL
computeAngleBetweenNormalsOnEdge
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
{
...
...
include/Algo/Geometry/volume.h
View file @
7e843f10
...
...
@@ -43,10 +43,18 @@ template <typename PFP>
typename
PFP
::
REAL
tetrahedronVolume
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
convexPolyhedronVolume
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
;
typename
PFP
::
REAL
convexPolyhedronVolume
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
=
allDarts
)
;
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
namespace
Parallel
{
template
<
typename
PFP
>
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
;
}
}
// namespace Geometry
...
...
include/Algo/Geometry/volume.hpp
View file @
7e843f10
...
...
@@ -58,18 +58,18 @@ typename PFP::REAL tetrahedronVolume(typename PFP::MAP& map, Dart d, const Verte
}
template
<
typename
PFP
>
typename
PFP
::
REAL
convexPolyhedronVolume
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
typename
PFP
::
REAL
convexPolyhedronVolume
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
unsigned
int
thread
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
if
(
Modelisation
::
Tetrahedralization
::
isTetrahedron
<
PFP
>
(
map
,
d
))
if
(
Modelisation
::
Tetrahedralization
::
isTetrahedron
<
PFP
>
(
map
,
d
,
thread
))
return
tetrahedronVolume
<
PFP
>
(
map
,
d
,
position
)
;
else
{
typename
PFP
::
REAL
vol
=
0
;
VEC3
vCentroid
=
Algo
::
Geometry
::
volumeCentroid
<
PFP
>
(
map
,
d
,
position
)
;
VEC3
vCentroid
=
Algo
::
Geometry
::
volumeCentroid
<
PFP
>
(
map
,
d
,
position
,
thread
)
;
DartMarkerStore
mark
(
map
);
// Lock a marker
DartMarkerStore
mark
(
map
,
thread
);
// Lock a marker
std
::
vector
<
Dart
>
visitedFaces
;
visitedFaces
.
reserve
(
100
)
;
...
...
@@ -115,15 +115,69 @@ typename PFP::REAL convexPolyhedronVolume(typename PFP::MAP& map, Dart d, const
}
template
<
typename
PFP
>
float
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
)
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
typename
PFP
::
REAL
vol
=
0
;
TraversorW
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
TraversorW
<
typename
PFP
::
MAP
>
t
(
map
,
select
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
vol
+=
convexPolyhedronVolume
<
PFP
>
(
map
,
d
,
position
)
;
vol
+=
convexPolyhedronVolume
<
PFP
>
(
map
,
d
,
position
,
thread
)
;
return
vol
;
}
namespace
Parallel
{
template
<
typename
PFP
>
class
FunctorTotalVolume
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
typename
PFP
::
REAL
m_vol
;
public:
FunctorTotalVolume
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_vol
(
0.0
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
{
m_vol
+=
convexPolyhedronVolume
<
PFP
>
(
this
->
m_map
,
d
,
m_position
,
threadID
)
;
}
typename
PFP
::
REAL
getVol
()
const
{
return
m_vol
;
}
};
template
<
typename
PFP
>
typename
PFP
::
REAL
totalVolume
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
if
(
nbth
==
0
)
nbth
=
Algo
::
Parallel
::
optimalNbThreads
();
std
::
vector
<
FunctorMapThreaded
<
typename
PFP
::
MAP
>*>
functs
;
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
functs
.
push_back
(
new
FunctorTotalVolume
<
PFP
>
(
map
,
position
));
}
typename
PFP
::
REAL
total
=
0.0
;
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VOLUME
>
(
map
,
functs
,
nbth
,
true
,
select
,
current_thread
);
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
total
+=
reinterpret_cast
<
FunctorTotalVolume
<
PFP
>*>
(
functs
[
i
])
->
getVol
();
delete
functs
[
i
];
}
return
total
;
}
}
}
// namespace Geometry
}
// namespace Algo
...
...
include/Algo/Modelisation/tetrahedralization.h
View file @
7e843f10
...
...
@@ -70,7 +70,7 @@ Dart splitVertex(typename PFP::MAP& map, std::vector<Dart>& vd);