Developer Documentation

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 #pragma once
43
44 //== INCLUDES =================================================================
45
46 #include <ACG/GL/gl.hh>
47 #include <ACG/Scenegraph/BaseNode.hh>
48 #include <ACG/Scenegraph/MaterialNode.hh>
49 #include <ACG/Scenegraph/DrawModes.hh>
50 #include <ACG/Geometry/Types/PlaneType.hh>
51 #include <OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh>
52 #include <OpenVolumeMesh/Core/BaseEntities.hh>
53 #include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
54 #include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
55 #include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
56 #include <OpenVolumeMesh/Attribs/TexCoordAttrib.hh>
57
58 #include "VolumeMeshBufferManager.hh"
59 #include "VolumeMeshDrawModesContainer.hh"
60
61
62 #include <ACG/GL/RenderObject.hh>
63 #include <ACG/GL/VertexDeclaration.hh>
64 #include <ACG/GL/IRenderer.hh>
65
66 //== FORWARDDECLARATIONS ======================================================
67
68 //== NAMESPACES ===============================================================
69
70 namespace ACG {
71 namespace SceneGraph {
72
73 //== CLASS DEFINITION =========================================================
74
78 template<class VolumeMeshT>
79 class VolumeMeshNodeT: public BaseNode {
80 public:
81
82 // typedefs for easy access
83 typedef VolumeMeshT VolumeMesh;
84 typedef OpenVolumeMesh::VertexHandle VertexHandle;
85 typedef OpenVolumeMesh::EdgeHandle EdgeHandle;
86 typedef OpenVolumeMesh::HalfEdgeHandle HalfEdgeHandle;
87 typedef OpenVolumeMesh::FaceHandle FaceHandle;
88 typedef OpenVolumeMesh::HalfFaceHandle HalfFaceHandle;
89 typedef OpenVolumeMesh::CellHandle CellHandle;
90
91 typedef typename VolumeMeshT::PointT Vertex;
92 typedef OpenVolumeMesh::OpenVolumeMeshEdge Edge;
93 typedef OpenVolumeMesh::OpenVolumeMeshFace Face;
94 typedef OpenVolumeMesh::OpenVolumeMeshCell Cell;
95
96 using Plane = ACG::Geometry::Plane;
97
98
100 VolumeMeshNodeT(const VolumeMesh& _mesh,
101 OpenVolumeMesh::StatusAttrib& _statusAttrib,
102 OpenVolumeMesh::ColorAttrib<Vec4f>& _colorAttrib,
103 OpenVolumeMesh::NormalAttrib<VolumeMesh>& _normalAttrib,
104 OpenVolumeMesh::TexCoordAttrib<Vec2f> &_texcoordAttrib,
105 const MaterialNode* _matNode, BaseNode* _parent = 0,
106 std::string _name = "<VolumeMeshNode>");
107
109 ~VolumeMeshNodeT();
110
112 ACG_CLASSNAME(VolumeMeshNodeT)
113
114
115 DrawModes::DrawMode availableDrawModes() const override;
116
118 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) override;
119
121 void draw(GLState& _state, const DrawModes::DrawMode& _drawMode) override;
122
126 void getRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat) override;
127
129 void pick(GLState& _state, PickTarget _target) override;
130
131 // clear all cutplanes
132 void clear_cut_planes();
133
134 // add a new cutplane
135 void add_cut_plane(const Plane& _p);
136 void add_cut_plane(const Vec3d& _p, const Vec3d& _n, const Vec3d& _xsize, const Vec3d& _ysize);
137
138 // set shrinkage of cells
139 void set_scaling(double _scale);
140
141 // Get scaling
142 double scaling() const { return scale_; }
143
144 // Choose whether to visualize the boundary only
145 void set_boundary_only(bool _boundary);
146 bool boundary_only() const { return boundary_only_; }
147
148 // Set translucency factor
149 void set_translucency_factor(float _factor) { translucency_factor_ = _factor; }
150 float translucency_factor() const { return translucency_factor_; }
151
152 // Set whether to update the topology in next render pass
153 void set_topology_changed(bool _topology_changed);
154
155 // Set whether to update the geometry in next render pass
156 void set_geometry_changed(bool _geom_changed);
157
158 // Set whether to update the color in next render pass
159 void set_color_changed(bool _color_changed);
160
161 // Set whether to update the texture in next render pass
162 void set_texture_changed(bool _texture_changed);
163
164 // Set whether to update the selectopm in next render pass
165 void set_selection_changed(bool _selection_changed);
166
167 private:
168
170 void drawCells(GLState& _state, const DrawModes::DrawMode& _drawMode);
172 void drawFaces(GLState& _state, const DrawModes::DrawMode& _drawMode);
174 void drawEdges(GLState& _state, const DrawModes::DrawMode& _drawMode);
176 void drawVertices(GLState& _state, const DrawModes::DrawMode& _drawMode);
178 void drawSelection(GLState& _state, const DrawModes::DrawMode& _drawMode);
179
181 void getCellRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
183 void getFaceRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
185 void getEdgeRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
187 void getVertexRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
188
190 void getSelectionRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat);
191
193 void invalidateAllBuffers();
195 void invalidateAllDrawBuffers();
197 void invalidateAllPickingBuffers();
199 void invalidateAllSelectionBuffers();
200
202 void pickVertices(GLState& _state);
204 void pickEdges(GLState& _state, unsigned int _offset);
206 void pickFaces(GLState& _state, unsigned int _offset);
208 void pickCells(GLState& _state, unsigned int _offset);
210 void pickVerticesCompat(GLState& _state);
212 void pickEdgesCompat(GLState& _state, unsigned int _offset);
214 void pickFacesCompat(GLState& _state, unsigned int _offset);
216 void pickCellsCompat(GLState& _state, unsigned int _offset);
218 void pickCompat(GLState& _state, PickTarget _target);
219
221 void update_face_normals();
223 void update_vertex_normals();
224
226 VolumeMeshNodeT(const VolumeMeshNodeT& _rhs);
227
229 VolumeMeshNodeT& operator=(const VolumeMeshNodeT& _rhs);
230
231 private:
232
233 const VolumeMesh& mesh_;
234
235 double scale_;
236
237 // Flag that indicates whether to render the boundary faces only
238 bool boundary_only_;
239
240 // Translucency factor in [0, 1]
241 GLfloat translucency_factor_;
242
243 // Hold color of selection
244 ACG::Vec4f selection_color_;
245
246 OpenVolumeMesh::StatusAttrib& statusAttrib_;
247 OpenVolumeMesh::ColorAttrib<Vec4f>& colorAttrib_;
248 OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_;
249 OpenVolumeMesh::TexCoordAttrib<Vec2f>& texcoordAttrib_;
250
251 const MaterialNode* materialNode_;
252
253 VolumeMeshBufferManager<VolumeMeshT> cellsBufferManager_;
254 VolumeMeshBufferManager<VolumeMeshT> facesBufferManager_;
255 VolumeMeshBufferManager<VolumeMeshT> edgesBufferManager_;
256 VolumeMeshBufferManager<VolumeMeshT> verticesBufferManager_;
257
258 VolumeMeshBufferManager<VolumeMeshT> cellSelectionBufferManager_;
259 VolumeMeshBufferManager<VolumeMeshT> faceSelectionBufferManager_;
260 VolumeMeshBufferManager<VolumeMeshT> edgeSelectionBufferManager_;
261 VolumeMeshBufferManager<VolumeMeshT> vertexSelectionBufferManager_;
262
263 VolumeMeshBufferManager<VolumeMeshT> cellPickBufferManager_;
264 VolumeMeshBufferManager<VolumeMeshT> facePickBufferManager_;
265 VolumeMeshBufferManager<VolumeMeshT> edgePickBufferManager_;
266 VolumeMeshBufferManager<VolumeMeshT> vertexPickBufferManager_;
267
268 VolumeMeshDrawModesContainer drawModes_;
269
270 DrawModes::DrawMode lastDrawMode_;
271 DrawModes::DrawMode lastCellDrawMode_;
272 DrawModes::DrawMode lastFaceDrawMode_;
273 DrawModes::DrawMode lastEdgeDrawMode_;
274 DrawModes::DrawMode lastVertexDrawMode_;
275
276 PickTarget lastPickTarget_;
277
278 bool face_normals_calculated_;
279 bool vertex_normals_calculated_;
280
281 };
282
283 //=============================================================================
284 } // namespace SceneGraph
285 } // namespace ACG
286 //=============================================================================
287
ACG::SceneGraph::VolumeMeshNodeT::draw
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
draw lines and normals
Definition: VolumeMeshNodeT_impl.hh:603
OpenVolumeMesh::OpenVolumeMeshCell
Definition: BaseEntities.hh:118
ACG::SceneGraph::VolumeMeshNodeT::pickEdges
void pickEdges(GLState &_state, unsigned int _offset)
pick edges
Definition: VolumeMeshNodeT_impl.hh:1299
OpenVolumeMesh::TexCoordAttrib
Definition: TexCoordAttrib.hh:58
ACG::SceneGraph::VolumeMeshNodeT::pickVerticesCompat
void pickVerticesCompat(GLState &_state)
pick vertices using opengl compatibility profile
Definition: VolumeMeshNodeGLCompatT_impl.hh:188
ACG::GLState
Definition: GLState.hh:213
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_impl.hh:808
ACG::SceneGraph::VolumeMeshNodeT::drawFaces
void drawFaces(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the faces or halffaces of the mesh
Definition: VolumeMeshNodeT_impl.hh:305
ACG::SceneGraph::VolumeMeshNodeT::pickCompat
void pickCompat(GLState &_state, PickTarget _target)
picking using opengl compatibility profile
Definition: VolumeMeshNodeGLCompatT_impl.hh:53
OpenVolumeMesh::ColorAttrib
Definition: ColorAttrib.hh:58
ACG::SceneGraph::VolumeMeshNodeT::pickCellsCompat
void pickCellsCompat(GLState &_state, unsigned int _offset)
pick cells using opengl compatibility profile
Definition: VolumeMeshNodeGLCompatT_impl.hh:299
OpenVolumeMesh::StatusAttrib
Definition: StatusAttrib.hh:57
OpenVolumeMesh::HandleT< Entity::Vertex >
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::SceneGraph::VolumeMeshNodeT::pick
void pick(GLState &_state, PickTarget _target) override
picking
Definition: VolumeMeshNodeT_impl.hh:1120
ACG::SceneGraph::VolumeMeshNodeT::pickCells
void pickCells(GLState &_state, unsigned int _offset)
pick cells
Definition: VolumeMeshNodeT_impl.hh:1389
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_impl.hh:75
OpenMesh::VectorT
Definition: Vector11T.hh:83
VolumeMeshDrawModesContainer
This class provides easy access to DrawModes supported by OpenVolumeMesh.
Definition: VolumeMeshDrawModesContainer.hh:50
ACG::SceneGraph::VolumeMeshNodeT::operator=
VolumeMeshNodeT & operator=(const VolumeMeshNodeT &_rhs)
Assignment operator (not used)
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_impl.hh:743
ACG::SceneGraph::VolumeMeshNodeT::pickFacesCompat
void pickFacesCompat(GLState &_state, unsigned int _offset)
pick faces using opengl compatibility profile
Definition: VolumeMeshNodeGLCompatT_impl.hh:266
ACG::SceneGraph::MaterialNode
Definition: MaterialNode.hh:338
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_impl.hh:926
ACG::IRenderer
Definition: IRenderer.hh:78
SceneGraph
Definition: QtPrincipalAxisDialog.hh:67
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllSelectionBuffers
void invalidateAllSelectionBuffers()
invalidates all buffers used for rendering selected primitives
Definition: VolumeMeshNodeT_impl.hh:594
ACG::SceneGraph::PickTarget
PickTarget
What target to use for picking.
Definition: PickTarget.hh:73
ACG::SceneGraph::VolumeMeshNodeT::drawCells
void drawCells(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the cells of the mesh
Definition: VolumeMeshNodeT_impl.hh:242
ACG::SceneGraph::VolumeMeshNodeT::pickFaces
void pickFaces(GLState &_state, unsigned int _offset)
pick faces
Definition: VolumeMeshNodeT_impl.hh:1346
OpenVolumeMesh::OpenVolumeMeshFace
Definition: BaseEntities.hh:87
OpenVolumeMesh::NormalAttrib< VolumeMesh >
ACG::SceneGraph::VolumeMeshNodeT::update_vertex_normals
void update_vertex_normals()
updates vertex normals
Definition: VolumeMeshNodeT_impl.hh:1436
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
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_impl.hh:973
ACG::SceneGraph::VolumeMeshNodeT::pickEdgesCompat
void pickEdgesCompat(GLState &_state, unsigned int _offset)
pick edges using opengl compatibility profile
Definition: VolumeMeshNodeGLCompatT_impl.hh:229
ACG::SceneGraph::VolumeMeshNodeT::pickVertices
void pickVertices(GLState &_state)
pick vertices
Definition: VolumeMeshNodeT_impl.hh:1251
OpenVolumeMesh::OpenVolumeMeshEdge
Definition: BaseEntities.hh:52
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllDrawBuffers
void invalidateAllDrawBuffers()
invalidates all buffers used for normal rendering
Definition: VolumeMeshNodeT_impl.hh:576
ACG::SceneGraph::VolumeMeshNodeT::drawSelection
void drawSelection(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw selected primitves
Definition: VolumeMeshNodeT_impl.hh:492
VolumeMeshBufferManager< VolumeMeshT >
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:288
ACG::SceneGraph::VolumeMeshNodeT::~VolumeMeshNodeT
~VolumeMeshNodeT()
Destructor.
Definition: VolumeMeshNodeT_impl.hh:129
ACG::SceneGraph::VolumeMeshNodeT::availableDrawModes
DrawModes::DrawMode availableDrawModes() const override
static name of this class
Definition: VolumeMeshNodeT_impl.hh:150
ACG::SceneGraph::VolumeMeshNodeT::boundingBox
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
Definition: VolumeMeshNodeT_impl.hh:136
ACG::SceneGraph::VolumeMeshNodeT::getRenderObjects
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) override
Draws the object deferred.
Definition: VolumeMeshNodeT_impl.hh:1070
ACG::Geometry::Plane
Definition: PlaneType.hh:50
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_impl.hh:878
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllPickingBuffers
void invalidateAllPickingBuffers()
invalidates all buffers used for picking
Definition: VolumeMeshNodeT_impl.hh:585
ACG::SceneGraph::VolumeMeshNodeT::drawEdges
void drawEdges(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the edges or halfedges of the mesh
Definition: VolumeMeshNodeT_impl.hh:413
ACG::SceneGraph::VolumeMeshNodeT::invalidateAllBuffers
void invalidateAllBuffers()
invalidates all buffers
Definition: VolumeMeshNodeT_impl.hh:568
ACG::SceneGraph::VolumeMeshNodeT
Definition: VolumeMeshNode.hh:79
ACG::SceneGraph::VolumeMeshNodeT::drawVertices
void drawVertices(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the vertices of the mesh
Definition: VolumeMeshNodeT_impl.hh:456
ACG::SceneGraph::Material
Definition: MaterialNode.hh:79
ACG::SceneGraph::VolumeMeshNodeT::update_face_normals
void update_face_normals()
updates face normals
Definition: VolumeMeshNodeT_impl.hh:1427