Skip to content

Commit 4f4fc92

Browse files
committed
doc fixes, added doxygen module on free functions handling variant types
1 parent 4940ff7 commit 4f4fc92

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

docs/homog2d_manual.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,6 +2539,7 @@ Bad casting will very probably lead to a segfault.
25392539
Check test file [homog2d_test_rtp_1.cpp](../misc/test_files/homog2d_test_rtp_1.cpp) for an example.
25402540

25412541
#### 12.3 - Variant-based runtime polymorphism
2542+
<a name="section_vrtp"></a>
25422543

25432544
This feature is made available by defining the symbol `HOMOG2D_ENABLE_VRTP`.
25442545
This will enable a templated common type `CommonType_` that holds all the geometrical primitives, as a `std::variant` (requiring a move to `C++17`).
@@ -2578,6 +2579,12 @@ fct::DrawFunct vde( im ); // or fct::DrawFunct vde( im, dp ); if you need to pas
25782579
for( auto& e: vec )
25792580
std::visit( vde, e );
25802581
```
2582+
Or, much simpler:
2583+
```C++
2584+
for( auto& e: vec )
2585+
draw( e ); // or: draw( e, drawParams );
2586+
```
2587+
25812588

25822589
To apply the same homography on each element (and store them in-place), simple as this:
25832590

@@ -2601,6 +2608,9 @@ if( type(e) == Type::Circle )
26012608
```
26022609

26032610

2611+
Checkout all the [default functors here](https://codedocs.xyz/skramm/homog2d/namespaceh2d_1_1fct.html), and the list of free functions
2612+
that handle basic types or variant types (`CommonType`) [here](https://codedocs.xyz/skramm/homog2d/group__varff.html).
2613+
26042614
Check test file [homog2d_test_rtp_2.cpp](../misc/test_files/homog2d_test_rtp_2.cpp) for an example.
26052615

26062616

homog2d.hpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7475,7 +7475,7 @@ Point2d_<HOMOG2D_INUMTYPE>
74757475
base::PolylineBase<PLT,FPT>::centroid() const
74767476
{
74777477
if( !isSimple() )
7478-
HOMOG2D_THROW_ERROR_2( "PolylineBase::centroid", "unable, is not a polygon" );
7478+
HOMOG2D_THROW_ERROR_1( "unable, Polyline object is not simple" );
74797479

74807480
if( _attribs._centroid.isBad() )
74817481
{
@@ -10123,11 +10123,24 @@ struct BBFunct
1012310123
// SECTION - FREE FUNCTIONS HANDLING VARIANT TYPE
1012410124
/////////////////////////////////////////////////////////////////////////////
1012510125

10126+
/**
10127+
\addtogroup varff Free functions handling variant type
10128+
10129+
10130+
defgroup
10131+
10132+
These function can be used on a "regular" geometric object or on a `CommonType` object,
10133+
holding a std::variant and allowing run-time polymorphism,
10134+
10135+
See md_docs_homog2d_manual.html#section_rtp
10136+
*/
10137+
1012610138
//------------------------------------------------------------------
1012710139
/// Free function. Returns the type of object or variant
1012810140
/**
1012910141
Can be printed with `getString()`
1013010142
\sa CommonType_
10143+
\ingroup varff
1013110144
*/
1013210145
template<typename T>
1013310146
Type
@@ -10145,6 +10158,7 @@ type( const T& elem )
1014510158
/// Returns the underlying data type of object or variant
1014610159
/**
1014710160
Can be printed with `getString()`
10161+
\ingroup varff
1014810162
*/
1014910163
template<typename T>
1015010164
Dtype
@@ -10160,6 +10174,7 @@ dtype( const T& elem )
1016010174

1016110175
//------------------------------------------------------------------
1016210176
/// Returns length of element or variant (free function)
10177+
/// \ingroup varff
1016310178
template<typename T>
1016410179
HOMOG2D_INUMTYPE
1016510180
length( const T& elem )
@@ -10174,6 +10189,7 @@ length( const T& elem )
1017410189

1017510190
//------------------------------------------------------------------
1017610191
/// Returns area of element or variant (free function)
10192+
/// \ingroup varff
1017710193
template<typename T>
1017810194
HOMOG2D_INUMTYPE
1017910195
area( const T& elem )
@@ -10188,6 +10204,7 @@ area( const T& elem )
1018810204

1018910205
//------------------------------------------------------------------
1019010206
/// Returns size of element or variant (free function)
10207+
/// \ingroup varff
1019110208
template<typename T>
1019210209
HOMOG2D_INUMTYPE
1019310210
size( const T& elem )
@@ -10245,6 +10262,7 @@ getBB_CommonType( const std::vector<CommonType_<FPT>>& v_var )
1024510262
/// Return Bounding Box of primitive or container holding primitives (free function)
1024610263
/**
1024710264
tests: [BB-cont]
10265+
\ingroup varff
1024810266
*/
1024910267
template<typename T>
1025010268
FRect_<HOMOG2D_INUMTYPE>
@@ -10308,7 +10326,9 @@ getBB( const T& t )
1030810326

1030910327
/// Apply homography to primitive
1031010328
/**
10311-
\warning The floating-point type of the returned object (variant) will be the one of the homography \c h, NOT the one of the input element.
10329+
\warning The floating-point type of the returned object (variant) will be the one of the homography \c h,
10330+
\b NOT the one of the input element.
10331+
\ingroup varff
1031210332
*/
1031310333
template<typename T, typename FPT>
1031410334
CommonType_<FPT>
@@ -11220,6 +11240,8 @@ impl_drawIndexes( img::Image<IMG>&, size_t, const img::DrawParams&, const DUMMY&
1122011240
- Type \c T can be \c std::array<type> or \c std::vector<type>, with \c type being anything drawable.
1122111241
- The types inside the container can be either plain \c h2d types (\c FRect, \c Segment, ...) of variant types,
1122211242
using the \c CommonType class (requires HOMOG2D_ENABLE_VRTP symbol).
11243+
11244+
\ingroup varff
1122311245
*/
1122411246
template<
1122511247
typename U,

misc/test_files/demo_svg_import.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int main( int argc, const char** argv )
8585
pp_all = getMinMax( pp_all, ptpair );
8686

8787
std::cout << "Shape " << c << ": " << getString( type(e) )
88-
<< ", size " << size(e) << ": " << print(e) << "\n";
88+
<< ", size " << size(e) << "\n";
8989

9090
if( type(e) != Type::Segment ) // because no BB is defined
9191
{

0 commit comments

Comments
 (0)