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
Thomas Pitiot
CGoGN
Commits
8d93c581
Commit
8d93c581
authored
Jun 14, 2013
by
untereiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding renderExplod generic to VertexAttributes
parent
bc65d8a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
23 deletions
+95
-23
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+20
-0
include/Algo/Render/GL2/explodeVolumeRender.h
include/Algo/Render/GL2/explodeVolumeRender.h
+16
-0
include/Algo/Render/GL2/explodeVolumeRender.hpp
include/Algo/Render/GL2/explodeVolumeRender.hpp
+57
-21
include/Algo/Render/GL2/topo3Render.hpp
include/Algo/Render/GL2/topo3Render.hpp
+2
-2
No files found.
include/Algo/Geometry/normal.hpp
View file @
8d93c581
...
...
@@ -71,6 +71,26 @@ typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const VertexAttr
return
N
;
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
EMB
newellNormalGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
position
)
{
typedef
EMB
VEC3
;
VEC3
N
(
0
);
Traversor2FV
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
for
(
Dart
it
=
t
.
begin
();
it
!=
t
.
end
();
it
=
t
.
next
())
{
const
VEC3
&
P
=
position
[
it
];
const
VEC3
&
Q
=
position
[
map
.
phi1
(
it
)];
N
[
0
]
+=
(
P
[
1
]
-
Q
[
1
])
*
(
P
[
2
]
+
Q
[
2
]);
N
[
1
]
+=
(
P
[
2
]
-
Q
[
2
])
*
(
P
[
0
]
+
Q
[
0
]);
N
[
2
]
+=
(
P
[
0
]
-
Q
[
0
])
*
(
P
[
1
]
+
Q
[
1
]);
}
N
.
normalize
();
return
N
;
}
template
<
typename
PFP
>
typename
PFP
::
VEC3
faceNormal
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
{
...
...
include/Algo/Render/GL2/explodeVolumeRender.h
View file @
8d93c581
...
...
@@ -96,13 +96,22 @@ protected:
const
typename
PFP
::
VEC3
&
centerFace
,
const
typename
PFP
::
VEC3
&
centerNormalFace
,
std
::
vector
<
typename
PFP
::
VEC3
>&
vertices
,
std
::
vector
<
typename
PFP
::
VEC3
>&
normals
);
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
computeFaceGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
positions
,
const
typename
PFP
::
VEC3
&
centerFace
,
const
typename
PFP
::
VEC3
&
centerNormalFace
,
std
::
vector
<
typename
PFP
::
VEC3
>&
vertices
,
std
::
vector
<
typename
PFP
::
VEC3
>&
normals
);
template
<
typename
PFP
>
void
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerFace
)
;
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
updateSmoothGen
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerFace
)
;
template
<
typename
PFP
>
void
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
)
;
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
)
;
public:
/**
...
...
@@ -136,6 +145,9 @@ public:
template
<
typename
PFP
>
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
)
;
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
updateDataGen
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
)
;
/**
* update all drawing buffers
* @param map the map
...
...
@@ -145,6 +157,10 @@ public:
template
<
typename
PFP
>
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerFace
)
;
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
updateDataGen
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerFace
)
;
/**
* draw edges
*/
...
...
include/Algo/Render/GL2/explodeVolumeRender.hpp
View file @
8d93c581
...
...
@@ -45,7 +45,7 @@ namespace GL2
inline
ExplodeVolumeRender
::
ExplodeVolumeRender
(
bool
withColorPerFace
,
bool
withExplodeFace
,
bool
withSmoothFaces
)
:
m_cpf
(
withColorPerFace
),
m_ef
(
withExplodeFace
),
m_smooth
(
withSmoothFaces
),
m_nbTris
(
0
),
m_nbLines
(
0
),
m_globalColor
(
0.7
f
,
0.7
f
,
0.7
f
)
m_nbTris
(
0
),
m_nbLines
(
0
),
m_globalColor
(
0.9
f
,
0.5
f
,
0.0
f
)
//
m_globalColor(0.7f,0.7f,0.7f)
{
m_vboPos
=
new
Utils
::
VBO
();
m_vboPos
->
setDataSize
(
3
);
...
...
@@ -93,10 +93,20 @@ inline ExplodeVolumeRender::~ExplodeVolumeRender()
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
computeFace
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
typename
PFP
::
VEC3
&
centerFace
,
const
typename
PFP
::
VEC3
&
/*
centerNormalFace
*/
,
const
typename
PFP
::
VEC3
&
centerFace
,
const
typename
PFP
::
VEC3
&
centerNormalFace
,
std
::
vector
<
typename
PFP
::
VEC3
>&
vertices
,
std
::
vector
<
typename
PFP
::
VEC3
>&
normals
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
computeFaceGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
ExplodeVolumeRender
::
computeFaceGen
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
EMBV
&
positions
,
const
typename
PFP
::
VEC3
&
centerFace
,
const
typename
PFP
::
VEC3
&
centerNormalFace
,
std
::
vector
<
typename
PFP
::
VEC3
>&
vertices
,
std
::
vector
<
typename
PFP
::
VEC3
>&
normals
)
{
//typedef typename PFP::VEC3 VEC3;
typedef
EMB
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
normals
.
clear
();
...
...
@@ -129,15 +139,21 @@ void ExplodeVolumeRender::computeFace(typename PFP::MAP& map, Dart d, const Vert
}
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerXXX
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
updateSmoothGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
positions
,
colorPerXXX
);
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
ExplodeVolumeRender
::
updateSmoothGen
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerXXX
)
{
typedef
EMB
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
map
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
computeCentroidELWVolumes
<
PFP
>
(
map
,
positions
,
centerVolumes
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidELWVolumes
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
positions
,
centerVolumes
);
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
...
...
@@ -158,10 +174,10 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
// compute normals
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
);
computeFace
<
PFP
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
computeFace
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
VEC3
volCol
=
colorPerXXX
[
d
];
...
...
@@ -259,12 +275,18 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
)
{
updateSmoothGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
positions
);
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
ExplodeVolumeRender
::
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
map
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
computeCentroidELWVolumes
<
PFP
>
(
map
,
positions
,
centerVolumes
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidELWVolumes
<
PFP
,
EMBV
,
EMB
>
(
map
,
positions
,
centerVolumes
);
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
...
...
@@ -284,10 +306,10 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
// compute normals
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
);
computeFace
<
PFP
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
computeFace
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
unsigned
int
nbs
=
vertices
.
size
();
// just to have more easy algo further
...
...
@@ -383,6 +405,12 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerXXX
)
{
updateDataGen
<
PFP
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
positions
,
colorPerXXX
);
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
ExplodeVolumeRender
::
updateDataGen
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerXXX
)
{
if
(
!
m_cpf
)
{
...
...
@@ -393,16 +421,17 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
if
(
m_smooth
)
{
updateSmooth
<
PFP
>
(
map
,
positions
,
colorPerXXX
);
updateSmooth
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
positions
,
colorPerXXX
);
return
;
}
typedef
typename
PFP
::
VEC3
VEC3
;
//typedef typename PFP::VEC3 VEC3;
typedef
EMB
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
map
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
computeCentroidELWVolumes
<
PFP
>
(
map
,
positions
,
centerVolumes
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidELWVolumes
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
positions
,
centerVolumes
);
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
...
...
@@ -415,7 +444,7 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
);
VEC3
volColor
=
colorPerXXX
[
d
];
Dart
b
=
d
;
...
...
@@ -494,19 +523,26 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
updateData
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
)
{
updateDataGen
<
PFP
,
VertexAttribute
<
typename
PFP
::
VEC3
>
,
typename
PFP
::
VEC3
>
(
map
,
positions
);
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
void
ExplodeVolumeRender
::
updateDataGen
(
typename
PFP
::
MAP
&
map
,
const
EMBV
&
positions
)
{
if
(
m_smooth
)
{
updateSmooth
<
PFP
>
(
map
,
positions
);
updateSmooth
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
positions
);
return
;
}
typedef
typename
PFP
::
VEC3
VEC3
;
//typedef typename PFP::VEC3 VEC3;
typedef
EMB
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
map
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
computeCentroidELWVolumes
<
PFP
>
(
map
,
positions
,
centerVolumes
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidELWVolumes
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
positions
,
centerVolumes
);
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
...
...
@@ -519,7 +555,7 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribu
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
Gen
<
PFP
,
EMBV
,
EMB
>
(
map
,
d
,
positions
);
Dart
b
=
d
;
Dart
c
=
map
.
phi1
(
b
);
...
...
include/Algo/Render/GL2/topo3Render.hpp
View file @
8d93c581
...
...
@@ -102,7 +102,7 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const EMBV& positions,
CellMarker
<
VOLUME
>
cmv
(
mapx
);
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
mapx
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidELWVolumes
<
PFP
>
(
mapx
,
positions
,
centerVolumes
,
3
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidELWVolumes
Gen
<
PFP
,
EMBV
,
EMB
>
(
mapx
,
positions
,
centerVolumes
,
3
);
// debut phi1
...
...
@@ -143,7 +143,7 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const EMBV& positions,
VEC3
vc
=
centerVolumes
[
d
];
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
mapx
,
d
,
positions
)
*
kv
+
vc
*
okv
;
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
Gen
<
PFP
,
EMBV
,
EMB
>
(
mapx
,
d
,
positions
)
*
kv
+
vc
*
okv
;
//shrink the face
float
okf
=
1.0
f
-
kf
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment