Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MeshObjectT.cc
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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50
51
52
53 //=============================================================================
54 //
55 // MyTypes
56 //
57 //=============================================================================
58
59 #define MESHOBJECT_C
60
61
62 //== INCLUDES =================================================================
63
64 #include <OpenFlipper/common/Types.hh>
65 #include <ACG/Scenegraph/DrawModes.hh>
66 #include <OpenFlipper/common/GlobalOptions.hh>
67 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
68
69
70 //== TYPEDEFS =================================================================
71
72 //== CLASS DEFINITION =========================================================
73
74 template < class MeshT >
75 MeshObject< MeshT >::MeshObject(const MeshObject& _object) :
76 BaseObjectData(_object),
77 statusNode_(0),
78 areaNode_(0),
79 handleNode_(0),
80 featureNode_(0),
81 meshNode_(0),
82 textureNode_(0),
83 shaderNode_(0),
84 statusView_(0),
85 triangle_bsp_(0)
86 {
87 init(_object.mesh_);
88
89
90 setName( name() );
91
92 // textures_ = _object.textures_;
93 // textureNames_ = _object.textureNames_;
94 }
95
103 template < class MeshT >
104 MeshObject< MeshT >::MeshObject( DataType _typeId ) :
105 BaseObjectData(),
106 mesh_(0),
107 statusNode_(0),
108 areaNode_(0),
109 handleNode_(0),
110 featureNode_(0),
111 meshNode_(0),
112 textureNode_(0),
113 shaderNode_(0),
114 statusView_(0),
115 triangle_bsp_(0)
116 {
117 setDataType(_typeId);
118 init();
119 }
120
124 template < class MeshT >
125 MeshObject< MeshT >::~MeshObject()
126 {
127 // Delete the data attached to this object ( this will remove all perObject data)
128 // Not the best way to do it but it will work.
129 // This is only necessary if people use references to the mesh below and
130 // they do something with the mesh in the destructor of their
131 // perObjectData.
132 deleteData();
133
134 // Delete the Mesh only, if this object contains a mesh
135 if ( mesh_ != NULL) {
136 delete mesh_;
137 mesh_ = NULL;
138 } else {
139 std::cerr << "Destructor error : Mesh already deleted" << std::endl;
140 }
141
142 if ( triangle_bsp_ != 0 )
143 delete triangle_bsp_;
144 triangle_bsp_ = 0;
145
146 // No need to delete the scenegraph Nodes as this will be managed by baseplugin
147 areaNode_ = 0;
148 handleNode_ = 0;
149 featureNode_ = 0;
150 meshNode_ = 0;
151 textureNode_ = 0;
152 shaderNode_ = 0;
153 statusView_ = 0;
154 }
155
159 template < class MeshT >
160 void MeshObject< MeshT >::cleanup() {
161 // Delete the Mesh only, if this object contains a mesh
162 if ( mesh_ != NULL) {
163 delete mesh_;
164 mesh_ = NULL;
165 } else {
166 std::cerr << "Cleanup error : Triangle Mesh already deleted" << std::endl;
167 }
168
169 if ( triangle_bsp_ != 0 )
170 delete triangle_bsp_;
171 triangle_bsp_ = 0;
172
173 BaseObjectData::cleanup();
174
175 statusNode_ = 0;
176 areaNode_ = 0;
177 handleNode_ = 0;
178 featureNode_ = 0;
179 textureNode_ = 0;
180 shaderNode_ = 0;
181 meshNode_ = 0;
182 statusView_ = 0;
183
184 init();
185
186 }
187
191 template < class MeshT >
192 void MeshObject< MeshT >::init(MeshT* _mesh) {
193
194 if ( _mesh == 0 )
195 mesh_ = new MeshT();
196 else
197 mesh_ = new MeshT(*_mesh);
198
199 // Prepare mesh and request required properties
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();
208
209 // Only initialize scenegraph nodes when we initialized a gui!!
210 if ( OpenFlipper::Options::nogui() )
211 return;
212
213 // This should never happen!
214 if ( manipulatorNode() == NULL)
215 std::cerr << "Error when creating Mesh Object! manipulatorNode is NULL!" << std::endl;
216
217
218 textureNode_ = new ACG::SceneGraph::EnvMapNode(materialNode(),"NEW TextureNode for ", true, GL_LINEAR_MIPMAP_LINEAR );
219
220 shaderNode_ = new ACG::SceneGraph::ShaderNode(textureNode() , "NEW ShaderNode for ");
221
222 meshNode_ = new ACG::SceneGraph::MeshNodeT<MeshT>(*mesh_, shaderNode_, "NEW MeshNode");
223
224 QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
225
226 std::string shaderDirectory = std::string( shaderDir.toUtf8() );
227 shaderNode_->setShaderDir( shaderDirectory );
228
229
230 if ( QFile( shaderDir + "Phong/Vertex.glsl").exists() && QFile( shaderDir + "Phong/Fragment.glsl" ).exists() )
231 shaderNode_->setShader(ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED,"Phong/Vertex.glsl" , "Phong/Fragment.glsl" );
232 else
233 std::cerr << "Shader Files for Phong not found!" << std::endl;
234
235
236 // Node showing selection
237 statusNode_ = new ACG::SceneGraph::SelectionNodeT<MeshT>(*mesh_, 0, "NEW StatusNode for mesh " );
238 statusNode_->set_point_size(4.0);
239 statusNode_->set_color(ACG::Vec4f(1.0f,0.0f,0.0f,1.0f));
240 statusNode_->set_base_color(ACG::Vec4f(1.0f,0.0f,0.0f,1.0f));
241 // Status nodes are handled specially by their StatusViewNodeT parent which
242 // is why they get a NONE draw mode.
243 statusNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
244
245 // Node showing modeling region
246 areaNode_ = new ACG::SceneGraph::StatusNodeT<MeshT, AreaNodeMod<MeshT> >(*mesh_, 0, "NEW AreaNode for mesh ");
247 areaNode_->set_round_points(true);
248 areaNode_->enable_alpha_test(0.5);
249 areaNode_->set_point_size(7.0);
250 areaNode_->set_color(ACG::Vec4f(0.4f, 0.4f, 1.0f, 1.0f));
251 // Status nodes are handled specially by their StatusViewNodeT parent which
252 // is why they get a NONE draw mode.
253 areaNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
254
255 // Node showing handle region
256 handleNode_ = new ACG::SceneGraph::StatusNodeT<MeshT, HandleNodeMod<MeshT> >(*mesh_, 0, "NEW HandleNode for mesh ");
257 handleNode_->set_round_points(true);
258 handleNode_->enable_alpha_test(0.5);
259 handleNode_->set_line_width(2.0);
260 handleNode_->set_point_size(7.0);
261 handleNode_->set_color(ACG::Vec4f(0.2f, 1.0f, 0.2f, 1.0f));
262 // Status nodes are handled specially by their StatusViewNodeT parent which
263 // is why they get a NONE draw mode.
264 handleNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
265
266 // Node showing feature selection
267 featureNode_ = new ACG::SceneGraph::StatusNodeT<MeshT, FeatureNodeMod<MeshT> >(*mesh_, 0, "NEW FeatureNode for mesh ");
268 featureNode_->set_round_points(true);
269 featureNode_->enable_alpha_test(0.5);
270 featureNode_->set_line_width(2.0);
271 featureNode_->set_point_size(7.0);
272 featureNode_->set_color(ACG::Vec4f(1.0f, 0.2f, 1.0f, 1.0f));
273 featureNode_->set_base_color(ACG::Vec4f(1.0f, 0.2f, 1.0f, 1.0f));
274 // Status nodes are handled specially by their StatusViewNodeT parent which
275 // is why they get a NONE draw mode.
276 featureNode_->drawMode(ACG::SceneGraph::DrawModes::NONE);
277
278 // Link the status nodes to the draw mesh of the mesh below them to reuse its buffers
279 if (meshNode_) {
280 statusNode_->setDrawMesh(meshNode_->getDrawMesh());
281 featureNode_->setDrawMesh(meshNode_->getDrawMesh());
282 areaNode_->setDrawMesh(meshNode_->getDrawMesh());
283 handleNode_->setDrawMesh(meshNode_->getDrawMesh());
284 }
285
286 // Node rendering selections in correct order
287 statusView_ = new ACG::SceneGraph::StatusViewNodeT<MeshT>(manipulatorNode(), "NEW StatusViewNode for mesh ",
288 statusNode_,
289 areaNode_,
290 handleNode_,
291 featureNode_);
292
293 // make StatusViewNode parent of status nodes
294 statusNode_->set_parent(statusView_);
295 areaNode_->set_parent(statusView_);
296 handleNode_->set_parent(statusView_);
297 featureNode_->set_parent(statusView_);
298
299 // Update all nodes
300 update();
301 }
302
303 // ===============================================================================
304 // Name/Path Handling
305 // ===============================================================================
306
310 template < class MeshT >
311 void MeshObject< MeshT >::setName( QString _name ) {
312 BaseObjectData::setName(_name);
313
314 // No update when gui is not active
315 if ( OpenFlipper::Options::nogui() )
316 return;
317
318 std::string nodename = std::string("StatusNode for mesh " + _name.toUtf8() );
319 statusNode_->name( nodename );
320
321 nodename = std::string("AreaNode for mesh " + _name.toUtf8() );
322 areaNode_->name( nodename );
323
324 nodename = std::string("HandleNode for mesh " + _name.toUtf8() );
325 handleNode_->name( nodename );
326
327 nodename = std::string("FeatureNode for mesh " + _name.toUtf8() );
328 featureNode_->name( nodename );
329
330 nodename = std::string("TextureNode for mesh "+ _name.toUtf8() );
331 textureNode_->name( nodename );
332
333 nodename = std::string("ShaderNode for mesh "+ _name.toUtf8() );
334 shaderNode_->name( nodename );
335
336 nodename = std::string("MeshNode for mesh " + _name.toUtf8() );
337 meshNode_->name( nodename );
338
339 nodename = std::string("StatusViewNode for mesh " + _name.toUtf8() );
340 statusView_->name( nodename );
341 }
342
343 // ===============================================================================
344 // Content
345 // ===============================================================================
346
350 template < class MeshT >
351 MeshT* MeshObject< MeshT >::mesh() {
352 return mesh_;
353 }
354
359 template < class MeshT >
360 void MeshObject< MeshT >::update(UpdateType _type) {
361
362 // No update necessary if no gui
363 if ( OpenFlipper::Options::nogui() )
364 return;
365
366 PluginFunctions::setMainGLContext();
367
368 if ( _type.contains(UPDATE_ALL) || _type.contains(UPDATE_TOPOLOGY) ){
369 updateGeometry();
370 updateColor();
371 updateTopology();
372 updateSelection();
373 updateFeatures();
374 updateModelingRegions();
375 updateTexture();
376 }
377 else
378 {
379 if ( _type.contains(UPDATE_GEOMETRY) ) {
380 updateGeometry();
381 }
382 if ( _type.contains(UPDATE_SELECTION) ) {
383 updateSelection();
384 updateFeatures();
385 updateModelingRegions();
386 }
387 if ( _type.contains(UPDATE_COLOR) ) {
388 updateColor();
389 }
390 if ( _type.contains(UPDATE_TEXTURE)) {
391 updateTexture();
392 }
393 }
394 }
395
397 template < class MeshT >
398 void MeshObject< MeshT >::updateSelection() {
399
400 if ( statusNode_ ){
401 statusNode_->updateSelection();
402 }
403 }
404
406 template < class MeshT >
407 void MeshObject< MeshT >::updateGeometry() {
408
409 if ( meshNode_ ) {
410 meshNode_->update_geometry();
411
412 // Also update the selection nodes here.
413 // These nodes store their positions based on the mesh.
414 // So they would be at the wrong position afterwards
415 statusNode_->updateGeometry();
416 featureNode_->updateGeometry();
417 areaNode_->updateGeometry();
418 handleNode_->updateGeometry();
419
420 }
421
422 invalidateTriangleBsp();
423 }
424
426 template < class MeshT >
427 void MeshObject< MeshT >::updateColor() {
428 if ( meshNode_ )
429 meshNode_->update_color();
430 }
431
433 template < class MeshT >
434 void MeshObject< MeshT >::updateTopology() {
435 if ( meshNode_ ) {
436 meshNode_->update_topology();
437 statusNode_->updateTopology();
438 featureNode_->updateTopology();
439 areaNode_->updateTopology();
440 handleNode_->updateTopology();
441 }
442 invalidateTriangleBsp();
443 }
444
446 template < class MeshT >
447 void MeshObject< MeshT >::updateModelingRegions() {
448 if ( areaNode_ && handleNode_ ) {
449 areaNode_->updateSelection();
450 handleNode_->updateSelection();
451 }
452 }
453
455 template < class MeshT >
456 void MeshObject< MeshT >::updateFeatures() {
457 if ( featureNode_ )
458 featureNode_->updateSelection();
459 }
460
462 template < class MeshT >
463 void MeshObject< MeshT >::updateTexture() {
464 meshNode_->update_textures();
465 }
466
467
468 // ===============================================================================
469 // Visualization
470 // ===============================================================================
471 template < class MeshT >
472 void MeshObject< MeshT >::setSelectionColor(const ACG::Vec4f& _color)
473 {
474 if (statusNode_)
475 {
476 statusNode_->set_color(_color);
477 statusNode_->set_base_color(_color);
478 }
479 }
480
481 template < class MeshT >
482 ACG::Vec4f MeshObject< MeshT >::selectionColor() const
483 {
484 if (statusNode_)
485 return statusNode_->base_color();
486 else
487 return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
488 }
489
490 template < class MeshT >
491 void MeshObject< MeshT >::setAreaColor(const ACG::Vec4f& _color)
492 {
493 if (areaNode_)
494 {
495 areaNode_->set_color(_color);
496 areaNode_->set_base_color(_color);
497 }
498 }
499 template < class MeshT >
500 ACG::Vec4f MeshObject< MeshT >::areaColor() const
501 {
502 if (areaNode_)
503 return areaNode_->base_color();
504 else
505 return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
506 }
507
508 template < class MeshT >
509 void MeshObject< MeshT >::setFeatureColor(const ACG::Vec4f& _color)
510 {
511 if (featureNode_)
512 {
513 featureNode_->set_color(_color);
514 featureNode_->set_base_color(_color);
515 }
516 }
517 template < class MeshT >
518 ACG::Vec4f MeshObject< MeshT >::featureColor() const
519 {
520 if (featureNode_)
521 return featureNode_->base_color();
522 else
523 return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
524 }
525
526 template < class MeshT >
527 void MeshObject< MeshT >::setHandleColor(const ACG::Vec4f& _color)
528 {
529 if (handleNode_)
530 {
531 handleNode_->set_color(_color);
532 handleNode_->set_base_color(_color);
533 }
534 }
535 template < class MeshT >
536 ACG::Vec4f MeshObject< MeshT >::handleColor() const
537 {
538 if (handleNode_)
539 return handleNode_->base_color();
540 else
541 return ACG::Vec4f(-1.f,-1.f,-1.f,-1.f);
542 }
543
544
548 template < class MeshT >
549 ACG::SceneGraph::EnvMapNode* MeshObject< MeshT >::textureNode() {
550 return textureNode_;
551 }
552
556 template < class MeshT >
557 ACG::SceneGraph::ShaderNode* MeshObject< MeshT >::shaderNode() {
558 return shaderNode_;
559 }
560
563 template < class MeshT >
564 void MeshObject< MeshT >::hideSelection( bool _hide ) {
565
566 if ( _hide ) {
567 statusNode_->set_status( ACG::SceneGraph::BaseNode::HideNode );
568 } else {
569 statusNode_->set_status( ACG::SceneGraph::BaseNode::Active );
570 }
571
572 }
573
574 template < class MeshT >
575 void MeshObject< MeshT >::hideFeatures( bool _hide ) {
576 if ( _hide ) {
577 featureNode_->set_status( ACG::SceneGraph::BaseNode::HideNode );
578 } else {
579 featureNode_->set_status( ACG::SceneGraph::BaseNode::Active );
580 }
581 }
582
583 template < class MeshT >
584 bool MeshObject< MeshT >::featuresVisible( ) {
585 return ( featureNode_->status() == ACG::SceneGraph::BaseNode::Active );
586 }
587
590 template < class MeshT >
591 void MeshObject< MeshT >::hideArea( StatusBits _bit, bool _hide ) {
592 ACG::SceneGraph::BaseNode::StatusMode status;
593
594 if ( _hide ) {
595 status = ACG::SceneGraph::BaseNode::HideNode;
596 }else
597 status = ACG::SceneGraph::BaseNode::Active;
598
599 if ( _bit & AREA ) {
600 areaNode_->set_status( status );
601 }
602
603 if ( _bit & HANDLEAREA )
604 handleNode_->set_status( status );
605
606 }
607
608 template < class MeshT >
609 bool MeshObject< MeshT >::selectionVisible() {
610 return ( statusNode_->status() == ACG::SceneGraph::BaseNode::Active );
611 }
612
613 template < class MeshT >
614 bool MeshObject< MeshT >::areaVisible( StatusBits _bit ) {
615 bool status = true;
616
617 if ( _bit & AREA )
618 status &= ( areaNode_->status() == ACG::SceneGraph::BaseNode::Active );
619
620 if ( _bit & HANDLEAREA )
621 status &= ( handleNode_->status() == ACG::SceneGraph::BaseNode::Active );
622
623 return status;
624 }
625
629 template < class MeshT >
630 ACG::SceneGraph::MeshNodeT<MeshT>* MeshObject< MeshT >::meshNode() {
631 return meshNode_;
632 }
633
636 template < class MeshT >
637 void MeshObject< MeshT >::boundingBox( ACG::Vec3d& _bbMin , ACG::Vec3d& _bbMax ) {
638 if ( meshNode_ ) {
639 _bbMin = ACG::Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
640 _bbMax = ACG::Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
641 meshNode_->boundingBox(_bbMin,_bbMax);
642 } else {
643 std::cerr << "Error: Bounding box computation via Scenegraph not available without gui" << std::endl;
644 }
645 }
646
647 // ===============================================================================
648 // Load/Save
649 // ===============================================================================
650
656 template < class MeshT >
657 bool MeshObject< MeshT >::loadMesh(QString _filename) {
658
659 setFromFileName(_filename);
660
661 // call the local function to update names
662 setName( name() );
663
664 std::string filename = std::string( _filename.toUtf8() );
665
666 // load file
667 bool ok = OpenMesh::IO::read_mesh( (*mesh()) , filename );
668 if (!ok)
669 {
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";
674 return false;
675 }
676
677 mesh()->update_normals();
678
679 update();
680
681 show();
682
683 return true;
684 }
685
686 // ===============================================================================
687 // Object information
688 // ===============================================================================
689
695 template < class MeshT >
696 QString MeshObject< MeshT >::getObjectinfo() {
697 QString output;
698
699 output += "========================================================================\n";
700 output += BaseObjectData::getObjectinfo();
701
702 if ( dataType( typeId("TriangleMesh") ) )
703 output += "Object Contains Triangle Mesh : ";
704
705 if ( dataType( typeId("PolyMesh") ) )
706 output += "Object Contains Poly Mesh : ";
707
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";
711
712 output += "========================================================================\n";
713 return output;
714 }
715
716 // ===============================================================================
717 // Picking
718 // ===============================================================================
719
726 template < class MeshT >
727 bool MeshObject< MeshT >::picked( uint _node_idx ) {
728 return ( _node_idx == meshNode_->id() );
729 }
730
731
732 template < class MeshT >
733 void MeshObject< MeshT >::enablePicking( bool _enable ) {
734 if ( OpenFlipper::Options::nogui())
735 return;
736
737 meshNode_->enablePicking( _enable );
738 areaNode_->enablePicking( _enable );
739 handleNode_->enablePicking( _enable );
740 featureNode_->enablePicking( _enable );
741 textureNode_->enablePicking( _enable );
742 shaderNode_->enablePicking( _enable );
743 }
744
745 template < class MeshT >
746 bool MeshObject< MeshT >::pickingEnabled() {
747 return meshNode_->pickingEnabled();
748 }
749
750 // ===============================================================================
751 // Octree
752 // ===============================================================================
753
754 template < class MeshT >
755 typename MeshObject< MeshT >::OMTriangleBSP*
756 MeshObject< MeshT >::requestTriangleBsp() {
757
758 if ( ! dataType( typeId("TriangleMesh") ) ) {
759 std::cerr << "Bsps are only supported for triangle meshes." << std::endl;
760 return 0;
761 }
762
763 // Create the tree if needed.
764 if ( triangle_bsp_ == 0 )
765 {
766 // create Triangle BSP
767 triangle_bsp_ = new OMTriangleBSP( *mesh() );
768
769 // build Triangle BSP
770 triangle_bsp_->reserve(mesh()->n_faces());
771
772 typename MeshT::FIter f_it = mesh()->faces_begin();
773 typename MeshT::FIter f_end = mesh()->faces_end();
774
775 for (; f_it!=f_end; ++f_it)
776 triangle_bsp_->push_back(*f_it);
777
778 triangle_bsp_->build(10, 100); //max vertices per leaf 10, max depth 100
779 }
780
781 // return pointer to triangle bsp
782 return triangle_bsp_;
783 }
784
785 template < class MeshT >
786 typename MeshObject< MeshT >::OMTriangleBSP*
787 MeshObject< MeshT >::resetTriangleBsp() {
788 if ( triangle_bsp_ != 0 )
789 {
790 delete triangle_bsp_;
791 triangle_bsp_ = 0;
792 }
793
794 return requestTriangleBsp();
795 }
796
797 template < class MeshT >
798 void
799 MeshObject< MeshT >::invalidateTriangleBsp() {
800 if ( triangle_bsp_ != 0 )
801 {
802 delete triangle_bsp_;
803 triangle_bsp_ = 0;
804 }
805 }
806
807
808 template < class MeshT >
809 bool
810 MeshObject< MeshT >::hasBsp() const {
811 return triangle_bsp_ != 0;
812 }
813
814
815 //=============================================================================
816
817 template < class MeshT >
818 BaseNode*
819 MeshObject< MeshT >::primaryNode(){
820 return boundingBoxNode();
821 }
822
823 //=============================================================================
824
typeId
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
Definition: Types.cc:150
MeshObject::getObjectinfo
QString getObjectinfo()
Get all Info for the Object as a string.
Definition: MeshObjectT.cc:696
ACG::SceneGraph::StatusNodeT::setDrawMesh
void setDrawMesh(DrawMeshT< Mesh > *_drawmesh)
Set drawmesh.
Definition: StatusNodesT.cc:750
MeshObject::meshNode
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
Definition: MeshObjectT.cc:630
MeshObject::shaderNode
ACG::SceneGraph::ShaderNode * shaderNode()
Return pointer to the shader node.
Definition: MeshObjectT.cc:557
OpenMesh::IO::read_mesh
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Definition: MeshIO.hh:104
MeshObject::setFeatureColor
void setFeatureColor(const ACG::Vec4f &_color)
set color for features
Definition: MeshObjectT.cc:509
MeshObject::hideArea
void hideArea(StatusBits _bit, bool _hide)
Hide or show the area Nodes of the object.
Definition: MeshObjectT.cc:591
ShaderNode
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
Definition: SplatCloudTypes.hh:79
MeshObject::mesh
MeshT * mesh()
return a pointer to the mesh
Definition: MeshObjectT.cc:351
MeshObject::hasBsp
bool hasBsp() const
check if a BSP has been computed and is valid
Definition: MeshObjectT.cc:810
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:135
UPDATE_GEOMETRY
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
MeshObject::primaryNode
BaseNode * primaryNode()
Status Node for a mesh, visualizing the selection state of a mesh.
Definition: MeshObjectT.cc:819
MeshObject::cleanup
virtual void cleanup()
Reset current object, including all related nodes.
Definition: MeshObjectT.cc:160
MeshObject::updateColor
void updateColor()
Update Colors of all data structures.
Definition: MeshObjectT.cc:427
BaseObject::getObjectinfo
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:255
ACG::SceneGraph::EnvMapNode
Definition: EnvMapNode.hh:83
BaseObjectData
Definition: BaseObjectData.hh:105
ACG::SceneGraph::MeshNodeT< MeshT >
BaseObject::name
QString name() const
return the name of the object. The name defaults to NONAME if unset.
Definition: BaseObject.cc:741
UpdateType::contains
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
Definition: UpdateType.cc:111
MeshObject::~MeshObject
virtual ~MeshObject()
destructor
Definition: MeshObjectT.cc:125
UpdateType
Update type class.
Definition: UpdateType.hh:70
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
ACG::SceneGraph::BaseNode::Active
Draw node & children.
Definition: BaseNode.hh:368
BaseObjectData::setName
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObjectData.cc:357
MeshObject::areaVisible
bool areaVisible(StatusBits _bit)
Return if the selected areas are currently visible.
Definition: MeshObjectT.cc:614
MeshObject::setName
void setName(QString _name)
Set the name of the Object.
Definition: MeshObjectT.cc:311
MeshObject::loadMesh
bool loadMesh(QString _filename)
Load a mesh from the given file.
Definition: MeshObjectT.cc:657
ACG::Vec4f
VectorT< float, 4 > Vec4f
Definition: VectorT.hh:144
MeshObject::requestTriangleBsp
OMTriangleBSP * requestTriangleBsp()
Definition: MeshObjectT.cc:756
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:127
MeshObject::handleColor
ACG::Vec4f handleColor() const
get color for handles. returns -1 vector, if handle node does not exists
Definition: MeshObjectT.cc:536
MeshObject::areaColor
ACG::Vec4f areaColor() const
get color for areas. returns -1 vector, if handle node does not exists
Definition: MeshObjectT.cc:500
ACG::SceneGraph::StatusViewNodeT
Definition: StatusViewNodeT.hh:77
MeshObject::featuresVisible
bool featuresVisible()
return if the feature Node of the object is currently visible
Definition: MeshObjectT.cc:584
MeshObject::init
virtual void init(MeshT *_mesh=0)
Initialise current object, including all related nodes.
Definition: MeshObjectT.cc:192
MeshObject::MeshObject
MeshObject(const MeshObject &_object)
copy constructor
Definition: MeshObjectT.cc:75
BaseObjectData::cleanup
virtual void cleanup()
Definition: BaseObjectData.cc:108
MeshObject::resetTriangleBsp
OMTriangleBSP * resetTriangleBsp()
Definition: MeshObjectT.cc:787
MeshObject::featureColor
ACG::Vec4f featureColor() const
get color for features. returns -1 vector, if handle node does not exists
Definition: MeshObjectT.cc:518
UPDATE_SELECTION
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
MeshObject::hideFeatures
void hideFeatures(bool _hide)
Hide or show the feature Node of the object.
Definition: MeshObjectT.cc:575
MeshObject::selectionVisible
bool selectionVisible()
return if the selections are currently visible
Definition: MeshObjectT.cc:609
MeshObject::boundingBox
void boundingBox(ACG::Vec3d &_bbMin, typename ACG::Vec3d &_bbMax)
Get the BoundingBox of this object.
Definition: MeshObjectT.cc:637
MeshObject::updateFeatures
void updateFeatures()
Update Feature Visualization Node.
Definition: MeshObjectT.cc:456
MeshObject::setHandleColor
void setHandleColor(const ACG::Vec4f &_color)
set color for handles
Definition: MeshObjectT.cc:527
MeshObject::setAreaColor
void setAreaColor(const ACG::Vec4f &_color)
set color for areas
Definition: MeshObjectT.cc:491
ACG::SceneGraph::ACG::SceneGraph::BaseNode::set_parent
void set_parent(BaseNode *_parent)
Set the parent of this node.
Definition: BaseNode.cc:152
MeshObject::updateModelingRegions
void updateModelingRegions()
Call this function to update the modeling regions.
Definition: MeshObjectT.cc:447
MeshObject::invalidateTriangleBsp
void invalidateTriangleBsp()
Definition: MeshObjectT.cc:799
ACG::SceneGraph::BaseNode::StatusMode
StatusMode
Status modi.
Definition: BaseNode.hh:365
MeshObject::updateGeometry
void updateGeometry()
Update Geometry of all data structures.
Definition: MeshObjectT.cc:407
MeshObject::enablePicking
void enablePicking(bool _enable)
Enable or disable picking for this Node.
Definition: MeshObjectT.cc:733
OpenMesh::VectorT
Definition: Vector11T.hh:83
UPDATE_TEXTURE
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
MeshObject::selectionColor
ACG::Vec4f selectionColor() const
get color for selection. returns -1 vector, if handle node does not exists
Definition: MeshObjectT.cc:482
BaseObject::setDataType
void setDataType(DataType _type)
Definition: BaseObject.cc:244
UPDATE_TOPOLOGY
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
GlobalOptions.hh
MeshObject::updateSelection
void updateSelection()
Call this function to update the modeling regions.
Definition: MeshObjectT.cc:398
ACG::SceneGraph::SelectionNodeT< MeshT >
ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
Definition: DrawModes.cc:89
OpenMeshTriangleBSPT
Definition: TriangleBSPT.hh:206
MeshObject::textureNode
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode of the current mesh.
Definition: MeshObjectT.cc:549
MeshObject::hideSelection
void hideSelection(bool _hide)
Hide or show the selection Node of the object.
Definition: MeshObjectT.cc:564
OpenMesh::PolyMeshT::update_normals
void update_normals()
Compute normals for all primitives.
Definition: PolyMeshT.cc:241
MeshObject::updateTexture
void updateTexture()
Update Texture of all data structures.
Definition: MeshObjectT.cc:463
ACG::SceneGraph::ShaderNode
Definition: ShaderNode.hh:87
ACG::SceneGraph::BaseNode::HideNode
Hide this node, but draw children.
Definition: BaseNode.hh:370
MeshObject::update
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
Definition: MeshObjectT.cc:360
MeshObject
Definition: MeshObjectT.hh:103
UPDATE_COLOR
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
PluginFunctions.hh
DataType
Predefined datatypes.
Definition: DataTypes.hh:96
MeshObject::picked
bool picked(uint _node_idx)
detect if the node has been picked
Definition: MeshObjectT.cc:727
Types.hh
MeshObject::pickingEnabled
bool pickingEnabled()
Check if picking is enabled for this Node.
Definition: MeshObjectT.cc:746
MeshObject::mesh_
MeshT * mesh_
pointer to the mesh
Definition: MeshObjectT.hh:157
ACG::SceneGraph::StatusNodeT
Definition: StatusNodesT.hh:183
PluginFunctions::setMainGLContext
void setMainGLContext()
Set current GL Context to main context.
Definition: PluginFunctions.cc:687
MeshObject::setSelectionColor
void setSelectionColor(const ACG::Vec4f &_color)
set color for selection
Definition: MeshObjectT.cc:472
ACG::SceneGraph::DrawModes::NONE
DrawMode NONE
not a valid draw mode
Definition: DrawModes.cc:77
MeshObject::updateTopology
void updateTopology()
Update Topology of all data structures.
Definition: MeshObjectT.cc:434