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 >
virtual QString getObjectinfo()
Get all Info for the Object as a string.
BaseNode * primaryNode()
Status Node for a mesh, visualizing the selection state of a mesh.
bool areaVisible(StatusBits _bit)
Return if the selected areas are currently visible.
void updateFeatures()
Update Feature Visualization Node.
void invalidateTriangleBsp()
void updateGeometry()
Update Geometry of all data structures.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
void deleteData()
Delete all data attached to this object ( calls delete on each object )
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
OMTriangleBSP * requestTriangleBsp()
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
void hideSelection(bool _hide)
Hide or show the selection Node of the object.
virtual void setName(QString _name) override
path to the file from which the object is loaded ( defaults to "." )
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
virtual ~MeshObject()
destructor
ACG::Vec4f selectionColor() const
get color for selection. returns -1 vector, if handle node does not exists
void hideFeatures(bool _hide)
Hide or show the feature Node of the object.
void updateSelection()
Call this function to update the modeling regions.
VectorT< float, 4 > Vec4f
void setDrawMesh(DrawMeshT< Mesh > *_drawmesh)
Set drawmesh.
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
void setHandleColor(const ACG::Vec4f &_color)
set color for handles
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
Current bounding box.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
bool loadMesh(QString _filename)
Load a mesh from the given file.
void update_geometry()
the geometry of the mesh has changed
void hideArea(StatusBits _bit, bool _hide)
Hide or show the area Nodes of the object.
QString filename() const
return the filename of the object
void updateTexture()
Update Texture of all data structures.
void build(unsigned int _max_handles, unsigned int _max_depth)
void update_textures()
force an texture update
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
MeshT * mesh()
return a pointer to the mesh
virtual void init(MeshT *_mesh=0)
Initialise current object, including all related nodes.
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
void updateSelection()
set selection invalid (Only selection changed, rest is kept)
QtTranslationManipulatorNode * manipulatorNode()
void setName(QString _name)
Set the name of the Object.
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
virtual void cleanup() override
void push_back(Handle _h)
Add a handle to the BSP.
void updateGeometry()
set geometry invalid, topology and selection is kept
OMTriangleBSP * resetTriangleBsp()
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
bool selectionVisible()
return if the selections are currently visible
BoundingBoxNode * boundingBoxNode()
get a pointer to the bounding box node
void updateColor()
Update Colors of all data structures.
bool featuresVisible()
return if the feature Node of the object is currently visible
ACG::Vec4f areaColor() const
get color for areas. returns -1 vector, if handle node does not exists
void update_topology()
the topology of the mesh has changed
void setAreaColor(const ACG::Vec4f &_color)
set color for areas
QString name() const
return the name of the object. The name defaults to NONAME if unset.
ACG::Vec4f handleColor() const
get color for handles. returns -1 vector, if handle node does not exists
QString getObjectinfo()
Get all Info for the Object as a string.
void update_color()
the colors of the mesh have changed
DrawMode NONE
not a valid draw mode
virtual void cleanup()
Reset current object, including all related nodes.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
void set_parent(BaseNode *_parent)
Set the parent of this node.
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
void reserve(size_t _n)
Reserve memory for _n entries.
void enablePicking(bool _enable)
Enable or disable picking for this Node.
MaterialNode * materialNode()
get a pointer to the materialnode
MeshT * mesh_
pointer to the mesh
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode of the current mesh.
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
void enablePicking(bool _enable)
void boundingBox(ACG::Vec3d &_bbMin, typename ACG::Vec3d &_bbMax)
Get the BoundingBox of this object.
ACG::Vec4f featureColor() const
get color for features. returns -1 vector, if handle node does not exists
void updateTopology()
Update Topology of all data structures.
void setFeatureColor(const ACG::Vec4f &_color)
set color for features
DrawMeshT< Mesh > * getDrawMesh()
Get DrawMesh instance.
void setSelectionColor(const ACG::Vec4f &_color)
set color for selection
void setMainGLContext()
Set current GL Context to main context.
Hide this node, but draw children.
bool pickingEnabled()
Check if picking is enabled for this Node.
std::string name() const
Returns: name of node (needs not be unique)
void setDataType(DataType _type)
MeshObject(const MeshObject &_object)
copy constructor
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
void updateModelingRegions()
Call this function to update the modeling regions.
void updateTopology()
set topology invalid (updates everything)
DataType dataType() const
void setFromFileName(const QString &_filename)
bool picked(uint _node_idx)
detect if the node has been picked
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
VectorT< double, 3 > Vec3d
bool hasBsp() const
check if a BSP has been computed and is valid
ACG::SceneGraph::ShaderNode * shaderNode()
Return pointer to the shader node.