Commit 070bf642 authored by Jan Möbius's avatar Jan Möbius
Browse files

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4033 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6876a6f3
......@@ -90,58 +90,6 @@ void set_sceneGraphRootNode( SeparatorNode* _root_node ) {
PluginFunctions::sceneGraph_root_node_ = _root_node;
}
bool get_source_meshes( std::vector<TriMesh*>& _meshes ) {
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_TRIANGLE_MESH) ; o_it != PluginFunctions::objects_end(); ++o_it) {
if (! o_it->source() )
continue;
_meshes.push_back ( dynamic_cast< TriMeshObject* >( *o_it )->mesh() );
}
return (_meshes.size() > 0 );
}
bool get_source_meshes( std::vector<PolyMesh*>& _meshes ) {
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_POLY_MESH) ; o_it != PluginFunctions::objects_end(); ++o_it) {
if (! o_it->source() )
continue;
_meshes.push_back ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() );
}
return (_meshes.size() > 0 );
}
bool get_target_meshes( std::vector<TriMesh*>& _meshes ) {
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_TRIANGLE_MESH) ; o_it != PluginFunctions::objects_end(); ++o_it) {
if (! o_it->target() )
continue;
if ( dynamic_cast< TriMeshObject* >( *o_it )->mesh() )
_meshes.push_back ( dynamic_cast< TriMeshObject* >( *o_it )->mesh() );
}
return (_meshes.size() > 0 );
}
bool get_target_meshes( std::vector<PolyMesh*>& _meshes ) {
_meshes.clear();
for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_POLY_MESH) ; o_it != PluginFunctions::objects_end(); ++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.size() > 0 );
}
bool get_picked_object(uint _node_idx , BaseObjectData*& _object) {
for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objects_end(); ++o_it) {
if ( o_it->picked( _node_idx ) ) {
......@@ -196,72 +144,10 @@ bool get_object( int _identifier , BaseObjectData*& _object ) {
return ( _object != 0 );
}
bool get_object( int _identifier , TriMeshObject*& _object ) {
if ( _identifier == -1 )
return false;
BaseObject* object = objectRoot_->childExists( _identifier );
_object = dynamic_cast< TriMeshObject* >(object);
return ( _object != 0 );
}
bool get_object( int _identifier , PolyMeshObject*& _object ) {
if ( _identifier == -1 )
return false;
BaseObject* object = objectRoot_->childExists( _identifier );
_object = dynamic_cast< PolyMeshObject* >(object);
return ( _object != 0 );
}
// ===============================================================================
// ===============================================================================
bool get_mesh( int _identifier , TriMesh*& _mesh ) {
if ( _identifier == -1 )
return false;
BaseObject* object = objectRoot_->childExists( _identifier );
// Unable to find object
if ( object == 0)
return false;
TriMeshObject* triangleMeshObject = dynamic_cast< TriMeshObject* > (object);
// Object is not a triangle mesh
if ( triangleMeshObject == 0)
return false;
_mesh = triangleMeshObject->mesh();
return true;
}
bool get_mesh( int _identifier , PolyMesh*& _mesh ) {
if ( _identifier == -1 )
return false;
BaseObject* object = objectRoot_->childExists( _identifier );
// Unable to find object
if ( object == 0)
return false;
PolyMeshObject* polyMeshObject = dynamic_cast< PolyMeshObject* > (object);
// Object is not a triangle mesh
if ( polyMeshObject == 0)
return false;
_mesh = polyMeshObject->mesh();
return true;
}
bool deleteObject( int _id ) {
if ( _id == -1 )
......@@ -618,8 +504,8 @@ void get_all_objects( std::vector < BaseObjectData*>& _objects ) {
}
/// Fly to point and viewing direction (animated).
void flyTo (const TriMesh::Point &_position, const TriMesh::Point &_center, double _time) {
examiner_widget_->flyTo((ACG::Vec3d)_position,(ACG::Vec3d)_center,_time);
void flyTo (const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time) {
examiner_widget_->flyTo(_position,_center,_time);
}
......@@ -634,48 +520,6 @@ BaseObjectData* baseObjectData( BaseObject* _object ){
return dynamic_cast< BaseObjectData* >(_object);
}
TriMesh* triMesh( BaseObjectData* _object ) {
if ( _object == 0 )
return 0;
if ( _object->dataType(DATA_TRIANGLE_MESH) ) {
TriMeshObject* object = dynamic_cast< TriMeshObject* >(_object);
return object->mesh();
} else
return NULL;
}
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;
}
TriMeshObject* triMeshObject( BaseObjectData* _object ) {
if ( _object == 0 )
return 0;
if ( ! _object->dataType(DATA_TRIANGLE_MESH) )
return NULL;
return dynamic_cast< TriMeshObject* >( _object );
}
PolyMeshObject* polyMeshObject( BaseObjectData* _object ) {
if ( _object == 0 )
return 0;
if ( ! _object->dataType(DATA_POLY_MESH) )
return NULL;
return dynamic_cast< PolyMeshObject* >( _object );
}
// ===============================================================================
// Get the root of the object structure
// ===============================================================================
......
......@@ -49,17 +49,11 @@
#include <OpenFlipper/common/Types.hh>
// #include <ACG/Math/VectorT.hh>
#include <ACG/QtWidgets/QtExaminerViewer.hh>
#include <ACG/QtWidgets/QtBaseViewer.hh>
#include <ACG/GL/GLState.hh>
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
#include "PluginFunctionsBSplineSurface.hh"
#endif
#include "PluginFunctionsPolyMesh.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 {
......@@ -70,38 +64,6 @@ namespace PluginFunctions {
* @{ */
//=======================================
/** \brief Get a pointer to every Triangle Mesh which is marked as a source mesh.
*
* @param _meshes ( vector returning the source meshes )
* @return false, if no mesh is selected as source
*/
DLLEXPORT
bool get_source_meshes( std::vector<TriMesh*>& _meshes );
/** \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
*/
DLLEXPORT
bool get_source_meshes( std::vector<PolyMesh*>& _meshes );
/** \brief Get a pointer to every Triangle Mesh which is marked as a target mesh.
*
* @param _meshes ( vector returning the target meshes )
* @return false, if no mesh is selected as target
*/
DLLEXPORT
bool get_target_meshes( std::vector<TriMesh*>& _meshes );
/** \brief Get a pointer to every Poly Mesh which is marked as a target mesh.
*
* @param _meshes ( vector returning the target meshes )
* @return false, if no mesh is selected as target
*/
DLLEXPORT
bool get_target_meshes( std::vector<PolyMesh*>& _meshes );
/** \brief Get the picked mesh
* @param _node_idx Node index returned by examiner picking
* @param _object returns the object which contains the mesh
......@@ -197,46 +159,6 @@ bool get_object( int _identifier , BaseObject*& _object );
DLLEXPORT
bool get_object( int _identifier , BaseObjectData*& _object );
/** This functions returns the object with the given id if it is a TriMeshObject.
* See get_object( int _identifier , BaseObject*& _object ) for more details.
*/
DLLEXPORT
bool get_object( int _identifier , TriMeshObject*& _object );
/** This functions returns the object with the given id if it is a PolyMeshObject.
* See get_object( int _identifier , BaseObject*& _object ) for more details.
*/
DLLEXPORT
bool get_object( int _identifier , PolyMeshObject*& _object );
/** \brief Get the Triangle Mesh which has the given identifier.
*
* Every loaded object has a unique identifier which is stored in the id field of the object container.
* Use this function to get the mesh which has this id. This can be used for a consistent mapping
* even if the data objects change during plugin operations (e.g. selection and main algorithm).\n
* This function checks, if the object requested contains a mesh.
* @param _identifier Object id to search for
* @param _mesh returns the mesh
* @return Mesh found?
*/
DLLEXPORT
bool get_mesh( int _identifier , TriMesh*& _mesh );
/** \brief Get the Poly Mesh which has the given identifier.
*
* Every loaded object has a unique identifier which is stored in the id field of the object container.
* Use this function to get the mesh which has this id. This can be used for a consistent mapping
* even if the data objects change during plugin operations (e.g. selection and main algorithm).\n
* This function checks, if the object requested contains a mesh.
* @param _identifier Object id to search for
* @param _mesh returns the mesh
* @return Mesh found?
*/
DLLEXPORT
bool get_mesh( int _identifier , PolyMesh*& _mesh );
/** \brief Check if an object with this identifier exists.
*
* Searches through the Data containers and checks if the object with the given identifier exists
......@@ -502,7 +424,7 @@ void mapToLocal( OpenMesh::Vec4f _color);
* @param _time Animation time in ms
*/
DLLEXPORT
void flyTo (const TriMesh::Point &_position, const TriMesh::Point &_center, double _time=1000.0);
void flyTo (const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time=1000.0);
/** @} */
......@@ -618,38 +540,6 @@ void setDataRoot( BaseObject* _root );
* @{ */
//=======================================
/** \brief Get a triangle mesh from an object.
*
* @param _object The object should be of type BaseDataObject. If the content is a triangle Mesh, a
* triangle mesh will be returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
TriMesh* triMesh( BaseObjectData* _object );
/** \brief Get a poly mesh from an object.
*
* @param _object The object should be of type BaseDataObject. If the content is a poly Mesh, a
* poly mesh will be returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
PolyMesh* polyMesh( BaseObjectData* _object );
/** \brief Cast an BaseObject to a TriMeshObject if possible
*
* @param _object The object should be of type BaseDataObject. If the content is a triangle Mesh, a
* a TriMeshObject is returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
TriMeshObject* triMeshObject( BaseObjectData* _object );
/** \brief Cast an BaseObject to a PolyMeshObject if possible
*
* @param _object The object should be of type BaseDataObject. If the content is a poly Mesh, a
* a PolyMeshObject is returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
PolyMeshObject* polyMeshObject( BaseObjectData* _object );
/** \brief Cast an BaseObject to a BaseObjectData if possible
*
* @param _object The object should be of type BaseObject. If the content is a BaseObjectData, a
......@@ -666,13 +556,4 @@ BaseObject*& objectRoot();
}
/*
#if defined(INCLUDE_TEMPLATES) && !defined(PLUGINFUNCTIONS_C)
#define PLUGINFUNCTIONS_TEMPLATES
#include "PluginFunctionsT.cc"
#endif
*/
#endif //PLUGINFUNCTIONS_HH
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// 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.
//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 4021 $
// $Author: moebius $
// $Date: 2008-12-18 13:57:59 +0100 (Do, 18. Dez 2008) $
//
//=============================================================================
//=============================================================================
//
// Standard Functions
//
//=============================================================================
/**
* \file PluginFunctions.hh
* This file contains functions which can be used by plugins to access data in the framework.
*/
//
#ifndef PLUGINFUNCTIONSPOLYMESH_HH
#define PLUGINFUNCTIONSPOLYMESH_HH
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
#include "PluginFunctionsBSplineSurface.hh"
#endif
/** 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 {
/** \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
*/
DLLEXPORT
bool get_source_meshes( std::vector<PolyMesh*>& _meshes );
/** \brief Get a pointer to every Poly Mesh which is marked as a target mesh.
*
* @param _meshes ( vector returning the target meshes )
* @return false, if no mesh is selected as target
*/
DLLEXPORT
bool get_target_meshes( std::vector<PolyMesh*>& _meshes );
/** This functions returns the object with the given id if it is a PolyMeshObject.
* See get_object( int _identifier , BaseObject*& _object ) for more details.
*/
DLLEXPORT
bool get_object( int _identifier , PolyMeshObject*& _object );
/** \brief Get the Poly Mesh which has the given identifier.
*
* Every loaded object has a unique identifier which is stored in the id field of the object container.
* Use this function to get the mesh which has this id. This can be used for a consistent mapping
* even if the data objects change during plugin operations (e.g. selection and main algorithm).\n
* This function checks, if the object requested contains a mesh.
* @param _identifier Object id to search for
* @param _mesh returns the mesh
* @return Mesh found?
*/
DLLEXPORT
bool get_mesh( int _identifier , PolyMesh*& _mesh );
//=======================================
/** @name Getting data from objects and casting between them
* @{ */
//=======================================
/** \brief Get a poly mesh from an object.
*
* @param _object The object should be of type BaseDataObject. If the content is a poly Mesh, a
* poly mesh will be returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
PolyMesh* polyMesh( BaseObjectData* _object );
/** \brief Cast an BaseObject to a PolyMeshObject if possible
*
* @param _object The object should be of type BaseDataObject. If the content is a poly Mesh, a
* a PolyMeshObject is returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
PolyMeshObject* polyMeshObject( BaseObjectData* _object );
/** @} */
}
#endif //PLUGINFUNCTIONSPOLYMESH_HH
......@@ -127,7 +127,7 @@ static bool hideToolbox_ = false;
static bool hideLogger_ = false;
/// Store if we should go into multiview Mode
static bool multiView_ = false;
static bool multiView_ = true;
/// Start in Fullscreen Mode?
static bool fullScreen_ = false;
......
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// 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.
//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision$
// $Author$
// $Date$
//
//=============================================================================
//=============================================================================
//
// MyTypes
//
//=============================================================================
#define MESHOBJECT_C
//== INCLUDES =================================================================
#include "Types.hh"
#include <ACG/Scenegraph/DrawModes.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
//== TYPEDEFS =================================================================
//== CLASS DEFINITION =========================================================
template < class MeshT , DataType objectDataType >
MeshObject< MeshT , objectDataType >::MeshObject(const MeshObject& _object) :
BaseObjectData(_object),
statusNode_(0),
areaNode_(0),
handleNode_(0),
meshNode_(0),
textureNode_(0),
shaderNode_(0),
triangle_bsp_(0)
{
init(_object.mesh_);
setName( name() );
}
/** Constructor for Mesh Objects. This object class gets a Separator Node giving
* the root node to which it should be connected. The mesh is generated internally
* and all nodes for visualization will be added below the scenegraph node.\n
* You dont need to create an object of this type manually. Use
* PluginFunctions::addTriMesh or PluginFunctions::addPolyMesh instead. The
* objectDataType has to match the one of MeshT ( see Types.hh::DataType )
*/
template < class MeshT , DataType objectDataType >
MeshObject< MeshT , objectDataType >::MeshObject( SeparatorNode* _rootNode ) :
BaseObjectData(_rootNode ),
mesh_(0),
statusNode_(0),
areaNode_(0),
handleNode_(0),
meshNode_(0),
textureNode_(0),
shaderNode_(0),
triangle_bsp_(0)
{
setDataType(objectDataType);
init();
}
/** Destructor for Mesh Objects. The destructor deletes the mesh and all
* Scenegraph nodes associated with the mesh or the object.
*/
template < class MeshT , DataType objectDataType >
MeshObject< MeshT , objectDataType >::~MeshObject()
{
// Delete the data attached to this object ( this will remove all perObject data)
// Not the best way to do it but it will work.
// This is only necessary if people use references to the mesh below and
// they do something with the mesh in the destructor of their
// perObjectData.
deleteData();
// Delete the Mesh only, if this object contains a mesh
if ( mesh_ != NULL) {
delete mesh_;
mesh_ = NULL;
} else {
std::cerr << "Destructor error : Mesh already deleted" << std::endl;
}
if ( triangle_bsp_ != 0 )
delete triangle_bsp_;
triangle_bsp_ = 0;
// No need to delete the scenegraph Nodes as this will be managed by baseplugin
areaNode_ = 0;
handleNode_ = 0;
meshNode_ = 0;
textureNode_ = 0;
shaderNode_ = 0;
}
/** Cleanup Function for Mesh Objects. Deletes the contents of the whole object and
* calls MeshObject::init afterwards.
*/
template < class MeshT , DataType objectDataType >
void MeshObject< MeshT , objectDataType >::cleanup() {
// Delete the Mesh only, if this object contains a mesh
if ( mesh_ != NULL) {
delete mesh_;
mesh_ = NULL;
} else {
std::cerr << "Cleanup error : Triangle Mesh already deleted" << std::endl;