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
Thomas Pitiot
CGoGN
Commits
691f92c8
Commit
691f92c8
authored
Nov 04, 2011
by
Pierre Kraemer
Browse files
Merge cgogn:~jund/CGoGN
Conflicts: Apps/Examples/simpleGMap2.cpp
parents
6c01192e
ed50e279
Changes
40
Expand all
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/Debug/CMakeLists.txt
View file @
691f92c8
...
...
@@ -54,6 +54,16 @@ add_executable( texturesExampleD ../texturesExample.cpp ${texturesExample_moc} )
target_link_libraries
(
texturesExampleD
${
CGoGN_LIBS_D
}
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
QT4_WRAP_CPP
(
simpleGMap2_moc ../simpleGMap2.h
)
add_executable
(
simpleGMap2D ../simpleGMap2.cpp
${
simpleGMap2_moc
}
)
target_link_libraries
(
simpleGMap2D
${
CGoGN_LIBS_D
}
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
QT4_WRAP_CPP
(
simpleGMap3_moc ../simpleGMap3.h
)
add_executable
(
simpleGMap3D ../simpleGMap3.cpp
${
simpleGMap3_moc
}
)
target_link_libraries
(
simpleGMap3D
${
CGoGN_LIBS_D
}
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
QT4_WRAP_CPP
(
extrusionView_moc ../extrusionView.h
)
add_executable
(
extrusionViewD ../extrusionView.cpp
${
extrusionView_moc
}
)
target_link_libraries
(
extrusionViewD
...
...
Apps/Examples/Release/CMakeLists.txt
View file @
691f92c8
...
...
@@ -55,6 +55,16 @@ add_executable( texturesExample ../texturesExample.cpp ${texturesExample_moc} )
target_link_libraries
(
texturesExample
${
CGoGN_LIBS_R
}
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
QT4_WRAP_CPP
(
simpleGMap2_moc ../simpleGMap2.h
)
add_executable
(
simpleGMap2 ../simpleGMap2.cpp
${
simpleGMap2_moc
}
)
target_link_libraries
(
simpleGMap2
${
CGoGN_LIBS_R
}
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
QT4_WRAP_CPP
(
simpleGMap3_moc ../simpleGMap3.h
)
add_executable
(
simpleGMap3 ../simpleGMap3.cpp
${
simpleGMap3_moc
}
)
target_link_libraries
(
simpleGMap3
${
CGoGN_LIBS_R
}
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
QT4_WRAP_CPP
(
extrusionView_moc ../extrusionView.h
)
add_executable
(
extrusionView ../extrusionView.cpp
${
extrusionView_moc
}
)
target_link_libraries
(
extrusionView
...
...
Apps/Examples/simpleGMap2.cpp
View file @
691f92c8
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009
-2011
, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009, 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 *
...
...
@@ -17,431 +17,84 @@
* 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/
*
* Web site: http
s
://
iggservis
.u-strasbg.fr/
CGoGN/
*
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
<iostream>
#include
"Utils/os_spec.h"
#include
"simpleGMap2.h"
#include
"Utils/GLSLShader.h"
#include
"Utils/glutwin.h"
#include
"Topology/generic/parameters.h"
#include
"Topology/gmap/embeddedGMap2.h"
#include
"Geometry/matrix.h"
#include
"Geometry/vector_gen.h"
#include
"Algo/Import/import.h"
#include
"Algo/Geometry/boundingbox.h"
#include
"Algo/Render/map_glRender.h"
#include
"Algo/Render/topo_vboRender.h"
using
namespace
CGoGN
;
// definition des parametres de la carte
struct
PFP
:
public
PFP_STANDARD
{
// definition of the map
typedef
EmbeddedGMap2
MAP
;
};
PFP
::
MAP
myMap
;
// interface
class
myGlutWin
:
public
Utils
::
SimpleGlutWin
{
public:
Geom
::
Vec4f
colDif
;
Geom
::
Vec4f
colSpec
;
Geom
::
Vec4f
colClear
;
Geom
::
Vec4f
colNormal
;
float
shininess
;
PFP
::
TVEC3
position
;
PFP
::
TVEC3
normal
;
/**
* position of object
*/
PFP
::
VEC3
gPosObj
;
/**
* width of object
*/
float
gWidthObj
;
/**
* factor to apply to normal drawing
*/
float
normalScaleFactor
;
/**
* mesh normals
*/
std
::
vector
<
PFP
::
VEC3
>
vnormals
;
/**
* redraw CB
*/
void
myRedraw
();
/**
* keyboard CB
*/
void
myKeyboard
(
unsigned
char
keycode
,
int
x
,
int
y
);
/**
* Display list init
*/
void
initDL
();
/**
* Display list init only for normal drawing
*/
void
initDLNormals
(
void
);
#include
"Algo/Modelisation/polyhedron.h"
/**
* Display list init only for lines drawing
*/
void
initDLLines
(
void
);
/**
* GL (old school) rendering function (called by init DL)
*/
void
render
(
int
renderMode
);
/**
* inverse the normal when computing normal
*/
bool
invertedNormals
;
/**
* inverse object for culling
*/
bool
invertedObject
;
/**
* rendering normals ?
*/
bool
renderNormal
;
/**
* rendering lines ?
*/
bool
renderLines
;
/**
* aide affichee
*/
bool
aff_help
;
/**
* style of rendering
*/
int
renderStyle
;
/**
* Display List for object
*/
GLuint
dl_obj
;
/**
* Display List for object (second)
*/
GLuint
dl_obj2
;
/**
* Display List for normal
*/
GLuint
dl_norm
;
/**
* render topology
*/
Algo
::
Render
::
GL2
::
topo_VBORenderGMap
*
m_render_topo
;
/**
* render mode enum
*/
enum
{
CLEAR
=
1
,
LINE
,
FLAT
,
GOURAUD
,
PHONG
,
NORMAL
,
NONE
};
myGlutWin
(
int
*
argc
,
char
**
argv
,
int
winX
,
int
winY
)
:
SimpleGlutWin
(
argc
,
argv
,
winX
,
winY
),
invertedNormals
(
true
),
invertedObject
(
true
),
renderNormal
(
false
),
renderLines
(
true
),
aff_help
(
false
),
renderStyle
(
FLAT
),
dl_obj
(
-
1
),
dl_obj2
(
-
1
),
dl_norm
(
-
1
)
{
if
(
this
->
shaderOk
)
shaders
[
0
].
loadShaders
(
"phong_vs.txt"
,
"phong_ps.txt"
);
m_render_topo
=
new
Algo
::
Render
::
GL2
::
topo_VBORenderGMap
();
}
};
void
myGlutWin
::
render
(
int
renderMode
)
SimpleGMap2
::
SimpleGMap2
()
{
switch
(
renderMode
)
{
case
FLAT
:
glEnable
(
GL_LIGHTING
);
glDisable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT
,
GL_FILL
);
glShadeModel
(
GL_FLAT
);
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
if
(
invertedObject
)
glFrontFace
(
GL_CW
);
else
glFrontFace
(
GL_CCW
);
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
);
Algo
::
Render
::
Direct
::
renderTriQuadPoly
<
PFP
>
(
myMap
,
Algo
::
Render
::
Direct
::
FLAT
,
1.0
f
,
position
,
normal
);
break
;
Dart
d
=
Algo
::
Modelisation
::
Polyhedron
<
PFP
>::
createOrientedTetra
(
myMap
);
position
[
d
]
=
VEC3
(
0
,
0
,
0
);
position
[
myMap
.
phi1
(
d
)]
=
VEC3
(
10
,
0
,
15
);
position
[
myMap
.
phi_1
(
d
)]
=
VEC3
(
10
,
20
,
15
);
position
[
myMap
.
phi_1
(
myMap
.
phi2
(
d
))]
=
VEC3
(
0
,
0
,
30
);
case
LINE
:
glDisable
(
GL_LIGHTING
);
glEnable
(
GL_CULL_FACE
);
glPolygonMode
(
GL_FRONT
,
GL_LINE
);
VEC3
mid
=
(
position
[
d
]
+
position
[
myMap
.
phi1
(
d
)])
/
2.0
f
;
myMap
.
cutEdge
(
d
);
position
[
myMap
.
phi1
(
d
)]
=
mid
;
if
(
invertedObject
)
glFrontFace
(
GL_CW
);
else
glFrontFace
(
GL_CCW
);
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
poly
(
myMap
,
position
);
if
(
renderStyle
!=
CLEAR
)
glColor3f
(
1.0
f
,
1.0
f
,
0.0
f
);
else
glColor4fv
(
colDif
.
data
());
d
=
poly
.
cylinder_topo
(
5
,
1
,
false
,
false
);
Algo
::
Render
::
Direct
::
renderTriQuadPoly
<
PFP
>
(
myMap
,
Algo
::
Render
::
Direct
::
LINE
,
1.0
f
,
position
,
normal
);
poly
.
embedCylinder
(
10
,
10
,
5
);
break
;
d
=
myMap
.
phi1
(
d
);
Dart
dd
=
myMap
.
beta2
(
d
);
myMap
.
unsewFaces
(
d
);
myMap
.
sewFaces
(
d
,
dd
);
case
NONE
:
break
;
default:
break
;
}
position
[
d
][
1
]
+=
3.0
f
;
}
void
myGlutWin
::
initDL
(
void
)
void
SimpleGMap2
::
initGUI
(
)
{
if
(
glIsList
(
dl_obj
))
glDeleteLists
(
dl_obj
,
1
);
dl_obj
=
glGenLists
(
1
);
glNewList
(
dl_obj
,
GL_COMPILE
);
if
(
renderStyle
==
FLAT
)
render
(
FLAT
);
glEndList
();
}
void
myGlutWin
::
initDLLines
(
void
)
void
SimpleGMap2
::
cb_initGL
(
)
{
std
::
vector
<
PFP
::
VEC3
>
normals
;
if
(
glIsList
(
dl_obj2
))
glDeleteLists
(
dl_obj2
,
1
);
dl_obj2
=
glGenLists
(
1
);
glNewList
(
dl_obj2
,
GL_COMPILE
);
render
(
LINE
);
Utils
::
GLSLShader
::
setCurrentOGLVersion
(
1
)
;
glEndList
();
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
VEC3
gPosObj
=
bb
.
center
()
;
float
tailleX
=
bb
.
size
(
0
)
;
float
tailleY
=
bb
.
size
(
1
)
;
float
tailleZ
=
bb
.
size
(
2
)
;
float
gWidthObj
=
std
::
max
<
float
>
(
std
::
max
<
float
>
(
tailleX
,
tailleY
),
tailleZ
)
;
setParamObject
(
gWidthObj
,
gPosObj
.
data
());
}
void
myGlutWin
::
myR
edraw
(
void
)
void
SimpleGMap2
::
cb_r
edraw
()
{
GLfloat
black
[
4
]
=
{
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
};
GLfloat
amb
[
4
]
=
{
0.2
f
,
0.1
f
,
0.1
f
,
1.0
f
};
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glPushMatrix
();
float
sc
=
50.
/
gWidthObj
;
glScalef
(
sc
,
sc
,
sc
);
glTranslatef
(
-
gPosObj
[
0
],
-
gPosObj
[
1
],
-
gPosObj
[
2
]);
if
(
glIsList
(
dl_obj2
))
glCallList
(
dl_obj2
);
m_render_topo
->
drawTopo
();
glEnable
(
GL_POLYGON_OFFSET_FILL
);
glPolygonOffset
(
1.0
f
,
1.0
f
);
if
(
glIsList
(
dl_obj
))
{
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
colDif
.
data
());
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
amb
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
black
);
glMaterialf
(
GL_FRONT
,
GL_SHININESS
,
1.0
f
);
glCallList
(
dl_obj
);
}
glDisable
(
GL_POLYGON_OFFSET_FILL
);
glPopMatrix
();
glDisable
(
GL_LIGHTING
);
glLineWidth
(
1.0
f
);
Algo
::
Render
::
GL1
::
renderTopoGMD2
<
PFP
>
(
myMap
,
position
,
true
,
true
,
true
,
0.9
f
,
0.9
f
,
0.9
f
);
}
void
myGlutWin
::
myKeyboard
(
unsigned
char
keycode
,
int
,
int
)
{
// GLint t1,t2;
// GLfloat seconds;
switch
(
keycode
)
{
case
'd'
:
setFoc
(
getFoc
()
/
1.05
f
);
reshape
(
-
1
,
-
1
);
glutPostRedisplay
();
break
;
case
'D'
:
setFoc
(
getFoc
()
*
1.05
f
);
reshape
(
-
1
,
-
1
);
glutPostRedisplay
();
break
;
case
'i'
:
invertedNormals
=
!
invertedNormals
;
initDL
();
glutPostRedisplay
();
break
;
case
'o'
:
invertedObject
=
!
invertedObject
;
initDL
();
glutPostRedisplay
();
break
;
case
'O'
:
invertedObject
=
!
invertedObject
;
invertedNormals
=
!
invertedNormals
;
initDL
();
glutPostRedisplay
();
break
;
case
'f'
:
renderStyle
=
FLAT
;
initDL
();
glutPostRedisplay
();
break
;
case
'l'
:
renderLines
=
!
renderLines
;
if
(
renderLines
)
initDLLines
();
else
{
if
(
glIsList
(
dl_obj2
))
glDeleteLists
(
dl_obj2
,
1
);
}
initDL
();
glutPostRedisplay
();
break
;
case
'z'
:
shininess
/=
1.1
f
;
glutPostRedisplay
();
break
;
case
'Z'
:
shininess
*=
1.1
f
;
glutPostRedisplay
();
break
;
}
}
/**********************************************************************************************
* MAIN FUNCTION *
**********************************************************************************************/
int
main
(
int
argc
,
char
**
argv
)
{
myGlutWin
mgw
(
&
argc
,
argv
,
800
,
800
);
char
*
filename
=
argv
[
1
]
;
PFP
::
VEC3
gMax
;
PFP
::
VEC3
gMin
;
if
(
argc
<
2
)
{
mgw
.
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
)
;
Dart
d
=
myMap
.
newFace
(
4
);
Dart
e
=
myMap
.
newFace
(
3
);
myMap
.
sewFaces
(
d
,
e
);
// plonge les 4 sommets du carré
mgw
.
position
[
d
]
=
PFP
::
VEC3
(
-
1
,
1
,
0
);
d
=
myMap
.
phi1
(
d
);
mgw
.
position
[
d
]
=
PFP
::
VEC3
(
1
,
1
,
0
);
d
=
myMap
.
phi1
(
d
);
mgw
.
position
[
d
]
=
PFP
::
VEC3
(
1
,
-
1
,
0
);
d
=
myMap
.
phi1
(
d
);
mgw
.
position
[
d
]
=
PFP
::
VEC3
(
-
1
,
-
1
,
0
);
QApplication
app
(
argc
,
argv
)
;
// plonge le dernier sommet du triangle
d
=
myMap
.
phi_1
(
e
);
mgw
.
position
[
d
]
=
PFP
::
VEC3
(
0
,
2
,
0
);
}
else
{
std
::
vector
<
std
::
string
>
attrNames
;
if
(
!
Algo
::
Import
::
importMesh
<
PFP
>
(
myMap
,
filename
,
attrNames
))
{
CGoGNerr
<<
"Import fail"
<<
CGoGNendl
;
exit
(
1
);
}
mgw
.
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
attrNames
[
0
])
;
}
SimpleGMap2
sqt
;
sqt
.
setGeometry
(
0
,
0
,
1000
,
800
)
;
sqt
.
show
()
;
mgw
.
normal
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"normal"
)
;
sqt
.
initGUI
(
)
;
// pour le rendu
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
mgw
.
position
)
;
mgw
.
gPosObj
=
bb
.
center
()
;
float
tailleX
=
bb
.
size
(
0
)
;
float
tailleY
=
bb
.
size
(
1
)
;
float
tailleZ
=
bb
.
size
(
2
)
;
mgw
.
gWidthObj
=
std
::
max
<
float
>
(
std
::
max
<
float
>
(
tailleX
,
tailleY
),
tailleZ
)
;
mgw
.
normalScaleFactor
=
std
::
min
<
float
>
(
std
::
min
<
float
>
(
tailleX
,
tailleY
),
tailleZ
)
/
50.0
f
;
mgw
.
colClear
=
Geom
::
Vec4f
(
0.2
f
,
0.2
f
,
0.2
f
,
0.1
);
mgw
.
colDif
=
Geom
::
Vec4f
(
0.8
f
,
0.9
f
,
0.7
f
,
1.0
f
);
mgw
.
colSpec
=
Geom
::
Vec4f
(
0.9
f
,
0.9
f
,
0.9
f
,
1.0
f
);
mgw
.
colNormal
=
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
mgw
.
shininess
=
80.0
f
;
mgw
.
m_render_topo
->
updateData
<
PFP
>
(
myMap
,
mgw
.
position
,
0.9
f
,
0.9
f
);
mgw
.
initDL
();
mgw
.
initDLLines
();
mgw
.
mainLoop
();
return
0
;
return
app
.
exec
()
;
}
Apps/Examples/simpleGMap2.h
0 → 100644
View file @
691f92c8
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
<iostream>
#include
"Utils/qtSimple.h"
#include
"Topology/generic/parameters.h"
#include
"Topology/gmap/embeddedGMap2.h"
#include
"Geometry/vector_gen.h"
#include
"Algo/Render/GL1/topo_render.h"
using
namespace
CGoGN
;
struct
PFP
:
public
PFP_STANDARD
{
// definition of the map
typedef
EmbeddedGMap2
MAP
;
};
typedef
PFP
::
MAP
MAP
;
typedef
PFP
::
VEC3
VEC3
;
class
SimpleGMap2
:
public
Utils
::
QT
::
SimpleQT
{
Q_OBJECT
public:
MAP
myMap
;
SelectorTrue
allDarts
;
PFP
::
TVEC3
position
;
SimpleGMap2
()
;
void
initGUI
()
;
void
cb_initGL
()
;
void
cb_redraw
()
;
};
Apps/Examples/simpleGMap3.cpp
0 → 100644
View file @
691f92c8
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
"simpleGMap3.h"
#include
"Utils/GLSLShader.h"