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
f348eec9
Commit
f348eec9
authored
Feb 28, 2011
by
untereiner
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of cgogn:~thery/CGoGN
parents
23236543
4cd0c557
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
353 additions
and
66 deletions
+353
-66
Apps/Examples/Debug/CMakeLists.txt
Apps/Examples/Debug/CMakeLists.txt
+6
-0
Apps/Tuto/tuto5.cpp
Apps/Tuto/tuto5.cpp
+62
-23
Apps/Tuto/tuto_ogl2.cpp
Apps/Tuto/tuto_ogl2.cpp
+0
-1
include/Algo/Render/gl3mapRender.h
include/Algo/Render/gl3mapRender.h
+14
-2
include/Algo/Render/topo3_vboRender.h
include/Algo/Render/topo3_vboRender.h
+31
-1
include/Algo/Render/topo3_vboRender.hpp
include/Algo/Render/topo3_vboRender.hpp
+44
-0
include/Topology/generic/dartmarker.h
include/Topology/generic/dartmarker.h
+14
-0
include/Topology/generic/genericFunc.h
include/Topology/generic/genericFunc.h
+61
-38
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+34
-0
src/Algo/Render/topo3_vboRender.cpp
src/Algo/Render/topo3_vboRender.cpp
+72
-1
src/Utils/glutwin.cpp
src/Utils/glutwin.cpp
+8
-0
src/Utils/glutwin_atb.cpp
src/Utils/glutwin_atb.cpp
+7
-0
No files found.
Apps/Examples/Debug/CMakeLists.txt
View file @
f348eec9
...
@@ -65,3 +65,9 @@ target_link_libraries( extrusionViewD
...
@@ -65,3 +65,9 @@ target_link_libraries( extrusionViewD
add_executable
(
sceneD ../scene.cpp
)
add_executable
(
sceneD ../scene.cpp
)
target_link_libraries
(
sceneD
target_link_libraries
(
sceneD
containerD topologyD utilsD algoD
${
COMMON_LIBS
}
)
containerD topologyD utilsD algoD
${
COMMON_LIBS
}
)
#add_executable( VizVolumeD ../VizVolume.cpp)
#target_link_libraries( VizVolumeD
# containerD topologyD utilsD algoD ${COMMON_LIBS} Zinri)
Apps/Tuto/tuto5.cpp
View file @
f348eec9
...
@@ -43,8 +43,6 @@
...
@@ -43,8 +43,6 @@
#include "Algo/Render/topo3_vboRender.h"
#include "Algo/Render/topo3_vboRender.h"
//#include "Algo/Render/topo_vboRender.h"
#include "Topology/generic/cellmarker.h"
#include "Topology/generic/cellmarker.h"
//#include "testMaps.h"
//#include "testMaps.h"
...
@@ -189,6 +187,42 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
...
@@ -189,6 +187,42 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
}
}
break
;
break
;
case
'x'
:
{
// push/pop color is only needed for dart coloring conservation
// can bee long long huge meshes
m_render_topo
->
pushColors
();
// setDartsIdColor can be done only once if dart coloring not used
m_render_topo
->
setDartsIdColor
<
PFP
>
(
myMap
,
allDarts
);
// transform as in drawing cb
glPushMatrix
();
float
sc
=
50.0
f
/
gWidthObj
;
glScalef
(
sc
,
sc
,
sc
);
glTranslatef
(
-
gPosObj
[
0
],
-
gPosObj
[
1
],
-
gPosObj
[
2
]);
//pick
Dart
d
=
m_render_topo
->
picking
(
x
,
H
-
y
);
glPopMatrix
();
m_render_topo
->
popColors
();
if
(
d
!=
Dart
::
nil
())
{
redraw
();
std
::
stringstream
ss
;
ss
<<
"Pick dart:"
<<
d
<<
std
::
endl
<<
"pos="
<<
position
[
d
];
glColor3f
(
1.
,
1.
,
0.
);
printString2D
(
x
+
12
,
y
+
22
,
ss
.
str
());
glutSwapBuffers
();
// std::cout << "Pick dart:" << d << " position= "<< position[d] << std::endl;
std
::
cout
<<
"Pick dart:"
<<
d
<<
std
::
endl
;
}
// in console:
break
;
}
case
'Q'
:
case
'Q'
:
m_render_topo
->
setAllDartsColor
(
1.0
f
,
1.0
f
,
1.0
f
);
m_render_topo
->
setAllDartsColor
(
1.0
f
,
1.0
f
,
1.0
f
);
glutPostRedisplay
();
glutPostRedisplay
();
...
@@ -380,33 +414,38 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
...
@@ -380,33 +414,38 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
std
::
vector
<
std
::
string
>
attrNames
;
// std::vector<std::string> attrNames ;
Algo
::
Import
::
importInESS
<
PFP
>
(
myMap
,
argv
[
1
],
attrNames
);
// Algo::Import::importInESS<PFP>(myMap, argv[1], attrNames);
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
attrNames
[
0
])
;
// position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
//plongement
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"position"
);
// Algo::Modelisation::Primitive3D<PFP> prim(myMap,position);
// dglobal = prim.hexaGrid_topo(3,3,3);
// prim.embedHexaGrid(1.0f,1.0f,1.0f);
Algo
::
Modelisation
::
Primitive3D
<
PFP
>
prim
(
myMap
,
position
);
int
nb
=
3
;
if
(
argc
>
1
)
nb
=
atoi
(
argv
[
1
]);
dglobal
=
prim
.
hexaGrid_topo
(
nb
,
nb
,
nb
);
prim
.
embedHexaGrid
(
1.0
f
,
1.0
f
,
1.0
f
);
// Geom::Matrix44f mat;
// Geom::Matrix44f mat;
// mat.identity();
// mat.identity();
// Geom::scale(2.0f, 2.0f,2.0f,mat);
// Geom::scale(2.0f, 2.0f,2.0f,mat);
// prim.transform(mat);
// prim.transform(mat);
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createOrientedPolyhedron
(
myMap
,
6
);
//
Dart d = Algo::Modelisation::Polyhedron<PFP>::createOrientedPolyhedron(myMap,6);
dglobal
=
d
;
//
dglobal=d;
//
position
[
d
]
=
PFP
::
VEC3
(
0
);
//
position[d] = PFP::VEC3(0);
position
[
myMap
.
phi1
(
d
)]
=
PFP
::
VEC3
(
1
,
0
,
0
);
//
position[myMap.phi1(d)] = PFP::VEC3(1,0,0);
position
[
myMap
.
phi1
(
myMap
.
phi1
(
d
))]
=
PFP
::
VEC3
(
1
,
0
,
1
);
//
position[myMap.phi1(myMap.phi1(d))] = PFP::VEC3(1,0,1);
position
[
myMap
.
phi_1
(
d
)]
=
PFP
::
VEC3
(
0
,
0
,
1
);
//
position[myMap.phi_1(d)] = PFP::VEC3(0,0,1);
//
d
=
myMap
.
phi_1
(
myMap
.
phi2
(
myMap
.
phi_1
(
myMap
.
phi_1
(
myMap
.
phi2
(
myMap
.
phi_1
(
d
))))));
//
d = myMap.phi_1(myMap.phi2(myMap.phi_1(myMap.phi_1(myMap.phi2(myMap.phi_1(d))))));
position
[
d
]
=
PFP
::
VEC3
(
1
,
1
,
0
);
//
position[d] = PFP::VEC3(1,1,0);
position
[
myMap
.
phi1
(
d
)]
=
PFP
::
VEC3
(
0
,
1
,
0
);
//
position[myMap.phi1(d)] = PFP::VEC3(0,1,0);
position
[
myMap
.
phi1
(
myMap
.
phi1
(
d
))]
=
PFP
::
VEC3
(
0
,
1
,
1
);
//
position[myMap.phi1(myMap.phi1(d))] = PFP::VEC3(0,1,1);
position
[
myMap
.
phi_1
(
d
)]
=
PFP
::
VEC3
(
1
,
1
,
1
);
//
position[myMap.phi_1(d)] = PFP::VEC3(1,1,1);
// Dart d = Algo::Modelisation::Polyhedron<PFP>::createOrientedPolyhedron(myMap,4);
// Dart d = Algo::Modelisation::Polyhedron<PFP>::createOrientedPolyhedron(myMap,4);
// dglobal=d;
// dglobal=d;
...
...
Apps/Tuto/tuto_ogl2.cpp
View file @
f348eec9
...
@@ -177,7 +177,6 @@ int main(int argc, char **argv)
...
@@ -177,7 +177,6 @@ int main(int argc, char **argv)
// mgw.m_render->initPrimitives<PFP>(myMap, allDarts,Algo::Render::VBO::POINTS);
// mgw.m_render->initPrimitives<PFP>(myMap, allDarts,Algo::Render::VBO::POINTS);
mgw
.
mainLoop
();
mgw
.
mainLoop
();
return
0
;
return
0
;
...
...
include/Algo/Render/gl3mapRender.h
View file @
f348eec9
...
@@ -76,13 +76,25 @@ protected:
...
@@ -76,13 +76,25 @@ protected:
* vbo buffers
* vbo buffers
*/
*/
GLuint
m_VBOBuffers
[
NB_BUFFERS
]
;
GLuint
m_VBOBuffers
[
NB_BUFFERS
]
;
// bool m_allocatedBuffers[NB_BUFFERS] ;
// bool m_usedBuffers[NB_BUFFERS] ;
/**
*
*/
bool
m_allocatedAttributes
[
NB_BUFFERS
]
;
bool
m_allocatedAttributes
[
NB_BUFFERS
]
;
/**
*
*/
bool
m_usedAttributes
[
NB_BUFFERS
]
;
bool
m_usedAttributes
[
NB_BUFFERS
]
;
/**
*
*/
unsigned
int
m_AttributesDataSize
[
NB_BUFFERS
];
unsigned
int
m_AttributesDataSize
[
NB_BUFFERS
];
/**
*
*/
std
::
map
<
std
::
string
,
GLuint
>
m_attributebyName
;
std
::
map
<
std
::
string
,
GLuint
>
m_attributebyName
;
/**
/**
...
...
include/Algo/Render/topo3_vboRender.h
View file @
f348eec9
...
@@ -85,6 +85,9 @@ protected:
...
@@ -85,6 +85,9 @@ protected:
*/
*/
float
m_topo_relation_width
;
float
m_topo_relation_width
;
float
*
m_color_save
;
AttributeHandler
<
unsigned
int
>
m_attIndex
;
AttributeHandler
<
unsigned
int
>
m_attIndex
;
/**
/**
...
@@ -207,10 +210,37 @@ public:
...
@@ -207,10 +210,37 @@ public:
* @param g green !
* @param g green !
* @param b blue !
* @param b blue !
*/
*/
void
overdrawDart
(
Dart
d
,
float
width
,
float
r
,
float
g
,
float
b
);
void
overdrawDart
(
Dart
d
,
float
width
,
float
r
,
float
g
,
float
b
);
/**
* save colors
*/
void
pushColors
();
/**
* restore colors
*/
void
popColors
();
/*
* store darts in color for picking
* @param map the map (must be the same than during updating data)
* @param good the selector (must be the same than during updating data)
*/
template
<
typename
PFP
>
void
setDartsIdColor
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
);
/**
* pick dart with color set bey setDartsIdColor
* Do not forget to apply same transformation to scene before picking than before drawing !
* @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL
*/
Dart
picking
(
unsigned
int
x
,
unsigned
int
y
);
};
};
//template<typename MAP>
//template<typename MAP>
...
...
include/Algo/Render/topo3_vboRender.hpp
View file @
f348eec9
...
@@ -890,6 +890,50 @@ void topo3_VBORenderMapD::updateData(typename PFP::MAP& map, const FunctorSelect
...
@@ -890,6 +890,50 @@ void topo3_VBORenderMapD::updateData(typename PFP::MAP& map, const FunctorSelect
//}
//}
template
<
typename
PFP
>
void
topo3_VBORender
::
setDartsIdColor
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
)
{
glBindBufferARB
(
GL_ARRAY_BUFFER
,
m_VBOBuffers
[
4
]);
float
*
colorBuffer
=
reinterpret_cast
<
float
*>
(
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
));
unsigned
int
nb
=
0
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
nb
<
m_nbDarts
)
{
if
(
good
(
d
))
{
unsigned
int
lab
=
d
.
index
+
1
;
// add one to avoid picking the black of screen
float
r
=
float
(
lab
%
256
)
/
256.0
f
;
lab
=
lab
/
256
;
float
g
=
float
(
lab
%
256
)
/
256.0
f
;
lab
=
lab
/
256
;
float
b
=
float
(
lab
%
256
)
/
256.0
f
;
lab
=
lab
/
256
;
if
(
lab
!=
0
)
std
::
cerr
<<
"Error picking color, too many darts"
<<
std
::
endl
;
*
colorBuffer
++
=
r
;
*
colorBuffer
++
=
g
;
*
colorBuffer
++
=
b
;
*
colorBuffer
++
=
r
;
*
colorBuffer
++
=
g
;
*
colorBuffer
++
=
b
;
nb
++
;
}
}
else
{
std
::
cerr
<<
"Error buffer too small for color picking (change the good parameter ?)"
<<
std
::
endl
;
d
=
map
.
end
();
}
}
glUnmapBufferARB
(
GL_ARRAY_BUFFER
);
}
}
//end namespace VBO
}
//end namespace VBO
}
//end namespace Algo
}
//end namespace Algo
...
...
include/Topology/generic/dartmarker.h
View file @
f348eec9
...
@@ -182,6 +182,20 @@ public:
...
@@ -182,6 +182,20 @@ public:
FunctorUnmark
<
GenericMap
>
fm
(
m_map
,
m_marker
,
m_map
.
getMarkerVector
(
DART_ORBIT
,
m_thread
))
;
FunctorUnmark
<
GenericMap
>
fm
(
m_map
,
m_marker
,
m_map
.
getMarkerVector
(
DART_ORBIT
,
m_thread
))
;
m_map
.
foreach_dart_of_orbit
(
orbit
,
d
,
fm
,
m_thread
)
;
m_map
.
foreach_dart_of_orbit
(
orbit
,
d
,
fm
,
m_thread
)
;
}
}
template
<
typename
MAP
>
void
markOrbitInParent
(
unsigned
int
orbit
,
Dart
d
)
{
FunctorMark
<
GenericMap
>
fm
(
m_map
,
m_marker
,
m_map
.
getMarkerVector
(
DART_ORBIT
,
m_thread
))
;
foreach_dart_of_orbit_in_parent
<
MAP
>
(
dynamic_cast
<
MAP
*>
(
&
m_map
),
orbit
,
d
,
fm
,
m_thread
);
}
template
<
typename
MAP
>
void
unmarkOrbit
(
unsigned
int
orbit
,
Dart
d
)
{
FunctorUnmark
<
GenericMap
>
fm
(
m_map
,
m_marker
,
m_map
.
getMarkerVector
(
DART_ORBIT
,
m_thread
))
;
foreach_dart_of_orbit_in_parent
<
MAP
>
(
m_map
,
orbit
,
d
,
fm
,
m_thread
);
}
};
};
/**
/**
...
...
include/Topology/generic/genericFunc.h
View file @
f348eec9
...
@@ -38,27 +38,52 @@
...
@@ -38,27 +38,52 @@
namespace
CGoGN
namespace
CGoGN
{
{
/**
///**
* mark darts of a cell with marker m
//* mark darts of a cell with marker m
* Warning: works only if any darts of vertex is already marked
//* Warning: works only if any darts of vertex is already marked
* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
* @param MF type of Map used for traversals
//* @param MF type of Map used for traversals
* @param d a dart of the cc
//* @param d a dart of the cc
* @param m index of the marker
//* @param m index of the marker
*/
//*/
template
<
typename
MF
,
typename
MM
>
//template <typename MF, typename MM>
void
markOrbitGen
(
int
dim
,
typename
MM
::
Dart
d
,
Marker
m
,
MM
*
ptr
,
unsigned
int
th
=
0
);
//void markOrbitGen(int dim, typename MM::Dart d, Marker m, MM *ptr, unsigned int th=0);
//
///**
//* unmark darts of a cell with marker m
//* Warning: works only if any darts of vertex is already marked
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param MF type of Map used for traversals
//* @param d a dart of the cc
//* @param m index of the marker
//*/
//template <typename MF, typename MM>
//void unmarkOrbitGen(int dim, typename MM::Dart d, Marker m, MM* ptr, unsigned int th=0);
//
///**
//* execute functor for each cell
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param MF type of Map used for traversals
//* @param f the functor
//*/
//template <typename MF, typename MM>
//void foreach_orbitGen(int dim, FunctorType<typename MM>& fonct, MM* ptr, unsigned int th=0);
//
//template <typename MF, typename MM>
//void foreach_orbitGen_sel(int dim, FunctorType<typename MM>& fonct, MM* ptr, FunctorType<typename MM>& good, unsigned int th=0);
//
///**
//* Associate an embedding to all darts of a vertex
//* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
//* @param MF type of Map used for traversals
//* @param d a dart of the topological vertex
//* @param index the index of Embedding to use
//* @param em the embedding to associate
//* ptr an ptr on the Map
//*/
//template <typename MF, typename MM>
//void embedOrbitGen(int dim, typename MM::Dart d, int index, Embedding* em, MM* ptr, unsigned int th=0);
/**
* unmark darts of a cell with marker m
* Warning: works only if any darts of vertex is already marked
* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
* @param MF type of Map used for traversals
* @param d a dart of the cc
* @param m index of the marker
*/
template
<
typename
MF
,
typename
MM
>
void
unmarkOrbitGen
(
int
dim
,
typename
MM
::
Dart
d
,
Marker
m
,
MM
*
ptr
,
unsigned
int
th
=
0
);
/**
/**
* execute functor for each cell
* execute functor for each cell
...
@@ -66,26 +91,24 @@ void unmarkOrbitGen(int dim, typename MM::Dart d, Marker m, MM* ptr, unsigned in
...
@@ -66,26 +91,24 @@ void unmarkOrbitGen(int dim, typename MM::Dart d, Marker m, MM* ptr, unsigned in
* @param MF type of Map used for traversals
* @param MF type of Map used for traversals
* @param f the functor
* @param f the functor
*/
*/
template
<
typename
MF
,
typename
MM
>
//template <typename MAP, typename TRAV>
void
foreach_orbitGen
(
int
dim
,
FunctorType
<
typename
MM
>&
fonct
,
MM
*
ptr
,
unsigned
int
th
=
0
);
//bool foreach_dart_of_orbit_gen(unsigned int orbit, Dart d, FunctorType& f, MAP *ptrMap, unsigned int thread=0)
//{
template
<
typename
MF
,
typename
MM
>
// switch(orbit)
void
foreach_orbitGen_sel
(
int
dim
,
FunctorType
<
typename
MM
>&
fonct
,
MM
*
ptr
,
FunctorType
<
typename
MM
>&
good
,
unsigned
int
th
=
0
);
// {
// case DART_ORBIT: return f(d);
/**
// case VERTEX_ORBIT: return ptrMap->TRAV::foreach_dart_of_vertex(d, f,thread);
* Associate an embedding to all darts of a vertex
// case EDGE_ORBIT: return ptrMap->TRAV::foreach_dart_of_edge(d, f,thread);
* @param dim the dimension of the cell: 0=vertex, 1=edge, 2=face, 3=volume, -1=connected component
// case FACE_ORBIT: return ptrMap->TRAV::foreach_dart_of_face(d, f,thread);
* @param MF type of Map used for traversals
// case VOLUME_ORBIT: return ptrMap->TRAV::foreach_dart_of_volume(d, f, thread);
* @param d a dart of the topological vertex
//// case -1: return foreach_dart_of_cc(d,f,thread);
* @param index the index of Embedding to use
// default: assert(!"Cells of this dimension are not handled");
* @param em the embedding to associate
// }
* ptr an ptr on the Map
// return false;
*/
//}
template
<
typename
MF
,
typename
MM
>
void
embedOrbitGen
(
int
dim
,
typename
MM
::
Dart
d
,
int
index
,
Embedding
*
em
,
MM
*
ptr
,
unsigned
int
th
=
0
);
}
//namespace CGoGN
}
//namespace CGoGN
#include "Topology/generic/genericFunc.hpp"
//
#include "Topology/generic/genericFunc.hpp"
#endif
#endif
include/Topology/generic/genericmap.h
View file @
f348eec9
...
@@ -404,8 +404,42 @@ public:
...
@@ -404,8 +404,42 @@ public:
* @return the number of orbits
* @return the number of orbits
*/
*/
unsigned
int
getNbOrbits
(
unsigned
int
orbit
,
const
FunctorSelect
&
good
=
SelectorTrue
());
unsigned
int
getNbOrbits
(
unsigned
int
orbit
,
const
FunctorSelect
&
good
=
SelectorTrue
());
}
;
}
;
template
<
typename
MAP
>
bool
foreach_dart_of_orbit_in_parent
(
MAP
*
ptrMap
,
unsigned
int
orbit
,
Dart
d
,
FunctorType
&
f
,
unsigned
int
thread
=
0
)
{
switch
(
orbit
)
{
case
DART_ORBIT
:
return
f
(
d
);
case
VERTEX_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
foreach_dart_of_vertex
(
d
,
f
,
thread
);
case
EDGE_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
foreach_dart_of_edge
(
d
,
f
,
thread
);
case
FACE_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
foreach_dart_of_face
(
d
,
f
,
thread
);
case
VOLUME_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
foreach_dart_of_volume
(
d
,
f
,
thread
);
default:
assert
(
!
"Cells of this dimension are not handled"
);
}
return
false
;
}
template
<
typename
MAP
>
bool
foreach_dart_of_orbit_in_parent2
(
MAP
*
ptrMap
,
unsigned
int
orbit
,
Dart
d
,
FunctorType
&
f
,
unsigned
int
thread
=
0
)
{
switch
(
orbit
)
{
case
DART_ORBIT
:
return
f
(
d
);
case
VERTEX_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
ParentMap
::
foreach_dart_of_vertex
(
d
,
f
,
thread
);
case
EDGE_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
ParentMap
::
foreach_dart_of_edge
(
d
,
f
,
thread
);
case
FACE_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
ParentMap
::
foreach_dart_of_face
(
d
,
f
,
thread
);
case
VOLUME_ORBIT
:
return
ptrMap
->
MAP
::
ParentMap
::
ParentMap
::
foreach_dart_of_volume
(
d
,
f
,
thread
);
default:
assert
(
!
"Cells of this dimension are not handled"
);
}
return
false
;
}
}
//namespace CGoGN
}
//namespace CGoGN
#include "Topology/generic/genericmap.hpp"
#include "Topology/generic/genericmap.hpp"
...
...
src/Algo/Render/topo3_vboRender.cpp
View file @
f348eec9
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "Algo/Render/topo3_vboRender.h"
#include "Algo/Render/topo3_vboRender.h"
#include "Topology/generic/dart.h"
#include "Topology/generic/dart.h"
#include <string.h>
namespace
CGoGN
namespace
CGoGN
{
{
...
@@ -40,7 +41,7 @@ namespace VBO
...
@@ -40,7 +41,7 @@ namespace VBO
topo3_VBORender
::
topo3_VBORender
()
:
topo3_VBORender
::
topo3_VBORender
()
:
m_topo_dart_width
(
2.0
f
),
m_topo_relation_width
(
3.0
f
)
m_topo_dart_width
(
2.0
f
),
m_topo_relation_width
(
3.0
f
)
,
m_color_save
(
NULL
)
{
{
glGenBuffersARB
(
5
,
m_VBOBuffers
);
glGenBuffersARB
(
5
,
m_VBOBuffers
);
}
}
...
@@ -51,6 +52,11 @@ topo3_VBORender::~topo3_VBORender()
...
@@ -51,6 +52,11 @@ topo3_VBORender::~topo3_VBORender()
glDeleteBuffersARB
(
5
,
m_VBOBuffers
);
glDeleteBuffersARB
(
5
,
m_VBOBuffers
);
if
(
m_attIndex
.
map
()
!=
NULL
)
if
(
m_attIndex
.
map
()
!=
NULL
)
static_cast
<
AttribMap
*>
(
m_attIndex
.
map
())
->
removeAttribute
(
m_attIndex
);
static_cast
<
AttribMap
*>
(
m_attIndex
.
map
())
->
removeAttribute
(
m_attIndex
);
if
(
m_color_save
!=
NULL
)
{
delete
[]
m_color_save
;
}
}
}
...
@@ -184,6 +190,71 @@ void topo3_VBORender::drawTopo()
...
@@ -184,6 +190,71 @@ void topo3_VBORender::drawTopo()
drawRelation3
();
drawRelation3
();
}
}
void
topo3_VBORender
::
pushColors
()
{
m_color_save
=
new
float
[
6
*
m_nbDarts
];
glBindBufferARB
(
GL_ARRAY_BUFFER
,
m_VBOBuffers
[
4
]);
void
*
colorBuffer
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
memcpy
(
m_color_save
,
colorBuffer
,
6
*
m_nbDarts
*
sizeof
(
float
));
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
void
topo3_VBORender
::
popColors
()
{
glBindBufferARB
(
GL_ARRAY_BUFFER
,
m_VBOBuffers
[
4
]);
void
*
colorBuffer
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
memcpy
(
colorBuffer
,
m_color_save
,
6
*
m_nbDarts
*
sizeof
(
float
));
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
delete
[]
m_color_save
;
m_color_save
=
0
;
}
Dart
topo3_VBORender
::
picking
(
unsigned
int
x
,
unsigned
int
y
)
{
//more easy picking for
unsigned
int
dw
=
m_topo_dart_width
;
m_topo_dart_width
+=
2
;
// save clear color and set to zero
float
cc
[
4
];
glGetFloatv
(
GL_COLOR_CLEAR_VALUE
,
cc
);
glClearColor
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glDisable
(
GL_LIGHTING
);
// draw in back buffer (not shown on screen)
drawDarts
();
// restore dart with
m_topo_dart_width
=
dw
;
// read the pixel under the mouse in back buffer
glReadBuffer
(
GL_BACK
);
float
color
[
3
];
glReadPixels
(
x
,
y
,
1
,
1
,
GL_RGB
,
GL_FLOAT
,
color
);
glClearColor
(
cc
[
0
],
cc
[
1
],
cc
[
2
],
cc
[
3
]);
// compute dart index:
unsigned
int
r
=
(
unsigned
int
)(
color
[
0
]
*
255.0
f
);
unsigned
int
g
=
(
unsigned
int
)(
color
[
1
]
*
255.0
f
);
unsigned
int
b
=
(
unsigned
int
)(
color
[
2
]
*
255.0
f
);
unsigned
int
id
=
r
+
256
*
g
+
256
*
256
*
b
;
if
(
id
==
0
)
return
Dart
::
nil
();
return
Dart
(
id
-
1
);
// -1 because we draw +1
}
}
//end namespace VBO
}
//end namespace VBO
...
...
src/Utils/glutwin.cpp
View file @
f348eec9
...
@@ -355,6 +355,11 @@ void SimpleGlutWin::printString2D(int x, int y, const std::string& str)
...
@@ -355,6 +355,11 @@ void SimpleGlutWin::printString2D(int x, int y, const std::string& str)
glDisable
(
GL_DEPTH_TEST
);
glDisable
(
GL_DEPTH_TEST
);
glDisable
(
GL_LIGHTING
);
glDisable
(
GL_LIGHTING
);
// not very optimized but not very important here
unsigned
char
blank
[
180
];
for
(
unsigned
int
i
=
0
;
i
<
180
;
++
i
)
blank
[
i
]
=
(
unsigned
char
)(
0
);
// AFFICHAGE EN 2D
// AFFICHAGE EN 2D