DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes
DGtal::LatticeSetByIntervals< TSpace > Class Template Reference

Aim: More...

#include <DGtal/kernel/LatticeSetByIntervals.h>

Public Types

typedef TSpace Space
 
using Self = LatticeSetByIntervals< Space >
 
using Point = typename Space::Point
 
using Vector = typename Space::Vector
 
using Integer = typename Space::Integer
 
using PointRange = std::vector< Point >
 
using Intervals = IntegralIntervals< Integer >
 
using Interval = typename Intervals::Interval
 
using Container = std::map< Point, Intervals >
 
using RowIterator = typename Container::iterator
 
using RowConstIterator = typename Container::const_iterator
 
using LatticeSetByInterval = std::map< Point, Interval >
 
using Size = std::size_t
 
using size_type = Size
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 
Standard services (construction, move, clear)
 LatticeSetByIntervals (Dimension axis=0)
 
 LatticeSetByIntervals (const Self &other)=default
 
 LatticeSetByIntervals (Self &&other)=default
 
Selfoperator= (const Self &other)=default
 
Selfoperator= (Self &&other)=default
 
template<typename PointIterator >
 LatticeSetByIntervals (PointIterator it, PointIterator itE, Dimension axis=0)
 
 LatticeSetByIntervals (const LatticeSetByInterval &aSet, Dimension axis)
 
void clear ()
 Clears the data structure. More...
 
void setAxis (Dimension axis)
 
Dimension axis () const
 
Containerdata ()
 
conversion services
PointRange toPointRange () const
 
capacity services
bool empty () const
 
Size size () const
 
Size max_size () const
 
modifier services
void insert (Point p)
 
void erase (Point p)
 
void purge ()
 Eliminates rows that contains no element. More...
 
set operations
Selfadd (const Self &other)
 
Selfsubtract (const Self &other)
 
Self set_union (const Self &other) const
 
Self set_difference (const Self &other) const
 
Self set_intersection (const Self &other) const
 
Self set_symmetric_difference (const Self &other) const
 
bool includes (const Self &other) const
 
bool equals (const Self &other) const
 
topology operations
Self starOfPoints () const
 
Self starOfCells () const
 
Self skeletonOfCells () const
 
PointRange extremaOfCells () const
 

Static Public Attributes

static const Dimension dimension = Space::dimension
 

specific services (interval insertion, removal)

Dimension myAxis
 The axis along which data is stacked in intervals. More...
 
Container myData
 Associate to each point its sequences of intervals. More...
 
size_type memory_usage () const noexcept
 
Intervalsat (Point q)
 
void reset (Point p)
 

Detailed Description

template<typename TSpace>
class DGtal::LatticeSetByIntervals< TSpace >

Aim:

Description of template class 'LatticeSetByIntervals'

A class that represents a set of lattice points using intervals along a given axis.

Template Parameters
TSpaceany model of concepts::CSpace, for instance any SpaceND like Z2i::Space, Z3i::Space.

Definition at line 61 of file LatticeSetByIntervals.h.

Member Typedef Documentation

◆ Container

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Container = std::map< Point, Intervals >

Definition at line 74 of file LatticeSetByIntervals.h.

◆ Integer

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Integer = typename Space::Integer

Definition at line 70 of file LatticeSetByIntervals.h.

◆ Interval

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Interval = typename Intervals::Interval

Definition at line 73 of file LatticeSetByIntervals.h.

◆ Intervals

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Intervals = IntegralIntervals< Integer >

Definition at line 72 of file LatticeSetByIntervals.h.

◆ LatticeSetByInterval

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::LatticeSetByInterval = std::map< Point, Interval >

Definition at line 77 of file LatticeSetByIntervals.h.

◆ Point

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Point = typename Space::Point

Definition at line 68 of file LatticeSetByIntervals.h.

◆ PointRange

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::PointRange = std::vector< Point >

Definition at line 71 of file LatticeSetByIntervals.h.

◆ RowConstIterator

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::RowConstIterator = typename Container::const_iterator

Definition at line 76 of file LatticeSetByIntervals.h.

◆ RowIterator

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::RowIterator = typename Container::iterator

Definition at line 75 of file LatticeSetByIntervals.h.

◆ Self

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Self = LatticeSetByIntervals< Space >

Definition at line 67 of file LatticeSetByIntervals.h.

◆ Size

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Size = std::size_t

Definition at line 78 of file LatticeSetByIntervals.h.

◆ size_type

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::size_type = Size

Definition at line 79 of file LatticeSetByIntervals.h.

◆ Space

template<typename TSpace >
typedef TSpace DGtal::LatticeSetByIntervals< TSpace >::Space

Definition at line 66 of file LatticeSetByIntervals.h.

◆ Vector

template<typename TSpace >
using DGtal::LatticeSetByIntervals< TSpace >::Vector = typename Space::Vector

Definition at line 69 of file LatticeSetByIntervals.h.

Constructor & Destructor Documentation

◆ LatticeSetByIntervals() [1/5]

template<typename TSpace >
DGtal::LatticeSetByIntervals< TSpace >::LatticeSetByIntervals ( Dimension  axis = 0)
inline

Constructor from axis.

Parameters
axisthe row axis chosen for stacking the points.

Definition at line 89 of file LatticeSetByIntervals.h.

90 : myAxis( axis ), myData() {}
Container myData
Associate to each point its sequences of intervals.
Dimension myAxis
The axis along which data is stacked in intervals.

◆ LatticeSetByIntervals() [2/5]

template<typename TSpace >
DGtal::LatticeSetByIntervals< TSpace >::LatticeSetByIntervals ( const Self other)
default

Copy constructor

Parameters
otherany other object.

◆ LatticeSetByIntervals() [3/5]

template<typename TSpace >
DGtal::LatticeSetByIntervals< TSpace >::LatticeSetByIntervals ( Self &&  other)
default

Move constructor

Parameters
otherany other object.

◆ LatticeSetByIntervals() [4/5]

template<typename TSpace >
template<typename PointIterator >
DGtal::LatticeSetByIntervals< TSpace >::LatticeSetByIntervals ( PointIterator  it,
PointIterator  itE,
Dimension  axis = 0 
)
inline

Constructor from range of points

Template Parameters
PointIteratorany model of input iterator on points.
Parameters
it,itEthe range of point
axisthe row axis chosen for stacking the points.

Definition at line 115 of file LatticeSetByIntervals.h.

116 : myAxis( axis )
117 {
118 for ( ; it != itE; ++it ) {
119 Point q = *it;
120 Integer x = q[ axis ];
121 q[ axis ] = 0;
122 myData[ q ].insert( x );
123 }
124 }
MyPointD Point
Definition: testClone2.cpp:383

References DGtal::LatticeSetByIntervals< TSpace >::axis(), and DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ LatticeSetByIntervals() [5/5]

template<typename TSpace >
DGtal::LatticeSetByIntervals< TSpace >::LatticeSetByIntervals ( const LatticeSetByInterval aSet,
Dimension  axis 
)
inline

Constructor from lattice set of interval (often a lattice set representation for a polytope, since there is at most one interval per row).

Parameters
aSetany lattice set represented by one interval per row.
axisthe row axis chosen for stacking the points in aSet.

Definition at line 132 of file LatticeSetByIntervals.h.

133 : myAxis( axis )
134 {
135 for ( const auto& aRow : aSet )
136 myData[ aRow.first ].data().push_back( aRow.second );
137 }

References DGtal::LatticeSetByIntervals< TSpace >::myData.

Member Function Documentation

◆ add()

template<typename TSpace >
Self & DGtal::LatticeSetByIntervals< TSpace >::add ( const Self other)
inline

Performs the union of set other with this object.

Parameters
otherany intervals
Returns
a reference to this object
Precondition
other and 'this' should share the same axis: this->axis() == other.axis()

Definition at line 272 of file LatticeSetByIntervals.h.

273 {
274 if ( other.axis() != axis() )
275 {
276 trace.error() << "[LatticeSetByInterval::add] "
277 << "Both lattice sets should share the same axis: "
278 << axis() << " != " << other.axis() << std::endl;
279 return *this;
280 }
281 for ( const auto& pV : other.myData )
282 {
283 const Point& p = pV.first;
284 auto it = myData.find( p );
285 if ( it != myData.end() )
286 it->second.add( pV.second );
287 else
288 myData[ p ] = pV.second;
289 }
290 return *this;
291 }
std::ostream & error()
Trace trace
Definition: Common.h:154

References DGtal::LatticeSetByIntervals< TSpace >::axis(), DGtal::Trace::error(), DGtal::LatticeSetByIntervals< TSpace >::myData, and DGtal::trace.

Referenced by DGtal::LatticeSetByIntervals< TSpace >::set_symmetric_difference(), and DGtal::LatticeSetByIntervals< TSpace >::set_union().

◆ at()

template<typename TSpace >
Intervals & DGtal::LatticeSetByIntervals< TSpace >::at ( Point  q)
inline
Parameters
qany point
Returns
the integral intervals corresponding to lattice point coordinates along the row of axis myAxis and containing q.

Definition at line 642 of file LatticeSetByIntervals.h.

643 {
644 q[ myAxis ] = 0;
645 return myData[ q ];
646 }

◆ axis()

template<typename TSpace >
Dimension DGtal::LatticeSetByIntervals< TSpace >::axis ( ) const
inline

◆ BOOST_CONCEPT_ASSERT()

template<typename TSpace >
DGtal::LatticeSetByIntervals< TSpace >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )

◆ clear()

template<typename TSpace >
void DGtal::LatticeSetByIntervals< TSpace >::clear ( )
inline

Clears the data structure.

Definition at line 140 of file LatticeSetByIntervals.h.

140{ myData.clear(); }

References DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ data()

template<typename TSpace >
Container & DGtal::LatticeSetByIntervals< TSpace >::data ( )
inline
Returns
a reference to the container

Definition at line 158 of file LatticeSetByIntervals.h.

158{ return myData; }

References DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ empty()

template<typename TSpace >
bool DGtal::LatticeSetByIntervals< TSpace >::empty ( ) const
inline
Returns
'true' iff this object represents the empty set.
Constant time operation.

Definition at line 194 of file LatticeSetByIntervals.h.

195 {
196 return myData.empty();
197 }

References DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ equals()

template<typename TSpace >
bool DGtal::LatticeSetByIntervals< TSpace >::equals ( const Self other) const
inline
Parameters
otherany other integral set represented by intervals
Returns
'true' iff this integer set equals the integer set other.

Definition at line 398 of file LatticeSetByIntervals.h.

399 {
400 if ( other.axis() != axis() )
401 {
402 trace.error() << "[LatticeSetByInterval::subtract] "
403 << "Both lattice sets should share the same axis: "
404 << axis() << " != " << other.axis() << std::endl;
405 return false;
406 }
407 if ( myData.size() != other.myData.size() ) return false;
408 auto it = myData.cbegin();
409 for ( const auto& I : other.myData )
410 {
411 if ( it->first != I.first ) return false;
412 if ( ! it->second.equals( I.second ) ) return false;
413 ++it;
414 }
415 return true;
416 }

References DGtal::LatticeSetByIntervals< TSpace >::axis(), DGtal::Trace::error(), DGtal::LatticeSetByIntervals< TSpace >::myData, and DGtal::trace.

◆ erase()

template<typename TSpace >
void DGtal::LatticeSetByIntervals< TSpace >::erase ( Point  p)
inline

Erases the point from the set.

Parameters
pany point.

Definition at line 236 of file LatticeSetByIntervals.h.

237 {
238 Integer x = p[ myAxis ];
239 p[ myAxis ] = 0;
240 auto it = myData.find( p );
241 if ( it != myData.end() )
242 {
243 it->second.erase( x );
244 if ( it->second.empty() )
245 myData.erase( it ); // purge element if it was the last in the row.
246 }
247 }

References DGtal::LatticeSetByIntervals< TSpace >::myAxis, and DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ extremaOfCells()

template<typename TSpace >
PointRange DGtal::LatticeSetByIntervals< TSpace >::extremaOfCells ( ) const
inline
Returns
the range of points that contains the vertices of all the cells stored in this set.

Definition at line 550 of file LatticeSetByIntervals.h.

551 {
552 typedef std::vector< Integer > Coordinates;
553 std::map< Point, Coordinates > E;
554 // Now extracting vertices along axis direction.
555 for ( const auto& pV : myData )
556 {
557 const Point& p = pV.first;
558 const auto& V = pV.second;
559 E[ p ] = V.extremaOfCells();
560 }
561 std::map< Point, Coordinates > next_E;
562 for ( Dimension k = 0; k != dimension; k++ )
563 {
564 if ( k == myAxis ) continue;
565 for ( const auto& pC : E )
566 {
567 const auto& p = pC.first;
568 Point q = p;
569 q[ k ] = q[ k ] >> 1;
570 bool odd = ( p[ k ] & 0x1 ) != 0;
571 { // odd/even always copy
572 auto it = next_E.find( q );
573 if ( it == next_E.end() ) next_E[ q ] = pC.second;
574 else
575 {
576 Coordinates F;
577 std::set_union( pC.second.cbegin(), pC.second.cend(),
578 it->second.cbegin(), it->second.cend(),
579 std::back_inserter( F ) );
580 it->second = F;
581 }
582 }
583 if ( odd )
584 { // odd: must copy forward also
585 q[ k ] += 1;
586 auto it = next_E.find( q );
587 if ( it == next_E.end() ) next_E[ q ] = pC.second;
588 else
589 {
590 Coordinates F;
591 std::set_union( pC.second.cbegin(), pC.second.cend(),
592 it->second.cbegin(), it->second.cend(),
593 std::back_inserter( F ) );
594 it->second = F;
595 }
596 }
597 } // for ( const auto& pC : E )
598 E.swap( next_E );
599 next_E.clear();
600 }
601 // Build point range.
603 for ( const auto& pC : E )
604 {
605 Point p = pC.first;
606 for ( auto&& x : pC.second )
607 {
608 p[ myAxis ] = x;
609 R.push_back( p );
610 }
611 }
612 std::sort( R.begin(), R.end() );
613 return R;
614 }
static const Dimension dimension
std::vector< Point > PointRange
DGtal::uint32_t Dimension
Definition: Common.h:137

References DGtal::LatticeSetByIntervals< TSpace >::dimension, DGtal::LatticeSetByIntervals< TSpace >::myAxis, and DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ includes()

template<typename TSpace >
bool DGtal::LatticeSetByIntervals< TSpace >::includes ( const Self other) const
inline
Parameters
otherany other lattice set represented by intervals
Returns
'true' iff this lattice set includes the lattice set other.
Precondition
other and 'this' should share the same axis: this->axis() == other.axis()

Definition at line 377 of file LatticeSetByIntervals.h.

378 {
379 if ( other.axis() != axis() )
380 {
381 trace.error() << "[LatticeSetByInterval::subtract] "
382 << "Both lattice sets should share the same axis: "
383 << axis() << " != " << other.axis() << std::endl;
384 return false;
385 }
386 for ( const auto& pV : other.myData )
387 {
388 const Point& p = pV.first;
389 const auto it = myData.find( p );
390 if ( it == myData.cend() ) return false;
391 if ( ! it->second.includes( pV.second ) ) return false;
392 }
393 return true;
394 }

References DGtal::LatticeSetByIntervals< TSpace >::axis(), DGtal::Trace::error(), DGtal::LatticeSetByIntervals< TSpace >::myData, and DGtal::trace.

◆ insert()

template<typename TSpace >
void DGtal::LatticeSetByIntervals< TSpace >::insert ( Point  p)
inline

Inserts the point into the set.

Parameters
pany point.

Definition at line 227 of file LatticeSetByIntervals.h.

228 {
229 Integer x = p[ myAxis ];
230 p[ myAxis ] = 0;
231 myData[ p ].insert( x );
232 }

References DGtal::LatticeSetByIntervals< TSpace >::myAxis, and DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ max_size()

template<typename TSpace >
Size DGtal::LatticeSetByIntervals< TSpace >::max_size ( ) const
inline
Returns
the the maximum number of elements the container is able to hold due to system or library implementation limitations.

Definition at line 213 of file LatticeSetByIntervals.h.

214 {
215 return myData.max_size();
216 }

References DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ memory_usage()

template<typename TSpace >
size_type DGtal::LatticeSetByIntervals< TSpace >::memory_usage ( ) const
inlinenoexcept
Note
Specific to this data structure.
Returns
an evaluation of the memory usage of this data structure.

Definition at line 625 of file LatticeSetByIntervals.h.

626 {
627 size_type nb = 0;
628 for ( const auto& pV : myData )
629 {
630 nb += sizeof( Interval ) * pV.second.capacity() + sizeof( void* );
631 nb += sizeof( pV ) + sizeof( void* );
632 }
633 nb += sizeof( Self );
634 return nb;
635 }
typename Intervals::Interval Interval
LatticeSetByIntervals< Space > Self

◆ operator=() [1/2]

template<typename TSpace >
Self & DGtal::LatticeSetByIntervals< TSpace >::operator= ( const Self other)
default

Assignment.

Parameters
otherany other object.
Returns
a reference to this object

◆ operator=() [2/2]

template<typename TSpace >
Self & DGtal::LatticeSetByIntervals< TSpace >::operator= ( Self &&  other)
default

Move Assignment.

Parameters
otherany other object.
Returns
a reference to this object

◆ purge()

template<typename TSpace >
void DGtal::LatticeSetByIntervals< TSpace >::purge ( )
inline

Eliminates rows that contains no element.

Definition at line 251 of file LatticeSetByIntervals.h.

252 {
253 for ( auto it = myData.begin(), itE = myData.end(); it != itE; )
254 if ( it->second.empty() )
255 it = myData.erase( it );
256 else ++it;
257 }

References DGtal::LatticeSetByIntervals< TSpace >::myData.

Referenced by DGtal::LatticeSetByIntervals< TSpace >::skeletonOfCells().

◆ reset()

template<typename TSpace >
void DGtal::LatticeSetByIntervals< TSpace >::reset ( Point  p)
inline

Reset the intervals for a given point.

Parameters
pany point
Note
After this operation, there is no lattice point on the row containing point p.

Definition at line 653 of file LatticeSetByIntervals.h.

654 {
655 p[ myAxis ] = 0;
656 auto it = myData.find( p );
657 if ( it != myData.end() ) myData.erase( it );
658 }

◆ set_difference()

template<typename TSpace >
Self DGtal::LatticeSetByIntervals< TSpace >::set_difference ( const Self other) const
inline

Performs the set difference between this and other.

Parameters
otherany other integral set represented by intervals
Returns
the set difference between this and other.
Precondition
other and 'this' should share the same axis: this->axis() == other.axis()

Definition at line 337 of file LatticeSetByIntervals.h.

338 {
339 Self U = *this;
340 U.subtract( other );
341 return U;
342 }
Self & subtract(const Self &other)

References DGtal::LatticeSetByIntervals< TSpace >::subtract().

◆ set_intersection()

template<typename TSpace >
Self DGtal::LatticeSetByIntervals< TSpace >::set_intersection ( const Self other) const
inline

Performs the set intersection between this and other.

Parameters
otherany other integral set represented by intervals
Returns
the set difference between this and other.
Precondition
other and 'this' should share the same axis: this->axis() == other.axis()

Definition at line 350 of file LatticeSetByIntervals.h.

351 {
352 Self A_plus_B = set_union( other );
353 Self A_delta_B = set_symmetric_difference( other );
354 return A_plus_B.subtract( A_delta_B );
355 }
Self set_union(const Self &other) const
Self set_symmetric_difference(const Self &other) const

References DGtal::LatticeSetByIntervals< TSpace >::set_symmetric_difference(), DGtal::LatticeSetByIntervals< TSpace >::set_union(), and DGtal::LatticeSetByIntervals< TSpace >::subtract().

◆ set_symmetric_difference()

template<typename TSpace >
Self DGtal::LatticeSetByIntervals< TSpace >::set_symmetric_difference ( const Self other) const
inline

Performs the set symmetric difference between this and other.

Parameters
otherany other integral set represented by intervals
Returns
the set symmetric difference between this and other.
Precondition
other and 'this' should share the same axis: this->axis() == other.axis()

Definition at line 363 of file LatticeSetByIntervals.h.

364 {
365 Self A_minus_B = *this;
366 A_minus_B.subtract( other );
367 Self B_minus_A = other;
368 B_minus_A.subtract( *this );
369 return A_minus_B.add( B_minus_A );
370 }
Self & add(const Self &other)

References DGtal::LatticeSetByIntervals< TSpace >::add(), and DGtal::LatticeSetByIntervals< TSpace >::subtract().

Referenced by DGtal::LatticeSetByIntervals< TSpace >::set_intersection().

◆ set_union()

template<typename TSpace >
Self DGtal::LatticeSetByIntervals< TSpace >::set_union ( const Self other) const
inline

Performs the set union between this and other.

Parameters
otherany other integral set represented by intervals
Returns
the set union between this and other.
Precondition
other and 'this' should share the same axis: this->axis() == other.axis()

Definition at line 324 of file LatticeSetByIntervals.h.

325 {
326 Self U = *this;
327 U.add( other );
328 return U;
329 }

References DGtal::LatticeSetByIntervals< TSpace >::add().

Referenced by DGtal::LatticeSetByIntervals< TSpace >::set_intersection().

◆ setAxis()

template<typename TSpace >
void DGtal::LatticeSetByIntervals< TSpace >::setAxis ( Dimension  axis)
inline

Change the main axis of projection. If the object is not empty, it empties the object.

Parameters
axisany valid integer between 0 and dimension (excluded)

Definition at line 147 of file LatticeSetByIntervals.h.

148 {
149 myData.clear();
150 myAxis = axis;
151 }

References DGtal::LatticeSetByIntervals< TSpace >::axis(), DGtal::LatticeSetByIntervals< TSpace >::myAxis, and DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ size()

template<typename TSpace >
Size DGtal::LatticeSetByIntervals< TSpace >::size ( ) const
inline
Returns
the number of lattice points represented in this object.
Warning
The complexity is linear in the number of stored intervals.

Definition at line 202 of file LatticeSetByIntervals.h.

203 {
204 Size nb = 0;
205 for ( const auto& pV : myData )
206 nb += pV.second.size();
207 return nb;
208 }
HalfEdgeDataStructure::Size Size

References DGtal::LatticeSetByIntervals< TSpace >::myData.

Referenced by DGtal::LatticeSetByIntervals< TSpace >::toPointRange().

◆ skeletonOfCells()

template<typename TSpace >
Self DGtal::LatticeSetByIntervals< TSpace >::skeletonOfCells ( ) const
inline

Consider the set of integers as cells represented by their Khalimsky coordinates, and build their skeleton.

Returns
the skeleton of this set of cells, i.e. the smallest set of cells such that its star covers it.

Definition at line 495 of file LatticeSetByIntervals.h.

496 {
497 Self S( *this );
498 // Now extracting implicitly its Skel
499 for ( const auto& pV : myData )
500 {
501 const Point& p = pV.first;
502 const auto& V = pV.second;
503 for ( Dimension k = 0; k < dimension; k++ )
504 {
505 if ( k == myAxis ) continue;
506 if ( ( p[ k ] & 0x1 ) != 0 ) continue; // if open along axis continue
507 // if closed, check upper incident cells along direction k
508 Point q = p; q[ k ] -= 1;
509 Point r = p; r[ k ] += 1;
510 auto itq = S.myData.find( q );
511 if ( itq != S.myData.end() )
512 {
513 auto& W = itq->second;
514 W.subtract( V );
515 }
516 auto itr = S.myData.find( r );
517 if ( itr != S.myData.end() )
518 {
519 auto& W = itr->second;
520 W.subtract( V );
521 }
522 }
523 }
524 // Extract skel along main axis
525 for ( auto& value : S.myData )
526 {
527 auto & V = value.second;
528 Intervals sub_to_V;
529 for ( auto I : V.data() )
530 {
531 if ( ( I.first & 0x1 ) != 0 )
532 {
533 if ( I.first != I.second )
534 sub_to_V.data().push_back( Interval{ I.first, I.first } );
535 I.first += 1;
536 }
537 if ( ( I.second & 0x1 ) != 0 ) I.second -= 1;
538 for ( auto x = I.first; x <= I.second; x += 2 )
539 sub_to_V.data().push_back( Interval{ x+1, x+1 } );
540 }
541 V.subtract( sub_to_V );
542 }
543 // Erase empty stacks
544 S.purge();
545 return S;
546 }
IntegralIntervals< Integer > Intervals

References DGtal::IntegralIntervals< TInteger >::data(), DGtal::LatticeSetByIntervals< TSpace >::dimension, DGtal::LatticeSetByIntervals< TSpace >::myAxis, DGtal::LatticeSetByIntervals< TSpace >::myData, and DGtal::LatticeSetByIntervals< TSpace >::purge().

◆ starOfCells()

template<typename TSpace >
Self DGtal::LatticeSetByIntervals< TSpace >::starOfCells ( ) const
inline

Consider the set of integers as cells represented by their Khalimsky coordinates, and build their star.

Returns
the star of this set of cells, i.e. the smallest open cell complex containing it.

Definition at line 467 of file LatticeSetByIntervals.h.

468 {
469 Self C( *this );
470 // First step, compute star along dimension a.
471 for ( auto& pV : C.myData )
472 pV.second = pV.second.starOfCells();
473 // Second step, dilate along remaining directions
474 for ( Dimension k = 0; k < dimension; k++ )
475 {
476 if ( k == myAxis ) continue;
477 for ( const auto& value : C.myData )
478 {
479 Point q = value.first;
480 if ( q[ k ] & 0x1 ) continue;
481 q[ k ] -= 1;
482 C.myData[ q ].add( value.second );
483 q[ k ] += 2;
484 C.myData[ q ].add( value.second );
485 }
486 }
487 return C;
488 }

References DGtal::LatticeSetByIntervals< TSpace >::dimension, DGtal::LatticeSetByIntervals< TSpace >::myAxis, and DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ starOfPoints()

template<typename TSpace >
Self DGtal::LatticeSetByIntervals< TSpace >::starOfPoints ( ) const
inline

Consider the set of integers as points, transform them into pointels in Khalimsky coordinates and build their star. Afterwards points represent cells with their Khalimsky coordinates (i.e. even along an axis means closed, odd along an axis means open). Concretely, points coordinates are multiplied by two, and all the incident points are added to this set.

Returns
the star of this set of points transformed to pointels, i.e. the smallest open cell complex containing it.

Definition at line 435 of file LatticeSetByIntervals.h.

436 {
437 Self C( myAxis );
438 // First step, place points as pointels and insert their star along
439 // dimension a.
440 for ( auto& pV : myData )
441 {
442 const Point q = 2 * pV.first;
443 C.myData[ q ] = pV.second.starOfPoints();
444 }
445 // Second step, dilate along remaining directions
446 for ( Dimension k = 0; k < dimension; k++ )
447 {
448 if ( k == myAxis ) continue;
449 for ( const auto& value : C.myData )
450 {
451 Point q = value.first;
452 if ( q[ k ] & 0x1 ) continue;
453 q[ k ] -= 1;
454 C.myData[ q ].add( value.second );
455 q[ k ] += 2;
456 C.myData[ q ].add( value.second );
457 }
458 }
459 return C;
460 }

References DGtal::LatticeSetByIntervals< TSpace >::dimension, DGtal::LatticeSetByIntervals< TSpace >::myAxis, and DGtal::LatticeSetByIntervals< TSpace >::myData.

◆ subtract()

template<typename TSpace >
Self & DGtal::LatticeSetByIntervals< TSpace >::subtract ( const Self other)
inline

Subtract set other from this object.

Parameters
otherany intervals
Returns
a reference to this object
Precondition
other and 'this' should share the same axis: this->axis() == other.axis()

Definition at line 299 of file LatticeSetByIntervals.h.

300 {
301 if ( other.axis() != axis() )
302 {
303 trace.error() << "[LatticeSetByInterval::subtract] "
304 << "Both lattice sets should share the same axis: "
305 << axis() << " != " << other.axis() << std::endl;
306 return *this;
307 }
308 for ( const auto& pV : other.myData )
309 {
310 const Point& p = pV.first;
311 auto it = myData.find( p );
312 if ( it != myData.end() )
313 it->second.subtract( pV.second );
314 }
315 return *this;
316 }

References DGtal::LatticeSetByIntervals< TSpace >::axis(), DGtal::Trace::error(), DGtal::LatticeSetByIntervals< TSpace >::myData, and DGtal::trace.

Referenced by DGtal::LatticeSetByIntervals< TSpace >::set_difference(), DGtal::LatticeSetByIntervals< TSpace >::set_intersection(), and DGtal::LatticeSetByIntervals< TSpace >::set_symmetric_difference().

◆ toPointRange()

template<typename TSpace >
PointRange DGtal::LatticeSetByIntervals< TSpace >::toPointRange ( ) const
inline
Returns
the range of points stored in this lattice set.

Definition at line 168 of file LatticeSetByIntervals.h.

169 {
170 PointRange X;
171 X.reserve( size() );
172 for ( const auto& pV : myData )
173 {
174 auto p = pV.first;
175 auto iVec = pV.second.integerVector();
176 for ( auto x : iVec )
177 {
178 p[ myAxis ] = x;
179 X.push_back( p );
180 }
181 }
182 return X;
183 }

References DGtal::LatticeSetByIntervals< TSpace >::myAxis, DGtal::LatticeSetByIntervals< TSpace >::myData, and DGtal::LatticeSetByIntervals< TSpace >::size().

Field Documentation

◆ dimension

template<typename TSpace >
const Dimension DGtal::LatticeSetByIntervals< TSpace >::dimension = Space::dimension
static

◆ myAxis

template<typename TSpace >
Dimension DGtal::LatticeSetByIntervals< TSpace >::myAxis

◆ myData

template<typename TSpace >
Container DGtal::LatticeSetByIntervals< TSpace >::myData

The documentation for this class was generated from the following file: