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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Etienne Schmitt
CGoGN
Commits
ed9da781
Commit
ed9da781
authored
Mar 14, 2014
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn:~cgogn/CGoGN
parents
71d3a2da
351c36b2
Changes
46
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
1847 additions
and
4340 deletions
+1847
-4340
Apps/SandBox/CMakeLists.txt
Apps/SandBox/CMakeLists.txt
+5
-0
Apps/SandBox/testPlaneCutting.cpp
Apps/SandBox/testPlaneCutting.cpp
+468
-0
Apps/SandBox/testPlaneCutting.h
Apps/SandBox/testPlaneCutting.h
+140
-0
Apps/SandBox/testPlaneCutting.ui
Apps/SandBox/testPlaneCutting.ui
+168
-0
Apps/SandBox/tilings.cpp
Apps/SandBox/tilings.cpp
+15
-2
include/Algo/DecimationVolumes/approximator.h
include/Algo/DecimationVolumes/approximator.h
+0
-192
include/Algo/DecimationVolumes/decimator.hpp
include/Algo/DecimationVolumes/decimator.hpp
+0
-163
include/Algo/DecimationVolumes/edgeSelector.h
include/Algo/DecimationVolumes/edgeSelector.h
+0
-200
include/Algo/DecimationVolumes/edgeSelector.hpp
include/Algo/DecimationVolumes/edgeSelector.hpp
+0
-329
include/Algo/DecimationVolumes/geometryApproximator.h
include/Algo/DecimationVolumes/geometryApproximator.h
+0
-158
include/Algo/DecimationVolumes/geometryApproximator.hpp
include/Algo/DecimationVolumes/geometryApproximator.hpp
+0
-173
include/Algo/DecimationVolumes/operator.h
include/Algo/DecimationVolumes/operator.h
+0
-192
include/Algo/DecimationVolumes/operator.hpp
include/Algo/DecimationVolumes/operator.hpp
+0
-170
include/Algo/DecimationVolumes/selector.h
include/Algo/DecimationVolumes/selector.h
+0
-74
include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp
include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp
+1
-43
include/Algo/Import/import2tables.h
include/Algo/Import/import2tables.h
+2
-2
include/Algo/Modelisation/planeCutting.h
include/Algo/Modelisation/planeCutting.h
+18
-0
include/Algo/Modelisation/planeCutting.hpp
include/Algo/Modelisation/planeCutting.hpp
+204
-0
include/Algo/Modelisation/polyhedron.h
include/Algo/Modelisation/polyhedron.h
+0
-259
include/Algo/Modelisation/polyhedron.hpp
include/Algo/Modelisation/polyhedron.hpp
+45
-830
include/Algo/Modelisation/primitives3d.hppxx
include/Algo/Modelisation/primitives3d.hppxx
+0
-248
include/Algo/Modelisation/primitives3d.hxx
include/Algo/Modelisation/primitives3d.hxx
+0
-193
include/Algo/Multiresolution/IHM2/ihm2_PrimalAdapt.hpp
include/Algo/Multiresolution/IHM2/ihm2_PrimalAdapt.hpp
+6
-2
include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp
include/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp
+40
-60
include/Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.h
include/Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.h
+3
-1
include/Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.hpp
include/Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.hpp
+107
-6
include/Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.h
include/Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.h
+22
-17
include/Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.hpp
include/Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.hpp
+110
-591
include/Algo/ProgressiveMesh/pmesh.h
include/Algo/ProgressiveMesh/pmesh.h
+6
-3
include/Algo/ProgressiveMesh/pmesh.hpp
include/Algo/ProgressiveMesh/pmesh.hpp
+41
-7
include/Algo/Render/GL2/colorPerFaceRender.hpp
include/Algo/Render/GL2/colorPerFaceRender.hpp
+2
-2
include/Algo/Tiling/tiling.h
include/Algo/Tiling/tiling.h
+15
-0
include/Algo/Tiling/tiling.hpp
include/Algo/Tiling/tiling.hpp
+23
-0
include/Algo/Topo/Map2/uniformOrientation.h
include/Algo/Topo/Map2/uniformOrientation.h
+14
-24
include/Algo/Topo/Map2/uniformOrientation.hpp
include/Algo/Topo/Map2/uniformOrientation.hpp
+217
-0
include/Algo/VolumetricProgressiveMesh/vpmesh.hpp
include/Algo/VolumetricProgressiveMesh/vpmesh.hpp
+0
-368
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+14
-0
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+98
-7
include/Topology/generic/traversorCell.h
include/Topology/generic/traversorCell.h
+13
-0
include/Topology/generic/traversorCellVirt.h
include/Topology/generic/traversorCellVirt.h
+8
-8
include/Topology/generic/traversorCellVirt.hpp
include/Topology/generic/traversorCellVirt.hpp
+2
-2
include/Topology/map/embeddedMap2.h
include/Topology/map/embeddedMap2.h
+3
-0
include/Topology/map/map1.h
include/Topology/map/map1.h
+2
-1
include/Topology/map/map2.h
include/Topology/map/map2.h
+5
-1
src/Topology/map/embeddedMap2.cpp
src/Topology/map/embeddedMap2.cpp
+12
-12
src/Topology/map/map2.cpp
src/Topology/map/map2.cpp
+18
-0
No files found.
Apps/SandBox/CMakeLists.txt
View file @
ed9da781
...
...
@@ -36,6 +36,11 @@ add_executable(test_traversor2 test_traversor2.cpp ${test_traversor2_ui} ${test
target_link_libraries
(
test_traversor2
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
QT4_WRAP_UI
(
testPlaneCutting_ui testPlaneCutting.ui
)
QT4_WRAP_CPP
(
testPlaneCutting_moc testPlaneCutting.h
)
add_executable
(
testPlaneCutting testPlaneCutting.cpp
${
testPlaneCutting_ui
}
${
testPlaneCutting_moc
}
)
target_link_libraries
(
testPlaneCutting
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
# Example with Qt
#
#QT4_WRAP_CPP(tuto1_moc tuto1.h)
...
...
Apps/SandBox/testPlaneCutting.cpp
0 → 100644
View file @
ed9da781
/*******************************************************************************
* 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: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "testPlaneCutting.h"
#include "Algo/Geometry/distances.h"
#include "Algo/Modelisation/subdivision.h"
#include "Utils/chrono.h"
#include "Algo/Modelisation/planeCutting.h"
Viewer
::
Viewer
()
:
m_renderStyle
(
FLAT
),
m_drawVertices
(
false
),
m_drawEdges
(
false
),
m_drawFaces
(
true
),
m_drawNormals
(
false
),
m_drawTopo
(
false
),
m_drawBoundaryTopo
(
true
),
m_render
(
NULL
),
m_phongShader
(
NULL
),
m_flatShader
(
NULL
),
m_vectorShader
(
NULL
),
m_simpleColorShader
(
NULL
),
m_pointSprite
(
NULL
)
{
normalScaleFactor
=
1.0
f
;
vertexScaleFactor
=
0.1
f
;
faceShrinkage
=
1.0
f
;
colClear
=
Geom
::
Vec4f
(
0.2
f
,
0.2
f
,
0.2
f
,
0.1
f
)
;
colDif
=
Geom
::
Vec4f
(
0.8
f
,
0.9
f
,
0.7
f
,
1.0
f
)
;
colSpec
=
Geom
::
Vec4f
(
0.9
f
,
0.9
f
,
0.9
f
,
1.0
f
)
;
colNormal
=
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
)
;
shininess
=
80.0
f
;
}
void
Viewer
::
initGUI
()
{
setDock
(
&
dock
)
;
dock
.
check_drawVertices
->
setChecked
(
false
)
;
dock
.
check_drawEdges
->
setChecked
(
false
)
;
dock
.
check_drawFaces
->
setChecked
(
true
)
;
dock
.
check_drawNormals
->
setChecked
(
false
)
;
dock
.
slider_verticesSize
->
setVisible
(
false
)
;
dock
.
slider_normalsSize
->
setVisible
(
false
)
;
dock
.
slider_verticesSize
->
setSliderPosition
(
50
)
;
dock
.
slider_normalsSize
->
setSliderPosition
(
50
)
;
setCallBack
(
dock
.
check_drawVertices
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawVertices
(
bool
))
)
;
setCallBack
(
dock
.
slider_verticesSize
,
SIGNAL
(
valueChanged
(
int
)),
SLOT
(
slot_verticesSize
(
int
))
)
;
setCallBack
(
dock
.
check_drawEdges
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawEdges
(
bool
))
)
;
setCallBack
(
dock
.
check_drawFaces
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawFaces
(
bool
))
)
;
setCallBack
(
dock
.
combo_faceLighting
,
SIGNAL
(
currentIndexChanged
(
int
)),
SLOT
(
slot_faceLighting
(
int
))
)
;
setCallBack
(
dock
.
check_drawTopo
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawTopo
(
bool
))
)
;
setCallBack
(
dock
.
check_drawNormals
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawNormals
(
bool
))
)
;
setCallBack
(
dock
.
slider_normalsSize
,
SIGNAL
(
valueChanged
(
int
)),
SLOT
(
slot_normalsSize
(
int
))
)
;
}
void
Viewer
::
cb_initGL
()
{
Utils
::
GLSLShader
::
setCurrentOGLVersion
(
2
)
;
m_render
=
new
Algo
::
Render
::
GL2
::
MapRender
()
;
m_topoRender
=
new
Algo
::
Render
::
GL2
::
TopoRender
()
;
m_topoRender
->
setInitialDartsColor
(
0.25
f
,
0.25
f
,
0.25
f
)
;
m_positionVBO
=
new
Utils
::
VBO
()
;
m_normalVBO
=
new
Utils
::
VBO
()
;
m_phongShader
=
new
Utils
::
ShaderPhong
()
;
m_phongShader
->
setAttributePosition
(
m_positionVBO
)
;
m_phongShader
->
setAttributeNormal
(
m_normalVBO
)
;
m_phongShader
->
setAmbiant
(
colClear
)
;
m_phongShader
->
setDiffuse
(
colDif
)
;
m_phongShader
->
setSpecular
(
colSpec
)
;
m_phongShader
->
setShininess
(
shininess
)
;
m_flatShader
=
new
Utils
::
ShaderFlat
()
;
m_flatShader
->
setAttributePosition
(
m_positionVBO
)
;
m_flatShader
->
setAmbiant
(
colClear
)
;
m_flatShader
->
setDiffuse
(
colDif
)
;
m_flatShader
->
setExplode
(
faceShrinkage
)
;
m_vectorShader
=
new
Utils
::
ShaderVectorPerVertex
()
;
m_vectorShader
->
setAttributePosition
(
m_positionVBO
)
;
m_vectorShader
->
setAttributeVector
(
m_normalVBO
)
;
m_vectorShader
->
setColor
(
colNormal
)
;
m_simpleColorShader
=
new
Utils
::
ShaderSimpleColor
()
;
m_simpleColorShader
->
setAttributePosition
(
m_positionVBO
)
;
Geom
::
Vec4f
c
(
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
)
;
m_simpleColorShader
->
setColor
(
c
)
;
m_pointSprite
=
new
Utils
::
PointSprite
()
;
m_pointSprite
->
setAttributePosition
(
m_positionVBO
)
;
m_pointSprite
->
setColor
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1.0
f
,
1.0
f
))
;
registerShader
(
m_phongShader
)
;
registerShader
(
m_flatShader
)
;
registerShader
(
m_vectorShader
)
;
registerShader
(
m_simpleColorShader
)
;
registerShader
(
m_pointSprite
)
;
}
void
Viewer
::
cb_redraw
()
{
if
(
m_drawVertices
)
{
m_pointSprite
->
setSize
(
vertexScaleFactor
)
;
m_render
->
draw
(
m_pointSprite
,
Algo
::
Render
::
GL2
::
POINTS
)
;
}
if
(
m_drawEdges
)
{
glLineWidth
(
1.0
f
)
;
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
LINES
)
;
}
if
(
m_drawFaces
)
{
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
glEnable
(
GL_LIGHTING
)
;
glEnable
(
GL_POLYGON_OFFSET_FILL
)
;
glPolygonOffset
(
1.0
f
,
1.0
f
)
;
switch
(
m_renderStyle
)
{
case
FLAT
:
m_flatShader
->
setExplode
(
faceShrinkage
)
;
m_render
->
draw
(
m_flatShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
break
;
case
PHONG
:
m_render
->
draw
(
m_phongShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
break
;
}
glDisable
(
GL_POLYGON_OFFSET_FILL
)
;
}
if
(
m_drawTopo
)
{
m_topoRender
->
drawTopo
()
;
}
if
(
m_drawNormals
)
{
float
size
=
normalBaseSize
*
normalScaleFactor
;
m_vectorShader
->
setScale
(
size
)
;
glLineWidth
(
1.0
f
)
;
m_render
->
draw
(
m_vectorShader
,
Algo
::
Render
::
GL2
::
POINTS
)
;
}
}
void
Viewer
::
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
;
importMesh
(
filename
)
;
updateGL
()
;
}
void
Viewer
::
cb_Save
()
{
std
::
string
filters
(
"all (*.*);; map (*.map);; off (*.off);; ply (*.ply)"
)
;
std
::
string
filename
=
selectFileSave
(
"Save Mesh"
,
""
,
filters
)
;
if
(
!
filename
.
empty
())
exportMesh
(
filename
)
;
}
void
Viewer
::
cb_keyPress
(
int
keycode
)
{
switch
(
keycode
)
{
case
'c'
:
myMap
.
check
();
break
;
case
'p'
:
{
std
::
cout
<<
"PlaneCut"
<<
std
::
endl
;
Geom
::
Vec3f
n
(
0.1
,
0.1
,
1.0
);
Geom
::
Vec3f
o
=
bb
.
center
();
Geom
::
Plane3D
<
PFP
::
REAL
>
plan
(
n
,
o
);
CellMarker
<
FACE
>
over
(
myMap
);
Algo
::
Surface
::
Modelisation
::
planeCut
<
PFP
>
(
myMap
,
position
,
plan
,
over
,
true
,
true
);
std
::
cout
<<
"PlaneCut Ok"
<<
std
::
endl
;
n
*=
bb
.
diagSize
()
/
20.0
f
;
TraversorV
<
PFP
::
MAP
>
trav
(
myMap
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
if
(
over
.
isMarked
(
d
))
position
[
d
]
+=
n
;
}
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
POINTS
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
LINES
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
Algo
::
Surface
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
m_topoRender
->
updateData
<
PFP
>
(
myMap
,
position
,
0.85
f
,
0.85
f
,
m_drawBoundaryTopo
)
;
updateGL
();
break
;
}
case
'P'
:
{
std
::
cout
<<
"PlaneCut"
<<
std
::
endl
;
Geom
::
Vec3f
n
(
0.1
,
0.1
,
1.0
);
Geom
::
Vec3f
o
=
bb
.
center
();
Geom
::
Plane3D
<
PFP
::
REAL
>
plan
(
n
,
o
);
CellMarker
<
FACE
>
over
(
myMap
);
Algo
::
Surface
::
Modelisation
::
planeCut2
<
PFP
>
(
myMap
,
position
,
plan
,
over
,
true
);
std
::
cout
<<
"PlaneCut Ok"
<<
std
::
endl
;
n
*=
bb
.
diagSize
()
/
20.0
f
;
TraversorV
<
PFP
::
MAP
>
trav
(
myMap
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
if
(
over
.
isMarked
(
d
))
position
[
d
]
+=
n
;
}
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
POINTS
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
LINES
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
Algo
::
Surface
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
m_topoRender
->
updateData
<
PFP
>
(
myMap
,
position
,
0.85
f
,
0.85
f
,
m_drawBoundaryTopo
)
;
updateGL
();
break
;
}
case
'd'
:
{
Utils
::
Chrono
ch
;
ch
.
start
();
VEC3
P
(
0.6
f
,
0.55
f
,
0.51
f
);
float
dist
=
10000.0
f
;
TraversorF
<
PFP
::
MAP
>
trav
(
myMap
);
unsigned
int
nb
=
0
;
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
nb
++
;
float
d2
=
Algo
::
Geometry
::
squaredDistancePoint2Face
<
PFP
>
(
myMap
,
d
,
position
,
P
);
if
(
d2
<
dist
)
dist
=
d2
;
}
std
::
cout
<<
"Dist="
<<
sqrt
(
dist
)
<<
" of "
<<
nb
<<
"faces in "
<<
ch
.
elapsed
()
<<
" ms"
<<
std
::
endl
;
break
;
}
default:
break
;
}
}
void
Viewer
::
importMesh
(
std
::
string
&
filename
)
{
myMap
.
clear
(
true
)
;
size_t
pos
=
filename
.
rfind
(
"."
);
// position of "." in filename
std
::
string
extension
=
filename
.
substr
(
pos
);
if
(
extension
==
std
::
string
(
".map"
))
{
myMap
.
loadMapBin
(
filename
);
position
=
myMap
.
getAttribute
<
VEC3
,
VERTEX
>
(
"position"
)
;
}
else
{
std
::
vector
<
std
::
string
>
attrNames
;
if
(
!
Algo
::
Surface
::
Import
::
importMesh
<
PFP
>
(
myMap
,
filename
.
c_str
(),
attrNames
))
{
CGoGNerr
<<
"could not import "
<<
filename
<<
CGoGNendl
;
return
;
}
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
attrNames
[
0
])
;
}
// myMap.enableQuickTraversal<VERTEX>() ;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
POINTS
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
LINES
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
m_topoRender
->
updateData
<
PFP
>
(
myMap
,
position
,
0.85
f
,
0.85
f
,
m_drawBoundaryTopo
)
;
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
normalBaseSize
=
bb
.
diagSize
()
/
100.0
f
;
// vertexBaseSize = normalBaseSize / 5.0f ;
normal
=
myMap
.
getAttribute
<
VEC3
,
VERTEX
>
(
"normal"
)
;
if
(
!
normal
.
isValid
())
normal
=
myMap
.
addAttribute
<
VEC3
,
VERTEX
>
(
"normal"
)
;
Algo
::
Surface
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
().
data
())
;
updateGLMatrices
()
;
}
void
Viewer
::
exportMesh
(
std
::
string
&
filename
,
bool
askExportMode
)
{
size_t
pos
=
filename
.
rfind
(
"."
)
;
// position of "." in filename
std
::
string
extension
=
filename
.
substr
(
pos
)
;
if
(
extension
==
std
::
string
(
".off"
))
Algo
::
Surface
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
())
;
else
if
(
extension
.
compare
(
0
,
4
,
std
::
string
(
".ply"
))
==
0
)
{
int
ascii
=
0
;
if
(
askExportMode
)
Utils
::
QT
::
inputValues
(
Utils
::
QT
::
VarCombo
(
"binary mode;ascii mode"
,
ascii
,
"Save in"
))
;
std
::
vector
<
VertexAttribute
<
VEC3
>*>
attributes
;
attributes
.
push_back
(
&
position
)
;
Algo
::
Surface
::
Export
::
exportPLYnew
<
PFP
>
(
myMap
,
attributes
,
filename
.
c_str
(),
!
ascii
)
;
}
else
if
(
extension
==
std
::
string
(
".map"
))
myMap
.
saveMapBin
(
filename
)
;
else
std
::
cerr
<<
"Cannot save file "
<<
filename
<<
" : unknown or unhandled extension"
<<
std
::
endl
;
}
void
Viewer
::
slot_drawVertices
(
bool
b
)
{
m_drawVertices
=
b
;
updateGL
()
;
}
void
Viewer
::
slot_verticesSize
(
int
i
)
{
vertexScaleFactor
=
i
/
500.0
f
;
updateGL
()
;
}
void
Viewer
::
slot_drawEdges
(
bool
b
)
{
m_drawEdges
=
b
;
updateGL
()
;
}
void
Viewer
::
slot_drawFaces
(
bool
b
)
{
m_drawFaces
=
b
;
if
(
b
)
{
Geom
::
Vec4f
c
(
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
)
;
m_simpleColorShader
->
setColor
(
c
)
;
}
else
{
Geom
::
Vec4f
c
(
0.9
f
,
0.9
f
,
0.1
f
,
1.0
f
)
;
m_simpleColorShader
->
setColor
(
c
)
;
}
updateGL
()
;
}
void
Viewer
::
slot_faceLighting
(
int
i
)
{
m_renderStyle
=
i
;
updateGL
()
;
}
void
Viewer
::
slot_drawTopo
(
bool
b
)
{
m_drawTopo
=
b
;
updateGL
()
;
}
void
Viewer
::
slot_drawNormals
(
bool
b
)
{
m_drawNormals
=
b
;
updateGL
()
;
}
void
Viewer
::
slot_normalsSize
(
int
i
)
{
normalScaleFactor
=
i
/
50.0
f
;
updateGL
()
;
}
/**********************************************************************************************
* MAIN FUNCTION *
**********************************************************************************************/
int
main
(
int
argc
,
char
**
argv
)
{
QApplication
app
(
argc
,
argv
)
;
Viewer
sqt
;
sqt
.
setGeometry
(
0
,
0
,
1000
,
800
)
;
sqt
.
show
()
;
if
(
argc
>=
2
)
{
std
::
string
filename
(
argv
[
1
])
;
sqt
.
importMesh
(
filename
)
;
if
(
argc
>=
3
)
{
std
::
string
filenameExp
(
argv
[
2
])
;
std
::
cout
<<
"Exporting "
<<
filename
<<
" as "
<<
filenameExp
<<
" ... "
<<
std
::
flush
;
sqt
.
exportMesh
(
filenameExp
,
false
)
;
std
::
cout
<<
"done!"
<<
std
::
endl
;
return
(
0
)
;
}
}
sqt
.
initGUI
()
;
return
app
.
exec
()
;
}
include/Algo/VolumetricProgressiveMesh/vpmesh
.h
→
Apps/SandBox/testPlaneCutting
.h
View file @
ed9da781
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009
-2012, 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 *
...
...
@@ -22,94 +22,119 @@
* *
*******************************************************************************/
#ifndef __VPMESH__
#define __VPMESH__
#include <iostream>
//TODO add this file with git !!!
#include "Algo/VolumetricProgressiveMesh/vsplit.h"
#include "Utils/Qt/qtQGLV.h"
#include "ui_testPlaneCutting.h"
#include "Utils/Qt/qtui.h"
#include "Algo/Decimation/selector.h"
#include "Algo/Decimation/edgeSelector.h"
#include "Algo/Decimation/geometryApproximator.h"
#include "Algo/Decimation/geometryPredictor.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Utils/quantization.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
namespace
CGoGN
{
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
namespace
Algo
{
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topoRender.h"
namespace
Volume
{
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vbo.h"
namespace
VPMesh
{
#include "Utils/Qt/qtInputs.h"
template
<
typename
PFP
>
class
VolumetricProgressiveMesh
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Geometry/convexity.h"
private:
MAP
&
m_map
;
VertexAttribute
<
typename
PFP
::
VEC3
>&
positionsTable
;
using
namespace
CGoGN
;
DartMarker
&
inactiveMarker
;
SelectorUnmarked
dartSelect
;
Algo
::
Decimation
::
EdgeSelector
<
PFP
>*
m_selector
;
std
::
vector
<
Algo
::
Decimation
::
ApproximatorGen
<
PFP
>*>
m_approximators
;
std
::
vector
<
Algo
::
Decimation
::
PredictorGen
<
PFP
>*>
m_predictors
;
std
::
vector
<
VSplit
<
PFP
>*>
m_splits
;
unsigned
int
m_cur
;
struct
PFP
:
public
PFP_STANDARD
{
// definition of the map
typedef
EmbeddedMap2
MAP
;
};
Algo
::
Decimation
::
Approximator
<
PFP
,
VEC3
>*
m_positionApproximator
;
typedef
PFP
::
MAP
MAP
;
typedef
PFP
::
VEC3
VEC3
;
bool
m_initOk
;
class
Viewer
:
public
Utils
::
QT
::
SimpleQGLV
{
Q_OBJECT
public:
VolumetricProgressiveMesh
(
MAP
&
map
,
DartMarker
&
inactive
,
Algo
::
Decimation
::
SelectorType
s
,
Algo
::
Decimation
::
ApproximatorType
a
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
)
;
MAP
myMap
;
Utils
::
QT
::
uiDockInterface
dock
;
enum
renderMode
{
FLAT
,
PHONG
}
;
~
VolumetricProgressiveMesh
()
;
Geom
::
Vec4f
colDif
;
Geom
::
Vec4f
colSpec
;
Geom
::
Vec4f
colClear
;
Geom
::
Vec4f
colNormal
;
bool
initOk
()
{
return
m_initOk
;
}
float
shininess
;
void
createPM
(
unsigned
int
percentWantedVertices
)
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
;
float
normalBaseSize
;
float
normalScaleFactor
;
float
vertexBaseSize
;
float
vertexScaleFactor
;
float
faceShrinkage
;
std
::
vector
<
VSplit
<
PFP
>*>&
splits
()
{
return
m_splits
;
}
Algo
::
Decimation
::
EdgeSelector
<
PFP
>*
selector
()
{
return
m_selector
;
}