32 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/topology/SurfelAdjacency.h"
35 #include "DGtal/topology/DigitalSurface.h"
36 #include "DGtal/topology/helpers/BoundaryPredicate.h"
37 #include "DGtal/topology/SetOfSurfels.h"
38 #include "DGtal/topology/SCellsFunctors.h"
40 #include "DGtal/shapes/Shapes.h"
41 #include "DGtal/shapes/ShapeFactory.h"
42 #include "DGtal/shapes/GaussDigitizer.h"
44 #include "DGtal/io/boards/Board2D.h"
46 #include "DGtalCatch.h"
50 using namespace DGtal;
58 double angle = atan2(point[1], point[0]);
59 if(angle < 0.) angle += 2. * M_PI;
66 return angle(h * emb(cell));
75 AngleLessCell(
const KSpace& kspace,
const double h) : _kspace(kspace), _h(h)
79 inline bool operator()(
const SCell& a,
const SCell& b)
const
81 return angle(_kspace, a, _h) <
angle(_kspace, b, _h);
90 template <
typename Shape>
91 void digitize(
Shape& shape, std::vector<SCell>& sCells0, std::vector<SCell>& sCells1,
KSpace& kspace,
const double h)
103 digitizer.attach(shape);
105 domain = digitizer.getDomain();
107 kspace.
init(digitizer.getLowerBound(), digitizer.getUpperBound(),
true);
109 const SurfelAdj surfel_adjacency(
true);
110 const KSpace::SCell cell_bel = Surf::findABel(kspace, digitizer);
111 Surf::track2DBoundary(sCells1, kspace, surfel_adjacency, digitizer, cell_bel);
113 typedef std::vector<Point> Points;
115 Surf::track2DBoundaryPoints(points, kspace, surfel_adjacency, digitizer, cell_bel);
117 for(Points::const_iterator pi = points.begin(), pe = points.end(); pi != pe; ++pi) sCells0.push_back(kspace.
sCell(*pi, point_ref));
120 std::sort(sCells0.begin(), sCells0.end(), AngleLessCell(kspace, h));
121 std::sort(sCells1.begin(), sCells1.end(), AngleLessCell(kspace, h));
123 ASSERT(sCells0.size() == sCells1.size());
126 template <
typename Shape>
129 std::vector<SCell> sCells0, sCells1;
133 digitize(shape, sCells0, sCells1, kspace, h);
137 for(
unsigned int i = 0; i < sCells0.size(); i++)
142 auto prev = ( i + sCells0.size() - 3 ) % sCells0.size(), next = (i + 3) % sCells0.size();
144 RealPoint inner_prev = sCellToInnerPoint( sCells0[prev] );
145 RealPoint outer_prev = sCellToOuterPoint( sCells0[prev] );
147 RealPoint inner_next = sCellToInnerPoint( sCells0[next] );
148 RealPoint outer_next = sCellToOuterPoint( sCells0[next] );
160 const double norm2 = (p - h * canonicSCellEmbedder( sCells0[i]) ).norm();
162 if ( norm2 > sqrt(2.) * h)
172 const Ball ball(
Point(0,0), 1.0);
Aim: Model of the concept StarShaped represents any accelerated flower in the plane.
RealPoint getLowerBound() const
RealPoint getUpperBound() const
Aim: Model of the concept StarShaped represents any circle in the plane.
Aim: Model of the concept StarShaped represents any ellipse in the plane.
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
SCell sCell(const SPreCell &c) const
From a signed cell, returns a signed cell lying into this Khalismky space.
Aim: Implements basic operations that will be used in Point and Vector classes.
RealPoint closestPointWithWitnesses(const RealPoint &p, const RealPoint &left, const RealPoint &right, const int step) const
RealPoint findIntersection(const RealPoint &inner, const RealPoint &outer, const double epsilon) const
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Aim: transforms a signed cell c into a point corresponding to the signed cell of greater dimension th...
Aim: transforms a signed cell c into a point corresponding to the signed cell of greater dimension th...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
void digitize(Shape &shape, std::vector< SCell > &sCells0, std::vector< SCell > &sCells1, KSpace &kspace, const double h)
double angle(const DGtal::Z2i::RealPoint &point)
bool test_shape(Shape &shape, const double h, const double epsilon)
TEST_CASE("Projection test on various shapes")
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))