Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
VolumeMeshNode.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 #ifndef VOLUMEMESHNODE_HH
51 #define VOLUMEMESHNODE_HH
52
53 //== INCLUDES =================================================================
54
55 #include <ACG/GL/gl.hh>
56 #include <ACG/Scenegraph/BaseNode.hh>
57 #include <ACG/Scenegraph/MaterialNode.hh>
58 #include <ACG/Scenegraph/DrawModes.hh>
59 #include <OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh>
60 #include <OpenVolumeMesh/Core/BaseEntities.hh>
61 #include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
62 #include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
63 #include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
64 #include <OpenVolumeMesh/Attribs/TexCoordAttrib.hh>
65
66 #include "VolumeMeshBufferManager.hh"
67 #include "VolumeMeshDrawModesContainer.hh"
68
69
70 #include <ACG/GL/RenderObject.hh>
71 #include <ACG/GL/VertexDeclaration.hh>
72 #include <ACG/GL/IRenderer.hh>
73
74 //== FORWARDDECLARATIONS ======================================================
75
76 //== NAMESPACES ===============================================================
77
78 namespace ACG {
79 namespace SceneGraph {
80
81 //== CLASS DEFINITION =========================================================
82
86 template<class VolumeMeshT>
87 class VolumeMeshNodeT: public BaseNode {
88 public:
89
90 // typedefs for easy access
91 typedef VolumeMeshT VolumeMesh;
92 typedef OpenVolumeMesh::VertexHandle VertexHandle;
93 typedef OpenVolumeMesh::EdgeHandle EdgeHandle;
94 typedef OpenVolumeMesh::HalfEdgeHandle HalfEdgeHandle;
95 typedef OpenVolumeMesh::FaceHandle FaceHandle;
96 typedef OpenVolumeMesh::HalfFaceHandle HalfFaceHandle;
97 typedef OpenVolumeMesh::CellHandle CellHandle;
98
99 typedef typename VolumeMeshT::PointT Vertex;
100 typedef OpenVolumeMesh::OpenVolumeMeshEdge Edge;
101 typedef OpenVolumeMesh::OpenVolumeMeshFace Face;
102 typedef OpenVolumeMesh::OpenVolumeMeshCell Cell;
103
104 typedef typename VolumeMeshBufferManager<VolumeMeshT>::Plane Plane;
105
106
108 VolumeMeshNodeT(const VolumeMesh& _mesh,
109 OpenVolumeMesh::StatusAttrib& _statusAttrib,
110 OpenVolumeMesh::ColorAttrib<Vec4f>& _colorAttrib,
111 OpenVolumeMesh::NormalAttrib<VolumeMesh>& _normalAttrib,
112 OpenVolumeMesh::TexCoordAttrib<Vec2f> &_texcoordAttrib,
113 const MaterialNode* _matNode, BaseNode* _parent = 0,
114 std::string _name = "<VolumeMeshNode>");
115
117 ~VolumeMeshNodeT();
118
120 ACG_CLASSNAME(VolumeMeshNodeT)
121
122
123 DrawModes::DrawMode availableDrawModes() const;
124
126 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
127
129 void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
130
134 void getRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
135
137 void pick(GLState& _state, PickTarget _target);
138
139 // clear all cutplanes
140 void clear_cut_planes();
141
142 // add a new cutplane
143 void add_cut_plane(const Plane& _p);
144 void add_cut_plane(const Vec3d& _p, const Vec3d& _n, const Vec3d& _xsize, const Vec3d& _ysize);
145
146 // set shrinkage of cells
147 void set_scaling(double _scale);
148
149 // Get scaling
150 double scaling() const { return scale_; }
151
152 // Choose whether to visualize the boundary only
153 void set_boundary_only(bool _boundary);
154 bool boundary_only() const { return boundary_only_; }
155
156 // Set translucency factor
157 void set_translucency_factor(float _factor) { translucency_factor_ = _factor; }
158 float translucency_factor() const { return translucency_factor_; }
159
160 // Set whether to update the topology in next render pass
161 void set_topology_changed(bool _topology_changed);
162
163 // Set whether to update the geometry in next render pass
164 void set_geometry_changed(bool _geom_changed);
165
166 // Set whether to update the color in next render pass
167 void set_color_changed(bool _color_changed);
168
169 // Set whether to update the texture in next render pass
170 void set_texture_changed(bool _texture_changed);
171
172 // Set whether to update the selectopm in next render pass
173 void set_selection_changed(bool _selection_changed);
174
175 private:
176
178 void drawCells(GLState& _state, const DrawModes::DrawMode& _drawMode);
180 void drawFaces(GLState& _state, const DrawModes::DrawMode& _drawMode);
182 void drawEdges(GLState& _state, const DrawModes::DrawMode& _drawMode);
184 void drawVertices(GLState& _state, const DrawModes::DrawMode& _drawMode);
186 void drawSelection(GLState& _state, const DrawModes::DrawMode& _drawMode);
187
189 void getCellRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
191 void getFaceRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
193 void getEdgeRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
195 void getVertexRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
196
198 void getSelectionRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
199
201 void invalidateAllBuffers();
203 void invalidateAllDrawBuffers();
205 void invalidateAllPickingBuffers();
207 void invalidateAllSelectionBuffers();
208
210 void pickVertices(GLState& _state);
212 void pickEdges(GLState& _state, unsigned int _offset);
214 void pickFaces(GLState& _state, unsigned int _offset);
216 void pickCells(GLState& _state, unsigned int _offset);
217
219 void update_face_normals();
221 void update_vertex_normals();
222
224 VolumeMeshNodeT(const VolumeMeshNodeT& _rhs);
225
227 VolumeMeshNodeT& operator=(const VolumeMeshNodeT& _rhs);
228
229 private:
230
231 const VolumeMesh& mesh_;
232
233 double scale_;
234
235 // Flag that indicates whether to render the boundary faces only
236 bool boundary_only_;
237
238 // Translucency factor in [0, 1]
239 GLfloat translucency_factor_;
240
241 // Hold color of selection
242 ACG::Vec4f selection_color_;
243
244 OpenVolumeMesh::StatusAttrib& statusAttrib_;
245 OpenVolumeMesh::ColorAttrib<Vec4f>& colorAttrib_;
246 OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_;
247 OpenVolumeMesh::TexCoordAttrib<Vec2f>& texcoordAttrib_;
248
249 const MaterialNode* materialNode_;
250
251 VolumeMeshBufferManager<VolumeMeshT> cellsBufferManager_;
252 VolumeMeshBufferManager<VolumeMeshT> facesBufferManager_;
253 VolumeMeshBufferManager<VolumeMeshT> edgesBufferManager_;
254 VolumeMeshBufferManager<VolumeMeshT> verticesBufferManager_;
255
256 VolumeMeshBufferManager<VolumeMeshT> cellSelectionBufferManager_;
257 VolumeMeshBufferManager<VolumeMeshT> faceSelectionBufferManager_;
258 VolumeMeshBufferManager<VolumeMeshT> edgeSelectionBufferManager_;
259 VolumeMeshBufferManager<VolumeMeshT> vertexSelectionBufferManager_;
260
261 VolumeMeshBufferManager<VolumeMeshT> cellPickBufferManager_;
262 VolumeMeshBufferManager<VolumeMeshT> facePickBufferManager_;
263 VolumeMeshBufferManager<VolumeMeshT> edgePickBufferManager_;
264 VolumeMeshBufferManager<VolumeMeshT> vertexPickBufferManager_;
265
266 VolumeMeshDrawModesContainer drawModes_;
267
268 DrawModes::DrawMode lastDrawMode_;
269 DrawModes::DrawMode lastCellDrawMode_;
270 DrawModes::DrawMode lastFaceDrawMode_;
271 DrawModes::DrawMode lastEdgeDrawMode_;
272 DrawModes::DrawMode lastVertexDrawMode_;
273
274 PickTarget lastPickTarget_;
275
276 bool face_normals_calculated_;
277 bool vertex_normals_calculated_;
278
279 };
280
281 //=============================================================================
282 } // namespace SceneGraph
283 } // namespace ACG
284 //=============================================================================
285 #if defined(INCLUDE_TEMPLATES) && !defined(VOLUMEMESHNODET_CC)
286 #include "VolumeMeshNodeT.cc"
287 #endif
288 //=============================================================================
289 #endif // VOLUMEMESHNODE_HH
290 //=============================================================================
291
ACG::SceneGraph::VolumeMeshNodeT::operator=
VolumeMeshNodeT & operator=(const VolumeMeshNodeT &_rhs)
Assignment operator (not used)
OpenVolumeMesh::ColorAttrib
Definition: ColorAttrib.hh:58
OpenVolumeMesh::EdgeHandle
Definition: OpenVolumeMeshHandle.hh:99
OpenVolumeMesh::CellHandle
Definition: OpenVolumeMeshHandle.hh:101
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:135
OpenVolumeMesh::FaceHandle
Definition: OpenVolumeMeshHandle.hh:100
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllDrawBuffers
void invalidateAllDrawBuffers()
invalidates all buffers used for normal rendering
Definition: VolumeMeshNodeT.cc:564
ACG::SceneGraph::PickTarget
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
OpenVolumeMesh::StatusAttrib
Definition: StatusAttrib.hh:57
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllPickingBuffers
void invalidateAllPickingBuffers()
invalidates all buffers used for picking
Definition: VolumeMeshNodeT.cc:573
ACG::SceneGraph::VolumeMeshNodeT::pickEdges
void pickEdges(GLState &_state, unsigned int _offset)
pick edges
Definition: VolumeMeshNodeT.cc:1287
OpenVolumeMesh::OpenVolumeMeshEdge
Definition: BaseEntities.hh:52
ACG::SceneGraph::VolumeMeshNodeT::~VolumeMeshNodeT
~VolumeMeshNodeT()
Destructor.
Definition: VolumeMeshNodeT.cc:132
ACG::SceneGraph::VolumeMeshNodeT::update_face_normals
void update_face_normals()
updates face normals
Definition: VolumeMeshNodeT.cc:1383
ACG::SceneGraph::VolumeMeshNodeT::drawEdges
void drawEdges(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the edges or halfedges of the mesh
Definition: VolumeMeshNodeT.cc:401
ACG::SceneGraph::VolumeMeshNodeT::drawSelection
void drawSelection(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw selected primitves
Definition: VolumeMeshNodeT.cc:480
ACG::SceneGraph::VolumeMeshNodeT::VolumeMeshNodeT
VolumeMeshNodeT(const VolumeMesh &_mesh, OpenVolumeMesh::StatusAttrib &_statusAttrib, OpenVolumeMesh::ColorAttrib< Vec4f > &_colorAttrib, OpenVolumeMesh::NormalAttrib< VolumeMesh > &_normalAttrib, OpenVolumeMesh::TexCoordAttrib< Vec2f > &_texcoordAttrib, const MaterialNode *_matNode, BaseNode *_parent=0, std::string _name="<VolumeMeshNode>")
Constructor.
Definition: VolumeMeshNodeT.cc:78
ACG::SceneGraph::VolumeMeshNodeT::boundingBox
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
Definition: VolumeMeshNodeT.cc:139
ACG::SceneGraph::VolumeMeshNodeT::getVertexRenderObjects
void getVertexRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing vertices to the given renderer
Definition: VolumeMeshNodeT.cc:900
VolumeMeshBufferManager
This class creates buffers that can be used to render open volume meshs.
Definition: VolumeMeshBufferManager.hh:69
ACG::GLState
Definition: GLState.hh:220
ACG::SceneGraph::VolumeMeshNodeT::availableDrawModes
DrawModes::DrawMode availableDrawModes() const
static name of this class
Definition: VolumeMeshNodeT.cc:153
ACG::SceneGraph::VolumeMeshNodeT::drawCells
void drawCells(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the cells of the mesh
Definition: VolumeMeshNodeT.cc:243
OpenVolumeMesh::HalfFaceHandle
Definition: OpenVolumeMeshHandle.hh:103
ACG::IRenderer
Definition: IRenderer.hh:84
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:294
Plane
Definition: PlaneType.hh:77
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllBuffers
void invalidateAllBuffers()
invalidates all buffers
Definition: VolumeMeshNodeT.cc:556
OpenVolumeMesh::TexCoordAttrib
Definition: TexCoordAttrib.hh:58
OpenVolumeMesh::OpenVolumeMeshCell
Definition: BaseEntities.hh:119
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::VolumeMeshNodeT::getEdgeRenderObjects
void getEdgeRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing edges or halfedges to the given renderer
Definition: VolumeMeshNodeT.cc:854
ACG::SceneGraph::VolumeMeshNodeT::update_vertex_normals
void update_vertex_normals()
updates vertex normals
Definition: VolumeMeshNodeT.cc:1392
OpenVolumeMesh::HalfEdgeHandle
Definition: OpenVolumeMeshHandle.hh:102
ACG::SceneGraph::VolumeMeshNodeT
Definition: VolumeMeshNode.hh:87
ACG::SceneGraph::VolumeMeshNodeT::getFaceRenderObjects
void getFaceRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing faces or halffaces to the given renderer
Definition: VolumeMeshNodeT.cc:792
OpenVolumeMesh::VertexHandle
Definition: OpenVolumeMeshHandle.hh:98
ACG::SceneGraph::VolumeMeshNodeT::getRenderObjects
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
Draws the object deferred.
Definition: VolumeMeshNodeT.cc:1042
OpenVolumeMesh::OpenVolumeMeshFace
Definition: BaseEntities.hh:90
ACG::SceneGraph::Material
Definition: MaterialNode.hh:85
ACG::SceneGraph::VolumeMeshNodeT::drawFaces
void drawFaces(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the faces or halffaces of the mesh
Definition: VolumeMeshNodeT.cc:306
ACG::SceneGraph::MaterialNode
Definition: MaterialNode.hh:321
ACG::SceneGraph::VolumeMeshNodeT::drawVertices
void drawVertices(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the vertices of the mesh
Definition: VolumeMeshNodeT.cc:444
ACG::SceneGraph::VolumeMeshNodeT::pick
void pick(GLState &_state, PickTarget _target)
picking
Definition: VolumeMeshNodeT.cc:1092
ACG::SceneGraph::VolumeMeshNodeT::draw
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw lines and normals
Definition: VolumeMeshNodeT.cc:591
ACG::SceneGraph::VolumeMeshNodeT::pickVertices
void pickVertices(GLState &_state)
pick vertices
Definition: VolumeMeshNodeT.cc:1246
ACG::SceneGraph::VolumeMeshNodeT::pickFaces
void pickFaces(GLState &_state, unsigned int _offset)
pick faces
Definition: VolumeMeshNodeT.cc:1324
ACG::SceneGraph::VolumeMeshNodeT::pickCells
void pickCells(GLState &_state, unsigned int _offset)
pick cells
Definition: VolumeMeshNodeT.cc:1357
ACG::SceneGraph::VolumeMeshNodeT::getSelectionRenderObjects
void getSelectionRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing selected primitves to the given renderer
Definition: VolumeMeshNodeT.cc:945
OpenVolumeMesh::NormalAttrib< VolumeMesh >
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllSelectionBuffers
void invalidateAllSelectionBuffers()
invalidates all buffers used for rendering selected primitives
Definition: VolumeMeshNodeT.cc:582
VolumeMeshDrawModesContainer
This class provides easy access to DrawModes supported by OpenVolumeMesh.
Definition: VolumeMeshDrawModesContainer.hh:59
ACG::SceneGraph::VolumeMeshNodeT::getCellRenderObjects
void getCellRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing cells to the given renderer
Definition: VolumeMeshNodeT.cc:728