File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
DGtal::DigitalShapesCSG< ShapeA, ShapeB > Class Template Reference

Aim: Constructive Solid Geometry (CSG) between models of CDigitalBoundedShape and CDigitalOrientedShape Use CSG operation (union, intersection, minus) from a shape of Type ShapeA with one (or more) shapes of Type ShapeB. Can combine differents operations. Limitations: Since we don't have a class derived by all shapes, operations can be done by only one type of shapes. Use CSG of CSG to go beyond this limitation. More...

#include <DGtal/shapes/DigitalShapesDecorator.h>

Public Types

typedef ShapeA::Space Space
typedef ShapeA::Point Point

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CDigitalBoundedShape< ShapeA >))
 BOOST_CONCEPT_ASSERT ((concepts::CDigitalOrientedShape< ShapeA >))
 DigitalShapesCSG ()
 DigitalShapesCSG (const DigitalShapesCSG &other)
 DigitalShapesCSG (ConstAlias< ShapeA > a)
DigitalShapesCSGoperator= (const DigitalShapesCSG &other)
void setParams (ConstAlias< ShapeA > a)
void plus (ConstAlias< ShapeB > b)
void intersection (ConstAlias< ShapeB > b)
void minus (ConstAlias< ShapeB > b)
Point getLowerBound () const
Point getUpperBound () const
Orientation orientation (const Point &p) const
void selfDisplay (std::ostream &out) const
bool isValid () const

Protected Types

enum  e_operator { e_plus , e_intersection , e_minus }

Private Attributes

CountedConstPtrOrConstPtr< ShapeA > myShapeA
 Base Shape.
std::vector< std::pair< e_operator, CountedConstPtrOrConstPtr< ShapeB > > > v_shapes
 Vector of all operations (ordered) of ShapeB.
Point myLowerBound
 Domain lower bound.
Point myUpperBound
 Domain upper bound.
bool bIsValid
 if the CSG is valid.

Detailed Description

template<typename ShapeA, typename ShapeB>
class DGtal::DigitalShapesCSG< ShapeA, ShapeB >

Aim: Constructive Solid Geometry (CSG) between models of CDigitalBoundedShape and CDigitalOrientedShape Use CSG operation (union, intersection, minus) from a shape of Type ShapeA with one (or more) shapes of Type ShapeB. Can combine differents operations. Limitations: Since we don't have a class derived by all shapes, operations can be done by only one type of shapes. Use CSG of CSG to go beyond this limitation.

Description of template class 'DigitalShapesCSG'

Template Parameters
ShapeAtype of a first shape. Must be a model of CDigitalBoundedShape and CDigitalOrientedShape
ShapeBtype of a second shape. Must be a model of CDigitalBoundedShape and CDigitalOrientedShape

Definition at line 67 of file DigitalShapesDecorator.h.

Member Typedef Documentation

◆ Point

template<typename ShapeA, typename ShapeB>
typedef ShapeA::Point DGtal::DigitalShapesCSG< ShapeA, ShapeB >::Point

Definition at line 82 of file DigitalShapesDecorator.h.

◆ Space

template<typename ShapeA, typename ShapeB>
typedef ShapeA::Space DGtal::DigitalShapesCSG< ShapeA, ShapeB >::Space

Definition at line 81 of file DigitalShapesDecorator.h.

Member Enumeration Documentation

◆ e_operator

template<typename ShapeA, typename ShapeB>
enum DGtal::DigitalShapesCSG::e_operator
protected
Enumerator
e_plus 
e_intersection 
e_minus 

Definition at line 70 of file DigitalShapesDecorator.h.

Constructor & Destructor Documentation

◆ DigitalShapesCSG() [1/3]

template<typename ShapeA, typename ShapeB>
DGtal::DigitalShapesCSG< ShapeA, ShapeB >::DigitalShapesCSG ( )
inline

Default constructor. DigitalShapesCSG will be not valid without setParams(ShapeA).

Definition at line 88 of file DigitalShapesDecorator.h.

89 : bIsValid(false)
90 {}
bool bIsValid
if the CSG is valid.

References bIsValid.

Referenced by DigitalShapesCSG(), and operator=().

◆ DigitalShapesCSG() [2/3]

template<typename ShapeA, typename ShapeB>
DGtal::DigitalShapesCSG< ShapeA, ShapeB >::DigitalShapesCSG ( const DigitalShapesCSG< ShapeA, ShapeB > & other)
inline

Copy constructor.

Parameters
[in]othera DigitalShapesCSG to copy

Definition at line 97 of file DigitalShapesDecorator.h.

101 {}
Aim: Constructive Solid Geometry (CSG) between models of CDigitalBoundedShape and CDigitalOrientedSha...
std::vector< std::pair< e_operator, CountedConstPtrOrConstPtr< ShapeB > > > v_shapes
Vector of all operations (ordered) of ShapeB.
CountedConstPtrOrConstPtr< ShapeA > myShapeA
Base Shape.
Point myUpperBound
Domain upper bound.
Point myLowerBound
Domain lower bound.

References bIsValid, DigitalShapesCSG(), myLowerBound, myShapeA, myUpperBound, and v_shapes.

◆ DigitalShapesCSG() [3/3]

template<typename ShapeA, typename ShapeB>
DGtal::DigitalShapesCSG< ShapeA, ShapeB >::DigitalShapesCSG ( ConstAlias< ShapeA > a)
inline

Constructor. DigitalShapesCSG will be valid.

Parameters
[in]aa model of CDigitalBoundedShape and CDigitalOrientedShape

Definition at line 109 of file DigitalShapesDecorator.h.

110 : myShapeA( a )
111 {
112 myLowerBound = myShapeA->getLowerBound();
113 myUpperBound = myShapeA->getUpperBound();
114
115 bIsValid = true;
116 }

References bIsValid, myLowerBound, myShapeA, and myUpperBound.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename ShapeA, typename ShapeB>
DGtal::DigitalShapesCSG< ShapeA, ShapeB >::BOOST_CONCEPT_ASSERT ( (concepts::CDigitalBoundedShape< ShapeA >) )

Referenced by intersection(), minus(), and plus().

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename ShapeA, typename ShapeB>
DGtal::DigitalShapesCSG< ShapeA, ShapeB >::BOOST_CONCEPT_ASSERT ( (concepts::CDigitalOrientedShape< ShapeA >) )

◆ getLowerBound()

template<typename ShapeA, typename ShapeB>
Point DGtal::DigitalShapesCSG< ShapeA, ShapeB >::getLowerBound ( ) const
inline
Returns
the lower bound of the shape bounding box.

Definition at line 224 of file DigitalShapesDecorator.h.

225 {
226 FATAL_ERROR_MSG( isValid(), "Operation invalid. Maybe you don't set a ShapeA object." );
227
228 return myLowerBound;
229 }

References isValid(), and myLowerBound.

◆ getUpperBound()

template<typename ShapeA, typename ShapeB>
Point DGtal::DigitalShapesCSG< ShapeA, ShapeB >::getUpperBound ( ) const
inline
Returns
the upper bound of the shape bounding box.

Definition at line 235 of file DigitalShapesDecorator.h.

236 {
237 FATAL_ERROR_MSG( isValid(), "Operation invalid. Maybe you don't set a ShapeA object." );
238
239 return myUpperBound;
240 }

References isValid(), and myUpperBound.

◆ intersection()

template<typename ShapeA, typename ShapeB>
void DGtal::DigitalShapesCSG< ShapeA, ShapeB >::intersection ( ConstAlias< ShapeB > b)
inline

Intersection between a (ShapeA) and b (ShapeB). If an operation was already set, the intersection will be between the CSG shape and b (ShapeB).

Parameters
[in]ba ShapeB, model of CDigitalBoundedShape and CDigitalOrientedShape

Definition at line 183 of file DigitalShapesDecorator.h.

184 {
187
188 FATAL_ERROR_MSG( isValid(), "Operation invalid. Maybe you don't set a ShapeA object." );
189
191
192 for(Dimension i=0; i < Space::dimension; ++i)
193 {
196 }
197
198 v_shapes.push_back(shape);
199 }
BOOST_CONCEPT_ASSERT((concepts::CDigitalBoundedShape< ShapeA >))

References BOOST_CONCEPT_ASSERT(), DGtal::SpaceND< 3, Integer >::dimension, e_intersection, isValid(), myLowerBound, myUpperBound, and v_shapes.

◆ isValid()

template<typename ShapeA, typename ShapeB>
bool DGtal::DigitalShapesCSG< ShapeA, ShapeB >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 316 of file DigitalShapesDecorator.h.

317 {
318 return bIsValid;
319 }

References bIsValid.

Referenced by getLowerBound(), getUpperBound(), intersection(), minus(), orientation(), and plus().

◆ minus()

template<typename ShapeA, typename ShapeB>
void DGtal::DigitalShapesCSG< ShapeA, ShapeB >::minus ( ConstAlias< ShapeB > b)
inline

Minus between a (ShapeA) and b (ShapeB). If an operation was already set, the minus will be between the CSG shape and b (ShapeB).

Parameters
[in]ba ShapeB, model of CDigitalBoundedShape and CDigitalOrientedShape

Definition at line 207 of file DigitalShapesDecorator.h.

208 {
211
212 FATAL_ERROR_MSG( isValid(), "Operation invalid. Maybe you don't set a ShapeA object." );
213
215
216 v_shapes.push_back(shape);
217
218 }

References BOOST_CONCEPT_ASSERT(), e_minus, isValid(), and v_shapes.

◆ operator=()

template<typename ShapeA, typename ShapeB>
DigitalShapesCSG & DGtal::DigitalShapesCSG< ShapeA, ShapeB >::operator= ( const DigitalShapesCSG< ShapeA, ShapeB > & other)
inline

Copy operator.

Parameters
[in]othera DigitalShapesCSG to copy
Returns
this

Definition at line 125 of file DigitalShapesDecorator.h.

126 {
129
132
134
135 return *this;
136 }

References bIsValid, DigitalShapesCSG(), myLowerBound, myShapeA, myUpperBound, and v_shapes.

◆ orientation()

template<typename ShapeA, typename ShapeB>
Orientation DGtal::DigitalShapesCSG< ShapeA, ShapeB >::orientation ( const Point & p) const
inline

Return the orientation of a point with respect to a shape. Resolve all operations done with operators in the order they are set.

Parameters
[in]pinput point
Returns
the orientation of the point (0 = INSIDE, 1 = ON, 2 = OUTSIDE)

e_plus

Definition at line 250 of file DigitalShapesDecorator.h.

251 {
252 FATAL_ERROR_MSG( isValid(), "Operation invalid. Maybe you don't set a ShapeA object." );
253
254 Orientation orient = myShapeA->orientation( p );
255
256 for(unsigned int i = 0; i < v_shapes.size(); ++i)
257 {
258 if( v_shapes[i].first == e_minus )
259 {
260 if (( v_shapes[i].second->orientation( p ) == INSIDE ) || ( v_shapes[i].second->orientation( p ) == ON ))
261 {
262 orient = OUTSIDE;
263 }
264 }
265 else if( v_shapes[i].first == e_intersection )
266 {
267 if (( orient == ON ) && ( v_shapes[i].second->orientation( p ) != OUTSIDE ))
268 {
269 orient = ON;
270 }
271 else if (( v_shapes[i].second->orientation( p ) == ON ) && ( orient != OUTSIDE ))
272 {
273 orient = ON;
274 }
275 else if (( orient == INSIDE ) && ( v_shapes[i].second->orientation( p ) == INSIDE ))
276 {
277 orient = INSIDE;
278 }
279 else
280 {
281 orient = OUTSIDE;
282 }
283 }
284 else
285 {
286 if (( orient == INSIDE ) || ( v_shapes[i].second->orientation( p ) == INSIDE ))
287 {
288 orient = INSIDE;
289 }
290 else if (( orient == ON ) || ( v_shapes[i].second->orientation( p ) == ON ))
291 {
292 orient = ON;
293 }
294 else
295 {
296 orient = OUTSIDE;
297 }
298 }
299 }
300
301 return orient;
302 }
Orientation orientation(const Point &p) const

References e_intersection, e_minus, DGtal::INSIDE, isValid(), myShapeA, DGtal::ON, DGtal::OUTSIDE, and v_shapes.

◆ plus()

template<typename ShapeA, typename ShapeB>
void DGtal::DigitalShapesCSG< ShapeA, ShapeB >::plus ( ConstAlias< ShapeB > b)
inline

Union between a shape (ShapeA, gived at construction) and b (ShapeB). If an operation was already set, the union will be between the CSG shape and b (ShapeB).

Parameters
[in]ba ShapeB, model of CDigitalBoundedShape and CDigitalOrientedShape

Definition at line 159 of file DigitalShapesDecorator.h.

160 {
163
164 FATAL_ERROR_MSG( isValid(), "Operation invalid. Maybe you don't set a ShapeA object." );
165
167
168 for(Dimension i =0; i < Space::dimension; ++i)
169 {
172 }
173
174 v_shapes.push_back(shape);
175 }

References BOOST_CONCEPT_ASSERT(), DGtal::SpaceND< 3, Integer >::dimension, e_plus, isValid(), myLowerBound, myUpperBound, and v_shapes.

◆ selfDisplay()

template<typename ShapeA, typename ShapeB>
void DGtal::DigitalShapesCSG< ShapeA, ShapeB >::selfDisplay ( std::ostream & out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ setParams()

template<typename ShapeA, typename ShapeB>
void DGtal::DigitalShapesCSG< ShapeA, ShapeB >::setParams ( ConstAlias< ShapeA > a)
inline

Add a (unique) ShapeA for the CSG computation. DigitalShapesCSG will be valid after. If a ShapeA was already set, the previous one will be override.

Parameters
[in]aa ShapeA, model of CDigitalBoundedShape and CDigitalOrientedShape

Definition at line 143 of file DigitalShapesDecorator.h.

144 {
145 myShapeA = a;
146
147 myLowerBound = myShapeA->getLowerBound();
148 myUpperBound = myShapeA->getUpperBound();
149
150 bIsValid = true;
151 }

References bIsValid, myLowerBound, myShapeA, and myUpperBound.

Field Documentation

◆ bIsValid

template<typename ShapeA, typename ShapeB>
bool DGtal::DigitalShapesCSG< ShapeA, ShapeB >::bIsValid
private

if the CSG is valid.

Definition at line 337 of file DigitalShapesDecorator.h.

Referenced by DigitalShapesCSG(), DigitalShapesCSG(), DigitalShapesCSG(), isValid(), operator=(), and setParams().

◆ myLowerBound

template<typename ShapeA, typename ShapeB>
Point DGtal::DigitalShapesCSG< ShapeA, ShapeB >::myLowerBound
private

◆ myShapeA

template<typename ShapeA, typename ShapeB>
CountedConstPtrOrConstPtr< ShapeA > DGtal::DigitalShapesCSG< ShapeA, ShapeB >::myShapeA
private

◆ myUpperBound

template<typename ShapeA, typename ShapeB>
Point DGtal::DigitalShapesCSG< ShapeA, ShapeB >::myUpperBound
private

◆ v_shapes

template<typename ShapeA, typename ShapeB>
std::vector< std::pair<e_operator, CountedConstPtrOrConstPtr< ShapeB > > > DGtal::DigitalShapesCSG< ShapeA, ShapeB >::v_shapes
private

Vector of all operations (ordered) of ShapeB.

Definition at line 328 of file DigitalShapesDecorator.h.

Referenced by DigitalShapesCSG(), intersection(), minus(), operator=(), orientation(), and plus().


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