Commit 5781198b authored by Mike Kremer's avatar Mike Kremer

Built foundation of OpenVolumeMesh integration. Hexahedral mesh specializations are yet to come.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13487 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 07c3cdbc
......@@ -37,6 +37,10 @@ find_package (OpenMesh)
if (NOT OPENMESH_FOUND)
message (FATAL_ERROR "OpenMesh not found!")
endif ()
find_package (OpenVolumeMesh)
if (NOT OPENVOLUMEMESH_FOUND)
message (FATAL_ERROR "OpenVolumeMesh not found!")
endif ()
# ========================================================================
......
This diff is collapsed.
//=============================================================================
//
// Plugin Functions for PolyhedralMeshes
//
//=============================================================================
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyhedralMesh/PluginFunctionsPolyhedralMesh.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
namespace PluginFunctions {
// ===============================================================================
// Get source meshes
// ===============================================================================
bool getSourceMeshes( std::vector<PolyhedralMesh*>& _meshes )
{
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::SOURCE_OBJECTS,DATA_POLYHEDRAL_MESH) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
_meshes.push_back ( PluginFunctions::polyhedralMesh( *o_it ) );
if( _meshes.back() == NULL)
std::cerr << "ERROR: PolyhedralMesh getSourceMeshes fatal error\n";
}
return (_meshes.size() > 0 );
}
// ===============================================================================
// Get target meshes
// ===============================================================================
bool getTargetMeshes( std::vector<PolyhedralMesh*>& _meshes )
{
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DATA_POLYHEDRAL_MESH ) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
_meshes.push_back ( PluginFunctions::polyhedralMesh( *o_it ) );
if( _meshes.back() == NULL)
std::cerr << "ERROR: PolyhedralMesh getTargetMeshes fatal error\n";
}
return (_meshes.size() > 0 );
}
// ===============================================================================
// Get objects
// ===============================================================================
bool getObject( int _identifier, PolyhedralMeshObject*& _object ) {
if ( _identifier == -1 ) {
_object = 0;
return false;
}
BaseObject* object = objectRoot()->childExists( _identifier );
_object = dynamic_cast< PolyhedralMeshObject* >(object);
return ( _object != 0 );
}
// ===============================================================================
// Getting data from objects and casting between them
// ===============================================================================
PolyhedralMesh* polyhedralMesh( BaseObjectData* _object ) {
if ( _object->dataType(DATA_POLYHEDRAL_MESH) ) {
PolyhedralMeshObject* object = dynamic_cast< PolyhedralMeshObject* >(_object);
return object->mesh();
} else
return 0;
}
PolyhedralMeshObject* polyhedralMeshObject( BaseObjectData* _object ) {
if ( ! _object->dataType(DATA_POLYHEDRAL_MESH) )
return 0;
return dynamic_cast< PolyhedralMeshObject* >( _object );
}
PolyhedralMeshObject* polyhedralMeshObject( int _identifier )
{
PolyhedralMeshObject* pol_obj;
if(getObject(_identifier, pol_obj))
return pol_obj;
else
return 0;
}
}
//=============================================================================
//
// Standard Functions
//
//=============================================================================
/**
* \file PluginFunctionsPolyhedralMesh.hh
* This file contains functions which can be used by plugins to access
* PolyhedralMeshes in the framework.
*/
//
#ifndef PLUGINFUNCTIONSPOLYHEDRALMESH_HH
#define PLUGINFUNCTIONSPOLYHEDRALMESH_HH
#include <ObjectTypes/VolumeMeshObject/VolumeMeshObject.hh>
#include <ObjectTypes/PolyhedralMesh/PolyhedralMesh.hh>
#include <OpenFlipper/common/Types.hh>
//== NAMESPACES ===============================================================
/** The Namespace PluginFunctions contains functions for all plugins. */
namespace PluginFunctions {
/** \brief Get a pointer to every PolyhedralMesh which is marked as a source.
*
* @param _meshes ( vector returning the source polyhedral meshes )
* @return false, if no polyhedral mesh is selected as source
*/
DLLEXPORT
bool getSourceMeshes( std::vector<PolyhedralMesh*>& _meshes );
/** \brief Get a pointer to every PolyhedralMesh which is marked as a target.
*
* @param _meshes ( vector returning the target polyhedral meshes )
* @return false, if no polyhedral mesh is selected as target
*/
DLLEXPORT
bool getTargetMeshes( std::vector<PolyhedralMesh*>& _meshes );
/** This functions returns the object with the given id if it is an PolyhedralMeshObject.
* See get_object( int _identifier , BaseObject*& _object ) for more details.
*/
DLLEXPORT
bool getObject( int _identifier, PolyhedralMeshObject*& _object );
/** \brief Get an PolyhedralMesh from an object.
*
* @param _object The object should be of type BaseDataObject. If the content is
* a polyhedral mesh, a polyhedral mesh will be returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
PolyhedralMesh* polyhedralMesh( BaseObjectData* _object );
/** \brief Cast an BaseObject to an PolyhedralMeshObject if possible
*
* @param _object The object should be of type BaseDataObject. If the content is
* an PolyhedralMesh, an PolyhedralMeshObject is returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
PolyhedralMeshObject* polyhedralMeshObject( BaseObjectData* _object );
/** \brief Cast an int to an PolyhedralMeshObject if possible
*
* @param _identifier
*/
DLLEXPORT
PolyhedralMeshObject* polyhedralMeshObject( int _identifier );
}
#endif // PLUGINFUNCTIONSOPENVOLUMEMESH_HH
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper 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. *
* *
* OpenFlipper 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 OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 10745 $ *
* $LastChangedBy: kremer $ *
* $Date: 2011-01-26 10:23:50 +0100 (Wed, 26 Jan 2011) $ *
* *
\*===========================================================================*/
/**
* \file PolyhedralMesh.hh
* This file contains all required includes for using polyhedral meshes
*/
#ifndef POLYHEDRAL_MESH_INCLUDE_HH
#define POLYHEDRAL_MESH_INCLUDE_HH
//== INCLUDES =================================================================
#define DATA_POLYHEDRAL_MESH typeId("PolyhedralMesh")
#include <ObjectTypes/VolumeMeshObject/VolumeMeshObject.hh>
#include <ObjectTypes/PolyhedralMesh/OpenFlipperPolyhedralMesh.hh>
/// Typedef for a mesh object containing a polyhedral mesh
typedef VolumeMeshObject< PolyhedralMesh > PolyhedralMeshObject;
#include <ObjectTypes/PolyhedralMesh/PluginFunctionsPolyhedralMesh.hh>
//=============================================================================
#endif // POLYHEDRAL_MESH_INCLUDE_HH defined
//=============================================================================
This diff is collapsed.
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper 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. *
* *
* OpenFlipper 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 OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 10745 $ *
* $LastChangedBy: kremer $ *
* $Date: 2011-01-26 10:23:50 +0100 (Wed, 26 Jan 2011) $ *
* *
\*===========================================================================*/
#ifndef VOLUME_MESH_OBJECT_HH
#define VOLUME_MESH_OBJECT_HH
// Includes
#include <ACG/Scenegraph/SeparatorNode.hh>
#include <ACG/Scenegraph/StatusNodesT.hh>
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/common/BaseObjectData.hh>
#include <ObjectTypes/VolumeMeshObject/VolumeMeshNode.hh>
template<class MeshT>
class DLLEXPORTONLY VolumeMeshObject : public BaseObjectData {
public:
/** \brief copy constructor
*
* Create a copy of this object
*/
VolumeMeshObject(const VolumeMeshObject& _object);
/** \brief Constructor
*
* This is the standard constructor for MeshObjects. As triangle and Poly Meshes are handled by this class, the
* typeId is passed to the MeshObject to specify it.
*
* @param _typeId This is the type Id the Object will use. Should be typeId("TriangleMesh") or typeId("PolyMesh")
*/
VolumeMeshObject(DataType _typeId);
/// destructor
virtual ~VolumeMeshObject();
/// Reset current object, including all related nodes.
virtual void cleanup();
protected:
/// Initialise current object, including all related nodes.
virtual void init(MeshT* _mesh = 0);
//===========================================================================
/** @name Name and Path handling
* @{ */
//===========================================================================
public:
/// Set the name of the Object
void setName( QString _name );
/** @} */
//===========================================================================
/** @name Content
* @{ */
//===========================================================================
public:
/// return a pointer to the mesh
MeshT* mesh();
/// Update the whole Object (Selection,Topology,...)
virtual void update(UpdateType _type = UPDATE_ALL);
/// Call this function to update the selection
void updateSelection();
/// Update Geometry of all data structures
void updateGeometry();
/// Update Colors of all data structures
void updateColor();
/// Update Topology of all data structures
void updateTopology();
/** return a full copy of this object ( All scenegraph nodes will be created )
* but the object will not be a part of the object tree.
*/
BaseObject* copy();
private:
MeshT* mesh_;
/** @} */
//===========================================================================
/** @name Visualization
* @{ */
//===========================================================================
public:
/// Get the Scenegraph Mesh Node
ACG::SceneGraph::VolumeMeshNodeT<MeshT>* meshNode();
/// Get the BoundingBox of this object
void boundingBox(ACG::Vec3d& _bbMin, typename ACG::Vec3d& _bbMax);
BaseNode* primaryNode();
private:
/// Scenegraph Mesh Node
ACG::SceneGraph::VolumeMeshNodeT<MeshT>* meshNode_;
/** @} */
//===========================================================================
/** @name Object Information
* @{ */
//===========================================================================
public:
/// Get all Info for the Object as a string
QString getObjectinfo();
/** @} */
//===========================================================================
/** @name Picking
* @{ */
//===========================================================================
public:
/// detect if the node has been picked
bool picked(unsigned int _node_idx);
/// Enable or disable picking for this Node
void enablePicking(bool _enable);
/// Check if picking is enabled for this Node
bool pickingEnabled();
/** @} */
};
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(VOLUMEMESHOBJECTT_CC)
#define VOLUMEMESHOBJECT_TEMPLATES
#include "VolumeMeshObjectT.cc"
#endif
#endif
This diff is collapsed.
......@@ -20,6 +20,7 @@ endforeach ()
include_directories (
..
${OPENMESH_INCLUDE_DIR}
${OPENVOLUMEMESH_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
......@@ -116,6 +117,7 @@ endif()
target_link_libraries (OpenFlipperPluginLib
OpenMeshCore
OpenMeshTools
${OPENVOLUMEMESH_LIBRARY}
ACG
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
......
......@@ -356,6 +356,7 @@ function (_build_openflipper_plugin plugin)
.
${CMAKE_SOURCE_DIR}
${OPENMESH_INCLUDE_DIR}
${OPENVOLUMEMESH_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${${_PLUGIN}_DEPS_INCDIRS}
......@@ -492,8 +493,9 @@ function (_build_openflipper_plugin plugin)
# generate dllinport defines
add_definitions (-DACGDLL -DUSEACG -DPLUGINLIBDLL -DUSEPLUGINLIBDLL)
target_link_libraries (Plugin-${plugin}
OpenMeshCore
OpenMeshCore
OpenMeshTools
${OPENVOLUMEMESH_LIBRARY}
ACG
OpenFlipperPluginLib
${GLUT_LIBRARIES}
......
include (plugin)
openflipper_plugin (OpenVolumeMesh)
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <QtGui>
#include <QFileInfo>
#include <ACG/GL/GLState.hh>
#include <OpenMesh/Core/IO/IOManager.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
#include "FileOpenVolumeMesh.hh"
FileOpenVolumeMeshPlugin::FileOpenVolumeMeshPlugin() :
loadOptions_(0),
saveOptions_(0),
typeCheck_(0),
loadCompMode_(0),
loadCorrectOrder_(0),
loadTopCheck_(0),
saveCompMode_(0) {
}
//----------------------------------------------------------------------------
void FileOpenVolumeMeshPlugin::initializePlugin() {
loadOptions_ = new QWidget();
QVBoxLayout* llayout = new QVBoxLayout();
llayout->setAlignment(Qt::AlignTop);
typeCheck_ = new QComboBox();
typeCheck_->addItem("Autodetect");
typeCheck_->addItem("Polyhedral Mesh");
typeCheck_->addItem("Hexahedral Mesh");
typeCheck_->setCurrentIndex(0);
loadCompMode_ = new QCheckBox("Load PolyVolMesh format");
loadCorrectOrder_= new QCheckBox("Correct face ordering");
loadTopCheck_ = new QCheckBox("Perform topology checks");
llayout->addWidget(typeCheck_);
llayout->addWidget(loadCompMode_);
llayout->addWidget(loadCorrectOrder_);
llayout->addWidget(loadTopCheck_);
loadOptions_->setLayout(llayout);
saveOptions_ = new QWidget();
QVBoxLayout* slayout = new QVBoxLayout();
slayout->setAlignment(Qt::AlignTop);
saveCompMode_ = new QCheckBox("Save in PolyVolMesh format");
slayout->addWidget(saveCompMode_);
saveOptions_->setLayout(slayout);
}
//----------------------------------------------------------------------------
QString FileOpenVolumeMeshPlugin::getLoadFilters() {
return QString(tr("Polyhedral Volume Mesh files ( *.ovm *.polyvolmesh )"));
}
;
//----------------------------------------------------------------------------
QString FileOpenVolumeMeshPlugin::getSaveFilters() {
return QString(tr("Polyhedral Volume Mesh files ( *.ovm )"));
}
;
//----------------------------------------------------------------------------
DataType FileOpenVolumeMeshPlugin::supportedType() {
DataType type = DATA_POLYHEDRAL_MESH;// | DATA_HEXAHEDRAL_MESH;
return type;
}
//----------------------------------------------------------------------------
int FileOpenVolumeMeshPlugin::loadObject(QString _filename) {
bool compatibility_mode = false;
if(!OpenFlipper::Options::nogui()) {
compatibility_mode = loadCompMode_->isChecked();
}
bool correct_face_order = false;
if(!OpenFlipper::Options::nogui()) {
correct_face_order = loadCorrectOrder_->isChecked();
}
bool topology_checks = true;
if(!OpenFlipper::Options::nogui()) {
topology_checks = loadTopCheck_->isChecked();
}
int id = -1;
bool hexMesh = false;
if(!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 0) {
hexMesh = fileManager_.isHexahedralMesh(_filename.toStdString());
} else if (!OpenFlipper::Options::nogui() && typeCheck_->currentIndex() == 2) {
hexMesh = false;
}
// Hack
hexMesh = false;
if(hexMesh) {
// emit addEmptyObject(DATA_HEXAHEDRAL_MESH, id);
// HexahedralMeshObject* obj(0);
//
// if (PluginFunctions::getObject(id, obj)) {
//
// if(compatibility_mode) {
// loadMesh((const char*) _filename.toAscii(), *(obj->mesh()), compatibility_mode,
// topology_checks, correct_face_order);
// } else {
// if(!fileManager_.readFile(_filename.toStdString(), *(obj->mesh()),
// topology_checks,true, true)) {
// emit log(LOGERR, QString("Could not open file %1!").arg(_filename));
// }
// }
//
// obj->setFromFileName(_filename);
// }
//
// emit openedFile(obj->id());
//
// // Go into solid flat shaded mode
// PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED, PluginFunctions::activeExaminer());
//