30 #include <DGtal/base/Common.h>
31 #include <DGtal/helpers/StdDefs.h>
32 #include <DGtal/helpers/Shortcuts.h>
33 #include <DGtal/helpers/ShortcutsGeometry.h>
34 #include <DGtal/shapes/SurfaceMesh.h>
35 #include <DGtal/dec/PolygonalCalculus.h>
36 #include <DGtal/dec/VectorsInHeat.h>
38 #include <polyscope/polyscope.h>
39 #include <polyscope/surface_mesh.h>
43 using namespace DGtal;
59 polyscope::SurfaceMesh *
psMesh;
68 std::vector<Vector> X_0;
69 std::vector<Vertex> idX_0;
74 bool noSources =
true;
81 void addRandomSource()
84 VHM->addSource(
id,Eigen::Vector3d::Random(3).normalized());
87 X_0[id] = VHM->extrinsicVectorSourceAtVertex(
id);
88 psMesh->addVertexVectorQuantity(
"X_0",X_0);
100 psMesh->addVertexVectorQuantity(
"VHM field",VHM->compute());
112 X_0.resize(nv,Vector::Zero(3));
114 psMesh->addVertexVectorQuantity(
"X_0",X_0);
125 psMesh->addVertexVectorQuantity(
"X_0",X_0);
126 psMesh->addVertexVectorQuantity(
"VHM field",X_0);
132 for(
const auto id: idX_0)
135 VHM->addSource(
id, x);
136 X_0[id] = VHM->extrinsicVectorSourceAtVertex(
id);
138 psMesh->addVertexVectorQuantity(
"X_0",X_0);
144 if(ImGui::Button(
"Compute Vector Field"))
148 if(ImGui::Button(
"Add random source"))
152 if(ImGui::Button(
"Clear sources"))
157 if(ImGui::Button(
"Start/stop rotating sources"))
168 int main(
int argc,
char **argv)
170 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
171 std::vector<RealPoint> positions;
175 trace.
error()<<
"Missing vol file. Usage: exampleVectorHeatMethod bunny.vol"<<std::endl;
180 auto params = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();
181 params(
"surfaceComponents",
"All");
182 auto binary_image = SH3::makeBinaryImage(argv[1], params );
185 auto primalSurface = SH3::makePrimalSurfaceMesh(
surface);
188 for(
size_t face= 0 ; face < primalSurface->nbFaces(); ++face)
189 faces.push_back(primalSurface->incidentVertices( face ));
192 positions = primalSurface->positions();
208 Rotx << 1, 0,0,0,cos(theta),-sin(theta),0,sin(theta),cos(theta);
209 Roty << cos(theta), 0,sin(theta),0,1,0,-sin(theta),0,cos(theta);
210 Rotz << cos(theta), -sin(theta),0,sin(theta),cos(theta),0,0,0,1;
216 psMesh = polyscope::registerSurfaceMesh(
"Digital Surface", positions, faces);
221 polyscope::view::upDir = polyscope::view::UpDir::XUp;
Implements differential operators on polygonal surfaces from .
LinAlg::SparseMatrix SparseMatrix
Type of sparse matrix.
LinAlg::DenseMatrix DenseMatrix
Type of dense matrix.
LinAlg::DenseVector Vector
Type of Vector.
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...
This class implements on polygonal surfaces (using Discrete differential calculus on polygonal surfa...
SurfaceMesh< RealPoint, RealVector > SurfMesh
polyscope::SurfaceMesh * psMesh
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
DigitalPlane::Point Vector
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 ...
std::vector< Vertex > Vertices
The type that defines a list/range of vertices (e.g. to define faces)
Scalar averageEdgeLength() const
int main(int argc, char **argv)
K init(Point(0, 0, 0), Point(512, 512, 512), true)
EigenLinearAlgebraBackend::SparseMatrix SparseMatrix
ShortcutsGeometry< Z3i::KSpace > SHG3
PointVector< 3, double > RealPoint