Developer Documentation

PluginFunctionsTetrahedralMesh.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43 #include <OpenFlipper/common/Types.hh>
44
45 #include <ObjectTypes/TetrahedralMesh/PluginFunctionsTetrahedralMesh.hh>
46 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
47
48 namespace PluginFunctions {
49
50 // ===============================================================================
51 // Get source meshes
52 // ===============================================================================
53
54
55 bool getSourceMeshes( std::vector<TetrahedralMesh*>& _meshes )
56 {
57 _meshes.clear();
58
59 for ( ObjectIterator o_it(PluginFunctions::SOURCE_OBJECTS,DATA_TETRAHEDRAL_MESH) ;
60 o_it != PluginFunctions::objectsEnd(); ++o_it) {
61 _meshes.push_back ( PluginFunctions::tetrahedralMesh( *o_it ) );
62 if( _meshes.back() == NULL)
63 std::cerr << "ERROR: TetrahedralMesh getSourceMeshes fatal error\n";
64 }
65
66 return ( !_meshes.empty() );
67 }
68
69
70 // ===============================================================================
71 // Get target meshes
72 // ===============================================================================
73
74
75 bool getTargetMeshes( std::vector<TetrahedralMesh*>& _meshes )
76 {
77 _meshes.clear();
78
79 for ( ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DATA_TETRAHEDRAL_MESH ) ;
80 o_it != PluginFunctions::objectsEnd(); ++o_it) {
81 _meshes.push_back ( PluginFunctions::tetrahedralMesh( *o_it ) );
82 if( _meshes.back() == NULL)
83 std::cerr << "ERROR: TetrahedralMesh getTargetMeshes fatal error\n";
84 }
85
86 return ( !_meshes.empty() );
87 }
88
89
90 // ===============================================================================
91 // Get objects
92 // ===============================================================================
93
94 bool getObject( int _identifier, TetrahedralMeshObject*& _object ) {
95
96 if ( _identifier == BaseObject::NOOBJECT ) {
97 _object = 0;
98 return false;
99 }
100
101 // Get object by using the map accelerated plugin function
102 BaseObjectData* object = 0;
103 PluginFunctions::getObject(_identifier,object);
104
105 _object = object ? tetrahedralMeshObject(object) : nullptr;
106 return ( _object != 0 );
107 }
108
109
110 // ===============================================================================
111 // Getting data from objects and casting between them
112 // ===============================================================================
113
114 TetrahedralMesh* tetrahedralMesh( BaseObjectData* _object ) {
115
116 if ( _object->dataType(DATA_TETRAHEDRAL_MESH) ) {
117 TetrahedralMeshObject* object = static_cast< TetrahedralMeshObject* >(_object);
118 return object->mesh();
119 } else
120 return 0;
121 }
122
123 TetrahedralMesh* tetrahedralMesh( int _identifier ) {
124 TetrahedralMeshObject* object = tetrahedralMeshObject(_identifier);
125
126 if ( object == 0)
127 return 0;
128 else
129 return object->mesh();
130 }
131
132
133 TetrahedralMeshObject* tetrahedralMeshObject( BaseObjectData* _object ) {
134 if ( ! _object->dataType(DATA_TETRAHEDRAL_MESH) )
135 return 0;
136 return static_cast< TetrahedralMeshObject* >( _object );
137 }
138
139
140 TetrahedralMeshObject* tetrahedralMeshObject( int _identifier )
141 {
142 TetrahedralMeshObject* pol_obj;
143 if(getObject(_identifier, pol_obj))
144 return pol_obj;
145 else
146 return 0;
147 }
148
149
150 }
151
PluginFunctions::SOURCE_OBJECTS
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
PluginFunctions.hh
BaseObject::dataType
bool dataType(DataType _type) const
Definition: BaseObject.cc:221
PluginFunctions::tetrahedralMeshObject
TetrahedralMeshObject * tetrahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an TetrahedralMeshObject if possible.
Definition: PluginFunctionsTetrahedralMesh.cc:133
PluginFunctions::TARGET_OBJECTS
const QStringList TARGET_OBJECTS("target")
Iterable object range.
OpenVolumeMesh::GeometryKernel
Definition: GeometryKernel.hh:55
VolumeMeshObject
Definition: VolumeMeshObject.hh:63
DATA_TETRAHEDRAL_MESH
#define DATA_TETRAHEDRAL_MESH
Definition: TetrahedralMesh.hh:55
PluginFunctions::getObject
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
Definition: PluginFunctions.cc:294
BaseObject::NOOBJECT
static int NOOBJECT
Definition: BaseObject.hh:106
Types.hh
PluginFunctions::objectsEnd
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
Definition: PluginFunctionsIterator.cc:177
PluginFunctionsTetrahedralMesh.hh
PluginFunctions
Definition: PluginFunctions.cc:57
PluginFunctions::getTargetMeshes
bool getTargetMeshes(std::vector< PolyMesh *> &_meshes)
Get a pointer to every Poly Mesh which is marked as a target mesh.
Definition: PluginFunctionsPolyMesh.cc:73
BaseObjectData
Definition: BaseObjectData.hh:102
PluginFunctions::getSourceMeshes
bool getSourceMeshes(std::vector< PolyMesh *> &_meshes)
Get a pointer to every Poly Mesh which is marked as a source mesh.
Definition: PluginFunctionsPolyMesh.cc:61
VolumeMeshObject::mesh
MeshT * mesh()
return a pointer to the mesh
Definition: VolumeMeshObjectT_impl.hh:212
PluginFunctions::tetrahedralMesh
TetrahedralMesh * tetrahedralMesh(BaseObjectData *_object)
Get an TetrahedralMesh from an object.
Definition: PluginFunctionsTetrahedralMesh.cc:114