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
OpenMesh
OpenMesh
Commits
53174e3a
Commit
53174e3a
authored
Mar 01, 2010
by
Ellen Dekkers
Browse files
VDProgMesh added
git-svn-id:
http://www.openmesh.org/svnrepo/OpenMesh/trunk@281
fdac6126-5c0c-442c-9429-916003d36597
parent
e3900216
Changes
6
Show whitespace changes
Inline
Side-by-side
src/OpenMesh/Apps/CMakeLists.txt
View file @
53174e3a
...
...
@@ -18,6 +18,7 @@ if (QT4_FOUND AND OPENGL_FOUND AND GLEW_FOUND AND GLUT_FOUND AND NOT BUILD_APPS
add_subdirectory
(
Decimating/DecimaterGui
)
add_subdirectory
(
QtViewer
)
add_subdirectory
(
Subdivider/SubdividerGui
)
add_subdirectory
(
ProgViewer
)
else
()
if
(
BUILD_APPS STREQUAL OFF
)
message
(
"Building Apps disabled by user."
)
...
...
src/OpenMesh/Apps/ProgViewer/ACGMakefile
0 → 100644
View file @
53174e3a
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Config
#==============================================================================
CXX_CFLAGS += -DQT_THREAD_SUPPORT
SUBDIRS = $(call find-subdirs)
PACKAGES := qt4 glut opengl x11 math
PROJ_LIBS = OpenMesh/Apps/QtViewer OpenMesh/Tools OpenMesh/Core
MODULES := moc4 cxx
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Rules
#==============================================================================
src/OpenMesh/Apps/ProgViewer/OpenMesh_Apps_ProgViewer.vcproj
0 → 100644
View file @
53174e3a
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType=
"Visual C++"
Version=
"9,00"
Name=
"OpenMesh_Apps_ProgViewer"
ProjectGUID=
"{6CC92D44-A0AC-47D0-9482-D983B1F27E63}"
Keyword=
"Win32Proj"
TargetFrameworkVersion=
"131072"
>
<Platforms>
<Platform
Name=
"Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name=
"Debug|Win32"
OutputDirectory=
"Debug"
IntermediateDirectory=
"Debug"
ConfigurationType=
"1"
InheritedPropertySheets=
"$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet=
"2"
>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCCLCompilerTool"
Optimization=
"0"
AdditionalIncludeDirectories=
"c:\glut\include;C:\glew\include;..\..\..;"$(QTDIR)/include";"$(QTDIR)/include/QtCore";"$(QTDIR)/inlcude/Qt";"$(QTDIR)/include/QtGUI";"$(QTDIR)/include/QtOpenGL""
PreprocessorDefinitions=
"WIN32;_DEBUG;_CONSOLE;_USE_MATH_DEFINES;QT_DLL"
MinimalRebuild=
"false"
BasicRuntimeChecks=
"3"
RuntimeLibrary=
"3"
DisableLanguageExtensions=
"false"
ForceConformanceInForLoopScope=
"true"
RuntimeTypeInfo=
"true"
UsePrecompiledHeader=
"0"
ProgramDataBaseFileName=
"$(IntDir)/vc70.pdb"
WarningLevel=
"3"
Detect64BitPortabilityProblems=
"false"
DebugInformationFormat=
"4"
/>
<Tool
Name=
"VCManagedResourceCompilerTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCLinkerTool"
AdditionalDependencies=
"QtCore4.lib QtGUI4.lib QtOpenGL4.lib opengl32.lib"
OutputFile=
"..\..\bin\progviewer_dbg.exe"
LinkIncremental=
"2"
AdditionalLibraryDirectories=
"$(QTDIR)/lib;C:\glut\lib;C:\glew\lib"
GenerateDebugInformation=
"true"
ProgramDatabaseFile=
"$(OutDir)\$(TargetName).pdb"
SubSystem=
"1"
RandomizedBaseAddress=
"1"
DataExecutionPrevention=
"0"
TargetMachine=
"1"
/>
<Tool
Name=
"VCALinkTool"
/>
<Tool
Name=
"VCManifestTool"
/>
<Tool
Name=
"VCXDCMakeTool"
/>
<Tool
Name=
"VCBscMakeTool"
/>
<Tool
Name=
"VCFxCopTool"
/>
<Tool
Name=
"VCAppVerifierTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name=
"Release|Win32"
OutputDirectory=
"Release"
IntermediateDirectory=
"Release"
ConfigurationType=
"1"
InheritedPropertySheets=
"$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet=
"2"
>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCCLCompilerTool"
AdditionalIncludeDirectories=
"c:\glut\include;C:\glew\include;..\..\..;"$(QTDIR)/include";"$(QTDIR)/include/QtCore";"$(QTDIR)/inlcude/Qt";"$(QTDIR)/include/QtGUI";"$(QTDIR)/include/QtOpenGL""
PreprocessorDefinitions=
"WIN32;NDEBUG;_CONSOLE;_USE_MATH_DEFINES;QT_DLL"
RuntimeLibrary=
"2"
DisableLanguageExtensions=
"false"
ForceConformanceInForLoopScope=
"true"
RuntimeTypeInfo=
"true"
UsePrecompiledHeader=
"0"
WarningLevel=
"3"
Detect64BitPortabilityProblems=
"false"
DebugInformationFormat=
"3"
/>
<Tool
Name=
"VCManagedResourceCompilerTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCLinkerTool"
AdditionalDependencies=
"QtCore4.lib QtGUI4.lib QtOpenGL4.lib opengl32.lib"
OutputFile=
"..\..\bin\progviewer.exe"
LinkIncremental=
"1"
AdditionalLibraryDirectories=
"$(QTDIR)/lib;C:\glut\lib;C:\glew\lib"
GenerateDebugInformation=
"true"
SubSystem=
"1"
OptimizeReferences=
"2"
EnableCOMDATFolding=
"2"
RandomizedBaseAddress=
"1"
DataExecutionPrevention=
"0"
TargetMachine=
"1"
/>
<Tool
Name=
"VCALinkTool"
/>
<Tool
Name=
"VCManifestTool"
/>
<Tool
Name=
"VCXDCMakeTool"
/>
<Tool
Name=
"VCBscMakeTool"
/>
<Tool
Name=
"VCFxCopTool"
/>
<Tool
Name=
"VCAppVerifierTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name=
"Generated Files"
>
<File
RelativePath=
".\moc_ProgViewerWidget.cpp"
>
</File>
<File
RelativePath=
".\moc_QGLViewerWidget.cpp"
>
</File>
</Filter>
<File
RelativePath=
"..\QtViewer\MeshViewerWidgetT.cc"
>
</File>
<File
RelativePath=
"..\QtViewer\QGLViewerWidget.cc"
>
</File>
<File
RelativePath=
"..\QtViewer\MeshViewerWidgetT.hh"
>
</File>
<File
RelativePath=
".\progviewer.cc"
>
</File>
<File
RelativePath=
".\ProgViewerWidget.cc"
>
</File>
<File
RelativePath=
".\ProgViewerWidget.hh"
>
<FileConfiguration
Name=
"Debug|Win32"
>
<Tool
Name=
"VCCustomBuildTool"
Description=
"MOC $(InputFileName)"
CommandLine=
"$(QTDIR)\bin\moc.exe $(InputFileName) -o moc_$(InputName).cpp
"
Outputs=
"moc_$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release|Win32"
>
<Tool
Name=
"VCCustomBuildTool"
Description=
"MOC $(InputFileName)"
CommandLine=
"$(QTDIR)\bin\moc.exe $(InputFileName) -o moc_$(InputName).cpp
"
Outputs=
"moc_$(InputName).cpp"
/>
</FileConfiguration>
</File>
<File
RelativePath=
"..\QtViewer\QGLViewerWidget.hh"
>
<FileConfiguration
Name=
"Debug|Win32"
>
<Tool
Name=
"VCCustomBuildTool"
Description=
"MOC $(InputFileName)"
CommandLine=
"$(QTDIR)\bin\moc.exe ..\QtViewer\$(InputFileName) -o moc_$(InputName).cpp
"
Outputs=
"moc_$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release|Win32"
>
<Tool
Name=
"VCCustomBuildTool"
Description=
"MOC $(InputFileName)"
CommandLine=
"$(QTDIR)\bin\moc.exe ..\QtViewer\$(InputFileName) -o moc_$(InputName).cpp
"
Outputs=
"moc_$(InputName).cpp"
/>
</FileConfiguration>
</File>
<File
RelativePath=
"..\..\test1.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
src/OpenMesh/Apps/ProgViewer/ProgViewerWidget.cc
0 → 100644
View file @
53174e3a
/*===========================================================================*\
* *
* OpenMesh *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenMesh. *
* *
* OpenMesh 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 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenMesh 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 LesserGeneral Public *
* License along with OpenMesh. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* *
\*===========================================================================*/
//== INCLUDES =================================================================
#ifdef _MSC_VER
# pragma warning(disable: 4267 4311)
#endif
#include
<iostream>
#include
<fstream>
// --------------------
#include
<QApplication>
#include
<QFileInfo>
#include
<QKeyEvent>
// --------------------
#include
<OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh>
#include
<OpenMesh/Core/IO/BinaryHelper.hh>
#include
<OpenMesh/Core/IO/MeshIO.hh>
#include
<OpenMesh/Core/Utils/Endian.hh>
#include
<OpenMesh/Tools/Utils/Timer.hh>
// --------------------
#ifdef ARCH_DARWIN
# include <gl.h>
#else
# include <GL/gl.h>
#endif
using
namespace
Qt
;
//== IMPLEMENTATION ==========================================================
void
ProgViewerWidget
::
open_prog_mesh
(
const
char
*
_filename
)
{
MyMesh
::
Point
p
;
unsigned
int
i
,
i0
,
i1
,
i2
;
unsigned
int
v1
,
vl
,
vr
;
char
c
[
10
];
std
::
ifstream
ifs
(
_filename
,
std
::
ios
::
binary
);
if
(
!
ifs
)
{
std
::
cerr
<<
"read error
\n
"
;
exit
(
1
);
}
//
bool
swap
=
OpenMesh
::
Endian
::
local
()
!=
OpenMesh
::
Endian
::
LSB
;
// read header
ifs
.
read
(
c
,
8
);
c
[
8
]
=
'\0'
;
if
(
std
::
string
(
c
)
!=
std
::
string
(
"ProgMesh"
))
{
std
::
cerr
<<
"Wrong file format.
\n
"
;
exit
(
1
);
}
OpenMesh
::
IO
::
binary
<
size_t
>::
restore
(
ifs
,
n_base_vertices_
,
swap
);
OpenMesh
::
IO
::
binary
<
size_t
>::
restore
(
ifs
,
n_base_faces_
,
swap
);
OpenMesh
::
IO
::
binary
<
size_t
>::
restore
(
ifs
,
n_detail_vertices_
,
swap
);
n_max_vertices_
=
n_base_vertices_
+
n_detail_vertices_
;
// load base mesh
mesh_
.
clear
();
for
(
i
=
0
;
i
<
n_base_vertices_
;
++
i
)
{
OpenMesh
::
IO
::
binary
<
MyMesh
::
Point
>::
restore
(
ifs
,
p
,
swap
);
mesh_
.
add_vertex
(
p
);
}
for
(
i
=
0
;
i
<
n_base_faces_
;
++
i
)
{
OpenMesh
::
IO
::
binary
<
unsigned
int
>::
restore
(
ifs
,
i0
,
swap
);
OpenMesh
::
IO
::
binary
<
unsigned
int
>::
restore
(
ifs
,
i1
,
swap
);
OpenMesh
::
IO
::
binary
<
unsigned
int
>::
restore
(
ifs
,
i2
,
swap
);
mesh_
.
add_face
(
mesh_
.
vertex_handle
(
i0
),
mesh_
.
vertex_handle
(
i1
),
mesh_
.
vertex_handle
(
i2
));
}
// load progressive detail
for
(
i
=
0
;
i
<
n_detail_vertices_
;
++
i
)
{
OpenMesh
::
IO
::
binary
<
MyMesh
::
Point
>::
restore
(
ifs
,
p
,
swap
);
OpenMesh
::
IO
::
binary
<
unsigned
int
>::
restore
(
ifs
,
v1
,
swap
);
OpenMesh
::
IO
::
binary
<
unsigned
int
>::
restore
(
ifs
,
vl
,
swap
);
OpenMesh
::
IO
::
binary
<
unsigned
int
>::
restore
(
ifs
,
vr
,
swap
);
PMInfo
pminfo
;
pminfo
.
p0
=
p
;
pminfo
.
v1
=
MyMesh
::
VertexHandle
(
v1
);
pminfo
.
vl
=
MyMesh
::
VertexHandle
(
vl
);
pminfo
.
vr
=
MyMesh
::
VertexHandle
(
vr
);
pminfos_
.
push_back
(
pminfo
);
}
pmiter_
=
pminfos_
.
begin
();
// update face and vertex normals
mesh_
.
update_face_normals
();
mesh_
.
update_vertex_normals
();
// bounding box
MyMesh
::
ConstVertexIter
vIt
(
mesh_
.
vertices_begin
()),
vEnd
(
mesh_
.
vertices_end
());
MyMesh
::
Point
bbMin
,
bbMax
;
bbMin
=
bbMax
=
mesh_
.
point
(
vIt
);
for
(;
vIt
!=
vEnd
;
++
vIt
)
{
bbMin
.
minimize
(
mesh_
.
point
(
vIt
));
bbMax
.
maximize
(
mesh_
.
point
(
vIt
));
}
// set center and radius
set_scene_pos
(
0.5
f
*
(
bbMin
+
bbMax
),
0.5
*
(
bbMin
-
bbMax
).
norm
());
// info
std
::
cerr
<<
mesh_
.
n_vertices
()
<<
" vertices, "
<<
mesh_
.
n_edges
()
<<
" edge, "
<<
mesh_
.
n_faces
()
<<
" faces, "
<<
n_detail_vertices_
<<
" detail vertices
\n
"
;
setWindowTitle
(
QFileInfo
(
_filename
).
fileName
()
);
}
//-----------------------------------------------------------------------------
void
ProgViewerWidget
::
refine
(
unsigned
int
_n
)
{
size_t
n_vertices
=
mesh_
.
n_vertices
();
while
(
n_vertices
<
_n
&&
pmiter_
!=
pminfos_
.
end
())
{
pmiter_
->
v0
=
mesh_
.
add_vertex
(
pmiter_
->
p0
);
mesh_
.
vertex_split
(
pmiter_
->
v0
,
pmiter_
->
v1
,
pmiter_
->
vl
,
pmiter_
->
vr
);
++
pmiter_
;
++
n_vertices
;
}
mesh_
.
update_face_normals
();
mesh_
.
update_vertex_normals
();
std
::
cerr
<<
n_vertices
<<
" vertices
\n
"
;
}
//-----------------------------------------------------------------------------
void
ProgViewerWidget
::
coarsen
(
unsigned
int
_n
)
{
size_t
n_vertices
=
mesh_
.
n_vertices
();
while
(
n_vertices
>
_n
&&
pmiter_
!=
pminfos_
.
begin
())
{
--
pmiter_
;
MyMesh
::
HalfedgeHandle
hh
=
mesh_
.
find_halfedge
(
pmiter_
->
v0
,
pmiter_
->
v1
);
mesh_
.
collapse
(
hh
);
--
n_vertices
;
}
mesh_
.
garbage_collection
();
mesh_
.
update_face_normals
();
mesh_
.
update_vertex_normals
();
std
::
cerr
<<
n_vertices
<<
" vertices
\n
"
;
}
//-----------------------------------------------------------------------------
void
ProgViewerWidget
::
keyPressEvent
(
QKeyEvent
*
_event
)
{
switch
(
_event
->
key
())
{
case
Key_Minus
:
if
(
_event
->
modifiers
()
&
ShiftModifier
)
coarsen
(
mesh_
.
n_vertices
()
-
1
);
else
coarsen
((
unsigned
int
)(
0.9
*
mesh_
.
n_vertices
()));
updateGL
();
break
;
case
Key_Plus
:
if
(
_event
->
modifiers
()
&
ShiftModifier
)
refine
(
mesh_
.
n_vertices
()
+
1
);
else
refine
((
unsigned
int
)(
std
::
max
(
1.1
*
mesh_
.
n_vertices
(),
mesh_
.
n_vertices
()
+
1.0
)
));
updateGL
();
break
;
case
Key_Home
:
coarsen
(
n_base_vertices_
);
updateGL
();
break
;
case
Key_A
:
if
(
timer_
->
isActive
())
{
timer_
->
stop
();
std
::
cout
<<
"animation stopped!"
<<
std
::
endl
;
}
else
{
timer_
->
setSingleShot
(
true
);
timer_
->
start
(
0
);
std
::
cout
<<
"animation started!"
<<
std
::
endl
;
}
break
;
case
Key_End
:
refine
(
n_base_vertices_
+
n_detail_vertices_
);
updateGL
();
break
;
case
Key_P
:
{
const
size_t
refine_max
=
100000
;
const
size_t
n_loop
=
5
;
OpenMesh
::
Utils
::
Timer
t
;
size_t
count
;
coarsen
(
0
);
count
=
mesh_
.
n_vertices
();
refine
(
refine_max
);
count
=
mesh_
.
n_vertices
()
-
count
;
t
.
start
();
for
(
size_t
i
=
0
;
i
<
n_loop
;
++
i
)
{
coarsen
(
0
);
refine
(
100000
);
}
t
.
stop
();
std
::
cout
<<
"# collapses/splits: "
<<
2
*
(
n_loop
+
1
)
*
count
<<
" in "
<<
t
.
as_string
()
<<
std
::
endl
;
std
::
cout
<<
"# collapses or splits per seconds: "
<<
2
*
(
n_loop
+
1
)
*
count
/
t
.
seconds
()
<<
"
\n
"
;
coarsen
(
0
);
updateGL
();
break
;
}
case
Key_S
:
if
(
OpenMesh
::
IO
::
write_mesh
(
mesh_
,
"result.off"
))
std
::
clog
<<
"Current mesh stored in 'result.off'
\n
"
;