DGtal 2.0.0
Loading...
Searching...
No Matches
DGtal::EuclideanShapesCSG< ShapeA, ShapeB > Class Template Reference

Aim: Constructive Solid Geometry (CSG) between models of CEuclideanBoundedShape and CEuclideanOrientedShape 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/EuclideanShapesDecorator.h>

Inheritance diagram for DGtal::EuclideanShapesCSG< ShapeA, ShapeB >:
[legend]

Public Types

typedef ShapeA::Space Space
typedef ShapeA::RealPoint RealPoint

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CEuclideanBoundedShape< ShapeA >))
 BOOST_CONCEPT_ASSERT ((concepts::CEuclideanOrientedShape< ShapeA >))
 EuclideanShapesCSG ()
 EuclideanShapesCSG (const EuclideanShapesCSG &other)
 EuclideanShapesCSG (ConstAlias< ShapeA > a)
EuclideanShapesCSGoperator= (const EuclideanShapesCSG &other)
void setParams (ConstAlias< ShapeA > a)
void plus (ConstAlias< ShapeB > b)
void intersection (ConstAlias< ShapeB > b)
void minus (ConstAlias< ShapeB > b)
RealPoint getLowerBound () const
RealPoint getUpperBound () const
Orientation orientation (const RealPoint &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.
RealPoint myLowerBound
 Domain lower bound.
RealPoint myUpperBound
 Domain upper bound.
bool bIsValid
 if the CSG is valid.

Detailed Description

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

Aim: Constructive Solid Geometry (CSG) between models of CEuclideanBoundedShape and CEuclideanOrientedShape 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 'EuclideanShapesCSG'

Template Parameters
ShapeAtype of a first shape. Must be a model of CEuclideanBoundedShape and CEuclideanOrientedShape
ShapeBtype of a second shape. Must be a model of CEuclideanBoundedShape and CEuclideanOrientedShape
Examples
shapes/exampleEuclideanShapesDecorator.cpp.

Definition at line 67 of file EuclideanShapesDecorator.h.

Member Typedef Documentation

◆ RealPoint

template<typename ShapeA, typename ShapeB>
typedef ShapeA::RealPoint DGtal::EuclideanShapesCSG< ShapeA, ShapeB >::RealPoint

Definition at line 82 of file EuclideanShapesDecorator.h.

◆ Space

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

Definition at line 81 of file EuclideanShapesDecorator.h.

Member Enumeration Documentation

◆ e_operator

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

Definition at line 70 of file EuclideanShapesDecorator.h.

Constructor & Destructor Documentation

◆ EuclideanShapesCSG() [1/3]

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

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

Definition at line 88 of file EuclideanShapesDecorator.h.

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

◆ EuclideanShapesCSG() [2/3]

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

Copy constructor.

Parameters
[in]othera EuclideanShapesCSG to copy

Definition at line 97 of file EuclideanShapesDecorator.h.

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

◆ EuclideanShapesCSG() [3/3]

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

Constructor. EuclideanShapesCSG will be valid.

Parameters
[in]aa model of CEuclideanBoundedShape and CEuclideanOrientedShape

Definition at line 108 of file EuclideanShapesDecorator.h.

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

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename ShapeA, typename ShapeB>
DGtal::EuclideanShapesCSG< ShapeA, ShapeB >::BOOST_CONCEPT_ASSERT ( (concepts::CEuclideanOrientedShape< ShapeA >) )

◆ getLowerBound()

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

Definition at line 222 of file EuclideanShapesDecorator.h.

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

◆ getUpperBound()

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

Definition at line 233 of file EuclideanShapesDecorator.h.

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

◆ intersection()

template<typename ShapeA, typename ShapeB>
void DGtal::EuclideanShapesCSG< 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 CEuclideanBoundedShape and CEuclideanOrientedShape

Definition at line 182 of file EuclideanShapesDecorator.h.

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

◆ isValid()

◆ minus()

template<typename ShapeA, typename ShapeB>
void DGtal::EuclideanShapesCSG< 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 CEuclideanBoundedShape and CEuclideanOrientedShape

Definition at line 206 of file EuclideanShapesDecorator.h.

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

◆ operator=()

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

Copy operator.

Parameters
[in]othera EuclideanShapesCSG to copy
Returns
this

Definition at line 124 of file EuclideanShapesDecorator.h.

125 {
128
131
133
134 return *this;
135 }

◆ orientation()

template<typename ShapeA, typename ShapeB>
Orientation DGtal::EuclideanShapesCSG< ShapeA, ShapeB >::orientation ( const RealPoint & 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 248 of file EuclideanShapesDecorator.h.

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

◆ plus()

template<typename ShapeA, typename ShapeB>
void DGtal::EuclideanShapesCSG< 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 CEuclideanBoundedShape and CEuclideanOrientedShape

Definition at line 158 of file EuclideanShapesDecorator.h.

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

◆ selfDisplay()

template<typename ShapeA, typename ShapeB>
void DGtal::EuclideanShapesCSG< 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::EuclideanShapesCSG< ShapeA, ShapeB >::setParams ( ConstAlias< ShapeA > a)
inline

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

Parameters
[in]aa ShapeA, model of CEuclideanBoundedShape and CEuclideanOrientedShape

Definition at line 142 of file EuclideanShapesDecorator.h.

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

Field Documentation

◆ bIsValid

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

if the CSG is valid.

Definition at line 335 of file EuclideanShapesDecorator.h.

Referenced by DGtal::EuclideanShapesCSG< KernelSupport, KernelSupport >::operator=().

◆ myLowerBound

template<typename ShapeA, typename ShapeB>
RealPoint DGtal::EuclideanShapesCSG< ShapeA, ShapeB >::myLowerBound
private

◆ myShapeA

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

◆ myUpperBound

template<typename ShapeA, typename ShapeB>
RealPoint DGtal::EuclideanShapesCSG< ShapeA, ShapeB >::myUpperBound
private

◆ v_shapes

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

Vector of all operations (ordered) of ShapeB.

Definition at line 326 of file EuclideanShapesDecorator.h.

Referenced by DGtal::EuclideanShapesCSG< KernelSupport, KernelSupport >::operator=().


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