28 #include <DGtal/base/Common.h>
29 #include <DGtal/helpers/StdDefs.h>
30 #include <DGtal/helpers/Shortcuts.h>
31 #include <DGtal/helpers/ShortcutsGeometry.h>
32 #include <DGtal/shapes/SurfaceMesh.h>
33 #include <DGtal/geometry/surfaces/DigitalSurfaceRegularization.h>
35 #include <DGtal/dec/PolygonalCalculus.h>
36 #include <DGtal/dec/GeodesicsInHeat.h>
38 #include <polyscope/polyscope.h>
39 #include <polyscope/surface_mesh.h>
40 #include <polyscope/point_cloud.h>
42 #include "ConfigExamples.h"
44 #include <Eigen/Dense>
45 #include <Eigen/Sparse>
47 using namespace DGtal;
91 auto params2 = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();
92 params2(
"r-radius", (
double)
radiusII);
93 auto surfels = SH3::getSurfelRange(
surface, params2 );
122 heat->addSource( pos );
124 psMesh->addVertexScalarQuantity(
"Sources", source);
130 psMeshReg->addVertexScalarQuantity(
"Sources", source);
137 psMesh->addVertexScalarQuantity(
"source",
heat->source());
144 psMesh->addVertexScalarQuantity(
"Sources", source);
146 psMesh->addVertexDistanceQuantity(
"geodesic", dist);
152 psMeshReg->addVertexScalarQuantity(
"Sources", sourceReg);
154 psMeshReg->addVertexDistanceQuantity(
"geodesic", dist);
161 ImGui::SliderFloat(
"dt", &
dt, 0.,4.);
162 ImGui::SliderFloat(
"ii radius for normal vector estimation", &
radiusII , 0.,10.);
163 ImGui::Checkbox(
"Skip regularization", &
skipReg);
165 ImGui::InputInt(
"Index of the first source vertex", &
sourceVertexId);
168 if(ImGui::Button(
"Precomputation (required if you change parameters)"))
174 if(ImGui::Button(
"Add a random source"))
183 if(ImGui::Button(
"Clear sources"))
193 if(ImGui::Button(
"Compute geodesic"))
206 auto params = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();
207 params(
"surfaceComponents",
"All");
208 params(
"r-radius", (
double)
radiusII);
209 std::string filename = examplesPath + std::string(
"/samples/bunny-128.vol");
213 auto primalSurface = SH3::makePrimalSurfaceMesh(
surface);
216 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
217 std::vector<RealPoint> positions;
219 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
220 faces.push_back(primalSurface->incidentVertices( face ));
223 positions = primalSurface->positions();
240 regularizedPosition.end(),
247 psMesh = polyscope::registerSurfaceMesh(
"digital surface", positions, faces);
248 psMeshReg = polyscope::registerSurfaceMesh(
"regularized surface", regularizedPosition, faces);
Aim: Smart pointer based on reference counts.
Aim: Implements Digital Surface Regularization as described in .
void init(const double alpha=0.001, const double beta=1.0, const double gamma=0.05)
Initialize the parameters of the energy function.
void attachConvolvedTrivialNormalVectors(const Parameters someParams=SH3::defaultParameters()|SHG3::defaultParameters())
const Positions & getRegularizedPositions() const
double regularize(const unsigned int nbIters, const double dt, const double epsilon, const AdvectionFunction &advectionFunc)
Main regularization loop.
This class implements on polygonal surfaces (using Discrete differential calculus on polygonal surfa...
PolygonalCalculus::Vector Vector
Implements differential operators on polygonal surfaces from .
void setEmbedder(const std::function< Real3dPoint(Face, Vertex)> &externalFunctor)
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
std::vector< RealVector > RealVectors
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
void beginBlock(const std::string &keyword="")
PolyCalculus * calculusReg
SurfaceMesh< RealPoint, RealVector > SurfMesh
bool useProjectedCalculus
GeodesicsInHeat< PolyCalculus > * heatReg
CountedPtr< SH3::DigitalSurface > surface
PolygonalCalculus< SH3::RealPoint, SH3::RealVector > PolyCalculus
CountedPtr< SH3::BinaryImage > binary_image
polyscope::SurfaceMesh * psMesh
Shortcuts< Z3i::KSpace > SH3
ShortcutsGeometry< Z3i::KSpace > SHG3
SHG3::RealVectors iinormals
polyscope::SurfaceMesh * psMeshReg
GeodesicsInHeat< PolyCalculus > * heat
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Edges computeNonManifoldEdges() const
Functor that projects a face vertex of a surface mesh onto the tangent plane given by a per-face norm...
K init(Point(0, 0, 0), Point(512, 512, 512), true)