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 <polyscope/polyscope.h>
35#include <polyscope/surface_mesh.h>
36#include <polyscope/point_cloud.h>
38#include <DGtal/shapes/WindingNumbersShape.h>
39#include <DGtal/shapes/GaussDigitizer.h>
41#include "ConfigExamples.h"
55 params(
"surfaceComponents",
"All")(
"gridstep", 1. )(
"r-radius" , 4.0);
57 std::string filename = examplesPath + std::string(
"/samples/bunny-32.vol");
68 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> faces;
69 std::vector<RealPoint> positions;
70 for(
auto face= 0 ; face < primalSurface->nbFaces(); ++face)
71 faces.push_back(primalSurface->incidentVertices( face ));
73 positions = primalSurface->positions();
81 trace.
info()<<
"Got "<<surfels.size()<<
" surfels."<<std::endl;
87 auto psMesh = polyscope::registerSurfaceMesh(
"input digital surface", positions, faces);
90 Eigen::MatrixXd points(surfels.size(),3);
91 Eigen::MatrixXd normals(surfels.size(),3);
92 std::ofstream ofs (
"bunny.pts", std::ofstream::out);
93 for(
auto i=0; i< surfels.size(); ++i)
95 auto p = embedder(surfels[i]);
104 ofs<<p(0)<<
" "<<p(1)<<
" "<<p(2)<<
" "<<n(0)<<
" "<< n(1)<<
" "<<n(2)<<std::endl;
107 auto pc= polyscope::registerPointCloud(
"input boundary points", points);
108 pc->addVectorQuantity(
"normals", normals);
117 auto resample_h = [&](
double h){
120 pointEmbedder.
init( h );
128 Eigen::MatrixXd queries(size,3);
130 for(
const auto &vox:
domain)
132 Eigen::RowVector3<double> p(vox[0],vox[1],vox[2]);
134 queries.row(cpt) = p;
137 trace.
info()<<
"Cpt= "<<cpt<<
" size= "<<size<<std::endl;
138 auto orientations = wnshape.orientationBatch(queries);
143 for(
const auto &voxel:
domain)
145 if (orientations[cpt]==
INSIDE)
146 voxels.insertNew(voxel);
149 trace.
info() <<
"Number of voxels = "<<voxels.size()<<std::endl;
153 kspace.
init(lowerPoint, upperPoint,
true);
159 MySurfelAdjacency surfAdj(
true );
160 MySetOfSurfels theSetOfSurfels( kspace, surfAdj );
166 trace.
info()<<
"Surfel set size= "<<theSetOfSurfels.surfelSet().size()<<std::endl;
172 std::vector<RealPoint> positionsReco = primalSurfaceReco->positions();
174 std::for_each(std::begin(positionsReco), std::end(positionsReco), [&](
RealPoint &p){p=p*h;});
176 std::vector<std::vector<SH3::SurfaceMesh::Vertex>> facesReco;
177 for(
auto face= 0 ; face < primalSurfaceReco->nbFaces(); ++face)
178 facesReco.push_back(primalSurfaceReco->incidentVertices( face ));
179 auto psMesh = polyscope::registerSurfaceMesh(
"Reconstruction "+std::to_string(h), positionsReco, facesReco);
189 trace.
warning() <<
"CMake Debug mode detected, limiting upscaling to 0.5.";
Aim: Smart pointer based on reference counts.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: A simple point embedder where grid steps are given for each axis. Note that the real point (0,...
Point floor(const RealPoint &p) const
Point ceil(const RealPoint &p) const
void init(typename RealVector::Component gridStep)
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
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()
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())
std::map< Cell, IdxVertex > Cell2Index
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
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 void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
polyscope::SurfaceMesh * psMesh
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
SHG3::RealVectors iinormals
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
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 ...
int main(int argc, char **argv)
Vector lower(const Vector &z, unsigned int k)
Vector upper(const Vector &z, unsigned int k)