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
Thomas Pitiot
CGoGN
Commits
726113c5
Commit
726113c5
authored
Feb 07, 2013
by
untereiner
Browse files
Merge cgogn:~thery/CGoGN
Conflicts: include/Algo/Render/GL2/explodeVolumeRender.hpp
parents
201807e9
6c3080c2
Changes
10
Hide whitespace changes
Inline
Side-by-side
include/Algo/Geometry/centroid.h
View file @
726113c5
...
...
@@ -54,6 +54,21 @@ namespace Geometry
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
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
* Pre: closed volume & embedded vertices
...
...
@@ -62,11 +77,25 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs, uns
* @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
,
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
);
}
/**
* 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)
* Template param:
...
...
@@ -80,6 +109,19 @@ typename PFP::VEC3 volumeCentroid(typename PFP::MAP& map, Dart d, const VertexAt
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
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
* Pre: closed face & embedded vertices
...
...
@@ -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
);
}
/**
* 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)
* Template param:
...
...
@@ -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
);
}
/**
* 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
>
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
)
;
/**
* 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
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
...
...
@@ -131,11 +217,40 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
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
>
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
)
;
/**
* 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
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
...
...
@@ -185,6 +300,11 @@ 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
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
* @param map the map
...
...
@@ -206,6 +326,12 @@ 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
)
;
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
>
void
computeNeighborhoodCentroidVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
vertex_centroid
,
...
...
include/Algo/Geometry/centroid.hpp
View file @
726113c5
...
...
@@ -59,6 +59,25 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs, uns
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
>
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
;
}
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
>
EMB
vertexNeighborhoodCentroidGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
attributs
)
{
...
...
@@ -98,6 +137,14 @@ void computeCentroidFaces(typename PFP::MAP& map, const VertexAttribute<typename
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
>
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:
}
};
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
>
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
);
}
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
>
class
FunctorComputeNeighborhoodCentroidVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
...
...
@@ -195,6 +268,15 @@ void computeCentroidVolumes(typename PFP::MAP& map, const VertexAttribute<typena
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
{
template
<
typename
PFP
>
...
...
@@ -212,6 +294,22 @@ public:
m_vol_centroid
[
d
]
=
Surface
::
Geometry
::
volumeCentroid
<
PFP
>
(
this
->
m_map
,
d
,
m_position
,
threadID
)
;
}
};
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
>
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
>
class
FunctorComputeNeighborhoodCentroidVertices
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
...
...
@@ -256,8 +364,6 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
}
// namespace Algo
}
// namespace CGoGN
include/Algo/Render/GL2/explodeVolumeRender.hpp
View file @
726113c5
...
...
@@ -28,7 +28,7 @@
#include
"Topology/generic/cellmarker.h"
#include
"Algo/Geometry/centroid.h"
#include
"Topology/generic/autoAttributeHandler.h"
#include
"Algo/Geometry/normal.h"
#include
"Algo/Geometry/basic.h"
namespace
CGoGN
...
...
@@ -99,7 +99,7 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
typedef
typename
PFP
::
REAL
REAL
;
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
;
buffer
.
reserve
(
16384
);
...
...
@@ -108,91 +108,97 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
bufferColors
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferNormals
;
bufferNormals
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
normals
;
bufferNormals
.
reserve
(
20
);
std
::
vector
<
VEC3
>
vertices
;
bufferNormals
.
reserve
(
20
);
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
FACE_OF_PARENT
>
traFace
(
map
,
good
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
// compute normals
normals
.
clear
();
VEC3
centerFace
(
0
);
unsigned
int
nbs
=
0
;
vertices
.
clear
();
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
do
{
VEC3
v1
=
Algo
::
Surface
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
a
,
positions
);
VEC3
v1
=
positions
[
a
]
-
centerFace
;
v1
.
normalize
();
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
;
N
.
normalize
();
double
l
=
N
.
norm
();
if
(
l
<
0.01
)
N
=
centerNormalFace
;
else
{
N
/=
l
;
if
(
N
*
centerNormalFace
<
0.707
)
N
=
centerNormalFace
;
}
normals
.
push_back
(
N
);
vertices
.
push_back
(
positions
[
e
]);
a
=
e
;
centerFace
+=
positions
[
a
];
nbs
++
;
}
while
(
a
!=
d
);
centerFace
/=
float
(
nbs
);
typename
std
::
vector
<
VEC3
>::
iterator
in
=
normals
.
begin
();
a
=
d
;
Dart
b
=
map
.
phi1
(
a
);
Dart
c
=
map
.
phi1
(
b
);
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
VEC3
volCol
=
colorPerXXX
[
d
];
unsigned
int
nbs
=
vertices
.
size
();
// just to have more easy algo further
vertices
.
push_back
(
vertices
.
front
());
normals
.
push_back
(
normals
.
front
());
typename
std
::
vector
<
VEC3
>::
iterator
iv
=
vertices
.
begin
();
typename
std
::
vector
<
VEC3
>::
iterator
in
=
normals
.
begin
();
if
(
nbs
==
3
)
{
buffer
.
push_back
(
centerVolumes
[
d
]);
bufferColors
.
push_back
(
centerFace
);
bufferNormals
.
push_back
(
centerFace
);
// unsused just for fill
buffer
.
push_back
(
positions
[
d
]);
bufferColors
.
push_back
(
colorPerXXX
[
d
]);
bufferNormals
.
push_back
(
normals
.
back
());
buffer
.
push_back
(
positions
[
b
]);
bufferColors
.
push_back
(
colorPerXXX
[
b
]);
bufferNormals
.
push_back
(
centerNormalFace
);
// unsused just for fill
buffer
.
push_back
(
*
iv
++
);
bufferNormals
.
push_back
(
*
in
++
);
buffer
.
push_back
(
positions
[
c
]);
bufferColors
.
push_back
(
colorPerXXX
[
c
]);
bufferNormals
.
push_back
(
*
in
);
b
=
c
;
c
=
map
.
phi1
(
b
);
}
while
(
c
!=
d
);
// a = d;
// Dart b = map.phi1(a);
// // loop to cut a polygon in triangle on the fly (works only with convex faces)
// do
// {
// buffer.push_back(centerVolumes[d]);
// bufferColors.push_back(centerFace);
// bufferNormals.push_back(centerFace); // unsused just for fill
// buffer.push_back(positions[a]);
// bufferColors.push_back(colorPerXXX[a]);
//
// VEC3 N1 = positions[a]^positions[b];
// N1.normalize();
// bufferNormals.push_back(N1);
//
// buffer.push_back(positions[b]);
// bufferColors.push_back(colorPerXXX[b]);
//
// VEC3 N2 = positions[b]^centerFace;
// N2.normalize();
// bufferNormals.push_back(N2);
//
// buffer.push_back(centerFace);
// bufferColors.push_back(colorPerXXX[a]);
//
// VEC3 N3 = centerFace^positions[a];
// N3.normalize();
// bufferNormals.push_back(N3);
//
// a = b;
// b = map.phi1(a);
// } while (a != d);
bufferColors
.
push_back
(
volCol
);
buffer
.
push_back
(
*
iv
++
);
bufferNormals
.
push_back
(
*
in
++
);
bufferColors
.
push_back
(
volCol
);
buffer
.
push_back
(
*
iv
++
);
bufferNormals
.
push_back
(
*
in
++
);
bufferColors
.
push_back
(
volCol
);
}
else
{
for
(
unsigned
int
i
=
0
;
i
<
nbs
;
++
i
)
{
buffer
.
push_back
(
centerVolumes
[
d
]);
bufferColors
.
push_back
(
centerFace
);
bufferNormals
.
push_back
(
centerNormalFace
);
// unsused just for fill
buffer
.
push_back
(
centerFace
);
bufferColors
.
push_back
(
volCol
);
bufferNormals
.
push_back
(
centerNormalFace
);
buffer
.
push_back
(
*
iv
++
);
bufferNormals
.
push_back
(
*
in
++
);
bufferColors
.
push_back
(
volCol
);
buffer
.
push_back
(
*
iv
);
bufferNormals
.
push_back
(
*
in
);
bufferColors
.
push_back
(
volCol
);
}
}
}
...
...
@@ -246,7 +252,7 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
typedef
typename
PFP
::
REAL
REAL
;
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
;
buffer
.
reserve
(
16384
);
...
...
@@ -255,60 +261,96 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
bufferColors
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferNormals
;
bufferNormals
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
normals
;
bufferNormals
.
reserve
(
20
);
std
::
vector
<
VEC3
>
vertices
;
bufferNormals
.
reserve
(
20
);
TraversorCell
<
typename
PFP
::
MAP
,
PFP
::
MAP
::
FACE_OF_PARENT
>
traFace
(
map
,
good
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
// compute normals
normals
.
clear
();
VEC3
centerFace
(
0
);
unsigned
int
nbs
=
0
;
vertices
.
clear
();
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
do
{
VEC3
v1
=
Algo
::
Surface
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
a
,
positions
);
VEC3
v1
=
positions
[
a
]
-
centerFace
;
v1
.
normalize
();
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
;
N
.
normalize
();
double
l
=
N
.
norm
();
if
(
l
<
0.01
)
N
=
centerNormalFace
;
else
{
N
/=
l
;
if
(
N
*
centerNormalFace
<
0.707
)
N
=
centerNormalFace
;
}
normals
.
push_back
(
N
);
vertices
.
push_back
(
positions
[
e
]);
a
=
e
;