56 #define VOLUMEMESHOBJECTT_CC
60 #include "VolumeMeshObject.hh"
63 #include <ACG/Scenegraph/DrawModes.hh>
67 #include "VolumeMeshDrawModesContainer.hh"
76 statusAttrib_(*mesh_),
78 normalAttrib_(*mesh_),
79 texcoordAttrib_(*mesh_),
93 statusAttrib_(*mesh_),
94 colorAttrib_(*mesh_,
ACG::
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
95 normalAttrib_(*mesh_),
96 texcoordAttrib_(*mesh_),
106 template<
class MeshT>
125 template<
class MeshT>
140 template<
class MeshT>
144 if(OpenFlipper::Options::nogui())
155 if(manipulatorNode() == NULL)
156 std::cerr <<
"Error when creating volume mesh object! Manipulator node is NULL!" << std::endl;
158 if(materialNode() == NULL)
159 std::cerr <<
"Error when creating mesh object! Material node is NULL!" << std::endl;
161 materialNode()->set_point_size(12.0f);
163 QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
165 std::string shaderDirectory = std::string( shaderDir.toUtf8() );
166 shaderNode_->setShaderDir( shaderDirectory );
168 if ( QFile( shaderDir +
"Phong/Vertex.glsl").exists() && QFile( shaderDir +
"Phong/Fragment.glsl" ).exists() )
170 shaderNode_->setShader(drawModes.cellsPhongShaded,
"Phong/Vertex.glsl" ,
"Phong/Fragment.glsl" );
171 shaderNode_->setShader(drawModes.facesPhongShaded,
"Phong/Vertex.glsl" ,
"Phong/Fragment.glsl" );
172 shaderNode_->setShader(drawModes.halffacesPhongShaded,
"Phong/Vertex.glsl" ,
"Phong/Fragment.glsl" );
175 std::cerr <<
"Shader Files for Phong not found!" << std::endl;
189 template<
class MeshT>
194 if(OpenFlipper::Options::nogui())
197 std::string meshnodename = std::string(
"VolumeMeshNode for mesh " + _name.toUtf8());
198 meshNode_->name(meshnodename);
200 std::string shadernodename = std::string(
"ShaderNode for mesh " + _name.toUtf8());
201 shaderNode_->name(shadernodename);
203 std::string texturenodename = std::string(
"TextureNode for mesh " + _name.toUtf8());
204 textureNode_->name(texturenodename);
214 template<
class MeshT>
223 template<
class MeshT>
227 if(OpenFlipper::Options::nogui())
254 template<
class MeshT>
258 meshNode_->set_selection_changed(
true);
263 template<
class MeshT>
266 normalAttrib_.update_face_normals();
269 meshNode_->set_geometry_changed(
true);
274 template<
class MeshT>
278 meshNode_->set_color_changed(
true);
282 template<
class MeshT>
286 meshNode_->set_texture_changed(
true);
291 template<
class MeshT>
294 meshNode_->set_topology_changed(
true);
298 template<
class MeshT>
304 template<
class MeshT>
310 template<
class MeshT>
322 template<
class MeshT>
329 template<
class MeshT>
332 _bbMin =
ACG::Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
333 _bbMax =
ACG::Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
334 meshNode_->boundingBox(_bbMin, _bbMax);
336 std::cerr <<
"Error: Bounding box computation via Scenegraph not available without gui." << std::endl;
349 template<
class MeshT>
353 output +=
"========================================================================\n";
356 if(dataType(
typeId(
"PolyhedralMesh")))
357 output +=
"Object Contains Polyhedral Mesh : ";
359 if(dataType(
typeId(
"HexahedralMesh")))
360 output +=
"Object Contains Hexahedral Mesh : ";
362 output += QString::number(mesh()->n_vertices()) +
" vertices\n";
363 output += QString::number(mesh()->n_edges()) +=
" edges\n";
364 output += QString::number(mesh()->n_halfedges()) +=
" half-edges\n";
365 output += QString::number(mesh()->n_faces()) +=
" faces\n";
366 output += QString::number(mesh()->n_halffaces()) +=
" half-faces\n";
367 output += QString::number(mesh()->n_cells()) +=
" cells\n";
369 output +=
"========================================================================\n";
383 template<
class MeshT>
385 return (_node_idx == meshNode_->id());
388 template<
class MeshT>
390 if(OpenFlipper::Options::nogui())
393 meshNode_->enablePicking(_enable);
394 shaderNode_->enablePicking(_enable);
397 template<
class MeshT>
399 return meshNode_->pickingEnabled();
404 template<
class MeshT>
407 return boundingBoxNode();
void updateGeometry()
Update Geometry of all data structures.
void boundingBox(ACG::Vec3d &_bbMin, typename ACG::Vec3d &_bbMax)
Get the BoundingBox of this object.
BaseNode * primaryNode()
Scenegraph Mesh Node.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
This class provides easy access to DrawModes supported by OpenVolumeMesh.
QString getObjectinfo()
Get all Info for the Object as a string.
virtual QString getObjectinfo()
Get all Info for the Object as a string.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
Namespace providing different geometric functions concerning angles.
bool pickingEnabled()
Check if picking is enabled for this Node.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
void updateTexture()
Update Texture of all data structures.
void updateColor()
Update Colors of all data structures.
ACG::SceneGraph::TextureNode * textureNode()
Return pointer to the texture node.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
virtual void cleanup()
Reset current object, including all related nodes.
MeshT * mesh()
return a pointer to the mesh
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
ACG::SceneGraph::ShaderNode * shaderNode()
Return pointer to the shader node.
void updateTopology()
Update Topology of all data structures.
VolumeMeshObject(const VolumeMeshObject &_object)
copy constructor
virtual ~VolumeMeshObject()
destructor
void updateSelection()
Call this function to update the selection.
void setDataType(DataType _type)
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
bool picked(unsigned int _node_idx)
detect if the node has been picked
void enablePicking(bool _enable)
Enable or disable picking for this Node.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
VectorT< double, 3 > Vec3d
void setMainGLContext()
Set current GL Context to main context.
virtual void init()
Initialise current object, including all related nodes.
void setName(QString _name)
Set the name of the Object.