46 for(
int i=0; i< (int)a.
size(); i++){
54 for(
int i=0; i< (int) (a.
size()-1); i++){
58 cos(a.
ro(i+1).
value)*distanceNext, sin(a.
ro(i+1).
value)*distanceNext);
59 distance=distanceNext;
66 template <
typename TIterator,
typename TInteger,
int connectivity>
85 vector<LibBoard::Point> bb;
86 bb.push_back(topLeftBoard);
87 bb.push_back(bottomLeftBoard);
88 bb.push_back(bottomRightBoard);
89 bb.push_back(topRightBoard);
94 template <
typename TIterator,
typename TInteger,
int connectivity>
99 typedef TIterator ConstIterator;
102 ConstIterator itend = a.
myL; ++itend;
105 if(aBoard.
getMode(
"PointVector")==
"Grid" || aBoard.
getMode(
"PointVector")==
"")
107 vector<LibBoard::Point> contour;
108 for (ConstIterator i = a.
myF; i != itend; ++i) {
118 for (ConstIterator i = a.
myF; i != itend; ++i) {
124 template <
typename TIterator,
typename TInteger,
int connectivity>
130 if ( mode ==
"BoundingBox" )
131 drawAsBoundingBox( board, a );
132 else if ( mode ==
"Points" )
133 drawAsDigitalPoints( board, a );
134 else if ( ( mode ==
"" ) )
136 drawAsDigitalPoints( board, a );
137 drawAsBoundingBox( board, a );
140 ASSERT(
false && (
"draw( DGtal::Board2D & board, const DGtal::ArithmeticalDSS<TIterator,TInteger,connectivity> & a ): Unknown mode "+mode)==
"" );
147 template <
typename TPo
int>
153 drawArc(aBoard,c,cf2p.
p(),cf2p.
q(),
true);
159 template <
typename Po
int>
163 typedef typename Point::Coordinate Coordinate;
164 typedef Point Vector;
166 double cx = 0, cy = 0, radius = 1;
174 alpha1 = (alpha1<0)?(alpha1+2.0*
M_PI):alpha1;
177 alpha2 = (alpha2<0)?(alpha2+2.0*
M_PI):alpha2;
179 Vector u(cf3p.
p() - cf3p.
q());
180 Vector v(cf3p.
r() - cf3p.
p());
181 bool orientation = ( ( (u[0] * v[1]) - (u[1] * v[0]) ) < 0 )?(!anOrientation):anOrientation;
183 aBoard.
drawArc (cx, cy, radius, alpha1, alpha2, orientation);
194 template <
typename Po
int>
198 typedef typename Point::Coordinate Coordinate;
199 typedef Point Vector;
201 double cx = 0, cy = 0, radius = 1;
209 alpha1 = (alpha1<0)?(alpha1+2.0*
M_PI):alpha1;
212 alpha2 = (alpha2<0)?(alpha2+2.0*
M_PI):alpha2;
214 Vector u(cf3p.
p() - cf3p.
q());
215 Vector v(cf3p.
r() - cf3p.
p());
216 bool orientation = ( ( (u[0] * v[1]) - (u[1] * v[0]) ) < 0 )?(!anOrientation):anOrientation;
218 aBoard.
drawArc (cx, cy, radius, alpha1, alpha2, orientation);
220 double fx = cx + radius*std::cos(alpha1);
221 double fy = cy + radius*std::sin(alpha1);
222 double lx = cx + radius*std::cos(alpha2);
223 double ly = cy + radius*std::sin(alpha2);
237 template <
typename Po
int>
241 typedef typename Point::Coordinate Coordinate;
242 typedef Point Vector;
244 double cx = 0, cy = 0, radius = 1;
252 alpha1 = (alpha1<0)?(alpha1+2.0*
M_PI):alpha1;
255 alpha2 = (alpha2<0)?(alpha2+2.0*
M_PI):alpha2;
257 Vector u(cf3p.
p() - cf3p.
q());
258 Vector v(cf3p.
r() - cf3p.
p());
259 bool orientation = ( ( (u[0] * v[1]) - (u[1] * v[0]) ) < 0 )?(!anOrientation):anOrientation;
261 aBoard.
drawArc (cx, cy, radius-w, alpha1, alpha2, orientation);
263 aBoard.
drawArc (cx, cy, radius+w, alpha1, alpha2, orientation);
265 double ifx = cx + (radius-w)*std::cos(alpha1);
266 double ify = cy + (radius-w)*std::sin(alpha1);
267 double ofx = cx + (radius+w)*std::cos(alpha1);
268 double ofy = cy + (radius+w)*std::sin(alpha1);
269 aBoard.
drawLine(ifx, ify, ofx, ofy);
271 double ilx = cx + (radius-w)*std::cos(alpha2);
272 double ily = cy + (radius-w)*std::sin(alpha2);
273 double olx = cx + (radius+w)*std::cos(alpha2);
274 double oly = cy + (radius+w)*std::sin(alpha2);
275 aBoard.
drawLine(ilx, ily, olx, oly);
286 template <
typename Po
int>
291 ASSERT( (mode==
"Arc" || mode==
"" || mode==
"Sector"|| mode==
"Annulus") ||
292 (
"draw(Board2D & aBoard, const DGtal::CircleFrom3Points<Point> & cf3p, const Point& aPoint1, const Point& aPoint2): Unknown mode "+mode)==
"" );
294 if ( mode ==
"Arc" || ( mode ==
"" ) )
295 drawArc( aBoard, cf3p, aPoint1, aPoint2, anOrientation);
296 else if ( mode ==
"Sector" )
297 drawSector( aBoard, cf3p, aPoint1, aPoint2, anOrientation);
298 else if ( mode ==
"Annulus" )
299 drawAnnulus( aBoard, cf3p, aPoint1, aPoint2, anOrientation);
302 template <
typename TPo
int>
306 typedef typename TPoint::Coordinate Coordinate;
308 double cx = 0, cy = 0, radius = 1;
326 template<
typename Domain>
331 typedef typename Domain::Point
Point;
332 typedef typename Point::Coordinate Coordinate;
333 typedef typename std::set<Point>::const_iterator ConstIterator;
335 ASSERT(Domain::Space::dimension == 2);
336 for(ConstIterator it = s.
begin(); it != s.
end(); ++it)
351 template<
typename Domain>
356 typedef typename Domain::Point
Point;
357 typedef typename std::vector<Point>::const_iterator ConstIterator;
359 if (Domain::dimension == 2)
361 for(ConstIterator it = v.
begin(); it != v.
end(); ++it)
365 ASSERT(
false && (
"draw-NOT-YET-IMPLEMENTED-in-ND"));
371 template <
typename TIterator,
typename TInteger,
int connectivity>
377 typedef std::list<Point> Polygon;
379 typedef typename Polygon::const_iterator ConstIterator;
382 vector<LibBoard::Point> polyline;
385 ConstIterator i = fp.
polygon().begin();
386 for ( ;i != fp.
polygon().end();++i) {
395 Point p = (*fp.
polygon().begin());
403 template <
typename TIterator,
typename TInteger,
int connectivity>
409 if ( mode ==
"Polygon" )
410 drawAsPolygon( board, fp );
411 else if ( ( mode ==
"Both" ) || ( mode ==
"" ) )
413 drawAsPolygon( board, fp );
417 mode =
"draw( DGtal::Board2D & board, const DGtal::FP<TIterator,TInteger,connectivity> & fp ): Unknown mode "+mode;
418 ASSERT2(
false, mode );
425 template <
typename TInteger>
430 typedef TInteger Integer;
433 vector<Point> aVContour;
435 TInteger minX, minY, maxX, maxY;
438 vector<LibBoard::Point> contour;
439 for(
unsigned int i=0; i< aVContour.size(); i++){
446 template <
typename TInteger>
451 typedef TInteger Integer;
454 vector<Point> aVContour;
456 TInteger minX, minY, maxX, maxY;
459 vector<LibBoard::Point> contour;
460 for(
unsigned int i=0; i< aVContour.size(); i++){
467 template <
typename TInteger>
473 ASSERT( (mode==
"Grid" || mode==
"" || mode==
"InterGrid") ||
474 (
"draw( DGtal::Board2D & board, const DGtal::FreemanChain<TInteger> & f ): Unknown mode "+mode)==
"" );
476 if ( mode ==
"Grid" || ( mode ==
"" ) )
477 drawAsGrid( aBoard, f );
478 else if ( mode ==
"InterGrid" )
479 drawAsInterGrid( aBoard, f );
485 template <
typename TConstIterator>
490 typedef TConstIterator ConstIterator;
492 typedef typename Pair::first_type
Point;
494 double alpha, beta, gamma;
497 typedef typename Point::Coordinate Coordinate;
500 Pair firstPair( *g.
begin() );
505 double fx = (fx1+fx2)/2.0;
506 double fy = (fy1+fy2)/2.0;
507 g.
projects(fx, fy, alpha, beta, gamma);
510 ConstIterator it (g.
end());
512 Pair lastPair( *it );
517 double lx = (lx1+lx2)/2.0;
518 double ly = (ly1+ly2)/2.0;
519 g.
projects(lx, ly, alpha, beta, gamma);
526 template <
typename TConstIterator>
532 typedef TConstIterator ConstIterator;
534 typedef typename Pair::first_type
Point;
540 typedef typename Point::Coordinate Coordinate;
543 Pair firstPair( *g.
begin() );
550 ConstIterator it (g.
end());
552 Pair lastPair( *it );
578 if ( mode ==
"Sector" )
579 drawSector( aBoard, circleToDraw, p1, p2, orientation );
580 else if ( mode ==
"Annulus" )
581 drawAnnulus( aBoard, circleToDraw, p1, p2, orientation );
583 drawArc( aBoard, circleToDraw, p1, p2, orientation );
598 template <
typename TIterator,
typename TInteger>
602 typedef TIterator Iterator;
604 typedef typename Point::Coordinate Coordinate;
607 Point p1 = *(f.
begin());
612 Iterator it (f.
end());
625 template <
typename TKSpace>
630 ConstIterator it (
object.begin() );
631 ConstIterator itEnd (
object.end() );
632 for( ; it != itEnd; ++it)
640 template <
typename TIterator,
typename TSCell>
645 typedef typename Range::ConstIterator ConstIterator;
647 ConstIterator it (
object.begin() );
648 ConstIterator itEnd (
object.end() );
649 for( ; it != itEnd; ++it)
657 template <
typename TIterator,
typename TKSpace>
662 typedef typename Range::ConstIterator ConstIterator;
664 ConstIterator it (
object.begin() );
665 ConstIterator itEnd (
object.end() );
666 for( ; it != itEnd; ++it)
668 aBoard <<
SetMode(it->className(),
"Grid");
675 template <
typename TIterator,
typename TKSpace>
678 typename TKSpace::Space::RealPoint> &
object )
680 typedef typename TKSpace::Space::RealPoint RPoint;
682 typedef typename Range::ConstIterator ConstIterator;
684 ConstIterator it (
object.begin() );
685 ConstIterator itEnd (
object.end() );
686 for( ; it != itEnd; ++it)
690 aBoard.
drawLine( p[0]-s, p[1]-s, p[0]+s, p[1]+s );
691 aBoard.
drawLine( p[0]-s, p[1]+s, p[0]+s, p[1]-s );
697 template <
typename TIterator,
typename TKSpace>
700 std::pair<typename TKSpace::Point, typename TKSpace::Vector> > &
object )
702 typedef typename TKSpace::Point
Point;
703 typedef typename TKSpace::Vector Vector;
704 typedef std::pair<Point, Vector> Arrow;
706 typedef typename Range::ConstIterator ConstIterator;
708 ConstIterator it (
object.begin() );
709 ConstIterator itEnd (
object.end() );
710 for( ; it != itEnd; ++it)
713 Vector shift( a.second );
719 draw(aBoard, shift, a.first);
725 template <
typename TIterator,
typename TKSpace>
728 typename TKSpace::Point > &
object )
730 typedef typename TKSpace::Point
Point;
732 typedef typename Range::ConstIterator ConstIterator;
734 ConstIterator it (
object.begin() );
735 ConstIterator itEnd (
object.end() );
736 for( ; it != itEnd; ++it)
738 aBoard <<
SetMode( it->className(),
"Both" )
747 template <
typename TIterator,
typename TKSpace>
750 typename TKSpace::Point > &
object )
752 typedef typename TKSpace::Point
Point;
754 typedef typename Range::ConstIterator ConstIterator;
756 ConstIterator it (
object.begin() );
757 ConstIterator itEnd (
object.end() );
758 for( ; it != itEnd; ++it)
760 aBoard <<
SetMode( it->className(),
"Both" )
769 template <
typename TIterator,
typename TKSpace>
772 std::pair<typename TKSpace::Point, typename TKSpace::Point> > &
object )
774 typedef typename TKSpace::Point
Point;
775 typedef std::pair<Point, Point> Pair;
777 typedef typename Range::ConstIterator ConstIterator;
779 ConstIterator it (
object.begin() );
780 ConstIterator itEnd (
object.end() );
781 for( ; it != itEnd; ++it)
784 aBoard <<
SetMode( pair.first.className(),
"Both" )
796 template<
typename TSpace>
801 typedef typename TSpace::Integer Integer;
803 ASSERT(TSpace::dimension == 2 ||
"drawAsGrid-NOT-YET-IMPLEMENTED-in-ND");
805 if (TSpace::dimension == 2)
833 template<
typename TSpace>
838 typedef typename TSpace::Integer Integer;
840 ASSERT(TSpace::dimension==2 ||
"drawAsPaving-NOT-YET-IMPLEMENTED-in-ND" );
842 if (TSpace::dimension == 2)
852 template<
typename TSpace>
858 ASSERT((mode==
"" || mode==
"Grid" || mode==
"Paving") ||
859 (
"draw( DGtal::Board2D & board, const DGtal::HyperRectDomain<TSpace> & h ): Unknown mode "+mode)==
"");
861 if ( ( mode ==
"" ) || ( mode ==
"Grid" ) )
862 drawAsGrid( board, h );
863 else if ( mode ==
"Paving" )
864 drawAsPaving( board, h );
870 template <
typename C,
typename Domain,
typename Value,
typename HashKey>
881 ASSERT ( Domain::dimension == 2 );
889 c = cmap ( i.
getNode ( key )->getObject() );
903 drawImageRecursive<C>( aBoard, i, children[0], np, nlen, board, cmap );
907 drawImageRecursive<C>( aBoard, i, children[1], np, nlen, board, cmap );
911 drawImageRecursive<C>( aBoard, i, children[2], np, nlen, board, cmap );
915 drawImageRecursive<C>( aBoard, i, children[3], np, nlen, board, cmap );
919 template <
typename C,
typename Domain,
typename Value,
typename HashKey>
923 const Value &minV,
const Value &maxV )
925 static const HashKey ROOT_KEY =
static_cast<HashKey
>(1);
927 ASSERT ( Domain::dimension == 2 );
929 C colormap ( minV, maxV );
939 drawImageRecursive<C>( board, i, ROOT_KEY, p, len, board, colormap );
945 template <
typename Colormap,
typename Image>
955 ASSERT(D::Space::dimension == 2);
957 Colormap colormap(minV, maxV);
962 for (
typename D::ConstIterator it = ldomain.begin();
963 it != ldomain.end(); ++it)
965 val = i.operator()( (*it) );
969 castToInt64_t((*it)[0]) - 0.5,
971 castToInt64_t((*it)[1]) + 0.5, 1, 1);
978 template < Dimension dim,
typename TInteger >
988 float retract = 0.05f;
991 float dx = xodd ? 1.0f - 2.0f*retract : 2.0f*retract;
992 float dy = yodd ? 1.0f - 2.0f*retract : 2.0f*retract;
993 board.
drawRectangle( !xodd ? x - retract - 0.5 : x + retract - 0.5,
994 !yodd ? y + retract - 0.5 : y - retract + 0.5,
1001 template <
typename TDigitalTopology,
typename TDigitalSet>
1006 typedef TDigitalSet DigitalSet;
1007 typedef typename DigitalSet::Point
Point;
1010 typedef typename DigitalSet::Domain Domain;
1018 for (
typename TDigitalSet::ConstIterator it = o.
pointSet().begin();
1024 for (
typename SmallObject::DigitalSet::ConstIterator it2 = neig.pointSet().begin();
1025 it2 != neig.pointSet().end();
1029 draw(aBoard, p, (*it));
1034 template <
typename TDigitalTopology,
typename TDigitalSet>
1043 if ( mode ==
"DrawAdjacencies" )
1046 drawWithAdjacencies( board, o );
1049 ASSERT(
false && ((
"draw( DGtal::Board2D & board, const DGtal::Object<TDigitalTopology, TDigitalSet> & o ): Unknown mode " + mode) ==
""));
1055 template<Dimension dim,
typename TComponent>
1065 template<Dimension dim,
typename TComponent>
1075 template<Dimension dim,
typename TComponent>
1081 ASSERT( (mode==
"Paving" || mode==
"Grid" || mode==
"Both" || mode==
"") ||
1082 (
"draw( DGtal::Board2D & board, const DGtal::PointVector<dim,TComponent> & p ): Unknown mode "+mode)==
"" );
1084 if ( mode ==
"Paving" || ( mode ==
"" ) )
1085 drawAsPaving( board, p );
1086 else if ( mode ==
"Grid" )
1087 drawAsGrid( board, p );
1088 else if ( ( mode ==
"Both" ))
1090 drawAsPaving( board, p );
1091 drawAsGrid( board, p );
1095 template<Dimension dim,
typename TComponent>
1103 board.
drawArrow((
float)apoint[0], (
float) apoint[1],
1104 (
float) apoint[0] + p.
myArray[0], (
float)apoint[1] + p.
myArray[1],
1111 template <
typename Shape>
1116 typedef typename Shape::Point
Point;
1117 typedef typename std::list<Point>::const_iterator ConstForwardIterator;
1120 Shape s( p.
shape() );
1121 ConstForwardIterator i = p.
pHull().begin();
1124 while ( i != p.
pHull().end() ) {
1131 i = p.
qHull().begin();
1134 while ( i != p.
qHull().end() ) {
1141 Point Pf(*p.
pHull().begin());
1142 Point Pl(*p.
pHull().rbegin());
1143 Point Qf(*p.
qHull().begin());
1144 Point Ql(*p.
qHull().rbegin());
1155 template < Dimension dim,
typename TInteger >
1165 float retract = 0.05f;
1168 float dx = xodd ? 1.0f - 2.0f*retract : 2.0f*retract;
1169 float dy = yodd ? 1.0f - 2.0f*retract : 2.0f*retract;
1170 board.
drawRectangle( !xodd ? x - retract - 0.5 : x + retract - 0.5,
1171 !yodd ? y + retract - 0.5 : y - retract + 0.5,
1178 template <
typename TPo
int>
1183 aBoard.
drawLine(slf2p.
p()[0],slf2p.
p()[1],slf2p.
q()[0],slf2p.
q()[1]);
1205 template <
typename TSpace,
typename TSequence>
1217 ASSERT( mode==
"Filled" || mode==
"" || mode==
"Transparent" ||
1218 (
"draw(Board2D & aBoard, const DGtal::LatticePolytope2D<Space,Sequence> & cip): Unknown mode "+mode)==
"" );
1220 std::vector<BoardPoint> pts;
1222 for ( ConstIterator it = cip.
begin(), it_end = cip.
end(); it != it_end; ++it )