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 
73 
74 #include <ObjectTypes/MeshObject/StatusNodeMods.hh>
75 #include <ObjectTypes/MeshObject/StatusViewNodeT.hh>
77 
78 // -------------------- BSP
79 #include <ACG/Geometry/bsp/TriangleBSPT.hh>
80 
81 
83 #include <ACG/Scenegraph/MeshNode2T.hh>
84 
85 
86 
87 //== TYPEDEFS =================================================================
88 
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 
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 
237 
239  void boundingBox( ACG::Vec3d& _bbMin , typename ACG::Vec3d& _bbMax );
240 
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 
266  statusNode() { return statusNode_; }
267 
270  areaNode() { return areaNode_; }
271 
274  handleNode() { return handleNode_; }
275 
278  featureNode() { return featureNode_; }
279 
280  private :
283 
286 
289 
292 
295 
298 
301 
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 
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 //=============================================================================
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode()
Returns the handle selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:274
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:244
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
Definition: MeshObjectT.hh:294
virtual bool picked(uint _node_idx)
detect if the node has been picked
virtual void setName(QString _name) override
path to the file from which the object is loaded ( defaults to "." )
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
Definition: MeshObjectT.hh:300
Predefined datatypes.
Definition: DataTypes.hh:83
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
Definition: MeshObjectT.hh:291
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode()
Returns the feature selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:278
virtual void enablePicking(bool _enable)
virtual BaseNode * primaryNode()
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:390
virtual void cleanup() override
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
Definition: MeshObjectT.hh:303
virtual void update(UpdateType _type=UPDATE_ALL) override
This function is called to update the object.
Update type class.
Definition: UpdateType.hh:60
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
Definition: MeshObjectT.hh:285
MeshT * mesh_
pointer to the mesh
Definition: MeshObjectT.hh:155
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
Definition: MeshObjectT.hh:297
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT.hh:282
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
Definition: MeshObjectT.hh:288
virtual ACG::SceneGraph::ShaderNode * shaderNode()
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:352
virtual bool pickingEnabled()
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode()
Definition: MeshObjectT.hh:266
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode()
Returns the area selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:270