diff --git a/Apps/Examples/Debug/CMakeLists.txt b/Apps/Examples/Debug/CMakeLists.txt index ffca3511273ae98a060b89ce5285b09e40b84f08..8b18edd8e6a359691048c704d5f4e8e522a7b3c2 100644 --- a/Apps/Examples/Debug/CMakeLists.txt +++ b/Apps/Examples/Debug/CMakeLists.txt @@ -26,62 +26,50 @@ ENDIF(WIN32) #define exec to compile -QT4_WRAP_CPP(polyhedronsView_moc ../polyhedronsView.h) -add_executable( polyhedronsViewD ../polyhedronsView.cpp ${polyhedronsView_moc}) -target_link_libraries( polyhedronsViewD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) - QT4_WRAP_CPP(frame_manip_moc ../frame_manip.h) add_executable( frame_manipD ../frame_manip.cpp ${frame_manip_moc}) -target_link_libraries( frame_manipD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( frame_manipD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(texturesExample_moc ../texturesExample.h) add_executable( texturesExampleD ../texturesExample.cpp ${texturesExample_moc} ) -target_link_libraries( texturesExampleD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( texturesExampleD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleMap3_moc ../simpleMap3.h) add_executable( simpleMap3D ../simpleMap3.cpp ${simpleMap3_moc} ) -target_link_libraries( simpleMap3D - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( simpleMap3D ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h) add_executable( simpleGMap2D ../simpleGMap2.cpp ${simpleGMap2_moc} ) -target_link_libraries( simpleGMap2D - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( simpleGMap2D ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap3_moc ../simpleGMap3.h) add_executable( simpleGMap3D ../simpleGMap3.cpp ${simpleGMap3_moc} ) -target_link_libraries( simpleGMap3D - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( simpleGMap3D ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(extrusionView_moc ../extrusionView.h) add_executable( extrusionViewD ../extrusionView.cpp ${extrusionView_moc}) -target_link_libraries( extrusionViewD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( extrusionViewD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( viewer_ui ../viewer.ui ) QT4_WRAP_CPP( viewer_moc ../viewer.h ) add_executable( viewerD ../viewer.cpp ${viewer_moc} ${viewer_ui}) -target_link_libraries( viewerD - ${CGoGN_LIBS_D} ${NUMERICAL_LIBS} ${CGoGN_EXT_LIBS} ) +target_link_libraries( viewerD ${CGoGN_LIBS_D} ${NUMERICAL_LIBS} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( clipping_ui ../clipping.ui ) QT4_WRAP_CPP( clipping_moc ../clipping.h ) add_executable( clippingD ../clipping.cpp ${clipping_ui} ${clipping_moc}) -target_link_libraries( clippingD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( clippingD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( volumeExplorer_ui ../volumeExplorer.ui ) QT4_WRAP_CPP( volumeExplorer_moc ../volumeExplorer.h ) add_executable( volumeExplorerD ../volumeExplorer.cpp ${volumeExplorer_ui} ${volumeExplorer_moc}) -target_link_libraries( volumeExplorerD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +target_link_libraries( volumeExplorerD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( mcmesh_ui ../mcmesh.ui ) QT4_WRAP_CPP( mcmesh_moc ../mcmesh.h ) -add_executable( mcmeshD ../mcmesh.cpp - ${mcmesh_moc} - ${mcmesh_ui} ) +add_executable( mcmeshD ../mcmesh.cpp ${mcmesh_moc} ${mcmesh_ui} ) target_link_libraries( mcmeshD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) + +QT4_WRAP_CPP( concave_rendering_moc ../concave_rendering.h ) +add_executable( concave_renderingD ../concave_rendering.cpp ${concave_rendering_moc} ${concave_rendering_ui} ) +target_link_libraries( concave_renderingD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) diff --git a/Apps/Examples/Release/CMakeLists.txt b/Apps/Examples/Release/CMakeLists.txt index a633ec957aa2c577164ada8a49c48ef1addcd800..5fd93f2b6df9819b298e3db6473a3f1d86709260 100644 --- a/Apps/Examples/Release/CMakeLists.txt +++ b/Apps/Examples/Release/CMakeLists.txt @@ -23,59 +23,46 @@ ENDIF(WIN32) #define exec to compile -QT4_WRAP_CPP(polyhedronsView_moc ../polyhedronsView.h) -add_executable( polyhedronsView ../polyhedronsView.cpp ${polyhedronsView_moc}) -target_link_libraries( polyhedronsView - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) - QT4_WRAP_CPP(frame_manip_moc ../frame_manip.h) add_executable( frame_manip ../frame_manip.cpp ${frame_manip_moc}) -target_link_libraries( frame_manip - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) +target_link_libraries( frame_manip ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(texturesExample_moc ../texturesExample.h) add_executable( texturesExample ../texturesExample.cpp ${texturesExample_moc} ) -target_link_libraries( texturesExample - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) +target_link_libraries( texturesExample ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h) add_executable( simpleGMap2 ../simpleGMap2.cpp ${simpleGMap2_moc} ) -target_link_libraries( simpleGMap2 - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) +target_link_libraries( simpleGMap2 ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap3_moc ../simpleGMap3.h) add_executable( simpleGMap3 ../simpleGMap3.cpp ${simpleGMap3_moc} ) -target_link_libraries( simpleGMap3 - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) +target_link_libraries( simpleGMap3 ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(extrusionView_moc ../extrusionView.h) add_executable( extrusionView ../extrusionView.cpp ${extrusionView_moc}) -target_link_libraries( extrusionView - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) +target_link_libraries( extrusionView ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( viewer_ui ../viewer.ui ) QT4_WRAP_CPP( viewer_moc ../viewer.h ) add_executable( viewer ../viewer.cpp ${viewer_moc} ${viewer_ui}) -target_link_libraries( viewer - ${CGoGN_LIBS_R} ${NUMERICAL_LIBS} ${CGoGN_EXT_LIBS} ) +target_link_libraries( viewer ${CGoGN_LIBS_R} ${NUMERICAL_LIBS} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( clipping_ui ../clipping.ui ) QT4_WRAP_CPP( clipping_moc ../clipping.h ) add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc}) -target_link_libraries( clipping - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) +target_link_libraries( clipping ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( volumeExplorer_ui ../volumeExplorer.ui ) QT4_WRAP_CPP( volumeExplorer_moc ../volumeExplorer.h ) add_executable( volumeExplorer ../volumeExplorer.cpp ${volumeExplorer_ui} ${volumeExplorer_moc}) -target_link_libraries( volumeExplorer - ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) +target_link_libraries( volumeExplorer ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( mcmesh_ui ../mcmesh.ui ) QT4_WRAP_CPP( mcmesh_moc ../mcmesh.h ) -add_executable( mcmesh - ../mcmesh.cpp - ${mcmesh_moc} - ${mcmesh_ui} ) +add_executable( mcmesh ../mcmesh.cpp ${mcmesh_moc} ${mcmesh_ui} ) target_link_libraries( mcmesh ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS}) - + +QT4_WRAP_CPP( concave_rendering_moc ../concave_rendering.h ) +add_executable( concave_rendering ../concave_rendering.cpp ${concave_rendering_moc} ${concave_rendering_ui} ) +target_link_libraries( concave_rendering ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS}) diff --git a/Apps/Examples/Tests/CMakeLists.txt b/Apps/Examples/Tests/CMakeLists.txt index 46d69acbb3f43dc3f32b2d43278d54da342ce9a0..badbfd3849908c62311af1550bcbe73fca9ba378 100644 --- a/Apps/Examples/Tests/CMakeLists.txt +++ b/Apps/Examples/Tests/CMakeLists.txt @@ -34,15 +34,4 @@ target_link_libraries( Geom_inclusionD add_executable( Geom_intersectionD ./Geom_intersection.cpp) target_link_libraries( Geom_intersectionD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) - -add_executable( test_compactD ./test_compact.cpp) -target_link_libraries( test_compactD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) - - -IF (WITH_QT) - QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h) - add_executable( concave_renderingD concave_rendering.cpp ${concave_rendering_moc}) - target_link_libraries( concave_renderingD - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) -ENDIF (WITH_QT) + diff --git a/Apps/Examples/Tests/concave_rendering.cpp b/Apps/Examples/concave_rendering.cpp similarity index 100% rename from Apps/Examples/Tests/concave_rendering.cpp rename to Apps/Examples/concave_rendering.cpp diff --git a/Apps/Examples/Tests/concave_rendering.h b/Apps/Examples/concave_rendering.h similarity index 100% rename from Apps/Examples/Tests/concave_rendering.h rename to Apps/Examples/concave_rendering.h diff --git a/Apps/Examples/extrusionView.cpp b/Apps/Examples/extrusionView.cpp index 4eeb617a840ee55b7cd3c175325632f33bba55e2..8aebcd6011a493ce120d525d0dea226eda48bb49 100644 --- a/Apps/Examples/extrusionView.cpp +++ b/Apps/Examples/extrusionView.cpp @@ -45,18 +45,14 @@ using namespace CGoGN; - - struct PFP: public PFP_STANDARD { // definition de la carte typedef EmbeddedMap2 MAP; }; - PFP::MAP myMap; - void MyQT::cb_initGL() { // choose to use GL version 2 @@ -68,7 +64,6 @@ void MyQT::cb_initGL() // create VBO for position m_positionVBO = new Utils::VBO(); - m_shader = new Utils::ShaderFlat(); m_shader->setAttributePosition(m_positionVBO); m_shader->setDiffuse(Geom::Vec4f(0.,1.,0.,0.)); @@ -83,7 +78,6 @@ void MyQT::cb_initGL() registerShader(m_shader2); } - void MyQT::cb_redraw() { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -99,9 +93,6 @@ void MyQT::cb_redraw() glDisable(GL_POLYGON_OFFSET_FILL); } - - - int main(int argc, char **argv) { // interface: @@ -145,23 +136,19 @@ int main(int argc, char **argv) float lWidthObj = std::max(std::max(bb.size(0), bb.size(1)), bb.size(2)); Geom::Vec3f lPosObj = (bb.min() + bb.max()) / PFP::REAL(2); - // envoit info BB a l'interface + // send the BB to the interface sqt.setParamObject(lWidthObj,lPosObj.data()); - // show 1 pour GL context + // first show creates GL context sqt.show(); - // update du VBO position (context GL necessaire) + // update position VBO sqt.m_positionVBO->updateData(position); - // update des primitives du renderer + // update render primitives sqt.m_render->initPrimitives(myMap, allDarts, Algo::Render::GL2::TRIANGLES); sqt.m_render->initPrimitives(myMap, allDarts, Algo::Render::GL2::LINES); - // show final pour premier redraw sqt.show(); - - // et on attend la fin. return app.exec(); - } diff --git a/Apps/Examples/extrusionView.h b/Apps/Examples/extrusionView.h index c1a388d63d2abaaef40de68e512708f3d65e5789..713c79bb32d2548d384afd8ed9c1b77f066316d2 100644 --- a/Apps/Examples/extrusionView.h +++ b/Apps/Examples/extrusionView.h @@ -22,12 +22,11 @@ * * *******************************************************************************/ -#ifndef EXTRUSIONVIEW_H_ -#define EXTRUSIONVIEW_H_ +#ifndef _EXTRUSIONVIEW_H_ +#define _EXTRUSIONVIEW_H_ #include - #include "Utils/Qt/qtSimple.h" // forward definitions (minimize includes) @@ -56,7 +55,8 @@ public: Utils::ShaderFlat* m_shader; Utils::ShaderSimpleColor* m_shader2; - MyQT():m_render(NULL), m_positionVBO(NULL), m_shader(NULL), m_shader2(NULL){} + MyQT() : m_render(NULL), m_positionVBO(NULL), m_shader(NULL), m_shader2(NULL) + {} // callbacks of simpleQT to overdefine: void cb_redraw(); @@ -65,4 +65,3 @@ public: }; #endif - diff --git a/Apps/Examples/texture.cpp b/Apps/Examples/texture.cpp deleted file mode 100644 index eaf3f6b67e19c070879b8263f31931304fac36fa..0000000000000000000000000000000000000000 --- a/Apps/Examples/texture.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - * texture.cpp - * - * Created on: Jul 25, 2011 - * Author: thery - */ - - - - diff --git a/Apps/Tuto/CMakeLists.txt b/Apps/Tuto/CMakeLists.txt index 520bdcf29bba5de021f972150d84490dab57b4a7..47b1893471ebec4903ea02721a9a30a0b9bfa661 100644 --- a/Apps/Tuto/CMakeLists.txt +++ b/Apps/Tuto/CMakeLists.txt @@ -78,9 +78,9 @@ add_executable( show_traversors show_traversors.cpp ${show_traversors_ui} ${show target_link_libraries( show_traversors ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) -#add_executable( tuto_subdivision tuto_subdivision.cpp) -#target_link_libraries( tuto_subdivision -# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) +add_executable( tuto_subdivision tuto_subdivision.cpp) +target_link_libraries( tuto_subdivision + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(tp_master_moc tp_master.h) add_executable( tp_master tp_master.cpp ${tp_master_moc}) @@ -93,20 +93,8 @@ target_link_libraries( tp_master # exemple: BOOST_LIBS(boost_lib_lists "boost_thread-mt;boost_iostreams-mt") #BOOST_LIBS(boost_lib_lists "boost_thread-mt") - QT4_WRAP_CPP(tuto_mt_moc tuto_mt.h) add_executable( tuto_mt tuto_mt.cpp ${tuto_mt_moc}) target_link_libraries( tuto_mt ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ${Boost_THREAD_LIBRARY}) - -QT4_WRAP_CPP(tuto_ogl3_moc tuto_ogl3.h) -add_executable( tuto_ogl3 tuto_ogl3.cpp ${tuto_ogl3_moc}) -target_link_libraries( tuto_ogl3 - ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) - - - -#add_executable( tuto_ogl2 tuto_ogl2.cpp) -#target_link_libraries( tuto_ogl2 -# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) diff --git a/Apps/Tuto/README.TXT b/Apps/Tuto/README.TXT deleted file mode 100644 index 20c4ac3b8fcbce6feca17d10b21d12aab47b2203..0000000000000000000000000000000000000000 --- a/Apps/Tuto/README.TXT +++ /dev/null @@ -1,10 +0,0 @@ - -Tutoriaux sur l'utilisation de CGoGN - -tuto1: -creation d'une carte simple avec attribut de sommet - -tuto2: -declaration et utilisation des MapBrowers - - diff --git a/Apps/Examples/README b/Apps/deprecated/README similarity index 100% rename from Apps/Examples/README rename to Apps/deprecated/README diff --git a/Apps/Examples/decimationVolumique.cpp b/Apps/deprecated/decimationVolumique.cpp similarity index 100% rename from Apps/Examples/decimationVolumique.cpp rename to Apps/deprecated/decimationVolumique.cpp diff --git a/Apps/Examples/decimationVolumique.h b/Apps/deprecated/decimationVolumique.h similarity index 100% rename from Apps/Examples/decimationVolumique.h rename to Apps/deprecated/decimationVolumique.h diff --git a/Apps/Examples/hm_convexhull.cpp b/Apps/deprecated/hm_convexhull.cpp similarity index 100% rename from Apps/Examples/hm_convexhull.cpp rename to Apps/deprecated/hm_convexhull.cpp diff --git a/Apps/Examples/miniTest.cpp b/Apps/deprecated/miniTest.cpp similarity index 100% rename from Apps/Examples/miniTest.cpp rename to Apps/deprecated/miniTest.cpp diff --git a/Apps/Examples/polyhedronsView.cpp b/Apps/deprecated/polyhedronsView.cpp similarity index 100% rename from Apps/Examples/polyhedronsView.cpp rename to Apps/deprecated/polyhedronsView.cpp diff --git a/Apps/Examples/polyhedronsView.h b/Apps/deprecated/polyhedronsView.h similarity index 100% rename from Apps/Examples/polyhedronsView.h rename to Apps/deprecated/polyhedronsView.h diff --git a/Apps/Examples/scene.cpp b/Apps/deprecated/scene.cpp similarity index 100% rename from Apps/Examples/scene.cpp rename to Apps/deprecated/scene.cpp diff --git a/Apps/Examples/simpleEMap3.cpp b/Apps/deprecated/simpleEMap3.cpp similarity index 100% rename from Apps/Examples/simpleEMap3.cpp rename to Apps/deprecated/simpleEMap3.cpp diff --git a/Apps/Examples/squelette3carte.cpp b/Apps/deprecated/squelette3carte.cpp similarity index 100% rename from Apps/Examples/squelette3carte.cpp rename to Apps/deprecated/squelette3carte.cpp diff --git a/Apps/Examples/squelette3carte.h b/Apps/deprecated/squelette3carte.h similarity index 100% rename from Apps/Examples/squelette3carte.h rename to Apps/deprecated/squelette3carte.h diff --git a/Apps/Examples/ter_meshes.cpp b/Apps/deprecated/ter_meshes.cpp similarity index 100% rename from Apps/Examples/ter_meshes.cpp rename to Apps/deprecated/ter_meshes.cpp diff --git a/Apps/Examples/Tests/test_compact.cpp b/Apps/deprecated/test_compact.cpp similarity index 100% rename from Apps/Examples/Tests/test_compact.cpp rename to Apps/deprecated/test_compact.cpp diff --git a/Apps/Examples/test_mapd1.cpp b/Apps/deprecated/test_mapd1.cpp similarity index 100% rename from Apps/Examples/test_mapd1.cpp rename to Apps/deprecated/test_mapd1.cpp diff --git a/Apps/Examples/triangulation.cpp b/Apps/deprecated/triangulation.cpp similarity index 100% rename from Apps/Examples/triangulation.cpp rename to Apps/deprecated/triangulation.cpp diff --git a/Apps/Tuto/tuto_ogl3.cpp b/Apps/deprecated/tuto_ogl3.cpp similarity index 100% rename from Apps/Tuto/tuto_ogl3.cpp rename to Apps/deprecated/tuto_ogl3.cpp diff --git a/Apps/Tuto/tuto_ogl3.h b/Apps/deprecated/tuto_ogl3.h similarity index 100% rename from Apps/Tuto/tuto_ogl3.h rename to Apps/deprecated/tuto_ogl3.h diff --git a/Apps/Examples/tutoriel.cpp b/Apps/deprecated/tutoriel.cpp similarity index 100% rename from Apps/Examples/tutoriel.cpp rename to Apps/deprecated/tutoriel.cpp diff --git a/Apps/Examples/tutoriel.h b/Apps/deprecated/tutoriel.h similarity index 100% rename from Apps/Examples/tutoriel.h rename to Apps/deprecated/tutoriel.h diff --git a/Apps/Examples/volumeViewer.h b/Apps/deprecated/volumeViewer.h similarity index 100% rename from Apps/Examples/volumeViewer.h rename to Apps/deprecated/volumeViewer.h diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/include/Algo/Export/export.hpp b/include/Algo/Export/export.hpp index 9c4a4a45a672c1783a8efb646edd6945da7f722d..75c1e92ae98e6c59c156549edff2246f96fbd60b 100644 --- a/include/Algo/Export/export.hpp +++ b/include/Algo/Export/export.hpp @@ -398,7 +398,7 @@ bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi out << "ply" << std::endl ; out << "format ascii 1.0" << std::endl ; - out << "comment ply SLF (K. Vanhoey generic format): SLF_" << ((extension == ".plyPTMext") ? "PTMext" : "SHreal") << std::endl ; + out << "comment ply SLF (K. Vanhoey generic format): SLF_" << (((extension == ".plyPTMext") || extension == ".plyPTMextBin" ) ? "PTMext" : "SHreal") << std::endl ; out << "element vertex " << vertices.size() << std::endl ; out << "property float x" << std::endl ; out << "property float y" << std::endl ; @@ -473,7 +473,6 @@ bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& p AutoAttributeHandler tableVertLab(map, VERTEX); - unsigned int nbDarts = map.getNbDarts() ; std::vector vertices; @@ -562,15 +561,24 @@ bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& p unsigned int vi = vertices[i]; // position for(unsigned int coord = 0 ; coord < 3 ; ++coord) - out.write((char*)(&(position[vi][coord])), sizeof(float)) ; + { + const float& floatofdouble = position[vi][coord] ; + out.write((char*)(&floatofdouble), sizeof(float)) ; + } // frame for(unsigned int axis = 0 ; axis < 3 ; ++axis) for (unsigned int coord = 0 ; coord < 3 ; ++coord) - out.write((char*)(&(frame[axis][vi][coord])), sizeof(float)) ; + { + const float& floatofdouble = frame[axis][vi][coord] ; + out.write((char*)(&floatofdouble), sizeof(float)) ; + } // coefficients for (unsigned int channel = 0 ; channel < 3 ; ++channel) for(unsigned int coefI = 0 ; coefI < nbCoefs ; ++coefI) - out.write((char*)(&(coefs[coefI][vi][channel])), sizeof(float)) ; + { + const float& floatofdouble = coefs[coefI][vi][channel] ; + out.write((char*)(&floatofdouble), sizeof(float)) ; + } } std::vector::iterator it = faces.begin(); diff --git a/include/Algo/Geometry/feature.h b/include/Algo/Geometry/feature.h index 3d22d87587b52e35c2940a13924161ea005f745a..d357a79ff9be265fe6705eff61faf7426399c89e 100644 --- a/include/Algo/Geometry/feature.h +++ b/include/Algo/Geometry/feature.h @@ -1,7 +1,7 @@ /******************************************************************************* * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * * version 0.1 * -* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg * +* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published by the * @@ -17,7 +17,7 @@ * along with this library; if not, write to the Free Software Foundation, * * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * * -* Web site: http://cgogn.unistra.fr/ * +* Web site: http://cgogn.u-strasbg.fr/ * * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ @@ -37,9 +37,42 @@ namespace Geometry template void featureEdgeDetection(typename PFP::MAP& map, const typename PFP::TVEC3& position, CellMarker& featureEdge) ; +template +void computeArea(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; + +template +void computeFaceGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_gradient, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; + +template +void computeGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& gradient, typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; + +template +void computeTriangleType(typename PFP::MAP& map, const typename PFP::TVEC3& position, CellMarker& regularMarker, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; + +template +void computeCurvatureSign(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; + template std::vector occludingContoursDetection(typename PFP::MAP& map, const typename PFP::VEC3& cameraPosition, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal) ; +template +typename PFP::TREAL faceArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; + +template +typename PFP::VEC3 faceGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area) ; + +template +bool triangleType(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; + +template +bool isInSameOctant(const typename PFP::VEC3& pos1, const typename PFP::VEC3& pos2) ; + +template +void curvatureSign(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k) ; + +template +typename PFP::TVEC3 vertexGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area) ; + } // namespace Geometry } // namespace Algo diff --git a/include/Algo/Geometry/feature.hpp b/include/Algo/Geometry/feature.hpp index 78c0de4556edeaa1ab32d4aa3c7d27df0d0e49e2..d325bea094083c3a0549c298c17df391c8807d61 100644 --- a/include/Algo/Geometry/feature.hpp +++ b/include/Algo/Geometry/feature.hpp @@ -1,7 +1,7 @@ /******************************************************************************* * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * * version 0.1 * -* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg * +* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published by the * @@ -17,7 +17,7 @@ * along with this library; if not, write to the Free Software Foundation, * * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * * -* Web site: http://cgogn.unistra.fr/ * +* Web site: http://cgogn.u-strasbg.fr/ * * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ @@ -58,6 +58,53 @@ void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position, // map.template removeAttribute(fNormal) ; } +template +void computeArea(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) +{ + TraversorF trav(map, select, thread); + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + area[d] = faceArea(map, d, position)[1] ; +} + +template +void computeFaceGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_gradient, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) +{ + TraversorF trav(map, select, thread); + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + face_gradient[d] = faceGradient(map, d, position, face_normal, kmax, area) ; +} + +template +void computeGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& gradient, typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) +{ + TraversorV trav(map, select, thread); + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + gradient[d] = vertexGradient(map, d, position, face_gradient, area) ; +} + +template +void computeTriangleType(typename PFP::MAP& map, const typename PFP::TVEC3& position, CellMarker& regularMarker, const FunctorSelect& select = allDarts, unsigned int thread = 0) +{ + TraversorF trav(map, select, thread); + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + if(triangleType(map, d, position)) + regularMarker.mark(d) ; +} + +template +void computeCurvatureSign(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k, const FunctorSelect& select = allDarts, unsigned int thread = 0) +{ + CellMarker mv(map, VERTEX, thread); + TraversorV trav(map, select, thread); + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if (!mv.isMarked(d)) + { + curvatureSign(map, d, position, triangle_type, k) ; + } + } +} + template std::vector occludingContoursDetection(typename PFP::MAP& map, const typename PFP::VEC3& cameraPosition, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal) { @@ -112,6 +159,188 @@ std::vector occludingContoursDetection(typename PFP::MAP& ma return occludingContours ; } +template +float faceArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +{ + typedef typename PFP::REAL REAL ; + typedef typename PFP::VEC3 VEC3 ; + + float A [1] ; + + VEC3 pos1(0) ; + VEC3 pos2(0) ; + VEC3 pos3(0) ; + + Traversor2FV t(map, d) ; + Dart it = t.begin() ; + + pos1 += position[it] ; + it = t.next ; + pos2 += position[it] ; + it = t.next ; + pos3 += position[it] ; + + A = 1/2 * abs( + ( (pos2.x - pos1.x) * (pos3.y - pos1.y) ) + - + ( (pos3.x - pos1.x) * (pos2.y - pos1.y) ) + ) ; + + return A ; +} + +template +typename PFP::VEC3 faceGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area) +{ + typedef typename PFP::REAL REAL ; + typedef typename PFP::VEC3 VEC3 ; + + VEC3 G(0) ; + + VEC3 pos1(0) ; + VEC3 pos2(0) ; + VEC3 pos3(0) ; + + VEC3 n = face_normal[d] ; + + REAL k1 ; + REAL k2 ; + REAL k3 ; + + REAL a = area[d] ; + + Traversor2FV t(map, d) ; + Dart it = t.begin() ; + + pos1 += position[it] ; + k1 = kmax[it] ; + it = t.next() ; + pos2 += position[it] ; + k2 = kmax[it] ; + it = t.next() ; + pos3 += position[it] ; + k3 = kmax[it] ; + + G += k1 * ( ( n ^ ( pos3 - pos2 ) ) / ( 2 * a ) ) + + k2 * ( ( n ^ ( pos1 - pos3 ) ) / ( 2 * a ) ) + + k3 * ( ( n ^ ( pos2 - pos1 ) ) / ( 2 * a ) ) ; + + G.normalize() ; + return G ; +} + +template +bool triangleType(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +{ + typedef typename PFP::REAL REAL ; + typedef typename PFP::VEC3 VEC3 ; + + VEC3 pos1(0) ; + VEC3 pos2(0) ; + VEC3 pos3(0) ; + + Traversor2FV t(map, d) ; + Dart it = t.begin() ; + + pos1 += position[it] ; + it = t.next() ; + pos2 += position[it] ; + it = t.next() ; + pos3 += position[it] ; + + if ( isInSameOctant(pos1,pos2) && isInSameOctant(pos1,pos3) ) + { + //regular triangle + return true ; + } + else + { + //singular triangle + return false ; + } +} + +template +bool isInSameOctant(const typename PFP::VEC3& pos1, const typename PFP::VEC3& pos2) +{ + return ( ( pos1[0] > 0 && pos1[1] > 0 && pos1[2] > 0 && //one of the eight octant + ( ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] > 0 ) or //one choice of sign + ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] < 0 ) ) ) or //the other choice + + ( pos1[0] > 0 && pos1[1] > 0 && pos1[2] < 0 && + ( ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] < 0 ) or + ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] > 0 ) ) ) or + + ( pos1[0] > 0 && pos1[1] < 0 && pos1[2] > 0 && + ( ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] > 0 ) or + ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] < 0 ) ) ) or + + ( pos1[0] > 0 && pos1[1] < 0 && pos1[2] < 0 && + ( ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] < 0 ) or + ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] > 0 ) ) ) or + + ( pos1[0] < 0 && pos1[1] > 0 && pos1[2] > 0 && + ( ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] > 0 ) or + ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] < 0 ) ) ) or + + ( pos1[0] < 0 && pos1[1] > 0 && pos1[2] < 0 && + ( ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] < 0 ) or + ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] > 0 ) ) ) or + + ( pos1[0] < 0 && pos1[1] < 0 && pos1[2] > 0 && + ( ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] > 0 ) or + ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] < 0 ) ) ) or + + ( pos1[0] < 0 && pos1[1] < 0 && pos1[2] < 0 && + ( ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] < 0 ) or + ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] > 0 ) ) ) ) ; +} + +template +void curvatureSign(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k) +{ + /*sommetTraité = true ;*/ + + Traversor2VE trav2(map, d) ; + for (Dart d2 = trav2.begin(); d2 != trav2.end(); d2 = trav2.next()) + { + if (/*arrete non traité*/ true) + { + if((k[d] * k[d2]) <= 0) + { + k[d2] *= -1 ; + } + /*arreteTraité = true ;*/ + + /*meme chose avec sommet le long de l'arrete*/ + /*curvatureSign(sommet le long del'arrete) ;*/ + } + } +} + +template +typename PFP::TVEC3 vertexGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area) +{ + typedef typename PFP::REAL REAL ; + typedef typename PFP::VEC3 VEC3 ; + + VEC3 G(0) ; + + REAL A = 0 ; + + Traversor2VF t(map, d) ; + for (Dart d = t.begin(); d != t.end(); d = t.next()) + { + G += area[d] * face_gradient[d] ; + A += area[d] ; + } + + G = G / A ; + + G.normalize() ; + return G ; +} + } // namespace Geometry } // namespace Algo diff --git a/include/Algo/Import/import.h b/include/Algo/Import/import.h index 11a1ca452a9ba48b7cf556ab8ba043a7880d058a..9e1d3a02fb69419a953df1144d7be1be9f48cde9 100644 --- a/include/Algo/Import/import.h +++ b/include/Algo/Import/import.h @@ -43,38 +43,44 @@ namespace Import /** * import a mesh * @param map the map in which the function imports the mesh -* @param filename (*.{trian,trianbgz,off,obj,ply}) +* @param filename * @param attrNames attribute names -* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values) -* @param mergeColseVertces a boolean indicating if the imported mesh should be closed +* @param mergeCloseVertices a boolean indicating if close vertices should be merged during import * @return a boolean indicating if import was successfull */ template -bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, ImportSurfacique::ImportType kind = ImportSurfacique::UNKNOWNSURFACE, bool mergeCloseVertices=false); +bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, bool mergeCloseVertices = false); /** * import a volumetric mesh * @param map the map in which the function imports the mesh - * @param filename (*.{tet,off,ts}) + * @param filename * @param attrNames attribute names - * @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values) - * @param mergeColseVertces a boolean indicating if the imported mesh should be closed + * @param mergeCloseVertices a boolean indicating if close vertices should be merged during import * @return a boolean indicating if import was successfull */ template -bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, ImportVolumique::ImportType kind = ImportVolumique::UNKNOWNVOLUME, bool mergeCloseVertices=false); +bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, bool mergeCloseVertices = false); /** * import a mesh and extrud it * @param map the map in which the function imports the mesh - * @param filename (*.{trian,trianbgz,off,obj,ply}) + * @param filename * @param attrNames attribute names - * @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values) - * @param mergeColseVertces a boolean indicating if the imported mesh should be closed + * @param mergeCloseVertices a boolean indicating if close vertices should be merged during import * @return a boolean indicating if import was successfull */ template -bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, ImportSurfacique::ImportType kind = ImportSurfacique::UNKNOWNSURFACE); +bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames); + +/** + * import a MOKA file + * @param gmap the gmap in which the function imports the mesh + * @param filename + * @param attrNames attribute names + */ +template +bool importMoka(typename PFP::MAP& gmap, const std::string& filename, std::vector& attrNames); /* @@ -104,6 +110,7 @@ bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vect } // namespace CGoGN #include "Algo/Import/importMesh.hpp" +#include "Algo/Import/importMoka.hpp" //#include "Algo/Import/importObjTex.hpp" #include "Algo/Import/importObjEle.hpp" #include "Algo/Import/importTet.hpp" diff --git a/include/Algo/Import/import2tables.h b/include/Algo/Import/import2tables.h index a25ccfbf5e5193a4ebfba8deb3bd79d8fc494bac..419ea1a61686f652d2d54ad3c46712c2a365d254 100644 --- a/include/Algo/Import/import2tables.h +++ b/include/Algo/Import/import2tables.h @@ -101,7 +101,7 @@ public: inline unsigned int getEmbIdx(int i) { return m_emb[i]; } - bool importMesh(const std::string& filename, std::vector& attrNames, ImportSurfacique::ImportType kind); + bool importMesh(const std::string& filename, std::vector& attrNames); bool importTrian(const std::string& filename, std::vector& attrNames); @@ -184,10 +184,9 @@ public: inline unsigned int getEmbIdx(int i) { return m_emb[i]; } - bool importMesh(const std::string& filename, std::vector& attrNames, ImportVolumique::ImportType kind, float scaleFactor); - - bool importTet(const std::string& filename, std::vector& attrNames, float scaleFactor); + bool importMesh(const std::string& filename, std::vector& attrNames, float scaleFactor = 1.0f); + bool importTet(const std::string& filename, std::vector& attrNames, float scaleFactor = 1.0f); MeshTablesVolume(typename PFP::MAP& map): m_map(map) diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index 63ce830a02ddc0d2ab8f619ae03665ee04c39339..d0ff8c9dde0258956f8bc3e9c25fa7d1689c5c08 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -80,10 +80,9 @@ ImportSurfacique::ImportType MeshTablesSurface::getFileType(const std::stri } template -bool MeshTablesSurface::importMesh(const std::string& filename, std::vector& attrNames, ImportSurfacique::ImportType kind) +bool MeshTablesSurface::importMesh(const std::string& filename, std::vector& attrNames) { - if (kind == ImportSurfacique::UNKNOWNSURFACE) - kind = getFileType(filename); + ImportSurfacique::ImportType kind = getFileType(filename); attrNames.clear() ; @@ -384,7 +383,9 @@ bool MeshTablesSurface::importMeshBin(const std::string& filename, std::vec AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; if (!positions.isValid()) + { positions = m_map.template addAttribute(VERTEX, "position") ; + } attrNames.push_back(positions.name()) ; @@ -413,7 +414,7 @@ bool MeshTablesSurface::importMeshBin(const std::string& filename, std::vec for (unsigned int vxNum = 0 ; vxNum < m_nbVertices ; ++vxNum) { - VEC3 pos ; + Geom::Vec3f pos ; fp.read((char*) &pos[0], sizeof(float)) ; fp.read((char*) &pos[1], sizeof(float)) ; fp.read((char*) &pos[2], sizeof(float)) ; @@ -591,6 +592,14 @@ bool MeshTablesSurface::importPly(const std::string& filename, std::vector< return false; } + AttributeHandler colors = m_map.template getAttribute(VERTEX, "color") ; + if (pid.hasColors()) + { + if(!colors.isValid()) + colors = m_map.template addAttribute(VERTEX, "color") ; + attrNames.push_back(colors.name()) ; + } + // lecture des nombres de sommets/aretes/faces m_nbVertices = pid.nbVertices(); m_nbFaces = pid.nbFaces(); @@ -606,6 +615,16 @@ bool MeshTablesSurface::importPly(const std::string& filename, std::vector< unsigned int id = container.insertLine(); positions[id] = pos; + if (pid.hasColors()) + { + Geom::Vector<3, unsigned char> col ; + pid.vertexColorUint8(i, col) ; + colors[id][0] = col[0] ; + colors[id][1] = col[1] ; + colors[id][2] = col[2] ; + colors[id] /= 255.0 ; + } + verticesID.push_back(id); } @@ -680,7 +699,7 @@ bool MeshTablesSurface::importPlySLFgeneric(const std::string& filename, st bool binormal = false ; bool normal = false ; unsigned int nbProps = 0 ; // # properties - unsigned int nbCoefsPerPol = 0 ; // # coefficients per polynomial + unsigned int nbCoefs = 0 ; // # coefficients per polynomial do // go to #faces and count #properties { fp >> tag ; @@ -696,11 +715,11 @@ bool MeshTablesSurface::importPlySLFgeneric(const std::string& filename, st else if (tag == std::string("nx") || tag == std::string("ny") || tag == std::string("nz")) normal = true ; if (tag.substr(0,1) == std::string("C") && tag.substr(2,1) == std::string("_")) - ++nbCoefsPerPol ; + ++nbCoefs ; } while (tag != std::string("face")) ; unsigned int nbRemainders = nbProps ; // # remaining properties - nbRemainders -= nbCoefsPerPol + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ; - nbCoefsPerPol /= 3 ; + nbRemainders -= nbCoefs + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ; + nbCoefs /= 3 ; fp >> m_nbFaces ; // Read #vertices @@ -723,8 +742,8 @@ bool MeshTablesSurface::importPlySLFgeneric(const std::string& filename, st attrNames.push_back(frame[1].name()) ; attrNames.push_back(frame[2].name()) ; - AttributeHandler *SLFcoefs = new AttributeHandler[nbCoefsPerPol] ; - for (unsigned int i = 0 ; i < nbCoefsPerPol ; ++i) + AttributeHandler *SLFcoefs = new AttributeHandler[nbCoefs] ; + for (unsigned int i = 0 ; i < nbCoefs ; ++i) { std::stringstream name ; name << "SLFcoefs_" << i ; @@ -760,9 +779,9 @@ bool MeshTablesSurface::importPlySLFgeneric(const std::string& filename, st for (unsigned int l = 0 ; l < 3 ; ++l) frame[k][id][l] = properties[3+(3*k+l)] ; for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients - for (unsigned int l = 0 ; l < nbCoefsPerPol ; ++l) - SLFcoefs[l][id][k] = properties[12+(nbCoefsPerPol*k+l)] ; - unsigned int cur = 12+3*nbCoefsPerPol ; + for (unsigned int l = 0 ; l < nbCoefs ; ++l) + SLFcoefs[l][id][k] = properties[12+(nbCoefs*k+l)] ; + unsigned int cur = 12+3*nbCoefs ; for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data remainders[k][id] = properties[cur + k] ; } @@ -826,7 +845,7 @@ bool MeshTablesSurface::importPlySLFgenericBin(const std::string& filename, bool binormal = false ; bool normal = false ; unsigned int nbProps = 0 ; // # properties - unsigned int nbCoefsPerPol = 0 ; // # coefficients per polynomial + unsigned int nbCoefs = 0 ; // # coefficients per polynomial do // go to #faces and count #properties { fp >> tag ; @@ -842,11 +861,11 @@ bool MeshTablesSurface::importPlySLFgenericBin(const std::string& filename, else if (tag == std::string("nx") || tag == std::string("ny") || tag == std::string("nz")) normal = true ; if (tag.substr(0,1) == std::string("C") && tag.substr(2,1) == std::string("_")) - ++nbCoefsPerPol ; + ++nbCoefs ; } while (tag != std::string("face")) ; unsigned int nbRemainders = nbProps ; // # remaining properties - nbRemainders -= nbCoefsPerPol + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ; - nbCoefsPerPol /= 3 ; + nbRemainders -= nbCoefs + 3*(position==true) + 3*(tangent==true) + 3*(binormal==true) + 3*(normal==true) ; + nbCoefs /= 3 ; fp >> m_nbFaces ; // Read #vertices @@ -876,8 +895,8 @@ bool MeshTablesSurface::importPlySLFgenericBin(const std::string& filename, attrNames.push_back(frame[1].name()) ; attrNames.push_back(frame[2].name()) ; - AttributeHandler *SLFcoefs = new AttributeHandler[nbCoefsPerPol] ; - for (unsigned int i = 0 ; i < nbCoefsPerPol ; ++i) + AttributeHandler *SLFcoefs = new AttributeHandler[nbCoefs] ; + for (unsigned int i = 0 ; i < nbCoefs ; ++i) { std::stringstream name ; name << "SLFcoefs_" << i ; @@ -905,19 +924,19 @@ bool MeshTablesSurface::importPlySLFgenericBin(const std::string& filename, unsigned int id = container.insertLine() ; verticesID.push_back(id) ; - for (unsigned int j = 0 ; j < nbProps ; ++j) // get all properties - fp.read((char*)&(properties[j]),sizeof(float)) ; + // for (unsigned int j = 0 ; j < nbProps ; ++j) // get all properties + fp.read((char*)properties,nbProps * sizeof(float)) ; positions[id] = VEC3(properties[0],properties[1],properties[2]) ; // position for (unsigned int k = 0 ; k < 3 ; ++k) // frame for (unsigned int l = 0 ; l < 3 ; ++l) - frame[k][id][l] = properties[3+(3*k+l)] ; + frame[k][id][l] = (typename PFP::REAL)(properties[3+(3*k+l)]) ; for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients - for (unsigned int l = 0 ; l < nbCoefsPerPol ; ++l) - SLFcoefs[l][id][k] = properties[12+(nbCoefsPerPol*k+l)] ; - unsigned int cur = 12+3*nbCoefsPerPol ; + for (unsigned int l = 0 ; l < nbCoefs ; ++l) + SLFcoefs[l][id][k] = (typename PFP::REAL)(properties[12+(nbCoefs*k+l)]) ; + unsigned int cur = 12+3*nbCoefs ; for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data - remainders[k][id] = properties[cur + k] ; + remainders[k][id] = (typename PFP::REAL)(properties[cur + k]) ; } m_nbVertices = verticesID.size() ; delete[] properties ; diff --git a/include/Algo/Import/import2tablesVolume.hpp b/include/Algo/Import/import2tablesVolume.hpp index 5d2c73c8664782036eb0f9cdb69f55bacbec00f8..ce9be86dfbd8ca14b999c64fdc5c83727897a319 100644 --- a/include/Algo/Import/import2tablesVolume.hpp +++ b/include/Algo/Import/import2tablesVolume.hpp @@ -47,10 +47,9 @@ ImportVolumique::ImportType MeshTablesVolume::getFileType(const std::string } template -bool MeshTablesVolume::importMesh(const std::string& filename, std::vector& attrNames, ImportVolumique::ImportType kind, float scaleFactor=1.0f) +bool MeshTablesVolume::importMesh(const std::string& filename, std::vector& attrNames, float scaleFactor) { - if (kind == ImportVolumique::UNKNOWNVOLUME) - kind = getFileType(filename); + ImportVolumique::ImportType kind = getFileType(filename); switch (kind) { @@ -69,7 +68,7 @@ bool MeshTablesVolume::importMesh(const std::string& filename, std::vector< } template -bool MeshTablesVolume::importTet(const std::string& filename, std::vector& attrNames, float scaleFactor=1.0f) +bool MeshTablesVolume::importTet(const std::string& filename, std::vector& attrNames, float scaleFactor) { AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; diff --git a/include/Algo/Import/importMesh.hpp b/include/Algo/Import/importMesh.hpp index 36d2c0230b48c41792551579dd1d4fcc81589d31..b443004532fc9885160ef3f51ae8798d0ac2b54b 100644 --- a/include/Algo/Import/importMesh.hpp +++ b/include/Algo/Import/importMesh.hpp @@ -241,18 +241,17 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume& mtv) { typedef typename PFP::VEC3 VEC3 ; - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); - + AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); return false; } template -bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, ImportSurfacique::ImportType kind, bool mergeCloseVertices) +bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, bool mergeCloseVertices) { MeshTablesSurface mts(map); - if(!mts.importMesh(filename, attrNames, kind)) + if(!mts.importMesh(filename, attrNames)) return false; if (mergeCloseVertices) @@ -262,8 +261,19 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector } template -bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, ImportVolumique::ImportType kind, bool mergeCloseVertices) +bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, bool mergeCloseVertices) { + ImportVolumique::ImportType kind = ImportVolumique::UNKNOWNVOLUME; + + if ((filename.rfind(".tet") != std::string::npos) || (filename.rfind(".TET") != std::string::npos)) + kind = ImportVolumique::TET; + + if ((filename.rfind(".ele") != std::string::npos) || (filename.rfind(".ELE") != std::string::npos)) + kind = ImportVolumique::ELE; + + if ((filename.rfind(".ts") != std::string::npos) || (filename.rfind(".TS") != std::string::npos)) + kind = ImportVolumique::TS; + switch (kind) { case ImportVolumique::TET: @@ -297,20 +307,18 @@ bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vecto return false; } - template -bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, ImportSurfacique::ImportType kind) +bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames) { float dist = 5.0f; MeshTablesSurface mts(map); - if(!mts.importMesh(filename, attrNames, kind)) + if(!mts.importMesh(filename, attrNames)) return false; return importMeshSToV(map, mts, dist); } - } // namespace Import } // namespace Algo diff --git a/include/Algo/Import/importMoka.hpp b/include/Algo/Import/importMoka.hpp new file mode 100644 index 0000000000000000000000000000000000000000..51bdc38c0948876843b48132d73b43a5c671b4a3 --- /dev/null +++ b/include/Algo/Import/importMoka.hpp @@ -0,0 +1,133 @@ +/******************************************************************************* +* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * +* version 0.1 * +* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg * +* * +* This library is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by the * +* Free Software Foundation; either version 2.1 of the License, or (at your * +* option) any later version. * +* * +* This library is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this library; if not, write to the Free Software Foundation, * +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * +* * +* Web site: http://cgogn.unistra.fr/ * +* Contact information: cgogn@unistra.fr * +* * +*******************************************************************************/ + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Import +{ + +template +bool importMoka(typename PFP::MAP& gmap, const std::string& filename, std::vector& attrNames) +{ + if(gmap.mapTypeName().compare("GMap3") != 0) + { + CGoGNerr << "Unable to load MOKA file " << filename << " : given map is not a 3-GMap" << CGoGNendl; + return false ; + } + + // open file + igzstream fp(filename.c_str(), std::ios::in|std::ios::binary); + + if (!fp.good()) + { + CGoGNerr << "Unable to open file " << filename << CGoGNendl; + return false; + } + + AttributeHandler position = gmap.template getAttribute(VERTEX, "position"); + if (!position.isValid()) + position = gmap.template addAttribute(VERTEX, "position"); + + attrNames.push_back(position.name()); + + AttributeContainer& vertexContainer = gmap.getAttributeContainer(VERTEX) ; + + std::string ligne; + std::getline (fp, ligne); + + // check if the file format is in ascii + if(ligne.compare("Moka file [ascii]") != 0) + { + CGoGNerr << "Unable to load this MOKA file " << filename << CGoGNendl; + return false; + } + + // ignore 2nd line + std::getline (fp, ligne); + + AttributeHandler att_beta0 = gmap.template getAttribute(DART, "beta0"); + AttributeHandler att_beta1 = gmap.template getAttribute(DART, "beta1"); + AttributeHandler att_beta2 = gmap.template getAttribute(DART, "beta2"); + AttributeHandler att_beta3 = gmap.template getAttribute(DART, "beta3"); + + std::map map_dart_emb; + + while(!std::getline(fp, ligne).eof()) + { + std::stringstream oss(ligne); + unsigned int beta0, beta1, beta2, beta3; + + Dart d = gmap.newDart(); + + // read involutions + oss >> beta0; + oss >> beta1; + oss >> beta2; + oss >> beta3; + + att_beta0[d] = beta0; + att_beta1[d] = beta1; + att_beta2[d] = beta2; + att_beta3[d] = beta3; + + // ignore markers + unsigned int tmp; + for(unsigned int i = 0 ; i < 4 ; ++i) + oss >> tmp; + + // check if contains embedding + unsigned int emb; + oss >> emb; + + if(emb == 1) + { + typename PFP::VEC3 pos; + oss >> pos[0]; + oss >> pos[1]; + oss >> pos[2]; + + unsigned int id = vertexContainer.insertLine(); + position[id] = pos; + map_dart_emb.insert(std::pair(d, id)); + } + } + + for(typename std::map::iterator it = map_dart_emb.begin() ; it != map_dart_emb.end() ; ++it) + gmap.embedOrbit(VERTEX, it->first, it->second); + + gmap.closeMap(); + + fp.close(); + return true; +} + +} // namespace Import + +} // namespace Algo + +} // namespace CGoGN diff --git a/include/Algo/Import/importPlyData.h b/include/Algo/Import/importPlyData.h index d93ef02c924b6dff5e10183690ec99770db28988..bda974c36e30655cf93382f3002222eb5b8d966e 100644 --- a/include/Algo/Import/importPlyData.h +++ b/include/Algo/Import/importPlyData.h @@ -47,7 +47,10 @@ public: void vertexNormal(int i, VEC& N) { N[0] = vlist[i]->nx; N[1] = vlist[i]->ny; N[2] = vlist[i]->nz;} template - void vertexColor(int i, VEC& C) { C[0] = vlist[i]->r; C[1] = vlist[i]->g; C[2] = vlist[i]->b;} + void vertexColorUint8(int i, VEC& C) { C[0] = vlist[i]->red; C[1] = vlist[i]->green; C[2] = vlist[i]->blue;} + + template + void vertexColorFloat32(int i, VEC& C) { C[0] = vlist[i]->r; C[1] = vlist[i]->g; C[2] = vlist[i]->b;} int nbVertices() { return nverts;} @@ -62,7 +65,9 @@ public: /** * each vertex has a color vector */ - bool hasColors() { return per_vertex_color!=0;} + bool hasColors() { return hasColorsUint8() || hasColorsFloat32() ;} + bool hasColorsUint8() { return per_vertex_color_uint8 != 0 ;} + bool hasColorsFloat32() { return per_vertex_color_float32 != 0 ;} /** * get the number of edges of a face @@ -88,6 +93,7 @@ protected: typedef struct Vertex { float x,y,z; float r,g,b; + unsigned char red,green,blue; float nx,ny,nz; void *other_props; /* other properties */ } Vertex; @@ -113,7 +119,7 @@ protected: PlyOtherProp *vert_other,*face_other; - int per_vertex_color; + int per_vertex_color_float32, per_vertex_color_uint8 ; int has_normals; }; diff --git a/include/Algo/MC/image.hpp b/include/Algo/MC/image.hpp index a0d7898a9bb4a14e047e90f932503f871b25da76..200531f5e82182d45c194fa7f83966880331b531 100644 --- a/include/Algo/MC/image.hpp +++ b/include/Algo/MC/image.hpp @@ -430,7 +430,8 @@ Image* Image::Blur3() for(int y=1; ygetVoxelPtr(0,y,z)) = *(getVoxelPtr(0,y,z)); - #pragma omp parallel for // OpenMP + +// #pragma omp parallel for // OpenMP for(int x=1; x& bb) ; - //return true if the vector belongs strictly to a bounding box + // return true if the vector belongs strictly to a bounding box bool contains(const VEC& p); - //return true if the bounding box belongs strictly to a bounding box + // return true if the bounding box belongs strictly to a bounding box bool contains(const BoundingBox & bb); - //resize a bounding box - void scale(float size); + // scale the bounding box + void scale(typename VEC::DATA_TYPE size); + + // 0-centered scale of the bounding box + void centeredScale(typename VEC::DATA_TYPE size); /**********************************************/ /* STREAM OPERATORS */ /**********************************************/ -// friend std::ostream& operator<<(std::ostream& out, const BoundingBox& bb); -// -// friend std::istream& operator>>(std::istream& in, BoundingBox& bb); - friend std::ostream& operator<<(std::ostream& out, const BoundingBox& bb) { out << bb.min() << " " << bb.max() ; diff --git a/include/Geometry/bounding_box.hpp b/include/Geometry/bounding_box.hpp index f3d97259d535c5ae6161a466c132abffc8074487..2b03aeebe1564900cdeeb7ba9c8ede78788d88a2 100644 --- a/include/Geometry/bounding_box.hpp +++ b/include/Geometry/bounding_box.hpp @@ -142,7 +142,7 @@ bool BoundingBox::isInitialized() const template void BoundingBox::reset() { - m_initialized=false; + m_initialized = false; } template @@ -197,7 +197,6 @@ void BoundingBox::fusion(const BoundingBox& bb) } } - template bool BoundingBox::contains(const VEC& p) { @@ -221,28 +220,20 @@ bool BoundingBox::contains(const BoundingBox& bb) } template -void BoundingBox::scale(float size) +void BoundingBox::scale(typename VEC::DATA_TYPE size) { assert(m_initialized || !"Bounding box not initialized"); - m_pMin *= size; - m_pMax *= size; + m_pMin *= size ; + m_pMax *= size ; } - - -//template -//friend std::ostream& BoundingBox::operator<<(std::ostream& out, const BoundingBox& bb) -//{ -// out << bb.min() << " " << bb.max() ; -// return out ; -//} -// -//template -//friend std::istream& BoundingBox::operator>>(std::istream& in, BoundingBox& bb) -//{ -// in >> bb.min() >> bb.max() ; -// return in ; -//} +template +void BoundingBox::centeredScale(typename VEC::DATA_TYPE size) +{ + VEC center = (m_pMin + m_pMax) / typename VEC::DATA_TYPE(2) ; + m_pMin = ((m_pMin - center) * size) + center ; + m_pMax = ((m_pMax - center) * size) + center ; +} } // namespace Geom diff --git a/include/Geometry/plane_3d.h b/include/Geometry/plane_3d.h index 6e921195b8f045387bc373882fbd655299390cc0..a496ce52bb5083a4a8ac13dc2df46497b45b293d 100644 --- a/include/Geometry/plane_3d.h +++ b/include/Geometry/plane_3d.h @@ -109,6 +109,6 @@ class Plane3D } // namespace CGoGN -#include "plane_3d.hpp" +#include "Geometry/plane_3d.hpp" #endif diff --git a/include/Geometry/plane_3d.hpp b/include/Geometry/plane_3d.hpp index 44572f9779188af4bb0a1c9b8e9bbe2fd88ee122..fb8eccdb3ba0b7fe54f8ed680da9477ea3444bc9 100644 --- a/include/Geometry/plane_3d.hpp +++ b/include/Geometry/plane_3d.hpp @@ -44,8 +44,7 @@ std::string Plane3D::CGoGNnameOfType() /**********************************************/ template -Plane3D::Plane3D(int d) : -m_normal(0), m_d(d) +Plane3D::Plane3D(int d) : m_normal(0), m_d(d) { } template @@ -56,15 +55,13 @@ Plane3D::Plane3D(const Plane3D& p) } template -Plane3D::Plane3D(const Vector<3,T>& n, T d) : -m_normal(n), m_d(d) +Plane3D::Plane3D(const Vector<3,T>& n, T d) : m_normal(n), m_d(d) { m_normal.normalize(); } template -Plane3D::Plane3D(const Vector<3,T>& n, const Vector<3,T>& p) : -m_normal(n), m_d(-(p*n)) +Plane3D::Plane3D(const Vector<3,T>& n, const Vector<3,T>& p) : m_normal(n), m_d(-(p*n)) { m_normal.normalize(); } @@ -118,7 +115,7 @@ T Plane3D::distance(const Vector<3,T>& p) const template void Plane3D::project(Vector<3,T>& p) const { -#define PRECISION 1e-5 +#define PRECISION 1e-10 T d = -distance(p) ; if(abs(d) > PRECISION) { @@ -131,7 +128,7 @@ void Plane3D::project(Vector<3,T>& p) const template Orientation3D Plane3D::orient(const Vector<3,T>& p) const { -#define PRECISION 1e-5 +#define PRECISION 1e-10 T dist = distance(p) ; if(dist < -PRECISION) return UNDER ; diff --git a/include/Topology/generic/attributeHandler.hpp b/include/Topology/generic/attributeHandler.hpp index 7b25bbaf726b4414b619e14d25c7c69ed0fcd66f..1457295ce94fe4079a6b0eba293bc061f97bcd08 100644 --- a/include/Topology/generic/attributeHandler.hpp +++ b/include/Topology/generic/attributeHandler.hpp @@ -58,7 +58,7 @@ template AttributeHandler::AttributeHandler(GenericMap* m, AttributeMultiVector* amv) : AttributeHandlerGen(m, false), m_attrib(amv) { - if(amv != NULL && amv->getIndex() != AttributeContainer::UNKNOWN) + if(m != NULL && amv != NULL && amv->getIndex() != AttributeContainer::UNKNOWN) { valid = true ; registerInMap() ; diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index 6a1943d4151edcbcfc35ce7ae05b0f36b8b141c5..1219ceb124b588aa619b29e8271de20e49750a12 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -428,7 +428,7 @@ protected: * @param name name of the relation * @return the attribute multi-vector pointer */ - AttributeMultiVector* getRelation(const std::string& name); + AttributeMultiVector* getRelation(const std::string& name) ; /**************************************** * THREAD MANAGEMENT * @@ -506,22 +506,22 @@ public: /** * copy from another map (of same type) */ - bool copyFrom(const GenericMap& map); + bool copyFrom(const GenericMap& map) ; /** * Dump attributes types and names per orbit */ - void dumpAttributesAndMarkers(); + void dumpAttributesAndMarkers() ; /** * update topo relation after compacting the container: */ - virtual void compactTopoRelations(const std::vector& oldnew) = 0; + virtual void compactTopoRelations(const std::vector& oldnew) = 0 ; /** * compact the map */ - void compact(); + void compact() ; /**************************************** * DARTS TRAVERSALS * @@ -531,13 +531,13 @@ public: * Begin of map * @return the first dart of the map */ - Dart begin() const; + Dart begin() const ; /** * End of map * @return the end iterator (next of last) of the map */ - Dart end() const; + Dart end() const ; /** * allow to go from a dart to the next @@ -590,39 +590,39 @@ public: protected: /// boundary marker - Mark m_boundaryMarker; + Mark m_boundaryMarker ; /** * mark a dart as belonging to boundary */ - void boundaryMark(Dart d); + void boundaryMark(Dart d) ; /** * unmark a dart from the boundary */ - void boundaryUnmark(Dart d); + void boundaryUnmark(Dart d) ; public: /** * test if a dart belong to the boundary */ - bool isBoundaryMarked(Dart d) const; + bool isBoundaryMarked(Dart d) const ; protected: /** * mark an orbit of dart as belonging to boundary */ - void boundaryMarkOrbit(unsigned int orbit, Dart d); + void boundaryMarkOrbit(unsigned int orbit, Dart d) ; /** * unmark an orbit of dart from the boundary */ - void boundaryUnmarkOrbit(unsigned int orbit, Dart d); + void boundaryUnmarkOrbit(unsigned int orbit, Dart d) ; /** * clear all boundary markers */ - void boundaryUnmarkAll(); + void boundaryUnmarkAll() ; } ; // diff --git a/include/Topology/map/map2MR/map2MR_PrimalAdapt.h b/include/Topology/map/map2MR/map2MR_PrimalAdapt.h index 8b47a0e6b05ca07d334672055f443f1c5533e678..26d4d1e2d2cb1a9ab28b15514b45745a1096feb3 100644 --- a/include/Topology/map/map2MR/map2MR_PrimalAdapt.h +++ b/include/Topology/map/map2MR/map2MR_PrimalAdapt.h @@ -46,7 +46,7 @@ protected: public: Map2MR_PrimalAdapt() ; - std::string mapTypeName() { return "Map2MR_PrimalAdapt" ; } + virtual std::string mapTypeName() const { return "Map2MR_PrimalAdapt" ; } /*************************************************** * CELLS INFORMATION * diff --git a/include/Topology/map/map2MR/map2MR_PrimalRegular.h b/include/Topology/map/map2MR/map2MR_PrimalRegular.h index bea34173129ff99258203062ee257ae7a50d4e74..737e10eb06e2dd63f967503a5ca5dd675cfb6f44 100644 --- a/include/Topology/map/map2MR/map2MR_PrimalRegular.h +++ b/include/Topology/map/map2MR/map2MR_PrimalRegular.h @@ -45,7 +45,7 @@ protected: public: Map2MR_PrimalRegular() ; - std::string mapTypeName() { return "Map2MR_PrimalRegular" ; } + virtual std::string mapTypeName() const { return "Map2MR_PrimalRegular" ; } void addNewLevel(bool embedNewVertices = true) ; diff --git a/include/Topology/map/map3MR/map3MR_PrimalAdapt.h b/include/Topology/map/map3MR/map3MR_PrimalAdapt.h index 2ca73f4ef985b10fc76ce5c573af562532312be4..17be4958bf7f7a58b246554ee07ed6f5e8cfdd02 100644 --- a/include/Topology/map/map3MR/map3MR_PrimalAdapt.h +++ b/include/Topology/map/map3MR/map3MR_PrimalAdapt.h @@ -55,7 +55,7 @@ protected: public: Map3MR_PrimalAdapt(); - std::string mapTypeName() { return "Map3MR_PrimalAdapt"; } + virtual std::string mapTypeName() const { return "Map3MR_PrimalAdapt"; } /*! @name Topological helping functions * diff --git a/include/Topology/map/map3MR/map3MR_PrimalRegular.h b/include/Topology/map/map3MR/map3MR_PrimalRegular.h index fed1fb8f78ddc1b251871e42918a99245fe1d13f..470e16f0c1a56378b52c5fb5e856f7ac39189942 100644 --- a/include/Topology/map/map3MR/map3MR_PrimalRegular.h +++ b/include/Topology/map/map3MR/map3MR_PrimalRegular.h @@ -51,7 +51,7 @@ protected: public: Map3MR_PrimalRegular(); - std::string mapTypeName() { return "Map3MR_PrimalRegular"; } + virtual std::string mapTypeName() const { return "Map3MR_PrimalRegular"; } /*! @name Topological helping functions * diff --git a/include/Utils/cgognStream.h b/include/Utils/cgognStream.h index 235af7f12a69e28f28bbe0a69cd46dfe1b000533..13a0ed6f4ba24590b08b658ca0d4bfb449be2a99 100644 --- a/include/Utils/cgognStream.h +++ b/include/Utils/cgognStream.h @@ -188,7 +188,7 @@ Out& Out::operator<< (const T& val) if (m_out_mode & STDERR) std::cerr << val; - if (m_out_mode && (FILEOUT|QTSTATUSBAR|QTCONSOLE|SSBUFFER)) + if (m_out_mode & (FILEOUT|QTSTATUSBAR|QTCONSOLE|SSBUFFER)) m_buffer << val; return *this; diff --git a/include/Utils/textures.hpp b/include/Utils/textures.hpp index 1ca3ddf4abf43554c3584a249f8b34de9fc4ae60..f028bd18870b6db7fb14bf7e2773e42f4750e8e8 100644 --- a/include/Utils/textures.hpp +++ b/include/Utils/textures.hpp @@ -863,7 +863,7 @@ Filter* Filter::createGaussian(int radius, double sigma) break; case 2: { - double tot=0.0; +// double tot=0.0; double coef = 1.0/(sig2*M_PI); for (int j=0; j< sz; ++j) for (int i=0; i< sz; ++i) diff --git a/src/Algo/Import/importPlyData.cpp b/src/Algo/Import/importPlyData.cpp index 4ae336ccd904d12a6cb31ca76e46ddc3860fdd6c..d2822dd27ea3b1dd001cc27507548add8a7bb941 100644 --- a/src/Algo/Import/importPlyData.cpp +++ b/src/Algo/Import/importPlyData.cpp @@ -37,6 +37,9 @@ PlyProperty PlyImportData::vert_props[] = { /* list of property information for {(char*) "x", PLY_Float32, PLY_Float32, offsetof(Vertex,x), 0, 0, 0, 0}, {(char*) "y", PLY_Float32, PLY_Float32, offsetof(Vertex,y), 0, 0, 0, 0}, {(char*) "z", PLY_Float32, PLY_Float32, offsetof(Vertex,z), 0, 0, 0, 0}, + {(char*) "red", PLY_Uint8, PLY_Uint8, offsetof(Vertex,red), 0, 0, 0, 0}, + {(char*) "green", PLY_Uint8, PLY_Uint8, offsetof(Vertex,green), 0, 0, 0, 0}, + {(char*) "blue", PLY_Uint8, PLY_Uint8, offsetof(Vertex,blue), 0, 0, 0, 0}, {(char*) "r", PLY_Float32, PLY_Float32, offsetof(Vertex,r), 0, 0, 0, 0}, {(char*) "g", PLY_Float32, PLY_Float32, offsetof(Vertex,g), 0, 0, 0, 0}, {(char*) "b", PLY_Float32, PLY_Float32, offsetof(Vertex,b), 0, 0, 0, 0}, @@ -57,7 +60,8 @@ PlyImportData::PlyImportData(): flist(NULL), vert_other(NULL), face_other(NULL), - per_vertex_color(0), + per_vertex_color_float32(0), + per_vertex_color_uint8(0), has_normals(0) { } @@ -126,28 +130,40 @@ bool PlyImportData::read_file(const std::string& filename) { PlyProperty *prop; prop = in_ply->elems[i]->props[j]; - if (equal_strings ((char*) "r", prop->name)) { + if (equal_strings ((char*) "red", prop->name)) { setup_property_ply (in_ply, &vert_props[3]); - per_vertex_color = 1; + per_vertex_color_uint8 = 1; } - if (equal_strings ((char*) "g", prop->name)) { + if (equal_strings ((char*) "green", prop->name)) { setup_property_ply (in_ply, &vert_props[4]); - per_vertex_color = 1; + per_vertex_color_uint8 = 1; } - if (equal_strings ((char*) "b", prop->name)) { + if (equal_strings ((char*) "blue", prop->name)) { setup_property_ply (in_ply, &vert_props[5]); - per_vertex_color = 1; + per_vertex_color_uint8 = 1; } - if (equal_strings ((char*) "nx", prop->name)) { + if (equal_strings ((char*) "r", prop->name)) { setup_property_ply (in_ply, &vert_props[6]); + per_vertex_color_float32 = 1; + } + if (equal_strings ((char*) "g", prop->name)) { + setup_property_ply (in_ply, &vert_props[7]); + per_vertex_color_float32 = 1; + } + if (equal_strings ((char*) "b", prop->name)) { + setup_property_ply (in_ply, &vert_props[8]); + per_vertex_color_float32 = 1; + } + if (equal_strings ((char*) "nx", prop->name)) { + setup_property_ply (in_ply, &vert_props[9]); has_normals = 1; } if (equal_strings ((char*) "ny", prop->name)) { - setup_property_ply (in_ply, &vert_props[7]); + setup_property_ply (in_ply, &vert_props[10]); has_normals = 1; } if (equal_strings ((char*) "nz", prop->name)) { - setup_property_ply (in_ply, &vert_props[8]); + setup_property_ply (in_ply, &vert_props[11]); has_normals = 1; } } diff --git a/src/Container/attributeContainer.cpp b/src/Container/attributeContainer.cpp index c80fabb960f79f69d4cfc42eb1192191aa1995c2..19fecf88c1bb8c3a37bf28f10c931d884d17835b 100644 --- a/src/Container/attributeContainer.cpp +++ b/src/Container/attributeContainer.cpp @@ -690,7 +690,6 @@ bool AttributeContainer::loadBin(CGoGNistream& fs) return true; } - void AttributeContainer::copyFrom(const AttributeContainer& cont) { // clear is done from the map @@ -742,5 +741,4 @@ void AttributeContainer::copyFrom(const AttributeContainer& cont) } } - } diff --git a/src/Container/holeblockref.cpp b/src/Container/holeblockref.cpp index 677f300cccb26d4a19b928186ca40526084128e0..fa89073af238f620c4f0e42d92acaa7e4a57407c 100644 --- a/src/Container/holeblockref.cpp +++ b/src/Container/holeblockref.cpp @@ -40,8 +40,7 @@ namespace CGoGN { -HoleBlockRef::HoleBlockRef(): -m_nbfree(0),m_nbref(0),m_nb(0) +HoleBlockRef::HoleBlockRef() : m_nbfree(0), m_nbref(0), m_nb(0) { m_tableFree = new unsigned int[_BLOCKSIZE_ + 10]; m_refCount = new unsigned int[_BLOCKSIZE_]; @@ -53,12 +52,11 @@ HoleBlockRef::HoleBlockRef(const HoleBlockRef& hb) m_nbref = hb.m_nbref; m_nb = hb.m_nb; - m_tableFree = new unsigned int[_BLOCKSIZE_ +10]; - memcpy(m_tableFree, hb.m_tableFree, (_BLOCKSIZE_+ 10) * sizeof(unsigned int)); + m_tableFree = new unsigned int[_BLOCKSIZE_ + 10]; + memcpy(m_tableFree, hb.m_tableFree, (_BLOCKSIZE_ + 10) * sizeof(unsigned int)); m_refCount = new unsigned int[_BLOCKSIZE_]; memcpy(m_refCount, hb.m_refCount, _BLOCKSIZE_ * sizeof(unsigned int)); - } HoleBlockRef::~HoleBlockRef() diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index 0c898e5b381547011aa81a00feaa7be07c1b01f7..bf74e5dc20422b9ad7fd8f8a8ace0f1b10178978 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -578,20 +578,16 @@ bool GenericMap::loadMapBin(const std::string& filename) return true; } - - bool GenericMap::copyFrom(const GenericMap& map) { if (mapTypeName() != map.mapTypeName()) { - CGoGNerr <<"try to copy from incompatible type map" << CGoGNendl; + CGoGNerr << "try to copy from incompatible type map" << CGoGNendl; return false; } GenericMap::clear(true); - - // load attrib container for (unsigned int i = 0; i < NB_ORBITS; ++i) m_attribs[i].copyFrom(map.m_attribs[i]); @@ -601,13 +597,12 @@ bool GenericMap::copyFrom(const GenericMap& map) m_mrattribs.copyFrom(map.m_mrattribs); m_mrCurrentLevel = map.m_mrCurrentLevel; - unsigned int nb= map.m_mrNbDarts.size(); + unsigned int nb = map.m_mrNbDarts.size(); m_mrNbDarts.resize(nb); - for (unsigned int i=0; i 6) // thread number is >9 - thread = 10*thread + listeNames[i][6]-'0'; + thread = 10*thread + (listeNames[i][6]-'0'); AttributeMultiVector* amvMark = cont.getDataVector(i); m_markTables[orbit][thread] = amvMark ; @@ -682,34 +677,34 @@ void GenericMap::update_topo_shortcuts() { std::vector names; m_mrattribs.getAttributesNames(names); - m_mrDarts.resize(names.size()-1); - for (unsigned int i=0; i(i); - if (sub=="MRdart_") + if (sub == "MRdart_") { sub = names[i].substr(7); // compute number following MT_Dart_ - unsigned int idx=0; - for (unsigned int j=0; j < sub.length(); j++) - idx = 10*idx+(sub[j]-'0'); - if (idx < names.size()-1) + unsigned int idx = 0; + for (unsigned int j = 0; j < sub.length(); j++) + idx = 10*idx + (sub[j]-'0'); + if (idx < names.size() - 1) m_mrDarts[idx] = m_mrattribs.getDataVector(i); else - CGoGNerr<<"Warning problem updating MR_DARTS" << CGoGNendl; + CGoGNerr << "Warning problem updating MR_DARTS" << CGoGNendl; } } // check if all pointers are != NULL - for (unsigned int i=0; i oldnew; m_attribs[DART].compact(oldnew); - // update MR indices to attribs[DART] if (m_isMultiRes) { @@ -830,7 +824,7 @@ void GenericMap::compact() } } - // update topo relations from real map + // update topo relations from real map compactTopoRelations(oldnewMR); // dumpAttributesAndMarkers(); diff --git a/src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp b/src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp index cea0cc98e9149aacc8054e11e23d2a9d1583674b..9119cc5fd8f66b6e75089fb6ce393c2b40a8564e 100644 --- a/src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp +++ b/src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp @@ -252,20 +252,7 @@ bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d) void Map2MR_PrimalAdapt::addNewLevel(bool embedNewVertices) { - pushLevel() ; - addLevel() ; - setCurrentLevel(getMaxLevel()) ; - -// for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i)) -// { -// unsigned int newindex = copyDartLine((*m_mrDarts[m_mrCurrentLevel])[i]) ; // duplicate all darts -// (*m_mrDarts[m_mrCurrentLevel])[i] = newindex ; // on the new max level -// if(!shareVertexEmbeddings) -// (*m_embeddings[VERTEX])[newindex] = EMBNULL ; // set vertex embedding to EMBNULL if no sharing -// } - - popLevel() ; } void Map2MR_PrimalAdapt::propagateDartRelation(Dart d, AttributeMultiVector* rel) diff --git a/src/Utils/Qt/qtSimple.cpp b/src/Utils/Qt/qtSimple.cpp index 852d85de9a9b0256cd256c9e78f72f023724d0f8..156d8c7df63d244911e643e029a208aac48419e8 100644 --- a/src/Utils/Qt/qtSimple.cpp +++ b/src/Utils/Qt/qtSimple.cpp @@ -112,7 +112,6 @@ SimpleQT::SimpleQT() : SimpleQT::SimpleQT(const SimpleQT& sqt): m_dock(NULL), - m_mat(m_mat), m_projection_matrix(m_mat.m_matrices[0]), m_modelView_matrix(m_mat.m_matrices[1]), m_transfo_matrix(m_mat.m_matrices[2])