DGtal 2.1.0
Loading...
Searching...
No Matches
viewer3D-12-quantities.cpp File Reference
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/helpers/Shortcuts.h"
#include "DGtal/helpers/ShortcutsGeometry.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
Include dependency graph for viewer3D-12-quantities.cpp:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

This program 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 3 of the License, or (at your option) any later version.

This program 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Batien Doignies LIRIS, Université Claude Bernard Lyon 1
Date
2025/06/02

Simple example of class PolyscopeViewer.

This file is part of the DGtal library.

Definition in file viewer3D-12-quantities.cpp.

Function Documentation

◆ main()

int main ( void  )

[ExampleViewer3DQuantitiesStream]

[ExampleViewer3DQuantitiesStream]

[ExampleViewer3DQuantitiesAddQuantity]

[ExampleViewer3DQuantitiesAddQuantity]

[ExampleViewer3DQuantitiesLoop]

[ExampleViewer3DQuantitiesLoop]

Definition at line 44 of file viewer3D-12-quantities.cpp.

44 {
45 typedef Shortcuts<KSpace> SH3;
47
48 auto params = SH3::defaultParameters() | SHG3::defaultParameters();
49
50 params( "polynomial", "3*x^2+2*y^2+z^2-90" )( "gridstep", 0.25 );
51 auto implicit_shape = SH3::makeImplicitShape3D ( params );
52 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
53 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
54 auto K = SH3::getKSpace( params );
55 auto surface = SH3::makeLightDigitalSurface( binary_image, K, params );
56 auto surfels = SH3::getSurfelRange( surface, params );
57 auto positions = SHG3::getPositions( implicit_shape, K, surfels, params );
58 auto normals = SHG3::getNormalVectors( implicit_shape, K, surfels, params );
59 auto mean_curvs = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
60 auto gauss_curvs = SHG3::getGaussianCurvatures( implicit_shape, K, surfels, params );
61
62 PolyscopeViewer viewer;
64 // Option 1: stream operator (Scell_1_2d in viewer)
65 // Most usefull when adding single quantity, otherwise
66 // it should be nested.
67 viewer << WithQuantity(
70 surfels, "Mean Curv", mean_curvs
71 ),
72 "Gauss Curve", gauss_curvs
73 ),
74 "Normal", normals
75 );
77
79 // Option 2: draw first then add quantities (Surfels 1 in viewer)
80 // This requires to obtain or set object name
81 std::string objectName = "Surfels 1";
82 viewer.draw(surfels, objectName); // Draws the object independantly
83 viewer.addQuantity(objectName, "Mean Curv", mean_curvs);
84 viewer.addQuantity(objectName, "Gauss Curv", gauss_curvs);
85 viewer.addQuantity(objectName, "Normal", normals);
87
88 // Option 3: Within loops (Surfels 3 within the viewer)
89 // Here, a group must be created for the colormaps to work
90 // Note: here Option 1 and 2 are superior, this is just an example
91
93 std::string objectName2 = "Surfels 3";
94 viewer.newVolumetricList(objectName2); // Signed cells are drawn as volumetric meshes
95 viewer.allowReuseList = true; // Allows for automatic groupping
96
97 auto surfIt = surfels.begin();
98 auto mcurveIt = mean_curvs.begin();
99 auto gcurveIt = gauss_curvs.begin();
100 auto ncurveIt = normals.begin();
101
102 for (; surfIt != surfels.end(); ++surfIt, ++mcurveIt, ++gcurveIt, ++ncurveIt) {
103 // Both options 1 and 2 can be used together, as long as we know the name for sure
104 viewer << WithQuantity(*surfIt, "Mean Curv", *mcurveIt);
105 viewer.addQuantity(objectName2, "Gauss Curve", *gcurveIt);
106 viewer.addQuantity(objectName2, "Normals", *ncurveIt);
107 }
109
110 viewer.show();
111 return 0;
112 }
std::string draw(const Point &p, const std::string &uname="Point_{i}")
void addQuantity(const std::string &oName, const std::string &qName, const Type &value, QuantityScale scale=QuantityScale::UNKNOWN)
std::string newVolumetricList(const std::string &name)
Definition Display3D.h:541
void show() override
Starts the event loop and display of elements.
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition Shortcuts.h:102
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
Attach a property to an element.
Definition Display3D.h:331
Shortcuts< KSpace > SH3
KSpace K
ShortcutsGeometry< Z3i::KSpace > SHG3

References DGtal::Display3D< Space, KSpace >::addQuantity(), DGtal::Display3D< Space, KSpace >::allowReuseList, binary_image, DGtal::Display3D< Space, KSpace >::draw(), K, DGtal::Display3D< Space, KSpace >::newVolumetricList(), DGtal::PolyscopeViewer< Space, KSpace >::show(), and surface.