Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 //=============================================================================
54 //
55 // Types
56 //
57 //=============================================================================
58 
65 #ifndef MESHOBJECT_HH
66 #define MESHOBJECT_HH
67 
68 //== INCLUDES =================================================================
69 
70 // -------------------- OpenMesh
71 #include <OpenMesh/Core/IO/MeshIO.hh>
72 
73 #include <ACG/Scenegraph/SeparatorNode.hh>
74 #include <ACG/Scenegraph/EnvMapNode.hh>
75 #include <ACG/Scenegraph/ShaderNode.hh>
76 #include <ACG/Scenegraph/StatusNodesT.hh>
77 
79 
80 #include <ObjectTypes/MeshObject/StatusNodeMods.hh>
81 #include <ObjectTypes/MeshObject/StatusViewNodeT.hh>
83 
84 // -------------------- BSP
85 #include <ACG/Geometry/bsp/TriangleBSPT.hh>
86 
87 
89 #include <ACG/Scenegraph/MeshNode2T.hh>
90 
91 
92 
93 //== TYPEDEFS =================================================================
94 
97 
98 //== CLASS DEFINITION =========================================================
99 
102 template < class MeshT >
103 class DLLEXPORTONLY MeshObject : public BaseObjectData {
104 
105  friend class TypePolyMeshPlugin;
106  friend class TypeTriangleMeshPlugin;
107 
108  public:
109 
114  MeshObject(const MeshObject& _object);
115 
123  MeshObject(DataType _typeId);
124 
126  virtual ~MeshObject();
127 
129  virtual void cleanup();
130 
131  protected:
132 
134  virtual void init( MeshT* _mesh = 0);
135 
136  //===========================================================================
139  //===========================================================================
140  public:
141 
143  void setName( QString _name );
144 
145 
146  //===========================================================================
149  //===========================================================================
150 
151  public:
153  MeshT* mesh();
154 
155  private:
157  MeshT* mesh_;
158 
161  //===========================================================================
168  //===========================================================================
169 
170  protected:
171 
173  virtual void update(UpdateType _type = UPDATE_ALL);
174 
176  void updateSelection();
177 
179  void updateModelingRegions();
180 
182  void updateFeatures();
183 
185  void updateGeometry();
186 
188  void updateColor();
189 
191  void updateTopology();
192 
194  void updateTexture();
195 
196 
199  //===========================================================================
202  //===========================================================================
203 
204  public:
205 
207  ACG::SceneGraph::EnvMapNode* textureNode();
208 
211 
213  void hideSelection( bool _hide );
214 
216  bool selectionVisible();
217 
219  void hideFeatures( bool _hide );
220 
222  bool featuresVisible( );
223 
225  void hideArea( StatusBits _bit, bool _hide );
226 
235  bool areaVisible( StatusBits _bit );
236 
239 
241  void boundingBox( ACG::Vec3d& _bbMin , typename ACG::Vec3d& _bbMax );
242 
244 
246  void setSelectionColor(const ACG::Vec4f& _color);
248  ACG::Vec4f selectionColor() const;
249 
251  void setAreaColor(const ACG::Vec4f& _color);
253  ACG::Vec4f areaColor() const;
254 
256  void setFeatureColor(const ACG::Vec4f& _color);
258  ACG::Vec4f featureColor() const;
259 
261  void setHandleColor(const ACG::Vec4f& _color);
263  ACG::Vec4f handleColor() const;
264 
268  statusNode() { return statusNode_; }
269 
272  areaNode() { return areaNode_; }
273 
276  handleNode() { return handleNode_; }
277 
280  featureNode() { return featureNode_; }
281 
282  private :
285 
288 
291 
294 
297 
300 
303 
306 
309  //===========================================================================
312  //===========================================================================
313 
314  public:
315 
317  bool loadMesh(QString _filename);
318 
321  //===========================================================================
324  //===========================================================================
325  public:
327  QString getObjectinfo();
328 
332  //===========================================================================
335  //===========================================================================
336  public:
338  bool picked( uint _node_idx );
339 
341  void enablePicking( bool _enable );
342 
344  bool pickingEnabled();
345 
348  //===========================================================================
351  //===========================================================================
352  public:
353 
355 
361  OMTriangleBSP* requestTriangleBsp();
362 
369  void invalidateTriangleBsp();
370 
371 
377  OMTriangleBSP* resetTriangleBsp();
378 
387  bool hasBsp() const;
388 
389 
390  private :
392  OMTriangleBSP* triangle_bsp_;
393 
395 };
396 
397 //=============================================================================
398 
399 #if defined(INCLUDE_TEMPLATES) && !defined(MESHOBJECT_C)
400 #define MESHOBJECT_TEMPLATES
401 #include "MeshObjectT.cc"
402 #endif
403 
404 
405 //=============================================================================
406 #endif // MESHOBJECT_HH defined
407 //=============================================================================
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
Definition: MeshObjectT.hh:302
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
Definition: MeshObjectT.hh:299
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:255
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
Definition: MeshObjectT.hh:296
Update type class.
Definition: UpdateType.hh:70
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
virtual bool pickingEnabled()
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:354
virtual void cleanup()
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT.hh:284
virtual BaseNode * primaryNode()
virtual void enablePicking(bool _enable)
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
Definition: MeshObjectT.hh:287
virtual ACG::SceneGraph::ShaderNode * shaderNode()
virtual void update(UpdateType _type=UPDATE_ALL)
This function is called to update the object.
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode()
Returns the handle selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:276
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
Definition: MeshObjectT.hh:293
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
Definition: MeshObjectT.hh:305
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
Definition: MeshObjectT.hh:290
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:392
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode()
Definition: MeshObjectT.hh:268
Predefined datatypes.
Definition: DataTypes.hh:96
MeshT * mesh_
pointer to the mesh
Definition: MeshObjectT.hh:157
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode()
Returns the area selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:272
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode()
Returns the feature selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:280
virtual bool picked(uint _node_idx)
detect if the node has been picked