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>
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/pick.h>
41 #include "ConfigExamples.h"
43 #include <Eigen/Dense>
44 #include <Eigen/Sparse>
46 using namespace DGtal;
73 auto projEmbedder = [&](
int f,
int v)
78 const auto cp = p - centroid;
92 heat->addSource( v_idx );
94 psMesh->addVertexScalarQuantity(
"source", source);
101 psMesh->addVertexDistanceQuantity(
"geodesic", dist);
108 if (polyscope::pick::haveSelection()) {
109 bool goodSelection =
false;
110 auto selection = polyscope::pick::getSelection();
111 auto selectedSurface =
static_cast<polyscope::SurfaceMesh*
>(selection.first);
112 size_t idx = selection.second;
115 auto surf = polyscope::getSurfaceMesh(
"digital surface");
116 goodSelection = goodSelection || (selectedSurface == surf);
117 const auto nv = selectedSurface->nVertices();
119 if ( goodSelection && idx < nv )
121 std::ostringstream otext;
122 otext <<
"Selected vertex = " << idx;
123 ImGui::Text(
"%s", otext.str().c_str() );
134 ImGui::SliderFloat(
"Lambda parameter", &
Lambda, 0.0, 1.0);
135 ImGui::SliderFloat(
"dt", &
dt, 0.,4.);
136 ImGui::Checkbox(
"Use mixed Neumann+Dirichlet heat solution", &
Mixed);
137 if(ImGui::Button(
"Precomputation (required if you change the dt)"))
143 if(ImGui::Button(
"Compute geodesic"))
152 ImGui::Text(
"You can use the mouse left-click to select the new source point.");
157 auto params = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();
158 params(
"surfaceComponents",
"All");
159 params(
"polynomial",
"x^2+(y+1)^2+z^2-1.0")
160 (
"minAABB",-1.0)(
"maxAABB",1.0)(
"offset",1.0)
162 auto shape = SH3::makeImplicitShape3D( params );
163 auto dshape = SH3::makeDigitizedImplicitShape3D( shape, params );
164 auto K = SH3::getKSpace( params );
165 auto binary_image = SH3::makeBinaryImage( dshape, params );
167 auto primalSurface= SH3::makePrimalSurfaceMesh(
surface);
168 auto surfels = SH3::getSurfelRange(
surface, params );
169 auto normals = SHG3::getNormalVectors( shape,
K, surfels, params );
172 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
173 std::vector<RealPoint> positions;
175 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
176 faces.push_back(primalSurface->incidentVertices( face ));
179 positions = primalSurface->positions();
192 psMesh = polyscope::registerSurfaceMesh(
"digital surface", positions, faces);
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...
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="")
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
SurfaceMesh< RealPoint, RealVector > SurfMesh
PolygonalCalculus< SH3::RealPoint, SH3::RealVector > PolyCalculus
polyscope::SurfaceMesh * psMesh
void picksource(int v_idx)
Shortcuts< Z3i::KSpace > SH3
ShortcutsGeometry< Z3i::KSpace > SHG3
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 ...
RealPoint & position(Vertex v)
RealPoint faceCentroid(Index f) const
RealVector & faceNormal(Face f)
bool setFaceNormals(RealVectorIterator itN, RealVectorIterator itNEnd)
Edges computeNonManifoldEdges() const
K init(Point(0, 0, 0), Point(512, 512, 512), true)