Skip to content

Commit 4940ff7

Browse files
committed
doc fixes, added SVG import image
1 parent 9084b84 commit 4940ff7

File tree

4 files changed

+109
-37
lines changed

4 files changed

+109
-37
lines changed

docs/homog2d_manual.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,8 @@ See [demo program](../misc/test_files/bg_test_1.cpp) that demonstrates that feat
10971097
10981098
We follow here the traditional parametrization of ellipses:
10991099
center point, semi-major (a) and semi-minor (b) distances, and angle between main axis and horizontal axis.
1100-
Internally, it is stored as a conic in its matrix form (see [build options](#build_options) for details).
1100+
Internally, it is stored as [a conic in its matrix form](https://en.wikipedia.org/wiki/Matrix_representation_of_conic_sections),
1101+
see [build options](#build_options) for details on how this is handled.
11011102
11021103
_Warning: support for ellipse is only partial at present, several features available with all the other primitives may not
11031104
all be available for this type_
@@ -2104,6 +2105,10 @@ auto vcol2 = img::genRandomColors(10,100); // return 10 random colors with va
21042105
auto vcol3 = img::genRandomColors(10,30,150); // return 10 random colors with values in the range [30-150]
21052106
```
21062107

2108+
You can then use these with the `setColor()` member function:
2109+
```C++
2110+
something.draw( image, img::DrawParams().setColor( vcol1.at(i) ) );
2111+
```
21072112

21082113
### 8.5 - Drawing containers holding variant objects (runtime polymorphism)
21092114

@@ -2288,12 +2293,21 @@ auto data = visitor.get();
22882293
```
22892294

22902295
The latter function returns a vector of polymorphic objects `CommonType`.
2291-
This is a wrapper around a `std::variant`, on which the library provides some helper functions.
2296+
This is a wrapper around a [`std::variant`](https://en.cppreference.com/w/cpp/utility/variant),
2297+
on which the library provides some helper functions.
22922298
See [RTP section](#section_rtp) on how to use this.
22932299
This polymorphic behavior is kept optional,
2294-
It is enabled only if symbol `HOMOG2D_ENABLE_VRTP` is defined
2300+
it is enabled only if symbol `HOMOG2D_ENABLE_VRTP` is defined
22952301
(which is automatically done if `HOMOG2D_USE_SVG_IMPORT` is defined).
22962302

2303+
For safety, you can check if the file has been correctly read by testing the return value of the `LoadFile()` member function:
2304+
```C++
2305+
tinyxml2::XMLDocument doc;
2306+
auto error = doc.LoadFile( "filename.svg" );
2307+
if( err != tinyxml2::XML_SUCCESS )
2308+
FAILURE!
2309+
```
2310+
22972311
You can fetch the size of image in the SVG file (as `double`) with `getImgSize()`.
22982312
However, this will throw if no size can be found, so you might consider using that in a "try/catch":
22992313
```C++
@@ -2349,9 +2363,14 @@ For example:
23492363
<br>
23502364
`$ BUILD/demo_svg_import docs/img/comparison_1.svg`
23512365
2352-
The previous line imports a file that has been generated by this library, so to have comething more realistic, you can run this:
2366+
The previous line imports a file that has been generated by this library, so to have something more realistic, you can run this:
23532367
<br>
2354-
`$ BUILD/demo_svg_import misc/test_files/France_Normandy.svg`
2368+
`$ BUILD/demo_svg_import misc/test_files/France.svg`
2369+
2370+
This will produce this image, with the bounding boxes of the different regions drawn with different colors:
2371+
2372+
![import_demo_France](img/import_demo_France.svg)
2373+
23552374
23562375
## 11 - Technical details
23572376
<a name="tech"></a>
@@ -2372,7 +2391,7 @@ For more details on the code, check [this page](homog2d_devinfo.md).
23722391
23732392
A unit-test program is included, can be run locally and is also used by GitHub CI.
23742393
It is uses the [Catch2](https://github.com/catchorg/Catch2) library.
2375-
The Github CI (aka "Github Acionts") loads the 2.13.6 release.
2394+
The Github CI (aka "Github Actions") loads the 2.13.6 release.
23762395
It is build and run with `$ make test`
23772396
The CI launches the tests with both Ubuntu 20 (gcc9.4) and Ubuntu 22, and also makes sure that the Microsoft C++ compiler is able to build the software
23782397
(but it does not run the tests with it).
@@ -2388,7 +2407,7 @@ make test USE_TINYXML2=Y
23882407
```
23892408
23902409
A second test target is included: `$ make testall`.
2391-
It will build and run the test program 3 times, one for each numerical data
2410+
It will build and run the tests programs 3 times, one for each numerical data
23922411
type (`float`, `double`, and `long double`), through the symbol `HOMOG2D_INUMTYPE`.
23932412
23942413
The test target also attempts to build the files in the folder `misc/no_build`.
@@ -2433,16 +2452,15 @@ If not defined, incorrect situations will throw a `std::runtime_error`.
24332452
If defined, program will very likely crash in case an abnormal situation is encountered.
24342453
- `HOMOG2D_NOWARNINGS`: on some situations, some warnings may be printed out to `stderr` (see below).
24352454
Defining this symbol will disables this.
2436-
Besides this build symbol, user code can silence all the warnings with `err:printWarnings() = false;`
2455+
Besides this build symbol, user code can silence all the warnings with `err::printWarnings() = false;`
24372456
(can be reactivated any time by passing `true`).
2438-
- `HOMOG2D_OPTIMIZE_SPEED`: this option may be useful if you intend to to a lot of processing with ellipses, and you favor speed over memory.
2457+
- `HOMOG2D_OPTIMIZE_SPEED`: this option may be useful if you intend to to a lot of processing with [ellipses](#p_ellipse), and you favor speed over memory.
24392458
The default behavior for class `Ellipse` is to store only the homogeneous matrix representation (conic form),to minimize memory footprint.
24402459
This drawback is that every time we need to access some parameter (say, center point), a lot of computations are required to get back to the "human-readable" values.
2441-
With this option activated, each ellipse will store both representations, so access to values is faster.
2460+
With this option activated, each ellipse will store **both** representations, so access to values is faster, but memory footprint will increase.
24422461
For more on this, [see this page](homog2d_speed.md).
24432462
- `HOMOG2D_ENABLE_PRTP`: enables pointer-based runtime polymorphism.
2444-
This will add a common base class `rtp::Root` to all the geometric primitives.
2445-
At present, runtime polymorphism is currently moving to a variant-based approach, see [RTP](#section_rtp) section.
2463+
This will add a common base class `rtp::Root` to all the geometric primitives, see [RTP](#section_rtp) section.
24462464
- `HOMOG2D_ENABLE_VRTP`: enables variant-based runtime polymorphism.
24472465
This will add a class `rtp::CommonType` holding all the geometric primitives as a std::variant.
24482466
See section [RTP](#section_rtp) for details.
@@ -2452,12 +2470,6 @@ While this shoudn't happen even with random data, numerical (floating-point) iss
24522470
[read this for details](homog2d_qa.md#assert_trigger).
24532471
24542472
2455-
**Situations that will generate a warning**
2456-
2457-
* When computing the angle between two lines/segments, and that this requires the computation of `arccos()` of a value slightly above 1.
2458-
Then the value 1.0 will be used instead, but a warning will be generated.
2459-
* When importing a SVG file and an element in the file cannot be processed.
2460-
24612473
24622474
### 12 - Runtime Polymorphism
24632475
<a name="section_rtp"></a>

0 commit comments

Comments
 (0)