PluginFunctionsPolyMesh.cc

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8503 $                                                         *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2010-02-09 15:23:48 +0100 (Di, 09. Feb 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  Plugin Functions PolyMesh
00049 //
00050 //=============================================================================
00051 
00052 #include <OpenFlipper/common/Types.hh>
00053 
00054 #include <ObjectTypes/PolyMesh/PluginFunctionsPolyMesh.hh>
00055 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
00056 
00057 
00058 
00059 namespace PluginFunctions {
00060 
00061 
00062 bool getSourceMeshes( std::vector<PolyMesh*>& _meshes  ) {
00063   _meshes.clear();
00064 
00065   for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_POLY_MESH) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
00066     if (! o_it->source() )
00067       continue;
00068     _meshes.push_back ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() );
00069   }
00070 
00071   return (_meshes.size() > 0 );
00072 }
00073 
00074 bool getTargetMeshes( std::vector<PolyMesh*>& _meshes  ) {
00075   _meshes.clear();
00076 
00077   for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_POLY_MESH) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
00078     if (! o_it->target() )
00079       continue;
00080     if ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() )
00081       _meshes.push_back ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() );
00082   }
00083 
00084   return (_meshes.size() > 0 );
00085 }
00086 
00087 bool getObject(  int _identifier , PolyMeshObject*& _object ) {
00088 
00089   if ( _identifier == -1 ) {
00090     _object = 0;
00091     return false;
00092   }
00093 
00094   BaseObject* object = objectRoot()->childExists( _identifier );
00095   _object = dynamic_cast< PolyMeshObject* >(object);
00096   return ( _object != 0 );
00097 }
00098 
00099 bool getMesh(  int _identifier , PolyMesh*& _mesh ) {
00100 
00101   if ( _identifier == -1 ) {
00102     _mesh = 0;
00103     return false;
00104   }
00105 
00106   BaseObject* object = objectRoot()->childExists( _identifier );
00107 
00108   // Unable to find object
00109   if ( object == 0)
00110     return false;
00111 
00112   PolyMeshObject* polyMeshObject = dynamic_cast< PolyMeshObject* > (object);
00113 
00114   // Object is not a triangle mesh
00115   if ( polyMeshObject == 0) {
00116     _mesh = 0;
00117     return false;
00118   }
00119 
00120   _mesh = polyMeshObject->mesh();
00121   return true;
00122 }
00123 
00124 PolyMesh* polyMesh( BaseObjectData* _object ) {
00125   
00126   if ( _object == 0 )
00127     return 0;
00128 
00129   if ( _object->dataType(DATA_POLY_MESH) ) {
00130     PolyMeshObject* object = dynamic_cast< PolyMeshObject* >(_object);
00131     return object->mesh();
00132   } else
00133     return NULL;
00134 }
00135 
00136 PolyMeshObject* polyMeshObject( BaseObjectData* _object ) {
00137   
00138   if ( _object == 0 )
00139     return 0;
00140 
00141   if ( ! _object->dataType(DATA_POLY_MESH) )
00142     return NULL;
00143   return dynamic_cast< PolyMeshObject* >( _object );
00144 }
00145 
00146 PolyMeshObject* polyMeshObject( int _objectId ) {
00147   
00148   if  (_objectId == -1)
00149     return 0;
00150   
00151   BaseObject* object = objectRoot()->childExists( _objectId );
00152   
00153   if ( object == 0 )
00154     return 0;
00155   
00156   PolyMeshObject* meshObject = dynamic_cast< PolyMeshObject* >(object);
00157   
00158   return meshObject;
00159 }
00160 
00161 }

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .