homog2d library
|
A test file for homog2d, needs Catch2, v2 (single header file version), see https://github.com/catchorg/Catch2
Run with $ make test
More...
#include "catch.hpp"
#include "../homog2d.hpp"
#include "figures_test/polyline_inside_a1.code"
#include "figures_test/polyline_inside_a2.code"
#include "figures_test/polyline_inside_a3.code"
#include "figures_test/polyline_inside_a4.code"
#include "figures_test/polyline_inside_b1.code"
#include "figures_test/polyline_inside_b2.code"
#include "figures_test/polyline_inside_b3.code"
#include "figures_test/frect_intersect_1.code"
#include "figures_test/frect_intersect_2.code"
#include "figures_test/frect_intersect_3.code"
#include "figures_test/frect_intersect_4.code"
#include "figures_test/frect_intersect_5.code"
#include "figures_test/frect_intersect_6.code"
#include "figures_test/frect_intersect_7.code"
#include "figures_test/frect_intersect_8.code"
#include "figures_test/frect_intersect_9.code"
#include "figures_test/frect_intersect_10.code"
#include "figures_test/frect_intersect_11.code"
#include "figures_test/frect_intersect_12.code"
#include "figures_test/frect_intersect_13.code"
#include "figures_test/polyline_min_1O.code"
#include "figures_test/polyline_min_1C.code"
#include "figures_test/polyline_min_2O.code"
#include "figures_test/polyline_min_2C.code"
#include "figures_test/polyline_min_3O.code"
#include "figures_test/polyline_min_3C.code"
#include "figures_test/polyline_comp_1a.code"
#include "figures_test/polyline_comp_1b.code"
#include "figures_test/polyline_chull_1.code"
Macros | |
#define | CATCH_CONFIG_RUNNER |
#define | HOMOG2D_BIND_X xxx |
see test [gen_bind] More... | |
#define | HOMOG2D_TEST_MODE |
#define | LOCALLOG(a) |
#define | NUMTYPE double |
Numerical type for object storage for tests. This is usually defined by makefile. (The internal numerical type for the library is defined by HOMOG2D_INUMTYPE) More... | |
#define | STR(s) #s |
#define | XSTR(s) STR(s) |
Functions | |
CHECK (s1.getPointAt(0)==Point2d_< NUMTYPE >(0, 0)) | |
CHECK (s1.getPointAt(5)==Point2d_< NUMTYPE >(5, 0)) | |
CHECK (s1.getPointAt(10)==Point2d_< NUMTYPE >(10, 0)) | |
CHECK (s1.getPointAt(20)==Point2d_< NUMTYPE >(20, 0)) | |
CHECK (pol.size()==5) | |
CHECK (opol.size()==0) | |
CHECK (cpol.size()==0) | |
CHECK (cir.size()==1) | |
CHECK (ell.size()==1) | |
CHECK (rect.size()==4) | |
CHECK (seg.size()==2) | |
CHECK (li.size()==0) | |
CHECK (pt.size()==1) | |
CHECK (size(opol)==0) | |
CHECK (size(cpol)==0) | |
CHECK (size(cir)==1) | |
CHECK (size(ell)==1) | |
CHECK (size(rect)==4) | |
CHECK (size(seg)==2) | |
CHECK (size(li)==0) | |
CHECK (size(pt)==1) | |
CHECK_THROWS (CPolyline(-5, 5u)) | |
CHECK_THROWS (CPolyline(1, 2u)) | |
CHECK_THROWS (CPolyline(0, 5u)) | |
CHECK_THROWS (pol.set(1, 2u)) | |
CHECK_THROWS (pol.set(0, 5u)) | |
CHECK_THROWS (pol.set(-5, 5u)) | |
CHECK_THROWS (pol.set(5, 0u)) | |
template<typename PT , typename CONT > | |
void | checkSizeNF (const PT &pt, const CONT &cont) |
long double | computeDistTransformedLined (Homogr_< NUMTYPE > &H, Point2d_< NUMTYPE > pt1) |
Computation of the line passed through H^{-T} and computation of the distance between the resulting line and the transformed point. Should be 0, always. More... | |
std::string | FullPrecision (long double d) |
template<typename I > | |
void | local_draw_test (img::Image< I > &im, std::string fn) |
Make sure all drawing functions and member functions are implemented. More... | |
local_draw_test (im, "BUILD/dummy_draw.svg") | |
local_draw_test (im, "BUILD/dummy_draw.png") | |
template<typename I , typename T > | |
void | local_draw_test2 (img::Image< I > &im, T &t) |
Helper function for local_draw_test() More... | |
int | main (int argc, char *argv[]) |
template<typename T , typename U > | |
void | polytest_1 (const base::PolylineBase< T, U > &pl1) |
pol | set (8, 4u) |
TEST_CASE ("numerical types access", "[types-access]") | |
TEST_CASE ("comparison testing", "[comparison-test]") | |
TEST_CASE ("types testing 1", "[test-types-1]") | |
TEST_CASE ("types testing 2", "[test-types-2]") | |
TEST_CASE ("normalization", "[normaliz]") | |
TEST_CASE ("homogeneous coordinates testing", "[homogeneous]") | |
TEST_CASE ("infinity point", "[points-inf]") | |
TEST_CASE ("types testing 3", "[test-types-3]") | |
TEST_CASE ("stream operator << test", "[streamingop-test]") | |
TEST_CASE ("line/point distance", "[lp-dist]") | |
TEST_CASE ("side-pt-line", "[side-pt-line]") | |
TEST_CASE ("test1", "[test1]") | |
TEST_CASE ("build point line from container", "[build-cont]") | |
TEST_CASE ("test throw", "[test_thr]") | |
TEST_CASE ("test parallel", "[test_para]") | |
TEST_CASE ("dist2points", "[t_d2p]") | |
TEST_CASE ("Homogr constructors", "[testHC]") | |
TEST_CASE ("test Homogr", "[testH]") | |
TEST_CASE ("matrix inversion", "[testH3]") | |
TEST_CASE ("line transformation", "[testH3]") | |
TEST_CASE ("matrix chained operations", "[testH2]") | |
TEST_CASE ("getPoints", "[test_points]") | |
TEST_CASE ("getAngle", "[test_angle]") | |
TEST_CASE ("getCorrectPoints", "[gcpts]") | |
TEST_CASE ("IsInside - manual", "[IsInside_man]") | |
TEST_CASE ("Polyline IsInside Polyline", "[tpolipol]") | |
TEST_CASE ("Point2d IsInside Polyline", "[tptipol]") | |
TEST_CASE ("Line2d IsInside something", "[tlir]") | |
TEST_CASE ("Point2d IsInside Circle", "[tptic]") | |
TEST_CASE ("Point2d IsInside FRect", "[tptir]") | |
TEST_CASE ("Segment IsInside FRect", "[tsir]") | |
TEST_CASE ("Circle IsInside FRect", "[tcir]") | |
TEST_CASE ("Circle IsInside Circle", "[tcic]") | |
TEST_CASE ("Intersection", "[int_all]") | |
TEST_CASE ("Line/Line intersection", "[int_LL]") | |
TEST_CASE ("Segment/Segment intersection", "[int_SS]") | |
TEST_CASE ("Circle/Circle intersection", "[int_CC]") | |
TEST_CASE ("FRect/FRect intersection", "[int_FF]") | |
TEST_CASE ("IoU of 2 rectangles", "[IOU_RECT]") | |
TEST_CASE ("Circle/Segment intersection", "[int_CS]") | |
TEST_CASE ("Circle/FRect intersection", "[int_CF]") | |
TEST_CASE ("Circle/Line intersection", "[int_CL]") | |
TEST_CASE ("Line/Segment intersection", "[int_LS]") | |
TEST_CASE ("Line/FRect intersection", "[int_LF]") | |
TEST_CASE ("Colinearity", "[colinearity]") | |
TEST_CASE ("Line2d", "[line1]") | |
TEST_CASE ("Circle", "[cir1]") | |
TEST_CASE ("Circle from points", "[cir2]") | |
TEST_CASE ("Ellipse", "[ell1]") | |
TEST_CASE ("OSegment point side", "[oseg-pt-side]") | |
TEST_CASE ("Segment", "[seg1]") | |
TEST_CASE ("Translate", "[trans]") | |
TEST_CASE ("MoveTo", "[moveto]") | |
TEST_CASE ("Segment-split-1", "[seg-split-1]") | |
TEST_CASE ("Segment-split-2", "[seg-split-2]") | |
TEST_CASE ("Segment 2", "[seg2]") | |
TEST_CASE ("Segment extended", "[seg_extended]") | |
TEST_CASE ("Segment orthogonal", "[seg_orthog]") | |
TEST_CASE ("min/max of two objects", "[minmax]") | |
TEST_CASE ("generalized bounding box of two objects", "[gen-BB]") | |
TEST_CASE ("bounding box of container", "[BB-cont]") | |
TEST_CASE ("common bounding box with points ", "[point2d-BB]") | |
TEST_CASE ("FRect pair bounding box", "[frect-BB]") | |
TEST_CASE ("bounding box of two objects", "[getBB-pair]") | |
TEST_CASE ("FRect", "[frect]") | |
TEST_CASE ("FRect extended", "[frect-ext]") | |
TEST_CASE ("FRect diagonals", "[frect-diags]") | |
TEST_CASE ("Polyline comparison 1", "[polyline-comparison-1]") | |
TEST_CASE ("Polyline minimization", "[polyline-min]") | |
TEST_CASE ("Polyline", "[polyline]") | |
TEST_CASE ("Polyline setParallelogram", "[polyline-setParallelogram]") | |
TEST_CASE ("Polyline get extreme point", "[polyline-getExtremePoint]") | |
TEST_CASE ("Bounding Box of set of objects", "[BB-cont]") | |
TEST_CASE ("getCenters() and getLines()", "[getCenters]") | |
TEST_CASE ("Polygon convexity", "[polyline-convex]") | |
TEST_CASE ("Polygon orientation", "[polyline-orient]") | |
TEST_CASE ("Polyline basic", "[polyline-basic]") | |
TEST_CASE ("Polyline fullstep rotation", "[polyline-rot]") | |
TEST_CASE ("Polygon area", "[polyline-area]") | |
TEST_CASE ("Polyline comparison 2", "[polyline-comp-2]") | |
TEST_CASE ("convex hull", "[conv_hull]") | |
TEST_CASE ("nearest/farthest points", "[nfp]") | |
TEST_CASE ("pts_inside", "[ptsins]") | |
TEST_CASE ("variant conversion tests", "[varconv]") | |
TEST_CASE ("variant-based polymorphism", "[polymorph_1]") | |
TEST_CASE ("SVG_Import_1", "[svg_import_1]") | |
TEST_CASE ("SVG Import Ellipse", "[svg_import_ell]") | |
TEST_CASE ("SVG Import path 1", "[svg_import_path_1]") | |
TEST_CASE ("boost geometry point import", "[bg-pt-import]") | |
TEST_CASE ("boost geometry point export", "[bg-pt-export]") | |
TEST_CASE ("boost geometry vector point export", "[bg-vpt-export]") | |
TEST_CASE ("Opencv build H", "[test_opencv2]") | |
TEST_CASE ("Opencv binding", "[test_opencv]") | |
Variables | |
Circle | cir |
CPolyline | cpol |
Ellipse | ell |
double | g_epsilon = std::numeric_limits<NUMTYPE>::epsilon()*10000. |
Line2d | li |
CPolyline | pol (5, 5u) |
Point2d | pt |
FRect | rect |
Segment | seg |
A test file for homog2d, needs Catch2, v2 (single header file version), see https://github.com/catchorg/Catch2
Run with $ make test
This file holds mostly "general" tests.
It also holds some tests that are only related to the OpenCv binding Thus, they are run only if the symbol HOMOG2D_USE_OPENCV
is defined.
This latter part starts around line 3350.
Run with $ make test USE_OPENCV=Y
It also holds some tests that are only related to the SVG import feature, that requires the tinyxml2
library, and that the symbol HOMOG2D_USE_SVG_IMPORT is defined.
Run with $ make test USE_TINYXML2=Y
#define CATCH_CONFIG_RUNNER |
#define HOMOG2D_BIND_X xxx |
see test [gen_bind]
#define HOMOG2D_TEST_MODE |
#define LOCALLOG | ( | a | ) |
#define NUMTYPE double |
Numerical type for object storage for tests. This is usually defined by makefile. (The internal numerical type for the library is defined by HOMOG2D_INUMTYPE)
#define STR | ( | s | ) | #s |
#define XSTR | ( | s | ) | STR(s) |
CHECK | ( | pol. | size() = =5 | ) |
CHECK | ( | opol. | size() = =0 | ) |
CHECK | ( | cpol. | size() = =0 | ) |
CHECK | ( | cir. | size() = =1 | ) |
CHECK | ( | ell. | size() = =1 | ) |
CHECK | ( | rect. | size() = =4 | ) |
CHECK | ( | seg. | size() = =2 | ) |
CHECK | ( | li. | size() = =0 | ) |
CHECK | ( | pt. | size() = =1 | ) |
CHECK | ( | size(opol) | = =0 | ) |
CHECK | ( | size(cpol) | = =0 | ) |
CHECK | ( | size(cir) | = =1 | ) |
CHECK | ( | size(ell) | = =1 | ) |
CHECK | ( | size(rect) | = =4 | ) |
CHECK | ( | size(seg) | = =2 | ) |
CHECK | ( | size(li) | = =0 | ) |
CHECK | ( | size(pt) | = =1 | ) |
CHECK_THROWS | ( | CPolyline(-5, 5u) | ) |
CHECK_THROWS | ( | CPolyline(1, 2u) | ) |
CHECK_THROWS | ( | CPolyline(0, 5u) | ) |
CHECK_THROWS | ( | pol. | set1, 2u | ) |
CHECK_THROWS | ( | pol. | set0, 5u | ) |
CHECK_THROWS | ( | pol. | set-5, 5u | ) |
CHECK_THROWS | ( | pol. | set5, 0u | ) |
void checkSizeNF | ( | const PT & | pt, |
const CONT & | cont | ||
) |
Computation of the line passed through H^{-T} and computation of the distance between the resulting line and the transformed point. Should be 0, always.
std::string FullPrecision | ( | long double | d | ) |
void local_draw_test | ( | img::Image< I > & | im, |
std::string | fn | ||
) |
Make sure all drawing functions and member functions are implemented.
No tests here, actually only checking that it builds fine
local_draw_test | ( | im | , |
"BUILD/dummy_draw.svg" | |||
) |
local_draw_test | ( | im | , |
"BUILD/dummy_draw.png" | |||
) |
void local_draw_test2 | ( | img::Image< I > & | im, |
T & | t | ||
) |
Helper function for local_draw_test()
int main | ( | int | argc, |
char * | argv[] | ||
) |
void polytest_1 | ( | const base::PolylineBase< T, U > & | pl1 | ) |
pol set | ( | 8 | , |
4u | |||
) |
TEST_CASE | ( | "numerical types access" | , |
"" | [types-access] | ||
) |
TEST_CASE | ( | "comparison testing" | , |
"" | [comparison-test] | ||
) |
TEST_CASE | ( | "types testing 1" | , |
"" | [test-types-1] | ||
) |
TEST_CASE | ( | "types testing 2" | , |
"" | [test-types-2] | ||
) |
TEST_CASE | ( | "normalization" | , |
"" | [normaliz] | ||
) |
TEST_CASE | ( | "homogeneous coordinates testing" | , |
"" | [homogeneous] | ||
) |
TEST_CASE | ( | "infinity point" | , |
"" | [points-inf] | ||
) |
TEST_CASE | ( | "types testing 3" | , |
"" | [test-types-3] | ||
) |
The goal of these is to make sure that the conversion (float to double, ...) does not trigger a build failure. The checking is only there to avoid a warning about "unused variable".
TEST_CASE | ( | "stream operator << test" | , |
"" | [streamingop-test] | ||
) |
TEST_CASE | ( | "line/point distance" | , |
"" | [lp-dist] | ||
) |
TEST_CASE | ( | "side-pt-line" | , |
"" | [side-pt-line] | ||
) |
TEST_CASE | ( | "test1" | , |
"" | [test1] | ||
) |
TEST_CASE | ( | "build point line from container" | , |
"" | [build-cont] | ||
) |
TEST_CASE | ( | "test throw" | , |
"" | [test_thr] | ||
) |
TEST_CASE | ( | "test parallel" | , |
"" | [test_para] | ||
) |
TEST_CASE | ( | "dist2points" | , |
"" | [t_d2p] | ||
) |
TEST_CASE | ( | "Homogr constructors" | , |
"" | [testHC] | ||
) |
TEST_CASE | ( | "test Homogr" | , |
"" | [testH] | ||
) |
TEST_CASE | ( | "matrix inversion" | , |
"" | [testH3] | ||
) |
TEST_CASE | ( | "line transformation" | , |
"" | [testH3] | ||
) |
TEST_CASE | ( | "matrix chained operations" | , |
"" | [testH2] | ||
) |
TEST_CASE | ( | "getPoints" | , |
"" | [test_points] | ||
) |
TEST_CASE | ( | "getAngle" | , |
"" | [test_angle] | ||
) |
TEST_CASE | ( | "getCorrectPoints" | , |
"" | [gcpts] | ||
) |
TEST_CASE | ( | "IsInside - manual" | , |
"" | [IsInside_man] | ||
) |
TEST_CASE | ( | "Polyline IsInside Polyline" | , |
"" | [tpolipol] | ||
) |
TEST_CASE | ( | "Point2d IsInside Polyline" | , |
"" | [tptipol] | ||
) |
TEST_CASE | ( | "Line2d IsInside something" | , |
"" | [tlir] | ||
) |
TEST_CASE | ( | "Point2d IsInside Circle" | , |
"" | [tptic] | ||
) |
TEST_CASE | ( | "Point2d IsInside FRect" | , |
"" | [tptir] | ||
) |
TEST_CASE | ( | "Segment IsInside FRect" | , |
"" | [tsir] | ||
) |
TEST_CASE | ( | "Circle IsInside FRect" | , |
"" | [tcir] | ||
) |
TEST_CASE | ( | "Circle IsInside Circle" | , |
"" | [tcic] | ||
) |
TEST_CASE | ( | "Intersection" | , |
"" | [int_all] | ||
) |
TEST_CASE | ( | "Line/Line intersection" | , |
"" | [int_LL] | ||
) |
TEST_CASE | ( | "Segment/Segment intersection" | , |
"" | [int_SS] | ||
) |
TEST_CASE | ( | "Circle/Circle intersection" | , |
"" | [int_CC] | ||
) |
TEST_CASE | ( | "FRect/FRect intersection" | , |
"" | [int_FF] | ||
) |
TEST_CASE | ( | "IoU of 2 rectangles" | , |
"" | [IOU_RECT] | ||
) |
TEST_CASE | ( | "Circle/Segment intersection" | , |
"" | [int_CS] | ||
) |
TEST_CASE | ( | "Circle/FRect intersection" | , |
"" | [int_CF] | ||
) |
TEST_CASE | ( | "Circle/Line intersection" | , |
"" | [int_CL] | ||
) |
TEST_CASE | ( | "Line/Segment intersection" | , |
"" | [int_LS] | ||
) |
TEST_CASE | ( | "Line/FRect intersection" | , |
"" | [int_LF] | ||
) |
TEST_CASE | ( | "Colinearity" | , |
"" | [colinearity] | ||
) |
TEST_CASE | ( | "Line2d" | , |
"" | [line1] | ||
) |
TEST_CASE | ( | "Circle" | , |
"" | [cir1] | ||
) |
?
TEST_CASE | ( | "Circle from points" | , |
"" | [cir2] | ||
) |
TEST_CASE | ( | "Ellipse" | , |
"" | [ell1] | ||
) |
TEST_CASE | ( | "OSegment point side" | , |
"" | [oseg-pt-side] | ||
) |
TEST_CASE | ( | "Segment" | , |
"" | [seg1] | ||
) |
TEST_CASE | ( | "Translate" | , |
"" | [trans] | ||
) |
TEST_CASE | ( | "MoveTo" | , |
"" | [moveto] | ||
) |
TEST_CASE | ( | "Segment-split-1" | , |
"" | [seg-split-1] | ||
) |
TEST_CASE | ( | "Segment-split-2" | , |
"" | [seg-split-2] | ||
) |
TEST_CASE | ( | "Segment 2" | , |
"" | [seg2] | ||
) |
TEST_CASE | ( | "Segment extended" | , |
"" | [seg_extended] | ||
) |
TEST_CASE | ( | "Segment orthogonal" | , |
"" | [seg_orthog] | ||
) |
TEST_CASE | ( | "min/max of two objects" | , |
"" | [minmax] | ||
) |
TEST_CASE | ( | "generalized bounding box of two objects" | , |
"" | [gen-BB] | ||
) |
TEST_CASE | ( | "bounding box of container" | , |
"" | [BB-cont] | ||
) |
TEST_CASE | ( | "common bounding box with points " | , |
"" | [point2d-BB] | ||
) |
TEST_CASE | ( | "FRect pair bounding box" | , |
"" | [frect-BB] | ||
) |
TEST_CASE | ( | "bounding box of two objects" | , |
"" | [getBB-pair] | ||
) |
TEST_CASE | ( | "FRect" | , |
"" | [frect] | ||
) |
TEST_CASE | ( | "FRect extended" | , |
"" | [frect-ext] | ||
) |
TEST_CASE | ( | "FRect diagonals" | , |
"" | [frect-diags] | ||
) |
TEST_CASE | ( | "Polyline comparison 1" | , |
"" | [polyline-comparison-1] | ||
) |
TEST_CASE | ( | "Polyline minimization" | , |
"" | [polyline-min] | ||
) |
TEST_CASE | ( | "Polyline" | , |
"" | [polyline] | ||
) |
TEST_CASE | ( | "Polyline setParallelogram" | , |
"" | [polyline-setParallelogram] | ||
) |
TEST_CASE | ( | "Polyline get extreme point" | , |
"" | [polyline-getExtremePoint] | ||
) |
TEST_CASE | ( | "Bounding Box of set of objects" | , |
"" | [BB-cont] | ||
) |
TEST_CASE | ( | "getCenters() and getLines()" | , |
"" | [getCenters] | ||
) |
TEST_CASE | ( | "Polygon convexity" | , |
"" | [polyline-convex] | ||
) |
TEST_CASE | ( | "Polygon orientation" | , |
"" | [polyline-orient] | ||
) |
TEST_CASE | ( | "Polyline basic" | , |
"" | [polyline-basic] | ||
) |
TEST_CASE | ( | "Polyline fullstep rotation" | , |
"" | [polyline-rot] | ||
) |
TEST_CASE | ( | "Polygon area" | , |
"" | [polyline-area] | ||
) |
TEST_CASE | ( | "Polyline comparison 2" | , |
"" | [polyline-comp-2] | ||
) |
TEST_CASE | ( | "convex hull" | , |
"" | [conv_hull] | ||
) |
TEST_CASE | ( | "nearest/farthest points" | , |
"" | [nfp] | ||
) |
TEST_CASE | ( | "pts_inside" | , |
"" | [ptsins] | ||
) |
TEST_CASE | ( | "variant conversion tests" | , |
"" | [varconv] | ||
) |
TEST_CASE | ( | "variant-based polymorphism" | , |
"" | [polymorph_1] | ||
) |
TEST_CASE | ( | "SVG_Import_1" | , |
"" | [svg_import_1] | ||
) |
TEST_CASE | ( | "SVG Import Ellipse" | , |
"" | [svg_import_ell] | ||
) |
TEST_CASE | ( | "SVG Import path 1" | , |
"" | [svg_import_path_1] | ||
) |
TEST_CASE | ( | "boost geometry point import" | , |
"" | [bg-pt-import] | ||
) |
TEST_CASE | ( | "boost geometry point export" | , |
"" | [bg-pt-export] | ||
) |
TEST_CASE | ( | "boost geometry vector point export" | , |
"" | [bg-vpt-export] | ||
) |
TEST_CASE | ( | "Opencv build H" | , |
"" | [test_opencv2] | ||
) |
TEST_CASE | ( | "Opencv binding" | , |
"" | [test_opencv] | ||
) |
Circle cir |
CPolyline cpol |
Ellipse ell |
double g_epsilon = std::numeric_limits<NUMTYPE>::epsilon()*10000. |
Line2d li |
CPolyline pol(5, 5u) |
Point2d pt |
FRect rect |
Segment seg |