Commit 9cfc30b3 authored by Jan Möbius's avatar Jan Möbius

Separated all OpenMesh related types, removed core dependency on OM Object types

parents
This diff is collapsed.
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef STATUSNODEMODS_HH
#define STATUSNODEMODS_HH
//=============================================================================
//
// Mesh Attribute bits for the Status Nodes
//
//=============================================================================
/** \brief Additional Node status Bits for Mesh
*
* These status bits define special Attributes on the mesh. The are used to define the handle area
* and modeling areas.
*
*/
enum StatusBits {
/// Modifyable area
AREA = OpenMesh::Attributes::UNUSED << 1,
/// Handle Area
HANDLEAREA = OpenMesh::Attributes::UNUSED << 2
};
//=============================================================================
//
// Mods for the Status Nodes
//
//=============================================================================
/** Structure used in the Status Nodes to show if an area is marked as a modeling area
*/
template< class MeshT >
struct AreaNodeMod
{
/// tell status node if the vertex is marked as modeling area
static inline bool is_area(const MeshT& _m, typename MeshT::VertexHandle _vh)
{ return _m.status(_vh).is_bit_set(AREA); }
/// tell status node if the face is marked as modeling area
static inline bool is_area(const MeshT& _m, typename MeshT::FaceHandle _fh)
{
for (typename MeshT::ConstFaceVertexIter cfv_it = _m.cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it)
if (_m.status(*cfv_it).is_bit_set(AREA))
return true;
return false;
}
/// tell status node if the vertex is marked as modeling area
static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
{
if (_mesh.is_isolated(_vh))
return is_area(_mesh, _vh);
else
return false;
}
/// default to false
static bool is_edge_selected(const MeshT& /*_mesh */, typename MeshT::EdgeHandle /* _eh */ )
{
return false;
}
/// default to false
static bool is_halfedge_selected(const MeshT& /*_mesh */, typename MeshT::HalfedgeHandle /* _eh */ )
{
return false;
}
/// tell status node if the face is marked as modeling area
static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
{
return is_area(_mesh, _fh);
}
};
/** Structure used in the Status Nodes to show if an area is marked as a handle region
*/
template< class MeshT >
struct HandleNodeMod
{
/// tell status node if the vertex is marked as handle area
static inline bool is_handle(const MeshT& _m, typename MeshT::VertexHandle _vh)
{ return _m.status(_vh).is_bit_set(HANDLEAREA); }
/// tell status node if the face is marked as handle area
static inline bool is_handle(const MeshT& _m, typename MeshT::FaceHandle _fh)
{
bool isArea = true;
for(typename MeshT::ConstFaceVertexIter cfv_it = _m.cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it) {
if(!_m.status(*cfv_it).is_bit_set(HANDLEAREA)) {
isArea = false;
break;
}
}
return isArea;
}
/// tell status node if the vertex is marked as handle area
static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
{
if (!is_handle(_mesh, _vh))
return false;
for (typename MeshT::CVFIter vf_it(_mesh.cvf_iter(_vh)); vf_it.is_valid(); ++vf_it)
if (is_handle(_mesh, *vf_it))
return false;
return true;
}
/// tell status node if the edge is marked as handle area
static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
{
typename MeshT::HalfedgeHandle hh;
typename MeshT::FaceHandle fh;
hh = _mesh.halfedge_handle(_eh, 0);
if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
fh = _mesh.face_handle(hh);
if (fh.is_valid() && is_handle(_mesh, fh)) return false;
hh = _mesh.halfedge_handle(_eh, 1);
if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
fh = _mesh.face_handle(hh);
if (fh.is_valid() && is_handle(_mesh, fh)) return false;
return true;
}
/// default to false
static bool is_halfedge_selected(const MeshT& /*_mesh */, typename MeshT::HalfedgeHandle /* _eh */ )
{
return false;
}
/// tell status node if the face is marked as handle area
static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
{
return is_handle(_mesh, _fh);
}
};
/** Structure used in the Status Nodes to show if an primitive is marked as a feature
*/
template< class MeshT >
struct FeatureNodeMod
{
/// tell status node if the vertex is marked as handle area
static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
{
return _mesh.status(_vh).feature();
}
/// tell status node if the edge is marked as handle area
static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
{
return _mesh.status(_eh).feature();
}
/// default to false
static bool is_halfedge_selected(const MeshT& _mesh, typename MeshT::HalfedgeHandle _heh)
{
return _mesh.status(_heh).feature();
}
/// tell status node if the face is marked as feature
static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
{
return _mesh.status(_fh).feature();
}
};
#endif
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 18128 $ *
* $LastChangedBy: moebius $ *
* $Date: 2014-02-05 10:20:28 +0100 (Wed, 05 Feb 2014) $ *
* *
\*===========================================================================*/
//=============================================================================
//
// StatusViewNode: Combined rendering of multiple Status Nodes
//
//=============================================================================
#ifndef STATUSVIEWNODE_HH
#define STATUSVIEWNODE_HH
//== INCLUDES =================================================================
#include <OpenFlipper/common/GlobalDefines.hh>
#include <ACG/Scenegraph/StatusNodesT.hh>
#include "StatusNodeMods.hh"
//== CLASS DEFINITION =========================================================
namespace ACG
{
namespace SceneGraph
{
template <class MeshT>
class DLLEXPORTONLY StatusViewNodeT : public ACG::SceneGraph::BaseNode
{
public:
StatusViewNodeT(
BaseNode* _parent,
const std::string& _name,
ACG::SceneGraph::SelectionNodeT<MeshT>* _statusNode,
ACG::SceneGraph::StatusNodeT<MeshT, AreaNodeMod<MeshT> >* _areaNode,
ACG::SceneGraph::StatusNodeT<MeshT, HandleNodeMod<MeshT> >* _handleNode,
ACG::SceneGraph::StatusNodeT<MeshT, FeatureNodeMod<MeshT> >* _featureNode);
// BaseNode implementation
ACG_CLASSNAME(StatusNodeView);
void draw(GLState& , const DrawModes::DrawMode& );
void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat);
void enter(GLState& _state, const DrawModes::DrawMode& _drawmode);
void leave(GLState& _state, const DrawModes::DrawMode& _drawmode);
private:
ACG::SceneGraph::SelectionNodeT<MeshT>* statusNode_;
ACG::SceneGraph::StatusNodeT<MeshT, AreaNodeMod<MeshT> >* areaNode_;
ACG::SceneGraph::StatusNodeT<MeshT, HandleNodeMod<MeshT> >* handleNode_;
ACG::SceneGraph::StatusNodeT<MeshT, FeatureNodeMod<MeshT> >* featureNode_;
// visibility of nodes
bool statusNodeVis_;
bool areaNodeVis_;
bool handleNodeVis_;
bool featureNodeVis_;
};
}
}
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(STATUSVIEWNODE_C)
#define STATUS_VIEW_NODE_TEMPLATES
#include "StatusViewNodeT.cc"
#endif
//=============================================================================
#endif // STATUSVIEWNODE_HH
//=============================================================================
include(ACGCommon)
include_directories (
..
${ACG_INCLUDE_DIR}
${OPENMESH_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
)
link_directories (
${GLEW_LIBRARY_DIR}
${ADDITIONAL_PLUGINLIB_LINK_DIRS}
)
#=======================================================
# General defines
#=======================================================
# generate dllexport macros on windows
if (WIN32)
add_definitions (
-DPLUGINLIBDLL
-DUSEPLUGINLIBDLL
-DBUILDOBJECTTYPEDLL
-DACGDLL
-DUSEACG
)
endif ()
#=======================================================
# Cleanup
#=======================================================
# collect all header,source files
acg_append_files (headers "*.hh" . )
acg_append_files (sources "*.cc" . )
acg_qt5_automoc (moc_targets ${headers})
# Match our current directory name
string (REGEX MATCH "[^/\\]*$" TYPENAME ${CMAKE_CURRENT_SOURCE_DIR})
string(TOUPPER ${TYPENAME} TYPENAME )
include_directories (
..
${ACG_INCLUDE_DIR}
${OPENMESH_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_BINARY_DIR}
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
)
# remove template cc files from source file list
acg_drop_templates (sources)
acg_add_library ( ${TYPENAME} SHARED ${sources} ${headers} ${moc_targets})
add_dependencies( ${TYPENAME} OpenMeshCore OpenMeshTools ACG OpenFlipperPluginLib)
target_link_libraries (${TYPENAME}
${OPENMESH_LIBRARIES}
ACG
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${GLUT_LIBRARIES}
OpenFlipperPluginLib
)
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// Plugin Functions PolyMesh
//
//=============================================================================
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PluginFunctionsPolyMesh.hh>
namespace PluginFunctions {
bool getSourceMeshes( std::vector<PolyMesh*>& _meshes ) {
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_POLY_MESH) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (! o_it->source() )
continue;
_meshes.push_back ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() );
}
return ( !_meshes.empty() );
}
bool getTargetMeshes( std::vector<PolyMesh*>& _meshes ) {
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_POLY_MESH) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (! o_it->target() )
continue;
if ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() )
_meshes.push_back ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() );
}
return ( !_meshes.empty() );
}
bool getObject( int _identifier , PolyMeshObject*& _object ) {
if ( _identifier == BaseObject::NOOBJECT ) {
_object = 0;
return false;
}
// Get object by using the map accelerated plugin function
BaseObjectData* object = 0;
PluginFunctions::getObject(_identifier,object);
_object = dynamic_cast< PolyMeshObject* >(object);
return ( _object != 0 );
}
bool getMesh( int _identifier , PolyMesh*& _mesh ) {
if ( _identifier == BaseObject::NOOBJECT ) {
_mesh = 0;
return false;
}
// Get object by using the map accelerated plugin function
BaseObjectData* object = 0;
PluginFunctions::getObject(_identifier,object);
// Unable to find object
if ( object == 0)
return false;
PolyMeshObject* polyMeshObject = dynamic_cast< PolyMeshObject* > (object);
// Object is not a triangle mesh
if ( polyMeshObject == 0) {
_mesh = 0;
return false;
}
_mesh = polyMeshObject->mesh();
return true;
}
PolyMesh* polyMesh( BaseObjectData* _object ) {
if ( _object == 0 )
return 0;
if ( _object->dataType(DATA_POLY_MESH) ) {
PolyMeshObject* object = dynamic_cast< PolyMeshObject* >(_object);
return object->mesh();
} else
return NULL;
}
PolyMesh* polyMesh( int _identifier ) {
PolyMeshObject* object = polyMeshObject(_identifier);
if ( object == 0)
return 0;
else
return object->mesh();
}
PolyMeshObject* polyMeshObject( BaseObjectData* _object ) {
if ( _object == 0 )
return 0;
if ( ! _object->dataType(DATA_POLY_MESH) )
return NULL;
return dynamic_cast< PolyMeshObject* >( _object );
}
PolyMeshObject* polyMeshObject( int _objectId ) {
if (_objectId == BaseObject::NOOBJECT)
return 0;
// Get object by using the map accelerated plugin function
BaseObjectData* object = 0;
PluginFunctions::getObject(_objectId,object);
if ( object == 0 )
return 0;
PolyMeshObject* meshObject = dynamic_cast< PolyMeshObject* >(object);
return meshObject;
}
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// Standard Functions
//
//=============================================================================
/**
* \file PluginFunctionsPolyMesh.hh
* This file contains functions which can be used by plugins to access polymeshes in the framework.
*/
//
#ifndef PLUGINFUNCTIONSPOLYMESH_HH
#define PLUGINFUNCTIONSPOLYMESH_HH
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <OpenFlipper/common/ObjectTypeDLLDefines.hh>
/** The Namespace PluginFunctions contains functions for all plugins. These functions should be used to get the
* objects to work on or to set modes in the examiner widget. */
namespace PluginFunctions {
//=======================================
// Get Source/Target objects
/** @name Active Objects
* @{ */
//=======================================
/** \brief Get a pointer to every Poly Mesh which is marked as a source mesh.
*
* @param _meshes ( vector returning the source meshes )
* @return false, if no mesh is selected as source
*/
OBJECTTYPEDLLEXPORT
bool getSourceMeshes( std::vector<PolyMesh*>& _meshes );