65 #include <ACG/Scenegraph/DrawModes.hh> 74 template <
class MeshT >
103 template <
class MeshT >
124 template <
class MeshT >
135 if (
mesh_ != NULL) {
139 std::cerr <<
"Destructor error : Mesh already deleted" << std::endl;
159 template <
class MeshT >
162 if (
mesh_ != NULL) {
166 std::cerr <<
"Cleanup error : Triangle Mesh already deleted" << std::endl;
191 template <
class MeshT >
197 mesh_ =
new MeshT(*_mesh);
200 mesh_->request_vertex_normals();
201 mesh_->request_face_normals();
202 mesh_->request_vertex_status();
203 mesh_->request_halfedge_status();
204 mesh_->request_face_status();
205 mesh_->request_edge_status();
206 mesh_->request_vertex_colors();
207 mesh_->request_face_colors();
210 if ( OpenFlipper::Options::nogui() )
215 std::cerr <<
"Error when creating Mesh Object! manipulatorNode is NULL!" << std::endl;
224 QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
226 std::string shaderDirectory = std::string( shaderDir.toUtf8() );
227 shaderNode_->setShaderDir( shaderDirectory );
230 if ( QFile( shaderDir +
"Phong/Vertex.glsl").exists() && QFile( shaderDir +
"Phong/Fragment.glsl" ).exists() )
233 std::cerr <<
"Shader Files for Phong not found!" << std::endl;
310 template <
class MeshT >
315 if ( OpenFlipper::Options::nogui() )
318 std::string nodename = std::string(
"StatusNode for mesh " + _name.toUtf8() );
321 nodename = std::string(
"AreaNode for mesh " + _name.toUtf8() );
324 nodename = std::string(
"HandleNode for mesh " + _name.toUtf8() );
327 nodename = std::string(
"FeatureNode for mesh " + _name.toUtf8() );
330 nodename = std::string(
"TextureNode for mesh "+ _name.toUtf8() );
333 nodename = std::string(
"ShaderNode for mesh "+ _name.toUtf8() );
336 nodename = std::string(
"MeshNode for mesh " + _name.toUtf8() );
339 nodename = std::string(
"StatusViewNode for mesh " + _name.toUtf8() );
350 template <
class MeshT >
359 template <
class MeshT >
363 if ( OpenFlipper::Options::nogui() )
397 template <
class MeshT >
406 template <
class MeshT >
426 template <
class MeshT >
433 template <
class MeshT >
446 template <
class MeshT >
455 template <
class MeshT >
462 template <
class MeshT >
471 template <
class MeshT >
481 template <
class MeshT >
490 template <
class MeshT >
499 template <
class MeshT >
508 template <
class MeshT >
517 template <
class MeshT >
526 template <
class MeshT >
535 template <
class MeshT >
548 template <
class MeshT >
556 template <
class MeshT >
563 template <
class MeshT >
574 template <
class MeshT >
583 template <
class MeshT >
590 template <
class MeshT >
603 if ( _bit & HANDLEAREA )
608 template <
class MeshT >
613 template <
class MeshT >
620 if ( _bit & HANDLEAREA )
629 template <
class MeshT >
636 template <
class MeshT >
639 _bbMin =
ACG::Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
640 _bbMax =
ACG::Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
643 std::cerr <<
"Error: Bounding box computation via Scenegraph not available without gui" << std::endl;
656 template <
class MeshT >
664 std::string
filename = std::string( _filename.toUtf8() );
670 if (
dataType() ==
typeid(
"TriangleMesh") )
671 std::cerr <<
"Main Application : Read error for Triangle Mesh at "<< filename << std::endl;
672 if (
dataType() ==
typeid(
"PolyMesh") )
673 std::cerr <<
"Main Application : Read error for Poly Mesh\n";
677 mesh()->update_normals();
695 template <
class MeshT >
699 output +=
"========================================================================\n";
703 output +=
"Object Contains Triangle Mesh : ";
706 output +=
"Object Contains Poly Mesh : ";
708 output += QString::number(
mesh()->n_vertices() ) +
" vertices, ";
709 output += QString::number(
mesh()->n_edges() ) +=
" edges ";
710 output += QString::number(
mesh()->n_faces() ) +=
" faces.\n";
712 output +=
"========================================================================\n";
726 template <
class MeshT >
732 template <
class MeshT >
734 if ( OpenFlipper::Options::nogui())
745 template <
class MeshT >
754 template <
class MeshT >
759 std::cerr <<
"Bsps are only supported for triangle meshes." << std::endl;
772 typename MeshT::FIter f_it =
mesh()->faces_begin();
773 typename MeshT::FIter f_end =
mesh()->faces_end();
775 for (; f_it!=f_end; ++f_it)
785 template <
class MeshT >
797 template <
class MeshT >
808 template <
class MeshT >
817 template <
class MeshT >
void setMainGLContext()
Set current GL Context to main context.
void setDrawMesh(DrawMeshT< Mesh > *_drawmesh)
Set drawmesh.
void reserve(size_t _n)
Reserve memory for _n entries.
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
void setDataType(DataType _type)
void update_geometry()
the geometry of the mesh has changed
MeshT * mesh_
pointer to the mesh
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
VectorT< float, 4 > Vec4f
ACG::Vec4f selectionColor() const
get color for selection. returns -1 vector, if handle node does not exists
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
virtual void init(MeshT *_mesh=0)
Initialise current object, including all related nodes.
QString filename() const
return the filename of the object
void update_topology()
the topology of the mesh has changed
void enablePicking(bool _enable)
Enable or disable picking for this Node.
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
BoundingBoxNode * boundingBoxNode()
get a pointer to the bounding box node
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
Current bounding box.
bool selectionVisible()
return if the selections are currently visible
void update_color()
the colors of the mesh have changed
void setHandleColor(const ACG::Vec4f &_color)
set color for handles
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
bool featuresVisible()
return if the feature Node of the object is currently visible
void hideArea(StatusBits _bit, bool _hide)
Hide or show the area Nodes of the object.
void updateTexture()
Update Texture of all data structures.
void push_back(Handle _h)
Add a handle to the BSP.
QtTranslationManipulatorNode * manipulatorNode()
void setFromFileName(const QString &_filename)
bool areaVisible(StatusBits _bit)
Return if the selected areas are currently visible.
MeshT * mesh()
return a pointer to the mesh
BaseNode * primaryNode()
Status Node for a mesh, visualizing the selection state of a mesh.
void set_parent(BaseNode *_parent)
Set the parent of this node.
ACG::Vec4f handleColor() const
get color for handles. returns -1 vector, if handle node does not exists
MaterialNode * materialNode()
get a pointer to the materialnode
MeshObject(const MeshObject &_object)
copy constructor
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
void enablePicking(bool _enable)
ACG::SceneGraph::ShaderNode * shaderNode()
Return pointer to the shader node.
void setName(QString _name)
Set the name of the Object.
void updateFeatures()
Update Feature Visualization Node.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
OMTriangleBSP * resetTriangleBsp()
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
void updateTopology()
set topology invalid (updates everything)
void setFeatureColor(const ACG::Vec4f &_color)
set color for features
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode of the current mesh.
void updateGeometry()
set geometry invalid, topology and selection is kept
void deleteData()
Delete all data attached to this object ( calls delete on each object )
Hide this node, but draw children.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
void boundingBox(ACG::Vec3d &_bbMin, typename ACG::Vec3d &_bbMax)
Get the BoundingBox of this object.
void hideSelection(bool _hide)
Hide or show the selection Node of the object.
OMTriangleBSP * requestTriangleBsp()
bool pickingEnabled()
Check if picking is enabled for this Node.
void updateModelingRegions()
Call this function to update the modeling regions.
bool hasBsp() const
check if a BSP has been computed and is valid
void invalidateTriangleBsp()
std::string name() const
Returns: name of node (needs not be unique)
void updateGeometry()
Update Geometry of all data structures.
void update_textures()
force an texture update
bool picked(uint _node_idx)
detect if the node has been picked
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
ACG::Vec4f featureColor() const
get color for features. returns -1 vector, if handle node does not exists
DrawMode NONE
not a valid draw mode
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
virtual ~MeshObject()
destructor
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
bool loadMesh(QString _filename)
Load a mesh from the given file.
virtual QString getObjectinfo()
Get all Info for the Object as a string.
void updateColor()
Update Colors of all data structures.
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
void build(unsigned int _max_handles, unsigned int _max_depth)
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void updateSelection()
set selection invalid (Only selection changed, rest is kept)
DrawMeshT< Mesh > * getDrawMesh()
Get DrawMesh instance.
void hideFeatures(bool _hide)
Hide or show the feature Node of the object.
QString getObjectinfo()
Get all Info for the Object as a string.
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
void setAreaColor(const ACG::Vec4f &_color)
set color for areas
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
VectorT< double, 3 > Vec3d
void updateSelection()
Call this function to update the modeling regions.
DataType dataType() const
virtual void cleanup()
Reset current object, including all related nodes.
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
ACG::Vec4f areaColor() const
get color for areas. returns -1 vector, if handle node does not exists
void updateTopology()
Update Topology of all data structures.
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
void setSelectionColor(const ACG::Vec4f &_color)
set color for selection