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
58 #include <OpenFlipper/common/Types.hh>
59 #include <ACG/Scenegraph/DrawModes.hh>
60 #include <OpenFlipper/common/GlobalOptions.hh>
61 #include <OpenFlipper/BasePlugin/PluginFunctions.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 >
73 MeshObject< MeshT >::MeshObject(const MeshObject& _object) :
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 >
102 MeshObject< MeshT >::MeshObject( DataType _typeId ) :
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 >
123 MeshObject< MeshT >::~MeshObject()
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 >
158 void MeshObject< MeshT >::cleanup() {
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
171 BaseObjectData::cleanup();
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
220 meshNode_ = new ACG::SceneGraph::MeshNodeT<MeshT>(*mesh_, shaderNode_, "NEW MeshNode");
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.
242 statusNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
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.
252 areaNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
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.
263 handleNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
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.
275 featureNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
276
277 // Link the status nodes to the draw mesh of the mesh below them to reuse its buffers
278 if (meshNode_) {
279 statusNode_->setDrawMesh(meshNode_->getDrawMesh());
280 featureNode_->setDrawMesh(meshNode_->getDrawMesh());
281 areaNode_->setDrawMesh(meshNode_->getDrawMesh());
282 handleNode_->setDrawMesh(meshNode_->getDrawMesh());
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 ) {
311 BaseObjectData::setName(_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 >
350 MeshT* MeshObject< MeshT >::mesh() {
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 >
367 void MeshObject< MeshT >::update(UpdateType _type) {
368
369 // No update necessary if no gui
370 if ( OpenFlipper::Options::nogui() )
371 return;
372
373 PluginFunctions::setMainGLContext();
374
375 if ( _type.contains(UPDATE_ALL) || _type.contains(UPDATE_TOPOLOGY) ){
376 updateGeometry();
377 updateColor();
378 updateTopology();
379 updateSelection();
380 updateFeatures();
381 updateModelingRegions();
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();
392 updateModelingRegions();
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 >
405 void MeshObject< MeshT >::updateSelection() {
406
407 if ( statusNode_ ){
408 statusNode_->updateSelection();
409 }
410 }
411
413 template < class MeshT >
414 void MeshObject< MeshT >::updateGeometry() {
415
416 if ( meshNode_ ) {
417 meshNode_->update_geometry();
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
422 statusNode_->updateGeometry();
423 featureNode_->updateGeometry();
424 areaNode_->updateGeometry();
425 handleNode_->updateGeometry();
426
427 }
428
429 invalidateTriangleBsp();
430 }
431
433 template < class MeshT >
434 void MeshObject< MeshT >::updateColor() {
435 if ( meshNode_ )
436 meshNode_->update_color();
437 }
438
440 template < class MeshT >
441 void MeshObject< MeshT >::updateTopology() {
442 if ( meshNode_ ) {
443 meshNode_->update_topology();
444 statusNode_->updateTopology();
445 featureNode_->updateTopology();
446 areaNode_->updateTopology();
447 handleNode_->updateTopology();
448 }
449 invalidateTriangleBsp();
450 }
451
453 template < class MeshT >
454 void MeshObject< MeshT >::updateModelingRegions() {
455 if ( areaNode_ && handleNode_ ) {
456 areaNode_->updateSelection();
457 handleNode_->updateSelection();
458 }
459 }
460
462 template < class MeshT >
463 void MeshObject< MeshT >::updateFeatures() {
464 if ( featureNode_ )
465 featureNode_->updateSelection();
466 }
467
469 template < class MeshT >
470 void MeshObject< MeshT >::updateTexture() {
471 meshNode_->update_textures();
472 }
473
474
475 // ===============================================================================
476 // Visualization
477 // ===============================================================================
478 template < class MeshT >
479 void MeshObject< MeshT >::setSelectionColor(const ACG::Vec4f& _color)
480 {
481 if (statusNode_)
482 {
483 statusNode_->set_color(_color);
484 statusNode_->set_base_color(_color);
485 }
486 }
487
488 template < class MeshT >
489 ACG::Vec4f MeshObject< MeshT >::selectionColor() const
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 >
498 void MeshObject< MeshT >::setAreaColor(const ACG::Vec4f& _color)
499 {
500 if (areaNode_)
501 {
502 areaNode_->set_color(_color);
503 areaNode_->set_base_color(_color);
504 }
505 }
506 template < class MeshT >
507 ACG::Vec4f MeshObject< MeshT >::areaColor() const
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 >
516 void MeshObject< MeshT >::setFeatureColor(const ACG::Vec4f& _color)
517 {
518 if (featureNode_)
519 {
520 featureNode_->set_color(_color);
521 featureNode_->set_base_color(_color);
522 }
523 }
524 template < class MeshT >
525 ACG::Vec4f MeshObject< MeshT >::featureColor() const
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 >
534 void MeshObject< MeshT >::setHandleColor(const ACG::Vec4f& _color)
535 {
536 if (handleNode_)
537 {
538 handleNode_->set_color(_color);
539 handleNode_->set_base_color(_color);
540 }
541 }
542 template < class MeshT >
543 ACG::Vec4f MeshObject< MeshT >::handleColor() const
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 >
556 ACG::SceneGraph::EnvMapNode* MeshObject< MeshT >::textureNode() {
557 return textureNode_;
558 }
559
563 template < class MeshT >
564 ACG::SceneGraph::ShaderNode* MeshObject< MeshT >::shaderNode() {
565 return shaderNode_;
566 }
567
570 template < class MeshT >
571 void MeshObject< MeshT >::hideSelection( bool _hide ) {
572
573 if ( _hide ) {
574 statusNode_->set_status( ACG::SceneGraph::BaseNode::HideNode );
575 } else {
576 statusNode_->set_status( ACG::SceneGraph::BaseNode::Active );
577 }
578
579 }
580
581 template < class MeshT >
582 void MeshObject< MeshT >::hideFeatures( bool _hide ) {
583 if ( _hide ) {
584 featureNode_->set_status( ACG::SceneGraph::BaseNode::HideNode );
585 } else {
586 featureNode_->set_status( ACG::SceneGraph::BaseNode::Active );
587 }
588 }
589
590 template < class MeshT >
591 bool MeshObject< MeshT >::featuresVisible( ) {
592 return ( featureNode_->status() == ACG::SceneGraph::BaseNode::Active );
593 }
594
597 template < class MeshT >
598 void MeshObject< MeshT >::hideArea( StatusBits _bit, bool _hide ) {
599 ACG::SceneGraph::BaseNode::StatusMode status;
600
601 if ( _hide ) {
602 status = ACG::SceneGraph::BaseNode::HideNode;
603 }else
604 status = ACG::SceneGraph::BaseNode::Active;
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 >
616 bool MeshObject< MeshT >::selectionVisible() {
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 >
637 ACG::SceneGraph::MeshNodeT<MeshT>* MeshObject< MeshT >::meshNode() {
638 return meshNode_;
639 }
640
643 template < class MeshT >
644 void MeshObject< MeshT >::boundingBox( ACG::Vec3d& _bbMin , ACG::Vec3d& _bbMax ) {
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 >
703 QString MeshObject< MeshT >::getObjectinfo() {
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 >
753 bool MeshObject< MeshT >::pickingEnabled() {
754 return meshNode_->pickingEnabled();
755 }
756
757 // ===============================================================================
758 // Octree
759 // ===============================================================================
760
761 template < class MeshT >
762 typename MeshObject< MeshT >::OMTriangleBSP*
763 MeshObject< MeshT >::requestTriangleBsp() {
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 >
793 typename MeshObject< MeshT >::OMTriangleBSP*
794 MeshObject< MeshT >::resetTriangleBsp() {
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
806 MeshObject< MeshT >::invalidateTriangleBsp() {
807 if ( triangle_bsp_ != 0 )
808 {
809 delete triangle_bsp_;
810 triangle_bsp_ = 0;
811 }
812 }
813
814
815 template < class MeshT >
816 bool
817 MeshObject< MeshT >::hasBsp() const {
818 return triangle_bsp_ != 0;
819 }
820
821
822 //=============================================================================
823
824 template < class MeshT >
825 BaseNode*
826 MeshObject< MeshT >::primaryNode(){
827 return boundingBoxNode();
828 }
829
830 //=============================================================================
831
BaseObject::getObjectinfo
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:244
ACG::SceneGraph::EnvMapNode
Definition: EnvMapNode.hh:77
MeshObject::primaryNode
BaseNode * primaryNode()
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT_impl.hh:826
MeshObject::areaVisible
bool areaVisible(StatusBits _bit)
Return if the selected areas are currently visible.
Definition: MeshObjectT_impl.hh:621
MeshObject::updateFeatures
void updateFeatures()
Update Feature Visualization Node.
Definition: MeshObjectT_impl.hh:463
MeshObject::invalidateTriangleBsp
void invalidateTriangleBsp()
Definition: MeshObjectT_impl.hh:806
MeshObject::updateGeometry
void updateGeometry()
Update Geometry of all data structures.
Definition: MeshObjectT_impl.hh:414
UPDATE_GEOMETRY
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
BaseObject::deleteData
void deleteData()
Delete all data attached to this object ( calls delete on each object )
Definition: BaseObject.cc:812
MeshObject::meshNode_
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode_
Scenegraph Mesh Node.
Definition: MeshObjectT.hh:294
MeshObject::requestTriangleBsp
OMTriangleBSP * requestTriangleBsp()
Definition: MeshObjectT_impl.hh:763
BaseObjectData::show
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
Definition: BaseObjectData.cc:188
MeshObject::hideSelection
void hideSelection(bool _hide)
Hide or show the selection Node of the object.
Definition: MeshObjectT_impl.hh:571
BaseObjectData::setName
virtual void setName(QString _name) override
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObjectData.cc:355
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
MeshObject::~MeshObject
virtual ~MeshObject()
destructor
Definition: MeshObjectT_impl.hh:123
MeshObject::selectionColor
ACG::Vec4f selectionColor() const
get color for selection. returns -1 vector, if handle node does not exists
Definition: MeshObjectT_impl.hh:489
MeshObject::hideFeatures
void hideFeatures(bool _hide)
Hide or show the feature Node of the object.
Definition: MeshObjectT_impl.hh:582
MeshObject::updateSelection
void updateSelection()
Call this function to update the modeling regions.
Definition: MeshObjectT_impl.hh:405
ACG::Vec4f
VectorT< float, 4 > Vec4f
Definition: VectorT.hh:138
ACG::SceneGraph::StatusNodeT::setDrawMesh
void setDrawMesh(DrawMeshT< Mesh > *_drawmesh)
Set drawmesh.
Definition: StatusNodesT_impl.hh:765
GlobalOptions.hh
MeshObject::shaderNode_
ACG::SceneGraph::ShaderNode * shaderNode_
Scenegraph ShaderNode.
Definition: MeshObjectT.hh:300
MeshObject::setHandleColor
void setHandleColor(const ACG::Vec4f &_color)
set color for handles
Definition: MeshObjectT_impl.hh:534
ACG::SceneGraph::MeshNodeT::boundingBox
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
Current bounding box.
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::StatusNodeT
Definition: StatusNodesT.hh:207
UPDATE_SELECTION
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
ACG::SceneGraph::ShaderNode
Definition: ShaderNode.hh:81
MeshObject::loadMesh
bool loadMesh(QString _filename)
Load a mesh from the given file.
Definition: MeshObjectT_impl.hh:664
ACG::SceneGraph::MeshNodeT::update_geometry
void update_geometry()
the geometry of the mesh has changed
MeshObject::hideArea
void hideArea(StatusBits _bit, bool _hide)
Hide or show the area Nodes of the object.
Definition: MeshObjectT_impl.hh:598
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
PluginFunctions.hh
BaseObject::filename
QString filename() const
return the filename of the object
Definition: BaseObject.cc:706
MeshObject::updateTexture
void updateTexture()
Update Texture of all data structures.
Definition: MeshObjectT_impl.hh:470
TriangleBSPCoreT::build
void build(unsigned int _max_handles, unsigned int _max_depth)
Definition: TriangleBSPCoreT_impl.hh:63
ACG::SceneGraph::BaseNode::Active
Draw node & children.
Definition: BaseNode.hh:392
ACG::SceneGraph::ACG::SceneGraph::BaseNode::id
unsigned int id() const
Definition: MeshNode2T_impl.hh:423
ACG::SceneGraph::MeshNodeT::update_textures
void update_textures()
force an texture update
MeshObject::featureNode_
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode_
Feature selection Vis.
Definition: MeshObjectT.hh:291
MeshObject::mesh
MeshT * mesh()
return a pointer to the mesh
Definition: MeshObjectT_impl.hh:350
MeshObject::init
virtual void init(MeshT *_mesh=0)
Initialise current object, including all related nodes.
Definition: MeshObjectT_impl.hh:190
MeshObject
Definition: MeshObjectT.hh:97
MeshObject::triangle_bsp_
OMTriangleBSP * triangle_bsp_
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:390
ACG::SceneGraph::StatusNodeT::updateSelection
void updateSelection()
set selection invalid (Only selection changed, rest is kept)
Definition: StatusNodesT_impl.hh:756
BaseObjectData::manipulatorNode
QtTranslationManipulatorNode * manipulatorNode()
Definition: BaseObjectData.cc:255
MeshObject::setName
void setName(QString _name)
Set the name of the Object.
Definition: MeshObjectT_impl.hh:310
ACG::SceneGraph::SelectionNodeT< MeshT >
ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
Definition: DrawModes.cc:83
BaseObjectData::cleanup
virtual void cleanup() override
Definition: BaseObjectData.cc:102
TriangleBSPCoreT::push_back
void push_back(Handle _h)
Add a handle to the BSP.
Definition: TriangleBSPCoreT.hh:97
ACG::SceneGraph::StatusNodeT::updateGeometry
void updateGeometry()
set geometry invalid, topology and selection is kept
Definition: StatusNodesT_impl.hh:741
ACG::SceneGraph::MeshNodeT< MeshT >
MeshObject::resetTriangleBsp
OMTriangleBSP * resetTriangleBsp()
Definition: MeshObjectT_impl.hh:794
MeshObject::statusView_
ACG::SceneGraph::StatusViewNodeT< MeshT > * statusView_
Scenegraph StatusNodeView.
Definition: MeshObjectT.hh:303
OpenMesh::IO::read_mesh
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Definition: MeshIO.hh:112
MeshObject::selectionVisible
bool selectionVisible()
return if the selections are currently visible
Definition: MeshObjectT_impl.hh:616
BaseObjectData::boundingBoxNode
BoundingBoxNode * boundingBoxNode()
get a pointer to the bounding box node
Definition: BaseObjectData.cc:271
MeshObject::updateColor
void updateColor()
Update Colors of all data structures.
Definition: MeshObjectT_impl.hh:434
MeshObject::featuresVisible
bool featuresVisible()
return if the feature Node of the object is currently visible
Definition: MeshObjectT_impl.hh:591
MeshObject::areaColor
ACG::Vec4f areaColor() const
get color for areas. returns -1 vector, if handle node does not exists
Definition: MeshObjectT_impl.hh:507
ACG::SceneGraph::MeshNodeT::update_topology
void update_topology()
the topology of the mesh has changed
MeshObject::setAreaColor
void setAreaColor(const ACG::Vec4f &_color)
set color for areas
Definition: MeshObjectT_impl.hh:498
BaseObject::name
QString name() const
return the name of the object. The name defaults to NONAME if unset.
Definition: BaseObject.cc:730
MeshObject::handleColor
ACG::Vec4f handleColor() const
get color for handles. returns -1 vector, if handle node does not exists
Definition: MeshObjectT_impl.hh:543
MeshObject::getObjectinfo
QString getObjectinfo()
Get all Info for the Object as a string.
Definition: MeshObjectT_impl.hh:703
ACG::SceneGraph::MeshNodeT::update_color
void update_color()
the colors of the mesh have changed
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
ACG::SceneGraph::DrawModes::NONE
DrawMode NONE
not a valid draw mode
Definition: DrawModes.cc:71
BaseObjectData
Definition: BaseObjectData.hh:102
UpdateType
Update type class.
Definition: UpdateType.hh:60
MeshObject::cleanup
virtual void cleanup()
Reset current object, including all related nodes.
Definition: MeshObjectT_impl.hh:158
UPDATE_TEXTURE
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
ACG::SceneGraph::ACG::SceneGraph::BaseNode::set_parent
void set_parent(BaseNode *_parent)
Set the parent of this node.
Definition: BaseNode.cc:146
MeshObject::areaNode_
ACG::SceneGraph::StatusNodeT< MeshT, AreaNodeMod< MeshT > > * areaNode_
Area selection Vis.
Definition: MeshObjectT.hh:285
TriangleBSPCoreT::reserve
void reserve(size_t _n)
Reserve memory for _n entries.
Definition: TriangleBSPCoreT.hh:95
MeshObject::enablePicking
void enablePicking(bool _enable)
Enable or disable picking for this Node.
Definition: MeshObjectT_impl.hh:740
BaseObjectData::materialNode
MaterialNode * materialNode()
get a pointer to the materialnode
Definition: BaseObjectData.cc:263
MeshObject::mesh_
MeshT * mesh_
pointer to the mesh
Definition: MeshObjectT.hh:155
MeshObject::meshNode
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
Definition: MeshObjectT_impl.hh:637
UpdateType::contains
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
Definition: UpdateType.cc:104
MeshObject::update
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
Definition: MeshObjectT_impl.hh:367
MeshObject::textureNode_
ACG::SceneGraph::EnvMapNode * textureNode_
Scenegraph TextureNode.
Definition: MeshObjectT.hh:297
UPDATE_TOPOLOGY
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
MeshObject::textureNode
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode of the current mesh.
Definition: MeshObjectT_impl.hh:556
MeshObject::statusNode_
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode_
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT.hh:282
ACG::SceneGraph::StatusViewNodeT
Definition: StatusViewNodeT.hh:69
MeshObject::handleNode_
ACG::SceneGraph::StatusNodeT< MeshT, HandleNodeMod< MeshT > > * handleNode_
Handle selection Vis.
Definition: MeshObjectT.hh:288
ACG::SceneGraph::ACG::SceneGraph::BaseNode::enablePicking
void enablePicking(bool _enable)
Definition: MeshNode2T_impl.hh:265
MeshObject::boundingBox
void boundingBox(ACG::Vec3d &_bbMin, typename ACG::Vec3d &_bbMax)
Get the BoundingBox of this object.
Definition: MeshObjectT_impl.hh:644
MeshObject::featureColor
ACG::Vec4f featureColor() const
get color for features. returns -1 vector, if handle node does not exists
Definition: MeshObjectT_impl.hh:525
MeshObject::updateTopology
void updateTopology()
Update Topology of all data structures.
Definition: MeshObjectT_impl.hh:441
MeshObject::setFeatureColor
void setFeatureColor(const ACG::Vec4f &_color)
set color for features
Definition: MeshObjectT_impl.hh:516
ACG::SceneGraph::MeshNodeT::getDrawMesh
DrawMeshT< Mesh > * getDrawMesh()
Get DrawMesh instance.
Types.hh
MeshObject::setSelectionColor
void setSelectionColor(const ACG::Vec4f &_color)
set color for selection
Definition: MeshObjectT_impl.hh:479
PluginFunctions::setMainGLContext
void setMainGLContext()
Set current GL Context to main context.
Definition: PluginFunctions.cc:685
ACG::SceneGraph::BaseNode::HideNode
Hide this node, but draw children.
Definition: BaseNode.hh:394
MeshObject::pickingEnabled
bool pickingEnabled()
Check if picking is enabled for this Node.
Definition: MeshObjectT_impl.hh:753
ACG::SceneGraph::ACG::SceneGraph::BaseNode::name
std::string name() const
Returns: name of node (needs not be unique)
Definition: MeshNode2T_impl.hh:415
BaseObject::setDataType
void setDataType(DataType _type)
Definition: BaseObject.cc:233
ACG::SceneGraph::BaseNode::StatusMode
StatusMode
Status modi.
Definition: BaseNode.hh:389
MeshObject::MeshObject
MeshObject(const MeshObject &_object)
copy constructor
Definition: MeshObjectT_impl.hh:73
MeshObject::OMTriangleBSP
OpenMeshTriangleBSPT< MeshT > OMTriangleBSP
If requested a bsp is created for this object.
Definition: MeshObjectT.hh:352
ShaderNode
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
Definition: SplatCloudTypes.hh:73
MeshObject::updateModelingRegions
void updateModelingRegions()
Call this function to update the modeling regions.
Definition: MeshObjectT_impl.hh:454
ACG::SceneGraph::StatusNodeT::updateTopology
void updateTopology()
set topology invalid (updates everything)
Definition: StatusNodesT_impl.hh:747
ACG::SceneGraph::ACG::SceneGraph::BaseNode::pickingEnabled
bool pickingEnabled()
Definition: MeshNode2T_impl.hh:269
BaseObject::dataType
DataType dataType() const
Definition: BaseObject.cc:229
BaseObject::setFromFileName
void setFromFileName(const QString &_filename)
Definition: BaseObject.cc:716
MeshObject::picked
bool picked(uint _node_idx)
detect if the node has been picked
Definition: MeshObjectT_impl.hh:734
UPDATE_COLOR
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
OpenMeshTriangleBSPT
Definition: TriangleBSPT.hh:211
typeId
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
Definition: Types.cc:139
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:121
MeshObject::hasBsp
bool hasBsp() const
check if a BSP has been computed and is valid
Definition: MeshObjectT_impl.hh:817
MeshObject::shaderNode
ACG::SceneGraph::ShaderNode * shaderNode()
Return pointer to the shader node.
Definition: MeshObjectT_impl.hh:564