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
David Cazier
CGoGN
Commits
c3d7a637
Commit
c3d7a637
authored
Jan 25, 2012
by
Sylvain Thery
Browse files
add tuto_orbits, show all orbits (with new ones !)
parent
efc05fd5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto_orbits.cpp
0 → 100644
View file @
c3d7a637
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, 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.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
"tuto_orbits.h"
#include
<iostream>
#include
"Algo/Modelisation/primitives3d.h"
#include
"Algo/Modelisation/polyhedron.h"
#include
"Algo/Modelisation/subdivision.h"
#include
"Algo/Render/GL2/topo3Render.h"
#include
"Algo/Render/SVG/mapSVGRender.h"
#include
"Algo/Import/import.h"
PFP
::
MAP
myMap
;
PFP
::
TVEC3
position
;
PFP
::
TVEC3
middleDarts
;
void
MyQT
::
text_onoff
(
bool
x
)
{
render_text
=
!
render_text
;
updateGL
();
CGoGNerr
<<
" text_onoff "
<<
CGoGNflush
;
}
void
MyQT
::
slider_text
(
int
x
)
{
m_strings
->
setScale
(
0.02
f
*
x
);
updateGL
();
}
void
MyQT
::
orbit_list
(
int
x
)
{
storeVerticesInfo
<
int
>
(
m_att_orbits
[
x
]);
current_orbit
=
x
;
updateGL
();
}
template
<
typename
T
>
void
MyQT
::
storeVerticesInfo
(
const
AttributeHandler
<
T
>&
attrib
)
{
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
myMap
);
m_render_topo
->
computeDartMiddlePositions
<
PFP
>
(
myMap
,
middleDarts
,
nb
);
m_strings
->
clear
();
for
(
Dart
d
=
myMap
.
begin
();
d
!=
myMap
.
end
();
myMap
.
next
(
d
))
{
if
(
nb
(
d
))
{
std
::
stringstream
ss
;
ss
<<
attrib
[
d
];
m_strings
->
addString
(
ss
.
str
(),
middleDarts
[
d
]);
}
}
m_strings
->
sendToVBO
();
}
void
MyQT
::
cb_initGL
()
{
// choose to use GL version 2
Utils
::
GLSLShader
::
setCurrentOGLVersion
(
2
);
m_render_topo
=
new
Algo
::
Render
::
GL2
::
Topo3Render
();
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
myMap
);
m_render_topo
->
updateData
<
PFP
>
(
myMap
,
position
,
0.9
f
,
0.8
f
,
0.8
f
,
nb
);
m_strings
=
new
Utils
::
Strings3D
(
true
,
Geom
::
Vec3f
(
0.1
f
,
0.0
f
,
0.3
f
));
registerShader
(
m_strings
);
storeVerticesInfo
<
int
>
(
m_att_orbits
[
0
]);
}
void
MyQT
::
cb_redraw
()
{
m_render_topo
->
drawTopo
();
for
(
unsigned
int
i
=
0
;
i
<
m_selected
.
size
();
++
i
)
m_render_topo
->
overdrawDart
(
m_selected
[
i
],
5
,
1.0
f
,
0.0
f
,
1.0
f
);
if
(
render_text
)
m_strings
->
drawAll
(
Geom
::
Vec3f
(
0.0
f
,
1.0
f
,
1.0
f
));
}
void
MyQT
::
cb_mousePress
(
int
button
,
int
x
,
int
y
)
{
if
(
Shift
())
{
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
myMap
);
Dart
d
=
m_render_topo
->
picking
<
PFP
>
(
myMap
,
x
,
y
,
nb
);
if
(
d
!=
Dart
::
nil
())
{
unsigned
int
orbs
[
9
]
=
{
VERTEX
,
EDGE
,
FACE
,
VOLUME
,
PFP
::
MAP
::
ORBIT_IN_PARENT
(
VERTEX
),
PFP
::
MAP
::
ORBIT_IN_PARENT
(
EDGE
),
PFP
::
MAP
::
ORBIT_IN_PARENT
(
FACE
),
PFP
::
MAP
::
ORBIT_IN_PARENT2
(
VERTEX
),
PFP
::
MAP
::
ORBIT_IN_PARENT2
(
EDGE
)};
m_selected
.
clear
();
// easy way to traverse darts of orbit
TraversorDartsOfOrbit
<
PFP
::
MAP
>
tra
(
myMap
,
orbs
[
current_orbit
],
d
);
for
(
Dart
e
=
tra
.
begin
();
e
!=
tra
.
end
();
e
=
tra
.
next
())
m_selected
.
push_back
(
e
);
}
updateGL
();
}
}
void
MyQT
::
initMap
()
{
std
::
cout
<<
"INIT MAP"
<<
std
::
endl
;
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
);
Algo
::
Modelisation
::
Primitive3D
<
PFP
>
prim
(
myMap
,
position
);
int
nb
=
2
;
prim
.
hexaGrid_topo
(
nb
,
nb
,
nb
);
prim
.
embedHexaGrid
(
1.0
f
,
1.0
f
,
1.0
f
);
m_att_orbits
[
0
]
=
myMap
.
addAttribute
<
int
>
(
VERTEX
,
"vertex"
);
m_att_orbits
[
1
]
=
myMap
.
addAttribute
<
int
>
(
EDGE
,
"edge"
);
m_att_orbits
[
2
]
=
myMap
.
addAttribute
<
int
>
(
FACE
,
"face"
);
m_att_orbits
[
3
]
=
myMap
.
addAttribute
<
int
>
(
VOLUME
,
"volume"
);
m_att_orbits
[
4
]
=
myMap
.
addAttribute
<
int
>
(
PFP
::
MAP
::
ORBIT_IN_PARENT
(
VERTEX
),
"vertex2"
);
m_att_orbits
[
5
]
=
myMap
.
addAttribute
<
int
>
(
PFP
::
MAP
::
ORBIT_IN_PARENT
(
EDGE
),
"edge2"
);
m_att_orbits
[
6
]
=
myMap
.
addAttribute
<
int
>
(
PFP
::
MAP
::
ORBIT_IN_PARENT
(
FACE
),
"face2"
);
m_att_orbits
[
7
]
=
myMap
.
addAttribute
<
int
>
(
PFP
::
MAP
::
ORBIT_IN_PARENT2
(
VERTEX
),
"vertex1"
);
m_att_orbits
[
8
]
=
myMap
.
addAttribute
<
int
>
(
PFP
::
MAP
::
ORBIT_IN_PARENT2
(
EDGE
),
"face1"
);
int
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra0
(
myMap
,
VERTEX
);
for
(
Dart
d
=
tra0
.
begin
();
d
!=
tra0
.
end
();
d
=
tra0
.
next
())
{
m_att_orbits
[
0
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra1
(
myMap
,
EDGE
);
for
(
Dart
d
=
tra1
.
begin
();
d
!=
tra1
.
end
();
d
=
tra1
.
next
())
{
m_att_orbits
[
1
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra2
(
myMap
,
FACE
);
for
(
Dart
d
=
tra2
.
begin
();
d
!=
tra2
.
end
();
d
=
tra2
.
next
())
{
m_att_orbits
[
2
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra3
(
myMap
,
VOLUME
);
for
(
Dart
d
=
tra3
.
begin
();
d
!=
tra3
.
end
();
d
=
tra3
.
next
())
{
m_att_orbits
[
3
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra02
(
myMap
,
PFP
::
MAP
::
ORBIT_IN_PARENT
(
VERTEX
));
for
(
Dart
d
=
tra02
.
begin
();
d
!=
tra02
.
end
();
d
=
tra02
.
next
())
{
m_att_orbits
[
4
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra12
(
myMap
,
PFP
::
MAP
::
ORBIT_IN_PARENT
(
EDGE
));
for
(
Dart
d
=
tra12
.
begin
();
d
!=
tra12
.
end
();
d
=
tra12
.
next
())
{
m_att_orbits
[
5
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra22
(
myMap
,
PFP
::
MAP
::
ORBIT_IN_PARENT
(
FACE
));
for
(
Dart
d
=
tra22
.
begin
();
d
!=
tra22
.
end
();
d
=
tra22
.
next
())
{
m_att_orbits
[
6
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra01
(
myMap
,
PFP
::
MAP
::
ORBIT_IN_PARENT2
(
VERTEX
));
for
(
Dart
d
=
tra01
.
begin
();
d
!=
tra01
.
end
();
d
=
tra01
.
next
())
{
m_att_orbits
[
7
][
d
]
=
i
++
;
}
i
=
0
;
TraversorCell
<
PFP
::
MAP
>
tra11
(
myMap
,
PFP
::
MAP
::
ORBIT_IN_PARENT2
(
EDGE
));
for
(
Dart
d
=
tra11
.
begin
();
d
!=
tra11
.
end
();
d
=
tra11
.
next
())
{
m_att_orbits
[
8
][
d
]
=
i
++
;
}
middleDarts
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
DART
,
"middle"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
// un peu d'interface
QApplication
app
(
argc
,
argv
);
MyQT
sqt
;
// interface de tuto5.ui
Utils
::
QT
::
uiDockInterface
dock
;
sqt
.
setDock
(
&
dock
);
// message d'aide
sqt
.
setHelpMsg
(
"Enter pour dock on/off
\n
Shift Enter pour console on/off
\n
Shift Click gauche pour selectionner un brin"
);
sqt
.
initMap
();
// bounding box
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
float
lWidthObj
=
std
::
max
<
PFP
::
REAL
>
(
std
::
max
<
PFP
::
REAL
>
(
bb
.
size
(
0
),
bb
.
size
(
1
)),
bb
.
size
(
2
));
Geom
::
Vec3f
lPosObj
=
(
bb
.
min
()
+
bb
.
max
())
/
PFP
::
REAL
(
2
);
// envoit info BB a l'interface
sqt
.
setParamObject
(
lWidthObj
,
lPosObj
.
data
());
sqt
.
setCallBack
(
dock
.
checkBox_text
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
text_onoff
(
bool
))
);
sqt
.
setCallBack
(
dock
.
slider_text
,
SIGNAL
(
valueChanged
(
int
)),
SLOT
(
slider_text
(
int
))
);
sqt
.
setCallBack
(
dock
.
Orbits
,
SIGNAL
(
currentIndexChanged
(
int
)),
SLOT
(
orbit_list
(
int
))
);
sqt
.
show
();
sqt
.
slider_text
(
50
);
// et on attend la fin.
return
app
.
exec
();
}
Apps/Tuto/tuto_orbits.h
0 → 100644
View file @
c3d7a637
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, 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.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __TUTO5_
#define __TUTO5_
#include
<iostream>
//#define WITH_GMAP 1
#include
"Topology/generic/parameters.h"
#ifdef WITH_GMAP
#include
"Topology/gmap/embeddedGMap3.h"
#else
#include
"Topology/map/embeddedMap3.h"
#endif
#include
"Geometry/vector_gen.h"
#include
"Algo/Geometry/boundingbox.h"
#include
"Algo/Render/GL2/mapRender.h"
#include
"Utils/Shaders/shaderSimpleColor.h"
#include
"Algo/Render/GL2/topo3Render.h"
#include
"Topology/generic/cellmarker.h"
#include
"Utils/text3d.h"
#include
"Utils/pointSprite.h"
#include
"Utils/Shaders/shaderVectorPerVertex.h"
#include
"Utils/cgognStream.h"
#include
"Algo/Render/GL2/explodeVolumeRender.h"
#include
"Utils/Qt/qtSimple.h"
#include
"ui_tuto_orbits.h"
// inclure qtui.h juste après le ui_xxx.h
#include
"Utils/Qt/qtui.h"
using
namespace
CGoGN
;
struct
PFP
:
public
PFP_STANDARD
{
// definition de la carte
#ifdef WITH_GMAP
typedef
EmbeddedGMap3
MAP
;
#else
typedef
EmbeddedMap3
MAP
;
#endif
};
using
namespace
CGoGN
;
/**
* Utilisation de designer-qt4:
* Faire un DockWiget (laisser le nom par defaut
* dans le Contents ajouter le layout choisi (vertical classiquement)
* Ajouter les widgets necessaires, mettre des noms clairs pour
* les utiliser dans le .cpp (pour les call back principalement)
*/
class
MyQT
:
public
Utils
::
QT
::
SimpleQT
{
Q_OBJECT
bool
render_text
;
bool
render_balls
;
bool
render_vectors
;
bool
render_topo
;
Algo
::
Render
::
GL2
::
MapRender
*
m_render
;
Algo
::
Render
::
GL2
::
Topo3Render
*
m_render_topo
;
Utils
::
VBO
*
m_positionVBO
;
Utils
::
VBO
*
m_dataVBO
;
Utils
::
ShaderSimpleColor
*
m_shader
;
Utils
::
ShaderVectorPerVertex
*
m_lines
;
Utils
::
Strings3D
*
m_strings
;
Utils
::
PointSprite
*
m_sprite
;
Algo
::
Render
::
GL2
::
ExplodeVolumeRender
*
m_explodeRender
;
// AttributeHandler<int> attv2;
AttributeHandler
<
int
>
m_att_orbits
[
9
];
QTimer
*
m_timer
;
unsigned
int
current_orbit
;
public:
MyQT
()
:
render_text
(
true
),
render_balls
(
true
),
render_vectors
(
true
),
render_topo
(
true
),
m_render
(
NULL
),
m_render_topo
(
NULL
),
m_positionVBO
(
NULL
),
m_dataVBO
(
NULL
),
m_shader
(
NULL
),
m_lines
(
NULL
),
m_strings
(
NULL
),
m_sprite
(
NULL
),
m_timer
(
NULL
),
current_orbit
(
0
)
{}
std
::
vector
<
Dart
>
m_selected
;
void
initMap
();
protected:
template
<
typename
T
>
void
storeVerticesInfo
(
const
AttributeHandler
<
T
>&
attrib
);
void
cb_redraw
();
void
cb_initGL
();
void
cb_mousePress
(
int
button
,
int
x
,
int
y
);
// slots locaux
public
slots
:
void
text_onoff
(
bool
x
);
void
slider_text
(
int
x
);
void
orbit_list
(
int
x
);
};
#endif
Apps/Tuto/tuto_orbits.ui
0 → 100644
View file @
c3d7a637
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
DockWidget
</class>
<widget
class=
"QDockWidget"
name=
"DockWidget"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
293
</width>
<height>
507
</height>
</rect>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
150
</width>
<height>
250
</height>
</size>
</property>
<property
name=
"windowTitle"
>
<string>
Interface
</string>
</property>
<widget
class=
"QWidget"
name=
"dockWidgetContents"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
150
</width>
<height>
200
</height>
</size>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<property
name=
"margin"
>
<number>
2
</number>
</property>
<property
name=
"spacing"
>
<number>
4
</number>
</property>
<item
row=
"0"
column=
"0"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"Line"
name=
"line_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"checkBox_text"
>
<property
name=
"text"
>
<string>
Display attribute
</string>
</property>
<property
name=
"checked"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QSlider"
name=
"slider_text"
>
<property
name=
"value"
>
<number>
50
</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=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Select orbit:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"Orbits"
>
<property
name=
"focusPolicy"
>
<enum>
Qt::NoFocus
</enum>
</property>
<item>
<property
name=
"text"
>
<string>
Vertex
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Edge
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Face
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Volume
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Vertex_of_parent
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Edge_of_parent
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Face_of_parent
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Vertex_of_parent2
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Edge_of_parent_2
</string>
</property>
</item>
</widget>
</item>
<item>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
40
</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>
checkBox_text
</sender>
<signal>
toggled(bool)
</signal>
<receiver>
slider_text
</receiver>
<slot>
setVisible(bool)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
95
</x>
<y>
157
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
95
</x>
<y>
183
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
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