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
92c348c6
Commit
92c348c6
authored
Feb 08, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better normals in explodeVolumeRender
parent
6c3080c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
59 deletions
+53
-59
include/Algo/Render/GL2/explodeVolumeRender.h
include/Algo/Render/GL2/explodeVolumeRender.h
+6
-0
include/Algo/Render/GL2/explodeVolumeRender.hpp
include/Algo/Render/GL2/explodeVolumeRender.hpp
+47
-59
No files found.
include/Algo/Render/GL2/explodeVolumeRender.h
View file @
92c348c6
...
...
@@ -81,6 +81,12 @@ protected:
GLuint
m_nbLines
;
Geom
::
Vec3f
m_globalColor
;
template
<
typename
PFP
>
void
computeFace
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
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
,
const
FunctorSelect
&
good
=
allDarts
)
;
...
...
include/Algo/Render/GL2/explodeVolumeRender.hpp
View file @
92c348c6
...
...
@@ -91,6 +91,44 @@ 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
,
std
::
vector
<
typename
PFP
::
VEC3
>&
vertices
,
std
::
vector
<
typename
PFP
::
VEC3
>&
normals
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
normals
.
clear
();
vertices
.
clear
();
Dart
a
=
d
;
do
{
VEC3
v1
=
positions
[
a
]
-
centerFace
;
v1
.
normalize
();
Dart
e
=
map
.
phi1
(
a
);
VEC3
v2
=
positions
[
e
]
-
centerFace
;
v2
.
normalize
();
VEC3
N
=
v1
^
v2
;
normals
.
push_back
(
N
);
vertices
.
push_back
(
positions
[
a
]);
a
=
e
;
}
while
(
a
!=
d
);
unsigned
int
nb
=
normals
.
size
();
VEC3
Ntemp
=
normals
[
0
];
normals
[
0
]
+=
normals
[
nb
-
1
];
normals
[
0
].
normalize
();
for
(
unsigned
int
i
=
1
;
i
!=
nb
;
++
i
)
{
VEC3
Ntemp2
=
normals
[
i
];
normals
[
i
]
+=
Ntemp
;
normals
[
i
].
normalize
();
Ntemp
=
Ntemp2
;
}
}
template
<
typename
PFP
>
void
ExplodeVolumeRender
::
updateSmooth
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
const
VolumeAttribute
<
typename
PFP
::
VEC3
>&
colorPerXXX
,
const
FunctorSelect
&
good
)
...
...
@@ -110,46 +148,21 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
bufferNormals
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
normals
;
bufferN
ormals
.
reserve
(
20
);
n
ormals
.
reserve
(
20
);
std
::
vector
<
VEC3
>
vertices
;
bufferNormal
s
.
reserve
(
20
);
vertice
s
.
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
();
vertices
.
clear
();
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
do
{
VEC3
v1
=
positions
[
a
]
-
centerFace
;
v1
.
normalize
();
Dart
e
=
map
.
phi1
(
a
);
VEC3
v2
=
positions
[
map
.
phi1
(
e
)]
-
centerFace
;
v2
.
normalize
();
VEC3
N
=
v1
^
v2
;
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
;
}
while
(
a
!=
d
);
computeFace
<
PFP
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
VEC3
volCol
=
colorPerXXX
[
d
];
unsigned
int
nbs
=
vertices
.
size
();
...
...
@@ -271,36 +284,11 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
// compute normals
normals
.
clear
();
vertices
.
clear
();
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
map
,
d
,
positions
);
VEC3
centerNormalFace
=
Algo
::
Surface
::
Geometry
::
newellNormal
<
PFP
>
(
map
,
d
,
positions
);
Dart
a
=
d
;
do
{
VEC3
v1
=
positions
[
a
]
-
centerFace
;
v1
.
normalize
();
Dart
e
=
map
.
phi1
(
a
);
VEC3
v2
=
positions
[
map
.
phi1
(
e
)]
-
centerFace
;
v2
.
normalize
();
VEC3
N
=
v1
^
v2
;
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
;
}
while
(
a
!=
d
);
computeFace
<
PFP
>
(
map
,
d
,
positions
,
centerFace
,
centerNormalFace
,
vertices
,
normals
);
unsigned
int
nbs
=
vertices
.
size
();
// just to have more easy algo further
vertices
.
push_back
(
vertices
.
front
());
...
...
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