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
CGoGN
CGoGN
Commits
76350c08
Commit
76350c08
authored
Feb 21, 2012
by
untereiner
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn:~kraemer/CGoGN
parents
e6c58f5b
3dd929f4
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
658 additions
and
106 deletions
+658
-106
Apps/Tuto/show_traversors.cpp
Apps/Tuto/show_traversors.cpp
+31
-13
Apps/Tuto/show_traversors.h
Apps/Tuto/show_traversors.h
+8
-0
Apps/Tuto/show_traversors.ui
Apps/Tuto/show_traversors.ui
+23
-0
include/Algo/ImplicitHierarchicalMesh/ihm.h
include/Algo/ImplicitHierarchicalMesh/ihm.h
+1
-1
include/Algo/ImplicitHierarchicalMesh/ihm.hpp
include/Algo/ImplicitHierarchicalMesh/ihm.hpp
+2
-1
include/Algo/ImplicitHierarchicalMesh/ihm3.h
include/Algo/ImplicitHierarchicalMesh/ihm3.h
+1
-1
include/Algo/ImplicitHierarchicalMesh/ihm3.hpp
include/Algo/ImplicitHierarchicalMesh/ihm3.hpp
+2
-1
include/Algo/Import/importMRDAT.h
include/Algo/Import/importMRDAT.h
+39
-7
include/Algo/Import/importMRDAT.hpp
include/Algo/Import/importMRDAT.hpp
+17
-4
include/Algo/Import/importMesh.hpp
include/Algo/Import/importMesh.hpp
+2
-3
include/Algo/Render/GL2/colorPerFaceRender.h
include/Algo/Render/GL2/colorPerFaceRender.h
+95
-0
include/Algo/Render/GL2/colorPerFaceRender.hpp
include/Algo/Render/GL2/colorPerFaceRender.hpp
+179
-0
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+4
-4
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+24
-2
include/Topology/generic/traversorCell.hpp
include/Topology/generic/traversorCell.hpp
+2
-2
include/Topology/gmap/gmap2.h
include/Topology/gmap/gmap2.h
+2
-1
include/Topology/gmap/gmap3.h
include/Topology/gmap/gmap3.h
+2
-1
include/Topology/map/map2.h
include/Topology/map/map2.h
+2
-1
include/Topology/map/map3.h
include/Topology/map/map3.h
+2
-1
include/Utils/Shaders/shaderFlatColor.frag
include/Utils/Shaders/shaderFlatColor.frag
+1
-1
include/Utils/Shaders/shaderFlatColor.geom
include/Utils/Shaders/shaderFlatColor.geom
+21
-10
include/Utils/Shaders/shaderFlatColor.h
include/Utils/Shaders/shaderFlatColor.h
+2
-2
include/Utils/Shaders/shaderFlatColor.vert
include/Utils/Shaders/shaderFlatColor.vert
+1
-1
include/Utils/drawer.h
include/Utils/drawer.h
+6
-0
include/Utils/svg.h
include/Utils/svg.h
+5
-0
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+0
-15
src/Topology/gmap/gmap2.cpp
src/Topology/gmap/gmap2.cpp
+6
-1
src/Topology/gmap/gmap3.cpp
src/Topology/gmap/gmap3.cpp
+6
-1
src/Topology/map/map2.cpp
src/Topology/map/map2.cpp
+6
-1
src/Topology/map/map3.cpp
src/Topology/map/map3.cpp
+6
-1
src/Utils/Shaders/shaderFlatColor.cpp
src/Utils/Shaders/shaderFlatColor.cpp
+19
-17
src/Utils/drawer.cpp
src/Utils/drawer.cpp
+69
-0
src/Utils/svg.cpp
src/Utils/svg.cpp
+72
-13
No files found.
Apps/Tuto/show_traversors.cpp
View file @
76350c08
...
...
@@ -106,6 +106,15 @@ void MyQT::cb_combo6(int x)
CGoGNerr
<<
"undefined traversor"
<<
CGoGNendl
;
}
void
MyQT
::
cb_explode
(
int
x
)
{
m_expl
=
float
(
x
)
/
100.0
f
;
if
(
m_last
==
2
)
traverse2
();
if
(
m_last
==
3
)
traverse3
();
}
void
MyQT
::
cb_initGL
()
{
...
...
@@ -154,6 +163,13 @@ void MyQT::cb_mousePress(int button, int x, int y)
}
void
MyQT
::
cb_Save
()
{
std
::
string
filename
=
selectFileSave
(
"Export SVG file "
,
"."
,
"(*.svg)"
);
Utils
::
SVG
::
SVGOut
svg
(
filename
,
modelViewMatrix
(),
projectionMatrix
());
m_drawer
.
toSVG
(
svg
);
}
void
MyQT
::
colorizeCell
(
Dart
d
,
unsigned
int
orbit
,
float
r
,
float
g
,
float
b
)
{
TraversorDartsOfOrbit
<
PFP
::
MAP
>
doo
(
myMap
,
orbit
,
d
);
...
...
@@ -166,37 +182,37 @@ void MyQT::traverse2()
{
if
(
m_selected
==
NIL
)
return
;
m_last
=
2
;
// int code = (m_ajd_or_inci2)*100+m_first2*10+m_second2;
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
myMap
);
m_drawer
.
newList
(
GL_COMPILE
);
m_drawer
.
lineWidth
(
3.0
f
);
m_drawer
.
pointSize
(
7.0
f
);
m_drawer
.
color3f
(
1
.0
f
,
1.0
f
,
0.0
f
);
m_drawer
.
color3f
(
0
.0
f
,
0.7
f
,
0.0
f
);
m_affDarts
.
clear
();
if
(
m_ajd_or_inci2
==
0
)
// incident
{
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_second2
,
m_drawer
,
myMap
,
m_selected
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_second2
,
m_drawer
,
myMap
,
m_selected
,
position
,
m_expl
);
m_drawer
.
color3f
(
1.0
f
,
0.0
f
,
0.0
f
);
Traversor2
<
PFP
::
MAP
>*
tra
=
Traversor2
<
PFP
::
MAP
>::
createIncident
(
myMap
,
m_selected
,
VERTEX
+
m_second2
,
VERTEX
+
m_first2
);
for
(
Dart
d
=
tra
->
begin
();
d
!=
tra
->
end
();
d
=
tra
->
next
())
m_affDarts
.
push_back
(
d
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first2
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first2
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
m_expl
);
}
else
// adjacent
{
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_first2
,
m_drawer
,
myMap
,
m_selected
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_first2
,
m_drawer
,
myMap
,
m_selected
,
position
,
m_expl
);
m_drawer
.
color3f
(
1.0
f
,
0.0
f
,
0.0
f
);
Traversor2
<
PFP
::
MAP
>*
tra
=
Traversor2
<
PFP
::
MAP
>::
createAdjacent
(
myMap
,
m_selected
,
VERTEX
+
m_first2
,
VERTEX
+
m_second2
);
for
(
Dart
d
=
tra
->
begin
();
d
!=
tra
->
end
();
d
=
tra
->
next
())
m_affDarts
.
push_back
(
d
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first2
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first2
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
m_expl
);
}
m_drawer
.
endList
();
...
...
@@ -207,35 +223,36 @@ void MyQT::traverse2()
void
MyQT
::
traverse3
()
{
// int code = (m_ajd_or_inci3)*100+m_first3*10+m_second3;
// std::cout << "CODE="<< code << std::endl;
if
(
m_selected
==
NIL
)
return
;
m_last
=
3
;
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
myMap
);
m_affDarts
.
clear
();
m_drawer
.
newList
(
GL_COMPILE
);
m_drawer
.
lineWidth
(
3.0
f
);
m_drawer
.
pointSize
(
7.0
f
);
m_drawer
.
color3f
(
1
.0
f
,
1.0
f
,
0.0
f
);
m_drawer
.
color3f
(
0
.0
f
,
0.7
f
,
0.0
f
);
if
(
m_ajd_or_inci3
==
0
)
// incident
{
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_second3
,
m_drawer
,
myMap
,
m_selected
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_second3
,
m_drawer
,
myMap
,
m_selected
,
position
,
m_expl
);
m_drawer
.
color3f
(
1.0
f
,
0.0
f
,
0.0
f
);
Traversor3XY
<
PFP
::
MAP
>
tra
(
myMap
,
m_selected
,
VERTEX
+
m_second3
,
VERTEX
+
m_first3
);
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
m_affDarts
.
push_back
(
d
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first3
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first3
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
m_expl
);
}
else
// adjacent
{
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_first3
,
m_drawer
,
myMap
,
m_selected
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCell
<
PFP
>
(
VERTEX
+
m_first3
,
m_drawer
,
myMap
,
m_selected
,
position
,
m_expl
);
m_drawer
.
color3f
(
1.0
f
,
0.0
f
,
0.0
f
);
Traversor3XXaY
<
PFP
::
MAP
>
tra
(
myMap
,
m_selected
,
VERTEX
+
m_first3
,
VERTEX
+
m_second3
);
for
(
Dart
d
=
tra
.
begin
();
d
!=
tra
.
end
();
d
=
tra
.
next
())
m_affDarts
.
push_back
(
d
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first3
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
0.7
f
);
Algo
::
Render
::
drawerCells
<
PFP
>
(
VERTEX
+
m_first3
,
m_drawer
,
myMap
,
m_affDarts
,
position
,
m_expl
);
}
m_drawer
.
endList
();
...
...
@@ -280,6 +297,7 @@ int main(int argc, char **argv)
sqt
.
setCallBack
(
dock
.
combo4
,
SIGNAL
(
activated
(
int
)),
SLOT
(
cb_combo4
(
int
))
);
sqt
.
setCallBack
(
dock
.
combo5
,
SIGNAL
(
activated
(
int
)),
SLOT
(
cb_combo5
(
int
))
);
sqt
.
setCallBack
(
dock
.
combo6
,
SIGNAL
(
activated
(
int
)),
SLOT
(
cb_combo6
(
int
))
);
sqt
.
setCallBack
(
dock
.
explodeSlider
,
SIGNAL
(
valueChanged
(
int
)),
SLOT
(
cb_explode
(
int
))
);
sqt
.
setCallBack
(
dock
.
checkTopo
,
SIGNAL
(
clicked
(
bool
)),
SLOT
(
cb_checkTopo
(
bool
))
);
...
...
Apps/Tuto/show_traversors.h
View file @
76350c08
...
...
@@ -96,6 +96,8 @@ class MyQT: public Utils::QT::SimpleQT
unsigned
int
m_first2
;
unsigned
int
m_ajd_or_inci2
;
unsigned
int
m_second2
;
float
m_expl
;
unsigned
int
m_last
;
public:
MyQT
()
:
m_render_topo
(
NULL
),
...
...
@@ -106,6 +108,8 @@ public:
m_first2
(
0
),
m_ajd_or_inci2
(
0
),
m_second2
(
1
),
m_expl
(
0.8
f
),
m_last
(
2
),
m_selected
(
NIL
)
{}
...
...
@@ -122,6 +126,8 @@ protected:
void
cb_initGL
();
void
cb_Save
();
void
cb_mousePress
(
int
button
,
int
x
,
int
y
);
void
colorizeCell
(
Dart
d
,
unsigned
int
orbit
,
float
r
,
float
g
,
float
b
);
...
...
@@ -139,6 +145,8 @@ public slots:
void
cb_combo5
(
int
x
);
void
cb_combo6
(
int
x
);
void
cb_checkTopo
(
bool
b
);
void
cb_explode
(
int
x
);
};
#endif
Apps/Tuto/show_traversors.ui
View file @
76350c08
...
...
@@ -210,6 +210,29 @@
</property>
</widget>
</item>
<item>
<widget
class=
"QSlider"
name=
"explodeSlider"
>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
<property
name=
"maximum"
>
<number>
100
</number>
</property>
<property
name=
"sliderPosition"
>
<number>
80
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"Line"
name=
"line_3"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"checkTopo"
>
<property
name=
"focusPolicy"
>
...
...
include/Algo/ImplicitHierarchicalMesh/ihm.h
View file @
76350c08
...
...
@@ -91,7 +91,7 @@ public:
virtual
Dart
end
()
;
virtual
void
next
(
Dart
&
d
)
;
virtual
Dart
next
(
Dart
&
d
)
;
virtual
bool
foreach_dart_of_vertex
(
Dart
d
,
FunctorType
&
f
,
unsigned
int
thread
=
0
)
;
...
...
include/Algo/ImplicitHierarchicalMesh/ihm.hpp
View file @
76350c08
...
...
@@ -152,12 +152,13 @@ inline Dart ImplicitHierarchicalMap::end()
return
Map2
::
end
()
;
}
inline
void
ImplicitHierarchicalMap
::
next
(
Dart
&
d
)
inline
Dart
ImplicitHierarchicalMap
::
next
(
Dart
&
d
)
{
do
{
Map2
::
next
(
d
)
;
}
while
(
d
!=
Map2
::
end
()
&&
m_dartLevel
[
d
]
>
m_curLevel
)
;
return
d
;
}
inline
bool
ImplicitHierarchicalMap
::
foreach_dart_of_vertex
(
Dart
d
,
FunctorType
&
f
,
unsigned
int
thread
)
...
...
include/Algo/ImplicitHierarchicalMesh/ihm3.h
View file @
76350c08
...
...
@@ -364,7 +364,7 @@ public:
virtual
Dart
end
()
;
virtual
void
next
(
Dart
&
d
)
;
virtual
Dart
next
(
Dart
&
d
)
;
virtual
bool
foreach_dart_of_vertex
(
Dart
d
,
FunctorType
&
f
,
unsigned
int
thread
=
0
)
;
...
...
include/Algo/ImplicitHierarchicalMesh/ihm3.hpp
View file @
76350c08
...
...
@@ -213,12 +213,13 @@ inline Dart ImplicitHierarchicalMap3::end()
return
Map3
::
end
()
;
}
inline
void
ImplicitHierarchicalMap3
::
next
(
Dart
&
d
)
inline
Dart
ImplicitHierarchicalMap3
::
next
(
Dart
&
d
)
{
do
{
Map3
::
next
(
d
)
;
}
while
(
d
!=
Map3
::
end
()
&&
m_dartLevel
[
d
]
>
m_curLevel
)
;
return
d
;
}
inline
bool
ImplicitHierarchicalMap3
::
foreach_dart_of_vertex
(
Dart
d
,
FunctorType
&
f
,
unsigned
int
thread
)
...
...
include/Algo/Import/importMRDAT.h
View file @
76350c08
...
...
@@ -76,10 +76,6 @@ public:
{
if
(
isSubdivided
())
{
unsigned
int
emb0
=
vID
[
children
[
0
]
->
indices
[
0
]]
;
unsigned
int
emb1
=
vID
[
children
[
0
]
->
indices
[
1
]]
;
unsigned
int
emb2
=
vID
[
children
[
0
]
->
indices
[
2
]]
;
Dart
d0
=
map
.
phi1
(
d
)
;
Dart
d1
,
d2
;
if
(
CCW
)
...
...
@@ -93,9 +89,40 @@ public:
d2
=
map
.
phi_1
(
d
)
;
}
map
.
incCurrentLevel
()
;
map
.
embedOrbit
(
VERTEX
,
map
.
phi1
(
d0
),
emb0
)
;
map
.
embedOrbit
(
VERTEX
,
map
.
phi1
(
d1
),
emb1
)
;
map
.
embedOrbit
(
VERTEX
,
map
.
phi1
(
d2
),
emb2
)
;
unsigned
int
emb0
=
vID
[
children
[
0
]
->
indices
[
0
]]
;
unsigned
int
e0
=
map
.
getEmbedding
(
VERTEX
,
map
.
phi2
(
d0
))
;
if
(
!
cm
.
isMarked
(
map
.
phi2
(
d0
)))
{
assert
(
e0
==
EMBNULL
)
;
map
.
embedOrbit
(
VERTEX
,
map
.
phi2
(
d0
),
emb0
)
;
cm
.
mark
(
map
.
phi2
(
d0
))
;
}
else
assert
(
e0
==
emb0
)
;
unsigned
int
emb1
=
vID
[
children
[
0
]
->
indices
[
1
]]
;
unsigned
int
e1
=
map
.
getEmbedding
(
VERTEX
,
map
.
phi2
(
d1
))
;
if
(
!
cm
.
isMarked
(
map
.
phi2
(
d1
)))
{
assert
(
e1
==
EMBNULL
)
;
map
.
embedOrbit
(
VERTEX
,
map
.
phi2
(
d1
),
emb1
)
;
cm
.
mark
(
map
.
phi2
(
d1
))
;
}
else
assert
(
e1
==
emb1
)
;
unsigned
int
emb2
=
vID
[
children
[
0
]
->
indices
[
2
]]
;
unsigned
int
e2
=
map
.
getEmbedding
(
VERTEX
,
map
.
phi2
(
d2
))
;
if
(
!
cm
.
isMarked
(
map
.
phi2
(
d2
)))
{
assert
(
e2
==
EMBNULL
)
;
map
.
embedOrbit
(
VERTEX
,
map
.
phi2
(
d2
),
emb2
)
;
cm
.
mark
(
map
.
phi2
(
d2
))
;
}
else
assert
(
e2
==
emb2
)
;
map
.
decCurrentLevel
()
;
Dart
t0
=
map
.
phi_1
(
d
)
;
...
...
@@ -121,6 +148,11 @@ public:
children
[
3
]
->
embed
(
map
,
t3
,
vID
,
cm
,
!
CCW
)
;
map
.
decCurrentLevel
()
;
}
else
{
if
(
map
.
getCurrentLevel
()
<
map
.
getMaxLevel
())
std
::
cout
<<
"adaptive !!!!!!!"
<<
std
::
endl
;
}
}
void
print
()
...
...
include/Algo/Import/importMRDAT.hpp
View file @
76350c08
...
...
@@ -235,14 +235,27 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
for
(
unsigned
int
i
=
0
;
i
<
depth
;
++
i
)
map
.
addNewLevel
(
false
)
;
map
.
setCurrentLevel
(
0
)
;
map
.
setCurrentLevel
(
0
)
;
qt
.
embed
(
map
,
verticesID
)
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
for
(
unsigned
int
l
=
0
;
l
<=
map
.
getMaxLevel
();
++
l
)
TraversorV
<
typename
PFP
::
MAP
>
tv
(
map
,
allDarts
,
true
)
;
for
(
Dart
d
=
tv
.
begin
();
d
!=
tv
.
end
();
d
=
tv
.
next
())
{
unsigned
int
vertexLevel
=
map
.
getDartLevel
(
d
)
;
if
(
vertexLevel
>
0
&&
vertexLevel
<
map
.
getMaxLevel
())
{
map
.
setCurrentLevel
(
l
)
;
map
.
check
()
;
map
.
pushLevel
()
;
map
.
setCurrentLevel
(
vertexLevel
)
;
unsigned
int
emb
=
map
.
getEmbedding
(
VERTEX
,
d
)
;
for
(
unsigned
int
i
=
vertexLevel
+
1
;
i
<=
map
.
getMaxLevel
();
++
i
)
{
map
.
setCurrentLevel
(
i
)
;
map
.
embedOrbit
(
VERTEX
,
d
,
emb
)
;
}
map
.
popLevel
()
;
}
}
return
true
;
...
...
include/Algo/Import/importMesh.hpp
View file @
76350c08
...
...
@@ -121,8 +121,8 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
if
(
nbBoundaryEdges
>
0
)
{
map
.
closeMap
();
CGoGNout
<<
"Map closed ("
<<
nbBoundaryEdges
<<
" boundary edges)"
<<
CGoGNendl
;
unsigned
int
nbH
=
map
.
closeMap
();
CGoGNout
<<
"Map closed ("
<<
nbBoundaryEdges
<<
" boundary edges
/ "
<<
nbH
<<
" holes
)"
<<
CGoGNendl
;
// ensure bijection between topo and embedding
map
.
bijectiveOrbitEmbedding
(
VERTEX
);
}
...
...
@@ -130,7 +130,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
return
true
;
}
template
<
typename
PFP
>
bool
importMeshSToV
(
typename
PFP
::
MAP
&
map
,
MeshTablesSurface
<
PFP
>&
mts
,
float
dist
)
{
...
...
include/Algo/Render/GL2/colorPerFaceRender.h
0 → 100644
View file @
76350c08
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _COLOR_PER_FACE_RENDER
#define _COLOR_PER_FACE_RENDER
#include <GL/glew.h>
#include "Topology/generic/dart.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/functor.h"
#include "Utils/vbo.h"
#include "Utils/GLSLShader.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Render
{
namespace
GL2
{
/**
* Class that update VBO to allow the rendering of per face color rendering
* Warning: do not use same position & color VBO than with pervertex rendering !
*/
class
ColorPerFaceRender
{
protected:
GLuint
m_nbTris
;
public:
/**
* Constructor
*/
ColorPerFaceRender
()
;
/**
* update drawing buffers
* @param map the map
* @param positions attribute of position vertices
* @param colorPerFace attribute of color (per face, or per vertex per face)
* @param good selector
*/
template
<
typename
PFP
>
void
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
const
typename
PFP
::
TVEC3
&
colorPerFace
,
const
FunctorSelect
&
good
=
allDarts
)
;
template
<
typename
PFP
>
void
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboNormals
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
const
typename
PFP
::
TVEC3
&
normals
,
const
typename
PFP
::
TVEC3
&
colorPerFace
,
const
FunctorSelect
&
good
=
allDarts
)
;
/**
* draw
*/
void
draw
(
Utils
::
GLSLShader
*
sh
)
;
};
}
//end namespace GL2
}
//end namespace Algo
}
//end namespace Render
}
//end namespace CGoGN
#include "Algo/Render/GL2/colorPerFaceRender.hpp"
#endif
include/Algo/Render/GL2/colorPerFaceRender.hpp
0 → 100644
View file @
76350c08
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <cmath>
#include "Geometry/vector_gen.h"
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/cellmarker.h"
#include "Algo/Geometry/centroid.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Render
{
namespace
GL2
{
inline
ColorPerFaceRender
::
ColorPerFaceRender
()
:
m_nbTris
(
0
)
{
}
template
<
typename
PFP
>
void
ColorPerFaceRender
::
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
const
typename
PFP
::
TVEC3
&
colorPerXXX
,
const
FunctorSelect
&
good
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferColors
;
bufferColors
.
reserve
(
16384
);
TraversorCell
<
typename
PFP
::
MAP
>
traFace
(
map
,
FACE
,
good
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
Dart
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
{
buffer
.
push_back
(
positions
[
d
]);
bufferColors
.
push_back
(
colorPerXXX
[
d
]);
buffer
.
push_back
(
positions
[
b
]);
bufferColors
.
push_back
(
colorPerXXX
[
b
]);
buffer
.
push_back
(
positions
[
c
]);
bufferColors
.
push_back
(
colorPerXXX
[
c
]);
b
=
c
;
c
=
map
.
phi1
(
b
);
}
while
(
c
!=
d
);
}
m_nbTris
=
buffer
.
size
()
/
3
;
vboPosition
.
setDataSize
(
3
);
vboPosition
.
allocate
(
buffer
.
size
());
VEC3
*
ptrPos
=
reinterpret_cast
<
VEC3
*>
(
vboPosition
.
lockPtr
());
memcpy
(
ptrPos
,
&
buffer
[
0
],
buffer
.
size
()
*
sizeof
(
VEC3
));
vboPosition
.
releasePtr
();
vboColor
.
setDataSize
(
3
);
vboColor
.
allocate
(
bufferColors
.
size
());
VEC3
*
ptrCol
=
reinterpret_cast
<
VEC3
*>
(
vboColor
.
lockPtr
());
memcpy
(
ptrCol
,
&
bufferColors
[
0
],
bufferColors
.
size
()
*
sizeof
(
VEC3
));
vboColor
.
releasePtr
();
}
template
<
typename
PFP
>
void
ColorPerFaceRender
::
updateVBO
(
Utils
::
VBO
&
vboPosition
,
Utils
::
VBO
&
vboNormal
,
Utils
::
VBO
&
vboColor
,
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
const
typename
PFP
::
TVEC3
&
normals
,
const
typename
PFP
::
TVEC3
&
colorPerXXX
,
const
FunctorSelect
&
good
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
std
::
vector
<
VEC3
>
buffer
;
buffer
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferNormals
;
bufferNormals
.
reserve
(
16384
);
std
::
vector
<
VEC3
>
bufferColors
;
bufferColors
.
reserve
(
16384
);
TraversorCell
<
typename
PFP
::
MAP
>
traFace
(
map
,
FACE
,
good
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
Dart
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
{
buffer
.
push_back
(
positions
[
d
]);
bufferNormals
.
push_back
(
normals
[
d
]);
bufferColors
.
push_back
(
colorPerXXX
[
d
]);
buffer
.
push_back
(
positions
[
b
]);
bufferNormals
.
push_back
(
normals
[
b
]);
bufferColors
.
push_back
(
colorPerXXX
[
b
]);
buffer
.
push_back
(
positions
[
c
]);