32 #include <unordered_map>
33 #include "ConfigExamples.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/base/Common.h"
36 #include "DGtal/geometry/surfaces/estimation/PlaneProbingTetrahedronEstimator.h"
37 #include "DGtal/geometry/surfaces/estimation/PlaneProbingParallelepipedEstimator.h"
38 #include "DGtal/geometry/surfaces/DigitalSurfacePredicate.h"
39 #include "DGtal/geometry/surfaces/estimation/PlaneProbingDigitalSurfaceLocalEstimator.h"
40 #include "DGtal/helpers/Shortcuts.h"
41 #include "DGtal/helpers/ShortcutsGeometry.h"
42 #include "DGtal/io/viewers/Viewer3D.h"
46 using namespace DGtal;
59 auto pointels = SH3::getPrimalVertices(
K, s,
true);
65 static const RealPoint shift(-0.5, -0.5, -0.5);
67 return p + 0.5 * u + 0.5 * v + shift;
72 int main(
int argc,
char** argv )
74 QApplication application(argc, argv);
76 std::string volfile = (argc > 1) ? argv[1] : (examplesPath +
"samples/cat10.vol");
78 auto params = SH3::defaultParameters() | SHG3::defaultParameters();
79 auto bimage = SH3::makeBinaryImage(volfile, params);
80 auto K = SH3::getKSpace(bimage, params);
81 auto surface = SH3::makeDigitalSurface(bimage,
K, params);
82 auto surfels = SH3::getSurfelRange(
surface);
85 double gridstep = params[
"gridstep"].as<
double>();
99 Estimator::ProbingFactory probingFactory = [&bound](
const Estimator::ProbingFrame& frame,
const SurfacePredicate& surfacePredicate) {
104 return new ProbingAlgorithm(frame.p, { frame.b1, frame.b2, frame.normal }, surfacePredicate, bound);
108 std::unordered_map<Surfel, RealPoint> preEstimations;
121 estimator.init(gridstep, surfels.begin(), surfels.end());
126 std::vector<Estimator::Quantity> quantities;
127 estimator.eval(surfels.begin(), surfels.end(), std::back_inserter(quantities));
133 Color fillColor = viewer.getFillColor();
136 for (
auto it = surfels.begin(); it != surfels.end(); ++it, ++i)
143 viewer.setFillColor(fillColor);
147 RealPoint const& preEstimation = estimator.getPreEstimation(it);
148 viewer.setLineColor(Color::Red);
149 viewer.addLine(origin, origin + 1.5 * preEstimation.
getNormalized(), 0.3);
152 viewer.setLineColor(Color::Green);
153 viewer.addLine(origin, origin + 1.5 * n.
getNormalized(), 0.3);
156 viewer << Viewer3D<>::updateDisplay;
Structure representing an RGB triple with alpha component.
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,...
Point uCoords(const Cell &c) const
Return its digital coordinates.
Aim: Adapt a plane-probing estimator on a digital surface to estimate normal vectors.
typename TetrahedronEstimator::Quantity Quantity
PointVector< dim, double, std::array< double, dim > > getNormalized() const
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...
LightDigitalSurface::SCell SCell
CountedPtr< SH3::DigitalSurface > surface
Point::Coordinate Integer
int main(int argc, char **argv)
RealPoint centerSurfel(KSpace const &K, SH3::SCell const &s)
DGtal is the top-level namespace which contains all DGtal functions and types.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.