From d58f08f71a59757b626e64f4f6a2aa6c2d96a19c Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sun, 19 Mar 2023 11:22:24 +0100 Subject: [PATCH 1/4] new option to apply a scale factors on the radius input values --- visualisation/graphViewer.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/visualisation/graphViewer.cpp b/visualisation/graphViewer.cpp index 2e4a4ca..309f748 100644 --- a/visualisation/graphViewer.cpp +++ b/visualisation/graphViewer.cpp @@ -92,6 +92,7 @@ int main( int argc, char** argv ) std::string nameFileVertex; std::string nameFileEdge; double r {1.0}; + double scaleRadius {1.0}; bool useRadiiFile {false}; bool autoEdgeOpt {false}; std::vector vectColMesh; @@ -109,6 +110,7 @@ int main( int argc, char** argv ) auto addMeshOpt = app.add_option("--addMesh,-m", meshName, "add mesh in the display."); auto meshColorOpt = app.add_option("--meshColor", vectColMesh, "specify the color of mesh."); auto vertexColorOpt = app.add_option("--vertexColor", vectColVertex, "specify the color of vertex."); + app.add_option("--scaleRadius,-s", scaleRadius, "apply a scale factors on the radius input values", true); auto edgeColorOpt = app.add_option("--edgeColor", vectColEdge, "specify the color of edges."); auto colormapOpt = app.add_flag("--colormap, -c","display vertex colored by order in vertex file or by radius scale if the radius file is specidfied (-r)."); auto doSnapShotAndExitOpt = app.add_option("--doSnapShotAndExit,-d", name, "save display snapshot into file. Notes that the camera setting is set by default according the last saved configuration (use SHIFT+Key_M to save current camera setting in the Viewer3D). If the camera setting was not saved it will use the default camera setting."); @@ -180,7 +182,15 @@ int main( int argc, char** argv ) << vectRadii.size() << ")." << std::endl; return 1; } - hueShade = HueShadeColorMap((*(std::min_element(vectRadii.begin(),vectRadii.end())))*10000,(*(std::max_element(vectRadii.begin(),vectRadii.end())))*10000); + hueShade = HueShadeColorMap((*(std::min_element(vectRadii.begin(), + vectRadii.end())))*10000, + (*(std::max_element(vectRadii.begin(), + vectRadii.end())))*10000); + if (scaleRadius != 1.0){ + for(auto &v: vectRadii){ + v *= scaleRadius; + } + } } @@ -221,7 +231,9 @@ int main( int argc, char** argv ) vertex = { vectVertex[e[0]], vectVertex[e[1]] }; radii = { vectRadii[e[0]], vectRadii[e[1]] }; Mesh::createTubularMesh(aMesh, vertex, radii, 0.05); - viewer << (useRadiiFile ? CustomColors3D( hueShade(radii[0]*10000), hueShade(radii[1]*10000) ) : CustomColors3D( hueShade(e[0]), hueShade(e[1]) )); + viewer << (useRadiiFile ? CustomColors3D( hueShade(radii[0]*10000), + hueShade(radii[1]*10000) ) : CustomColors3D( hueShade(e[0]), + hueShade(e[1]) )); viewer << aMesh; } } @@ -249,7 +261,7 @@ int main( int argc, char** argv ) viewer << Viewer3D<>::updateDisplay; - if(doSnapShotAndExitOpt->count() > 0){ + if(doSnapShotAndExitOpt->count() > 0){ // Appy cleaning just save the last snap DGtal::trace.info() << "sorting surfel according camera position...."; viewer.sortSurfelFromCamera(); From 1bb946c4b36650440ee4dd4754b6d28ff48f28bc Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sun, 19 Mar 2023 11:51:05 +0100 Subject: [PATCH 2/4] new option to display constant radius tubular mesh --- visualisation/graphViewer.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/visualisation/graphViewer.cpp b/visualisation/graphViewer.cpp index 309f748..28b08dc 100644 --- a/visualisation/graphViewer.cpp +++ b/visualisation/graphViewer.cpp @@ -95,6 +95,7 @@ int main( int argc, char** argv ) double scaleRadius {1.0}; bool useRadiiFile {false}; bool autoEdgeOpt {false}; + bool cstSectionEdgeRad {false}; std::vector vectColMesh; std::vector vectColVertex; std::vector vectColEdge; @@ -105,6 +106,7 @@ int main( int argc, char** argv ) app.add_option("--inputVertex,-v", nameFileVertex, "input file containing the vertex list.")->required()->check(CLI::ExistingFile); app.add_option("--inputEdge,-e", nameFileEdge, "input file containing the edge list.")->required()->check(CLI::ExistingFile); app.add_flag("--autoEdge,-a", autoEdgeOpt, "generate edge list from vertex order."); + app.add_flag("--cstSectionEdgeRad",cstSectionEdgeRad, "use a constant edge radius between two consecutive vertices."); auto inputRadiiOpt = app.add_option("--inputRadii,-r", nameFileRadii, "input file containing the radius for each vertex."); app.add_option("--ballRadius,-b", r, "radius of vertex balls.", true); auto addMeshOpt = app.add_option("--addMesh,-m", meshName, "add mesh in the display."); @@ -229,7 +231,12 @@ int main( int argc, char** argv ) { Mesh aMesh; vertex = { vectVertex[e[0]], vectVertex[e[1]] }; - radii = { vectRadii[e[0]], vectRadii[e[1]] }; + if (cstSectionEdgeRad) { + radii = { std::min(vectRadii[e[0]], vectRadii[e[1]]), std::min(vectRadii[e[0]], vectRadii[e[1]]) }; + } + else { + radii = { vectRadii[e[0]], vectRadii[e[1]] }; + } Mesh::createTubularMesh(aMesh, vertex, radii, 0.05); viewer << (useRadiiFile ? CustomColors3D( hueShade(radii[0]*10000), hueShade(radii[1]*10000) ) : CustomColors3D( hueShade(e[0]), @@ -243,7 +250,12 @@ int main( int argc, char** argv ) for ( const auto& e: vectEdges ) { vertex = { vectVertex[e[0]], vectVertex[e[1]] }; - radii = { vectRadii[e[0]], vectRadii[e[1]] }; + if (cstSectionEdgeRad) { + radii = { std::min(vectRadii[e[0]], vectRadii[e[1]]), std::min(vectRadii[e[0]], vectRadii[e[1]]) }; + } + else { + radii = { vectRadii[e[0]], vectRadii[e[1]] }; + } Mesh::createTubularMesh(aMesh, vertex, radii, 0.05); } viewer << CustomColors3D(DGtal::Color::Black, edgeColor); From 0bf2e9104575f98a964d813468ccfd58f7a45d90 Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sun, 19 Mar 2023 11:51:58 +0100 Subject: [PATCH 3/4] update doc --- visualisation/graphViewer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/visualisation/graphViewer.cpp b/visualisation/graphViewer.cpp index 28b08dc..1c403cf 100644 --- a/visualisation/graphViewer.cpp +++ b/visualisation/graphViewer.cpp @@ -49,11 +49,13 @@ Usage: ./graphViewer [OPTIONS] -v,--inputVertex TEXT:FILE REQUIRED input file containing the vertex list. -e,--inputEdge TEXT:FILE REQUIRED input file containing the edge list. -a,--autoEdge generate edge list from vertex order. + --cstSectionEdgeRad use a constant edge radius between two consecutive vertices. -r,--inputRadii TEXT input file containing the radius for each vertex. -b,--ballRadius FLOAT=1 radius of vertex balls. -m,--addMesh TEXT add mesh in the display. --meshColor UINT ... specify the color of mesh. --vertexColor UINT ... specify the color of vertex. + -s,--scaleRadius FLOAT=1 apply a scale factors on the radius input values --edgeColor UINT ... specify the color of edges. -c,--colormap display vertex colored by order in vertex file or by radius scale if the radius file is specidfied (-r). -d,--doSnapShotAndExit TEXT save display snapshot into file. Notes that the camera setting is set by default according the last saved configuration (use SHIFT+Key_M to save current camera setting in the Viewer3D). If the camera setting was not saved it will use the default camera setting. From d8aaf0cf0d81a77c4ce53901dfbaf22ac35ec624 Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sun, 19 Mar 2023 12:05:33 +0100 Subject: [PATCH 4/4] changelog --- ChangeLog.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index b9cbf4f..75149ee 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,7 +8,11 @@ (Bertrand Kerautret [#71](https://github.com/DGtal-team/DGtalTools-contrib/pull/71)) - basicEditMesh: improvement of mesh read using generic reader/writer. (Bertrand Kerautret [#72](https://github.com/DGtal-team/DGtalTools-contrib/pull/72)) - + +- *visualisation* + - graphViewer: new options to apply a scale factors on the radius input values + and to display constant tube section. (Bertrand Kerautret [#74](https://github.com/DGtal-team/DGtalTools-contrib/pull/74)) + # DGtalTools-contrib 1.3 - *global*