Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 /*===========================================================================*\
43 * *
44  * $Revision: 13489 $ *
45  * $LastChangedBy: kremer $ *
46  * $Date: 2012-01-25 12:30:09 +0100 (Wed, 25 Jan 2012) $ *
47  * *
48  \*===========================================================================*/
49 
51 
53 
54 namespace PluginFunctions {
55 
56 // ===============================================================================
57 // Get source meshes
58 // ===============================================================================
59 
60 
61 bool getSourceMeshes( std::vector<HexahedralMesh*>& _meshes )
62 {
63  _meshes.clear();
64 
66  o_it != PluginFunctions::objectsEnd(); ++o_it) {
67  _meshes.push_back ( PluginFunctions::hexahedralMesh( *o_it ) );
68  if( _meshes.back() == NULL)
69  std::cerr << "ERROR: HexahedralMesh getSourceMeshes fatal error\n";
70  }
71 
72  return ( !_meshes.empty() );
73 }
74 
75 
76 // ===============================================================================
77 // Get target meshes
78 // ===============================================================================
79 
80 
81 bool getTargetMeshes( std::vector<HexahedralMesh*>& _meshes )
82 {
83  _meshes.clear();
84 
86  o_it != PluginFunctions::objectsEnd(); ++o_it) {
87  _meshes.push_back ( PluginFunctions::hexahedralMesh( *o_it ) );
88  if( _meshes.back() == NULL)
89  std::cerr << "ERROR: HexahedralMesh getTargetMeshes fatal error\n";
90  }
91 
92  return ( !_meshes.empty() );
93 }
94 
95 
96 // ===============================================================================
97 // Get objects
98 // ===============================================================================
99 
100 bool getObject( int _identifier, HexahedralMeshObject*& _object ) {
101 
102  if ( _identifier == BaseObject::NOOBJECT ) {
103  _object = 0;
104  return false;
105  }
106 
107  // Get object by using the map accelerated plugin function
108  BaseObjectData* object = 0;
109  PluginFunctions::getObject(_identifier,object);
110 
111  _object = dynamic_cast< HexahedralMeshObject* >(object);
112  return ( _object != 0 );
113 }
114 
115 
116 // ===============================================================================
117 // Getting data from objects and casting between them
118 // ===============================================================================
119 
121 
122  if ( _object->dataType(DATA_HEXAHEDRAL_MESH) ) {
123  HexahedralMeshObject* object = dynamic_cast< HexahedralMeshObject* >(_object);
124  return object->mesh();
125  } else
126  return 0;
127 }
128 
129 HexahedralMesh* hexahedralMesh( int _identifier ) {
130  HexahedralMeshObject* object = hexahedralMeshObject(_identifier);
131 
132  if ( object == 0)
133  return 0;
134  else
135  return object->mesh();
136 }
137 
138 
140  if ( ! _object->dataType(DATA_HEXAHEDRAL_MESH) )
141  return 0;
142  return dynamic_cast< HexahedralMeshObject* >( _object );
143 }
144 
145 
147 {
148  HexahedralMeshObject* pol_obj;
149  if(getObject(_identifier, pol_obj))
150  return pol_obj;
151  else
152  return 0;
153 }
154 
155 
156 }
MeshT * mesh()
return a pointer to the mesh
bool getSourceMeshes(std::vector< HexahedralMesh * > &_meshes)
Get a pointer to every HexahedralMesh which is marked as a source.
bool getObject(int _identifier, BSplineCurveObject *&_object)
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
bool getTargetMeshes(std::vector< HexahedralMesh * > &_meshes)
Get a pointer to every HexahedralMesh which is marked as a target.
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
static int NOOBJECT
Definition: BaseObject.hh:118
#define DATA_HEXAHEDRAL_MESH
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.