Developer Documentation
VolumeMeshObjectInfoScripting.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: 16055 $ *
45 * $LastChangedBy: moebius $ *
46 * $Date: 2013-01-08 10:57:31 +0100 (Tue, 08 Jan 2013) $ *
47 * *
48 \*===========================================================================*/
49 
50 #include "VolumeMeshObjectInfoPlugin.hh"
51 
53 
56 
57 //------------------------------------------------------------------------------
58 
63 
64  emit setSlotDescription("vertexCount(int)",tr("get total number of vertices for a given object"),
65  QStringList(tr("objectID")), QStringList(tr("id of an object")));
66 
67  emit setSlotDescription("edgeCount(int)",tr("get total number of edges for a given object"),
68  QStringList(tr("objectID")), QStringList(tr("id of an object")));
69 
70  emit setSlotDescription("faceCount(int)",tr("get total number of faces for a given object"),
71  QStringList(tr("objectID")), QStringList(tr("id of an object")));
72 
73  emit setSlotDescription("cellCount(int)",tr("get total number of cells for a given object"),
74  QStringList(tr("objectID")), QStringList(tr("id of an object")));
75 }
76 
77 
78 //------------------------------------------------------------------------------
79 
86 {
87 
88  BaseObjectData* object;
89  if ( ! PluginFunctions::getObject(_id,object) )
90  return -1;
91 
92  if ( object == 0){
93  emit log(LOGERR, tr("Unable to get object"));
94  return -1;
95  }
96 
97  if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
99 
100  if ( mesh == 0 ) {
101  emit log(LOGERR, tr("Unable to get mesh"));
102  return -1;
103  }
104 
105  return mesh->n_vertices();
106 
107  } else {
109 
110  if ( mesh == 0 ) {
111  emit log(LOGERR, tr("Unable to get mesh"));
112  return -1;
113  }
114 
115  return mesh->n_vertices();
116  }
117 }
118 
119 
120 //------------------------------------------------------------------------------
121 
128 {
129 
130  BaseObjectData* object;
131  if ( ! PluginFunctions::getObject(_id,object) )
132  return -1;
133 
134  if ( object == 0){
135  emit log(LOGERR, tr("Unable to get object"));
136  return -1;
137  }
138 
139  if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
141 
142  if ( mesh == 0 ) {
143  emit log(LOGERR, tr("Unable to get mesh"));
144  return -1;
145  }
146 
147  return mesh->n_edges();
148 
149  } else {
151 
152  if ( mesh == 0 ) {
153  emit log(LOGERR, tr("Unable to get mesh"));
154  return -1;
155  }
156 
157  return mesh->n_edges();
158  }
159 }
160 
161 
162 //------------------------------------------------------------------------------
163 
170 {
171 
172  BaseObjectData* object;
173  if ( ! PluginFunctions::getObject(_id,object) )
174  return -1;
175 
176  if ( object == 0){
177  emit log(LOGERR, tr("Unable to get object"));
178  return -1;
179  }
180 
181  if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
183 
184  if ( mesh == 0 ) {
185  emit log(LOGERR, tr("Unable to get mesh"));
186  return -1;
187  }
188 
189  return mesh->n_faces();
190 
191  } else {
193 
194  if ( mesh == 0 ) {
195  emit log(LOGERR, tr("Unable to get mesh"));
196  return -1;
197  }
198 
199  return mesh->n_faces();
200  }
201 }
202 
203 
204 //------------------------------------------------------------------------------
205 
212 {
213 
214  BaseObjectData* object;
215  if ( ! PluginFunctions::getObject(_id,object) )
216  return -1;
217 
218  if ( object == 0){
219  emit log(LOGERR, tr("Unable to get object"));
220  return -1;
221  }
222 
223  if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
225 
226  if ( mesh == 0 ) {
227  emit log(LOGERR, tr("Unable to get mesh"));
228  return -1;
229  }
230 
231  return mesh->n_faces();
232 
233  } else {
235 
236  if ( mesh == 0 ) {
237  emit log(LOGERR, tr("Unable to get mesh"));
238  return -1;
239  }
240 
241  return mesh->n_cells();
242  }
243 }
244 
245 //------------------------------------------------------------------------------
246 
247 
int faceCount(int _id)
get total number of faces for a given object
int edgeCount(int _id)
get total number of edges for a given object
bool getObject(int _identifier, BSplineCurveObject *&_object)
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
void setDescriptions()
set scripting slot descriptions
int vertexCount(int _id)
get total number of vertices for a given object
#define DATA_HEXAHEDRAL_MESH
int cellCount(int _id)
get total number of cells for a given object
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.