27#include <DGtal/base/Common.h>
28#include <DGtal/helpers/StdDefs.h>
29#include <DGtal/helpers/Shortcuts.h>
30#include <DGtal/helpers/ShortcutsGeometry.h>
31#include <DGtal/shapes/SurfaceMesh.h>
32#include <DGtal/geometry/surfaces/DigitalSurfaceRegularization.h>
34#include <DGtal/dec/PolygonalCalculus.h>
35#include <DGtal/dec/GeodesicsInHeat.h>
37#include <polyscope/polyscope.h>
38#include <polyscope/surface_mesh.h>
39#include <polyscope/point_cloud.h>
41#include "ConfigExamples.h"
44#include <Eigen/Sparse>
58polyscope::SurfaceMesh *psMesh;
59polyscope::SurfaceMesh *psMeshReg;
80bool useProjectedCalculus =
true;
85 if (!useProjectedCalculus)
91 params2(
"r-radius", (
double) radiusII);
94 trace.
info()<<iinormals.size()<<std::endl;
97 const auto nn = iinormals[f];
105 centroid = centroid / (double)cpt;
107 auto cp = p-centroid;
111 psMesh->addFaceVectorQuantity(
"II normals", iinormals);
132 std::vector<std::pair<size_t,int>> counts;
133 for(
auto i=0; i< source.size(); ++i)
136 counts.push_back(std::pair<size_t,int>(i,1));
144 heat->addSource( pos );
146 psMesh->addVertexCountQuantity(
"Sources", source2count(source));
150 heatReg->addSource( pos );
152 psMeshReg->addVertexCountQuantity(
"Sources", source2count(source));
159 psMesh->addVertexScalarQuantity(
"source", heat->source());
162void computeGeodesics()
164 heat->addSource( sourceVertexId );
166 psMesh->addVertexCountQuantity(
"Sources", source2count(source));
168 psMesh->addVertexDistanceQuantity(
"geodesic", dist);
172 heatReg->addSource( sourceVertexId );
174 psMeshReg->addVertexCountQuantity(
"Sources", source2count(sourceReg));
176 psMeshReg->addVertexDistanceQuantity(
"geodesic", dist);
180bool isPrecomputed=
false;
183 ImGui::SliderFloat(
"dt", &dt, 0.,4.);
184 ImGui::SliderFloat(
"ii radius for normal vector estimation", &radiusII , 0.,10.);
185 ImGui::Checkbox(
"Skip regularization", &skipReg);
186 ImGui::Checkbox(
"Using projection", &useProjectedCalculus);
187 ImGui::InputInt(
"Index of the first source vertex", &sourceVertexId);
190 if(ImGui::Button(
"Precomputation (required if you change parameters)"))
196 if(ImGui::Button(
"Add a random source"))
205 if(ImGui::Button(
"Clear sources"))
215 if(ImGui::Button(
"Compute geodesic"))
229 params(
"surfaceComponents",
"All");
230 params(
"r-radius", (
double) radiusII);
231 std::string filename = examplesPath + std::string(
"/samples/bunny-128.vol");
238 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
239 std::vector<RealPoint> positions;
241 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
242 faces.push_back(primalSurface->incidentVertices( face ));
245 positions = primalSurface->positions();
247 surfmesh =
SurfMesh(positions.begin(),
251 std::cout << surfmesh << std::endl;
257 regul.attachConvolvedTrivialNormalVectors(params);
259 auto regularizedPosition = regul.getRegularizedPositions();
261 surfmeshReg =
SurfMesh(regularizedPosition.begin(),
262 regularizedPosition.end(),
269 psMesh = polyscope::registerSurfaceMesh(
"digital surface", positions, faces);
270 psMeshReg = polyscope::registerSurfaceMesh(
"regularized surface", regularizedPosition, faces);
271 psMeshReg->setEnabled(
false);
274 polyscope::state::userCallback = myCallback;
Aim: Smart pointer based on reference counts.
Aim: Implements Digital Surface Regularization as described in .
This class implements on polygonal surfaces (using Discrete differential calculus on polygonal surfa...
PolygonalCalculus::Vector Vector
Aim: Implements basic operations that will be used in Point and Vector classes.
auto dot(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v))
Dot product with a PointVector.
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...
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="")
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 ...
const Vertices & incidentVertices(Face f) const
RealPoint & position(Vertex v)
Edges computeNonManifoldEdges() const
int main(int argc, char **argv)