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>
33#include <DGtal/dec/PolygonalCalculus.h>
34#include <DGtal/dec/GeodesicsInHeat.h>
36#include <polyscope/polyscope.h>
37#include <polyscope/surface_mesh.h>
38#include <polyscope/pick.h>
40#include "ConfigExamples.h"
43#include <Eigen/Sparse>
57polyscope::SurfaceMesh *psMesh;
72 auto projEmbedder = [&](
int f,
int v)
77 const auto cp = p - centroid;
85 heat->init(dt,Lambda,Mixed);
89void picksource(
int v_idx )
91 heat->addSource( v_idx );
93 psMesh->addVertexScalarQuantity(
"source", source);
96void computeGeodesics()
100 psMesh->addVertexDistanceQuantity(
"geodesic", dist);
103bool isPrecomputed=
false;
107 if (polyscope::pick::haveSelection()) {
108 bool goodSelection =
false;
109 auto selection = polyscope::pick::getSelection();
110 auto selectedSurface =
static_cast<polyscope::SurfaceMesh*
>(selection.first);
111 size_t idx = selection.second;
114 auto surf = polyscope::getSurfaceMesh(
"digital surface");
115 goodSelection = goodSelection || (selectedSurface == surf);
116 const auto nv = selectedSurface->nVertices();
118 if ( goodSelection && idx < nv )
120 std::ostringstream otext;
121 otext <<
"Selected vertex = " << idx;
122 ImGui::Text(
"%s", otext.str().c_str() );
129 picksource( vertex_idx );
133 ImGui::SliderFloat(
"Lambda parameter", &Lambda, 0.0, 1.0);
134 ImGui::SliderFloat(
"dt", &dt, 0.,4.);
135 ImGui::Checkbox(
"Use mixed Neumann+Dirichlet heat solution", &Mixed);
136 if(ImGui::Button(
"Precomputation (required if you change the dt)"))
142 if(ImGui::Button(
"Compute geodesic"))
156 params(
"surfaceComponents",
"All");
157 params(
"polynomial",
"x^2+(y+1)^2+z^2-1.0")
158 (
"minAABB",-1.0)(
"maxAABB",1.0)(
"offset",1.0)
170 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
171 std::vector<RealPoint> positions;
173 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
174 faces.push_back(primalSurface->incidentVertices( face ));
177 positions = primalSurface->positions();
179 surfmesh =
SurfMesh(positions.begin(),
184 std::cout << surfmesh << std::endl;
190 psMesh = polyscope::registerSurfaceMesh(
"digital surface", positions, faces);
193 polyscope::state::userCallback = myCallback;
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 getNormalVectors(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static Parameters defaultParameters()
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 CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
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)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
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 ...
RealVector & faceNormal(Face f)
RealPoint faceCentroid(Index f) const
bool setFaceNormals(RealVectorIterator itN, RealVectorIterator itNEnd)
RealPoint & position(Vertex v)
Edges computeNonManifoldEdges() const
int main(int argc, char **argv)