38 tinyxml2::XMLDocument doc;
41 std::cout <<
"arg missing!\n";
44 auto err = doc.LoadFile( argv[1] );
45 if( err != tinyxml2::XML_SUCCESS )
47 std::cout <<
"...exiting, failed to read file '" << argv[1] <<
"'\n";
53 std::pair<double,double> imSize(500.,500.);
57 std::cout <<
"Input image size: " << imSize.first <<
" x " << imSize.second <<
'\n';
59 catch(
const std::exception& error )
61 std::cout <<
"input file has no size, size set to 500x500\n -msg=" << error.what() <<
'\n';
65 doc.Accept( &visitor );
66 const auto& data = visitor.
get();
67 std::cout << argv[0] <<
": Read " << data.size() <<
" shapes in file '" << argv[1] <<
"'\n";
70 std::cout <<
"...exiting, no data!\n";
80 for(
const auto& e: data )
82 std::visit( dfunc, e );
88 <<
", size " <<
size(e) <<
"\n";
97 auto s =
FRect(pp_all);
98 out.setSize( s.width(), s.height() );
99 std::cout <<
"min/max=" << s <<
'\n';
101 out.write(
"demo_import.svg" );
void printFileAttrib(const tinyxml2::XMLDocument &doc)
Definition: homog2d.hpp:13077
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12395
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
PointPair_< double > PointPair
Definition: homog2d.hpp:12445
auto getImgSize(const tinyxml2::XMLDocument &doc)
Fetch size of image in SVG file.
Definition: homog2d.hpp:13092
A functor used to draw objects. To use with std::variant and std::visit()
Definition: homog2d.hpp:1068
Type type(const T &elem)
Free function. Returns the type of object or variant.
Definition: homog2d.hpp:10190
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
Visitor class, derived from the tinyxml2 visitor class. Used to import SVG data.
Definition: homog2d.hpp:12864
A functor to get the Bounding Box.
Definition: homog2d.hpp:10151
std::vector< img::Color > genRandomColors(size_t nb, int minval=20, int maxval=250)
Helper function, will generate a vector of nb random RGB colors.
Definition: homog2d.hpp:453
auto getMinMax(const PointPair2_< T1, T2 > &pp1, const PointPair2_< T3, T4 > &pp2)
Returns a pair of points holding min and max coordinates of the two input pair of points...
Definition: homog2d.hpp:10398
HOMOG2D_INUMTYPE size(const T &elem)
Returns size of element or variant (free function)
Definition: homog2d.hpp:10253
const std::vector< CommonType_< double > > & get() const
Used to access the data once the file has been read.
Definition: homog2d.hpp:12904
A functor to get pair of points englobing the element.
Definition: homog2d.hpp:10138
Opaque data structure, will hold the image type, depending on back-end library. This type is the one ...
Definition: homog2d.hpp:712
const char * getString(PtStyle t)
Definition: homog2d.hpp:496