Developer Documentation

VolumeMeshObject.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 #include <ACG/Utils/SmartPointer.hh>
46
47 #include <ACG/Math/VectorT.hh>
48 #include <ACG/Scenegraph/SeparatorNode.hh>
49 #include <ACG/Scenegraph/StatusNodesT.hh>
50 #include <ACG/Scenegraph/ShaderNode.hh>
51 #include <ACG/Scenegraph/TextureNode.hh>
52 #include <OpenFlipper/common/ObjectTypeDLLDefines.hh>
53 #include <OpenFlipper/common/BaseObjectData.hh>
54 #include <ObjectTypes/VolumeMeshObject/VolumeMeshNode.hh>
55
56 #include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
57 #include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
58 #include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
59 #include <OpenVolumeMesh/Attribs/TexCoordAttrib.hh>
60
61
62 template<class MeshT>
63 class OBJECTTYPEDLLEXPORTONLY VolumeMeshObject : public BaseObjectData {
64
65 friend class TypePolyhedralMeshPlugin;
66 friend class TypeHexahedralMeshPlugin;
67 friend class TypeTetrahedralMeshPlugin;
68
69 public:
70
75 VolumeMeshObject(const VolumeMeshObject& _object);
76
84 explicit VolumeMeshObject(DataType _typeId);
85
87 virtual ~VolumeMeshObject();
88
90 virtual void cleanup();
91
92 protected:
93
95 virtual void init();
96
97 //===========================================================================
100 //===========================================================================
101 public:
102
104 void setName( QString _name );
105
108 //===========================================================================
111 //===========================================================================
112
113 public:
115 MeshT* mesh();
116 const MeshT* mesh() const;
117
121 BaseObject* copy();
122
123 typedef OpenVolumeMesh::ColorAttrib<ACG::Vec4f> ColorAttrib;
124 typedef OpenVolumeMesh::NormalAttrib<MeshT> NormalAttrib;
125 typedef OpenVolumeMesh::StatusAttrib StatusAttrib;
126 typedef OpenVolumeMesh::TexCoordAttrib<ACG::Vec2f> TexCoordAttrib;
127
128 const StatusAttrib& status() const { return statusAttrib_; }
129 StatusAttrib& status() { return statusAttrib_; }
130
131 const ColorAttrib& colors() const { return colorAttrib_; }
132 ColorAttrib& colors() { return colorAttrib_; }
133
134 const NormalAttrib& normals() const { return normalAttrib_; }
135 NormalAttrib& normals() { return normalAttrib_; }
136
137 const TexCoordAttrib& texcoords() const { return texcoordAttrib_; }
138 TexCoordAttrib& texcoords() { return texcoordAttrib_; }
139
140 private:
141 ptr::shared_ptr<MeshT> mesh_;
142
143 StatusAttrib statusAttrib_;
144
145 ColorAttrib colorAttrib_;
146
147 NormalAttrib normalAttrib_;
148
149 TexCoordAttrib texcoordAttrib_;
150
153 //===========================================================================
160 //===========================================================================
161 protected:
162
164 virtual void update(UpdateType _type = UPDATE_ALL);
165
167 void updateSelection();
168
170 void updateGeometry();
171
173 void updateColor();
174
176 void updateTexture();
177
179 void updateTopology();
180
182 //===========================================================================
185 //===========================================================================
186
187 public:
188
190 ACG::SceneGraph::TextureNode* textureNode();
191
193 ACG::SceneGraph::ShaderNode* shaderNode();
194
196 ACG::SceneGraph::VolumeMeshNodeT<MeshT>* meshNode();
197
199 void boundingBox(ACG::Vec3d& _bbMin, typename ACG::Vec3d& _bbMax);
200
201 BaseNode* primaryNode();
202
203 private:
204
206 ACG::SceneGraph::VolumeMeshNodeT<MeshT>* meshNode_;
207
209 ACG::SceneGraph::ShaderNode* shaderNode_;
210
212 ACG::SceneGraph::TextureNode* textureNode_;
213
216 //===========================================================================
219 //===========================================================================
220 public:
222 QString getObjectinfo();
223
226 //===========================================================================
229 //===========================================================================
230 public:
231
233 bool picked(unsigned int _node_idx);
234
236 void enablePicking(bool _enable);
237
239 bool pickingEnabled();
240
242 };
243
244 //=============================================================================
UpdateType
Update type class.
Definition: UpdateType.hh:60
BaseObject::getObjectinfo
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:244
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
BaseObjectData::update
virtual void update(UpdateType _type=UPDATE_ALL)
This function is called to update the object.
Definition: BaseObjectData.cc:329
VolumeMeshObject::meshNode_
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
Definition: VolumeMeshObject.hh:206
BaseObjectData::primaryNode
virtual BaseNode * primaryNode()
Definition: BaseObjectData.cc:251
ObjectTypeDLLDefines.hh
OpenVolumeMesh::NormalAttrib< MeshT >
VolumeMeshObject::normals
NormalAttrib & normals()
return a pointer to the mesh
Definition: VolumeMeshObject.hh:135
VolumeMeshObject::texcoords
const TexCoordAttrib & texcoords() const
return a pointer to the mesh
Definition: VolumeMeshObject.hh:137
VolumeMeshObject::normalAttrib_
NormalAttrib normalAttrib_
return a pointer to the mesh
Definition: VolumeMeshObject.hh:147
VolumeMeshObject::texcoordAttrib_
TexCoordAttrib texcoordAttrib_
return a pointer to the mesh
Definition: VolumeMeshObject.hh:149
VolumeMeshObject::statusAttrib_
StatusAttrib statusAttrib_
return a pointer to the mesh
Definition: VolumeMeshObject.hh:143
OpenVolumeMesh::StatusAttrib
Definition: StatusAttrib.hh:57
BaseObjectData::cleanup
virtual void cleanup()
Definition: BaseObjectData.cc:102
BaseObjectData.hh
VolumeMeshObject::status
const StatusAttrib & status() const
return a pointer to the mesh
Definition: VolumeMeshObject.hh:128
BaseObjectData::pickingEnabled
virtual bool pickingEnabled()
Definition: BaseObjectData.cc:318
VolumeMeshObject::TexCoordAttrib
OpenVolumeMesh::TexCoordAttrib< ACG::Vec2f > TexCoordAttrib
return a pointer to the mesh
Definition: VolumeMeshObject.hh:126
VolumeMeshObject::StatusAttrib
OpenVolumeMesh::StatusAttrib StatusAttrib
return a pointer to the mesh
Definition: VolumeMeshObject.hh:125
VolumeMeshObject
Definition: VolumeMeshObject.hh:63
VolumeMeshObject::status
StatusAttrib & status()
return a pointer to the mesh
Definition: VolumeMeshObject.hh:129
VolumeMeshObject::texcoords
TexCoordAttrib & texcoords()
return a pointer to the mesh
Definition: VolumeMeshObject.hh:138
VolumeMeshObject::shaderNode_
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph Shader Node.
Definition: VolumeMeshObject.hh:209
BaseObjectData::setName
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObjectData.cc:355
OpenVolumeMesh::ColorAttrib< ACG::Vec4f >
TypePolyhedralMeshPlugin
Definition: TypePolyhedralMesh.hh:58
VolumeMeshObject::colorAttrib_
ColorAttrib colorAttrib_
return a pointer to the mesh
Definition: VolumeMeshObject.hh:145
VolumeMeshObject::normals
const NormalAttrib & normals() const
return a pointer to the mesh
Definition: VolumeMeshObject.hh:134
VolumeMeshObject::colors
ColorAttrib & colors()
return a pointer to the mesh
Definition: VolumeMeshObject.hh:132
VolumeMeshObject::ColorAttrib
OpenVolumeMesh::ColorAttrib< ACG::Vec4f > ColorAttrib
return a pointer to the mesh
Definition: VolumeMeshObject.hh:123
VolumeMeshObject::NormalAttrib
OpenVolumeMesh::NormalAttrib< MeshT > NormalAttrib
return a pointer to the mesh
Definition: VolumeMeshObject.hh:124
ACG::SceneGraph::ShaderNode
Definition: ShaderNode.hh:81
BaseObjectData::enablePicking
virtual void enablePicking(bool _enable)
Definition: BaseObjectData.cc:315
ACG::SceneGraph::VolumeMeshNodeT< MeshT >
VolumeMeshObject::mesh_
ptr::shared_ptr< MeshT > mesh_
return a pointer to the mesh
Definition: VolumeMeshObject.hh:141
OpenVolumeMesh::TexCoordAttrib< ACG::Vec2f >
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
VolumeMeshObject::colors
const ColorAttrib & colors() const
return a pointer to the mesh
Definition: VolumeMeshObject.hh:131
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
BaseObject
Definition: BaseObject.hh:82
OpenMesh::VectorT
Definition: Vector11T.hh:83
TypeHexahedralMeshPlugin
Definition: TypeHexahedralMesh.hh:56
BaseObject::copy
virtual BaseObject * copy()
Returns a full copy of the object.
Definition: BaseObject.cc:769
BaseObjectData::picked
virtual bool picked(uint _node_idx)
detect if the node has been picked
Definition: BaseObjectData.cc:311
BaseObjectData
Definition: BaseObjectData.hh:102
TypeTetrahedralMeshPlugin
Definition: TypeTetrahedralMesh.hh:55
VolumeMeshObject::textureNode_
ACG::SceneGraph::TextureNode * textureNode_
Scenegraph Texture Node.
Definition: VolumeMeshObject.hh:212
ACG::SceneGraph::TextureNode
Definition: TextureNode.hh:87
BaseObjectData::shaderNode
virtual ACG::SceneGraph::ShaderNode * shaderNode()
Definition: BaseObjectData.cc:259