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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
753c8238
Commit
753c8238
authored
May 09, 2014
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parallel::foreach_cell usage
parent
8f89cbb4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
482 additions
and
571 deletions
+482
-571
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+49
-39
include/Algo/Geometry/area.hpp
include/Algo/Geometry/area.hpp
+29
-53
include/Algo/Geometry/centroid.hpp
include/Algo/Geometry/centroid.hpp
+26
-114
include/Algo/Geometry/curvature.hpp
include/Algo/Geometry/curvature.hpp
+9
-91
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+36
-78
include/Algo/Geometry/volume.hpp
include/Algo/Geometry/volume.hpp
+15
-36
include/Topology/generic/traversor/traversorCell.h
include/Topology/generic/traversor/traversorCell.h
+15
-155
include/Topology/generic/traversor/traversorCell.hpp
include/Topology/generic/traversor/traversorCell.hpp
+303
-5
No files found.
Apps/Examples/viewer.cpp
View file @
753c8238
...
...
@@ -272,31 +272,31 @@ void Viewer::cb_keyPress(int keycode)
if
(
!
pos2
.
isValid
())
pos2
=
myMap
.
addAttribute
<
VEC3
,
VERTEX
>
(
"pos2"
)
;
foreach_cell_EvenOddd
<
VERTEX
>
(
myMap
,
[
&
]
(
Vertex
d
)
{
pos2
[
d
]
=
VEC3
(
0
,
0
,
0
);
int
nb
=
0
;
foreach_adjacent2
<
FACE
>
(
myMap
,
d
,[
&
](
Vertex
e
)
{
pos2
[
d
]
+=
position
[
e
];
nb
++
;
});
pos2
[
d
]
/=
nb
;
},
[
&
]
(
Vertex
d
)
{
position
[
d
]
=
VEC3
(
0
,
0
,
0
);
int
nb
=
0
;
foreach_adjacent2
<
FACE
>
(
myMap
,
d
,[
&
](
Vertex
e
)
{
position
[
d
]
+=
pos2
[
e
];
nb
++
;
});
position
[
d
]
/=
nb
;
},
3
);
std
::
cout
<<
"Even/Odd "
<<
ch
.
elapsed
()
<<
" ms "
<<
std
::
endl
;
//
foreach_cell_EvenOddd<VERTEX>(myMap, [&] (Vertex d)
//
{
//
pos2[d] = VEC3(0,0,0);
//
int nb=0;
//
foreach_adjacent2<FACE>(myMap,d,[&](Vertex e)
//
{
//
pos2[d] += position[e];
//
nb++;
//
});
//
pos2[d]/=nb;
//
},
//
[&] (Vertex d)
//
{
//
position[d] = VEC3(0,0,0);
//
int nb=0;
//
foreach_adjacent2<FACE>(myMap,d,[&](Vertex e)
//
{
//
position[d] += pos2[e];
//
nb++;
//
});
//
position[d]/=nb;
//
},
//
3);
//
std::cout << "Even/Odd "<< ch.elapsed()<< " ms "<< std::endl;
Algo
::
Surface
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
...
...
@@ -460,22 +460,32 @@ void Viewer::cb_keyPress(int keycode)
Utils
::
Chrono
ch
;
ch
.
start
();
TraversorCell
<
MAP
,
VERTEX
>
trav
(
myMap
,
true
);
TraversorCellEven
<
MAP
,
VERTEX
>
tr1
(
trav
)
;
TraversorCellOdd
<
MAP
,
VERTEX
>
tr2
(
trav
)
;
for
(
unsigned
int
i
=
0
;
i
<
4
;
++
i
)
Algo
::
Surface
::
Geometry
::
Parallel
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
std
::
cout
<<
"Algo::Surface::Geometry::Parallel::computeNormalVertices "
<<
ch
.
elapsed
()
<<
" ms "
<<
std
::
endl
;
for
(
unsigned
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
Cell
<
VERTEX
>
v
=
tr1
.
begin
(),
e
=
tr1
.
end
();
v
.
dart
!=
e
.
dart
;
v
=
tr1
.
next
())
{
normal
[
v
][
0
]
=
0.0
f
;
}
for
(
Cell
<
VERTEX
>
v
=
tr2
.
begin
(),
e
=
tr2
.
end
();
v
.
dart
!=
e
.
dart
;
v
=
tr2
.
next
())
ch
.
start
();
for
(
unsigned
int
i
=
0
;
i
<
4
;
++
i
)
Parallel
::
foreach_cell
<
VERTEX
>
(
myMap
,[
&
](
Vertex
v
,
unsigned
int
th
)
{
normal
[
v
][
0
]
=
0.0
f
;
}
}
std
::
cout
<<
"Timing 5 traversors even/odd "
<<
ch
.
elapsed
()
<<
" ms "
<<
std
::
endl
;
normal
[
v
]
=
Algo
::
Surface
::
Geometry
::
vertexNormal
<
PFP
>
(
myMap
,
v
,
position
);
},
4
,
false
,
FORCE_CELL_MARKING
);
std
::
cout
<<
"Parallel::foreach_cell "
<<
ch
.
elapsed
()
<<
" ms "
<<
std
::
endl
;
// ch.start();
// Parallel::foreach_cell_EO<VERTEX>(myMap,[&](Vertex v, unsigned int thr)
// {
// normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position);
// },
// [&](Vertex v, unsigned int th)
// {
// normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position);
// },2,4,false,FORCE_CELL_MARKING);
// std::cout << "Parallel::foreach_cell_EO "<< ch.elapsed()<< " ms "<< std::endl;
}
break
;
...
...
include/Algo/Geometry/area.hpp
View file @
753c8238
...
...
@@ -201,73 +201,49 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
namespace
Parallel
{
template
<
typename
PFP
>
class
FunctorConvexFaceArea
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
m_position
;
FaceAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
m_area
;
public:
FunctorConvexFaceArea
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
area
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_area
(
area
)
{
}
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_area
[
d
]
=
convexFaceArea
<
PFP
>
(
this
->
m_map
,
d
,
m_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
>&
area
,
unsigned
int
nbth
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
);
// if (map.isOrbitEmbedded<FACE>())
// {
// Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
// {
// area[f] = convexFaceArea<PFP>(map, f, position) ;
// },nbth,false,FORCE_CELL_MARKING);
// }
// else
// {
// Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
// {
// area[f] = convexFaceArea<PFP>(map, f, position) ;
// },nbth,false,AUTO);
// }
// TODO A REMPLACER QUAND PLGTS CHANGES
CGoGN
::
Parallel
::
foreach_cell
<
FACE
>
(
map
,[
&
](
Face
f
,
unsigned
int
thr
)
{
area
[
f
]
=
convexFaceArea
<
PFP
>
(
map
,
f
,
position
)
;
},
nbth
,
false
,
AUTO
);
}
template
<
typename
PFP
>
class
FunctorVertexOneRingArea
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
m_position
;
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
m_area
;
public:
FunctorVertexOneRingArea
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
area
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_area
(
area
)
{
}
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_area
[
d
]
=
vertexOneRingArea
<
PFP
>
(
this
->
m_map
,
d
,
m_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
>&
area
,
unsigned
int
nbth
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
);
}
template
<
typename
PFP
>
class
FunctorVertexVoronoiArea
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
m_position
;
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
m_area
;
public:
FunctorVertexVoronoiArea
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
::
IMPL
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
::
IMPL
>&
area
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_area
(
area
)
{
}
void
run
(
Dart
d
,
unsigned
int
threadID
)
CGoGN
::
Parallel
::
foreach_cell
<
VERTEX
>
(
map
,[
&
](
Vertex
v
,
unsigned
int
thr
)
{
m_area
[
d
]
=
vertexVoronoiArea
<
PFP
>
(
this
->
m_map
,
d
,
m_
position
)
;
}
}
;
area
[
v
]
=
vertexOneRingArea
<
PFP
>
(
map
,
v
,
position
)
;
}
,
nbth
,
false
,
FORCE_CELL_MARKING
);
}
template
<
typename
PFP
>
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
,
typename
PFP
::
MAP
>&
area
,
unsigned
int
nbth
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
);
CGoGN
::
Parallel
::
foreach_cell
<
VERTEX
>
(
map
,[
&
](
Vertex
v
,
unsigned
int
thr
)
{
area
[
v
]
=
vertexVoronoiArea
<
PFP
>
(
map
,
v
,
position
)
;
},
nbth
,
false
,
FORCE_CELL_MARKING
);
}
}
// namespace Parallel
...
...
include/Algo/Geometry/centroid.hpp
View file @
753c8238
...
...
@@ -169,71 +169,25 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& po
namespace Parallel
{
template <typename PFP, typename V_ATT, typename F_ATT>
class FunctorComputeCentroidFaces: public FunctorMapThreaded<typename PFP::MAP>
{
const V_ATT& m_position;
F_ATT& m_fcentroid;
public:
FunctorComputeCentroidFaces<PFP,V_ATT,F_ATT>( typename PFP::MAP& map, const V_ATT& position, F_ATT& fcentroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_fcentroid(fcentroid)
{ }
void run(Dart d, unsigned int /*threadID*/)
{
m_fcentroid[d] = faceCentroid<PFP>(this->m_map, d, m_position) ;
}
};
template <typename PFP, typename V_ATT, typename F_ATT>
class FunctorComputeCentroidELWFaces: public FunctorMapThreaded<typename PFP::MAP>
{
const V_ATT& m_position;
F_ATT& m_fcentroid;
public:
FunctorComputeCentroidELWFaces<PFP,V_ATT,F_ATT>( typename PFP::MAP& map, const V_ATT& position, F_ATT& fcentroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_fcentroid(fcentroid)
{ }
void run(Dart d, unsigned int threadID)
{
m_fcentroid[d] = faceCentroidELW<PFP>(this->m_map, d, m_position) ;
}
};
template <typename PFP, typename V_ATT>
class FunctorComputeNeighborhoodCentroidVertices: public FunctorMapThreaded<typename PFP::MAP >
{
const V_ATT& m_position;
V_ATT& m_vcentroid;
public:
FunctorComputeNeighborhoodCentroidVertices<PFP,V_ATT>( typename PFP::MAP& map, const V_ATT& position, V_ATT& vcentroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_vcentroid(vcentroid)
{ }
void run(Dart d, unsigned int /*threadID*/)
{
m_vcentroid[d] = vertexNeighborhoodCentroid<PFP>(this->m_map, d, m_position) ;
}
};
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 nbth
, unsigned int current_thread
)
unsigned int nbth)
{
FunctorComputeCentroidFaces<PFP,V_ATT,F_ATT> funct(map,position,face_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,FACE>(map, funct, nbth, false, current_thread);
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
face_centroid[f] = faceCentroid<PFP>(map, f, position) ;
},nbth,false,AUTO);
}
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 nbth, unsigned int current_thread)
{
FunctorComputeCentroidELWFaces<PFP,V_ATT,F_ATT> funct(map,position,face_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,FACE>(map, funct, nbth, false, current_thread);
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
face_centroid[f] = faceCentroidELW<PFP>(map, f, position) ;
},nbth,false,AUTO);
}
template <typename PFP, typename V_ATT>
...
...
@@ -241,8 +195,10 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
const V_ATT& position, V_ATT& vertex_centroid,
unsigned int nbth, unsigned int current_thread)
{
FunctorComputeNeighborhoodCentroidVertices<PFP,V_ATT> funct(map,position,vertex_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,VERTEX>(map, funct, nbth, false);
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
vertex_centroid[v] = vertexNeighborhoodCentroid<PFP>(map, v, position) ;
},nbth,false,FORCE_CELL_MARKING);
}
} // namespace Parallel
...
...
@@ -308,79 +264,35 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& po
namespace Parallel
{
template <typename PFP, typename V_ATT, typename W_ATT>
class FunctorComputeCentroidVolumes: public FunctorMapThreaded<typename PFP::MAP >
{
const V_ATT& m_position;
W_ATT& m_vol_centroid;
public:
FunctorComputeCentroidVolumes<PFP,V_ATT,W_ATT>( typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_vol_centroid(vol_centroid)
{ }
void run(Dart d, unsigned int threadID)
{
m_vol_centroid[d] = Surface::Geometry::volumeCentroid<PFP,V_ATT,W_ATT>(this->m_map, d, m_position,threadID) ;
}
};
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 nbth)
{
FunctorComputeCentroidVolumes<PFP,V_ATT,W_ATT> funct(map,position,vol_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,VOLUME>(map, funct, nbth, true);
}
template <typename PFP, typename V_ATT, typename W_ATT>
class FunctorComputeCentroidELWVolumes: public FunctorMapThreaded<typename PFP::MAP >
{
const V_ATT& m_position;
W_ATT& m_vol_centroid;
public:
FunctorComputeCentroidELWVolumes<PFP,V_ATT,W_ATT>( typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_vol_centroid(vol_centroid)
{ }
void run(Dart d, unsigned int threadID)
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{
m_vol_centroid[d] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(this->m_map, d, m_position, threadID
) ;
}
}
;
vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT,W_ATT>(map, v, position, thr
) ;
}
,nbth,true,AUTO);
}
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 nbth)
{
FunctorComputeCentroidELWVolumes<PFP,V_ATT,W_ATT> funct(map,position,vol_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,VOLUME>(map, funct, nbth, true);
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{
vol_centroid[v] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(map, v, position, thr) ;
},nbth,true,AUTO);
}
template <typename PFP, typename V_ATT>
class FunctorComputeNeighborhoodCentroidVertices: public FunctorMapThreaded<typename PFP::MAP >
{
const V_ATT& m_position;
V_ATT& m_vcentroid;
public:
FunctorComputeNeighborhoodCentroidVertices<PFP,V_ATT>( typename PFP::MAP& map, const V_ATT& position, V_ATT& vcentroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_vcentroid(vcentroid)
{ }
void run(Dart d, unsigned int /*threadID*/)
{
m_vcentroid[d] = vertexNeighborhoodCentroid<PFP,V_ATT>(this->m_map, d, m_position) ;
}
};
template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& vertex_centroid,
unsigned int nbth)
{
FunctorComputeNeighborhoodCentroidVertices<PFP,V_ATT> funct(map,position,vertex_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,VERTEX>(map, funct, nbth, false);
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
vertex_centroid[v] = Volume::Geometry::vertexNeighborhoodCentroid<PFP,V_ATT>(map, v, position,thr) ;
},nbth,true,FORCE_CELL_MARKING);
}
} // namespace Parallel
...
...
include/Algo/Geometry/curvature.hpp
View file @
753c8238
...
...
@@ -602,54 +602,6 @@ void normalCycles_ProjectTensor(Geom::Matrix<3,3,typename PFP::REAL>& tensor, co
namespace Parallel
{
template <typename PFP>
class FunctorComputeCurvatureVertices_NormalCycles: public FunctorMapThreaded<typename PFP::MAP >
{
typedef typename PFP::MAP MAP ;
typedef typename PFP::MAP::IMPL MAP_IMPL ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
REAL m_radius;
const VertexAttribute<VEC3, MAP_IMPL>& m_position;
const VertexAttribute<VEC3, MAP_IMPL>& m_normal;
const EdgeAttribute<REAL, MAP_IMPL>& m_edgeangle;
VertexAttribute<REAL, MAP_IMPL>& m_kmax;
VertexAttribute<REAL, MAP_IMPL>& m_kmin;
VertexAttribute<VEC3, MAP_IMPL>& m_Kmax;
VertexAttribute<VEC3, MAP_IMPL>& m_Kmin;
VertexAttribute<VEC3, MAP_IMPL>& m_Knormal;
public:
FunctorComputeCurvatureVertices_NormalCycles(
MAP& map,
REAL radius,
const VertexAttribute<VEC3, MAP_IMPL>& position,
const VertexAttribute<VEC3, MAP_IMPL>& normal,
const EdgeAttribute<REAL, MAP_IMPL>& edgeangle,
VertexAttribute<REAL, MAP_IMPL>& kmax,
VertexAttribute<REAL, MAP_IMPL>& kmin,
VertexAttribute<VEC3, MAP_IMPL>& Kmax,
VertexAttribute<VEC3, MAP_IMPL>& Kmin,
VertexAttribute<VEC3, MAP_IMPL>& Knormal):
FunctorMapThreaded<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(Knormal)
{ }
void run(Dart d, unsigned int threadID)
{
computeCurvatureVertex_NormalCycles<PFP>(this->m_map, d, m_radius, m_position, m_normal, m_edgeangle, m_kmax, m_kmin, m_Kmax, m_Kmin, m_Knormal, threadID) ;
}
};
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
typename PFP::MAP& map,
...
...
@@ -681,50 +633,13 @@ void computeCurvatureVertices_NormalCycles(
map.template initAllOrbitsEmbedding<FACE>();
}
FunctorComputeCurvatureVertices_NormalCycles<PFP> funct(map, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal);
Algo::Parallel::foreach_cell<typename PFP::MAP,VERTEX>(map, funct, nbth, true);
Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{
computeCurvatureVertex_NormalCycles<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ;
},nbth,true,FORCE_CELL_MARKING);
}
template <typename PFP>
class FunctorComputeCurvatureVertices_QuadraticFitting: public FunctorMapThreaded<typename PFP::MAP >
{
typedef typename PFP::MAP MAP ;
typedef typename PFP::MAP::IMPL MAP_IMPL ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
const VertexAttribute<VEC3, MAP_IMPL>& m_position;
const VertexAttribute<VEC3, MAP_IMPL>& m_normal;
VertexAttribute<REAL, MAP_IMPL>& m_kmax;
VertexAttribute<REAL, MAP_IMPL>& m_kmin;
VertexAttribute<VEC3, MAP_IMPL>& m_Kmax;
VertexAttribute<VEC3, MAP_IMPL>& m_Kmin;
public:
FunctorComputeCurvatureVertices_QuadraticFitting(
MAP& map,
const VertexAttribute<VEC3, MAP_IMPL>& position,
const VertexAttribute<VEC3, MAP_IMPL>& normal,
VertexAttribute<REAL, MAP_IMPL>& kmax,
VertexAttribute<REAL, MAP_IMPL>& kmin,
VertexAttribute<VEC3, MAP_IMPL>& Kmax,
VertexAttribute<VEC3, MAP_IMPL>& Kmin):
FunctorMapThreaded<MAP>(map),
m_position(position),
m_normal(normal),
m_kmax(kmax),
m_kmin(kmin),
m_Kmax(Kmax),
m_Kmin(Kmin)
{ }
void run(Dart d, unsigned int threadID)
{
computeCurvatureVertex_QuadraticFitting<PFP>(this->m_map, d, m_position, m_normal, m_kmax, m_kmin, m_Kmax, m_Kmin) ;
}
};
template <typename PFP>
void computeCurvatureVertices_QuadraticFitting(
typename PFP::MAP& map,
...
...
@@ -736,8 +651,11 @@ void computeCurvatureVertices_QuadraticFitting(
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmin,
unsigned int nbth)
{
FunctorComputeCurvatureVertices_QuadraticFitting<PFP> funct(map, position, normal, kmax, kmin, Kmax, Kmin);
Algo::Parallel::foreach_cell<typename PFP::MAP,VERTEX>(map, funct, nbth, true);
Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{
computeCurvatureVertex_QuadraticFitting<PFP>(map, v, position, normal, kmax, kmin, Kmax, Kmin, threadID) ;
},nbth,true,FORCE_CELL_MARKING);
}
} // namespace Parallel
...
...
include/Algo/Geometry/normal.hpp
View file @
753c8238
...
...
@@ -163,84 +163,6 @@ void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT&
}
namespace Parallel
{
template <typename PFP, typename V_ATT>
class FunctorComputeNormalVertices : public FunctorMapThreaded<typename PFP::MAP>
{
const V_ATT& m_position;
V_ATT& m_normal;
public:
FunctorComputeNormalVertices<PFP,V_ATT>(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_normal(normal)
{ }
void run(Dart d, unsigned int /*threadID*/)
{
m_normal[d] = vertexNormal<PFP>(this->m_map, d, m_position) ;
}
};
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int nbth)
{
FunctorComputeNormalVertices<PFP,V_ATT> funct(map, position, normal);
Algo::Parallel::foreach_cell<typename PFP::MAP, VERTEX>(map, funct, nbth, false);
}
template <typename PFP, typename V_ATT, typename F_ATT>
class FunctorComputeNormalFaces : public FunctorMapThreaded<typename PFP::MAP>
{
const V_ATT& m_position;
F_ATT& m_normal;
public:
FunctorComputeNormalFaces<PFP,V_ATT,F_ATT>(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_normal(normal)
{ }
void run(Dart d, unsigned int /*threadID*/)
{
m_normal[d] = faceNormal<PFP>(this->m_map, d, m_position) ;
}
};
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal, unsigned int nbth)
{
FunctorComputeNormalFaces<PFP,V_ATT,F_ATT> funct(map, position, normal);
Algo::Parallel::foreach_cell<typename PFP::MAP, FACE>(map, funct, nbth, false);
}
template <typename PFP, typename V_ATT, typename E_ATT>
class FunctorComputeAngleBetweenNormalsOnEdge: public FunctorMapThreaded<typename PFP::MAP>
{
const V_ATT& m_position;
E_ATT& m_angles;
public:
FunctorComputeAngleBetweenNormalsOnEdge<PFP,V_ATT,E_ATT>( typename PFP::MAP& map, const V_ATT& position, E_ATT& angles):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_angles(angles)
{ }
void run(Dart d, unsigned int threadID)
{
m_angles[d] = computeAngleBetweenNormalsOnEdge<PFP>(this->m_map, d, m_position) ;
}
};
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles, unsigned int nbth)
{
FunctorComputeAngleBetweenNormalsOnEdge<PFP,V_ATT,E_ATT> funct(map,position,angles);
Algo::Parallel::foreach_cell<typename PFP::MAP,EDGE>(map, funct, nbth, false);
}
} // namespace Parallel
template <typename PFP, typename V_ATT>
typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge e, const V_ATT& position)
{
...
...
@@ -284,6 +206,42 @@ void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& pos
false, thread);
}
namespace Parallel
{
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int nbth)
{
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
},nbth,true,FORCE_CELL_MARKING);
}
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal, unsigned int nbth)
{
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
normal[f] = faceNormal