Commit 90708a39 authored by David Bommes's avatar David Bommes

added Laplace Smoothing on TetrahedralMeshes

parents e9900546 c8c8cb54
Pipeline #5405 passed with stage
in 51 minutes and 13 seconds
......@@ -26,6 +26,7 @@ find_path(GUROBI_INCLUDE_DIR
PATHS "$ENV{GUROBI_HOME}/include"
"/Library/gurobi502/mac64/include"
"/Library/gurobi562/mac64/include"
"/Library/gurobi650/mac64/include"
"C:\\libs\\gurobi502\\include"
"C:\\libs\\gurobi562\\include"
"${GUROBI_BASE}/include"
......@@ -46,6 +47,7 @@ find_library( GUROBI_LIBRARY
PATHS "$ENV{GUROBI_HOME}/lib"
"/Library/gurobi562/mac64/lib"
"/Library/gurobi502/mac64/lib"
"/Library/gurobi650/mac64/lib"
"C:\\libs\\gurobi562\\lib"
"C:\\libs\\gurobi502\\lib"
"${GUROBI_BASE}/lib"
......
......@@ -22,8 +22,8 @@ file (
FIND_PATH( ISOEX_INCLUDE_DIRS IsoEx/Extractors/MarchingCubesT.hh
PATHS "${_libdirs}"
"${CMAKE_SOURCE_DIR}/libs" )
PATHS ${_libdirs}
${CMAKE_SOURCE_DIR}/libs )
add_definitions (-DISOEXDLL -DUSEISOEX )
......
......@@ -20,8 +20,8 @@ file (
FIND_PATH(PHYSIM_INCLUDE_DIR PhySim/Config/PhySimDefines.hh
PATHS "${_libdirs}"
"${CMAKE_SOURCE_DIR}/libs" )
PATHS ${_libdirs}
${CMAKE_SOURCE_DIR}/libs )
add_definitions (-DPHYSIMDLL -DUSEPHYSIM )
......
# - Try to find SPECTRA
# Once done this will define
# SPECTRA_FOUND - System has SPECTRA
# SPECTRA_INCLUDE_DIRS - The SPECTRA include directories
if (SPECTRA_INCLUDE_DIR)
# in cache already
set(SPECTRA_FOUND TRUE)
set(SPECTRA_INCLUDE_DIRS "${SPECTRA_INCLUDE_DIR}" )
else (SPECTRA_INCLUDE_DIR)
# Check if the base path is set
if ( NOT CMAKE_WINDOWS_LIBS_DIR )
# This is the base directory for windows library search used in the finders we shipp.
set(CMAKE_WINDOWS_LIBS_DIR "c:/libs" CACHE STRING "Default Library search dir on windows." )
endif()
if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x32/")
endif()
find_path( SPECTRA_INCLUDE_DIR
NAMES SymEigsSolver.h
PATHS $ENV{SPECTRA_DIR}
/usr/include/spectra
/usr/local/include
/usr/local/include/spectra/
/opt/local/include/spectra/
"${CMAKE_WINDOWS_LIBS_DIR}/general/spectra"
"${CMAKE_WINDOWS_LIBS_DIR}/spectra"
"${CMAKE_WINDOWS_LIBS_DIR}/spectra/include"
"${CMAKE_WINDOWS_LIBS_DIR}/eigen/include"
${PROJECT_SOURCE_DIR}/MacOS/Libs/SPECTRA/include
../../External/include
${module_file_path}/../../../External/include
)
set(SPECTRA_INCLUDE_DIRS "${SPECTRA_INCLUDE_DIR}" )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set SPECTRA_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(SPECTRA DEFAULT_MSG
SPECTRA_INCLUDE_DIR)
mark_as_advanced(SPECTRA_INCLUDE_DIR)
endif(SPECTRA_INCLUDE_DIR)
......@@ -49,6 +49,10 @@ namespace
}
}
/**
* Member functions
*/
void MergePlugin::slotCleanup( DataType _type, bool _deleteSeparateObjects )
{
//clean up conversion objects
......@@ -123,6 +127,8 @@ MergePlugin::MergePlugin() :
/// init the Toolbox
void MergePlugin::initializePlugin() {
if ( ! OpenFlipper::Options::gui())
return;
tool_ = new MergeToolBox();
QSize size(300, 300);
......@@ -140,12 +146,28 @@ void MergePlugin::initializePlugin() {
void MergePlugin::pluginsInitialized()
{
//populate scripting function
emit setSlotDescription("mergeObjects(const std::vector< BaseObjectData* >,QString,bool)", "Merges multiple meshes into one mesh. returns the ID of the new mesh or -1 in case of error.",
emit setSlotDescription("mergeObjects(const std::vector< BaseObjectData* >,QString,bool,DataType)", "Merges multiple meshes into one mesh. returns the ID of the new mesh or -1 in case of error.",
QString("objects,mergedName,deleteSeparateObjects").split(","),
QString(" vector of BaseObjectData* containing Poly or TriMeshes to be merged, name for the merged object, flag to remove separated objects default is true").split(","));
QString(" vector of BaseObjectData* containing Poly or TriMeshes to be merged, name for the merged object, flag to remove separated objects default is true, DataType for the new mesh if used in nogui mode").split(","));
emit setSlotDescription("mergeObjects(IdList,QString,bool,DataType)", "Merges multiple meshes into one mesh. returns the ID of the new mesh or -1 in case of error.",
QString("objects,mergedName,deleteSeparateObjects").split(","),
QString(" vector of Object Ids of Poly or TriMeshes to be merged, name for the merged object, flag to remove separated objects default is true, DataType for the new mesh if used in nogui mode").split(","));
}
int MergePlugin::mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name, bool _deleteSeparateObjects)
int MergePlugin::mergeObjects(IdList _objects, QString _name, bool _deleteSeparateObjects, DataType _type)
{
std::vector< BaseObjectData* > objects;
for(int i : _objects)
{
BaseObject* obj;
PluginFunctions::getObject(i,obj);
objects.push_back(PluginFunctions::baseObjectData(obj));
}
return mergeObjects(objects, _name, _deleteSeparateObjects, _type);
}
int MergePlugin::mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name, bool _deleteSeparateObjects, DataType _type)
{
int result = -1;
if (_objects.size() < 2)
......@@ -153,8 +175,11 @@ int MergePlugin::mergeObjects(const std::vector< BaseObjectData* > & _objects, Q
objects = _objects;
//check dataType
DataType type = checkType(objects);
DataType type;
if ( OpenFlipper::Options::gui())
type = checkType(objects);
else
type = _type;
//user pushed the cancel button
if(type != DATA_TRIANGLE_MESH && type != DATA_POLY_MESH)
......
......@@ -63,6 +63,10 @@ private :
DataType checkType(const std::vector< BaseObjectData* > &);
private slots :
// Tell system that this plugin runs without ui
void noguiSupported( ) {} ;
public slots:
// BaseInterface
void initializePlugin();
......@@ -77,7 +81,17 @@ public slots:
* @param _deleteSeparateObjects flag to determine if the separate objects shall be deleted after merging (default is true)
* @return
*/
int mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name = "merged object", bool _deleteSeparateObjects = true);
int mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name = "merged object", bool _deleteSeparateObjects = true, DataType type_ = typeId("TriangleMesh"));
/**
* @brief mergeObjects
* @param _objects
* @param _name
* @param _deleteSeparateObjects
* @param type_
* @return
*/
int mergeObjects(IdList _objects, QString _name = "merged object", bool _deleteSeparateObjects = true, DataType type_ = typeId("TriangleMesh"));
/**
* @brief slotCleanup is called when the cleanup event is processed at the end of mergeObjects.
......
......@@ -66,6 +66,13 @@ void MeshConvertPlugin::initializePlugin()
void MeshConvertPlugin::pluginsInitialized()
{
//populate scripting function
emit setSlotDescription("convert(int,bool)", "Convert a mesh to PolyMesh or to TriMesh. returns the ID of the new mesh or -1 in case of error. The old mesh remains unchanged.",
QString("object_id,toTriMesh").split(","),
QString(" id of an object to convert, flag to convert to a TriMesh, if not set creates a new PolyMesh").split(","));
if(! OpenFlipper::Options::gui())
return;
// Create your toolbar
toolbar = new QToolBar(tr("Mesh conversion"));
......@@ -94,10 +101,7 @@ void MeshConvertPlugin::pluginsInitialized()
// Integrate the new toolbar into OpenFlipper
emit addToolbar( toolbar );
//populate scripting function
emit setSlotDescription("convert(int,bool)", "Convert a mesh to PolyMesh or to TriMesh. returns the ID of the new mesh or -1 in case of error. The old mesh remains unchanged.",
QString("object_id,toTriMesh").split(","),
QString(" id of an object to convert, flag to convert to a TriMesh, if not set creates a new PolyMesh").split(","));
}
......
......@@ -101,6 +101,9 @@ private slots:
void initializePlugin();
void pluginsInitialized();
/// Tell system that this plugin runs without ui
void noguiSupported( ) {} ;
private:
QToolBar* toolbar;
......
include (plugin)
openflipper_plugin (INSTALLDATA Icons
TYPES POLYMESH TRIANGLEMESH)
openflipper_plugin (DEPS OpenVolumeMesh
INSTALLDATA Icons
TYPES POLYMESH TRIANGLEMESH TETRAHEDRALMESH POLYHEDRALMESH)
......@@ -51,9 +51,11 @@
#include "SmootherPlugin.hh"
#include <ACG/Utils/StopWatch.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <ObjectTypes/TetrahedralMesh/TetrahedralMesh.hh>
SmootherPlugin::SmootherPlugin() :
iterationsSpinbox_(0)
......@@ -273,8 +275,52 @@ void SmootherPlugin::simpleLaplace(int _iterations) {
// Create backup
emit createBackup(o_it->id(), "Simple Smoothing", UPDATE_GEOMETRY);
} else {
} else if ( o_it->dataType( DATA_TETRAHEDRAL_MESH ) ) {
// Get the mesh to work on
TetrahedralMesh* mesh = PluginFunctions::tetrahedralMesh(*o_it);
TetrahedralMeshObject::StatusAttrib& status = PluginFunctions::tetrahedralMeshObject(*o_it)->status();
// Property for the active mesh to store new point positions
OpenVolumeMesh::VertexPropertyT<TetrahedralMesh::PointT> newPositions =
mesh->request_vertex_property<TetrahedralMesh::PointT>("newPositions");
ACG::StopWatch sw; sw.start();
for ( int i = 0 ; i < _iterations ; ++i ) {
for(OpenVolumeMesh::VertexIter v_it = mesh->vertices_begin(); v_it != mesh->vertices_end(); ++v_it)
if(!status[*v_it].selected())
{
newPositions[*v_it] = TetrahedralMesh::PointT(0,0,0);
int n = 0.0;
for(OpenVolumeMesh::VertexOHalfEdgeIter voh_it = mesh->voh_iter(*v_it); voh_it.valid(); ++voh_it)
{
newPositions[*v_it] += mesh->vertex(mesh->halfedge(*voh_it).to_vertex());
++n;
}
newPositions[*v_it] /= double(n);
}
// set new positions
for(OpenVolumeMesh::VertexIter v_it = mesh->vertices_begin(); v_it != mesh->vertices_end(); ++v_it)
if(!status[*v_it].selected())
{
mesh->set_vertex(*v_it,newPositions[*v_it]);
}
}// Iterations end
std::cerr << _iterations << "smoothing iterations took " << sw.stop()/1000.0 << "s on mesh with #V = " << mesh->n_vertices() << std::endl;
emit updatedObject( o_it->id() , UPDATE_GEOMETRY);
// Create backup
emit createBackup(o_it->id(), "Simple Smoothing", UPDATE_GEOMETRY);
}
else
{
emit log(LOGERR, "DataType not supported.");
}
}
......
......@@ -90,8 +90,9 @@ void Renderer::render(ACG::GLState* _glState, Viewer::ViewerProperties& _propert
if (oM)
{
glClear (GL_STENCIL_BUFFER_BIT);
ACG::GLState::enable (GL_STENCIL_TEST);
ACG::GLState::enable(GL_STENCIL_TEST);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilOp (GL_KEEP, GL_KEEP, GL_ZERO);
glStencilFunc (GL_ALWAYS, 0, ~0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment