Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Pitiot
CGoGN
Commits
7596ab32
Commit
7596ab32
authored
Feb 20, 2012
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn:~thery/CGoGN
parents
a52d10da
c2731df0
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
568 additions
and
84 deletions
+568
-84
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/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/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/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 @
7596ab32
...
...
@@ -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 @
7596ab32
...
...
@@ -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 @
7596ab32
...
...
@@ -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 @
7596ab32
...
...
@@ -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 @
7596ab32
...
...
@@ -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 @
7596ab32
...
...
@@ -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 @
7596ab32
...
...
@@ -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/Render/GL2/colorPerFaceRender.h
0 → 100644
View file @
7596ab32
/*******************************************************************************
* 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 @
7596ab32
/*******************************************************************************
* 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
]);
bufferNormals
.
push_back
(
normals
[
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
();
vboNormal
.
setDataSize
(
3
);
vboNormal
.
allocate
(
bufferColors
.
size
());
VEC3
*
ptrNorm
=
reinterpret_cast
<
VEC3
*>
(
vboNormal
.
lockPtr
());
memcpy
(
ptrNorm
,
&
bufferColors
[
0
],
bufferColors
.
size
()
*
sizeof
(
VEC3
));
vboNormal
.
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
();
}
inline
void
ColorPerFaceRender
::
draw
(
Utils
::
GLSLShader
*
sh
)
{
sh
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
0
,
m_nbTris
*
3
);
sh
->
disableVertexAttribs
();
}
}
//end namespace VBO
}
//end namespace Algo
}
//end namespace Render
}
//end namespace CGoGN
include/Topology/generic/genericmap.h
View file @
7596ab32
...
...
@@ -55,7 +55,7 @@ class MapBrowser
public:
virtual
Dart
begin
()
=
0
;
virtual
Dart
end
()
=
0
;
virtual
void
next
(
Dart
&
d
)
=
0
;
virtual
Dart
next
(
Dart
&
d
)
=
0
;
};
class
AttributeHandlerGen
;
...
...
@@ -254,7 +254,7 @@ public:
/**
* get the index of dart in topological table
*/
unsigned
int
dartIndex
(
Dart
d
);
unsigned
int
dartIndex
(
Dart
d
)
const
;
/**
* get the insertion level of a dart (use only in MRMaps)
...
...
@@ -539,7 +539,7 @@ public:
* in the order of storage
* @param d reference to the dart to be modified
*/
void
next
(
Dart
&
d
)
;
Dart
next
(
Dart
&
d
)
;
/**
* Apply a functor on each dart of the map
...
...
@@ -601,7 +601,7 @@ public:
/**
* test if a dart belong to the boundary
*/
bool
isBoundaryMarked
(
Dart
d
);
bool
isBoundaryMarked
(
Dart
d
)
const
;
protected:
/**
...
...
include/Topology/generic/genericmap.hpp
View file @
7596ab32
...
...
@@ -187,7 +187,7 @@ inline void GenericMap::duplicateDart(Dart d)
}
}
inline
unsigned
int
GenericMap
::
dartIndex
(
Dart
d
)
inline
unsigned
int
GenericMap
::
dartIndex
(
Dart
d
)
const
{
if
(
m_isMultiRes
)
return
(
*
m_mrDarts
[
m_mrCurrentLevel
])[
d
.
index
]
;
...
...
@@ -360,7 +360,7 @@ inline Dart GenericMap::end()
return
Dart
::
create
(
m_attribs
[
DART
].
end
())
;
}
inline
void
GenericMap
::
next
(
Dart
&
d
)
inline
Dart
GenericMap
::
next
(
Dart
&
d
)
{
if
(
m_isMultiRes
)
{
...
...
@@ -371,6 +371,7 @@ inline void GenericMap::next(Dart& d)
}
else
m_attribs
[
DART
].
next
(
d
.
index
)
;
return
d
;
}
/****************************************
...
...
@@ -396,4 +397,25 @@ inline AttributeMultiVector<Dart>* GenericMap::getRelation(const std::string& na
return
amv
;
}
/**************************
* BOUNDARY MANAGEMENT *
**************************/
inline
void
GenericMap
::
boundaryMark
(
Dart
d
)
{
m_markTables
[
DART
][
0
]
->
operator
[](
dartIndex
(
d
)).
setMark
(
m_boundaryMarker
);
}
inline
void
GenericMap
::
boundaryUnmark
(
Dart
d
)
{
m_markTables
[
DART
][
0
]
->
operator
[](
dartIndex
(
d
)).
unsetMark
(
m_boundaryMarker
);
}
inline
bool
GenericMap
::
isBoundaryMarked
(
Dart
d
)
const
{