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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
3bee55cb
Commit
3bee55cb
authored
Mar 23, 2012
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn:~cgogn/CGoGN
parents
a39d1a2d
fbf4fa5d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
414 additions
and
2 deletions
+414
-2
Apps/Examples/Debug/CMakeLists.txt
Apps/Examples/Debug/CMakeLists.txt
+8
-1
Apps/Examples/Release/CMakeLists.txt
Apps/Examples/Release/CMakeLists.txt
+9
-1
Apps/Examples/mcmesh.cpp
Apps/Examples/mcmesh.cpp
+238
-0
Apps/Examples/mcmesh.h
Apps/Examples/mcmesh.h
+109
-0
Apps/Examples/mcmesh.ui
Apps/Examples/mcmesh.ui
+50
-0
No files found.
Apps/Examples/Debug/CMakeLists.txt
View file @
3bee55cb
...
...
@@ -77,4 +77,11 @@ QT4_WRAP_UI( volumeExplorer_ui ../volumeExplorer.ui )
QT4_WRAP_CPP
(
volumeExplorer_moc ../volumeExplorer.h
)
add_executable
(
volumeExplorerD ../volumeExplorer.cpp
${
volumeExplorer_ui
}
${
volumeExplorer_moc
}
)
target_link_libraries
(
volumeExplorerD
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
\ No newline at end of file
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
QT4_WRAP_UI
(
mcmesh_ui ../mcmesh.ui
)
QT4_WRAP_CPP
(
mcmesh_moc ../mcmesh.h
)
add_executable
(
mcmeshD ../mcmesh.cpp
${
mcmesh_moc
}
${
mcmesh_ui
}
)
target_link_libraries
(
mcmeshD
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
Apps/Examples/Release/CMakeLists.txt
View file @
3bee55cb
...
...
@@ -70,4 +70,12 @@ QT4_WRAP_CPP( volumeExplorer_moc ../volumeExplorer.h )
add_executable
(
volumeExplorer ../volumeExplorer.cpp
${
volumeExplorer_ui
}
${
volumeExplorer_moc
}
)
target_link_libraries
(
volumeExplorer
${
CGoGN_LIBS_R
}
${
CGoGN_EXT_LIBS
}
)
\ No newline at end of file
QT4_WRAP_UI
(
mcmesh_ui ../mcmesh.ui
)
QT4_WRAP_CPP
(
mcmesh_moc ../mcmesh.h
)
add_executable
(
mcmesh
../mcmesh.cpp
${
mcmesh_moc
}
${
mcmesh_ui
}
)
target_link_libraries
(
mcmesh
${
CGoGN_LIBS_R
}
${
CGoGN_EXT_LIBS
}
)
Apps/Examples/mcmesh.cpp
0 → 100644
View file @
3bee55cb
/*******************************************************************************
* 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 "mcmesh.h"
MCMesh
::
MCMesh
()
:
m_drawEdges
(
true
),
m_drawFaces
(
true
),
m_render
(
NULL
),
m_flatShader
(
NULL
),
m_simpleColorShader
(
NULL
)
{
}
void
MCMesh
::
initGUI
()
{
setDock
(
&
dock
);
dock
.
check_drawEdges
->
setChecked
(
true
);
dock
.
check_drawFaces
->
setChecked
(
true
);
setCallBack
(
dock
.
check_drawEdges
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawEdges
(
bool
))
);
setCallBack
(
dock
.
check_drawFaces
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawFaces
(
bool
))
);
}
void
MCMesh
::
cb_initGL
()
{
Geom
::
Vec4f
colClear
(
0.2
f
,
0.2
f
,
0.2
f
,
0.1
f
);
Geom
::
Vec4f
colDif
(
0.8
f
,
0.9
f
,
0.7
f
,
1.0
f
);
Geom
::
Vec4f
colSpec
(
0.9
f
,
0.9
f
,
0.9
f
,
1.0
f
);
Utils
::
GLSLShader
::
setCurrentOGLVersion
(
2
);
m_render
=
new
Algo
::
Render
::
GL2
::
MapRender
();
m_positionVBO
=
new
Utils
::
VBO
();
m_flatShader
=
new
Utils
::
ShaderFlat
();
m_flatShader
->
setAttributePosition
(
m_positionVBO
);
m_flatShader
->
setAmbiant
(
colClear
);
m_flatShader
->
setDiffuse
(
colDif
);
m_flatShader
->
setExplode
(
1.0
f
);
m_simpleColorShader
=
new
Utils
::
ShaderSimpleColor
();
m_simpleColorShader
->
setAttributePosition
(
m_positionVBO
);
registerShader
(
m_flatShader
);
registerShader
(
m_simpleColorShader
);
}
void
MCMesh
::
cb_redraw
()
{
if
(
m_drawEdges
)
{
glLineWidth
(
1.0
f
);
if
(
m_drawFaces
)
{
Geom
::
Vec4f
c
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
);
m_simpleColorShader
->
setColor
(
c
);
}
else
{
Geom
::
Vec4f
c
(
1.0
f
,
1.0
f
,
0.0
f
,
0.0
f
);
m_simpleColorShader
->
setColor
(
c
);
}
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
LINES
);
}
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
glEnable
(
GL_LIGHTING
);
glEnable
(
GL_POLYGON_OFFSET_FILL
);
glPolygonOffset
(
1.0
f
,
1.0
f
);
if
(
m_drawFaces
)
{
m_flatShader
->
setExplode
(
1.0
f
);
m_render
->
draw
(
m_flatShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
}
else
{
if
(
m_drawEdges
)
{
Geom
::
Vec4f
c
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
);
m_simpleColorShader
->
setColor
(
c
);
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
}
}
glDisable
(
GL_POLYGON_OFFSET_FILL
);
}
void
MCMesh
::
cb_Open
()
{
// std::string filters("all (*.*);; trian (*.trian);; ctm (*.ctm);; off (*.off);; ply (*.ply)");
// std::string filename = selectFile("Open Mesh", "", filters);
// if (filename.empty())
// return;
//
// updateGL();
}
void
MCMesh
::
slot_drawEdges
(
bool
b
)
{
m_drawEdges
=
b
;
updateGL
();
}
void
MCMesh
::
slot_drawFaces
(
bool
b
)
{
m_drawFaces
=
b
;
updateGL
();
}
void
MCMesh
::
MC
()
{
myMap
.
clear
(
false
);
// elargir l'image pour le calcul de la courbure
Algo
::
MC
::
Image
<
DATATYPE
>*
myImgFr
=
myImg
->
addFrame
(
1
);
Algo
::
MC
::
WindowingGreater
<
DATATYPE
>
myWindFunc
;
myWindFunc
.
setIsoValue
(
DATATYPE
(
127
));
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
);
if
(
!
position
.
isValid
())
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
);
// instanciation du mc
Algo
::
MC
::
MarchingCube
<
DATATYPE
,
Algo
::
MC
::
WindowingGreater
,
PFP
>
mc
(
myImgFr
,
&
myMap
,
position
,
myWindFunc
,
false
);
mc
.
simpleMeshing
();
delete
myImgFr
;
updateRender
();
updateGL
();
}
void
MCMesh
::
updateRender
()
{
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
myMap
);
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
nb
,
Algo
::
Render
::
GL2
::
LINES
);
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
nb
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
m_positionVBO
->
updateData
(
position
);
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
setParamObject
(
bb
.
maxSize
(),
bb
.
center
().
data
());
updateGLMatrices
();
}
void
MCMesh
::
fromFile
(
char
*
fname
)
{
myImg
=
new
Algo
::
MC
::
Image
<
DATATYPE
>
();
myImg
->
loadInrgz
(
fname
);
CGoGNout
<<
"Image chargee"
<<
CGoGNendl
;
CGoGNout
<<
myImg
->
getWidthX
()
<<
"x"
<<
myImg
->
getWidthY
()
<<
"x"
<<
myImg
->
getWidthZ
()
<<
"voxels"
<<
CGoGNendl
;
}
void
MCMesh
::
sphere
()
{
DATATYPE
*
img
=
new
DATATYPE
[
128
*
128
*
128
];
DATATYPE
*
ptr
=
img
;
for
(
int
x
=
0
;
x
<
128
;
++
x
)
for
(
int
y
=
0
;
y
<
128
;
++
y
)
for
(
int
z
=
0
;
z
<
128
;
++
z
)
{
Geom
::
Vec3f
V
(
x
-
64
,
y
-
64
,
z
-
64
);
if
(
V
.
norm
()
<
30
)
*
ptr
++
=
255
;
else
*
ptr
++
=
0
;
}
myImg
=
new
Algo
::
MC
::
Image
<
DATATYPE
>
(
img
,
128
,
128
,
128
,
1.0
f
,
1.0
f
,
1.0
f
,
false
);
}
/**********************************************************************************************
* MAIN FUNCTION *
**********************************************************************************************/
int
main
(
int
argc
,
char
**
argv
)
{
QApplication
app
(
argc
,
argv
);
MCMesh
sqt
;
sqt
.
setGeometry
(
0
,
0
,
1000
,
800
);
sqt
.
show
();
sqt
.
valLabel
=
DATATYPE
(
0
);
if
(
argc
==
2
)
{
sqt
.
fromFile
(
argv
[
1
]);
}
else
{
sqt
.
sphere
();
}
sqt
.
initGUI
();
sqt
.
show
();
sqt
.
MC
();
return
app
.
exec
();
}
Apps/Examples/mcmesh.h
0 → 100644
View file @
3bee55cb
/*******************************************************************************
* 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/Qt/qtSimple.h"
#include "ui_mcmesh.h"
#include "Utils/Qt/qtui.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/MC/marchingcube.h"
using
namespace
CGoGN
;
struct
PFP
:
public
PFP_STANDARD
{
// definition of the map
typedef
EmbeddedMap2
MAP
;
};
typedef
PFP
::
MAP
MAP
;
typedef
unsigned
char
DATATYPE
;
class
MCMesh
:
public
Utils
::
QT
::
SimpleQT
{
Q_OBJECT
public:
MAP
myMap
;
SelectorTrue
allDarts
;
Utils
::
QT
::
uiDockInterface
dock
;
float
shininess
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
;
bool
m_drawEdges
;
bool
m_drawFaces
;
PFP
::
TVEC3
position
;
Algo
::
Render
::
GL2
::
MapRender
*
m_render
;
Utils
::
VBO
*
m_positionVBO
;
Utils
::
ShaderFlat
*
m_flatShader
;
Utils
::
ShaderSimpleColor
*
m_simpleColorShader
;
DATATYPE
valLabel
;
Algo
::
MC
::
Image
<
DATATYPE
>*
myImg
;
MCMesh
()
;
void
initGUI
();
void
updateRender
();
void
MC
();
void
cb_initGL
()
;
void
cb_redraw
()
;
void
cb_Open
()
;
void
fromFile
(
char
*
fname
);
void
sphere
();
public
slots
:
void
slot_drawEdges
(
bool
b
)
;
void
slot_drawFaces
(
bool
b
)
;
};
Apps/Examples/mcmesh.ui
0 → 100644
View file @
3bee55cb
<?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>
134
</width>
<height>
513
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
DockWidget
</string>
</property>
<widget
class=
"QWidget"
name=
"dockWidgetContents"
>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"check_drawEdges"
>
<property
name=
"text"
>
<string>
draw edges
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"check_drawFaces"
>
<property
name=
"text"
>
<string>
draw faces
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
>
<spacer
name=
"verticalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
2
</width>
<height>
40
</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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