DGtal  0.9.4beta
Public Types | Public Member Functions | Private Attributes
DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger > Class Template Reference

#include <DGtal/kernel/BasicPointFunctors.h>

Collaboration diagram for DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >:
[legend]

Public Types

typedef SpaceND< 3, TInteger > Space
 
typedef Space::Point Point
 
typedef Space::Integer Integer
 

Public Member Functions

 Point2DEmbedderIn3D (const TDomain3D &aDomain3DImg, const Point &anOriginPoint, const Point &anUpperPointOnAxis1, const Point &anUpperPointOnAxis2, const Point &aDefautPoint=Point(0, 0, 0))
 
 Point2DEmbedderIn3D (const TDomain3D &aDomain3DImg, const Point &anOriginPoint, const typename Space::RealPoint &anNormalVector, const typename Point::Component &anWidth, const Point &aDefautPoint=Point(0, 0, 0))
 
template<typename TPoint2D >
Point operator() (const TPoint2D &aPoint, bool checkInsideDomain=true) const
 

Private Attributes

TDomain3D myDomain
 
Point myOriginPointEmbeddedIn3D
 
Point myDefaultPoint
 
Space::RealPoint myFirstAxisEmbeddedDirection
 
Space::RealPoint mySecondAxisEmbeddedDirection
 

Detailed Description

template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
class DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >

Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given in the 3D space.

Description of template class 'Point2DEmbedderIn3D'

It also checks if the resulting point is inside the 3D domain, else it returns a particular point (by default the point at domain origin (from the domain method lowerBound())).

It can be used to extract 2D images from volumetric files. For instance (see full example images/extract2DImagesFrom3D.cpp):

See also
tests/kernel/testBasicPointFunctors.cpp
Template Parameters
TDomain3Dthe type of the 3d domain.
TIntegerspecifies the integer number type used to define the space.
Examples:
images/extract2DImagesFrom3D.cpp, images/extract2DImagesFrom3DandVisu.cpp, and io/viewers/viewer3D-8bis-2Dimages.cpp.

Definition at line 370 of file BasicPointFunctors.h.

Member Typedef Documentation

template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
typedef Space::Integer DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Integer

Definition at line 376 of file BasicPointFunctors.h.

template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
typedef Space::Point DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Point

Definition at line 375 of file BasicPointFunctors.h.

template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
typedef SpaceND< 3, TInteger> DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Space

Definition at line 374 of file BasicPointFunctors.h.

Constructor & Destructor Documentation

template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Point2DEmbedderIn3D ( const TDomain3D &  aDomain3DImg,
const Point anOriginPoint,
const Point anUpperPointOnAxis1,
const Point anUpperPointOnAxis2,
const Point aDefautPoint = Point(0,0,0) 
)
inline

Constructor. Construct the functor from an origin 3D point, and two other 3D points defining the upper part of the 2D domain.

Parameters
aDomain3DImgthe 3D domain used to keep the resulting point in the domain.
anOriginPointthe origin point given in the 3D domain.
anUpperPointOnAxis1the upper point given in the 3D domain to define the first axis of the 2D domain.
anUpperPointOnAxis2the upper point given in the 3D domain to define the second axis of the 2D domain.
aDefautPointthe point given when the resulting point is outside the domain (default Point(0,0,0)).

Definition at line 388 of file BasicPointFunctors.h.

References DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myFirstAxisEmbeddedDirection, DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::mySecondAxisEmbeddedDirection, and DGtal::PointVector< dim, TEuclideanRing, TContainer >::norm().

391  : myDomain(aDomain3DImg),
392  myOriginPointEmbeddedIn3D(anOriginPoint),
393  myDefaultPoint (aDefautPoint),
394  myFirstAxisEmbeddedDirection(Point(anUpperPointOnAxis1[0]-anOriginPoint[0],
395  anUpperPointOnAxis1[1]-anOriginPoint[1],
396  anUpperPointOnAxis1[2]-anOriginPoint[2])),
397  mySecondAxisEmbeddedDirection(Point(anUpperPointOnAxis2[0]-anOriginPoint[0],
398  anUpperPointOnAxis2[1]-anOriginPoint[1],
399  anUpperPointOnAxis2[2]-anOriginPoint[2]))
400 
401 
402  {
405  }
double norm(const NormType type=L_2) const
template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Point2DEmbedderIn3D ( const TDomain3D &  aDomain3DImg,
const Point anOriginPoint,
const typename Space::RealPoint anNormalVector,
const typename Point::Component anWidth,
const Point aDefautPoint = Point(0,0,0) 
)
inline

Constructor. Construct the functor from an origin 3D point, an normal vector (normal to the 2D domain), and a width. The points of an 2D domain are embedded in 3D by using a normal vector giving the direction of the 2D domain embedded in the 3D space.

Parameters
aDomain3DImgthe 3D domain used to keep the resulting point in the domain.
anOriginPointthe center point given in the 3D domain.
anNormalVectorthe normal vector to the 2d domain embedded in 3D.
anWidththe width to determine the 2d domain bounds (the resulting 2d domain will be a square of length anWidth).
aDefautPointthe point given when the resulting point is outside the domain (default Point(0,0,0)).

Definition at line 420 of file BasicPointFunctors.h.

References DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myFirstAxisEmbeddedDirection, DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myOriginPointEmbeddedIn3D, DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::mySecondAxisEmbeddedDirection, and DGtal::PointVector< dim, TEuclideanRing, TContainer >::norm().

423  : myDomain(aDomain3DImg),
424  myDefaultPoint (aDefautPoint)
425  {
426  double d = -anNormalVector[0]*anOriginPoint[0] - anNormalVector[1]*anOriginPoint[1] - anNormalVector[2]*anOriginPoint[2];
427  typename Space::RealPoint pRefOrigin;
428  if(anNormalVector[0]!=0){
429  pRefOrigin [0]= -d/anNormalVector[0];
430  pRefOrigin [1]= 0.0;
431  pRefOrigin [2]= 0.0;
432  if(pRefOrigin==anOriginPoint){
433  pRefOrigin[1]=-1.0;
434  }
435  }else if (anNormalVector[1]!=0){
436  pRefOrigin [0]= 0.0;
437  pRefOrigin [1]= -d/anNormalVector[1];
438  pRefOrigin [2]= 0.0;
439  if(pRefOrigin==anOriginPoint){
440  pRefOrigin[0]=-1.0;
441  }
442  }else if (anNormalVector[2]!=0){
443  pRefOrigin [0]= 0.0;
444  pRefOrigin [1]= 0.0;
445  pRefOrigin [2]= -d/anNormalVector[2];
446  if(pRefOrigin==anOriginPoint){
447  pRefOrigin[0]=-1.0;
448  }
449  }
450  typename Space::RealPoint uDir1;
451  uDir1=(pRefOrigin-anOriginPoint)/((pRefOrigin-anOriginPoint).norm());
452  typename Space::RealPoint uDir2;
453  uDir2[0] = uDir1[1]*anNormalVector[2]-uDir1[2]*anNormalVector[1];
454  uDir2[1] = uDir1[2]*anNormalVector[0]-uDir1[0]*anNormalVector[2];
455  uDir2[2] = uDir1[0]*anNormalVector[1]-uDir1[1]*anNormalVector[0];
456 
457  uDir2/=uDir2.norm();
458 
459  myOriginPointEmbeddedIn3D = anOriginPoint + uDir1*anWidth/2 + uDir2*anWidth/2;
462 
463  }
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117

Member Function Documentation

template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
template<typename TPoint2D >
Point DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::operator() ( const TPoint2D &  aPoint,
bool  checkInsideDomain = true 
) const
inline

The operator just recover the 3D Point associated to the Point2DEmbederIn3D parameters.

Parameters
[in]aPointpoint of the input domain (of dimension 2).
checkInsideDomainif 'true', checks that the point lies inside the domain.
Returns
the digital point of dimension 3 (value rounded downward with floor).

Definition at line 477 of file BasicPointFunctors.h.

References DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myDefaultPoint, DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myDomain, DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myFirstAxisEmbeddedDirection, DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myOriginPointEmbeddedIn3D, DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::mySecondAxisEmbeddedDirection, DGtal::PointVector< dim, TEuclideanRing, TContainer >::size(), DGtal::trace, and DGtal::Trace::warning().

478  {
479  Point pt = myOriginPointEmbeddedIn3D;
480  for( Dimension i=0; i<pt.size(); i++){
481 
482  pt[i] = pt[i]+static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[0])
484  pt[i] = pt[i]+static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[1])
486  }
487 
488  if(myDomain.isInside(pt)|| !checkInsideDomain)
489  {
490  return pt;
491  }
492  else
493  {
494 #ifdef DEBUG_VERBOSE
495  trace.warning() << "Warning pt outside the 3D domain " << pt << std::endl;
496 #endif
497  return myDefaultPoint;
498  }
499  }
Trace trace
Definition: Common.h:137
static double castToDouble(const Integer &aT)
Definition: NumberTraits.h:154
DGtal::uint32_t Dimension
Definition: Common.h:120
std::ostream & warning()

Field Documentation

template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
Point DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myDefaultPoint
private
template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
TDomain3D DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myDomain
private
template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
Space::RealPoint DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myFirstAxisEmbeddedDirection
private
template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
Point DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myOriginPointEmbeddedIn3D
private
template<typename TDomain3D, typename TInteger = DGtal::Z3i::Integer>
Space::RealPoint DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::mySecondAxisEmbeddedDirection
private

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