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"
45#include <Eigen/Sparse>
92 params2(
"r-radius", (
double)
radiusII);
119 std::vector<std::pair<size_t,int>> counts;
120 for(
auto i=0; i< source.size(); ++i)
123 counts.push_back(std::pair<size_t,int>(i,1));
131 heat->addSource( pos );
146 psMesh->addVertexScalarQuantity(
"source",
heat->source());
155 psMesh->addVertexDistanceQuantity(
"geodesic", dist);
163 psMeshReg->addVertexDistanceQuantity(
"geodesic", dist);
170 ImGui::SliderFloat(
"dt", &
dt, 0.,4.);
171 ImGui::SliderFloat(
"ii radius for normal vector estimation", &
radiusII , 0.,10.);
172 ImGui::Checkbox(
"Skip regularization", &
skipReg);
174 ImGui::InputInt(
"Index of the first source vertex", &
sourceVertexId);
177 if(ImGui::Button(
"Precomputation (required if you change parameters)"))
183 if(ImGui::Button(
"Add a random source"))
192 if(ImGui::Button(
"Clear sources"))
202 if(ImGui::Button(
"Compute geodesic"))
216 params(
"surfaceComponents",
"All");
217 params(
"r-radius", (
double)
radiusII);
218 std::string filename = examplesPath + std::string(
"/samples/bunny-128.vol");
225 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
226 std::vector<RealPoint> positions;
228 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
229 faces.push_back(primalSurface->incidentVertices( face ));
232 positions = primalSurface->positions();
249 regularizedPosition.end(),
256 psMesh = polyscope::registerSurfaceMesh(
"digital surface", positions, faces);
257 psMeshReg = polyscope::registerSurfaceMesh(
"regularized surface", regularizedPosition, faces);
Aim: Smart pointer based on reference counts.
Aim: Implements Digital Surface Regularization as described in coeurjolly17regDGCI.
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 Crane2013 on polygonal surfaces (using Discrete differential calculus on polygo...
PolygonalCalculus::Vector Vector
Implements differential operators on polygonal surfaces from degoes2020discrete.
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...
static Parameters parametersGeometryEstimation()
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Parameters defaultParameters()
std::vector< RealVector > RealVectors
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static Parameters defaultParameters()
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
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
std::vector< std::pair< size_t, int > > source2count(GeodesicsInHeat< PolyCalculus >::Vector &source)
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...