59 #include <ACG/Scenegraph/DrawModes.hh> 63 #include <ACG/Scenegraph/ManipulatorNode.hh> 64 #include <ACG/Scenegraph/BoundingBoxNode.hh> 65 #include <ACG/QtScenegraph/QtTranslationManipulatorNode.hh> 72 template <
class MeshT >
101 template <
class MeshT >
122 template <
class MeshT >
133 if (
mesh_ != NULL) {
137 std::cerr <<
"Destructor error : Mesh already deleted" << std::endl;
157 template <
class MeshT >
160 if (
mesh_ != NULL) {
164 std::cerr <<
"Cleanup error : Triangle Mesh already deleted" << std::endl;
189 template <
class MeshT >
195 mesh_ =
new MeshT(*_mesh);
198 mesh_->request_vertex_normals();
199 mesh_->request_face_normals();
200 mesh_->request_vertex_status();
201 mesh_->request_halfedge_status();
202 mesh_->request_face_status();
203 mesh_->request_edge_status();
204 mesh_->request_vertex_colors();
205 mesh_->request_face_colors();
208 if ( OpenFlipper::Options::nogui() )
213 std::cerr <<
"Error when creating Mesh Object! manipulatorNode is NULL!" << std::endl;
222 QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
224 std::string shaderDirectory = std::string( shaderDir.toUtf8() );
225 shaderNode_->setShaderDir( shaderDirectory );
227 if(!OpenFlipper::Options::coreProfile())
229 if ( QFile( shaderDir +
"Phong/Vertex.glsl").exists() && QFile( shaderDir +
"Phong/Fragment.glsl" ).exists() )
232 std::cerr <<
"Shader Files for Phong not found!" << std::endl;
309 template <
class MeshT >
314 if ( OpenFlipper::Options::nogui() )
317 std::string nodename = std::string(
"StatusNode for mesh " + _name.toUtf8() );
320 nodename = std::string(
"AreaNode for mesh " + _name.toUtf8() );
323 nodename = std::string(
"HandleNode for mesh " + _name.toUtf8() );
326 nodename = std::string(
"FeatureNode for mesh " + _name.toUtf8() );
329 nodename = std::string(
"TextureNode for mesh "+ _name.toUtf8() );
332 nodename = std::string(
"ShaderNode for mesh "+ _name.toUtf8() );
335 nodename = std::string(
"MeshNode for mesh " + _name.toUtf8() );
338 nodename = std::string(
"StatusViewNode for mesh " + _name.toUtf8() );
349 template <
class MeshT >
357 template <
class MeshT >
366 template <
class MeshT >
370 if ( OpenFlipper::Options::nogui() )
404 template <
class MeshT >
413 template <
class MeshT >
433 template <
class MeshT >
440 template <
class MeshT >
453 template <
class MeshT >
462 template <
class MeshT >
469 template <
class MeshT >
478 template <
class MeshT >
488 template <
class MeshT >
497 template <
class MeshT >
506 template <
class MeshT >
515 template <
class MeshT >
524 template <
class MeshT >
533 template <
class MeshT >
542 template <
class MeshT >
555 template <
class MeshT >
563 template <
class MeshT >
570 template <
class MeshT >
581 template <
class MeshT >
590 template <
class MeshT >
597 template <
class MeshT >
610 if ( _bit & HANDLEAREA )
615 template <
class MeshT >
620 template <
class MeshT >
627 if ( _bit & HANDLEAREA )
636 template <
class MeshT >
643 template <
class MeshT >
646 _bbMin =
ACG::Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
647 _bbMax =
ACG::Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
650 std::cerr <<
"Error: Bounding box computation via Scenegraph not available without gui" << std::endl;
663 template <
class MeshT >
671 std::string
filename = std::string( _filename.toUtf8() );
678 std::cerr <<
"Main Application : Read error for Triangle Mesh at "<< filename << std::endl;
680 std::cerr <<
"Main Application : Read error for Poly Mesh\n";
684 mesh()->update_normals();
702 template <
class MeshT >
706 output +=
"========================================================================\n";
710 output +=
"Object Contains Triangle Mesh : ";
713 output +=
"Object Contains Poly Mesh : ";
715 output += QString::number(
mesh()->n_vertices() ) +
" vertices, ";
716 output += QString::number(
mesh()->n_edges() ) +=
" edges ";
717 output += QString::number(
mesh()->n_faces() ) +=
" faces.\n";
719 output +=
"========================================================================\n";
733 template <
class MeshT >
739 template <
class MeshT >
741 if ( OpenFlipper::Options::nogui())
752 template <
class MeshT >
761 template <
class MeshT >
766 std::cerr <<
"Bsps are only supported for triangle meshes." << std::endl;
779 typename MeshT::FIter f_it =
mesh()->faces_begin();
780 typename MeshT::FIter f_end =
mesh()->faces_end();
782 for (; f_it!=f_end; ++f_it)
792 template <
class MeshT >
804 template <
class MeshT >
815 template <
class MeshT >
824 template <
class MeshT >
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
void updateSelection()
Call this function to update the modeling regions.
void updateFeatures()
Update Feature Visualization Node.
virtual QString getObjectinfo()
Get all Info for the Object as a string.
void enablePicking(bool _enable)
Enable or disable picking for this Node.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool picked(uint _node_idx)
detect if the node has been picked
void update_color()
the colors of the mesh have changed
void update_textures()
force an texture update
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
bool areaVisible(StatusBits _bit)
Return if the selected areas are currently visible.
void hideSelection(bool _hide)
Hide or show the selection Node of the object.
ACG::Vec4f areaColor() const
get color for areas. returns -1 vector, if handle node does not exists
void updateSelection()
set selection invalid (Only selection changed, rest is kept)
void enablePicking(bool _enable)
void setFeatureColor(const ACG::Vec4f &_color)
set color for features
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
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode of the current mesh.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
void setDataType(DataType _type)
bool hasBsp() const
check if a BSP has been computed and is valid
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
void updateGeometry()
set geometry invalid, topology and selection is kept
std::string name() const
Returns: name of node (needs not be unique)
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
OMTriangleBSP * requestTriangleBsp()
void deleteData()
Delete all data attached to this object ( calls delete on each object )
virtual ~MeshObject()
destructor
VectorT< float, 4 > Vec4f
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
void setFromFileName(const QString &_filename)
Hide this node, but draw children.
virtual void init(MeshT *_mesh=0)
Initialise current object, including all related nodes.
BaseNode * primaryNode()
Status Node for a mesh, visualizing the selection state of a mesh.
void hideFeatures(bool _hide)
Hide or show the feature Node of the object.
MeshT * mesh_
pointer to the mesh
MeshT * mesh()
return a pointer to the mesh
void updateColor()
Update Colors of all data structures.
OMTriangleBSP * resetTriangleBsp()
void updateModelingRegions()
Call this function to update the modeling regions.
bool loadMesh(QString _filename)
Load a mesh from the given file.
void update_geometry()
the geometry of the mesh has changed
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void setSelectionColor(const ACG::Vec4f &_color)
set color for selection
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
VectorT< double, 3 > Vec3d
QString filename() const
return the filename of the object
ACG::Vec4f selectionColor() const
get color for selection. returns -1 vector, if handle node does not exists
DrawMode NONE
not a valid draw mode
void updateGeometry()
Update Geometry of all data structures.
ACG::Vec4f featureColor() const
get color for features. returns -1 vector, if handle node does not exists
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
void setMainGLContext()
Set current GL Context to main context.
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
void update_topology()
the topology of the mesh has changed
void hideArea(StatusBits _bit, bool _hide)
Hide or show the area Nodes of the object.
void setDrawMesh(DrawMeshT< Mesh > *_drawmesh)
Set drawmesh.
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
void invalidateTriangleBsp()
BoundingBoxNode * boundingBoxNode()
get a pointer to the bounding box node
MeshObject(const MeshObject &_object)
copy constructor
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
void setName(QString _name)
Set the name of the Object.
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
void push_back(Handle _h)
Add a handle to the BSP.
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
Current bounding box.
void reserve(size_t _n)
Reserve memory for _n entries.
void updateTopology()
set topology invalid (updates everything)
bool selectionVisible()
return if the selections are currently visible
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
bool featuresVisible()
return if the feature Node of the object is currently visible
void updateTopology()
Update Topology of all data structures.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
QString getObjectinfo()
Get all Info for the Object as a string.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
bool pickingEnabled()
Check if picking is enabled for this Node.
void updateTexture()
Update Texture of all data structures.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
void build(unsigned int _max_handles, unsigned int _max_depth)
void setAreaColor(const ACG::Vec4f &_color)
set color for areas
virtual void cleanup()
Reset current object, including all related nodes.
ACG::SceneGraph::ShaderNode * shaderNode()
Return pointer to the shader node.
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
DataType dataType() const
void set_parent(BaseNode *_parent)
Set the parent of this node.
void setHandleColor(const ACG::Vec4f &_color)
set color for handles
QtTranslationManipulatorNode * manipulatorNode()
DrawMeshT< Mesh > * getDrawMesh()
Get DrawMesh instance.
void boundingBox(ACG::Vec3d &_bbMin, typename ACG::Vec3d &_bbMax)
Get the BoundingBox of this object.