Developer Documentation

MeshObjectT.hh
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
45
46
47 //=============================================================================
48 //
49 // Types
50 //
51 //=============================================================================
52
59 #ifndef MESHOBJECT_HH
60 #define MESHOBJECT_HH
61
62 //== INCLUDES =================================================================
63
64 // -------------------- OpenMesh
65 #include <OpenMesh/Core/IO/MeshIO.hh>
66
67 #include <ACG/Scenegraph/SeparatorNode.hh>
68 #include <ACG/Scenegraph/EnvMapNode.hh>
69 #include <ACG/Scenegraph/ShaderNode.hh>
70 #include <ACG/Scenegraph/StatusNodesT.hh>
71
72 #include <OpenFlipper/common/GlobalDefines.hh>
73
74 #include <ObjectTypes/MeshObject/StatusNodeMods.hh>
75 #include <ObjectTypes/MeshObject/StatusViewNodeT.hh>
76 #include <OpenFlipper/common/BaseObjectData.hh>
77
78 // -------------------- BSP
79 #include <ACG/Geometry/bsp/TriangleBSPT.hh>
80
81
82 #include <OpenFlipper/common/BaseObjectData.hh>
83 #include <ACG/Scenegraph/MeshNode2T.hh>
84
85
86
87 //== TYPEDEFS =================================================================
88
90 typedef ACG::SceneGraph::TextureNode TextureNode;
91
92 //== CLASS DEFINITION =========================================================
93
96 template < class MeshT >
97 class DLLEXPORTONLY MeshObject : public BaseObjectData {
98
99 friend class TypePolyMeshPlugin;
100 friend class TypeTriangleMeshPlugin;
101
102 public:
103
108 MeshObject(const MeshObject& _object);
109
117 MeshObject(DataType _typeId);
118
120 virtual ~MeshObject();
121
123 virtual void cleanup();
124
125 protected:
126
128 virtual void init( MeshT* _mesh = 0);
129
130 //===========================================================================
133 //===========================================================================
134 public:
135
137 void setName( QString _name );
138
141 //===========================================================================
144 //===========================================================================
145
146 public:
148 MeshT* mesh();
149
151 const MeshT* mesh() const;
152
153 private:
155 MeshT* mesh_;
156
159 //===========================================================================
166 //===========================================================================
167
168 protected:
169
171 virtual void update(UpdateType _type = UPDATE_ALL);
172
174 void updateSelection();
175
177 void updateModelingRegions();
178
180 void updateFeatures();
181
183 void updateGeometry();
184
186 void updateColor();
187
189 void updateTopology();
190
192 void updateTexture();
193
194
197 //===========================================================================
200 //===========================================================================
201
202 public:
203
205 ACG::SceneGraph::EnvMapNode* textureNode();
206
208 ACG::SceneGraph::ShaderNode* shaderNode();
209
211 void hideSelection( bool _hide );
212
214 bool selectionVisible();
215
217 void hideFeatures( bool _hide );
218
220 bool featuresVisible( );
221
223 void hideArea( StatusBits _bit, bool _hide );
224
233 bool areaVisible( StatusBits _bit );
234
236 ACG::SceneGraph::MeshNodeT<MeshT>* meshNode();
237
239 void boundingBox( ACG::Vec3d& _bbMin , typename ACG::Vec3d& _bbMax );
240
241 BaseNode* primaryNode();
242
244 void setSelectionColor(const ACG::Vec4f& _color);
246 ACG::Vec4f selectionColor() const;
247
249 void setAreaColor(const ACG::Vec4f& _color);
251 ACG::Vec4f areaColor() const;
252
254 void setFeatureColor(const ACG::Vec4f& _color);
256 ACG::Vec4f featureColor() const;
257
259 void setHandleColor(const ACG::Vec4f& _color);
261 ACG::Vec4f handleColor() const;
262
265 ACG::SceneGraph::SelectionNodeT<MeshT> *
266 statusNode() { return statusNode_; }
267
269 ACG::SceneGraph::StatusNodeT<MeshT, AreaNodeMod<MeshT> > *
270 areaNode() { return areaNode_; }
271
273 ACG::SceneGraph::StatusNodeT<MeshT, HandleNodeMod<MeshT> > *
274 handleNode() { return handleNode_; }
275
277 ACG::SceneGraph::StatusNodeT<MeshT, FeatureNodeMod<MeshT> > *
278 featureNode() { return featureNode_; }
279
280 private :
282 ACG::SceneGraph::SelectionNodeT<MeshT>* statusNode_;
283
285 ACG::SceneGraph::StatusNodeT<MeshT, AreaNodeMod<MeshT> > * areaNode_;
286
288 ACG::SceneGraph::StatusNodeT<MeshT, HandleNodeMod<MeshT> > * handleNode_;
289
291 ACG::SceneGraph::StatusNodeT<MeshT, FeatureNodeMod<MeshT> > *featureNode_;
292
294 ACG::SceneGraph::MeshNodeT<MeshT>* meshNode_;
295
297 ACG::SceneGraph::EnvMapNode* textureNode_;
298
300 ACG::SceneGraph::ShaderNode* shaderNode_;
301
303 ACG::SceneGraph::StatusViewNodeT<MeshT>* statusView_;
304
307 //===========================================================================
310 //===========================================================================
311
312 public:
313
315 bool loadMesh(QString _filename);
316
319 //===========================================================================
322 //===========================================================================
323 public:
325 QString getObjectinfo();
326
330 //===========================================================================
333 //===========================================================================
334 public:
336 bool picked( uint _node_idx );
337
339 void enablePicking( bool _enable );
340
342 bool pickingEnabled();
343
346 //===========================================================================
349 //===========================================================================
350 public:
351
352 typedef OpenMeshTriangleBSPT< MeshT > OMTriangleBSP;
353
359 OMTriangleBSP* requestTriangleBsp();
360
367 void invalidateTriangleBsp();
368
369
375 OMTriangleBSP* resetTriangleBsp();
376
385 bool hasBsp() const;
386
387
388 private :
390 OMTriangleBSP* triangle_bsp_;
391
393 };
394
395 //=============================================================================
396
397 #if defined(INCLUDE_TEMPLATES) && !defined(MESHOBJECT_C)
398 #define MESHOBJECT_TEMPLATES
399 #include "MeshObjectT_impl.hh"
400 #endif
401
402
403 //=============================================================================
404 #endif // MESHOBJECT_HH defined
405 //=============================================================================
TypePolyMeshPlugin
Definition: TypePolyMesh.hh:60
UpdateType
Update type class.
Definition: UpdateType.hh:60
BaseObject::getObjectinfo
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:244
ACG::SceneGraph::EnvMapNode
Definition: EnvMapNode.hh:77
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
BaseObjectData::update
virtual void update(UpdateType _type=UPDATE_ALL)
This function is called to update the object.
Definition: BaseObjectData.cc:329
MeshObject::areaNode
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode()
Returns the area selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:270
BaseObjectData::primaryNode
virtual BaseNode * primaryNode()
Definition: BaseObjectData.cc:251
MeshObject::handleNode_
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
Definition: MeshObjectT.hh:288
GlobalDefines.hh
MeshObject::OMTriangleBSP
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:352
MeshObject::textureNode_
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
Definition: MeshObjectT.hh:297
MeshObject::handleNode
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode()
Returns the handle selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:274
BaseObjectData::cleanup
virtual void cleanup()
Definition: BaseObjectData.cc:102
MeshObject::mesh_
MeshT * mesh_
pointer to the mesh
Definition: MeshObjectT.hh:155
BaseObjectData.hh
BaseObjectData::pickingEnabled
virtual bool pickingEnabled()
Definition: BaseObjectData.cc:318
MeshObject::featureNode
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode()
Returns the feature selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:278
ACG::SceneGraph::MeshNodeT< MeshT >
BaseObjectData::setName
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObjectData.cc:355
ACG::SceneGraph::StatusViewNodeT
Definition: StatusViewNodeT.hh:69
MeshObject::meshNode_
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
Definition: MeshObjectT.hh:294
MeshObject::statusNode_
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT.hh:282
TypeTriangleMeshPlugin
Definition: TypeTriangleMesh.hh:60
MeshObject::statusView_
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
Definition: MeshObjectT.hh:303
MeshObject::statusNode
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode()
Definition: MeshObjectT.hh:266
ACG::SceneGraph::ShaderNode
Definition: ShaderNode.hh:81
MeshObject::areaNode_
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
Definition: MeshObjectT.hh:285
BaseObjectData::enablePicking
virtual void enablePicking(bool _enable)
Definition: BaseObjectData.cc:315
MeshObject::shaderNode_
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
Definition: MeshObjectT.hh:300
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::SelectionNodeT< MeshT >
MeshObject::triangle_bsp_
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:390
OpenMeshTriangleBSPT
Definition: TriangleBSPT.hh:212
ACG::SceneGraph::StatusNodeT
Definition: StatusNodesT.hh:207
MeshObject
Definition: MeshObjectT.hh:97
BaseObjectData::picked
virtual bool picked(uint _node_idx)
detect if the node has been picked
Definition: BaseObjectData.cc:311
BaseObjectData
Definition: BaseObjectData.hh:102
MeshObject::featureNode_
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
Definition: MeshObjectT.hh:291
ACG::SceneGraph::TextureNode
Definition: TextureNode.hh:87
BaseObjectData::shaderNode
virtual ACG::SceneGraph::ShaderNode * shaderNode()
Definition: BaseObjectData.cc:259