diff --git a/.gitignore b/.gitignore index 95aa0b11a084a739058181a1306a8ab0b0c9540f..028b32ebfc243ac1edbcd9d612f55d8d3aadefbe 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ CMakeLists.txt.user bin/ ThirdParty/bin/ -SCHNApps/bin \ No newline at end of file +SCHNApps/bin/ +windows_dependencies/ diff --git a/Apps/CMakeLists.txt b/Apps/CMakeLists.txt index ffad42c64800bcd964f059d3498fbee78e32da32..6cbc10228bd40ab5d3f7ad59fb8dd05cec5c1bd5 100644 --- a/Apps/CMakeLists.txt +++ b/Apps/CMakeLists.txt @@ -14,7 +14,7 @@ IF (WIN32) link_directories( ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE}) SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE}) # Release/Debug added automatically by visual ELSE() - link_directories( ${CGoGN_ROOT_DIR}/bin/${ConfigurationName}) + link_directories( ${CGoGN_ROOT_DIR}/bin/$(ConfigurationName)) SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual ENDIF() ELSE() diff --git a/Apps/Examples/viewer.cpp b/Apps/Examples/viewer.cpp index ee3092b22af2cc35b535e37f3fa8d20d04aa4291..07eb549dcc70b227f703ce5c912acc19bec5ff50 100644 --- a/Apps/Examples/viewer.cpp +++ b/Apps/Examples/viewer.cpp @@ -92,21 +92,20 @@ void Viewer::cb_initGL() m_positionVBO = new Utils::VBO() ; m_normalVBO = new Utils::VBO() ; - m_phongShader = new Utils::ShaderPhong(true,false,false) ; + m_phongShader = new Utils::ShaderPhong(true,false) ; m_phongShader->setAttributePosition(m_positionVBO) ; m_phongShader->setAttributeNormal(m_normalVBO) ; m_phongShader->setAmbiant(colClear) ; m_phongShader->setDiffuse(colDif) ; m_phongShader->setSpecular(colSpec) ; m_phongShader->setShininess(shininess) ; - m_phongShader->setBackColor(Geom::Vec4f(0,0,0.2,0)) ; + m_phongShader->setBackColor(Geom::Vec4f(0.9f, 0.0f, 0.0f, 0.0f)); - m_flatShader = new Utils::ShaderSimpleFlat(true,false) ; + m_flatShader = new Utils::ShaderSimpleFlat() ; m_flatShader->setAttributePosition(m_positionVBO) ; m_flatShader->setAmbiant(colClear) ; m_flatShader->setDiffuse(colDif) ; - m_flatShader->setBackColor(Geom::Vec4f(0,0,0.2,0)) ; - + m_flatShader->setBackColor(Geom::Vec4f(0.9f, 0.0f, 0.0f, 0.0f)); m_vectorShader = new Utils::ShaderVectorPerVertex() ; m_vectorShader->setAttributePosition(m_positionVBO) ; @@ -182,7 +181,7 @@ void Viewer::cb_redraw() } m_nbFrames++; - if (m_nbFrames >=100) + if (m_nbFrames >=500) { std::cout << 100000.0/m_frame_ch.elapsed()<< " fps"<setDoubleSided(true); + m_flatShader->setDoubleSided(true); + updateGL(); + } + break; + case 'D': + { + m_phongShader->setDoubleSided(false); + m_flatShader->setDoubleSided(false); + updateGL(); + } + break; + + case 'q': + { + Utils::Chrono ch; + ch.start(); + + for (int i = 0; i < 1000; ++i) + { + m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES); + glFlush(); + } + + std::cout << "speed render " << 1000.0*1000.0/ch.elapsed() << " fps " << std::endl; + } case 'n': m_flatShader->setNoClippingPlane(); m_phongShader->setNoClippingPlane(); diff --git a/Apps/Examples/viewer.h b/Apps/Examples/viewer.h index 080ff17a5b781f88d16f403cce46b07584ab160e..7d934d061276c272a6a8ee85660d7dc578f30753 100644 --- a/Apps/Examples/viewer.h +++ b/Apps/Examples/viewer.h @@ -43,6 +43,7 @@ #include "Utils/Shaders/shaderPhong.h" #include "Utils/Shaders/shaderSimpleFlat.h" +//#include "Utils/Shaders/shaderFlat.h" #include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderVectorPerVertex.h" #include "Utils/pointSprite.h" diff --git a/Apps/SandBox/tilings.cpp b/Apps/SandBox/tilings.cpp index 541402525ebe055d7ffc5e8cc1dd19e59f0da8b3..3ac055b814fe3a05fa4423ca5007652d865f3dac 100644 --- a/Apps/SandBox/tilings.cpp +++ b/Apps/SandBox/tilings.cpp @@ -135,7 +135,7 @@ void MyQT::squareTiling(int code) { std::cout << "square grid helicoid tiling" << std::endl; Algo::Surface::Tilings::Square::Grid g(myMap,20,20,true); - g.embedIntoHelicoid(position, 0.2, 0.3, 0.8, 2.0); + g.embedIntoHelicoid(position, 0.2f, 0.3f, 0.8f, 2.0f); // Geom::Matrix44f trf; // trf.identity(); diff --git a/Apps/SandBox/wallPaper.cpp b/Apps/SandBox/wallPaper.cpp index 59f23ed60ee72daa710a33fca9ab8d37cb6f396c..658d216dcf015b74d39aad583b3ab183d2cd89e0 100644 --- a/Apps/SandBox/wallPaper.cpp +++ b/Apps/SandBox/wallPaper.cpp @@ -31,7 +31,7 @@ void MyQT::cb_initGL() { position = myMap.addAttribute("position"); Algo::Surface::Tilings::Square::Cylinder c(myMap,50,50); - c.embedIntoCylinder(position,0.5,0.7,1.0); + c.embedIntoCylinder(position,0.5f,0.7f,1.0f); Geom::BoundingBox bb = Algo::Geometry::computeBoundingBox(myMap, position); 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); diff --git a/Apps/Tests/Algo/BooleanOperator/CMakeLists.txt b/Apps/Tests/Algo/BooleanOperator/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0a9e9c7ce9595227c8e515e56eae6a41c1e9fd32 --- /dev/null +++ b/Apps/Tests/Algo/BooleanOperator/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_booleanOperator) + +add_executable( test_algo_booleanOperator +algo_booleanOperator.cpp +mergeVertices.cpp +) + +target_link_libraries( test_algo_booleanOperator + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + + diff --git a/Apps/Tests/Algo/BooleanOperator/algo_booleanOperator.cpp b/Apps/Tests/Algo/BooleanOperator/algo_booleanOperator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3dafeb8011ec883324e35dddfb1a85450ad9c58c --- /dev/null +++ b/Apps/Tests/Algo/BooleanOperator/algo_booleanOperator.cpp @@ -0,0 +1,10 @@ +#include + +extern int test_mergeVertices(); + +int main() +{ + test_mergeVertices(); + + return 0; +} diff --git a/Apps/Tests/Algo/BooleanOperator/mergeVertices.cpp b/Apps/Tests/Algo/BooleanOperator/mergeVertices.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8296037f8237da4034f5017fe5a4425a36539595 --- /dev/null +++ b/Apps/Tests/Algo/BooleanOperator/mergeVertices.cpp @@ -0,0 +1,48 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/BooleanOperator/mergeVertices.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::BooleanOperator::isBetween(PFP1::MAP& map, const VertexAttribute& positions, Dart d, Dart e, Dart f); +template void Algo::Surface::BooleanOperator::mergeVertex(PFP1::MAP& map, VertexAttribute& positions, Dart d, Dart e, int precision); +template void Algo::Surface::BooleanOperator::mergeVertices(PFP1::MAP& map, VertexAttribute& positions, int precision); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::BooleanOperator::isBetween(PFP2::MAP& map, const VertexAttribute& positions, Dart d, Dart e, Dart f); +template void Algo::Surface::BooleanOperator::mergeVertex(PFP2::MAP& map, VertexAttribute& positions, Dart d, Dart e, int precision); +template void Algo::Surface::BooleanOperator::mergeVertices(PFP2::MAP& map, VertexAttribute& positions, int precision); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//struct PFP3 : public PFP_STANDARD +//{ +// typedef EmbeddedGMap2 MAP; +//}; + +//template bool Algo::Surface::BooleanOperator::isBetween(PFP3::MAP& map, const VertexAttribute& positions, Dart d, Dart e, Dart f); +//template void Algo::Surface::BooleanOperator::mergeVertex(PFP3::MAP& map, VertexAttribute& positions, Dart d, Dart e, int precision); +//template void Algo::Surface::BooleanOperator::mergeVertices(PFP3::MAP& map, VertexAttribute& positions, int precision); + +// TODO add removeEdgeFromVertex & insertEdgeInVertex in GMap2 + +int test_mergeVertices() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/CMakeLists.txt b/Apps/Tests/Algo/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..31421e7e33b130bb8417e30c3ffc4d599782a690 --- /dev/null +++ b/Apps/Tests/Algo/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo) + +add_subdirectory(BooleanOperator) +add_subdirectory(Decimation) +add_subdirectory(Export) +add_subdirectory(Filtering) +add_subdirectory(Geometry) +add_subdirectory(Histogram) +#add_subdirectory(ImplicitHierarchicalMesh) +add_subdirectory(Import) +add_subdirectory(LinearSolving) +add_subdirectory(MC) +add_subdirectory(Modelisation) +add_subdirectory(MovingObjects) +#add_subdirectory(Multiresolution) +add_subdirectory(ProgressiveMesh) +add_subdirectory(Remeshing) +add_subdirectory(Render) +add_subdirectory(Selection) +add_subdirectory(Simulation) +add_subdirectory(Tiling) +add_subdirectory(Topo) diff --git a/Apps/Tests/Algo/Decimation/CMakeLists.txt b/Apps/Tests/Algo/Decimation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f9699e0cc476622dd71520202b0d2dbd7a72d0dd --- /dev/null +++ b/Apps/Tests/Algo/Decimation/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_decimation) + +add_executable( test_algo_decimation +algo_decimation.cpp +colorPerVertexApproximator.cpp +decimation.cpp +edgeSelector.cpp +geometryApproximator.cpp +geometryPredictor.cpp +halfEdgeSelector.cpp +predictor.cpp +) + +target_link_libraries( test_algo_decimation + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/Decimation/algo_decimation.cpp b/Apps/Tests/Algo/Decimation/algo_decimation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..473f8705317f12e9e00c11fcf75d5384df74eee7 --- /dev/null +++ b/Apps/Tests/Algo/Decimation/algo_decimation.cpp @@ -0,0 +1,26 @@ +#include + +extern int test_geometryApproximator(); +extern int test_colorPerVertexApproximator(); + +extern int test_predictor(); +extern int test_geometryPredictor(); + +extern int test_edgeSelector(); +extern int test_halfEdgeSelector(); +extern int test_decimation(); + +int main() +{ + test_geometryApproximator(); + test_colorPerVertexApproximator(); + + test_predictor(); + test_geometryPredictor(); + + test_edgeSelector(); + test_halfEdgeSelector(); + test_decimation(); + + return 0; +} diff --git a/Apps/Tests/Algo/Decimation/colorPerVertexApproximator.cpp b/Apps/Tests/Algo/Decimation/colorPerVertexApproximator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f7b274fd5bb80b4514619965867f5bc98a3c54b5 --- /dev/null +++ b/Apps/Tests/Algo/Decimation/colorPerVertexApproximator.cpp @@ -0,0 +1,35 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Decimation/colorPerVertexApproximator.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template class Algo::Surface::Decimation::Approximator_ColorNaive; + + +int test_colorPerVertexApproximator() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/Decimation/decimation.cpp b/Apps/Tests/Algo/Decimation/decimation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f4adad62cebd81f1ee77ca9d9be33777b8a9595d --- /dev/null +++ b/Apps/Tests/Algo/Decimation/decimation.cpp @@ -0,0 +1,81 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Decimation/decimation.h" + + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template int Algo::Surface::Decimation::decimate( + PFP1::MAP& map, + SelectorType s, + ApproximatorType a, + std::vector >& attribs, + unsigned int nbWantedVertices, + EdgeAttribute* edgeErrors, + void(*callback_wrapper)(void*, const void*) , + void* callback_object + ); + + +template int Algo::Surface::Decimation::decimate( + PFP1::MAP& map, + Selector* s, + std::vector*>& a, + unsigned int nbWantedVertices, + bool recomputePriorityList, + EdgeAttribute* edgeErrors, + void(*callback_wrapper)(void*, const void*), + void* callback_object + ); + + +template int Algo::Surface::Decimation::decimate( + PFP2::MAP& map, + SelectorType s, + ApproximatorType a, + std::vector >& attribs, + unsigned int nbWantedVertices, + EdgeAttribute* edgeErrors, + void(*callback_wrapper)(void*, const void*), + void* callback_object + ); +// +// +//template int Algo::Surface::Decimation::decimate( +// PFP2::MAP& map, +// Selector* s, +// std::vector*>& a, +// unsigned int nbWantedVertices, +// bool recomputePriorityList, +// EdgeAttribute* edgeErrors, +// void(*callback_wrapper)(void*, const void*), +// void* callback_object +// ); + + + +int test_decimation() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Decimation/edgeSelector.cpp b/Apps/Tests/Algo/Decimation/edgeSelector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7cefb83f2543184363223dbf2d919228169f947b --- /dev/null +++ b/Apps/Tests/Algo/Decimation/edgeSelector.cpp @@ -0,0 +1,45 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Decimation/edgeSelector.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template class Algo::Surface::Decimation::EdgeSelector_MapOrder; +template class Algo::Surface::Decimation::EdgeSelector_Random; +template class Algo::Surface::Decimation::EdgeSelector_Length; +template class Algo::Surface::Decimation::EdgeSelector_QEM; +template class Algo::Surface::Decimation::EdgeSelector_QEMml; +template class Algo::Surface::Decimation::EdgeSelector_NormalArea; +template class Algo::Surface::Decimation::EdgeSelector_Curvature; +template class Algo::Surface::Decimation::EdgeSelector_CurvatureTensor; +template class Algo::Surface::Decimation::EdgeSelector_MinDetail; +template class Algo::Surface::Decimation::EdgeSelector_ColorNaive; +template class Algo::Surface::Decimation::EdgeSelector_GeomColOptGradient; +template class Algo::Surface::Decimation::EdgeSelector_QEMextColor; + + + +int test_edgeSelector() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Decimation/geometryApproximator.cpp b/Apps/Tests/Algo/Decimation/geometryApproximator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9b4318558f5d0f893c8cfa085a7eab5970489de9 --- /dev/null +++ b/Apps/Tests/Algo/Decimation/geometryApproximator.cpp @@ -0,0 +1,42 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Decimation/geometryApproximator.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template class Algo::Surface::Decimation::Approximator_QEM; +template class Algo::Surface::Decimation::Approximator_QEMhalfEdge; +template class Algo::Surface::Decimation::Approximator_InterpolateAlongEdge; +template class Algo::Surface::Decimation::Approximator_HalfCollapse; +template class Algo::Surface::Decimation::Approximator_CornerCutting; +template class Algo::Surface::Decimation::Approximator_NormalArea; + + + +int test_geometryApproximator() +{ + + return 0; +} + + diff --git a/Apps/Tests/Algo/Decimation/geometryPredictor.cpp b/Apps/Tests/Algo/Decimation/geometryPredictor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e91895f6e97967d20f03e930a6a3277599501709 --- /dev/null +++ b/Apps/Tests/Algo/Decimation/geometryPredictor.cpp @@ -0,0 +1,44 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Decimation/geometryPredictor.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template class Algo::Surface::Decimation::Predictor_HalfCollapse; +template class Algo::Surface::Decimation::Predictor_TangentPredict1; +template class Algo::Surface::Decimation::Predictor_TangentPredict2; + +template class Algo::Surface::Decimation::Predictor_HalfCollapse; +template class Algo::Surface::Decimation::Predictor_TangentPredict1; +template class Algo::Surface::Decimation::Predictor_TangentPredict2; + +template class Algo::Surface::Decimation::Predictor_HalfCollapse; +template class Algo::Surface::Decimation::Predictor_TangentPredict1; +template class Algo::Surface::Decimation::Predictor_TangentPredict2; + + +int test_geometryPredictor() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Decimation/halfEdgeSelector.cpp b/Apps/Tests/Algo/Decimation/halfEdgeSelector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d7cfe23ec4750b835319e66863e311ccf7026de7 --- /dev/null +++ b/Apps/Tests/Algo/Decimation/halfEdgeSelector.cpp @@ -0,0 +1,38 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Decimation/halfEdgeSelector.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + + + +template class Algo::Surface::Decimation::HalfEdgeSelector_QEMml; +template class Algo::Surface::Decimation::HalfEdgeSelector_QEMextColor; +template class Algo::Surface::Decimation::HalfEdgeSelector_QEMextColorNormal; +template class Algo::Surface::Decimation::HalfEdgeSelector_ColorGradient; + +template class Algo::Surface::Decimation::HalfEdgeSelector_QEMml; +template class Algo::Surface::Decimation::HalfEdgeSelector_QEMextColor; +template class Algo::Surface::Decimation::HalfEdgeSelector_QEMextColorNormal; +template class Algo::Surface::Decimation::HalfEdgeSelector_ColorGradient; + + +int test_halfEdgeSelector() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Decimation/predictor.cpp b/Apps/Tests/Algo/Decimation/predictor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..43c8049206450d7b0638f374aa058eaa18997cd4 --- /dev/null +++ b/Apps/Tests/Algo/Decimation/predictor.cpp @@ -0,0 +1,36 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Decimation/predictor.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template class Algo::Surface::Decimation::Predictor; +template class Algo::Surface::Decimation::Predictor; +template class Algo::Surface::Decimation::Predictor; + + +int test_predictor() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/Export/CMakeLists.txt b/Apps/Tests/Algo/Export/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ed8c04e9ef0cd2567c517b7d2e9ffc4e117790bd --- /dev/null +++ b/Apps/Tests/Algo/Export/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_export) + +add_executable( test_algo_export +algo_export.cpp +export.cpp +exportPov.cpp +exportVTU.cpp +exportVol.cpp +) + +target_link_libraries( test_algo_export + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) \ No newline at end of file diff --git a/Apps/Tests/Algo/Export/algo_export.cpp b/Apps/Tests/Algo/Export/algo_export.cpp new file mode 100644 index 0000000000000000000000000000000000000000..107e7cda42f94a3b80f9e64d0246f2269d6d2b00 --- /dev/null +++ b/Apps/Tests/Algo/Export/algo_export.cpp @@ -0,0 +1,16 @@ +#include + +extern int test_export(); +extern int test_exportPov(); +extern int test_exportVTU(); +extern int test_exportVol(); + +int main() +{ + test_export(); + test_exportPov(); + test_exportVTU(); + test_exportVol(); + + return 0; +} diff --git a/Apps/Tests/Algo/Export/export.cpp b/Apps/Tests/Algo/Export/export.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0a4159eb80c25a8ecca600e819275798e58f52b1 --- /dev/null +++ b/Apps/Tests/Algo/Export/export.cpp @@ -0,0 +1,51 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Export/export.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::Export::exportPLY(PFP1::MAP& map, const VertexAttribute& position, const char* filename, const bool binary); +template bool Algo::Surface::Export::exportPLYnew(PFP1::MAP& map, const std::vector* >& attributeHandlers, const char* filename, const bool binary); +template bool Algo::Surface::Export::exportOFF(PFP1::MAP& map, const VertexAttribute& position, const char* filename); +template bool Algo::Surface::Export::exportOBJ(PFP1::MAP& map, const VertexAttribute& position, const char* filename); +template bool Algo::Surface::Export::exportChoupi(PFP1::MAP& map, const VertexAttribute& position, const char* filename); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::Export::exportPLY(PFP2::MAP& map, const VertexAttribute& position, const char* filename, const bool binary); +template bool Algo::Surface::Export::exportPLYnew(PFP2::MAP& map, const std::vector* >& attributeHandlers, const char* filename, const bool binary); +template bool Algo::Surface::Export::exportOFF(PFP2::MAP& map, const VertexAttribute& position, const char* filename); +template bool Algo::Surface::Export::exportOBJ(PFP2::MAP& map, const VertexAttribute& position, const char* filename); +template bool Algo::Surface::Export::exportChoupi(PFP2::MAP& map, const VertexAttribute& position, const char* filename); + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template bool Algo::Surface::Export::exportPLY(PFP3::MAP& map, const VertexAttribute& position, const char* filename, const bool binary); +template bool Algo::Surface::Export::exportPLYnew(PFP3::MAP& map, const std::vector* >& attributeHandlers, const char* filename, const bool binary); +template bool Algo::Surface::Export::exportOFF(PFP3::MAP& map, const VertexAttribute& position, const char* filename); +template bool Algo::Surface::Export::exportOBJ(PFP3::MAP& map, const VertexAttribute& position, const char* filename); +template bool Algo::Surface::Export::exportChoupi(PFP3::MAP& map, const VertexAttribute& position, const char* filename); + + +int test_export() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Export/exportPov.cpp b/Apps/Tests/Algo/Export/exportPov.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a726e7fcef5f849e22f00d07c980c759acc8d941 --- /dev/null +++ b/Apps/Tests/Algo/Export/exportPov.cpp @@ -0,0 +1,49 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Export/exportPov.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Surface::ExportPov::exportTriangleWire(std::ofstream& out, PFP1::VEC3& p1, PFP1::VEC3& p2, PFP1::VEC3& p3, float width); +template void Algo::Surface::ExportPov::exportTrianglePlain(std::ofstream& out, PFP1::VEC3& p1, PFP1::VEC3& p2, PFP1::VEC3& p3); +template void Algo::Surface::ExportPov::exportMeshPlain(std::ofstream& out, PFP1::MAP& map, VertexAttribute& position, const std::string& meshName); +template void Algo::Surface::ExportPov::exportMeshWire(std::ofstream& out, PFP1::MAP& map, VertexAttribute& position, const std::string& meshName); +template bool Algo::Surface::ExportPov::exportScenePov(PFP1::MAP& map, VertexAttribute& position, const std::string& filename, PFP1::VEC3 cameraPos, PFP1::VEC3 cameraLook, PFP1::VEC3 translate, float angle_X, float angle_Y, float angle_Z); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Surface::ExportPov::exportTriangleWire(std::ofstream& out, PFP2::VEC3& p1, PFP2::VEC3& p2, PFP2::VEC3& p3, float width); +template void Algo::Surface::ExportPov::exportTrianglePlain(std::ofstream& out, PFP2::VEC3& p1, PFP2::VEC3& p2, PFP2::VEC3& p3); +template void Algo::Surface::ExportPov::exportMeshPlain(std::ofstream& out, PFP2::MAP& map, VertexAttribute& position, const std::string& meshName); +template void Algo::Surface::ExportPov::exportMeshWire(std::ofstream& out, PFP2::MAP& map, VertexAttribute& position, const std::string& meshName); +template bool Algo::Surface::ExportPov::exportScenePov(PFP2::MAP& map, VertexAttribute& position, const std::string& filename, PFP2::VEC3 cameraPos, PFP2::VEC3 cameraLook, PFP2::VEC3 translate, float angle_X, float angle_Y, float angle_Z); + + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template void Algo::Surface::ExportPov::export3MeshPlainSmooth(std::ofstream& out, PFP3::MAP& map, VertexAttribute& position, const std::string& meshName); +template bool Algo::Surface::ExportPov::exportScenePovSmooth(PFP3::MAP& map, VertexAttribute& position, const std::string& filename, PFP3::VEC3 cameraPos, PFP3::VEC3 cameraLook, PFP3::VEC3 translate, float angle_X, float angle_Y, float angle_Z); + + +int test_exportPov() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Export/exportVTU.cpp b/Apps/Tests/Algo/Export/exportVTU.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03d8642e08b2d0d83e1550d67b9464eada263d21 --- /dev/null +++ b/Apps/Tests/Algo/Export/exportVTU.cpp @@ -0,0 +1,32 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Export/exportVTU.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::Export::exportVTU(PFP1::MAP& map, const VertexAttribute& position, const char* filename); +template bool Algo::Surface::Export::exportVTUBinary(PFP1::MAP& map, const VertexAttribute& position, const char* filename); +template class Algo::Surface::Export::VTUExporter; + + +struct PFP2 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +template class Algo::Volume::Export::VTUExporter; + +int test_exportVTU() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Export/exportVol.cpp b/Apps/Tests/Algo/Export/exportVol.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d483d95d19519b393a4c07934a8af62fe05517ea --- /dev/null +++ b/Apps/Tests/Algo/Export/exportVol.cpp @@ -0,0 +1,20 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap3.h" + +#include "Algo/Export/exportVol.hpp" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + + +template bool Algo::Volume::Export::exportMesh(PFP1::MAP& map, const VertexAttribute& position, const std::string& filename) ; + +int test_exportVol() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Filtering/CMakeLists.txt b/Apps/Tests/Algo/Filtering/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..989ef4f79c624e12a11b0f4879e9b9d84f5c75d3 --- /dev/null +++ b/Apps/Tests/Algo/Filtering/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_filtering) + +add_executable( test_algo_filtering +algo_filtering.cpp +average.cpp +average_normals.cpp +bilateral.cpp +taubin.cpp +tools.cpp +) + +target_link_libraries( test_algo_filtering + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + + diff --git a/Apps/Tests/Algo/Filtering/algo_filtering.cpp b/Apps/Tests/Algo/Filtering/algo_filtering.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27a8a98df734e5282a6ae3bee1e5f4323954e998 --- /dev/null +++ b/Apps/Tests/Algo/Filtering/algo_filtering.cpp @@ -0,0 +1,18 @@ +#include + +extern int test_average(); +extern int test_average_normals(); +extern int test_bilateral(); +extern int test_taubin(); +extern int test_tools(); + +int main() +{ + test_average(); + test_average_normals(); + test_bilateral(); + test_taubin(); + test_tools(); + + return 0; +} diff --git a/Apps/Tests/Algo/Filtering/average.cpp b/Apps/Tests/Algo/Filtering/average.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc66cd3be206fafd4805b1b5fe644d208c17b5f9 --- /dev/null +++ b/Apps/Tests/Algo/Filtering/average.cpp @@ -0,0 +1,80 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Filtering/average.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template void Algo::Surface::Filtering::filterAverageAttribute_OneRing(PFP1::MAP& map, +const VertexAttribute& attIn, VertexAttribute& attOut, int neigh); + +template void Algo::Surface::Filtering::filterAverageVertexAttribute_WithinSphere(PFP1::MAP& map, + const VertexAttribute& attIn, VertexAttribute& attOut, int neigh, + VertexAttribute& position, PFP1::REAL radius); + +template void Algo::Surface::Filtering::filterAverageEdgeAttribute_WithinSphere(PFP1::MAP& map, + const EdgeAttribute& attIn, EdgeAttribute& attOut, int neigh, + VertexAttribute& position, PFP1::REAL radius); + +template void Algo::Surface::Filtering::filterAverageFaceAttribute_WithinSphere(PFP1::MAP& map, + const FaceAttribute& attIn, FaceAttribute& attOut, int neigh, + VertexAttribute& position, PFP1::REAL radius); + + + +template void Algo::Surface::Filtering::filterAverageAttribute_OneRing(PFP2::MAP& map, + const VertexAttribute& attIn, VertexAttribute& attOut, int neigh); + +template void Algo::Surface::Filtering::filterAverageVertexAttribute_WithinSphere(PFP2::MAP& map, + const VertexAttribute& attIn, VertexAttribute& attOut, int neigh, + VertexAttribute& position, PFP2::REAL radius); + +template void Algo::Surface::Filtering::filterAverageEdgeAttribute_WithinSphere(PFP2::MAP& map, + const EdgeAttribute& attIn, EdgeAttribute& attOut, int neigh, + VertexAttribute& position, PFP2::REAL radius); + +template void Algo::Surface::Filtering::filterAverageFaceAttribute_WithinSphere(PFP2::MAP& map, + const FaceAttribute& attIn, FaceAttribute& attOut, int neigh, + VertexAttribute& position, PFP2::REAL radius); + + + +template void Algo::Surface::Filtering::filterAverageAttribute_OneRing(PFP3::MAP& map, + const VertexAttribute& attIn, VertexAttribute& attOut, int neigh); + +template void Algo::Surface::Filtering::filterAverageVertexAttribute_WithinSphere(PFP3::MAP& map, + const VertexAttribute& attIn, VertexAttribute& attOut, int neigh, + VertexAttribute& position, PFP3::REAL radius); + +template void Algo::Surface::Filtering::filterAverageEdgeAttribute_WithinSphere(PFP3::MAP& map, + const EdgeAttribute& attIn, EdgeAttribute& attOut, int neigh, + VertexAttribute& position, PFP3::REAL radius); + +template void Algo::Surface::Filtering::filterAverageFaceAttribute_WithinSphere(PFP3::MAP& map, + const FaceAttribute& attIn, FaceAttribute& attOut, int neigh, + VertexAttribute& position, PFP3::REAL radius); + +int test_average() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Filtering/average_normals.cpp b/Apps/Tests/Algo/Filtering/average_normals.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d86a8d76742b52a7d7c55c1bcb13091d39758ddc --- /dev/null +++ b/Apps/Tests/Algo/Filtering/average_normals.cpp @@ -0,0 +1,94 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Filtering/average_normals.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template void Algo::Surface::Filtering::computeNewPositionsFromFaceNormals(PFP1::MAP& map, + const VertexAttribute& position, VertexAttribute& position2, + const FaceAttribute& faceArea, + const FaceAttribute& faceCentroid, + const FaceAttribute& faceNormal, + const FaceAttribute& faceNewNormal); + +template void Algo::Surface::Filtering::filterAverageNormals(PFP1::MAP& map, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterMMSE(PFP1::MAP& map, float sigmaN2, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterTNBA(PFP1::MAP& map, float sigmaN2, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterVNBA(PFP1::MAP& map, float sigmaN2, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal); + + + + +template void Algo::Surface::Filtering::computeNewPositionsFromFaceNormals(PFP2::MAP& map, + const VertexAttribute& position, VertexAttribute& position2, + const FaceAttribute& faceArea, + const FaceAttribute& faceCentroid, + const FaceAttribute& faceNormal, + const FaceAttribute& faceNewNormal); + +template void Algo::Surface::Filtering::filterAverageNormals(PFP2::MAP& map, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterMMSE(PFP2::MAP& map, float sigmaN2, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterTNBA(PFP2::MAP& map, float sigmaN2, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterVNBA(PFP2::MAP& map, float sigmaN2, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal); + + + +template void Algo::Surface::Filtering::computeNewPositionsFromFaceNormals(PFP3::MAP& map, + const VertexAttribute& position, VertexAttribute& position2, + const FaceAttribute& faceArea, + const FaceAttribute& faceCentroid, + const FaceAttribute& faceNormal, + const FaceAttribute& faceNewNormal); + +template void Algo::Surface::Filtering::filterAverageNormals(PFP3::MAP& map, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterMMSE(PFP3::MAP& map, float sigmaN2, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterTNBA(PFP3::MAP& map, float sigmaN2, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterVNBA(PFP3::MAP& map, float sigmaN2, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal); + + +int test_average_normals() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Filtering/bilateral.cpp b/Apps/Tests/Algo/Filtering/bilateral.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c0dac74d9a9a04f493f98d1849e2663016eb6bca --- /dev/null +++ b/Apps/Tests/Algo/Filtering/bilateral.cpp @@ -0,0 +1,59 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Filtering/bilateral.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ +typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ +typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ +typedef EmbeddedGMap2 MAP; +}; + + +template void Algo::Surface::Filtering::filterBilateral( PFP1::MAP& map, + const VertexAttribute& positionIn,VertexAttribute& positionOut, + const VertexAttribute& normal); + +template void Algo::Surface::Filtering::filterSUSAN(PFP1::MAP& map, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2, + const VertexAttribute& normal); + + + +template void Algo::Surface::Filtering::filterBilateral(PFP2::MAP& map, + const VertexAttribute& positionIn, VertexAttribute& positionOut, + const VertexAttribute& normal); + +template void Algo::Surface::Filtering::filterSUSAN(PFP2::MAP& map, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2, + const VertexAttribute& normal); + + + +template void Algo::Surface::Filtering::filterBilateral(PFP3::MAP& map, + const VertexAttribute& positionIn, VertexAttribute& positionOut, + const VertexAttribute& normal); + +template void Algo::Surface::Filtering::filterSUSAN(PFP3::MAP& map, float SUSANthreshold, + const VertexAttribute& position, VertexAttribute& position2, + const VertexAttribute& normal); + + +int test_bilateral() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Filtering/functors.cpp b/Apps/Tests/Algo/Filtering/functors.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aff9aa7540ab1274089b5eb253fbd0e32abfd5e7 --- /dev/null +++ b/Apps/Tests/Algo/Filtering/functors.cpp @@ -0,0 +1,110 @@ +///******************************************************************************* +//* 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 * +//* * +//*******************************************************************************/ +// +//#ifndef __FILTERING_FUNCTORS_H__ +//#define __FILTERING_FUNCTORS_H__ +// +//#include "Topology/generic/functor.h" +//#include "Algo/Geometry/intersection.h" +// +//namespace CGoGN +//{ +// +//namespace Algo +//{ +// +//namespace Surface +//{ +// +//namespace Filtering +//{ +// +//template +//class FunctorAverage : public virtual FunctorType +//{ +// typedef typename ATTR_TYPE::DATA_TYPE T ; +// +//protected: +// const ATTR_TYPE& attr ; +// T sum ; +// unsigned int count ; +// +//public: +// FunctorAverage(const ATTR_TYPE& a) : FunctorType(), attr(a), sum(0), count(0) +// {} +// bool operator()(Dart d) +// { +// sum += attr[d] ; +// ++count ; +// return false ; +// } +// inline void reset() { sum = T(0) ; count = 0 ; } +// inline T getSum() { return sum ; } +// inline unsigned int getCount() { return count ; } +// inline T getAverage() { return sum / typename T::DATA_TYPE(count) ; } +//} ; +// +//template +//class FunctorAverageOnSphereBorder : public FunctorMap +//{ +// typedef typename PFP::VEC3 VEC3; +// +//protected: +// const VertexAttribute& attr ; +// const VertexAttribute& position ; +// VEC3 center; +// typename PFP::REAL radius; +// T sum ; +// unsigned int count ; +// +//public: +// FunctorAverageOnSphereBorder(typename PFP::MAP& map, const VertexAttribute& a, const VertexAttribute& p) : +// FunctorMap(map), attr(a), position(p), sum(0), count(0) +// { +// center = VEC3(0); +// radius = 0; +// } +// bool operator()(Dart d) +// { +// typename PFP::REAL alpha = 0; +// Geometry::intersectionSphereEdge(this->m_map, center, radius, d, position, alpha); +// sum += (1 - alpha) * attr[d] + alpha * attr[this->m_map.phi1(d)] ; +// ++count ; +// return false ; +// } +// inline void reset(VEC3& c, typename PFP::REAL r) { center = c; radius = r; sum = T(0) ; count = 0 ; } +// inline T getSum() { return sum ; } +// inline unsigned int getCount() { return count ; } +// inline T getAverage() { return sum / typename T::DATA_TYPE(count) ; } +//} ; +// +//} // namespace Filtering +// +//} // namespace Surface +// +//} // namespace Algo +// +//} // namespace CGoGN +// +//#endif diff --git a/Apps/Tests/Algo/Filtering/taubin.cpp b/Apps/Tests/Algo/Filtering/taubin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..db87e6f87dd878ed80d384d7baae65e8473ef880 --- /dev/null +++ b/Apps/Tests/Algo/Filtering/taubin.cpp @@ -0,0 +1,52 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Filtering/taubin.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template void Algo::Surface::Filtering::filterTaubin(PFP1::MAP& map, + VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterTaubin_modified(PFP1::MAP& map, + VertexAttribute& position, VertexAttribute& position2, PFP1::REAL radius); + + +template void Algo::Surface::Filtering::filterTaubin(PFP2::MAP& map, + VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterTaubin_modified(PFP2::MAP& map, + VertexAttribute& position, VertexAttribute& position2, PFP2::REAL radius); + + +template void Algo::Surface::Filtering::filterTaubin(PFP3::MAP& map, + VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Surface::Filtering::filterTaubin_modified(PFP3::MAP& map, + VertexAttribute& position, VertexAttribute& position2, PFP3::REAL radius); + + +int test_taubin() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Filtering/tools.cpp b/Apps/Tests/Algo/Filtering/tools.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0fac31700ceb9ba9b2302cc9c0c819e240033cd5 --- /dev/null +++ b/Apps/Tests/Algo/Filtering/tools.cpp @@ -0,0 +1,64 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Filtering/tools.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template PFP1::REAL Algo::Surface::Filtering::computeHaussdorf(PFP1::MAP& map, const VertexAttribute& originalPosition, const VertexAttribute& position2); +template void Algo::Surface::Filtering::computeNoise(PFP1::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal); +template void Algo::Surface::Filtering::computeUnfirmAdditiveNoise(PFP1::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2); +template void Algo::Surface::Filtering::computeGaussianAdditiveNoise(PFP1::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2); + +template PFP2::REAL Algo::Surface::Filtering::computeHaussdorf(PFP2::MAP& map, const VertexAttribute& originalPosition, const VertexAttribute& position2); +template void Algo::Surface::Filtering::computeNoise(PFP2::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal); +template void Algo::Surface::Filtering::computeUnfirmAdditiveNoise(PFP2::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2); +template void Algo::Surface::Filtering::computeGaussianAdditiveNoise(PFP2::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2); + +template PFP3::REAL Algo::Surface::Filtering::computeHaussdorf(PFP3::MAP& map, const VertexAttribute& originalPosition, const VertexAttribute& position2); +template void Algo::Surface::Filtering::computeNoise(PFP3::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal); +template void Algo::Surface::Filtering::computeUnfirmAdditiveNoise(PFP3::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2); +template void Algo::Surface::Filtering::computeGaussianAdditiveNoise(PFP3::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2); + + +struct PFP4 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +struct PFP5 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template void Algo::Volume::Filtering::computeNoise(PFP4::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2); +template void Algo::Volume::Filtering::computeNoiseGaussian(PFP4::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2); + +template void Algo::Volume::Filtering::computeNoise(PFP5::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2); +template void Algo::Volume::Filtering::computeNoiseGaussian(PFP5::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2); + + +int test_tools() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Geometry/CMakeLists.txt b/Apps/Tests/Algo/Geometry/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..73ee0920f51db5dcb862088ca88437ba8f593f1e --- /dev/null +++ b/Apps/Tests/Algo/Geometry/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_geometry) + +add_executable( test_algo_geometry +algo_geometry.cpp +area.cpp +basic.cpp +boundingbox.cpp +centroid.cpp +convexity.cpp +curvature.cpp +distances.cpp +feature.cpp +inclusion.cpp +intersection.cpp +laplacian.cpp +localFrame.cpp +normal.cpp +normalization.cpp +orientation.cpp +plane.cpp +stats.cpp +volume.cpp +voronoiDiagrams.cpp +) + +target_link_libraries( test_algo_geometry + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/Geometry/algo_geometry.cpp b/Apps/Tests/Algo/Geometry/algo_geometry.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b092de17110e081978ab602c9f1b6c6203e4552d --- /dev/null +++ b/Apps/Tests/Algo/Geometry/algo_geometry.cpp @@ -0,0 +1,23 @@ +#include + +extern int test_area(); +extern int test_centroid(); +extern int test_boundingbox(); +extern int test_basic(); +extern int test_convexity(); +extern int test_curvature(); +extern int test_distances(); + + +int main() +{ + test_area(); + test_centroid(); + test_boundingbox(); + test_basic(); + test_convexity(); + test_curvature(); + test_distances(); + + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/area.cpp b/Apps/Tests/Algo/Geometry/area.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8fb1b513a25b5ae69173f5100f0cb1243c0061be --- /dev/null +++ b/Apps/Tests/Algo/Geometry/area.cpp @@ -0,0 +1,99 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Geometry/area.h" + + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +using namespace CGoGN; + + +/***************************************** +* AREA INSTANTIATION +*****************************************/ + +template PFP1::REAL Algo::Surface::Geometry::triangleArea(PFP1::MAP& map, Face f, const VertexAttribute& position); +template PFP1::REAL Algo::Surface::Geometry::convexFaceArea(PFP1::MAP& map, Face f, const VertexAttribute& position); +template PFP1::REAL Algo::Surface::Geometry::totalArea(PFP1::MAP& map, const VertexAttribute& position); +template PFP1::REAL Algo::Surface::Geometry::vertexOneRingArea(PFP1::MAP& map, Vertex v, const VertexAttribute& position); +template PFP1::REAL Algo::Surface::Geometry::vertexBarycentricArea(PFP1::MAP& map, Vertex v, const VertexAttribute& position); +template PFP1::REAL Algo::Surface::Geometry::vertexVoronoiArea(PFP1::MAP& map, Vertex v, const VertexAttribute& position); +template PFP1::REAL Algo::Surface::Geometry::edgeArea(PFP1::MAP& map, Edge e, const VertexAttribute& position); +template void Algo::Surface::Geometry::computeAreaFaces(PFP1::MAP& map, const VertexAttribute& position, FaceAttribute& face_area); +template void Algo::Surface::Geometry::computeAreaEdges(PFP1::MAP& map, const VertexAttribute& position, EdgeAttribute& edge_area); +template void Algo::Surface::Geometry::computeOneRingAreaVertices(PFP1::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::computeBarycentricAreaVertices(PFP1::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::computeVoronoiAreaVertices(PFP1::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); + +template PFP1::REAL Algo::Surface::Geometry::Parallel::totalArea(PFP1::MAP& map, const VertexAttribute& position); +template void Algo::Surface::Geometry::Parallel::computeAreaFaces(PFP1::MAP& map, const VertexAttribute& position, FaceAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeAreaEdges(PFP1::MAP& map, const VertexAttribute& position, EdgeAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeOneRingAreaVertices(PFP1::MAP& map, const VertexAttribute& position, VertexAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeBarycentricAreaVertices(PFP1::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::Parallel::computeVoronoiAreaVertices(PFP1::MAP& map, const VertexAttribute& position, VertexAttribute& area); + + +template PFP2::REAL Algo::Surface::Geometry::triangleArea(PFP2::MAP& map, Face f, const VertexAttribute& position); +template PFP2::REAL Algo::Surface::Geometry::convexFaceArea(PFP2::MAP& map, Face f, const VertexAttribute& position); +template PFP2::REAL Algo::Surface::Geometry::totalArea(PFP2::MAP& map, const VertexAttribute& position); +template PFP2::REAL Algo::Surface::Geometry::vertexOneRingArea(PFP2::MAP& map, Vertex v, const VertexAttribute& position); +template PFP2::REAL Algo::Surface::Geometry::vertexBarycentricArea(PFP2::MAP& map, Vertex v, const VertexAttribute& position); +template PFP2::REAL Algo::Surface::Geometry::vertexVoronoiArea(PFP2::MAP& map, Vertex v, const VertexAttribute& position); +template PFP2::REAL Algo::Surface::Geometry::edgeArea(PFP2::MAP& map, Edge e, const VertexAttribute& position); +template void Algo::Surface::Geometry::computeAreaFaces(PFP2::MAP& map, const VertexAttribute& position, FaceAttribute& face_area); +template void Algo::Surface::Geometry::computeAreaEdges(PFP2::MAP& map, const VertexAttribute& position, EdgeAttribute& edge_area); +template void Algo::Surface::Geometry::computeOneRingAreaVertices(PFP2::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::computeBarycentricAreaVertices(PFP2::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::computeVoronoiAreaVertices(PFP2::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); + +template PFP2::REAL Algo::Surface::Geometry::Parallel::totalArea(PFP2::MAP& map, const VertexAttribute& position); +template void Algo::Surface::Geometry::Parallel::computeAreaFaces(PFP2::MAP& map, const VertexAttribute& position, FaceAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeAreaEdges(PFP2::MAP& map, const VertexAttribute& position, EdgeAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeOneRingAreaVertices(PFP2::MAP& map, const VertexAttribute& position, VertexAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeBarycentricAreaVertices(PFP2::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::Parallel::computeVoronoiAreaVertices(PFP2::MAP& map, const VertexAttribute& position, VertexAttribute& area); + +template PFP3::REAL Algo::Surface::Geometry::triangleArea(PFP3::MAP& map, Face f, const VertexAttribute& position); +template PFP3::REAL Algo::Surface::Geometry::convexFaceArea(PFP3::MAP& map, Face f, const VertexAttribute& position); +template PFP3::REAL Algo::Surface::Geometry::totalArea(PFP3::MAP& map, const VertexAttribute& position); +template PFP3::REAL Algo::Surface::Geometry::vertexOneRingArea(PFP3::MAP& map, Vertex v, const VertexAttribute& position); +template PFP3::REAL Algo::Surface::Geometry::vertexBarycentricArea(PFP3::MAP& map, Vertex v, const VertexAttribute& position); +template PFP3::REAL Algo::Surface::Geometry::vertexVoronoiArea(PFP3::MAP& map, Vertex v, const VertexAttribute& position); +template PFP3::REAL Algo::Surface::Geometry::edgeArea(PFP3::MAP& map, Edge e, const VertexAttribute& position); +template void Algo::Surface::Geometry::computeAreaFaces(PFP3::MAP& map, const VertexAttribute& position, FaceAttribute& face_area); +template void Algo::Surface::Geometry::computeAreaEdges(PFP3::MAP& map, const VertexAttribute& position, EdgeAttribute& edge_area); +template void Algo::Surface::Geometry::computeOneRingAreaVertices(PFP3::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::computeBarycentricAreaVertices(PFP3::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::computeVoronoiAreaVertices(PFP3::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); + +template PFP3::REAL Algo::Surface::Geometry::Parallel::totalArea(PFP3::MAP& map, const VertexAttribute& position); +template void Algo::Surface::Geometry::Parallel::computeAreaFaces(PFP3::MAP& map, const VertexAttribute& position, FaceAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeAreaEdges(PFP3::MAP& map, const VertexAttribute& position, EdgeAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeOneRingAreaVertices(PFP3::MAP& map, const VertexAttribute& position, VertexAttribute& area); +template void Algo::Surface::Geometry::Parallel::computeBarycentricAreaVertices(PFP3::MAP& map, const VertexAttribute& position, VertexAttribute& vertex_area); +template void Algo::Surface::Geometry::Parallel::computeVoronoiAreaVertices(PFP3::MAP& map, const VertexAttribute& position, VertexAttribute& area); + + +int test_area() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/basic.cpp b/Apps/Tests/Algo/Geometry/basic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d8a427d9d55539b7b3fc64eed9941a9d59cf4bc4 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/basic.cpp @@ -0,0 +1,57 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Geometry/basic.h" + + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +using namespace CGoGN; + + +/***************************************** +* BASIC INSTANTIATION +*****************************************/ + + +template PFP1::VEC3 Algo::Geometry::vectorOutOfDart(PFP1::MAP& map, Dart d, const VertexAttribute& position); +template PFP1::REAL Algo::Geometry::edgeLength(PFP1::MAP& map, Dart d, const VertexAttribute& position); +template PFP1::REAL Algo::Geometry::meanEdgeLength(PFP1::MAP& map, const VertexAttribute& position); +template PFP1::REAL Algo::Geometry::angle(PFP1::MAP& map, Dart d1, Dart d2, const VertexAttribute& position); +template bool Algo::Geometry::isTriangleObtuse(PFP1::MAP& map, Dart d, const VertexAttribute& position); + +template PFP2::VEC3 Algo::Geometry::vectorOutOfDart(PFP2::MAP& map, Dart d, const VertexAttribute& position); +template PFP2::REAL Algo::Geometry::edgeLength(PFP2::MAP& map, Dart d, const VertexAttribute& position); +template PFP2::REAL Algo::Geometry::meanEdgeLength(PFP2::MAP& map, const VertexAttribute& position); +template PFP2::REAL Algo::Geometry::angle(PFP2::MAP& map, Dart d1, Dart d2, const VertexAttribute& position); +template bool Algo::Geometry::isTriangleObtuse(PFP2::MAP& map, Dart d, const VertexAttribute& position); + +template PFP3::VEC3 Algo::Geometry::vectorOutOfDart(PFP3::MAP& map, Dart d, const VertexAttribute& position); +template PFP3::REAL Algo::Geometry::edgeLength(PFP3::MAP& map, Dart d, const VertexAttribute& position); +template PFP3::REAL Algo::Geometry::meanEdgeLength(PFP3::MAP& map, const VertexAttribute& position); +template PFP3::REAL Algo::Geometry::angle(PFP3::MAP& map, Dart d1, Dart d2, const VertexAttribute& position); +template bool Algo::Geometry::isTriangleObtuse(PFP3::MAP& map, Dart d, const VertexAttribute& position); + + +int test_basic() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/boundingbox.cpp b/Apps/Tests/Algo/Geometry/boundingbox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4c990fb162e16fa43227c83f13dff9b6684b10b3 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/boundingbox.cpp @@ -0,0 +1,42 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Geometry/boundingbox.h" + + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +using namespace CGoGN; + + +/***************************************** +* INSTANTIATION +*****************************************/ + +template Geom::BoundingBox Algo::Geometry::computeBoundingBox(PFP1::MAP& map, const VertexAttribute& position); +template Geom::BoundingBox Algo::Geometry::computeBoundingBox(PFP2::MAP& map, const VertexAttribute& position); +template Geom::BoundingBox Algo::Geometry::computeBoundingBox(PFP3::MAP& map, const VertexAttribute& position); + + +int test_boundingbox() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/centroid.cpp b/Apps/Tests/Algo/Geometry/centroid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2d9ced25b5523150a9003500a4273ffda59cc764 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/centroid.cpp @@ -0,0 +1,103 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Geometry/centroid.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +using namespace CGoGN; + + +/***************************************** +* CENTROID INSTANTIATION +*****************************************/ + +typedef VertexAttribute VATT1; +typedef FaceAttribute FATT1; +typedef VolumeAttribute WATT1; +template VATT1::DATA_TYPE Algo::Surface::Geometry::volumeCentroid(PFP1::MAP& map, Vol d, const VATT1& attributs); +template VATT1::DATA_TYPE Algo::Surface::Geometry::volumeCentroidELW(PFP1::MAP& map, Vol d, const VATT1& attributs); +template VATT1::DATA_TYPE Algo::Surface::Geometry::faceCentroid(PFP1::MAP& map, Face d, const VATT1& attributs); +template VATT1::DATA_TYPE Algo::Surface::Geometry::faceCentroidELW(PFP1::MAP& map, Face d, const VATT1& attributs); +template VATT1::DATA_TYPE Algo::Surface::Geometry::vertexNeighborhoodCentroid(PFP1::MAP& map, Vertex d, const VATT1& attributs); +template void Algo::Surface::Geometry::computeCentroidFaces(PFP1::MAP& map, const VATT1& position, FATT1& face_centroid); +template void Algo::Surface::Geometry::computeCentroidELWFaces(PFP1::MAP& map, const VATT1& position, FATT1& face_centroid); +template void Algo::Surface::Geometry::computeNeighborhoodCentroidVertices(PFP1::MAP& map, const VATT1& position, VATT1& vertex_centroid); + +template void Algo::Surface::Geometry::Parallel::computeCentroidFaces(PFP1::MAP& map, const VATT1& position, FATT1& face_centroid); +template void Algo::Surface::Geometry::Parallel::computeCentroidELWFaces(PFP1::MAP& map, const VATT1& position, FATT1& face_centroid); +template void Algo::Surface::Geometry::Parallel::computeNeighborhoodCentroidVertices(PFP1::MAP& map, const VATT1& position, VATT1& vertex_centroid); + +template VATT1::DATA_TYPE Algo::Volume::Geometry::vertexNeighborhoodCentroid(PFP1::MAP& map, Vertex d, const VATT1& attributs); +template void Algo::Volume::Geometry::computeCentroidVolumes(PFP1::MAP& map, const VATT1& position, WATT1& vol_centroid); +template void Algo::Volume::Geometry::computeCentroidELWVolumes(PFP1::MAP& map, const VATT1& position, WATT1& vol_centroid); +template void Algo::Volume::Geometry::computeNeighborhoodCentroidVertices(PFP1::MAP& map, const VATT1& position, VATT1& vertex_centroid); + + +typedef VertexAttribute VATT2; +typedef FaceAttribute FATT2; +typedef VolumeAttribute WATT2; +template VATT2::DATA_TYPE Algo::Surface::Geometry::volumeCentroid(PFP2::MAP& map, Vol d, const VATT2& attributs); +template VATT2::DATA_TYPE Algo::Surface::Geometry::volumeCentroidELW(PFP2::MAP& map, Vol d, const VATT2& attributs); +template VATT2::DATA_TYPE Algo::Surface::Geometry::faceCentroid(PFP2::MAP& map, Face d, const VATT2& attributs); +template VATT2::DATA_TYPE Algo::Surface::Geometry::faceCentroidELW(PFP2::MAP& map, Face d, const VATT2& attributs); +template VATT2::DATA_TYPE Algo::Surface::Geometry::vertexNeighborhoodCentroid(PFP2::MAP& map, Vertex d, const VATT2& attributs); +template void Algo::Surface::Geometry::computeCentroidFaces(PFP2::MAP& map, const VATT2& position, FATT2& face_centroid); +template void Algo::Surface::Geometry::computeCentroidELWFaces(PFP2::MAP& map, const VATT2& position, FATT2& face_centroid); +template void Algo::Surface::Geometry::computeNeighborhoodCentroidVertices(PFP2::MAP& map, const VATT2& position, VATT2& vertex_centroid); + +template void Algo::Surface::Geometry::Parallel::computeCentroidFaces(PFP2::MAP& map, const VATT2& position, FATT2& face_centroid); +template void Algo::Surface::Geometry::Parallel::computeCentroidELWFaces(PFP2::MAP& map, const VATT2& position, FATT2& face_centroid); +template void Algo::Surface::Geometry::Parallel::computeNeighborhoodCentroidVertices(PFP2::MAP& map, const VATT2& position, VATT2& vertex_centroid); + +template VATT2::DATA_TYPE Algo::Volume::Geometry::vertexNeighborhoodCentroid(PFP2::MAP& map, Vertex d, const VATT2& attributs); +template void Algo::Volume::Geometry::computeCentroidVolumes(PFP2::MAP& map, const VATT2& position, WATT2& vol_centroid); +template void Algo::Volume::Geometry::computeCentroidELWVolumes(PFP2::MAP& map, const VATT2& position, WATT2& vol_centroid); +template void Algo::Volume::Geometry::computeNeighborhoodCentroidVertices(PFP2::MAP& map, const VATT2& position, VATT2& vertex_centroid); + + +typedef VertexAttribute VATT3; +typedef FaceAttribute FATT3; +typedef VolumeAttribute WATT3; +template VATT3::DATA_TYPE Algo::Surface::Geometry::volumeCentroid(PFP3::MAP& map, Vol d, const VATT3& attributs); +template VATT3::DATA_TYPE Algo::Surface::Geometry::volumeCentroidELW(PFP3::MAP& map, Vol d, const VATT3& attributs); +template VATT3::DATA_TYPE Algo::Surface::Geometry::faceCentroid(PFP3::MAP& map, Face d, const VATT3& attributs); +template VATT3::DATA_TYPE Algo::Surface::Geometry::faceCentroidELW(PFP3::MAP& map, Face d, const VATT3& attributs); +template VATT3::DATA_TYPE Algo::Surface::Geometry::vertexNeighborhoodCentroid(PFP3::MAP& map, Vertex d, const VATT3& attributs); +template void Algo::Surface::Geometry::computeCentroidFaces(PFP3::MAP& map, const VATT3& position, FATT3& face_centroid); +template void Algo::Surface::Geometry::computeCentroidELWFaces(PFP3::MAP& map, const VATT3& position, FATT3& face_centroid); +template void Algo::Surface::Geometry::computeNeighborhoodCentroidVertices(PFP3::MAP& map, const VATT3& position, VATT3& vertex_centroid); + +template void Algo::Surface::Geometry::Parallel::computeCentroidFaces(PFP3::MAP& map, const VATT3& position, FATT3& face_centroid); +template void Algo::Surface::Geometry::Parallel::computeCentroidELWFaces(PFP3::MAP& map, const VATT3& position, FATT3& face_centroid); +template void Algo::Surface::Geometry::Parallel::computeNeighborhoodCentroidVertices(PFP3::MAP& map, const VATT3& position, VATT3& vertex_centroid); + +template VATT3::DATA_TYPE Algo::Volume::Geometry::vertexNeighborhoodCentroid(PFP3::MAP& map, Vertex d, const VATT3& attributs); +template void Algo::Volume::Geometry::computeCentroidVolumes(PFP3::MAP& map, const VATT3& position, WATT3& vol_centroid); +template void Algo::Volume::Geometry::computeCentroidELWVolumes(PFP3::MAP& map, const VATT3& position, WATT3& vol_centroid); +template void Algo::Volume::Geometry::computeNeighborhoodCentroidVertices(PFP3::MAP& map, const VATT3& position, VATT3& vertex_centroid); + + + +int test_centroid() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/convexity.cpp b/Apps/Tests/Algo/Geometry/convexity.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8030dc945270b97ee072d418dd754298ce1cc8ee --- /dev/null +++ b/Apps/Tests/Algo/Geometry/convexity.cpp @@ -0,0 +1,40 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Geometry/convexity.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +using namespace CGoGN; + + +/***************************************** +* CONVEXITY INSTANTIATION +*****************************************/ + +template bool Algo::Surface::Geometry::isEdgeConvex(PFP1::MAP& map, Edge e, const VertexAttribute& position); +template bool Algo::Surface::Geometry::isEdgeConvex(PFP2::MAP& map, Edge e, const VertexAttribute& position); +template bool Algo::Surface::Geometry::isEdgeConvex(PFP3::MAP& map, Edge e, const VertexAttribute& position); + +int test_convexity() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/curvature.cpp b/Apps/Tests/Algo/Geometry/curvature.cpp new file mode 100644 index 0000000000000000000000000000000000000000..622dde46e5ce3a03fac905c33dd7ea6ffd14ab28 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/curvature.cpp @@ -0,0 +1,472 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Geometry/curvature.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +using namespace CGoGN; + + +/***************************************** +* MAP FLOAT INSTANTIATION +*****************************************/ + + +template void Algo::Surface::Geometry::computeCurvatureVertices_QuadraticFitting( + PFP1::MAP& map, + const VertexAttribute& position, + const VertexAttribute& normal, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_QuadraticFitting( + PFP1::MAP& map, + Vertex v, + const VertexAttribute& position, + const VertexAttribute& normal, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin + ); + +template void Algo::Surface::Geometry::vertexQuadraticFitting( + PFP1::MAP& map, + Vertex v, + PFP1::MATRIX33& localFrame, + const VertexAttribute& position, + const VertexAttribute& normal, + PFP1::REAL& a, PFP1::REAL& b, PFP1::REAL& c, PFP1::REAL& d, PFP1::REAL& e + ); + +template void Algo::Surface::Geometry::quadraticFittingAddVertexPos( + PFP1::VEC3& v, + PFP1::VEC3& p, + PFP1::MATRIX33& localFrame + ); + +template void Algo::Surface::Geometry::quadraticFittingAddVertexNormal( + PFP1::VEC3& v, + PFP1::VEC3& n, + PFP1::VEC3& p, + PFP1::MATRIX33& localFrame + ); + + +template void Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles( + PFP1::MAP& map, + PFP1::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_NormalCycles( + PFP1::MAP& map, + Vertex v, + PFP1::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected( + PFP1::MAP& map, + PFP1::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_NormalCycles_Projected( + PFP1::MAP& map, + Vertex v, + PFP1::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + + + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + Geom::Matrix<3, 3, PFP1::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + const EdgeAttribute& edgeangle, + Geom::Matrix<3, 3, PFP1::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + Geom::Matrix<3, 3, PFP1::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_SortAndSetEigenComponents( + const PFP1::VEC3& e_val, + const Geom::Matrix<3, 3, PFP1::REAL> & e_vec, + PFP1::REAL& kmax, + PFP1::REAL& kmin, + PFP1::VEC3& Kmax, + PFP1::VEC3& Kmin, + PFP1::VEC3& Knormal, + const PFP1::VEC3& normal + ); + +template void Algo::Surface::Geometry::normalCycles_SortTensor(Geom::Matrix<3, 3, PFP1::REAL>& tensor); + +template void Algo::Surface::Geometry::normalCycles_ProjectTensor(Geom::Matrix<3, 3, PFP1::REAL>& tensor, const PFP1::VEC3& normal_vector); + + +/***************************************** +* MAP DOUBLE INSTANTIATION +*****************************************/ + + +template void Algo::Surface::Geometry::computeCurvatureVertices_QuadraticFitting( + PFP2::MAP& map, + const VertexAttribute& position, + const VertexAttribute& normal, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_QuadraticFitting( + PFP2::MAP& map, + Vertex v, + const VertexAttribute& position, + const VertexAttribute& normal, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin + ); + +template void Algo::Surface::Geometry::vertexQuadraticFitting( + PFP2::MAP& map, + Vertex v, + PFP2::MATRIX33& localFrame, + const VertexAttribute& position, + const VertexAttribute& normal, + PFP2::REAL& a, PFP2::REAL& b, PFP2::REAL& c, PFP2::REAL& d, PFP2::REAL& e + ); + +template void Algo::Surface::Geometry::quadraticFittingAddVertexPos( + PFP2::VEC3& v, + PFP2::VEC3& p, + PFP2::MATRIX33& localFrame + ); + +template void Algo::Surface::Geometry::quadraticFittingAddVertexNormal( + PFP2::VEC3& v, + PFP2::VEC3& n, + PFP2::VEC3& p, + PFP2::MATRIX33& localFrame + ); + + +template void Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles( + PFP2::MAP& map, + PFP2::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_NormalCycles( + PFP2::MAP& map, + Vertex v, + PFP2::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected( + PFP2::MAP& map, + PFP2::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_NormalCycles_Projected( + PFP2::MAP& map, + Vertex v, + PFP2::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + + + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + Geom::Matrix<3, 3, PFP2::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + const EdgeAttribute& edgeangle, + Geom::Matrix<3, 3, PFP2::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + Geom::Matrix<3, 3, PFP2::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_SortAndSetEigenComponents( + const PFP2::VEC3& e_val, + const Geom::Matrix<3, 3, PFP2::REAL> & e_vec, + PFP2::REAL& kmax, + PFP2::REAL& kmin, + PFP2::VEC3& Kmax, + PFP2::VEC3& Kmin, + PFP2::VEC3& Knormal, + const PFP2::VEC3& normal + ); + +template void Algo::Surface::Geometry::normalCycles_SortTensor(Geom::Matrix<3, 3, PFP2::REAL>& tensor); + +template void Algo::Surface::Geometry::normalCycles_ProjectTensor(Geom::Matrix<3, 3, PFP2::REAL>& tensor, const PFP2::VEC3& normal_vector); + + +/***************************************** +* GMAP float INSTANTIATION +*****************************************/ + + +template void Algo::Surface::Geometry::computeCurvatureVertices_QuadraticFitting( + PFP3::MAP& map, + const VertexAttribute& position, + const VertexAttribute& normal, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_QuadraticFitting( + PFP3::MAP& map, + Vertex v, + const VertexAttribute& position, + const VertexAttribute& normal, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin + ); + +template void Algo::Surface::Geometry::vertexQuadraticFitting( + PFP3::MAP& map, + Vertex v, + PFP3::MATRIX33& localFrame, + const VertexAttribute& position, + const VertexAttribute& normal, + PFP3::REAL& a, PFP3::REAL& b, PFP3::REAL& c, PFP3::REAL& d, PFP3::REAL& e + ); + +template void Algo::Surface::Geometry::quadraticFittingAddVertexPos( + PFP3::VEC3& v, + PFP3::VEC3& p, + PFP3::MATRIX33& localFrame + ); + +template void Algo::Surface::Geometry::quadraticFittingAddVertexNormal( + PFP3::VEC3& v, + PFP3::VEC3& n, + PFP3::VEC3& p, + PFP3::MATRIX33& localFrame + ); + + +template void Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles( + PFP3::MAP& map, + PFP3::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_NormalCycles( + PFP3::MAP& map, + Vertex v, + PFP3::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected( + PFP3::MAP& map, + PFP3::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + +template void Algo::Surface::Geometry::computeCurvatureVertex_NormalCycles_Projected( + PFP3::MAP& map, + Vertex v, + PFP3::REAL radius, + const VertexAttribute& position, + const VertexAttribute& normal, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + VertexAttribute& kmax, + VertexAttribute& kmin, + VertexAttribute& Kmax, + VertexAttribute& Kmin, + VertexAttribute& Knormal + ); + + + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + Geom::Matrix<3, 3, PFP3::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + const EdgeAttribute& edgeangle, + Geom::Matrix<3, 3, PFP3::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_computeTensor( + Algo::Surface::Selection::Collector& col, + const VertexAttribute& position, + const EdgeAttribute& edgeangle, + const EdgeAttribute& edgearea, + Geom::Matrix<3, 3, PFP3::REAL>& tensor + ); + +template void Algo::Surface::Geometry::normalCycles_SortAndSetEigenComponents( + const PFP3::VEC3& e_val, + const Geom::Matrix<3, 3, PFP3::REAL> & e_vec, + PFP3::REAL& kmax, + PFP3::REAL& kmin, + PFP3::VEC3& Kmax, + PFP3::VEC3& Kmin, + PFP3::VEC3& Knormal, + const PFP3::VEC3& normal + ); + +template void Algo::Surface::Geometry::normalCycles_SortTensor(Geom::Matrix<3, 3, PFP3::REAL>& tensor); + +template void Algo::Surface::Geometry::normalCycles_ProjectTensor(Geom::Matrix<3, 3, PFP3::REAL>& tensor, const PFP3::VEC3& normal_vector); + + + + +int test_curvature() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/distances.cpp b/Apps/Tests/Algo/Geometry/distances.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d418aacd5a3b1639f2fa92c5f667ff77915b6737 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/distances.cpp @@ -0,0 +1,44 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" + +#include "Algo/Geometry/distances.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + + + +template PFP1::REAL Algo::Geometry::squaredDistancePoint2FacePlane(PFP1::MAP& map, Face f, const VertexAttribute& position, const PFP1::VEC3& P); +template PFP1::REAL Algo::Geometry::squaredDistancePoint2Face(PFP1::MAP& map, Face f, const VertexAttribute& position, const PFP1::VEC3& P); +template PFP1::REAL Algo::Geometry::squaredDistancePoint2Edge(PFP1::MAP& map, Edge e, const VertexAttribute& position, const PFP1::VEC3& P); + +template PFP2::REAL Algo::Geometry::squaredDistancePoint2FacePlane(PFP2::MAP& map, Face f, const VertexAttribute& position, const PFP2::VEC3& P); +template PFP2::REAL Algo::Geometry::squaredDistancePoint2Face(PFP2::MAP& map, Face f, const VertexAttribute& position, const PFP2::VEC3& P); +template PFP2::REAL Algo::Geometry::squaredDistancePoint2Edge(PFP2::MAP& map, Edge e, const VertexAttribute& position, const PFP2::VEC3& P); + +template PFP3::REAL Algo::Geometry::squaredDistancePoint2FacePlane(PFP3::MAP& map, Face f, const VertexAttribute& position, const PFP3::VEC3& P); +template PFP3::REAL Algo::Geometry::squaredDistancePoint2Face(PFP3::MAP& map, Face f, const VertexAttribute& position, const PFP3::VEC3& P); +template PFP3::REAL Algo::Geometry::squaredDistancePoint2Edge(PFP3::MAP& map, Edge e, const VertexAttribute& position, const PFP3::VEC3& P); + + + +int test_distances() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Geometry/feature.cpp b/Apps/Tests/Algo/Geometry/feature.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d57a8e4e4d2a2f5e28c531f699a81d14482ddb9f --- /dev/null +++ b/Apps/Tests/Algo/Geometry/feature.cpp @@ -0,0 +1,209 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Geometry/feature.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + + + +template void Algo::Surface::Geometry::featureEdgeDetection( + PFP1::MAP& map, + const VertexAttribute& position, + CellMarker& featureEdge) ; + +template void Algo::Surface::Geometry::computeFaceGradient( + PFP1::MAP& map, + const VertexAttribute& position, + const FaceAttribute& face_normal, + const VertexAttribute& scalar, + const FaceAttribute& face_area, + FaceAttribute& face_gradient) ; + +template PFP1::VEC3 Algo::Surface::Geometry::faceGradient( + PFP1::MAP& map, + Dart d, + const VertexAttribute& position, + const FaceAttribute& face_normal, + const VertexAttribute& scalar, + const FaceAttribute& face_area) ; + +template void Algo::Surface::Geometry::computeVertexGradient( + PFP1::MAP& map, + const FaceAttribute& face_gradient, + const FaceAttribute& face_area, + VertexAttribute& vertex_gradient) ; + +template PFP1::VEC3 Algo::Surface::Geometry::vertexGradient( + PFP1::MAP& map, + Dart d, + const FaceAttribute& face_gradient, + const FaceAttribute& area) ; + + +template void Algo::Surface::Geometry::computeTriangleType( + PFP1::MAP& map, + const VertexAttribute& K, + CellMarker& regularMarker) ; + +template bool Algo::Surface::Geometry::isTriangleRegular( + PFP1::MAP& map, + Dart d, + const VertexAttribute& K) ; + +template void Algo::Surface::Geometry::initRidgeSegments( + PFP1::MAP& map, + FaceAttribute, PFP1::MAP>& ridge_segments) ; + +template void Algo::Surface::Geometry::computeRidgeLines( + PFP1::MAP& map, + CellMarker& regularMarker, + const VertexAttribute& position, + const VertexAttribute& K, + const VertexAttribute& vertex_gradient, + const VertexAttribute& k, + const VertexAttribute& k2, + FaceAttribute, PFP1::MAP>& ridge_segments) ; + + +template void Algo::Surface::Geometry::ridgeLines( + PFP1::MAP& map, + Dart d, + const VertexAttribute& position, + const VertexAttribute& K, + const VertexAttribute& vertex_gradient, + const VertexAttribute& k, + const VertexAttribute& k2, + FaceAttribute, PFP1::MAP>& ridge_segments) ; + +template void Algo::Surface::Geometry::computeSingularTriangle( + PFP1::MAP& map, + CellMarker& regularMarker, + FaceAttribute, PFP1::MAP>& ridge_segments) ; + +template void Algo::Surface::Geometry::singularTriangle( + PFP1::MAP& map, + Dart d, + CellMarker& regularMarker, + FaceAttribute, PFP1::MAP>& ridge_segments) ; + +template bool Algo::Surface::Geometry::isEdgeInTriangle( + PFP1::MAP& map, + Dart edge, + Dart triangle) ; + +template std::vector Algo::Surface::Geometry::occludingContoursDetection( + PFP1::MAP& map, + const PFP1::VEC3& cameraPosition, + const VertexAttribute& position, + const VertexAttribute& normal) ; + + +// WITH DOUBLE + +template void Algo::Surface::Geometry::featureEdgeDetection( + PFP2::MAP& map, + const VertexAttribute& position, + CellMarker& featureEdge); + +template void Algo::Surface::Geometry::computeFaceGradient( + PFP2::MAP& map, + const VertexAttribute& position, + const FaceAttribute& face_normal, + const VertexAttribute& scalar, + const FaceAttribute& face_area, + FaceAttribute& face_gradient); + +template PFP2::VEC3 Algo::Surface::Geometry::faceGradient( + PFP2::MAP& map, + Dart d, + const VertexAttribute& position, + const FaceAttribute& face_normal, + const VertexAttribute& scalar, + const FaceAttribute& face_area); + +template void Algo::Surface::Geometry::computeVertexGradient( + PFP2::MAP& map, + const FaceAttribute& face_gradient, + const FaceAttribute& face_area, + VertexAttribute& vertex_gradient); + +template PFP2::VEC3 Algo::Surface::Geometry::vertexGradient( + PFP2::MAP& map, + Dart d, + const FaceAttribute& face_gradient, + const FaceAttribute& area); + + +template void Algo::Surface::Geometry::computeTriangleType( + PFP2::MAP& map, + const VertexAttribute& K, + CellMarker& regularMarker); + +template bool Algo::Surface::Geometry::isTriangleRegular( + PFP2::MAP& map, + Dart d, + const VertexAttribute& K); + +template void Algo::Surface::Geometry::initRidgeSegments( + PFP2::MAP& map, + FaceAttribute, PFP2::MAP>& ridge_segments); + +template void Algo::Surface::Geometry::computeRidgeLines( + PFP2::MAP& map, + CellMarker& regularMarker, + const VertexAttribute& position, + const VertexAttribute& K, + const VertexAttribute& vertex_gradient, + const VertexAttribute& k, + const VertexAttribute& k2, + FaceAttribute, PFP2::MAP>& ridge_segments); + +template void Algo::Surface::Geometry::ridgeLines( + PFP2::MAP& map, + Dart d, + const VertexAttribute& position, + const VertexAttribute& K, + const VertexAttribute& vertex_gradient, + const VertexAttribute& k, + const VertexAttribute& k2, + FaceAttribute, PFP2::MAP>& ridge_segments); + +template void Algo::Surface::Geometry::computeSingularTriangle( + PFP2::MAP& map, + CellMarker& regularMarker, + FaceAttribute, PFP2::MAP>& ridge_segments); + +template void Algo::Surface::Geometry::singularTriangle( + PFP2::MAP& map, + Dart d, + CellMarker& regularMarker, + FaceAttribute, PFP2::MAP>& ridge_segments); + +template bool Algo::Surface::Geometry::isEdgeInTriangle( + PFP2::MAP& map, + Dart edge, + Dart triangle); + +template std::vector Algo::Surface::Geometry::occludingContoursDetection( + PFP2::MAP& map, + const PFP2::VEC3& cameraPosition, + const VertexAttribute& position, + const VertexAttribute& normal); + + +int test_feature() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/inclusion.cpp b/Apps/Tests/Algo/Geometry/inclusion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b4fa318271ab46a19a477195f59986f748b20cc5 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/inclusion.cpp @@ -0,0 +1,66 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/inclusion.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template bool Algo::Surface::Geometry::isConvex(PFP1::MAP& map, Vol v, const VertexAttribute& positions, bool CCW); +template bool Algo::Surface::Geometry::isPointInVolume(PFP1::MAP& map, Vol v, const VertexAttribute& positions, const PFP1::VEC3& point); +template bool Algo::Surface::Geometry::isPointInConvexVolume(PFP1::MAP& map, Vol v, const VertexAttribute& positions, const PFP1::VEC3& point, bool CCW); +template bool Algo::Surface::Geometry::isPointInConvexFace(PFP1::MAP& map, Face f, const VertexAttribute& positions, const PFP1::VEC3& point, bool CCW); +template bool Algo::Surface::Geometry::isPointInConvexFace2D(PFP1::MAP& map, Face f, const VertexAttribute& positions, const PFP1::VEC3& point, bool CCW); +template bool Algo::Surface::Geometry::isPointOnEdge(PFP1::MAP& map, Edge e, const VertexAttribute& positions, const PFP1::VEC3& point); +template bool Algo::Surface::Geometry::isPointOnHalfEdge(PFP1::MAP& map, Dart d, const VertexAttribute& positions, const PFP1::VEC3& point); +template bool Algo::Surface::Geometry::isPointOnVertex(PFP1::MAP& map, Vertex v, const VertexAttribute& positions, const PFP1::VEC3& point); +template bool Algo::Surface::Geometry::isConvexFaceInOrIntersectingTetrahedron(PFP1::MAP& map, Face f, const VertexAttribute& positions, const PFP1::VEC3 points[4], bool CCW); + +// Double + +template bool Algo::Surface::Geometry::isConvex(PFP2::MAP& map, Vol v, const VertexAttribute& positions, bool CCW); +template bool Algo::Surface::Geometry::isPointInVolume(PFP2::MAP& map, Vol v, const VertexAttribute& positions, const PFP2::VEC3& point); +template bool Algo::Surface::Geometry::isPointInConvexVolume(PFP2::MAP& map, Vol v, const VertexAttribute& positions, const PFP2::VEC3& point, bool CCW ); +template bool Algo::Surface::Geometry::isPointInConvexFace(PFP2::MAP& map, Face f, const VertexAttribute& positions, const PFP2::VEC3& point, bool CCW); +template bool Algo::Surface::Geometry::isPointInConvexFace2D(PFP2::MAP& map, Face f, const VertexAttribute& positions, const PFP2::VEC3& point, bool CCW ); +template bool Algo::Surface::Geometry::isPointOnEdge(PFP2::MAP& map, Edge e, const VertexAttribute& positions, const PFP2::VEC3& point); +template bool Algo::Surface::Geometry::isPointOnHalfEdge(PFP2::MAP& map, Dart d, const VertexAttribute& positions, const PFP2::VEC3& point); +template bool Algo::Surface::Geometry::isPointOnVertex(PFP2::MAP& map, Vertex v, const VertexAttribute& positions, const PFP2::VEC3& point); +template bool Algo::Surface::Geometry::isConvexFaceInOrIntersectingTetrahedron(PFP2::MAP& map, Face f, const VertexAttribute& positions, const PFP2::VEC3 points[4], bool CCW); + + +//GMAP + +template bool Algo::Surface::Geometry::isConvex(PFP3::MAP& map, Vol v, const VertexAttribute& positions, bool CCW); +template bool Algo::Surface::Geometry::isPointInVolume(PFP3::MAP& map, Vol v, const VertexAttribute& positions, const PFP3::VEC3& point); +template bool Algo::Surface::Geometry::isPointInConvexVolume(PFP3::MAP& map, Vol v, const VertexAttribute& positions, const PFP3::VEC3& point, bool CCW ); +template bool Algo::Surface::Geometry::isPointInConvexFace(PFP3::MAP& map, Face f, const VertexAttribute& positions, const PFP3::VEC3& point, bool CCW); +template bool Algo::Surface::Geometry::isPointInConvexFace2D(PFP3::MAP& map, Face f, const VertexAttribute& positions, const PFP3::VEC3& point, bool CCW ); +template bool Algo::Surface::Geometry::isPointOnEdge(PFP3::MAP& map, Edge e, const VertexAttribute& positions, const PFP3::VEC3& point); +template bool Algo::Surface::Geometry::isPointOnHalfEdge(PFP3::MAP& map, Dart d, const VertexAttribute& positions, const PFP3::VEC3& point); +template bool Algo::Surface::Geometry::isPointOnVertex(PFP3::MAP& map, Vertex v, const VertexAttribute& positions, const PFP3::VEC3& point); +template bool Algo::Surface::Geometry::isConvexFaceInOrIntersectingTetrahedron(PFP3::MAP& map, Face f, const VertexAttribute& positions, const PFP3::VEC3 points[4], bool CCW); + + +int test_inclusion() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Geometry/intersection.cpp b/Apps/Tests/Algo/Geometry/intersection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..37a99106d82047e54c65a9f38eaaedfbb38de585 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/intersection.cpp @@ -0,0 +1,50 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/intersection.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +template bool Algo::Surface::Geometry::intersectionLineConvexFace(PFP1::MAP& map, Face f, const VertexAttribute& position, const PFP1::VEC3& P, const PFP1::VEC3& Dir, PFP1::VEC3& Inter); +template bool Algo::Surface::Geometry::intersectionSegmentConvexFace(PFP1::MAP& map, Face f, const VertexAttribute& position, const PFP1::VEC3& PA, const PFP1::VEC3& PB, PFP1::VEC3& Inter); +template bool Algo::Surface::Geometry::areTrianglesInIntersection(PFP1::MAP& map, Face t1, Face t2, const VertexAttribute& position); +template bool Algo::Surface::Geometry::intersectionSphereEdge(PFP1::MAP& map, const PFP1::VEC3& center, PFP1::REAL radius, Edge e, const VertexAttribute& position, PFP1::REAL& alpha); + +// double + +template bool Algo::Surface::Geometry::intersectionLineConvexFace(PFP2::MAP& map, Face f, const VertexAttribute& position, const PFP2::VEC3& P, const PFP2::VEC3& Dir, PFP2::VEC3& Inter); +template bool Algo::Surface::Geometry::intersectionSegmentConvexFace(PFP2::MAP& map, Face f, const VertexAttribute& position, const PFP2::VEC3& PA, const PFP2::VEC3& PB, PFP2::VEC3& Inter); +template bool Algo::Surface::Geometry::areTrianglesInIntersection(PFP2::MAP& map, Face t1, Face t2, const VertexAttribute& position); +template bool Algo::Surface::Geometry::intersectionSphereEdge(PFP2::MAP& map, const PFP2::VEC3& center, PFP2::REAL radius, Edge e, const VertexAttribute& position, PFP2::REAL& alpha); + +// GMap + +template bool Algo::Surface::Geometry::intersectionLineConvexFace(PFP3::MAP& map, Face f, const VertexAttribute& position, const PFP3::VEC3& P, const PFP3::VEC3& Dir, PFP3::VEC3& Inter); +template bool Algo::Surface::Geometry::intersectionSegmentConvexFace(PFP3::MAP& map, Face f, const VertexAttribute& position, const PFP3::VEC3& PA, const PFP3::VEC3& PB, PFP3::VEC3& Inter); +template bool Algo::Surface::Geometry::areTrianglesInIntersection(PFP3::MAP& map, Face t1, Face t2, const VertexAttribute& position); +template bool Algo::Surface::Geometry::intersectionSphereEdge(PFP3::MAP& map, const PFP3::VEC3& center, PFP3::REAL radius, Edge e, const VertexAttribute& position, PFP3::REAL& alpha); + + + +int test_intersection() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Geometry/laplacian.cpp b/Apps/Tests/Algo/Geometry/laplacian.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b1f7f1ac711b0acd4f22474b7b7dd7217889e8a1 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/laplacian.cpp @@ -0,0 +1,70 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" + +#include "Algo/Geometry/laplacian.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; +typedef float ATTR; + +template ATTR Algo::Surface::Geometry::computeLaplacianTopoVertex ( + PFP1::MAP& map, + Dart d, + const VertexAttribute& attr) ; + +template ATTR Algo::Surface::Geometry::computeLaplacianCotanVertex( + PFP1::MAP& map, + Dart d, + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr) ; + +template void Algo::Surface::Geometry::computeLaplacianTopoVertices( + PFP1::MAP& map, + const VertexAttribute& attr, + VertexAttribute& laplacian) ; + +template void Algo::Surface::Geometry::computeLaplacianCotanVertices( + PFP1::MAP& map, + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr, + VertexAttribute& laplacian) ; + +template PFP1::REAL Algo::Surface::Geometry::computeCotanWeightEdge( + PFP1::MAP& map, + Dart d, + const VertexAttribute& position) ; + +template void Algo::Surface::Geometry::computeCotanWeightEdges( + PFP1::MAP& map, + const VertexAttribute& position, + EdgeAttribute& edgeWeight) ; + + +struct PFP3: public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +template ATTR Algo::Volume::Geometry::computeLaplacianTopoVertex( + PFP3::MAP& map, + Dart d, + const VertexAttribute& attr) ; + +template void Algo::Volume::Geometry::computeLaplacianTopoVertices( + PFP3::MAP& map, + const VertexAttribute& attr, + VertexAttribute& laplacian) ; + + +int test_laplacian() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Geometry/localFrame.cpp b/Apps/Tests/Algo/Geometry/localFrame.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e69108657e1fa27c56153b004ea43bdafd5f4db5 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/localFrame.cpp @@ -0,0 +1,49 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/localFrame.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + + +template void Algo::Geometry::vertexLocalFrame(PFP1::MAP& map, Dart d, const VertexAttribute& position, PFP1::VEC3& X, PFP1::VEC3& Y, PFP1::VEC3& Z); +template PFP1::MATRIX33 Algo::Geometry::vertexLocalFrame(PFP1::MAP& map, Dart d, const VertexAttribute& position); +template void Algo::Geometry::vertexLocalFrame(PFP1::MAP& map, Dart d, const VertexAttribute& position, PFP1::VEC3& normal, PFP1::VEC3& X, PFP1::VEC3& Y, PFP1::VEC3& Z); +template PFP1::MATRIX33 Algo::Geometry::vertexLocalFrame(PFP1::MAP& map, Dart d, const VertexAttribute& position, PFP1::VEC3& normal); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + + +template void Algo::Geometry::vertexLocalFrame(PFP2::MAP& map, Dart d, const VertexAttribute& position, PFP2::VEC3& X, PFP2::VEC3& Y, PFP2::VEC3& Z); +template PFP2::MATRIX33 Algo::Geometry::vertexLocalFrame(PFP2::MAP& map, Dart d, const VertexAttribute& position); +template void Algo::Geometry::vertexLocalFrame(PFP2::MAP& map, Dart d, const VertexAttribute& position, PFP2::VEC3& normal, PFP2::VEC3& X, PFP2::VEC3& Y, PFP2::VEC3& Z); +template PFP2::MATRIX33 Algo::Geometry::vertexLocalFrame(PFP2::MAP& map, Dart d, const VertexAttribute& position, PFP2::VEC3& normal); + + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + + +template void Algo::Geometry::vertexLocalFrame(PFP3::MAP& map, Dart d, const VertexAttribute& position, PFP3::VEC3& X, PFP3::VEC3& Y, PFP3::VEC3& Z); +template PFP3::MATRIX33 Algo::Geometry::vertexLocalFrame(PFP3::MAP& map, Dart d, const VertexAttribute& position); +template void Algo::Geometry::vertexLocalFrame(PFP3::MAP& map, Dart d, const VertexAttribute& position, PFP3::VEC3& normal, PFP3::VEC3& X, PFP3::VEC3& Y, PFP3::VEC3& Z); +template PFP3::MATRIX33 Algo::Geometry::vertexLocalFrame(PFP3::MAP& map, Dart d, const VertexAttribute& position, PFP3::VEC3& normal); + + +int test_localFrame() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Geometry/normal.cpp b/Apps/Tests/Algo/Geometry/normal.cpp new file mode 100644 index 0000000000000000000000000000000000000000..084ad36402cc8606d507e97532e15f014d7890d0 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/normal.cpp @@ -0,0 +1,89 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap3.h" + +#include "Algo/Geometry/normal.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +typedef VertexAttribute VATT1; +typedef FaceAttribute FATT1; +typedef EdgeAttribute EATT1; + +template VATT1::DATA_TYPE Algo::Surface::Geometry::triangleNormal(PFP1::MAP& map, Face f, const VATT1& position); +template VATT1::DATA_TYPE Algo::Surface::Geometry::newellNormal(PFP1::MAP& map, Face f, const VATT1& position); +template VATT1::DATA_TYPE Algo::Surface::Geometry::faceNormal(PFP1::MAP& map, Face f, const VATT1& position); +template VATT1::DATA_TYPE Algo::Surface::Geometry::vertexNormal(PFP1::MAP& map, Vertex v, const VATT1& position); +template void Algo::Surface::Geometry::computeNormalFaces(PFP1::MAP& map, const VATT1& position, FATT1& face_normal); +template void Algo::Surface::Geometry::computeNormalVertices(PFP1::MAP& map, const VATT1& position, VATT1& normal); +template PFP1::REAL Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge(PFP1::MAP& map, Edge d, const VATT1& position); +template void Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges(PFP1::MAP& map, const VATT1& position, EATT1& angles); + + +struct PFP11 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +typedef VertexAttribute VATT11; +typedef FaceAttribute FATT11; +typedef EdgeAttribute EATT11; + + +template VATT11::DATA_TYPE Algo::Surface::Geometry::vertexBorderNormal(PFP11::MAP& map, Vertex v, const VATT11& position); + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +typedef VertexAttribute VATT2; +typedef FaceAttribute FATT2; +typedef EdgeAttribute EATT2; + +template VATT2::DATA_TYPE Algo::Surface::Geometry::triangleNormal(PFP2::MAP& map, Face f, const VATT2& position); +template VATT2::DATA_TYPE Algo::Surface::Geometry::newellNormal(PFP2::MAP& map, Face f, const VATT2& position); +template VATT2::DATA_TYPE Algo::Surface::Geometry::faceNormal(PFP2::MAP& map, Face f, const VATT2& position); +template VATT2::DATA_TYPE Algo::Surface::Geometry::vertexNormal(PFP2::MAP& map, Vertex v, const VATT2& position); +//TODO VOLUME INSTANTIATION +// template VATT2::DATA_TYPE Algo::Surface::Geometry::vertexBorderNormal(PFP2::MAP& map, Vertex v, const VATT2& position); +template void Algo::Surface::Geometry::computeNormalFaces(PFP2::MAP& map, const VATT2& position, FATT2& face_normal); +template void Algo::Surface::Geometry::computeNormalVertices(PFP2::MAP& map, const VATT2& position, VATT2& normal); +template PFP2::REAL Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge(PFP2::MAP& map, Edge d, const VATT2& position); +template void Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges(PFP2::MAP& map, const VATT2& position, EATT2& angles); + + + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; +typedef VertexAttribute VATT3; +typedef FaceAttribute FATT3; +typedef EdgeAttribute EATT3; + +template VATT3::DATA_TYPE Algo::Surface::Geometry::triangleNormal(PFP3::MAP& map, Face f, const VATT3& position); +template VATT3::DATA_TYPE Algo::Surface::Geometry::newellNormal(PFP3::MAP& map, Face f, const VATT3& position); +template VATT3::DATA_TYPE Algo::Surface::Geometry::faceNormal(PFP3::MAP& map, Face f, const VATT3& position); +template VATT3::DATA_TYPE Algo::Surface::Geometry::vertexNormal(PFP3::MAP& map, Vertex v, const VATT3& position); +//TODO VOLUME INSTANTIATION +// template VATT3::DATA_TYPE Algo::Surface::Geometry::vertexBorderNormal(PFP3::MAP& map, Vertex v, const VATT3& position); +template void Algo::Surface::Geometry::computeNormalFaces(PFP3::MAP& map, const VATT3& position, FATT3& face_normal); +template void Algo::Surface::Geometry::computeNormalVertices(PFP3::MAP& map, const VATT3& position, VATT3& normal); +template PFP3::REAL Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge(PFP3::MAP& map, Edge d, const VATT3& position); +template void Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges(PFP3::MAP& map, const VATT3& position, EATT3& angles); + + + +int test_normal() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Geometry/normalization.cpp b/Apps/Tests/Algo/Geometry/normalization.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2122247a7c729185a6e9a433fb77c58145ebc6ee --- /dev/null +++ b/Apps/Tests/Algo/Geometry/normalization.cpp @@ -0,0 +1,31 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/normalization.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +//PFP1::REAL Algo::Geometry::normalizeLength(PFP1::MAP& map, AttributeHandler& m_attr, PFP1::REAL scale); +//PFP1::REAL Algo::Geometry::normalizeLength(PFP1::MAP & map, AttributeHandler & m_attr, PFP1::REAL scale); +//PFP1::REAL Algo::Geometry::normalizeLength(PFP1::MAP & map, AttributeHandler & m_attr, PFP1::REAL scale); + +//struct PFP2 : public PFP_STANDARD +//{ +// typedef EmbeddedMap2 MAP; +//}; +// +//PFP2::REAL Algo::Geometry::normalizeLength(PFP2::MAP & map, AttributeHandler & m_attr, const PFP2::REAL scale); +//PFP2::REAL Algo::Geometry::normalizeLength(PFP2::MAP & map, AttributeHandler & m_attr, const PFP2::REAL scale); +//PFP2::REAL Algo::Geometry::normalizeLength(PFP2::MAP & map, AttributeHandler & m_attr, const PFP2::REAL scale); + +int test_normalization() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/orientation.cpp b/Apps/Tests/Algo/Geometry/orientation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4109b0999deae5818fe953471470ac85c6c7d7cd --- /dev/null +++ b/Apps/Tests/Algo/Geometry/orientation.cpp @@ -0,0 +1,29 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/orientation.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::Geometry::isTetrahedronWellOriented(PFP1::MAP& map, Dart d, const VertexAttribute& positions, bool CCW); + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template bool Algo::Surface::Geometry::isTetrahedronWellOriented(PFP2::MAP& map, Dart d, const VertexAttribute& positions, bool CCW); + + +int test_orientation() +{ + return 0; +} + diff --git a/Apps/Tests/Algo/Geometry/plane.cpp b/Apps/Tests/Algo/Geometry/plane.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ea474a1f07655e16bb0cf71e425a15054f697530 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/plane.cpp @@ -0,0 +1,43 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/plane.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + + +template Geom::Plane3D Algo::Surface::Geometry::trianglePlane(PFP1::MAP& map, Face f, const VertexAttribute& position); +template Geom::Plane3D Algo::Surface::Geometry::facePlane(PFP1::MAP& map, Face f, const VertexAttribute& position); +template Geom::Plane3D Algo::Surface::Geometry::vertexTangentPlane(PFP1::MAP& map, Vertex v, const VertexAttribute& position); + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template Geom::Plane3D Algo::Surface::Geometry::trianglePlane(PFP2::MAP& map, Face f, const VertexAttribute& position); +template Geom::Plane3D Algo::Surface::Geometry::facePlane(PFP2::MAP& map, Face f, const VertexAttribute& position); +template Geom::Plane3D Algo::Surface::Geometry::vertexTangentPlane(PFP2::MAP& map, Vertex v, const VertexAttribute& position); + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template Geom::Plane3D Algo::Surface::Geometry::trianglePlane(PFP3::MAP& map, Face f, const VertexAttribute& position); +template Geom::Plane3D Algo::Surface::Geometry::facePlane(PFP3::MAP& map, Face f, const VertexAttribute& position); +template Geom::Plane3D Algo::Surface::Geometry::vertexTangentPlane(PFP3::MAP& map, Vertex v, const VertexAttribute& position); + + + +int test_plane() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Geometry/stats.cpp b/Apps/Tests/Algo/Geometry/stats.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5282754590583ee859b8a023266b5a79a949516f --- /dev/null +++ b/Apps/Tests/Algo/Geometry/stats.cpp @@ -0,0 +1,9 @@ + +//template +//void statModele(typename PFP::MAP& map, const VertexAttribute& position) + +int test_stats() +{ + return 0; +} + diff --git a/Apps/Tests/Algo/Geometry/volume.cpp b/Apps/Tests/Algo/Geometry/volume.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82a75dade0b902a46c994190c10e338435307a02 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/volume.cpp @@ -0,0 +1,47 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/volume.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template PFP1::REAL Algo::Geometry::tetrahedronSignedVolume(PFP1::MAP& map, Vol v, const VertexAttribute& position); +template PFP1::REAL Algo::Geometry::tetrahedronVolume(PFP1::MAP& map, Vol v, const VertexAttribute& position); +template PFP1::REAL Algo::Geometry::convexPolyhedronVolume(PFP1::MAP& map, Vol v, const VertexAttribute& position); +template PFP1::REAL Algo::Geometry::totalVolume(PFP1::MAP& map, const VertexAttribute& position); + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template PFP2::REAL Algo::Geometry::tetrahedronSignedVolume(PFP2::MAP& map, Vol v, const VertexAttribute& position); +template PFP2::REAL Algo::Geometry::tetrahedronVolume(PFP2::MAP& map, Vol v, const VertexAttribute& position); +template PFP2::REAL Algo::Geometry::convexPolyhedronVolume(PFP2::MAP& map, Vol v, const VertexAttribute& position); +template PFP2::REAL Algo::Geometry::totalVolume(PFP2::MAP& map, const VertexAttribute& position); + + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + +template PFP3::REAL Algo::Geometry::tetrahedronSignedVolume(PFP3::MAP& map, Vol v, const VertexAttribute& position); +template PFP3::REAL Algo::Geometry::tetrahedronVolume(PFP3::MAP& map, Vol v, const VertexAttribute& position); +template PFP3::REAL Algo::Geometry::convexPolyhedronVolume(PFP3::MAP& map, Vol v, const VertexAttribute& position); +template PFP3::REAL Algo::Geometry::totalVolume(PFP3::MAP& map, const VertexAttribute& position); + + + +int test_volume() +{ + return 0; +} + diff --git a/Apps/Tests/Algo/Geometry/voronoiDiagrams.cpp b/Apps/Tests/Algo/Geometry/voronoiDiagrams.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4329ff854cc64232e55533cb81db558764cbbb18 --- /dev/null +++ b/Apps/Tests/Algo/Geometry/voronoiDiagrams.cpp @@ -0,0 +1,40 @@ +#include +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Geometry/voronoiDiagrams.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::Geometry::VoronoiDiagram; +template class Algo::Surface::Geometry::CentroidalVoronoiDiagram; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::Geometry::VoronoiDiagram; +template class Algo::Surface::Geometry::CentroidalVoronoiDiagram; + + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; + +template class Algo::Surface::Geometry::VoronoiDiagram; +template class Algo::Surface::Geometry::CentroidalVoronoiDiagram; + + +int test_voronoiDiagrams() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Histogram/CMakeLists.txt b/Apps/Tests/Algo/Histogram/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..05f52cbae48b1988284d045338988044bd85b0c1 --- /dev/null +++ b/Apps/Tests/Algo/Histogram/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_histogram) + +add_executable( test_algo_histogram +algo_histogram.cpp +histogram.cpp +) + +target_link_libraries( test_algo_histogram + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + + diff --git a/Apps/Tests/Algo/Histogram/algo_histogram.cpp b/Apps/Tests/Algo/Histogram/algo_histogram.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e8be812e5db499fab0a9465f3eb31b91b88c43f --- /dev/null +++ b/Apps/Tests/Algo/Histogram/algo_histogram.cpp @@ -0,0 +1,10 @@ +#include + +extern int test_histogram(); + +int main() +{ + test_histogram(); + + return 0; +} diff --git a/Apps/Tests/Algo/Histogram/histogram.cpp b/Apps/Tests/Algo/Histogram/histogram.cpp new file mode 100644 index 0000000000000000000000000000000000000000..13a531ca2870e564a4bd227d66d271575d5549cd --- /dev/null +++ b/Apps/Tests/Algo/Histogram/histogram.cpp @@ -0,0 +1,31 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Histogram/histogram.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; +typedef VertexAttribute VA1; +typedef VertexAttribute VAC1; +typedef CellMarker CM1; + +template void Algo::Histogram::Histogram::initData(const VA1& attr); +template void Algo::Histogram::Histogram::histoColorize(VAC1& colors); +template void Algo::Histogram::Histogram::quantilesColorize(VAC1& colors, const std::vector& tc); +template unsigned int Algo::Histogram::Histogram::markCellsOfHistogramColumn(unsigned int c, CM1& cm) const; +template unsigned int Algo::Histogram::Histogram::markCellsOfQuantilesColumn(unsigned int c, CM1& cm) const; + + + + +int test_histogram() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm.hppxx b/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm.hppxx new file mode 100644 index 0000000000000000000000000000000000000000..bb866949e2230920e6bd84bc477180a4144c8a03 --- /dev/null +++ b/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm.hppxx @@ -0,0 +1,419 @@ +/******************************************************************************* +* 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 Surface +{ + +namespace IHM +{ + +/*************************************************** + * ATTRIBUTES MANAGEMENT * + ***************************************************/ + +template +AttributeHandler_IHM ImplicitHierarchicalMap::addAttribute(const std::string& nameAttr) +{ + bool addNextLevelCell = false ; + if(!isOrbitEmbedded()) + addNextLevelCell = true ; + + AttributeHandler h = Map2::addAttribute(nameAttr) ; + + if(addNextLevelCell) + { + AttributeContainer& cellCont = m_attribs[ORBIT] ; + AttributeMultiVector* amv = cellCont.addAttribute("nextLevelCell") ; + m_nextLevelCell[ORBIT] = amv ; + for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i)) + amv->operator[](i) = EMBNULL ; + } + + return AttributeHandler_IHM(this, h.getDataVector()) ; +} + +template +AttributeHandler_IHM ImplicitHierarchicalMap::getAttribute(const std::string& nameAttr) +{ + AttributeHandler h = Map2::getAttribute(nameAttr) ; + return AttributeHandler_IHM(this, h.getDataVector()) ; +} + +inline void ImplicitHierarchicalMap::update_topo_shortcuts() +{ + Map2::update_topo_shortcuts(); + m_dartLevel = Map2::getAttribute("dartLevel") ; + m_edgeId = Map2::getAttribute("edgeId") ; + + //AttributeContainer& cont = m_attribs[DART] ; + //m_nextLevelCell = cont.getDataVector(cont.getAttributeIndex("nextLevelCell")) ; +} + + +/*************************************************** + * MAP TRAVERSAL * + ***************************************************/ + +inline Dart ImplicitHierarchicalMap::newDart() +{ + Dart d = Map2::newDart() ; + m_dartLevel[d] = m_curLevel ; + if(m_curLevel > m_maxLevel) // update max level + m_maxLevel = m_curLevel ; // if needed + return d ; +} + +inline Dart ImplicitHierarchicalMap::phi1(Dart d) +{ + assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; + bool finished = false ; + unsigned int edgeId = m_edgeId[d] ; + Dart it = d ; + do + { + it = Map2::phi1(it) ; + if(m_dartLevel[it] <= m_curLevel) + finished = true ; + else + { + while(m_edgeId[it] != edgeId) + it = Map2::alpha_1(it) ; + } + } while(!finished) ; + return it ; +} + +inline Dart ImplicitHierarchicalMap::phi_1(Dart d) +{ + assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; + bool finished = false ; + Dart it = Map2::phi_1(d) ; + unsigned int edgeId = m_edgeId[it] ; + do + { + if(m_dartLevel[it] <= m_curLevel) + finished = true ; + else + { + it = Map2::phi_1(it) ; + while(m_edgeId[it] != edgeId) + it = Map2::phi_1(Map2::phi2(it)) ; + } + } while(!finished) ; + return it ; +} + +inline Dart ImplicitHierarchicalMap::phi2(Dart d) +{ + assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; + if(Map2::phi2(d) == d) + return d ; + return Map2::alpha1(phi1(d)) ; +} + +inline Dart ImplicitHierarchicalMap::alpha0(Dart d) +{ + return phi2(d) ; +} + +inline Dart ImplicitHierarchicalMap::alpha1(Dart d) +{ + return Map2::alpha1(d) ; +} + +inline Dart ImplicitHierarchicalMap::alpha_1(Dart d) +{ + return Map2::alpha_1(d) ; +} + +inline Dart ImplicitHierarchicalMap::begin() const +{ + Dart d = Map2::begin() ; + while(d != Map2::end() && m_dartLevel[d] > m_curLevel) + Map2::next(d) ; + return d ; +} + +inline Dart ImplicitHierarchicalMap::end() const +{ + return Map2::end() ; +} + +inline void ImplicitHierarchicalMap::next(Dart& d) const +{ + do + { + Map2::next(d) ; + } while(d != Map2::end() && m_dartLevel[d] > m_curLevel) ; +} + +inline bool ImplicitHierarchicalMap::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int /*thread*/) +{ + Dart dNext = d; + do + { + if (f(dNext)) + return true; + dNext = alpha1(dNext); + } while (dNext != d); + return false; +} + +inline bool ImplicitHierarchicalMap::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int /*thread*/) +{ + if (f(d)) + return true; + + Dart d2 = phi2(d); + if (d2 != d) + return f(d2); + else + return false; +} + +inline bool ImplicitHierarchicalMap::foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int /*thread*/) +{ + Dart dNext = d ; + do + { + if (f(dNext)) + return true ; + dNext = phi1(dNext) ; + } while (dNext != d) ; + return false ; +} + +inline bool ImplicitHierarchicalMap::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread) +{ + return foreach_dart_of_oriented_face(d, f,thread) ; +} + +inline bool ImplicitHierarchicalMap::foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread) +{ + DartMarkerStore mark(*this,thread); // Lock a marker + bool found = false; // Last functor return value + + std::list visitedFaces; // Faces that are traversed + visitedFaces.push_back(d); // Start with the face of d + std::list::iterator face; + + // For every face added to the list + for (face = visitedFaces.begin(); !found && face != visitedFaces.end(); ++face) + { + if (!mark.isMarked(*face)) // Face has not been visited yet + { + // Apply functor to the darts of the face + found = foreach_dart_of_oriented_face(*face, f); + + // If functor returns false then mark visited darts (current face) + // and add non visited adjacent faces to the list of face + if (!found) + { + Dart dNext = *face ; + do + { + mark.mark(dNext); // Mark + Dart adj = phi2(dNext); // Get adjacent face + if (adj != dNext && !mark.isMarked(adj)) + visitedFaces.push_back(adj); // Add it + dNext = phi1(dNext); + } while(dNext != *face); + } + } + } + return found; +} + +inline bool ImplicitHierarchicalMap::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread) +{ + return foreach_dart_of_oriented_volume(d, f, thread) ; +} + +inline bool ImplicitHierarchicalMap::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread) +{ + return foreach_dart_of_oriented_volume(d, f, thread) ; +} + +/*************************************************** + * MAP MANIPULATION * + ***************************************************/ + +inline void ImplicitHierarchicalMap::splitFace(Dart d, Dart e) +{ + EmbeddedMap2::splitFace(d, e) ; + if(isOrbitEmbedded()) + { + unsigned int cur = m_curLevel ; + m_curLevel = m_maxLevel ; + this->setOrbitEmbedding(d, this->getEmbedding(d)) ; + this->setOrbitEmbedding(e, this->getEmbedding(e)) ; + m_curLevel = cur ; + } +} + +/*************************************************** + * LEVELS MANAGEMENT * + ***************************************************/ + +inline unsigned int ImplicitHierarchicalMap::getCurrentLevel() +{ + return m_curLevel ; +} + +inline void ImplicitHierarchicalMap::setCurrentLevel(unsigned int l) +{ + m_curLevel = l ; +} + +inline unsigned int ImplicitHierarchicalMap::getMaxLevel() +{ + return m_maxLevel ; +} + +inline unsigned int ImplicitHierarchicalMap::getDartLevel(Dart d) +{ + return m_dartLevel[d] ; +} + +inline void ImplicitHierarchicalMap::setDartLevel(Dart d, unsigned int l) +{ + m_dartLevel[d] = l ; +} + +/*************************************************** + * EDGE ID MANAGEMENT * + ***************************************************/ + +inline unsigned int ImplicitHierarchicalMap::getNewEdgeId() +{ + return m_idCount++ ; +} + +inline unsigned int ImplicitHierarchicalMap::getEdgeId(Dart d) +{ + return m_edgeId[d] ; +} + +inline void ImplicitHierarchicalMap::setEdgeId(Dart d, unsigned int i) +{ + m_edgeId[d] = i ; +} + +inline unsigned int ImplicitHierarchicalMap::getMaxEdgeId() +{ + return m_idCount; +} + +/*************************************************** + * CELLS INFORMATION * + ***************************************************/ + +inline unsigned int ImplicitHierarchicalMap::vertexInsertionLevel(Dart d) +{ + assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; + return m_dartLevel[d] ; +} + +inline unsigned int ImplicitHierarchicalMap::edgeLevel(Dart d) +{ + assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; + unsigned int ld = m_dartLevel[d] ; +// unsigned int ldd = m_dartLevel[phi2(d)] ; // the level of an edge is the maximum of the + unsigned int ldd = m_dartLevel[phi1(d)] ; + return ld < ldd ? ldd : ld ; // insertion levels of its two darts +} + +/*************************************************** + * ATTRIBUTE HANDLER * + ***************************************************/ + +template +T& AttributeHandler_IHM::operator[](Dart d) +{ + ImplicitHierarchicalMap* m = reinterpret_cast(this->m_map) ; + assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ; + assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ; + + unsigned int orbit = this->getOrbit() ; + unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; + unsigned int index = m->getEmbedding(d) ; + + if(index == EMBNULL) + { + index = m->setOrbitEmbeddingOnNewCell(d) ; + m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ; + } + + AttributeContainer& cont = m->getAttributeContainer() ; + unsigned int step = 0 ; + while(step < nbSteps) + { + step++ ; + unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ; + if (nextIdx == EMBNULL) + { + nextIdx = m->newCell() ; + m->copyCell(nextIdx, index) ; + m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ; + m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ; + cont.refLine(index) ; + } + index = nextIdx ; + } + return this->m_attrib->operator[](index); +} + +template +const T& AttributeHandler_IHM::operator[](Dart d) const +{ + ImplicitHierarchicalMap* m = reinterpret_cast(this->m_map) ; + assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ; + assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ; + + unsigned int orbit = this->getOrbit() ; + unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; + unsigned int index = m->getEmbedding(d) ; + + unsigned int step = 0 ; + while(step < nbSteps) + { + step++ ; + unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ; + if(next != EMBNULL) index = next ; + else break ; + } + return this->m_attrib->operator[](index); +} + +} //namespace IHM +} // Surface +} //namespace Algo + +} //namespace CGoGN diff --git a/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm.hxx b/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm.hxx new file mode 100644 index 0000000000000000000000000000000000000000..a00e077e6f792b85177190103df5305590c9ad65 --- /dev/null +++ b/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm.hxx @@ -0,0 +1,275 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __IMPLICIT_HIERARCHICAL_MAP__ +#define __IMPLICIT_HIERARCHICAL_MAP__ + +#include "Topology/map/embeddedMap2.h" + +namespace CGoGN +{ + +namespace Algo +{ +namespace Surface +{ +namespace IHM +{ + +template class AttributeHandler_IHM ; + +class ImplicitHierarchicalMap : public EmbeddedMap2 +{ + template friend class AttributeHandler_IHM ; + +private: + unsigned int m_curLevel ; + unsigned int m_maxLevel ; + unsigned int m_idCount ; + + DartAttribute m_dartLevel ; + DartAttribute m_edgeId ; + + AttributeMultiVector* m_nextLevelCell[NB_ORBITS] ; + +public: + ImplicitHierarchicalMap() ; + + ~ImplicitHierarchicalMap() ; + + static const unsigned int DIMENSION = 2 ; + + //! + /*! + * + */ + void update_topo_shortcuts(); + + + void initImplicitProperties() ; + + /** + * clear the map + * @param remove attrib remove attribute (not only clear the content) + */ + void clear(bool removeAttrib); + + + /*************************************************** + * ATTRIBUTES MANAGEMENT * + ***************************************************/ + + template + AttributeHandler_IHM addAttribute(const std::string& nameAttr) ; + + template + AttributeHandler_IHM getAttribute(const std::string& nameAttr) ; + + /*************************************************** + * MAP TRAVERSAL * + ***************************************************/ + + virtual Dart newDart() ; + + Dart phi1(Dart d) ; + + Dart phi_1(Dart d) ; + + Dart phi2(Dart d) ; + + Dart alpha0(Dart d) ; + + Dart alpha1(Dart d) ; + + Dart alpha_1(Dart d) ; + + virtual Dart begin() const ; + + virtual Dart end() const ; + + virtual void next(Dart& d) const ; + + virtual bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0) ; + + virtual bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0) ; + + virtual bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread = 0) ; + virtual bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0) ; + + virtual bool foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread = 0) ; + virtual bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0) ; + + virtual bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0) ; + + /*************************************************** + * MAP MANIPULATION * + ***************************************************/ + + void splitFace(Dart d, Dart e) ; + + /*************************************************** + * LEVELS MANAGEMENT * + ***************************************************/ + + unsigned int getCurrentLevel() ; + + void setCurrentLevel(unsigned int l) ; + + unsigned int getMaxLevel() ; + + unsigned int getDartLevel(Dart d) ; + + void setDartLevel(Dart d, unsigned int i) ; + + + /*************************************************** + * EDGE ID MANAGEMENT * + ***************************************************/ + + /** + * Give a new unique id to all the edges of the map + */ + void initEdgeId() ; + + /** + * Return the next available edge id + */ + unsigned int getNewEdgeId() ; + + unsigned int getEdgeId(Dart d) ; + + void setEdgeId(Dart d, unsigned int i) ; + + unsigned int getMaxEdgeId(); + + /*************************************************** + * CELLS INFORMATION * + ***************************************************/ + + /** + * Return the level of insertion of the vertex of d + */ + unsigned int vertexInsertionLevel(Dart d) ; + + /** + * Return the level of the edge of d in the current level map + */ + unsigned int edgeLevel(Dart d) ; + + /** + * Return the level of the face of d in the current level map + */ + unsigned int faceLevel(Dart d) ; + + /** + * Given the face of d in the current level map, + * return a level 0 dart of its origin face + */ + Dart faceOrigin(Dart d) ; + + /** + * Return the oldest dart of the face of d in the current level map + */ + Dart faceOldestDart(Dart d) ; + + //! Test if dart d and e belong to the same face + /*! @param d a dart + * @param e a dart + */ + bool sameFace(Dart d, Dart e) ; + + /** + * Return true if the edge of d in the current level map + * has already been subdivided to the next level + */ + bool edgeIsSubdivided(Dart d) ; + + /** + * Return true if the edge of d in the current level map + * is subdivided to the next level, + * none of its resulting edges is in turn subdivided to the next level + * and the middle vertex is of degree 2 + */ + bool edgeCanBeCoarsened(Dart d) ; + + /** + * Return true if the face of d in the current level map + * has already been subdivided to the next level + */ + bool faceIsSubdivided(Dart d) ; + + /** + * Return true if the face of d in the current level map + * is subdivided to the next level + * and none of its resulting faces is in turn subdivided to the next level + */ + bool faceIsSubdividedOnce(Dart d) ; +} ; + +template +class AttributeHandler_IHM : public AttributeHandler +{ +public: + typedef T DATA_TYPE ; + + AttributeHandler_IHM() : AttributeHandler() + {} + + AttributeHandler_IHM(GenericMap* m, AttributeMultiVector* amv) : AttributeHandler(m, amv) + {} + + AttributeMultiVector* getDataVector() const + { + return AttributeHandler::getDataVector() ; + } + + bool isValid() const + { + return AttributeHandler::isValid() ; + } + + T& operator[](Dart d) ; + + const T& operator[](Dart d) const ; + + T& operator[](unsigned int a) + { + return AttributeHandler::operator[](a) ; + } + + const T& operator[](unsigned int a) const + { + return AttributeHandler::operator[](a) ; + } +} ; + +} //namespace IHM +} // Surface +} //namespace Algo + +} //namespace CGoGN + +#include "Algo/ImplicitHierarchicalMesh/ihm.hpp" + +#endif diff --git a/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm3.cpp b/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f28af39d366a49bd25fecdea9d19d7fdace2024b --- /dev/null +++ b/Apps/Tests/Algo/ImplicitHierarchicalMesh/ihm3.cpp @@ -0,0 +1,502 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __IMPLICIT_HIERARCHICAL_MAP3__ +#define __IMPLICIT_HIERARCHICAL_MAP3__ + +#include "Topology/map/embeddedMap3.h" +#include "Algo/Multiresolution/filter.h" + + + +#ifdef WIN32 +#ifndef CGoGN_ALGO_API +#if defined CGoGN_ALGO_DLL_EXPORT +#define CGoGN_ALGO_API __declspec(dllexport) +#else +#define CGoGN_ALGO_API __declspec(dllimport) +#endif +#endif +#else +#define CGoGN_ALGO_API +#endif + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace IHM +{ + +template class AttributeHandler_IHM ; + +CGoGN_ALGO_API class ImplicitHierarchicalMap3 : public EmbeddedMap3 +{ + template friend class AttributeHandler_IHM ; + +public: + FunctorType* vertexVertexFunctor ; + FunctorType* edgeVertexFunctor ; + FunctorType* faceVertexFunctor ; + FunctorType* volumeVertexFunctor ; + + unsigned int m_curLevel ; + unsigned int m_maxLevel ; + unsigned int m_edgeIdCount ; + unsigned int m_faceIdCount; + + DartAttribute m_dartLevel ; + DartAttribute m_edgeId ; + DartAttribute m_faceId ; + + AttributeMultiVector* m_nextLevelCell[NB_ORBITS] ; + +// std::vector synthesisFilters ; +// std::vector analysisFilters ; + +public: + ImplicitHierarchicalMap3() ; + + ~ImplicitHierarchicalMap3() ; + + static const unsigned int DIMENSION = 3 ; + + //! + /*! + * + */ + void update_topo_shortcuts(); + + //! + /*! + * + */ + void initImplicitProperties() ; + + /** + * clear the map + * @param remove attrib remove attribute (not only clear the content) + */ + void clear(bool removeAttrib); + + /*! @name Attributes Management + * To handles Attributes for each level of an implicit 3-map + *************************************************************************/ + + //@{ + //! + /*! + * + */ +// template +// AttributeHandler_IHM addAttribute(const std::string& nameAttr) ; + + //! + /*! + * + */ +// template +// AttributeHandler_IHM getAttribute(const std::string& nameAttr) ; + //@} + + /*! @name Basic Topological Operators + * Redefinition of the basic topological operators + *************************************************************************/ + + //@{ + virtual Dart newDart() ; + + Dart phi1(Dart d) const; + + Dart phi_1(Dart d) const; + + Dart phi2(Dart d) const; + +private: + Dart phi2bis(Dart d) const; + +public: + Dart phi3(Dart d) const; + + Dart alpha0(Dart d) const; + + Dart alpha1(Dart d) const; + + Dart alpha2(Dart d) const; + + Dart alpha_2(Dart d) const; + //@} + + /*! @name Topological Operators with Cells id management + * Topological operations on Hierarchical Implicit 3-maps + *************************************************************************/ + +// void deleteVolume(Dart d); + + bool isWellEmbedded(); + + //@{ + + //! + /*! + * + */ + void swapEdges(Dart d, Dart e); + + + + + +// void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } +// void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } + +// void clearSynthesisFilters() { synthesisFilters.clear() ; } +// void clearAnalysisFilters() { analysisFilters.clear() ; } + +// void analysis() ; +// void synthesis() ; + + //! + /*! + * + */ + void saveRelationsAroundVertex(Dart d, std::vector >& vd); + + void unsewAroundVertex(std::vector >& vd); + + Dart quadranguleFace(Dart d); + + void deleteVertexSubdividedFace(Dart d); + //@} + + void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; } + void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; } + void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } + void setVolumeVertexFunctor(FunctorType* f) { volumeVertexFunctor = f ; } + + void computeVertexVertexFunctor(Dart d) { (*vertexVertexFunctor)(d); } + void computeEdgeVertexFunctor(Dart d) { (*edgeVertexFunctor)(d); } + void computeFaceVertexFunctor(Dart d) { (*faceVertexFunctor)(d); } + void computerVolumeVertexFunctor(Dart d) { (*volumeVertexFunctor)(d); } + + /*! @name Levels Management + * Operations to manage the levels of an Implicit Hierarchical 3-map + *************************************************************************/ + + void incCurrentLevel(); + + void decCurrentLevel(); + + + //@{ + //! + /*! + * + */ + unsigned int getCurrentLevel() const ; + + //! + /*! + * + */ + void setCurrentLevel(unsigned int l) ; + + //! + /*! + * + */ + unsigned int getMaxLevel() const ; + + //! + /*! + * + */ + unsigned int getDartLevel(Dart d) const ; + + //! + /*! + * + */ + void setDartLevel(Dart d, unsigned int i) ; + //@} + + /*! @name Id Management + * Operations to manage the ids of edges and faces + *************************************************************************/ + + //@{ + //! Give a new unique id to all the edges of the map + /*! + */ + void initEdgeId() ; + + //! Return the next available edge id + /*! + */ + unsigned int getNewEdgeId() ; + + //! Return the id of the edge of d + /*! + */ + unsigned int getEdgeId(Dart d) ; + + //! Set an edge id to all darts from an orbit of d + /*! + */ + void setEdgeId(Dart d, unsigned int i, unsigned int orbit); //TODO a virer + void setEdgeId(Dart d, unsigned int i); + + //! Give a new unique id to all the faces of the map + /*! + */ + void initFaceId() ; + + //! Return the next available face id + /*! + */ + unsigned int getNewFaceId() ; + + //! Return the id of the face of d + /*! + */ + unsigned int getFaceId(Dart d) ; + + //! Set a face id to all darts from an orbit of d + /*! + */ + void setFaceId(Dart d, unsigned int i, unsigned int orbit); //TODO a virer + void setFaceId(unsigned int orbit, Dart d); + //@} + + /*! @name Cells Information + * Operations to manage the cells informations : + *************************************************************************/ + + //@{ + //! Return the level of insertion of the vertex of d + /*! + */ + unsigned int vertexInsertionLevel(Dart d) const; + + //! Return the level of the edge of d in the current level map + /*! + */ + unsigned int edgeLevel(Dart d) ; + + //! Return the level of the face of d in the current level map + /*! + */ + unsigned int faceLevel(Dart d); + + //! Return the level of the volume of d in the current level map + /*! + */ + unsigned int volumeLevel(Dart d); + + //! Return the oldest dart of the face of d in the current level map + /*! + */ + Dart faceOldestDart(Dart d); + + //! Return the oldest dart of the volume of d in the current level map + /*! + */ + Dart volumeOldestDart(Dart d); + + //! Return true if the edge of d in the current level map + //! has already been subdivided to the next level + /*! + */ + bool edgeIsSubdivided(Dart d) ; + + //! Return true if the edge of d in the current level map + //! is subdivided to the next level, + //! none of its resulting edges is in turn subdivided to the next level + //! and the middle vertex is of degree 2 + /*! + */ + bool edgeCanBeCoarsened(Dart d); + + //! Return true if the face of d in the current level map + //! has already been subdivided to the next level + /*! + */ + bool faceIsSubdivided(Dart d) ; + + //! + /*! + */ + bool faceCanBeCoarsened(Dart d); + + //! Return true if the volume of d in the current level map + //! has already been subdivided to the next level + /*! + */ + bool volumeIsSubdivided(Dart d); + + //! + /*! + */ + bool volumeIsSubdividedOnce(Dart d); + + + /*! @name + *************************************************************************/ + + //! + /*! + */ + bool neighborhoodLevelDiffersMoreThanOne(Dart d); + + //! wired !!! + /*! + */ + bool coarsenNeighborhoodLevelDiffersMoreThanOne(Dart d); + //@} + + /*! @name Cell Functors + * Redefition of the 3-maps map traversor + *************************************************************************/ + + //@{ + Dart begin() const; + + Dart end() const; + + void next(Dart& d) const ; + + template + void foreach_dart_of_orbit(Cell c, FUNC f) const ; + template + void foreach_dart_of_orbit(Cell c, FUNC& f) const ; + + template + void foreach_dart_of_vertex(Dart d, FUNC& f) const ; + + template + void foreach_dart_of_edge(Dart d, FUNC& f) const ; + + template + void foreach_dart_of_oriented_face(Dart d, FUNC& f) const; + + template + void foreach_dart_of_face(Dart d, FUNC& f) const ; + + template + void foreach_dart_of_oriented_volume(Dart d, FUNC& f) const; + + template + void foreach_dart_of_volume(Dart d, FUNC& f) const ; + + template + void foreach_dart_of_vertex1(Dart d, FUNC& f) const; + + template + void foreach_dart_of_edge1(Dart d, FUNC& f) const; + + template + void foreach_dart_of_vertex2(Dart d, FUNC& f) const; + + template + void foreach_dart_of_edge2(Dart d, FUNC& f) const; + + template + void foreach_dart_of_face2(Dart d, FUNC& f) const; + + template + void foreach_dart_of_cc(Dart d, FUNC& f) const ; + //@} + +// template +// unsigned int getEmbedding(Cell c) const; +} ; + +template +class AttributeHandler_IHM : public AttributeHandler +{ +public: + typedef T DATA_TYPE ; + + AttributeHandler_IHM() : AttributeHandler() + {} + + AttributeHandler_IHM(ImplicitHierarchicalMap3* m, AttributeMultiVector* amv) : AttributeHandler(m, amv) + {} + + AttributeMultiVector* getDataVector() const + { + return AttributeHandler::getDataVector() ; + } + + bool isValid() const + { + return AttributeHandler::isValid() ; + } + + virtual T& operator[](Dart d) ; + + virtual const T& operator[](Dart d) const ; + + T& operator[](unsigned int a) + { + return AttributeHandler::operator[](a) ; + } + + const T& operator[](unsigned int a) const + { + return AttributeHandler::operator[](a) ; + } + +} ; + +template +class VertexAttribute_IHM : public IHM::AttributeHandler_IHM +{ +public: + VertexAttribute_IHM() : IHM::AttributeHandler_IHM() {} + VertexAttribute_IHM(const IHM::AttributeHandler_IHM& ah) : IHM::AttributeHandler_IHM(ah) {} +// VertexAttribute_IHM& operator=(const IHM::AttributeHandler_IHM& ah) { this->IHM::AttributeHandler_IHM::operator=(ah); return *this; } +}; + +} // namespace IHM + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/ImplicitHierarchicalMesh/ihm3.hpp" + +#endif + +////! +///*! +// */ +//bool faceIsSubdividedOnce(Dart d); diff --git a/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision.hppxx b/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision.hppxx new file mode 100644 index 0000000000000000000000000000000000000000..1deae89c535e290d99f5661dc122f7458300998c --- /dev/null +++ b/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision.hppxx @@ -0,0 +1,275 @@ +/******************************************************************************* +* 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 Surface +{ + +namespace IHM +{ + +template +void subdivideEdge(typename PFP::MAP& map, Dart d, VertexAttribute& position) +{ + assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ; + assert(!map.edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ; + + unsigned int eLevel = map.edgeLevel(d) ; + + unsigned int cur = map.getCurrentLevel() ; + map.setCurrentLevel(eLevel) ; + + Dart dd = map.phi2(d) ; + typename PFP::VEC3 p1 = position[d] ; + typename PFP::VEC3 p2 = position[map.phi1(d)] ; + + map.setCurrentLevel(eLevel + 1) ; + + map.cutEdge(d) ; + unsigned int eId = map.getEdgeId(d) ; + map.setEdgeId(map.phi1(d), eId) ; + map.setEdgeId(map.phi1(dd), eId) ; + position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ; + + map.setCurrentLevel(cur) ; +} + +template +void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute& position, bool forceTri) +{ + assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ; + assert(!map.faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ; + + unsigned int fLevel = map.faceLevel(d) ; + Dart old = map.faceOldestDart(d) ; + + unsigned int cur = map.getCurrentLevel() ; + map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges + + std::cout << "subdiv" << std::endl; + + unsigned int degree = 0 ; + typename PFP::VEC3 p ; + Dart it = old ; + do + { + ++degree ; + p += position[it] ; + if(!map.edgeIsSubdivided(it)) // first cut the edges (if they are not already) + IHM::subdivideEdge(map, it, position) ; // and compute the degree of the face + it = map.phi1(it) ; + } while(it != old) ; + p /= typename PFP::REAL(degree) ; + + map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision + + if(degree == 3 && forceTri) // if subdividing a triangle + { + Dart dd = map.phi1(old) ; + Dart e = map.phi1(map.phi1(dd)) ; + map.splitFace(dd, e) ; // insert a new edge + unsigned int id = map.getNewEdgeId() ; + map.setEdgeId(map.phi_1(dd), id) ; // set the edge id of the inserted + map.setEdgeId(map.phi_1(e), id) ; // edge to the next available id + + dd = e ; + e = map.phi1(map.phi1(dd)) ; + map.splitFace(dd, e) ; + id = map.getNewEdgeId() ; + map.setEdgeId(map.phi_1(dd), id) ; + map.setEdgeId(map.phi_1(e), id) ; + + dd = e ; + e = map.phi1(map.phi1(dd)) ; + map.splitFace(dd, e) ; + id = map.getNewEdgeId() ; + map.setEdgeId(map.phi_1(dd), id) ; + map.setEdgeId(map.phi_1(e), id) ; + + +// Dart stop = map.phi2(map.phi1(old)); +// Dart dit = stop; +// do +// { +// unsigned int dId = map.getEdgeId(map.phi_1(map.phi2(dit))); +// unsigned int eId = map.getEdgeId(map.phi1(map.phi2(dit))); + +// unsigned int t = dId + eId; + +// if(t == 0) +// { +// map.setEdgeId(dit, 1); +// map.setEdgeId(map.phi2(dit), 1); +// } +// else if(t == 1) +// { +// map.setEdgeId(dit, 2); +// map.setEdgeId(map.phi2(dit), 2); +// } +// else if(t == 2) +// { +// if(dId == eId) +// { +// map.setEdgeId(dit, 0); +// map.setEdgeId(map.phi2(dit), 0); +// } +// else +// { +// map.setEdgeId(dit, 1); +// map.setEdgeId(map.phi2(dit), 1); +// } +// } +// else if(t == 3) +// { +// map.setEdgeId(dit, 0); +// map.setEdgeId(map.phi2(dit), 0); +// } + +// dit = map.phi1(dit); +// }while(dit != stop); + + } + else // if subdividing a polygonal face + { + Dart dd = map.phi1(old) ; + map.splitFace(dd, map.phi1(map.phi1(dd))) ; // insert a first edge + Dart ne = map.alpha1(dd) ; + Dart ne2 = map.phi2(ne) ; + + map.cutEdge(ne) ; // cut the new edge to insert the central vertex + unsigned int id = map.getNewEdgeId() ; + map.setEdgeId(ne, id) ; + map.setEdgeId(map.phi2(ne), id) ; // set the edge id of the inserted + id = map.getNewEdgeId() ; + map.setEdgeId(ne2, id) ; // edges to the next available ids + map.setEdgeId(map.phi2(ne2), id) ; + + position[map.phi2(ne)] = p ; + + dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ; + while(dd != ne) // turn around the face and insert new edges + { // linked to the central vertex + Dart next = map.phi1(map.phi1(dd)) ; + map.splitFace(map.phi1(ne), dd) ; + Dart nne = map.alpha1(dd) ; + id = map.getNewEdgeId() ; + map.setEdgeId(nne, id) ; + map.setEdgeId(map.phi2(nne), id) ; + dd = next ; + } + +// Dart dit = map.phi2(ne); +// do +// { +// unsigned int eId = map.getEdgeId(map.phi1(dit)); +// if(eId == 0) +// { +// map.setEdgeId(dit, 1); +// map.setEdgeId(map.phi2(dit), 1); +// } +// else if(eId == 1) +// { +// map.setEdgeId(dit, 0); +// map.setEdgeId(map.phi2(dit), 0); +// } +// dit = map.phi2(map.phi_1(dit)); +// } +// while(dit != map.phi2(ne)); + } + + map.setCurrentLevel(cur) ; +} + +template +void coarsenEdge(typename PFP::MAP& map, Dart d, VertexAttribute& position) +{ + assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ; + assert(map.edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ; + + unsigned int cur = map.getCurrentLevel() ; +// Dart e = map.phi2(d) ; + map.setCurrentLevel(cur + 1) ; +// unsigned int dl = map.getDartLevel(e) ; +// map.setDartLevel(map.phi1(e), dl) ; +// map.collapseEdge(e) ; + map.uncutEdge(d) ; + map.setCurrentLevel(cur) ; +} + +template +void coarsenFace(typename PFP::MAP& map, Dart d, VertexAttribute& position) +{ + assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ; + assert(map.faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ; + + unsigned int cur = map.getCurrentLevel() ; + + unsigned int degree = 0 ; + Dart fit = d ; + do + { + ++degree ; + fit = map.phi1(fit) ; + } while(fit != d) ; + + if(degree == 3) + { + fit = d ; + do + { + map.setCurrentLevel(cur + 1) ; + Dart innerEdge = map.phi1(fit) ; + map.setCurrentLevel(map.getMaxLevel()) ; + map.mergeFaces(innerEdge) ; + map.setCurrentLevel(cur) ; + fit = map.phi1(fit) ; + } while(fit != d) ; + } + else + { + map.setCurrentLevel(cur + 1) ; + Dart centralV = map.phi1(map.phi1(d)) ; + map.setCurrentLevel(map.getMaxLevel()) ; + map.deleteVertex(centralV) ; + map.setCurrentLevel(cur) ; + } + + fit = d ; + do + { + if(map.edgeCanBeCoarsened(fit)) + coarsenEdge(map, fit, position) ; + fit = map.phi1(fit) ; + } while(fit != d) ; +} + +} //namespace IHM +} // Surface +} //namespace Algo +} //namespace CGoGN diff --git a/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision.hxx b/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision.hxx new file mode 100644 index 0000000000000000000000000000000000000000..29015521444401656dc53e6d7065778a37cca8f3 --- /dev/null +++ b/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision.hxx @@ -0,0 +1,59 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __IMPLICIT_HIERARCHICAL_MESH_SUBDIVISION__ +#define __IMPLICIT_HIERARCHICAL_MESH_SUBDIVISION__ + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace IHM +{ + +template +void subdivideEdge(typename PFP::MAP& map, Dart d, VertexAttribute& position) ; + +template +void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute& position, bool forceTri = true); + +template +void coarsenEdge(typename PFP::MAP& map, Dart d, VertexAttribute& position) ; + +template +void coarsenFace(typename PFP::MAP& map, Dart d, VertexAttribute& position) ; + +} //namespace IHM +} // Surface +} //namespace Algo +} //namespace CGoGN + +#include "Algo/ImplicitHierarchicalMesh/subdivision.hpp" + +#endif diff --git a/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision3.cpp b/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9b0dc69fcc584b10f5e4be3e370c3d6e6b1b4207 --- /dev/null +++ b/Apps/Tests/Algo/ImplicitHierarchicalMesh/subdivision3.cpp @@ -0,0 +1,143 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __IMPLICIT_HIERARCHICAL_MESH_SUBDIVISION3__ +#define __IMPLICIT_HIERARCHICAL_MESH_SUBDIVISION3__ + + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace IHM +{ + +enum SubdivideType +{ + S_TRI, + S_QUAD +} ; + + + + +template +void newLevelHexa(typename PFP::MAP& map, VertexAttribute& position); + + +/*********************************************************************************** + * Subdivision * + ***********************************************************************************/ + +template +void subdivideEdge(typename PFP::MAP& map, Dart d, VertexAttribute& position) ; + +template +void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute& position, SubdivideType sType = S_TRI); + +template +Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, VertexAttribute& position); + + + + + + + + +template +void subdivideEdgeWrong(typename PFP::MAP& map, Dart d, VertexAttribute& position) ; + +template +void subdivideFaceWrong(typename PFP::MAP& map, Dart d, VertexAttribute& position, SubdivideType sType = S_TRI); + +template +Dart subdivideVolumeClassicWrong(typename PFP::MAP& map, Dart d, VertexAttribute& position); + + + + + + + + + +template +Dart subdivideVolume(typename PFP::MAP& map, Dart d, VertexAttribute& position); + + + + + +template +Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, VertexAttribute& position); + + + +template +Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, VertexAttribute& position); + + +template +void subdivideLoop(typename PFP::MAP& map, Dart d, VertexAttribute& position); + + +/*********************************************************************************** + * Simplification * + ***********************************************************************************/ + +template +void coarsenEdge(typename PFP::MAP& map, Dart d, VertexAttribute& position); + +template +void coarsenFace(typename PFP::MAP& map, Dart d, VertexAttribute& position, SubdivideType sType = S_TRI); + +template +void coarsenVolume(typename PFP::MAP& map, Dart d, VertexAttribute& position); + +/*********************************************************************************** + * Raffinement + ***********************************************************************************/ +/* + * Un brin de la face oppose aux faces a spliter + */ +template +void splitVolume(typename PFP::MAP& map, Dart d, VertexAttribute& position); + + + + +} //namespace IHM +} // Volume +} //namespace Algo +} //namespace CGoGN + +#include "Algo/ImplicitHierarchicalMesh/subdivision3.hpp" + +#endif diff --git a/Apps/Tests/Algo/Import/AHEM.cpp b/Apps/Tests/Algo/Import/AHEM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5dd2fa7340f7f3c8bd8100145d48c1ecd22fa27a --- /dev/null +++ b/Apps/Tests/Algo/Import/AHEM.cpp @@ -0,0 +1,167 @@ +#ifndef __AHEM_H__ +#define __AHEM_H__ + + + + +#include + + + +#ifdef _WIN32 + +typedef __int8 stInt8; +typedef __int16 stInt16; +typedef __int32 stInt32; +typedef __int64 stInt64; + +typedef unsigned __int8 stUInt8; +typedef unsigned __int16 stUInt16; +typedef unsigned __int32 stUInt32; +typedef unsigned __int64 stUInt64; + + +#else + +#include + +typedef int8_t stInt8; +typedef int16_t stInt16; +typedef int32_t stInt32; +typedef int64_t stInt64; + +typedef uint8_t stUInt8; +typedef uint16_t stUInt16; +typedef uint32_t stUInt32; +typedef uint64_t stUInt64; + +#endif + + +#ifdef _WIN32 +#include +#define DEFINE_GUID_INFUNC(name, dw, w0, w1, b0, b1, b2, b3, b4, b5, b6, b7) static const GUID name = { dw, w0, w1, { b0, b1, b2, b3, b4, b5, b6, b7 } } +#else +#include +#define DEFINE_GUID(name, dw, w0, w1, b0, b1, b2, b3, b4, b5, b6, b7) UUID_DEFINE(name, dw & 0xff, (dw >> 8) & 0xff, (dw >> 16) & 0xff, (dw >> 24) & 0xff, w0 & 0xff, (w0 >> 8) & 0xff, w1 & 0xff, (w1 >> 8) & 0xff, b0, b1, b2, b3, b4, b5, b6, b7) +#define DEFINE_GUID_INFUNC DEFINE_GUID +typedef uuid_t GUID; +#endif + + +inline bool IsEqualGUID(const stUInt8* v1, const GUID& v2) +{ + const stUInt32* w1 = (stUInt32*)v1; + const stUInt32* w2 = (stUInt32*)&v2; + + return w1[0] == w2[0] && w1[1] == w2[1] && w1[2] == w2[2] && w1[3] == w2[3]; +} + + + +// {1B8E15D6-FE16-44E2-BDC8-9FBA3420B267} +DEFINE_GUID(AHEMDATATYPE_INT8, 0x1b8e15d6, 0xfe16, 0x44e2, 0xbd, 0xc8, 0x9f, 0xba, 0x34, 0x20, 0xb2, 0x67); +// {3D772789-9D2A-4527-8709-5B3E08BDD071} +DEFINE_GUID(AHEMDATATYPE_UINT8, 0x3d772789, 0x9d2a, 0x4527, 0x87, 0x9, 0x5b, 0x3e, 0x8, 0xbd, 0xd0, 0x71); +// {E6D2DD95-A4EF-4EA3-82FF-12F4BAB40C51} +DEFINE_GUID(AHEMDATATYPE_INT16, 0xe6d2dd95, 0xa4ef, 0x4ea3, 0x82, 0xff, 0x12, 0xf4, 0xba, 0xb4, 0xc, 0x51); +// {5A926579-9586-413B-BEF5-992E0A9CA8E5} +DEFINE_GUID(AHEMDATATYPE_UINT16, 0x5a926579, 0x9586, 0x413b, 0xbe, 0xf5, 0x99, 0x2e, 0xa, 0x9c, 0xa8, 0xe5); +// {717210F9-4AB4-4ED3-9ACC-8AC89AA6BE55} +DEFINE_GUID(AHEMDATATYPE_INT32, 0x717210f9, 0x4ab4, 0x4ed3, 0x9a, 0xcc, 0x8a, 0xc8, 0x9a, 0xa6, 0xbe, 0x55); +// {9EA6E534-B251-44C7-B40C-C33CCCD6C18F} +DEFINE_GUID(AHEMDATATYPE_UINT32, 0x9ea6e534, 0xb251, 0x44c7, 0xb4, 0xc, 0xc3, 0x3c, 0xcc, 0xd6, 0xc1, 0x8f); +// {F10D01EF-D677-453B-B7A7-E3C85E56A18D} +DEFINE_GUID(AHEMDATATYPE_INT64, 0xf10d01ef, 0xd677, 0x453b, 0xb7, 0xa7, 0xe3, 0xc8, 0x5e, 0x56, 0xa1, 0x8d); +// {C0FD73C4-8A06-4CB0-86D4-1B305BCEC3C7} +DEFINE_GUID(AHEMDATATYPE_UINT64, 0xc0fd73c4, 0x8a06, 0x4cb0, 0x86, 0xd4, 0x1b, 0x30, 0x5b, 0xce, 0xc3, 0xc7); +// {2BD6E606-E3E3-4873-AA23-21D552EB11B3} +DEFINE_GUID(AHEMDATATYPE_FLOAT32, 0x2bd6e606, 0xe3e3, 0x4873, 0xaa, 0x23, 0x21, 0xd5, 0x52, 0xeb, 0x11, 0xb3); +// {4CC5D944-4336-49B0-901D-842E30E87D3E} +DEFINE_GUID(AHEMDATATYPE_FLOAT64, 0x4cc5d944, 0x4336, 0x49b0, 0x90, 0x1d, 0x84, 0x2e, 0x30, 0xe8, 0x7d, 0x3e); + + + +// {0FDAF25D-2389-4A6D-BE3B-F8C00D118F23} +DEFINE_GUID(AHEMATTRIBUTE_POSITION, 0xfdaf25d, 0x2389, 0x4a6d, 0xbe, 0x3b, 0xf8, 0xc0, 0xd, 0x11, 0x8f, 0x23); + + + + +#define AHEM_MAGIC 0x4148454D + +#ifdef _WIN32 +typedef enum : stUInt32 +#else +typedef enum +#endif +{ + AHEMATTROWNER_UNKNOWN = 0, + AHEMATTROWNER_HALFEDGE = 1, + AHEMATTROWNER_VERTEX = 2, + AHEMATTROWNER_FACE = 3, + AHEMATTROWNER_HE_FACECORNER = 4, +#ifndef _WIN32 + AHEMATTROWNER_FORCE_DWORD = 0xffffffff +#endif +} AHEMAttributeOwner; + + +#pragma pack(push, 1) + +typedef struct +{ + stUInt32 meshChunkSize; + + stUInt32 heCount; + stUInt32 vxCount; + stUInt32 faceCount; + + stUInt32 faceMaxSize; +} AHEMTopologyHeader; + + +typedef struct +{ + stUInt32 fileStartOffset; + stUInt32 attributeChunkSize; + + stUInt8 semantic[16]; // Semantic GUID + + AHEMAttributeOwner owner; + stUInt32 attrPodSize; // 0 means non-pod-stored attribute + stUInt8 dataType[16]; // datatype GUID + stUInt32 dimension; + + stUInt32 nameSize; +} AHEMAttributeDescriptor; + + + +#define AHEM_MAGIC 0x4148454D + +typedef struct +{ + stUInt32 magic; + stUInt32 version; + + AHEMTopologyHeader meshHdr; + stUInt32 meshFileStartOffset; + + stUInt32 attributesChunkNumber; +} AHEMHeader; + + +typedef struct +{ + stUInt32 batchLength; + stUInt32 batchFaceSize; +} AHEMFaceBatchDescriptor; + + +#pragma pack(pop) + + + + +#endif // __AHEM_H__ diff --git a/Apps/Tests/Algo/Import/AHEMImporter.cpp b/Apps/Tests/Algo/Import/AHEMImporter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7c62a39b9c6813f4c0091673e3b28a0c89569b4 --- /dev/null +++ b/Apps/Tests/Algo/Import/AHEMImporter.cpp @@ -0,0 +1,34 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Import/AHEMImporter.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Import::AHEMImporter; + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Import::AHEMImporter; + + +int test_AHEMImporter() +{ + + return 0; +} + + diff --git a/Apps/Tests/Algo/Import/AHEMImporterDefAttr.cpp b/Apps/Tests/Algo/Import/AHEMImporterDefAttr.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03fd53876210527f5080355b79c315771e16ace6 --- /dev/null +++ b/Apps/Tests/Algo/Import/AHEMImporterDefAttr.cpp @@ -0,0 +1,17 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Import/AHEMImporterDefAttr.h" + +using namespace CGoGN; + +template class Algo::Import::UniversalLoader; + +int test_AHEMImporterDefAttr() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Import/CMakeLists.txt b/Apps/Tests/Algo/Import/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c99b1bccef8e6152e9b8ec559a87cdd7b0dd0da8 --- /dev/null +++ b/Apps/Tests/Algo/Import/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_import) + +add_executable( test_algo_import +algo_import.cpp +#AHEMImporter.cpp +#AHEMImporterDefAttr.cpp +import.cpp +importMRDAT.cpp +importObjTex.cpp +#importSvg +) + +target_link_libraries( test_algo_import + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + +qt_use_cgogn_modules(test_algo_import) diff --git a/Apps/Tests/Algo/Import/algo_import.cpp b/Apps/Tests/Algo/Import/algo_import.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f65aa72566ee6c99b68206b12a682caa63033999 --- /dev/null +++ b/Apps/Tests/Algo/Import/algo_import.cpp @@ -0,0 +1,21 @@ +#include + +//extern int test_AHEMImporter(); +//extern int test_AHEMImporterDefAttr(); +extern int test_import(); +extern int test_importObjTex(); +//extern int test_importSvg(); + + +int main() +{ +// test_AHEMImporter(); +// test_AHEMImporterDefAttr(); + test_import(); + test_importObjTex(); +// test_importSvg(); + + return 0; +} + + diff --git a/Apps/Tests/Algo/Import/import.cpp b/Apps/Tests/Algo/Import/import.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b45a7b592b4f04b0cbc0a536e354a0b62982a785 --- /dev/null +++ b/Apps/Tests/Algo/Import/import.cpp @@ -0,0 +1,65 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Import/import.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::Import::importMesh(PFP1::MAP& map, const std::string& filename, std::vector& attrNames, bool mergeCloseVertices); +template bool Algo::Surface::Import::importVoxellisation(PFP1::MAP& map, Algo::Surface::Modelisation::Voxellisation& voxellisation, std::vector& attrNames, bool mergeCloseVertices); +//template bool Algo::Surface::Import::importChoupi(const std::string& filename, const std::vector& tabV, const std::vector& tabE); + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template bool Algo::Surface::Import::importMesh(PFP2::MAP& map, const std::string& filename, std::vector& attrNames, bool mergeCloseVertices); +template bool Algo::Surface::Import::importVoxellisation(PFP2::MAP& map, Algo::Surface::Modelisation::Voxellisation& voxellisation, std::vector& attrNames, bool mergeCloseVertices); +//template bool Algo::Surface::Import::importChoupi(const std::string& filename, const std::vector& tabV, const std::vector& tabE); + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template bool Algo::Surface::Import::importMesh(PFP3::MAP& map, const std::string& filename, std::vector& attrNames, bool mergeCloseVertices); +template bool Algo::Surface::Import::importVoxellisation(PFP3::MAP& map, Algo::Surface::Modelisation::Voxellisation& voxellisation, std::vector& attrNames, bool mergeCloseVertices); +//template bool Algo::Surface::Import::importChoupi(const std::string& filename, const std::vector& tabV, const std::vector& tabE); + + + + +struct PFP4 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +template bool Algo::Volume::Import::importMesh(PFP4::MAP& map, const std::string& filename, std::vector& attrNames); +template bool Algo::Volume::Import::importMeshToExtrude(PFP4::MAP& map, const std::string& filename, std::vector& attrNames, float scale, unsigned int nbStage); +//template bool Algo::Volume::Import::importMeshSAsV(PFP4::MAP& map, const std::string& filename, std::vector& attrNames); + +struct PFP5 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template bool Algo::Volume::Import::importMesh(PFP5::MAP& map, const std::string& filename, std::vector& attrNames); +template bool Algo::Volume::Import::importMeshToExtrude(PFP5::MAP& map, const std::string& filename, std::vector& attrNames, float scale, unsigned int nbStage); +//template bool Algo::Volume::Import::importMeshSAsV(PFP5::MAP& map, const std::string& filename, std::vector& attrNames); + + + +int test_import() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Import/importFileTypes.cpp b/Apps/Tests/Algo/Import/importFileTypes.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5b8d48b248f0e2d712a00b11265809fe4ab5c8d6 --- /dev/null +++ b/Apps/Tests/Algo/Import/importFileTypes.cpp @@ -0,0 +1,131 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _IMPORT_FILE_TYPES_H +#define _IMPORT_FILE_TYPES_H + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ +namespace Import +{ + enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, /*PLYPTM, */PLYSLFgeneric, PLYSLFgenericBin, OFF, OBJ, VRML, AHEM, STL, STLB }; + + inline ImportType getFileType(const std::string& filename) + { + if ((filename.rfind(".trianbgz")!=std::string::npos) || (filename.rfind(".TRIANBGZ")!=std::string::npos)) + return TRIANBGZ; + + if ((filename.rfind(".trian")!=std::string::npos) || (filename.rfind(".TRIAN")!=std::string::npos)) + return TRIAN; + + if ((filename.rfind(".meshbin")!=std::string::npos) || (filename.rfind(".MESHBIN")!=std::string::npos)) + return MESHBIN; + + if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos)) + return PLY; + + if ((filename.rfind(".off")!=std::string::npos) || (filename.rfind(".OFF")!=std::string::npos)) + return OFF; + + if ((filename.rfind(".obj")!=std::string::npos) || (filename.rfind(".OBJ")!=std::string::npos)) + return OBJ; + + if ((filename.rfind(".ahem")!=std::string::npos) || (filename.rfind(".AHEM")!=std::string::npos)) + return AHEM; + + if ((filename.rfind(".stlb")!=std::string::npos) || (filename.rfind(".STLB")!=std::string::npos)) + return STLB; + + if ((filename.rfind(".stl")!=std::string::npos) || (filename.rfind(".STL")!=std::string::npos)) + return STL; + + return UNKNOWNSURFACE; + } +} +} + + +namespace Volume +{ +namespace Import +{ + enum ImportType { UNKNOWNVOLUME , TET, OFF, TS, MOKA, NODE, MSH, VTU, NAS, VBGZ, TETMESH/*, OVM*/}; + + inline ImportType getFileType(const std::string& filename) + { + if ((filename.rfind(".tetmesh")!=std::string::npos) || (filename.rfind(".TETMESH")!=std::string::npos)) + return TETMESH; + + if ((filename.rfind(".tet")!=std::string::npos) || (filename.rfind(".TET")!=std::string::npos)) + return TET; + + if ((filename.rfind(".node")!=std::string::npos) || (filename.rfind(".NODE")!=std::string::npos)) + return NODE; + + if ((filename.rfind(".off")!=std::string::npos) || (filename.rfind(".OFF")!=std::string::npos)) + return OFF; + + if ((filename.rfind(".ts")!=std::string::npos) || (filename.rfind(".TS")!=std::string::npos)) + return TS; + + if ((filename.rfind(".moka")!=std::string::npos) || (filename.rfind(".MOKA")!=std::string::npos)) + return MOKA; + + if ((filename.rfind(".node")!=std::string::npos) || (filename.rfind(".NODE")!=std::string::npos)) + return NODE; + + if ((filename.rfind(".msh")!=std::string::npos) || (filename.rfind(".MSH")!=std::string::npos)) + return MSH; + + if ((filename.rfind(".vtu")!=std::string::npos) || (filename.rfind(".VTU")!=std::string::npos)) + return VTU; + + if ((filename.rfind(".nas")!=std::string::npos) || (filename.rfind(".NAS")!=std::string::npos)) + return NAS; + + if ((filename.rfind(".vbgz")!=std::string::npos) || (filename.rfind(".VBGZ")!=std::string::npos)) + return VBGZ; + +// if ((filename.rfind(".ovm")!=std::string::npos) || (filename.rfind(".OVM")!=std::string::npos)) +// return OVM; + + return UNKNOWNVOLUME; + } + +} +} + + +} +} + +#endif diff --git a/Apps/Tests/Algo/Import/importMRDAT.cpp b/Apps/Tests/Algo/Import/importMRDAT.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4f144283e651a76f5cd8a7e0c18797418febe055 --- /dev/null +++ b/Apps/Tests/Algo/Import/importMRDAT.cpp @@ -0,0 +1,20 @@ +//#include "Topology/generic/parameters.h" +//// MAP? +// +//#include "Algo/Import/importMRDAT.h" +// +//using namespace CGoGN; +// +//struct PFP1 : public PFP_STANDARD +//{ +// typedef ?? MAP; +//} +// +//template bool importMRDAT(PFP1::MAP& map, const std::string& filename, std::vector& attrNames, QuadTree& qt) ; +// +// +//int test_importMRDAT() +//{ +// +// return 0; +//} diff --git a/Apps/Tests/Algo/Import/importObjTex.cpp b/Apps/Tests/Algo/Import/importObjTex.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c23fb2a5417c34400d7405712a0847c7c7cbaa75 --- /dev/null +++ b/Apps/Tests/Algo/Import/importObjTex.cpp @@ -0,0 +1,32 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Import/importObjTex.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::Import::OBJModel; + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::Import::OBJModel; + + +int test_importObjTex() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Import/importSvg.cpp b/Apps/Tests/Algo/Import/importSvg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b069dad96199a3e2f871330d36db9d09e7d892a --- /dev/null +++ b/Apps/Tests/Algo/Import/importSvg.cpp @@ -0,0 +1,82 @@ +///******************************************************************************* +//* 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 * +//* * +//*******************************************************************************/ +// +//#ifndef __IMPORTSVG_H__ +//#define __IMPORTSVG_H__ +// +//#include "Utils/xml.h" +// +//namespace CGoGN +//{ +// +//namespace Algo +//{ +// +//namespace Surface +//{ +// +//namespace Import +//{ +// +///** +// * check if an xml node has a given name +// * @param node the xml node +// * @param name the name +// * @ return true if node has the good name +// */ +//bool checkXmlNode(tinyxml2::XMLElement* node, const std::string& name); +// +//template +//void readCoordAndStyle(tinyxml2::XMLElement* cur_path, +// std::vector >& allPoly, +// std::vector >& allBrokenLines, +// std::vector& allBrokenLinesWidth); +// +//template +//bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttribute& position, CellMarker& polygons, CellMarker& polygonsFaces); +// +///** +// * +// */ +// +//template +//bool readSVG(const std::string& filename, std::vector > &allPoly); +// +//template +//bool importBB(const std::string& filename, std::vector > &bb); +// +//template +//bool importSVG(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames); +// +//} // namespace Import +// +//} +// +//} // namespace Algo +// +//} // namespace CGoGN +// +//#include "Algo/Import/importSvg.hpp" +// +//#endif diff --git a/Apps/Tests/Algo/LinearSolving/CMakeLists.txt b/Apps/Tests/Algo/LinearSolving/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..93ab3e2135b6f7a8925d8d7f4e729d9d0b1d37af --- /dev/null +++ b/Apps/Tests/Algo/LinearSolving/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_linearSolving) + +add_executable( test_algo_linearSolving +algo_linearSolving.cpp +basic.cpp +) + +target_link_libraries( test_algo_linearSolving + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/LinearSolving/algo_linearSolving.cpp b/Apps/Tests/Algo/LinearSolving/algo_linearSolving.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b8c37129910092d45fc28f242751b32a3c59b3fa --- /dev/null +++ b/Apps/Tests/Algo/LinearSolving/algo_linearSolving.cpp @@ -0,0 +1,11 @@ +#include + +extern int test_basic(); + +int main() +{ + test_basic(); + + + return 0; +} diff --git a/Apps/Tests/Algo/LinearSolving/basic.cpp b/Apps/Tests/Algo/LinearSolving/basic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bcb3212d1d1c92d2df534f3c4ec69a772fa38fda --- /dev/null +++ b/Apps/Tests/Algo/LinearSolving/basic.cpp @@ -0,0 +1,176 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/LinearSolving/basic.h" + +using namespace CGoGN; + + +template struct Algo::LinearSolving::Coeff; +template struct Algo::LinearSolving::Coeff; + + +struct PFP1 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; +typedef float SCAL_1; +typedef Geom::Vec3f VEC_1; + +template void Algo::LinearSolving::setupVariables(PFP1::MAP& m, + const VertexAttribute& index, + const CellMarker& freeMarker, + const VertexAttribute& attr); + +template void Algo::LinearSolving::setupVariables(PFP1::MAP& m, + const VertexAttribute& index, + const CellMarker& freeMarker, + const VertexAttribute& attr, + unsigned int coord); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + const VertexAttribute& weight); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + float weight); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + const VertexAttribute& weight, + unsigned int coord); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + float weight, + unsigned int coord); + +template void Algo::LinearSolving::addRows_Laplacian_Topo(PFP1::MAP& m, + const VertexAttribute& index); + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Topo(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr); + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Topo(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + unsigned int coord); + +template void Algo::LinearSolving::addRows_Laplacian_Cotan(PFP1::MAP& m, + const VertexAttribute& index, + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea); + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Cotan(PFP1::MAP& m, + const VertexAttribute& index, + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr); + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Cotan(PFP1::MAP& m, + const VertexAttribute& index, + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr, + unsigned int coord); + +template void Algo::LinearSolving::getResult(PFP1::MAP& m, + const VertexAttribute& index, + VertexAttribute& attr); + +template void Algo::LinearSolving::getResult(PFP1::MAP& m, + const VertexAttribute& index, + VertexAttribute& attr, + unsigned int coord); + + + +//struct PFP1 : public PFP_DOUBLE +//{ +// typedef EmbeddedMap2 MAP; +//}; +typedef double SCAL_2; +typedef Geom::Vec3d VEC_2; + +template void Algo::LinearSolving::setupVariables(PFP1::MAP& m, + const VertexAttribute& index, + const CellMarker& freeMarker, + const VertexAttribute& attr); + +template void Algo::LinearSolving::setupVariables(PFP1::MAP& m, + const VertexAttribute& index, + const CellMarker& freeMarker, + const VertexAttribute& attr, + unsigned int coord); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + const VertexAttribute& weight); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + float weight); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + const VertexAttribute& weight, + unsigned int coord); + +template void Algo::LinearSolving::addRowsRHS_Equality(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + float weight, + unsigned int coord); + + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Topo(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr); + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Topo(PFP1::MAP& m, + const VertexAttribute& index, + const VertexAttribute& attr, + unsigned int coord); + + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Cotan(PFP1::MAP& m, + const VertexAttribute& index, + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr); + +template void Algo::LinearSolving::addRowsRHS_Laplacian_Cotan(PFP1::MAP& m, + const VertexAttribute& index, + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr, + unsigned int coord); + +template void Algo::LinearSolving::getResult(PFP1::MAP& m, + const VertexAttribute& index, + VertexAttribute& attr); + +template void Algo::LinearSolving::getResult(PFP1::MAP& m, + const VertexAttribute& index, + VertexAttribute& attr, + unsigned int coord); + + + +int test_basic() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/MC/CMakeLists.txt b/Apps/Tests/Algo/MC/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..338e06e3fbc24f6e1887e7098bcbac19a08c7625 --- /dev/null +++ b/Apps/Tests/Algo/MC/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_mc) + +add_executable( test_algo_mc +algo_mc.cpp +image.cpp +marchingcube.cpp +marchingcubeGen.cpp +windowing.cpp +) + +target_link_libraries( test_algo_mc + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/MC/algo_mc.cpp b/Apps/Tests/Algo/MC/algo_mc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c73c36f96b9ed57870c00a5861408590bbacfd1c --- /dev/null +++ b/Apps/Tests/Algo/MC/algo_mc.cpp @@ -0,0 +1,17 @@ +#include + +extern int test_image(); +extern int test_planeCutting(); +extern int test_marchingcube(); +extern int test_marchingcubeGen(); +extern int test_windowing(); + +int main() +{ + test_image(); + test_marchingcube(); + test_marchingcubeGen(); + test_windowing(); + + return 0; +} diff --git a/Apps/Tests/Algo/MC/image.cpp b/Apps/Tests/Algo/MC/image.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e5901535e2a4c1a459eb00f6162993ef85b1c2e --- /dev/null +++ b/Apps/Tests/Algo/MC/image.cpp @@ -0,0 +1,22 @@ + +#include "Algo/MC/image.h" + +using namespace CGoGN; + +template class Algo::Surface::MC::Image; +template class Algo::Surface::MC::Image; +template class Algo::Surface::MC::Image; +template class Algo::Surface::MC::Image; + +template class Algo::Surface::MC::Image; +template class Algo::Surface::MC::Image; +template class Algo::Surface::MC::Image; +template class Algo::Surface::MC::Image; + +template class Algo::Surface::MC::Image; +template class Algo::Surface::MC::Image; + +int test_image() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/MC/marchingcube.cpp b/Apps/Tests/Algo/MC/marchingcube.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21a3c1a8edc435d725bd561db76c113e3e629686 --- /dev/null +++ b/Apps/Tests/Algo/MC/marchingcube.cpp @@ -0,0 +1,51 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/MC/marchingcube.h" +#include "Algo/MC/windowing.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MC::MarchingCube< char, Algo::Surface::MC::WindowingEqual, PFP1 >; +template class Algo::Surface::MC::MarchingCube< unsigned char, Algo::Surface::MC::WindowingEqual, PFP1 >; +template class Algo::Surface::MC::MarchingCube< int, Algo::Surface::MC::WindowingEqual, PFP1 >; +template class Algo::Surface::MC::MarchingCube< double, Algo::Surface::MC::WindowingEqual, PFP1 >; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MC::MarchingCube< char, Algo::Surface::MC::WindowingEqual, PFP2 >; +template class Algo::Surface::MC::MarchingCube< unsigned char, Algo::Surface::MC::WindowingEqual, PFP2 >; +template class Algo::Surface::MC::MarchingCube< int, Algo::Surface::MC::WindowingEqual, PFP2 >; +template class Algo::Surface::MC::MarchingCube< double, Algo::Surface::MC::WindowingEqual, PFP2 >; + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template class Algo::Surface::MC::MarchingCube< char, Algo::Surface::MC::WindowingEqual, PFP3 >; +template class Algo::Surface::MC::MarchingCube< unsigned char, Algo::Surface::MC::WindowingEqual, PFP3 >; +template class Algo::Surface::MC::MarchingCube< int, Algo::Surface::MC::WindowingEqual, PFP3 >; +template class Algo::Surface::MC::MarchingCube< double, Algo::Surface::MC::WindowingEqual, PFP3 >; + + + +int test_marchingcube() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/MC/marchingcubeGen.cpp b/Apps/Tests/Algo/MC/marchingcubeGen.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cd9ea2b1309dd749919429334fa8865b320a7a8e --- /dev/null +++ b/Apps/Tests/Algo/MC/marchingcubeGen.cpp @@ -0,0 +1,65 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/MC/marchingcubeGen.h" +#include "Algo/MC/windowing.h" + +using namespace CGoGN; + +template +class ImageTest +{ +public: + float getVoxSizeX() const { return 1.0f; } + float getVoxSizeY() const { return 1.0f; } + float getVoxSizeZ() const { return 1.0f; } + int getWidthX() const { return 256; } + int getWidthY() const { return 256; } + int getWidthZ() const { return 256; } + T getVoxel(int x, int y, int z) const { return T(std::sqrt(double((x - 128)*(x - 128) + (y - 128)*(y - 128) + (z - 128)*(y - 128)))); } +}; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MC::MarchingCubeGen< char, ImageTest, Algo::Surface::MC::WindowingEqual, PFP1 >; +template class Algo::Surface::MC::MarchingCubeGen< unsigned char, ImageTest, Algo::Surface::MC::WindowingEqual, PFP1 >; +template class Algo::Surface::MC::MarchingCubeGen< int, ImageTest, Algo::Surface::MC::WindowingEqual, PFP1 >; +template class Algo::Surface::MC::MarchingCubeGen< double, ImageTest, Algo::Surface::MC::WindowingEqual, PFP1 >; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MC::MarchingCubeGen< char, ImageTest, Algo::Surface::MC::WindowingEqual, PFP2 >; +template class Algo::Surface::MC::MarchingCubeGen< unsigned char, ImageTest, Algo::Surface::MC::WindowingEqual, PFP2 >; +template class Algo::Surface::MC::MarchingCubeGen< int, ImageTest, Algo::Surface::MC::WindowingEqual, PFP2 >; +template class Algo::Surface::MC::MarchingCubeGen< double, ImageTest, Algo::Surface::MC::WindowingEqual, PFP2 >; + + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template class Algo::Surface::MC::MarchingCubeGen< char, ImageTest, Algo::Surface::MC::WindowingEqual, PFP3 >; +template class Algo::Surface::MC::MarchingCubeGen< unsigned char, ImageTest, Algo::Surface::MC::WindowingEqual, PFP3 >; +template class Algo::Surface::MC::MarchingCubeGen< int, ImageTest, Algo::Surface::MC::WindowingEqual, PFP3 >; +template class Algo::Surface::MC::MarchingCubeGen< double, ImageTest, Algo::Surface::MC::WindowingEqual, PFP3 >; + + +int test_marchingcubeGen() +{ + // TODO faire une passe de MAJ et tester + return 0; +} + + diff --git a/Apps/Tests/Algo/MC/windowing.cpp b/Apps/Tests/Algo/MC/windowing.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fe935c2c9c2fb76a3735a4f78a66f679121ef5a7 --- /dev/null +++ b/Apps/Tests/Algo/MC/windowing.cpp @@ -0,0 +1,72 @@ + +#include "Algo/MC/windowing.h" +#include "Geometry/vector_gen.h" + +using namespace CGoGN; + +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; +template class Algo::Surface::MC::WindowingEqual; + + +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; +template class Algo::Surface::MC::WindowingDiff; + + +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; +template class Algo::Surface::MC::WindowingGreater; + +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; +template class Algo::Surface::MC::WindowingLess; + +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; +template class Algo::Surface::MC::WindowingInterval; + + +int test_windowing() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Modelisation/CMakeLists.txt b/Apps/Tests/Algo/Modelisation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7544fe3234eca20b0ef4e8d5aa2a947c2304f551 --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_modelisation) + +add_executable( test_algo_modelisation +algo_modelisation.cpp +boundEmb.cpp +extrusion.cpp +planeCutting.cpp +polyhedron.cpp +subdivision.cpp +subdivision3.cpp +tetrahedralization.cpp +triangulation.cpp +voxellisation.cpp +) + +target_link_libraries( test_algo_modelisation + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) diff --git a/Apps/Tests/Algo/Modelisation/algo_modelisation.cpp b/Apps/Tests/Algo/Modelisation/algo_modelisation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f7c5f15e98d35df780d915dca97fa998b7f308aa --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/algo_modelisation.cpp @@ -0,0 +1,24 @@ +#include + +extern int test_extrusion(); +extern int test_planeCutting(); +extern int test_polyhedron(); +extern int test_subdivision(); +extern int test_subdivision3(); +extern int test_tetrahedralization(); +extern int test_triangulation(); +extern int test_voxellisation(); + +int main() +{ + test_extrusion(); + test_planeCutting(); + test_polyhedron(); + test_subdivision(); + test_subdivision3(); + test_tetrahedralization(); + test_triangulation(); + test_voxellisation(); + + return 0; +} diff --git a/Apps/Tests/Algo/Modelisation/boundEmb.cpp b/Apps/Tests/Algo/Modelisation/boundEmb.cpp new file mode 100644 index 0000000000000000000000000000000000000000..22f6192f9ca54ae022ac17900994510458fd2be3 --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/boundEmb.cpp @@ -0,0 +1,8 @@ + + +//template +//void sewFaceEmb(typename PFP::MAP& map, Dart d, Dart e); +// +//template +//Dart newFaceEmb(typename PFP::MAP& map, unsigned int n); + diff --git a/Apps/Tests/Algo/Modelisation/extrusion.cpp b/Apps/Tests/Algo/Modelisation/extrusion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..48e45facf5bcae088f6cb4d8d4fdee450c41fa1d --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/extrusion.cpp @@ -0,0 +1,226 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Modelisation/extrusion.h" + +using namespace CGoGN; + + +// MAP2 / FLOAT instantiation +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template Dart Algo::Surface::Modelisation::extrusion_scale(PFP1::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP1::VEC3& centerProfile, + const PFP1::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::extrusion_scale_prim(PFP1::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP1::VEC3& centerProfile, + const PFP1::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::extrusion_prim(PFP1::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP1::VEC3& centerProfile, + const PFP1::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed); + +template Dart Algo::Surface::Modelisation::extrusion(PFP1::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP1::VEC3& centerProfile, + const PFP1::VEC3& normal, + bool profile_closed, + const std::vector& path, + bool path_closed); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::revolution_prim(PFP1::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP1::VEC3& center, + const PFP1::VEC3& axis, + bool profile_closed, + int nbSides); + +template Dart Algo::Surface::Modelisation::revolution(PFP1::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP1::VEC3& center, + const PFP1::VEC3& axis, + bool profile_closed, + int nbSides); + +template Dart Algo::Surface::Modelisation::extrudeFace(PFP1::MAP& the_map, + VertexAttribute& positions, Dart d, const PFP1::VEC3& N); + +template Dart Algo::Surface::Modelisation::extrudeFace(PFP1::MAP& the_map, + VertexAttribute& positions, Dart d, float dist); + +template Dart Algo::Surface::Modelisation::extrudeRegion(PFP1::MAP& the_map, + VertexAttribute& position, Dart d, const CellMarker& cm); + + +// MAP2 / DOUBLE instantiation +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template Dart Algo::Surface::Modelisation::extrusion_scale(PFP2::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP2::VEC3& centerProfile, + const PFP2::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::extrusion_scale_prim( PFP2::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP2::VEC3& centerProfile, + const PFP2::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::extrusion_prim(PFP2::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP2::VEC3& centerProfile, + const PFP2::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed); + +template Dart Algo::Surface::Modelisation::extrusion(PFP2::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP2::VEC3& centerProfile, + const PFP2::VEC3& normal, + bool profile_closed, + const std::vector& path, + bool path_closed); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::revolution_prim(PFP2::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP2::VEC3& center, + const PFP2::VEC3& axis, + bool profile_closed, + int nbSides); + +template Dart Algo::Surface::Modelisation::revolution(PFP2::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP2::VEC3& center, + const PFP2::VEC3& axis, + bool profile_closed, + int nbSides); + + +template Dart Algo::Surface::Modelisation::extrudeFace(PFP2::MAP& the_map, + VertexAttribute& positions, Dart d, const PFP2::VEC3& N); + +template Dart Algo::Surface::Modelisation::extrudeFace(PFP2::MAP& the_map, + VertexAttribute& positions, Dart d, float dist); + +template Dart Algo::Surface::Modelisation::extrudeRegion(PFP2::MAP& the_map, + VertexAttribute& position, Dart d, const CellMarker& cm); + + + +// GMAP2 / DOUBLE instantiation +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template Dart Algo::Surface::Modelisation::extrusion_scale(PFP3::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP3::VEC3& centerProfile, + const PFP3::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::extrusion_scale_prim(PFP3::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP3::VEC3& centerProfile, + const PFP3::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::extrusion_prim(PFP3::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP3::VEC3& centerProfile, + const PFP3::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed); + +template Dart Algo::Surface::Modelisation::extrusion(PFP3::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP3::VEC3& centerProfile, + const PFP3::VEC3& normal, + bool profile_closed, + const std::vector& path, + bool path_closed); + +template Algo::Surface::Tilings::Tiling* Algo::Surface::Modelisation::revolution_prim(PFP3::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP3::VEC3& center, + const PFP3::VEC3& axis, + bool profile_closed, + int nbSides); + +template Dart Algo::Surface::Modelisation::revolution(PFP3::MAP& the_map, + VertexAttribute& positions, + const std::vector& profile, + const PFP3::VEC3& center, + const PFP3::VEC3& axis, + bool profile_closed, + int nbSides); + +template Dart Algo::Surface::Modelisation::extrudeFace(PFP3::MAP& the_map, + VertexAttribute& positions, Dart d, const PFP3::VEC3& N); + +template Dart Algo::Surface::Modelisation::extrudeFace(PFP3::MAP& the_map, + VertexAttribute& positions, Dart d, float dist); + +template Dart Algo::Surface::Modelisation::extrudeRegion(PFP3::MAP& the_map, + VertexAttribute& position, Dart d, const CellMarker& cm); + +int test_extrusion() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Modelisation/planeCutting.cpp b/Apps/Tests/Algo/Modelisation/planeCutting.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ecfb3e920972354cd9f986bed1dc1f31d3906a32 --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/planeCutting.cpp @@ -0,0 +1,64 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Modelisation/planeCutting.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Surface::Modelisation::planeCut(PFP1::MAP& map, VertexAttribute& position, + const Geom::Plane3D& plane, CellMarker& cmf_over, bool keepTriangles, bool with_unsew); + +template void Algo::Surface::Modelisation::planeCut2(PFP1::MAP& map, VertexAttribute& position, + const Geom::Plane3D& plane, CellMarker& cmf_over, bool with_unsew); + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Surface::Modelisation::planeCut(PFP2::MAP& map, VertexAttribute& position, + const Geom::Plane3D& plane, CellMarker& cmf_over, bool keepTriangles, bool with_unsew); + +template void Algo::Surface::Modelisation::planeCut2(PFP2::MAP& map, VertexAttribute& position, + const Geom::Plane3D& plane, CellMarker& cmf_over, bool with_unsew); + + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template void Algo::Surface::Modelisation::planeCut(PFP3::MAP& map, VertexAttribute& position, + const Geom::Plane3D& plane, CellMarker& cmf_over, bool keepTriangles, bool with_unsew); + +template void Algo::Surface::Modelisation::planeCut2(PFP3::MAP& map, VertexAttribute& position, + const Geom::Plane3D& plane, CellMarker& cmf_over, bool with_unsew); + + + + +struct PFP4 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template void Algo::Volume::Modelisation::planeCut(PFP4::MAP& map, VertexAttribute& position, + const Geom::Plane3D& plane, CellMarker& cmv_over, bool keepTetrahedra, bool with_unsew); + + +int test_planeCutting() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Modelisation/polyhedron.cpp b/Apps/Tests/Algo/Modelisation/polyhedron.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5afb83db46cf77b68a47367e64b4a114f214ded2 --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/polyhedron.cpp @@ -0,0 +1,80 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Modelisation/polyhedron.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Surface::Modelisation::quads2TrianglesCC(PFP1::MAP& the_map, Dart primd); +//template void Algo::Surface::Modelisation::explodPolyhedron(PFP1::MAP& map, Dart d, VertexAttribute& position); +template Dart Algo::Surface::Modelisation::createPyramid(PFP1::MAP& map, unsigned int nbSides, bool withBoundary); +template Dart Algo::Surface::Modelisation::createPrism(PFP1::MAP& map, unsigned int nbSides, bool withBoundary); +template Dart Algo::Surface::Modelisation::createDiamond(PFP1::MAP& map, unsigned int nbSides, bool withBoundary); +template Dart Algo::Surface::Modelisation::createTetrahedron(PFP1::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createHexahedron(PFP1::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createTriangularPrism(PFP1::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createQuadrangularPyramid(PFP1::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createOctahedron(PFP1::MAP& map, bool withBoundary); +template bool Algo::Surface::Modelisation::isPyra(PFP1::MAP& map, Dart d); +template bool Algo::Surface::Modelisation::isPrism(PFP1::MAP& map, Dart d); +template bool Algo::Surface::Modelisation::isHexahedron(PFP1::MAP& the_map, Dart d); +template Dart Algo::Surface::Modelisation::embedPrism(PFP1::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height); +template Dart Algo::Surface::Modelisation::embedPyramid(PFP1::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float radius, float height); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Surface::Modelisation::quads2TrianglesCC(PFP2::MAP& the_map, Dart primd); +//template void Algo::Surface::Modelisation::explodPolyhedron(PFP2::MAP& map, Dart d, VertexAttribute& position); +template Dart Algo::Surface::Modelisation::createPyramid(PFP2::MAP& map, unsigned int nbSides, bool withBoundary); +template Dart Algo::Surface::Modelisation::createPrism(PFP2::MAP& map, unsigned int nbSides, bool withBoundary); +template Dart Algo::Surface::Modelisation::createDiamond(PFP2::MAP& map, unsigned int nbSides, bool withBoundary); +template Dart Algo::Surface::Modelisation::createTetrahedron(PFP2::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createHexahedron(PFP2::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createTriangularPrism(PFP2::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createQuadrangularPyramid(PFP2::MAP& map, bool withBoundary); +template Dart Algo::Surface::Modelisation::createOctahedron(PFP2::MAP& map, bool withBoundary); +template bool Algo::Surface::Modelisation::isPyra(PFP2::MAP& map, Dart d); +template bool Algo::Surface::Modelisation::isPrism(PFP2::MAP& map, Dart d); +template bool Algo::Surface::Modelisation::isHexahedron(PFP2::MAP& the_map, Dart d); +template Dart Algo::Surface::Modelisation::embedPrism(PFP2::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height); +template Dart Algo::Surface::Modelisation::embedPyramid(PFP2::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float radius, float height); + + +//struct PFP3 : public PFP_DOUBLE +//{ +// typedef EmbeddedGMap2 MAP; +//}; +// +//template void Algo::Surface::Modelisation::quads2TrianglesCC(PFP3::MAP& the_map, Dart primd); +//template void Algo::Surface::Modelisation::explodPolyhedron(PFP3::MAP& map, Dart d, VertexAttribute& position); +//template Dart Algo::Surface::Modelisation::createPyramid(PFP3::MAP& map, unsigned int nbSides, bool withBoundary); +//template Dart Algo::Surface::Modelisation::createPrism(PFP3::MAP& map, unsigned int nbSides, bool withBoundary); +//template Dart Algo::Surface::Modelisation::createDiamond(PFP3::MAP& map, unsigned int nbSides, bool withBoundary); +//template Dart Algo::Surface::Modelisation::createTetrahedron(PFP3::MAP& map, bool withBoundary); +//template Dart Algo::Surface::Modelisation::createHexahedron(PFP3::MAP& map, bool withBoundary); +//template Dart Algo::Surface::Modelisation::createTriangularPrism(PFP3::MAP& map, bool withBoundary); +//template Dart Algo::Surface::Modelisation::createQuadrangularPyramid(PFP3::MAP& map, bool withBoundary); +//template Dart Algo::Surface::Modelisation::createOctahedron(PFP3::MAP& map, bool withBoundary); +//template bool Algo::Surface::Modelisation::isPyra(PFP3::MAP& map, Dart d); +//template bool Algo::Surface::Modelisation::isPrism(PFP3::MAP& map, Dart d); +//template bool Algo::Surface::Modelisation::isHexahedron(PFP3::MAP& the_map, Dart d); +//template Dart Algo::Surface::Modelisation::embedPrism(PFP3::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height); +//template Dart Algo::Surface::Modelisation::embedPyramid(PFP3::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float radius, float height); + + +int test_polyhedron() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Modelisation/subdivision.cpp b/Apps/Tests/Algo/Modelisation/subdivision.cpp new file mode 100644 index 0000000000000000000000000000000000000000..894201fc99f9b99b25a02a9bd8c0050debb450bc --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/subdivision.cpp @@ -0,0 +1,100 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Modelisation/subdivision.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +typedef VertexAttribute VPOS1; + + + +template Dart Algo::Surface::Modelisation::trianguleFace(PFP1::MAP& map, Dart d); +template void Algo::Surface::Modelisation::trianguleFaces(PFP1::MAP& map, VPOS1& attributs); +template void Algo::Surface::Modelisation::trianguleFaces(PFP1::MAP& map, + VertexAttribute& position, const FaceAttribute& positionF) ; +template Dart Algo::Surface::Modelisation::quadranguleFace(PFP1::MAP& map, Dart d); +template void Algo::Surface::Modelisation::quadranguleFaces(PFP1::MAP& map, VPOS1& attributs); +template void Algo::Surface::Modelisation::CatmullClarkSubdivision(PFP1::MAP& map, VPOS1& attributs); +template void Algo::Surface::Modelisation::CatmullClarkInterpolSubdivision(PFP1::MAP& map, VPOS1& attributs); +template void Algo::Surface::Modelisation::LoopSubdivision(PFP1::MAP& map, VPOS1& attributs); +template void Algo::Surface::Modelisation::LoopSubdivisionGen(PFP1::MAP& map, VertexAttributeGen& attrib); +template void Algo::Surface::Modelisation::LoopSubdivisionAttribNameTyped(PFP1::MAP& map, const std::string& nameAttrib); +template void Algo::Surface::Modelisation::LoopSubdivisionAttribName(PFP1::MAP& map, const std::string& nameAttrib); +template void Algo::Surface::Modelisation::TwoNPlusOneSubdivision(PFP1::MAP& map, VPOS1& attributs, float size); +template void Algo::Surface::Modelisation::DooSabin(PFP1::MAP& map, VPOS1& position); +template void Algo::Surface::Modelisation::computeDual(PFP1::MAP& map, VertexAttribute& position); +template void Algo::Surface::Modelisation::computeBoundaryConstraintDual(PFP1::MAP& map, VertexAttribute& position); +template void Algo::Surface::Modelisation::computeBoundaryConstraintKeepingOldVerticesDual(PFP1::MAP& map, VertexAttribute& position); + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +typedef VertexAttribute VPOS2; + + +template Dart Algo::Surface::Modelisation::trianguleFace(PFP2::MAP& map, Dart d); +template void Algo::Surface::Modelisation::trianguleFaces(PFP2::MAP& map, VPOS2& attributs); +template void Algo::Surface::Modelisation::trianguleFaces(PFP2::MAP& map, + VertexAttribute& position, const FaceAttribute& positionF); +template Dart Algo::Surface::Modelisation::quadranguleFace(PFP2::MAP& map, Dart d); +template void Algo::Surface::Modelisation::quadranguleFaces(PFP2::MAP& map, VPOS2& attributs); +template void Algo::Surface::Modelisation::CatmullClarkSubdivision(PFP2::MAP& map, VPOS2& attributs); +template void Algo::Surface::Modelisation::CatmullClarkInterpolSubdivision(PFP2::MAP& map, VPOS2& attributs); +template void Algo::Surface::Modelisation::LoopSubdivision(PFP2::MAP& map, VPOS2& attributs); +template void Algo::Surface::Modelisation::LoopSubdivisionGen(PFP2::MAP& map, VertexAttributeGen& attrib); +template void Algo::Surface::Modelisation::LoopSubdivisionAttribNameTyped(PFP2::MAP& map, const std::string& nameAttrib); +template void Algo::Surface::Modelisation::LoopSubdivisionAttribName(PFP2::MAP& map, const std::string& nameAttrib); +template void Algo::Surface::Modelisation::TwoNPlusOneSubdivision(PFP2::MAP& map, VPOS2& attributs, float size); +template void Algo::Surface::Modelisation::DooSabin(PFP2::MAP& map, VPOS2& position); +template void Algo::Surface::Modelisation::computeDual(PFP2::MAP& map, VertexAttribute& position); +template void Algo::Surface::Modelisation::computeBoundaryConstraintDual(PFP2::MAP& map, VertexAttribute& position); +template void Algo::Surface::Modelisation::computeBoundaryConstraintKeepingOldVerticesDual(PFP2::MAP& map, VertexAttribute& position); + + + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +typedef VertexAttribute VPOS3; + + +template Dart Algo::Surface::Modelisation::trianguleFace(PFP3::MAP& map, Dart d); +template void Algo::Surface::Modelisation::trianguleFaces(PFP3::MAP& map, VPOS3& attributs); +template void Algo::Surface::Modelisation::trianguleFaces(PFP3::MAP& map, + VertexAttribute& position, const FaceAttribute& positionF); +template Dart Algo::Surface::Modelisation::quadranguleFace(PFP3::MAP& map, Dart d); +template void Algo::Surface::Modelisation::quadranguleFaces(PFP3::MAP& map, VPOS3& attributs); +template void Algo::Surface::Modelisation::CatmullClarkSubdivision(PFP3::MAP& map, VPOS3& attributs); +template void Algo::Surface::Modelisation::CatmullClarkInterpolSubdivision(PFP3::MAP& map, VPOS3& attributs); +template void Algo::Surface::Modelisation::LoopSubdivision(PFP3::MAP& map, VPOS3& attributs); +template void Algo::Surface::Modelisation::LoopSubdivisionGen(PFP3::MAP& map, VertexAttributeGen& attrib); +template void Algo::Surface::Modelisation::LoopSubdivisionAttribNameTyped(PFP3::MAP& map, const std::string& nameAttrib); +template void Algo::Surface::Modelisation::LoopSubdivisionAttribName(PFP3::MAP& map, const std::string& nameAttrib); +template void Algo::Surface::Modelisation::TwoNPlusOneSubdivision(PFP3::MAP& map, VPOS3& attributs, float size); +//template void Algo::Surface::Modelisation::DooSabin(PFP3::MAP& map, VPOS3& position); +template void Algo::Surface::Modelisation::computeDual(PFP3::MAP& map, VertexAttribute& position); +//template void Algo::Surface::Modelisation::computeBoundaryConstraintDual(PFP3::MAP& map, VertexAttribute& position); +//template void Algo::Surface::Modelisation::computeBoundaryConstraintKeepingOldVerticesDual(PFP3::MAP& map, VertexAttribute& position); + + + +int test_subdivision() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Modelisation/subdivision3.cpp b/Apps/Tests/Algo/Modelisation/subdivision3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7c06bd7cc752536a0c3ce9ac8edd27d01d9f1471 --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/subdivision3.cpp @@ -0,0 +1,57 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap3.h" + +#include "Algo/Modelisation/subdivision3.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +typedef VertexAttribute VPOS1; + + +template bool Algo::Volume::Modelisation::isHexahedron(PFP1::MAP& the_map, Dart d); +template Dart Algo::Volume::Modelisation::cut3Ear(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::sliceConvexVolume(PFP1::MAP& map, VertexAttribute& position, Dart d, Geom::Plane3D pl); +template Dart Algo::Volume::Modelisation::sliceConvexVolume(PFP1::MAP& map, VertexAttribute& position, Dart d, CellMarker& edgesToCut, CellMarker& verticesToSplit); +template std::vector Algo::Volume::Modelisation::sliceConvexVolumes(PFP1::MAP& map, VertexAttribute& position, CellMarker& volumesToCut, CellMarker& edgesToCut, CellMarker& verticesToSplit); +template void Algo::Volume::Modelisation::catmullClarkVol(PFP1::MAP& map, VPOS1& attributs); +template void Algo::Volume::Modelisation::sqrt3Vol(PFP1::MAP& map, VertexAttribute& position); +template void Algo::Volume::Modelisation::relaxation(PFP1::MAP& map, VertexAttribute& position); +template void Algo::Volume::Modelisation::computeDual(PFP1::MAP& map, VertexAttribute& position); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; +typedef VertexAttribute VPOS2; + +template bool Algo::Volume::Modelisation::isHexahedron(PFP2::MAP& the_map, Dart d); +template Dart Algo::Volume::Modelisation::cut3Ear(PFP2::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::sliceConvexVolume(PFP2::MAP& map, VertexAttribute& position, Dart d, Geom::Plane3D pl); +template Dart Algo::Volume::Modelisation::sliceConvexVolume(PFP2::MAP& map, VertexAttribute& position, Dart d, CellMarker& edgesToCut, CellMarker& verticesToSplit); +template std::vector Algo::Volume::Modelisation::sliceConvexVolumes(PFP2::MAP& map, VertexAttribute& position, CellMarker& volumesToCut, CellMarker& edgesToCut, CellMarker& verticesToSplit); +template void Algo::Volume::Modelisation::catmullClarkVol(PFP2::MAP& map, VPOS2& attributs); +template void Algo::Volume::Modelisation::sqrt3Vol(PFP2::MAP& map, VertexAttribute& position); +template void Algo::Volume::Modelisation::relaxation(PFP2::MAP& map, VertexAttribute& position); +template void Algo::Volume::Modelisation::computeDual(PFP2::MAP& map, VertexAttribute& position); + + +//struct PFP3 : public PFP_DOUBLE +//{ +// typedef EmbeddedGMap3 MAP; +//}; +//typedef VertexAttribute VPOS3; + + + +int test_subdivision3() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Modelisation/tetrahedralization.cpp b/Apps/Tests/Algo/Modelisation/tetrahedralization.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0ddf96f911c85ae1b977e1d1afaaf404a0b4306d --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/tetrahedralization.cpp @@ -0,0 +1,37 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap3.h" + +#include "Algo/Modelisation/tetrahedralization.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + + +template class Algo::Volume::Modelisation::Tetrahedralization::EarTriangulation; +template Dart Algo::Volume::Modelisation::Tetrahedralization::splitVertex(PFP1::MAP& map, std::vector& vd); +template bool Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(PFP1::MAP& map, Vol d); +template bool Algo::Volume::Modelisation::Tetrahedralization::isTetrahedralization(PFP1::MAP& map); +template Dart Algo::Volume::Modelisation::Tetrahedralization::swap2To2(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::swap4To4(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::swap3To2(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::swap2To3(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::swap5To4(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::swapGen3To2(PFP1::MAP& map, Dart d); +template std::vector Algo::Volume::Modelisation::Tetrahedralization::swapGen3To2Optimized(PFP1::MAP& map, Dart d); +template void Algo::Volume::Modelisation::Tetrahedralization::swapGen2To3(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::flip1To4(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::flip1To3(PFP1::MAP& map, Dart d); +template Dart Algo::Volume::Modelisation::Tetrahedralization::edgeBisection(PFP1::MAP& map, Dart d); + + + +int test_tetrahedralization() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Modelisation/triangulation.cpp b/Apps/Tests/Algo/Modelisation/triangulation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c9a5c0da85da943bd519332092fb0569389a01ba --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/triangulation.cpp @@ -0,0 +1,37 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Modelisation/triangulation.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + + +template class Algo::Surface::Modelisation::EarTriangulation; +template class Algo::Surface::Modelisation::EarTriangulation; +template class Algo::Surface::Modelisation::EarTriangulation; + + + +int test_triangulation() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Modelisation/voxellisation.cpp b/Apps/Tests/Algo/Modelisation/voxellisation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5645c439dc7b3e5cbb9d8a811463a1655839eb6e --- /dev/null +++ b/Apps/Tests/Algo/Modelisation/voxellisation.cpp @@ -0,0 +1,24 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Modelisation/voxellisation.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + + + + +int test_voxellisation() +{ + + Algo::Surface::Modelisation::Voxellisation vox; + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/MovingObjects/CMakeLists.txt b/Apps/Tests/Algo/MovingObjects/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2add0cdfef38d89eaec517077991869faef0bc1a --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_movingObjects) + +add_executable( test_algo_movingObjects +algo_movingObjects.cpp +particle_cell_2D.cpp +particle_cell_2D_memo.cpp +particle_cell_2D_secured.cpp +particle_cell_2DandHalf.cpp +particle_cell_2DandHalf_memo.cpp +particle_cell_3D.cpp +) + +target_link_libraries( test_algo_movingObjects + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) diff --git a/Apps/Tests/Algo/MovingObjects/algo_movingObjects.cpp b/Apps/Tests/Algo/MovingObjects/algo_movingObjects.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d2d4ab74fccd3b8a6fdf4e117f89a0f4494c0b7d --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/algo_movingObjects.cpp @@ -0,0 +1,20 @@ +#include + +extern int test_particle_cell_2D(); +extern int test_particle_cell_2D_memo(); +extern int test_particle_cell_2D_secured(); +extern int test_particle_cell_2DandHalf(); +extern int test_particle_cell_2DandHalf_memo(); +extern int test_particle_cell_3D(); + +int main() +{ + test_particle_cell_2D(); + test_particle_cell_2D_memo(); + test_particle_cell_2D_secured(); + test_particle_cell_2DandHalf(); + test_particle_cell_2DandHalf_memo(); + test_particle_cell_3D(); + + return 0; +} diff --git a/Apps/Tests/Algo/MovingObjects/particle_cell_2D.cpp b/Apps/Tests/Algo/MovingObjects/particle_cell_2D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..33f3926d664b61f558f9273fea9891df8cba3423 --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/particle_cell_2D.cpp @@ -0,0 +1,40 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/MovingObjects/particle_cell_2D.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2D; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2D; + + +// +//struct PFP3 : public PFP_DOUBLE +//{ +// typedef EmbeddedGMap2 MAP; +//}; +// +//template class Algo::Surface::MovingObjects::ParticleCell2D; + + +int test_particle_cell_2D() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/MovingObjects/particle_cell_2D_memo.cpp b/Apps/Tests/Algo/MovingObjects/particle_cell_2D_memo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f45fcb603b10dc977d356c6124680b43c4a6e1ee --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/particle_cell_2D_memo.cpp @@ -0,0 +1,41 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/MovingObjects/particle_cell_2D_memo.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DMemo; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DMemo; + + + +//struct PFP3 : public PFP_DOUBLE +//{ +// typedef EmbeddedGMap2 MAP; +//}; +// +//template class Algo::Surface::MovingObjects::ParticleCell2DMemo; +// + +int test_particle_cell_2D_memo() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/MovingObjects/particle_cell_2D_secured.cpp b/Apps/Tests/Algo/MovingObjects/particle_cell_2D_secured.cpp new file mode 100644 index 0000000000000000000000000000000000000000..76486e5c850a145876f26d72b5dafc9f33e19992 --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/particle_cell_2D_secured.cpp @@ -0,0 +1,41 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/MovingObjects/particle_cell_2D_secured.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DSecured; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DSecured; + + + +//struct PFP3 : public PFP_DOUBLE +//{ +// typedef EmbeddedGMap2 MAP; +//}; +// +//template class Algo::Surface::MovingObjects::ParticleCell2DSecured; +// + +int test_particle_cell_2D_secured() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/MovingObjects/particle_cell_2DandHalf.cpp b/Apps/Tests/Algo/MovingObjects/particle_cell_2DandHalf.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb744d368efee0c915ef117d58560e368907bb03 --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/particle_cell_2DandHalf.cpp @@ -0,0 +1,42 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/MovingObjects/particle_cell_2DandHalf.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DAndHalf; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DAndHalf; + + +// +//struct PFP3 : public PFP_DOUBLE +//{ +// typedef EmbeddedGMap2 MAP; +//}; +// +//template class Algo::Surface::MovingObjects::ParticleCell2DAndHalf; + + +int test_particle_cell_2DandHalf() +{ + + return 0; +} + + diff --git a/Apps/Tests/Algo/MovingObjects/particle_cell_2DandHalf_memo.cpp b/Apps/Tests/Algo/MovingObjects/particle_cell_2DandHalf_memo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..acb57ad5779c1b3b957807d475de4bfc9bd20bbf --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/particle_cell_2DandHalf_memo.cpp @@ -0,0 +1,41 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/MovingObjects/particle_cell_2DandHalf_memo.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DAndHalfMemo; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Surface::MovingObjects::ParticleCell2DAndHalfMemo; + + +// +//struct PFP3 : public PFP_DOUBLE +//{ +// typedef EmbeddedGMap2 MAP; +//}; +// +//template class Algo::Surface::MovingObjects::ParticleCell2DAndHalfMemo; + + +int test_particle_cell_2DandHalf_memo() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/MovingObjects/particle_cell_3D.cpp b/Apps/Tests/Algo/MovingObjects/particle_cell_3D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5bdc14c9cde97c5841a41bb6cc4a60485f224859 --- /dev/null +++ b/Apps/Tests/Algo/MovingObjects/particle_cell_3D.cpp @@ -0,0 +1,40 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap3.h" + + +#include "Algo/MovingObjects/particle_cell_3D.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +template class Algo::Volume::MovingObjects::ParticleCell3D; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template class Algo::Volume::MovingObjects::ParticleCell3D; + + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap3 MAP; +}; + +template class Algo::Volume::MovingObjects::ParticleCell3D; + + +int test_particle_cell_3D() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/Multiresolution/IHM2/ihm2_PrimalAdapt.cpp b/Apps/Tests/Algo/Multiresolution/IHM2/ihm2_PrimalAdapt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b2b51eeebeb9948f563696aae59f3160de958ebe --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/IHM2/ihm2_PrimalAdapt.cpp @@ -0,0 +1,165 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP2MR_PRIMAL_ADAPT__ +#define __MAP2MR_PRIMAL_ADAPT__ + +#include "Topology/ihmap/ihm2.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Adaptive +{ + +template +class IHM2 +{ + +public: + typedef typename PFP::MAP MAP ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + FunctorType* vertexVertexFunctor ; + FunctorType* edgeVertexFunctor ; + FunctorType* faceVertexFunctor ; + +public: + IHM2(MAP& map) ; + + /*************************************************** + * CELLS INFORMATION * + ***************************************************/ + + /** + * Return the level of the edge of d in the current level map + */ + unsigned int edgeLevel(Dart d) ; + + /** + * Return the level of the face of d in the current level map + */ + unsigned int faceLevel(Dart d) ; + + /** + * Given the face of d in the current level map, + * return a level 0 dart of its origin face + */ + Dart faceOrigin(Dart d) ; + + /** + * Return the oldest dart of the face of d in the current level map + */ + Dart faceOldestDart(Dart d) ; + + /** + * Return true if the edge of d in the current level map + * has already been subdivided to the next level + */ + bool edgeIsSubdivided(Dart d) ; + + /** + * Return true if the edge of d in the current level map + * is subdivided to the next level, + * none of its resulting edges is in turn subdivided to the next level + * and the middle vertex is of degree 2 + */ + bool edgeCanBeCoarsened(Dart d) ; + + /** + * Return true if the face of d in the current level map + * has already been subdivided to the next level + */ + bool faceIsSubdivided(Dart d) ; + + /** + * Return true if the face of d in the current level map + * is subdivided to the next level + * and none of its resulting faces is in turn subdivided to the next level + */ + bool faceIsSubdividedOnce(Dart d) ; + +protected: + /*************************************************** + * SUBDIVISION * + ***************************************************/ + + /** + * subdivide the edge of d to the next level + */ + void subdivideEdge(Dart d) ; + + /** + * coarsen the edge of d from the next level + */ + void coarsenEdge(Dart d) ; + +public: + /** + * subdivide the face of d to the next level + */ + unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true); + + /** + * coarsen the face of d from the next level + */ + void coarsenFace(Dart d) ; + + /** + * vertices attributes management + */ + void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; } + void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; } + void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } +} ; + +} // namespace Adaptive + +} // namespace Primal + +} // namespace MR + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/IHM2/ihm2_PrimalAdapt.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.cpp b/Apps/Tests/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0a54fdd8cc841bea6d992050e1708a5feb65fd21 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/IHM2/ihm2_PrimalRegular.cpp @@ -0,0 +1,102 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _IHM2MR_PRIMAL_REGULAR_ +#define _IHM2MR_PRIMAL_REGULAR_ + +#include "Topology/ihmap/ihm2.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" + +#include "Algo/Multiresolution/filter.h" +#include "Algo/Import/importMRDAT.h" + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Regular +{ + +template +class IHM2 +{ +public: + typedef typename PFP::MAP MAP ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + std::vector synthesisFilters ; + std::vector analysisFilters ; + +public: + IHM2(MAP& map) ; + + //if true : tri and quad else quad + void addNewLevel(bool triQuad = true) ; + + void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } + + void clearSynthesisFilters() { synthesisFilters.clear() ; } + void clearAnalysisFilters() { analysisFilters.clear() ; } + + void analysis() ; + void synthesis() ; + + void addLevelFront(); + + void import(Algo::Surface::Import::QuadTree& qt); +} ; + +} // namespace Regular + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/IHM2/ihm2_PrimalRegular.hpp" + +#endif // _IHM2MR_PRIMAL_REGULAR_ diff --git a/Apps/Tests/Algo/Multiresolution/IHM3/ihm3_PrimalAdapt.cpp b/Apps/Tests/Algo/Multiresolution/IHM3/ihm3_PrimalAdapt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7de084a8582b8849872e42e5705869b71b4854a9 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/IHM3/ihm3_PrimalAdapt.cpp @@ -0,0 +1,208 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP3MR_PRIMAL_ADAPT__ +#define __MAP3MR_PRIMAL_ADAPT__ + +#include "Topology/ihmap/ihm3.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor3.h" + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Adaptive +{ + +template +class IHM3 +{ + +public: + typedef typename PFP::MAP MAP ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + FunctorType* vertexVertexFunctor ; + FunctorType* edgeVertexFunctor ; + FunctorType* faceVertexFunctor ; + FunctorType* volumeVertexFunctor ; + +public: + IHM3(MAP& map) ; + + /*************************************************** + * CELLS INFORMATION * + ***************************************************/ + + //! Return the level of the edge of d in the current level map + /*! + */ + unsigned int edgeLevel(Dart d) ; + + //! Return the level of the face of d in the current level map + /*! + */ + unsigned int faceLevel(Dart d); + + //! Return the level of the volume of d in the current level map + /*! + */ + unsigned int volumeLevel(Dart d); + + //! Return the oldest dart of the face of d in the current level map + /*! + */ + Dart faceOldestDart(Dart d); + + //! Return the oldest dart of the volume of d in the current level map + /*! + */ + Dart volumeOldestDart(Dart d); + + //! Return true if the edge of d in the current level map + //! has already been subdivided to the next level + /*! + */ + bool edgeIsSubdivided(Dart d) ; + + //! Return true if the edge of d in the current level map + //! is subdivided to the next level, + //! none of its resulting edges is in turn subdivided to the next level + //! and the middle vertex is of degree 2 + /*! + */ + bool edgeCanBeCoarsened(Dart d); + + //! Return true if the face of d in the current level map + //! has already been subdivided to the next level + /*! + */ + bool faceIsSubdivided(Dart d) ; + + //! + /*! + */ + bool faceCanBeCoarsened(Dart d); + + //! Return true if the volume of d in the current level map + //! has already been subdivided to the next level + /*! + */ + bool volumeIsSubdivided(Dart d); + + //! + /*! + */ + bool volumeIsSubdividedOnce(Dart d); + +protected: + /*************************************************** + * SUBDIVISION * + ***************************************************/ +public: + /** + * subdivide the edge of d to the next level + */ + void subdivideEdge(Dart d) ; + + /** + * coarsen the edge of d from the next level + */ + void coarsenEdge(Dart d) ; + + /** + * subdivide the face of d to the next level + */ + unsigned int subdivideFace(Dart d, bool triQuad); + + /** + * coarsen the face of d from the next level + */ + void coarsenFace(Dart d) ; + + + //! Subdivide the volume of d to hexahedral cells + /*! @param d Dart from the volume + */ + Dart subdivideVolume(Dart d, bool triQuad = true, bool OneLevelDifference = true); + + /*! + * \brief subdivideHexa + * + * Detailed description of the function + * \param d + * \param OneLevelDifference + * \return + */ + unsigned int subdivideHexa(Dart d, bool OneLevelDifference = true); + + //! Subdivide the volume of d to hexahedral cells + /*! @param d Dart from the volume + */ + void subdivideVolumeTetOcta(Dart d) ; + + void coarsenVolume(Dart d) ; + + /** + * vertices attributes management + */ + void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; } + void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; } + void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } + void setVolumeVertexFunctor(FunctorType* f) { volumeVertexFunctor = f ; } + +} ; + +} // namespace Adaptive + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/IHM3/ihm3_PrimalAdapt.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/Dual/catmullClark.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/Dual/catmullClark.cpp new file mode 100644 index 0000000000000000000000000000000000000000..426648d52560fd3cef72d697456dc244c02c5b8c --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/Dual/catmullClark.cpp @@ -0,0 +1,144 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MR_CC_MASK__ +#define __MR_CC_MASK__ + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Dual +{ + +namespace Filters +{ + +template +class CCVertexSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCVertexSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart dV = trav.begin(); dV != trav.end(); dV = trav.next()) + { + m_map.incCurrentLevel() ; + + Dart start = m_map.phi2(m_map.phi1(m_map.phi2(dV))); + Dart dit = start; + do + { + Dart d = m_map.phi1(m_map.phi2(m_map.phi1(m_map.phi2(dit)))); + unsigned int degree = m_map.faceDegree(d); + VEC3 p(0.0); + + REAL a0 = 1.0 / 2.0 + 1.0 / (4.0 * REAL(degree)); + REAL a1 = 1.0 / 8.0 + 1.0 / (4.0 * REAL(degree)); + REAL ak_1 = a1; + + if(degree == 3) + { + p += a0 * m_position[d] + a1 * m_position[m_map.phi1(d)] + ak_1 * m_position[m_map.phi_1(d)]; + + m_map.incCurrentLevel(); + m_position[d] = p; + m_map.decCurrentLevel(); + + } + else if(degree == 4) + { + REAL a2 = 1.0 / (4.0 * REAL(degree)); + + p += a0 * m_position[d] + a1 * m_position[m_map.phi1(d)] + a2 * m_position[m_map.phi1(m_map.phi1(d))] + ak_1 * m_position[m_map.phi_1(d)]; + + m_map.incCurrentLevel(); + m_position[d] = p; + + } + else + { + p += a0 * m_position[d] + a1 * m_position[m_map.phi1(d)]; + + Dart end = m_map.phi_1(m_map.phi_1(d)); + Dart dit = m_map.phi1(m_map.phi1(d)); + do + { + REAL ai = 1.0 / (4.0 * REAL(degree)); + p += ai * m_position[dit]; + + dit = m_map.phi1(dit); + } + while(dit != end); + + p += ak_1 * m_position[m_map.phi_1(d)]; + + m_map.incCurrentLevel(); + m_position[d] = p; + } + + + dit = m_map.phi1(dit); + } + while(dit != start); + } + + m_map.decCurrentLevel(); + } +} ; + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/Dual/dooSabin.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/Dual/dooSabin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2b5ad7e316b7f3b38d2dc9f16f6dde34f90d27b3 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/Dual/dooSabin.cpp @@ -0,0 +1,103 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MR_DOOSABIN_MASK__ +#define __MR_DOOSABIN_MASK__ + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Dual +{ + +namespace Filters +{ + +template +class DooSabinVertexSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + DooSabinVertexSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + for (Dart dV = m_map.begin(); dV != m_map.end(); m_map.next(dV)) + { + VEC3 p(0.0); + + unsigned int N = m_map.faceDegree(dV); + REAL K0 = float(N+5)/float(4*N);//(1.0 / 4.0) + (5.0 / 4.0) * double(N); + p += K0 * m_position[dV]; + unsigned int j = 1; + Dart tmp = m_map.phi1(dV); + do + { + REAL Kj = (3.0 + 2.0 * cos(2.0 * double(j) * M_PI / double(N))) / (4.0 * N); + p += Kj * m_position[tmp]; + tmp = m_map.phi1(tmp); + ++j; + }while(tmp != dV); + + m_map.incCurrentLevel(); + + m_position[dV] = p; + + m_map.decCurrentLevel(); + } + } +} ; + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/bertram.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/bertram.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ba2f9ee9e8f7ad01df47dd6f608ebeef181e78c3 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/bertram.cpp @@ -0,0 +1,451 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __2MR_BERTRAM_FILTER__ +#define __2MR_BERTRAM_FILTER__ + +#include +#include "Algo/Geometry/centroid.h" +#include "Algo/Modelisation/tetrahedralization.h" +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/********************************************************************************* + * ANALYSIS FILTERS + *********************************************************************************/ + +//w-lift(a) +template +class Ber02OddAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + typename VEC3::DATA_TYPE m_a; + +public: + Ber02OddAnalysisFilter(MAP& m, VertexAttribute& p, typename VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] -= ve; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + VEC3 vf(0.0); + VEC3 ef(0.0); + + unsigned int count = 0; + Traversor2FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 4.0 * m_a; + + vf /= count; + vf *= 4.0 * m_a * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= vf + ef ; + m_map.decCurrentLevel() ; + } + } +}; + +// s-lift(a) +template +class Ber02EvenAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + typename VEC3::DATA_TYPE m_a; + +public: + Ber02EvenAnalysisFilter(MAP& m, VertexAttribute& p, typename VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(!m_map.isBoundaryEdge(d)) + { + unsigned int count = 0; + + VEC3 fe(0); + Traversor2EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(d); + m_position[midF] -= fe; + m_map.decCurrentLevel() ; + } + } + + TraversorV travV(m_map); + for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) + { + VEC3 ev(0.0); + VEC3 fv(0.0); + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryEdgeOfVertex(d); + m_map.incCurrentLevel() ; + ev += (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]) * typename PFP::REAL(0.5); + //ev = (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]); + m_map.decCurrentLevel() ; + ev *= 2 * m_a; + //ev *= m_a; + + m_position[d] -= ev; + } + else + { + unsigned int count = 0; + + Traversor2VF travVF(m_map,d); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + + Dart midEdgeV = m_map.phi1(dit); + ev += m_position[midEdgeV]; + fv += m_position[m_map.phi1(midEdgeV)]; + + m_map.decCurrentLevel() ; + ++count; + } + fv /= count; + fv *= 4 * m_a * m_a; + + ev /= count; + ev *= 4 * m_a; + + m_position[d] -= fv + ev; + } + } + } +}; + +// s-scale(a) +template +class Ber02ScaleAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + typename VEC3::DATA_TYPE m_a; + +public: + Ber02ScaleAnalysisFilter(MAP& m, VertexAttribute& p, typename VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + if(!m_map.isBoundaryVertex(midE)) + m_position[midE] /= m_a ; + m_map.decCurrentLevel() ; + } + + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + m_position[d] /= m_a; + else + m_position[d] /= m_a * m_a; + } + } +}; + + + +/********************************************************************************* + * SYNTHESIS FILTERS + *********************************************************************************/ + +//w-lift(a) +template +class Ber02OddSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + typename VEC3::DATA_TYPE m_a; + + +public: + Ber02OddSynthesisFilter(MAP& m, VertexAttribute& p, typename VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + VEC3 vf(0.0); + VEC3 ef(0.0); + + unsigned int count = 0; + Traversor2FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 4.0 * m_a; + + vf /= count; + vf *= 4.0 * m_a * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += vf + ef ; + m_map.decCurrentLevel() ; + + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d) ; + m_position[midE] += ve; + m_map.decCurrentLevel() ; + } + } +} ; + +// s-lift(a) +template +class Ber02EvenSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + typename VEC3::DATA_TYPE m_a; + +public: + Ber02EvenSynthesisFilter(MAP& m, VertexAttribute& p, typename VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorV travV(m_map); + for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) + { + VEC3 ev(0.0); + VEC3 fv(0.0); + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryEdgeOfVertex(d); + m_map.incCurrentLevel() ; + ev += (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]) * typename PFP::REAL(0.5); + m_map.decCurrentLevel() ; + ev *= 2 * m_a; + + m_position[db] += ev; + } + else + { + unsigned int count = 0; + Traversor2VF travVF(m_map,d); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + + Dart midEdgeV = m_map.phi1(dit); + ev += m_position[midEdgeV]; + fv += m_position[m_map.phi1(midEdgeV)]; + + m_map.decCurrentLevel() ; + ++count; + } + fv /= count; + fv *= 4 * m_a * m_a; + + ev /= count; + ev *= 4 * m_a; + m_position[d] += fv + ev; + } + } + + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(!m_map.isBoundaryEdge(d)) + { + unsigned int count = 0; + + VEC3 fe(0.0); + Traversor2EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(d); + m_position[midF] += fe; + m_map.decCurrentLevel() ; + } + } + } +} ; + +// s-scale(a) +template +class Ber02ScaleSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + typename VEC3::DATA_TYPE m_a; + +public: + Ber02ScaleSynthesisFilter(MAP& m, VertexAttribute& p, typename VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + m_position[d] *= m_a; + else + m_position[d] *= m_a * m_a; + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + if(!m_map.isBoundaryVertex(midE)) + m_position[midE] *= m_a ; + m_map.decCurrentLevel() ; + } + } +} ; + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif /* __2MR_FILTERS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/catmullClark.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/catmullClark.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dade3cf0038eb510f05a9c7e9dc52040edbd7a9e --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/catmullClark.cpp @@ -0,0 +1,488 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __2MR_CC_FILTER__ +#define __2MR_CC_FILTER__ + +#include +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/* + @article {springerlink:10.1007/s00371-006-0074-7, + author = {Wang, Huawei and Qin, Kaihuai and Tang, Kai}, + affiliation = {Hong Kong University of Science & Technology Department of Mechanical Engineering Hong Kong China}, + title = {Efficient wavelet construction with Catmull–Clark subdivision}, + journal = {The Visual Computer}, + publisher = {Springer Berlin / Heidelberg}, + issn = {0178-2789}, + keyword = {Computer Science}, + pages = {874-884}, + volume = {22}, + issue = {9}, + url = {http://dx.doi.org/10.1007/s00371-006-0074-7}, + note = {10.1007/s00371-006-0074-7}, + year = {2006} + } +*/ + +/********************************************************************************* + * Lazy Wavelet + *********************************************************************************/ +template +class CCInitEdgeSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + bool first; + +public: + CCInitEdgeSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p), first(true) + {} + + void operator() () + { + if(first) + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + m_map.incCurrentLevel() ; + m_position[m_map.phi1(d)] = VEC3(0.0); + m_map.decCurrentLevel() ; + } + first = false; + } + } +} ; + +template +class CCInitFaceSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + bool first; + +public: + CCInitFaceSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p), first(true) + {} + + void operator() () + { + if(first) + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + m_map.incCurrentLevel() ; + m_position[m_map.phi2(m_map.phi1(d))] = VEC3(0.0); // ou phi2(d) + m_map.decCurrentLevel() ; + } + first = false; + } + } +} ; + +template +class CCEdgeSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCEdgeSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 ei = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] += ei ; + m_map.decCurrentLevel() ; + } + } +} ; + +template +class CCFaceSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCFaceSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + float u = 1.0/2.0; + + VEC3 v(0.0); + VEC3 e(0.0); + unsigned int degree = 0; + + Dart dit = d; + do + { + v += m_position[dit]; + + m_map.incCurrentLevel() ; + e += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel() ; + + ++degree; + + dit = m_map.phi1(dit); + } + while(dit != d); + + v *= (1.0 - u) / degree; + e *= u / degree; + + m_map.incCurrentLevel() ; + m_position[m_map.phi2(m_map.phi1(d))] += v + e ; + m_map.decCurrentLevel() ; + } + + } +} ; + +template +class CCVertexSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCVertexSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 np1(0) ; + VEC3 np2(0) ; + unsigned int degree1 = 0 ; + unsigned int degree2 = 0 ; + Dart it = d ; + do + { + ++degree1 ; + Dart dd = m_map.phi1(it) ; + np1 += m_position[dd] ; + Dart end = m_map.phi_1(it) ; + dd = m_map.phi1(dd) ; + do + { + ++degree2 ; + np2 += m_position[dd] ; + dd = m_map.phi1(dd) ; + } while(dd != end) ; + it = m_map.alpha1(it) ; + } while(it != d) ; + + float beta = 3.0 / (2.0 * degree1) ; + float gamma = 1.0 / (4.0 * degree2) ; + np1 *= beta / degree1 ; + np2 *= gamma / degree2 ; + + VEC3 vp = m_position[d] ; + vp *= 1.0 - beta - gamma ; + + m_map.incCurrentLevel() ; + m_position[d] = np1 + np2 + vp ; + m_map.decCurrentLevel() ; + } + } +} ; + +template +class CCScalingSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCScalingSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + m_map.incCurrentLevel() ; + + VEC3 ei = m_position[m_map.phi1(d)]; + + VEC3 f = m_position[m_map.phi2(m_map.phi1(d))]; + f += m_position[m_map.phi_1(m_map.phi2(d))]; + f *= 1.0 / 2.0; + + ei += f; + ei *= 1.0 / 2.0; + + m_position[m_map.phi1(d)] = ei; + m_map.decCurrentLevel() ; + } + } +} ; + +template +class CCScalingAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCScalingAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + m_map.incCurrentLevel() ; + + VEC3 ei = m_position[m_map.phi1(d)]; + + VEC3 f = m_position[m_map.phi2(m_map.phi1(d))]; + f += m_position[m_map.phi_1(m_map.phi2(d))]; + f *= 1.0 / 2.0; + + ei *= 2.0; + ei -= f; + + m_position[m_map.phi1(d)] = ei; + m_map.decCurrentLevel() ; + } + } +} ; + +template +class CCVertexAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCVertexAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + m_map.incCurrentLevel() ; + VEC3 np1(0) ; + VEC3 np2(0) ; + unsigned int degree1 = 0 ; + unsigned int degree2 = 0 ; + Dart it = d ; + do + { + ++degree1 ; + Dart dd = m_map.phi1(it) ; + np1 += m_position[dd] ; + Dart end = m_map.phi_1(it) ; + dd = m_map.phi1(dd) ; + do + { + ++degree2 ; + np2 += m_position[dd] ; + dd = m_map.phi1(dd) ; + } while(dd != end) ; + it = m_map.alpha1(it) ; + } while(it != d) ; + + float beta = 3.0 / (2.0 * degree1) ; + float gamma = 1.0 / (4.0 * degree2) ; + np1 *= beta / degree1 ; + np2 *= gamma / degree2 ; + + VEC3 vd = m_position[d] ; + + m_map.decCurrentLevel() ; + + m_position[d] = vd - np1 - np2; + m_position[d] /= 1.0 - beta - gamma ; + + } + } +} ; + +template +class CCFaceAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCFaceAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + + float u = 1.0/2.0; + + VEC3 v(0.0); + VEC3 e(0.0); + unsigned int degree = 0; + + Dart dit = d; + do + { + v += m_position[dit]; + + m_map.incCurrentLevel() ; + e += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel() ; + + ++degree; + + dit = m_map.phi1(dit); + } + while(dit != d); + + v *= (1.0 - u) / degree; + e *= u / degree; + + m_map.incCurrentLevel() ; + m_position[m_map.phi2(m_map.phi1(d))] = m_position[m_map.phi2(m_map.phi1(d))] - v - e ; + m_map.decCurrentLevel() ; + } + } +} ; + +template +class CCEdgeAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCEdgeAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 ei = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] -= ei ; + m_map.decCurrentLevel() ; + } + } +} ; + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/lerp.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/lerp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a9b76977673f88ed98c145ac8bd8a64a5586bf4 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/lerp.cpp @@ -0,0 +1,306 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __2MR_LERP_FILTER__ +#define __2MR_LERP_FILTER__ + +#include +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/********************************************************************************* + * SYNTHESIS FILTERS + *********************************************************************************/ + +// Quad refinement +template +class LerpQuadOddSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpQuadOddSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + VEC3 vf(0.0); + VEC3 ef(0.0); + + unsigned int count = 0; + Traversor2FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + + ef /= count; + ef *= 2.0; + + vf /= count; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += vf + ef ; + m_map.decCurrentLevel() ; + break; + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] += ve ; + m_map.decCurrentLevel() ; + } + } +}; + +// Tri/quad refinement +template +class LerpTriQuadOddSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpTriQuadOddSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + if(m_map.faceDegree(d) != 3) + { + VEC3 vf(0.0); + VEC3 ef(0.0); + + unsigned int count = 0; + Traversor2FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 2.0; + + vf /= count; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += vf + ef ; + m_map.decCurrentLevel() ; + } + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] += ve ; + m_map.decCurrentLevel() ; + } + } +}; + +/********************************************************************************* + * ANALYSIS FILTERS + *********************************************************************************/ + +// Quad refinement +template +class LerpQuadOddAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpQuadOddAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] -= ve ; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + VEC3 vf(0.0); + VEC3 ef(0.0); + + unsigned int count = 0; + Traversor2FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 2.0; + + vf /= count; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= vf + ef ; + m_map.decCurrentLevel() ; + } + } +}; + +// Tri/quad refinement +template +class LerpTriQuadOddAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpTriQuadOddAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] -= ve ; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + if(m_map.faceDegree(d) != 3) + { + VEC3 vf(0.0); + VEC3 ef(0.0); + + unsigned int count = 0; + Traversor2FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 2.0; + + vf /= count; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= vf + ef ; + m_map.decCurrentLevel() ; + } + } + } +}; + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/loop.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/loop.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9fbdea93ff30fa77adba52043e7cd5818f8cf1da --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/loop.cpp @@ -0,0 +1,292 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __2MR_LOOP_FILTER__ +#define __2MR_LOOP_FILTER__ + +#include +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + + +/********************************************************************************* + * LOOP BASIC FUNCTIONS + *********************************************************************************/ + +template +typename PFP::VEC3 loopOddVertex( + typename PFP::MAP& map, + const VertexAttribute& position, + Dart d1) +{ + Dart d2 = map.phi2(d1) ; + Dart d3 = map.phi_1(d1) ; + Dart d4 = map.phi_1(d2) ; + + typename PFP::VEC3 p1 = position[d1] ; + typename PFP::VEC3 p2 = position[d2] ; + typename PFP::VEC3 p3 = position[d3] ; + typename PFP::VEC3 p4 = position[d4] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 8.0 ; + p4 *= 1.0 / 8.0 ; + + return p1 + p2 + p3 + p4 ; +} + +template +typename PFP::VEC3 loopEvenVertex( + typename PFP::MAP& map, + const VertexAttribute& position, + Dart d) +{ + map.incCurrentLevel() ; + + typename PFP::VEC3 np(0) ; + unsigned int degree = 0 ; + Traversor2VVaE trav(map, d) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + np += position[it] ; + } + + map.decCurrentLevel() ; + + float mu = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; + mu = (5.0/8.0 - (mu * mu)) / degree ; + np *= 8.0/5.0 * mu ; + + return np ; +} + +/********************************************************************************* + * ANALYSIS FILTERS + *********************************************************************************/ + +template +class LoopOddAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopOddAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 p = loopOddVertex(m_map, m_position, d) ; + + m_map.incCurrentLevel() ; + + Dart oddV = m_map.phi2(d) ; + m_position[oddV] -= p ; + + m_map.decCurrentLevel() ; + } + } +} ; + +template +class LoopEvenAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position; + +public: + LoopEvenAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 p = loopEvenVertex(m_map, m_position, d) ; + m_position[d] -= p ; + } + } +} ; + +template +class LoopNormalisationAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position; + +public: + LoopNormalisationAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + unsigned int degree = m_map.vertexDegree(d) ; + float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; + n = 8.0/5.0 * (n * n) ; + + m_position[d] /= n ; + } + } +} ; + +/********************************************************************************* + * SYNTHESIS FILTERS + *********************************************************************************/ + +template +class LoopOddSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position; + +public: + LoopOddSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 p = loopOddVertex(m_map, m_position, d) ; + + m_map.incCurrentLevel() ; + + Dart oddV = m_map.phi2(d) ; + m_position[oddV] += p ; + + m_map.decCurrentLevel() ; + } + } +} ; + +template +class LoopEvenSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopEvenSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 p = loopEvenVertex(m_map, m_position, d) ; + m_position[d] += p ; + } + } +} ; + +template +class LoopNormalisationSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopNormalisationSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + unsigned int degree = m_map.vertexDegree(d) ; + float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; + n = 8.0/5.0 * (n * n) ; + + m_position[d] *= n ; + } + } +} ; + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/sqrt2.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/sqrt2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28cd7577ad262ab6633a943e0aa7cb5c80a53736 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/sqrt2.cpp @@ -0,0 +1,102 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __2MR_SQRT2_FILTER__ +#define __2MR_SQRT2_FILTER__ + +#include +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/********************************************************************************* + * SYNTHESIS FILTERS + *********************************************************************************/ + +template +class Sqrt2FaceSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + Sqrt2FaceSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 p = Geometry::faceCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + + Dart midF = m_map.phi2(d); + if(m_map.isBoundaryEdge(d)) + { + midF = m_map.phi1(m_map.phi2(m_map.phi_1(d))); + } + + m_position[midF] = p ; + + m_map.decCurrentLevel() ; + } + } +} ; + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/sqrt3.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/sqrt3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3a5a5792ca37af09fba88aca7994721bcf86aabd --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Filters/sqrt3.cpp @@ -0,0 +1,354 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __2MR_SQRT3_FILTER__ +#define __2MR_SQRT3_FILTER__ + +#include +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ +/* + @article{10.1109/TVCG.2007.1031, + author = {Huawei Wang and Kaihuai Qin and Hanqiu Sun}, + title = {$\sqrt{3}$-Subdivision-Based Biorthogonal Wavelets}, + journal ={IEEE Transactions on Visualization and Computer Graphics}, + volume = {13}, + issn = {1077-2626}, + year = {2007}, + pages = {914-925}, + doi = {http://doi.ieeecomputersociety.org/10.1109/TVCG.2007.1031}, + publisher = {IEEE Computer Society}, + address = {Los Alamitos, CA, USA}, + } +*/ + +inline double omega12(unsigned int n) +{ + switch(n) + { + case 3: return -0.138438 ; + case 4: return -0.193032 ; + case 5: return -0.216933 ; + case 6: return -0.229537 ; + case 7: return -0.237236 ; + case 8: return -0.242453 ; + case 9: return -0.246257 ; + case 10: return -0.249180 ; + case 15: return -0.257616 ; + case 20: return -0.261843 ; + default: return 0.0; + //find formulation ? + } +} + +inline double omega0(unsigned int n) +{ + switch(n) + { + case 3: return -0.684601 ; + case 4: return -0.403537 ; + case 5: return -0.288813 ; + case 6: return -0.229537 ; + case 7: return -0.193385 ; + case 8: return -0.168740 ; + case 9: return -0.150618 ; + case 10: return -0.136570 ; + case 15: return -0.095201 ; + case 20: return -0.073924 ; + default: return 0.0; + //find formulation ? + } +} + +/********************************************************************************* + * Lazy Wavelet + *********************************************************************************/ + +template +class Sqrt3FaceSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + Sqrt3FaceSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + Dart d1 = m_map.phi1(d) ; + Dart d2 = m_map.phi1(d1) ; + + VEC3 p0 = m_position[d] ; + VEC3 p1 = m_position[d1] ; + VEC3 p2 = m_position[d2] ; + + p0 *= 1.0 / 3.0 ; + p1 *= 1.0 / 3.0 ; + p2 *= 1.0 / 3.0 ; + + if(m_map.isFaceIncidentToBoundary(d)) + { + Dart df = m_map.findBoundaryEdgeOfFace(d); + m_map.incCurrentLevel() ; + m_position[m_map.phi_1(m_map.phi2(df))] += p0 + p1 + p2 ; + } + else + { + m_map.incCurrentLevel() ; + m_position[m_map.phi2(d)] += p0 + p1 + p2 ; + } + + m_map.decCurrentLevel() ; + } + } +} ; + +template +class Sqrt3VertexSynthesisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + Sqrt3VertexSynthesisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart df = m_map.findBoundaryEdgeOfVertex(d); + + if((m_map.getCurrentLevel()%2 == 0)) + { + VEC3 np(0) ; + VEC3 nl(0) ; + VEC3 nr(0) ; + + VEC3 pi = m_position[df]; + VEC3 pi_1 = m_position[m_map.phi_1(df)]; + VEC3 pi1 = m_position[m_map.phi1(df)]; + + np += pi_1 * 4 + pi * 19 + pi1 * 4; + np /= 27; + + nl += pi_1 * 10 + pi * 16 + pi1; + nl /= 27; + + nr += pi_1 + pi * 16 + pi1 * 10; + nr /= 27; + + m_map.incCurrentLevel() ; + + m_position[df] = np; + m_position[m_map.phi_1(df)] = nl; + m_position[m_map.phi1(df)] = nr; + + m_map.decCurrentLevel() ; + } + } + else + { + VEC3 nf(0) ; + unsigned int degree = 0 ; + + m_map.incCurrentLevel() ; + Dart df = m_map.phi2(m_map.phi1(d)); + + Traversor2VVaE trav(m_map, df) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + nf += m_position[it] ; + + } + m_map.decCurrentLevel() ; + + float alpha = 1.0/9.0 * ( 4.0 - 2.0 * cos(2.0 * M_PI / degree)); + float teta = 1 - (3 * alpha) / 2; + float sigma = (3 * alpha) / (2 * degree); + + nf *= sigma; + + VEC3 vp = m_position[d] ; + vp *= teta ; + + m_map.incCurrentLevel() ; + + m_position[df] = vp + nf; + + m_map.decCurrentLevel() ; + } + } + } +} ; + +template +class Sqrt3VertexAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + Sqrt3VertexAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + VEC3 nf(0) ; + unsigned int degree = 0 ; + + m_map.incCurrentLevel() ; + Dart df = m_map.phi2(m_map.phi1(d)); + + Traversor2VVaE trav(m_map, df) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + nf += m_position[it] ; + + } + m_map.decCurrentLevel() ; + + float alpha = 1.0/9.0 * ( 4.0 - 2.0 * cos(2.0 * M_PI / degree)); + float teta = 1 - (3 * alpha) / 2; + float sigma = (3 * alpha) / (2 * degree); + + nf *= sigma; + + VEC3 vp = m_position[d] ; + vp -= nf ; + + m_map.incCurrentLevel() ; + + m_position[df] = vp * (1.0 / teta) ; + + m_map.decCurrentLevel() ; + + } + } +} ; + +template +class Sqrt3FaceAnalysisFilter : public Algo::MR::Filter +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + MAP& m_map ; + VertexAttribute& m_position ; + +public: + Sqrt3FaceAnalysisFilter(MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + Dart d1 = m_map.phi1(d) ; + Dart d2 = m_map.phi1(d1) ; + + VEC3 p0 = m_position[d] ; + VEC3 p1 = m_position[d1] ; + VEC3 p2 = m_position[d2] ; + + p0 *= 1.0 / 3.0 ; + p1 *= 1.0 / 3.0 ; + p2 *= 1.0 / 3.0 ; + + m_map.incCurrentLevel() ; + + m_position[m_map.phi2(d)] -= p0 + p1 + p2 ; + + m_map.decCurrentLevel() ; + + } + } +} ; + +/********************************************************************************* + * Three-Point Orthogonalization + *********************************************************************************/ + + +/********************************************************************************* + * Six-Point Orthogonalization + *********************************************************************************/ + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/catmullClark.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/catmullClark.cpp new file mode 100644 index 0000000000000000000000000000000000000000..73235ba4da34ec077c5296059c34fdf5c22e92b2 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/catmullClark.cpp @@ -0,0 +1,189 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MR_CC_MASK__ +#define __MR_CC_MASK__ + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Masks +{ + +template +class CCVertexVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCVertexVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + m_map.decCurrentLevel() ; + + typename PFP::VEC3 np1(0) ; + typename PFP::VEC3 np2(0) ; + unsigned int degree1 = 0 ; + unsigned int degree2 = 0 ; + Dart it = d ; + do + { + ++degree1 ; + Dart dd = m_map.phi1(it) ; + np1 += m_position[dd] ; + Dart end = m_map.phi_1(it) ; + dd = m_map.phi1(dd) ; + do + { + ++degree2 ; + np2 += m_position[dd] ; + dd = m_map.phi1(dd) ; + } while(dd != end) ; + it = m_map.phi2(m_map.phi_1(it)) ; + } while(it != d) ; + + float beta = 3.0 / (2.0 * degree1) ; + float gamma = 1.0 / (4.0 * degree2) ; + np1 *= beta / degree1 ; + np2 *= gamma / degree2 ; + + typename PFP::VEC3 vp = m_position[d] ; + vp *= 1.0 - beta - gamma ; + + m_map.incCurrentLevel() ; + + m_position[d] = np1 + np2 + vp ; + + return false ; + } +} ; + +template +class CCEdgeVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCEdgeVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart d1 = m_map.phi2(d) ; + + m_map.decCurrentLevel() ; + + Dart d2 = m_map.phi2(d1) ; + Dart d3 = m_map.phi_1(d1) ; + Dart d4 = m_map.phi_1(d2) ; + Dart d5 = m_map.phi1(m_map.phi1(d1)) ; + Dart d6 = m_map.phi1(m_map.phi1(d2)) ; + + typename PFP::VEC3 p1 = m_position[d1] ; + typename PFP::VEC3 p2 = m_position[d2] ; + typename PFP::VEC3 p3 = m_position[d3] ; + typename PFP::VEC3 p4 = m_position[d4] ; + typename PFP::VEC3 p5 = m_position[d5] ; + typename PFP::VEC3 p6 = m_position[d6] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 16.0 ; + p4 *= 1.0 / 16.0 ; + p5 *= 1.0 / 16.0 ; + p6 *= 1.0 / 16.0 ; + + m_map.incCurrentLevel() ; + + m_position[d] = p1 + p2 + p3 + p4 + p5 + p6 ; + + return false ; + } +} ; + +template +class CCFaceVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + CCFaceVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart df = m_map.phi1(m_map.phi1(d)) ; + + m_map.decCurrentLevel() ; + + typename PFP::VEC3 p(0) ; + unsigned int degree = 0 ; + Traversor2FV trav(m_map, df) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + p += m_position[it] ; + } + p /= degree ; + + m_map.incCurrentLevel() ; + + m_position[d] = p ; + + return false ; + } +} ; + + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/lerp.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/lerp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4afeb97fd5d47b25e54e30dcbdbe17ce94002a94 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/lerp.cpp @@ -0,0 +1,145 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MR_LERP_MASK__ +#define __MR_LERP_MASK__ + +#include +//#include "Algo/Decimation/decimation.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Masks +{ + +template +class LerpVertexVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpVertexVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + std::cout << "dartIndex(d) = " << m_map.dartIndex(d) << std::endl; + m_map.decCurrentLevel() ; + std::cout << "dartIndex(d) = " << m_map.dartIndex(d) << std::endl; + typename PFP::VEC3 p = m_position[d] ; + std::cout << "p = " << p << std::endl; + m_map.incCurrentLevel() ; + + m_position[d] = p ; + + return false ; + } +} ; + +template +class LerpEdgeVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpEdgeVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart d1 = m_map.phi2(d) ; + + m_map.decCurrentLevel() ; + Dart d2 = m_map.phi2(d1) ; + typename PFP::VEC3 p = (m_position[d1] + m_position[d2]) / 2.0 ; + m_map.incCurrentLevel() ; + + m_position[d] = p ; + + return false ; + } +} ; + +template +class LerpFaceVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpFaceVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart df = m_map.phi1(m_map.phi1(d)) ; + //Dart df = m_map.phi1(d) ; + + m_map.decCurrentLevel() ; + + typename PFP::VEC3 p(0) ; + unsigned int degree = 0 ; + Traversor2FV trav(m_map, df) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + p += m_position[it] ; + } + p /= degree ; + + m_map.incCurrentLevel() ; + + m_position[d] = p ; + + return false ; + } +} ; + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/loop.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/loop.cpp new file mode 100644 index 0000000000000000000000000000000000000000..68f431e5e72fa974181d0da3bfa4f858bf8ee021 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/loop.cpp @@ -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 * +* * +*******************************************************************************/ + +#ifndef __MR_LOOP_MASK__ +#define __MR_LOOP_MASK__ + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Masks +{ + +template +class LoopVertexVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopVertexVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + m_map.decCurrentLevel() ; + + typename PFP::VEC3 np(0) ; + unsigned int degree = 0 ; + Traversor2VVaE trav(m_map, d) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + np += m_position[it] ; + } + float tmp = 3.0 + 2.0 * cos(2.0 * M_PI / degree) ; + float beta = (5.0 / 8.0) - ( tmp * tmp / 64.0 ) ; + np *= beta / degree ; + + typename PFP::VEC3 vp = m_position[d] ; + vp *= 1.0 - beta ; + + m_map.incCurrentLevel() ; + + m_position[d] = np + vp ; + + return false ; + } +} ; + +template +class LoopEdgeVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopEdgeVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart d1 = m_map.phi2(d) ; + + m_map.decCurrentLevel() ; + + Dart d2 = m_map.phi2(d1) ; + Dart d3 = m_map.phi_1(d1) ; + Dart d4 = m_map.phi_1(d2) ; + + typename PFP::VEC3 p1 = m_position[d1] ; + typename PFP::VEC3 p2 = m_position[d2] ; + typename PFP::VEC3 p3 = m_position[d3] ; + typename PFP::VEC3 p4 = m_position[d4] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 8.0 ; + p4 *= 1.0 / 8.0 ; + + m_map.incCurrentLevel() ; + + m_position[d] = p1 + p2 + p3 + p4 ; + + return false ; + } +} ; + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/sqrt3.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/sqrt3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a0f384ee7ebca6d315a454f0043011f2e9fa7203 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/Masks/sqrt3.cpp @@ -0,0 +1,168 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MR_SQRT3_MASK__ +#define __MR_SQRT3_MASK__ + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Masks +{ + + +template +class Sqrt3VertexVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + Sqrt3VertexVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + if(m_map.isBoundaryVertex(d)) + { + Dart df = m_map.findBoundaryEdgeOfVertex(d); + + if(m_map.getDartLevel(df) < m_map.getCurrentLevel()) + { + if((m_map.getCurrentLevel()%2 == 0)) + { + m_map.decCurrentLevel() ; + + typename PFP::VEC3 np(0) ; + typename PFP::VEC3 nl(0) ; + typename PFP::VEC3 nr(0) ; + + typename PFP::VEC3 pi = m_position[df]; + typename PFP::VEC3 pi_1 = m_position[m_map.phi_1(df)]; + typename PFP::VEC3 pi1 = m_position[m_map.phi1(df)]; + + np += pi_1 * 4 + pi * 19 + pi1 * 4; + np /= 27; + + nl += pi_1 * 10 + pi * 16 + pi1; + nl /= 27; + + nr += pi_1 + pi * 16 + pi1 * 10; + nr /= 27; + + m_map.incCurrentLevel() ; + + m_position[df] = np; + m_position[m_map.phi_1(df)] = nl; + m_position[m_map.phi1(df)] = nr; + + return false; + } + } + } + + m_map.decCurrentLevel() ; + + typename PFP::VEC3 np(0) ; + unsigned int degree = 0 ; + Traversor2VVaE trav(m_map, d) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + np += m_position[it] ; + } + float alpha = 1.0/9.0 * ( 4.0 - 2.0 * cos(2.0 * M_PI / degree)); + np *= alpha / degree ; + + typename PFP::VEC3 vp = m_position[d] ; + vp *= 1.0 - alpha ; + + m_map.incCurrentLevel() ; + + m_position[d] = np + vp ; + + return false ; + } +} ; + +template +class Sqrt3FaceVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + Sqrt3FaceVertexFunctor(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart d0 = m_map.phi1(d) ; + + m_map.decCurrentLevel() ; + + Dart d1 = m_map.phi1(d0) ; + Dart d2 = m_map.phi1(d1) ; + + typename PFP::VEC3 p0 = m_position[d0] ; + typename PFP::VEC3 p1 = m_position[d1] ; + typename PFP::VEC3 p2 = m_position[d2] ; + + p0 *= 1.0 / 3.0 ; + p1 *= 1.0 / 3.0 ; + p2 *= 1.0 / 3.0 ; + + m_map.incCurrentLevel() ; + + m_position[d] = p0 + p1 + p2; + + return false ; + } +} ; + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/lerpAttributes.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/lerpAttributes.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a680d263336d7c5dfb889d914bf54e6d088d84a --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/lerpAttributes.cpp @@ -0,0 +1,251 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MR_LERPATTRIB_FILTER__ +#define __MR_LERPATTRIB_FILTER__ + +#include +#include "Algo/Multiresolution/filter.h" +#include "Topology/generic/functor.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +/********************************************************************************* + * SYNTHESIS FILTERS + *********************************************************************************/ + +template +class vertexFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + vertexFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV tE(m_map); + for(Dart d = tE.begin() ; d != tE.end() ; d = tE.next()) + { + Dart dit = d; + Dart dres = d; + bool found = false; + do + { + if((m_map.getDartLevel(dit) == (m_map.getCurrentLevel()-1)) && (m_map.getDartLevel(m_map.phi2(dit)) == m_map.getCurrentLevel())) + { + dres = dit; + found = true; + } + + dit = m_map.phi2(m_map.phi_1(dit)); + + }while(!found && dit!=d); + +// m_map.template setOrbitEmbedding(dres, m_map.template getEmbedding(dres)); + Algo::Topo::setOrbitEmbedding(m_map,template getEmbedding(dres)); + } + +// SelectorEdgeLevel ml(m_map, m_map.getCurrentLevel()); +// +// TraversorV tV(m_map, ml, true); +// for(Dart d = tV.begin() ; d != tV.end() ; d = tV.next()) +// { +// m_map.template embedOrbit(d, m_map.template getEmbedding(d)); +// } + } +}; + +template +class LerpVertexSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_attrib ; + +public: + LerpVertexSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_attrib(p) + {} + + void operator() () + { + if(m_attrib.isValid()) + { + TraversorV tE(m_map); + for(Dart d = tE.begin() ; d != tE.end() ; d = tE.next()) + { + Dart dit = d; + Dart dres = d; + bool found = false; + //1ere boucle est-ce qu'il y a un brin de niveau i + + do + { + if((m_map.getDartLevel(dit) < m_map.getCurrentLevel()) && (m_map.getDartLevel(m_map.phi2(dit)) == m_map.getCurrentLevel())) + { + dres = dit; + found = true; + } + + dit = m_map.phi2(m_map.phi_1(dit)); + + }while(!found && dit!=d); + + + if(found) + { + m_map.decCurrentLevel(); + typename PFP::VEC3 c = m_attrib[dres]; + m_map.incCurrentLevel(); + + m_attrib[dres] = c; + } + } + } + } +} ; + + +template +class LerpVertexAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_attrib ; + +public: + LerpVertexAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_attrib(p) + {} + + void operator() () + { + if(m_attrib.isValid()) + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + Dart dit = d; + Dart dres = d; + bool found = false; + + do + { + + m_map.incCurrentLevel(); + Dart d2_1 = m_map.phi2(dit); + m_map.decCurrentLevel(); + + if((m_map.getDartLevel(dit) == m_map.getCurrentLevel()) && m_map.phi2(dit) != d2_1) + { + dres = dit; + found = true; + } + + dit = m_map.phi2(m_map.phi_1(dit)); + + }while(!found && dit!=d); + + if(found) + { + m_map.incCurrentLevel(); + + typename PFP::VEC3 c1 = m_attrib[m_map.phi2(m_map.phi_1(dres))]; + typename PFP::VEC3 c2 = m_attrib[m_map.phi1(m_map.phi2(m_map.phi_1(m_map.phi2(dres))))]; + m_map.decCurrentLevel(); + + m_attrib[dres] = c1 + c2; + m_attrib[dres] /= 2; + } + } + } + } +} ; + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#endif + +// Dart dit = d; +// Dart ds = d; +// bool found = false; +// //1ere boucle est-ce qu'il y a un brin de niveau i +// do +// { +// if((m_map.getDartLevel(dit) < m_map.getCurrentLevel()) && (m_map.getDartLevel(m_map.phi2(dit)) == m_map.getCurrentLevel())) +// { +// ds = dit; +// found = true; +// } +// +// dit = m_map.phi2(m_map.phi_1(dit)); +// +// }while(!found && dit!=d); +// +// +// if(found) +// { +// bool found2 = false; +// dit = d; +// Dart dres = dit; +// //2e boucle chercher un brin de niveau i-1 +// do +// { +// if(m_map.getDartLevel(dit) < (m_map.getCurrentLevel())) +// { +// if(m_map.getDartLevel(dit) > m_map.getDartLevel(dres)) +// dres = dit; +// +// //found2 = true; +// } +// +// dit = m_map.phi2(m_map.phi_1(dit)); +// +// }while(dit!=d); +// +// //if(!found2) +// // std::cout << "non trouve......." << std::endl; +// +// //if(dres != d) +// m_attrib[ds] = m_attrib[dres]; +// } + diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_DualRegular.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_DualRegular.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c66fcad3af10ab2e743d51475ecb91be96dec370 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_DualRegular.cpp @@ -0,0 +1,99 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP2MR_DUAL_REGULAR__ +#define __MAP2MR_DUAL_REGULAR__ + +#include "Topology/map/embeddedMap2.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" + +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Dual +{ + +namespace Regular +{ + +template +class Map2MR: public MapManipulator +{ +public: + typedef typename PFP::MAP MAP ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + std::vector synthesisFilters ; + std::vector analysisFilters ; + +public: + Map2MR(MAP& map); + + virtual MapManipulator* create(GenericMap *gm); + + ~Map2MR(); + + //if true : tri and quad else quad + void addNewLevel(bool embedNewVertices = true) ; + + void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } + + void clearSynthesisFilters() { synthesisFilters.clear() ; } + void clearAnalysisFilters() { analysisFilters.clear() ; } + + void analysis() ; + void synthesis() ; +} ; + +} // namespace Regular + +} // namespace Dual + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/Map2MR/map2MR_DualRegular.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PM.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af1a4b5b643b77a9cbb4277843e855dc516646ab --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PM.cpp @@ -0,0 +1,126 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP2MR_PM__ +#define __MAP2MR_PM__ + +#include "Topology/map/embeddedMap2.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" + +#include "Container/attributeContainer.h" + +#include "Algo/Decimation/selector.h" +#include "Algo/Decimation/edgeSelector.h" +#include "Algo/Decimation/geometryApproximator.h" +#include "Algo/Decimation/geometryPredictor.h" +#include "Algo/Decimation/lightfieldApproximator.h" + +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +template +class Map2MR_PM +{ +public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + +private: + MAP& m_map ; + VertexAttribute& m_position; + + bool m_initOk ; + + Algo::Surface::Decimation::EdgeSelector* m_selector ; + std::vector*> m_approximators ; + std::vector*> m_predictors ; + + Algo::Surface::Decimation::Approximator* m_positionApproximator ; + + std::vector synthesisFilters ; + std::vector analysisFilters ; + +public: + Map2MR_PM(MAP& map, VertexAttribute& position); + + ~Map2MR_PM(); + + //create a progressive mesh (a coarser level) + void createPM(Algo::Surface::Decimation::SelectorType s, Algo::Surface::Decimation::ApproximatorType a) ; + + void addNewLevel(unsigned int percentWantedVertices); + + void collapseEdge(Dart d); + + //coarsen the mesh -> analysis + void coarsen() ; + + //refine the mesh -> synthesis + void refine() ; + + bool initOk() { return m_initOk; } + + void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } + + void clearSynthesisFilters() { synthesisFilters.clear() ; } + void clearAnalysisFilters() { analysisFilters.clear() ; } + + /** + * Given the vertex of d in the current level, + * return a dart of from the vertex of the current level + */ + Dart vertexOrigin(Dart d) ; + +// /** +// * Return the level of the vertex of d in the current level map +// */ +// unsigned int vertexLevel(Dart d); +} ; + +} // namespace Multiresolution + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + + +#include "Algo/Multiresolution/Map2MR/map2MR_PM.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..003503baa433d143d3cd9172984070bd58fa15bc --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.cpp @@ -0,0 +1,193 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP2MR_PRIMAL_ADAPT__ +#define __MAP2MR_PRIMAL_ADAPT__ + +#include "Topology/map/embeddedMap2.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Adaptive +{ + +template +class Map2MR +{ + +public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + FunctorType* vertexVertexFunctor ; + FunctorType* edgeVertexFunctor ; + FunctorType* faceVertexFunctor ; + +public: + Map2MR(MAP& map) ; + + /*************************************************** + * CELLS INFORMATION * + ***************************************************/ + + /** + * Return the level of the edge of d in the current level map + */ + unsigned int edgeLevel(Dart d) ; + + /** + * Return the level of the face of d in the current level map + */ + unsigned int faceLevel(Dart d) ; + + /** + * Given the face of d in the current level map, + * return a level 0 dart of its origin face + */ + Dart faceOrigin(Dart d) ; + + /** + * Return the oldest dart of the face of d in the current level map + */ + Dart faceOldestDart(Dart d) ; + + /** + * Return true if the edge of d in the current level map + * has already been subdivided to the next level + */ + bool edgeIsSubdivided(Dart d) ; + + /** + * Return true if the edge of d in the current level map + * is subdivided to the next level, + * none of its resulting edges is in turn subdivided to the next level + * and the middle vertex is of degree 2 + */ + bool edgeCanBeCoarsened(Dart d) ; + + /** + * Return true if the face of d in the current level map + * has already been subdivided to the next level + */ + bool faceIsSubdivided(Dart d) ; + + /** + * Return true if the face of d in the current level map + * is subdivided to the next level + * and none of its resulting faces is in turn subdivided to the next level + */ + bool faceIsSubdividedOnce(Dart d) ; + + +protected: + /** + * + */ + Dart cutEdge(Dart d) ; + + /** + * + */ + void splitFace(Dart d, Dart e) ; + + /** + * + */ + void flipBackEdge(Dart d); + + /*************************************************** + * SUBDIVISION * + ***************************************************/ + + /** + * subdivide the edge of d to the next level + */ + void subdivideEdge(Dart d) ; + + /** + * coarsen the edge of d from the next level + */ + void coarsenEdge(Dart d) ; + +public: + /** + * subdivide the face of d to the next level + */ + unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true); + + /** + * + */ + unsigned int subdivideFaceSqrt3(Dart d); + + /** + * coarsen the face of d from the next level + */ + void coarsenFace(Dart d) ; + + /** + * vertices attributes management + */ + void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; } + void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; } + void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } +} ; + +} // namespace Adaptive + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/Map2MR/map2MR_PrimalAdapt.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.cpp b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2937003f3583a588788bb521056316bf5a933e38 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.cpp @@ -0,0 +1,105 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP2MR_PRIMAL_REGULAR__ +#define __MAP2MR_PRIMAL_REGULAR__ + +#include "Topology/map/embeddedMap2.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" + +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Regular +{ + +template +class Map2MR +{ +public: + typedef typename PFP::MAP MAP ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + std::vector synthesisFilters ; + std::vector analysisFilters ; + +public: + Map2MR(MAP& map); + + ~Map2MR(); + + //if true : tri and quad else quad + void addNewLevel(bool triQuad = true, bool embedNewVertices = false) ; + + void addNewLevelSqrt3(); + + void addNewLevelSqrt2(); + + void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } + + void clearSynthesisFilters() { synthesisFilters.clear() ; } + void clearAnalysisFilters() { analysisFilters.clear() ; } + + void analysis() ; + void synthesis() ; + + void addLevelFront(); + + void import(Algo::Surface::Import::QuadTree& qt); +} ; + +} // namespace Regular + +} // namespace Primal + +} // namespace MR + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Dual/dooSabin.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Dual/dooSabin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b3c09a3d1807ac65c9df1a525c4712e7bff7305 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Dual/dooSabin.cpp @@ -0,0 +1,148 @@ +/******************************************************************************* + * 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 * + * * + *******************************************************************************/ + +#ifndef __MR_DOOSABIN_MASK__ +#define __MR_DOOSABIN_MASK__ + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Dual +{ + +namespace Filters +{ + +template +class DooSabinVertexSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + DooSabinVertexSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { +// TraversorV tv(m_map); +// for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next()) +// { +// if(m_map.isBoundaryVertex(d)) +// { +// Dart db = m_map.findBoundaryFaceOfVertex(d); +// +// typename PFP::VEC3 p(0.0); +// +// unsigned int N = m_map.faceDegree(db); +// typename PFP::REAL K0 = float(N+5)/float(4*N);//(1.0 / 4.0) + (5.0 / 4.0) * double(N); +// p += K0 * m_position[db]; +// unsigned int j = 1; +// Dart tmp = m_map.phi1(db); +// do +// { +// typename PFP::REAL Kj = (3.0 + 2.0 * cos(2.0 * double(j) * M_PI / double(N))) / (4.0 * N); +// p += Kj * m_position[tmp]; +// tmp = m_map.phi1(tmp); +// ++j; +// }while(tmp != db); +// +// m_map.incCurrentLevel(); +// +// m_position[db] = p; +// +// m_map.decCurrentLevel(); +// +// } +// else +// { +// Traversor3VW tvw(m_map,d); +// for(Dart dit = tvw.begin() ; dit != tvw.end() ; dit = tvw.next()) +// { +// typename PFP::VEC3 p(0.0); +// unsigned int count = 0; +// +// Dart ditface = dit; +// do +// { +// typename PFP::VEC3 tmpP(0.0); +// unsigned int N = m_map.faceDegree(ditface); +// typename PFP::REAL K0 = float(N+5)/float(4*N);//(1.0 / 4.0) + (5.0 / 4.0) * double(N); +// tmpP += K0 * m_position[ditface]; +// unsigned int j = 1; +// Dart tmp = m_map.phi1(ditface); +// do +// { +// typename PFP::REAL Kj = (3.0 + 2.0 * cos(2.0 * double(j) * M_PI / double(N))) / (4.0 * N); +// tmpP += Kj * m_position[tmp]; +// tmp = m_map.phi1(tmp); +// ++j; +// }while(tmp != ditface); +// +// p += tmpP; +// ++count; +// ditface = m_map.phi2(m_map.phi_1(ditface)); +// } +// while(ditface != dit); +// +// p /= count; +// +// m_map.incCurrentLevel(); +// +// m_position[dit] = p; +// +// m_map.decCurrentLevel(); +// } +// } +// } + } +} ; + + +} // namespace Masks + +} // namespace Dual + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#endif + diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/bertram.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/bertram.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86b5fbc4a506f10c7ab79d06b5dc7f06e0d0b6b1 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/bertram.cpp @@ -0,0 +1,805 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_BERTRAM_FILTER__ +#define __3MR_BERTRAM_FILTER__ + +#include +#include "Algo/Geometry/centroid.h" +#include "Algo/Modelisation/tetrahedralization.h" +#include "Algo/Multiresolution/filter.h" +#include "Topology/generic/traversor/traversor2_closed.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/******************************************************************************* + * Without features preserving + *******************************************************************************/ + +// +// Analysis +// + +//w-lift(a) +template +class Ber02OddAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02OddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] -= ve; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + typename PFP::VEC3 vf(0.0); + typename PFP::VEC3 ef(0.0); + + unsigned int count = 0; + Traversor3FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 4.0 * m_a; + + vf /= count; + vf *= 4.0 * m_a * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= vf + ef ; + m_map.decCurrentLevel() ; + } + + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + vc *= 8 * m_a * m_a * m_a; + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 12 * m_a * m_a; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 6 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] -= vc + ec + fc; + m_map.decCurrentLevel() ; + } + } +} ; + +// s-lift(a) +template +class Ber02EvenAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02EvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + if(!m_map.isBoundaryFace(d)) + { + unsigned int count = 0; + + typename PFP::VEC3 cf(0.0); + Traversor3FW travFW(m_map, d); + for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) + { + m_map.incCurrentLevel(); + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cf += m_position[midV]; + m_map.decCurrentLevel(); + ++count; + } + cf /= count; + cf *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= cf; + m_map.decCurrentLevel() ; + } + } + + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 fe(0.0); + +// unsigned int count = 2; +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(m_map.phi1(db)); +// fe += m_position[midV]; +// midV = m_map.phi_1(m_map.phi2(db)); +// fe += m_position[midV]; +// m_map.decCurrentLevel() ; + + //TODO Replace do--while with a Traversor2 on Boundary + unsigned int count = 0; + Traversor2EF travEF(m_map, db); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(db); + m_position[midE] -= fe; + m_map.decCurrentLevel() ; + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 ce(0.0); + Traversor3EW travEW(m_map, d); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + ce += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ce /= count; + ce *= 4 * m_a * m_a; + + typename PFP::VEC3 fe(0.0); + count = 0; + Traversor3EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fe /= count; + fe *= 4 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + m_position[midE] -= ce + fe; + m_map.decCurrentLevel() ; + } + } + + TraversorV travV(m_map); + for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + unsigned int count = 0; + typename PFP::VEC3 ev(0.0); + typename PFP::VEC3 fv(0.0); + +// Dart dit = db; +// do +// { +// m_map.incCurrentLevel() ; +// +// Dart midEdgeV = m_map.phi1(dit); +// ev += m_position[midEdgeV]; +// fv += m_position[m_map.phi1(midEdgeV)]; +// +// m_map.decCurrentLevel() ; +// ++count; +// +// dit = m_map.phi2(m_map.phi_1(dit)); +// +// }while(dit != db); + + Traversor2VF travVF(m_map,db); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + + Dart midEdgeV = m_map.phi1(dit); + ev += m_position[midEdgeV]; + fv += m_position[m_map.phi1(midEdgeV)]; + + m_map.decCurrentLevel() ; + ++count; + } + + fv /= count; + fv *= 4 * m_a * m_a; + + ev /= count; + ev *= 4 * m_a; + + m_position[d] -= fv + ev; + + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 cv(0.0); + Traversor3VW travVW(m_map,d); + for(Dart dit = travVW.begin(); dit != travVW.end() ; dit = travVW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cv += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + cv /= count; + cv *= 8 * m_a * m_a * m_a; + + typename PFP::VEC3 fv(0.0); + count = 0; + Traversor3VF travVF(m_map,d); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fv += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fv /= count; + fv *= 12 * m_a * m_a; + + typename PFP::VEC3 ev(0.0); + count = 0; + Traversor3VE travVE(m_map,d); + for(Dart dit = travVE.begin(); dit != travVE.end() ; dit = travVE.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(dit); + ev += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ev /= count; + ev *= 6 * m_a; + + m_position[d] -= cv + fv + ev; + } + } + } +} ; + +// s-scale(a) +template +class Ber02ScaleAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02ScaleAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + if(!m_map.isBoundaryVertex(midF)) + m_position[midF] /= m_a ; + m_map.decCurrentLevel() ; + + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + if(m_map.isBoundaryVertex(midE)) + m_position[midE] /= m_a; + else + m_position[midE] /= m_a * m_a; + m_map.decCurrentLevel() ; + + } + + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + m_position[d] /= m_a * m_a; + else + m_position[d] /= m_a *m_a * m_a; + } + } +} ; + + +// +// Synthesis +// + +//w-lift(a) +template +class Ber02OddSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + vc *= 8 * m_a * m_a * m_a; + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 12 * m_a * m_a; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 6 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] += vc + ec + fc; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + typename PFP::VEC3 vf(0.0); + typename PFP::VEC3 ef(0.0); + + unsigned int count = 0; + Traversor3FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 4.0 * m_a; + + vf /= count; + vf *= 4.0 * m_a * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += vf + ef ; + m_map.decCurrentLevel() ; + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] += ve; + m_map.decCurrentLevel() ; + } + } +} ; + +// s-lift(a) +template +class Ber02EvenSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02EvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorV travV(m_map); + for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + unsigned int count = 0; + typename PFP::VEC3 ev(0.0); + typename PFP::VEC3 fv(0.0); + +// Dart dit = db; +// do +// { +// m_map.incCurrentLevel() ; +// +// Dart midEdgeV = m_map.phi1(dit); +// ev += m_position[midEdgeV]; +// fv += m_position[m_map.phi1(midEdgeV)]; +// +// m_map.decCurrentLevel() ; +// ++count; +// +// dit = m_map.phi2(m_map.phi_1(dit)); +// +// }while(dit != db); + + //TODO Replace do--while with a Traversor2 on Boundary + Traversor2VF travVF(m_map,db); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + + Dart midEdgeV = m_map.phi1(dit); + ev += m_position[midEdgeV]; + fv += m_position[m_map.phi1(midEdgeV)]; + + m_map.decCurrentLevel() ; + ++count; + } + + fv /= count; + fv *= 4 * m_a * m_a; + + ev /= count; + ev *= 4 * m_a; + + m_position[d] += fv + ev; + + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 cv(0.0); + Traversor3VW travVW(m_map,d); + for(Dart dit = travVW.begin(); dit != travVW.end() ; dit = travVW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cv += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + cv /= count; + cv *= 8 * m_a * m_a * m_a; + + typename PFP::VEC3 fv(0.0); + count = 0; + Traversor3VF travVF(m_map,d); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fv += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fv /= count; + fv *= 12 * m_a * m_a; + + typename PFP::VEC3 ev(0.0); + count = 0; + Traversor3VE travVE(m_map,d); + for(Dart dit = travVE.begin(); dit != travVE.end() ; dit = travVE.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(dit); + ev += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ev /= count; + ev *= 6 * m_a; + + m_position[d] += cv + fv + ev; + } + } + + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 fe(0.0); + +// unsigned int count = 2; +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(m_map.phi1(db)); +// fe += m_position[midV]; +// midV = m_map.phi_1(m_map.phi2(db)); +// fe += m_position[midV]; +// m_map.decCurrentLevel() ; + + //TODO Replace do--while with a Traversor2 on Boundary + unsigned int count = 0; + Traversor2EF travEF(m_map, db); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(db); + m_position[midE] += fe; + m_map.decCurrentLevel() ; + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 ce(0.0); + Traversor3EW travEW(m_map, d); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + ce += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ce /= count; + ce *= 4 * m_a * m_a; + + typename PFP::VEC3 fe(0.0); + count = 0; + Traversor3EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fe /= count; + fe *= 4 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + m_position[midE] += ce + fe; + m_map.decCurrentLevel() ; + } + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + if(!m_map.isBoundaryFace(d)) + { + unsigned int count = 0; + + typename PFP::VEC3 cf(0.0); + Traversor3FW travFW(m_map, d); + for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) + { + m_map.incCurrentLevel(); + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cf += m_position[midV]; + m_map.decCurrentLevel(); + ++count; + } + cf /= count; + cf *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += cf; + m_map.decCurrentLevel() ; + } + } + } +} ; + +// s-scale(a) +template +class Ber02ScaleSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02ScaleSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + m_position[d] *= m_a * m_a; + else + m_position[d] *= m_a *m_a * m_a; + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + if(m_map.isBoundaryVertex(midE)) + m_position[midE] *= m_a; + else + m_position[midE] *= m_a * m_a; + m_map.decCurrentLevel() ; + + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + if(!m_map.isBoundaryVertex(midF)) + m_position[midF] *= m_a ; + m_map.decCurrentLevel() ; + + } + } +} ; + + + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + + +#endif /* __3MR_FILTERS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/bertramBoundary.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/bertramBoundary.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1683dc008b1cced95f57f50fe8ea4c67fdadcbc6 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/bertramBoundary.cpp @@ -0,0 +1,782 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_BERTRAM_BOUNDARY_FILTER__ +#define __3MR_BERTRAM_BOUNDARY_FILTER__ + +#include +#include "Algo/Geometry/centroid.h" +#include "Algo/Modelisation/tetrahedralization.h" +#include "Algo/Multiresolution/filter.h" +#include "Topology/generic/traversor2_closed.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/******************************************************************************* + * Without features preserving + *******************************************************************************/ + +// +// Analysis +// + +//w-lift(a) +template +class Ber02OddAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02OddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] -= ve; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + typename PFP::VEC3 vf(0.0); + typename PFP::VEC3 ef(0.0); + + unsigned int count = 0; + Traversor3FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 4.0 * m_a; + + vf /= count; + vf *= 4.0 * m_a * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= vf + ef ; + m_map.decCurrentLevel() ; + } + + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + vc *= 8 * m_a * m_a * m_a; + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 12 * m_a * m_a; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 6 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] -= vc + ec + fc; + m_map.decCurrentLevel() ; + } + } +} ; + +// s-lift(a) +template +class Ber02EvenAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02EvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + if(!m_map.isBoundaryFace(d)) + { + unsigned int count = 0; + + typename PFP::VEC3 cf(0.0); + Traversor3FW travFW(m_map, d); + for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) + { + m_map.incCurrentLevel(); + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cf += m_position[midV]; + m_map.decCurrentLevel(); + ++count; + } + cf /= count; + cf *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= cf; + m_map.decCurrentLevel() ; + } + } + + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 fe(0.0); + +// unsigned int count = 2; +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(m_map.phi1(db)); +// fe += m_position[midV]; +// midV = m_map.phi_1(m_map.phi2(db)); +// fe += m_position[midV]; +// m_map.decCurrentLevel() ; + + //TODO Replace do--while with a Traversor2 on Boundary + unsigned int count = 0; + Traversor2EF travEF(m_map, db); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(db); + m_position[midE] -= fe; + m_map.decCurrentLevel() ; + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 ce(0.0); + Traversor3EW travEW(m_map, d); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + ce += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ce /= count; + ce *= 4 * m_a * m_a; + + typename PFP::VEC3 fe(0.0); + count = 0; + Traversor3EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fe /= count; + fe *= 4 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + m_position[midE] -= ce + fe; + m_map.decCurrentLevel() ; + } + } + + TraversorV travV(m_map); + for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + unsigned int count = 0; + typename PFP::VEC3 ev(0.0); + typename PFP::VEC3 fv(0.0); + +// Dart dit = db; +// do +// { +// m_map.incCurrentLevel() ; +// +// Dart midEdgeV = m_map.phi1(dit); +// ev += m_position[midEdgeV]; +// fv += m_position[m_map.phi1(midEdgeV)]; +// +// m_map.decCurrentLevel() ; +// ++count; +// +// dit = m_map.phi2(m_map.phi_1(dit)); +// +// }while(dit != db); + + Traversor2VF travVF(m_map,db); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + + Dart midEdgeV = m_map.phi1(dit); + ev += m_position[midEdgeV]; + fv += m_position[m_map.phi1(midEdgeV)]; + + m_map.decCurrentLevel() ; + ++count; + } + + fv /= count; + fv *= 4 * m_a * m_a; + + ev /= count; + ev *= 4 * m_a; + + m_position[d] -= fv + ev; + + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 cv(0.0); + Traversor3VW travVW(m_map,d); + for(Dart dit = travVW.begin(); dit != travVW.end() ; dit = travVW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cv += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + cv /= count; + cv *= 8 * m_a * m_a * m_a; + + typename PFP::VEC3 fv(0.0); + count = 0; + Traversor3VF travVF(m_map,d); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fv += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fv /= count; + fv *= 12 * m_a * m_a; + + typename PFP::VEC3 ev(0.0); + count = 0; + Traversor3VE travVE(m_map,d); + for(Dart dit = travVE.begin(); dit != travVE.end() ; dit = travVE.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(dit); + ev += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ev /= count; + ev *= 6 * m_a; + + m_position[d] -= cv + fv + ev; + } + } + } +} ; + +// s-scale(a) +template +class Ber02ScaleAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02ScaleAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + if(!m_map.isBoundaryVertex(midF)) + m_position[midF] /= m_a ; + m_map.decCurrentLevel() ; + + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + if(m_map.isBoundaryVertex(midE)) + m_position[midE] /= m_a; + else + m_position[midE] /= m_a * m_a; + m_map.decCurrentLevel() ; + + } + + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + m_position[d] /= m_a * m_a; + else + m_position[d] /= m_a *m_a * m_a; + } + } +} ; + + +// +// Synthesis +// + +//w-lift(a) +template +class Ber02OddSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + vc *= 8 * m_a * m_a * m_a; + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 12 * m_a * m_a; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 6 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] += vc; // + ec + fc; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + typename PFP::VEC3 vf(0.0); + typename PFP::VEC3 ef(0.0); + + unsigned int count = 0; + Traversor3FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 4.0 * m_a; + + vf /= count; + vf *= 4.0 * m_a * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += vf; // + ef ; + m_map.decCurrentLevel() ; + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(d) ; + m_position[midV] += ve; + m_map.decCurrentLevel() ; + } + } +} ; + +// s-lift(a) +template +class Ber02EvenSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02EvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorV travV(m_map); + for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + unsigned int count = 0; + typename PFP::VEC3 ev(0.0); + typename PFP::VEC3 fv(0.0); + + + //TODO Replace do--while with a Traversor2 on Boundary + Traversor2VF travVF(m_map,db); + for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) + { + m_map.incCurrentLevel() ; + + Dart midEdgeV = m_map.phi1(dit); + ev += m_position[midEdgeV]; + fv += m_position[m_map.phi1(midEdgeV)]; + + m_map.decCurrentLevel() ; + ++count; + } + + fv /= count; + fv *= 4 * m_a * m_a; + + ev /= count; + ev *= 4 * m_a; + + m_position[d] += fv + ev; + + } + else + { +// unsigned int count = 0; +// +// typename PFP::VEC3 cv(0.0); +// Traversor3VW travVW(m_map,d); +// for(Dart dit = travVW.begin(); dit != travVW.end() ; dit = travVW.next()) +// { +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); +// cv += m_position[midV]; +// m_map.decCurrentLevel() ; +// ++count; +// } +// cv /= count; +// cv *= 8 * m_a * m_a * m_a; +// +// typename PFP::VEC3 fv(0.0); +// count = 0; +// Traversor3VF travVF(m_map,d); +// for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) +// { +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(m_map.phi1(dit)); +// fv += m_position[midV]; +// m_map.decCurrentLevel() ; +// ++count; +// } +// fv /= count; +// fv *= 12 * m_a * m_a; +// +// typename PFP::VEC3 ev(0.0); +// count = 0; +// Traversor3VE travVE(m_map,d); +// for(Dart dit = travVE.begin(); dit != travVE.end() ; dit = travVE.next()) +// { +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(dit); +// ev += m_position[midV]; +// m_map.decCurrentLevel() ; +// ++count; +// } +// ev /= count; +// ev *= 6 * m_a; +// +// m_position[d] += cv + fv + ev; + } + } + + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 fe(0.0); + + //TODO Replace do--while with a Traversor2 on Boundary + unsigned int count = 0; + Traversor2EF travEF(m_map, db); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(db); + m_position[midE] += fe; + m_map.decCurrentLevel() ; + } + else + { +// unsigned int count = 0; +// +// typename PFP::VEC3 ce(0.0); +// Traversor3EW travEW(m_map, d); +// for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) +// { +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); +// ce += m_position[midV]; +// m_map.decCurrentLevel() ; +// ++count; +// } +// ce /= count; +// ce *= 4 * m_a * m_a; +// +// typename PFP::VEC3 fe(0.0); +// count = 0; +// Traversor3EF travEF(m_map, d); +// for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) +// { +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(m_map.phi1(dit)); +// fe += m_position[midV]; +// m_map.decCurrentLevel() ; +// ++count; +// } +// fe /= count; +// fe *= 4 * m_a; +// +// m_map.incCurrentLevel() ; +// Dart midE = m_map.phi1(d); +// m_position[midE] += ce + fe; +// m_map.decCurrentLevel() ; + } + } + +// TraversorF travF(m_map) ; +// for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) +// { +// if(!m_map.isBoundaryFace(d)) +// { +// unsigned int count = 0; +// +// typename PFP::VEC3 cf(0.0); +// Traversor3FW travFW(m_map, d); +// for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) +// { +// m_map.incCurrentLevel(); +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); +// cf += m_position[midV]; +// m_map.decCurrentLevel(); +// ++count; +// } +// cf /= count; +// cf *= 2 * m_a; +// +// m_map.incCurrentLevel() ; +// Dart midF = m_map.phi1(m_map.phi1(d)); +// m_position[midF] += cf; +// m_map.decCurrentLevel() ; +// } +// } + } +} ; + +// s-scale(a) +template +class Ber02ScaleSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; + +public: + Ber02ScaleSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + + void operator() () + { + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + m_position[d] *= m_a * m_a; + //else + // m_position[d] *= m_a *m_a * m_a; + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + if(m_map.isBoundaryVertex(midE)) + m_position[midE] *= m_a; + //else + // m_position[midE] *= m_a * m_a; + m_map.decCurrentLevel() ; + + } + +// TraversorF travF(m_map) ; +// for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) +// { +// m_map.incCurrentLevel() ; +// Dart midF = m_map.phi1(m_map.phi1(d)); +// if(!m_map.isBoundaryVertex(midF)) +// m_position[midF] *= m_a ; +// m_map.decCurrentLevel() ; +// +// } + } +} ; + + + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + + +#endif /* __3MR_BERTRAM_BOUNDARY_FILTER__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/lerp.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/lerp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..166f4f6189788aa3ae61daee22953867179b9639 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/lerp.cpp @@ -0,0 +1,725 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_LERP_FILTER__ +#define __3MR_LERP_FILTER__ + +#include +#include "Algo/Geometry/centroid.h" +#include "Algo/Modelisation/tetrahedralization.h" +#include "Algo/Modelisation/polyhedron.h" +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/********************************************************************************* + * SYNTHESIS FILTERS + *********************************************************************************/ + +/* Linear Interpolation + *********************************************************************************/ + + +template +class LerpQuadOddSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpQuadOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 3; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 3; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] += vc + ec + fc; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + typename PFP::VEC3 vf(0.0); + typename PFP::VEC3 ef(0.0); + + unsigned int count = 0; + Traversor3FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 2.0; + + vf /= count; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += vf + ef ; + m_map.decCurrentLevel() ; + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d) ; + m_position[midE] += ve; + m_map.decCurrentLevel() ; + } + } + +}; + + + + +template +class LerpQuadOddAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpQuadOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d) ; + m_position[midE] -= ve; + m_map.decCurrentLevel() ; + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + typename PFP::VEC3 vf(0.0); + typename PFP::VEC3 ef(0.0); + + unsigned int count = 0; + Traversor3FE travFE(m_map, d); + for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next()) + { + vf += m_position[dit]; + m_map.incCurrentLevel(); + ef += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ef /= count; + ef *= 2.0; + + vf /= count; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= vf;// + ef ; + m_map.decCurrentLevel() ; + } + + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 3;//12 * m_a * m_a; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 3;//6 * m_a; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] -= vc;// + ec + fc; + m_map.decCurrentLevel() ; + } + } + +}; + + + + + +template +class LerpTriOddSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpTriOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 3; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 3; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] += vc + ec + fc; + m_map.decCurrentLevel() ; + } + } + + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d) ; + m_position[midE] += ve; + m_map.decCurrentLevel() ; + } + } + +}; + + + + +template +class LerpTriOddAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpTriOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + { + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d) ; + m_position[midE] -= ve; + m_map.decCurrentLevel() ; + } + + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + { + if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) + { + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 3; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 3; + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] -= vc + ec + fc; + m_map.decCurrentLevel() ; + } + } + } + +}; + + + + + + + + + + + + + + + + + + +/*****************************************************************************************/ + + +template +class LerpEdgeSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpEdgeSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d) ; + m_position[midV] = p ; + + m_map.decCurrentLevel() ; + } + } +} ; + +template +class LerpFaceSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpFaceSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + typename PFP::VEC3 p = Algo::Surface::Geometry::faceCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] = p ; + + m_map.decCurrentLevel() ; + + } + } +} ; + +template +class LerpTriQuadFaceSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpTriQuadFaceSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.faceDegree(d) > 3) + { + typename PFP::VEC3 p = Algo::Surface::Geometry::faceCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] = p ; + + m_map.decCurrentLevel() ; + } + } + } +} ; + +template +class LerpVolumeSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpVolumeSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) + { + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] = p ; + + m_map.decCurrentLevel() ; + } + } + } +} ; + +template +class LerpTriQuadVolumeSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpTriQuadVolumeSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d) + && !Algo::Surface::Modelisation::isPrism(m_map,d) + && !Algo::Surface::Modelisation::isPyra(m_map,d)) + { + typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] = p ; + + m_map.decCurrentLevel() ; + } + } + } +} ; + + +//template +//bool isDartOfFaceAtLevel(typename PFP::MAP map, Dart d, unsigned int level) +//{ +// unsigned int cur = map.getCurrentLevel(); +// map.setCurrentLevel(level); +//// TraversorDartsOfOrbit to(map,d); +//// for (Dart dit = to.begin(); dit != to.end(); dit = to.next()) +//// { +//// if(d == dit) +//// { +//// map.setCurrentLevel(cur); +//// return true; +//// } +//// } +// Dart dit = d; +// do +// { +// if(d == dit) +// { +// map.setCurrentLevel(cur); +// return true; +// } +// dit = map.phi1(dit); +// }while(dit != d); + +// map.setCurrentLevel(cur); +// return false; +//} +/* +template +class LerpSqrt3VolumeSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LerpSqrt3VolumeSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + Dart findDartOfCentralVertex(Dart d) + { + Dart olddart = NIL; + TraversorDartsOfOrbit to(m_map,d); + for(Dart dit = to.begin() ; (olddart == NIL) && (dit != to.end()) ; dit = to.next()) + { + m_map.incCurrentLevel(); + unsigned int emb = m_map.template getEmbedding(dit); + m_map.decCurrentLevel(); + if(!m_map.isBoundaryMarked3(m_map.phi3(dit))) + { + if(emb == EMBNULL) + olddart = dit; + } + } + + std::cout << "findDartOfCentralVertex = " << olddart << std::endl; + return olddart; + } + + void operator() () + { +// m_map.incCurrentLevel() ; + +// unsigned int cur = m_map.getCurrentLevel(); + +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(!m_map.isBoundaryVertex(d)) +// { +// std::cout << "sommet" << std::endl; + +// //search an old dart +// Dart olddart = NIL; +// TraversorDartsOfOrbit to(m_map,d); +// for(Dart dit = to.begin() ; (olddart == NIL) && (dit != to.end()) ; dit = to.next()) +// { +// if(m_map.getDartLevel(dit) == (cur - 1)) && isDartOfFaceAtLevel(m_map,dit, cur-1)) +// { +// olddart = dit; +// } +// } + +// if(olddart != NIL) +// { +// std::cout << "olddart = " << olddart << std::endl; + +// m_map.decCurrentLevel(); +// typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, olddart, m_position); +// m_map.incCurrentLevel() ; +// m_position[d] = p; +// } +// } +// } +// m_map.decCurrentLevel() ; + + + + + +// TraversorW trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { + +// typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d , m_position); + +// m_map.incCurrentLevel() ; + +// Dart midV = m_map.phi_1(m_map.phi2(d)); +// m_position[midV] = p; +// //m_position[d] = p; + +// m_map.decCurrentLevel() ; +// } + + + TraversorW trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + Dart dit = d; + + if(m_map.isBoundaryAdjacentVolume(d)) + { + dit = findDartOfCentralVertex(d); + } + + typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + //Dart midV = m_map.phi1(dit); + + m_map.incCurrentLevel() ; + m_position[dit] = p; + m_map.decCurrentLevel() ; + } + + TraversorF tf(m_map); + for(Dart dit = tf.begin() ; dit != tf.end() ; dit = tf.next()) + { + if(m_map.isBoundaryFace(dit)) + { + typename PFP::VEC3 p = Algo::Surface::Geometry::faceCentroid(m_map, dit, m_position); + m_map.incCurrentLevel(); + Dart midF = m_map.phi_1(dit); + m_position[midF] = p; + m_map.decCurrentLevel(); + } + } + + } +} ; + +*/ + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#endif /* __3MR_FILTERS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/mcCrackenJoy.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/mcCrackenJoy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..43564e9f0a242f532da88402cb0a769921ef9a84 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/mcCrackenJoy.cpp @@ -0,0 +1,349 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_MCCRACKENJOY_FILTER__ +#define __3MR_MCCRACKENJOY_FILTER__ + +#include +#include "Algo/Geometry/centroid.h" +#include "Algo/Modelisation/tetrahedralization.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/* Catmull-clark on Boundary Vertices and MJ96 on Insides Vertices + *********************************************************************************/ +template +class MJ96VertexSubdivision : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96VertexSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + typename PFP::VEC3 np1(0) ; + typename PFP::VEC3 np2(0) ; + unsigned int degree1 = 0 ; + unsigned int degree2 = 0 ; + Dart it = db ; + do + { + ++degree1 ; + Dart dd = m_map.phi1(it) ; + np1 += m_position[dd] ; + Dart end = m_map.phi_1(it) ; + dd = m_map.phi1(dd) ; + do + { + ++degree2 ; + np2 += m_position[dd] ; + dd = m_map.phi1(dd) ; + } while(dd != end) ; + it = m_map.phi2(m_map.phi_1(it)) ; + } while(it != db) ; + + float beta = 3.0 / (2.0 * degree1) ; + float gamma = 1.0 / (4.0 * degree2) ; + np1 *= beta / degree1 ; + np2 *= gamma / degree2 ; + + typename PFP::VEC3 vp = m_position[db] ; + vp *= 1.0 - beta - gamma ; + + m_map.incCurrentLevel() ; + + m_position[d] = np1 + np2 + vp ; + + m_map.decCurrentLevel() ; + + } + else + { + typename PFP::VEC3 P = m_position[d]; + + //vertex points + typename PFP::VEC3 Cavg = typename PFP::VEC3(0); + unsigned int degree = 0; + Traversor3VW travVW(m_map, d); + for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) + { + Cavg += Algo::Surface::Geometry::volumeCentroid(m_map, dit, m_position); + ++degree; + } + Cavg /= degree; + + typename PFP::VEC3 Aavg = typename PFP::VEC3(0); + degree = 0; + Traversor3VF travVF(m_map, d); + for(Dart dit = travVF.begin() ; dit != travVF.end() ; dit = travVF.next()) + { + Aavg += Algo::Surface::Geometry::faceCentroid(m_map, dit, m_position); + ++degree; + } + Aavg /= degree; + + typename PFP::VEC3 Mavg = typename PFP::VEC3(0); + degree = 0; + Traversor3VE travVE(m_map, d); + for(Dart dit = travVE.begin() ; dit != travVE.end() ; dit = travVE.next()) + { + Dart d2 = m_map.phi2(dit); + Aavg += (m_position[dit] + m_position[d2]) * typename PFP::REAL(0.5); + ++degree; + } + Aavg /= degree; + + typename PFP::VEC3 vp = Cavg + Aavg * 3 + Mavg * 3 + P; + vp /= 8; + + m_map.incCurrentLevel() ; + + m_position[d] = P;//vp; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class MJ96EdgeSubdivision : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96EdgeSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + + Dart d1 = m_map.phi2(db) ; + Dart d2 = m_map.phi2(d1) ; + Dart d3 = m_map.phi_1(d1) ; + Dart d4 = m_map.phi_1(d2) ; + Dart d5 = m_map.phi1(m_map.phi1(d1)) ; + Dart d6 = m_map.phi1(m_map.phi1(d2)) ; + + typename PFP::VEC3 p1 = m_position[d1] ; + typename PFP::VEC3 p2 = m_position[d2] ; + typename PFP::VEC3 p3 = m_position[d3] ; + typename PFP::VEC3 p4 = m_position[d4] ; + typename PFP::VEC3 p5 = m_position[d5] ; + typename PFP::VEC3 p6 = m_position[d6] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 16.0 ; + p4 *= 1.0 / 16.0 ; + p5 *= 1.0 / 16.0 ; + p6 *= 1.0 / 16.0 ; + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d); + + m_position[midV] = p1 + p2 + p3 + p4 + p5 + p6 ; + + m_map.decCurrentLevel() ; + } + else + { + //edge points + typename PFP::VEC3 Cavg = typename PFP::VEC3(0); + unsigned int degree = 0; + Traversor3EW travEW(m_map, d); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + Cavg += Algo::Surface::Geometry::volumeCentroid(m_map, dit, m_position); + ++degree; + } + Cavg /= degree; + + typename PFP::VEC3 Aavg = typename PFP::VEC3(0); + degree = 0; + Traversor3EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + Aavg += Algo::Surface::Geometry::faceCentroid(m_map, dit, m_position); + ++degree; + } + Aavg /= degree; + + Dart d2 = m_map.phi2(d); + typename PFP::VEC3 M = (m_position[d] + m_position[d2]) * typename PFP::REAL(0.5); + + typename PFP::VEC3 ep = Cavg + Aavg * 2 + M * (degree - 3); + ep /= degree; + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d); + + m_position[midV] = ep; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class MJ96FaceSubdivision : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96FaceSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryFace(d)) + { + Dart db = m_map.phi3(d); + + typename PFP::VEC3 p(0) ; + unsigned int degree = 0 ; + Traversor2FV trav(m_map, db) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + p += m_position[it] ; + } + p /= degree ; + + m_map.incCurrentLevel() ; + + Dart df = m_map.phi1(m_map.phi1(d)) ; + + m_position[df] = p ; + + m_map.decCurrentLevel() ; + } + else + { + //face points + typename PFP::VEC3 C0 = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + typename PFP::VEC3 C1 = Algo::Surface::Geometry::volumeCentroid(m_map, m_map.phi3(d), m_position); + + typename PFP::VEC3 A = Algo::Surface::Geometry::faceCentroid(m_map, m_map.phi3(d), m_position); + + typename PFP::VEC3 fp = C0 + A * 2 + C1; + fp /= 4; + + m_map.incCurrentLevel() ; + + Dart df = m_map.phi1(m_map.phi1(d)) ; + m_position[df] = fp; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class MJ96VolumeSubdivision : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96VolumeSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + //cell points : these points are the average of the + //vertices of the lattice that bound the cell + typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] = p ; + m_map.decCurrentLevel() ; + + } + } +}; + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + + +#endif /* __3MR_FILTERS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/schaefer.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/schaefer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..733d2c5f445f6ec4f3b80fe02fb5d25cbb953c86 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Filters/schaefer.cpp @@ -0,0 +1,1328 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_LOOP_FILTER__ +#define __3MR_LOOP_FILTER__ + +#include +#include "Algo/Geometry/centroid.h" +#include "Algo/Modelisation/tetrahedralization.h" +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Filters +{ + +/********************************************************************************* + * LOOP BASIC FUNCTIONS + *********************************************************************************/ +template +typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const VertexAttribute& position, Dart d1) +{ + Dart d2 = map.phi2(d1) ; + Dart d3 = map.phi_1(d1) ; + Dart d4 = map.phi_1(d2) ; + + typename PFP::VEC3 p1 = position[d1] ; + typename PFP::VEC3 p2 = position[d2] ; + typename PFP::VEC3 p3 = position[d3] ; + typename PFP::VEC3 p4 = position[d4] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 8.0 ; + p4 *= 1.0 / 8.0 ; + + return p1 + p2 + p3 + p4 ; +} + +template +typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const VertexAttribute& position, Dart d) +{ + map.incCurrentLevel() ; + + typename PFP::VEC3 np(0) ; + unsigned int degree = 0 ; + Traversor2VVaE trav(map, d) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + np += position[it] ; + } + + map.decCurrentLevel() ; + + float mu = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; + mu = (5.0/8.0 - (mu * mu)) / degree ; + np *= 8.0/5.0 * mu ; + + return np ; +} + +/********************************************************************************* + * SHW04 BASIC FUNCTIONS : tetrahedral/octahedral meshes + *********************************************************************************/ +template +typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const VertexAttribute& position, Dart d) +{ + typename PFP::VEC3 res(0); + + if(Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(map, d)) + { + Dart d1 = map.phi1(d) ; + Dart d2 = map.phi_1(d); + Dart d3 = map.phi_1(map.phi2(d)); + + typename PFP::VEC3 p = position[d]; + typename PFP::VEC3 p1 = position[d1] ; + typename PFP::VEC3 p2 = position[d2] ; + typename PFP::VEC3 p3 = position[d3] ; + + p *= -1; + p1 *= 17.0 / 3.0; + p2 *= 17.0 / 3.0; + p3 *= 17.0 / 3.0; + + res += p + p1 + p2 + p3; + res *= 1.0 / 16.0; + } + else + { + Dart d1 = map.phi1(d); + Dart d2 = map.phi_1(d); + Dart d3 = map.phi_1(map.phi2(d)); + Dart d4 = map.phi_1(map.phi2(d3)); + Dart d5 = map.phi_1(map.phi2(map.phi_1(d))); + + typename PFP::VEC3 p = position[d]; + typename PFP::VEC3 p1 = position[d1] ; + typename PFP::VEC3 p2 = position[d2] ; + typename PFP::VEC3 p3 = position[d3] ; + typename PFP::VEC3 p4 = position[d4] ; + typename PFP::VEC3 p5 = position[d5] ; + + p *= 3.0 / 4.0; + p1 *= 1.0 / 6.0; + p2 *= 1.0 / 6.0; + p3 *= 1.0 / 6.0; + p4 *= 7.0 / 12.0; + p5 *= 1.0 / 6.0; + + res += p + p1 + p2 + p3 + p4 + p5; + res *= 1.0 / 2.0; + } + + return res; +} + + +/********************************************************************************* + * FIRST VERSION + *********************************************************************************/ + +/************** Analysis Filters ***********************/ +template +class LoopEvenAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopEvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + typename PFP::VEC3 p = loopEvenVertex(m_map, m_position, db) ; + m_position[db] -= p ; + } + } + } +} ; + +template +class LoopNormalisationAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopNormalisationAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + unsigned int degree = m_map.vertexDegreeOnBoundary(db) ; + float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; + n = 8.0/5.0 * (n * n) ; + + m_position[db] /= n ; + } + } + } +} ; + +template +class LoopOddAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 p = loopOddVertex(m_map, m_position, db) ; + + m_map.incCurrentLevel() ; + + Dart oddV = m_map.phi2(db) ; + m_position[oddV] -= p ; + + m_map.decCurrentLevel() ; + } + else + { + typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d) ; + m_position[midV] -= p ; + + m_map.decCurrentLevel() ; + } + } + } +} ; + + +/************** Synthesis Filters ***********************/ + +/* Loop on Boundary Vertices and SHW04 on Insides Vertices + *********************************************************************************/ +template +class LoopOddSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 p = loopOddVertex(m_map, m_position, db) ; + + m_map.incCurrentLevel() ; + + Dart oddV = m_map.phi2(db) ; + m_position[oddV] += p ; + + m_map.decCurrentLevel() ; + } + else + { + typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d) ; + m_position[midV] += p ; + + m_map.decCurrentLevel() ; + } + } + } +} ; + +template +class LoopNormalisationSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + unsigned int degree = m_map.vertexDegreeOnBoundary(db) ; + float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; + n = 8.0/5.0 * (n * n) ; + + m_position[db] *= n ; + } + } + } +} ; + +template +class LoopEvenSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopEvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + typename PFP::VEC3 p = loopEvenVertex(m_map, m_position, db) ; + m_position[db] += p ; + } + } + } +} ; + +template +class LoopVolumeSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopVolumeSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) + { + typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] = p ; + + m_map.decCurrentLevel() ; + } + } + } +} ; + +template +class SHW04VolumeNormalisationSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + SHW04VolumeNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + m_map.incCurrentLevel() ; + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(!m_map.isBoundaryVertex(d)) + { + typename PFP::VEC3 p = typename PFP::VEC3(0); + unsigned int degree = 0; + + Traversor3VW travVW(m_map, d); + for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) + { + p += SHW04Vertex(m_map, m_position, dit); + ++degree; + } + + p /= degree; + + m_position[d] = p ; + } + } + m_map.decCurrentLevel() ; + } +} ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +///***************************************************************************************** +// * SECOND VERSION * +// *****************************************************************************************/ +///************** Synthesis Filters ***********************/ +//template +//class LoopWarrenOddSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorW travW(m_map) ; +// for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) +// { +// if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) +// { +// typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + +// unsigned int count = 0; +// typename PFP::VEC3 ec(0.0); +// Traversor3WE travWE(m_map, d); +// for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) +// { +// m_map.incCurrentLevel(); +// ec += m_position[m_map.phi1(dit)]; +// m_map.decCurrentLevel(); +// ++count; +// } +// ec /= count; +// ec *= 3; + +// count = 0; +// typename PFP::VEC3 fc(0.0); +// Traversor3WF travWF(m_map, d); +// for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) +// { +// m_map.incCurrentLevel(); +// fc += m_position[m_map.phi1(m_map.phi1(dit))]; +// m_map.decCurrentLevel(); +// ++count; +// } +// fc /= count; +// fc *= 3; + +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); +// m_position[midV] += vc + ec + fc; +// m_map.decCurrentLevel() ; +// } +// } + +// TraversorE trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryEdge(d)) +// { +// Dart db = m_map.findBoundaryFaceOfEdge(d); +// typename PFP::VEC3 p = loopOddVertex(m_map, m_position, db) ; + +// m_map.incCurrentLevel() ; + +// Dart oddV = m_map.phi2(db) ; +// m_position[oddV] += p ; + +// m_map.decCurrentLevel() ; +// } +// else +// { +// typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + +// m_map.incCurrentLevel() ; +// Dart midE = m_map.phi1(d) ; +// m_position[midE] += ve; +// m_map.decCurrentLevel() ; +// } +// } +// } +//} ; + +//template +//class LoopWarrenNormalisationSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryVertex(d)) +// { +// Dart db = m_map.findBoundaryFaceOfVertex(d); + +// unsigned int degree = m_map.vertexDegreeOnBoundary(db) ; +// float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; +// n = 8.0/5.0 * (n * n) ; + +// m_position[db] *= n ; +// } +// else +// { +// m_map.incCurrentLevel() ; + +// typename PFP::VEC3 p = typename PFP::VEC3(0); +// unsigned int degree = 0; + +// Traversor3VW travVW(m_map, d); +// for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) +// { +// p += SHW04Vertex(m_map, m_position, dit); +// ++degree; +// } + +// p /= degree; + +// //p *= + +// m_position[d] = p ; + +// m_map.decCurrentLevel() ; +// } +// } +// } +//} ; + +//template +//class LoopWarrenEvenSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenEvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryVertex(d)) +// { +// Dart db = m_map.findBoundaryFaceOfVertex(d); +// typename PFP::VEC3 p = loopEvenVertex(m_map, m_position, db) ; +// m_position[db] += p ; +// } +// } +// } +//} ; + +///************** Analysis Filters ***********************/ +//template +//class LoopWarrenEvenAnalysisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenEvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryVertex(d)) +// { +// Dart db = m_map.findBoundaryFaceOfVertex(d); +// typename PFP::VEC3 p = loopEvenVertex(m_map, m_position, db) ; +// m_position[db] -= p ; +// } +// } +// } +//} ; + +//template +//class LoopWarrenNormalisationAnalysisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenNormalisationAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryVertex(d)) +// { +// Dart db = m_map.findBoundaryFaceOfVertex(d); + +// unsigned int degree = m_map.vertexDegreeOnBoundary(db) ; +// float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; +// n = 8.0/5.0 * (n * n) ; + +// m_position[db] /= n ; +// } +// else +// { +// m_map.incCurrentLevel() ; + +// typename PFP::VEC3 p = typename PFP::VEC3(0); +// unsigned int degree = 0; + +// Traversor3VW travVW(m_map, d); +// for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) +// { +// p += SHW04Vertex(m_map, m_position, dit); +// ++degree; +// } + +// p /= degree; + +// m_position[d] -= p ; + +// m_map.decCurrentLevel() ; +// } +// } +// } +//} ; + +//template +//class LoopWarrenOddAnalysisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorE trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryEdge(d)) +// { +// Dart db = m_map.findBoundaryFaceOfEdge(d); +// typename PFP::VEC3 p = loopOddVertex(m_map, m_position, db) ; + +// m_map.incCurrentLevel() ; + +// Dart oddV = m_map.phi2(db) ; +// m_position[oddV] -= p ; + +// m_map.decCurrentLevel() ; +// } +// else +// { +// typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + +// m_map.incCurrentLevel() ; +// Dart midE = m_map.phi1(d) ; +// m_position[midE] -= ve; +// m_map.decCurrentLevel() ; +// } +// } + +// TraversorW travW(m_map) ; +// for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) +// { +// if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) +// { +// typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + +// unsigned int count = 0; +// typename PFP::VEC3 ec(0.0); +// Traversor3WE travWE(m_map, d); +// for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) +// { +// m_map.incCurrentLevel(); +// ec += m_position[m_map.phi1(dit)]; +// m_map.decCurrentLevel(); +// ++count; +// } +// ec /= count; +// ec *= 3; + +// count = 0; +// typename PFP::VEC3 fc(0.0); +// Traversor3WF travWF(m_map, d); +// for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) +// { +// m_map.incCurrentLevel(); +// fc += m_position[m_map.phi1(m_map.phi1(dit))]; +// m_map.decCurrentLevel(); +// ++count; +// } +// fc /= count; +// fc *= 3; + +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); +// m_position[midV] -= vc + ec + fc; +// m_map.decCurrentLevel() ; +// } +// } +// } +//} ; + + + + + + + + + + + + + + + +///***************************************************************************************** +// * THIRD VERSION * +// *****************************************************************************************/ + +///********************************************************************************* +// * SHW04 BASIC FUNCTIONS : tetrahedral/octahedral meshes +// *********************************************************************************/ +//template +//typename PFP::VEC3 SHW04Vertex2(typename PFP::MAP& map, const VertexAttribute& position, Dart d) +//{ +// typename PFP::VEC3 res(0); + +// if(Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(map, d)) +// { +// Dart d1 = map.phi1(d) ; +// Dart d2 = map.phi_1(d); +// Dart d3 = map.phi_1(map.phi2(d)); + +// typename PFP::VEC3 p1 = position[d1] ; +// typename PFP::VEC3 p2 = position[d2] ; +// typename PFP::VEC3 p3 = position[d3] ; + +// p1 *= 17.0 / 48.0; +// p2 *= 17.0 / 48.0; +// p3 *= 17.0 / 48.0; + +// res += p1 + p2 + p3; + +// res /= -1.0 / 16.0; +// } +// else +// { +// Dart d1 = map.phi1(d); +// Dart d2 = map.phi_1(d); +// Dart d3 = map.phi_1(map.phi2(d)); +// Dart d4 = map.phi_1(map.phi2(d3)); +// Dart d5 = map.phi_1(map.phi2(map.phi_1(d))); + +// typename PFP::VEC3 p1 = position[d1] ; +// typename PFP::VEC3 p2 = position[d2] ; +// typename PFP::VEC3 p3 = position[d3] ; +// typename PFP::VEC3 p4 = position[d4] ; +// typename PFP::VEC3 p5 = position[d5] ; + +//// p *= 3.0 / 4.0; +// p1 *= 1.0 / 6.0; +// p2 *= 1.0 / 6.0; +// p3 *= 1.0 / 6.0; +// p4 *= 7.0 / 12.0; +// p5 *= 1.0 / 6.0; + +// res += p1 + p2 + p3 + p4 + p5; +// res *= 1.0 / 2.0; + +// res /= 3.0 / 4.0; + +// //res *= -4.0 / 48.0; +// } + +// return res; +//} + + + + +///************** Synthesis Filters ***********************/ +//template +//class LoopWarrenOddSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorW travW(m_map) ; +// for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) +// { +// if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) +// { +// typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + +// unsigned int count = 0; +// typename PFP::VEC3 ec(0.0); +// Traversor3WE travWE(m_map, d); +// for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) +// { +// m_map.incCurrentLevel(); +// ec += m_position[m_map.phi1(dit)]; +// m_map.decCurrentLevel(); +// ++count; +// } +// ec /= count; +// ec *= 3; + +// count = 0; +// typename PFP::VEC3 fc(0.0); +// Traversor3WF travWF(m_map, d); +// for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) +// { +// m_map.incCurrentLevel(); +// fc += m_position[m_map.phi1(m_map.phi1(dit))]; +// m_map.decCurrentLevel(); +// ++count; +// } +// fc /= count; +// fc *= 3; + +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); +// m_position[midV] += vc + ec + fc; +// m_map.decCurrentLevel() ; +// } +// } + +// TraversorE trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + +// m_map.incCurrentLevel() ; +// Dart midE = m_map.phi1(d) ; +// m_position[midE] += ve; +// m_map.decCurrentLevel() ; + +// } +// } +//} ; + +//template +//class LoopWarrenNormalisationSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { + +// m_map.incCurrentLevel() ; + +// typename PFP::VEC3 p = typename PFP::VEC3(0); +// unsigned int degree = 0; + +// Traversor3VW travVW(m_map, d); +// for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) +// { +// p += SHW04Vertex(m_map, m_position, dit); +// ++degree; +// } + +// p /= degree; + +// p *= -1.0 / 16.0; + +// m_position[d] += p ; + +// m_map.decCurrentLevel() ; +// } +// } +//} ; + +//template +//class LoopWarrenEvenSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenEvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +//// TraversorV trav(m_map) ; +//// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +//// { +//// if(m_map.isBoundaryVertex(d)) +//// { +//// Dart db = m_map.findBoundaryFaceOfVertex(d); +//// typename PFP::VEC3 p = loopEvenVertex(m_map, m_position, db) ; +//// m_position[db] += p ; +//// } +//// } +// } +//} ; + +///************** Analysis Filters ***********************/ +//template +//class LoopWarrenEvenAnalysisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenEvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +//// TraversorV trav(m_map) ; +//// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +//// { +//// if(m_map.isBoundaryVertex(d)) +//// { +//// Dart db = m_map.findBoundaryFaceOfVertex(d); +//// typename PFP::VEC3 p = loopEvenVertex(m_map, m_position, db) ; +//// m_position[db] -= p ; +//// } +//// } +// } +//} ; + +//template +//class LoopWarrenNormalisationAnalysisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenNormalisationAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// m_map.incCurrentLevel() ; + +// typename PFP::VEC3 p = typename PFP::VEC3(0); +// unsigned int degree = 0; + +// Traversor3VW travVW(m_map, d); +// for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) +// { +// p += SHW04Vertex(m_map, m_position, dit); +// ++degree; +// } + +// p /= degree; + +// m_position[d] -= p ; + +// m_map.decCurrentLevel() ; +// } +// } +//} ; + +//template +//class LoopWarrenOddAnalysisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopWarrenOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorE trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + +// m_map.incCurrentLevel() ; +// Dart midE = m_map.phi1(d) ; +// m_position[midE] -= ve; +// m_map.decCurrentLevel() ; + +// } + +// TraversorW travW(m_map) ; +// for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) +// { +// if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) +// { +// typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + +// unsigned int count = 0; +// typename PFP::VEC3 ec(0.0); +// Traversor3WE travWE(m_map, d); +// for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) +// { +// m_map.incCurrentLevel(); +// ec += m_position[m_map.phi1(dit)]; +// m_map.decCurrentLevel(); +// ++count; +// } +// ec /= count; +// ec *= 3; + +// count = 0; +// typename PFP::VEC3 fc(0.0); +// Traversor3WF travWF(m_map, d); +// for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) +// { +// m_map.incCurrentLevel(); +// fc += m_position[m_map.phi1(m_map.phi1(dit))]; +// m_map.decCurrentLevel(); +// ++count; +// } +// fc /= count; +// fc *= 3; + +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); +// m_position[midV] -= vc + ec + fc; +// m_map.decCurrentLevel() ; +// } +// } +// } +//} ; + + + + + + + + + + + + +//template +//class SHW04OddSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map; +// VertexAttribute& m_position; + +//public: +// SHW04OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorW travW(m_map) ; +// for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) +// { +// if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) +// { +// typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + +// unsigned int count = 0; +// typename PFP::VEC3 ec(0.0); +// Traversor3WE travWE(m_map, d); +// for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) +// { +// m_map.incCurrentLevel(); +// ec += m_position[m_map.phi1(dit)]; +// m_map.decCurrentLevel(); +// ++count; +// } +// ec /= count; +// ec *= 3; + +// count = 0; +// typename PFP::VEC3 fc(0.0); +// Traversor3WF travWF(m_map, d); +// for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) +// { +// m_map.incCurrentLevel(); +// fc += m_position[m_map.phi1(m_map.phi1(dit))]; +// m_map.decCurrentLevel(); +// ++count; +// } +// fc /= count; +// fc *= 3; + +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); +// m_position[midV] += vc + ec + fc; +// m_map.decCurrentLevel() ; +// } +// } + +// TraversorE trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryEdge(d)) +// { +// Dart db = m_map.findBoundaryFaceOfEdge(d); +// typename PFP::VEC3 p = loopOddVertex(m_map, m_position, db) ; + +// m_map.incCurrentLevel() ; + +// Dart oddV = m_map.phi2(db) ; +// m_position[oddV] += p ; + +// m_map.decCurrentLevel() ; +// } +// else +// { +// typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(d) ; +// m_position[midV] += ve; +// m_map.decCurrentLevel() ; +// } +// } +// } +//}; + +//template +//class LoopNormalisationSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryVertex(d)) +// { +// Dart db = m_map.findBoundaryFaceOfVertex(d); + +// unsigned int degree = m_map.vertexDegreeOnBoundary(db) ; +// float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; +// n = 8.0/5.0 * (n * n) ; + +// m_position[db] *= n ; +// } +// } +// } +//} ; + +//template +//class LoopEvenSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// LoopEvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(m_map.isBoundaryVertex(d)) +// { +// Dart db = m_map.findBoundaryFaceOfVertex(d); +// typename PFP::VEC3 p = loopEvenVertex(m_map, m_position, db) ; +// m_position[db] += p ; +// } +// } +// } +//} ; + + +//template +//class SHW04NormalisationSynthesisFilter : public Algo::MR::Filter +//{ +//protected: +// typename PFP::MAP& m_map ; +// VertexAttribute& m_position ; + +//public: +// SHW04NormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) +// {} + +// void operator() () +// { +// m_map.incCurrentLevel() ; +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(!m_map.isBoundaryVertex(d)) +// { +// typename PFP::VEC3 p = typename PFP::VEC3(0); +// unsigned int degree = 0; + +// Traversor3VW travVW(m_map, d); +// for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) +// { +// p += SHW04Vertex(m_map, m_position, dit); +// ++degree; +// } + +// p /= degree; + +// m_position[d] = p ; +// } +// } +// m_map.decCurrentLevel() ; +// } +//} ; + + + +} // namespace Filters + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + + +#endif /* __3MR_FILTERS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/lerp.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/lerp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..943982bd49d2425a36c014097f0c0cc5a97c78b5 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/lerp.cpp @@ -0,0 +1,173 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_LERP_MASK__ +#define __3MR_LERP_MASK__ + +#include +#include "Algo/Geometry/centroid.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Masks +{ + +/* Linear Interpolation + *********************************************************************************/ +template +class LerpVertexVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + AttributeHandler& m_position ; + +public: + LerpVertexVertexFunctor(typename PFP::MAP& m, AttributeHandler& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + m_map.decCurrentLevel() ; + typename PFP::VEC3 p = m_position[d] ; +// std::cout << " p du niv i-1 = " << p << std::endl; + m_map.incCurrentLevel() ; + +// std::cout << " p du niv i+1 = " << p << std::endl; + + //m_position[d] = p; + +// m_map.decCurrentLevel() ; +// std::cout << "dec = " << m_position[d] << std::endl; +// m_map.incCurrentLevel(); +// std::cout << "inc = " << m_position[d] << std::endl << std::endl; + + return false ; + } +}; + +template +class LerpEdgeVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + AttributeHandler& m_position ; + +public: + LerpEdgeVertexFunctor(typename PFP::MAP& m, AttributeHandler& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart d1 = m_map.phi2(d); + + m_map.decCurrentLevel(); + Dart d2 = m_map.phi2(d1); + typename PFP::VEC3 p = (m_position[d1] + m_position[d2]) * typename PFP::REAL(0.5); + m_map.incCurrentLevel(); + + m_position[d] = p; + + return false; + } +} ; + +template +class LerpFaceVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + AttributeHandler& m_position ; + +public: + LerpFaceVertexFunctor(typename PFP::MAP& m, AttributeHandler& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart df = m_map.phi1(m_map.phi1(d)) ; + + m_map.decCurrentLevel() ; + typename PFP::VEC3 p = Algo::Surface::Geometry::faceCentroid(m_map, df, m_position); + m_map.incCurrentLevel() ; + + m_position[d] = p ; + + return false ; + } +} ; + +template +class LerpVolumeVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + AttributeHandler& m_position ; + +public: + LerpVolumeVertexFunctor(typename PFP::MAP& m, AttributeHandler& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ; + + m_map.decCurrentLevel() ; + typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, df, m_position); + m_map.incCurrentLevel() ; + + m_position[d] = p ; + + + return false ; + } +} ; + + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + + +#endif /* __3MR_FUNCTORS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/mcCrackenJoy.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/mcCrackenJoy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5b032127852fbb685a50553f8a4afb615384dd76 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/mcCrackenJoy.cpp @@ -0,0 +1,365 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_MCCRACKENJOY_MASK__ +#define __3MR_MCCRACKENJOY_MASK__ + +#include +#include "Algo/Geometry/centroid.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Masks +{ + + + +/* MJ96 basic functions : polyhedral meshes + *********************************************************************************/ +template +class MJ96VertexVertexFunctor : public FunctorType +{ +protected: + typedef typename EMBV::DATA_TYPE EMB; + typename PFP::MAP& m_map ; + EMBV& m_attribut; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + +public: + //MJ96VertexVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + //MJ96VertexVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + MJ96VertexVertexFunctor(typename PFP::MAP& m, EMBV& p) : m_map(m), m_attribut(p) + {} + + bool operator() (Dart d) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + m_map.decCurrentLevel() ; + + EMB np1(0.0) ; + EMB np2(0.0) ; + unsigned int degree1 = 0 ; + unsigned int degree2 = 0 ; + Dart it = db ; + do + { + ++degree1 ; + Dart dd = m_map.phi1(it) ; + np1 += m_attribut[dd] ; + Dart end = m_map.phi_1(it) ; + dd = m_map.phi1(dd) ; + do + { + ++degree2 ; + np2 += m_attribut[dd] ; + dd = m_map.phi1(dd) ; + } while(dd != end) ; + it = m_map.phi2(m_map.phi_1(it)) ; + } while(it != db) ; + + float beta = 3.0 / (2.0 * degree1) ; + float gamma = 1.0 / (4.0 * degree2) ; + np1 *= beta / degree1 ; + np2 *= gamma / degree2 ; + + EMB vp = m_attribut[db] ; + vp *= 1.0 - beta - gamma ; + + m_map.incCurrentLevel() ; + + m_attribut[d] = np1 + np2 + vp ; + } + else + { + m_map.decCurrentLevel() ; + + EMB P = m_attribut[d]; + + //vertex points + EMB Cavg = EMB(0); + unsigned int degree = 0; + Traversor3VW travVW(m_map, d); + for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) + { + Cavg += Algo::Surface::Geometry::volumeCentroid(m_map, dit, m_attribut); + ++degree; + } + Cavg /= degree; + + EMB Aavg(0.0); + degree = 0; + Traversor3VF travVF(m_map, d); + for(Dart dit = travVF.begin() ; dit != travVF.end() ; dit = travVF.next()) + { + Aavg += Algo::Surface::Geometry::faceCentroid(m_map, dit, m_attribut); + ++degree; + } + Aavg /= degree; + + EMB Mavg(0.0); + degree = 0; + Traversor3VE travVE(m_map, d); + for(Dart dit = travVE.begin() ; dit != travVE.end() ; dit = travVE.next()) + { + Dart d2 = m_map.phi2(dit); + Mavg += (m_attribut[dit] + m_attribut[d2]) * typename PFP::REAL(0.5); + ++degree; + } + Mavg /= degree; + + EMB vp = Cavg + Aavg * 3 + Mavg * 3 + P; + vp /= 8; + + m_map.incCurrentLevel() ; + + m_attribut[d] = vp; + } + + return false; + } +}; + +template +class MJ96EdgeVertexFunctor : public FunctorType +{ +protected: + typedef typename EMBV::DATA_TYPE EMB; + typename PFP::MAP& m_map ; + EMBV& m_attribut; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + +public: + //MJ96EdgeVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + //MJ96EdgeVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + MJ96EdgeVertexFunctor(typename PFP::MAP& m, EMBV& p) : m_map(m), m_attribut(p) + {} + + bool operator() (Dart d) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + + Dart d1 = m_map.phi2(db) ; + + m_map.decCurrentLevel() ; + + Dart d2 = m_map.phi2(d1) ; + Dart d3 = m_map.phi_1(d1) ; + Dart d4 = m_map.phi_1(d2) ; + Dart d5 = m_map.phi1(m_map.phi1(d1)) ; + Dart d6 = m_map.phi1(m_map.phi1(d2)) ; + + EMB p1 = m_attribut[d1] ; + EMB p2 = m_attribut[d2] ; + EMB p3 = m_attribut[d3] ; + EMB p4 = m_attribut[d4] ; + EMB p5 = m_attribut[d5] ; + EMB p6 = m_attribut[d6] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 16.0 ; + p4 *= 1.0 / 16.0 ; + p5 *= 1.0 / 16.0 ; + p6 *= 1.0 / 16.0 ; + + m_map.incCurrentLevel() ; + + m_attribut[d] = p1 + p2 + p3 + p4 + p5 + p6 ; + } + else + { + Dart d2 = m_map.phi2(d); + + m_map.decCurrentLevel() ; + + //edge points + EMB Cavg(0.0); + unsigned int degree = 0; + Traversor3EW travEW(m_map, d2); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + Cavg += Algo::Surface::Geometry::volumeCentroid(m_map, dit, m_attribut); + ++degree; + } + Cavg /= degree; + + EMB Aavg(0.0); + degree = 0; + Traversor3EF travEF(m_map, d2); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + Aavg += Algo::Surface::Geometry::faceCentroid(m_map, dit, m_attribut); + ++degree; + } + Aavg /= degree; + + Dart d22 = m_map.phi2(d2); + EMB M = (m_attribut[d2] + m_attribut[d22]) * typename PFP::REAL(0.5); + + EMB ep = Cavg + Aavg * 2 + M * (degree - 3); + ep /= degree; + + m_map.incCurrentLevel() ; + + m_attribut[d] = ep; + } + + return false; + } +}; + +template +class MJ96FaceVertexFunctor : public FunctorType +{ +protected: + typedef typename EMBV::DATA_TYPE EMB; + typename PFP::MAP& m_map ; + EMBV& m_attribut; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + +public: + //MJ96FaceVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + //MJ96FaceVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + MJ96FaceVertexFunctor(typename PFP::MAP& m, EMBV& p) : m_map(m), m_attribut(p) + {} + + bool operator() (Dart d) + { + if(m_map.isBoundaryFace(d)) + { + Dart db = m_map.phi_1(m_map.phi3(d)); + + m_map.decCurrentLevel() ; + + EMB p(0.0) ; + unsigned int degree = 0 ; + Traversor2FV trav(m_map, db) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + p += m_attribut[it] ; + } + p /= degree ; + + m_map.incCurrentLevel() ; + + m_attribut[d] = p ; + } + else + { + Dart df = m_map.phi1(m_map.phi1(d)) ; + + m_map.decCurrentLevel() ; + + //face points + EMB C0 = Algo::Surface::Geometry::volumeCentroid(m_map, df, m_attribut); + EMB C1 = Algo::Surface::Geometry::volumeCentroid(m_map, m_map.phi3(df), m_attribut); + + EMB A = Algo::Surface::Geometry::faceCentroid(m_map, df, m_attribut); + + EMB fp = C0 + A * 2 + C1; + fp /= 4; + + m_map.incCurrentLevel() ; + + m_attribut[d] = fp; + } + + return false; + } + +}; + +template +class MJ96VolumeVertexFunctor : public FunctorType +{ +protected: + typedef typename EMBV::DATA_TYPE EMB; + typename PFP::MAP& m_map ; + EMBV& m_attribut; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + //Algo::Volume::IHM::AttributeHandler_IHM& m_position ; + +public: + //MJ96VolumeVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + //MJ96VolumeVertexFunctor(typename PFP::MAP& m, Algo::Volume::IHM::AttributeHandler_IHM& p) : m_map(m), m_position(p) + MJ96VolumeVertexFunctor(typename PFP::MAP& m, EMBV& p) : m_map(m), m_attribut(p) + {} + + bool operator() (Dart d) + { + Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ; + + m_map.decCurrentLevel() ; + + //cell points : these points are the average of the + //vertices of the lattice that bound the cell + EMB p = Algo::Surface::Geometry::volumeCentroid(m_map,df,m_attribut); + + m_map.incCurrentLevel() ; + + m_attribut[d] = p; + + return false; + } +}; + + + + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + + +#endif /* __3MR_FUNCTORS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/schaefer.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/schaefer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7bd77230856063a7389f77e933d0501e11023b9f --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/schaefer.cpp @@ -0,0 +1,323 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_SCHAEFER_MASK__ +#define __3MR_SCHAEFER_MASK__ + +#include +#include "Algo/Geometry/centroid.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Masks +{ + + +/********************************************************************************* + * LOOP BASIC FUNCTIONS + *********************************************************************************/ +template +typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const AttributeHandler& position, Dart d1) +{ + Dart d2 = map.phi2(d1) ; + Dart d3 = map.phi_1(d1) ; + Dart d4 = map.phi_1(d2) ; + + typename PFP::VEC3 p1 = position[d1] ; + typename PFP::VEC3 p2 = position[d2] ; + typename PFP::VEC3 p3 = position[d3] ; + typename PFP::VEC3 p4 = position[d4] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 8.0 ; + p4 *= 1.0 / 8.0 ; + + return p1 + p2 + p3 + p4 ; +} + +template +typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const AttributeHandler& position, Dart d) +{ + map.incCurrentLevel() ; + + typename PFP::VEC3 np(0) ; + unsigned int degree = 0 ; + Traversor2VVaE trav(map, d) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + np += position[it] ; + } + + map.decCurrentLevel() ; + + float mu = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ; + mu = (5.0/8.0 - (mu * mu)) / degree ; + np *= 8.0/5.0 * mu ; + + return np ; +} + +/********************************************************************************* + * SHW04 BASIC FUNCTIONS : tetrahedral/octahedral meshes + *********************************************************************************/ +template +typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const AttributeHandler& position, Dart d) +{ + typename PFP::VEC3 res(0); + + if(map.isTetrahedron(d)) + { + Dart d1 = map.phi1(d) ; + Dart d2 = map.phi_1(d); + Dart d3 = map.phi_1(map.phi2(d)); + + typename PFP::VEC3 p = position[d]; + typename PFP::VEC3 p1 = position[d1] ; + typename PFP::VEC3 p2 = position[d2] ; + typename PFP::VEC3 p3 = position[d3] ; + + p *= -1; + p1 *= 17.0 / 3.0; + p2 *= 17.0 / 3.0; + p3 *= 17.0 / 3.0; + + res += p + p1 + p2 + p3; + res *= 1.0 / 16.0; + } + else + { + Dart d1 = map.phi1(d); + Dart d2 = map.phi_1(d); + Dart d3 = map.phi_1(map.phi2(d)); + Dart d4 = map.phi_1(map.phi2(d3)); + Dart d5 = map.phi_1(map.phi2(map.phi_1(d))); + + typename PFP::VEC3 p = position[d]; + typename PFP::VEC3 p1 = position[d1] ; + typename PFP::VEC3 p2 = position[d2] ; + typename PFP::VEC3 p3 = position[d3] ; + typename PFP::VEC3 p4 = position[d4] ; + typename PFP::VEC3 p5 = position[d5] ; + + p *= 3.0 / 4.0; + p1 *= 1.0 / 6.0; + p2 *= 1.0 / 6.0; + p3 *= 1.0 / 6.0; + p4 *= 7.0 / 12.0; + p5 *= 1.0 / 6.0; + + res += p + p1 + p2 + p3 + p4 + p5; + res *= 1.0 / 2.0; + } + + return res; +} + + +/* SHW04 basic functions : tetrahedral/octahedral meshes + *********************************************************************************/ +template +class SHW04VertexVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + AttributeHandler& m_position ; + +public: + SHW04VertexVertexFunctor(typename PFP::MAP& m, AttributeHandler& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + m_map.decCurrentLevel() ; + + typename PFP::VEC3 np(0) ; + unsigned int degree = 0 ; + Traversor2VVaE trav(m_map, db) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + np += m_position[it] ; + } + float tmp = 3.0 + 2.0 * cos(2.0 * M_PI / degree) ; + float beta = (5.0 / 8.0) - ( tmp * tmp / 64.0 ) ; + np *= beta / degree ; + + typename PFP::VEC3 vp = m_position[db] ; + vp *= 1.0 - beta ; + + m_map.incCurrentLevel() ; + + m_position[d] = np + vp ; + } + else + { + typename PFP::VEC3 p = typename PFP::VEC3(0); + unsigned int degree = 0; + + m_map.decCurrentLevel() ; + + Traversor3VW travVW(m_map, d); + for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) + { + p += SHW04Vertex(m_map, m_position, dit); + ++degree; + } + + p /= degree; + + m_map.incCurrentLevel() ; + + m_position[d] = p ; + } + return false ; + } +} ; + +template +class SHW04EdgeVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + AttributeHandler& m_position ; + +public: + SHW04EdgeVertexFunctor(typename PFP::MAP& m, AttributeHandler& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + if(m_map.isBoundaryEdge(d)) + { + Dart dd = m_map.phi2(d) ; + m_map.decCurrentLevel() ; + + Dart d1 = m_map.findBoundaryFaceOfEdge(dd); + + Dart d2 = m_map.phi2(d1) ; + Dart d3 = m_map.phi_1(d1) ; + Dart d4 = m_map.phi_1(d2) ; + + typename PFP::VEC3 p1 = m_position[d1] ; + typename PFP::VEC3 p2 = m_position[d2] ; + typename PFP::VEC3 p3 = m_position[d3] ; + typename PFP::VEC3 p4 = m_position[d4] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 8.0 ; + p4 *= 1.0 / 8.0 ; + + m_map.incCurrentLevel() ; + + m_position[d] = p1 + p2 + p3 + p4 ; + } + else + { + Dart d1 = m_map.phi2(d); + + m_map.decCurrentLevel(); + Dart d2 = m_map.phi2(d1); + typename PFP::VEC3 mid = (m_position[d1] + m_position[d2]) * typename PFP::REAL(0.5); + + + typename PFP::VEC3 p = typename PFP::VEC3(0); + unsigned int degree = 0; + + Traversor3VW travVW(m_map, d); + for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) + { + p += SHW04Vertex(m_map, m_position, dit); + ++degree; + } + + p /= degree; + + m_map.incCurrentLevel(); + + m_position[d] = mid + p ; + } + + return false ; + } +} ; + +template +class SHW04VolumeVertexFunctor : public FunctorType +{ +protected: + typename PFP::MAP& m_map ; + AttributeHandler& m_position; + +public: + SHW04VolumeVertexFunctor(typename PFP::MAP& m, AttributeHandler& p) : m_map(m), m_position(p) + {} + + bool operator() (Dart d) + { + Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ; + + m_map.decCurrentLevel() ; + typename PFP::VEC3 p = Algo::Geometry::volumeCentroid(m_map, df, m_position); + m_map.incCurrentLevel() ; + + m_position[d] = p ; + + return false; + } +}; + +} // namespace Masks + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#endif /* __3MR_FUNCTORS_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/schemes_Primal.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/schemes_Primal.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dcf3f6025d44ccd08061f4d9c20a63177872345e --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/Masks/schemes_Primal.cpp @@ -0,0 +1,987 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __3MR_SCHEMES_PRIMAL__ +#define __3MR_SCHEMES_PRIMAL__ + +#include +#include "Algo/Geometry/centroid.h" + +namespace CGoGN +{ + +namespace Multiresolution +{ + +class MRScheme +{ +public: + MRScheme() {} + virtual ~MRScheme() {} + virtual void operator() () = 0 ; +} ; + + + + + +/* Loop on Boundary Vertices and SHW04 on Insides Vertices + *********************************************************************************/ +template +class LoopEvenSubdivisionScheme : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopEvenSubdivisionScheme(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + typename PFP::VEC3 np(0) ; + unsigned int degree = 0 ; + Traversor2VVaE trav(m_map, db) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + np += m_position[it] ; + } + float tmp = 3.0 + 2.0 * cos(2.0 * M_PI / degree) ; + float beta = (5.0 / 8.0) - ( tmp * tmp / 64.0 ) ; + np *= beta / degree ; + + typename PFP::VEC3 vp = m_position[db] ; + vp *= 1.0 - beta ; + + m_map.incCurrentLevel() ; + + m_position[d] = np + vp ; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class LoopOddSubdivisionScheme : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + LoopOddSubdivisionScheme(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 p = loopOddVertex(m_map, m_position, db) ; + + m_map.incCurrentLevel() ; + + Dart oddV = m_map.phi2(db) ; + m_position[oddV] = p ; + + m_map.decCurrentLevel() ; + } + else + { + typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d) ; + m_position[midV] = p ; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class SHW04SubdivisionScheme : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + SHW04SubdivisionScheme(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(!m_map.isTetrahedron(d)) + { + typename PFP::VEC3 p = Algo::Geometry::volumeCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] = p ; + + m_map.decCurrentLevel() ; + } + } + + m_map.incCurrentLevel() ; + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(!m_map.isBoundaryVertex(d)) + { + typename PFP::VEC3 p = typename PFP::VEC3(0); + unsigned int degree = 0; + + Traversor3VW travVW(m_map, d); + for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) + { + p += SHW04Vertex(m_map, m_position, dit); + ++degree; + } + + p /= degree; + + m_position[d] = p ; + } + } + m_map.decCurrentLevel() ; + + } +}; + +/* Catmull-clark on Boundary Vertices and MJ96 on Insides Vertices + *********************************************************************************/ +template +class MJ96VertexSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96VertexSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryVertex(d)) + { + Dart db = m_map.findBoundaryFaceOfVertex(d); + + typename PFP::VEC3 np1(0) ; + typename PFP::VEC3 np2(0) ; + unsigned int degree1 = 0 ; + unsigned int degree2 = 0 ; + Dart it = db ; + do + { + ++degree1 ; + Dart dd = m_map.phi1(it) ; + np1 += m_position[dd] ; + Dart end = m_map.phi_1(it) ; + dd = m_map.phi1(dd) ; + do + { + ++degree2 ; + np2 += m_position[dd] ; + dd = m_map.phi1(dd) ; + } while(dd != end) ; + it = m_map.phi2(m_map.phi_1(it)) ; + } while(it != db) ; + + float beta = 3.0 / (2.0 * degree1) ; + float gamma = 1.0 / (4.0 * degree2) ; + np1 *= beta / degree1 ; + np2 *= gamma / degree2 ; + + typename PFP::VEC3 vp = m_position[db] ; + vp *= 1.0 - beta - gamma ; + + m_map.incCurrentLevel() ; + + m_position[d] = np1 + np2 + vp ; + + m_map.decCurrentLevel() ; + + } + else + { + typename PFP::VEC3 P = m_position[d]; + + //vertex points + typename PFP::VEC3 Cavg = typename PFP::VEC3(0); + unsigned int degree = 0; + Traversor3VW travVW(m_map, d); + for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) + { + Cavg += Algo::Geometry::volumeCentroid(m_map, dit, m_position); + ++degree; + } + Cavg /= degree; + + typename PFP::VEC3 Aavg = typename PFP::VEC3(0); + degree = 0; + Traversor3VF travVF(m_map, d); + for(Dart dit = travVF.begin() ; dit != travVF.end() ; dit = travVF.next()) + { + Aavg += Algo::Geometry::faceCentroid(m_map, dit, m_position); + ++degree; + } + Aavg /= degree; + + typename PFP::VEC3 Mavg = typename PFP::VEC3(0); + degree = 0; + Traversor3VE travVE(m_map, d); + for(Dart dit = travVE.begin() ; dit != travVE.end() ; dit = travVE.next()) + { + Dart d2 = m_map.phi2(dit); + Aavg += (m_position[dit] + m_position[d2]) * typename PFP::REAL(0.5); + ++degree; + } + Aavg /= degree; + + typename PFP::VEC3 vp = Cavg + Aavg * 3 + Mavg * 3 + P; + vp /= 8; + + m_map.incCurrentLevel() ; + + m_position[d] = P;//vp; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class MJ96EdgeSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96EdgeSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + + Dart d1 = m_map.phi2(db) ; + Dart d2 = m_map.phi2(d1) ; + Dart d3 = m_map.phi_1(d1) ; + Dart d4 = m_map.phi_1(d2) ; + Dart d5 = m_map.phi1(m_map.phi1(d1)) ; + Dart d6 = m_map.phi1(m_map.phi1(d2)) ; + + typename PFP::VEC3 p1 = m_position[d1] ; + typename PFP::VEC3 p2 = m_position[d2] ; + typename PFP::VEC3 p3 = m_position[d3] ; + typename PFP::VEC3 p4 = m_position[d4] ; + typename PFP::VEC3 p5 = m_position[d5] ; + typename PFP::VEC3 p6 = m_position[d6] ; + + p1 *= 3.0 / 8.0 ; + p2 *= 3.0 / 8.0 ; + p3 *= 1.0 / 16.0 ; + p4 *= 1.0 / 16.0 ; + p5 *= 1.0 / 16.0 ; + p6 *= 1.0 / 16.0 ; + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d); + + m_position[midV] = p1 + p2 + p3 + p4 + p5 + p6 ; + + m_map.decCurrentLevel() ; + } + else + { + //edge points + typename PFP::VEC3 Cavg = typename PFP::VEC3(0); + unsigned int degree = 0; + Traversor3EW travEW(m_map, d); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + Cavg += Algo::Geometry::volumeCentroid(m_map, dit, m_position); + ++degree; + } + Cavg /= degree; + + typename PFP::VEC3 Aavg = typename PFP::VEC3(0); + degree = 0; + Traversor3EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + Aavg += Algo::Geometry::faceCentroid(m_map, dit, m_position); + ++degree; + } + Aavg /= degree; + + Dart d2 = m_map.phi2(d); + typename PFP::VEC3 M = (m_position[d] + m_position[d2]) * typename PFP::REAL(0.5); + + typename PFP::VEC3 ep = Cavg + Aavg * 2 + M * (degree - 3); + ep /= degree; + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(d); + + m_position[midV] = ep; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class MJ96FaceSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96FaceSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + if(m_map.isBoundaryFace(d)) + { + Dart db = m_map.phi3(d); + + typename PFP::VEC3 p(0) ; + unsigned int degree = 0 ; + Traversor2FV trav(m_map, db) ; + for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) + { + ++degree ; + p += m_position[it] ; + } + p /= degree ; + + m_map.incCurrentLevel() ; + + Dart df = m_map.phi1(m_map.phi1(d)) ; + + m_position[df] = p ; + + m_map.decCurrentLevel() ; + } + else + { + //face points + typename PFP::VEC3 C0 = Algo::Geometry::volumeCentroid(m_map, d, m_position); + typename PFP::VEC3 C1 = Algo::Geometry::volumeCentroid(m_map, m_map.phi3(d), m_position); + + typename PFP::VEC3 A = Algo::Geometry::faceCentroid(m_map, m_map.phi3(d), m_position); + + typename PFP::VEC3 fp = C0 + A * 2 + C1; + fp /= 4; + + m_map.incCurrentLevel() ; + + Dart df = m_map.phi1(m_map.phi1(d)) ; + m_position[df] = fp; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class MJ96VolumeSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MJ96VolumeSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + //cell points : these points are the average of the + //vertices of the lattice that bound the cell + typename PFP::VEC3 p = Algo::Geometry::volumeCentroid(m_map, d, m_position); + + m_map.incCurrentLevel() ; + + if(!m_map.isTetrahedron(d)) + { + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] = p ; + } + + m_map.decCurrentLevel() ; + + } + } +}; + +/* Lerp on Boundary Vertices and on Insides Vertices and BSXW02 Averaging + *********************************************************************************/ + +template +class BSXW02AveragingSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + BSXW02AveragingSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + m_map.incCurrentLevel() ; + TraversorV trav(m_map) ; + for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next()) + { + if(m_map.isBoundaryVertex(ditE)) + { + Dart db = m_map.findBoundaryFaceOfVertex(ditE); + + typename PFP::VEC3 P(0); + unsigned int count = 0; + Traversor2VF travVF(m_map, db); + for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next()) + { + P += Algo::Geometry::faceCentroid(m_map, ditVF, m_position); + ++count; + } + + P /= count; + + m_position[db] = P; + } + else if(m_map.isBoundaryEdge(ditE)) + { + Dart db = m_map.findBoundaryEdgeOfVertex(ditE); + + typename PFP::VEC3 P(0); + unsigned int count = 0; + Traversor2VF travVF(m_map, db); + for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next()) + { + P += Algo::Geometry::faceCentroid(m_map, ditVF, m_position); + ++count; + } + + P /= count; + + m_position[db] = P; + } + else + { + typename PFP::VEC3 P(0); + unsigned int count = 0; + Traversor3VW travVF(m_map, ditE); + for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next()) + { + P += Algo::Geometry::volumeCentroid(m_map, ditVF, m_position); + ++count; + } + + P /= count; + + m_position[ditE] = P; + } + } + m_map.decCurrentLevel() ; + } +}; + +template +class BSXW02EdgeAveragingSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + BSXW02EdgeAveragingSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorE trav(m_map) ; + for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next()) + { + if(m_map.isBoundaryEdge(ditE)) + { + Dart db = m_map.findBoundaryFaceOfEdge(ditE); + + m_map.incCurrentLevel() ; + + db = m_map.phi1(db); + + typename PFP::VEC3 P(0); + unsigned int count = 0; + Traversor2VF travVF(m_map, db); + for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next()) + { + P += Algo::Geometry::faceCentroid(m_map, ditVF, m_position); + ++count; + } + + P /= count; + + m_position[db] = P; + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class BSXW02FaceAveragingSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + BSXW02FaceAveragingSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorF trav(m_map) ; + for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next()) + { + if(m_map.isBoundaryFace(ditE)) + { + Dart db = m_map.phi3(ditE); + + m_map.incCurrentLevel() ; + + if(m_map.faceDegree(db) != 3) + { + db = m_map.phi2(m_map.phi1(db)); + + typename PFP::VEC3 P(0); + unsigned int count = 0; + Traversor2VF travVF(m_map, db); + for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next()) + { + P += Algo::Geometry::faceCentroid(m_map, ditVF, m_position); + ++count; + } + + P /= count; + + m_position[db] = P; + + } + + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class BSXW02VolumeAveragingSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + BSXW02VolumeAveragingSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorW trav(m_map) ; + for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next()) + { + m_map.incCurrentLevel() ; + if(!m_map.isTetrahedron(ditE)) + { + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(ditE))); + + typename PFP::VEC3 P(0); + unsigned int count = 0; + Traversor3VW travVF(m_map, midV); + for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next()) + { + P += Algo::Geometry::volumeCentroid(m_map, ditVF, m_position); + ++count; + } + + P /= count; + + m_position[midV] = P; + } + m_map.decCurrentLevel() ; + } + } +}; + +/* DHL93 on Boundary Vertices and MCQ04 on Insides Vertices + *********************************************************************************/ +template +class MCQ04VertexSubdivision: public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MCQ04VertexSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + TraversorV trav(m_map) ; + for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) + { + typename PFP::VEC3 p = m_position[d]; + + m_map.incCurrentLevel() ; + m_position[d] = p ; + m_map.decCurrentLevel() ; + } + } +} ; + +template +class MCQ04EdgeSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MCQ04EdgeSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + typename PFP::REAL omega = 1.0/16.0; + + TraversorE trav(m_map) ; + for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next()) + { + if(m_map.isBoundaryEdge(ditE)) + { + Dart db = m_map.findBoundaryFaceOfEdge(ditE); + + + typename PFP::VEC3 p = (m_position[db] + m_position[m_map.phi2(db)]) * typename PFP::REAL(0.5); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(db) ; + m_position[midV] = p ; + + m_map.decCurrentLevel() ; + + } + else + { + typename PFP::VEC3 P = ( m_position[ditE] + m_position[m_map.phi2(ditE)] ) * typename PFP::REAL(0.5); + + typename PFP::VEC3 Q(0); + typename PFP::VEC3 R(0); + unsigned int count = 0; + Dart dit = ditE; + do + { + Dart d_1 = m_map.phi_1(dit); + Dart d11 = m_map.phi1(m_map.phi1(dit)); + + Q += m_position[d_1]; + Q += m_position[d11]; + ++count; + + Dart dr1 = m_map.phi1(m_map.phi1(m_map.alpha2(d_1))); + R += m_position[dr1]; + + Dart dr2 = m_map.phi1(m_map.phi1(m_map.alpha2(m_map.phi1(dit)))); + R += m_position[dr2]; + + + dit = m_map.alpha2(dit); + }while(dit != ditE); + + Q *= (omega / count); + + R *= (omega / count); + + m_map.incCurrentLevel() ; + + Dart midV = m_map.phi2(ditE); + + m_position[midV] = P + Q - R; + + m_map.decCurrentLevel() ; + + + } + } + } +}; + +template +class MCQ04FaceSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MCQ04FaceSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + typename PFP::REAL omega = 1.0/16.0; + + TraversorF trav(m_map) ; + for (Dart ditF = trav.begin(); ditF != trav.end(); ditF = trav.next()) + { + if(m_map.isBoundaryFace(ditF)) + { + typename PFP::VEC3 p = Algo::Geometry::faceCentroid(m_map, ditF, m_position); + + m_map.incCurrentLevel() ; + if(m_map.faceDegree(ditF) != 3) + { + Dart midF = m_map.phi2(m_map.phi1(ditF)); + m_position[midF] = p ; + } + m_map.decCurrentLevel() ; + + } + else + { + //Calcul des Pi + typename PFP::VEC3 P(0); + CellMarker mv(m_map); + Traversor3FV travFV(m_map, ditF); + for (Dart ditFV = travFV.begin(); ditFV != travFV.end(); ditFV = travFV.next()) + { + P += m_position[ditFV]; + mv.mark(ditFV); + } + + P *= (2.0 * omega + 1) / 4.0; + + //Calcul des Qi + typename PFP::VEC3 Q(0); + Traversor3FW travFW(m_map, ditF); + for (Dart ditFW = travFW.begin(); ditFW != travFW.end(); ditFW = travFW.next()) + { + Traversor3WV travWV(m_map, ditFW); + for(Dart ditFV = travWV.begin() ; ditFV != travWV.end() ; ditFV = travWV.next()) + { + if(!mv.isMarked(ditFV)) + { + Q += m_position[ditFV]; + mv.mark(ditFV); + } + } + } + + Q *= omega / 4.0; + + //Calcul des Ri + typename PFP::VEC3 R(0); + Traversor3FFaE travFFaE(m_map, ditF); + for (Dart ditFFaE = travFFaE.begin(); ditFFaE != travFFaE.end(); ditFFaE = travFFaE.next()) + { + Traversor3FV travFV(m_map, ditFFaE); + for (Dart ditFV = travFV.begin(); ditFV != travFV.end(); ditFV = travFV.next()) + { + if(!mv.isMarked(ditFV)) + { + R += m_position[ditFV]; + mv.mark(ditFV); + } + } + } + + R *= omega / 4.0; + + //Calcul des Si + typename PFP::VEC3 S(0); + Traversor3FFaV travFFaV(m_map, ditF); + for (Dart ditFFaV = travFFaV.begin(); ditFFaV != travFFaV.end(); ditFFaV = travFFaV.next()) + { + Traversor3FV travFV(m_map, ditFFaV); + for (Dart ditFV = travFV.begin(); ditFV != travFV.end(); ditFV = travFV.next()) + { + if(!mv.isMarked(ditFV)) + { + S += m_position[ditFV]; + mv.mark(ditFV); + } + } + } + + S *= omega / 8.0; + + m_map.incCurrentLevel() ; + if(m_map.faceDegree(ditF) != 3) + { + Dart midF = m_map.phi2(m_map.phi1(ditF)); + m_position[midF] = P + Q - R - S ; + } + m_map.decCurrentLevel() ; + } + } + } +}; + +template +class MCQ04VolumeSubdivision : public MRScheme +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + MCQ04VolumeSubdivision(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { + typename PFP::REAL omega = 1.0/16.0; + + TraversorW trav(m_map) ; + for (Dart ditW = trav.begin(); ditW != trav.end(); ditW = trav.next()) + { + + if(m_map.isBoundaryAdjacentVolume(ditW)) + { + typename PFP::VEC3 p = Algo::Geometry::volumeCentroid(m_map, ditW, m_position); + + m_map.incCurrentLevel() ; + + if(!m_map.isTetrahedron(ditW)) + { + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(ditW))); + m_position[midV] = p ; + } + + m_map.decCurrentLevel() ; + } + else + { + CellMarker mv(m_map); + + typename PFP::VEC3 P(0); + Traversor3WV travWV(m_map, ditW); + for(Dart ditWV = travWV.begin() ; ditWV != travWV.end() ; ditWV = travWV.next()) + { + P += m_position[ditWV]; + mv.mark(ditWV); + } + + P *= ((6.0 * omega + 1.0) / 8.0); + + typename PFP::VEC3 Q(0); + Traversor3WWaF travWWaF(m_map, ditW); + for(Dart ditWWaF = travWV.begin() ; ditWWaF != travWV.end() ; ditWWaF = travWV.next()) + { + Traversor3WV travWV(m_map, ditWWaF); + for(Dart ditWV = travWV.begin() ; ditWV != travWV.end() ; ditWV = travWV.next()) + { + if(!mv.isMarked(ditWV)) + { + Q += m_position[ditWV]; + } + } + } + + Q *= omega / 4.0; + + + m_map.incCurrentLevel() ; + + if(!m_map.isTetrahedron(ditW)) + { + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(ditW))); + m_position[midV] = P - Q; + } + + m_map.decCurrentLevel() ; + } + } + } +}; + +} // namespace Multiresolution + +} // namespace CGoGN + + +#endif /* __3MR_SCHEMES_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_DualRegular.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_DualRegular.cpp new file mode 100644 index 0000000000000000000000000000000000000000..31c9f9300afa8b09865a2948468848c3fa2f9e0a --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_DualRegular.cpp @@ -0,0 +1,97 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP3MR_DUAL_REGULAR__ +#define __MAP3MR_DUAL_REGULAR__ + +#include "Topology/map/embeddedMap3.h" +#include "Topology/generic/traversorCell.h" +#include "Topology/generic/traversor3.h" + +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Dual +{ + +namespace Regular +{ + +template +class Map3MR +{ +public: + typedef typename PFP::MAP MAP ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + std::vector synthesisFilters ; + std::vector analysisFilters ; + +public: + Map3MR(MAP& map); + + ~Map3MR(); + + //if true : tri and quad else quad + void addNewLevel(bool embedNewVertices = true) ; + + void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } + + void clearSynthesisFilters() { synthesisFilters.clear() ; } + void clearAnalysisFilters() { analysisFilters.clear() ; } + + void analysis() ; + void synthesis() ; +} ; + +} // namespace Regular + +} // namespace Dual + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/Map3MR/map3MR_DualRegular.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PM.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de83cfa6a9ceedd85f8e14dbf771bd713a0656d7 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PM.cpp @@ -0,0 +1,125 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP3MR_PM__ +#define __MAP3MR_PM__ + +#include "Topology/map/embeddedMap3.h" +#include "Topology/generic/traversorCell.h" +#include "Topology/generic/traversor3.h" + +#include "Container/attributeContainer.h" + +#include "Algo/DecimationVolumes/selector.h" +#include "Algo/DecimationVolumes/edgeSelector.h" +#include "Algo/DecimationVolumes/geometryApproximator.h" + + +#include "Algo/Multiresolution/filter.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +template +class Map3MR_PM +{ +public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + +private: + MAP& m_map ; + VertexAttribute& m_position; + + bool m_initOk ; + + Algo::Volume::Decimation::EdgeSelector* m_selector ; + std::vector*> m_approximators ; + std::vector*> m_predictors ; + + Algo::Volume::Decimation::Approximator* m_positionApproximator ; + + std::vector synthesisFilters ; + std::vector analysisFilters ; + +public: + Map3MR_PM(MAP& map, VertexAttribute& position); + + ~Map3MR_PM(); + + //create a progressive mesh (a coarser level) + void createPM(Algo::Volume::Decimation::SelectorType s, Algo::Volume::Decimation::ApproximatorType a) ; + + void addNewLevel(unsigned int percentWantedVertices); + + void collapseEdge(Dart d); + + //coarsen the mesh -> analysis + void coarsen() ; + + //refine the mesh -> synthesis + void refine() ; + + bool initOk() { return m_initOk; } + + void addSynthesisFilter(Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(Filter* f) { analysisFilters.push_back(f) ; } + + void clearSynthesisFilters() { synthesisFilters.clear() ; } + void clearAnalysisFilters() { analysisFilters.clear() ; } + + /** + * Given the vertex of d in the current level, + * return a dart of from the vertex of the current level + */ + Dart vertexOrigin(Dart d) ; + +// /** +// * Return the level of the vertex of d in the current level map +// */ +// unsigned int vertexLevel(Dart d); +} ; + +} // namespace Multiresolution + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + + +#include "Algo/Multiresolution/Map3MR/map3MR_PM.hpp" + +#endif diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0704e6f54d03f9d9db12ded64f7c8a4ca1bd7cd2 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.cpp @@ -0,0 +1,212 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP3MR_PRIMAL_ADAPT__ +#define __MAP3MR_PRIMAL_ADAPT__ + +#include "Topology/map/embeddedMap3.h" +#include "Topology/generic/traversorCell.h" +#include "Topology/generic/traversor3.h" +#include "Algo/Modelisation/tetrahedralization.h" +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Adaptive +{ + +/*! \brief The class of adaptive 3-map MR + */ + +template +class Map3MR +{ + +public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings; + + FunctorType* vertexVertexFunctor ; + FunctorType* edgeVertexFunctor ; + FunctorType* faceVertexFunctor ; + FunctorType* volumeVertexFunctor ; + +public: + Map3MR(MAP& map); + + /*! @name Cells informations + * + *************************************************************************/ + //@{ + //! Return the level of the edge of d in the current level map + /* @param d Dart from the edge + */ + unsigned int edgeLevel(Dart d); + + //! Return the level of the face of d in the current level map + /* @param d Dart from the face + */ + unsigned int faceLevel(Dart d); + + //! Return the level of the volume of d in the current level map + /* @param d Dart from the volume + */ + unsigned int volumeLevel(Dart d); + + //! Return the oldest dart of the face of d in the current level map + /* @param d Dart from the edge + */ + Dart faceOldestDart(Dart d); + + //! Return the level of the edge of d in the current level map + /* @param d Dart from the edge + */ + Dart volumeOldestDart(Dart d); + + //! Return true if the edge of d in the current level map + //! has already been subdivided to the next level + /*! @param d Dart from the edge + */ + bool edgeIsSubdivided(Dart d) ; + + //! Return true if the face of d in the current level map + //! has already been subdivided to the next level + /*! @param d Dart from the face + */ + bool faceIsSubdivided(Dart d) ; + + //! Return true if the volume of d in the current level map + //! has already been subdivided to the next level + /*! @param d Dart from the volume + */ + bool volumeIsSubdivided(Dart d); + //@} + +//protected: + /*! @name Topological helping functions + * + *************************************************************************/ + //@{ + //! + /*! + */ + void swapEdges(Dart d, Dart e); + + void splitVolume(std::vector& vd); + + Dart cutEdge(Dart d) ; + + void splitFace(Dart d, Dart e) ; + //@} + + /*! @name Subdivision + * + *************************************************************************/ + //@{ + //! Subdivide the edge of d to the next level + /*! @param d Dart from the edge + */ + void subdivideEdge(Dart d) ; + + //! + /*! + */ + void coarsenEdge(Dart d); + + //! Subdivide the edge of d to the next level + /*! @param d Dart frome the face + */ + void subdivideFace(Dart d, bool triQuad) ; + + //! + /*! + */ + void coarsenFace(Dart d); + +public: + //! Subdivide the volume of d to hexahedral cells + /*! @param d Dart from the volume + */ + unsigned int subdivideVolume(Dart d, bool triQuad = true, bool OneLevelDifference = true); + + /*! + * \brief subdivideHexa + * + * Detailed description of the function + * \param d + * \param OneLevelDifference + * \return + */ + unsigned int subdivideHexa(Dart d, bool OneLevelDifference = true); + + //! Subdivide the volume of d to hexahedral cells + /*! @param d Dart from the volume + */ + void subdivideVolumeTetOcta(Dart d) ; + //@} + + /*! @name Vertices Attributes management + * + *************************************************************************/ + //@{ + void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; } + void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; } + void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } + void setVolumeVertexFunctor(FunctorType* f) { volumeVertexFunctor = f ; } + //@} +}; + +} // namespace Adaptive + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/Map3MR/map3MR_PrimalAdapt.hpp" + +#endif /* __MAP3MR_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.cpp b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.cpp new file mode 100644 index 0000000000000000000000000000000000000000..301cfb760a8879bee91d70cb3f618aee3d4195b9 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.cpp @@ -0,0 +1,161 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MAP3MR_PRIMAL_REGULAR_ +#define __MAP3MR_PRIMAL_REGULAR_ + +#include "Topology/map/embeddedMap3.h" +#include "Topology/generic/traversorCell.h" +#include "Topology/generic/traversor3.h" + +#include "Algo/Multiresolution/filter.h" +#include "Algo/Modelisation/tetrahedralization.h" +#include "Algo/Modelisation/subdivision.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Regular +{ + +/*! \brief The class of regular 3-map MR + */ + +template +class Map3MR +{ + +public: + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + +protected: + MAP& m_map; + bool shareVertexEmbeddings; + + std::vector synthesisFilters ; + std::vector analysisFilters ; + + +public: + Map3MR(MAP& map); + + ~Map3MR(); + +private: + /*! @name Topological helping functions + * + *************************************************************************/ + //@{ + + + void splitSurfaceInVolume(std::vector& vd, bool firstSideClosed = true, bool secondSideClosed = false); + //@} + +public: + + void swapEdges(Dart d, Dart e); + + + Dart swap2To2(Dart d); + void swap4To4(Dart d); + Dart swap2To3(Dart d); + void swapGen3To2(Dart d); + + /*! @name Level creation + * + *************************************************************************/ + //@{ + //! + /* + */ + void addNewLevelTetraOcta(); + + //! + /* + */ + void addNewLevelHexa(); + + //! + /* + */ + void addNewLevel(); + + void addNewLevelSqrt3(bool embedNewVertices = false); + + void addNewLevelSqrt3(bool embedNewVertices, VertexAttribute position); + void addNewLevelSqrt3Geom(bool embedNewVertices, VertexAttribute position); + + //! + /* + */ + //void addNewLevel(bool embedNewVertices); + //@} + + /*! @name Geometry modification + * Analysis / Synthesis + *************************************************************************/ + //@{ + + void setSharingVertexEmbeddings(bool b) { shareVertexEmbeddings = b; } + + void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } + + void clearSynthesisFilters() { synthesisFilters.clear() ; } + void clearAnalysisFilters() { analysisFilters.clear() ; } + + void analysis() ; + void synthesis() ; + //@} +}; + +} // namespace Regular + +} // namespace Primal + +} // namespace MR + +} // namespace Volume + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.hpp" + +#endif /* __MAP3MR_PRIMAL__ */ diff --git a/Apps/Tests/Algo/Multiresolution/filter.cpp b/Apps/Tests/Algo/Multiresolution/filter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a1c72d7f1e3fbf3c6cfc7433cf3b14effd5e3977 --- /dev/null +++ b/Apps/Tests/Algo/Multiresolution/filter.cpp @@ -0,0 +1,183 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __MR_FILTERS__ +#define __MR_FILTERS__ + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace MR +{ + +class Filter +{ +public: + Filter() {} + virtual ~Filter() {} + virtual void operator() () = 0 ; +} ; + +template +unsigned int vertexLevel(typename PFP::MAP& map, Vertex v) +{ + assert(map.getDartLevel(v.dart) <= map.getCurrentLevel() || !"vertexLevel : called with a dart inserted after current level") ; + + unsigned int level = map.getMaxLevel(); + + map.foreach_dart_of_orbit(v, [&] (Dart d) + { + unsigned int ldit = map.getDartLevel(d) ; + if(ldit < level) + level = ldit; + }); + +// Dart dit = d; +// do +// { +// unsigned int ldit = map.getDartLevel(dit) ; +// if(ldit < level) +// level = ldit; +// +// dit = map.phi2(map.phi_1(dit)); +// } +// while(dit != d); + + return level; +} + + +template +void filterLowPass(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevel) +{ + unsigned int cur = map.getCurrentLevel(); + unsigned int max = map.getMaxLevel(); + + map.setCurrentLevel(max); + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + if(vertexLevel(map,d) > cutoffLevel) + attIn[d] = T(0.0); + } + + map.setCurrentLevel(cur); +} + +template +void filterHighPass(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevel) +{ + unsigned int cur = map.getCurrentLevel(); + unsigned int max = map.getMaxLevel(); + + map.setCurrentLevel(max); + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + if(vertexLevel(map,d) < cutoffLevel) + attIn[d] = T(0.0); + } + + map.setCurrentLevel(cur); +} + +template +void filterBandPass(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevelLow, unsigned int cutoffLevelHigh) +{ + unsigned int cur = map.getCurrentLevel(); + unsigned int max = map.getMaxLevel(); + + map.setCurrentLevel(max); + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + unsigned int vLevel = vertexLevel(map,d); + if(cutoffLevelLow > vLevel && vLevel < cutoffLevelHigh) + attIn[d] = T(0.0); + } + + map.setCurrentLevel(cur); +} + +template +typename PFP::VEC3 doTwist(typename PFP::VEC3 pos, float t ) +{ + typedef typename PFP::VEC3 VEC3; + + float st = std::sin(t); + float ct = std::cos(t); + VEC3 new_pos; + + new_pos[0] = pos[0]*ct - pos[2]*st; + new_pos[2] = pos[0]*st + pos[2]*ct; + + new_pos[1] = pos[1]; + + return new_pos; +} + +template +void frequencyDeformation(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevel) +{ + float time = 1.0; + //float angle_deg_max = 0.4; + //float height = 0.4; + + float A = 20.0; + float frequency = 1.0; + float phase = time * 2.0; + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + typename PFP::VEC3 p = attIn[d]; + + float dist = std::sqrt(p[0]*p[0] + p[2]*p[2]); + + p[1] += A * std::sin(frequency * dist + phase); + +// float angle_deg = angle_deg_max * std::sin(time); +// float angle_rad = angle_deg * 3.14159 / 180.0; + +// float ang = (height*0.5 + attIn[d][1])/height * angle_rad; + +// attIn[d] = doTwist(attIn[d], ang); + } +} + +} // namespace MR + +} // namespace Algo + +} // namespace CGoGN + +#endif diff --git a/Apps/Tests/Algo/ProgressiveMesh/CMakeLists.txt b/Apps/Tests/Algo/ProgressiveMesh/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa0c6e87bc1fdf5ea04f8c7cf860b3efa44954ec --- /dev/null +++ b/Apps/Tests/Algo/ProgressiveMesh/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_progessiveMesh) + +add_executable( test_algo_progessiveMesh +algo_progressiveMesh.cpp +pmesh.cpp +vsplit.cpp +) + +target_link_libraries( test_algo_progessiveMesh + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/ProgressiveMesh/algo_progressiveMesh.cpp b/Apps/Tests/Algo/ProgressiveMesh/algo_progressiveMesh.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ba219f882876a5674654d0eb51e51cdc82678209 --- /dev/null +++ b/Apps/Tests/Algo/ProgressiveMesh/algo_progressiveMesh.cpp @@ -0,0 +1,12 @@ +#include + +extern int test_pmesh(); +extern int test_vsplit(); + +int main() +{ + test_pmesh(); + test_vsplit(); + + return 0; +} diff --git a/Apps/Tests/Algo/ProgressiveMesh/pmesh.cpp b/Apps/Tests/Algo/ProgressiveMesh/pmesh.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5475b03c53fc22a0e0245e6fe96f1dfc8e047dbf --- /dev/null +++ b/Apps/Tests/Algo/ProgressiveMesh/pmesh.cpp @@ -0,0 +1,35 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/ProgressiveMesh/pmesh.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +// TODO modif ProgressiveMesh +//template class Algo::Surface::PMesh::ProgressiveMesh; +//template class Algo::Surface::PMesh::ProgressiveMesh; +//template class Algo::Surface::PMesh::ProgressiveMesh; + + +int test_pmesh() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/ProgressiveMesh/vsplit.cpp b/Apps/Tests/Algo/ProgressiveMesh/vsplit.cpp new file mode 100644 index 0000000000000000000000000000000000000000..acb06a0916499f9fef6917dfdcdd51ebacb6996d --- /dev/null +++ b/Apps/Tests/Algo/ProgressiveMesh/vsplit.cpp @@ -0,0 +1,36 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/ProgressiveMesh/vsplit.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template class Algo::Surface::PMesh::VSplit; +template class Algo::Surface::PMesh::VSplit; +template class Algo::Surface::PMesh::VSplit; + + +int test_vsplit() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/Remeshing/CMakeLists.txt b/Apps/Tests/Algo/Remeshing/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..44137027ca2b8553b6d3e4aad9fb2133290ee46d --- /dev/null +++ b/Apps/Tests/Algo/Remeshing/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_remeshing) + +add_executable( test_algo_remeshing +algo_remeshing.cpp +pliant.cpp +) + +target_link_libraries( test_algo_remeshing + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/Remeshing/algo_remeshing.cpp b/Apps/Tests/Algo/Remeshing/algo_remeshing.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a3dbc854bfab65eb29c60847e92a3e2a99ffc6b4 --- /dev/null +++ b/Apps/Tests/Algo/Remeshing/algo_remeshing.cpp @@ -0,0 +1,10 @@ +#include + +extern int test_pliant(); + +int main() +{ + test_pliant(); + + return 0; +} diff --git a/Apps/Tests/Algo/Remeshing/pliant.cpp b/Apps/Tests/Algo/Remeshing/pliant.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cd6dad027c9d5578160cdf579b8ec87cab1f4534 --- /dev/null +++ b/Apps/Tests/Algo/Remeshing/pliant.cpp @@ -0,0 +1,35 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Remeshing/pliant.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template void Algo::Surface::Remeshing::pliantRemeshing(PFP1::MAP& map, VertexAttribute& position, VertexAttribute& normal); +template void Algo::Surface::Remeshing::pliantRemeshing(PFP2::MAP& map, VertexAttribute& position, VertexAttribute& normal); +template void Algo::Surface::Remeshing::pliantRemeshing(PFP3::MAP& map, VertexAttribute& position, VertexAttribute& normal); + + +int test_pliant() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/CMakeLists.txt b/Apps/Tests/Algo/Render/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e5319093323e62a18ea301f39e92dfd58413124a --- /dev/null +++ b/Apps/Tests/Algo/Render/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_render) + +add_executable( test_algo_render +algo_render.cpp +GL2/colorPerEdgeRender.cpp +GL2/colorPerFaceRender.cpp +GL2/dataPerFaceRender.cpp +GL2/drawerCells.cpp +GL2/explodeVolumeRender.cpp +GL2/mapRender.cpp +GL2/topo3PrimalRender.cpp +GL2/topo3Render.cpp +GL2/topoPrimalRender.cpp +GL2/topoRender.cpp +SVG/mapSVGRender.cpp +) + +target_link_libraries( test_algo_render + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + + diff --git a/Apps/Tests/Algo/Render/Deprecated/gl3mapRender.cpp b/Apps/Tests/Algo/Render/Deprecated/gl3mapRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75a68630a44969628c8b07af35490b7f29a6f6ce --- /dev/null +++ b/Apps/Tests/Algo/Render/Deprecated/gl3mapRender.cpp @@ -0,0 +1,294 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _GL3_MAP_RENDER_ +#define _GL3_MAP_RENDER_ + +#include +#include +#include + +#include "Topology/generic/dart.h" +#include "Topology/generic/functor.h" +#include "Topology/generic/attributeHandler.h" +#include "Container/convert.h" +#include "Geometry/vector_gen.h" + +#include "Utils/GLSLShader.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Render +{ + +namespace GL3 +{ + +enum drawingType { + TRIANGLES = 1, + LINES = 2, + POINTS = 4, + EXPLODED = 8, + FLAT_TRIANGLES = 16, + ERR = 32 +} ; + +enum bufferIndex { + TRIANGLE_INDICES = 0, + LINE_INDICES = 1, + POINT_INDICES = 2, + FLAT_BUFFER = 3, + FIRST_ATTRIBUTE_BUFFER = 4, +} ; + +const unsigned int NB_BUFFERS = 16 ; + +class MapRender +{ + +protected: + /** + * vbo buffers + */ + GLuint m_VBOBuffers[NB_BUFFERS] ; + + /** + * + */ + bool m_allocatedAttributes[NB_BUFFERS] ; + + /** + * + */ + bool m_usedAttributes[NB_BUFFERS] ; + + /** + * + */ + unsigned int m_AttributesDataSize[NB_BUFFERS]; + + /** + * + */ + std::map m_attributebyName; + + /** + * number of vertex attributes + */ + GLuint m_nbVertexAttrib ; + + /** + * number of indices of triangles + */ + GLuint m_nbIndicesTri ; + + /** + * number of indices of lines + */ + GLuint m_nbIndicesLines ; + + /** + * number of indices of points + */ + GLuint m_nbIndicesPoints ; + + /** + * number of elts for flat vbo + */ + GLuint m_nbFlatElts; + +public: + /** + * Constructor + */ + MapRender() ; + + /** + * Constructor that share vertices attributes vbo (position/normals/colors...) + */ + MapRender(const MapRender& mrvbo); + + /** + * Destructor + */ + ~MapRender() ; + +public: + /** + * update the data + * @param vertex_attrib vertex attrib id + * @param attrib attribute where data is stored + * @param conv Callback of attribute conversion (NULL if direct copy, default value) + */ + template + void updateData(unsigned int vertex_attrib, const ATTR_HANDLER& attrib, ConvertAttrib* conv = NULL) ; + + /** + * update the data + * @param va_name vertex attrib name (in shader) + * @param attrib attribute where data is stored + * @param conv Callback of attribute conversion (NULL if direct copy, default value) + */ + template + void updateData(const std::string& name, const ATTR_HANDLER& attrib, ConvertAttrib* conv = NULL) ; + + /** + * enable a vertex attribute for rendering (updateDate automatically enable attrib) + */ + void enableVertexAttrib(const std::string& name); + + /** + * disable a vertex attribute for rendering + */ + void disableVertexAttrib(const std::string& name); + + /** + * associate a name to a vertex attribute + * @param name the name in shader + * @param sh the shader + * @return the id to use with update (if not using name) + */ + unsigned int useVertexAttributeName(const std::string& name, const Utils::GLSLShader& sh); + +protected: + /** + * enable a vertex attribute for rendering (updateDate automatically enable attrib) + */ + void enableVertexAttrib(unsigned int index); + + /** + * disable a vertex attribute for rendering + */ + void disableVertexAttrib(unsigned int index); + + /** + * fill buffer directly from attribute + */ + template + void fillBufferDirect(unsigned int indexVBO, const ATTR_HANDLER& attrib) ; + + /** + * fill buffer with conversion from attribute + */ + template + void fillBufferConvert(unsigned int indexVBO, const ATTR_HANDLER& attrib, ConvertAttrib* conv) ; + + /** + * addition of indices table of one triangle + * @param d a dart of the triangle + * @param tableIndices the indices table + */ + template + void addTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices) ; + +public: + /** + * creation of indices table of triangles (optimized order) + * @param tableIndices the table where indices are stored + */ + template + void initTriangles(typename PFP::MAP& map,std::vector& tableIndices, unsigned int thread=0) ; + template + void initTrianglesOptimized(typename PFP::MAP& map,std::vector& tableIndices, unsigned int thread=0) ; + + /** + * creation of indices table of lines (optimized order) + * @param tableIndices the table where indices are stored + */ + template + void initLines(typename PFP::MAP& map, std::vector& tableIndices, unsigned int thread=0) ; + template + void initLinesOptimized(typename PFP::MAP& map, std::vector& tableIndices, unsigned int thread=0) ; + + /** + * creation of indices table of points + * @param tableIndices the table where indices are stored + */ + template + void initPoints(typename PFP::MAP& map,std::vector& tableIndices, unsigned int thread=0) ; + + /** + * creation of VBO for flat faces rendering + */ + template + void initFlatTriangles(typename PFP::MAP& map, unsigned int vertex_attrib_position , unsigned int thread=0); + + /** + * initialization of the VBO indices primitives + * computed by a traversal of the map + * @param prim primitive to draw: VBO_TRIANGLES, VBO_LINES + */ + template + void initPrimitives(typename PFP::MAP& map, int prim, bool optimized = true, unsigned int thread=0) ; + + /** + * initialization of the VBO indices primitives + * using the given table + * @param prim primitive to draw: VBO_TRIANGLES, VBO_LINES + */ + void initPrimitives(int prim, std::vector& tableIndices) ; + +protected: + /** + * Drawing triangles function + */ + void drawTriangles(bool bindColors = true) ; + + /** + * Drawing lines function + */ + void drawLines(bool bindColors = true) ; + + /** + * Drawing points function + */ + void drawPoints(bool bindColors = true) ; + + /** + * Drawing flat faces function + */ + void drawFlat(); + +public: + /** + * draw the VBO (function to call in the drawing callback) + */ + void draw(int prim, bool bindColors = true) ; +} ; + +} // namespace VBO + +} // namespace Render + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Render/gl3mapRender.hpp" + +#endif diff --git a/Apps/Tests/Algo/Render/Deprecated/vbo_MapRender.cpp b/Apps/Tests/Algo/Render/Deprecated/vbo_MapRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ffddddc8ce0b71304faa33767e1db756533e3d17 --- /dev/null +++ b/Apps/Tests/Algo/Render/Deprecated/vbo_MapRender.cpp @@ -0,0 +1,321 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _VBO_MAP_RENDER_ +#define _VBO_MAP_RENDER_ + +#include +#include +#include + +#include "Topology/generic/dart.h" +#include "Topology/generic/functor.h" +#include "Topology/generic/attributeHandler.h" +#include "Container/convert.h" +#include "Geometry/vector_gen.h" + +#include "Utils/GLSLShader.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Render +{ + +namespace VBO +{ + +enum drawingType { + TRIANGLES = 1, + LINES = 2, + POINTS = 4, + EXPLODED = 8, + FLAT_TRIANGLES = 16, + ERR = 32 +} ; + +enum bufferType { + POSITIONS = 1, + NORMALS = 2, + COLORS = 4, + TEXCOORDS = 8, + ENDVECTORS = 16 +} ; + +enum bufferIndex { + TRIANGLE_INDICES = 0, + LINE_INDICES = 1, + POINT_INDICES = 2, + FLAT_BUFFER = 3, + POSITIONS_BUFFER = 4, + NORMALS_BUFFER = 5, + COLORS_BUFFER = 6, + FIRST_ATTRIBUTE_BUFFER = 7 +} ; + +const unsigned int NB_BUFFERS = 20 ; + +// Warning using attributes forbid using the following buildin attributes +// gl_SecondaryColor +// gl_FogCoord +// gl_MultiTexCoord0 +// gl_MultiTexCoord1 +// gl_MultiTexCoord2 +// gl_MultiTexCoord3 +// gl_MultiTexCoord4 +// gl_MultiTexCoord5 +// gl_MultiTexCoord6 +// gl_MultiTexCoord7 +const unsigned int FIRST_VERTEX_ATTRIB = 4 ; + +const unsigned int NB_ATTRIBUTES = 12 ; + +class MapRender_VBO +{ + +protected: + /** + * vbo buffers + */ + GLuint m_VBOBuffers[NB_BUFFERS] ; + bool m_allocatedBuffers[NB_BUFFERS] ; + bool m_usedBuffers[NB_BUFFERS] ; + + bool m_allocatedAttributes[NB_ATTRIBUTES] ; + bool m_usedAttributes[NB_ATTRIBUTES] ; + unsigned int m_AttributesDataSize[NB_ATTRIBUTES]; + + unsigned int m_nbVertexAttrib; + + std::map m_attributebyName; + + + /** + * number of indices of triangles + */ + GLuint m_nbIndicesTri ; + + /** + * number of indices of lines + */ + GLuint m_nbIndicesLines ; + + /** + * number of indices of points + */ + GLuint m_nbIndicesPoints ; + + + GLuint m_nbFlatElts; + +public: + /** + * Constructor + */ + MapRender_VBO() ; + + /** + * Constructor that share vertices attributes vbo (position/normals/colors...) + */ + MapRender_VBO(const MapRender_VBO& mrvbo); + + /** + * Destructor + */ + ~MapRender_VBO() ; + + /** + * update the data + * @param uptype that have to be updated: POSITIONS, NORMALS, COLORS, TEXCOORDS, ??? + * @param attribId attribute where data is stored + * @param conv Callback of attribute conversion (NULL if direct copy, default value) + */ + template + void updateData(int upType, const ATTR_HANDLER& attrib, ConvertAttrib* conv = NULL) ; + + void enableBuffers(int buffersMask) ; + void disableBuffers(int buffersMask) ; + + + /** + * update the data for vertex attributes + * @param vertex_attrib vertex attrib id + * @param attrib attribute where data is stored + * @param conv Callback of attribute conversion (NULL if direct copy, default value) + */ + template + void updateVAData(unsigned int vertex_attrib, const ATTR_HANDLER& attrib, ConvertAttrib* conv = NULL) ; + + /** + * update the data for vertex attributes + * @param va_name vertex attrib name (in shader) + * @param attrib attribute where data is stored + * @param conv Callback of attribute conversion (NULL if direct copy, default value) + */ + template + void updateVAData(const std::string& name, const ATTR_HANDLER& attrib, ConvertAttrib* conv = NULL) ; + + + /** + * enable a vertex attribute for rendering (updateDate automatically enable attrib) + */ + void enableVertexAttrib(const std::string& name); + + /** + * disable a vertex attribute for rendering + */ + void disableVertexAttrib(const std::string& name); + + + /** + * associate a name to a vertex attribute + * @param name the name in shader + * @param sh the shader + * @return the id to use with update (if not using name) + */ + unsigned int useVertexAttributeName(const std::string& name, const Utils::GLSLShader& sh); + +protected: + + unsigned int vbo_index_attribute( unsigned int att) { return att + FIRST_ATTRIBUTE_BUFFER - FIRST_VERTEX_ATTRIB;} + + /** + * enable a vertex attribute for rendering (updateDate automatically enable attrib) + */ + void enableVertexAttrib(unsigned int index); + + /** + * disable a vertex attribute for rendering + */ + void disableVertexAttrib(unsigned int index); + + /** + * fill buffer directly from attribute + */ + template + void fillBufferDirect(unsigned int indexVBO, const ATTR_HANDLER& attrib) ; + + /** + * fill buffer with conversion from attribute + */ + template + void fillBufferConvert(unsigned int indexVBO, const ATTR_HANDLER& attrib, ConvertAttrib* conv) ; + + /** + * addition of indices table of one triangle + * @param d a dart of the triangle + * @param tableIndices the indices table + */ + template + void addTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices) ; + +public: + /** + * creation of indices table of triangles (optimized order) + * @param tableIndices the table where indices are stored + */ + template + void initTriangles(typename PFP::MAP& map, const FunctorSelect& good,std::vector& tableIndices, unsigned int thread=0) ; + template + void initTrianglesOptimized(typename PFP::MAP& map, const FunctorSelect& good,std::vector& tableIndices, unsigned int thread=0) ; + + /** + * creation of indices table of lines (optimized order) + * @param tableIndices the table where indices are stored + */ + template + void initLines(typename PFP::MAP& map, const FunctorSelect& good,std::vector& tableIndices, unsigned int thread=0) ; + template + void initLinesOptimized(typename PFP::MAP& map, const FunctorSelect& good,std::vector& tableIndices, unsigned int thread=0) ; + + /** + * creation of indices table of points + * @param tableIndices the table where indices are stored + */ + template + void initPoints(typename PFP::MAP& map, const FunctorSelect& good,std::vector& tableIndices, unsigned int thread=0) ; + + /** + * creation of VBO for flat faces rendering + */ + template + void initFlatTriangles(typename PFP::MAP& map, const FunctorSelect& good, unsigned int thread=0); + + /** + * initialization of the VBO indices primitives + * computed by a traversal of the map + * @param prim primitive to draw: VBO_TRIANGLES, VBO_LINES + */ + template + void initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, bool optimized = true, unsigned int thread=0) ; + + /** + * initialization of the VBO indices primitives + * using the given table + * @param prim primitive to draw: VBO_TRIANGLES, VBO_LINES + */ + void initPrimitives(int prim, std::vector& tableIndices) ; + +protected: + /** + * Drawing triangles function + */ + void drawTriangles(bool bindColors = true) ; + + /** + * Drawing lines function + */ + void drawLines(bool bindColors = true) ; + + /** + * Drawing points function + */ + void drawPoints(bool bindColors = true) ; + + /** + * Drawing flat faces function + */ + void drawFlat(); + +public: + /** + * draw the VBO (function to call in the drawing callback) + */ + void draw(int prim, bool bindColors = true) ; +} ; + +} // namespace VBO + +} // namespace Render + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Render/Deprecated/vbo_MapRender.hpp" + +#endif diff --git a/Apps/Tests/Algo/Render/Deprecated/vbo_VectorAttributeRender.cpp b/Apps/Tests/Algo/Render/Deprecated/vbo_VectorAttributeRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..90583ebd89189d3d3d39a294e3c1d83beb551a45 --- /dev/null +++ b/Apps/Tests/Algo/Render/Deprecated/vbo_VectorAttributeRender.cpp @@ -0,0 +1,115 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _VBO_VECTOR_ATTRIBUTE_RENDER_ +#define _VBO_VECTOR_ATTRIBUTE_RENDER_ + +#include +#include + +#include "Topology/generic/functor.h" +#include "Container/convert.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Render +{ + +namespace VBO +{ + +template +class VectorAttributeRender +{ +protected: + typedef typename PFP::MAP MAP ; + + /** + * the map to draw + */ + MAP& m_map ; + + /** + * darts selector + */ + FunctorType& m_good ; + + /** + * vbo buffer + */ + GLuint m_VBOBuffer ; + + /** + * number of indices of lines + */ + GLuint m_nbIndices ; + + /** + * creation of indices table of lines + * @param tableIndices the table where indices are stored + */ + void initLines(std::vector& tableIndices) ; + +public: + /** + * Constructor + * @param map the map to draw + * @param good functor that return true for darts of part to draw + */ + VectorAttributeRender(MAP& map, FunctorType& good) ; + + /** + * Destructor + */ + ~VectorAttributeRender() ; + + /** + * update the data + * @param uptype what have ot be update: POSITIONS, NORMALS, COLORS, TEXCOORDS, ??? + * @param attribId id of attribute where data are stored + * @param conv Callback of attribute conversion (NULL if direct copy, default value) + */ + void updateData(int upType, unsigned int attribId, ConvertAttrib* conv = NULL); + + /** + * draw the VBO (function to call in the drawing callback) + */ + void draw() ; +} ; + +} // namespace VBO + +} // namespace Render + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Render/vbo_VectorAttributeRender.hpp" + +#endif diff --git a/Apps/Tests/Algo/Render/GL1/map_glRender.cpp b/Apps/Tests/Algo/Render/GL1/map_glRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7d65324553f948db36050fa1d42236572d9cf9df --- /dev/null +++ b/Apps/Tests/Algo/Render/GL1/map_glRender.cpp @@ -0,0 +1,86 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _MAP_GL_RENDER +#define _MAP_GL_RENDER + +#include +#include + +#include "Topology/generic/functor.h" + +/** +* A set of functions that allow the creation of rendering +* object using Vertex-Buffer-Object. +* Function are made for dual-2-map and can be used on +* any subset of a dual-N-map which is a 2-map +*/ +namespace CGoGN +{ + +namespace Algo +{ + +namespace Render +{ + +namespace GL1 +{ + +enum RenderType { NO_LIGHT=1, LINE, FLAT, SMOOTH }; +enum RenderPrimitives { NONE=0, TRIANGLES=3, QUADS=4, POLYGONS=5, TRIFAN=6 }; + +/** +* @param the_map the map to render +* @param rt type of rendu (FLAT, SMOOTH, FIL) +* @param explode face exploding coefficient +*/ +template +void renderTriQuadPoly(typename PFP::MAP& the_map, RenderType rt, float explode, + const VertexAttribute& position, const VertexAttribute& normal); + +template +void renderTriQuadPoly(typename PFP::MAP& the_map, RenderType rt, float explode, + const VertexAttribute& position, const VertexAttribute& normal, const VertexAttribute& color); + +template +void renderNormalVertices(typename PFP::MAP& the_map, + const VertexAttribute& position, const VertexAttribute& normal, float scale); + +template +void renderFrameVertices(typename PFP::MAP& the_map, + const VertexAttribute& position, const VertexAttribute frame[3], float scale); + +} // namespace Direct + +} // namespace Render + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Render/GL1/renderFunctor.h" +#include "Algo/Render/GL1/map_glRender.hpp" + +#endif diff --git a/Apps/Tests/Algo/Render/GL1/renderFunctor.cpp b/Apps/Tests/Algo/Render/GL1/renderFunctor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2df40ec53ea13be03f6db46997f40fe78667948f --- /dev/null +++ b/Apps/Tests/Algo/Render/GL1/renderFunctor.cpp @@ -0,0 +1,260 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __RENDER_FUNCTOR_GL_H +#define __RENDER_FUNCTOR_GL_H + +#include + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Render +{ + +namespace GL1 +{ + +template +class FunctorGLFace: public FunctorMap +{ + typedef typename PFP::MAP MAP; + +protected: + /** + * functor used in GL smooth rendering ? (normal per vertex or per face) + */ + bool m_smooth; + + /** + * functor used in lighted rendering ? (use normal or not) + */ + bool m_lighted; + + /** + * Nb edges of primitive (3 for triangle and 4 for quad, -1 for polygon) + */ + unsigned m_nbEdges; + + /** + * coefficient for exploding faces + */ + float m_explode; + + /** + * storing faces that have not been rendered + */ + bool m_storing; + + /** + * positions of vertices + */ + const VertexAttribute& m_positions; + + /** + * normals of vertices + */ + const VertexAttribute& m_normals; + + /** + * vector of darts (one for each polygon) + */ + std::vector m_poly; + + +public: + /** + * @param lighted use normal (face or vertex) + * @param smooth use per vertex normal + * @param nbe number of vertex per primitive (3 for triangles, 4 for quads, -1 for polygons) + * @param expl exploding coefficient + * @param stor shall we store faces that are not of the good primitive type + * @param vn the vertex normal vector (indiced by dart label) + */ + FunctorGLFace(MAP& map, bool lighted, bool smooth, int nbe, float expl, bool stor, + const VertexAttribute& posi, const VertexAttribute& normals ); + + /** + * get back the vector of darts of faces that have not been treated + */ + std::vector& getPolyDarts(); + + /** + * operator applied on each face: + * if the face has the right number of edges + * it is rendered (glVertex). Other are stored + * if needed. + */ + bool operator() (Dart d); + + /** + * Render a face without exploding + */ + void renderFace(Dart d); + + /** + * Render a face with exploding + */ + void renderFaceExplode(Dart d); +}; + + +/** + * Fonctor for color rendering + */ + +template +class FunctorGLFaceColor: public FunctorMap +{ + typedef typename PFP::MAP MAP; + +protected: + /** + * functor used in GL smooth rendering ? (normal per vertex or per face) + */ + bool m_smooth; + + /** + * functor used in lighted rendering ? (use normal or not) + */ + bool m_lighted; + + /** + * Nb edges of primitive (3 for triangle and 4 for quad, -1 for polygon) + */ + unsigned m_nbEdges; + + /** + * coefficient for exploding faces + */ + float m_explode; + + /** + * storing faces that have not been rendered + */ + bool m_storing; + + /** + * positions of vertices + */ + const VertexAttribute& m_positions; + + /** + * normals of vertices + */ + const VertexAttribute& m_normals; + + /** + * colors of vertices + */ + const VertexAttribute& m_colors; + + /** + * vector of darts (one for each polygon) + */ + std::vector m_poly; + + +public: + + FunctorGLFaceColor(MAP& map, bool lighted, bool smooth, int nbe, float expl, bool stor, + const VertexAttribute& posi, const VertexAttribute& normals , const VertexAttribute& colors); + + std::vector& getPolyDarts(); + + bool operator() (Dart d); + + void renderFace(Dart d); + + void renderFaceExplode(Dart d); +}; + +template +class FunctorGLNormal : public CGoGN::FunctorMap +{ + typedef typename PFP::MAP MAP; + + +protected: + /** + * positions of vertices + */ + const VertexAttribute& m_positions; + + /** + * normals of vertices + */ + const VertexAttribute& m_normals; + + + float m_scale; + +public: + + FunctorGLNormal(MAP& map, const VertexAttribute& posi, const VertexAttribute& normals, float scale); + + bool operator() (Dart d); +}; + +template +class FunctorGLFrame : public CGoGN::FunctorMap +{ + typedef typename PFP::MAP MAP; + + +protected: + /** + * positions of vertices + */ + const VertexAttribute& m_positions; + + /** + * frame of vertices + */ + const VertexAttribute *m_frames; + + + float m_scale; + +public: + + FunctorGLFrame (MAP& map, const VertexAttribute& posi, const VertexAttribute frames[3], float scale); + + bool operator() (Dart d); +}; + +} // namespace GL1 + +} // namespace Render + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Render/GL1/renderFunctor.hpp" + +#endif diff --git a/Apps/Tests/Algo/Render/GL1/topo_render.cpp b/Apps/Tests/Algo/Render/GL1/topo_render.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c9859148cb669f1c04a96a4e8751b874c28ac86e --- /dev/null +++ b/Apps/Tests/Algo/Render/GL1/topo_render.cpp @@ -0,0 +1,118 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _TOPO_GL_RENDER +#define _TOPO_GL_RENDER + +#include +//#include +//#include +#include + +#include "Topology/generic/functor.h" + +// OpenGL direct mode rendering of darts of maps + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Render +{ + +namespace GL1 +{ + +///** +//* Render darts of generalized map +//*/ +//template +//void renderTopoGM2(typename PFP::MAP& the_map, Mark m); + +/** +* Render darts of dual map +* +* @param the_map map to render +* @param drawPhi1 draw the phi1 relation ? +* @param drawPhi2 draw the phi2 relation ? +* @param ke exploding coefficient for edge (1.0 normal draw) +* @param kf exploding coefficient for face (1.0 normal draw) +*/ +template +void renderTopoMD2(typename PFP::MAP& the_map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, float ke, float kf); + + +/** + * Render darts of dual map + * + * @param the_map map to render + * @param drawPhi1 draw the phi1 relation ? + * @param drawPhi2 draw the phi2 relation ? + * @param drawPhi3 draw the phi3 relation ? + * @param ke exploding coefficient for edge (1.0 normal draw) + * @param kf exploding coefficient for face (1.0 normal draw) + * @param kv exploding coefficient for volumes (1.0 normal draw) + */ +template +void renderTopoMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv); + +/** + * Render darts of g-map + * + * @param the_map map to render + * @param drawPhi1 draw the beta1 relation ? + * @param drawPhi2 draw the beta2 relation ? + * @param ke exploding coefficient for edge (1.0 normal draw) + * @param kf exploding coefficient for face (1.0 normal draw) + */ +template +void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, float ke, float kf); + +/** + * Render darts of g-map + * + * @param the_map map to render + * @param drawPhi1 draw the beta1 relation ? + * @param drawPhi2 draw the beta2 relation ? + * @param drawPhi3 draw the beta3 relation ? + * @param ke exploding coefficient for edge (1.0 normal draw) + * @param kf exploding coefficient for face (1.0 normal draw) + * @param kv exploding coefficient for volumes (1.0 normal draw) + */ +template +void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, bool drawBeta3, float kd, float ke, float kf, float kv); + +} // namespace GL1 + +} // namespace Render + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Render/GL1/topo_render.hpp" + +#endif diff --git a/Apps/Tests/Algo/Render/GL2/colorPerEdgeRender.cpp b/Apps/Tests/Algo/Render/GL2/colorPerEdgeRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27b569d12f03cd94454469db2ac6a1c505c484ac --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/colorPerEdgeRender.cpp @@ -0,0 +1,38 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Render/GL2/colorPerEdgeRender.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; +typedef EdgeAttribute ATT1; + +template void Algo::Render::GL2::ColorPerEdgeRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP1::MAP& map, + const VertexAttribute& positions, const ATT1& colorPerXXX); + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; +typedef AttributeHandler ATT2; + +template void Algo::Render::GL2::ColorPerEdgeRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP2::MAP& map, + const VertexAttribute& positions, const ATT2& colorPerXXX); + + + +int test_colorPerEdgeRender() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/GL2/colorPerFaceRender.cpp b/Apps/Tests/Algo/Render/GL2/colorPerFaceRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..69154132ae41b4b94620ff5f410ace5b67f5e86b --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/colorPerFaceRender.cpp @@ -0,0 +1,103 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Render/GL2/colorPerFaceRender.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP1::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP1::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP1::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP1::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP2::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP2::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP2::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP2::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP3::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP3::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP3::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP3::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + + + +struct PFP4 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP4::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP4::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, PFP4::MAP& map, + const VertexAttribute& positions, const AttributeHandler& colorPerXXX); + +template void Algo::Render::GL2::ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, PFP4::MAP& map, + const VertexAttribute& positions, const VertexAttribute& normals, + const AttributeHandler& colorPerXXX); + + +int test_colorPerFaceRender() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/GL2/dataPerFaceRender.cpp b/Apps/Tests/Algo/Render/GL2/dataPerFaceRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4a483c5d0ed4dd64f6d4edd1c6471c281f727ae1 --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/dataPerFaceRender.cpp @@ -0,0 +1,60 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Render/GL2/dataPerFaceRender.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; +typedef double SCAL; + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP1::MAP& map, +const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP1::MAP& map, + const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + + +typedef Geom::Vec4d VEC; + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP1::MAP& map, + const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP1::MAP& map, + const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; +typedef float SCAL2; + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP2::MAP& map, + const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP2::MAP& map, + const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + + +typedef Geom::Vec4f VEC2; + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP2::MAP& map, + const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + +template void Algo::Render::GL2::DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, PFP2::MAP& map, + const VertexAttribute& positions, const AttributeHandler& dataPerXXX); + + + +int test_dataPerFaceRender() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/GL2/drawerCells.cpp b/Apps/Tests/Algo/Render/GL2/drawerCells.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e5421d24270003c337f24b965bb57dcc8b167876 --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/drawerCells.cpp @@ -0,0 +1,100 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Render/GL2/drawerCells.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Render::drawerCells(unsigned int cell, Utils::Drawer& dr, PFP1::MAP& map, std::vector& vd, const VertexAttribute& positions,float k); +template void Algo::Render::drawerCell(unsigned int cell, Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertices(Utils::Drawer& dr, PFP1::MAP& map, std::vector& vd, const VertexAttribute& positions); +template void Algo::Render::drawerEdges(Utils::Drawer& dr, PFP1::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFaces(Utils::Drawer& dr, PFP1::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolumes(Utils::Drawer& dr, PFP1::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertex(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions); +template void Algo::Render::drawerEdge(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFace(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolume(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdge(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdgeShrink(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, const PFP1::VEC3& C, float k); +template void Algo::Render::drawerAddFace(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddVolume(Utils::Drawer& dr, PFP1::MAP& map, Dart d, const VertexAttribute& positions, float k); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Render::drawerCells(unsigned int cell, Utils::Drawer& dr, PFP2::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerCell(unsigned int cell, Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertices(Utils::Drawer& dr, PFP2::MAP& map, std::vector& vd, const VertexAttribute& positions); +template void Algo::Render::drawerEdges(Utils::Drawer& dr, PFP2::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFaces(Utils::Drawer& dr, PFP2::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolumes(Utils::Drawer& dr, PFP2::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertex(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions); +template void Algo::Render::drawerEdge(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFace(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolume(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdge(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdgeShrink(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, const PFP2::VEC3& C, float k); +template void Algo::Render::drawerAddFace(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddVolume(Utils::Drawer& dr, PFP2::MAP& map, Dart d, const VertexAttribute& positions, float k); + + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template void Algo::Render::drawerCells(unsigned int cell, Utils::Drawer& dr, PFP3::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerCell(unsigned int cell, Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertices(Utils::Drawer& dr, PFP3::MAP& map, std::vector& vd, const VertexAttribute& positions); +template void Algo::Render::drawerEdges(Utils::Drawer& dr, PFP3::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFaces(Utils::Drawer& dr, PFP3::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolumes(Utils::Drawer& dr, PFP3::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertex(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions); +template void Algo::Render::drawerEdge(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFace(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolume(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdge(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdgeShrink(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, const PFP3::VEC3& C, float k); +template void Algo::Render::drawerAddFace(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddVolume(Utils::Drawer& dr, PFP3::MAP& map, Dart d, const VertexAttribute& positions, float k); + + +struct PFP4 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template void Algo::Render::drawerCells(unsigned int cell, Utils::Drawer& dr, PFP4::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerCell(unsigned int cell, Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertices(Utils::Drawer& dr, PFP4::MAP& map, std::vector& vd, const VertexAttribute& positions); +template void Algo::Render::drawerEdges(Utils::Drawer& dr, PFP4::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFaces(Utils::Drawer& dr, PFP4::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolumes(Utils::Drawer& dr, PFP4::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVertex(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions); +template void Algo::Render::drawerEdge(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerFace(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerVolume(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdge(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddEdgeShrink(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, const PFP4::VEC3& C, float k); +template void Algo::Render::drawerAddFace(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, float k); +template void Algo::Render::drawerAddVolume(Utils::Drawer& dr, PFP4::MAP& map, Dart d, const VertexAttribute& positions, float k); + + +int test_drawerCells() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/GL2/explodeVolumeRender.cpp b/Apps/Tests/Algo/Render/GL2/explodeVolumeRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d26e5afdf230512b269eb663d5d66b11655fe74a --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/explodeVolumeRender.cpp @@ -0,0 +1,43 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Render/GL2/explodeVolumeRender.h" + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; +typedef VertexAttribute VATT1; +typedef VolumeAttribute WATT1; + +template void Algo::Render::GL2::ExplodeVolumeRender::updateData(PFP1::MAP& map, const VATT1& positions); +template void Algo::Render::GL2::ExplodeVolumeRender::updateData(PFP1::MAP& map, const VATT1& positions, const WATT1& colorPerFace); + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; +typedef VertexAttribute VATT2; +typedef VolumeAttribute WATT2; + +template void Algo::Render::GL2::ExplodeVolumeRender::updateData(PFP2::MAP& map, const VATT2& positions); +template void Algo::Render::GL2::ExplodeVolumeRender::updateData(PFP2::MAP& map, const VATT2& positions, const WATT2& colorPerFace); + + + + +int test_explodeVolumeRender() +{ + + return 0; +} + + diff --git a/Apps/Tests/Algo/Render/GL2/mapRender.cpp b/Apps/Tests/Algo/Render/GL2/mapRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..676e27378ba277006ff203d3d2903bd59ee095e7 --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/mapRender.cpp @@ -0,0 +1,49 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Render/GL2/mapRender.h" + + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Render::GL2::MapRender::initPrimitives(PFP1::MAP& map, int prim, bool optimized); +template void Algo::Render::GL2::MapRender::initPrimitives(PFP1::MAP& map, int prim, const VertexAttribute* position, bool optimized); +template void Algo::Render::GL2::MapRender::addPrimitives(PFP1::MAP& map, int prim, const VertexAttribute* position, bool optimized); + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Render::GL2::MapRender::initPrimitives(PFP2::MAP& map, int prim, bool optimized); +template void Algo::Render::GL2::MapRender::initPrimitives(PFP2::MAP& map, int prim, const VertexAttribute* position, bool optimized); +template void Algo::Render::GL2::MapRender::addPrimitives(PFP2::MAP& map, int prim, const VertexAttribute* position, bool optimized); + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template void Algo::Render::GL2::MapRender::initPrimitives(PFP3::MAP& map, int prim, bool optimized); +template void Algo::Render::GL2::MapRender::initPrimitives(PFP3::MAP& map, int prim, const VertexAttribute* position, bool optimized); +template void Algo::Render::GL2::MapRender::addPrimitives(PFP3::MAP& map, int prim, const VertexAttribute* position, bool optimized); + + + +int test_mapRender() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Render/GL2/topo3PrimalRender.cpp b/Apps/Tests/Algo/Render/GL2/topo3PrimalRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5fb7d45069e506224281d5afb20a3caa5511961b --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/topo3PrimalRender.cpp @@ -0,0 +1,34 @@ + +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap3.h" + + +#include "Algo/Render/GL2/topo3PrimalRender.h" + + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +template class Algo::Render::GL2::Topo3PrimalRender; + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template class Algo::Render::GL2::Topo3PrimalRender; + + +int test_topo3PrimalRender() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/GL2/topo3Render.cpp b/Apps/Tests/Algo/Render/GL2/topo3Render.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c6636f76f942b95a78f3bd037c20ebb81634ae8 --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/topo3Render.cpp @@ -0,0 +1,51 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap3.h" + + +#include "Algo/Render/GL2/topo3Render.h" + + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +template class Algo::Render::GL2::Topo3RenderMap; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template class Algo::Render::GL2::Topo3RenderMap; + + + +struct PFP3 : public PFP_STANDARD +{ + typedef EmbeddedGMap3 MAP; +}; + +template class Algo::Render::GL2::Topo3RenderGMap; + + +struct PFP4 : public PFP_DOUBLE +{ + typedef EmbeddedGMap3 MAP; +}; + +template class Algo::Render::GL2::Topo3RenderGMap; + + + +int test_topo3Render() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/Render/GL2/topoPrimalRender.cpp b/Apps/Tests/Algo/Render/GL2/topoPrimalRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..87735a30ee01738dca3db5859e065c379276d573 --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/topoPrimalRender.cpp @@ -0,0 +1,31 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" + +#include "Algo/Render/GL2/topoPrimalRender.h" + + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Render::GL2::TopoPrimalRender; + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template class Algo::Render::GL2::TopoPrimalRender; + + + +int test_topoPrimalRender() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/GL2/topoRender.cpp b/Apps/Tests/Algo/Render/GL2/topoRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a4e500cee180d5e2bb49ae6c28ff63b78e5339c8 --- /dev/null +++ b/Apps/Tests/Algo/Render/GL2/topoRender.cpp @@ -0,0 +1,73 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Render/GL2/topoRender.h" + + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; +typedef PFP1::MAP MAP1; + +template void Algo::Render::GL2::TopoRender::overdrawDart(MAP1& map, Dart d, float width, float r, float g, float b); +template Dart Algo::Render::GL2::TopoRender::picking(MAP1& map, int x, int y, bool withBoundary); +template Dart Algo::Render::GL2::TopoRender::coneSelection(MAP1& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); +template Dart Algo::Render::GL2::TopoRender::raySelection(MAP1& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); +template void Algo::Render::GL2::TopoRender::updateData(PFP1::MAP &map, const VertexAttribute& positions, float ke, float kf, bool withBoundary, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::updateData(PFP1::MAP &map, const VertexAttribute& positions, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::updateDataBoundary(PFP1::MAP& map, const VertexAttribute& positions, float ke, float kf, float ns); +template void Algo::Render::GL2::TopoRender::updateDataBoundary(PFP1::MAP& map, const VertexAttribute& positions); +//template void Algo::Render::GL2::TopoRender::updateDataGMap(PFP1::MAP &map, const VertexAttribute& positions, float ke, float kf, bool withBoundary, bool onlyBoundary); +//template void Algo::Render::GL2::TopoRender::updateDataGMap(PFP1::MAP &map, const VertexAttribute& positions, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::drawColoredDarts(MAP1& map); + + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; +template void Algo::Render::GL2::TopoRender::updateData(PFP2::MAP &map, const VertexAttribute& positions, float ke, float kf, bool withBoundary, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::updateData(PFP2::MAP &map, const VertexAttribute& positions, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::updateDataBoundary(PFP2::MAP& map, const VertexAttribute& positions, float ke, float kf, float ns); +template void Algo::Render::GL2::TopoRender::updateDataBoundary(PFP2::MAP& map, const VertexAttribute& positions); + + +struct PFPG1 : public PFP_STANDARD +{ + typedef EmbeddedGMap2 MAP; +}; +typedef PFPG1::MAP GMAP1; + +template void Algo::Render::GL2::TopoRender::overdrawDart(GMAP1& map, Dart d, float width, float r, float g, float b); +template Dart Algo::Render::GL2::TopoRender::picking(GMAP1& map, int x, int y, bool withBoundary); +template Dart Algo::Render::GL2::TopoRender::coneSelection(GMAP1& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); +template Dart Algo::Render::GL2::TopoRender::raySelection(GMAP1& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); +template void Algo::Render::GL2::TopoRender::updateDataGMap(PFPG1::MAP &map, const VertexAttribute& positions, float ke, float kf, bool withBoundary, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::updateDataGMap(PFPG1::MAP &map, const VertexAttribute& positions, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::drawColoredDarts(GMAP1& map); + + + +struct PFPG2 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; +typedef PFPG2::MAP GMAP2; +template void Algo::Render::GL2::TopoRender::updateDataGMap(PFPG2::MAP &map, const VertexAttribute& positions, float ke, float kf, bool withBoundary, bool onlyBoundary); +template void Algo::Render::GL2::TopoRender::updateDataGMap(PFPG2::MAP &map, const VertexAttribute& positions, bool onlyBoundary); + + + +int test_topoRender() +{ + + return 0; +} diff --git a/Apps/Tests/Algo/Render/SVG/mapSVGRender.cpp b/Apps/Tests/Algo/Render/SVG/mapSVGRender.cpp new file mode 100644 index 0000000000000000000000000000000000000000..00d8b8bdd653bf2b4922e6e94282db4f50c9ac42 --- /dev/null +++ b/Apps/Tests/Algo/Render/SVG/mapSVGRender.cpp @@ -0,0 +1,74 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/gmap/embeddedGMap3.h" + + +#include "Algo/Render/SVG/mapSVGRender.h" + + +using namespace CGoGN; + + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP1::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP1::MAP& map, const VertexAttribute& position, const VertexAttribute& color); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP1::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP1::MAP& map, const VertexAttribute& position, const VertexAttribute& color); + + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP2::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP2::MAP& map, const VertexAttribute& position, const VertexAttribute& color); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP2::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP2::MAP& map, const VertexAttribute& position, const VertexAttribute& color); + + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP3::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP3::MAP& map, const VertexAttribute& position, const VertexAttribute& color); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP3::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP3::MAP& map, const VertexAttribute& position, const VertexAttribute& color); + + +struct PFP4 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP4::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP4::MAP& map, const VertexAttribute& position, const VertexAttribute& color); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP4::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP4::MAP& map, const VertexAttribute& position, const VertexAttribute& color); + + +struct PFP5 : public PFP_STANDARD +{ + typedef EmbeddedGMap3 MAP; +}; + +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP5::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderVertices(Utils::SVG::SVGOut& svg, PFP5::MAP& map, const VertexAttribute& position, const VertexAttribute& color); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP5::MAP& map, const VertexAttribute& position); +template void Algo::Render::SVG::renderEdges(Utils::SVG::SVGOut& svg, PFP5::MAP& map, const VertexAttribute& position, const VertexAttribute& color); + + + +int test_mapSVGRender() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Render/algo_render.cpp b/Apps/Tests/Algo/Render/algo_render.cpp new file mode 100644 index 0000000000000000000000000000000000000000..afd0713259515166c154651e8e008ccdd70699cd --- /dev/null +++ b/Apps/Tests/Algo/Render/algo_render.cpp @@ -0,0 +1,29 @@ +#include + +extern int test_colorPerEdgeRender(); +extern int test_colorPerFaceRender(); +extern int test_dataPerFaceRender(); +extern int test_drawerCells(); +extern int test_explodeVolumeRender(); +extern int test_mapRender(); +extern int test_topoRender(); +extern int test_topo3Render(); +extern int test_mapSVGRender(); +extern int test_topoPrimalRender(); +extern int test_topo3PrimalRender(); + +int main() +{ + test_colorPerEdgeRender(); + test_dataPerFaceRender(); + test_drawerCells(); + test_explodeVolumeRender(); + test_mapRender(); + test_topoRender(); + test_topo3Render(); + test_mapSVGRender(); + test_topoPrimalRender(); + test_topo3PrimalRender(); + + return 0; +} diff --git a/Apps/Tests/Algo/Selection/CMakeLists.txt b/Apps/Tests/Algo/Selection/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce55c79c35665a928e592b5d6cd52dc3fe4e10f5 --- /dev/null +++ b/Apps/Tests/Algo/Selection/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_selection) + +add_executable( test_algo_selection +algo_selection.cpp +collector.cpp +raySelector.cpp +) + +target_link_libraries( test_algo_selection + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/Selection/algo_selection.cpp b/Apps/Tests/Algo/Selection/algo_selection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f108b3f2f3b679092ab622020fdaeefd0f00904 --- /dev/null +++ b/Apps/Tests/Algo/Selection/algo_selection.cpp @@ -0,0 +1,12 @@ +#include + +extern int test_collector(); +extern int test_raySelector(); + +int main() +{ + test_collector(); + test_raySelector(); + + return 0; +} diff --git a/Apps/Tests/Algo/Selection/collector.cpp b/Apps/Tests/Algo/Selection/collector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa2493b2d5c7bb407d686bdb0e8b12bb1132cad2 --- /dev/null +++ b/Apps/Tests/Algo/Selection/collector.cpp @@ -0,0 +1,73 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Selection/collector.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template class Algo::Surface::Selection::Collector_OneRing; +template class Algo::Surface::Selection::Collector_OneRing_AroundEdge; +template class Algo::Surface::Selection::Collector_WithinSphere; +template class Algo::Surface::Selection::Collector_NormalAngle; +template class Algo::Surface::Selection::Collector_NormalAngle_Triangles; +template class Algo::Surface::Selection::CollectorCriterion_VertexNormalAngle; +template class Algo::Surface::Selection::CollectorCriterion_TriangleNormalAngle; +template class Algo::Surface::Selection::CollectorCriterion_VertexWithinSphere; +template class Algo::Surface::Selection::Collector_Vertices; +template class Algo::Surface::Selection::Collector_Triangles; +template class Algo::Surface::Selection::Collector_Dijkstra_Vertices; +template class Algo::Surface::Selection::Collector_Dijkstra; + +template class Algo::Surface::Selection::Collector_OneRing; +template class Algo::Surface::Selection::Collector_OneRing_AroundEdge; +template class Algo::Surface::Selection::Collector_WithinSphere; +template class Algo::Surface::Selection::Collector_NormalAngle; +template class Algo::Surface::Selection::Collector_NormalAngle_Triangles; +template class Algo::Surface::Selection::CollectorCriterion_VertexNormalAngle; +template class Algo::Surface::Selection::CollectorCriterion_TriangleNormalAngle; +template class Algo::Surface::Selection::CollectorCriterion_VertexWithinSphere; +template class Algo::Surface::Selection::Collector_Vertices; +template class Algo::Surface::Selection::Collector_Triangles; +template class Algo::Surface::Selection::Collector_Dijkstra_Vertices; +template class Algo::Surface::Selection::Collector_Dijkstra; + + +template class Algo::Surface::Selection::Collector_OneRing; +template class Algo::Surface::Selection::Collector_OneRing_AroundEdge; +template class Algo::Surface::Selection::Collector_WithinSphere; +template class Algo::Surface::Selection::Collector_NormalAngle; +template class Algo::Surface::Selection::Collector_NormalAngle_Triangles; +template class Algo::Surface::Selection::CollectorCriterion_VertexNormalAngle; +template class Algo::Surface::Selection::CollectorCriterion_TriangleNormalAngle; +template class Algo::Surface::Selection::CollectorCriterion_VertexWithinSphere; +template class Algo::Surface::Selection::Collector_Vertices; +template class Algo::Surface::Selection::Collector_Triangles; +template class Algo::Surface::Selection::Collector_Dijkstra_Vertices; +template class Algo::Surface::Selection::Collector_Dijkstra; + + +int test_collector() +{ + + return 0; +} + + diff --git a/Apps/Tests/Algo/Selection/raySelector.cpp b/Apps/Tests/Algo/Selection/raySelector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..65ac6d70e8d5256a4170f89c34c4bed1d2e86e92 --- /dev/null +++ b/Apps/Tests/Algo/Selection/raySelector.cpp @@ -0,0 +1,203 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Selection/raySelector.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +struct PFP4 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + + +template void Algo::Selection::facesRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, std::vector& vecFaces, std::vector& iPoints); + +template void Algo::Selection::facesRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, std::vector& vecFaces); + +template void Algo::Selection::faceRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, Face& face); + +template void Algo::Selection::edgesRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, std::vector& vecEdges, float distMax); + +template void Algo::Selection::edgeRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, Edge& edge); + +template void Algo::Selection::verticesRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, std::vector& vecVertices, float dist); + +template void Algo::Selection::vertexRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, Vertex& vertex); + +template void Algo::Selection::volumesRaySelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, std::vector& vecVolumes); + +template void Algo::Selection::facesPlanSelection( PFP1::MAP& map, const VertexAttribute& position, + const Geom::Plane3D& plan, std::vector& vecFaces); + +template void Algo::Selection::verticesConeSelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, float angle, std::vector& vecVertices); + +template void Algo::Selection::edgesConeSelection(PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& rayA, const PFP1::VEC3& rayAB, float angle, std::vector& vecEdges); + +template Vertex Algo::Selection::verticesBubbleSelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& cursor, PFP1::REAL radiusMax); + +template Edge Algo::Selection::edgesBubbleSelection( PFP1::MAP& map, const VertexAttribute& position, + const PFP1::VEC3& cursor, PFP1::REAL radiusMax); + + +// MAP2 DOUBLE +template void Algo::Selection::facesRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, std::vector& vecFaces, std::vector& iPoints); + +template void Algo::Selection::facesRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, std::vector& vecFaces); + +template void Algo::Selection::faceRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, Face& face); + +template void Algo::Selection::edgesRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, std::vector& vecEdges, float distMax); + +template void Algo::Selection::edgeRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, Edge& edge); + +template void Algo::Selection::verticesRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, std::vector& vecVertices, float dist); + +template void Algo::Selection::vertexRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, Vertex& vertex); + +template void Algo::Selection::volumesRaySelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, std::vector& vecVolumes); + +template void Algo::Selection::facesPlanSelection(PFP2::MAP& map, const VertexAttribute& position, + const Geom::Plane3D& plan, std::vector& vecFaces); + +template void Algo::Selection::verticesConeSelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, float angle, std::vector& vecVertices); + +template void Algo::Selection::edgesConeSelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& rayA, const PFP2::VEC3& rayAB, float angle, std::vector& vecEdges); + +template Vertex Algo::Selection::verticesBubbleSelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& cursor, PFP2::REAL radiusMax); + +template Edge Algo::Selection::edgesBubbleSelection(PFP2::MAP& map, const VertexAttribute& position, + const PFP2::VEC3& cursor, PFP2::REAL radiusMax); + +// GMAP2 + +template void Algo::Selection::facesRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, std::vector& vecFaces, std::vector& iPoints); + +template void Algo::Selection::facesRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, std::vector& vecFaces); + +template void Algo::Selection::faceRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, Face& face); + +template void Algo::Selection::edgesRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, std::vector& vecEdges, float distMax); + +template void Algo::Selection::edgeRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, Edge& edge); + +template void Algo::Selection::verticesRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, std::vector& vecVertices, float dist); + +template void Algo::Selection::vertexRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, Vertex& vertex); + +template void Algo::Selection::volumesRaySelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, std::vector& vecVolumes); + +template void Algo::Selection::facesPlanSelection(PFP3::MAP& map, const VertexAttribute& position, + const Geom::Plane3D& plan, std::vector& vecFaces); + +template void Algo::Selection::verticesConeSelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, float angle, std::vector& vecVertices); + +template void Algo::Selection::edgesConeSelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& rayA, const PFP3::VEC3& rayAB, float angle, std::vector& vecEdges); + +template Vertex Algo::Selection::verticesBubbleSelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& cursor, PFP3::REAL radiusMax); + +template Edge Algo::Selection::edgesBubbleSelection(PFP3::MAP& map, const VertexAttribute& position, + const PFP3::VEC3& cursor, PFP3::REAL radiusMax); + + +// MAP3 double + +template void Algo::Selection::facesRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, std::vector& vecFaces, std::vector& iPoints); + +template void Algo::Selection::facesRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, std::vector& vecFaces); + +template void Algo::Selection::faceRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, Face& face); + +template void Algo::Selection::edgesRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, std::vector& vecEdges, float distMax); + +template void Algo::Selection::edgeRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, Edge& edge); + +template void Algo::Selection::verticesRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, std::vector& vecVertices, float dist); + +template void Algo::Selection::vertexRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, Vertex& vertex); + +template void Algo::Selection::volumesRaySelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, std::vector& vecVolumes); + +template void Algo::Selection::facesPlanSelection(PFP4::MAP& map, const VertexAttribute& position, + const Geom::Plane3D& plan, std::vector& vecFaces); + +template void Algo::Selection::verticesConeSelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, float angle, std::vector& vecVertices); + +template void Algo::Selection::edgesConeSelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& rayA, const PFP4::VEC3& rayAB, float angle, std::vector& vecEdges); + +template Vertex Algo::Selection::verticesBubbleSelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& cursor, PFP4::REAL radiusMax); + +template Edge Algo::Selection::edgesBubbleSelection(PFP4::MAP& map, const VertexAttribute& position, + const PFP4::VEC3& cursor, PFP4::REAL radiusMax); + + + + + +int test_raySelector() +{ + return 0; +} + diff --git a/Apps/Tests/Algo/Simulation/CMakeLists.txt b/Apps/Tests/Algo/Simulation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5415476fe5de19dd13f30d0546d3a392423dc639 --- /dev/null +++ b/Apps/Tests/Algo/Simulation/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_simulation) + +add_executable( test_algo_simulation +algo_simulation.cpp +ShapeMatching/shapeMatchingLinear.cpp +ShapeMatching/shapeMatchingQuadratic.cpp +) + +target_link_libraries( test_algo_simulation + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatching.cpp b/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatching.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd2c18a6940b80dd47995dddb628f17453434126 --- /dev/null +++ b/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatching.cpp @@ -0,0 +1,92 @@ +/******************************************************************************* +* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * +* version 0.1 * +* Copyright (C) 2009-2013, IGG Team, ICube, 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 * +* * +*******************************************************************************/ + +#include +#include + +#ifndef _SHAPE_MATCHING_H_ +#define _SHAPE_MATCHING_H_ + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace Simulation +{ + +namespace ShapeMatching +{ + +template +class ShapeMatching +{ +public: + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + +protected: + MAP& m_map; + VertexAttribute& m_position; // x_i : position + VertexAttribute& m_mass; // m_i : mass + VertexAttribute m_goal; + + // q_{i} = x^{0} - x^{0}_{cm} + std::vector m_q; + +public: + ShapeMatching(MAP& map, VertexAttribute& position, VertexAttribute& mass); + + virtual ~ShapeMatching(); + + Eigen::Vector3d massCenter(); + + void initialize(); + + void shapeMatch(); + + void computeVelocities(VertexAttribute& velocity, VertexAttribute& fext, REAL h, REAL alpha); + + void applyVelocities(VertexAttribute& velocity, REAL h); +}; + +} // namespace ShapeMatching + +} // namespace Simulation + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + + +#include "shapeMatching.hpp" + +#endif diff --git a/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatchingLinear.cpp b/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatchingLinear.cpp new file mode 100644 index 0000000000000000000000000000000000000000..abaaba080b813f25f167cd4b30293687692c6203 --- /dev/null +++ b/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatchingLinear.cpp @@ -0,0 +1,36 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Simulation/ShapeMatching/shapeMatchingLinear.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template class Algo::Surface::Simulation::ShapeMatching::ShapeMatchingLinear; +template class Algo::Surface::Simulation::ShapeMatching::ShapeMatchingLinear; +template class Algo::Surface::Simulation::ShapeMatching::ShapeMatchingLinear; + + +int test_shapeMatchingLinear() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.cpp b/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c328830e026c0f09315073799b02a967f6b8f108 --- /dev/null +++ b/Apps/Tests/Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.cpp @@ -0,0 +1,36 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template class Algo::Surface::Simulation::ShapeMatching::ShapeMatchingQuadratic; +template class Algo::Surface::Simulation::ShapeMatching::ShapeMatchingQuadratic; +template class Algo::Surface::Simulation::ShapeMatching::ShapeMatchingQuadratic; + + +int test_shapeMatchingQuadratic() +{ + + return 0; +} + diff --git a/Apps/Tests/Algo/Simulation/algo_simulation.cpp b/Apps/Tests/Algo/Simulation/algo_simulation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23a4cea5aa9bf669e070e8408d6d6be19808434e --- /dev/null +++ b/Apps/Tests/Algo/Simulation/algo_simulation.cpp @@ -0,0 +1,14 @@ +#include + +extern int test_shapeMatchingLinear(); +extern int test_shapeMatchingQuadratic(); + + +int main() +{ + test_shapeMatchingLinear(); + test_shapeMatchingQuadratic(); + + + return 0; +} diff --git a/Apps/Tests/Algo/Tiling/CMakeLists.txt b/Apps/Tests/Algo/Tiling/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..edcb7a229c6503ac78feb9e5d61e85e5e7c81205 --- /dev/null +++ b/Apps/Tests/Algo/Tiling/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_tiling) + +add_executable( test_algo_tiling +algo_tiling.cpp +Surface/hexagonal.cpp +Surface/square.cpp +Surface/triangular.cpp +Volume/cubic.cpp +) + +target_link_libraries( test_algo_tiling + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/Tiling/Surface/hexagonal.cpp b/Apps/Tests/Algo/Tiling/Surface/hexagonal.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2e1ab6ae70fc954f90b61eb955df338f858ba50d --- /dev/null +++ b/Apps/Tests/Algo/Tiling/Surface/hexagonal.cpp @@ -0,0 +1,36 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Tiling/Surface/hexagonal.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +// TODO implementation !!! +template class Algo::Surface::Tilings::Hexagonal::Grid; +template class Algo::Surface::Tilings::Hexagonal::Grid; +template class Algo::Surface::Tilings::Hexagonal::Grid; + + + +int test_hexagonal() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Tiling/Surface/square.cpp b/Apps/Tests/Algo/Tiling/Surface/square.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a987c533d8430e1acea8ee129692cd5872acea15 --- /dev/null +++ b/Apps/Tests/Algo/Tiling/Surface/square.cpp @@ -0,0 +1,46 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Tiling/Surface/square.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + + +template class Algo::Surface::Tilings::Square::Grid; +template class Algo::Surface::Tilings::Square::Cylinder; +template class Algo::Surface::Tilings::Square::Cube; +template class Algo::Surface::Tilings::Square::Tore; + +template class Algo::Surface::Tilings::Square::Grid; +template class Algo::Surface::Tilings::Square::Cylinder; +template class Algo::Surface::Tilings::Square::Cube; +template class Algo::Surface::Tilings::Square::Tore; + +template class Algo::Surface::Tilings::Square::Grid; +template class Algo::Surface::Tilings::Square::Cylinder; +template class Algo::Surface::Tilings::Square::Cube; +template class Algo::Surface::Tilings::Square::Tore; + + +int test_square() +{ + return 0; +} + diff --git a/Apps/Tests/Algo/Tiling/Surface/triangular.cpp b/Apps/Tests/Algo/Tiling/Surface/triangular.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ecd2e56040134768ca26b1693a4e631e1ed05c4e --- /dev/null +++ b/Apps/Tests/Algo/Tiling/Surface/triangular.cpp @@ -0,0 +1,46 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Algo/Tiling/Surface/triangular.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap2 MAP; +}; + +struct PFP3 : public PFP_DOUBLE +{ + typedef EmbeddedGMap2 MAP; +}; + +template class Algo::Surface::Tilings::Triangular::Grid; +template class Algo::Surface::Tilings::Triangular::Cylinder; +template class Algo::Surface::Tilings::Triangular::Cube; +template class Algo::Surface::Tilings::Triangular::Tore; + +template class Algo::Surface::Tilings::Triangular::Grid; +template class Algo::Surface::Tilings::Triangular::Cylinder; +template class Algo::Surface::Tilings::Triangular::Cube; +template class Algo::Surface::Tilings::Triangular::Tore; + + +template class Algo::Surface::Tilings::Triangular::Grid; +template class Algo::Surface::Tilings::Triangular::Cylinder; +template class Algo::Surface::Tilings::Triangular::Cube; +template class Algo::Surface::Tilings::Triangular::Tore; + + +int test_triangular() +{ + return 0; +} + diff --git a/Apps/Tests/Algo/Tiling/Volume/cubic.cpp b/Apps/Tests/Algo/Tiling/Volume/cubic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..77a5c09b7d3cc88ba6575d011cb466ca4bb9fe15 --- /dev/null +++ b/Apps/Tests/Algo/Tiling/Volume/cubic.cpp @@ -0,0 +1,27 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap3.h" + + +#include "Algo/Tiling/Volume/cubic.h" + +using namespace CGoGN; + +struct PFP1 : public PFP_STANDARD +{ + typedef EmbeddedMap3 MAP; +}; + +struct PFP2 : public PFP_DOUBLE +{ + typedef EmbeddedMap3 MAP; +}; + + +template class Algo::Volume::Tilings::Cubic::Grid; +template class Algo::Volume::Tilings::Cubic::Grid; + + +int test_cubic() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Tiling/algo_tiling.cpp b/Apps/Tests/Algo/Tiling/algo_tiling.cpp new file mode 100644 index 0000000000000000000000000000000000000000..50b36de397d6eb75ec78185a3440f96f12e3c561 --- /dev/null +++ b/Apps/Tests/Algo/Tiling/algo_tiling.cpp @@ -0,0 +1,17 @@ +#include + +extern int test_square(); +extern int test_triangular(); +extern int test_hexagonal(); +extern int test_cubic(); + +int main() +{ + test_square(); + test_triangular(); + test_hexagonal(); + test_cubic(); + + + return 0; +} diff --git a/Apps/Tests/Algo/Tiling/tiling.cpp b/Apps/Tests/Algo/Tiling/tiling.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f18624e2982613dbe127f0ac0adb5d98ce4a4c30 --- /dev/null +++ b/Apps/Tests/Algo/Tiling/tiling.cpp @@ -0,0 +1,138 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef _TILING_H_ +#define _TILING_H_ + +#include "Geometry/transfo.h" +#include "Topology/generic/cellmarker.h" + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Surface +{ + +namespace Tilings +{ + +/*! \brief The class of regular tiling + */ +template +class Tiling +{ + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + +protected: + /** + * Map in which we are working + */ + MAP& m_map; + + unsigned int m_nx, m_ny, m_nz; + + VEC3 m_center; + + /** + * Reference dart of Polyhedron + */ + Dart m_dart; + + /** + * Table of vertex darts (one dart per vertex) + * Order depend on tiling kind + */ + std::vector m_tableVertDarts; + + /** + * Table of vertex darts (one dart per vertex) + * Order depend on tiling kind + */ + std::vector m_tableFaceDarts; + +public: + Tiling(MAP& map, unsigned int x, unsigned int y, unsigned int z): + m_map(map), + m_nx(x), m_ny(y), m_nz(z) + {} + + Tiling(MAP& map) : + m_map(map), + m_nx(-1), m_ny(-1), m_nz(-1) + {} + + Tiling(const Tiling& t1, const Tiling t2); + + /** + * get the table of vertex darts (one per vertex) + */ + std::vector& getVertexDarts() { return m_tableVertDarts; } + + /** + * get the table of face darts (one per face) + */ + std::vector& getFaceDarts() { return m_tableFaceDarts; } + + void computeCenter(VertexAttribute& position); + + //void Polyhedron::transform(float* matrice) + void transform(VertexAttribute& position, const Geom::Matrix44f& matrice); + + void mark(CellMarker& m); + + /* + * get the reference dart + */ + Dart getDart() { return m_dart; } + + bool exportPositions(const VertexAttribute& position, const char* filename); + + // /** + // * mark all embedded vertices of the Polyhedron + // * @param m the marker to use + // */ + //// void markEmbVertices(Mark m); + + // /** + // * test if a vertex is in the Polyhedron + // * @param d a dart of the vertex to test + // */ + // bool containVertex(Dart d); +}; + +} // namespace Tilings + +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN + +#include "Algo/Tiling/tiling.hpp" + +#endif //_TILING_H_ diff --git a/Apps/Tests/Algo/Topo/CMakeLists.txt b/Apps/Tests/Algo/Topo/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..25fb22a6a84094ea2c9266569e417a71c7acf39e --- /dev/null +++ b/Apps/Tests/Algo/Topo/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_algo_topo) + +add_executable( test_algo_topo +algo_topo.cpp +basic.cpp +embedding.cpp +simplex.cpp +Map2/uniformOrientation.cpp +) + +target_link_libraries( test_algo_topo + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Algo/Topo/Map2/uniformOrientation.cpp b/Apps/Tests/Algo/Topo/Map2/uniformOrientation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..66f0d6629e9bcde951f8406cd19c8f7baac36cfb --- /dev/null +++ b/Apps/Tests/Algo/Topo/Map2/uniformOrientation.cpp @@ -0,0 +1,18 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" + +#include "Algo/Topo/Map2/uniformOrientation.h" + +using namespace CGoGN; + +template void Algo::Topo::uniformOrientationCC(EmbeddedMap2& map, Dart faceSeed); + +// do not work but do not need ! +//template void Algo::Topo::uniformOrientationCC(EmbeddedGMap2& map, Dart faceSeed); + + +int test_uniformOrientation() +{ + return 0; +} diff --git a/Apps/Tests/Algo/Topo/algo_topo.cpp b/Apps/Tests/Algo/Topo/algo_topo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a3e41a22f167837dc4aaa4d191279b1aa68c797a --- /dev/null +++ b/Apps/Tests/Algo/Topo/algo_topo.cpp @@ -0,0 +1,17 @@ +#include + +extern int test_basic(); +extern int test_embedding(); +extern int test_simplex(); +extern int test_uniformOrientation(); + +int main() +{ + test_basic(); + test_embedding(); + test_simplex(); + test_uniformOrientation(); + + + return 0; +} diff --git a/Apps/Tests/Algo/Topo/basic.cpp b/Apps/Tests/Algo/Topo/basic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f6a824704ca2fd2de7370fe10b877265ed8c5e20 --- /dev/null +++ b/Apps/Tests/Algo/Topo/basic.cpp @@ -0,0 +1,84 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap3.h" + +#include "Algo/Topo/basic.h" + +using namespace CGoGN; + +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap2& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap2& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap2& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap2& map); + +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedGMap2& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedGMap2& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedGMap2& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedGMap2& map); + +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap3& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap3& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap3& map); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap3& map); + + + +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap2& map, unsigned int orbit); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedGMap2& map, unsigned int orbit); +template unsigned int Algo::Topo::getNbOrbits(const EmbeddedMap3& map, unsigned int orbit); + + +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap2& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap2& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap2& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap2& map, bool realloc); + +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedGMap2& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedGMap2& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedGMap2& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedGMap2& map, bool realloc); + +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap3& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap3& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap3& map, bool realloc); +template void Algo::Topo::initAllOrbitsEmbedding(EmbeddedMap3& map, bool realloc); + + +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap2& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap2& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap2& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap2& map, AttributeHandler& idx); + +template unsigned int Algo::Topo::computeIndexCells(EmbeddedGMap2& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedGMap2& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedGMap2& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedGMap2& map, AttributeHandler& idx); + +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap3& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap3& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap3& map, AttributeHandler& idx); +template unsigned int Algo::Topo::computeIndexCells(EmbeddedMap3& map, AttributeHandler& idx); + + +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap2& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap2& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap2& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap2& map); + +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedGMap2& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedGMap2& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedGMap2& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedGMap2& map); + +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap3& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap3& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap3& map); +template void Algo::Topo::bijectiveOrbitEmbedding(EmbeddedMap3& map); + + + +int test_basic() +{ + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Algo/Topo/embedding.cpp b/Apps/Tests/Algo/Topo/embedding.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9edb5742aa8db78332e843b18369bf7be7056ff2 --- /dev/null +++ b/Apps/Tests/Algo/Topo/embedding.cpp @@ -0,0 +1,131 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap3.h" + +#include "Algo/Topo/embedding.h" + +using namespace CGoGN; + +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); + +template void Algo::Topo::setOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); + +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); +template void Algo::Topo::setOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); + + + +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap2& m, Cell c, unsigned int em); + +template void Algo::Topo::initOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedGMap2& m, Cell c, unsigned int em); + +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); +template void Algo::Topo::initOrbitEmbedding(EmbeddedMap3& m, Cell c, unsigned int em); + + +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); + +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); + +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); +template unsigned int Algo::Topo::setOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); + + + +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap2& m, Cell c); + +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedGMap2& m, Cell c); + +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); +template unsigned int Algo::Topo::initOrbitEmbeddingOnNewCell(EmbeddedMap3& m, Cell c); + + + +template void Algo::Topo::copyCellAttributes(EmbeddedMap2& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedMap2& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedMap2& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedMap2& m, Cell c, Cell e); + +template void Algo::Topo::copyCellAttributes(EmbeddedGMap2& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedGMap2& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedGMap2& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedGMap2& m, Cell c, Cell e); + +template void Algo::Topo::copyCellAttributes(EmbeddedMap3& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedMap3& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedMap3& m, Cell c, Cell e); +template void Algo::Topo::copyCellAttributes(EmbeddedMap3& m, Cell c, Cell e); + + + +template void Algo::Topo::boundaryMarkOrbit<2, VERTEX, EmbeddedMap2>(EmbeddedMap2& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<2, EDGE, EmbeddedMap2>(EmbeddedMap2& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<2, FACE, EmbeddedMap2>(EmbeddedMap2& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<2, VOLUME, EmbeddedMap2>(EmbeddedMap2& m, Cell c); + +template void Algo::Topo::boundaryMarkOrbit<2, VERTEX, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<2, EDGE, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<2, FACE, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<2, VOLUME, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); + +template void Algo::Topo::boundaryMarkOrbit<3, VERTEX, EmbeddedMap3>(EmbeddedMap3& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<3, EDGE, EmbeddedMap3>(EmbeddedMap3& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<3, FACE, EmbeddedMap3>(EmbeddedMap3& m, Cell c); +template void Algo::Topo::boundaryMarkOrbit<3, VOLUME, EmbeddedMap3>(EmbeddedMap3& m, Cell c); + + + +template void Algo::Topo::boundaryUnmarkOrbit<2, VERTEX, EmbeddedMap2>(EmbeddedMap2& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<2, EDGE, EmbeddedMap2>(EmbeddedMap2& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<2, FACE, EmbeddedMap2>(EmbeddedMap2& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<2, VOLUME, EmbeddedMap2>(EmbeddedMap2& m, Cell c); + +template void Algo::Topo::boundaryUnmarkOrbit<2, VERTEX, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<2, EDGE, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<2, FACE, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<2, VOLUME, EmbeddedGMap2>(EmbeddedGMap2& m, Cell c); + +template void Algo::Topo::boundaryUnmarkOrbit<3, VERTEX, EmbeddedMap3>(EmbeddedMap3& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<3, EDGE, EmbeddedMap3>(EmbeddedMap3& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<3, FACE, EmbeddedMap3>(EmbeddedMap3& m, Cell c); +template void Algo::Topo::boundaryUnmarkOrbit<3, VOLUME, EmbeddedMap3>(EmbeddedMap3& m, Cell c); + + +int test_embedding() +{ + return 0; +} + diff --git a/Apps/Tests/Algo/Topo/simplex.cpp b/Apps/Tests/Algo/Topo/simplex.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f6c3f2d5bb9c9839095296f2c770712118fff77a --- /dev/null +++ b/Apps/Tests/Algo/Topo/simplex.cpp @@ -0,0 +1,26 @@ +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" +#include "Topology/gmap/embeddedGMap2.h" +#include "Topology/map/embeddedMap3.h" + +#include "Algo/Topo/simplex.h" + +using namespace CGoGN; + +template bool Algo::Topo::isSimplex(const EmbeddedMap2& map, Dart d); +template bool Algo::Topo::isSimplex(const EmbeddedMap2& map, Dart d); +template bool Algo::Topo::isSimplex(const EmbeddedMap2& map, Dart d); +template bool Algo::Topo::isSimplex(const EmbeddedMap2& map, Dart d); + + +template bool Algo::Topo::isSimplex(const EmbeddedMap3& map, Dart d); +template bool Algo::Topo::isSimplex(const EmbeddedMap3& map, Dart d); +template bool Algo::Topo::isSimplex(const EmbeddedMap3& map, Dart d); +template bool Algo::Topo::isSimplex(const EmbeddedMap3& map, Dart d); + + +int test_simplex() +{ + return 0; +} + diff --git a/Apps/Tests/CMakeLists.txt b/Apps/Tests/CMakeLists.txt index 30e129b13c7e630df8943a3f82a0c64f9c51512d..2d805eb950b75de4a0b58e610c5b3ac13712f47f 100644 --- a/Apps/Tests/CMakeLists.txt +++ b/Apps/Tests/CMakeLists.txt @@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 2.6) project(testing) - +add_subdirectory(Algo) +add_subdirectory(Container) +add_subdirectory(Geometry) +add_subdirectory(Utils) #define exec to compile diff --git a/Apps/Tests/Container/CMakeLists.txt b/Apps/Tests/Container/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b0149b83292dce047b7727d19226f6d7284f6c3 --- /dev/null +++ b/Apps/Tests/Container/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_container) + +add_executable( test_container + test_container.cpp + attributeContainer.cpp + attributeMultiVector.cpp + containerBrowser.cpp ) + +target_link_libraries( test_container + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) diff --git a/Apps/Tests/Container/attributeContainer.cpp b/Apps/Tests/Container/attributeContainer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ee8325ab7b798b491d492eac7ebd2150c7a8009 --- /dev/null +++ b/Apps/Tests/Container/attributeContainer.cpp @@ -0,0 +1,69 @@ +#include "Container/attributeContainer.h" +#include "Geometry/vector_gen.h" + + +namespace CGoGN +{ + +// char instantiation + +template AttributeMultiVector* AttributeContainer::addAttribute(const std::string& attribName); +template void AttributeContainer::addAttribute(const std::string& attribName, const std::string& typeName, unsigned int index); +template bool AttributeContainer::removeAttribute(const std::string& attribName); +template bool AttributeContainer::removeAttribute(unsigned int index); +template unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrIndex, std::vector& vect_ptr, unsigned int& byteBlockSize) const; +template AttributeMultiVector* AttributeContainer::getDataVector(unsigned int attrIndex); +template AttributeMultiVector* AttributeContainer::getDataVector(const std::string& attribName); +template char& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex) ; +template const char& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex) const ; +template void AttributeContainer::setData(unsigned int attrIndex, unsigned int eltIndex, const char& data); + + +// int instantiation +// +//template AttributeMultiVector* AttributeContainer::addAttribute(const std::string& attribName); +//template void AttributeContainer::addAttribute(const std::string& attribName, const std::string& typeName, unsigned int index); +//template bool AttributeContainer::removeAttribute(const std::string& attribName); +//template bool AttributeContainer::removeAttribute(unsigned int index); +//template unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrIndex, std::vector& vect_ptr, unsigned int& byteBlockSize) const; +//template AttributeMultiVector* AttributeContainer::getDataVector(unsigned int attrIndex); +//template AttributeMultiVector* AttributeContainer::getDataVector(const std::string& attribName); +//template int& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex); +//template const int& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex) const; +//template void AttributeContainer::setData(unsigned int attrIndex, unsigned int eltIndex, const int& data); +// +// +//// double instantiation +// +//template AttributeMultiVector* AttributeContainer::addAttribute(const std::string& attribName); +//template void AttributeContainer::addAttribute(const std::string& attribName, const std::string& typeName, unsigned int index); +//template bool AttributeContainer::removeAttribute(const std::string& attribName); +//template bool AttributeContainer::removeAttribute(unsigned int index); +//template unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrIndex, std::vector& vect_ptr, unsigned int& byteBlockSize) const; +//template AttributeMultiVector* AttributeContainer::getDataVector(unsigned int attrIndex); +//template AttributeMultiVector* AttributeContainer::getDataVector(const std::string& attribName); +//template double& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex); +//template const double& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex) const; +//template void AttributeContainer::setData(unsigned int attrIndex, unsigned int eltIndex, const double& data); +// +// +//// Geom::Vec4f instantiation +// +//template AttributeMultiVector* AttributeContainer::addAttribute(const std::string& attribName); +//template void AttributeContainer::addAttribute(const std::string& attribName, const std::string& typeName, unsigned int index); +//template bool AttributeContainer::removeAttribute(const std::string& attribName); +//template bool AttributeContainer::removeAttribute(unsigned int index); +//template unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrIndex, std::vector& vect_ptr, unsigned int& byteBlockSize) const; +//template AttributeMultiVector* AttributeContainer::getDataVector(unsigned int attrIndex); +//template AttributeMultiVector* AttributeContainer::getDataVector(const std::string& attribName); +//template Geom::Vec4f& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex); +//template const Geom::Vec4f& AttributeContainer::getData(unsigned int attrIndex, unsigned int eltIndex) const; +//template void AttributeContainer::setData(unsigned int attrIndex, unsigned int eltIndex, const Geom::Vec4f& data); + +} + +int test_attributeContainer() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Container/attributeMultiVector.cpp b/Apps/Tests/Container/attributeMultiVector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..52cc24ad8d08f54054b7d35bbf6a2c766f6be8d2 --- /dev/null +++ b/Apps/Tests/Container/attributeMultiVector.cpp @@ -0,0 +1,27 @@ +#include "Container/attributeMultiVector.h" +#include "Geometry/vector_gen.h" +#include "Container/fakeAttribute.h" + + +namespace CGoGN +{ + +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector; +template class AttributeMultiVector< NoTypeNameAttribute::const_iterator> >; + +} + +int test_attributeMultiVector() +{ + + return 0; +} + diff --git a/Apps/Tests/Container/containerBrowser.cpp b/Apps/Tests/Container/containerBrowser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..590bb288d920c0bec0755d800abb85c3ce7f2777 --- /dev/null +++ b/Apps/Tests/Container/containerBrowser.cpp @@ -0,0 +1,37 @@ + +#include "Topology/map/embeddedMap2.h" +#include "Topology/map/embeddedMap3.h" +#include "Topology/gmap/embeddedGMap2.h" + + +#include "Container/containerBrowser.h" + +namespace CGoGN +{ + + +template class DartContainerBrowserSelector; +template class DartContainerBrowserSelector; +template class DartContainerBrowserSelector; + + +template class ContainerBrowserCellMarked; +template class ContainerBrowserCellMarked; +template class ContainerBrowserCellMarked; + +template class ContainerBrowserCellMarked; +template class ContainerBrowserCellMarked; +template class ContainerBrowserCellMarked; + +template class ContainerBrowserCellMarked; +template class ContainerBrowserCellMarked; +template class ContainerBrowserCellMarked; +template class ContainerBrowserCellMarked; + +} + +int test_containerBrowser() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Container/test_container.cpp b/Apps/Tests/Container/test_container.cpp new file mode 100644 index 0000000000000000000000000000000000000000..909d52ebdd292bc9e568c17adabee0ca23bcf3b0 --- /dev/null +++ b/Apps/Tests/Container/test_container.cpp @@ -0,0 +1,17 @@ +#include + + +// no header files test function names from cpp files +extern int test_attributeContainer(); +extern int test_attributeMultiVector(); +extern int test_containerBrowser(); + + +int main() +{ + test_attributeContainer(); + test_attributeMultiVector(); + test_containerBrowser(); + + return 0; +} diff --git a/Apps/Tests/Geometry/CMakeLists.txt b/Apps/Tests/Geometry/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0b07614818f8c30e6bb4210d470c44bf4b78f0d0 --- /dev/null +++ b/Apps/Tests/Geometry/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_geometry) + +add_executable( test_geometry + test_geometry.cpp + basic.cpp + bounding_box.cpp + distances.cpp + frame.cpp + inclusion.cpp + intersection.cpp + matrix.cpp + orientation.cpp + plane_3d.cpp + tensor.cpp + transfo.cpp + vector_gen.cpp ) + +target_link_libraries( test_geometry + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) diff --git a/Apps/Tests/Geometry/basic.cpp b/Apps/Tests/Geometry/basic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3a07b36dc9cc89f2f0aa8535396073ccf789996e --- /dev/null +++ b/Apps/Tests/Geometry/basic.cpp @@ -0,0 +1,55 @@ +#include +#include + +using namespace CGoGN; + +/***************************************** +* BASIC INSTANTIATION +*****************************************/ + +template Geom::Vec3f Geom::lerp(const Geom::Vec3f& v1, const Geom::Vec3f& v2, float s); +template Geom::Vec3d Geom::lerp(const Geom::Vec3d& v1, const Geom::Vec3d& v2, double s); +template Geom::Vec4f Geom::lerp(const Geom::Vec4f& v1, const Geom::Vec4f& v2, float s); +template Geom::Vec4d Geom::lerp(const Geom::Vec4d& v1, const Geom::Vec4d& v2, double s); + +template Geom::Vector<3, float> Geom::barycenter(const Vector<3, float>& v1, const Vector<3, float>& v2, float a, float b); +template Geom::Vector<3, double> Geom::barycenter(const Vector<3, double>& v1, const Vector<3, double>& v2, double a, double b); +template Geom::Vector<4, float> Geom::barycenter(const Vector<4, float>& v1, const Vector<4, float>& v2, float a, float b); +template Geom::Vector<4, double> Geom::barycenter(const Vector<4, double>& v1, const Vector<4, double>& v2, double a, double b); + +template Geom::Vector<3, float> Geom::isobarycenter(const Vector<3, float>& v1, const Vector<3, float>& v2); +template Geom::Vector<3, double> Geom::isobarycenter(const Vector<3, double>& v1, const Vector<3, double>& v2); +template Geom::Vector<4, float> Geom::isobarycenter(const Vector<4, float>& v1, const Vector<4, float>& v2); +template Geom::Vector<4, double> Geom::isobarycenter(const Vector<4, double>& v1, const Vector<4, double>& v2); + +template Geom::Vector<3, float> Geom::barycenter(const Vector<3, float>& v1, const Vector<3, float>& v2, const Vector<3, float>& v3, float a, float b, float c); +template Geom::Vector<3, double> Geom::barycenter(const Vector<3, double>& v1, const Vector<3, double>& v2, const Vector<3, double>& v3, double a, double b, double c); +template Geom::Vector<4, float> Geom::barycenter(const Vector<4, float>& v1, const Vector<4, float>& v2, const Vector<4, float>& v3, float a, float b, float c); +template Geom::Vector<4, double> Geom::barycenter(const Vector<4, double>& v1, const Vector<4, double>& v2, const Vector<4, double>& v3, double a, double b, double c); + +template Geom::Vector<3, float> Geom::isobarycenter(const Vector<3, float>& v1, const Vector<3, float>& v2, const Vector<3, float>& v3); +template Geom::Vector<3, double> Geom::isobarycenter(const Vector<3, double>& v1, const Vector<3, double>& v2, const Vector<3, double>& v3); +template Geom::Vector<4, float> Geom::isobarycenter(const Vector<4, float>& v1, const Vector<4, float>& v2, const Vector<4, float>& v3); +template Geom::Vector<4, double> Geom::isobarycenter(const Vector<4, double>& v1, const Vector<4, double>& v2, const Vector<4, double>& v3); + +template float Geom::angle(const Geom::Vec3f& a, const Geom::Vec3f& b); +template double Geom::angle(const Geom::Vec3d& a, const Geom::Vec3d& b); + +template float Geom::triangleArea(const Geom::Vec3f& p1, const Geom::Vec3f& p2, const Geom::Vec3f& p3); +template double Geom::triangleArea(const Geom::Vec3d& p1, const Geom::Vec3d& p2, const Geom::Vec3d& p3); + +template Geom::Vec3f Geom::triangleNormal(const Geom::Vec3f& p1, const Geom::Vec3f& p2, const Geom::Vec3f& p3); +template Geom::Vec3d Geom::triangleNormal(const Geom::Vec3d& p1, const Geom::Vec3d& p2, const Geom::Vec3d& p3); + +template float Geom::tetraVolume(const Geom::Vec3f& p1, const Geom::Vec3f& p2, const Geom::Vec3f& p3, const Geom::Vec3f& p4); +template double Geom::tetraVolume(const Geom::Vec3d& p1, const Geom::Vec3d& p2, const Geom::Vec3d& p3, const Geom::Vec3d& p4); + +template float Geom::parallelepipedVolume(const Geom::Vec3f& p1, const Geom::Vec3f& p2, const Geom::Vec3f& p3); +template double Geom::parallelepipedVolume(const Geom::Vec3d& p1, const Geom::Vec3d& p2, const Geom::Vec3d& p3); + + + +int test_basic() +{ + return 0; +} diff --git a/Apps/Tests/Geometry/bounding_box.cpp b/Apps/Tests/Geometry/bounding_box.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e1b105934c1e22d3ecf8144970922d9cea1d984 --- /dev/null +++ b/Apps/Tests/Geometry/bounding_box.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +using namespace CGoGN; + + +/***************************************** +* BOUNDING BOX INSTANTIATION +*****************************************/ + +template class Geom::BoundingBox< Geom::Vector<3, int> >; +template class Geom::BoundingBox< Geom::Vector<3, float> >; +template class Geom::BoundingBox< Geom::Vector<3, double> >; + +template class Geom::BoundingBox< Geom::Vector<4, int> >; +template class Geom::BoundingBox< Geom::Vector<4, float> >; +template class Geom::BoundingBox< Geom::Vector<4, double> >; + + + +int test_bounding_box() +{ + + return 0; +} diff --git a/Apps/Tests/Geometry/distances.cpp b/Apps/Tests/Geometry/distances.cpp new file mode 100644 index 0000000000000000000000000000000000000000..271788027e65f8d182fb1e33f111803bb9fe4600 --- /dev/null +++ b/Apps/Tests/Geometry/distances.cpp @@ -0,0 +1,37 @@ +#include + +#include + +using namespace CGoGN; + +/***************************************** +* DISTANCES INSTANTIATION +*****************************************/ + +template float Geom::squaredDistancePoint2TrianglePlane(const Geom::Vec3f& P, const Geom::Vec3f& A, const Geom::Vec3f& B, const Geom::Vec3f& C); +template float Geom::distancePoint2TrianglePlane(const Geom::Vec3f& P, const Geom::Vec3f& A, const Geom::Vec3f& B, const Geom::Vec3f& C); +template float Geom::squaredDistancePoint2Triangle(const Geom::Vec3f& P, const Geom::Vec3f& A, const Geom::Vec3f& B, const Geom::Vec3f& C); +template float Geom::squaredDistanceLine2Point(const Geom::Vec3f& A, const Geom::Vec3f& AB, float AB1, const Geom::Vec3f& P); +template float Geom::squaredDistanceLine2Point(const Geom::Vec3f& A, const Geom::Vec3f& B, const Geom::Vec3f& P); +template float Geom::squaredDistanceLine2Line(const Geom::Vec3f& A, const Geom::Vec3f& AB, float AB2, const Geom::Vec3f& P, const Geom::Vec3f& Q); +template float Geom::squaredDistanceLine2Seg(const Geom::Vec3f& A, const Geom::Vec3f& AB, float AB2, const Geom::Vec3f& P, const Geom::Vec3f& Q); +template float Geom::squaredDistanceSeg2Point(const Geom::Vec3f& A, const Geom::Vec3f& AB, float AB2, const Geom::Vec3f& P); +template bool Geom::lineLineClosestPoints(const Geom::Vec3f& P1, const Geom::Vec3f& V1, const Geom::Vec3f& P2, const Geom::Vec3f& V2, Geom::Vec3f& Q1, Geom::Vec3f& Q2); + + +template double Geom::squaredDistancePoint2TrianglePlane(const Geom::Vec3d& P, const Geom::Vec3d& A, const Geom::Vec3d& B, const Geom::Vec3d& C); +template double Geom::distancePoint2TrianglePlane(const Geom::Vec3d& P, const Geom::Vec3d& A, const Geom::Vec3d& B, const Geom::Vec3d& C); +template double Geom::squaredDistancePoint2Triangle(const Geom::Vec3d& P, const Geom::Vec3d& A, const Geom::Vec3d& B, const Geom::Vec3d& C); +template double Geom::squaredDistanceLine2Point(const Geom::Vec3d& A, const Geom::Vec3d& AB, double AB1, const Geom::Vec3d& P); +template double Geom::squaredDistanceLine2Point(const Geom::Vec3d& A, const Geom::Vec3d& B, const Geom::Vec3d& P); +template double Geom::squaredDistanceLine2Line(const Geom::Vec3d& A, const Geom::Vec3d& AB, double AB2, const Geom::Vec3d& P, const Geom::Vec3d& Q); +template double Geom::squaredDistanceLine2Seg(const Geom::Vec3d& A, const Geom::Vec3d& AB, double AB2, const Geom::Vec3d& P, const Geom::Vec3d& Q); +template double Geom::squaredDistanceSeg2Point(const Geom::Vec3d& A, const Geom::Vec3d& AB, double AB2, const Geom::Vec3d& P); +template bool Geom::lineLineClosestPoints(const Geom::Vec3d& P1, const Geom::Vec3d& V1, const Geom::Vec3d& P2, const Geom::Vec3d& V2, Geom::Vec3d& Q1, Geom::Vec3d& Q2); + + +int test_distances() +{ + + return 0; +} diff --git a/Apps/Tests/Geometry/frame.cpp b/Apps/Tests/Geometry/frame.cpp new file mode 100644 index 0000000000000000000000000000000000000000..186994db0893090ef8863351f6d5c0544a213e88 --- /dev/null +++ b/Apps/Tests/Geometry/frame.cpp @@ -0,0 +1,33 @@ +#include +#include + +using namespace CGoGN; + +/***************************************** +* FRAME INSTANTIATION +*****************************************/ + +template Geom::Vector<3, float> Geom::rotate(Geom::Vector<3, float> axis, float angle, Geom::Vector<3, float> p); +template Geom::Vector<3, float> Geom::sphericalToCart(const Geom::Vector<3, float>& sph); +template Geom::Vector<3, float> Geom::cartToSpherical(const Geom::Vector<3, float>& cart); +template bool Geom::isDirectOrthoNormalFrame(const Geom::Vec3f& X, const Geom::Vec3f& Y, const Geom::Vec3f& Z, float epsilon); +template bool Geom::isDirectFrame(const Geom::Vec3f& X, const Geom::Vec3f& Y, const Geom::Vec3f& Z, float epsilon); +template bool Geom::isOrthogonalFrame(const Geom::Vec3f& X, const Geom::Vec3f& Y, const Geom::Vec3f& Z, float epsilon); +template bool Geom::isNormalizedFrame(const Geom::Vec3f& X, const Geom::Vec3f& Y, const Geom::Vec3f& Z, float epsilon); + +template Geom::Vector<3, double> Geom::rotate(Geom::Vector<3, double> axis, double angle, Geom::Vector<3, double> p); +template Geom::Vector<3, double> Geom::sphericalToCart(const Geom::Vector<3, double>& sph); +template Geom::Vector<3, double> Geom::cartToSpherical(const Geom::Vector<3, double>& cart); +template bool Geom::isDirectOrthoNormalFrame(const Geom::Vec3d& X, const Geom::Vec3d& Y, const Geom::Vec3d& Z, double epsilon); +template bool Geom::isDirectFrame(const Geom::Vec3d& X, const Geom::Vec3d& Y, const Geom::Vec3d& Z, double epsilon); +template bool Geom::isOrthogonalFrame(const Geom::Vec3d& X, const Geom::Vec3d& Y, const Geom::Vec3d& Z, double epsilon); +template bool Geom::isNormalizedFrame(const Geom::Vec3d& X, const Geom::Vec3d& Y, const Geom::Vec3d& Z, double epsilon); + +template class Geom::Frame; +template class Geom::Frame; + + +int test_frame() +{ + return 0; +} diff --git a/Apps/Tests/Geometry/inclusion.cpp b/Apps/Tests/Geometry/inclusion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f0a5078aecbcb8ce2e335a694252737899b49d1c --- /dev/null +++ b/Apps/Tests/Geometry/inclusion.cpp @@ -0,0 +1,27 @@ +#include +#include + +using namespace CGoGN; + +/***************************************** +* INCLUSION INSTANTIATION +*****************************************/ + +template Geom::Inclusion Geom::isPointInTriangle(const Geom::Vec3f& point, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc); +template bool Geom::isPointInSphere(const Geom::Vec3f& point, const Geom::Vec3f& center, const float& radius); +template Geom::Inclusion Geom::isSegmentInTriangle2D(const Geom::Vec3f& P1, const Geom::Vec3f& P2, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, const Geom::Vec3f& N); +template bool Geom::isPointInTetrahedron(Geom::Vec3f points[4], Geom::Vec3f& point, bool); +template bool Geom::isEdgeInOrIntersectingTetrahedron(Geom::Vec3f points[4], Geom::Vec3f& point1, Geom::Vec3f& point2, bool CCW); +template bool Geom::arePointsEquals(const Geom::Vec3f& point1, const Geom::Vec3f& point2); + +template Geom::Inclusion Geom::isPointInTriangle(const Geom::Vec3d& point, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc); +template bool Geom::isPointInSphere(const Geom::Vec3d& point, const Geom::Vec3d& center, const double& radius); +template Geom::Inclusion Geom::isSegmentInTriangle2D(const Geom::Vec3d& P1, const Geom::Vec3d& P2, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, const Geom::Vec3d& N); +template bool Geom::isPointInTetrahedron(Geom::Vec3d points[4], Geom::Vec3d& point, bool); +template bool Geom::isEdgeInOrIntersectingTetrahedron(Geom::Vec3d points[4], Geom::Vec3d& point1, Geom::Vec3d& point2, bool CCW); +template bool Geom::arePointsEquals(const Geom::Vec3d& point1, const Geom::Vec3d& point2); + +int test_inclusion() +{ + return 0; +} diff --git a/Apps/Tests/Geometry/intersection.cpp b/Apps/Tests/Geometry/intersection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb4a72f5dc8fd5b2b116cdce633183cee22d969c --- /dev/null +++ b/Apps/Tests/Geometry/intersection.cpp @@ -0,0 +1,49 @@ +#include + +#include + +using namespace CGoGN; + +/***************************************** +* INTERSECTION INSTANTIATION +*****************************************/ + +template Geom::Intersection Geom::intersectionLinePlane(const Geom::Vec3f& P, const Geom::Vec3f& Dir, const Geom::Vec3f& PlaneP, const Geom::Vec3f& NormP, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionLinePlane(const Geom::Vec3f& P, const Geom::Vec3f& Dir, const Geom::Plane3D& Plane, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionRayTriangle(const Geom::Vec3f& P, const Geom::Vec3f& Dir, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionRayTriangleOpt(const Geom::Vec3f& P, const Geom::Vec3f& Dir, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionRayTriangleOpt(const Geom::Vec3f& P, const Geom::Vec3f& Dir, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc); +template Geom::Intersection Geom::intersectionLineTriangle(const Geom::Vec3f& P, const Geom::Vec3f& Dir, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionLineTriangle2D(const Geom::Vec3f& P, const Geom::Vec3f& Dir, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionSegmentTriangle(const Geom::Vec3f& PA, const Geom::Vec3f& PB, const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionPlaneRay(const Geom::Plane3D& pl, const Geom::Vec3f& p1, const Geom::Vec3f& dir, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersection2DSegmentSegment(const Geom::Vec3f& PA, const Geom::Vec3f& PB, const Geom::Vec3f& QA, const Geom::Vec3f& QB, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionSegmentPlan(const Geom::Vec3f& PA, const Geom::Vec3f& PB, const Geom::Vec3f& PlaneP, const Geom::Vec3f& NormP); +template Geom::Intersection Geom::intersectionSegmentPlan(const Geom::Vec3f& PA, const Geom::Vec3f& PB, const Geom::Vec3f& PlaneP, const Geom::Vec3f& NormP, Geom::Vec3f& Inter); +template Geom::Intersection Geom::intersectionTrianglePlan(const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, const Geom::Vec3f& PlaneP, const Geom::Vec3f& NormP); +template Geom::Intersection Geom::intersectionSegmentHalfPlan(const Geom::Vec3f& PA, const Geom::Vec3f& PB, const Geom::Vec3f& P, const Geom::Vec3f& DirP, const Geom::Vec3f& OrientP); +template Geom::Intersection Geom::intersectionTriangleHalfPlan(const Geom::Vec3f& Ta, const Geom::Vec3f& Tb, const Geom::Vec3f& Tc, const Geom::Vec3f& P, const Geom::Vec3f& DirP, const Geom::Vec3f& OrientP); +template bool Geom::interLineSeg(const Geom::Vec3f& A, const Geom::Vec3f& AB, float AB2, const Geom::Vec3f& P, const Geom::Vec3f& Q, Geom::Vec3f& inter); + +template Geom::Intersection Geom::intersectionLinePlane(const Geom::Vec3d& P, const Geom::Vec3d& Dir, const Geom::Vec3d& PlaneP, const Geom::Vec3d& NormP, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionLinePlane(const Geom::Vec3d& P, const Geom::Vec3d& Dir, const Geom::Plane3D& Plane, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionRayTriangle(const Geom::Vec3d& P, const Geom::Vec3d& Dir, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionRayTriangleOpt(const Geom::Vec3d& P, const Geom::Vec3d& Dir, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionRayTriangleOpt(const Geom::Vec3d& P, const Geom::Vec3d& Dir, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc); +template Geom::Intersection Geom::intersectionLineTriangle(const Geom::Vec3d& P, const Geom::Vec3d& Dir, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionLineTriangle2D(const Geom::Vec3d& P, const Geom::Vec3d& Dir, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionSegmentTriangle(const Geom::Vec3d& PA, const Geom::Vec3d& PB, const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionPlaneRay(const Geom::Plane3D& pl, const Geom::Vec3d& p1, const Geom::Vec3d& dir, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersection2DSegmentSegment(const Geom::Vec3d& PA, const Geom::Vec3d& PB, const Geom::Vec3d& QA, const Geom::Vec3d& QB, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionSegmentPlan(const Geom::Vec3d& PA, const Geom::Vec3d& PB, const Geom::Vec3d& PlaneP, const Geom::Vec3d& NormP); +template Geom::Intersection Geom::intersectionSegmentPlan(const Geom::Vec3d& PA, const Geom::Vec3d& PB, const Geom::Vec3d& PlaneP, const Geom::Vec3d& NormP, Geom::Vec3d& Inter); +template Geom::Intersection Geom::intersectionTrianglePlan(const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, const Geom::Vec3d& PlaneP, const Geom::Vec3d& NormP); +template Geom::Intersection Geom::intersectionSegmentHalfPlan(const Geom::Vec3d& PA, const Geom::Vec3d& PB, const Geom::Vec3d& P, const Geom::Vec3d& DirP, const Geom::Vec3d& OrientP); +template Geom::Intersection Geom::intersectionTriangleHalfPlan(const Geom::Vec3d& Ta, const Geom::Vec3d& Tb, const Geom::Vec3d& Tc, const Geom::Vec3d& P, const Geom::Vec3d& DirP, const Geom::Vec3d& OrientP); +template bool Geom::interLineSeg(const Geom::Vec3d& A, const Geom::Vec3d& AB, double AB2, const Geom::Vec3d& P, const Geom::Vec3d& Q, Geom::Vec3d& inter); + + +int test_intersection() +{ + return 0; +} diff --git a/Apps/Tests/Geometry/matrix.cpp b/Apps/Tests/Geometry/matrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..97419ccc260006c6246ab5c7f30fcc8dd792d066 --- /dev/null +++ b/Apps/Tests/Geometry/matrix.cpp @@ -0,0 +1,42 @@ +#include + +#include + +using namespace CGoGN; + +/***************************************** +* MATRIX INSTANTIATION +*****************************************/ + +template class Geom::Matrix<2, 2, float>; +template class Geom::Matrix<3, 3, float>; +template class Geom::Matrix<4, 4, float>; +template class Geom::Matrix<7, 7, float>; + +template class Geom::Matrix<2, 2, double>; +template class Geom::Matrix<3, 3, double>; +template class Geom::Matrix<4, 4, double>; +template class Geom::Matrix<7, 7, double>; + + +int test_matrix() +{ + // test matrixx MN + Geom::Matrix<3, 2, float> Af; + Geom::Matrix<2, 3, float> Bf; + Geom::Matrix<3, 3, float> Cf = Af*Bf; + Geom::Matrix<2, 2, float> Df = Bf*Af; + + std::cout << Cf << std::endl; + std::cout << Df << std::endl; + + Geom::Matrix<3, 2, double> Ad; + Geom::Matrix<2, 3, double> Bd; + Geom::Matrix<3, 3, double> Cd = Ad*Bd; + Geom::Matrix<2, 2, double> Dd = Bd*Ad; + + std::cout << Cd << std::endl; + std::cout << Dd << std::endl; + + return 0; +} diff --git a/Apps/Tests/Geometry/orientation.cpp b/Apps/Tests/Geometry/orientation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..df33e830aa6059a6caba8bf356b4516d436cba83 --- /dev/null +++ b/Apps/Tests/Geometry/orientation.cpp @@ -0,0 +1,33 @@ +#include +#include + +using namespace CGoGN; + +/***************************************** +* ORIENTATION INSTANTIATION +*****************************************/ +template Geom::OrientationLine Geom::testOrientationLines(const Geom::Vec3f& a, const Geom::Vec3f& b, const Geom::Vec3f& c, const Geom::Vec3f& d); +template Geom::Orientation3D Geom::testOrientation3D(const Geom::Vec3f& P, const Geom::Vec3f& A, const Geom::Vec3f& B, const Geom::Vec3f& C); +template Geom::Orientation3D Geom::testOrientation3D(const Geom::Vec3f& P, const Geom::Vec3f& N, const Geom::Vec3f& PP); +template Geom::Orientation2D Geom::testOrientation2D(const Geom::Vec3f& P, const Geom::Vec3f& Pa, const Geom::Vec3f& Pb); +template int Geom::orientation2D(const Geom::Vec3f& u, const Geom::Vec3f& v); +template int Geom::aligned2D(const Geom::Vec3f& u, const Geom::Vec3f& v); +template bool Geom::isBetween(const Geom::Vec3f& u, const Geom::Vec3f& v, const Geom::Vec3f& w); +template bool Geom::isTetrahedronWellOriented(const Geom::Vec3f points[4], bool CCW); + + +template Geom::OrientationLine Geom::testOrientationLines(const Geom::Vec3d& a, const Geom::Vec3d& b, const Geom::Vec3d& c, const Geom::Vec3d& d); +template Geom::Orientation3D Geom::testOrientation3D(const Geom::Vec3d& P, const Geom::Vec3d& A, const Geom::Vec3d& B, const Geom::Vec3d& C); +template Geom::Orientation3D Geom::testOrientation3D(const Geom::Vec3d& P, const Geom::Vec3d& N, const Geom::Vec3d& PP); +template Geom::Orientation2D Geom::testOrientation2D(const Geom::Vec3d& P, const Geom::Vec3d& Pa, const Geom::Vec3d& Pb); +template int Geom::orientation2D(const Geom::Vec3d& u, const Geom::Vec3d& v); +template int Geom::aligned2D(const Geom::Vec3d& u, const Geom::Vec3d& v); +template bool Geom::isBetween(const Geom::Vec3d& u, const Geom::Vec3d& v, const Geom::Vec3d& w); +template bool Geom::isTetrahedronWellOriented(const Geom::Vec3d points[4], bool CCW); + + +int test_orientation() +{ + + return 0; +} diff --git a/Apps/Tests/Geometry/plane_3d.cpp b/Apps/Tests/Geometry/plane_3d.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cc1903d6ef40cc9bee1d70176e0d7e3085884ac7 --- /dev/null +++ b/Apps/Tests/Geometry/plane_3d.cpp @@ -0,0 +1,18 @@ +#include + +#include + +using namespace CGoGN; + +/***************************************** +* PLANE3D INSTANTIATION +*****************************************/ + +template class Geom::Plane3D; +template class Geom::Plane3D; + + +int test_plane3d() +{ + return 0; +} diff --git a/Apps/Tests/Geometry/tensor.cpp b/Apps/Tests/Geometry/tensor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21fdbb243b4a23738a25266bfc9e3168ee008e21 --- /dev/null +++ b/Apps/Tests/Geometry/tensor.cpp @@ -0,0 +1,25 @@ +#include + +#include + +using namespace CGoGN; + +/***************************************** +* TENSOR INSTANTIATION +*****************************************/ + +template class Geom::Tensor < 2, float>; +template class Geom::Tensor < 3, float>; +template class Geom::Tensor < 4, float>; + +template class Geom::Tensor < 2, double>; +template class Geom::Tensor < 3, double>; +template class Geom::Tensor < 4, double>; + + + + +int test_tensor() +{ + return 0; +} diff --git a/Apps/Tests/Geometry/test_geometry.cpp b/Apps/Tests/Geometry/test_geometry.cpp new file mode 100644 index 0000000000000000000000000000000000000000..289e0bb3b278bf6463a3e4883808c79a87a1b1e5 --- /dev/null +++ b/Apps/Tests/Geometry/test_geometry.cpp @@ -0,0 +1,34 @@ +#include + + +// no header files test function names from cpp files +extern int test_basic(); +extern int test_bounding_box(); +extern int test_intersection(); +extern int test_orientation(); +extern int test_inclusion(); +extern int test_matrix(); +extern int test_tensor(); +extern int test_transfo(); +extern int test_plane3d(); +extern int test_frame(); +extern int test_distances(); + + + +int main() +{ + test_basic(); + test_bounding_box(); + test_intersection(); + test_orientation(); + test_inclusion(); + test_matrix(); + test_tensor(); + test_transfo(); + test_plane3d(); + test_frame(); + test_distances(); + + return 0; +} diff --git a/Apps/Tests/Geometry/transfo.cpp b/Apps/Tests/Geometry/transfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b60d100556b2ec8c8c3e0bc32d2eadd9bf2ec130 --- /dev/null +++ b/Apps/Tests/Geometry/transfo.cpp @@ -0,0 +1,35 @@ +#include +#include + + +using namespace CGoGN; + + +/***************************************** +* TRNASFO INSTANTIATION +*****************************************/ + +template void Geom::scale(float sx, float sy, float sz, Geom::Matrix<4, 4, float>& mat); +template void Geom::translate(float tx, float ty, float tz, Matrix<4, 4, float>& mat); +template void Geom::rotateZ(float angle, Matrix<4, 4, float>& mat); +template void Geom::rotateY(float angle, Matrix<4, 4, float>& mat); +template void Geom::rotateX(float angle, Matrix<4, 4, float>& mat); +template void Geom::rotate(float axis_x, float axis_y, float axis_z, float angle, Matrix<4, 4, float>& mat); +template void Geom::rotate(Geom::Vector<3, float>& axis, float angle, Matrix<4, 4, float>& mat); +template Geom::Vector<3, float> Geom::transform(const Vector<3, float>& P, const Matrix<4, 4, float>& mat); + +template void Geom::scale(double sx, double sy, double sz, Geom::Matrix<4, 4, double>& mat); +template void Geom::translate(double tx, double ty, double tz, Matrix<4, 4, double>& mat); +template void Geom::rotateZ(double angle, Matrix<4, 4, double>& mat); +template void Geom::rotateY(double angle, Matrix<4, 4, double>& mat); +template void Geom::rotateX(double angle, Matrix<4, 4, double>& mat); +template void Geom::rotate(double axis_x, double axis_y, double axis_z, double angle, Matrix<4, 4, double>& mat); +template void Geom::rotate(Geom::Vector<3, double>& axis, double angle, Matrix<4, 4, double>& mat); +template Geom::Vector<3, double> Geom::transform(const Vector<3, double>& P, const Matrix<4, 4, double>& mat); + + + +int test_transfo() +{ + return 0; +} diff --git a/Apps/Tests/Geometry/vector_gen.cpp b/Apps/Tests/Geometry/vector_gen.cpp new file mode 100644 index 0000000000000000000000000000000000000000..00afc4b096cb1a722e7871395c365eb63678bccd --- /dev/null +++ b/Apps/Tests/Geometry/vector_gen.cpp @@ -0,0 +1,38 @@ +#include + +#define CGOGN_NO_STATIC_ASSERT 1 +#include "Geometry/vector_gen.h" + +using namespace CGoGN; + +template class Geom::Vector<2, short>; +template class Geom::Vector<2, float>; +template class Geom::Vector<2, double>; + +template class Geom::Vector<3, short>; +template class Geom::Vector<3, float>; +template class Geom::Vector<3, double>; + +template class Geom::Vector<4, short>; +template class Geom::Vector<4, float>; +template class Geom::Vector<4, double>; + +template class Geom::Vector<11, short>; +template class Geom::Vector<11, float>; +template class Geom::Vector<11, double>; + +int test_vector() +{ + Geom::Vec3f v1(3.0f,4.0f,5.0f); + Geom::Vec3f v2(13.0f,14.0f,15.0f); + + Geom::Vec3f v3 = v1+v2; + Geom::Vec3f v4 = v1^v2; + float sc = v1*v2; + + v1 *= 10.0f; + v2 *= 100.0f; + + return 0; +} + diff --git a/Apps/Tests/Utils/CMakeLists.txt b/Apps/Tests/Utils/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8bf0002ebf3e7e304d924930fe4a523c5374e2a1 --- /dev/null +++ b/Apps/Tests/Utils/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_utils) + +add_executable( test_utils + test_utils.cpp + colorMaps.cpp + colourConverter.cpp + qem.cpp + quadricRGBfunctions.cpp + quantization.cpp +# shared_mem.cpp + sphericalHarmonics.cpp + textures.cpp ) + +target_link_libraries( test_utils + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + +qt_use_cgogn_modules(test_utils) + diff --git a/Apps/Tests/Utils/colorMaps.cpp b/Apps/Tests/Utils/colorMaps.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bd2164730cda395b8b0f45ef02b2adba6abedf86 --- /dev/null +++ b/Apps/Tests/Utils/colorMaps.cpp @@ -0,0 +1,3 @@ +// +// TODO template instead of float + diff --git a/Apps/Tests/Utils/colourConverter.cpp b/Apps/Tests/Utils/colourConverter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cf54432ece907765481baf9d63acf92601a70e55 --- /dev/null +++ b/Apps/Tests/Utils/colourConverter.cpp @@ -0,0 +1,14 @@ +#include "Utils/colourConverter.h" + + +template class CGoGN::Utils::ColourConverter; +template class CGoGN::Utils::ColourConverter; + + +int test_colourConverter() +{ + + return 0; +} + + diff --git a/Apps/Tests/Utils/qem.cpp b/Apps/Tests/Utils/qem.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24121c39162778604b101c8500c67441ea95b5b2 --- /dev/null +++ b/Apps/Tests/Utils/qem.cpp @@ -0,0 +1,19 @@ +#include "Utils/qem.h" + + +template class CGoGN::Utils::Quadric; +template class CGoGN::Utils::Quadric; + +template class CGoGN::Utils::QuadricNd; +template class CGoGN::Utils::QuadricNd; + + +template class CGoGN::Utils::QuadricHF; +template class CGoGN::Utils::QuadricHF; + + +int test_qem() +{ + + return 0; +} diff --git a/Apps/Tests/Utils/quadricRGBfunctions.cpp b/Apps/Tests/Utils/quadricRGBfunctions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a36ab4a654fa69c7f72c55ee1a39b594f1695879 --- /dev/null +++ b/Apps/Tests/Utils/quadricRGBfunctions.cpp @@ -0,0 +1,11 @@ + +#include "Utils/quadricRGBfunctions.h" + +template class CGoGN::Utils::QuadricRGBfunctions; +template class CGoGN::Utils::QuadricRGBfunctions; + +int test_quadricRGBfunctions() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Utils/quantization.cpp b/Apps/Tests/Utils/quantization.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd316e0df60c8570ee67c1edab4958da7d45a85b --- /dev/null +++ b/Apps/Tests/Utils/quantization.cpp @@ -0,0 +1,21 @@ +#include "Utils/quantization.h" +#include "Geometry/vector_gen.h" + +using namespace CGoGN; + +template struct Utils::CodeVector; +template struct Utils::CodeVector; +template struct Utils::CodeVector; + + + +template class Utils::Quantization; +template class Utils::Quantization; +template class Utils::Quantization; + + +int test_quantization() +{ + + return 0; +} diff --git a/Apps/Tests/Utils/shared_mem.cpp b/Apps/Tests/Utils/shared_mem.cpp new file mode 100644 index 0000000000000000000000000000000000000000..962a27ea233e23369b4a7f3d8f6a58ab48a8b1a5 --- /dev/null +++ b/Apps/Tests/Utils/shared_mem.cpp @@ -0,0 +1,17 @@ +#include "Utils/shared_mem.h" +#include "Geometry/vector_gen.h" + +template class CGoGN::Utils::SharedMemSeg; +template class CGoGN::Utils::SharedMemSeg; +template class CGoGN::Utils::SharedMemSeg; + +template class CGoGN::Utils::SharedMemSeg; + + +int test_shared_mem() +{ + + return 0; +} + + diff --git a/Apps/Tests/Utils/sphericalHarmonics.cpp b/Apps/Tests/Utils/sphericalHarmonics.cpp new file mode 100644 index 0000000000000000000000000000000000000000..196e8b852497ba0d0efb8830ee6fde372aa1f693 --- /dev/null +++ b/Apps/Tests/Utils/sphericalHarmonics.cpp @@ -0,0 +1,15 @@ +#include "Utils/sphericalHarmonics.h" + + +template class CGoGN::Utils::SphericalHarmonics; +template class CGoGN::Utils::SphericalHarmonics; +template class CGoGN::Utils::SphericalHarmonics; +template class CGoGN::Utils::SphericalHarmonics; + + +int test_sphericalHarmonics() +{ + + return 0; +} + diff --git a/Apps/Tests/Utils/test_utils.cpp b/Apps/Tests/Utils/test_utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7bdd5917eb0ebae1fc467c362cd8147bf4737006 --- /dev/null +++ b/Apps/Tests/Utils/test_utils.cpp @@ -0,0 +1,26 @@ +#include + + +// no header files test function names from cpp files +//extern int test_colorMaps(); +extern int test_colourConverter(); +extern int test_qem(); +extern int test_quadricRGBfunctions(); +extern int test_quantization(); +//extern int test_shared_mem(); +extern int test_sphericalHarmonics(); +extern int test_texture(); + + +int main() +{ + //test_colorMaps(); + test_colourConverter(); + test_qem(); + test_quadricRGBfunctions(); + test_quantization(); +// test_shared_mem(); + test_sphericalHarmonics(); + test_texture(); + return 0; +} diff --git a/Apps/Tests/Utils/textures.cpp b/Apps/Tests/Utils/textures.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2c79bf3e23dc107ee7c814b69fec2214139eacd4 --- /dev/null +++ b/Apps/Tests/Utils/textures.cpp @@ -0,0 +1,67 @@ +#define CGOGN_NO_STATIC_ASSERT 1 + +#include "Utils/textures.h" + +template class CGoGN::Utils::Filter<1>; +template class CGoGN::Utils::Filter<2>; +template class CGoGN::Utils::Filter<3>; + +///////////////// 1 //////////////////////////////// + +template class CGoGN::Utils::ImageData<1, unsigned char>; +template class CGoGN::Utils::Image<1, unsigned char>; +template class CGoGN::Utils::Texture<1, unsigned char>; + +template class CGoGN::Utils::ImageData<1, int>; +template class CGoGN::Utils::Image<1, int>; +template class CGoGN::Utils::Texture<1, int>; + +template class CGoGN::Utils::ImageData<1, double>; +template class CGoGN::Utils::Image<1, double>; +template class CGoGN::Utils::Texture<1, double>; + +template class CGoGN::Utils::ImageData<1, CGoGN::Geom::Vec4f>; +template class CGoGN::Utils::Image<1, CGoGN::Geom::Vec4f>; +template class CGoGN::Utils::Texture<1, CGoGN::Geom::Vec4f>; + +///////////////// 2 ////////////////////////////////////// + +template class CGoGN::Utils::ImageData<2, unsigned char>; +template class CGoGN::Utils::Image<2, unsigned char>; +template class CGoGN::Utils::Texture<2, unsigned char>; + +template class CGoGN::Utils::ImageData<2, int>; +template class CGoGN::Utils::Image<2, int>; +template class CGoGN::Utils::Texture<2, int>; + +template class CGoGN::Utils::ImageData<2, double>; +template class CGoGN::Utils::Image<2, double>; +template class CGoGN::Utils::Texture<2, double>; + +template class CGoGN::Utils::ImageData<2, CGoGN::Geom::Vec4f>; +template class CGoGN::Utils::Image<2, CGoGN::Geom::Vec4f>; +template class CGoGN::Utils::Texture<2, CGoGN::Geom::Vec4f>; + +////////////////// 3 ///////////////////////////////////// + +template class CGoGN::Utils::ImageData<3, unsigned char>; +template class CGoGN::Utils::Image<3, unsigned char>; +template class CGoGN::Utils::Texture<3, unsigned char>; + +template class CGoGN::Utils::ImageData<3, int>; +template class CGoGN::Utils::Image<3, int>; +template class CGoGN::Utils::Texture<3, int>; + +template class CGoGN::Utils::ImageData<3, double>; +template class CGoGN::Utils::Image<3, double>; +template class CGoGN::Utils::Texture<3, double>; + +template class CGoGN::Utils::ImageData<3, CGoGN::Geom::Vec4f>; +template class CGoGN::Utils::Image<3, CGoGN::Geom::Vec4f>; +template class CGoGN::Utils::Texture<3, CGoGN::Geom::Vec4f>; + +int test_texture() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/howto.txt b/Apps/Tests/howto.txt new file mode 100644 index 0000000000000000000000000000000000000000..f99a15252dddef044d6459e794946fcdd9a71861 --- /dev/null +++ b/Apps/Tests/howto.txt @@ -0,0 +1,12 @@ + + + + +cp -r algo_dir Test/ +find . -name "*.hpp" -exec rm {} \; +find . -name "*.h" -exec rename.sh {} \; + +rename.sh: + name=`basename $1 .h` + dir=`dirname $1` + mv $dir/$name.h $dir/$name.cpp diff --git a/Apps/Tests/rename.sh b/Apps/Tests/rename.sh new file mode 100644 index 0000000000000000000000000000000000000000..195bc3cc925b90f5389b82d02b1beae7f21e2d7d --- /dev/null +++ b/Apps/Tests/rename.sh @@ -0,0 +1,3 @@ +name=`basename $1 .h` +dir=`dirname $1` +mv $dir/$name.h $dir/$name.cpp diff --git a/Apps/Tuto/CMakeLists.txt b/Apps/Tuto/CMakeLists.txt index 597d8601fbb16d1b265f5843a7e8222e754a5cad..7b349be461fa1e862b77865b76dddf43bae0d3a1 100644 --- a/Apps/Tuto/CMakeLists.txt +++ b/Apps/Tuto/CMakeLists.txt @@ -42,10 +42,10 @@ IF (CGoGN_WITH_QT) target_link_libraries( tuto_orbits ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} ) -# qt_wrap_cpp(tuto_histo_moc tuto_histo.h) -# add_executable( tuto_histo tuto_histo.cpp tuto_histo.h ${tuto_histo_ui} ${tuto_histo_moc}) -# target_link_libraries( tuto_histo -# ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} ) + qt_wrap_cpp(tuto_histo_moc tuto_histo.h) + add_executable( tuto_histo tuto_histo.cpp tuto_histo.h ${tuto_histo_ui} ${tuto_histo_moc}) + target_link_libraries( tuto_histo + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} ) # qt_wrap_cpp(tp_master_moc tp_master.h) diff --git a/Apps/Tuto/tuto_histo.cpp b/Apps/Tuto/tuto_histo.cpp index c7cb6e4b0400ca3bc40bf74fbf066e6e5cc4c246..78de7a2fb3ed52d082fdfe8cb8a4e743521789a3 100644 --- a/Apps/Tuto/tuto_histo.cpp +++ b/Apps/Tuto/tuto_histo.cpp @@ -115,10 +115,10 @@ void MyQT::createMap(const std::string& filename) // create a popup window - l_popup = new Utils::QT::QtPopUp(this); + l_popup = new Utils::QT::QtPopUp(); // create the widget to view histogram - l_histodraw = new Utils::QT::RenderHistogram(l_popup, *l_histo); + l_histodraw = new Algo::Histogram::RenderHistogram(l_popup, *l_histo); // some simple parameters l_histodraw->setQuantilesDraw(true); @@ -274,7 +274,7 @@ void MyQT::clickHisto(unsigned int i,unsigned int j) { std::cout << "CLICK on column Histo: " << i << " / Quantiles: " << j < vc; l_histo->cellsOfHistogramColumn(i,vc); @@ -287,7 +287,7 @@ void MyQT::clickHisto(unsigned int i,unsigned int j) std::cout << l_histo->markCellsOfHistogramColumn(i,cm) << " marked cells" << std::endl; } - if (j != Utils::QT::RenderHistogram::NONE) + if (j != Algo::Histogram::RenderHistogram::NONE) { std::vector vc; l_histo->cellsOfHistogramColumn(j,vc); diff --git a/Apps/Tuto/tuto_histo.h b/Apps/Tuto/tuto_histo.h index 99c515fd48c80e45e7cb9a3b49da0bf3a2a96de6..5715461c194918b2f3a9398504580533c1925ea3 100644 --- a/Apps/Tuto/tuto_histo.h +++ b/Apps/Tuto/tuto_histo.h @@ -38,7 +38,8 @@ #include "Utils/vbo.h" #include "Algo/Histogram/histogram.h" -#include "Utils/Qt/qthistodraw.h" +#include "Algo/Histogram/qthistodraw.h" +#include "Utils/Qt/qtpopup.h" using namespace CGoGN ; @@ -120,7 +121,7 @@ protected: ColMap* l_cm; Algo::Histogram::Histogram* l_histo; Utils::QT::QtPopUp* l_popup; - Utils::QT::RenderHistogram* l_histodraw; + Algo::Histogram::RenderHistogram* l_histodraw; unsigned int l_nbc; unsigned int l_nbq; diff --git a/CGoGN/CMakeLists.txt b/CGoGN/CMakeLists.txt index 5b8184491ff51c0ac11b545b72366664ed78c26a..fb0849a2962060f5cf0553ca96d5ad5db8d2e219 100644 --- a/CGoGN/CMakeLists.txt +++ b/CGoGN/CMakeLists.txt @@ -32,6 +32,11 @@ file( ${CGoGN_SRC_DIR}/include/Algo/*.h ) +IF(CGoGN_WITH_QT) + qt_wrap_cpp(ALGO_QT_HEADERS_MOC ${CGoGN_SRC_DIR}/include/Algo/Histogram/qthistodraw.h) + SET (files_algo_withQt ${files_algo} ${ALGO_QT_HEADERS_MOC}) +ENDIF() + file( GLOB shaders_src @@ -45,7 +50,7 @@ file( IF(WIN32) - add_custom_target(shader_target ${CGoGN_ROOT_DIR}/ThirdParty/bin/Release/shader_to_h ${shaders_src} + add_custom_target(shader_target ${CGoGN_ROOT_DIR}/ThirdParty/bin/$(ConfigurationName)/shader_to_h ${shaders_src} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${shaders_src} ) ELSE() @@ -103,12 +108,12 @@ file( GLOB_RECURSE ${CGoGN_ROOT_DIR}/ThirdParty/include/*.hpp ) -link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} ) +#link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} ) IF (CGoGN_ONELIB) IF(CGoGN_WITH_QT) add_definitions(-DCGoGN_QT_DLL_EXPORT) - add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils_withQt}) + add_library( cgogn ${files_topology} ${files_container} ${files_algo_withQt} ${files_utils_withQt}) qt_use_modules(cgogn Gui OpenGL Xml Svg) ELSE() add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils} ) @@ -132,7 +137,13 @@ ELSE() add_library( topology ${files_topology}) target_link_libraries(topology container) - add_library( algo ${files_algo}) + IF (CGoGN_WITH_QT) + add_definitions(-DCGoGN_QT_DLL_EXPORT) + add_library( algo ${files_algo_withQt} ) + qt_use_modules(algo Gui OpenGL Xml Svg) + ELSE() + add_library( algo ${files_algo} ) + ENDIF() target_link_libraries(algo utils topology) diff --git a/CGoGN/include/Algo/BooleanOperator/mergeVertices.h b/CGoGN/include/Algo/BooleanOperator/mergeVertices.h index 236a194ab5c6f4ca97f4d849fcb3192dce58057d..dfe88a77adff00b1aab49a285b5ff50e392bf866 100644 --- a/CGoGN/include/Algo/BooleanOperator/mergeVertices.h +++ b/CGoGN/include/Algo/BooleanOperator/mergeVertices.h @@ -45,10 +45,10 @@ template bool isBetween(typename PFP::MAP& map, const VertexAttribute& positions, Dart d, Dart e, Dart f) ; template -void mergeVertex(typename PFP::MAP& map, VertexAttribute& positions, Dart d, Dart e); +void mergeVertex(typename PFP::MAP& map, VertexAttribute& positions, Dart d, Dart e, int precision); template -void mergeVertices(typename PFP::MAP& map, VertexAttribute& positions); +void mergeVertices(typename PFP::MAP& map, VertexAttribute& positions, int precision); } diff --git a/CGoGN/include/Algo/Decimation/colorPerVertexApproximator.hpp b/CGoGN/include/Algo/Decimation/colorPerVertexApproximator.hpp index eb2b15b67f201d8a4c12ea42e479c9e731421f10..53cd8273b5746b007edad42e36bd996d286856a0 100644 --- a/CGoGN/include/Algo/Decimation/colorPerVertexApproximator.hpp +++ b/CGoGN/include/Algo/Decimation/colorPerVertexApproximator.hpp @@ -21,6 +21,7 @@ * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ +#include namespace CGoGN { diff --git a/CGoGN/include/Algo/Decimation/decimation.hpp b/CGoGN/include/Algo/Decimation/decimation.hpp index 5e854545c7f2e02a5b1931d5f64ded9ccd2ca32c..aaa11cd4a1cce4fec68735f8b807ff5b009b9abc 100644 --- a/CGoGN/include/Algo/Decimation/decimation.hpp +++ b/CGoGN/include/Algo/Decimation/decimation.hpp @@ -87,18 +87,20 @@ int decimate( approximators.push_back(new Approximator_ColorNaive(map, attribs[1], attribs[0], attrib0ApproxResult)) ; } break ; -// case A_ColorQEMext : { + case A_ColorQEMext : +// { // // pos + col // assert(attribs.size() >= 2 || !"Decimate: A_ColorQEMext --> not enough attribs provided") ; // approximators.push_back(new Approximator_ColorQEMext(map, attribs)) ; // } -// break; -// case A_GeomColorOpt : { + break; + case A_GeomColorOpt : +// { // // pos + col // assert(attribs.size() >= 2 || !"Decimate: A_GeomColorOpt --> not enough attribs provided") ; // approximators.push_back(new Approximator_GeomColOpt(map, attribs)) ; // } -// break ; + break ; case A_hQEM : // pos approximators.push_back(new Approximator_QEMhalfEdge(map, attribs[0])) ; diff --git a/CGoGN/include/Algo/Decimation/edgeSelector.h b/CGoGN/include/Algo/Decimation/edgeSelector.h index a3ac121662bd99f13b71fc5b474bff0dbaefe9ba..a96e590ce7a6737d0fe5d6769982f6288ace32d0 100644 --- a/CGoGN/include/Algo/Decimation/edgeSelector.h +++ b/CGoGN/include/Algo/Decimation/edgeSelector.h @@ -109,7 +109,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "LengthEdgeInfo" ; } } LengthEdgeInfo ; @@ -117,8 +117,8 @@ private: EdgeAttribute edgeInfo ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d, bool recompute) ; @@ -176,7 +176,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "QEMedgeInfo" ; } } QEMedgeInfo ; @@ -186,8 +186,8 @@ private: VertexAttribute, MAP> quadric ; Utils::Quadric tmpQ ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d, bool recompute) ; @@ -232,7 +232,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "QEMedgeInfo" ; } } QEMedgeInfo ; @@ -241,8 +241,8 @@ private: EdgeAttribute edgeInfo ; VertexAttribute, MAP> quadric ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d, bool recompute) ; @@ -288,7 +288,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "NormalAreaEdgeInfo" ; } } NormalAreaEdgeInfo ; @@ -297,8 +297,8 @@ private: EdgeAttribute edgeInfo ; EdgeAttribute, MAP> edgeMatrix ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d) ; @@ -342,7 +342,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "CurvatureEdgeInfo" ; } } CurvatureEdgeInfo ; @@ -361,8 +361,8 @@ private: VertexAttribute Kmin ; VertexAttribute Knormal ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d, bool recompute) ; @@ -453,7 +453,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "CurvatureTensorEdgeInfo" ; } } CurvatureTensorEdgeInfo ; @@ -463,8 +463,8 @@ private: EdgeAttribute edgeangle ; EdgeAttribute edgearea ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d) ; // TODO : usually has a 2nd arg (, bool recompute) : why ?? @@ -521,7 +521,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "MinDetailEdgeInfo" ; } } MinDetailEdgeInfo ; @@ -529,8 +529,8 @@ private: EdgeAttribute edgeInfo ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d, bool recompute) ; @@ -577,7 +577,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "ColorNaiveEdgeInfo" ; } } ColorNaiveedgeInfo ; @@ -586,8 +586,8 @@ private: EdgeAttribute edgeInfo ; VertexAttribute, MAP> m_quadric ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d, bool recompute) ; @@ -645,7 +645,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "GeomColOptGradEdgeInfo" ; } } ColorNaiveedgeInfo ; @@ -654,8 +654,8 @@ private: EdgeAttribute edgeInfo ; VertexAttribute, MAP> m_quadric ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d) ; @@ -735,7 +735,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "QEMextColorEdgeInfo" ; } } QEMextColorEdgeInfo ; @@ -744,8 +744,8 @@ private: EdgeAttribute edgeInfo ; VertexAttribute, MAP> m_quadric ; - std::multimap edges ; - typename std::multimap::iterator cur ; + std::multimap edges ; + typename std::multimap::iterator cur ; void initEdgeInfo(Dart d) ; void updateEdgeInfo(Dart d, bool recompute) ; diff --git a/CGoGN/include/Algo/Decimation/edgeSelector.hpp b/CGoGN/include/Algo/Decimation/edgeSelector.hpp index b403760d2f52700795a199acf3121c418e43a38c..1e42c0ade9fde69fa90a6ab05f1d00132c0fa64a 100644 --- a/CGoGN/include/Algo/Decimation/edgeSelector.hpp +++ b/CGoGN/include/Algo/Decimation/edgeSelector.hpp @@ -290,7 +290,7 @@ void EdgeSelector_Length::updateEdgeInfo(Dart d, bool recompute) template void EdgeSelector_Length::computeEdgeInfo(Dart d, EdgeInfo& einfo) { - VEC3 vec = Algo::Surface::Geometry::vectorOutOfDart(this->m_map, d, position) ; + VEC3 vec = Algo::Geometry::vectorOutOfDart(this->m_map, d, position) ; einfo.it = edges.insert(std::make_pair(vec.norm2(), d)) ; einfo.valid = true ; } @@ -884,8 +884,8 @@ void EdgeSelector_NormalArea::computeEdgeInfo(Dart d, EdgeInfo& einfo) MAP& m = this->m_map ; Dart dd = m.phi2(d); - Geom::Matrix33f M1; // init zero included - Geom::Matrix33f M2; // init zero included + Geom::Matrix<3, 3, REAL> M1; // init zero included + Geom::Matrix<3, 3, REAL> M2; // init zero included assert(! m.isBoundaryEdge(d)); @@ -939,7 +939,7 @@ void EdgeSelector_NormalArea::computeEdgeInfo(Dart d, EdgeInfo& einfo) template void EdgeSelector_NormalArea::computeEdgeMatrix(Dart d) { - const VEC3 e = Algo::Surface::Geometry::vectorOutOfDart(this->m_map, d, m_position) ; + const VEC3 e = Algo::Geometry::vectorOutOfDart(this->m_map, d, m_position) ; edgeMatrix[d].identity(); edgeMatrix[d] *= e.norm2(); edgeMatrix[d] -= Geom::transposed_vectors_mult(e,e) ; @@ -1982,7 +1982,7 @@ void EdgeSelector_GeomColOptGradient::computeEdgeInfo(Dart d, EdgeInfo& ein const REAL t = 0.01f ; const REAL err = t * quad(newPos) + - (1-t) * (computeEdgeGradientColorError(d, newPos, newCol) + computeEdgeGradientColorError(m.phi2(d), newPos, newCol)).norm() / sqrt(3.0) ; + (1-t) * (computeEdgeGradientColorError(d, newPos, newCol) + computeEdgeGradientColorError(m.phi2(d), newPos, newCol)).norm() / REAL(sqrt(3.0)) ; einfo.it = edges.insert(std::make_pair(err, d)) ; einfo.valid = true ; @@ -2017,7 +2017,7 @@ typename PFP::VEC3 EdgeSelector_GeomColOptGradient::computeEdgeGradientColo //const VEC3 e0 = Pj - Pi ; const REAL areaIJ0sq = (ei ^ ej).norm2() ; - const REAL areaIJ0 = sqrt(areaIJ0sq)/2. ; + const REAL areaIJ0 = REAL(std::sqrt(areaIJ0sq)/2.0f) ; areaSum += areaIJ0 ; // per-channel treatment diff --git a/CGoGN/include/Algo/Decimation/geometryApproximator.h b/CGoGN/include/Algo/Decimation/geometryApproximator.h index 6239e02bcefb37a012cb107a62f755787cb09ddc..0ecb6c0cc0e48749ca74fc938473d913ad47466b 100644 --- a/CGoGN/include/Algo/Decimation/geometryApproximator.h +++ b/CGoGN/include/Algo/Decimation/geometryApproximator.h @@ -26,6 +26,7 @@ #define __GEOMETRY_APPROXIMATOR_H__ #include "Algo/Decimation/approximator.h" +#include "Utils/qem.h" #include "Utils/convertType.h" #include diff --git a/CGoGN/include/Algo/Decimation/geometryApproximator.hpp b/CGoGN/include/Algo/Decimation/geometryApproximator.hpp index c9d88a9abdc2296f5adb6d4d2c673659760e604a..bcff8cd8bf20aba7b60fd3323ebd215fb6a47215 100644 --- a/CGoGN/include/Algo/Decimation/geometryApproximator.hpp +++ b/CGoGN/include/Algo/Decimation/geometryApproximator.hpp @@ -23,6 +23,7 @@ *******************************************************************************/ #include "Algo/Topo/embedding.h" +#include "Topology/generic/traversor/traversor2.h" namespace CGoGN { diff --git a/CGoGN/include/Algo/Decimation/halfEdgeSelector.h b/CGoGN/include/Algo/Decimation/halfEdgeSelector.h index f7d123c4831325ce32625c6c2a4afb6013b062e6..0061b3f23a5007d57478cc89a335a0e59ba52991 100644 --- a/CGoGN/include/Algo/Decimation/halfEdgeSelector.h +++ b/CGoGN/include/Algo/Decimation/halfEdgeSelector.h @@ -26,6 +26,9 @@ #define __HALFEDGESELECTOR_H__ #include "Algo/Decimation/selector.h" +#include "Algo/Decimation/approximator.h" +#include "Utils/qem.h" +#include "Topology/generic/dart.h" namespace CGoGN { @@ -56,7 +59,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it; bool valid ; static std::string CGoGNnameOfType() { return "QEMhalfEdgeInfo" ; } } QEMhalfEdgeInfo ; @@ -65,8 +68,8 @@ private: DartAttribute halfEdgeInfo ; VertexAttribute, MAP> m_quadric ; - std::multimap halfEdges ; - typename std::multimap::iterator cur ; + std::multimap halfEdges ; + typename std::multimap::iterator cur ; void initHalfEdgeInfo(Dart d) ; void updateHalfEdgeInfo(Dart d, bool recompute) ; @@ -118,7 +121,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "QEMextColorHalfEdgeInfo" ; } } QEMextColorHalfEdgeInfo ; @@ -127,8 +130,8 @@ private: DartAttribute halfEdgeInfo ; VertexAttribute, MAP> m_quadric ; - std::multimap halfEdges ; - typename std::multimap::iterator cur ; + std::multimap halfEdges ; + typename std::multimap::iterator cur ; void initHalfEdgeInfo(Dart d) ; void updateHalfEdgeInfo(Dart d, bool recompute) ; @@ -212,7 +215,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "QEMextColorNormalHalfEdgeInfo" ; } } QEMextColorNormalHalfEdgeInfo ; @@ -221,8 +224,8 @@ private: DartAttribute halfEdgeInfo ; VertexAttribute, MAP> m_quadric ; - std::multimap halfEdges ; - typename std::multimap::iterator cur ; + std::multimap halfEdges ; + typename std::multimap::iterator cur ; void initHalfEdgeInfo(Dart d) ; void updateHalfEdgeInfo(Dart d, bool recompute) ; @@ -307,7 +310,7 @@ private: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; static std::string CGoGNnameOfType() { return "ColorExperimentalHalfEdgeInfo" ; } } QEMextColorHalfEdgeInfo ; @@ -316,8 +319,8 @@ private: DartAttribute halfEdgeInfo ; VertexAttribute, MAP> m_quadric ; - std::multimap halfEdges ; - typename std::multimap::iterator cur ; + std::multimap halfEdges ; + typename std::multimap::iterator cur ; void initHalfEdgeInfo(Dart d) ; void updateHalfEdgeInfo(Dart d) ; diff --git a/CGoGN/include/Algo/Decimation/halfEdgeSelector.hpp b/CGoGN/include/Algo/Decimation/halfEdgeSelector.hpp index 9d7b39eca4d52583af9736fbdb470645cf563d55..b4351ac544521929b55fe0689f15101e43f09f8a 100644 --- a/CGoGN/include/Algo/Decimation/halfEdgeSelector.hpp +++ b/CGoGN/include/Algo/Decimation/halfEdgeSelector.hpp @@ -22,6 +22,8 @@ * * *******************************************************************************/ +#include "Topology/generic/traversor/traversor2.h" + namespace CGoGN { @@ -1034,7 +1036,7 @@ void HalfEdgeSelector_ColorGradient::computeHalfEdgeInfo(Dart d, HalfEdgeIn const REAL t = 0.01f ; const REAL& err = t * quadGeom(newPos) + // geom - (1-t) * computeGradientColorError(v0,v1).norm()/sqrt(3.0) // color + (1.0f-t) * computeGradientColorError(v0,v1).norm()/REAL(sqrt(3.0)) // color ; /*std::cout << quadGeom(newPos) << std::endl ; @@ -1082,7 +1084,7 @@ HalfEdgeSelector_ColorGradient::computeGradientColorError(const Dart& v0, c //const VEC3 e0 = Pj - Pi ; const REAL areaIJ0sq = (ei ^ ej).norm2() ; - const REAL areaIJ0 = sqrt(areaIJ0sq)/2. ; + const REAL areaIJ0 = REAL(sqrt(areaIJ0sq)/2.0f) ; areaSum += areaIJ0 ; // per-channel treatment for (unsigned int c = 0 ; c < 3 ; ++c) diff --git a/CGoGN/include/Algo/Export/export.h b/CGoGN/include/Algo/Export/export.h index 288d916cad72c35914be1f8f1ff47806cd700b0d..877c08c5ceb9b41b5539d054d95477fb5b32a5c6 100644 --- a/CGoGN/include/Algo/Export/export.h +++ b/CGoGN/include/Algo/Export/export.h @@ -89,8 +89,8 @@ bool exportOBJ(typename PFP::MAP& map, const VertexAttribute -bool exportTrian(typename PFP::MAP& map, const VertexAttribute& position, char* filename) ; +//template +//bool exportTrian(typename PFP::MAP& map, const VertexAttribute& position, char* filename) ; diff --git a/CGoGN/include/Algo/Export/exportPov.h b/CGoGN/include/Algo/Export/exportPov.h index aa6d017a7408251bf153d9ba06b8d6972ea24590..64f84736bc2d617d9b505cacecc8713ff6dae166 100644 --- a/CGoGN/include/Algo/Export/exportPov.h +++ b/CGoGN/include/Algo/Export/exportPov.h @@ -38,7 +38,7 @@ void exportTrianglePlain(std::ofstream& out,typename PFP::VEC3& p1,typename PFP: } template -void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, VertexAttribute& position, const std::string& meshName) +void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, VertexAttribute& position, const std::string& meshName) { out << "#declare " << meshName << "= union {" << std::endl; @@ -69,7 +69,7 @@ void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, VertexAttribute } template -void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, VertexAttribute& position, const std::string& meshName) +void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, VertexAttribute& position, const std::string& meshName) { typedef typename PFP::VEC3 VEC3; @@ -96,20 +96,20 @@ void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, VertexAt vertices.reserve(nbDarts/6) ; normals.reserve(nbDarts/6) ; - CellMarker markV(map) ; - DartMarker markF(map) ; + CellMarker markV(map) ; + DartMarker markF(map); for(Dart d = map.begin(); d != map.end(); map.next(d)) { if(!markF.isMarked(d) && map.phi3(d)==d) { - markF.markOrbit(d) ; + markF.template markOrbit(d) ; std::vector fidx ; fidx.reserve(4) ; Dart dd = d ; do { - unsigned int vNum = map.getEmbedding(dd) ; + unsigned int vNum = map.template getEmbedding(dd) ; if(!markV.isMarked(dd)) { markV.mark(dd) ; @@ -167,7 +167,7 @@ void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, VertexAt } template -void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, VertexAttribute& position, const std::string& meshName) +void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, VertexAttribute& position, const std::string& meshName) { out << "#declare " << meshName << "= union {" << std::endl; @@ -189,7 +189,7 @@ void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, VertexAttribute< } template -bool exportScenePov(typename PFP::MAP& map, VertexAttribute& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z) +bool exportScenePov(typename PFP::MAP& map, VertexAttribute& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z) { std::ofstream out(filename.c_str(), std::ios::out); if (!out.good()) @@ -231,7 +231,7 @@ bool exportScenePov(typename PFP::MAP& map, VertexAttribute& } template -bool exportScenePovSmooth(typename PFP::MAP& map, VertexAttribute& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z) +bool exportScenePovSmooth(typename PFP::MAP& map, VertexAttribute& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z) { std::ofstream out(filename.c_str(), std::ios::out); if (!out.good()) { diff --git a/CGoGN/include/Algo/Export/exportVTU.h b/CGoGN/include/Algo/Export/exportVTU.h index 5cb96f0939e11c2cd1178aa1ed37cfb878f62dd6..59019571fa2b25f3dad59c9fa5d3def78c2932fc 100644 --- a/CGoGN/include/Algo/Export/exportVTU.h +++ b/CGoGN/include/Algo/Export/exportVTU.h @@ -52,7 +52,7 @@ namespace Export * @return true if ok */ template -bool exportVTU(typename PFP::MAP& map, const VertexAttribute& position, const char* filename); +bool exportVTU(typename PFP::MAP& map, const VertexAttribute& position, const char* filename); /** * simple export of the geometry of map into a binary VTU file (VTK unstructured grid xml format) @@ -62,7 +62,7 @@ bool exportVTU(typename PFP::MAP& map, const VertexAttribute * @return true if ok */ template -bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute& position, const char* filename); +bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute& position, const char* filename); //template //bool exportVTUCompressed(typename PFP::MAP& map, const VertexAttribute& position, const char* filename); @@ -79,7 +79,7 @@ protected: typedef typename PFP::VEC3 VEC3; typename PFP::MAP& m_map; - const VertexAttribute& m_position; + const VertexAttribute& m_position; unsigned int nbtotal; bool noPointData; @@ -105,16 +105,16 @@ protected: template - void addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); template - void addBinaryFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addBinaryFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp = 0, const std::string& name = ""); bool binaryClose(); public: - VTUExporter(typename PFP::MAP& map, const VertexAttribute& position); + VTUExporter(typename PFP::MAP& map, const VertexAttribute& position); ~VTUExporter(); @@ -136,7 +136,7 @@ public: * @param name data name, if none then used attribute's name */ template - void addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); /** @@ -152,7 +152,7 @@ public: * @param name data name, if none then used attribute's name */ template - void addFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); /** @@ -190,7 +190,7 @@ protected: typedef typename PFP::VEC3 VEC3; typename PFP::MAP& m_map; - const VertexAttribute& m_position; + const VertexAttribute& m_position; unsigned int nbtotal; bool noPointData; @@ -212,16 +212,16 @@ protected: FILE* f_tempoBin_out ; template - void addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); template - void addBinaryVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addBinaryVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); bool binaryClose(); public: - VTUExporter(typename PFP::MAP& map, const VertexAttribute& position); + VTUExporter(MAP& map, const VertexAttribute& position); ~VTUExporter(); @@ -243,7 +243,7 @@ public: * @param name data name, if none then used attribute's name */ template - void addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); /** @@ -259,7 +259,7 @@ public: * @param name data name, if none then used attribute's name */ template - void addVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); + void addVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name=""); /** diff --git a/CGoGN/include/Algo/Export/exportVTU.hpp b/CGoGN/include/Algo/Export/exportVTU.hpp index 35ae08df0b57ef87c77ec28c395c79ac9029a38c..8c1cae4c1146908f5b82da0b45fdb819a9518769 100644 --- a/CGoGN/include/Algo/Export/exportVTU.hpp +++ b/CGoGN/include/Algo/Export/exportVTU.hpp @@ -24,8 +24,8 @@ #include "Topology/generic/attributeHandler.h" #include "Topology/generic/autoAttributeHandler.h" -#include "Topology/generic/traversorCell.h" -#include "Topology/generic/traversor2.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" #include "Topology/generic/cellmarker.h" #include "Utils/compress.h" @@ -43,7 +43,7 @@ namespace Export { template -bool exportVTU(typename PFP::MAP& map, const VertexAttribute& position, const char* filename) +bool exportVTU(typename PFP::MAP& map, const VertexAttribute& position, const char* filename) { if (map.dimension() != 2) { @@ -64,7 +64,8 @@ bool exportVTU(typename PFP::MAP& map, const VertexAttribute return false ; } - VertexAutoAttribute indices(map,"indices_vert"); + VertexAutoAttribute indices(map,"indices_vert"); + unsigned int count=0; for (unsigned int i = position.begin(); i != position.end(); position.next(i)) @@ -101,7 +102,7 @@ bool exportVTU(typename PFP::MAP& map, const VertexAttribute break; default: - others_begin.push_back(others.size()); + others_begin.push_back((unsigned int)(others.size())); do { others.push_back(indices[f]); f = map.phi1(f); @@ -110,9 +111,9 @@ bool exportVTU(typename PFP::MAP& map, const VertexAttribute break; } } - others_begin.push_back(others.size()); + others_begin.push_back(uint32(others.size())); - unsigned int nbtotal = triangles.size()/3 + quads.size()/4 + others_begin.size()-1; + unsigned int nbtotal = (unsigned int)(triangles.size() / 3 + quads.size() / 4 + others_begin.size() - 1); fout << "" << std::endl; fout << "" << std::endl; @@ -217,7 +218,7 @@ bool exportVTU(typename PFP::MAP& map, const VertexAttribute template -bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute& position, const char* filename) +bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute& position, const char* filename) { if (map.dimension() != 2) { @@ -238,7 +239,7 @@ bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute indices(map,"indices_vert"); + VertexAutoAttribute indices(map,"indices_vert"); unsigned int count=0; for (unsigned int i = position.begin(); i != position.end(); position.next(i)) @@ -275,7 +276,7 @@ bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute" << std::endl; fout << "" << std::endl; @@ -328,10 +329,10 @@ bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute" << std::endl; - offsetAppend +=bufferInt.size() * sizeof(unsigned int) + sizeof(unsigned int); + offsetAppend += uint32(bufferInt.size() * sizeof(unsigned int)+sizeof(unsigned int)); fout << "" << std::endl; - offsetAppend += (triangles.size()/3 + quads.size()/4 + others_begin.size()-1) * sizeof(unsigned int) + sizeof(unsigned int); + offsetAppend += uint32((triangles.size() / 3 + quads.size() / 4 + others_begin.size() - 1) * sizeof(unsigned int)+sizeof(unsigned int)); fout << "" << std::endl; @@ -352,14 +353,14 @@ bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute -bool exportVTUCompressed(typename PFP::MAP& map, const VertexAttribute& position, const char* filename) +bool exportVTUCompressed(typename PFP::MAP& map, const VertexAttribute& position, const char* filename) { if (map.dimension() != 2) { @@ -642,7 +643,7 @@ bool exportVTUCompressed(typename PFP::MAP& map, const VertexAttribute -VTUExporter::VTUExporter(typename PFP::MAP& map, const VertexAttribute& position): +VTUExporter::VTUExporter(MAP& map, const VertexAttribute& position): m_map(map),m_position(position), nbtotal(0),noPointData(true),noCellData(true),closed(false),binaryMode(false),f_tempoBin_out(NULL) { @@ -668,7 +669,7 @@ bool VTUExporter::init(const char* filename, bool bin) return false; } - VertexAutoAttribute indices(m_map,"indices_vert"); + VertexAutoAttribute indices(m_map,"indices_vert"); unsigned int count=0; for (unsigned int i = m_position.begin(); i != m_position.end(); m_position.next(i)) @@ -708,7 +709,7 @@ bool VTUExporter::init(const char* filename, bool bin) default: bufferOther.push_back(d); - others_begin.push_back(others.size()); + others_begin.push_back(uint32(others.size())); do { others.push_back(indices[f]); f = m_map.phi1(f); @@ -717,9 +718,9 @@ bool VTUExporter::init(const char* filename, bool bin) break; } } - others_begin.push_back(others.size()); + others_begin.push_back(uint32(others.size())); - nbtotal = triangles.size()/3 + quads.size()/4 + others_begin.size()-1; + nbtotal = uint32(triangles.size() / 3 + quads.size() / 4 + others_begin.size() - 1); fout << "" << std::endl; fout << "" << std::endl; @@ -739,7 +740,7 @@ bool VTUExporter::init(const char* filename, bool bin) template template -void VTUExporter::addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (binaryMode) return addBinaryVertexAttribute(attrib,vtkType,nbComp,name); @@ -803,7 +804,7 @@ void VTUExporter::endVertexAttributes() template template -void VTUExporter::addFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (binaryMode) return addBinaryFaceAttribute(attrib,vtkType,nbComp,name); @@ -983,7 +984,7 @@ bool VTUExporter::close() template template -void VTUExporter::addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (!noCellData) { @@ -1038,7 +1039,7 @@ void VTUExporter::addBinaryVertexAttribute(const VertexAttribute& attrib template template -void VTUExporter::addBinaryFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addBinaryFaceAttribute(const FaceAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (!noPointData) { @@ -1111,7 +1112,7 @@ bool VTUExporter::binaryClose() for (unsigned int i = m_position.begin(); i != m_position.end(); m_position.next(i)) buffer.push_back(m_position[i]); - unsigned int sz = buffer.size()*sizeof(VEC3); + unsigned int sz = uint32(buffer.size()*sizeof(VEC3)); offsetAppend += sz + sizeof(unsigned int); @@ -1152,7 +1153,7 @@ bool VTUExporter::binaryClose() bufferInt.push_back(others[j]); } - unsigned int sz = bufferInt.size() * sizeof(unsigned int); + unsigned int sz = uint32(bufferInt.size() * sizeof(unsigned int)); offsetAppend += sz + sizeof(unsigned int); fwrite(&sz, sizeof(unsigned int), 1, f_tempoBin_out); // size of block fwrite(&bufferInt[0], sizeof(unsigned int), bufferInt.size(), f_tempoBin_out); // block @@ -1180,7 +1181,7 @@ bool VTUExporter::binaryClose() bufferInt.push_back(offset); } - sz = bufferInt.size() * sizeof(unsigned int); + sz = uint32(bufferInt.size() * sizeof(unsigned int)); offsetAppend += sz + sizeof(unsigned int); fwrite(&sz, sizeof(unsigned int), 1, f_tempoBin_out); // size of block @@ -1201,9 +1202,9 @@ bool VTUExporter::binaryClose() for (unsigned int i=1; i -VTUExporter::VTUExporter(typename PFP::MAP& map, const VertexAttribute& position): +VTUExporter::VTUExporter(MAP& map, const VertexAttribute& position): m_map(map),m_position(position), nbtotal(0),noPointData(true),noCellData(true),closed(false),binaryMode(false),f_tempoBin_out(NULL) { @@ -1297,7 +1298,7 @@ bool VTUExporter::init(const char* filename, bool bin) return false; } - VertexAutoAttribute indices(m_map,"indices_vert"); + VertexAutoAttribute indices(m_map,"indices_vert"); unsigned int count=0; for (unsigned int i = m_position.begin(); i != m_position.end(); m_position.next(i)) @@ -1316,7 +1317,7 @@ bool VTUExporter::init(const char* filename, bool bin) { unsigned int degree = 0 ; - Traversor3WV twv(m_map, d) ; + Traversor3WV twv(m_map, d) ; for(Dart it = twv.begin(); it != twv.end(); it = twv.next()) { degree++; @@ -1358,7 +1359,7 @@ bool VTUExporter::init(const char* filename, bool bin) } } - nbtotal = tetras.size()/4 + hexas.size()/8; + nbtotal = uint32(tetras.size() / 4 + hexas.size() / 8); fout << "" << std::endl; fout << "" << std::endl; @@ -1378,7 +1379,7 @@ bool VTUExporter::init(const char* filename, bool bin) template template -void VTUExporter::addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (binaryMode) return addBinaryVertexAttribute(attrib,vtkType,nbComp,name); @@ -1442,7 +1443,7 @@ void VTUExporter::endVertexAttributes() template template -void VTUExporter::addVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (binaryMode) return addBinaryVolumeAttribute(attrib,vtkType,nbComp,name); @@ -1594,7 +1595,7 @@ bool VTUExporter::close() template template -void VTUExporter::addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addBinaryVertexAttribute(const VertexAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (!noCellData) { @@ -1649,7 +1650,7 @@ void VTUExporter::addBinaryVertexAttribute(const VertexAttribute& attrib template template -void VTUExporter::addBinaryVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) +void VTUExporter::addBinaryVolumeAttribute(const VolumeAttribute& attrib, const std::string& vtkType, unsigned int nbComp, const std::string& name) { if (!noPointData) { @@ -1721,7 +1722,7 @@ bool VTUExporter::binaryClose() for (unsigned int i = m_position.begin(); i != m_position.end(); m_position.next(i)) buffer.push_back(m_position[i]); - unsigned int sz = buffer.size()*sizeof(VEC3); + unsigned int sz = uint32(buffer.size()*sizeof(VEC3)); offsetAppend += sz + sizeof(unsigned int); @@ -1755,7 +1756,7 @@ bool VTUExporter::binaryClose() bufferInt.push_back(hexas[i+3]); } - unsigned int sz = bufferInt.size() * sizeof(unsigned int); + unsigned int sz = uint32(bufferInt.size() * sizeof(unsigned int)); offsetAppend += sz + sizeof(unsigned int); fwrite(&sz, sizeof(unsigned int), 1, f_tempoBin_out); // size of block fwrite(&bufferInt[0], sizeof(unsigned int), bufferInt.size(), f_tempoBin_out); // block @@ -1776,7 +1777,7 @@ bool VTUExporter::binaryClose() bufferInt.push_back(offset); } - sz = bufferInt.size() * sizeof(unsigned int); + sz = uint32(bufferInt.size() * sizeof(unsigned int)); offsetAppend += sz + sizeof(unsigned int); fwrite(&sz, sizeof(unsigned int), 1, f_tempoBin_out); // size of block @@ -1795,7 +1796,7 @@ bool VTUExporter::binaryClose() bufferUC.push_back((unsigned char)12); - unsigned int sz = bufferUC.size() * sizeof(unsigned char); + unsigned int sz = uint32(bufferUC.size() * sizeof(unsigned char)); offsetAppend += sz + sizeof(unsigned int); diff --git a/CGoGN/include/Algo/Filtering/average_normals.h b/CGoGN/include/Algo/Filtering/average_normals.h index 57a15a02bee55bf6683d4b6d9fa6dc7de8e0ebc4..d99ccce854eacfd30ddd7c5c259e0c7f38ec920f 100644 --- a/CGoGN/include/Algo/Filtering/average_normals.h +++ b/CGoGN/include/Algo/Filtering/average_normals.h @@ -24,6 +24,10 @@ #include "Topology/generic/traversor/traversorCell.h" #include "Topology/generic/traversor/traversor2.h" +#include "Topology/generic/autoAttributeHandler.h" +#include "Algo/Geometry/area.h" +#include "Algo/Geometry/normal.h" + namespace CGoGN { @@ -248,7 +252,7 @@ void filterTNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con // get info from face embedding and sum const VEC3& normal = faceNormal[it] ; - float angle = Geom::angle(normF, normal) ; + REAL angle = Geom::angle(normF, normal) ; if(angle <= SUSANthreshold) { REAL area = faceArea[it] ; @@ -366,7 +370,7 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con for(Dart it = tav.begin(); it != tav.end(); it = tav.next()) { const VEC3& neighborNormal = normal[it] ; - float angle = Geom::angle(normV, neighborNormal) ; + REAL angle = Geom::angle(normV, neighborNormal) ; if( angle <= SUSANthreshold ) { REAL umbArea = Algo::Surface::Geometry::vertexOneRingArea(map, it, position) ; diff --git a/CGoGN/include/Algo/Filtering/bilateral.h b/CGoGN/include/Algo/Filtering/bilateral.h index cd638d32021f31724021d7abe6f52cb11f9e7f9b..0145d474cfcf08b33ecefadbbd5ba22444ef516d 100644 --- a/CGoGN/include/Algo/Filtering/bilateral.h +++ b/CGoGN/include/Algo/Filtering/bilateral.h @@ -24,6 +24,8 @@ #include #include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" +#include "Algo/Geometry/basic.h" namespace CGoGN { @@ -38,25 +40,26 @@ namespace Filtering { template -void sigmaBilateral(typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& normal, float& sigmaC, float& sigmaS) +void sigmaBilateral(typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& normal, typename PFP::REAL& sigmaC, typename PFP::REAL& sigmaS) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; - float sumLengths = 0.0f ; - float sumAngles = 0.0f ; + REAL sumLengths = 0.0f; + REAL sumAngles = 0.0f; long nbEdges = 0 ; TraversorE t(map); for(Dart d = t.begin(); d != t.end(); d = t.next()) { - sumLengths += Algo::Surface::Geometry::edgeLength(map, d, position) ; + sumLengths += Algo::Geometry::edgeLength(map, d, position) ; sumAngles += Geom::angle(normal[d], normal[map.phi1(d)]) ; ++nbEdges ; } // update of returned values - sigmaC = 1.0f * ( sumLengths / float(nbEdges) ) ; - sigmaS = 2.5f * ( sumAngles / float(nbEdges) ) ; + sigmaC = 1.0f * (sumLengths / REAL(nbEdges)); + sigmaS = 2.5f * (sumAngles / REAL(nbEdges)); } /** @@ -74,8 +77,9 @@ void filterBilateral( const VertexAttribute& normal) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; - float sigmaC, sigmaS ; + REAL sigmaC, sigmaS; sigmaBilateral(map, positionIn, normal, sigmaC, sigmaS) ; TraversorV t(map) ; @@ -87,14 +91,14 @@ void filterBilateral( const VEC3& normal_d = normal[d] ; // traversal of incident edges - float sum = 0.0f, normalizer = 0.0f ; + REAL sum = 0.0f, normalizer = 0.0f; Traversor2VE te(map, d) ; for(Dart it = te.begin(); it != te.end(); it = te.next()) { - VEC3 vec = Algo::Surface::Geometry::vectorOutOfDart(map, it, positionIn) ; - float h = normal_d * vec ; - float t = vec.norm() ; - float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) ) ; + VEC3 vec = Algo::Geometry::vectorOutOfDart(map, it, positionIn) ; + REAL h = normal_d * vec; + REAL t = vec.norm(); + REAL wcs = std::exp((-1.0f * (t * t) / (2.0f * sigmaC * sigmaC)) + (-1.0f * (h * h) / (2.0f * sigmaS * sigmaS))); sum += wcs * h ; normalizer += wcs ; } @@ -110,8 +114,9 @@ template void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; - float sigmaC, sigmaS ; + REAL sigmaC, sigmaS; sigmaBilateral(map, position, normal, sigmaC, sigmaS) ; long nbTot = 0 ; @@ -127,19 +132,19 @@ void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const VertexAttri const VEC3& normal_d = normal[d] ; // traversal of incident edges - float sum = 0.0f, normalizer = 0.0f ; + REAL sum = 0.0f, normalizer = 0.0f; bool SUSANregion = false ; Traversor2VE te(map, d) ; for(Dart it = te.begin(); it != te.end(); it = te.next()) { const VEC3& neighborNormal = normal[map.phi1(it)] ; - float angle = Geom::angle(normal_d, neighborNormal) ; + REAL angle = Geom::angle(normal_d, neighborNormal); if( angle <= SUSANthreshold ) { - VEC3 vec = Algo::Surface::Geometry::vectorOutOfDart(map, it, position) ; - float h = normal_d * vec ; - float t = vec.norm() ; - float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) ); + VEC3 vec = Algo::Geometry::vectorOutOfDart(map, it, position) ; + REAL h = normal_d * vec; + REAL t = vec.norm(); + REAL wcs = std::exp((-1.0f * (t * t) / (2.0f * sigmaC * sigmaC)) + (-1.0f * (h * h) / (2.0f * sigmaS * sigmaS))); sum += wcs * h ; normalizer += wcs ; } diff --git a/CGoGN/include/Algo/Filtering/taubin.h b/CGoGN/include/Algo/Filtering/taubin.h index ae0ed1618df7803057599c44180a9f02d0adf2c1..e81bcd80245923082a4221c16b30886e297a119b 100644 --- a/CGoGN/include/Algo/Filtering/taubin.h +++ b/CGoGN/include/Algo/Filtering/taubin.h @@ -42,11 +42,12 @@ void filterTaubin(typename PFP::MAP& map, VertexAttribute c(map) ; - const float lambda = 0.6307 ; - const float mu = -0.6732 ; + const REAL lambda = 0.6307f; + const REAL mu = -0.6732f; CellMarkerNoUnmark mv(map) ; @@ -104,9 +105,10 @@ void filterTaubin_modified(typename PFP::MAP& map, VertexAttribute mv(map) ; diff --git a/CGoGN/include/Algo/Filtering/tools.h b/CGoGN/include/Algo/Filtering/tools.h index 077d2532cca1e8a489c77874fb44d1f85687f4ac..b656b309d2d939e784a130919fb4f68ff10a45c8 100644 --- a/CGoGN/include/Algo/Filtering/tools.h +++ b/CGoGN/include/Algo/Filtering/tools.h @@ -23,11 +23,13 @@ *******************************************************************************/ #include "Geometry/distances.h" +#include "Topology/generic/traversor/traversor2.h" #include #include #include + namespace CGoGN { @@ -41,12 +43,13 @@ namespace Filtering { template -float computeHaussdorf(typename PFP::MAP& map, const VertexAttribute& originalPosition, const VertexAttribute& position2) +typename PFP::REAL computeHaussdorf(typename PFP::MAP& map, const VertexAttribute& originalPosition, const VertexAttribute& position2) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; - float dist_o = 0.0f ; - float dist_f = 0.0f ; + REAL dist_o = 0.0f; + REAL dist_f = 0.0f; TraversorV t(map) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -54,8 +57,8 @@ float computeHaussdorf(typename PFP::MAP& map, const VertexAttribute::max(); - float dv_f = std::numeric_limits::max(); + REAL dv_o = std::numeric_limits::max(); + REAL dv_f = std::numeric_limits::max(); // just test the faces around the vertex => warning not real haussdorff distance! Traversor2VF tf(map, d) ; @@ -68,7 +71,7 @@ float computeHaussdorf(typename PFP::MAP& map, const VertexAttribute dist_o) - return sqrtf(dist_f) ; - return sqrtf(dist_o) ; + return REAL(std::sqrt(dist_f)) ; + return REAL(sqrt(dist_o)) ; } template void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2, const VertexAttribute& normal) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; // init the seed for random - srand(time(NULL)) ; + srand((unsigned int)(time(NULL))) ; // apply noise on each vertex TraversorV t(map) ; @@ -102,14 +106,14 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute= 5) - r2 = float(rand() % (amount/5)) / 100.0f ; + r2 = REAL(rand() % (amount / 5)) / 100.0f; long sign = rand() % 2 ; if (sign == 1) norm *= -1.0f ; - float avEL = 0.0f ; + REAL avEL = 0.0f; VEC3 td(0) ; long nbE = 0 ; @@ -118,14 +122,14 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute void computeUnfirmAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; // Compute mesh center unsigned int count = 0; @@ -164,15 +169,15 @@ void computeUnfirmAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, co // add random uniform-distributed (between [-noiseLevel, +noiseLevel]) srand((unsigned)time(NULL)); - float noisex, noisey, noisez; - float noiseLevel = distanceCentroid * noiseIntensity; + REAL noisex, noisey, noisez; + REAL noiseLevel = REAL(distanceCentroid * noiseIntensity); for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) { - noisex = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2; - noisey = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2; - noisez = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2; + noisex = noiseLevel * REAL(1.0*rand() / RAND_MAX - 0.5) * 2; + noisey = noiseLevel * REAL(1.0*rand() / RAND_MAX - 0.5) * 2; + noisez = noiseLevel * REAL(1.0*rand() / RAND_MAX - 0.5) * 2; position2[dit] = position[dit] + VEC3(noisex,noisey,noisez); } @@ -185,6 +190,7 @@ template void computeGaussianAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; // Compute mesh center unsigned int count = 0; @@ -205,30 +211,30 @@ void computeGaussianAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, { VEC3 dist = position[dit]; dist -= centroid; - distanceCentroid += float(dist.norm()); + distanceCentroid += dist.norm(); } distanceCentroid /= count; // add random gaussian-distributed srand((unsigned)time(NULL)); - float noisex, noisey, noisez; - float gaussNumbers[3]; - float noiseLevel = distanceCentroid * noiseIntensity; + REAL noisex, noisey, noisez; + REAL gaussNumbers[3]; + REAL noiseLevel = REAL(distanceCentroid * noiseIntensity); for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) { // pseudo-random Gaussian-distributed numbers generation from uniformly-distributed pseudo-random numbers - float x, y, r2; + REAL x, y, r2; for (int i=0; i<3; i++) { do { - x = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; - y = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; + x = REAL(- 1.0 + 2.0 * 1.0*rand() / RAND_MAX); + y = REAL(-1.0 + 2.0 * 1.0*rand()/RAND_MAX); r2 = x * x + y * y; - } while ((r2>1.0)||(r2==0.0)); - gaussNumbers[i] = y * sqrt(-2.0 * log(r2) / r2); + } while ((r2>1.0f)||(r2==0.0f)); + gaussNumbers[i] = y * std::sqrt(-2.0f * std::log(r2) / r2); } noisex = noiseLevel * gaussNumbers[0]; @@ -255,11 +261,12 @@ template void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; // add random gaussian-distributed srand((unsigned)time(NULL)); - float noisex, noisey, noisez; - float gaussNumbers[3]; +// float noisex, noisey, noisez; +// float gaussNumbers[3]; float noiseLevel = 0.1f; // TraversorV tv(map) ; @@ -288,7 +295,7 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute t(map) ; @@ -297,14 +304,14 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute= 5) r2 = float(rand() % (amount/5)) / 100.0f ; long sign = rand() % 2 ; if (sign == 1) norm *= -1.0f ; - float avEL = 0.0f ; + REAL avEL = 0.0f; VEC3 td(0) ; long nbE = 0 ; @@ -313,14 +320,14 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute void computeNoiseGaussian(typename PFP::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; // add random gaussian-distributed srand((unsigned)time(NULL)); - float noisex, noisey, noisez; - float gaussNumbers[3]; - float noiseLevel = 0.08f; + REAL noisex, noisey, noisez; + REAL gaussNumbers[3]; + REAL noiseLevel = 0.08f; TraversorV tv(map) ; for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) { // pseudo-random Gaussian-distributed numbers generation from uniformly-distributed pseudo-random numbers - float x, y, r2; + REAL x, y, r2; for (int i=0; i<3; i++) { do { - x = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; - y = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; + x = REAL(- 1.0 + 2.0 * 1.0*rand() / RAND_MAX); + y = REAL(-1.0 + 2.0 * 1.0*rand()/RAND_MAX); r2 = x * x + y * y; } while ((r2>1.0)||(r2==0.0)); - gaussNumbers[i] = y * sqrt(-2.0 * log(r2) / r2); + gaussNumbers[i] = y * std::sqrt(-2.0f * std::log(r2) / r2); } noisex = noiseLevel * gaussNumbers[0]; diff --git a/CGoGN/include/Algo/Geometry/area.h b/CGoGN/include/Algo/Geometry/area.h index 299845c654729ca44c57b2e8c19d095e609b8d58..da076dfc4cc0380aa1861da1b9d00e6d2d3862fa 100644 --- a/CGoGN/include/Algo/Geometry/area.h +++ b/CGoGN/include/Algo/Geometry/area.h @@ -25,6 +25,8 @@ #ifndef __ALGO_GEOMETRY_AREA_H__ #define __ALGO_GEOMETRY_AREA_H__ +#include "Topology/generic/attributeHandler.h" + namespace CGoGN { diff --git a/CGoGN/include/Algo/Geometry/area.hpp b/CGoGN/include/Algo/Geometry/area.hpp index 5982c3b5c99363971f3b8d89e466899e5a71cad2..4dd815c313800e5317b5bb09fea66228f3e51b99 100644 --- a/CGoGN/include/Algo/Geometry/area.hpp +++ b/CGoGN/include/Algo/Geometry/area.hpp @@ -58,7 +58,7 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Face d, const VertexAt return triangleArea(map, d, position) ; else { - float area = 0.0f ; + typename PFP::REAL area = 0; VEC3 centroid = faceCentroid(map, d, position) ; Traversor2FE t(map, d) ; for(Dart it = t.begin(); it != t.end(); it = t.next()) @@ -119,7 +119,7 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, const Ver typename PFP::REAL area(0) ; foreach_incident2(map, v, [&] (Face it) { - const typename PFP::VEC3& p1 = position[it] ; + const typename PFP::VEC3& p1 = position[it.dart] ; const typename PFP::VEC3& p2 = position[map.phi1(it)] ; const typename PFP::VEC3& p3 = position[map.phi_1(it)] ; if(!Geom::isTriangleObtuse(p1, p2, p3)) diff --git a/CGoGN/include/Algo/Geometry/basic.h b/CGoGN/include/Algo/Geometry/basic.h index 8b34ce526cafa4944fa0d703da668e2e72743205..e4804a047100ed2565346cc0024c1feeaa648250 100644 --- a/CGoGN/include/Algo/Geometry/basic.h +++ b/CGoGN/include/Algo/Geometry/basic.h @@ -33,9 +33,6 @@ namespace CGoGN namespace Algo { -namespace Surface -{ - namespace Geometry { @@ -54,7 +51,7 @@ template inline typename PFP::REAL edgeLength(typename PFP::MAP& map, Dart d, const VertexAttribute& position) { typename PFP::VEC3 v = vectorOutOfDart(map, d, position) ; - return v.norm() ; + return typename PFP::REAL(v.norm()); } namespace Parallel @@ -110,7 +107,7 @@ inline typename PFP::REAL meanEdgeLength(typename PFP::MAP& map,const VertexAttr } template -inline float angle(typename PFP::MAP& map, Dart d1, Dart d2, const VertexAttribute& position) +inline typename PFP::REAL angle(typename PFP::MAP& map, Dart d1, Dart d2, const VertexAttribute& position) { typename PFP::VEC3 v1 = vectorOutOfDart(map, d1, position) ; typename PFP::VEC3 v2 = vectorOutOfDart(map, d2, position) ; @@ -125,8 +122,6 @@ bool isTriangleObtuse(typename PFP::MAP& map, Dart d, const VertexAttribute @@ -45,7 +45,7 @@ bool isEdgeConvex(typename PFP::MAP& map, Edge e, const VertexAttribute(map, e.dart, position); - const VEC3 ee = vectorOutOfDart(map, map.phi1(map.phi2(e.dart)), position) ; + const VEC3 ee = Algo::Geometry::vectorOutOfDart(map, map.phi1(map.phi2(e.dart)), position); if((ee * n) < 0) return true; diff --git a/CGoGN/include/Algo/Geometry/curvature.hpp b/CGoGN/include/Algo/Geometry/curvature.hpp index 54ea028a54492db9bc5954d0d674b7e0671f15e4..54651620c03f7e97827f57c5a355cc6bb8e338c2 100644 --- a/CGoGN/include/Algo/Geometry/curvature.hpp +++ b/CGoGN/include/Algo/Geometry/curvature.hpp @@ -22,6 +22,7 @@ * * *******************************************************************************/ +#include "Algo/Geometry/basic.h" #include "Algo/Geometry/localFrame.h" #include "Geometry/matrix.h" #include "Topology/generic/traversor/traversorCell.h" @@ -152,11 +153,11 @@ void vertexQuadraticFitting( nlEnd(NL_SYSTEM) ; nlSolve() ; - a = nlGetVariable(0) ; - b = nlGetVariable(1) ; - c = nlGetVariable(2) ; - d = nlGetVariable(3) ; - e = nlGetVariable(4) ; + a = typename PFP::REAL(nlGetVariable(0)); + b = typename PFP::REAL(nlGetVariable(1)); + c = typename PFP::REAL(nlGetVariable(2)); + d = typename PFP::REAL(nlGetVariable(3)); + e = typename PFP::REAL(nlGetVariable(4)); nlDeleteContext(nlContext) ; } @@ -546,8 +547,8 @@ void normalCycles_computeTensor( for (Edge e : col.getInsideEdges()) { typename PFP::REAL edgeangle = Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge(col.getMap(), e, position); - typename PFP::VEC3 ev = Algo::Surface::Geometry::vectorOutOfDart(col.getMap(), e, position); - tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle * (1.0 / ev.norm()); + typename PFP::VEC3 ev = Algo::Geometry::vectorOutOfDart(col.getMap(), e, position); + tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle * (1.0f / ev.norm()); } // collect edges on the border @@ -555,8 +556,8 @@ void normalCycles_computeTensor( { typename PFP::REAL edgeangle = Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge(col.getMap(), d, position); typename PFP::REAL alpha = col.borderEdgeRatio(d, position); - typename PFP::VEC3 ev = Algo::Surface::Geometry::vectorOutOfDart(col.getMap(), d, position); - tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle * (1.0 / ev.norm()) * alpha; + typename PFP::VEC3 ev = Algo::Geometry::vectorOutOfDart(col.getMap(), d, position); + tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle * (1.0f / ev.norm()) * alpha; } tensor /= col.computeArea(position); @@ -574,16 +575,16 @@ void normalCycles_computeTensor( // collect edges inside the neighborhood for (Edge e : col.getInsideEdges()) { - typename PFP::VEC3 ev = Algo::Surface::Geometry::vectorOutOfDart(col.getMap(), e, position); - tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[e] * (1.0 / ev.norm()); + typename PFP::VEC3 ev = Algo::Geometry::vectorOutOfDart(col.getMap(), e, position); + tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[e] * (1.0f / ev.norm()); } // collect edges on the border for (Dart d : col.getBorder()) { typename PFP::REAL alpha = col.borderEdgeRatio(d, position); - typename PFP::VEC3 ev = Algo::Surface::Geometry::vectorOutOfDart(col.getMap(), d, position); - tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[d] * (1.0 / ev.norm()) * alpha; + typename PFP::VEC3 ev = Algo::Geometry::vectorOutOfDart(col.getMap(), d, position); + tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[d] * (1.0f / ev.norm()) * alpha; } tensor /= col.computeArea(position); @@ -602,16 +603,16 @@ void normalCycles_computeTensor( // collect edges inside the neighborhood for (Edge e : col.getInsideEdges()) { - typename PFP::VEC3 ev = Algo::Surface::Geometry::vectorOutOfDart(col.getMap(), e, position); - tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[e] * (1.0 / ev.norm()); + typename PFP::VEC3 ev = Algo::Geometry::vectorOutOfDart(col.getMap(), e, position); + tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[e] * (1.0f / ev.norm()); } // collect edges on the border for (Dart d : col.getBorder()) { typename PFP::REAL alpha = col.borderEdgeRatio(d, position); - typename PFP::VEC3 ev = Algo::Surface::Geometry::vectorOutOfDart(col.getMap(), d, position); - tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[d] * (1.0 / ev.norm()) * alpha; + typename PFP::VEC3 ev = Algo::Geometry::vectorOutOfDart(col.getMap(), d, position); + tensor += Geom::transposed_vectors_mult(ev,ev) * edgeangle[d] * (1.0f / ev.norm()) * alpha; } tensor /= col.computeArea(position, edgearea); diff --git a/CGoGN/include/Algo/Geometry/feature.h b/CGoGN/include/Algo/Geometry/feature.h index 5de4475b9e68f7a223e0ed670f1736baa53eb38d..79b6b159bfb383ed2262cc6173ea88769d28e2e2 100644 --- a/CGoGN/include/Algo/Geometry/feature.h +++ b/CGoGN/include/Algo/Geometry/feature.h @@ -45,9 +45,26 @@ enum FEATURE }; -typedef struct { Dart d ; float w ; } e0point ; -typedef struct { e0point p1 ; e0point p2 ; unsigned char type ; } e0segment ; -typedef NoTypeNameAttribute ridgeSegment ; +//typedef struct { Dart d ; float w ; } e0point ; +//typedef struct { e0point p1 ; e0point p2 ; unsigned char type ; } e0segment ; +//typedef NoTypeNameAttribute RidgeSegment ; + +template +struct RidgeSegment +{ + struct { Dart d; REAL w; } p1; + struct { Dart d; REAL w; } p2; + unsigned char type; + static std::string CGoGNnameOfType() { return "RidgeSegment"; } +}; + +template +std::ostream& operator<<(std::ostream& out, const RidgeSegment&) +{ + out << "no_output"; + return out; +} + template void featureEdgeDetection( @@ -110,7 +127,7 @@ bool isTriangleRegular( template void initRidgeSegments( typename PFP::MAP& map, - FaceAttribute& ridge_segments) ; + FaceAttribute, typename PFP::MAP>& ridge_segments) ; template void computeRidgeLines( @@ -121,32 +138,32 @@ void computeRidgeLines( const VertexAttribute& vertex_gradient, const VertexAttribute& k, const VertexAttribute& k2, - FaceAttribute& ridge_segments) ; + FaceAttribute, typename PFP::MAP>& ridge_segments) ; template void ridgeLines( typename PFP::MAP& map, Dart d, const VertexAttribute& position, - const FaceAttribute& face_area, +// const FaceAttribute& face_area, const VertexAttribute& K, const VertexAttribute& vertex_gradient, const VertexAttribute& k, const VertexAttribute& k2, - FaceAttribute& ridge_segments) ; + FaceAttribute, typename PFP::MAP>& ridge_segments) ; template void computeSingularTriangle( typename PFP::MAP& map, CellMarker& regularMarker, - FaceAttribute& ridge_segments) ; + FaceAttribute, typename PFP::MAP>& ridge_segments) ; template void singularTriangle( typename PFP::MAP& map, Dart d, CellMarker& regularMarker, - FaceAttribute& ridge_segments) ; + FaceAttribute, typename PFP::MAP>& ridge_segments) ; template bool isEdgeInTriangle( diff --git a/CGoGN/include/Algo/Geometry/feature.hpp b/CGoGN/include/Algo/Geometry/feature.hpp index 0429a50ad4094d6d3b840a9e860b39eafd850aee..86439729a67f31a1e95b407fe4d97bf9de44293a 100644 --- a/CGoGN/include/Algo/Geometry/feature.hpp +++ b/CGoGN/include/Algo/Geometry/feature.hpp @@ -41,7 +41,7 @@ namespace Geometry template void featureEdgeDetection( typename PFP::MAP& map, - VertexAttribute& position, + const VertexAttribute& position, CellMarker& featureEdge) { typedef typename PFP::MAP MAP ; @@ -50,9 +50,9 @@ void featureEdgeDetection( featureEdge.unmarkAll() ; - FaceAttribute fNormal = map.template getAttribute("normal") ; + FaceAttribute fNormal = map.template getAttribute("normal") ; if(!fNormal.isValid()) - fNormal = map.template addAttribute("normal") ; + fNormal = map.template addAttribute("normal") ; Algo::Surface::Geometry::computeNormalFaces(map, position, fNormal) ; TraversorE t(map) ; @@ -241,7 +241,7 @@ bool isTriangleRegular( template void initRidgeSegments( typename PFP::MAP& map, - FaceAttribute& ridge_segments) + FaceAttribute, typename PFP::MAP>& ridge_segments) { TraversorF trav(map); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -257,7 +257,7 @@ void computeRidgeLines( const VertexAttribute& vertex_gradient, const VertexAttribute& k, const VertexAttribute& k2, - FaceAttribute& ridge_segments) + FaceAttribute, typename PFP::MAP>& ridge_segments) { TraversorF trav(map); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -276,7 +276,7 @@ void ridgeLines( const VertexAttribute& vertex_gradient, const VertexAttribute& k, const VertexAttribute& k2, - FaceAttribute& ridge_segments) + FaceAttribute, typename PFP::MAP>& ridge_segments) { typedef typename PFP::REAL REAL ; typedef typename PFP::VEC3 VEC3 ; @@ -365,9 +365,9 @@ void ridgeLines( VEC3 Ktotal = Kv1 + Kv2 + Kv3 ; REAL ktotal = k[v1] + k[v2] + k[v3] ; - ktotal = ktotal > 0 ? ktotal : -1.0 * ktotal ; + ktotal = ktotal > 0 ? ktotal : -1.0f * ktotal ; REAL k2total = k2[v1] + k2[v2] + k2[v3] ; - k2total = k2total > 0 ? k2total : -1.0 * k2total ; + k2total = k2total > 0 ? k2total : -1.0f * k2total ; if( ( (eg * Ktotal) < 0 ) && ( ktotal > k2total ) ) ridge_segments[d].type = FEATURE ; @@ -378,7 +378,7 @@ template void computeSingularTriangle( typename PFP::MAP& map, CellMarker& regularMarker, - FaceAttribute& ridge_segments) + FaceAttribute, typename PFP::MAP>& ridge_segments) { TraversorF trav(map); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -393,27 +393,27 @@ void singularTriangle( typename PFP::MAP& map, Dart d, CellMarker& regularMarker, - FaceAttribute& ridge_segments) + FaceAttribute, typename PFP::MAP>& ridge_segments) { int nbPoint = 0 ; Traversor2FFaE f(map, d) ; for (Dart d2 = f.begin(); d2 != f.end(); d2 = f.next()) { - if(regularMarker.isMarked(d2) and ridge_segments[d2].type == SEGMENT) + if(regularMarker.isMarked(d2) && (ridge_segments[d2].type == SEGMENT)) { if(isEdgeInTriangle(map, ridge_segments[d2].p1.d, d)) { if(nbPoint == 0) { ridge_segments[d].p1.d = map.phi2(ridge_segments[d2].p1.d) ; - ridge_segments[d].p1.w = 1.0 - ridge_segments[d2].p1.w ; + ridge_segments[d].p1.w = 1.0f - ridge_segments[d2].p1.w ; } else { ridge_segments[d].type ++ ; ridge_segments[d].p2.d = map.phi2(ridge_segments[d2].p1.d) ; - ridge_segments[d].p2.w = 1.0 - ridge_segments[d2].p1.w ; + ridge_segments[d].p2.w = 1.0f - ridge_segments[d2].p1.w ; } nbPoint ++ ; } @@ -422,13 +422,13 @@ void singularTriangle( if(nbPoint == 0) { ridge_segments[d].p1.d = map.phi2(ridge_segments[d2].p2.d) ; - ridge_segments[d].p1.w = 1.0 - ridge_segments[d2].p2.w ; + ridge_segments[d].p1.w = 1.0f - ridge_segments[d2].p2.w ; } else { ridge_segments[d].type ++ ; ridge_segments[d].p2.d = map.phi2(ridge_segments[d2].p2.d) ; - ridge_segments[d].p2.w = 1.0 - ridge_segments[d2].p2.w ; + ridge_segments[d].p2.w = 1.0f - ridge_segments[d2].p2.w ; } nbPoint ++ ; } diff --git a/CGoGN/include/Algo/Geometry/inclusion.hpp b/CGoGN/include/Algo/Geometry/inclusion.hpp index e99b0089e4d4fe3a05aa013dbec7e8c30c8f80e2..4f5cbd5d0a5598c399f34a72dae6b7c1108e22d8 100644 --- a/CGoGN/include/Algo/Geometry/inclusion.hpp +++ b/CGoGN/include/Algo/Geometry/inclusion.hpp @@ -56,7 +56,7 @@ bool isConvex(typename PFP::MAP& map, Vol v, const VertexAttribute(e) ; + m.template markOrbit(e) ; convex = isTetrahedronWellOriented(map, e, position, CCW) ; } } @@ -69,6 +69,7 @@ template bool isPointInVolume(typename PFP::MAP& map, Vol v, const VertexAttribute& position, const typename PFP::VEC3& point) { typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; //number of intersection between a ray and the volume must be odd int countInter = 0; @@ -104,7 +105,7 @@ bool isPointInVolume(typename PFP::MAP& map, Vol v, const VertexAttribute 0) ++countInter; if (v < 0) @@ -263,17 +264,17 @@ bool isPointOnHalfEdge(typename PFP::MAP& map, Dart d, const VertexAttribute(map, d, position); + VEC3 v1 = Algo::Geometry::vectorOutOfDart(map, d, position); VEC3 v2(point - position[d]); v1.normalize(); v2.normalize(); - return abs(v1*v2) <= REAL(0.00001); + return std::abs(v1*v2) <= REAL(0.00001); } template -bool isPointOnVertex(typename PFP::MAP& map, Vertex v, const VertexAttribute& position, const typename PFP::VEC3& point) +bool isPointOnVertex(typename PFP::MAP& /*map*/, Vertex v, const VertexAttribute& position, const typename PFP::VEC3& point) { return Geom::arePointsEquals(point, position[v]); } @@ -291,12 +292,12 @@ bool isConvexFaceInOrIntersectingTetrahedron(typename PFP::MAP& map, Face f, con } VEC3 inter; - if( intersectionSegmentConvexFace(map, f, position, points[0], points[1], inter) - || intersectionSegmentConvexFace(map, f, position, points[1], points[2], inter) - || intersectionSegmentConvexFace(map, f, position, points[2], points[0], inter) - || intersectionSegmentConvexFace(map, f, position, points[0], points[3], inter) - || intersectionSegmentConvexFace(map, f, position, points[1], points[3], inter) - || intersectionSegmentConvexFace(map, f, position, points[2], points[3], inter) + if( intersectionSegmentConvexFace(map, f, position, points[0], points[1], inter) + || intersectionSegmentConvexFace(map, f, position, points[1], points[2], inter) + || intersectionSegmentConvexFace(map, f, position, points[2], points[0], inter) + || intersectionSegmentConvexFace(map, f, position, points[0], points[3], inter) + || intersectionSegmentConvexFace(map, f, position, points[1], points[3], inter) + || intersectionSegmentConvexFace(map, f, position, points[2], points[3], inter) ) return true; diff --git a/CGoGN/include/Algo/Geometry/intersection.hpp b/CGoGN/include/Algo/Geometry/intersection.hpp index ad14f00d388066acbc9c16531a0af22c36e8e6a6..580e32b4fb67bbebeb9a61ab9840cbe05c500577 100644 --- a/CGoGN/include/Algo/Geometry/intersection.hpp +++ b/CGoGN/include/Algo/Geometry/intersection.hpp @@ -47,28 +47,29 @@ template bool intersectionLineConvexFace(typename PFP::MAP& map, Face f, const VertexAttribute& position, const typename PFP::VEC3& P, const typename PFP::VEC3& Dir, typename PFP::VEC3& Inter) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; - const float SMALL_NUM = std::numeric_limits::min() * 5.0f; + const REAL SMALL_NUM = std::numeric_limits::min() * 5.0f; Dart d = f.dart; VEC3 p1 = position[d]; VEC3 n = faceNormal(map, d, position); VEC3 w0 = P - p1; - float a = -(n*w0); - float b = n*Dir; + REAL a = -(n*w0); + REAL b = n*Dir; if (fabs(b) < SMALL_NUM) return false; - float r = a / b; + REAL r = a / b; Inter = P + r * Dir; // intersect point of ray and plane // is I inside the face? VEC3 p2 = position[map.phi1(d)]; VEC3 v = p2 - p1 ; VEC3 vInter = Inter - p1; - float dirV = v * vInter; + REAL dirV = v * vInter; if(fabs(dirV) < SMALL_NUM) // on an edge return true; @@ -79,7 +80,7 @@ bool intersectionLineConvexFace(typename PFP::MAP& map, Face f, const VertexAttr p2 = position[map.phi1(it)]; v = p2 - p1; vInter = Inter - p1; - float dirD = v * vInter; + REAL dirD = v * vInter; if(fabs(dirD) < SMALL_NUM) // on an edge return true; @@ -97,7 +98,7 @@ bool intersectionSegmentConvexFace(typename PFP::MAP& map, Face f, const VertexA typedef typename PFP::VEC3 VEC3 ; VEC3 dir = PB - PA; - if (intersectionLineConvexFace(map, f, position, PA, dir, Inter)) + if (intersectionLineConvexFace(map, f, position, PA, dir, Inter)) { VEC3 dirA = PA - Inter; VEC3 dirB = PB - Inter; @@ -112,6 +113,7 @@ template bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const VertexAttribute& position) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; Dart tri1 = t1.dart; Dart tri2 = t2.dart; @@ -188,7 +190,7 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const for (unsigned int i = 0; i < 3 ; ++i) { VEC3 nTest = bary1 - tris2[i]; - float scal = nTest * normale1; + REAL scal = nTest * normale1; if (scal < 0) ++neg; if (scal > 0) @@ -207,7 +209,7 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const for (unsigned int i = 0; i < 3 ; ++i) { VEC3 nTest = bary2 - tris1[i]; - float scal = nTest * normale2; + REAL scal = nTest * normale2; if (scal<0) ++neg; if (scal>0) @@ -222,7 +224,7 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const for (unsigned int i = 0; i < 3 && !intersection; ++i) { VEC3 inter; - intersection = Geom::intersectionSegmentTriangle(tris1[i], tris1[(i+1)%3], tris2[0], tris2[1], tris2[2], inter); + intersection = Geom::intersectionSegmentTriangle(tris1[i], tris1[(i + 1) % 3], tris2[0], tris2[1], tris2[2], inter) != Geom::NO_INTERSECTION; } if (intersection) @@ -231,7 +233,7 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const for (unsigned int i = 0; i < 3 && !intersection; ++i) { VEC3 inter; - intersection = Geom::intersectionSegmentTriangle(tris2[i], tris2[(i+1)%3], tris1[0], tris1[1], tris1[2], inter); + intersection = Geom::intersectionSegmentTriangle(tris2[i], tris2[(i + 1) % 3], tris1[0], tris1[1], tris1[2], inter) != Geom::NO_INTERSECTION; } return intersection; diff --git a/CGoGN/include/Algo/Geometry/laplacian.hpp b/CGoGN/include/Algo/Geometry/laplacian.hpp index bb9f9e831a1ba8c6a5e98ea93f7497a9628695a3..f66e3c8229c08b0e1dbad5c91ec5bdaa76ba9628 100644 --- a/CGoGN/include/Algo/Geometry/laplacian.hpp +++ b/CGoGN/include/Algo/Geometry/laplacian.hpp @@ -126,7 +126,7 @@ typename PFP::REAL computeCotanWeightEdge( const VEC3& p3 = position[map.phi_1(d)] ; REAL cot_alpha = 1 / tan(Geom::angle(p1 - p3, p2 - p3)) ; - return 0.5 * cot_alpha ; + return 0.5f * cot_alpha ; } else { @@ -137,7 +137,7 @@ typename PFP::REAL computeCotanWeightEdge( REAL cot_alpha = 1 / tan(Geom::angle(p1 - p3, p2 - p3)) ; REAL cot_beta = 1 / tan(Geom::angle(p2 - p4, p1 - p4)) ; - return 0.5 * ( cot_alpha + cot_beta ) ; + return 0.5f * ( cot_alpha + cot_beta ) ; } } diff --git a/CGoGN/include/Algo/Geometry/localFrame.h b/CGoGN/include/Algo/Geometry/localFrame.h index 614bff785b93e37dbe9efb3f5a34372b3458712b..97bfe049d2b2d3bf69ae3df6baaaa6a6abc1233c 100644 --- a/CGoGN/include/Algo/Geometry/localFrame.h +++ b/CGoGN/include/Algo/Geometry/localFrame.h @@ -45,7 +45,7 @@ template void vertexLocalFrame(typename PFP::MAP& map, Dart d, const VertexAttribute& position, typename PFP::VEC3& X, typename PFP::VEC3& Y, typename PFP::VEC3& Z) { Z = Algo::Surface::Geometry::vertexNormal(map, d, position) ; - X = Algo::Surface::Geometry::vectorOutOfDart(map, d, position) ; + X = Algo::Geometry::vectorOutOfDart(map, d, position) ; Y = Z ^ X ; Y.normalize() ; X = Y ^ Z ; @@ -70,7 +70,7 @@ template void vertexLocalFrame(typename PFP::MAP& map, Dart d, const VertexAttribute& position, typename PFP::VEC3& normal, typename PFP::VEC3& X, typename PFP::VEC3& Y, typename PFP::VEC3& Z) { Z = normal ; - X = Algo::Surface::Geometry::vectorOutOfDart(map, d, position) ; + X = Algo::Geometry::vectorOutOfDart(map, d, position) ; Y = Z ^ X ; Y.normalize() ; X = Y ^ Z ; diff --git a/CGoGN/include/Algo/Geometry/normal.hpp b/CGoGN/include/Algo/Geometry/normal.hpp index 7442d837ed0d09e3f43568b2d8bf61b67bdd98bf..b4ce103bb7654f659db779cd4677b0ab2575499a 100644 --- a/CGoGN/include/Algo/Geometry/normal.hpp +++ b/CGoGN/include/Algo/Geometry/normal.hpp @@ -102,8 +102,8 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V VEC3 n = faceNormal(map, f, position) ; if(!n.hasNan()) { - VEC3 v1 = vectorOutOfDart(map, f.dart, position) ; - VEC3 v2 = vectorOutOfDart(map, map.phi_1(f), position) ; + VEC3 v1 = Algo::Geometry::vectorOutOfDart(map, f.dart, position) ; + VEC3 v2 = Algo::Geometry::vectorOutOfDart(map, map.phi_1(f), position); typename VEC3::DATA_TYPE l = (v1.norm2() * v2.norm2()); if (l > (typename VEC3::DATA_TYPE(0.0)) ) { @@ -135,14 +135,15 @@ typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, c for(std::vector::iterator it = faces.begin() ; it != faces.end() ; ++it) { - if(!f.isMarked(*it) && map.isBoundaryIncidentFace(*it)) +// if(!f.isMarked(*it) && map.isBoundaryIncidentFace(*it)) + if (!f.isMarked(*it) && (map.template isBoundaryMarked<3>(map.phi3(*it)))) { f.mark(*it); VEC3 n = faceNormal(map, *it, position); if(!n.hasNan()) { - VEC3 v1 = vectorOutOfDart(map, *it, position); - VEC3 v2 = vectorOutOfDart(map, map.phi_1(*it), position); + VEC3 v1 = Algo::Geometry::vectorOutOfDart(map, *it, position); + VEC3 v2 = Algo::Geometry::vectorOutOfDart(map, map.phi_1(*it), position); n *= convexFaceArea(map, *it, position) / (v1.norm2() * v2.norm2()); N += n ; } diff --git a/CGoGN/include/Algo/Geometry/normalization.h b/CGoGN/include/Algo/Geometry/normalization.h index 562ef69afa93465fb06cf169dc588a0fff31abcb..dcedfa13cdda64ff795cc7c410f9de285cbfe493 100644 --- a/CGoGN/include/Algo/Geometry/normalization.h +++ b/CGoGN/include/Algo/Geometry/normalization.h @@ -27,6 +27,7 @@ #include "Geometry/vector_gen.h" #include "Container/containerBrowser.h" +#include "Topology/generic/attributeHandler.h" namespace CGoGN { diff --git a/CGoGN/include/Algo/Geometry/voronoiDiagrams.h b/CGoGN/include/Algo/Geometry/voronoiDiagrams.h index 711f63e6061b077af880f9ec3ee7ec99317e56bb..9b011b73f6190bc7e56e8f6a051905b929183930 100644 --- a/CGoGN/include/Algo/Geometry/voronoiDiagrams.h +++ b/CGoGN/include/Algo/Geometry/voronoiDiagrams.h @@ -30,7 +30,7 @@ class VoronoiDiagram protected : typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it ; bool valid ; // unsigned int region; Dart pathOrigin; @@ -46,7 +46,7 @@ protected : std::vector seeds; VertexAttribute vertexInfo; - std::multimap front ; + std::multimap front ; CellMarker vmReached; public : @@ -57,7 +57,8 @@ public : virtual void setSeeds_fromVector (const std::vector&); virtual void setSeeds_random (unsigned int nbseeds); const std::vector& getBorder () { return border; } - void setCost (const EdgeAttribute& c); + +// void setCost (const EdgeAttribute& c); // impossible to reaffect a ref TODO pointer ? Dart computeDiagram (); virtual void computeDiagram_incremental (unsigned int nbseeds); @@ -67,8 +68,8 @@ protected : virtual void clear (); void initFrontWithSeeds(); virtual void collectVertexFromFront(Dart e); - void addVertexToFront(Dart f, float d); - void updateVertexInFront(Dart f, float d); + void addVertexToFront(Dart f, REAL d); + void updateVertexInFront(Dart f, REAL d); }; template @@ -108,7 +109,7 @@ public : // move each seed along one edge according to the energy gradient + check that the energy decreases unsigned int moveSeedsToMedioid(); // returns the number of seeds that did move // move each seed to the medioid of its region - REAL getGlobalEnergy() { return globalEnergy; } + REAL getGlobalEnergy() { return REAL(globalEnergy); } protected : void clear(); diff --git a/CGoGN/include/Algo/Geometry/voronoiDiagrams.hpp b/CGoGN/include/Algo/Geometry/voronoiDiagrams.hpp index f6883670bd9c4afdfeeaad24e04bfd615f8db931..91b9fdb0e0ef752e64ff4f01643b6fc4bed40580 100644 --- a/CGoGN/include/Algo/Geometry/voronoiDiagrams.hpp +++ b/CGoGN/include/Algo/Geometry/voronoiDiagrams.hpp @@ -50,7 +50,7 @@ template void VoronoiDiagram::setSeeds_random (unsigned int nseeds) { seeds.clear(); - srand ( time(NULL) ); + srand ( (unsigned int)(time(NULL)) ); const unsigned int nbv = map.getNbCells(VERTEX); std::set myVertices ; @@ -94,18 +94,18 @@ void VoronoiDiagram::initFrontWithSeeds () { Dart d = seeds[i]; vmReached.mark(d); - vertexInfo[d].it = front.insert(std::pair(0.0, d)); + vertexInfo[d].it = front.insert(std::pair(0.0, d)); vertexInfo[d].valid = true; regions[d] = i; vertexInfo[d].pathOrigin = d; } } -template -void VoronoiDiagram::setCost (const EdgeAttribute& c) -{ - edgeCost = c; -} +//template +//void VoronoiDiagram::setCost (const EdgeAttribute& c) +//{ +// edgeCost = c; +//} template void VoronoiDiagram::collectVertexFromFront(Dart e) @@ -116,24 +116,24 @@ void VoronoiDiagram::collectVertexFromFront(Dart e) } template -void VoronoiDiagram::addVertexToFront(Dart f, float d) +void VoronoiDiagram::addVertexToFront(Dart f, REAL d) { VertexInfo& vi (vertexInfo[f]); - vi.it = front.insert(std::pair(d + edgeCost[f], f)); + vi.it = front.insert(std::pair(d + edgeCost[f], f)); vi.valid = true; vi.pathOrigin = map.phi2(f); vmReached.mark(f); } template -void VoronoiDiagram::updateVertexInFront(Dart f, float d) +void VoronoiDiagram::updateVertexInFront(Dart f, REAL d) { VertexInfo& vi (vertexInfo[f]); - float dist = d + edgeCost[f]; + REAL dist = d + edgeCost[f]; if (dist < vi.it->first) { front.erase(vi.it); - vi.it = front.insert(std::pair(dist, f)); + vi.it = front.insert(std::pair(dist, f)); vi.pathOrigin = map.phi2(f); } } @@ -147,7 +147,7 @@ Dart VoronoiDiagram::computeDiagram () while ( !front.empty() ) { e = front.begin()->second; - float d = front.begin()->first; + REAL d = front.begin()->first; collectVertexFromFront(e); @@ -179,7 +179,7 @@ void VoronoiDiagram::computeDiagram_incremental (unsigned int nseeds) seeds.clear(); // first seed - srand ( time(NULL) ); + srand ((unsigned int)(time(NULL)) ); unsigned int s = rand() % map.getNbCells(VERTEX); unsigned int n = 0; TraversorV tv (map); @@ -209,7 +209,7 @@ void VoronoiDiagram::computeDistancesWithinRegion (Dart seed) vmReached.unmarkAll(); vmReached.mark(seed); - vertexInfo[seed].it = front.insert(std::pair(0.0, seed)); + vertexInfo[seed].it = front.insert(std::pair(0.0, seed)); vertexInfo[seed].valid = true; vertexInfo[seed].pathOrigin = seed; @@ -217,7 +217,7 @@ void VoronoiDiagram::computeDistancesWithinRegion (Dart seed) while ( !front.empty() ) { Dart e = front.begin()->second; - float d = front.begin()->first; + REAL d = front.begin()->first; collectVertexFromFront(e); @@ -416,13 +416,14 @@ typename PFP::REAL CentroidalVoronoiDiagram::cumulateEnergyFromRoot(Dart e) template void CentroidalVoronoiDiagram::cumulateEnergyAndGradientFromSeed(unsigned int numSeed) { + typedef typename PFP::REAL REAL; // precondition : energyGrad.size() > numSeed Dart e = this->seeds[numSeed]; std::vector v; v.reserve(8); - std::vector da; + std::vector da; da.reserve(8); distances[e] = 0.0; @@ -432,7 +433,7 @@ void CentroidalVoronoiDiagram::cumulateEnergyAndGradientFromSeed(unsigned i { if ( pathOrigins[f] == this->map.phi2(f)) { - float distArea = cumulateEnergyFromRoot(f); + REAL distArea = cumulateEnergyFromRoot(f); da.push_back(distArea); distances[e] += distances[f]; v.push_back(f); @@ -458,12 +459,13 @@ void CentroidalVoronoiDiagram::cumulateEnergyAndGradientFromSeed(unsigned i template Dart CentroidalVoronoiDiagram::selectBestNeighborFromSeed(unsigned int numSeed) { + typedef typename PFP::REAL REAL; Dart e = this->seeds[numSeed]; Dart newSeed = e; const VertexAttribute& pos = this->map.template getAttribute("position"); // TODO : check if the computation of grad and proj is still valid for other edgeCost than geodesic distances - float maxProj = 0.0; + REAL maxProj = 0; Traversor2VVaE tv (this->map, e); for (Dart f = tv.begin(); f != tv.end(); f=tv.next()) { @@ -471,7 +473,7 @@ Dart CentroidalVoronoiDiagram::selectBestNeighborFromSeed(unsigned int numS { VEC3 edgeV = pos[f] - pos[this->map.phi2(f)]; // edgeV.normalize(); - float proj = edgeV * energyGrad[numSeed]; + REAL proj = edgeV * energyGrad[numSeed]; if (proj > maxProj) { maxProj = proj; @@ -514,7 +516,7 @@ unsigned int CentroidalVoronoiDiagram::moveSeed(unsigned int numSeed){ std::vector v; v.reserve(8); - std::vector da; + std::vector da; da.reserve(8); distances[e] = 0.0; @@ -524,7 +526,7 @@ unsigned int CentroidalVoronoiDiagram::moveSeed(unsigned int numSeed){ { if ( pathOrigins[f] == this->map.phi2(f)) { - float distArea = cumulateEnergyFromRoot(f); + REAL distArea = cumulateEnergyFromRoot(f); da.push_back(distArea); distances[e] += distances[f]; v.push_back(f); @@ -545,14 +547,14 @@ unsigned int CentroidalVoronoiDiagram::moveSeed(unsigned int numSeed){ } grad /= 2.0; - float maxProj = 0.0; -// float memoForTest = 0.0; + REAL maxProj = 0.0; +// REAL memoForTest = 0.0; for (unsigned int j = 0; jmap.phi2(f)]; // edgeV.normalize(); - float proj = edgeV * grad; + REAL proj = edgeV * grad; // proj -= areaElts[e] * this->edgeCost[f] * this->edgeCost[f]; if (proj > maxProj) { diff --git a/CGoGN/include/Algo/Histogram/histogram.hpp b/CGoGN/include/Algo/Histogram/histogram.hpp index 428e46a7e02632fb5f9730350ea1fa7f78c68d54..f3ca32b9f6f948eb7ef2edccb8f89a8eb188089d 100644 --- a/CGoGN/include/Algo/Histogram/histogram.hpp +++ b/CGoGN/include/Algo/Histogram/histogram.hpp @@ -157,7 +157,7 @@ inline unsigned int Histogram::whichQuantille(double val) const template void Histogram::histoColorize(ATTC& colors) { - unsigned int nb = m_dataIdx.size(); + unsigned int nb = uint32(m_dataIdx.size()); for (unsigned int i = 0; i void Histogram::quantilesColorize(ATTC& colors, const std::vector& tc) { - unsigned int nb = m_dataIdx.size(); - unsigned int nbi = m_interv.size()-1; + unsigned int nb = uint32(m_dataIdx.size()); + unsigned int nbi = uint32(m_interv.size() - 1); assert(tc.size() >= nbi); @@ -239,7 +239,7 @@ unsigned int Histogram::markCellsOfQuantilesColumn(unsigned int c, CELLMARKER& c double bi = m_interv[c]; double bs = m_interv[c+1]; - unsigned int nb=m_dataIdx.size(); + unsigned int nb = uint32(m_dataIdx.size()); unsigned int i=0; while ((i -//#include -//#include -// -//#include "Utils/Qt/qtpopup.h" -//#include "Algo/Histogram/histogram.h" -// -//#ifdef WIN32 -//#if defined CGoGN_QT_DLL_EXPORT -//#define CGoGN_UTILS_API __declspec(dllexport) -//#else -//#define CGoGN_UTILS_API __declspec(dllimport) -//#endif -//#endif -// -//namespace CGoGN -//{ -// -//namespace Utils -//{ -// -//namespace QT -//{ -// -// -//class CGoGN_UTILS_API RenderHistogram : public QWidget -//{ -// Q_OBJECT -// -// static const int m_frameWidth = 10; -// -// -// const Algo::Histogram::Histogram& m_histo; -// std::vector m_qcolors; -// -// unsigned int m_max; -// int m_h; -// int m_w; -// unsigned int m_l; -// -// std::vector m_vals_ax_left; -// -// int m_axl_nbd; -// bool m_drawHisto; -// bool m_drawQuantiles; -// bool m_histoFront; -// float m_opacity; -// bool m_drawAxis; -// -// /// draw all in painter -// void draw(QPainter& painter); -// -// /// compute left axis value -// void axeVals(); -// -//public: -// -// static const unsigned int NONE = 0xffffffff; -// -// /** -// * constructor -// * @param parent parent widget -// * @param histo histogram to draw -// */ -// RenderHistogram(QWidget* parent, Algo::Histogram::Histogram& histo, bool drawAxis=true ); -// -// /// minimum size -// virtual QSize minimumSizeHint() const; -// -// /// size at launch -// virtual QSize sizeHint() const; -// -// /** -// * set color table for quantiles drawing -// * @param colors vector of colors -// */ -// void setQuantilesColors(const std::vector& colors); -// -// /*** -// * svg export -// * @param filename file name of svg file -// */ -// void svgExport(const std::string& filename); -// -// /** -// * set histo position (front or back) -// * @param hf if true histo is in front of the quantille -// */ -// void setHistoPosition(bool hf); -// -// /** -// * define if histogram is drawn -// */ -// void setHistoDraw(bool d); -// -// /** -// * define if quantille is drawn -// */ -// void setQuantilesDraw(bool d); -// -// /** -// * get bool value that indicate drawing of histogram -// */ -// bool getHistoDraw(); -// -// /** -// * get bool value that indicate drawing of quantille -// */ -// bool getQuantilesDraw(); -// -// /** -// * get opacity value -// */ -// float getOpacity(); -// -// /** -// * define the opacity if the two graphs are drawn -// */ -// void setOpacity(float op); -// -// /** -// * update drawing -// */ -// void update(); -// -// signals: -// /** -// * emitted signal when a column of histogram is clicked -// * @param i column of histo (NONE if none) -// * @param j column of quantileq (NONE if none) -// */ -// void clicked(unsigned int, unsigned int); -// -// -// -//protected: -// -// /// draw the histogram in painter widget -// void drawHisto(QPainter& painter); -// -// /// draw the quatilles in painter widget -// void drawQuantiles(QPainter& painter); -// -// /// functinn calles when widget need to be redraw -// void paintEvent(QPaintEvent *event); -// -// /// draw the histogram in painter widget -// void mousePressEvent(QMouseEvent* event); -// -//}; -// -//} -//} -//} -// -// -//#endif +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#ifndef __QT_HISTO_DRAW__ +#define __QT_HISTO_DRAW__ + + +#include +#include +#include + +#include "Algo/Histogram/histogram.h" + +#ifdef WIN32 +#if defined CGoGN_QT_DLL_EXPORT +#define CGoGN_ALGO_API __declspec(dllexport) +#else +#define CGoGN_ALGO_API __declspec(dllimport) +#endif +#endif + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Histogram +{ + + +class CGoGN_ALGO_API RenderHistogram : public QWidget +{ + Q_OBJECT + + static const int m_frameWidth = 10; + + + const Algo::Histogram::Histogram& m_histo; + std::vector m_qcolors; + + unsigned int m_max; + int m_h; + int m_w; + unsigned int m_l; + + std::vector m_vals_ax_left; + + int m_axl_nbd; + bool m_drawHisto; + bool m_drawQuantiles; + bool m_histoFront; + float m_opacity; + bool m_drawAxis; + + /// draw all in painter + void draw(QPainter& painter); + + /// compute left axis value + void axeVals(); + +public: + + static const unsigned int NONE = 0xffffffff; + + /** + * constructor + * @param parent parent widget + * @param histo histogram to draw + */ + RenderHistogram(QWidget* parent, Algo::Histogram::Histogram& histo, bool drawAxis=true ); + + /// minimum size + virtual QSize minimumSizeHint() const; + + /// size at launch + virtual QSize sizeHint() const; + + /** + * set color table for quantiles drawing + * @param colors vector of colors + */ + void setQuantilesColors(const std::vector& colors); + + /*** + * svg export + * @param filename file name of svg file + */ + void svgExport(const std::string& filename); + + /** + * set histo position (front or back) + * @param hf if true histo is in front of the quantille + */ + void setHistoPosition(bool hf); + + /** + * define if histogram is drawn + */ + void setHistoDraw(bool d); + + /** + * define if quantille is drawn + */ + void setQuantilesDraw(bool d); + + /** + * get bool value that indicate drawing of histogram + */ + bool getHistoDraw(); + + /** + * get bool value that indicate drawing of quantille + */ + bool getQuantilesDraw(); + + /** + * get opacity value + */ + float getOpacity(); + + /** + * define the opacity if the two graphs are drawn + */ + void setOpacity(float op); + + /** + * update drawing + */ + void update(); + + signals: + /** + * emitted signal when a column of histogram is clicked + * @param i column of histo (NONE if none) + * @param j column of quantileq (NONE if none) + */ + void clicked(unsigned int, unsigned int); + + + +protected: + + /// draw the histogram in painter widget + void drawHisto(QPainter& painter); + + /// draw the quatilles in painter widget + void drawQuantiles(QPainter& painter); + + /// functinn calles when widget need to be redraw + void paintEvent(QPaintEvent *event); + + /// draw the histogram in painter widget + void mousePressEvent(QMouseEvent* event); + +}; + +} +} +} + + +#endif diff --git a/CGoGN/include/Algo/Import/AHEMImporter.hpp b/CGoGN/include/Algo/Import/AHEMImporter.hpp index a2cc962de5afd9edb481e9aa84d00b0566ffd169..6114341ffa9b0c09cba12d31dd7660859f75409d 100644 --- a/CGoGN/include/Algo/Import/AHEMImporter.hpp +++ b/CGoGN/include/Algo/Import/AHEMImporter.hpp @@ -28,6 +28,8 @@ #include "Algo/Import/AHEMImporterDefAttr.h" +#include + namespace CGoGN { @@ -230,10 +232,10 @@ void AHEMImporter::LoadTopology() // Ensure vertices are created by querying the position attribute - VertexAttribute position = map->template getAttribute("position") ; + VertexAttribute position = map->template getAttribute("position"); if (!position.isValid()) - position = map->template addAttribute("position") ; + position = map->template addAttribute("position"); // Read faces stream and create faces [only intra-face links] @@ -304,10 +306,10 @@ void AHEMImporter::LoadTopology() template void AHEMImporter::LoadPosition(AHEMAttributeDescriptor* posDescr) { - VertexAttribute position = map->template getAttribute("position") ; + VertexAttribute position = map->template getAttribute("position"); if (!position.isValid()) - position = map->template addAttribute("position") ; + position = map->template addAttribute("position"); f.seekg(posDescr->fileStartOffset, std::ios_base::beg); f.read(buffer, posDescr->attributeChunkSize); diff --git a/CGoGN/include/Algo/Import/AHEMImporterDefAttr.hpp b/CGoGN/include/Algo/Import/AHEMImporterDefAttr.hpp index 46cc902e0d9f71b7fc130ef13ddd3ca718b4bf4e..65553322ec9558e89bfb04e88feff5056f32c656 100644 --- a/CGoGN/include/Algo/Import/AHEMImporterDefAttr.hpp +++ b/CGoGN/include/Algo/Import/AHEMImporterDefAttr.hpp @@ -75,10 +75,10 @@ void UniversalLoader::ImportAttribute( MapType& map, template void UniversalLoader::UnpackOnVertex(MapType& map, const unsigned int* verticesId, const AHEMHeader* hdr, const char* attrName, const void* buffer) const { - VertexAttribute attr = map.template getAttribute(attrName); + VertexAttribute attr = map.template getAttribute(attrName); if (!attr.isValid()) - attr = map.template addAttribute(attrName); + attr = map.template addAttribute(attrName); char* p = (char*)buffer; @@ -92,10 +92,10 @@ void UniversalLoader::UnpackOnVertex(MapType& map, cons template void UniversalLoader:: UnpackOnFace(MapType& map, const Dart* facesId, const AHEMHeader* hdr, const char* attrName, const void* buffer) const { - FaceAttribute attr = map.template getAttribute, FACE(attrName); + FaceAttribute attr = map.template getAttribute, FACE(attrName); if (!attr.isValid()) - attr = map.template addAttribute(FACE, attrName); + attr = map.template addAttribute(FACE, attrName); char* p = (char*)buffer; @@ -109,7 +109,7 @@ void UniversalLoader:: UnpackOnFace(MapType& map, const template void UniversalLoader:: UnpackOnHE(MapType& map, const Dart* facesId, const AHEMHeader* hdr, const char* attrName, const void* buffer) const { - DartAttribute attr = map.template getAttribute(attrName); + DartAttribute attr = map.template getAttribute(attrName); if (!attr.isValid()) attr = map.template addAttribute(attrName); @@ -134,10 +134,10 @@ void UniversalLoader:: UnpackOnHE(MapType& map, const D template void UniversalLoader:: UnpackOnHEFC(MapType& map, const Dart* facesId, const AHEMHeader* hdr, const char* attrName, const void* buffer) const { - DartAttribute attr = map.template getAttribute(attrName); + DartAttribute attr = map.template getAttribute(attrName); if (!attr.isValid()) - attr = map.template addAttribute(attrName); + attr = map.template addAttribute(attrName); char* p = (char*)buffer; diff --git a/CGoGN/include/Algo/Import/import2tablesSurface.hpp b/CGoGN/include/Algo/Import/import2tablesSurface.hpp index f5530adef528995c87e2a834b0cfc5f2d628632c..c49bf6a2c4a202f8ab7ad8f080d27e0ea81f5013 100644 --- a/CGoGN/include/Algo/Import/import2tablesSurface.hpp +++ b/CGoGN/include/Algo/Import/import2tablesSurface.hpp @@ -340,14 +340,14 @@ bool MeshTablesSurface::importOff(const std::string& filename, std::vector< template bool MeshTablesSurface::importVoxellisation(Algo::Surface::Modelisation::Voxellisation& voxellisation, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position"); if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position"); attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.template getAttributeContainer() ; + AttributeContainer& container = m_map.template getAttributeContainer(); // lecture des nombres de sommets/faces m_nbVertices = voxellisation.getNbSommets(); @@ -1623,9 +1623,9 @@ bool MeshTablesSurface::mergeCloseVertices() { typename PFP::VEC3 P = positions[i]; P -= bb.min(); - float pz = floor((P[2]/bbsize[2])*NBV); - float py = floor((P[1]/bbsize[1])*NBV); - float px = floor((P[0]/bbsize[0])*NBV); + typename PFP::REAL pz = floor((P[2] / bbsize[2])*NBV); + typename PFP::REAL py = floor((P[1] / bbsize[1])*NBV); + typename PFP::REAL px = floor((P[0] / bbsize[0])*NBV); unsigned int index = uint32(NBV*NBV*pz + NBV*py + px); diff --git a/CGoGN/include/Algo/Import/importObjTex.h b/CGoGN/include/Algo/Import/importObjTex.h index 2b435712689ea87cefcff722ab67d9a5bd003ac1..47321db42ff1598c93303ed4ccdbc6fa71c8cf53 100644 --- a/CGoGN/include/Algo/Import/importObjTex.h +++ b/CGoGN/include/Algo/Import/importObjTex.h @@ -29,6 +29,7 @@ #include "Topology/generic/cellmarker.h" #include "Utils/textures.h" #include "Geometry/bounding_box.h" +#include "Utils/vbo.h" namespace CGoGN { @@ -171,13 +172,13 @@ public: * @brief set position attribute * @param position attribute */ - void setPositionAttribute(VertexAttribute position); + void setPositionAttribute(VertexAttribute position); /** * @brief set position attribute * @param position attribute */ - void setNormalAttribute(VertexAttribute normal); + void setNormalAttribute(VertexAttribute normal); /** * @brief set texture coordinate attribute @@ -226,13 +227,13 @@ public: * @param browsers vector of MapBrowers representing the groups * @return ok or not */ - bool generateBrowsers(std::vector& browsers); +// bool generateBrowsers(std::vector& browsers); /** * @brief getMaterialNames * @return */ - std::vector& getMaterialNames(); +// std::vector& getMaterialNames(); /** * @brief getMaterialIndex diff --git a/CGoGN/include/Algo/Import/importObjTex.hpp b/CGoGN/include/Algo/Import/importObjTex.hpp index b5d43beef02a24a116a3c14ec359dc209750685e..a7fcc9b1915aa829cb3632f86fb6e85608cf44aa 100644 --- a/CGoGN/include/Algo/Import/importObjTex.hpp +++ b/CGoGN/include/Algo/Import/importObjTex.hpp @@ -25,6 +25,7 @@ #include "Topology/generic/attributeHandler.h" #include "Topology/generic/autoAttributeHandler.h" #include "Container/fakeAttribute.h" + #include #include @@ -84,13 +85,13 @@ inline Geom::Vec2f OBJModel::getTexCoord(Dart d) } template -void OBJModel::setPositionAttribute(VertexAttribute position) +void OBJModel::setPositionAttribute(VertexAttribute position) { m_positions = position; } template -void OBJModel::setNormalAttribute(VertexAttribute normal) +void OBJModel::setNormalAttribute(VertexAttribute normal) { m_normals = normal; } @@ -259,7 +260,7 @@ void OBJModel::readMaterials(const std::string& filename) template unsigned int OBJModel::getMaterialIndex(const std::string& name) const { - std::map::iterator it = m_materialNames.find(name); + std::map::const_iterator it = m_materialNames.find(name); if (it != m_materialNames.end()) return it->second; return 0xffffffff; @@ -363,7 +364,7 @@ unsigned int OBJModel::createSimpleVBO_P(Utils::VBO* positionVBO) } positionVBO->setDataSize(3); - positionVBO->allocate(posBuff.size()); + positionVBO->allocate((unsigned int)(posBuff.size())); Geom::Vec3f* ptrPos = reinterpret_cast(positionVBO->lockPtr()); memcpy(ptrPos,&posBuff[0],posBuff.size()*sizeof(Geom::Vec3f)); positionVBO->releasePtr(); @@ -411,13 +412,13 @@ unsigned int OBJModel::createSimpleVBO_PT(Utils::VBO* positionVBO, Utils::V } positionVBO->setDataSize(3); - positionVBO->allocate(posBuff.size()); + positionVBO->allocate((unsigned int)(posBuff.size())); Geom::Vec3f* ptrPos = reinterpret_cast(positionVBO->lockPtr()); memcpy(ptrPos,&posBuff[0],posBuff.size()*sizeof(Geom::Vec3f)); positionVBO->releasePtr(); texcoordVBO->setDataSize(2); - texcoordVBO->allocate(TCBuff.size()); + texcoordVBO->allocate((unsigned int)(TCBuff.size())); Geom::Vec2f* ptrTC = reinterpret_cast(texcoordVBO->lockPtr()); memcpy(ptrTC,&TCBuff[0],TCBuff.size()*sizeof(Geom::Vec2f)); texcoordVBO->releasePtr(); @@ -430,7 +431,7 @@ unsigned int OBJModel::createSimpleVBO_PN(Utils::VBO* positionVBO, Utils::V { TraversorF traf(m_map); std::vector posBuff; - std::vector normalBuff; + std::vector normalBuff; posBuff.reserve(16384); normalBuff.reserve(16384); @@ -477,13 +478,13 @@ unsigned int OBJModel::createSimpleVBO_PN(Utils::VBO* positionVBO, Utils::V } positionVBO->setDataSize(3); - positionVBO->allocate(posBuff.size()); + positionVBO->allocate((unsigned int)(posBuff.size())); Geom::Vec3f* ptrPos = reinterpret_cast(positionVBO->lockPtr()); memcpy(ptrPos,&posBuff[0],posBuff.size()*sizeof(Geom::Vec3f)); positionVBO->releasePtr(); normalVBO->setDataSize(3); - normalVBO->allocate(normalBuff.size()); + normalVBO->allocate((unsigned int)(normalBuff.size())); Geom::Vec3f* ptrNormal = reinterpret_cast(normalVBO->lockPtr()); memcpy(ptrNormal, &normalBuff[0], normalBuff.size()*sizeof(Geom::Vec3f)); normalVBO->releasePtr(); @@ -724,7 +725,7 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) m_groupFirstSub[outGr] = inSg; } } - m_groupNbSub[outGr+1] = m_sgMat.size() - m_groupNbSub[outGr]; + m_groupNbSub[outGr + 1] = (unsigned int)(m_sgMat.size()) - m_groupNbSub[outGr]; // now create VBOs @@ -733,7 +734,7 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) unsigned int firstIndex = 0; - unsigned int sz = group_faces.size(); + unsigned int sz = (unsigned int)(group_faces.size()); m_beginIndices.resize(sz); m_nbIndices.resize(sz); m_groupIdx.resize(sz); @@ -774,7 +775,7 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) } positionVBO->setDataSize(3); - positionVBO->allocate(posBuff.size()); + positionVBO->allocate((unsigned int)(posBuff.size())); Geom::Vec3f* ptrPos = reinterpret_cast(positionVBO->lockPtr()); memcpy(ptrPos,&posBuff[0],posBuff.size()*sizeof(Geom::Vec3f)); positionVBO->releasePtr(); @@ -974,7 +975,7 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, m_groupFirstSub[outGr] = inSg; } } - m_groupNbSub[outGr+1] = m_sgMat.size() - m_groupNbSub[outGr]; + m_groupNbSub[outGr + 1] = (unsigned int)(m_sgMat.size()) - m_groupNbSub[outGr]; // now create VBOs @@ -985,7 +986,7 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, unsigned int firstIndex = 0; - unsigned int sz = group_faces.size(); + unsigned int sz = (unsigned int)(group_faces.size()); m_beginIndices.resize(sz); m_nbIndices.resize(sz); m_groupIdx.resize(sz); @@ -1044,13 +1045,13 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, } positionVBO->setDataSize(3); - positionVBO->allocate(posBuff.size()); + positionVBO->allocate((unsigned int)(posBuff.size())); Geom::Vec3f* ptrPos = reinterpret_cast(positionVBO->lockPtr()); memcpy(ptrPos,&posBuff[0],posBuff.size()*sizeof(Geom::Vec3f)); positionVBO->releasePtr(); texcoordVBO->setDataSize(2); - texcoordVBO->allocate(TCBuff.size()); + texcoordVBO->allocate((unsigned int)(TCBuff.size())); Geom::Vec2f* ptrTC = reinterpret_cast(texcoordVBO->lockPtr()); memcpy(ptrTC,&TCBuff[0],TCBuff.size()*sizeof(Geom::Vec2f)); texcoordVBO->releasePtr(); @@ -1180,7 +1181,7 @@ bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, m_groupFirstSub[outGr] = inSg; } } - m_groupNbSub[outGr+1] = m_sgMat.size() - m_groupNbSub[outGr]; + m_groupNbSub[outGr + 1] = (unsigned int)(m_sgMat.size()) - m_groupNbSub[outGr]; // now create VBOs @@ -1192,7 +1193,7 @@ bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, unsigned int firstIndex = 0; - unsigned int sz = group_faces.size(); + unsigned int sz = (unsigned int)(group_faces.size()); m_beginIndices.resize(sz); m_nbIndices.resize(sz); m_groupIdx.resize(sz); @@ -1251,13 +1252,13 @@ bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, } positionVBO->setDataSize(3); - positionVBO->allocate(posBuff.size()); + positionVBO->allocate((unsigned int)(posBuff.size())); Geom::Vec3f* ptrPos = reinterpret_cast(positionVBO->lockPtr()); memcpy(ptrPos,&posBuff[0],posBuff.size()*sizeof(Geom::Vec3f)); positionVBO->releasePtr(); normalVBO->setDataSize(3); - normalVBO->allocate(normalBuff.size()); + normalVBO->allocate((unsigned int)(normalBuff.size())); Geom::Vec3f* ptrNormal = reinterpret_cast(normalVBO->lockPtr()); memcpy(ptrNormal, &normalBuff[0], normalBuff.size()*sizeof(Geom::Vec3f)); normalVBO->releasePtr(); @@ -1844,7 +1845,7 @@ bool OBJModel::import( const std::string& filename, std::vector unsigned int OBJModel::storeFacesOfGroup(unsigned int groupId, std::vector& dartFaces) { - unsigned int nb=dartFaces.size(); + unsigned int nb = (unsigned int)(dartFaces.size()); TraversorF traf(m_map); for (Dart d=traf.begin(); d!= traf.end(); d = traf.next()) @@ -1855,7 +1856,7 @@ unsigned int OBJModel::storeFacesOfGroup(unsigned int groupId, std::vector< } } - return dartFaces.size()-nb; + return (unsigned int)(dartFaces.size() - nb); } } // namespace Import diff --git a/CGoGN/include/Algo/LinearSolving/basic.h b/CGoGN/include/Algo/LinearSolving/basic.h index 81b5b9d1dc485ae4352c5e7e7aa809347c2a7e4a..cb6afada03aa99a9f1479e47115d63512ff846b5 100644 --- a/CGoGN/include/Algo/LinearSolving/basic.h +++ b/CGoGN/include/Algo/LinearSolving/basic.h @@ -27,10 +27,14 @@ #include "NL/nl.h" #include "Topology/generic/traversor/traversorCell.h" +#include "Topology/generic/traversor/traversor2.h" namespace CGoGN { +namespace Algo +{ + namespace LinearSolving { @@ -395,7 +399,7 @@ void getResult( { foreach_cell(m, [&] (Dart d) { - attr[d] = nlGetVariable(index[d]) ; + attr[d] = ATTR_TYPE(nlGetVariable(index[d])); }); } @@ -408,12 +412,14 @@ void getResult( { foreach_cell(m, [&] (Dart d) { - (attr[d])[coord] = nlGetVariable(index[d]) ; + (attr[d])[coord] = typename ATTR_TYPE::DATA_TYPE(nlGetVariable(index[d])); }); } } // namespace LinearSolving +} // Algo + } // namespace CGoGN #endif diff --git a/CGoGN/include/Algo/MC/image.h b/CGoGN/include/Algo/MC/image.h index 0f15a12458c6d6373ae5938b116e1af83b9459c5..073136d3f5d807bf875b9ed6794154f0e1a985c7 100644 --- a/CGoGN/include/Algo/MC/image.h +++ b/CGoGN/include/Algo/MC/image.h @@ -25,10 +25,9 @@ #ifndef IMAGE_H #define IMAGE_H - #include "Geometry/vector_gen.h" - #include "Utils/img3D_IO.h" +#include #ifdef CGOGN_WITH_ZINRI #include "Zinrimage.h" @@ -152,12 +151,13 @@ public: template< typename DataTypeIn > void createMask(const Image& img ); +#ifdef CGOGN_WITH_QT /** * Load a file (png) in an empty image * @param _cName file to open */ bool loadPNG3D(const char *_cName); - +#endif /** * Load an ipb-format file in an empty image @@ -165,12 +165,13 @@ public: */ bool loadIPB(const char* _cName); +#ifdef CGOGN_WITH_ZINRI /** * Load an inr.gz format file in an empty image * @param filname file to open */ bool loadInrgz(const char* filename); - +#endif /** * @brief load VTK binary mask image * @param filename @@ -202,12 +203,13 @@ public: */ void loadVox(const char *filename); +#ifdef CGOGN_WITH_ZINRI /** * save current image into file * @param _cName file to save */ void saveInrMask(const char* _cName); - +#endif /** * get the width along X axis */ @@ -313,7 +315,7 @@ public: * @param _lWidth width of filtering * @return the new image */ - Image* filtering(int _lWidth); +// Image* filtering(int _lWidth); /** * add Frame of zero around the image diff --git a/CGoGN/include/Algo/MC/image.hpp b/CGoGN/include/Algo/MC/image.hpp index e818804fe49771a1d02d85a7dcd8005ad78a7ad8..95d9c796cc4b566bfaae37395207d143e0c3c7fa 100644 --- a/CGoGN/include/Algo/MC/image.hpp +++ b/CGoGN/include/Algo/MC/image.hpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include "Utils/cgognStream.h" namespace CGoGN { @@ -515,6 +517,11 @@ DataType* Image::getVoxelPtr(int lX, int lY, int lZ) return m_Data + lX + m_WX*lY + m_WXY*lZ; } +template< typename DataType > +DataType Image::getVoxel(const Geom::Vec3i &V) +{ + return m_Data[V[0] + m_WX*V[1] + m_WXY*V[2]]; +} /* @@ -678,7 +685,7 @@ Image* Image::Blur3() } val += 3.0 * (*ori); val /= (27.0 + 3.0); - DataType res(val); + DataType res = DataType(val); *dest= res; } *(newImg->getVoxelPtr(txm,y,z)) = *(getVoxelPtr(txm,y,z)); @@ -740,11 +747,11 @@ void Image::createMaskOffsetSphere(std::vector& table, int _i32ra float ys = m_SY/smin; float zs = m_SZ/smin; - int radX = ceil(float(_i32radius)/xs); - int radY = ceil(float(_i32radius)/ys); - int radZ = ceil(float(_i32radius)/zs); + int radX = int(ceil(float(_i32radius)/xs)); + int radY = int(ceil(float(_i32radius)/ys)); + int radZ = int(ceil(float(_i32radius)/zs)); - float sRadius = sqrt( double(_i32radius)/xs*double(_i32radius)/xs + double(_i32radius)/ys*double(_i32radius)/ys + double(_i32radius)/zs*double(_i32radius)/zs); + double sRadius = sqrt( double(_i32radius)/xs*double(_i32radius)/xs + double(_i32radius)/ys*double(_i32radius)/ys + double(_i32radius)/zs*double(_i32radius)/zs); // memory allocation // difficult to know how many voxels before computing, @@ -760,7 +767,7 @@ void Image::createMaskOffsetSphere(std::vector& table, int _i32ra for (int x = -radX; x::createNormalSphere(std::vector& table, int _i for (int x = -_i32radius; x<=_i32radius; x++) { Geom::Vec3f v((float)x,(float)y,(float)z); - float fLength = v.normalize(); + double fLength = v.normalize(); // if inside the sphere if (fLength<=_i32radius) table.push_back(v); diff --git a/CGoGN/include/Algo/MC/marchingcube.h b/CGoGN/include/Algo/MC/marchingcube.h index 7064b10e87ef0859d77259b1d3ed0300fad5849b..4fe945edad4c9128cdde9b84d5fe439604f1306d 100644 --- a/CGoGN/include/Algo/MC/marchingcube.h +++ b/CGoGN/include/Algo/MC/marchingcube.h @@ -53,6 +53,7 @@ template class Windowing, typename PF class MarchingCube { protected: + typedef typename PFP::REAL REAL; typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::MAP L_MAP ; typedef Dart L_DART ; @@ -209,7 +210,7 @@ public: * constructor from filename * @param _cName name of file to open */ - MarchingCube(const char* _cName); +// MarchingCube(const char* _cName); /** * constructor from image @@ -217,10 +218,10 @@ public: * @param wind the windowing class (for inside/outside distinguish) * @param boundRemoved true is bound is going to be removed */ - MarchingCube(Image* img, Windowing wind, bool boundRemoved); +// MarchingCube(Image* img, Windowing wind, bool boundRemoved); /** - * constructor from filename + * constructor * @param img voxel image * @param map ptr to the map use to store the mesh * @param idPos id of attribute position diff --git a/CGoGN/include/Algo/MC/marchingcube.hpp b/CGoGN/include/Algo/MC/marchingcube.hpp index fc1206379cfea62f4d716bb8d063bf74d4e359dd..293939a033d2a165b9766dd8a7eaaf024fb4e70d 100644 --- a/CGoGN/include/Algo/MC/marchingcube.hpp +++ b/CGoGN/include/Algo/MC/marchingcube.hpp @@ -37,39 +37,39 @@ namespace Surface namespace MC { -template< typename DataType, template < typename D2 > class Windowing, typename PFP > -MarchingCube::MarchingCube(const char* _cName) -{ - m_Image = new Image(); - - m_Image->loadInr(_cName); // voxel sizes initialized with (1.0,1.0,1.0) - m_Buffer = NULL; - m_map = NULL; - - m_fOrigin = VEC3(0.0,0.0,0.0); - m_fScal = VEC3(1.0,1.0,1.0); - - #ifdef MC_WIDTH_EDGE_Z_EMBEDED - m_currentZSlice = 0; - m_zslice = NULL; - #endif -} - -template< typename DataType, template < typename D2 > class Windowing, typename PFP > -MarchingCube::MarchingCube(Image* img, Windowing wind, bool boundRemoved): - m_Image(img), - m_windowFunc(wind), - m_Buffer(NULL), - m_map(NULL), - m_fOrigin(VEC3(0.0,0.0,0.0)), - m_fScal(VEC3(1.0,1.0,1.0)), - m_brem(boundRemoved) -{ - #ifdef MC_WIDTH_EDGE_Z_EMBEDED - m_currentZSlice = 0; - m_zslice = NULL; - #endif -} +//template< typename DataType, template < typename D2 > class Windowing, typename PFP > +//MarchingCube::MarchingCube(const char* _cName) +//{ +// m_Image = new Image(); +// +// m_Image->loadInr(_cName); // voxel sizes initialized with (1.0,1.0,1.0) +// m_Buffer = NULL; +// m_map = NULL; +// +// m_fOrigin = VEC3(0.0,0.0,0.0); +// m_fScal = VEC3(1.0,1.0,1.0); +// +// #ifdef MC_WIDTH_EDGE_Z_EMBEDED +// m_currentZSlice = 0; +// m_zslice = NULL; +// #endif +//} +// +//template< typename DataType, template < typename D2 > class Windowing, typename PFP > +//MarchingCube::MarchingCube(Image* img, Windowing wind, bool boundRemoved): +// m_Image(img), +// m_windowFunc(wind), +// m_Buffer(NULL), +// m_map(NULL), +// m_fOrigin(VEC3(0.0,0.0,0.0)), +// m_fScal(VEC3(1.0,1.0,1.0)), +// m_brem(boundRemoved) +//{ +// #ifdef MC_WIDTH_EDGE_Z_EMBEDED +// m_currentZSlice = 0; +// m_zslice = NULL; +// #endif +//} template< typename DataType, template < typename D2 > class Windowing, typename PFP > MarchingCube::MarchingCube(Image* img, L_MAP* map, VertexAttribute& position, Windowing wind, bool boundRemoved): @@ -246,7 +246,7 @@ void MarchingCube::simpleMeshing() m_Buffer->nextSlice(); } - CGoGNout << "Taille 2-carte:"<getNbDarts()<<" brins"<getNbDarts()<<" brins"< class Windowing, typename PFP > @@ -478,7 +478,7 @@ void MarchingCube::createPointEdge11(const unsigned ch } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_1(DataType *vox, const int _lX,const int _lY,const int _lZ, unsigned char tag) +void MarchingCube::createFaces_1(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -488,7 +488,9 @@ void MarchingCube::createFaces_1(DataType *vox, const // VEC3 vPos(float(_lX) , float(_lY) , float(_lZ) ); // VEC3 vPos(float(_lX) + 0.5f, float(_lY) + 0.5f, (float)_lZ + 0.5f); - VEC3 vPos(_lX, _lY, _lZ); + + //VEC3 vPos((double)_lX, (double)_lY, (double)_lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices @@ -545,7 +547,7 @@ void MarchingCube::createFaces_2(DataType *vox, const return; unsigned int lVertTable[12]; - VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices int lX = _lX; @@ -596,7 +598,7 @@ void MarchingCube::createFaces_3(DataType *vox, const return; unsigned int lVertTable[12]; - VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices int lX = _lX; @@ -648,7 +650,7 @@ void MarchingCube::createFaces_4(DataType *vox, const return; unsigned int lVertTable[12]; - VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices int lX = _lX; @@ -703,7 +705,7 @@ void MarchingCube::createFaces_5(DataType *vox, const return; unsigned int lVertTable[12]; - VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices int lX = _lX; @@ -756,7 +758,7 @@ void MarchingCube::createFaces_6(DataType *vox, const return; unsigned int lVertTable[12]; - VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices int lX = _lX+1; @@ -814,7 +816,7 @@ void MarchingCube::createFaces_7(DataType *vox, const return; unsigned int lVertTable[12]; - VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices int lX = _lX+1; @@ -872,7 +874,7 @@ void MarchingCube::createFaces_8(DataType *vox, const return; unsigned int lVertTable[12]; - VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos((REAL)_lX, (REAL)_lY, (REAL)_lZ); // create the new vertices int lX = _lX+1; @@ -954,7 +956,7 @@ void MarchingCube::setNeighbour(L_DART d1, L_DART d2) } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int const *_lVertTable, const unsigned short _usMask, float /*curv*/, unsigned char /*tag*/) +void MarchingCube::createLocalFaces(const unsigned char _ucCubeIndex, int _lX, int _lY, int /*_lZ*/, unsigned int const *_lVertTable, const unsigned short _usMask, float /*curv*/, unsigned char /*tag*/) { // TODO parametre _LZ not used => a supprimer ? // TODO parametre curv not used => a supprimer ? @@ -1156,12 +1158,12 @@ void MarchingCube::createLocalFaces(const unsigned cha template< typename DataType, template < typename D2 > class Windowing, typename PFP > void MarchingCube::removeFacesOfBoundary(VertexAttribute& boundVertices, unsigned int frameWidth) { - float xmin = frameWidth; - float xmax = m_Image->getWidthX() - frameWidth -1; - float ymin = frameWidth; - float ymax = m_Image->getWidthY() - frameWidth -1; - float zmin = frameWidth; - float zmax = m_Image->getWidthZ() - frameWidth -1; + float xmin = float(frameWidth); + float xmax = float(m_Image->getWidthX() - frameWidth - 1); + float ymin = float(frameWidth); + float ymax = float(m_Image->getWidthY() - frameWidth - 1); + float zmin = float(frameWidth); + float zmax = float(m_Image->getWidthZ() - frameWidth - 1); // traverse position and create bound attrib for(unsigned int it = m_positions.begin(); it != m_positions.end(); m_positions.next(it)) @@ -1182,7 +1184,7 @@ void MarchingCube::removeFacesOfBoundary(VertexAttribu DartMarker mf(*m_map); for (Dart d = m_map->begin(); d != m_map->end();) // next done inside loop because of deleteFace { - if (!mf.isMarked(d) && !m_map->isBoundaryMarked<2>(d)) + if (!mf.isMarked(d) && !m_map->template isBoundaryMarked<2>(d)) { Dart dd = d; Dart e = m_map->phi1(d); @@ -1193,9 +1195,9 @@ void MarchingCube::removeFacesOfBoundary(VertexAttribu m_map->next(d); } if ((boundVertices[dd]!=0) && (boundVertices[e]!=0) && (boundVertices[f]!=0)) - m_map->deleteFace(dd,false); + m_map->deleteFace(dd); else - mf.markOrbit(dd); + mf.template markOrbit(dd); } else m_map->next(d); } diff --git a/CGoGN/include/Algo/MC/marchingcubeGen.h b/CGoGN/include/Algo/MC/marchingcubeGen.h index 0a19b5c68b7bf1bf7d52bb11234ba1e7b3918ec8..77aed0ed1d0bae1565cfc2a1bc7e22de59cb59d3 100644 --- a/CGoGN/include/Algo/MC/marchingcubeGen.h +++ b/CGoGN/include/Algo/MC/marchingcubeGen.h @@ -55,6 +55,7 @@ template< typename DataType, typename ImgT, template < typename D2 > class Wind class MarchingCubeGen { protected: + typedef typename PFP::VEC3 VEC3; typedef typename PFP::MAP L_MAP; typedef Dart L_DART; @@ -81,7 +82,7 @@ protected: /** * position attribute table */ - VertexAttribute m_positions; + VertexAttribute& m_positions; /** * Origin of image @@ -203,13 +204,13 @@ protected: L_DART createTriEmb(unsigned int e1, unsigned int e2, unsigned int e3); public: - /** - * constructor from image - * @param img voxel image - * @param wind the windowing class (for inside/outside distinguish) - * @param boundRemoved true is bound is going to be removed - */ - MarchingCubeGen(ImgT* img, Windowing wind, bool boundRemoved); + ///** + //* constructor from image + //* @param img voxel image + //* @param wind the windowing class (for inside/outside distinguish) + //* @param boundRemoved true is bound is going to be removed + //*/ + //MarchingCubeGen(ImgT* img, Windowing wind, bool boundRemoved); /** * constructor from filename @@ -218,7 +219,7 @@ public: * @param wind the windowing class (for inside/outside distinguish) * @param boundRemoved true is bound is going to be removed */ - MarchingCubeGen(ImgT* img, L_MAP* map, unsigned int idPos, Windowing wind, bool boundRemoved); + MarchingCubeGen(ImgT* img, L_MAP* map, VertexAttribute& position, Windowing wind, bool boundRemoved); /** * destructor @@ -246,15 +247,15 @@ public: */ ImgT* getImg() { return m_Image; } - /** - * Get the lower corner of bounding AABB - */ - typename PFP::VEC3 boundMin() const { return m_Image->boundMin(); } + ///** + // * Get the lower corner of bounding AABB + // */ + //typename PFP::VEC3 boundMin() const { return m_Image->boundMin(); } - /** - * Get the upper corner of bounding AABB - */ - typename PFP::VEC3 boundMax() const {return m_Image->boundMax();} + ///** + // * Get the upper corner of bounding AABB + // */ + //typename PFP::VEC3 boundMax() const {return m_Image->boundMax();} }; diff --git a/CGoGN/include/Algo/MC/marchingcubeGen.hpp b/CGoGN/include/Algo/MC/marchingcubeGen.hpp index aba8068d951aabfe409b8c3beba13b89c7b7da39..276d41e240783b0533b7d3ca1855e8646e2819c8 100644 --- a/CGoGN/include/Algo/MC/marchingcubeGen.hpp +++ b/CGoGN/include/Algo/MC/marchingcubeGen.hpp @@ -45,32 +45,32 @@ namespace MC // m_Buffer = NULL; // m_map = NULL; // -// m_fOrigin = typename PFP::VEC3(0.0,0.0,0.0); -// m_fScal = typename PFP::VEC3(1.0,1.0,1.0); +// m_fOrigin = VEC3(0.0,0.0,0.0); +// m_fScal = VEC3(1.0,1.0,1.0); // } +// +//template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > +//MarchingCubeGen::MarchingCubeGen(ImgT* img, Windowing wind, bool boundRemoved): +// m_Image(img), +// m_windowFunc(wind), +// m_Buffer(NULL), +// m_map(NULL), +// m_fOrigin(VEC3(0.0,0.0,0.0)), +// m_fScal(VEC3(1.0,1.0,1.0)), +// m_brem(boundRemoved) +//{ +//} template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -MarchingCubeGen::MarchingCubeGen(ImgT* img, Windowing wind, bool boundRemoved): - m_Image(img), - m_windowFunc(wind), - m_Buffer(NULL), - m_map(NULL), - m_fOrigin(typename PFP::VEC3(0.0,0.0,0.0)), - m_fScal(typename PFP::VEC3(1.0,1.0,1.0)), - m_brem(boundRemoved) -{ -} - -template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -MarchingCubeGen::MarchingCubeGen(ImgT* img, L_MAP* map, unsigned int idPos, Windowing wind, bool boundRemoved): +MarchingCubeGen::MarchingCubeGen(ImgT* img, L_MAP* map, VertexAttribute& position, Windowing wind, bool boundRemoved) : m_Image(img), m_windowFunc(wind), m_Buffer(NULL), m_map(map), - m_positions(idPos,*map), - m_fOrigin(typename PFP::VEC3(0.0,0.0,0.0)), - m_fScal(typename PFP::VEC3(1.0,1.0,1.0)), + m_positions(position), + m_fOrigin(VEC3(0.0,0.0,0.0)), + m_fScal(VEC3(1.0,1.0,1.0)), m_brem(boundRemoved) { } @@ -105,18 +105,18 @@ void MarchingCubeGen::deleteMesh() template< typename DataType, typename ImgT, template < typename D2 > class Windowing, typename PFP > -Dart MarchingCube::createTriEmb(unsigned int e1, unsigned int e2, unsigned int e3) +Dart MarchingCubeGen::createTriEmb(unsigned int e1, unsigned int e2, unsigned int e3) { L_DART d = m_map->newFace(3,false); - - FunctorSetEmb fsetemb(*m_map, e1); - m_map->template foreach_dart_of_orbit(d, fsetemb); + + unsigned int vemb = e1; + m_map->template foreach_dart_of_orbit(d, [&](Dart dd) { m_map->template setDartEmbedding(dd, vemb); }); d = m_map->phi1(d); - fsetemb.changeEmb(e2); - m_map->template foreach_dart_of_orbit(d, fsetemb); + vemb = e2; + m_map->template foreach_dart_of_orbit(d, [&](Dart dd) { m_map->template setDartEmbedding(dd, vemb); }); d = m_map->phi1(d); - fsetemb.changeEmb(e3); - m_map->template foreach_dart_of_orbit(d, fsetemb); + vemb = e3; + m_map->template foreach_dart_of_orbit(d, [&](Dart dd) { m_map->template setDartEmbedding(dd, vemb); }); d = m_map->phi1(d); return d; @@ -143,7 +143,7 @@ void MarchingCubeGen::simpleMeshing() // compute value to transform points directly to final system coordinate -/* m_fOrigin = typename PFP::VEC3((float)(m_Image->getOrigin()[0]),(float)(m_Image->getOrigin()[1]),(float)(m_Image->getOrigin()[2]));*/ +/* m_fOrigin = VEC3((float)(m_Image->getOrigin()[0]),(float)(m_Image->getOrigin()[1]),(float)(m_Image->getOrigin()[2]));*/ m_fScal[0] = m_Image->getVoxSizeX(); m_fScal[1] = m_Image->getVoxSizeY(); @@ -226,7 +226,7 @@ void MarchingCubeGen::simpleMeshing() m_Buffer->nextSlice(); } - CGoGNout << "Taille 2-carte:"<size()<<" brins"<getNbDarts() << " brins" << CGoGNendl; } @@ -273,7 +273,7 @@ unsigned char MarchingCubeGen::computeIndex(int template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > typename PFP::VEC3 MarchingCubeGen::recalPoint(const typename PFP::VEC3& _P, const typename PFP::VEC3& _dec ) const { - typename PFP::VEC3 point = _P + _dec ; + VEC3 point = _P + _dec ; point -= m_fOrigin; @@ -287,7 +287,7 @@ typename PFP::VEC3 MarchingCubeGen::recalPoint(c template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge0(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge0(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -295,8 +295,8 @@ void MarchingCubeGen::createPointEdge0(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData(_lX,_lY), m_Buffer->getData(_lX+1,_lY) ); - lVertTable[0] = m_map->newCell(VERTEX); - m_positions[lVertTable[0]] = recalPoint(vPos,typename PFP::VEC3(interp, 0., 0.)); + lVertTable[0] = m_map->template newCell(); + m_positions[lVertTable[0]] = recalPoint(vPos,VEC3(interp, 0., 0.)); m_Buffer->setPointEdge0(_lX, _lY,lVertTable[0]); @@ -306,7 +306,7 @@ void MarchingCubeGen::createPointEdge0(const uns template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge1(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge1(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -314,15 +314,15 @@ void MarchingCubeGen::createPointEdge1(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData(_lX,_lY), m_Buffer->getData(_lX,_lY+1) ); - lVertTable[1] = m_map->newCell(VERTEX); - m_positions[lVertTable[1]] = recalPoint(vPos,typename PFP::VEC3(1.,interp, 0.)); + lVertTable[1] = m_map->template newCell(); + m_positions[lVertTable[1]] = recalPoint(vPos,VEC3(1.,interp, 0.)); m_Buffer->setPointEdge1(_lX, _lY,lVertTable[1]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge2(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge2(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -330,30 +330,30 @@ void MarchingCubeGen::createPointEdge2(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData(_lX-1,_lY), m_Buffer->getData(_lX,_lY) ); - lVertTable[2] = m_map->newCell(VERTEX); - m_positions[lVertTable[2]] = recalPoint(vPos,typename PFP::VEC3(interp, 1., 0.)); + lVertTable[2] = m_map->template newCell(); + m_positions[lVertTable[2]] = recalPoint(vPos,VEC3(interp, 1., 0.)); m_Buffer->setPointEdge2(_lX, _lY,lVertTable[2]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge3(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge3(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 8) { float interp = m_windowFunc.interpole( m_Buffer->getData(_lX,_lY-1), m_Buffer->getData(_lX,_lY-1) ); - lVertTable[3] = m_map->newCell(VERTEX); - m_positions[lVertTable[3]] = recalPoint(vPos,typename PFP::VEC3(0., interp, 0.)); + lVertTable[3] = m_map->template newCell(); + m_positions[lVertTable[3]] = recalPoint(vPos,VEC3(0., interp, 0.)); m_Buffer->setPointEdge3(_lX, _lY,lVertTable[3]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge4(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge4(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -361,15 +361,15 @@ void MarchingCubeGen::createPointEdge4(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData2(_lX,_lY), m_Buffer->getData2(_lX+1,_lY) ); - lVertTable[4] = m_map->newCell(VERTEX); - m_positions[lVertTable[4]] = recalPoint(vPos,typename PFP::VEC3(interp, 0., 1.)); + lVertTable[4] = m_map->template newCell(); + m_positions[lVertTable[4]] = recalPoint(vPos,VEC3(interp, 0., 1.)); m_Buffer->setPointEdge4(_lX, _lY,lVertTable[4]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge5(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge5(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -377,15 +377,15 @@ void MarchingCubeGen::createPointEdge5(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData2(_lX,_lY), m_Buffer->getData2(_lX,_lY+1) ); - lVertTable[5] = m_map->newCell(VERTEX); - m_positions[lVertTable[5]] = recalPoint(vPos,typename PFP::VEC3(1., interp, 1.)); + lVertTable[5] = m_map->template newCell(); + m_positions[lVertTable[5]] = recalPoint(vPos,VEC3(1., interp, 1.)); m_Buffer->setPointEdge5(_lX, _lY,lVertTable[5]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge6(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge6(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -393,15 +393,15 @@ void MarchingCubeGen::createPointEdge6(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData2(_lX-1,_lY), m_Buffer->getData2(_lX,_lY) ); - lVertTable[6] = m_map->newCell(VERTEX); - m_positions[lVertTable[6]] = recalPoint(vPos,typename PFP::VEC3(interp, 1., 1.)); + lVertTable[6] = m_map->template newCell(); + m_positions[lVertTable[6]] = recalPoint(vPos,VEC3(interp, 1., 1.)); m_Buffer->setPointEdge6(_lX, _lY,lVertTable[6]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge7(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge7(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -409,8 +409,8 @@ void MarchingCubeGen::createPointEdge7(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData2(_lX,_lY-1), m_Buffer->getData2(_lX,_lY) ); - lVertTable[7] = m_map->newCell(VERTEX); - m_positions[lVertTable[7]] = recalPoint(vPos,typename PFP::VEC3(0., interp, 1.)); + lVertTable[7] = m_map->template newCell(); + m_positions[lVertTable[7]] = recalPoint(vPos,VEC3(0., interp, 1.)); m_Buffer->setPointEdge7(_lX, _lY,lVertTable[7]); } } @@ -418,7 +418,7 @@ void MarchingCubeGen::createPointEdge7(const uns template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge8(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge8(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -426,15 +426,15 @@ void MarchingCubeGen::createPointEdge8(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData2(_lX,_lY), m_Buffer->getData2(_lX,_lY) ); - lVertTable[8] = m_map->newCell(VERTEX); - m_positions[lVertTable[8]] = recalPoint(vPos,typename PFP::VEC3(0., 0., interp)); + lVertTable[8] = m_map->template newCell(); + m_positions[lVertTable[8]] = recalPoint(vPos,VEC3(0., 0., interp)); m_Buffer->setPointEdge8(_lX, _lY,lVertTable[8]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge9(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge9(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -442,15 +442,15 @@ void MarchingCubeGen::createPointEdge9(const uns { float interp = m_windowFunc.interpole( m_Buffer->getData2(_lX,_lY), m_Buffer->getData2(_lX,_lY+1) ); - lVertTable[9] = m_map->newCell(VERTEX); - m_positions[lVertTable[9]] = recalPoint(vPos,typename PFP::VEC3(1., 0., interp)); + lVertTable[9] = m_map->template newCell(); + m_positions[lVertTable[9]] = recalPoint(vPos,VEC3(1., 0., interp)); m_Buffer->setPointEdge9(_lX, _lY,lVertTable[9]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge10(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge10(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -458,15 +458,15 @@ void MarchingCubeGen::createPointEdge10(const un { float interp = m_windowFunc.interpole( m_Buffer->getData(_lX,_lY), m_Buffer->getData2(_lX,_lY) ); - lVertTable[10] = m_map->newCell(VERTEX); - m_positions[lVertTable[10]] = recalPoint(vPos,typename PFP::VEC3(1., 1., interp)); + lVertTable[10] = m_map->template newCell(); + m_positions[lVertTable[10]] = recalPoint(vPos,VEC3(1., 1., interp)); m_Buffer->setPointEdge10(_lX, _lY,lVertTable[10]); } } template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createPointEdge11(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCubeGen::createPointEdge11(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int* const lVertTable, const typename PFP::VEC3& vPos) { // TODO parametre _LZ not used => a supprimer ? @@ -474,8 +474,8 @@ void MarchingCubeGen::createPointEdge11(const un { float interp = m_windowFunc.interpole( m_Buffer->getData(_lX,_lY), m_Buffer->getData2(_lX,_lY) ); - lVertTable[11] = m_map->newCell(VERTEX); - m_positions[lVertTable[11]] = recalPoint(vPos,typename PFP::VEC3(0., 1., interp)); + lVertTable[11] = m_map->template newCell(); + m_positions[lVertTable[11]] = recalPoint(vPos,VEC3(0., 1., interp)); m_Buffer->setPointEdge11(_lX, _lY,lVertTable[11]); } } @@ -503,7 +503,7 @@ void MarchingCubeGen::createFaces_1(const int _l unsigned int lVertTable[12]; - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices @@ -571,8 +571,8 @@ void MarchingCubeGen::createFaces_2(const int _l return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices int lX = _lX; @@ -635,8 +635,8 @@ void MarchingCubeGen::createFaces_3(const int _l return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices int lX = _lX; @@ -695,8 +695,8 @@ void MarchingCubeGen::createFaces_4(const int _l return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices int lX = _lX; @@ -760,8 +760,8 @@ void MarchingCubeGen::createFaces_5(const int _l return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices int lX = _lX; @@ -821,8 +821,8 @@ void MarchingCubeGen::createFaces_6(const int _l return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices int lX = _lX+1; @@ -885,8 +885,8 @@ void MarchingCubeGen::createFaces_7(const int _l return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices int lX = _lX+1; @@ -948,8 +948,8 @@ void MarchingCubeGen::createFaces_8(const int _l return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); + VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); // create the new vertices int lX = _lX+1; @@ -1023,7 +1023,7 @@ void MarchingCubeGen::setNeighbour(L_DART d1, L_ template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int const *_lVertTable, const unsigned short _usMask, float curv, unsigned char tag) +void MarchingCubeGen::createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int /*_lZ*/, unsigned int const *_lVertTable, const unsigned short _usMask, float /*curv*/, unsigned char /*tag*/) { // TODO parametre _LZ not used => a supprimer ? // TODO parametre curv not used => a supprimer ? diff --git a/CGoGN/include/Algo/MC/windowing.h b/CGoGN/include/Algo/MC/windowing.h index 106481817e40f820683feaa9da5b01bb2de19629..8cb6b060dce9a94f8d90d6d0b17c7eb4cd121032 100644 --- a/CGoGN/include/Algo/MC/windowing.h +++ b/CGoGN/include/Algo/MC/windowing.h @@ -48,7 +48,6 @@ namespace MC * Windowing derived classes are used as template, * and minimum interface are function * - inside - * - insideWich * - interpole * */ @@ -111,14 +110,6 @@ public: */ WindowingEqual(const WindowingEqual& wind) : WindowingClass(wind) {} - /** - * @return a label corresponding to value - * @param val voxel value - * @return label - */ - int16 insideWich(DataType val) const { - return static_cast(val); - } /** * @return true if voxel is inside the object @@ -132,7 +123,7 @@ public: * @param val1 voxel first value * @param val2 voxel second value */ - float interpole(DataType val1, DataType val2) const { + float interpole(DataType /*val1*/, DataType /*val2*/) const { return 0.5f; } }; @@ -153,14 +144,7 @@ public: */ WindowingDiff(const WindowingDiff& wind) : WindowingClass(wind) {} - /** - * @return a label corresponding to value - * @param val voxel value - * @return label - */ - int16 insideWich(DataType val) const { - return static_cast(val); - } + /** * @return true if voxel is inside the object @@ -195,14 +179,6 @@ public: */ WindowingGreater(const WindowingGreater& wind) : WindowingClass(wind) {} - /** - * @return a label corresponding to value - * @param val voxel value - * @return label - */ - int16 insideWich(DataType val) const { - return static_cast(val); - } /** * @return true if voxel is inside the object @@ -237,14 +213,6 @@ public: */ WindowingLess(const WindowingLess& wind) : WindowingClass(wind) {} - /** - * @return a label corresponding to value - * @param val voxel value - * @return label - */ - int16 insideWich(DataType val) const { - return static_cast(val); - } /** * @return true if voxel is inside the object @@ -280,14 +248,6 @@ public: */ WindowingInterval(const WindowingInterval& wind) : WindowingClass(wind) {} - /** - * @return a label corresponding to value - * @param val voxel value - * @return label - */ - int16 insideWich(DataType val) const { - return static_cast(val); - } /** * @return true if voxel is inside the object diff --git a/CGoGN/include/Algo/Modelisation/extrusion.hpp b/CGoGN/include/Algo/Modelisation/extrusion.hpp index 21822fd60520bd16f7df72b685d8ac7111c9514c..fe5578f95aced7408e84167b2310e360ab1257fb 100644 --- a/CGoGN/include/Algo/Modelisation/extrusion.hpp +++ b/CGoGN/include/Algo/Modelisation/extrusion.hpp @@ -48,9 +48,10 @@ Algo::Surface::Tilings::Tiling* revolution_prim( int nbSides) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; // find circle center - float k = (axis * (center-profile[0])) / (axis*axis); + REAL k = (axis * (center - profile[0])) / (axis*axis); VEC3 circCenter = center + k*axis; // compute vector base plane for the circle @@ -64,7 +65,7 @@ Algo::Surface::Tilings::Tiling* revolution_prim( path.reserve(nbSides); for(int i=0; i< nbSides; ++i) { - float alpha = float(2.0*M_PI/nbSides*i); + REAL alpha = REAL(2.0*M_PI / nbSides*i); VEC3 P = circCenter + cos(alpha)*V + sin(alpha)*U; path.push_back(P); } @@ -152,6 +153,10 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim( bool path_closed, const std::vector& scalePath) { + + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + // topological creation Algo::Surface::Tilings::Tiling* prim; @@ -188,23 +193,23 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim( glPushMatrix(); // embedding std::vector& vertD = prim->getVertexDarts(); - typename PFP::VEC3 normalObj(normal); + VEC3 normalObj(normal); normalObj.normalize(); // put profile at the beginning of path - std::vector localObj; + std::vector localObj; localObj.reserve(profile.size()); - for(typename std::vector::const_iterator ip=profile.begin(); ip!=profile.end(); ++ip) + for(typename std::vector::const_iterator ip=profile.begin(); ip!=profile.end(); ++ip) { - typename PFP::VEC3 P = *ip + path[0] - centerProfile; + VEC3 P = *ip + path[0] - centerProfile; localObj.push_back(P); } int index=0; for(unsigned int i=0; i* extrusion_scale_prim( } else { - typename PFP::VEC3 V1 = path[0] - path[i]; - typename PFP::VEC3 V2 = path[i] - path[i-1]; + VEC3 V1 = path[0] - path[i]; + VEC3 V2 = path[i] - path[i-1]; V1.normalize(); V2.normalize(); // vector on path @@ -239,8 +244,8 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim( } else // middle nodes { - typename PFP::VEC3 V1 = path[i+1] - path[i]; - typename PFP::VEC3 V2 = path[i] - path[i-1]; + VEC3 V1 = path[i+1] - path[i]; + VEC3 V2 = path[i] - path[i-1]; V1.normalize(); V2.normalize(); @@ -254,15 +259,15 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim( } // computing angle of rotation - float pscal = normalObj*VP; - float asinAlpha = rot.normalize(); - float alpha; + REAL pscal = normalObj*VP; + REAL asinAlpha = REAL(rot.normalize()); + REAL alpha; if (pscal>=0) - alpha = asin(asinAlpha); + alpha = std::asin(asinAlpha); else - alpha = float(M_PI) - asin(asinAlpha); + alpha = REAL(M_PI) - std::asin(asinAlpha); // creation of transformation matrix - Geom::Matrix44f transf; + Geom::Matrix<4,4,REAL> transf; transf.identity(); if (alpha>0.00001f) { @@ -273,7 +278,7 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim( CGoGNout << "PATH: "<< i<< CGoGNendl; // apply transfo on object to embed Polyhedron. - for(typename std::vector::iterator ip = localObj.begin(); ip != localObj.end(); ++ip) + for(typename std::vector::iterator ip = localObj.begin(); ip != localObj.end(); ++ip) { if (i!=0) //exept for first point of path { @@ -284,7 +289,7 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim( unsigned int em = the_map.template newCell(); // positions[em] = (*ip); - typename PFP::VEC3 P = (*ip); //positions.at(em); + VEC3 P = (*ip); //positions.at(em); if (!scalePath.empty()) P = path[i] + (scalePath[i]*(P-path[i])); @@ -292,12 +297,12 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim( CGoGNout << "P: "<< P<< CGoGNendl; // compute the scale factor for angle deformation - float coef = 1.0f/(float(sin(M_PI/2.0f - alpha))); // warning here is angle/2 but alpha is half of angle we want to use + REAL coef = 1.0f / (REAL(sin(M_PI / 2.0f - alpha))); // warning here is angle/2 but alpha is half of angle we want to use if (fabs(coef-1.0f)>0.00001f) { // projection of path point on plane define par P and the rot vector - float k = (rot*(P-path[i])) / (rot*rot); - typename PFP::VEC3 X = path[i] + k*rot; + REAL k = (rot*(P - path[i])) / (rot*rot); + VEC3 X = path[i] + k*rot; //and scale in the plane position[em] = X + coef*(P-X); } diff --git a/CGoGN/include/Algo/Modelisation/planeCutting.hpp b/CGoGN/include/Algo/Modelisation/planeCutting.hpp index 0b22bea4bcca12c2aff5024b72340779ec0bb8dd..025cb6d5b3ca9675636cb9a0feaac51f2f3d28e8 100644 --- a/CGoGN/include/Algo/Modelisation/planeCutting.hpp +++ b/CGoGN/include/Algo/Modelisation/planeCutting.hpp @@ -1,3 +1,33 @@ +/******************************************************************************* +* 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 * +* * +*******************************************************************************/ + +#include "Topology/generic/autoAttributeHandler.h" +#include "Topology/generic/cellmarker.h" +#include "Topology/generic/traversor/traversorCell.h" +#include "Algo/Modelisation/triangulation.h" + + namespace CGoGN { @@ -267,6 +297,7 @@ void planeCut2( bool with_unsew) { typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; typedef typename PFP::REAL REAL; //marker for vertices on the plane diff --git a/CGoGN/include/Algo/Modelisation/polyhedron.h b/CGoGN/include/Algo/Modelisation/polyhedron.h index 278fdb70b53a07785a56895456df5edb58b8fa8a..2f41633e73e2650268b643c841eabcd0c8f9dbb0 100644 --- a/CGoGN/include/Algo/Modelisation/polyhedron.h +++ b/CGoGN/include/Algo/Modelisation/polyhedron.h @@ -137,7 +137,7 @@ template bool isPrism(typename PFP::MAP& map, Dart d); template -bool isHexahedron(typename PFP::MAP& the_map, Dart d, unsigned int thread=0); +bool isHexahedron(typename PFP::MAP& the_map, Dart d); template Dart embedPrism(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height); diff --git a/CGoGN/include/Algo/Modelisation/polyhedron.hpp b/CGoGN/include/Algo/Modelisation/polyhedron.hpp index d893f90e508ef6473d84f7ca69b9146142e6f837..d8a8d73a1c7d71d5e18166114e0657f4c07fb0ff 100644 --- a/CGoGN/include/Algo/Modelisation/polyhedron.hpp +++ b/CGoGN/include/Algo/Modelisation/polyhedron.hpp @@ -22,6 +22,8 @@ * * *******************************************************************************/ +#include "Topology/generic/traversor/traversor3.h" + namespace CGoGN { @@ -416,12 +418,12 @@ bool isPrism(typename PFP::MAP& map, Dart d) } template -bool isHexahedron(typename PFP::MAP& the_map, Dart d, unsigned int thread) +bool isHexahedron(typename PFP::MAP& the_map, Dart d) { unsigned int nbFaces = 0; //Test the number of faces end its valency - Traversor3WF travWF(the_map, d, false, thread); + Traversor3WF travWF(the_map, d, false); for(Dart dit = travWF.begin() ; dit != travWF.end(); dit = travWF.next()) { //increase the number of faces diff --git a/CGoGN/include/Algo/Modelisation/subdivision.h b/CGoGN/include/Algo/Modelisation/subdivision.h index d5d092893f438355441c80a53c774599eb216c4e..7ee54f69e403677391f899bba036189f29da6c26 100644 --- a/CGoGN/include/Algo/Modelisation/subdivision.h +++ b/CGoGN/include/Algo/Modelisation/subdivision.h @@ -53,7 +53,7 @@ Dart trianguleFace(typename PFP::MAP& map, Dart d); /** * Triangule all the faces of the mesh */ -template +template void trianguleFaces(typename PFP::MAP& map, EMBV& attributs) ; //template @@ -82,7 +82,7 @@ Dart quadranguleFace(typename PFP::MAP& map, Dart d); /** * Quadrangule all the faces of the mesh */ -template +template void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs) ; //template @@ -161,6 +161,8 @@ void LoopSubdivisionAttribName(typename PFP::MAP& map, const std::string& nameAt case CGoGNVEC4D: return LoopSubdivisionAttribNameTyped(map,nameAttrib); break; + default: + break; } CGoGNerr << "LoopSubdivision not supported on attribute "<< nameAttrib << CGoGNendl; } @@ -171,7 +173,7 @@ void LoopSubdivisionAttribName(typename PFP::MAP& map, const std::string& nameAt * Cut 1 face of degree n in 2n+1 faces (cut 2 times each edge and "insert" a face in the middle) * @param size indicates where to cut edges, its value must stay between 0 and 0.5 excluded */ -template +template void TwoNPlusOneSubdivision(typename PFP::MAP& map, EMBV& attributs, float size=1.0f/3.0f) ; /** diff --git a/CGoGN/include/Algo/Modelisation/subdivision.hpp b/CGoGN/include/Algo/Modelisation/subdivision.hpp index 8f4d35bbc649b6adfe36f92519ca4a3409cbeec8..5ce5d0cff37d003fb54101888dee28799a921cce 100644 --- a/CGoGN/include/Algo/Modelisation/subdivision.hpp +++ b/CGoGN/include/Algo/Modelisation/subdivision.hpp @@ -709,7 +709,7 @@ void LoopSubdivision(typename PFP::MAP& map, EMBV& attributs) { double beta = betaF(n) ; temp *= (beta / double(n)); - emcp *= (1.0 - beta); + emcp *= (1.0f - beta); emcp += temp; } attributs[*vert] = emcp; @@ -801,8 +801,8 @@ void TwoNPlusOneSubdivision(typename PFP::MAP& map, EMBV& attributs, float size) map.cutEdge(map.phi1(dd)); mCorner.mark(map.phi2(map.phi1(dd))); // attributs[map.template phi<11>(dd)] = c*(1.0-size)+ attributs[dd]*size; - attributs[map.template phi<11>(dd)] = attributs[dd] + Geometry::vectorOutOfDart(map,dd,attributs) - - Geometry::vectorOutOfDart(map,map.phi_1(dd),attributs); + attributs[map.template phi<11>(dd)] = attributs[dd] + Algo::Geometry::vectorOutOfDart(map,dd,attributs) + - Algo::Geometry::vectorOutOfDart(map,map.phi_1(dd),attributs); dd = map.phi1(map.phi1(map.phi1(map.phi2(map.phi1(dd))))); } while(!mCorner.isMarked(dd)); } @@ -821,6 +821,8 @@ void TwoNPlusOneSubdivision(typename PFP::MAP& map, EMBV& attributs, float size) } + +// remark do not compil with GMap ! template void DooSabin(typename PFP::MAP& map, EMBV& position) { @@ -895,7 +897,7 @@ void DooSabin(typename PFP::MAP& map, EMBV& position) for (std::vector::iterator di=faces.begin(); di != faces.end(); ++di) { Dart e = *di; - typename PFP::VEC3 center = Geometry::faceCentroid(map,e,position); +// typename PFP::VEC3 center = Geometry::faceCentroid(map,e,position); do { @@ -904,7 +906,7 @@ void DooSabin(typename PFP::MAP& map, EMBV& position) e = map.phi1(e); }while (e != * di); - int N = buffer.size(); + int N = int(buffer.size()); for (int i = 0; i < N; ++i) { EMB P(0); @@ -912,12 +914,12 @@ void DooSabin(typename PFP::MAP& map, EMBV& position) { if (j==i) { - /*float*/typename PFP::REAL c1 = double(N+5)/double(4*N); + /*float*/typename PFP::REAL c1 = typename PFP::REAL(double(N + 5) / double(4 * N)); P += buffer[j]*c1; } else { - /*float*/typename PFP::REAL c2 = (3.0+2.0*cos(2.0*M_PI*(double(i-j))/double(N))) /(4.0*N); + /*float*/typename PFP::REAL c2 = typename PFP::REAL((3.0 + 2.0*std::cos(2.0*M_PI*(double(i - j)) / double(N))) / (4.0*N)); P+= c2*buffer[j]; } } diff --git a/CGoGN/include/Algo/Modelisation/subdivision3.hpp b/CGoGN/include/Algo/Modelisation/subdivision3.hpp index 9237bc8e5de0c7483e5b80192c50254ec7751285..68bd2c0dd34a8bafa00c907ff3fe29f932a48ff6 100644 --- a/CGoGN/include/Algo/Modelisation/subdivision3.hpp +++ b/CGoGN/include/Algo/Modelisation/subdivision3.hpp @@ -29,6 +29,7 @@ #include "NL/nl.h" //#include "Algo/LinearSolving/basic.h" #include "Algo/Geometry/laplacian.h" +#include "Algo/Topo/basic.h" namespace CGoGN { @@ -142,7 +143,7 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute(map,dd,position)); + VEC3 vec(Algo::Geometry::vectorOutOfDart(map,dd,position)); Geom::Intersection inter = Geom::intersectionLinePlane >(position[dd],vec,pl,interP); if(inter==Geom::FACE_INTERSECTION) @@ -709,7 +710,7 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute(ditWF); + m.template markOrbit(ditWF); } VEC3 volCenter(0.0); @@ -731,7 +732,7 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute(dit); + m.template unmarkOrbit(dit); Volume::Modelisation::Tetrahedralization::swap2To3(map, dit); } } @@ -742,13 +743,14 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute tWb(map); for(Dart dit = tWb.begin() ; dit != tWb.end() ; dit = tWb.next()) { - if(map.isBoundaryAdjacentVolume(dit)) +// if(map.isBoundaryAdjacentVolume(dit)) + if (map.isVolumeIncidentToBoundary(dit)) { Traversor3WE tWE(map, dit); for(Dart ditWE = tWE.begin() ; ditWE != tWE.end() ; ditWE = tWE.next()) { if(map.isBoundaryEdge(ditWE) && !m.isMarked(ditWE)) - m.markOrbit(ditWE); + m.template markOrbit(ditWE); } VEC3 faceCenter(0.0); @@ -760,7 +762,7 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute(map, dit); position[dres] = faceCenter; - newBoundaryV.markOrbit(dres); + newBoundaryV.template markOrbit(dres); } } @@ -904,12 +906,13 @@ void relaxation(typename PFP::MAP& map, VertexAttribute indexV = map.template getAttribute("indexV"); + VertexAttribute indexV = map.template getAttribute("indexV"); if(!indexV.isValid()) - indexV = map.template addAttribute("indexV"); + indexV = map.template addAttribute("indexV"); - unsigned int nb_vertices = map.template computeIndexCells(indexV); + unsigned int nb_vertices = Algo::Topo::computeIndexCells(map, indexV); //uniform weight float weight = 1.0; @@ -979,7 +982,7 @@ void relaxation(typename PFP::MAP& map, VertexAttribute tv3(map); for(Dart dit = tv3.begin() ; dit != tv3.end() ; dit = tv3.next()) { - position[dit][coord] = nlGetVariable(indexV[dit]); + position[dit][coord] = REAL(nlGetVariable(indexV[dit])); } nlReset(NL_TRUE) ; @@ -996,9 +999,9 @@ void computeDual(typename PFP::MAP& map, VertexAttribute after dual new VertexAttribute - VolumeAttribute positionV = map.template getAttribute("position") ; + VolumeAttribute positionV = map.template getAttribute("position") ; if(!positionV.isValid()) - positionV = map.template addAttribute("position") ; + positionV = map.template addAttribute("position") ; // Compute Centroid for the volumes Algo::Volume::Geometry::computeCentroidVolumes(map, position, positionV) ; diff --git a/CGoGN/include/Algo/Modelisation/tetrahedralization.h b/CGoGN/include/Algo/Modelisation/tetrahedralization.h index e400c52dceb4431d34386082fb8b346d5d055add..4dfdb4803e4d26b774b72ddbe4c3a4f360fbe589 100644 --- a/CGoGN/include/Algo/Modelisation/tetrahedralization.h +++ b/CGoGN/include/Algo/Modelisation/tetrahedralization.h @@ -51,6 +51,7 @@ class EarTriangulation { typedef typename PFP::MAP MAP ; typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; protected: // forward declaration @@ -65,13 +66,13 @@ protected: { public: Dart dart; - float angle; - float length; + REAL angle; + REAL length; VertexPoly() {} - VertexPoly(Dart d, float v, float l) : dart(d), angle(v), length(l) + VertexPoly(Dart d, REAL v, REAL l) : dart(d), angle(v), length(l) {} bool operator()(const VertexPoly& vp1, const VertexPoly& vp2) @@ -97,7 +98,7 @@ protected: void recompute2Ears(Dart d, const VEC3& normalPoly, bool convex); - float computeEarInit(Dart d, const VEC3& normalPoly, float& val); + REAL computeEarInit(Dart d, const VEC3& normalPoly, REAL& val); public: @@ -152,7 +153,7 @@ Dart splitVertex(typename PFP::MAP& map, std::vector& vd); * */ template -bool isTetrahedron(typename PFP::MAP& map, Dart d); +bool isTetrahedron(typename PFP::MAP& map, Vol d); //! /*! diff --git a/CGoGN/include/Algo/Modelisation/tetrahedralization.hpp b/CGoGN/include/Algo/Modelisation/tetrahedralization.hpp index d0d0b343512f093550d165f68d9e0eac0d7cc7a5..9c82588fa41790ba3431d993e5c84bc496ad9ff2 100644 --- a/CGoGN/include/Algo/Modelisation/tetrahedralization.hpp +++ b/CGoGN/include/Algo/Modelisation/tetrahedralization.hpp @@ -83,8 +83,8 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no // float dotpr1 = 1.0f - (v1*v2); // float dotpr2 = 1.0f + (v1*v3); - float dotpr1 = acos(v1*v2) / (M_PI/2.0f); - float dotpr2 = acos(-(v1*v3)) / (M_PI/2.0f); + REAL dotpr1 = std::acos(v1*v2) / REAL(M_PI / 2.0f); + REAL dotpr2 = std::acos(-(v1*v3)) / REAL(M_PI/2.0f); if (!convex) // if convex no need to test if vertex is an ear (yes) { @@ -114,7 +114,7 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no } } - float length = (Tb-Tc).norm2(); + REAL length = (Tb - Tc).norm2(); m_dartEars[d2] = m_ears.insert(VertexPoly(d2,dotpr1,length)); length = (Td-Ta).norm2(); @@ -122,7 +122,7 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no } template -float EarTriangulation::computeEarInit(Dart d, const typename PFP::VEC3& normalPoly, float& val) +typename PFP::REAL EarTriangulation::computeEarInit(Dart d, const typename PFP::VEC3& normalPoly, REAL& val) { Dart e = m_map.phi1(d); Dart f = m_map.phi1(e); @@ -137,7 +137,7 @@ float EarTriangulation::computeEarInit(Dart d, const typename PFP::VEC3& no v2.normalize(); // val = 1.0f - (v1*v2); - val = acos(v1*v2) / (M_PI/2.0f); + val = std::acos(v1*v2) / REAL(M_PI / 2.0f); typename PFP::VEC3 vn = v1^v2; if (vn*normalPoly > 0.0f) @@ -181,8 +181,8 @@ void EarTriangulation::trianguleFace(Dart d) do { - float val; - float length = computeEarInit(a,normalPoly,val); + REAL val; + REAL length = computeEarInit(a, normalPoly, val); a = m_map.phi1(a); // phi here because ears is next of a m_dartEars[a] = m_ears.insert(VertexPoly(a,val,length)); if (length!=0) diff --git a/CGoGN/include/Algo/Modelisation/triangulation.h b/CGoGN/include/Algo/Modelisation/triangulation.h index 78b2d49cea215d5ebcd447f850dd6c0283ba3e18..689266e6e7bab46180905ca9ca9dcae9bd9314c1 100644 --- a/CGoGN/include/Algo/Modelisation/triangulation.h +++ b/CGoGN/include/Algo/Modelisation/triangulation.h @@ -51,6 +51,7 @@ class EarTriangulation { typedef typename PFP::MAP MAP ; typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; protected: // forward declaration @@ -65,13 +66,13 @@ protected: { public: Dart dart; - float angle; - float length; + REAL angle; + REAL length; VertexPoly() {} - VertexPoly(Dart d, float v, float l) : dart(d), angle(v), length(l) + VertexPoly(Dart d, REAL v, REAL l) : dart(d), angle(v), length(l) {} bool operator()(const VertexPoly& vp1, const VertexPoly& vp2) @@ -95,7 +96,7 @@ protected: void recompute2Ears(Dart d, const VEC3& normalPoly, bool convex); - float computeEarInit(Dart d, const VEC3& normalPoly, float& val); + REAL computeEarInit(Dart d, const VEC3& normalPoly, REAL& val); public: diff --git a/CGoGN/include/Algo/Modelisation/triangulation.hpp b/CGoGN/include/Algo/Modelisation/triangulation.hpp index 698cfdb26155396d726137ac19d63755ece42f6d..3c9abc7140ed8971cf878de76d24d96ea4d650e1 100644 --- a/CGoGN/include/Algo/Modelisation/triangulation.hpp +++ b/CGoGN/include/Algo/Modelisation/triangulation.hpp @@ -56,6 +56,7 @@ template void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& normalPoly, bool convex) { typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; Dart d2 = m_map.phi_1(d); Dart d_p = m_map.phi_1(d2); @@ -77,8 +78,8 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no // float dotpr1 = 1.0f - (v1*v2); // float dotpr2 = 1.0f + (v1*v3); - float dotpr1 = acos(v1*v2) / (M_PI/2.0f); - float dotpr2 = acos(-(v1*v3)) / (M_PI/2.0f); + REAL dotpr1 = std::acos(v1*v2) / REAL(M_PI / 2.0f); + REAL dotpr2 = std::acos(-(v1*v3)) / REAL(M_PI / 2.0f); if (!convex) // if convex no need to test if vertex is an ear (yes) { @@ -108,7 +109,7 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no } } - float length = (Tb-Tc).norm2(); + REAL length = (Tb - Tc).norm2(); m_dartEars[d2] = m_ears.insert(VertexPoly(d2,dotpr1,length)); length = (Td-Ta).norm2(); @@ -116,7 +117,7 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no } template -float EarTriangulation::computeEarInit(Dart d, const typename PFP::VEC3& normalPoly, float& val) +typename PFP::REAL EarTriangulation::computeEarInit(Dart d, const typename PFP::VEC3& normalPoly, REAL& val) { typedef typename PFP::VEC3 VEC3 ; @@ -133,7 +134,7 @@ float EarTriangulation::computeEarInit(Dart d, const typename PFP::VEC3& no v2.normalize(); // val = 1.0f - (v1*v2); - val = acos(v1*v2) / (M_PI/2.0f); + val = std::acos(v1*v2) / REAL(M_PI / 2.0f); VEC3 vn = v1^v2; if (vn*normalPoly > 0.0f) @@ -177,8 +178,8 @@ void EarTriangulation::trianguleFace(Dart d) do { - float val; - float length = computeEarInit(a,normalPoly,val); + REAL val; + REAL length = computeEarInit(a, normalPoly, val); a = m_map.phi1(a); // phi here because ears is next of a m_dartEars[a] = m_ears.insert(VertexPoly(a,val,length)); if (length!=0) diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2D.h b/CGoGN/include/Algo/MovingObjects/particle_cell_2D.h index a083134833bbbf618d1ae89e61199a61cace543b..3e45a83bb76b435185e1cdd7e8b34934f26f1e77 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2D.h +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2D.h @@ -36,18 +36,19 @@ class ParticleCell2D : public Algo::MovingObjects::ParticleBase public: typedef typename PFP::MAP MAP ; typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL; typedef VertexAttribute TAB_POS ; MAP& m ; - const TAB_POS& positionAttribut ; + /*const*/ TAB_POS& positionAttribut ; Dart d ; Dart lastCrossed ; unsigned int crossCell ; - ParticleCell2D(MAP& map, Dart belonging_cell, const VEC3& pos, const TAB_POS& tabPos) : + ParticleCell2D(MAP& map, Dart belonging_cell, const VEC3& pos, /*const*/ TAB_POS& tabPos) : Algo::MovingObjects::ParticleBase(pos), m(map), positionAttribut(tabPos), diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2D.hpp b/CGoGN/include/Algo/MovingObjects/particle_cell_2D.hpp index f72c6c6cfd8f4c146cd84c4593372a73d5acf312..b231bec6e33646db40817649e9af0e6ccaae43d3 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2D.hpp +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2D.hpp @@ -24,6 +24,8 @@ //#define DEBUG +#include "Geometry/vector_gen.h" + namespace CGoGN { @@ -99,7 +101,7 @@ void ParticleCell2D::vertexState(const VEC3& goal) #ifdef DEBUG CGoGNout << "vertexState" << d << CGoGNendl ; #endif - assert(goal.isFinite()) ; + assert(Geom::isFinite(goal)) ; crossCell = CROSS_OTHER ; @@ -195,7 +197,7 @@ void ParticleCell2D::edgeState(const VEC3& goal, Geom::Orientation2D sideOf CGoGNout<<"goal :"<(m,d,m_positions,m_position)); if (crossCell == NO_CROSS) @@ -248,12 +250,13 @@ Dart ParticleCell2D::faceOrientationState(const VEC3& toward) CGoGNout << "faceOrientationState" << d << CGoGNendl ; #endif - assert(this->getPosition().isnormal()); - assert(toward.isnormal()); + // TODO what's isnormal + //assert(this->getPosition().isnormal()); + //assert(toward.isnormal()); Dart res = d ; Dart dd = d ; - float wsoe = getOrientationFace(toward, m.phi1(res)) ; + Geom::Orientation2D wsoe = getOrientationFace(toward, m.phi1(res)) ; // orientation step if (wsoe != Geom::RIGHT) @@ -326,12 +329,12 @@ void ParticleCell2D::faceState(const VEC3& goal) CGoGNout << "faceState" << d << CGoGNendl ; #endif - assert(this->getPosition().isFinite()); - assert(goal.isFinite()) ; + assert(Geom::isFinite(this->getPosition())); + assert(Geom::isFinite(goal)); // assert(Geometry::isPointInConvexFace2D(m,d,m_positions,m_position,true)); Dart dd = d ; - float wsoe = getOrientationFace(goal, m.phi1(d)) ; + Geom::Orientation2D wsoe = getOrientationFace(goal, m.phi1(d)); // orientation step if (wsoe != Geom::RIGHT) diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.h b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.h index 395ef2e9559731697b431d8a610b1be3373ca7b5..21bd397a6bda83254e4af1bccaa61c448e6e1ccb 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.h +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.h @@ -35,13 +35,13 @@ public: typedef VertexAttribute TAB_POS ; private: - ParticleCell2DMemo() - { - } + //ParticleCell2DMemo() + //{ + //} public: - ParticleCell2DMemo(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) : + ParticleCell2DMemo(MAP& map, Dart belonging_cell, VEC3 pos, /*const*/ TAB_POS& tabPos) : ParticleCell2D(map, belonging_cell, pos, tabPos) { } diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.hpp b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.hpp index 397422eb46cb15df9711b5f97ed41f144c6f4872..85bd033bedf76506177bf360882bfcebea090b1b 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.hpp +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_memo.hpp @@ -40,7 +40,7 @@ std::vector ParticleCell2DMemo::move(const VEC3& goal) this->crossCell = NO_CROSS ; if (!Geom::arePointsEquals(goal, this->getPosition())) { - CellMarkerMemo memo_cross(this->m); + CellMarkerMemo memo_cross(this->m); switch (this->getState()) @@ -249,7 +249,7 @@ void ParticleCell2DMemo::faceState(const VEC3& current, CellMarkerMemo(m,d,m_positions,m_position,true)); memo_cross.mark(this->d); Dart dd = this->d ; - float wsoe = this->getOrientationFace(current, this->m.phi1(this->d)) ; + Geom::Orientation2D wsoe = this->getOrientationFace(current, this->m.phi1(this->d)) ; // orientation step if (wsoe != Geom::RIGHT) diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.h b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.h index 38a5d52615af37d0d06fe274107fe0e510f0f7e1..dc35cb01a86021701d01963c9fd7586c0e8ef17d 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.h +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.h @@ -34,14 +34,14 @@ class ParticleCell2DSecured : public ParticleCell2DMemo typedef VertexAttribute TAB_POS ; private: - ParticleCell2DSecured() - { - std::cout << "Particle Secured : for debugging (unoptimized)" << std::endl; - } + //ParticleCell2DSecured() + //{ + // std::cout << "Particle Secured : for debugging (unoptimized)" << std::endl; + //} public: - ParticleCell2DSecured(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) : + ParticleCell2DSecured(MAP& map, Dart belonging_cell, VEC3 pos, /*const*/ TAB_POS& tabPos) : ParticleCell2DMemo(map, belonging_cell, pos, tabPos) { // std::cout << "Particle Memo : for debugging (unoptimized)" << std::endl; @@ -58,8 +58,8 @@ public: virtual void faceState(const VEC3& current, CellMarkerMemo& memo_cross) ; std::vector move(const VEC3& goal) ; - - std::vector move(const VEC3& goal, CellMarkerMemo& memo_cross) ; + // NOT IMPLEMENTED + //std::vector move(const VEC3& goal, CellMarkerMemo& memo_cross) ; } ; } // namespace MovingObjects diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.hpp b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.hpp index 737aa54d0fa5ab8fb9de9000ba47cf248ee1761f..fd413f8b009b7458144f99b39a3fa92e4eab8f62 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.hpp +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2D_secured.hpp @@ -40,7 +40,7 @@ std::vector ParticleCell2DSecured::move(const VEC3& goal) this->crossCell = NO_CROSS ; if (!Geom::arePointsEquals(goal, this->getPosition())) { - CellMarkerMemo memo_cross(this->m); + CellMarkerMemo memo_cross(this->m); // memo_cross.mark(this->d); switch (this->getState()) diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.h b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.h index c46a4b56c5cda2ec26e84bf30f540cf94751f302..0525a272e5f442514734ae71d2e1a53a6bb4a1ef 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.h +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.h @@ -40,11 +40,12 @@ class ParticleCell2DAndHalf : public Algo::MovingObjects::ParticleBase public : typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; typedef VertexAttribute TAB_POS; MAP& m; - const TAB_POS& m_positions; + /*const*/ TAB_POS& m_positions; Dart d; Dart lastCrossed; @@ -53,12 +54,12 @@ public : unsigned int crossCell ; - float distance; + REAL distance; - ParticleCell2DAndHalf(MAP& map) : m(map) - {} + //ParticleCell2DAndHalf(MAP& map) : m(map) + //{} - ParticleCell2DAndHalf(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) : + ParticleCell2DAndHalf(MAP& map, Dart belonging_cell, VEC3 pos, /*const*/ TAB_POS& tabPos) : Algo::MovingObjects::ParticleBase(pos), m(map), m_positions(tabPos), @@ -71,7 +72,7 @@ public : Dart getCell() { return d; } - float getDistance() { return distance; } + REAL getDistance() { return distance; } Geom::Orientation3D getOrientationEdge(const VEC3& point, Dart d); diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.hpp b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.hpp index cf2a30ccad8cde08b3f3263275e5de913fd504c2..32ddb9aa395bedf87e20d73f455d064d84809d5e 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.hpp +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf.hpp @@ -25,6 +25,7 @@ //#define DEBUG #include "Geometry/frame.h" +#include "Geometry/vector_gen.h" namespace CGoGN { @@ -92,7 +93,7 @@ typename PFP::VEC3 ParticleCell2DAndHalf::intersectLineEdge(const VEC3& pA, Geom::intersectionLinePlane(pA, pB - pA, q1, n, Inter) ; - Geom::Plane3D pl = Geometry::facePlane(m, d, m_positions); + Geom::Plane3D pl = Geometry::facePlane(m, d, m_positions); pl.project(Inter); return Inter; @@ -114,7 +115,7 @@ void ParticleCell2DAndHalf::vertexState(VEC3 goal) #ifdef DEBUG CGoGNout << "vertexState" << d << CGoGNendl; #endif - assert(goal.isFinite()) ; + assert(Geom::isFinite(goal)); crossCell = CROSS_OTHER; @@ -189,7 +190,7 @@ void ParticleCell2DAndHalf::edgeState(VEC3 goal, Geom::Orientation3D sideOf CGoGNout << "edgeState" << d << CGoGNendl; #endif - assert(goal.isFinite()) ; + assert(Geom::isFinite(goal)); // assert(Geometry::isPointOnEdge(m,d,m_positions,m_position)); if(crossCell == NO_CROSS) @@ -221,7 +222,7 @@ void ParticleCell2DAndHalf::edgeState(VEC3 goal, Geom::Orientation3D sideOf VEC3 n2 = Geometry::faceNormal(m, m.phi2(d), m_positions); VEC3 axis = n1 ^ n2 ; - float angle = Geom::angle(n1, n2) ; + REAL angle = Geom::angle(n1, n2) ; displ = Geom::rotate(axis, angle, displ) ; goal = this->getPosition() + displ; @@ -261,8 +262,8 @@ void ParticleCell2DAndHalf::faceState(VEC3 goal) CGoGNout << "faceState" << d << CGoGNendl; #endif - assert(goal.isFinite()) ; - assert(this->getPosition().isFinite()) ; + assert(Geom::isFinite(goal)); + assert(Geom::isFinite(this->getPosition())); //project goal within face plane VEC3 n1 = Geometry::faceNormal(m,d,m_positions); @@ -275,7 +276,7 @@ void ParticleCell2DAndHalf::faceState(VEC3 goal) //track new position within map Dart dd = d; - float wsoe = getOrientationFace(goal, this->getPosition(), m.phi1(d)); + Geom::Orientation3D wsoe = getOrientationFace(goal, this->getPosition(), m.phi1(d)); // orientation step if(wsoe != Geom::UNDER) diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.h b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.h index 4b520dadb956b635bff15c848ea94053b67e027a..18c5b0ef5dda4896160f6fc02a3f8e33db758d34 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.h +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.h @@ -35,9 +35,9 @@ public : // bool detect_vertex; // bool detect_edge; // bool detect_face; - ParticleCell2DAndHalfMemo() {}; + //ParticleCell2DAndHalfMemo() {}; - ParticleCell2DAndHalfMemo(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) : + ParticleCell2DAndHalfMemo(MAP& map, Dart belonging_cell, VEC3 pos, /*const*/ TAB_POS& tabPos) : ParticleCell2DAndHalf(map,belonging_cell,pos,tabPos) // detect_vertex(false),detect_edge(false),detect_face(true) { diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.hpp b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.hpp index 26072def22afd16d83fd86127de64238b0842882..e085ebba6f25440330a60aacc19448198a02c1f3 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.hpp +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_2DandHalf_memo.hpp @@ -24,7 +24,7 @@ //#define DEBUG #include "Geometry/frame.h" - +#include "Geometry/vector_gen.h" namespace CGoGN @@ -46,7 +46,7 @@ std::vector ParticleCell2DAndHalfMemo::move(const VEC3& goal) this->crossCell = NO_CROSS ; if (!Geom::arePointsEquals(goal, this->getPosition())) { - CellMarkerMemo memo_cross(this->m); + CellMarkerMemo memo_cross(this->m); switch (this->getState()) { @@ -106,7 +106,7 @@ void ParticleCell2DAndHalfMemo::vertexState(VEC3 current, CellMarkerMemocrossCell = CROSS_OTHER; @@ -177,7 +177,7 @@ void ParticleCell2DAndHalfMemo::edgeState(VEC3 current, CellMarkerMemo(m,d,m_positions,m_position)); if(this->crossCell == NO_CROSS) @@ -209,7 +209,7 @@ void ParticleCell2DAndHalfMemo::edgeState(VEC3 current, CellMarkerMemo(this->m, this->m.phi2(this->d), this->m_positions); VEC3 axis = n1 ^ n2 ; - float angle = Geom::angle(n1, n2) ; + typename PFP::REAL angle = Geom::angle(n1, n2) ; displ = Geom::rotate(axis, angle, displ) ; current = this->getPosition() + displ; @@ -249,8 +249,8 @@ void ParticleCell2DAndHalfMemo::faceState(VEC3 current, CellMarkerMemod)) return ; memo_cross.mark(this->d); - assert(this->getPosition().isFinite()); - assert(current.isFinite()); + assert(Geom::isFinite(this->getPosition())); + assert(Geom::isFinite(current)); // assert(Geometry::isPointInConvexFace2D(m,d,m_positions,m_position,true)); //project current within face plane @@ -264,7 +264,7 @@ void ParticleCell2DAndHalfMemo::faceState(VEC3 current, CellMarkerMemod; - float wsoe = this->getOrientationFace(current, this->getPosition(), this->m.phi1(this->d)); + Geom::Orientation3D wsoe = this->getOrientationFace(current, this->getPosition(), this->m.phi1(this->d)); // orientation step if(wsoe != Geom::UNDER) diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_3D.h b/CGoGN/include/Algo/MovingObjects/particle_cell_3D.h index 00daa3b822e22354f83c7ed18ea5641852a945dc..2640eeda9bca8d21a62d495510c22c29483dafb6 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_3D.h +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_3D.h @@ -37,6 +37,7 @@ class ParticleCell3D : public Algo::MovingObjects::ParticleBase public : typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; typedef VertexAttribute TAB_POS; MAP& m; @@ -52,8 +53,8 @@ public : unsigned int crossCell ; - ParticleCell3D(MAP& map) : m(map) - {} + //ParticleCell3D(MAP& map) : m(map) + //{} ParticleCell3D(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) : Algo::MovingObjects::ParticleBase(pos), diff --git a/CGoGN/include/Algo/MovingObjects/particle_cell_3D.hpp b/CGoGN/include/Algo/MovingObjects/particle_cell_3D.hpp index 869bcc7df0776a4a09fed98fec0787fa977ae39f..4cfe801379a60610532d421356402ffb43f7105f 100644 --- a/CGoGN/include/Algo/MovingObjects/particle_cell_3D.hpp +++ b/CGoGN/include/Algo/MovingObjects/particle_cell_3D.hpp @@ -792,7 +792,7 @@ void ParticleCell3D::volumeSpecialCase(const VEC3& current) Dart d_min; std::vector dart_list; - std::vector dist_list; + std::vector dist_list; std::list visitedFaces; // Faces that are traversed visitedFaces.push_back(d); // Start with the face of d @@ -853,7 +853,7 @@ void ParticleCell3D::volumeSpecialCase(const VEC3& current) } if(dist_list.size()>0) { - float min=dist_list[0]; + REAL min=dist_list[0]; for(unsigned int i = 1;i originalDetailVectors ; bool quantizationInitialized, quantizationApplied ; - Algo::PMesh::Quantization* q ; + Utils::Quantization* q ; public: ProgressiveMesh( @@ -109,7 +109,7 @@ public: void gotoLevel(unsigned int goal) ; unsigned int& currentLevel() { return m_cur ; } - unsigned int nbSplits() { return m_splits.size() ; } + unsigned int nbSplits() { return (unsigned int)(m_splits.size()) ; } void recomputeApproxAndDetails() ; diff --git a/CGoGN/include/Algo/ProgressiveMesh/pmesh.hpp b/CGoGN/include/Algo/ProgressiveMesh/pmesh.hpp index 830209dec810fe9ae7e5582f01245c7a3d382e84..409b4d5c40cfc95bcaadd1dfeedfed22a88983cb 100644 --- a/CGoGN/include/Algo/ProgressiveMesh/pmesh.hpp +++ b/CGoGN/include/Algo/ProgressiveMesh/pmesh.hpp @@ -50,35 +50,35 @@ ProgressiveMesh::ProgressiveMesh( { CGoGNout << " creating approximator and predictor.." << CGoGNflush ; - std::vector*> pos_v ; - pos_v.push_back(&position) ; +// std::vector*> pos_v ; +// pos_v.push_back(&position) ; switch(a) { case Algo::Surface::Decimation::A_QEM : { - m_approximators.push_back(new Algo::Surface::Decimation::Approximator_QEM(m_map, pos_v)) ; + m_approximators.push_back(new Algo::Surface::Decimation::Approximator_QEM(m_map, pos)) ; break ; } case Algo::Surface::Decimation::A_MidEdge : { - m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge(m_map, pos_v)) ; + m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge(m_map, pos)) ; break ; } case Algo::Surface::Decimation::A_hHalfCollapse : { Algo::Surface::Decimation::Predictor_HalfCollapse* pred = new Algo::Surface::Decimation::Predictor_HalfCollapse(m_map, position) ; m_predictors.push_back(pred) ; - m_approximators.push_back(new Algo::Surface::Decimation::Approximator_HalfCollapse(m_map, pos_v, pred)) ; + m_approximators.push_back(new Algo::Surface::Decimation::Approximator_HalfCollapse(m_map, pos, pred)) ; break ; } case Algo::Surface::Decimation::A_CornerCutting : { Algo::Surface::Decimation::Predictor_CornerCutting* pred = new Algo::Surface::Decimation::Predictor_CornerCutting(m_map, position) ; m_predictors.push_back(pred) ; - m_approximators.push_back(new Algo::Surface::Decimation::Approximator_CornerCutting(m_map, pos_v, pred)) ; + m_approximators.push_back(new Algo::Surface::Decimation::Approximator_CornerCutting(m_map, pos, pred)) ; break ; } case Algo::Surface::Decimation::A_TangentPredict1 : { Algo::Surface::Decimation::Predictor_TangentPredict1* pred = new Algo::Surface::Decimation::Predictor_TangentPredict1(m_map, position) ; m_predictors.push_back(pred) ; - m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge(m_map, pos_v, pred)) ; + m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge(m_map, pos, pred)) ; break ; } case Algo::Surface::Decimation::A_TangentPredict2 : { Algo::Surface::Decimation::Predictor_TangentPredict2* pred = new Algo::Surface::Decimation::Predictor_TangentPredict2(m_map, position) ; m_predictors.push_back(pred) ; - m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge(m_map, pos_v, pred)) ; + m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge(m_map, pos, pred)) ; break ; } } CGoGNout << "..done" << CGoGNendl ; @@ -87,22 +87,25 @@ ProgressiveMesh::ProgressiveMesh( switch(s) { case Algo::Surface::Decimation::S_MapOrder : { - m_selector = new Algo::Surface::Decimation::EdgeSelector_MapOrder(m_map, position, m_approximators) ; + m_selector = new Algo::Surface::Decimation::EdgeSelector_MapOrder(m_map) ; break ; } case Algo::Surface::Decimation::S_Random : { - m_selector = new Algo::Surface::Decimation::EdgeSelector_Random(m_map, position, m_approximators) ; + m_selector = new Algo::Surface::Decimation::EdgeSelector_Random(m_map) ; break ; } case Algo::Surface::Decimation::S_EdgeLength : { - m_selector = new Algo::Surface::Decimation::EdgeSelector_Length(m_map, position, m_approximators) ; + m_selector = new Algo::Surface::Decimation::EdgeSelector_Length(m_map, position) ; break ; } case Algo::Surface::Decimation::S_QEM : { - m_selector = new Algo::Surface::Decimation::EdgeSelector_QEM(m_map, position, m_approximators) ; + Algo::Surface::Decimation::Approximator* approx = dynamic_cast*>(m_approximators[0]); + m_selector = new Algo::Surface::Decimation::EdgeSelector_QEM(m_map, position, *approx) ; break ; } case Algo::Surface::Decimation::S_MinDetail : { - m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail(m_map, position, m_approximators) ; + Algo::Surface::Decimation::Approximator* approx = dynamic_cast*>(m_approximators[0]); + m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail(m_map, position, *approx) ; break ; } case Algo::Surface::Decimation::S_Curvature : { - m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature(m_map, position, m_approximators) ; + Algo::Surface::Decimation::Approximator* approx = dynamic_cast*>(m_approximators[0]); + m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature(m_map, position, *approx) ; break ; } } CGoGNout << "..done" << CGoGNendl ; @@ -336,30 +339,30 @@ void ProgressiveMesh::refine() Algo::Topo::setOrbitEmbedding(m_map, dd1, e3) ; Algo::Topo::setOrbitEmbedding(m_map, dd2, e4) ; - if(!m_predictors.empty()) - { - typename std::vector*>::iterator pit ; - typename std::vector*>::iterator ait ; - for(pit = m_predictors.begin(), ait = m_approximators.begin(); - pit != m_predictors.end(); - ++pit, ++ait) - { - typename PFP::MATRIX33* detailTransform = NULL ; - if(m_localFrameDetailVectors) - detailTransform = &invLocalFrame ; - - (*pit)->affectPredict(d) ; - if((*ait)->getType() == Algo::Surface::Decimation::A_hHalfCollapse) - { - (*ait)->addDetail(dd, m_detailAmount, true, detailTransform) ; - } - else - { - (*ait)->addDetail(d, m_detailAmount, true, detailTransform) ; - (*ait)->addDetail(dd, m_detailAmount, false, detailTransform) ; - } - } - } +// if(!m_predictors.empty()) +// { +// typename std::vector*>::iterator pit ; +// typename std::vector*>::iterator ait ; +// for(pit = m_predictors.begin(), ait = m_approximators.begin(); +// pit != m_predictors.end(); +// ++pit, ++ait) +// { +// typename PFP::MATRIX33* detailTransform = NULL ; +// if(m_localFrameDetailVectors) +// detailTransform = &invLocalFrame ; + +// (*pit)->affectPredict(d) ; +// if((*ait)->getType() == Algo::Surface::Decimation::A_hHalfCollapse) +// { +// (*ait)->addDetail(dd, m_detailAmount, true, detailTransform) ; +// } +// else +// { +// (*ait)->addDetail(d, m_detailAmount, true, detailTransform) ; +// (*ait)->addDetail(dd, m_detailAmount, false, detailTransform) ; +// } +// } +// } } template @@ -469,16 +472,16 @@ void ProgressiveMesh::globalizeDetailVectors() template void ProgressiveMesh::initQuantization() { - if(m_positionApproximator->getPredictor() && !quantizationInitialized) - { - gotoLevel(nbSplits()) ; - originalDetailVectors.resize(m_splits.size()) ; - for(unsigned int i = 0; i < m_splits.size(); ++i) - originalDetailVectors[i] = m_positionApproximator->getDetail(m_splits[i]->getEdge(),0) ; - q = new Algo::PMesh::Quantization(originalDetailVectors) ; - quantizationInitialized = true ; - CGoGNout << " Differential Entropy -> " << q->getDifferentialEntropy() << CGoGNendl ; - } +// if(m_positionApproximator->getPredictor() && !quantizationInitialized) +// { +// gotoLevel(nbSplits()) ; +// originalDetailVectors.resize(m_splits.size()) ; +// for(unsigned int i = 0; i < m_splits.size(); ++i) +// originalDetailVectors[i] = m_positionApproximator->getDetail(m_splits[i]->getEdge(),0) ; +// q = new Algo::PMesh::Quantization(originalDetailVectors) ; +// quantizationInitialized = true ; +// CGoGNout << " Differential Entropy -> " << q->getDifferentialEntropy() << CGoGNendl ; +// } } template diff --git a/CGoGN/include/Algo/Remeshing/pliant.hpp b/CGoGN/include/Algo/Remeshing/pliant.hpp index 3a8712831039378d3686281358051c6ee69ebb37..048828e134dcb03ac1fe67dacc8a76b568483596 100644 --- a/CGoGN/include/Algo/Remeshing/pliant.hpp +++ b/CGoGN/include/Algo/Remeshing/pliant.hpp @@ -56,7 +56,7 @@ void pliantRemeshing( if(!m1.isMarked(d)) { m1.template markOrbit(d) ; - meanEdgeLength += Geometry::edgeLength(map, d, position) ; + meanEdgeLength += Algo::Geometry::edgeLength(map, d, position) ; ++nbEdges ; } } @@ -73,7 +73,7 @@ void pliantRemeshing( if(!m2.isMarked(d)) { m2.template markOrbit(d) ; - REAL length = Geometry::edgeLength(map, d, position) ; + REAL length = Algo::Geometry::edgeLength(map, d, position) ; if(length > edgeLengthSup) { Dart dd = map.phi2(d) ; @@ -128,7 +128,7 @@ void pliantRemeshing( if(!cornerVertex.isMarked(d) && !cornerVertex.isMarked(d1) && ( (featureVertex.isMarked(d) && featureVertex.isMarked(d1)) || (!featureVertex.isMarked(d) && !featureVertex.isMarked(d1)) )) { - REAL length = Geometry::edgeLength(map, d, position) ; + REAL length = Algo::Geometry::edgeLength(map, d, position); if(length < edgeLengthInf && map.edgeCanCollapse(d)) { bool collapse = true ; @@ -185,7 +185,7 @@ void pliantRemeshing( Algo::Surface::Geometry::computeNormalVertices(map, position, normal) ; // tangential relaxation - VertexAttribute centroid = map.template addAttribute("centroid") ; + VertexAttribute centroid = map.template addAttribute("centroid") ; Surface::Geometry::computeNeighborhoodCentroidVertices(map, position, centroid) ; CellMarker vm(map) ; diff --git a/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.h b/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.h index 4722afa6a31f9283bab80bc3f15ce5e879e85a24..ef41d8b3cefd5453392fc5745b22dd6737bb0c40 100644 --- a/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.h +++ b/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.h @@ -70,7 +70,7 @@ public: */ template void updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, typename PFP::MAP& map, - const VertexAttribute& positions, const ATTRIB& colorPerXXX) ; + const VertexAttribute& positions, const ATTRIB& colorPerXXX); /** * draw diff --git a/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.hpp b/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.hpp index 6a2ed485c84b5cd880fd4f0a8570ebf9867962d1..6fce7408f3ea2018990dfbf773038c590599382f 100644 --- a/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/colorPerEdgeRender.hpp @@ -51,7 +51,7 @@ m_nbEdges(0) template void ColorPerEdgeRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, typename PFP::MAP& map, - const VertexAttribute& positions, const ATTRIB& colorPerXXX) + const VertexAttribute& positions, const ATTRIB& colorPerXXX) { typedef typename PFP::VEC3 VEC3; typedef typename PFP::REAL REAL; @@ -67,23 +67,23 @@ void ColorPerEdgeRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor for (Dart d=traEdge.begin(); d!=traEdge.end(); d=traEdge.next()) { - buffer.push_back(PFP::toVec3f(positions[d]); + buffer.push_back(PFP::toVec3f(positions[d])); bufferColors.push_back(PFP::toVec3f(colorPerXXX[d])); Dart e = map.phi2(d); buffer.push_back(PFP::toVec3f(positions[e])); bufferColors.push_back(PFP::toVec3f(colorPerXXX[e])) ; } - m_nbEdges = buffer.size()/2; + m_nbEdges = uint32(buffer.size()/2); vboPosition.setDataSize(3); - vboPosition.allocate(buffer.size()); + vboPosition.allocate(uint32(buffer.size())); VEC3F* ptrPos = reinterpret_cast(vboPosition.lockPtr()); memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F)); vboPosition.releasePtr(); vboColor.setDataSize(3); - vboColor.allocate(bufferColors.size()); + vboColor.allocate(uint32(bufferColors.size())); VEC3F* ptrCol = reinterpret_cast(vboColor.lockPtr()); memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F)); vboColor.releasePtr(); diff --git a/CGoGN/include/Algo/Render/GL2/colorPerFaceRender.hpp b/CGoGN/include/Algo/Render/GL2/colorPerFaceRender.hpp index d96f89efe79adf521387e639e691b55bb14324ab..ab7eb99b967fa53a9bfb5220736726ed58e7b1b4 100644 --- a/CGoGN/include/Algo/Render/GL2/colorPerFaceRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/colorPerFaceRender.hpp @@ -84,16 +84,16 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor } while (c != d); } - m_nbTris = buffer.size()/3; + m_nbTris = GLuint(buffer.size()/3); vboPosition.setDataSize(3); - vboPosition.allocate(buffer.size()); + vboPosition.allocate(uint32(buffer.size())); VEC3F* ptrPos = reinterpret_cast(vboPosition.lockPtr()); memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F)); vboPosition.releasePtr(); vboColor.setDataSize(3); - vboColor.allocate(bufferColors.size()); + vboColor.allocate(uint32(bufferColors.size())); VEC3F* ptrCol = reinterpret_cast(vboColor.lockPtr()); memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F)); vboColor.releasePtr(); @@ -141,22 +141,22 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNorma } while (c != d); } - m_nbTris = buffer.size()/3; + m_nbTris = GLuint(buffer.size()/3); vboPosition.setDataSize(3); - vboPosition.allocate(buffer.size()); + vboPosition.allocate(uint32(buffer.size())); VEC3F* ptrPos = reinterpret_cast(vboPosition.lockPtr()); memcpy(ptrPos, &buffer[0], buffer.size()*sizeof(VEC3F)); vboPosition.releasePtr(); vboNormal.setDataSize(3); - vboNormal.allocate(bufferColors.size()); + vboNormal.allocate(uint32(bufferColors.size())); VEC3F* ptrNorm = reinterpret_cast(vboNormal.lockPtr()); memcpy(ptrNorm, &bufferColors[0], bufferColors.size()*sizeof(VEC3F)); vboNormal.releasePtr(); vboColor.setDataSize(3); - vboColor.allocate(bufferColors.size()); + vboColor.allocate(uint32(bufferColors.size())); VEC3F* ptrCol = reinterpret_cast(vboColor.lockPtr()); memcpy(ptrCol, &bufferColors[0], bufferColors.size()*sizeof(VEC3F)); vboColor.releasePtr(); diff --git a/CGoGN/include/Algo/Render/GL2/dataPerFaceRender.hpp b/CGoGN/include/Algo/Render/GL2/dataPerFaceRender.hpp index 0e7f0415a91e802f5e39169487ec26e1b089fb12..48e2f8de3c176141fd4eafe439f30c169098712a 100644 --- a/CGoGN/include/Algo/Render/GL2/dataPerFaceRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/dataPerFaceRender.hpp @@ -83,17 +83,17 @@ DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, typen } while (c != d); } - m_nbTris = buffer.size()/3; + m_nbTris = uint32(buffer.size()/3); vboPosition.setDataSize(3); - vboPosition.allocate(buffer.size()); + vboPosition.allocate(uint32(buffer.size())); VEC3F* ptrPos = reinterpret_cast(vboPosition.lockPtr()); memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F)); vboPosition.releasePtr(); assert(sizeof(T) % sizeof(float) == 0 || !"DataPerFaceRender::updateVBO: VBO's only work with data types which are a multiple of 4 bytes") ; vboData.setDataSize(sizeof(T) / sizeof(float)); // Warning : works only for data types of 4 bytes (as do the VBO's) - vboData.allocate(bufferData.size()); + vboData.allocate(uint32(bufferData.size())); T* ptrData = reinterpret_cast(vboData.lockPtr()); memcpy(ptrData,&bufferData[0],bufferData.size()*sizeof(T)); vboData.releasePtr(); diff --git a/CGoGN/include/Algo/Render/GL2/drawerCells.h b/CGoGN/include/Algo/Render/GL2/drawerCells.h index 5253bc00f43cc81601ae9767827d35f16a21ea70..4d1d77aa8eca44aa1bc5e1ad162335b1997c0ad4 100644 --- a/CGoGN/include/Algo/Render/GL2/drawerCells.h +++ b/CGoGN/include/Algo/Render/GL2/drawerCells.h @@ -46,7 +46,7 @@ namespace Render * @param k shrinking factor */ template -void drawerCells(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, std::vector& vd, const VertexAttribute& positions); +void drawerCells(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, std::vector& vd, const VertexAttribute& positions, float k); /** * add a set of volumes to a drawer @@ -58,7 +58,7 @@ void drawerCells(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, s * @param k shrinking factor */ template -void drawerCell(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute& positions); +void drawerCell(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute& positions, float k); /** * add a set of vertices to a drawer diff --git a/CGoGN/include/Algo/Render/GL2/drawerCells.hpp b/CGoGN/include/Algo/Render/GL2/drawerCells.hpp index 7f43dcdbd6e808b767a12b314e460c345edff433..1632998bcecff5612033320679950cfc3187c405 100644 --- a/CGoGN/include/Algo/Render/GL2/drawerCells.hpp +++ b/CGoGN/include/Algo/Render/GL2/drawerCells.hpp @@ -22,7 +22,9 @@ * * *******************************************************************************/ + #include "Geometry/vector_gen.h" +#include "Algo/Geometry/centroid.h" namespace CGoGN { diff --git a/CGoGN/include/Algo/Render/GL2/explodeVolumeRender.hpp b/CGoGN/include/Algo/Render/GL2/explodeVolumeRender.hpp index 3602eba2d08874964ba1da923dd5a7ec1abd9cbb..97f5ccb17760de1f679beb16cfadbc2a54289c9f 100644 --- a/CGoGN/include/Algo/Render/GL2/explodeVolumeRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/explodeVolumeRender.hpp @@ -305,15 +305,16 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit // TraversorCell traFace(map); // for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next()) - foreach_cell(map, [&] (Cell d) + foreach_cell(map, [&] (Cell fop) { + Dart d = fop.dart; // compute normals VEC3 centerFace = Algo::Surface::Geometry::faceCentroidELW(map, d, positions); VEC3 centerNormalFace = Algo::Surface::Geometry::newellNormal(map, d, positions); computeFace(map,d,positions,centerFace,centerNormalFace,vertices,normals); - unsigned int nbs = vertices.size(); + unsigned int nbs = uint32(vertices.size()); // just to have more easy algo further vertices.push_back(vertices.front()); normals.push_back(normals.front()); @@ -362,21 +363,21 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit } }); // false) ??? - m_nbTris = buffer.size()/4; + m_nbTris = uint32(buffer.size()/4); - m_vboPos->allocate(buffer.size()); + m_vboPos->allocate(uint32(buffer.size())); VEC3F* ptrPos = reinterpret_cast(m_vboPos->lockPtr()); memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F)); m_vboPos->releasePtr(); m_shaderS->setAttributePosition(m_vboPos); - m_vboColors->allocate(bufferColors.size()); + m_vboColors->allocate(uint32(bufferColors.size())); VEC3F* ptrCol = reinterpret_cast(m_vboColors->lockPtr()); memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F)); m_vboColors->releasePtr(); m_shaderS->setAttributeColor(m_vboColors); - m_vboNormals->allocate(bufferNormals.size()); + m_vboNormals->allocate(uint32(bufferNormals.size())); VEC3F* ptrNorm = reinterpret_cast(m_vboNormals->lockPtr()); memcpy(ptrNorm,&bufferNormals[0],bufferNormals.size()*sizeof(VEC3F)); m_vboNormals->releasePtr(); @@ -393,9 +394,9 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit buffer.push_back(PFP::toVec3f(positions[map.phi1(c.dart)])); }); - m_nbLines = buffer.size()/3; + m_nbLines = GLuint(buffer.size()/3); - m_vboPosLine->allocate(buffer.size()); + m_vboPosLine->allocate(uint32(buffer.size())); ptrPos = reinterpret_cast(m_vboPosLine->lockPtr()); memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F)); @@ -553,8 +554,9 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const EMBV& positio bufferColors.reserve(16384); // TraversorCell traFace(map); - foreach_cell(map, [&] (Cell d) + foreach_cell(map, [&] (Cell fop) { + Dart d = fop.dart; VEC3F centerFace = PFP::toVec3f(Algo::Surface::Geometry::faceCentroidELW(map, d, positions)); Dart b = d; @@ -597,15 +599,15 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const EMBV& positio }); - m_nbTris = buffer.size()/4; + m_nbTris = uint32(buffer.size()/4); - m_vboPos->allocate(buffer.size()); + m_vboPos->allocate(uint32(buffer.size())); VEC3F* ptrPos = reinterpret_cast(m_vboPos->lockPtr()); memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F)); m_vboPos->releasePtr(); m_shader->setAttributePosition(m_vboPos); - m_vboColors->allocate(bufferColors.size()); + m_vboColors->allocate(uint32(bufferColors.size())); VEC3F* ptrCol = reinterpret_cast(m_vboColors->lockPtr()); memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F)); m_vboColors->releasePtr(); @@ -621,9 +623,9 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const EMBV& positio buffer.push_back(PFP::toVec3f(positions[map.phi1(c)])); }); - m_nbLines = buffer.size()/3; + m_nbLines = GLuint(buffer.size()/3); - m_vboPosLine->allocate(buffer.size()); + m_vboPosLine->allocate(uint32(buffer.size())); ptrPos = reinterpret_cast(m_vboPosLine->lockPtr()); memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F)); diff --git a/CGoGN/include/Algo/Render/GL2/mapRender.h b/CGoGN/include/Algo/Render/GL2/mapRender.h index 1aeff2d36396f73e3fa6a68dd4eca50e2ea869be..e662124d202022f42663f94c58a85aa4e5871404 100644 --- a/CGoGN/include/Algo/Render/GL2/mapRender.h +++ b/CGoGN/include/Algo/Render/GL2/mapRender.h @@ -120,6 +120,7 @@ protected: prev->next = this; } + static void close(VertexPoly* first, VertexPoly* last) { last->next = first; diff --git a/CGoGN/include/Algo/Render/GL2/mapRender.hpp b/CGoGN/include/Algo/Render/GL2/mapRender.hpp index 299788a4fe606db82b6932bfeac0084b096bf9e1..0c459deed00105518505e7b772d147d284ed08a8 100644 --- a/CGoGN/include/Algo/Render/GL2/mapRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/mapRender.hpp @@ -125,10 +125,10 @@ void MapRender::recompute2Ears(const VertexAttributevalue = dotpr1; - vp->length = (Tb-Tc).norm2(); + vp->length = float((Tb-Tc).norm2()); vp->ear = ears.insert(vp); vp2->value = dotpr2; - vp->length = (Td-Ta).norm2(); + vp->length = float((Td-Ta).norm2()); vp2->ear = ears.insert(vp2); } @@ -181,6 +181,7 @@ template inline void MapRender::addEarTri(typename PFP::MAP& map, Face f, std::vector& tableIndices, const VertexAttribute* pos) { typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; bool(*fn_pt1)(VertexPoly*,VertexPoly*) = &(MapRender::cmpVP); VPMS ears(fn_pt1); @@ -205,7 +206,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Face f, std::vector(P1, P2, P3, normalPoly); - VertexPoly* vp = new VertexPoly(map.getEmbedding(b), val, (P3-P1).norm2(), vpp); + VertexPoly* vp = new VertexPoly(map.getEmbedding(b), val, float((P3-P1).norm2()), vpp); if (vp->value < 5.0f) nbe++; @@ -600,7 +601,7 @@ void MapRender::addPrimitives(typename PFP::MAP& map, int prim, const VertexAttr glDeleteBuffers(1,&(m_indexBuffers[prim])); m_indexBuffers[prim] = newBuffer; - m_nbIndices[prim] += tableIndices.size(); + m_nbIndices[prim] += GLuint(tableIndices.size()); } } // namespace GL2 diff --git a/CGoGN/include/Algo/Render/GL2/topo3PrimalRender.hpp b/CGoGN/include/Algo/Render/GL2/topo3PrimalRender.hpp index 93bc253a5511b521a976e98c740cb53906b235ca..2c9720f2878c7e022de1be2ff7fe93e8e95a860a 100644 --- a/CGoGN/include/Algo/Render/GL2/topo3PrimalRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/topo3PrimalRender.hpp @@ -268,7 +268,7 @@ template Dart Topo3PrimalRender::pickColor(unsigned int x, unsigned int y) { //more easy picking for - unsigned int dw = m_topo_dart_width; + float dw = m_topo_dart_width; m_topo_dart_width+=2; // save clear color and set to zero diff --git a/CGoGN/include/Algo/Render/GL2/topoPrimalRender.h b/CGoGN/include/Algo/Render/GL2/topoPrimalRender.h index c7673a3f5348895ed8d353e236e8fcdb655af2da..a502dae6ba0251834cd73d312973d1d9764bd287 100644 --- a/CGoGN/include/Algo/Render/GL2/topoPrimalRender.h +++ b/CGoGN/include/Algo/Render/GL2/topoPrimalRender.h @@ -263,7 +263,7 @@ public: * @param map the map * @param posExpl the output positions */ - template + //template void computeDartMiddlePositions(MAP& map, DartAttribute& posExpl); /** diff --git a/CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp b/CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp index 66e6bc4e001546ac79d4cc34d91b6482bce69f4a..22767c967081abc7c8b1077e6c922dcb8d4c1a4a 100644 --- a/CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp @@ -28,7 +28,7 @@ #include "Topology/generic/cellmarker.h" #include "Topology/map/map3.h" -#include "Topology/generic/traversorCell.h" +#include "Topology/generic/traversor/traversorCell.h" #include "Geometry/distances.h" namespace CGoGN @@ -277,7 +277,7 @@ template Dart TopoPrimalRender::pickColor(unsigned int x, unsigned int y) { //more easy picking for - unsigned int dw = m_topo_dart_width; + float dw = m_topo_dart_width; m_topo_dart_width+=2; // save clear color and set to zero @@ -436,9 +436,9 @@ template void TopoPrimalRender::updateData(MAP& map, const VertexAttribute& positions, float ke) { if (m_attIndex.map() != &map) - m_attIndex = map.template getAttribute("dart_index"); + m_attIndex = map.template getAttribute("dart_index"); if (!m_attIndex.isValid()) - m_attIndex = map.template addAttribute("dart_index"); + m_attIndex = map.template addAttribute("dart_index"); // m_nbDarts = 0; // for (Dart d = map.begin(); d != map.end(); map.next(d)) @@ -483,7 +483,7 @@ void TopoPrimalRender::updateData(MAP& map, const VertexAttribute(d)) + if (map.template isBoundaryMarked<2>(d)) { *colorDartBuf++ = m_boundaryDartsColor; *colorDartBuf++ = m_boundaryDartsColor; @@ -502,7 +502,7 @@ void TopoPrimalRender::updateData(MAP& map, const VertexAttribute(dx)) + if (map.template isBoundaryMarked<2>(dx)) { *colorDartBuf++ = m_boundaryDartsColor; *colorDartBuf++ = m_boundaryDartsColor; diff --git a/CGoGN/include/Algo/Render/GL2/topoRender.hpp b/CGoGN/include/Algo/Render/GL2/topoRender.hpp index 28115ebfd35462eb25fdda4cec9c98a4a5829559..d27930abab1946a651049f599728d9e4bcbace51 100644 --- a/CGoGN/include/Algo/Render/GL2/topoRender.hpp +++ b/CGoGN/include/Algo/Render/GL2/topoRender.hpp @@ -219,7 +219,7 @@ void TopoRender::updateData(typename PFP::MAP& map, const VertexAttribute(map,ee,positions); - VEC3 vd = Algo::Surface::Geometry::vectorOutOfDart(map,ee,positions); + VEC3 vd = Algo::Geometry::vectorOutOfDart(map,ee,positions); VEC3 v = vd ^ normal; v.normalize(); VEC3 P = positions[map.phi1(ee)] + v* this->m_boundShift; @@ -521,7 +521,7 @@ Dart TopoRender::picking(MAP& map,int x, int y, bool withBoundary) float cc[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE,cc); - bool multi = glIsEnabled(GL_MULTISAMPLE); + GLboolean multi = glIsEnabled(GL_MULTISAMPLE); if (multi) glDisable(GL_MULTISAMPLE); diff --git a/CGoGN/include/Algo/Selection/collector.h b/CGoGN/include/Algo/Selection/collector.h index 3b3622bc6872b150c62209628b923897221b031c..0abfc86849d761dffe9e2918654722d967b5acc0 100644 --- a/CGoGN/include/Algo/Selection/collector.h +++ b/CGoGN/include/Algo/Selection/collector.h @@ -30,6 +30,8 @@ #include "Topology/generic/traversor/traversor2.h" +#include + /***************************************** * Class hierarchy : * Collector (virtual) @@ -308,7 +310,7 @@ public: {} inline void setAngleThreshold(REAL a) { angleThreshold = a; } inline REAL getAngleThreshold() const { return angleThreshold; } - inline const VertexAttribute& getNormal() const { return normal ; } + inline const FaceAttribute& getNormal() const { return normal; } void collectAll(Dart d) ; void collectBorder(Dart d) ; @@ -479,7 +481,7 @@ protected: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it; bool valid ; static std::string CGoGNnameOfType() { return "DijkstraVertexInfo" ; } } DijkstraVertexInfo ; @@ -487,7 +489,7 @@ protected: VertexAttribute vertexInfo ; - std::multimap front ; + std::multimap front; public: Collector_Dijkstra_Vertices(MAP& m, const EdgeAttribute& c, REAL d = 0) : @@ -530,7 +532,7 @@ protected: typedef struct { - typename std::multimap::iterator it ; + typename std::multimap::iterator it; bool valid ; static std::string CGoGNnameOfType() { return "DijkstraVertexInfo" ; } } DijkstraVertexInfo ; @@ -538,7 +540,7 @@ protected: VertexAttribute vertexInfo ; - std::multimap front ; + std::multimap front; public: Collector_Dijkstra(MAP& m, const VertexAttribute& p, REAL d = 0) : @@ -546,7 +548,7 @@ public: position(p), maxDist(d) { - vertexInfo = m.template addAttribute("vertexInfo"); + vertexInfo = m.template addAttribute("vertexInfo"); } ~Collector_Dijkstra() { @@ -561,7 +563,7 @@ public: void collectBorder(Dart d); private : - inline float edgeLength (Dart d); + inline REAL edgeLength(Dart d); // inline Dart oppositeVertex (Dart d); }; diff --git a/CGoGN/include/Algo/Selection/collector.hpp b/CGoGN/include/Algo/Selection/collector.hpp index 4b4c76749267b523cdf878a184aca864283aa313..b9844b9a56f23c26b7d95cfdcdd5947cb7cb73f9 100644 --- a/CGoGN/include/Algo/Selection/collector.hpp +++ b/CGoGN/include/Algo/Selection/collector.hpp @@ -601,7 +601,7 @@ void Collector_NormalAngle_Triangles::collectAll(Dart d) CellMarkerStore vm(this->map); // mark inside-vertices and border-vertices CellMarkerStore em(this->map); // mark inside-edges and border-edges - std::vector::iterator f_it; + std::vector::iterator f_it; for (f_it = this->insideFaces.begin(); f_it != this->insideFaces.end(); f_it++) { // collect insideVertices, insideEdges, and border Traversor2FE te (this->map, *f_it) ; @@ -679,7 +679,7 @@ void Collector_NormalAngle_Triangles::collectBorder(Dart d) } CellMarkerStore em(this->map); // mark inside-edges and border-edges - std::vector::iterator f_it; + std::vector::iterator f_it; for (f_it = this->insideFaces.begin(); f_it != this->insideFaces.end(); f_it++) { // collect border (edges) Traversor2FE te (this->map, *f_it) ; @@ -948,14 +948,14 @@ void Collector_Dijkstra_Vertices::collectAll(Dart dinit) this->isInsideCollected = true; CellMarkerStore vmReached (this->map); - vertexInfo[this->centerDart].it = front.insert(std::pair(0.0, this->centerDart)); + vertexInfo[this->centerDart].it = front.insert(std::pair(0.0f, this->centerDart)); vertexInfo[this->centerDart].valid = true; vmReached.mark(this->centerDart); while ( !front.empty() && front.begin()->first < this->maxDist) { Dart e = front.begin()->second; - float d = front.begin()->first; + REAL d = front.begin()->first; front.erase(vertexInfo[e].it); vertexInfo[e].valid=false; this->insideVertices.push_back(e); @@ -968,17 +968,17 @@ void Collector_Dijkstra_Vertices::collectAll(Dart dinit) { if (vi.valid) // probably useless (because of distance test) but faster { - float dist = d + edge_cost[f]; + REAL dist = d + edge_cost[f]; if (dist < vi.it->first) { front.erase(vi.it); - vi.it = front.insert(std::pair(dist, f)); + vi.it = front.insert(std::pair(dist, f)); } } } else { - vi.it = front.insert(std::pair(d + edge_cost[f], f)); + vi.it = front.insert(std::pair(d + edge_cost[f], f)); vi.valid=true; vmReached.mark(f); } @@ -1033,14 +1033,14 @@ void Collector_Dijkstra_Vertices::collectBorder(Dart dinit) init(dinit); CellMarkerStore vmReached (this->map); - vertexInfo[this->centerDart].it = front.insert(std::pair(0.0, this->centerDart)); + vertexInfo[this->centerDart].it = front.insert(std::pair(0.0f, this->centerDart)); vertexInfo[this->centerDart].valid = true; vmReached.mark(this->centerDart); while ( !front.empty() && front.begin()->first < this->maxDist) { Dart e = front.begin()->second; - float d = front.begin()->first; + REAL d = front.begin()->first; front.erase(vertexInfo[e].it); vertexInfo[e].valid=false; this->insideVertices.push_back(e); @@ -1053,17 +1053,17 @@ void Collector_Dijkstra_Vertices::collectBorder(Dart dinit) { if (vi.valid) // probably useless (because of distance test) but faster { - float dist = d + edge_cost[f]; + REAL dist = d + edge_cost[f]; if (dist < vi.it->first) { front.erase(vi.it); - vi.it = front.insert(std::pair(dist, f)); + vi.it = front.insert(std::pair(dist, f)); } } } else { - vi.it = front.insert(std::pair(d + edge_cost[f], f)); + vi.it = front.insert(std::pair(d + edge_cost[f], f)); vi.valid = true; vmReached.mark(f); } @@ -1107,14 +1107,14 @@ void Collector_Dijkstra::collectAll(Dart dinit) this->isInsideCollected = true; CellMarkerStore vmReached (this->map); - vertexInfo[this->centerDart].it = front.insert(std::pair(0.0, this->centerDart)); + vertexInfo[this->centerDart].it = front.insert(std::pair(0.0f, this->centerDart)); vertexInfo[this->centerDart].valid = true; vmReached.mark(this->centerDart); while ( !front.empty() && front.begin()->first < this->maxDist) { Dart e = front.begin()->second; - float d = front.begin()->first; + REAL d = front.begin()->first; front.erase(vertexInfo[e].it); vertexInfo[e].valid=false; this->insideVertices.push_back(e); @@ -1127,17 +1127,17 @@ void Collector_Dijkstra::collectAll(Dart dinit) { if (vi.valid) // probably useless (because of distance test) but faster { - float dist = d + edgeLength(f); + REAL dist = d + edgeLength(f); if (dist < vi.it->first) { front.erase(vi.it); - vi.it = front.insert(std::pair(dist, f)); + vi.it = front.insert(std::pair(dist, f)); } } } else { - vi.it = front.insert(std::pair(d + edgeLength(f), f)); + vi.it = front.insert(std::pair(d + edgeLength(f), f)); vi.valid = true; vmReached.mark(f); } @@ -1152,7 +1152,7 @@ void Collector_Dijkstra::collectAll(Dart dinit) CellMarkerStore em (this->map); CellMarkerStore fm (this->map); - for (std::vector::iterator e_it = this->insideVertices.begin(); e_it != this->insideVertices.end() ; e_it++) + for (std::vector::iterator e_it = this->insideVertices.begin(); e_it != this->insideVertices.end() ; e_it++) { // collect insideEdges Traversor2VE te (this->map, *e_it); @@ -1190,14 +1190,14 @@ void Collector_Dijkstra::collectBorder(Dart dinit) init(dinit); CellMarkerStore vmReached (this->map); - vertexInfo[this->centerDart].it = front.insert(std::pair(0.0, this->centerDart)); + vertexInfo[this->centerDart].it = front.insert(std::pair(0.0f, this->centerDart)); vertexInfo[this->centerDart].valid = true; vmReached.mark(this->centerDart); while ( !front.empty() && front.begin()->first < this->maxDist) { Dart e = front.begin()->second; - float d = front.begin()->first; + REAL d = front.begin()->first; front.erase(vertexInfo[e].it); vertexInfo[e].valid=false; this->insideVertices.push_back(e); @@ -1210,17 +1210,17 @@ void Collector_Dijkstra::collectBorder(Dart dinit) { if (vi.valid) // probably useless (because of distance test) but faster { - float dist = d + edgeLength(f); + REAL dist = d + edgeLength(f); if (dist < vi.it->first) { front.erase(vi.it); - vi.it = front.insert(std::pair(dist, f)); + vi.it = front.insert(std::pair(dist, f)); } } } else { - vi.it = front.insert(std::pair(d + edgeLength(f), f)); + vi.it = front.insert(std::pair(d + edgeLength(f), f)); vi.valid = true; vmReached.mark(f); } @@ -1234,7 +1234,7 @@ void Collector_Dijkstra::collectBorder(Dart dinit) } CellMarkerStore fm (this->map); - for (std::vector::iterator e_it = this->insideVertices.begin(); e_it != this->insideVertices.end() ; e_it++) + for (std::vector::iterator e_it = this->insideVertices.begin(); e_it != this->insideVertices.end() ; e_it++) { // collect border Traversor2VF tf (this->map, *e_it); @@ -1255,9 +1255,9 @@ void Collector_Dijkstra::collectBorder(Dart dinit) } template -inline float Collector_Dijkstra::edgeLength (Dart d) +inline typename PFP::REAL Collector_Dijkstra::edgeLength(Dart d) { - typename PFP::VEC3 v = Geometry::vectorOutOfDart(this->map, d, this->position); + typename PFP::VEC3 v = Algo::Geometry::vectorOutOfDart(this->map, d, this->position); return v.norm(); } diff --git a/CGoGN/include/Algo/Selection/raySelector.hpp b/CGoGN/include/Algo/Selection/raySelector.hpp index ad0871af0abe075bba8370fbec6b6c74f8235393..0ab053b73e7adce3207a125aecdf7cadf1501682 100644 --- a/CGoGN/include/Algo/Selection/raySelector.hpp +++ b/CGoGN/include/Algo/Selection/raySelector.hpp @@ -207,7 +207,7 @@ void edgesRaySelection( const typename PFP::VEC3& P = position[e.dart]; const typename PFP::VEC3& Q = position[map.phi1(e.dart)]; // the three distance to P, Q and (PQ) not used here - float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q); + typename PFP::REAL ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q); if (ld2 < dist2) vecEdges.push_back(e); }); @@ -217,7 +217,7 @@ void edgesRaySelection( typedef std::pair EdgeDist; std::vector distnedge; - unsigned int nbi = vecEdges.size(); + unsigned int nbi = (unsigned int)(vecEdges.size()); distnedge.resize(nbi); // compute all distances to observer for each middle of intersected edge @@ -318,7 +318,7 @@ void verticesRaySelection( foreach_cell(map, [&] (Vertex v) { const typename PFP::VEC3& P = position[v]; - float ld2 = Geom::squaredDistanceLine2Point(rayA, rayAB, AB2, P); + typename PFP::REAL ld2 = Geom::squaredDistanceLine2Point(rayA, rayAB, AB2, P); if (ld2 < dist2) vecVertices.push_back(v); }); @@ -328,7 +328,7 @@ void verticesRaySelection( typedef std::pair VertexDist; std::vector distnvertex; - unsigned int nbi = vecVertices.size(); + unsigned int nbi = (unsigned int)(vecVertices.size()); distnvertex.resize(nbi); // compute all distances to observer for each intersected vertex @@ -473,7 +473,7 @@ void facesPlanSelection( position[f.dart], position[map.phi1(f.dart)], position[map.phi_1(f.dart)], - plan.d(), + plan.point(), plan.normal() ) == Geom::FACE_INTERSECTION) { @@ -514,7 +514,7 @@ void verticesConeSelection( foreach_cell(map, [&] (Vertex v) { const typename PFP::VEC3& P = position[v]; - float ld2 = Geom::squaredDistanceLine2Point(rayA, rayAB, AB2, P); + typename PFP::REAL ld2 = Geom::squaredDistanceLine2Point(rayA, rayAB, AB2, P); typename PFP::VEC3 V = P - rayA; double s2 = double(ld2) / double(V*V); if (s2 < sin2) @@ -524,7 +524,7 @@ void verticesConeSelection( typedef std::pair VertexDist; std::vector distnvertex; - unsigned int nbi = vecVertices.size(); + unsigned int nbi = (unsigned int)(vecVertices.size()); distnvertex.resize(nbi); // compute all distances to observer for each intersected vertex @@ -578,7 +578,7 @@ void edgesConeSelection( const typename PFP::VEC3& P = position[e.dart]; const typename PFP::VEC3& Q = position[map.phi1(e.dart)]; // the three distance to P, Q and (PQ) not used here - float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q); + typename PFP::REAL ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q); typename PFP::VEC3 V = (P+Q)/2.0f - rayA; double s2 = double(ld2) / double(V*V); if (s2 < sin2) @@ -588,7 +588,7 @@ void edgesConeSelection( typedef std::pair EdgeDist; std::vector distnedge; - unsigned int nbi = vecEdges.size(); + unsigned int nbi = (unsigned int)(vecEdges.size()); distnedge.resize(nbi); // compute all distances to observer for each middle of intersected edge diff --git a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.h b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.h index fd2c18a6940b80dd47995dddb628f17453434126..152d098493984c8932846433fd7afeb088c55122 100644 --- a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.h +++ b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.h @@ -53,15 +53,15 @@ public: protected: MAP& m_map; - VertexAttribute& m_position; // x_i : position - VertexAttribute& m_mass; // m_i : mass - VertexAttribute m_goal; + VertexAttribute& m_position; // x_i : position + VertexAttribute& m_mass; // m_i : mass + VertexAttribute m_goal; // q_{i} = x^{0} - x^{0}_{cm} std::vector m_q; public: - ShapeMatching(MAP& map, VertexAttribute& position, VertexAttribute& mass); + ShapeMatching(MAP& map, VertexAttribute& position, VertexAttribute& mass); virtual ~ShapeMatching(); @@ -71,9 +71,9 @@ public: void shapeMatch(); - void computeVelocities(VertexAttribute& velocity, VertexAttribute& fext, REAL h, REAL alpha); + void computeVelocities(VertexAttribute& velocity, VertexAttribute& fext, REAL h, REAL alpha); - void applyVelocities(VertexAttribute& velocity, REAL h); + void applyVelocities(VertexAttribute& velocity, REAL h); }; } // namespace ShapeMatching diff --git a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.hpp b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.hpp index c1b8d1959b2262a89942866606fc941238299ca8..a3281773a45d54bad7505599b0b2f94c973c0628 100644 --- a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.hpp +++ b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatching.hpp @@ -39,7 +39,7 @@ namespace ShapeMatching template -ShapeMatching::ShapeMatching(MAP& map, VertexAttribute& position, VertexAttribute& mass): +ShapeMatching::ShapeMatching(MAP& map, VertexAttribute& position, VertexAttribute& mass) : m_map(map), m_position(position), m_mass(mass) @@ -48,17 +48,17 @@ ShapeMatching::ShapeMatching(MAP& map, VertexAttribute& position, Ver m_q.reserve(nbE); - m_goal = this->m_map.template getAttribute("goal"); + m_goal = this->m_map.template getAttribute("goal"); if(!m_goal.isValid()) - m_goal = this->m_map.template addAttribute("goal"); + m_goal = this->m_map.template addAttribute("goal"); } template ShapeMatching::~ShapeMatching() { if(m_goal.isValid()) - m_map.template removeAttribute(m_goal); + m_map.template removeAttribute(m_goal); } template @@ -184,7 +184,7 @@ void ShapeMatching::shapeMatch() // \alpha : stiffness | v_i : velocity | f_ext : force exterieure template -void ShapeMatching::computeVelocities(VertexAttribute& velocity, VertexAttribute& fext, REAL h, REAL alpha) +void ShapeMatching::computeVelocities(VertexAttribute& velocity, VertexAttribute& fext, REAL h, REAL alpha) { for(unsigned int i = velocity.begin() ; i < velocity.end() ; velocity.next(i)) { @@ -193,7 +193,7 @@ void ShapeMatching::computeVelocities(VertexAttribute& velocity, Vert } template -void ShapeMatching::applyVelocities(VertexAttribute& velocity, REAL h) +void ShapeMatching::applyVelocities(VertexAttribute& velocity, REAL h) { for(unsigned int i = m_position.begin() ; i < m_position.end() ; m_position.next(i)) { diff --git a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.h b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.h index c815c5585149d37520c7651ac9800c8c8b693ed7..d597b93dc6bd8e6b0268fe48a053b72caeed26f5 100644 --- a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.h +++ b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.h @@ -60,7 +60,7 @@ private: void computeAqqMatrix(); public: - ShapeMatchingLinear(MAP& map, VertexAttribute& position, VertexAttribute& mass, REAL beta): + ShapeMatchingLinear(MAP& map, VertexAttribute& position, VertexAttribute& mass, REAL beta) : ShapeMatching(map, position, mass), m_beta(beta) { } diff --git a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.hpp b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.hpp index 573099fa779d961e772a729b8c4e0c3feb54f455..925e308264c02cd1f3713093436e4f3de0468272 100644 --- a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.hpp +++ b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingLinear.hpp @@ -137,8 +137,8 @@ void ShapeMatchingLinear::shapeMatch() //4. Eigen::Matrix3d A = apq * m_aqq; // - REAL det = A.determinant(); - det = 1.0f/powf(det,1.0f/3.0f); + double det_d = A.determinant(); + REAL det = REAL(1.0 / pow(det_d, 1.0 / 3.0)); // \beta * A + (1 - \beta) * R if(std::isfinite(det)) @@ -170,7 +170,7 @@ void ShapeMatchingLinear::shapeMatch() VEC3 g; for (unsigned int j = 0 ; j < 3 ; ++j) - g[j] = tmp(j); + g[j] = REAL(tmp(j)); this->m_goal[i] = g; } diff --git a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.h b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.h index b20427e27d7d15764a129eabc1571b864cc2ec7e..88db29f3a917114f7f6e5df408ebefe503fc8e0f 100644 --- a/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.h +++ b/CGoGN/include/Algo/Simulation/ShapeMatching/shapeMatchingQuadratic.h @@ -64,7 +64,7 @@ protected: std::vector m_qtild; public: - ShapeMatchingQuadratic(MAP& map, VertexAttribute& position, VertexAttribute& mass, REAL beta): + ShapeMatchingQuadratic(MAP& map, VertexAttribute& position, VertexAttribute& mass, REAL beta) : ShapeMatching(map, position, mass), m_beta(beta) { } diff --git a/CGoGN/include/Algo/Tiling/Surface/triangular.hpp b/CGoGN/include/Algo/Tiling/Surface/triangular.hpp index cff0fd3537e74592248820db959d15465bccb853..5bd429922e8772f2340a64ca617e4871e13a30f4 100644 --- a/CGoGN/include/Algo/Tiling/Surface/triangular.hpp +++ b/CGoGN/include/Algo/Tiling/Surface/triangular.hpp @@ -22,6 +22,8 @@ * * *******************************************************************************/ +#include "Algo/Modelisation/subdivision.h" + namespace CGoGN { diff --git a/CGoGN/include/Algo/Topo/Map2/uniformOrientation.hpp b/CGoGN/include/Algo/Topo/Map2/uniformOrientation.hpp index b52e1dc260042e763f2431a20216748f0c9bf606..abe99ffba8e2e61f6a4b90ea82d30648e71add5c 100644 --- a/CGoGN/include/Algo/Topo/Map2/uniformOrientation.hpp +++ b/CGoGN/include/Algo/Topo/Map2/uniformOrientation.hpp @@ -30,7 +30,7 @@ void reverse2MapFaceKeepPhi2(MAP& map, Dart d) // private function inline Dart findOtherInCouplesOfDarts(const std::vector& couples, Dart d) { - unsigned int nb = couples.size(); + unsigned int nb = (unsigned int)(couples.size()); for (unsigned int i=0; i couples; - int nb = boundEdges.size(); + int nb = int(boundEdges.size()); int nbm = nb-1; for (int i=0; i< nbm; ++i) { diff --git a/CGoGN/include/Algo/Topo/basic.h b/CGoGN/include/Algo/Topo/basic.h index 57c24a67815c54540bacf59a5ff7b4d684eb3895..a264c132529ad434d2742ed493b91a891e084297 100644 --- a/CGoGN/include/Algo/Topo/basic.h +++ b/CGoGN/include/Algo/Topo/basic.h @@ -127,6 +127,7 @@ void bijectiveOrbitEmbedding(MAP& map) map.removeAttribute(counter) ; } + } // namespace Topo } // namespace Algo diff --git a/CGoGN/include/Algo/Topo/simplex.h b/CGoGN/include/Algo/Topo/simplex.h index ed155d4a94a461d7fad90729ab199e3d250ef2a4..07689dc24564fb230a050360b42c0676318320ad 100644 --- a/CGoGN/include/Algo/Topo/simplex.h +++ b/CGoGN/include/Algo/Topo/simplex.h @@ -38,7 +38,7 @@ namespace Topo { -template +template bool isSimplex(const MAP& map, Dart d) { if (ORBIT==VOLUME) diff --git a/CGoGN/include/Container/attributeContainer.hpp b/CGoGN/include/Container/attributeContainer.hpp index 584df3afc5c5139278ac48b187b8cdaccbcd2fb3..7bb3bc3f2cd68afd38b6069ea315cffdb0a86d8d 100644 --- a/CGoGN/include/Container/attributeContainer.hpp +++ b/CGoGN/include/Container/attributeContainer.hpp @@ -142,7 +142,7 @@ void AttributeContainer::addAttribute(const std::string& attribName, const std:: m_lineCost += sizeof(T) ; // resize the new attribute so that it has the same size than others - amv->setNbBlocks(m_holesBlocks.size()) ; + amv->setNbBlocks(uint32(m_holesBlocks.size())) ; m_nbAttributes++; } @@ -205,7 +205,7 @@ unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrInd AttributeMultiVector* atm = dynamic_cast*>(m_tableAttribs[attrIndex]); assert((atm != NULL) || !"getAttributeBlocksPointers: wrong type"); - return atm->getBlocksPointers(vect_ptr, byteBlockSize); + return atm->getBlocksPointers(reinterpret_cast&>(vect_ptr), byteBlockSize); } /************************************** diff --git a/CGoGN/include/Geometry/basic.h b/CGoGN/include/Geometry/basic.h index d3e6111f50e5617bc0a8928539ea4ab7044f3015..173aa539a81a2d4ee726a1df2df56aac6daa043f 100644 --- a/CGoGN/include/Geometry/basic.h +++ b/CGoGN/include/Geometry/basic.h @@ -80,7 +80,7 @@ typename VEC::DATA_TYPE cos_angle(const VEC& a, const VEC& b) typename VEC::DATA_TYPE nb2 = b.norm2() ; typename VEC::DATA_TYPE res = (a * b) / sqrt(na2 * nb2) ; - return res > 1.0 ? 1.0 : (res < -1.0 ? -1.0 : res) ; + return res > 1.0f ? 1.0f : (res < -1.0f ? -1.0f : res) ; } // angle formed by 2 vectors diff --git a/CGoGN/include/Geometry/bounding_box.hpp b/CGoGN/include/Geometry/bounding_box.hpp index 71250f18689a88e439140df490080ce718fd3de3..afcc1934e3676db6b7448e6c2021f24fce8db8fd 100644 --- a/CGoGN/include/Geometry/bounding_box.hpp +++ b/CGoGN/include/Geometry/bounding_box.hpp @@ -22,6 +22,8 @@ * * *******************************************************************************/ +#include + namespace CGoGN { @@ -226,7 +228,8 @@ bool BoundingBox::contains(const VEC& a, const VEC& b) VEC dir(b-a); /*ray */ bool inside = true; - char quadrant[m_pMin.dimension()]; +// char quadrant[m_pMin.dimension()]; + std::vector quadrant(m_pMin.dimension()); VEC candidatePlane; @@ -264,7 +267,7 @@ bool BoundingBox::contains(const VEC& a, const VEC& b) if (quadrant[i] != MIDDLE && dir[i] !=0) maxT[i] = (candidatePlane[i]-a[i]) / dir[i]; else - maxT[i] = -1.; + maxT[i] = -1; } #undef LEFT @@ -326,7 +329,7 @@ bool BoundingBox::rayIntersect(const VEC& P, const VEC& V) const { static float EPSILON = 0.000001f; - if (fabs(V[2]) > EPSILON) + if (fabs(double(V[2])) > EPSILON) { VEC Q = P + ((m_pMin[2] - P[2])/V[2])*V; if ((Q[0]m_pMin[0]) && (Q[1]m_pMin[1])) @@ -336,7 +339,7 @@ bool BoundingBox::rayIntersect(const VEC& P, const VEC& V) const return true; } - if (fabs(V[1]) > EPSILON) + if (fabs(double(V[1])) > EPSILON) { VEC Q = P + ((m_pMin[1] - P[1])/V[1])*V; if ((Q[0]m_pMin[0]) && (Q[2]m_pMin[2])) @@ -347,7 +350,7 @@ bool BoundingBox::rayIntersect(const VEC& P, const VEC& V) const } - if (fabs(V[0]) > EPSILON) + if (fabs(double(V[0])) > EPSILON) { VEC Q = P + ((m_pMin[0] - P[0])/V[0])*V; if ((Q[1]m_pMin[1]) && (Q[2]m_pMin[2])) diff --git a/CGoGN/include/Geometry/distances.hpp b/CGoGN/include/Geometry/distances.hpp index 6d0d86e4e0927808eb19262673c5dff497894e9d..a99fb19f5bd152e851ef658455d52af72b3a8880 100644 --- a/CGoGN/include/Geometry/distances.hpp +++ b/CGoGN/include/Geometry/distances.hpp @@ -401,30 +401,30 @@ typename VEC3::DATA_TYPE squaredDistanceSeg2Point(const VEC3& A, const VEC3& AB, template bool lineLineClosestPoints(const VEC3& P1, const VEC3& V1, const VEC3& P2, const VEC3& V2, VE