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 
147  //===========================================================================
150  //===========================================================================
151 
152  public:
154  MeshT* mesh();
155 
156  private:
158  MeshT* mesh_;
159 
162  //===========================================================================
169  //===========================================================================
170 
171  protected:
172 
174  virtual void update(UpdateType _type = UPDATE_ALL);
175 
177  void updateSelection();
178 
180  void updateModelingRegions();
181 
183  void updateFeatures();
184 
186  void updateGeometry();
187 
189  void updateColor();
190 
192  void updateTopology();
193 
195  void updateTexture();
196 
197 
200  //===========================================================================
203  //===========================================================================
204 
205  public:
206 
208  ACG::SceneGraph::EnvMapNode* textureNode();
209 
212 
214  void hideSelection( bool _hide );
215 
217  bool selectionVisible();
218 
220  void hideFeatures( bool _hide );
221 
223  bool featuresVisible( );
224 
226  void hideArea( StatusBits _bit, bool _hide );
227 
236  bool areaVisible( StatusBits _bit );
237 
240 
242  void boundingBox( ACG::Vec3d& _bbMin , typename ACG::Vec3d& _bbMax );
243 
245 
247  void setSelectionColor(const ACG::Vec4f& _color);
249  ACG::Vec4f selectionColor() const;
250 
252  void setAreaColor(const ACG::Vec4f& _color);
254  ACG::Vec4f areaColor() const;
255 
257  void setFeatureColor(const ACG::Vec4f& _color);
259  ACG::Vec4f featureColor() const;
260 
262  void setHandleColor(const ACG::Vec4f& _color);
264  ACG::Vec4f handleColor() const;
265 
269  statusNode() { return statusNode_; }
270 
273  areaNode() { return areaNode_; }
274 
277  handleNode() { return handleNode_; }
278 
281  featureNode() { return featureNode_; }
282 
283  private :
286 
289 
292 
295 
298 
301 
304 
307 
310  //===========================================================================
313  //===========================================================================
314 
315  public:
316 
318  bool loadMesh(QString _filename);
319 
322  //===========================================================================
325  //===========================================================================
326  public:
328  QString getObjectinfo();
329 
333  //===========================================================================
336  //===========================================================================
337  public:
339  bool picked( uint _node_idx );
340 
342  void enablePicking( bool _enable );
343 
345  bool pickingEnabled();
346 
349  //===========================================================================
352  //===========================================================================
353  public:
354 
356 
362  OMTriangleBSP* requestTriangleBsp();
363 
370  void invalidateTriangleBsp();
371 
372 
378  OMTriangleBSP* resetTriangleBsp();
379 
388  bool hasBsp() const;
389 
390 
391  private :
393  OMTriangleBSP* triangle_bsp_;
394 
396 };
397 
398 //=============================================================================
399 
400 #if defined(INCLUDE_TEMPLATES) && !defined(MESHOBJECT_C)
401 #define MESHOBJECT_TEMPLATES
402 #include "MeshObjectT.cc"
403 #endif
404 
405 
406 //=============================================================================
407 #endif // MESHOBJECT_HH defined
408 //=============================================================================
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode()
Returns the feature selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:281
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
Definition: MeshObjectT.hh:303
MeshT * mesh_
pointer to the mesh
Definition: MeshObjectT.hh:158
virtual bool picked(uint _node_idx)
detect if the node has been picked
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:255
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode()
Returns the area selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:273
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
Definition: MeshObjectT.hh:297
virtual bool pickingEnabled()
virtual void cleanup()
virtual void update(UpdateType _type=UPDATE_ALL)
This function is called to update the object.
virtual BaseNode * primaryNode()
virtual void enablePicking(bool _enable)
Update type class.
Definition: UpdateType.hh:70
virtual ACG::SceneGraph::ShaderNode * shaderNode()
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode()
Definition: MeshObjectT.hh:269
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode()
Returns the handle selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:277
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
Definition: MeshObjectT.hh:288
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:355
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT.hh:285
Predefined datatypes.
Definition: DataTypes.hh:96
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
Definition: MeshObjectT.hh:291
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:393
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 "." )
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
Definition: MeshObjectT.hh:306
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
Definition: MeshObjectT.hh:300
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
Definition: MeshObjectT.hh:294