49#define VOLUMEMESHOBJECTT_CC
53#include "VolumeMeshObject.hh"
56#include <ACG/Scenegraph/DrawModes.hh>
60#include "VolumeMeshDrawModesContainer.hh"
62#include <ACG/Scenegraph/BoundingBoxNode.hh>
71 statusAttrib_(*mesh_),
73 normalAttrib_(*mesh_),
74 texcoordAttrib_(*mesh_),
88 statusAttrib_(*mesh_),
89 colorAttrib_(*mesh_,
ACG::
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
90 normalAttrib_(*mesh_),
91 texcoordAttrib_(*mesh_),
149 if(OpenFlipper::Options::nogui())
160 if(manipulatorNode() == NULL)
161 std::cerr <<
"Error when creating volume mesh object! Manipulator node is NULL!" << std::endl;
163 if(materialNode() == NULL)
164 std::cerr <<
"Error when creating mesh object! Material node is NULL!" << std::endl;
166 materialNode()->set_point_size(12.0f);
168 QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
170 std::string shaderDirectory = std::string( shaderDir.toUtf8() );
171 shaderNode_->setShaderDir( shaderDirectory );
173 if(!OpenFlipper::Options::coreProfile())
175 if ( QFile( shaderDir +
"Phong/Vertex.glsl").exists() && QFile( shaderDir +
"Phong/Fragment.glsl" ).exists() )
177 shaderNode_->setShader(drawModes.cellsPhongShaded,
"Phong/Vertex.glsl" ,
"Phong/Fragment.glsl" );
178 shaderNode_->setShader(drawModes.facesPhongShaded,
"Phong/Vertex.glsl" ,
"Phong/Fragment.glsl" );
179 shaderNode_->setShader(drawModes.halffacesPhongShaded,
"Phong/Vertex.glsl" ,
"Phong/Fragment.glsl" );
182 std::cerr <<
"Shader Files for Phong not found!" << std::endl;
201 if(OpenFlipper::Options::nogui())
204 std::string meshnodename = std::string(
"VolumeMeshNode for mesh " + _name.toUtf8());
205 meshNode_->name(meshnodename);
207 std::string shadernodename = std::string(
"ShaderNode for mesh " + _name.toUtf8());
208 shaderNode_->name(shadernodename);
210 std::string texturenodename = std::string(
"TextureNode for mesh " + _name.toUtf8());
211 textureNode_->name(texturenodename);
239 if(OpenFlipper::Options::nogui())
270 meshNode_->set_selection_changed(
true);
278 normalAttrib_.update_face_normals();
281 meshNode_->set_geometry_changed(
true);
290 meshNode_->set_color_changed(
true);
298 meshNode_->set_texture_changed(
true);
306 meshNode_->set_topology_changed(
true);
344 _bbMin =
ACG::Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
345 _bbMax =
ACG::Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
346 meshNode_->boundingBox(_bbMin, _bbMax);
348 std::cerr <<
"Error: Bounding box computation via Scenegraph not available without gui." << std::endl;
365 output +=
"========================================================================\n";
368 if(dataType(
typeId(
"PolyhedralMesh")))
369 output +=
"Object Contains Polyhedral Mesh : ";
371 if(dataType(
typeId(
"HexahedralMesh")))
372 output +=
"Object Contains Hexahedral Mesh : ";
374 output += QString::number(mesh()->n_vertices()) +
" vertices\n";
375 output += QString::number(mesh()->n_edges()) +=
" edges\n";
376 output += QString::number(mesh()->n_halfedges()) +=
" half-edges\n";
377 output += QString::number(mesh()->n_faces()) +=
" faces\n";
378 output += QString::number(mesh()->n_halffaces()) +=
" half-faces\n";
379 output += QString::number(mesh()->n_cells()) +=
" cells\n";
381 output +=
"========================================================================\n";
397 return (_node_idx == meshNode_->id());
402 if(OpenFlipper::Options::nogui())
405 meshNode_->enablePicking(_enable);
406 shaderNode_->enablePicking(_enable);
411 return meshNode_->pickingEnabled();
419 return boundingBoxNode();
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
virtual void setName(QString _name) override
path to the file from which the object is loaded ( defaults to "." )
virtual void cleanup() override
virtual QString getObjectinfo()
Get all Info for the Object as a string.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void setDataType(DataType _type)
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
This class provides easy access to DrawModes supported by OpenVolumeMesh.
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
bool pickingEnabled()
Check if picking is enabled for this Node.
QString getObjectinfo()
Get all Info for the Object as a string.
MeshT * mesh()
return a pointer to the mesh
virtual void cleanup()
Reset current object, including all related nodes.
ACG::SceneGraph::TextureNode * textureNode()
Return pointer to the texture node.
void updateGeometry()
Update Geometry of all data structures.
bool picked(unsigned int _node_idx)
detect if the node has been picked
virtual void init()
Initialise current object, including all related nodes.
VolumeMeshObject(const VolumeMeshObject &_object)
copy constructor
void updateColor()
Update Colors of all data structures.
void boundingBox(ACG::Vec3d &_bbMin, typename ACG::Vec3d &_bbMax)
Get the BoundingBox of this object.
void recreateAttributes()
BaseNode * primaryNode()
Scenegraph Mesh Node.
ACG::SceneGraph::ShaderNode * shaderNode()
Return pointer to the shader node.
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
void updateTopology()
Update Topology of all data structures.
void updateTexture()
Update Texture of all data structures.
void enablePicking(bool _enable)
Enable or disable picking for this Node.
void setName(QString _name)
Set the name of the Object.
void updateSelection()
Call this function to update the selection.
virtual ~VolumeMeshObject()
destructor
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(2048))
Textures have changed.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(8))
Topology updated.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(4))
Geometry updated.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1024))
Colors have changed.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(16))
Selection updated.
Namespace providing different geometric functions concerning angles.
VectorT< double, 3 > Vec3d
void setMainGLContext()
Set current GL Context to main context.