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
fd2e0512
Commit
fd2e0512
authored
Aug 22, 2012
by
Sylvain Thery
Browse files
rename parallelDo in run (as in QThread)
add parallel version of ray selection
parent
9e73639a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto_mt.cpp
View file @
fd2e0512
...
...
@@ -171,7 +171,7 @@ public:
FunctorAttribThreaded
(),
m_positions
(
pos
),
m_positions2
(
pos2
)
{}
void
parallelDo
(
unsigned
int
i
,
unsigned
int
threadID
)
void
run
(
unsigned
int
i
,
unsigned
int
threadID
)
{
m_positions2
[
i
]
=
1.1
f
*
m_positions
[
i
];
}
...
...
@@ -207,7 +207,7 @@ public:
m_positions
(
pos
),
m_positions2
(
pos2
)
{}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
typename
XXX
::
VEC3
Q
(
0
,
0
,
0
);
int
nb
=
0
;
...
...
@@ -258,7 +258,7 @@ public:
unsigned
int
getNb
()
{
return
m_nb
;}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
Dart
dd
=
this
->
m_map
.
phi2
(
d
);
typename
XXX
::
VEC3
V
=
m_positions
[
dd
]
-
m_positions
[
d
];
...
...
@@ -281,19 +281,9 @@ void MyQT::threadStorage()
functs
.
push_back
(
lef
);
}
// LengthEdgeFunctor<PFP>* lef0 = new LengthEdgeFunctor<PFP>(myMap,position);
// LengthEdgeFunctor<PFP>* lef1 = new LengthEdgeFunctor<PFP>(myMap,position);
// LengthEdgeFunctor<PFP>* lef2 = new LengthEdgeFunctor<PFP>(myMap,position);
// LengthEdgeFunctor<PFP>* lef3 = new LengthEdgeFunctor<PFP>(myMap,position);
// functs.push_back(lef0);
// functs.push_back(lef1);
// functs.push_back(lef2);
// functs.push_back(lef3);
Algo
::
Parallel
::
foreach_cell
<
PFP
::
MAP
,
EDGE
>
(
myMap
,
functs
,
4
);
//compute average length from each thread result and delete functors
double
average
=
0
;
unsigned
int
all
=
0
;
...
...
@@ -306,21 +296,11 @@ void MyQT::threadStorage()
}
average
/=
all
;
// double average = (lef0->getLength()+lef1->getLength()+lef2->getLength()+lef3->getLength()) / (lef0->getNb()+lef1->getNb()+lef2->getNb()+lef3->getNb());
std
::
cout
<<
"AVERAGE LENGTH "
<<
average
<<
std
::
endl
;
// delete lef0;
// delete lef1;
// delete lef2;
// delete lef3;
}
int
main
(
int
argc
,
char
**
argv
)
{
// interface:
...
...
include/Algo/Geometry/centroid.hpp
View file @
fd2e0512
...
...
@@ -124,7 +124,7 @@ public:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_vol_centroid
(
vol_centroid
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_vol_centroid
[
d
]
=
volumeCentroid
<
PFP
>
(
this
->
m_map
,
d
,
m_position
,
threadID
)
;
}
...
...
@@ -151,7 +151,7 @@ public:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_fcentroid
(
fcentroid
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_fcentroid
[
d
]
=
faceCentroid
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
...
...
@@ -178,7 +178,7 @@ public:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_vcentroid
(
vcentroid
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_vcentroid
[
d
]
=
vertexNeighborhoodCentroid
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
...
...
include/Algo/Geometry/curvature.hpp
View file @
fd2e0512
...
...
@@ -418,7 +418,7 @@ public:
m_Knormal
(
normal
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
computeCurvatureVertex_NormalCycles
<
PFP
>
(
map
,
d
,
radius
,
position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
,
threadID
)
;
}
...
...
include/Algo/Geometry/normal.hpp
View file @
fd2e0512
...
...
@@ -180,7 +180,7 @@ public:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_normal
(
normal
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_normal
[
d
]
=
vertexNormal
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
...
...
@@ -204,7 +204,7 @@ public:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_normal
(
normal
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_normal
[
d
]
=
faceNormal
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
...
...
include/Algo/Geometry/volume.hpp
View file @
fd2e0512
...
...
@@ -138,7 +138,7 @@ public:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_vol
(
0.0
)
{
}
void
parallelDo
(
Dart
d
,
unsigned
int
threadID
)
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_vol
+=
convexPolyhedronVolume
<
PFP
>
(
this
->
m_map
,
d
,
m_position
,
threadID
)
;
}
...
...
include/Algo/Parallel/parallel_foreach.hpp
View file @
fd2e0512
...
...
@@ -58,7 +58,7 @@ public:
while
(
!
m_finished
)
{
for
(
std
::
vector
<
unsigned
int
>::
const_iterator
it
=
m_ids
.
begin
();
it
!=
m_ids
.
end
();
++
it
)
m_functor
->
parallelDo
(
*
it
,
m_id
);
m_functor
->
run
(
*
it
,
m_id
);
m_sync1
.
wait
();
m_sync2
.
wait
();
}
...
...
@@ -95,7 +95,7 @@ public:
while
(
!
m_finished
)
{
for
(
std
::
vector
<
Dart
>::
const_iterator
it
=
m_darts
.
begin
();
it
!=
m_darts
.
end
();
++
it
)
m_functor
->
parallelDo
(
*
it
,
m_id
);
m_functor
->
run
(
*
it
,
m_id
);
m_sync1
.
wait
();
m_sync2
.
wait
();
}
...
...
include/Algo/Selection/raySelectFunctor.hpp
View file @
fd2e0512
...
...
@@ -221,147 +221,8 @@ public:
}
};
/**
* Order relation between Darts with respect to the depth of
* their 0-embedding
*
* Used in a std::sort algorithm
*/
//template <typename PFP>
//class DartDepthOrdering
//{
// typedef typename PFP::MAP MAP;
//// typedef typename PFP::EMB EMB;
//
//
//protected:
// MAP& m_map;
// const typename PFP::VEC3& m_A;
// VertexAttribute<typename PFP::VEC3>& m_positions;
//public:
// DartDepthOrdering(MAP& map, unsigned int idPos, const typename PFP::VEC3& A):
// m_map(map), m_A(A), m_positions(idPos,map) {}
//
// bool operator()(const Dart& d, const Dart& e)
// {
// typename PFP::VEC3 P = m_positions[d]; //m_map.getVertexEmb(d)->getPosition();
// P -= m_A;
// typename PFP::REAL ld = P*P;// l^2
//
// P = m_positions[e]; //m_map.getVertexEmb(e)->getPosition();
// P -= m_A;
// typename PFP::REAL le = P*P;// l^2
//
// if (ld < le)
// return true;
// return false;
// }
//};
/**
* Order relation between Darts with respect to the distance of
* their 0-embedding to the line given in parameter in the constructor
*
* Used in a std::sort algorithm
*/
//template <typename PFP>
//class DartRayDistanceOrdering
//{
// typedef typename PFP::MAP MAP ;
//// typedef typename PFP::EMB EMB ;
//
//
//protected:
// MAP& m_map ;
// const typename PFP::VEC3& m_A ;
// const typename PFP::VEC3& m_AB ;
// float m_AB2 ;
// VertexAttribute<typename PFP::VEC3>& m_positions;
//
//public:
// DartRayDistanceOrdering(MAP& map, unsigned int idPos, const typename PFP::VEC3& A, const typename PFP::VEC3& AB) :
// m_map(map), m_A(A), m_AB(AB), m_positions(idPos,map)
// {
// m_AB2 = m_AB*m_AB ; // l^2
// }
//
// bool operator()(const Dart& d, const Dart& e)
// {
// typename PFP::VEC3 P = m_positions[d]; //m_map.getVertexEmb(d)->getPosition() ;
// float ld = Geom::squaredDistanceLine2Point(m_A, m_AB, m_AB2, P) ;
// P = m_positions[e]; //m_map.getVertexEmb(e)->getPosition() ;
// float le = Geom::squaredDistanceLine2Point(m_A, m_AB, m_AB2, P) ;
//
// if (ld < le)
// return true;
// return false;
// }
//};
/**
* Order relation between Darts with respect to the depth
* of their faces :
* f1 < f2 if f1 contains the vertex whose 0-embedding is the closest
*
* Used in a std::sort algorithm
*/
//template <typename PFP>
//class FaceDepthOrdering
//{
// typedef typename PFP::MAP MAP ;
//
//
//protected:
// MAP& m_map ;
// const typename PFP::VEC3& m_A ;
// VertexAttribute<typename PFP::VEC3>& m_positions;
// std::vector<Dart>& m_faces;
//
//public:
// FaceDepthOrdering(MAP& map, unsigned int idPos, const typename PFP::VEC3& A, std::vector<Dart>& faces) : m_map(map), m_A(A), m_positions(idPos,map), m_faces(faces) {}
//
//// bool operator()(const Dart& d, const Dart& e)
// bool operator()(Dart d, Dart e)
// {
// for (typename std::vector<Dart>::iterator it = m_faces.begin(); it != m_faces.end(); ++it)
// {
// CGoGNout << "Dart: "<< (it - m_faces.begin()) <<" = " << (*it)->getLabel()<<CGoGNendl;
// }
//
// CGoGNout << "beg sort op:"<<CGoGNendl;
// CGoGNout <<" darts "<<d->getLabel() <<" ?? "<< e->getLabel()<<CGoGNendl;
// typename PFP::VEC3 P = m_positions[d]; //m_map.getVertexEmb(d)->getPosition() ;
// P -= m_A ;
// typename PFP::REAL minDist = P*P ;
// Dart closestD = d ;
// Dart it = d ;
// do
// {
// P = m_positions[it]; //m_map.getVertexEmb(it)->getPosition() ; // compute the minimum
// P -= m_A ; // distance among the vertices
// typename PFP::REAL dist = P*P ; // of the face of d
// if(dist < minDist)
// minDist = dist ;
// it = m_map.phi1(it) ;
// } while(it != d) ;
// it = e ;
// do
// {
// P = m_positions[it]; //m_map.getVertexEmb(it)->getPosition() ; // if one vertex of the face
// P -= m_A ; // of e is closer than the previous
// typename PFP::REAL dist = P*P ; // minimum, then e < d
// if(dist < minDist) // else, d < e
// return false ;
// it = m_map.phi1(it) ;
// } while(it != e) ;
//
// CGoGNout << "end sort op"<<CGoGNendl;
//
//// return rand()&1;
//
// return true ;
// }
//} ;
template
<
typename
PFP
>
bool
distndartOrdering
(
const
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>&
e1
,
const
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>&
e2
)
...
...
@@ -375,6 +236,148 @@ bool distnintOrdering(const std::pair<typename PFP::REAL, unsigned int>& e1, con
return
(
e1
.
first
<
e2
.
first
);
}
namespace
Parallel
{
template
<
typename
PFP
>
class
FuncVertexInter
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
typedef
typename
PFP
::
MAP
MAP
;
protected:
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_positions
;
const
typename
PFP
::
VEC3
&
m_A
;
const
typename
PFP
::
VEC3
&
m_AB
;
float
m_AB2
;
float
m_distMax
;
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>
m_vd
;
public:
FuncVertexInter
(
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
typename
PFP
::
VEC3
&
A
,
const
typename
PFP
::
VEC3
&
AB
,
typename
PFP
::
REAL
AB2
,
typename
PFP
::
REAL
dm2
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_positions
(
position
),
m_A
(
A
),
m_AB
(
AB
),
m_AB2
(
AB2
),
m_distMax
(
dm2
)
{}
void
run
(
Dart
d
,
unsigned
int
thread
)
{
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
float
dist
=
Geom
::
squaredDistanceLine2Point
(
m_A
,
m_AB
,
m_AB2
,
P
);
if
(
dist
<
m_distMax
)
{
typename
PFP
::
REAL
distA
=
(
P
-
m_A
).
norm2
();
m_vd
.
push_back
(
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
(
distA
,
d
));
}
}
const
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>&
getVertexDistances
()
{
return
m_vd
;}
};
template
<
typename
PFP
>
class
FuncEdgeInter
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
typedef
typename
PFP
::
MAP
MAP
;
protected:
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_positions
;
const
typename
PFP
::
VEC3
&
m_A
;
const
typename
PFP
::
VEC3
&
m_AB
;
float
m_AB2
;
float
m_distMax
;
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>
m_ed
;
public:
FuncEdgeInter
(
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
typename
PFP
::
VEC3
&
A
,
const
typename
PFP
::
VEC3
&
AB
,
typename
PFP
::
REAL
AB2
,
typename
PFP
::
REAL
dm2
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_positions
(
position
),
m_A
(
A
),
m_AB
(
AB
),
m_AB2
(
AB2
),
m_distMax
(
dm2
)
{}
void
run
(
Dart
d
,
unsigned
int
thread
)
{
// get back position of segment PQ
const
typename
PFP
::
VEC3
&
P
=
m_positions
[
d
];
Dart
dd
=
this
->
m_map
.
phi1
(
d
);
const
typename
PFP
::
VEC3
&
Q
=
m_positions
[
dd
];
// the three distance to P, Q and (PQ) not used here
float
dist
=
Geom
::
squaredDistanceLine2Seg
(
m_A
,
m_AB
,
m_AB2
,
P
,
Q
);
if
(
dist
<
m_distMax
)
{
typename
PFP
::
VEC3
M
=
(
P
+
Q
)
/
2.0
;
typename
PFP
::
REAL
distA
=
(
M
-
m_A
).
norm2
();
m_ed
.
push_back
(
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
(
distA
,
d
));
}
}
const
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>&
getEdgeDistances
()
{
return
m_ed
;}
};
template
<
typename
PFP
>
class
FuncFaceInter
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
typedef
typename
PFP
::
MAP
MAP
;
protected:
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_positions
;
const
typename
PFP
::
VEC3
&
m_A
;
const
typename
PFP
::
VEC3
&
m_AB
;
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>
m_fd
;
public:
FuncFaceInter
(
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
typename
PFP
::
VEC3
&
A
,
const
typename
PFP
::
VEC3
&
AB
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_positions
(
position
),
m_A
(
A
),
m_AB
(
AB
)
{}
void
run
(
Dart
d
,
unsigned
int
thread
)
{
const
typename
PFP
::
VEC3
&
Ta
=
m_positions
[
d
];
Dart
dd
=
this
->
m_map
.
phi1
(
d
);
Dart
ddd
=
this
->
m_map
.
phi1
(
dd
);
bool
notfound
=
true
;
do
{
// get back position of triangle Ta,Tb,Tc
const
typename
PFP
::
VEC3
&
Tb
=
m_positions
[
dd
];
const
typename
PFP
::
VEC3
&
Tc
=
m_positions
[
ddd
];
typename
PFP
::
VEC3
I
;
if
(
Geom
::
intersectionRayTriangleOpt
<
typename
PFP
::
VEC3
>
(
m_A
,
m_AB
,
Ta
,
Tb
,
Tc
,
I
))
{
typename
PFP
::
REAL
dist
=
(
I
-
m_A
).
norm2
();
m_fd
.
push_back
(
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
(
dist
,
d
));
notfound
=
false
;
}
// next triangle if we are in polygon
dd
=
ddd
;
ddd
=
this
->
m_map
.
phi1
(
dd
);
}
while
((
ddd
!=
d
)
&&
notfound
);
}
const
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>&
getFaceDistances
()
{
return
m_fd
;}
};
}
}
//namespace Selection
}
//namespace Algo
...
...
include/Algo/Selection/raySelector.h
View file @
fd2e0512
...
...
@@ -28,6 +28,7 @@
#include
<algorithm>
#include
<vector>
#include
"Algo/Selection/raySelectFunctor.hpp"
#include
"Algo/Parallel/parallel_foreach.h"
namespace
CGoGN
{
...
...
@@ -165,6 +166,133 @@ void verticesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename
vecVertices
[
i
]
=
distndart
[
i
].
second
;
}
namespace
Parallel
{
template
<
typename
PFP
>
void
facesRaySelection
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
good
,
const
typename
PFP
::
VEC3
&
rayA
,
const
typename
PFP
::
VEC3
&
rayAB
,
std
::
vector
<
Dart
>&
vecFaces
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
{
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
Parallel
::
FuncFaceInter
<
PFP
>
(
map
,
position
,
rayA
,
rayAB
));
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
functs
,
nbth
,
false
,
good
,
current_thread
);
// compute total nb of intersection
unsigned
int
nbtot
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
nbtot
+=
static_cast
<
Parallel
::
FuncFaceInter
<
PFP
>*>
(
functs
[
i
])
->
getFaceDistances
().
size
();
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>
distndart
;
distndart
.
reserve
(
nbtot
);
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
distndart
.
insert
(
distndart
.
end
(),
static_cast
<
Parallel
::
FuncFaceInter
<
PFP
>*>
(
functs
[
i
])
->
getFaceDistances
().
begin
(),
static_cast
<
Parallel
::
FuncFaceInter
<
PFP
>*>
(
functs
[
i
])
->
getFaceDistances
().
end
()
);
delete
functs
[
i
];
}
// sort the vector of pair dist/dart
std
::
sort
(
distndart
.
begin
(),
distndart
.
end
(),
distndartOrdering
<
PFP
>
);
vecFaces
.
clear
();
vecFaces
.
reserve
(
nbtot
);
// store sorted darts in returned vector
for
(
unsigned
int
i
=
0
;
i
<
nbtot
;
++
i
)
vecFaces
.
push_back
(
distndart
[
i
].
second
);
}
template
<
typename
PFP
>
void
edgesRaySelection
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
FunctorSelect
&
good
,
const
typename
PFP
::
VEC3
&
rayA
,
const
typename
PFP
::
VEC3
&
rayAB
,
std
::
vector
<
Dart
>&
vecEdges
,
float
dist
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
{
typename
PFP
::
REAL
dist2
=
dist
*
dist
;
typename
PFP
::
REAL
AB2
=
rayAB
*
rayAB
;
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
Parallel
::
FuncEdgeInter
<
PFP
>
(
map
,
position
,
rayA
,
rayAB
,
AB2
,
dist2
));
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
EDGE
>
(
map
,
functs
,
nbth
,
false
,
good
,
current_thread
);
// compute total nb of intersection
unsigned
int
nbtot
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
nbtot
+=
static_cast
<
Parallel
::
FuncEdgeInter
<
PFP
>*>
(
functs
[
i
])
->
getEdgeDistances
().
size
();
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>
distndart
;
distndart
.
reserve
(
nbtot
);
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
distndart
.
insert
(
distndart
.
end
(),
static_cast
<
Parallel
::
FuncEdgeInter
<
PFP
>*>
(
functs
[
i
])
->
getEdgeDistances
().
begin
(),
static_cast
<
Parallel
::
FuncEdgeInter
<
PFP
>*>
(
functs
[
i
])
->
getEdgeDistances
().
end
()
);
delete
functs
[
i
];
}
// sort the vector of pair dist/dart
std
::
sort
(
distndart
.
begin
(),
distndart
.
end
(),
distndartOrdering
<
PFP
>
);
// store sorted darts in returned vector
vecEdges
.
clear
();
vecEdges
.
reserve
(
nbtot
);
for
(
unsigned
int
i
=
0
;
i
<
nbtot
;
++
i
)
vecEdges
.
push_back
(
distndart
[
i
].
second
);
}
template
<
typename
PFP
>
void
verticesRaySelection
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
typename
PFP
::
VEC3
&
rayA
,
const
typename
PFP
::
VEC3
&
rayAB
,
std
::
vector
<
Dart
>&
vecVertices
,
float
dist
,
const
FunctorSelect
&
good
=
allDarts
,
unsigned
int
nbth
=
0
,
unsigned
int
current_thread
=
0
)
{
typename
PFP
::
REAL
dist2
=
dist
*
dist
;
typename
PFP
::
REAL
AB2
=
rayAB
*
rayAB
;
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
Parallel
::
FuncVertexInter
<
PFP
>
(
map
,
position
,
rayA
,
rayAB
,
AB2
,
dist2
));
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
functs
,
nbth
,
false
,
good
,
current_thread
);
// compute total nb of intersection
unsigned
int
nbtot
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
nbtot
+=
static_cast
<
Parallel
::
FuncVertexInter
<
PFP
>*>
(
functs
[
i
])
->
getVertexDistances
().
size
();
std
::
vector
<
std
::
pair
<
typename
PFP
::
REAL
,
Dart
>
>
distndart
;
distndart
.
reserve
(
nbtot
);
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
distndart
.
insert
(
distndart
.
end
(),
static_cast
<
Parallel
::
FuncVertexInter
<
PFP
>*>
(
functs
[
i
])
->
getVertexDistances
().
begin
(),
static_cast
<
Parallel
::
FuncVertexInter
<
PFP
>*>
(
functs
[
i
])
->
getVertexDistances
().
end
()
);
delete
functs
[
i
];
}
// sort the vector of pair dist/dart
std
::
sort
(
distndart
.
begin
(),
distndart
.
end
(),
distndartOrdering
<
PFP
>
);
// store sorted darts in returned vector
vecVertices
.
clear
();
vecVertices
.
reserve
(
nbtot
);
for
(
unsigned
int
i
=
0
;
i
<
nbtot
;
++
i
)
vecVertices
.
push_back
(
distndart
[
i
].
second
);
}
}
/**
* Function that does the selection of one vertex
* @param map the map we want to test
...
...
include/Topology/generic/functor.h
View file @
fd2e0512
...
...
@@ -439,7 +439,7 @@ public:
/**
* Functor class for parallel::foreach_orbit/cell/dart
* Overload
bool parallelDo
* Overload
run
* Overload duplicate if necessary (no sharing of functors)
*/
template
<
typename
MAP
>
...
...
@@ -463,13 +463,13 @@ public:
* @param d the dart on which apply functor