Developer Documentation
MeshObjectT_impl.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 
44 
45 
46 
47  //=============================================================================
48  //
49  // MyTypes
50  //
51  //=============================================================================
52 
53  #define MESHOBJECT_C
54 
55 
56  //== INCLUDES =================================================================
57 
59  #include <ACG/Scenegraph/DrawModes.hh>
62 
63  #include <ACG/Scenegraph/ManipulatorNode.hh>
64  #include <ACG/Scenegraph/BoundingBoxNode.hh>
65  #include <ACG/QtScenegraph/QtTranslationManipulatorNode.hh>
66 
67 
68  //== TYPEDEFS =================================================================
69 
70  //== CLASS DEFINITION =========================================================
71 
72  template < class MeshT >
74  BaseObjectData(_object),
75  statusNode_(0),
76  areaNode_(0),
77  handleNode_(0),
78  featureNode_(0),
79  meshNode_(0),
80  textureNode_(0),
81  shaderNode_(0),
82  statusView_(0),
83  triangle_bsp_(0)
84  {
85  init(_object.mesh_);
86 
87 
88  setName( name() );
89 
90 // textures_ = _object.textures_;
91 // textureNames_ = _object.textureNames_;
92  }
93 
101  template < class MeshT >
103  BaseObjectData(),
104  mesh_(0),
105  statusNode_(0),
106  areaNode_(0),
107  handleNode_(0),
108  featureNode_(0),
109  meshNode_(0),
110  textureNode_(0),
111  shaderNode_(0),
112  statusView_(0),
113  triangle_bsp_(0)
114  {
115  setDataType(_typeId);
116  init();
117  }
118 
122  template < class MeshT >
124  {
125  // Delete the data attached to this object ( this will remove all perObject data)
126  // Not the best way to do it but it will work.
127  // This is only necessary if people use references to the mesh below and
128  // they do something with the mesh in the destructor of their
129  // perObjectData.
130  deleteData();
131 
132  // Delete the Mesh only, if this object contains a mesh
133  if ( mesh_ != NULL) {
134  delete mesh_;
135  mesh_ = NULL;
136  } else {
137  std::cerr << "Destructor error : Mesh already deleted" << std::endl;
138  }
139 
140  if ( triangle_bsp_ != 0 )
141  delete triangle_bsp_;
142  triangle_bsp_ = 0;
143 
144  // No need to delete the scenegraph Nodes as this will be managed by baseplugin
145  areaNode_ = 0;
146  handleNode_ = 0;
147  featureNode_ = 0;
148  meshNode_ = 0;
149  textureNode_ = 0;
150  shaderNode_ = 0;
151  statusView_ = 0;
152  }
153 
157  template < class MeshT >
159  // Delete the Mesh only, if this object contains a mesh
160  if ( mesh_ != NULL) {
161  delete mesh_;
162  mesh_ = NULL;
163  } else {
164  std::cerr << "Cleanup error : Triangle Mesh already deleted" << std::endl;
165  }
166 
167  if ( triangle_bsp_ != 0 )
168  delete triangle_bsp_;
169  triangle_bsp_ = 0;
170 
172 
173  statusNode_ = 0;
174  areaNode_ = 0;
175  handleNode_ = 0;
176  featureNode_ = 0;
177  textureNode_ = 0;
178  shaderNode_ = 0;
179  meshNode_ = 0;
180  statusView_ = 0;
181 
182  init();
183 
184  }
185 
189  template < class MeshT >
190  void MeshObject< MeshT >::init(MeshT* _mesh) {
191 
192  if ( _mesh == 0 )
193  mesh_ = new MeshT();
194  else
195  mesh_ = new MeshT(*_mesh);
196 
197  // Prepare mesh and request required properties
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();
206 
207  // Only initialize scenegraph nodes when we initialized a gui!!
208  if ( OpenFlipper::Options::nogui() )
209  return;
210 
211  // This should never happen!
212  if ( manipulatorNode() == NULL)
213  std::cerr << "Error when creating Mesh Object! manipulatorNode is NULL!" << std::endl;
214 
215 
216  textureNode_ = new ACG::SceneGraph::EnvMapNode(materialNode(),"NEW TextureNode for ", true, GL_LINEAR_MIPMAP_LINEAR );
217 
218  shaderNode_ = new ACG::SceneGraph::ShaderNode(textureNode() , "NEW ShaderNode for ");
219 
221 
222  QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
223 
224  std::string shaderDirectory = std::string( shaderDir.toUtf8() );
225  shaderNode_->setShaderDir( shaderDirectory );
226 
227  if(!OpenFlipper::Options::coreProfile())
228  {
229  if ( QFile( shaderDir + "Phong/Vertex.glsl").exists() && QFile( shaderDir + "Phong/Fragment.glsl" ).exists() )
230  shaderNode_->setShader(ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED,"Phong/Vertex.glsl" , "Phong/Fragment.glsl" );
231  else
232  std::cerr << "Shader Files for Phong not found!" << std::endl;
233  }
234 
235  // Node showing selection
236  statusNode_ = new ACG::SceneGraph::SelectionNodeT<MeshT>(*mesh_, 0, "NEW StatusNode for mesh " );
237  statusNode_->set_point_size(4.0);
238  statusNode_->set_color(ACG::Vec4f(1.0f,0.0f,0.0f,1.0f));
239  statusNode_->set_base_color(ACG::Vec4f(1.0f,0.0f,0.0f,1.0f));
240  // Status nodes are handled specially by their StatusViewNodeT parent which
241  // is why they get a NONE draw mode.
243 
244  // Node showing modeling region
245  areaNode_ = new ACG::SceneGraph::StatusNodeT<MeshT, AreaNodeMod<MeshT> >(*mesh_, 0, "NEW AreaNode for mesh ");
246  areaNode_->set_round_points(true);
247  areaNode_->enable_alpha_test(0.5);
248  areaNode_->set_point_size(7.0);
249  areaNode_->set_color(ACG::Vec4f(0.4f, 0.4f, 1.0f, 1.0f));
250  // Status nodes are handled specially by their StatusViewNodeT parent which
251  // is why they get a NONE draw mode.
253 
254  // Node showing handle region
255  handleNode_ = new ACG::SceneGraph::StatusNodeT<MeshT, HandleNodeMod<MeshT> >(*mesh_, 0, "NEW HandleNode for mesh ");
256  handleNode_->set_round_points(true);
257  handleNode_->enable_alpha_test(0.5);
258  handleNode_->set_line_width(2.0);
259  handleNode_->set_point_size(7.0);
260  handleNode_->set_color(ACG::Vec4f(0.2f, 1.0f, 0.2f, 1.0f));
261  // Status nodes are handled specially by their StatusViewNodeT parent which
262  // is why they get a NONE draw mode.
264 
265  // Node showing feature selection
266  featureNode_ = new ACG::SceneGraph::StatusNodeT<MeshT, FeatureNodeMod<MeshT> >(*mesh_, 0, "NEW FeatureNode for mesh ");
267  featureNode_->set_round_points(true);
268  featureNode_->enable_alpha_test(0.5);
269  featureNode_->set_line_width(2.0);
270  featureNode_->set_point_size(7.0);
271  featureNode_->set_color(ACG::Vec4f(1.0f, 0.2f, 1.0f, 1.0f));
272  featureNode_->set_base_color(ACG::Vec4f(1.0f, 0.2f, 1.0f, 1.0f));
273  // Status nodes are handled specially by their StatusViewNodeT parent which
274  // is why they get a NONE draw mode.
276 
277  // Link the status nodes to the draw mesh of the mesh below them to reuse its buffers
278  if (meshNode_) {
283  }
284 
285  // Node rendering selections in correct order
286  statusView_ = new ACG::SceneGraph::StatusViewNodeT<MeshT>(manipulatorNode(), "NEW StatusViewNode for mesh ",
287  statusNode_,
288  areaNode_,
289  handleNode_,
290  featureNode_);
291 
292  // make StatusViewNode parent of status nodes
293  statusNode_->set_parent(statusView_);
294  areaNode_->set_parent(statusView_);
295  handleNode_->set_parent(statusView_);
296  featureNode_->set_parent(statusView_);
297 
298  // Update all nodes
299  update();
300  }
301 
302  // ===============================================================================
303  // Name/Path Handling
304  // ===============================================================================
305 
309  template < class MeshT >
310  void MeshObject< MeshT >::setName( QString _name ) {
312 
313  // No update when gui is not active
314  if ( OpenFlipper::Options::nogui() )
315  return;
316 
317  std::string nodename = std::string("StatusNode for mesh " + _name.toUtf8() );
318  statusNode_->name( nodename );
319 
320  nodename = std::string("AreaNode for mesh " + _name.toUtf8() );
321  areaNode_->name( nodename );
322 
323  nodename = std::string("HandleNode for mesh " + _name.toUtf8() );
324  handleNode_->name( nodename );
325 
326  nodename = std::string("FeatureNode for mesh " + _name.toUtf8() );
327  featureNode_->name( nodename );
328 
329  nodename = std::string("TextureNode for mesh "+ _name.toUtf8() );
330  textureNode_->name( nodename );
331 
332  nodename = std::string("ShaderNode for mesh "+ _name.toUtf8() );
333  shaderNode_->name( nodename );
334 
335  nodename = std::string("MeshNode for mesh " + _name.toUtf8() );
336  meshNode_->name( nodename );
337 
338  nodename = std::string("StatusViewNode for mesh " + _name.toUtf8() );
339  statusView_->name( nodename );
340  }
341 
342  // ===============================================================================
343  // Content
344  // ===============================================================================
345 
349  template < class MeshT >
351  return mesh_;
352  }
353 
357  template < class MeshT >
358  const MeshT* MeshObject< MeshT >::mesh() const {
359  return mesh_;
360  }
361 
366  template < class MeshT >
368 
369  // No update necessary if no gui
370  if ( OpenFlipper::Options::nogui() )
371  return;
372 
374 
375  if ( _type.contains(UPDATE_ALL) || _type.contains(UPDATE_TOPOLOGY) ){
376  updateGeometry();
377  updateColor();
378  updateTopology();
379  updateSelection();
380  updateFeatures();
382  updateTexture();
383  }
384  else
385  {
386  if ( _type.contains(UPDATE_GEOMETRY) ) {
387  updateGeometry();
388  }
389  if ( _type.contains(UPDATE_SELECTION) ) {
390  updateSelection();
391  updateFeatures();
393  }
394  if ( _type.contains(UPDATE_COLOR) ) {
395  updateColor();
396  }
397  if ( _type.contains(UPDATE_TEXTURE)) {
398  updateTexture();
399  }
400  }
401  }
402 
404  template < class MeshT >
406 
407  if ( statusNode_ ){
409  }
410  }
411 
413  template < class MeshT >
415 
416  if ( meshNode_ ) {
418 
419  // Also update the selection nodes here.
420  // These nodes store their positions based on the mesh.
421  // So they would be at the wrong position afterwards
426 
427  }
428 
430  }
431 
433  template < class MeshT >
435  if ( meshNode_ )
437  }
438 
440  template < class MeshT >
442  if ( meshNode_ ) {
448  }
450  }
451 
453  template < class MeshT >
455  if ( areaNode_ && handleNode_ ) {
458  }
459  }
460 
462  template < class MeshT >
464  if ( featureNode_ )
466  }
467 
469  template < class MeshT >
472  }
473 
474 
475  // ===============================================================================
476  // Visualization
477  // ===============================================================================
478  template < class MeshT >
480  {
481  if (statusNode_)
482  {
483  statusNode_->set_color(_color);
484  statusNode_->set_base_color(_color);
485  }
486  }
487 
488  template < class MeshT >
490  {
491  if (statusNode_)
492  return statusNode_->base_color();
493  else
494  return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
495  }
496 
497  template < class MeshT >
499  {
500  if (areaNode_)
501  {
502  areaNode_->set_color(_color);
503  areaNode_->set_base_color(_color);
504  }
505  }
506  template < class MeshT >
508  {
509  if (areaNode_)
510  return areaNode_->base_color();
511  else
512  return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
513  }
514 
515  template < class MeshT >
517  {
518  if (featureNode_)
519  {
520  featureNode_->set_color(_color);
521  featureNode_->set_base_color(_color);
522  }
523  }
524  template < class MeshT >
526  {
527  if (featureNode_)
528  return featureNode_->base_color();
529  else
530  return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
531  }
532 
533  template < class MeshT >
535  {
536  if (handleNode_)
537  {
538  handleNode_->set_color(_color);
539  handleNode_->set_base_color(_color);
540  }
541  }
542  template < class MeshT >
544  {
545  if (handleNode_)
546  return handleNode_->base_color();
547  else
548  return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
549  }
550 
551 
555  template < class MeshT >
557  return textureNode_;
558  }
559 
563  template < class MeshT >
565  return shaderNode_;
566  }
567 
570  template < class MeshT >
572 
573  if ( _hide ) {
575  } else {
577  }
578 
579  }
580 
581  template < class MeshT >
583  if ( _hide ) {
585  } else {
587  }
588  }
589 
590  template < class MeshT >
592  return ( featureNode_->status() == ACG::SceneGraph::BaseNode::Active );
593  }
594 
597  template < class MeshT >
598  void MeshObject< MeshT >::hideArea( StatusBits _bit, bool _hide ) {
600 
601  if ( _hide ) {
603  }else
605 
606  if ( _bit & AREA ) {
607  areaNode_->set_status( status );
608  }
609 
610  if ( _bit & HANDLEAREA )
611  handleNode_->set_status( status );
612 
613  }
614 
615  template < class MeshT >
617  return ( statusNode_->status() == ACG::SceneGraph::BaseNode::Active );
618  }
619 
620  template < class MeshT >
621  bool MeshObject< MeshT >::areaVisible( StatusBits _bit ) {
622  bool status = true;
623 
624  if ( _bit & AREA )
625  status &= ( areaNode_->status() == ACG::SceneGraph::BaseNode::Active );
626 
627  if ( _bit & HANDLEAREA )
628  status &= ( handleNode_->status() == ACG::SceneGraph::BaseNode::Active );
629 
630  return status;
631  }
632 
636  template < class MeshT >
638  return meshNode_;
639  }
640 
643  template < class MeshT >
645  if ( meshNode_ ) {
646  _bbMin = ACG::Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
647  _bbMax = ACG::Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
648  meshNode_->boundingBox(_bbMin,_bbMax);
649  } else {
650  std::cerr << "Error: Bounding box computation via Scenegraph not available without gui" << std::endl;
651  }
652  }
653 
654  // ===============================================================================
655  // Load/Save
656  // ===============================================================================
657 
663  template < class MeshT >
664  bool MeshObject< MeshT >::loadMesh(QString _filename) {
665 
666  setFromFileName(_filename);
667 
668  // call the local function to update names
669  setName( name() );
670 
671  std::string filename = std::string( _filename.toUtf8() );
672 
673  // load file
674  bool ok = OpenMesh::IO::read_mesh( (*mesh()) , filename );
675  if (!ok)
676  {
677  if ( dataType() == typeId("TriangleMesh") )
678  std::cerr << "Main Application : Read error for Triangle Mesh at "<< filename << std::endl;
679  if ( dataType() == typeId("PolyMesh") )
680  std::cerr << "Main Application : Read error for Poly Mesh\n";
681  return false;
682  }
683 
684  mesh()->update_normals();
685 
686  update();
687 
688  show();
689 
690  return true;
691  }
692 
693  // ===============================================================================
694  // Object information
695  // ===============================================================================
696 
702  template < class MeshT >
704  QString output;
705 
706  output += "========================================================================\n";
707  output += BaseObjectData::getObjectinfo();
708 
709  if ( dataType( typeId("TriangleMesh") ) )
710  output += "Object Contains Triangle Mesh : ";
711 
712  if ( dataType( typeId("PolyMesh") ) )
713  output += "Object Contains Poly Mesh : ";
714 
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";
718 
719  output += "========================================================================\n";
720  return output;
721  }
722 
723  // ===============================================================================
724  // Picking
725  // ===============================================================================
726 
733  template < class MeshT >
734  bool MeshObject< MeshT >::picked( uint _node_idx ) {
735  return ( _node_idx == meshNode_->id() );
736  }
737 
738 
739  template < class MeshT >
740  void MeshObject< MeshT >::enablePicking( bool _enable ) {
741  if ( OpenFlipper::Options::nogui())
742  return;
743 
744  meshNode_->enablePicking( _enable );
745  areaNode_->enablePicking( _enable );
746  handleNode_->enablePicking( _enable );
747  featureNode_->enablePicking( _enable );
748  textureNode_->enablePicking( _enable );
749  shaderNode_->enablePicking( _enable );
750  }
751 
752  template < class MeshT >
754  return meshNode_->pickingEnabled();
755  }
756 
757  // ===============================================================================
758  // Octree
759  // ===============================================================================
760 
761  template < class MeshT >
764 
765  if ( ! dataType( typeId("TriangleMesh") ) ) {
766  std::cerr << "Bsps are only supported for triangle meshes." << std::endl;
767  return 0;
768  }
769 
770  // Create the tree if needed.
771  if ( triangle_bsp_ == 0 )
772  {
773  // create Triangle BSP
774  triangle_bsp_ = new OMTriangleBSP( *mesh() );
775 
776  // build Triangle BSP
777  triangle_bsp_->reserve(mesh()->n_faces());
778 
779  typename MeshT::FIter f_it = mesh()->faces_begin();
780  typename MeshT::FIter f_end = mesh()->faces_end();
781 
782  for (; f_it!=f_end; ++f_it)
783  triangle_bsp_->push_back(*f_it);
784 
785  triangle_bsp_->build(10, 100); //max vertices per leaf 10, max depth 100
786  }
787 
788  // return pointer to triangle bsp
789  return triangle_bsp_;
790  }
791 
792  template < class MeshT >
795  if ( triangle_bsp_ != 0 )
796  {
797  delete triangle_bsp_;
798  triangle_bsp_ = 0;
799  }
800 
801  return requestTriangleBsp();
802  }
803 
804  template < class MeshT >
805  void
807  if ( triangle_bsp_ != 0 )
808  {
809  delete triangle_bsp_;
810  triangle_bsp_ = 0;
811  }
812  }
813 
814 
815  template < class MeshT >
816  bool
818  return triangle_bsp_ != 0;
819  }
820 
821 
822  //=============================================================================
823 
824  template < class MeshT >
825  BaseNode*
827  return boundingBoxNode();
828  }
829 
830  //=============================================================================
831 
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
Definition: DrawModes.cc:83
void updateSelection()
Call this function to update the modeling regions.
Update type class.
Definition: UpdateType.hh:60
void updateFeatures()
Update Feature Visualization Node.
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:244
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.
Definition: MeshObjectT.hh:288
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 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)
Definition: BaseObject.cc:233
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.
Definition: MeshObjectT.hh:352
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.
Definition: MeshObjectT.hh:297
OMTriangleBSP * requestTriangleBsp()
void deleteData()
Delete all data attached to this object ( calls delete on each object )
Definition: BaseObject.cc:812
virtual ~MeshObject()
destructor
VectorT< float, 4 > Vec4f
Definition: VectorT.hh:138
StatusMode
Status modi.
Definition: BaseNode.hh:389
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
void setFromFileName(const QString &_filename)
Definition: BaseObject.cc:716
Hide this node, but draw children.
Definition: BaseNode.hh:394
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.
virtual void cleanup()
MeshT * mesh_
pointer to the mesh
Definition: MeshObjectT.hh:155
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.
Definition: BaseObject.cc:730
void setSelectionColor(const ACG::Vec4f &_color)
set color for selection
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
Definition: MeshObjectT.hh:294
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT.hh:282
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:121
QString filename() const
return the filename of the object
Definition: BaseObject.cc:706
ACG::Vec4f selectionColor() const
get color for selection. returns -1 vector, if handle node does not exists
DrawMode NONE
not a valid draw mode
Definition: DrawModes.cc:71
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.
Definition: UpdateType.cc:104
void setMainGLContext()
Set current GL Context to main context.
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
Definition: MeshObjectT.hh:303
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.
Definition: MeshObjectT.hh:285
void setName(QString _name)
Set the name of the Object.
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
Definition: MeshObjectT.hh:300
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.
Predefined datatypes.
Definition: DataTypes.hh:83
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.
Definition: MeshObjectT.hh:390
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.
Draw node & children.
Definition: BaseNode.hh:392
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.
Definition: MeshIO.hh:112
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
Definition: MeshObjectT.hh:291
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.
Definition: Types.cc:139
DataType dataType() const
Definition: BaseObject.cc:229
void set_parent(BaseNode *_parent)
Set the parent of this node.
Definition: BaseNode.cc:146
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.