Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
David Cazier
CGoGN
Commits
7044f2cf
Commit
7044f2cf
authored
Feb 07, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enhancement of ExplodeVolumeRender
parent
090ec7e8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
487 additions
and
223 deletions
+487
-223
include/Algo/Geometry/centroid.h
include/Algo/Geometry/centroid.h
+127
-1
include/Algo/Geometry/centroid.hpp
include/Algo/Geometry/centroid.hpp
+108
-2
include/Algo/Render/GL2/explodeVolumeRender.hpp
include/Algo/Render/GL2/explodeVolumeRender.hpp
+234
-191
include/Geometry/vector_gen.h
include/Geometry/vector_gen.h
+2
-0
include/Geometry/vector_gen.hpp
include/Geometry/vector_gen.hpp
+10
-0
include/Utils/Shaders/shaderExplodeSmoothVolumes.frag
include/Utils/Shaders/shaderExplodeSmoothVolumes.frag
+2
-7
include/Utils/Shaders/shaderExplodeSmoothVolumes.h
include/Utils/Shaders/shaderExplodeSmoothVolumes.h
+1
-5
src/Utils/Shaders/shaderExplodeSmoothVolumes.cpp
src/Utils/Shaders/shaderExplodeSmoothVolumes.cpp
+3
-17
No files found.
include/Algo/Geometry/centroid.h
View file @
7044f2cf
...
@@ -54,6 +54,21 @@ namespace Geometry
...
@@ -54,6 +54,21 @@ namespace Geometry
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
volumeCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
,
unsigned
int
thread
=
0
);
EMB
volumeCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
,
unsigned
int
thread
=
0
);
/**
* Compute volume centroid weighted by edge length (generic version)
* Pre: closed volume & embedded vertices
* Template param:
* PFP: as usual
* EMBV: attributes vector type or cell type (VertexCell, FaceCell, ...)
* EMB: type of attribute (Geom::Vec3f) or cell type (VertexCell, FaceCell, ...)
* @param map the map
* @param d a dart of the face
* @param attributs the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
volumeCentroidELWGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
,
unsigned
int
thread
=
0
);
/**
/**
* Compute volume centroid
* Compute volume centroid
* Pre: closed volume & embedded vertices
* Pre: closed volume & embedded vertices
...
@@ -62,11 +77,25 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs, uns
...
@@ -62,11 +77,25 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs, uns
* @param position the vector of attribute
* @param position the vector of attribute
*/
*/
template
<
typename
PFP
>
template
<
typename
PFP
>
typename
PFP
::
VEC3
volumeCentroid
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
unsigned
int
thread
=
0
)
inline
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
,
thread
);
return
volumeCentroidGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
,
thread
);
}
}
/**
* Compute volume centroid weighted by edge length
* Pre: closed volume & embedded vertices
* @param map the map
* @param d a dart of the face
* @param position the vector of attribute
*/
template
<
typename
PFP
>
inline
typename
PFP
::
VEC3
volumeCentroidELW
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
unsigned
int
thread
=
0
)
{
return
volumeCentroidELWGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
,
thread
);
}
/**
/**
* Compute face centroid (generic version)
* Compute face centroid (generic version)
* Template param:
* Template param:
...
@@ -80,6 +109,19 @@ typename PFP::VEC3 volumeCentroid(typename PFP::MAP& map, Dart d, const VertexAt
...
@@ -80,6 +109,19 @@ typename PFP::VEC3 volumeCentroid(typename PFP::MAP& map, Dart d, const VertexAt
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
faceCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
);
EMB
faceCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
);
/**
* Compute face centroid weighted by edge length (generic version)
* Template param:
* PFP: as usual
* EMBV: attributes vector type or cell type (VertexCell, FaceCell, ...)
* EMB: type of attribute (Geom::Vec3f) or cell type (VertexCell, FaceCell, ...)
* @param map the map
* @param d a dart of the face
* @param attributs the vector of attribute or cell
*/
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
faceCentroidELWGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
);
/**
/**
* Compute face centroid
* Compute face centroid
* Pre: closed face & embedded vertices
* Pre: closed face & embedded vertices
...
@@ -93,6 +135,20 @@ typename PFP::VEC3 faceCentroid(typename PFP::MAP& map, Dart d, const VertexAttr
...
@@ -93,6 +135,20 @@ typename PFP::VEC3 faceCentroid(typename PFP::MAP& map, Dart d, const VertexAttr
return
faceCentroidGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
);
return
faceCentroidGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
);
}
}
/**
* Compute face centroid weighted by edge length
* Pre: closed face & embedded vertices
* @param map the map
* @param d a dart of the face
* @param position the vector of attribute
*/
template
<
typename
PFP
>
typename
PFP
::
VEC3
faceCentroidELW
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
{
return
faceCentroidELWGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
);
}
/**
/**
* Compute vertex neighbours centroid (generic version)
* Compute vertex neighbours centroid (generic version)
* Template param:
* Template param:
...
@@ -118,11 +174,41 @@ typename PFP::VEC3 vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, co
...
@@ -118,11 +174,41 @@ typename PFP::VEC3 vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, co
return
vertexNeighborhoodCentroidGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
);
return
vertexNeighborhoodCentroidGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
position
);
}
}
/**
* Compute centroid of all faces
* @param map the map
* @param position position vertex attribute
* @param face_centroid centroid face attribute
* @param select the selector
* @param thread the thread id (default 0)
*/
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
/**
* Compute centroid of all faces (Edge Length Weighted)
* @param map the map
* @param position position vertex attribute
* @param face_centroid centroid face attribute
* @param select the selector
* @param thread the thread id (default 0)
*/
template
<
typename
PFP
>
void
computeCentroidELWFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
/**
* Compute neighborhood centroid of all vertices
* @param map the map
* @param position position vertex attribute
* @param vertex_centroid centroid vertex attribute
* @param select the selector
* @param thread the thread id (default 0)
*/
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
...
@@ -131,11 +217,40 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
...
@@ -131,11 +217,40 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
namespace
Parallel
namespace
Parallel
{
{
/**
* Compute centroid of all faces
* @param map the map
* @param position position vertex attribute
* @param face_centroid centroid face attribute
* @param select the selector
* @param nbth the number of threads
*/
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
/**
* Compute centroid of all faces (Edge Length Weighted)
* @param map the map
* @param position position vertex attribute
* @param face_centroid centroid face attribute
* @param select the selector
* @param nbth the number of threads
*/
template
<
typename
PFP
>
void
computeCentroidELWFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
VEC3
>&
face_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
/**
* Compute neighborhood centroid of all vertices (in parallel)
* @param map the map
* @param position position vertex attribute
* @param vertex_centroid centroid vertex attribute
* @param select the selector
* @param nbth the number of threads
*/
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
...
@@ -185,6 +300,11 @@ void computeCentroidVolumes(typename PFP::MAP& map,
...
@@ -185,6 +300,11 @@ void computeCentroidVolumes(typename PFP::MAP& map,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeCentroidELWVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
/**
/**
* compute centroid of all vertices
* compute centroid of all vertices
* @param map the map
* @param map the map
...
@@ -206,6 +326,12 @@ void computeCentroidVolumes(typename PFP::MAP& map,
...
@@ -206,6 +326,12 @@ void computeCentroidVolumes(typename PFP::MAP& map,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
template
<
typename
PFP
>
void
computeCentroidELWVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
nbth
=
0
)
;
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
...
...
include/Algo/Geometry/centroid.hpp
View file @
7044f2cf
...
@@ -59,6 +59,25 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs, uns
...
@@ -59,6 +59,25 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs, uns
return
center
;
return
center
;
}
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
volumeCentroidELWGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
,
unsigned
int
thread
)
{
EMB
center
=
AttribOps
::
zero
<
EMB
,
PFP
>
();
double
count
=
0.0
;
Traversor3WE
<
typename
PFP
::
MAP
>
t
(
map
,
d
,
false
,
thread
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
{
EMB
e1
=
attributs
[
it
];
EMB
e2
=
attributs
[
map
.
phi1
(
it
)];
double
l
=
(
e2
-
e1
).
norm
();
center
+=
(
e1
+
e2
)
*
l
;
count
+=
2.0
*
l
;
}
center
/=
double
(
count
);
return
center
;
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
faceCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
)
EMB
faceCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
)
{
{
...
@@ -74,6 +93,26 @@ EMB faceCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs)
...
@@ -74,6 +93,26 @@ EMB faceCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs)
return
center
;
return
center
;
}
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
faceCentroidELWGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
)
{
EMB
center
=
AttribOps
::
zero
<
EMB
,
PFP
>
();
double
count
=
0.0
;
Traversor2FE
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
{
EMB
e1
=
attributs
[
it
];
EMB
e2
=
attributs
[
map
.
phi1
(
it
)];
double
l
=
(
e2
-
e1
).
norm
();
center
+=
(
e1
+
e2
)
*
l
;
count
+=
2.0
*
l
;
}
center
/=
double
(
count
);
return
center
;
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
vertexNeighborhoodCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
)
EMB
vertexNeighborhoodCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
)
{
{
...
@@ -98,6 +137,14 @@ void computeCentroidFaces(typename PFP::MAP& map, const VertexAttribute<typename
...
@@ -98,6 +137,14 @@ void computeCentroidFaces(typename PFP::MAP& map, const VertexAttribute<typename
face_centroid
[
d
]
=
faceCentroid
<
PFP
>
(
map
,
d
,
position
)
;
face_centroid
[
d
]
=
faceCentroid
<
PFP
>
(
map
,
d
,
position
)
;
}
}
template
<
typename
PFP
>
void
computeCentroidELWFaces
(
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
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
face_centroid
[
d
]
=
faceCentroidELW
<
PFP
>
(
map
,
d
,
position
)
;
}
template
<
typename
PFP
>
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
thread
)
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
{
...
@@ -127,6 +174,23 @@ public:
...
@@ -127,6 +174,23 @@ public:
}
}
};
};
template
<
typename
PFP
>
class
FunctorComputeCentroidELWFaces
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
FaceAttribute
<
typename
PFP
::
VEC3
>&
m_fcentroid
;
public:
FunctorComputeCentroidELWFaces
<
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
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_fcentroid
[
d
]
=
faceCentroidELW
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
void
computeCentroidFaces
(
typename
PFP
::
MAP
&
map
,
...
@@ -137,6 +201,15 @@ void computeCentroidFaces(typename PFP::MAP& map,
...
@@ -137,6 +201,15 @@ void computeCentroidFaces(typename PFP::MAP& map,
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
}
}
template
<
typename
PFP
>
void
computeCentroidELWFaces
(
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
)
{
FunctorComputeCentroidELWFaces
<
PFP
>
funct
(
map
,
position
,
face_centroid
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
}
template
<
typename
PFP
>
template
<
typename
PFP
>
class
FunctorComputeNeighborhoodCentroidVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
class
FunctorComputeNeighborhoodCentroidVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
...
@@ -195,6 +268,15 @@ void computeCentroidVolumes(typename PFP::MAP& map, const VertexAttribute<typena
...
@@ -195,6 +268,15 @@ void computeCentroidVolumes(typename PFP::MAP& map, const VertexAttribute<typena
vol_centroid
[
d
]
=
Surface
::
Geometry
::
volumeCentroid
<
PFP
>
(
map
,
d
,
position
,
thread
)
;
vol_centroid
[
d
]
=
Surface
::
Geometry
::
volumeCentroid
<
PFP
>
(
map
,
d
,
position
,
thread
)
;
}
}
template
<
typename
PFP
>
void
computeCentroidELWVolumes
(
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
,
thread
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
vol_centroid
[
d
]
=
Surface
::
Geometry
::
volumeCentroidELW
<
PFP
>
(
map
,
d
,
position
,
thread
)
;
}
namespace
Parallel
namespace
Parallel
{
{
template
<
typename
PFP
>
template
<
typename
PFP
>
...
@@ -213,6 +295,22 @@ public:
...
@@ -213,6 +295,22 @@ public:
}
}
};
};
template
<
typename
PFP
>
class
FunctorComputeCentroidELWVolumes
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
VolumeAttribute
<
typename
PFP
::
VEC3
>&
m_vol_centroid
;
public:
FunctorComputeCentroidELWVolumes
<
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
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_vol_centroid
[
d
]
=
Surface
::
Geometry
::
volumeCentroidELW
<
PFP
>
(
this
->
m_map
,
d
,
m_position
,
threadID
)
;
}
};
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
void
computeCentroidVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
...
@@ -223,6 +321,16 @@ void computeCentroidVolumes(typename PFP::MAP& map,
...
@@ -223,6 +321,16 @@ void computeCentroidVolumes(typename PFP::MAP& map,
}
}
template
<
typename
PFP
>
void
computeCentroidELWVolumes
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VolumeAttribute
<
typename
PFP
::
VEC3
>&
vol_centroid
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
)
{
FunctorComputeCentroidELWVolumes
<
PFP
>
funct
(
map
,
position
,
vol_centroid
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VOLUME
>
(
map
,
funct
,
nbth
,
true
,
select
);
}
template
<
typename
PFP
>
template
<
typename
PFP
>
class
FunctorComputeNeighborhoodCentroidVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
class
FunctorComputeNeighborhoodCentroidVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
{
...
@@ -256,8 +364,6 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
...
@@ -256,8 +364,6 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
}
// namespace Algo
}
// namespace Algo
}
// namespace CGoGN
}
// namespace CGoGN
include/Algo/Render/GL2/explodeVolumeRender.hpp
View file @
7044f2cf
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "Topology/generic/cellmarker.h"
#include "Topology/generic/cellmarker.h"
#include "Algo/Geometry/centroid.h"
#include "Algo/Geometry/centroid.h"
#include "Topology/generic/autoAttributeHandler.h"
#include "Topology/generic/autoAttributeHandler.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Geometry/basic.h"
#include "Algo/Geometry/basic.h"
namespace
CGoGN
namespace
CGoGN
...
@@ -99,7 +99,7 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
...
@@ -99,7 +99,7 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
REAL
REAL
;
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
map
,
"centerVolumes"
);
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
map
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidVolumes
<
PFP
>
(
map
,
positions
,
centerVolumes
,
good
);
Algo
::
Volume
::
Geometry
::
computeCentroid
ELW
Volumes
<
PFP
>
(
map
,
positions
,
centerVolumes
,
good
);
std
::
vector
<
VEC3
>
buffer
;
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
buffer
.
reserve
(
16384
);
...
@@ -108,120 +108,145 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
...
@@ -108,120 +108,145 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
bufferColors
.
reserve
(
16384
);
bufferColors
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferNormals
;
std
::
vector
<
VEC3
>
bufferNormals
;
bufferNormals
.
reserve
(
16384
);
bufferNormals
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
normals
;
std
::
vector
<
VEC3
>
normals
;
bufferNormals
.
reserve
(
20
);
bufferNormals
.
reserve
(
20
);
std
::
vector
<
VEC3
>
vertices
;
bufferNormals
.
reserve
(
20
);
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
FACE_OF_PARENT
>
traFace
(
map
,
good
);
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
FACE_OF_PARENT
>
traFace
(
map
,
good
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
{
// compute normals
// compute normals
normals
.
clear
();
normals
.
clear
();
VEC3
centerFace
(
0
);
vertices
.
clear
();
unsigned
int
nbs
=
0
;
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
Dart
a
=
d
;
do
do
{
{
VEC3
v1
=
Algo
::
Surface
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
a
,
positions
);
VEC3
v1
=
positions
[
a
]
-
centerFace
;
v1
.
normalize
();
Dart
e
=
map
.
phi1
(
a
);
Dart
e
=
map
.
phi1
(
a
);
VEC3
v2
=
Algo
::
Surface
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
e
,
positions
);
VEC3
v2
=
positions
[
map
.
phi1
(
e
)]
-
centerFace
;
v2
.
normalize
();
VEC3
N
=
v1
^
v2
;
VEC3
N
=
v1
^
v2
;
double
l
=
N
.
norm
();
double
l
=
N
.
norm
();
if
(
l
>
0.000001
)
if
(
l
<
0.01
)
{
N
=
centerNormalFace
;
N
/=
l
;
normals
.
push_back
(
N
);
}
else
else
{
{
normals
.
push_back
(
VEC3
(
9
,
9
,
9
));
N
/=
l
;
if
(
N
*
centerNormalFace
<
0.707
)
N
=
centerNormalFace
;
}
}
centerFace
+=
positions
[
a
];
normals
.
push_back
(
N
);
vertices
.
push_back
(
positions
[
e
]);
// VEC3 v1 = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map,a,positions);
// Dart e = map.phi1(a);
// VEC3 v2 = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map,e,positions);
// v1.normalize();
// v2.normalize();
// VEC3 N = v1^v2;
// double l = N.norm();
// double ll = fabs(N*centerNormalFace());
// if ((l<0.2) && l<0
// if (l<0.3)
// {
// N = centerNormalFace;
// }
// else
// {
// if (N*centerNormalFace < 0.0)
// N /= -l;
// else
// N /= l;
// }
// if ((l < 0.5) || (N*centerNormalFace < 0.0))
// {
// N = centerNormalFace;
// }
// if (N*centerNormalFace < 0.0)
// {
// std::cout << "INVERTED" <<std::endl;
// N =-N;
// }
// N.normalize();
// normals.push_back(N);
// }
// normals.push_back(N);
// vertices.push_back(positions[e]);
//centerFace += positions[e];