Developer Documentation
PluginFunctionsHexahedralMesh.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 
45 
47 
48 namespace PluginFunctions {
49 
50 // ===============================================================================
51 // Get source meshes
52 // ===============================================================================
53 
54 
55 bool getSourceMeshes( std::vector<HexahedralMesh*>& _meshes )
56 {
57  _meshes.clear();
58 
60  o_it != PluginFunctions::objectsEnd(); ++o_it) {
61  _meshes.push_back ( PluginFunctions::hexahedralMesh( *o_it ) );
62  if( _meshes.back() == NULL)
63  std::cerr << "ERROR: HexahedralMesh 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<HexahedralMesh*>& _meshes )
76 {
77  _meshes.clear();
78 
80  o_it != PluginFunctions::objectsEnd(); ++o_it) {
81  _meshes.push_back ( PluginFunctions::hexahedralMesh( *o_it ) );
82  if( _meshes.back() == NULL)
83  std::cerr << "ERROR: HexahedralMesh getTargetMeshes fatal error\n";
84  }
85 
86  return ( !_meshes.empty() );
87 }
88 
89 
90 // ===============================================================================
91 // Get objects
92 // ===============================================================================
93 
94 bool getObject( int _identifier, HexahedralMeshObject*& _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 ? hexahedralMeshObject(object) : nullptr;
106  return ( _object != 0 );
107 }
108 
109 
110 // ===============================================================================
111 // Getting data from objects and casting between them
112 // ===============================================================================
113 
115 
116  if ( _object->dataType(DATA_HEXAHEDRAL_MESH) ) {
117  HexahedralMeshObject* object = static_cast< HexahedralMeshObject* >(_object);
118  return object->mesh();
119  } else
120  return 0;
121 }
122 
123 HexahedralMesh* hexahedralMesh( int _identifier ) {
124  HexahedralMeshObject* object = hexahedralMeshObject(_identifier);
125 
126  if ( object == 0)
127  return 0;
128  else
129  return object->mesh();
130 }
131 
132 
134  if ( ! _object->dataType(DATA_HEXAHEDRAL_MESH) )
135  return 0;
136  return static_cast< HexahedralMeshObject* >( _object );
137 }
138 
139 
141 {
142  HexahedralMeshObject* pol_obj;
143  if(getObject(_identifier, pol_obj))
144  return pol_obj;
145  else
146  return 0;
147 }
148 
149 
150 }
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
bool dataType(DataType _type) const
Definition: BaseObject.cc:221
const QStringList TARGET_OBJECTS("target")
Iterable object range.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
#define DATA_HEXAHEDRAL_MESH
static int NOOBJECT
Definition: BaseObject.hh:106
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
bool getTargetMeshes(std::vector< PolyMesh *> &_meshes)
Get a pointer to every Poly Mesh which is marked as a target mesh.
bool getSourceMeshes(std::vector< PolyMesh *> &_meshes)
Get a pointer to every Poly Mesh which is marked as a source mesh.
MeshT * mesh()
return a pointer to the mesh