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
KennethVanhoey
CGoGN
Commits
48357051
Commit
48357051
authored
Feb 08, 2013
by
untereiner
Browse files
Merge cgogn:~thery/CGoGN
parents
726113c5
038eb8d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
include/Algo/Render/GL2/explodeVolumeRender.h
View file @
48357051
...
...
@@ -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 @
48357051
...
...
@@ -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
();
...
...
@@ -272,36 +285,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
());
...
...
include/Algo/Render/GL2/topo3Render.hpp
View file @
48357051
...
...
@@ -83,7 +83,7 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttribute<
CellMarker
<
VOLUME
>
cmv
(
mapx
);
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
mapx
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidVolumes
<
PFP
>
(
mapx
,
positions
,
centerVolumes
,
allDarts
,
3
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroid
ELW
Volumes
<
PFP
>
(
mapx
,
positions
,
centerVolumes
,
allDarts
,
3
);
// debut phi1
...
...
@@ -123,27 +123,21 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttribute<
float
okv
=
1.0
f
-
kv
;
VEC3
vc
=
centerVolumes
[
d
];
VEC3
centerFace
(
0
,
0
,
0
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
mapx
,
d
,
positions
)
*
kv
+
vc
*
okv
;
//shrink the face
float
okf
=
1.0
f
-
kf
;
Dart
dd
=
d
;
do
{
VEC3
P
=
positions
[
dd
];
P
=
vc
*
okv
+
P
*
kv
;
VEC3
P
=
centerFace
*
okf
+
(
vc
*
okv
+
positions
[
dd
]
*
kv
)
*
kf
;
vecPos
.
push_back
(
P
);
centerFace
+=
P
;
dd
=
mapx
.
phi1
(
dd
);
}
while
(
dd
!=
d
);
centerFace
/=
REAL
(
vecPos
.
size
());
//shrink the face
unsigned
int
nb
=
vecPos
.
size
();
float
okf
=
1.0
f
-
kf
;
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
vecPos
[
i
]
=
centerFace
*
okf
+
vecPos
[
i
]
*
kf
;
}
vecPos
.
push_back
(
vecPos
.
front
());
// copy the first for easy computation on next loop
// compute position of points to use for drawing topo
...
...
@@ -338,7 +332,7 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute
// compute center of each volumes
VolumeAutoAttribute
<
VEC3
>
centerVolumes
(
mapx
,
"centerVolumes"
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroidVolumes
<
PFP
>
(
mapx
,
positions
,
centerVolumes
,
good
);
Algo
::
Volume
::
Geometry
::
Parallel
::
computeCentroid
ELW
Volumes
<
PFP
>
(
mapx
,
positions
,
centerVolumes
,
good
);
// beta1
DartAutoAttribute
<
VEC3
>
fv1
(
mapx
);
...
...
@@ -379,27 +373,22 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute
float
okv
=
1.0
f
-
kv
;
VEC3
vc
=
centerVolumes
[
d
];
VEC3
centerFace
(
0
,
0
,
0
);
VEC3
centerFace
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
mapx
,
d
,
positions
)
*
kv
+
vc
*
okv
;
//shrink the face
float
okf
=
1.0
f
-
kf
;
Dart
dd
=
d
;
do
{
VEC3
P
=
positions
[
dd
];
P
=
vc
*
okv
+
P
*
kv
;
VEC3
P
=
centerFace
*
okf
+
(
vc
*
okv
+
positions
[
dd
]
*
kv
)
*
kf
;
vecPos
.
push_back
(
P
);
centerFace
+=
P
;
dd
=
mapx
.
phi1
(
dd
);
}
while
(
dd
!=
d
);
centerFace
/=
REAL
(
vecPos
.
size
());
//shrink the face
unsigned
int
nb
=
vecPos
.
size
();
float
okf
=
1.0
f
-
kf
;
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
vecPos
[
i
]
=
centerFace
*
okf
+
vecPos
[
i
]
*
kf
;
}
vecPos
.
push_back
(
vecPos
.
front
());
// copy the first for easy computation on next loop
// compute position of points to use for drawing topo
...
...
include/Algo/Render/GL2/topoRender.hpp
View file @
48357051
...
...
@@ -31,6 +31,8 @@
#include
"Topology/gmap/embeddedGMap2.h"
#include
"Geometry/distances.h"
#include
"Algo/Geometry/centroid.h"
namespace
CGoGN
{
...
...
@@ -117,30 +119,21 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty
Dart
d
=
*
id
;
if
(
!
mf
.
isMarked
(
d
))
{
vecPos
.
clear
();
// store the face & center
VEC3
center
(
0.0
f
,
0.0
f
,
0.0
f
);
VEC3
center
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
mapx
,
d
,
positions
);
float
k
=
1.0
f
-
kf
;
Dart
dd
=
d
;
do
{
const
VEC3
&
P
=
positions
[
d
];
vecPos
.
push_back
(
P
);
center
+=
P
;
Dart
e
=
map
.
phi1
(
d
);
d
=
e
;
}
while
(
d
!=
dd
);
center
/=
REAL
(
vecPos
.
size
());
//shrink the face
vecPos
.
push_back
(
center
*
k
+
positions
[
dd
]
*
kf
);
dd
=
map
.
phi1
(
dd
);
}
while
(
dd
!=
d
);
unsigned
int
nb
=
vecPos
.
size
();
float
k
=
1.0
f
-
kf
;
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
vecPos
[
i
]
=
center
*
k
+
vecPos
[
i
]
*
kf
;
}
vecPos
.
push_back
(
vecPos
.
front
());
// copy the first for easy computation on next loop
k
=
1.0
f
-
ke
;
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
...
...
@@ -266,25 +259,17 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const VertexAttribute<t
if
(
!
mf
.
isMarked
(
d
))
{
vecPos
.
clear
();
// store the face & center
VEC3
center
(
0.0
f
,
0.0
f
,
0.0
f
);
VEC3
center
=
Algo
::
Surface
::
Geometry
::
faceCentroidELW
<
PFP
>
(
mapx
,
d
,
positions
);
float
k
=
1.0
f
-
kf
;
Dart
dd
=
d
;
do
{
const
VEC3
&
P
=
positions
[
d
];
vecPos
.
push_back
(
P
);
center
+=
P
;
d
=
map
.
phi1
(
d
);
}
while
(
d
!=
dd
);
center
/=
REAL
(
vecPos
.
size
());
vecPos
.
push_back
(
center
*
k
+
positions
[
dd
]
*
kf
);
dd
=
map
.
phi1
(
dd
);
}
while
(
dd
!=
d
);
//shrink the face
unsigned
int
nb
=
vecPos
.
size
();
float
k
=
1.0
f
-
kf
;
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
vecPos
[
i
]
=
center
*
k
+
vecPos
[
i
]
*
kf
;
}
vecPos
.
push_back
(
vecPos
.
front
());
// copy the first for easy computation on next loop
k
=
1.0
f
-
ke
;
...
...
include/Geometry/vector_gen.h
View file @
48357051
...
...
@@ -117,7 +117,11 @@ public:
Vector
<
DIM
,
T
>
operator
-
()
const
;
Vector
<
DIM
,
T
>
operator
*
(
T
a
)
const
;
Vector
<
DIM
,
T
>
operator
*
(
T
a
)
const
;
// template <typename T2>
// Vector<DIM, T> operator*(T2 a) const ;
Vector
<
DIM
,
T
>
operator
/
(
T
a
)
const
;
...
...
@@ -208,8 +212,8 @@ bool isNull(T x, int precision = 0) ;
template
<
typename
T
>
bool
isNull2
(
T
x
,
int
precision
=
0
)
;
template
<
unsigned
int
DIM
,
typename
T
>
Vector
<
DIM
,
T
>
operator
*
(
T
a
,
const
Vector
<
DIM
,
T
>&
v
)
;
//
template <unsigned int DIM, typename T>
//
Vector<DIM, T> operator*(T a, const Vector<DIM, T>& v) ;
template
<
unsigned
int
DIM
,
typename
T
>
Vector
<
DIM
,
T
>
operator
/
(
T
a
,
const
Vector
<
DIM
,
T
>&
v
)
;
...
...
@@ -222,6 +226,9 @@ T tripleProduct(const Vector<DIM, T>& v1, const Vector<DIM, T>& v2, const Vector
template
<
unsigned
int
DIM
,
typename
T
>
Vector
<
DIM
,
T
>
slerp
(
const
Vector
<
DIM
,
T
>
&
v1
,
const
Vector
<
DIM
,
T
>
&
v2
,
const
T
&
t
)
;
template
<
unsigned
int
DIM
,
typename
T
,
typename
T2
>
Vector
<
DIM
,
T
>
operator
*
(
T2
b
,
const
Vector
<
DIM
,
T
>&
v
);
/**********************************************/
/* SOME USEFUL TYPEDEFS */
...
...
include/Geometry/vector_gen.hpp
View file @
48357051
...
...
@@ -405,12 +405,13 @@ inline bool isNull2(T x, int precision)
return
(
isNull
(
x
,
-
(
precision
*
precision
)))
;
}
template
<
unsigned
int
DIM
,
typename
T
>
inline
Vector
<
DIM
,
T
>
operator
*
(
T
a
,
const
Vector
<
DIM
,
T
>&
v
)
template
<
unsigned
int
DIM
,
typename
T
,
typename
T2
>
inline
Vector
<
DIM
,
T
>
operator
*
(
T
2
b
,
const
Vector
<
DIM
,
T
>&
v
)
{
return
v
*
a
;
return
v
*
T
(
b
)
;
}
template
<
unsigned
int
DIM
,
typename
T
>
inline
Vector
<
DIM
,
T
>
operator
/
(
T
a
,
const
Vector
<
DIM
,
T
>&
v
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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