19 #include <osg/MatrixTransform>
21 #include <osgManipulator/TabBoxDragger>
24 #include <osgManipulator/TrackballDragger>
27 #include <osg/LineWidth>
46 std::cout <<
"*** this=" <<
this <<
" entering " << __func__ << std::endl;
50 std::cout <<
"*** this=" <<
this <<
" leaving " << __func__ << std::endl;
59 std::cout <<
"*** this=" <<
this <<
" entering " << __func__ << std::endl;
68 std::vector< Adapter * > *adapters = myWindow->getAdapters();
69 for(
unsigned int ii = 0; ii < (*adapters).size(); ++ii)
71 if((*adapters)[ii] == myAdapter)
73 (*adapters).erase((*adapters).begin() + ii);
90 for(
unsigned int ii = 0; ii < v_mixed_meshes.size(); ++ii)
93 auto mesh_type_pair = v_mixed_meshes[ii];
96 if(mesh_type_pair.second ==
"POLYHEDRON")
99 std::cout <<
"[SimpleViewer] deleting mesh " << mesh_ptr <<
" with datastructure POLYHEDRON" << std::endl;
102 if(mesh_type_pair.second ==
"SURFACEMESH")
105 std::cout <<
"[SimpleViewer] deleting mesh " << mesh_ptr <<
" with datastructure SURFACEMESH" << std::endl;
108 if(mesh_type_pair.second ==
"LCC")
110 auto mesh_ptr =
static_cast< FEVV::MeshLCC*
>(mesh_type_pair.first);
111 std::cout <<
"[SimpleViewer] deleting mesh " << mesh_ptr <<
" with datastructure LCC" << std::endl;
114 if(mesh_type_pair.second ==
"CGALPOINTSET")
117 std::cout <<
"[SimpleViewer] deleting mesh " << mesh_ptr
118 <<
" with datastructure CGALPOINTSET" << std::endl;
121 #endif //FEVV_USE_CGAL
123 #ifdef FEVV_USE_OPENMESH
124 if(mesh_type_pair.second ==
"OPENMESH")
127 std::cout <<
"[SimpleViewer] deleting mesh " << mesh_ptr <<
" with datastructure OPENMESH" << std::endl;
130 #endif //FEVV_USE_OPENMESH
133 if(mesh_type_pair.second ==
"AIF")
135 auto mesh_ptr =
static_cast< FEVV::MeshAIF*
>(mesh_type_pair.first);
136 std::cout <<
"[SimpleViewer] deleting mesh " << mesh_ptr <<
" with datastructure AIF" << std::endl;
139 #endif //FEVV_USE_AIF
142 if(mesh_type_pair.second ==
"PCLPOINTCLOUD")
145 std::cout <<
"[SimpleViewer] deleting mesh " << mesh_ptr
146 <<
" with datastructure PCLPOINTCLOUD" << std::endl;
149 #endif //FEVV_USE_PCL
153 for(
unsigned int ii = 0; ii < v_properties_maps.size(); ++ii)
155 delete v_properties_maps[ii];
177 std::cout <<
"*** this=" <<
this <<
" leaving " << __func__ << std::endl;
187 !bIsInit,
"is already init. Leaving...",
"SimpleViewer::init"))
192 #if(FEVV_USE_QT5) // FOR_QT6
196 setKeyEventSetsDone(0);
204 osg::Light *pLight =
new osg::Light;
205 pLight->setLightNum(1);
209 pLight->setAmbient(osg::Vec4d(1.0, 1.0, 1.0, 0.0));
210 pLight->setDiffuse(osg::Vec4(1.0f, 1.0f, 1.0f, 0.0f));
211 pLight->setSpecular(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
218 pLight->setPosition(osg::Vec4(2.0f, 0.0f, 2.0f, 1.0f));
220 osg::LightSource *pLightSource =
new osg::LightSource;
221 pLightSource->setLight(pLight);
222 root_node->addChild(pLightSource);
226 osg::StateSet *state = root_node->getOrCreateStateSet();
227 state->setMode(GL_LIGHT0, osg::StateAttribute::OFF);
228 state->setMode(GL_LIGHT1, osg::StateAttribute::ON);
233 gizmo->setNodeMask(m_ShowAxis ? 0xffffffff : 0x0);
237 grid->setNodeMask(m_ShowGrid ? 0xffffffff : 0x0);
244 i_time = current_i_time = -1;
247 std::cout <<
"SimpleViewer init" << std::endl;
289 osgViewer::View *_osgView =
290 dynamic_cast< osgViewer::View *
>(
this);
292 #if(FEVV_USE_QT5) // FOR_QT6
298 _osgView = sav->my_osgQOpenGLWindow->getOsgViewer();
314 std::unique_ptr< osgViewer::ScreenCaptureHandler > scrn(
315 new osgViewer::ScreenCaptureHandler());
316 std::unique_ptr< osgViewer::ScreenCaptureHandler::WriteToFile > captureOper(
317 new osgViewer::ScreenCaptureHandler::WriteToFile(_name,
"png"));
319 scrn->setCaptureOperation(captureOper.get());
320 #if(FEVV_USE_QT5) // FOR_QT6
323 scrn->captureNextFrame(*
this);
335 root_node->addChild(_geode);
336 if(myWindow !=
nullptr)
350 root_node->addChild(_group);
351 if(myWindow !=
nullptr)
367 root_node->traverse(*visitor);
369 return visitor->exportResults();
374 std::vector< osg::Geode * >
377 std::vector< osg::Geode * > result;
378 unsigned int i_pos = 0;
379 for(
bool b : v_meshIsSelected)
383 result.push_back(v_geodes[i_pos]);
393 std::vector< osg::Geode * >
405 unsigned int i_pos = 0;
406 for(
bool b : v_meshIsSelected)
423 return v_mixed_meshes;
428 std::vector< std::string >
431 std::vector< std::string > result;
432 unsigned int i_pos = 0;
433 for(
bool b : v_meshIsSelected)
437 result.push_back(v_meshes_names[i_pos]);
447 std::vector< std::string >
450 return v_meshes_names;
455 std::vector< FEVV::PMapsContainer * >
458 std::vector< FEVV::PMapsContainer * > result;
459 unsigned int i_pos = 0;
460 for(
bool b : v_meshIsSelected)
464 result.push_back(v_properties_maps[i_pos]);
474 std::vector< FEVV::PMapsContainer * >
477 return v_properties_maps;
482 std::vector< osg::Group * >
485 std::vector< osg::Group * > result;
486 unsigned int i_pos = 0;
487 for(
bool b : v_meshIsSelected)
491 result.push_back(v_draggers1[i_pos]);
501 std::vector< osg::Group * >
509 std::vector< osg::Group * >
512 std::vector< osg::Group * > result;
513 unsigned int i_pos = 0;
514 for(
bool b : v_meshIsSelected)
518 result.push_back(v_draggers2[i_pos]);
528 std::vector< osg::Group * >
534 #if 0 //TODO-elo-rm-?-ask_MTO
535 template<
typename HalfedgeGraph >
540 "The given position must be lower than v_meshes.size()",
541 "SimpleViewer::getMesh(int)");
543 return v_meshes[_position];
548 template<
typename HalfedgeGraph,
typename Po
intMap >
553 std::vector< osg::ref_ptr< osg::Geometry > > &geometries,
554 std::vector< osg::ref_ptr< osg::Geometry > > &geometriesL,
555 std::vector< osg::ref_ptr< osg::Geometry > > &geometriesP,
556 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_edges,
557 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_vertices,
558 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_normals,
559 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_custom_vectors,
560 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays,
561 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_edges,
562 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_vertices,
563 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_normals,
564 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_custom_vectors,
565 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays,
566 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArraysF,
567 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays_edges,
568 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays_vertices,
569 std::vector< osg::ref_ptr< osg::Vec3Array > > &tangentsArrays,
570 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays,
571 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_edges,
572 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_vertices,
573 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_normals,
574 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_custom_vectors,
575 std::vector< osg::ref_ptr< osg::Vec2Array > > &texcoordsArrays,
577 std::string _mesh_file)
582 internal_createMesh(geode,
591 geometries_custom_vectors,
594 vertexArrays_vertices,
595 vertexArrays_normals,
596 vertexArrays_custom_vectors,
600 normalsArrays_vertices,
604 colorsArrays_vertices,
605 colorsArrays_normals,
606 colorsArrays_custom_vectors,
614 template<
typename HalfedgeGraph,
typename Po
intMap >
620 std::vector< osg::ref_ptr< osg::Geometry > > &geometries,
621 std::vector< osg::ref_ptr< osg::Geometry > > &geometriesL,
622 std::vector< osg::ref_ptr< osg::Geometry > > &geometriesP,
623 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_edges,
624 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_vertices,
625 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_normals,
626 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_custom_vectors,
627 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays,
628 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_edges,
629 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_vertices,
630 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_normals,
631 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_custom_vectors,
632 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays,
633 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArraysF,
634 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays_edges,
635 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays_vertices,
636 std::vector< osg::ref_ptr< osg::Vec3Array > > &tangentsArrays,
637 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays,
638 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_edges,
639 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_vertices,
640 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_normals,
641 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_custom_vectors,
642 std::vector< osg::ref_ptr< osg::Vec2Array > > &texcoordsArrays,
644 std::string _mesh_file)
646 using GraphTraits = boost::graph_traits< HalfedgeGraph >;
648 using face_iterator =
typename GraphTraits::face_iterator;
650 using edge_iterator =
typename GraphTraits::edge_iterator;
652 using halfedge_descriptor =
typename GraphTraits::halfedge_descriptor;
653 using vertex_iterator =
typename GraphTraits::vertex_iterator;
659 using VertexNormalMap =
661 HalfedgeGraph >::pmap_type;
663 HalfedgeGraph >::pmap_type;
666 HalfedgeGraph >::pmap_type;
668 HalfedgeGraph >::pmap_type;
671 HalfedgeGraph >::pmap_type;
673 HalfedgeGraph >::pmap_type;
676 using VertexTangentMap =
678 HalfedgeGraph >::pmap_type;
680 using FaceMaterialMap =
682 HalfedgeGraph >::pmap_type;
683 using MeshMaterialsMap =
685 HalfedgeGraph >::pmap_type;
687 using VertexCustomVectorMap =
689 HalfedgeGraph >::pmap_type;
691 using VertexCustomVectorColorMap =
693 HalfedgeGraph >::pmap_type;
695 using VertexCustomVectorParamMap =
697 HalfedgeGraph >::pmap_type;
699 using MeshGuipropertiesMap =
701 HalfedgeGraph >::pmap_type;
703 VertexNormalMap v_nm;
710 VertexTangentMap vt_m;
712 FaceMaterialMap f_mm;
713 MeshMaterialsMap m_mm;
715 VertexCustomVectorMap v_CVm;
716 VertexCustomVectorColorMap v_CVCm;
717 VertexCustomVectorParamMap v_CVPm;
719 MeshGuipropertiesMap m_gpm;
721 VertexNormalMap *_vt_nm =
nullptr;
722 FaceNormalMap *_f_nm =
nullptr;
723 VertexColorMap *_vt_cm =
nullptr;
724 FaceColorMap *_f_cm =
nullptr;
725 VertexUVMap *_vt_uv_m =
nullptr;
726 HalfedgeUVMap *_het_uv_m =
nullptr;
728 VertexTangentMap *v_tan_m =
nullptr;
730 FaceMaterialMap *_f_mm =
nullptr;
731 MeshMaterialsMap *_m_mm =
nullptr;
733 VertexCustomVectorMap *_vt_CVm =
nullptr;
734 VertexCustomVectorColorMap *_vt_CVCm =
nullptr;
735 VertexCustomVectorParamMap *_vt_CVPm =
nullptr;
737 size_t _m_mm_size = 0;
755 put(m_gpm, 0, gui_props);
767 std::cout <<
"[SimpleViewer] using face normal" << std::endl;
773 if(_f_nm ==
nullptr || m_recomputeNT_if_redraw)
776 std::cout <<
"[SimpleViewer] face normal missing, computing it"
790 std::cout <<
"[SimpleViewer] using vertex normal" << std::endl;
796 if(_vt_nm ==
nullptr || m_recomputeNT_if_redraw)
799 std::cout <<
"[SimpleViewer] vertex normal missing, computing it"
813 std::cout <<
"[SimpleViewer] using face color" << std::endl;
819 m_UseVertexColor =
false;
820 m_UseFaceColor =
true;
821 m_UseTexture =
false;
830 std::cout <<
"[SimpleViewer] using vertex color" << std::endl;
836 m_UseVertexColor =
true;
837 m_UseFaceColor =
false;
838 m_UseTexture =
false;
847 std::cout <<
"[SimpleViewer] using vertex texture-coordinates"
855 m_UseVertexColor =
false;
856 m_UseFaceColor =
false;
863 std::cout <<
"[SimpleViewer] using vertex tangents" << std::endl;
873 std::cout <<
"[SimpleViewer] vertex tangents missing, computing it"
884 std::cout <<
"[SimpleViewer] using halfedge texture-coordinates"
892 m_UseVertexColor =
false;
893 m_UseFaceColor =
false;
900 std::cout <<
"[SimpleViewer] using halfedge tangents" << std::endl;
910 std::cout <<
"[SimpleViewer] halfedge tangents missing, computing it"
937 _m_mm_size = std::distance(m_mm.storage_begin(), m_mm.storage_end());
939 std::cout <<
"[SimpleViewer] number of materials: " << _m_mm_size
946 std::cout <<
"[SimpleViewer] no material found, disabling textures"
955 std::cout <<
"[SimpleViewer] using vertex CUSTOM VECTOR" << std::endl;
961 if(_vt_CVm ==
nullptr || m_recomputeNT_if_redraw)
964 std::cout <<
"[SimpleViewer] vertex CUSTOM VECTOR missing, filling it with example values"
973 vertex_iterator vi = iterator_pair.first;
974 vertex_iterator vi_end = iterator_pair.second;
975 for (; vi != vi_end; ++vi)
977 v_CVm[*vi] =
Vector(1., 1., 1.);
991 std::cout <<
"[SimpleViewer] using vertex CUSTOM VECTOR COLOR" << std::endl;
997 if(_vt_CVCm ==
nullptr || m_recomputeNT_if_redraw)
1000 std::cout <<
"[SimpleViewer] vertex CUSTOM VECTOR COLOR missing, filling it with example values"
1008 auto iterator_pair =
vertices(*_g);
1009 vertex_iterator vi = iterator_pair.first;
1010 vertex_iterator vi_end = iterator_pair.second;
1011 for (; vi != vi_end; ++vi)
1013 v_CVCm[*vi] =
Vector(139/255.0f, 195/255.0f, 74/255.0f);
1027 std::cout <<
"[SimpleViewer] using vertex CUSTOM VECTOR PARAM" << std::endl;
1033 if(_vt_CVPm ==
nullptr || m_recomputeNT_if_redraw)
1036 std::cout <<
"[SimpleViewer] vertex CUSTOM VECTOR PARAM missing, filling it with example values"
1044 auto iterator_pair =
vertices(*_g);
1045 vertex_iterator vi = iterator_pair.first;
1046 vertex_iterator vi_end = iterator_pair.second;
1047 for (; vi != vi_end; ++vi)
1049 v_CVPm[*vi] =
Vector(0.1f, 0.1f, 0.08f);
1069 if(m_UseVertexColor || m_UseFaceColor ||
1071 if((!m_space_time) || (m_space_time && m_space_time_changeColorMode))
1078 _het_uv_m =
nullptr;
1088 if(m_UseVertexColor)
1116 else if(m_UseFaceColor)
1128 else if(m_UseTexture)
1166 std::distance(m_mm.storage_begin(), m_mm.storage_end());
1179 QApplication::setOverrideCursor(Qt::ForbiddenCursor);
1183 sw->statusBar()->showMessage(
1184 QObject::tr(
"Create and populate OSG objects...") );
1186 GeometryTraits gt(*_g);
1188 if(geode ==
nullptr)
1190 geode =
new osg::Geode;
1195 geode->removeDrawables(0, geode->getNumDrawables());
1199 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1201 geometries.push_back(
new osg::Geometry());
1202 geometries[0]->setSupportsDisplayList(
true);
1203 geometries[0]->setUseDisplayList(
true);
1204 geometries[0]->setUseVertexBufferObjects(
1207 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1209 geometriesL.push_back(
new osg::Geometry());
1210 geometriesL[0]->setSupportsDisplayList(
true);
1211 geometriesL[0]->setUseDisplayList(
true);
1212 geometriesL[0]->setUseVertexBufferObjects(
1215 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1217 geometriesP.push_back(
new osg::Geometry());
1218 geometriesP[0]->setSupportsDisplayList(
true);
1219 geometriesP[0]->setUseDisplayList(
true);
1220 geometriesP[0]->setUseVertexBufferObjects(
1223 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1225 geometries_edges.push_back(
new osg::Geometry());
1226 geometries_edges[0]->setSupportsDisplayList(
true);
1227 geometries_edges[0]->setUseDisplayList(
true);
1228 geometries_edges[0]->setUseVertexBufferObjects(
1231 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1233 geometries_vertices.push_back(
new osg::Geometry());
1234 geometries_vertices[0]->setSupportsDisplayList(
true);
1235 geometries_vertices[0]->setUseDisplayList(
true);
1236 geometries_vertices[0]->setUseVertexBufferObjects(
1239 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1241 geometries_normals.push_back(
new osg::Geometry());
1242 geometries_normals[0]->setSupportsDisplayList(
true);
1243 geometries_normals[0]->setUseDisplayList(
true);
1244 geometries_normals[0]->setUseVertexBufferObjects(
1247 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1249 geometries_custom_vectors.push_back(
new osg::Geometry());
1250 geometries_custom_vectors[0]->setSupportsDisplayList(
true);
1251 geometries_custom_vectors[0]->setUseDisplayList(
true);
1252 geometries_custom_vectors[0]->setUseVertexBufferObjects(
1255 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1257 vertexArrays.push_back(
new osg::Vec3Array);
1259 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1261 vertexArrays_edges.push_back(
new osg::Vec3Array);
1263 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1265 vertexArrays_vertices.push_back(
new osg::Vec3Array);
1267 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1269 vertexArrays_normals.push_back(
new osg::Vec3Array);
1271 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1273 vertexArrays_custom_vectors.push_back(
new osg::Vec3Array);
1275 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1277 normalsArrays.push_back(
new osg::Vec3Array);
1279 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1281 normalsArraysF.push_back(
new osg::Vec3Array);
1283 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1285 normalsArrays_edges.push_back(
new osg::Vec3Array);
1287 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1289 normalsArrays_vertices.push_back(
new osg::Vec3Array);
1291 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1293 tangentsArrays.push_back(
new osg::Vec3Array);
1295 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1297 colorsArrays.push_back(
new osg::Vec4Array);
1299 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1301 colorsArrays_edges.push_back(
new osg::Vec4Array);
1303 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1305 colorsArrays_vertices.push_back(
new osg::Vec4Array);
1307 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1309 colorsArrays_normals.push_back(
new osg::Vec4Array);
1311 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1313 colorsArrays_custom_vectors.push_back(
new osg::Vec4Array);
1315 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1317 texcoordsArrays.push_back(
new osg::Vec2Array);
1323 for(
size_t mi = 1; mi < _m_mm_size; mi++)
1325 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1327 geometries.push_back(
new osg::Geometry());
1328 geometries[mi]->setSupportsDisplayList(
true);
1329 geometries[mi]->setUseDisplayList(
true);
1330 geometries[mi]->setUseVertexBufferObjects(
1333 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1335 geometriesL.push_back(
new osg::Geometry());
1336 geometriesL[mi]->setSupportsDisplayList(
true);
1337 geometriesL[mi]->setUseDisplayList(
true);
1338 geometriesL[mi]->setUseVertexBufferObjects(
1341 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1343 geometriesP.push_back(
new osg::Geometry());
1344 geometriesP[mi]->setSupportsDisplayList(
true);
1345 geometriesP[mi]->setUseDisplayList(
true);
1346 geometriesP[mi]->setUseVertexBufferObjects(
1349 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1351 geometries_edges.push_back(
new osg::Geometry());
1352 geometries_edges[mi]->setSupportsDisplayList(
true);
1353 geometries_edges[mi]->setUseDisplayList(
true);
1354 geometries_edges[mi]->setUseVertexBufferObjects(
1357 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1359 geometries_vertices.push_back(
new osg::Geometry());
1360 geometries_vertices[mi]->setSupportsDisplayList(
true);
1361 geometries_vertices[mi]->setUseDisplayList(
true);
1362 geometries_vertices[mi]->setUseVertexBufferObjects(
1365 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1367 geometries_normals.push_back(
new osg::Geometry());
1368 geometries_normals[mi]->setSupportsDisplayList(
true);
1369 geometries_normals[mi]->setUseDisplayList(
true);
1370 geometries_normals[mi]->setUseVertexBufferObjects(
1373 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1375 geometries_custom_vectors.push_back(
new osg::Geometry());
1376 geometries_custom_vectors[mi]->setSupportsDisplayList(
true);
1377 geometries_custom_vectors[mi]->setUseDisplayList(
true);
1378 geometries_custom_vectors[mi]->setUseVertexBufferObjects(
1381 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1383 vertexArrays.push_back(
new osg::Vec3Array);
1385 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1387 vertexArrays_edges.push_back(
new osg::Vec3Array);
1389 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1391 vertexArrays_vertices.push_back(
new osg::Vec3Array);
1393 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1395 vertexArrays_normals.push_back(
new osg::Vec3Array);
1397 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1399 vertexArrays_custom_vectors.push_back(
new osg::Vec3Array);
1401 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1403 normalsArrays.push_back(
new osg::Vec3Array);
1405 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1407 normalsArraysF.push_back(
new osg::Vec3Array);
1409 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1411 normalsArrays_edges.push_back(
new osg::Vec3Array);
1413 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1415 normalsArrays_vertices.push_back(
new osg::Vec3Array);
1417 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1419 tangentsArrays.push_back(
new osg::Vec3Array);
1421 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1423 colorsArrays.push_back(
new osg::Vec4Array);
1425 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1427 colorsArrays_edges.push_back(
new osg::Vec4Array);
1429 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1431 colorsArrays_vertices.push_back(
new osg::Vec4Array);
1433 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1435 colorsArrays_normals.push_back(
new osg::Vec4Array);
1437 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1439 colorsArrays_custom_vectors.push_back(
new osg::Vec4Array);
1441 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1443 texcoordsArrays.push_back(
new osg::Vec2Array);
1448 unsigned int sizeVertex = 0;
1449 unsigned int sizeFace = 0;
1450 unsigned int sizeSPoints = 0;
1451 unsigned int sizeSLines = 0;
1453 face_iterator fb, fe;
1456 halfedge_vector normal;
1458 bool texture_corner_mode_on =
1460 bool texture_vertex_mode_on =
1469 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1471 const float MAGNITUDE = 0.0005;
1475 HalfedgeGraph >::pmap_type;
1477 EdgeColorMap *_e_cm =
nullptr;
1488 halfedge_point ps, pt;
1490 edge_iterator eb, ee;
1491 for(boost::tie(eb, ee) =
edges(*_g); eb != ee; ++eb)
1498 vertexArrays_edges[mtl_id]->push_back( Helpers::VectorConverter< HalfedgeGraph >(ps) + Helpers::VectorConverter< HalfedgeGraph >(
get(v_nm, vs)) * MAGNITUDE );
1505 vertexArrays_edges[mtl_id]->push_back( Helpers::VectorConverter< HalfedgeGraph >(pt) + Helpers::VectorConverter< HalfedgeGraph >(
get(v_nm, vt)) * MAGNITUDE );
1512 colorsArrays_edges[mtl_id]->push_back(
1513 Helpers::VectorColorConverter< HalfedgeGraph >(
1515 colorsArrays_edges[mtl_id]->push_back(
1516 Helpers::VectorColorConverter< HalfedgeGraph >(
1521 colorsArrays_edges[mtl_id]->push_back(
1523 colorsArrays_edges[mtl_id]->push_back(
1530 normalsArrays_edges[mtl_id]->push_back(
1531 Helpers::VectorConverter< HalfedgeGraph >(
1534 normalsArrays_edges[mtl_id]->push_back(
1535 Helpers::VectorConverter< HalfedgeGraph >(
1540 geometries_edges[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
1541 osg::PrimitiveSet::LINES, 0, vertexArrays_edges[mtl_id]->size()));
1546 osg::ref_ptr< osg::LineWidth > linewidth =
new osg::LineWidth();
1547 linewidth->setWidth(1.5f);
1548 geometries_edges[mtl_id]
1549 ->getOrCreateStateSet()
1550 ->setAttribute(linewidth, osg::StateAttribute::ON);
1553 geometries_edges[mtl_id]->getOrCreateStateSet()->setMode(
1555 osg::StateAttribute::OFF);
1559 geometries_edges[mtl_id]->setStateSet(NULL);
1562 osg::ref_ptr< osg::LineWidth > linewidth =
new osg::LineWidth();
1563 linewidth->setWidth(1.5f);
1564 geometries_edges[mtl_id]
1565 ->getOrCreateStateSet()
1566 ->setAttribute(linewidth, osg::StateAttribute::ON);
1569 geometries_edges[mtl_id]->getOrCreateStateSet()->setMode(
1571 osg::StateAttribute::OFF);
1578 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1580 const float MAGNITUDE_N = 0.08;
1584 VertexColorMap *SAVE_vt_cm = _vt_cm;
1594 for(vertex_iterator v_it =
vertices(*_g).first;
1603 vertexArrays_vertices[mtl_id]->push_back(
1604 Helpers::VectorConverter< HalfedgeGraph >(p0));
1607 vertexArrays_normals[mtl_id]->push_back( Helpers::VectorConverter< HalfedgeGraph >(p0) );
1608 vertexArrays_normals[mtl_id]->push_back( Helpers::VectorConverter< HalfedgeGraph >(p0) + Helpers::VectorConverter< HalfedgeGraph >(
get(v_nm, *v_it)) * 0.5 * MAGNITUDE_N );
1614 float MAGNITUDE_CV = 0.08;
1625 MAGNITUDE_CV = _vector[2];
1628 vertexArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorConverter< HalfedgeGraph >(p0) - Helpers::VectorConverter< HalfedgeGraph >(
get(v_CVm, *v_it)) * B_CV * MAGNITUDE_CV );
1629 vertexArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorConverter< HalfedgeGraph >(p0) + Helpers::VectorConverter< HalfedgeGraph >(
get(v_CVm, *v_it)) * E_CV * MAGNITUDE_CV );
1637 colorsArrays_vertices[mtl_id]->push_back(
1638 Helpers::VectorColorConverter< HalfedgeGraph >(
1641 colorsArrays_vertices[mtl_id]->push_back(
1646 normalsArrays_vertices[mtl_id]->push_back(
1647 Helpers::VectorConverter< HalfedgeGraph >(
1658 colorsArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorColorConverter< HalfedgeGraph >(
get(v_CVCm, *v_it)) );
1659 colorsArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorColorConverter< HalfedgeGraph >(
get(v_CVCm, *v_it)) );
1669 geometries_vertices[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
1670 osg::PrimitiveSet::POINTS, 0, vertexArrays_vertices[mtl_id]->size()));
1673 geometries_normals[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
1674 osg::PrimitiveSet::LINES, 0, vertexArrays_normals[mtl_id]->size()));
1678 geometries_custom_vectors[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
1679 osg::PrimitiveSet::LINES, 0, vertexArrays_custom_vectors[mtl_id]->size()));
1684 if(m_RenderSuperimposedVertices || m_RenderSuperimposedVertices_Big)
1687 osg::ref_ptr< osg::Point > pt =
new osg::Point();
1688 if(m_RenderSuperimposedVertices_Big)
1692 geometries_vertices[mtl_id]->getOrCreateStateSet()->setAttribute(
1693 pt, osg::StateAttribute::ON);
1697 geometries_vertices[mtl_id]->getOrCreateStateSet()->setMode(
1698 GL_LIGHTING, osg::StateAttribute::OFF);
1704 _vt_cm = SAVE_vt_cm;
1707 geometries_vertices[mtl_id]->setStateSet(NULL);
1710 osg::ref_ptr< osg::Point > pt =
new osg::Point();
1711 if(m_RenderSuperimposedVertices_Big)
1713 else if(m_RenderSuperimposedVertices)
1717 geometries_vertices[mtl_id]->getOrCreateStateSet()->setAttribute(
1718 pt, osg::StateAttribute::ON);
1721 geometries_vertices[mtl_id]->getOrCreateStateSet()->setMode(
1722 GL_LIGHTING, osg::StateAttribute::OFF);
1726 geometries_normals[mtl_id]->setStateSet(NULL);
1729 osg::ref_ptr< osg::LineWidth > linewidth =
new osg::LineWidth();
1730 linewidth->setWidth(1.5f);
1731 geometries_normals[mtl_id]
1732 ->getOrCreateStateSet()
1733 ->setAttribute(linewidth, osg::StateAttribute::ON);
1736 geometries_normals[mtl_id]->getOrCreateStateSet()->setMode(
1738 osg::StateAttribute::OFF);
1742 geometries_custom_vectors[mtl_id]->setStateSet(NULL);
1745 osg::ref_ptr< osg::LineWidth > linewidth =
new osg::LineWidth();
1746 linewidth->setWidth(1.5f);
1747 geometries_custom_vectors[mtl_id]
1748 ->getOrCreateStateSet()
1749 ->setAttribute(linewidth, osg::StateAttribute::ON);
1752 geometries_custom_vectors[mtl_id]->getOrCreateStateSet()->setMode(
1754 osg::StateAttribute::OFF);
1759 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
1763 for(boost::tie(fb, fe) =
faces(*_g); fb != fe; ++fb)
1767 if(texture_corner_mode_on || texture_vertex_mode_on)
1769 mtl_id =
get(*_f_mm, *fb);
1774 halfedge_descriptor edg =
halfedge(*fb, *_g);
1775 halfedge_descriptor edg_begin = edg;
1777 std::vector< halfedge_point > p;
1778 std::vector< vertex_descriptor > vd;
1783 vd.push_back(
target(edg, *_g));
1784 p.push_back((*_pm)[vd.back()]);
1786 vertexArrays[mtl_id]->push_back(
1787 Helpers::VectorConverter< HalfedgeGraph >(p.back()));
1789 if(_vt_cm !=
nullptr)
1791 colorsArrays[mtl_id]->push_back(
1792 Helpers::VectorColorConverter< HalfedgeGraph >(
1793 (*_vt_cm)[vd.back()]));
1798 texcoordsArrays[mtl_id]->push_back(
1799 osg::Vec2((*_het_uv_m)[edg][0], (*_het_uv_m)[edg][1]));
1803 texcoordsArrays[mtl_id]->push_back(
1804 osg::Vec2((*_vt_uv_m)[vd.back()][0], (*_vt_uv_m)[vd.back()][1]));
1807 if(_vt_nm !=
nullptr)
1811 normal = (*_vt_nm)[vd.back()];
1812 normalsArrays[mtl_id]->push_back(
1813 Helpers::VectorConverter< HalfedgeGraph >(
1818 normal = (*_f_nm)[*fb];
1819 normalsArraysF[mtl_id]->push_back(
1820 Helpers::VectorConverter< HalfedgeGraph >(
1825 if(v_tan_m !=
nullptr)
1830 tangentsArrays[mtl_id]->push_back(
1831 osg::Vec3((*v_tan_m)[vd.back()][0],
1832 (*v_tan_m)[vd.back()][1],
1833 (*v_tan_m)[vd.back()][2]));
1839 edg =
next(edg, *_g);
1840 }
while(edg != edg_begin);
1843 uint num_vertices_in_face =
static_cast< uint
>(p.size());
1845 auto drawing_method =
1846 static_cast< osg::PrimitiveSet::Mode
>(m_RenderMethod);
1847 if(m_RenderMethod ==
1850 if(num_vertices_in_face == 3)
1851 drawing_method = osg::PrimitiveSet::TRIANGLES;
1852 else if(num_vertices_in_face == 4)
1854 drawing_method = osg::PrimitiveSet::QUADS;
1863 geometries[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
1865 vertexArrays[mtl_id]->size() - num_vertices_in_face,
1866 num_vertices_in_face));
1868 geometriesL[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
1870 vertexArrays[mtl_id]->size() - num_vertices_in_face,
1871 num_vertices_in_face));
1872 geometriesP[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
1874 vertexArrays[mtl_id]->size() - num_vertices_in_face,
1875 num_vertices_in_face));
1878 if(_vt_nm !=
nullptr)
1884 else if(_f_nm !=
nullptr)
1886 std::cout <<
"---> normal per face - normal per face - normal per face --> MUST NEVER HAPPENS !!!"
1889 normal = (*_f_nm)[*fb];
1890 normalsArrays[mtl_id]->push_back(
1891 Helpers::VectorConverter< HalfedgeGraph >(normal));
1895 std::cout <<
"---> NEVER HAPPENS - NEVER HAPPENS - NEVER HAPPENS"
1899 if(num_vertices_in_face == 3)
1901 normal = gt.unit_normal(p[1], p[2], p[0]);
1902 normalsArrays[mtl_id]->push_back(
1903 Helpers::VectorConverter< HalfedgeGraph >(normal));
1905 else if(num_vertices_in_face == 4)
1907 normal = gt.NULL_VECTOR;
1908 normal = gt.normal(p[1], p[2], p[0]) + gt.normal(p[2], p[3], p[1]);
1909 normal = normal / gt.length(normal);
1910 normalsArrays[mtl_id]->push_back(
1911 Helpers::VectorConverter< HalfedgeGraph >(normal));
1916 std::cerr <<
"-----> [SimpleViewer] Only re-computed normals for "
1917 "triangles/quads are implemented -> re-computed normals "
1918 "for other polygons are not yet implemented."
1925 if(_f_cm !=
nullptr)
1927 colorsArrays[mtl_id]->push_back(
1928 Helpers::VectorColorConverter< HalfedgeGraph >((*_f_cm)[*fb]));
1934 std::cout <<
"[SimpleViewer] I have drawn " << sizeFace <<
" faces (with "
1935 << sizeVertex <<
" vertices)." << std::endl;
1936 std::cout <<
"[SimpleViewer] I have also drawn " << sizeSPoints
1937 <<
" (superimpose) points and " << sizeSLines
1938 <<
" superimpose lines." << std::endl;
1942 QApplication::restoreOverrideCursor();
1947 const auto loadingStartTime = std::chrono::system_clock::now();
1949 QApplication::setOverrideCursor(Qt::BusyCursor);
1950 sw->statusBar()->showMessage(
QObject::tr(
"Render mesh...") );
1953 std::vector< osg::ref_ptr< osg::Vec3Array > > *_normalsArrays =
nullptr;
1954 if(m_SmoothFlat_Shading)
1955 _normalsArrays = &normalsArrays;
1957 _normalsArrays = &normalsArraysF;
1960 std::vector< osg::ref_ptr< osg::Geometry > > *_geometries =
nullptr;
1962 _geometries = &geometries;
1964 _geometries = &geometriesL;
1966 _geometries = &geometriesP;
1968 if(m_RenderMode == RenderMode::RENDER_SHADERS_DIRECT_LIGHTING ||
1971 internal_loadShadedMesh(geode,
1975 geometries_vertices,
1977 geometries_custom_vectors,
1980 vertexArrays_vertices,
1981 vertexArrays_normals,
1982 vertexArrays_custom_vectors,
1984 normalsArrays_edges,
1985 normalsArrays_vertices,
1990 colorsArrays_vertices,
1991 colorsArrays_normals,
1992 colorsArrays_custom_vectors,
2005 std::cout <<
"[SimpleViewer] Rendering with indirect lighting."
2008 geode->getOrCreateStateSet()->addUniform(
2009 new osg::Uniform(
"uniUseIndirectLighting",
true));
2013 std::cout <<
"[SimpleViewer] Rendering with direct lighting."
2019 internal_loadLegacyMesh(geode,
2023 geometries_vertices,
2025 geometries_custom_vectors,
2028 vertexArrays_vertices,
2029 vertexArrays_normals,
2030 vertexArrays_custom_vectors,
2032 normalsArrays_edges,
2033 normalsArrays_vertices,
2037 colorsArrays_vertices,
2038 colorsArrays_normals,
2039 colorsArrays_custom_vectors,
2052 QApplication::restoreOverrideCursor();
2054 std::cout <<
"[SimpleViewer] Done 'loading' mesh (in graphic card) in "
2055 << std::chrono::duration_cast< std::chrono::duration< float > >(
2056 std::chrono::system_clock::now() - loadingStartTime)
2058 <<
" seconds." << std::endl;
2060 gizmo->setNodeMask(m_ShowAxis ? 0xffffffff : 0x0);
2061 grid->setNodeMask(m_ShowGrid ? 0xffffffff : 0x0);
2070 std::string ds_name = FEVV::getDatastructureName(_g);
2071 geode->setName(_mesh_file + std::string(
" [") + ds_name +
" " +
2072 bavQt->windowTitle().left(bavQt->windowTitle().indexOf(
'>') + 1).toStdString() + std::string(
"]"));
2073 geode->addDescription(
"MESH");
2077 template<
typename Po
intCloud,
typename Po
intMap >
2083 std::vector< osg::ref_ptr< osg::Geometry > > &geometries,
2084 std::vector< osg::ref_ptr< osg::Geometry > > &geometriesL,
2085 std::vector< osg::ref_ptr< osg::Geometry > > &geometriesP,
2086 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_edges,
2087 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_vertices,
2088 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_normals,
2089 std::vector< osg::ref_ptr< osg::Geometry > > &geometries_custom_vectors,
2090 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays,
2091 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_edges,
2092 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_vertices,
2093 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_normals,
2094 std::vector< osg::ref_ptr< osg::Vec3Array > > &vertexArrays_custom_vectors,
2095 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays,
2096 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArraysF,
2097 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays_edges,
2098 std::vector< osg::ref_ptr< osg::Vec3Array > > &normalsArrays_vertices,
2099 std::vector< osg::ref_ptr< osg::Vec3Array > > &tangentsArrays,
2100 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays,
2101 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_edges,
2102 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_vertices,
2103 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_normals,
2104 std::vector< osg::ref_ptr< osg::Vec4Array > > &colorsArrays_custom_vectors,
2105 std::vector< osg::ref_ptr< osg::Vec2Array > > &texcoordsArrays,
2107 std::string _mesh_file)
2109 using GraphTraits = boost::graph_traits< PointCloud >;
2112 using vertex_iterator =
typename GraphTraits::vertex_iterator;
2117 using VertexNormalMap =
2119 PointCloud >::pmap_type;
2121 PointCloud >::pmap_type;
2123 using VertexCustomVectorMap =
2125 PointCloud >::pmap_type;
2127 using VertexCustomVectorColorMap =
2129 PointCloud >::pmap_type;
2131 using VertexCustomVectorParamMap =
2133 PointCloud >::pmap_type;
2135 using MeshGuipropertiesMap =
2137 PointCloud >::pmap_type;
2139 VertexNormalMap v_nm;
2140 VertexColorMap v_cm;
2142 VertexCustomVectorMap v_CVm;
2143 VertexCustomVectorColorMap v_CVCm;
2144 VertexCustomVectorParamMap v_CVPm;
2146 MeshGuipropertiesMap m_gpm;
2148 VertexNormalMap *_vt_nm =
nullptr;
2149 VertexColorMap *_vt_cm =
nullptr;
2151 VertexCustomVectorMap *_vt_CVm =
nullptr;
2152 VertexCustomVectorColorMap *_vt_CVCm =
nullptr;
2153 VertexCustomVectorParamMap *_vt_CVPm =
nullptr;
2155 size_t _m_mm_size = 0;
2166 put(m_gpm, 0, gui_props);
2176 std::cout <<
"[SimpleViewer] using vertex normal" << std::endl;
2181 #if 0 //TODO-elo-restore-if-needed
2183 if(_vt_nm ==
nullptr || m_recomputeNT_if_redraw)
2186 std::cout <<
"[SimpleViewer] vertex normal missing, computing it"
2201 std::cout <<
"[SimpleViewer] using vertex color" << std::endl;
2208 m_UseVertexColor =
true;
2209 m_UseFaceColor =
false;
2210 m_UseTexture =
false;
2219 std::cout <<
"[SimpleViewer] using vertex CUSTOM VECTOR" << std::endl;
2225 if(_vt_CVm ==
nullptr || m_recomputeNT_if_redraw)
2228 std::cout <<
"[SimpleViewer] vertex CUSTOM VECTOR missing, filling it with example values"
2236 auto iterator_pair =
vertices(*_g);
2237 vertex_iterator vi = iterator_pair.first;
2238 vertex_iterator vi_end = iterator_pair.second;
2239 for (; vi != vi_end; ++vi)
2241 v_CVm[*vi] =
Vector(-1., 1., 1.);
2255 std::cout <<
"[SimpleViewer] using vertex CUSTOM VECTOR COLOR" << std::endl;
2261 if(_vt_CVCm ==
nullptr || m_recomputeNT_if_redraw)
2264 std::cout <<
"[SimpleViewer] vertex CUSTOM VECTOR COLOR missing, filling it with example values"
2272 auto iterator_pair =
vertices(*_g);
2273 vertex_iterator vi = iterator_pair.first;
2274 vertex_iterator vi_end = iterator_pair.second;
2275 for (; vi != vi_end; ++vi)
2277 v_CVCm[*vi] =
Vector(22/255.0f, 160/255.0f, 133/255.0f);
2291 std::cout <<
"[SimpleViewer] using vertex CUSTOM VECTOR PARAM" << std::endl;
2297 if(_vt_CVPm ==
nullptr || m_recomputeNT_if_redraw)
2300 std::cout <<
"[SimpleViewer] vertex CUSTOM VECTOR PARAM missing, filling it with example values"
2308 auto iterator_pair =
vertices(*_g);
2309 vertex_iterator vi = iterator_pair.first;
2310 vertex_iterator vi_end = iterator_pair.second;
2311 for (; vi != vi_end; ++vi)
2313 v_CVPm[*vi] =
Vector(0.1f, 0.1f, 0.08f);
2325 if(m_UseVertexColor)
2326 if((!m_space_time) || (m_space_time && m_space_time_changeColorMode))
2330 if(m_UseVertexColor)
2366 QApplication::setOverrideCursor(Qt::ForbiddenCursor);
2370 sw->statusBar()->showMessage(
2371 QObject::tr(
"Create and populate OSG objects...") );
2373 GeometryTraits gt(*_g);
2375 if(geode ==
nullptr)
2377 geode =
new osg::Geode;
2382 geode->removeDrawables(0, geode->getNumDrawables());
2386 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2388 geometries.push_back(
new osg::Geometry());
2389 geometries[0]->setSupportsDisplayList(
true);
2390 geometries[0]->setUseDisplayList(
true);
2391 geometries[0]->setUseVertexBufferObjects(
2394 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2396 geometriesL.push_back(
new osg::Geometry());
2397 geometriesL[0]->setSupportsDisplayList(
true);
2398 geometriesL[0]->setUseDisplayList(
true);
2399 geometriesL[0]->setUseVertexBufferObjects(
2402 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2404 geometriesP.push_back(
new osg::Geometry());
2405 geometriesP[0]->setSupportsDisplayList(
true);
2406 geometriesP[0]->setUseDisplayList(
true);
2407 geometriesP[0]->setUseVertexBufferObjects(
2410 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2412 geometries_edges.push_back(
new osg::Geometry());
2413 geometries_edges[0]->setSupportsDisplayList(
true);
2414 geometries_edges[0]->setUseDisplayList(
true);
2415 geometries_edges[0]->setUseVertexBufferObjects(
2418 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2420 geometries_vertices.push_back(
new osg::Geometry());
2421 geometries_vertices[0]->setSupportsDisplayList(
true);
2422 geometries_vertices[0]->setUseDisplayList(
true);
2423 geometries_vertices[0]->setUseVertexBufferObjects(
2426 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2428 geometries_normals.push_back(
new osg::Geometry());
2429 geometries_normals[0]->setSupportsDisplayList(
true);
2430 geometries_normals[0]->setUseDisplayList(
true);
2431 geometries_normals[0]->setUseVertexBufferObjects(
2434 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2436 geometries_custom_vectors.push_back(
new osg::Geometry());
2437 geometries_custom_vectors[0]->setSupportsDisplayList(
true);
2438 geometries_custom_vectors[0]->setUseDisplayList(
true);
2439 geometries_custom_vectors[0]->setUseVertexBufferObjects(
2442 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2444 vertexArrays.push_back(
new osg::Vec3Array);
2446 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2448 vertexArrays_edges.push_back(
new osg::Vec3Array);
2450 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2452 vertexArrays_vertices.push_back(
new osg::Vec3Array);
2454 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2456 vertexArrays_normals.push_back(
new osg::Vec3Array);
2458 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2460 vertexArrays_custom_vectors.push_back(
new osg::Vec3Array);
2462 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2464 normalsArrays.push_back(
new osg::Vec3Array);
2466 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2468 normalsArraysF.push_back(
new osg::Vec3Array);
2470 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2472 normalsArrays_edges.push_back(
new osg::Vec3Array);
2474 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2476 normalsArrays_vertices.push_back(
new osg::Vec3Array);
2478 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2480 tangentsArrays.push_back(
new osg::Vec3Array);
2482 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2484 colorsArrays.push_back(
new osg::Vec4Array);
2486 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2488 colorsArrays_edges.push_back(
new osg::Vec4Array);
2490 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2492 colorsArrays_vertices.push_back(
new osg::Vec4Array);
2494 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2496 colorsArrays_normals.push_back(
new osg::Vec4Array);
2498 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2500 colorsArrays_custom_vectors.push_back(
new osg::Vec4Array);
2502 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2504 texcoordsArrays.push_back(
new osg::Vec2Array);
2510 unsigned int sizeSPoints = 0;
2516 if((!m_redraw) || (m_redraw && m_recreateOSGobj_if_redraw))
2518 const float MAGNITUDE_N = 0.08;
2522 VertexColorMap *SAVE_vt_cm = _vt_cm;
2532 for(vertex_iterator v_it =
vertices(*_g).first;
2541 vertexArrays_vertices[mtl_id]->push_back(
2542 Helpers::VectorConverter< PointCloud >(
2543 Vector(GeometryTraits::get_x(p0),
2544 GeometryTraits::get_y(p0),
2545 GeometryTraits::get_z(p0))));
2549 vertexArrays_normals[mtl_id]->push_back( Helpers::VectorConverter< PointCloud >(p0) );
2550 vertexArrays_normals[mtl_id]->push_back( Helpers::VectorConverter< PointCloud >(p0) + Helpers::VectorConverter< PointCloud >(
get(v_nm, *v_it)) * 0.5 * MAGNITUDE_N );
2557 float MAGNITUDE_CV = 0.08;
2568 MAGNITUDE_CV = _vector[2];
2571 vertexArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorConverter< PointCloud >(p0) - Helpers::VectorConverter< PointCloud >(
get(v_CVm, *v_it)) * B_CV * MAGNITUDE_CV );
2572 vertexArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorConverter< PointCloud >(p0) + Helpers::VectorConverter< PointCloud >(
get(v_CVm, *v_it)) * E_CV * MAGNITUDE_CV );
2581 auto color_uint8 =
get(v_cm, *v_it);
2582 osg::Vec4 colorf((
float)(color_uint8[0]/255.0f),
2583 (
float)(color_uint8[1]/255.0f),
2584 (
float)(color_uint8[2]/255.0f),
2586 colorsArrays_vertices[mtl_id]->push_back(colorf);
2590 colorsArrays_vertices[mtl_id]->push_back(
2596 normalsArrays_vertices[mtl_id]->push_back(
2597 Helpers::VectorConverter< PointCloud >(
2608 colorsArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorColorConverter< PointCloud >(
get(v_CVCm, *v_it)) );
2609 colorsArrays_custom_vectors[mtl_id]->push_back( Helpers::VectorColorConverter< PointCloud >(
get(v_CVCm, *v_it)) );
2619 geometries_vertices[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
2620 osg::PrimitiveSet::POINTS, 0, vertexArrays_vertices[mtl_id]->size()));
2623 geometries_normals[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
2624 osg::PrimitiveSet::LINES, 0, vertexArrays_normals[mtl_id]->size()));
2628 geometries_custom_vectors[mtl_id]->addPrimitiveSet(
new osg::DrawArrays(
2629 osg::PrimitiveSet::LINES, 0, vertexArrays_custom_vectors[mtl_id]->size()));
2632 _vt_cm = SAVE_vt_cm;
2634 std::cout <<
"[SimpleViewer] I have drawn " << sizeSPoints <<
" points." << std::endl;
2638 geometries_vertices[mtl_id]->setStateSet(NULL);
2641 osg::ref_ptr< osg::Point > pt =
new osg::Point();
2642 if(m_RenderSuperimposedVertices_Big)
2644 else if(m_RenderSuperimposedVertices)
2648 geometries_vertices[mtl_id]->getOrCreateStateSet()->setAttribute(
2649 pt, osg::StateAttribute::ON);
2652 geometries_vertices[mtl_id]->getOrCreateStateSet()->setMode(
2653 GL_LIGHTING, osg::StateAttribute::OFF);
2658 geometries_normals[mtl_id]->setStateSet(NULL);
2661 osg::ref_ptr< osg::LineWidth > linewidth =
new osg::LineWidth();
2662 linewidth->setWidth(1.5f);
2663 geometries_normals[mtl_id]
2664 ->getOrCreateStateSet()
2665 ->setAttribute(linewidth, osg::StateAttribute::ON);
2668 geometries_normals[mtl_id]->getOrCreateStateSet()->setMode(
2670 osg::StateAttribute::OFF);
2675 geometries_custom_vectors[mtl_id]->setStateSet(NULL);
2678 osg::ref_ptr< osg::LineWidth > linewidth =
new osg::LineWidth();
2679 linewidth->setWidth(1.5f);
2680 geometries_custom_vectors[mtl_id]
2681 ->getOrCreateStateSet()
2682 ->setAttribute(linewidth, osg::StateAttribute::ON);
2685 geometries_custom_vectors[mtl_id]->getOrCreateStateSet()->setMode(
2687 osg::StateAttribute::OFF);
2692 QApplication::restoreOverrideCursor();
2694 const auto loadingStartTime = std::chrono::system_clock::now();
2696 QApplication::setOverrideCursor(Qt::BusyCursor);
2697 sw->statusBar()->showMessage(
QObject::tr(
"Render mesh...") );
2700 std::vector< osg::ref_ptr< osg::Vec3Array > > *_normalsArrays =
nullptr;
2701 if(m_SmoothFlat_Shading)
2702 _normalsArrays = &normalsArrays;
2704 _normalsArrays = &normalsArraysF;
2707 std::vector< osg::ref_ptr< osg::Geometry > > *_geometries =
nullptr;
2708 _geometries = &geometriesP;
2710 if(m_RenderMode == RenderMode::RENDER_SHADERS_DIRECT_LIGHTING ||
2713 using VertexTangentMap =
2715 PointCloud >::pmap_type;
2716 using FaceColorMap =
2718 PointCloud >::pmap_type;
2721 PointCloud >::pmap_type;
2722 using HalfedgeUVMap =
2724 PointCloud >::pmap_type;
2725 using MeshMaterialsMap =
2727 PointCloud >::pmap_type;
2729 VertexTangentMap *v_tan_m =
nullptr;
2730 FaceColorMap *_f_cm =
nullptr;
2731 VertexUVMap *_vt_uv_m =
nullptr;
2732 HalfedgeUVMap *_het_uv_m =
nullptr;
2733 MeshMaterialsMap *_m_mm =
nullptr;
2735 internal_loadShadedMesh(geode,
2739 geometries_vertices,
2741 geometries_custom_vectors,
2744 vertexArrays_vertices,
2745 vertexArrays_normals,
2746 vertexArrays_custom_vectors,
2748 normalsArrays_edges,
2749 normalsArrays_vertices,
2754 colorsArrays_vertices,
2755 colorsArrays_normals,
2756 colorsArrays_custom_vectors,
2769 std::cout <<
"[SimpleViewer] Rendering with indirect lighting."
2772 geode->getOrCreateStateSet()->addUniform(
2773 new osg::Uniform(
"uniUseIndirectLighting",
true));
2777 std::cout <<
"[SimpleViewer] Rendering with direct lighting."
2783 using FaceColorMap =
2785 PointCloud >::pmap_type;
2788 PointCloud >::pmap_type;
2789 using HalfedgeUVMap =
2791 PointCloud >::pmap_type;
2792 using MeshMaterialsMap =
2794 PointCloud >::pmap_type;
2796 FaceColorMap *_f_cm =
nullptr;
2797 VertexUVMap *_vt_uv_m =
nullptr;
2798 HalfedgeUVMap *_het_uv_m =
nullptr;
2799 MeshMaterialsMap *_m_mm =
nullptr;
2802 internal_loadLegacyMesh(geode,
2806 geometries_vertices,
2808 geometries_custom_vectors,
2811 vertexArrays_vertices,
2812 vertexArrays_normals,
2813 vertexArrays_custom_vectors,
2815 normalsArrays_edges,
2816 normalsArrays_vertices,
2820 colorsArrays_vertices,
2821 colorsArrays_normals,
2822 colorsArrays_custom_vectors,
2835 QApplication::restoreOverrideCursor();
2837 std::cout <<
"[SimpleViewer] Done 'loading' mesh (in graphic card) in "
2838 << std::chrono::duration_cast< std::chrono::duration< float > >(
2839 std::chrono::system_clock::now() - loadingStartTime)
2841 <<
" seconds." << std::endl;
2843 gizmo->setNodeMask(m_ShowAxis ? 0xffffffff : 0x0);
2844 grid->setNodeMask(m_ShowGrid ? 0xffffffff : 0x0);
2853 std::string ds_name = FEVV::getDatastructureName(_g);
2854 geode->setName(_mesh_file + std::string(
" [") + ds_name +
" " +
2855 bavQt->windowTitle().left(bavQt->windowTitle().indexOf(
'>') + 1).toStdString() + std::string(
"]"));
2856 geode->addDescription(
"MESH");
2866 virtual bool constrain(osgManipulator::Scale1DCommand &command)
const
2868 command.setScale(1.0f);
2873 virtual bool constrain(osgManipulator::Scale2DCommand &command)
const
2875 command.setScale(osg::Vec2d(1.0, 1.0));
2884 osgManipulator::Dragger *
2887 osgManipulator::Dragger *dragger = 0;
2889 if(name ==
"TrackballDragger")
2891 osgManipulator::TrackballDragger *d =
2892 new osgManipulator::TrackballDragger();
2893 d->setupDefaultGeometry();
2894 #if OSG_MIN_VERSION_REQUIRED(3, 4, 0)
2895 d->setAxisLineWidth(2.0f);
2902 osgManipulator::TabBoxDragger *d =
new osgManipulator::TabBoxDragger();
2904 d->setupDefaultGeometry();
2905 d->setPlaneColor(osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f));
2910 dragger->setName(name);
2920 const std::string &nameDrag1,
2923 const std::string &nameDrag2,
2945 osg::MatrixTransform *transform =
new osg::MatrixTransform;
2946 transform->setName(
"MatrixTransform");
2947 transform->addChild(scene);
2949 osg::Group *root =
new osg::Group;
2950 root->setName(
"GroupRoot");
2951 root->addChild(transform);
2955 osgManipulator::Dragger *dragger1 =
createDragger(nameDrag1);
2957 osg::Group *draggergroup1 =
new osg::Group;
2958 draggergroup1->setName(
"DraggerGrp1_translate");
2959 draggergroup1->addChild(dragger1);
2960 root->addChild(draggergroup1);
2961 scale = scene->getBound().radius() * fScaleDrag1;
2962 dragger1->setMatrix(osg::Matrix::scale(scale, scale, scale) *
2964 dragger1->addTransformUpdating(transform);
2965 dragger1->setHandleEvents(
true);
2966 dragger1->setActivationKeyEvent(keyDrag1);
2968 dragger1->setNodeMask(m_ShowTranslateDragger ? 0xffffffff : 0x0);
2969 v_draggers1.push_back(dragger1);
2971 osgManipulator::Dragger *dragger2 =
createDragger(nameDrag2);
2973 osg::Group *draggergroup2 =
new osg::Group;
2974 draggergroup2->setName(
"DraggerGrp2_rotate");
2975 draggergroup2->addChild(dragger2);
2976 transform->addChild(
2979 scale = scene->getBound().radius() * fScaleDrag2;
2980 dragger2->setMatrix(osg::Matrix::scale(scale, scale, scale) *
2982 dragger2->addTransformUpdating(transform);
2983 dragger2->setHandleEvents(
true);
2984 dragger2->setActivationKeyEvent(keyDrag2);
2986 dragger2->setNodeMask(m_ShowRotateDragger ? 0xffffffff : 0x0);
2987 v_draggers2.push_back(dragger2);
2994 template<
typename HalfedgeGraph,
typename Po
intMap >
2995 osg::ref_ptr< osg::Group >
3000 std::string _mesh_file,
3001 osg::ref_ptr< osg::Group > _group)
3003 std::vector< osg::ref_ptr< osg::Geometry > > l_geometries, l_geometriesL,
3004 l_geometriesP, l_geometries_edges, l_geometries_vertices, l_geometries_normals, l_geometries_custom_vectors;
3005 std::vector< osg::ref_ptr< osg::Vec3Array > > l_vertexArrays,
3006 l_vertexArrays_edges, l_vertexArrays_vertices, l_vertexArrays_normals, l_vertexArrays_custom_vectors;
3007 std::vector< osg::ref_ptr< osg::Vec3Array > > l_normalsArrays,
3008 l_normalsArraysF, l_normalsArrays_edges, l_normalsArrays_vertices, l_tangentsArrays;
3009 std::vector< osg::ref_ptr< osg::Vec4Array > > l_colorsArrays,
3010 l_colorsArrays_edges, l_colorsArrays_vertices, l_colorsArrays_normals, l_colorsArrays_custom_vectors;
3011 std::vector< osg::ref_ptr< osg::Vec2Array > > l_texcoordsArrays;
3013 osg::Geode *geode = internal_createMesh(_g,
3019 l_geometries_vertices,
3020 l_geometries_normals,
3021 l_geometries_custom_vectors,
3023 l_vertexArrays_edges,
3024 l_vertexArrays_vertices,
3025 l_vertexArrays_normals,
3026 l_vertexArrays_custom_vectors,
3029 l_normalsArrays_edges,
3030 l_normalsArrays_vertices,
3033 l_colorsArrays_edges,
3034 l_colorsArrays_vertices,
3035 l_colorsArrays_normals,
3036 l_colorsArrays_custom_vectors,
3042 _group->addChild(addDraggersToScene(
3043 geode,
"TabBoxDragger", 2.0,
't',
"TrackballDragger", 1.0,
'r'));
3045 _group->addChild(geode);
3048 v_geometries.push_back(l_geometries);
3049 v_geometriesL.push_back(l_geometriesL);
3050 v_geometriesP.push_back(l_geometriesP);
3051 v_geometries_edges.push_back(l_geometries_edges);
3052 v_geometries_vertices.push_back(l_geometries_vertices);
3053 v_geometries_normals.push_back(l_geometries_normals);
3054 v_geometries_custom_vectors.push_back(l_geometries_custom_vectors);
3055 v_vertexArrays.push_back(l_vertexArrays);
3056 v_vertexArrays_edges.push_back(l_vertexArrays_edges);
3057 v_vertexArrays_vertices.push_back(l_vertexArrays_vertices);
3058 v_vertexArrays_normals.push_back(l_vertexArrays_normals);
3059 v_vertexArrays_custom_vectors.push_back(l_vertexArrays_custom_vectors);
3060 v_normalsArrays.push_back(l_normalsArrays);
3061 v_normalsArraysF.push_back(l_normalsArraysF);
3062 v_normalsArrays_edges.push_back(l_normalsArrays_edges);
3063 v_normalsArrays_vertices.push_back(l_normalsArrays_vertices);
3064 v_tangentsArrays.push_back(l_tangentsArrays);
3065 v_colorsArrays.push_back(l_colorsArrays);
3066 v_colorsArrays_edges.push_back(l_colorsArrays_edges);
3067 v_colorsArrays_vertices.push_back(l_colorsArrays_vertices);
3068 v_colorsArrays_normals.push_back(l_colorsArrays_normals);
3069 v_colorsArrays_custom_vectors.push_back(l_colorsArrays_custom_vectors);
3070 v_texcoordsArrays.push_back(l_texcoordsArrays);
3072 v_mixed_meshes.push_back(_g);
3073 v_meshes_names.push_back(_mesh_file);
3074 v_properties_maps.push_back(_pmaps);
3075 v_geodes.push_back(geode);
3076 v_meshIsSelected.push_back(
false);
3079 setNodeSelected(geode,
true);
3098 template<
typename HalfedgeGraph,
typename Po
intMap >
3103 std::string _mesh_file)
3105 QApplication::setOverrideCursor(Qt::BusyCursor);
3110 sw->statusBar()->showMessage(
3111 QObject::tr(
"Draw : calculate normals & tangents...") );
3115 m_recomputeNT_if_redraw =
false;
3116 m_recreateOSGobj_if_redraw =
true;
3119 addGroup(createMesh(_g, _pmaps, _pm, _mesh_file));
3122 QApplication::restoreOverrideCursor();
3125 template<
typename HalfedgeGraph,
typename Po
intMap >
3130 std::string _mesh_file)
3132 QApplication::setOverrideCursor(Qt::BusyCursor);
3136 if(m_recomputeNT_if_redraw)
3137 sw->statusBar()->showMessage(
3138 QObject::tr(
"Redraw : recalculate normals & tangents...") );
3141 "Redraw : get already calculated normals & tangents...") );
3151 position = getMeshId(
static_cast< void *
>(_g));
3154 #pragma GCC diagnostic push
3155 #pragma GCC diagnostic warning "-Wsign-compare"
3158 "mesh was not found. Leaving...",
3159 "SimpleViewer::redrawMesh"))
3164 #pragma GCC diagnostic pop
3168 if(_mesh_file != std::string(
""))
3169 v_meshes_names[position] = _mesh_file;
3175 v_geodes[position]->setStateSet(NULL);
3177 if(m_recreateOSGobj_if_redraw)
3179 v_geometries[position].clear();
3180 v_geometriesL[position].clear();
3181 v_geometriesP[position].clear();
3182 v_vertexArrays[position].clear();
3183 v_colorsArrays[position].clear();
3185 v_normalsArrays[position].clear();
3186 v_normalsArraysF[position].clear();
3187 v_tangentsArrays[position].clear();
3189 v_texcoordsArrays[position].clear();
3191 if(m_recreateOSGobj_if_redraw)
3193 v_geometries_edges[position].clear();
3194 v_geometries_vertices[position].clear();
3195 v_geometries_normals[position].clear();
3196 v_geometries_custom_vectors[position].clear();
3197 v_vertexArrays_edges[position].clear();
3198 v_vertexArrays_vertices[position].clear();
3199 v_vertexArrays_normals[position].clear();
3200 v_vertexArrays_custom_vectors[position].clear();
3201 v_colorsArrays_edges[position].clear();
3202 v_colorsArrays_vertices[position].clear();
3203 v_colorsArrays_normals[position].clear();
3204 v_colorsArrays_custom_vectors[position].clear();
3206 v_normalsArrays_edges[position].clear();
3207 v_normalsArrays_vertices[position].clear();
3210 internal_createMesh(v_geodes[position],
3213 v_geometries[position],
3214 v_geometriesL[position],
3215 v_geometriesP[position],
3216 v_geometries_edges[position],
3217 v_geometries_vertices[position],
3218 v_geometries_normals[position],
3219 v_geometries_custom_vectors[position],
3220 v_vertexArrays[position],
3221 v_vertexArrays_edges[position],
3222 v_vertexArrays_vertices[position],
3223 v_vertexArrays_normals[position],
3224 v_vertexArrays_custom_vectors[position],
3225 v_normalsArrays[position],
3226 v_normalsArraysF[position],
3227 v_normalsArrays_edges[position],
3228 v_normalsArrays_vertices[position],
3229 v_tangentsArrays[position],
3230 v_colorsArrays[position],
3231 v_colorsArrays_edges[position],
3232 v_colorsArrays_vertices[position],
3233 v_colorsArrays_normals[position],
3234 v_colorsArrays_custom_vectors[position],
3235 v_texcoordsArrays[position],
3237 v_meshes_names[position]);
3240 QApplication::restoreOverrideCursor();
3243 template<
typename HalfedgeGraph >
3248 position = getMeshId(
static_cast< void *
>(_g));
3251 #pragma GCC diagnostic push
3252 #pragma GCC diagnostic warning "-Wsign-compare"
3255 "mesh was not found. Leaving...",
3256 "SimpleViewer::centerMesh"))
3261 #pragma GCC diagnostic pop
3268 osgViewer::View *_osgView =
3269 dynamic_cast< osgViewer::View *
>(
this);
3272 #if(FEVV_USE_QT5) // FOR_QT6
3278 _osgView = sav->my_osgQOpenGLWindow->getOsgViewer();
3284 _osgView->getCameraManipulator()->setNode(v_geodes[position]->getParent(0));
3296 _osgView->getCameraManipulator()->setNode(v_geodes[position]);
3300 _osgView->getCameraManipulator()->computeHomePosition();
3316 osgViewer::View *_osgView =
3317 dynamic_cast< osgViewer::View *
>(
this);
3320 #if(FEVV_USE_QT5) // FOR_QT6
3326 _osgView = sav->my_osgQOpenGLWindow->getOsgViewer();
3331 matrix = _osgView->getCameraManipulator()->getMatrix();
3343 osgViewer::View *_osgView =
3344 dynamic_cast< osgViewer::View *
>(
this);
3347 #if(FEVV_USE_QT5) // FOR_QT6
3353 _osgView = sav->my_osgQOpenGLWindow->getOsgViewer();
3358 _osgView->getCameraManipulator()->setByMatrix(matrix);
3365 unsigned int position)
3367 assert(position < v_geodes.size());
3368 osg::MatrixTransform *grp_MatrixTransform =
3369 dynamic_cast< osg::MatrixTransform *
>(v_geodes[position]->getParent(0));
3370 assert(grp_MatrixTransform !=
nullptr);
3371 osg::Matrix matrix = grp_MatrixTransform->getMatrix();
3380 unsigned int position)
3382 osg::Matrix osg_mat = getTransformMatrixOsg(position);
3386 Eigen::Matrix4d eigen_mat;
3387 eigen_mat << osg_mat(0, 0), osg_mat(1, 0), osg_mat(2, 0), osg_mat(3, 0),
3388 osg_mat(0, 1), osg_mat(1, 1), osg_mat(2, 1), osg_mat(3, 1), osg_mat(0, 2),
3389 osg_mat(1, 2), osg_mat(2, 2), osg_mat(3, 2), osg_mat(0, 3), osg_mat(1, 3),
3390 osg_mat(2, 3), osg_mat(3, 3);
3402 assert(position < v_geodes.size());
3403 osg::MatrixTransform *grp_MatrixTransform =
3404 dynamic_cast< osg::MatrixTransform *
>(v_geodes[position]->getParent(0));
3405 assert(grp_MatrixTransform !=
nullptr);
3407 osg::Matrix identity;
3408 identity.makeIdentity();
3409 grp_MatrixTransform->setMatrix(identity);
3413 template<
typename HalfedgeGraph >
3419 bool _recomputeNT_if_redraw,
3420 std::string _mesh_filename,
3421 bool _recreateOSGobj_if_redraw,
3424 auto pm =
get(boost::vertex_point, *_g);
3441 m_recomputeNT_if_redraw = _recomputeNT_if_redraw;
3442 m_recreateOSGobj_if_redraw = _recreateOSGobj_if_redraw;
3495 osg::Geode *geode =
dynamic_cast< osg::Geode *
>(_geode);
3496 if(geode !=
nullptr)
3498 unsigned int position = 0;
3499 for(osg::Geode *g : v_geodes)
3503 v_meshIsSelected[position] = _isSelected;
3509 current_i_time = position;
3513 for(
unsigned i = 0; i < v_geodes.size(); i++)
3514 v_geodes[i]->setNodeMask(0x0);
3515 for(
unsigned i = 0; i < v_draggers1.size(); i++)
3516 v_draggers1[i]->setNodeMask(0x0);
3517 for(
unsigned i = 0; i < v_draggers2.size(); i++)
3518 v_draggers2[i]->setNodeMask(0x0);
3520 v_geodes[position]->setNodeMask(0xffffffff);
3521 if(v_draggers1.size())
3522 v_draggers1[position]->setNodeMask(
3523 m_ShowTranslateDragger ? 0xffffffff : 0x0);
3524 if(v_draggers2.size())
3525 v_draggers2[position]->setNodeMask(
3526 m_ShowRotateDragger ? 0xffffffff : 0x0);
3538 osg::ref_ptr< osgFX::Outline > outline =
new osgFX::Outline;
3541 outline->setWidth(3);
3543 outline->addChild(_geode);
3544 for(
auto parent : _geode->getParents() )
3546 if( parent == outline )
3550 parent->replaceChild( _geode, outline );
3557 for(
auto parent : _geode->getParents() )
3559 if( parent->isSameKindAs( outline ))
3561 for(
auto grandpa : parent->getParents() )
3563 grandpa->replaceChild( parent, _geode );
3574 std::cout <<
"viewer " <<
this <<
" v_meshIsSelected =";
3575 for(
bool b: v_meshIsSelected)
3576 std::cout <<
" " << b;
3577 std::cout << std::endl;
3586 osg::Geode *geode =
dynamic_cast< osg::Geode *
>(_geode);
3587 if(geode !=
nullptr)
3589 unsigned int position = 0;
3590 for(osg::Geode *g : v_geodes)
3594 return v_meshIsSelected[position];
3609 for(
size_t i_pos = 0; i_pos < v_mixed_meshes.size(); i_pos++)
3611 if(v_mixed_meshes[i_pos].first == mesh_ptr)