From 1fa846306e736d6d8385be115dcee4a4e64e80ca Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sun, 8 Oct 2023 17:01:28 +0200 Subject: [PATCH 1/3] add custom alpha value for mesh display --- visualisation/meshViewer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/visualisation/meshViewer.cpp b/visualisation/meshViewer.cpp index ee705c22..b7b2a70e 100644 --- a/visualisation/meshViewer.cpp +++ b/visualisation/meshViewer.cpp @@ -67,6 +67,7 @@ using namespace DGtal; -z,--scaleZ FLOAT set the scale value in the z direction (default 1.0) --minLineWidth FLOAT=1.5 set the min line width of the mesh faces (default 1.5) --customColorMesh UINT ... set the R, G, B, A components of the colors of the mesh faces and eventually the color R, G, B, A of the mesh edge lines (set by default to black). + --customAlphaMesh INT set the alpha components of the colors of the mesh faces. --customColorSDP UINT x 4 set the R, G, B, A components of the colors of the sdp view -f,--displayVectorField TEXT display a vector field from a simple sdp file (two points per line) --vectorFieldIndex UINT x 6 specify special indices for the two point coordinates (instead usinf the default indices: 0 1, 2, 3, 4, 5) @@ -188,7 +189,7 @@ int main( int argc, char** argv ) bool useLastCamSet {false}; bool fixLightToScene {false}; float ambiantLight {0.0}; - + unsigned int customAlphaMesh {255}; // parse command line using CLI ---------------------------------------------- CLI::App app; @@ -203,6 +204,7 @@ int main( int argc, char** argv ) app.add_option("-z,--scaleZ", sz, "set the scale value in the z direction (default 1.0)"); app.add_option("--minLineWidth", lineWidth, "set the min line width of the mesh faces (default 1.5)", true); app.add_option("--customColorMesh", customColorMesh, "set the R, G, B, A components of the colors of the mesh faces and eventually the color R, G, B, A of the mesh edge lines (set by default to black)."); + app.add_option("--customAlphaMesh", customAlphaMesh, "set the alpha components of the colors of the mesh faces."); app.add_option("--customColorSDP", customColorSDP, "set the R, G, B, A components of the colors of the sdp view") ->expected(4); @@ -292,7 +294,14 @@ int main( int argc, char** argv ) for (unsigned int j = 0; j < aMesh.nbFaces(); j++){ aMesh.setFaceColor(j, Color(meshColorR, meshColorG, meshColorB, meshColorA)); } + }else if (customAlphaMesh != 255) { + for (unsigned int j = 0; j < aMesh.nbFaces(); j++){ + auto c = aMesh.getFaceColor(j); + aMesh.setFaceColor(j, Color(c.red(), c.green(), c.blue(), customAlphaMesh)); + } + } + vectMesh.push_back(aMesh); } DGtal::Z3i::RealPoint centerMeshes; From 6922162c0c757aa3d2e2cd2a6ff0526020346ba3 Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sun, 8 Oct 2023 17:09:35 +0200 Subject: [PATCH 2/3] changelog --- ChangeLog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 86ab3252..e8391301 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -10,7 +10,9 @@ some simplications of the option --doSnapShotAndExit. (Bertrand Kerautret [#448](https://github.com/DGtal-team/DGtalTools/pull/448)) - + - meshViewer: new option to set alpha channel of the mesh color. + (Bertrand Kerautret + [#451](https://github.com/DGtal-team/DGtalTools/pull/451)) - *volumetric* - volReSample: fix the impossibility to export to vol when ITK is activated (Bertrand Kerautret [#445](https://github.com/DGtal-team/DGtalTools/pull/445)) From 65d737f31a41c19ebb2fa49b907300e2a0342626 Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sun, 8 Oct 2023 17:19:44 +0200 Subject: [PATCH 3/3] alpha for each mesh --- visualisation/meshViewer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/visualisation/meshViewer.cpp b/visualisation/meshViewer.cpp index b7b2a70e..84a87f5c 100644 --- a/visualisation/meshViewer.cpp +++ b/visualisation/meshViewer.cpp @@ -67,7 +67,7 @@ using namespace DGtal; -z,--scaleZ FLOAT set the scale value in the z direction (default 1.0) --minLineWidth FLOAT=1.5 set the min line width of the mesh faces (default 1.5) --customColorMesh UINT ... set the R, G, B, A components of the colors of the mesh faces and eventually the color R, G, B, A of the mesh edge lines (set by default to black). - --customAlphaMesh INT set the alpha components of the colors of the mesh faces. + --customAlphaMesh UINT ... set the alpha components of the colors of the mesh faces (can be applied for each mesh). --customColorSDP UINT x 4 set the R, G, B, A components of the colors of the sdp view -f,--displayVectorField TEXT display a vector field from a simple sdp file (two points per line) --vectorFieldIndex UINT x 6 specify special indices for the two point coordinates (instead usinf the default indices: 0 1, 2, 3, 4, 5) @@ -189,7 +189,7 @@ int main( int argc, char** argv ) bool useLastCamSet {false}; bool fixLightToScene {false}; float ambiantLight {0.0}; - unsigned int customAlphaMesh {255}; + std::vector customAlphaMesh; // parse command line using CLI ---------------------------------------------- CLI::App app; @@ -204,7 +204,7 @@ int main( int argc, char** argv ) app.add_option("-z,--scaleZ", sz, "set the scale value in the z direction (default 1.0)"); app.add_option("--minLineWidth", lineWidth, "set the min line width of the mesh faces (default 1.5)", true); app.add_option("--customColorMesh", customColorMesh, "set the R, G, B, A components of the colors of the mesh faces and eventually the color R, G, B, A of the mesh edge lines (set by default to black)."); - app.add_option("--customAlphaMesh", customAlphaMesh, "set the alpha components of the colors of the mesh faces."); + app.add_option("--customAlphaMesh", customAlphaMesh, "set the alpha components of the colors of the mesh faces (can be applied for each mesh)."); app.add_option("--customColorSDP", customColorSDP, "set the R, G, B, A components of the colors of the sdp view") ->expected(4); @@ -294,10 +294,10 @@ int main( int argc, char** argv ) for (unsigned int j = 0; j < aMesh.nbFaces(); j++){ aMesh.setFaceColor(j, Color(meshColorR, meshColorG, meshColorB, meshColorA)); } - }else if (customAlphaMesh != 255) { + }else if (customAlphaMesh.size() > 0 ) { for (unsigned int j = 0; j < aMesh.nbFaces(); j++){ auto c = aMesh.getFaceColor(j); - aMesh.setFaceColor(j, Color(c.red(), c.green(), c.blue(), customAlphaMesh)); + aMesh.setFaceColor(j, Color(c.red(), c.green(), c.blue(), customAlphaMesh.at(i