Developer Documentation
PluginFunctionsTetrahedralMesh.cc
1 /*===========================================================================*\
2 * *
3  * OpenFlipper *
4  * Copyright (C) 2001-2014 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$ *
38  * $Date$ *
39  * $LastChangedBy$ *
40  * *
41 \*===========================================================================*/
42 
43 #ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT
44 
46 
49 
50 namespace PluginFunctions {
51 
52 // ===============================================================================
53 // Get source meshes
54 // ===============================================================================
55 
56 
57 bool getSourceMeshes( std::vector<TetrahedralMesh*>& _meshes )
58 {
59  _meshes.clear();
60 
61  for ( ObjectIterator o_it(PluginFunctions::SOURCE_OBJECTS,DATA_TETRAHEDRAL_MESH) ;
62  o_it != PluginFunctions::objectsEnd(); ++o_it) {
63  _meshes.push_back ( PluginFunctions::tetrahedralMesh( *o_it ) );
64  if( _meshes.back() == NULL)
65  std::cerr << "ERROR: TetrahedralMesh getSourceMeshes fatal error\n";
66  }
67 
68  return ( !_meshes.empty() );
69 }
70 
71 
72 // ===============================================================================
73 // Get target meshes
74 // ===============================================================================
75 
76 
77 bool getTargetMeshes( std::vector<TetrahedralMesh*>& _meshes )
78 {
79  _meshes.clear();
80 
81  for ( ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DATA_TETRAHEDRAL_MESH ) ;
82  o_it != PluginFunctions::objectsEnd(); ++o_it) {
83  _meshes.push_back ( PluginFunctions::tetrahedralMesh( *o_it ) );
84  if( _meshes.back() == NULL)
85  std::cerr << "ERROR: TetrahedralMesh getTargetMeshes fatal error\n";
86  }
87 
88  return ( !_meshes.empty() );
89 }
90 
91 
92 // ===============================================================================
93 // Get objects
94 // ===============================================================================
95 
96 bool getObject( int _identifier, TetrahedralMeshObject*& _object ) {
97 
98  if ( _identifier == BaseObject::NOOBJECT ) {
99  _object = 0;
100  return false;
101  }
102 
103  // Get object by using the map accelerated plugin function
104  BaseObjectData* object = 0;
105  PluginFunctions::getObject(_identifier,object);
106 
107  _object = dynamic_cast< TetrahedralMeshObject* >(object);
108  return ( _object != 0 );
109 }
110 
111 
112 // ===============================================================================
113 // Getting data from objects and casting between them
114 // ===============================================================================
115 
116 TetrahedralMesh* tetrahedralMesh( BaseObjectData* _object ) {
117 
118  if ( _object->dataType(DATA_TETRAHEDRAL_MESH) ) {
119  TetrahedralMeshObject* object = dynamic_cast< TetrahedralMeshObject* >(_object);
120  return object->mesh();
121  } else
122  return 0;
123 }
124 
125 TetrahedralMesh* tetrahedralMesh( int _identifier ) {
126  TetrahedralMeshObject* object = tetrahedralMeshObject(_identifier);
127 
128  if ( object == 0)
129  return 0;
130  else
131  return object->mesh();
132 }
133 
134 
135 TetrahedralMeshObject* tetrahedralMeshObject( BaseObjectData* _object ) {
136  if ( ! _object->dataType(DATA_TETRAHEDRAL_MESH) )
137  return 0;
138  return dynamic_cast< TetrahedralMeshObject* >( _object );
139 }
140 
141 
142 TetrahedralMeshObject* tetrahedralMeshObject( int _identifier )
143 {
144  TetrahedralMeshObject* pol_obj;
145  if(getObject(_identifier, pol_obj))
146  return pol_obj;
147  else
148  return 0;
149 }
150 
151 
152 }
153 
154 
155 #endif // ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT
bool getObject(int _identifier, BSplineCurveObject *&_object)
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
const QStringList TARGET_OBJECTS("target")
Iterable object range.
static int NOOBJECT
Definition: BaseObject.hh:118
bool getTargetMeshes(std::vector< HexahedralMesh * > &_meshes)
Get a pointer to every HexahedralMesh which is marked as a target.
bool getSourceMeshes(std::vector< HexahedralMesh * > &_meshes)
Get a pointer to every HexahedralMesh which is marked as a source.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.