From e99556424b57f814f8611233eec7153517645de5 Mon Sep 17 00:00:00 2001 From: David Coeurjolly Date: Fri, 9 Jul 2021 12:20:28 +0200 Subject: [PATCH 1/3] export obj in 3dImplicitSurfaceExtractorByThickening --- ...3dImplicitSurfaceExtractorByThickening.cpp | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/visualisation/3dImplicitSurfaceExtractorByThickening.cpp b/visualisation/3dImplicitSurfaceExtractorByThickening.cpp index 899c1329..47aa322a 100644 --- a/visualisation/3dImplicitSurfaceExtractorByThickening.cpp +++ b/visualisation/3dImplicitSurfaceExtractorByThickening.cpp @@ -48,6 +48,7 @@ #include "DGtal/topology/helpers/Surfaces.h" #include "DGtal/shapes/GaussDigitizer.h" #include "DGtal/shapes/Mesh.h" +#include "DGtal/io/boards/Board3D.h" #include "DGtal/shapes/implicit/ImplicitPolynomial3Shape.h" /////////////////////////////////////////////////////////////////////////////// @@ -79,6 +80,7 @@ using namespace DGtal; -P,--project TEXT:{No,Newton}=Newton defines the projection: either No or Newton. -e,--epsilon FLOAT=1e-06 the maximum precision relative to the implicit surface in the Newton approximation of F=0. -n,--max_iter UINT=500 the maximum number of iteration in the Newton approximation of F=0. + -o,--obj TEXT OBJ export filename. -v,--view TEXT:{Singular,Normal,Hide}=Normal specifies if the surface is viewed as is (Normal) or if places close to singularities are highlighted (Singular), or if unsure places should not be displayed (Hide). @endcode @@ -303,7 +305,8 @@ int main( int argc, char** argv ) double epsilon {1e-6}; unsigned int max_iter {500}; std::string view {"Normal"}; - + std::string OBJexport=""; + app.description( "Computes the zero level set of the given polynomial. Usage: 3dImplicitSurfaceExtractorByThickening -p [options]\n Example:\n 3dImplicitSurfaceExtractorByThickening -p \"x^2-y*z^2\" -g 0.1 -a -2 -A 2 -v Singular\n - whitney : x^2-y*z^2 \n - 4lines : x*y*(y-x)*(y-z*x) \n - cone : z^2-x^2-y^2 \n - simonU : x^2-z*y^2+x^4+y^4 \n - cayley3 : 4*(x^2 + y^2 + z^2) + 16*x*y*z - 1 \n - crixxi : -0.9*(y^2+z^2-1)^2-(x^2+y^2-1)^3 \n Some other examples (more difficult): \n 3dImplicitSurfaceExtractorByThickening -a -2 -A 2 -p \"((y^2+z^2-1)^2-(x^2+y^2-1)^3)*(y*(x-1)^2-z*(x+1))^2\" -g 0.025 -e 1e-6 -n 50000 -v Singular -t 0.5 -P Newton \n 3dImplicitSurfaceExtractorByThickening -a -2 -A 2 -p \"(x^5-4*z^3*y^2)*((x+y)^2-(z-x)^3)\" -g 0.025 -e 1e-6 -n 50000 -v Singular -t 0.05 -P Newton "); app.add_option("-p,--polynomial,1", poly_str, "the implicit polynomial whose zero-level defines the shape of interest." ) ->required(); @@ -314,6 +317,7 @@ int main( int argc, char** argv ) app.add_option("--project,-P", project, "defines the projection: either No or Newton.", true) -> check(CLI::IsMember({"No", "Newton"})); app.add_option("--epsilon,-e", epsilon, "the maximum precision relative to the implicit surface in the Newton approximation of F=0.", true); + app.add_option("--obj,-o", OBJexport, "OBJ export filename."); app.add_option("--max_iter,-n", max_iter, "the maximum number of iteration in the Newton approximation of F=0.", true ); app.add_option("--view,-v", view, "specifies if the surface is viewed as is (Normal) or if places close to singularities are highlighted (Singular), or if unsure places should not be displayed (Hide).",true ) -> check(CLI::IsMember({"Singular", "Normal", "Hide"})); @@ -496,6 +500,34 @@ int main( int argc, char** argv ) } trace.endBlock(); + + //-------------- export OBJ ------------------------------------------- + if (OBJexport != "") + { + Board3D board( K3 ); + // Display lines that are not in the mesh. + board<first; + bool fixed = it->second.data & CC3::FIXED; + std::vector dummy; + std::back_insert_iterator< std::vector > outIt( dummy ); + complex3.directCoFaces( outIt, cell ); + if ( ! dummy.empty() ) continue; + + Cells3 bdry = complex3.cellBoundary( cell, true ); + Cell3 v0 = *(bdry.begin() ); + Cell3 v1 = *(bdry.begin() + 1); + if ( ( ! fixed ) && hide ) continue; + Color color = highlight + ? ( fixed ? Color::White : Color(128,255,128) ) + : Color::White; + board.setLineColor( color ); + board.addLine( points[ indices[ v0 ] ], points[ indices[ v1 ] ], h/2.0 ); + } + board.saveOBJ(OBJexport); + } //-------------- View surface ------------------------------------------- QApplication application(argc,argv); Viewer3D viewer( K3 ); From a601d9a6783a7c5d600258b40b54d4feb598f3f9 Mon Sep 17 00:00:00 2001 From: David Coeurjolly Date: Fri, 9 Jul 2021 12:54:59 +0200 Subject: [PATCH 2/3] changelog --- ChangeLog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 594beebe..5139efc2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,10 @@ +# DGtalTools 1.2 + +- *visualisation* + - 3dImplicitSurfaceExtractorByThickening: adding OBJ export. + (David Coeurjolly [#413](https://github.com/DGtal-team/DGtalTools/pull/413)) + + # DGtalTools 1.2 - *global* - Fix itk2vol and fix ITK cmake configuaration that was making issues with the ITK image read. From d12389eecac92e7fc7b16a7ecb5e575e406a8015 Mon Sep 17 00:00:00 2001 From: David Coeurjolly Date: Tue, 20 Jul 2021 20:51:49 +0200 Subject: [PATCH 3/3] Update ChangeLog.md --- ChangeLog.md | 1 - 1 file changed, 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 478bcb1d..219dd46d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,7 +2,6 @@ - # DGtalTools 1.2 - *visualisation*