Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PluginFunctionsPolyMesh.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
5 * www.openflipper.org *
6 * *
7 *--------------------------------------------------------------------------- *
8 * This file is part of OpenFlipper. *
9 * *
10 * OpenFlipper is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenFlipper is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenFlipper. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36 * *
37 * $Revision: 13237 $ *
38 * $LastChangedBy: moebius $ *
39 * $Date: 2012-01-06 10:36:40 +0100 (Fr, 06 Jan 2012) $ *
40 * *
41 \*===========================================================================*/
42 
43 
44 
45 
46 //=============================================================================
47 //
48 // Plugin Functions PolyMesh
49 //
50 //=============================================================================
51 
53 
56 
57 
58 
59 namespace PluginFunctions {
60 
61 
62 bool getSourceMeshes( std::vector<PolyMesh*>& _meshes ) {
63  _meshes.clear();
64 
66  if (! o_it->source() )
67  continue;
68  _meshes.push_back ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() );
69  }
70 
71  return ( !_meshes.empty() );
72 }
73 
74 bool getTargetMeshes( std::vector<PolyMesh*>& _meshes ) {
75  _meshes.clear();
76 
78  if (! o_it->target() )
79  continue;
80  if ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() )
81  _meshes.push_back ( dynamic_cast< PolyMeshObject* >( *o_it )->mesh() );
82  }
83 
84  return ( !_meshes.empty() );
85 }
86 
87 bool getObject( int _identifier , PolyMeshObject*& _object ) {
88 
89  if ( _identifier == -1 ) {
90  _object = 0;
91  return false;
92  }
93 
94  BaseObject* object = objectRoot()->childExists( _identifier );
95  _object = dynamic_cast< PolyMeshObject* >(object);
96  return ( _object != 0 );
97 }
98 
99 bool getMesh( int _identifier , PolyMesh*& _mesh ) {
100 
101  if ( _identifier == -1 ) {
102  _mesh = 0;
103  return false;
104  }
105 
106  BaseObject* object = objectRoot()->childExists( _identifier );
107 
108  // Unable to find object
109  if ( object == 0)
110  return false;
111 
112  PolyMeshObject* polyMeshObject = dynamic_cast< PolyMeshObject* > (object);
113 
114  // Object is not a triangle mesh
115  if ( polyMeshObject == 0) {
116  _mesh = 0;
117  return false;
118  }
119 
120  _mesh = polyMeshObject->mesh();
121  return true;
122 }
123 
124 PolyMesh* polyMesh( BaseObjectData* _object ) {
125 
126  if ( _object == 0 )
127  return 0;
128 
129  if ( _object->dataType(DATA_POLY_MESH) ) {
130  PolyMeshObject* object = dynamic_cast< PolyMeshObject* >(_object);
131  return object->mesh();
132  } else
133  return NULL;
134 }
135 
136 PolyMesh* polyMesh( int _identifier ) {
137  PolyMeshObject* object = polyMeshObject(_identifier);
138 
139  if ( object == 0)
140  return 0;
141  else
142  return object->mesh();
143 }
144 
146 
147  if ( _object == 0 )
148  return 0;
149 
150  if ( ! _object->dataType(DATA_POLY_MESH) )
151  return NULL;
152  return dynamic_cast< PolyMeshObject* >( _object );
153 }
154 
155 PolyMeshObject* polyMeshObject( int _objectId ) {
156 
157  if (_objectId == -1)
158  return 0;
159 
160  BaseObject* object = objectRoot()->childExists( _objectId );
161 
162  if ( object == 0 )
163  return 0;
164 
165  PolyMeshObject* meshObject = dynamic_cast< PolyMeshObject* >(object);
166 
167  return meshObject;
168 }
169 
170 }