DGtal  1.5.beta
DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger > Class Template Reference

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

#include <DGtal/kernel/BasicPointFunctors.h>

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 &aNormalVector, const typename Point::Component &aWidth, const Point &aDefautPoint=Point(0, 0, 0))
 
 Point2DEmbedderIn3D (const TDomain3D &aDomain3DImg, const Point &anOriginPoint, const typename Space::RealPoint &aNormalVector, const typename Space::RealPoint &orientXaxisVector, const typename Point::Component &aWidth, const Point &aDefautPoint=Point(0, 0, 0))
 
template<typename TPoint2D >
Point operator() (const TPoint2D &aPoint, bool checkInsideDomain=true) const
 
void shiftOriginPoint (const typename Space::RealPoint &shift)
 

Private Attributes

TDomain3D myDomain
 
Space::RealPoint 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 372 of file BasicPointFunctors.h.

Member Typedef Documentation

◆ Integer

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

Definition at line 378 of file BasicPointFunctors.h.

◆ Point

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

Definition at line 377 of file BasicPointFunctors.h.

◆ Space

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

Definition at line 376 of file BasicPointFunctors.h.

Constructor & Destructor Documentation

◆ Point2DEmbedderIn3D() [1/3]

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 390 of file BasicPointFunctors.h.

393  : myDomain(aDomain3DImg),
394  myOriginPointEmbeddedIn3D(anOriginPoint),
395  myDefaultPoint (aDefautPoint),
396  myFirstAxisEmbeddedDirection(Point(anUpperPointOnAxis1[0]-anOriginPoint[0],
397  anUpperPointOnAxis1[1]-anOriginPoint[1],
398  anUpperPointOnAxis1[2]-anOriginPoint[2])),
399  mySecondAxisEmbeddedDirection(Point(anUpperPointOnAxis2[0]-anOriginPoint[0],
400  anUpperPointOnAxis2[1]-anOriginPoint[1],
401  anUpperPointOnAxis2[2]-anOriginPoint[2]))
402 
403 
404  {
407  }
double norm(const NormType type=L_2) const

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

◆ Point2DEmbedderIn3D() [2/3]

template<typename TDomain3D , typename TInteger = DGtal::Z3i::Integer>
DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Point2DEmbedderIn3D ( const TDomain3D &  aDomain3DImg,
const Point anOriginPoint,
const typename Space::RealPoint aNormalVector,
const typename Point::Component aWidth,
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.
aNormalVectorthe normal vector to the 2d domain embedded in 3D.
aWidththe width to determine the 2d domain bounds (the resulting 2d domain will be a square of length aWidth).
aDefautPointthe point given when the resulting point is outside the domain (default Point(0,0,0)).

Definition at line 422 of file BasicPointFunctors.h.

425  : myDomain(aDomain3DImg),
426  myDefaultPoint (aDefautPoint)
427  {
428  double d = -aNormalVector[0]*anOriginPoint[0] - aNormalVector[1]*anOriginPoint[1] - aNormalVector[2]*anOriginPoint[2];
429  typename Space::RealPoint pRefOrigin;
430  if(aNormalVector[0]!=0){
431  pRefOrigin [0]= -d/aNormalVector[0];
432  pRefOrigin [1]= 0.0;
433  pRefOrigin [2]= 0.0;
434  if(pRefOrigin==anOriginPoint){
435  pRefOrigin[1]=-1.0;
436  }
437  }else if (aNormalVector[1]!=0){
438  pRefOrigin [0]= 0.0;
439  pRefOrigin [1]= -d/aNormalVector[1];
440  pRefOrigin [2]= 0.0;
441  if(pRefOrigin==anOriginPoint){
442  pRefOrigin[0]=-1.0;
443  }
444  }else if (aNormalVector[2]!=0){
445  pRefOrigin [0]= 0.0;
446  pRefOrigin [1]= 0.0;
447  pRefOrigin [2]= -d/aNormalVector[2];
448  if(pRefOrigin==anOriginPoint){
449  pRefOrigin[0]=-1.0;
450  }
451  }
452  typename Space::RealPoint uDir1;
453  uDir1=(pRefOrigin-anOriginPoint)/((pRefOrigin-anOriginPoint).norm());
454  typename Space::RealPoint uDir2;
455  uDir2[0] = uDir1[1]*aNormalVector[2]-uDir1[2]*aNormalVector[1];
456  uDir2[1] = uDir1[2]*aNormalVector[0]-uDir1[0]*aNormalVector[2];
457  uDir2[2] = uDir1[0]*aNormalVector[1]-uDir1[1]*aNormalVector[0];
458 
459  uDir2/=uDir2.norm();
460 
461  myOriginPointEmbeddedIn3D = anOriginPoint + Point(uDir1*aWidth/2) + Point(uDir2*aWidth/2);
464  }

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().

◆ Point2DEmbedderIn3D() [3/3]

template<typename TDomain3D , typename TInteger = DGtal::Z3i::Integer>
DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Point2DEmbedderIn3D ( const TDomain3D &  aDomain3DImg,
const Point anOriginPoint,
const typename Space::RealPoint aNormalVector,
const typename Space::RealPoint orientXaxisVector,
const typename Point::Component aWidth,
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), another vector fixing the direction of the the image plane (from the x axis) 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.
aNormalVectorthe normal vector to the 2d domain embedded in 3D.
orientXaxisVectorthe vector determining the 3D orientation of the image plane (from the x axis).
aWidththe width to determine the 2d domain bounds (the resulting 2d domain will be a square of length aWidth).
aDefautPointthe point given when the resulting point is outside the domain (default Point(0,0,0)).

Definition at line 480 of file BasicPointFunctors.h.

484  : myDomain(aDomain3DImg),
485  myDefaultPoint (aDefautPoint)
486  {
487 
488  typename Space::RealPoint uDir1;
489  uDir1 = orientXaxisVector/orientXaxisVector.norm();
490  typename Space::RealPoint uDir2;
491  uDir2[0] = uDir1[1]*aNormalVector[2]-uDir1[2]*aNormalVector[1];
492  uDir2[1] = uDir1[2]*aNormalVector[0]-uDir1[0]*aNormalVector[2];
493  uDir2[2] = uDir1[0]*aNormalVector[1]-uDir1[1]*aNormalVector[0];
494  uDir2/=uDir2.norm();
495  myOriginPointEmbeddedIn3D = anOriginPoint + Point(-uDir1*aWidth/2) + Point(-uDir2*aWidth/2);
498  }

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().

Member Function Documentation

◆ operator()()

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 510 of file BasicPointFunctors.h.

511  {
512  Point pt ;
513  for( Dimension i=0; i<pt.size(); i++){
514 
515  pt[i] = static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[0])
517  pt[i] += static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[1])
519  }
520 
521  if(myDomain.isInside(pt)|| !checkInsideDomain)
522  {
523  return pt;
524  }
525  else
526  {
527 #ifdef DEBUG_VERBOSE
528  trace.warning() << "Warning pt outside the 3D domain " << pt << std::endl;
529 #endif
530  return myDefaultPoint;
531  }
532  }
std::ostream & warning()
DGtal::uint32_t Dimension
Definition: Common.h:136
Trace trace
Definition: Common.h:153
static double castToDouble(const std::decay< T >::type &aT)
Cast method to double (for I/O or board export uses only).
Definition: NumberTraits.h:164
MyPointD Point
Definition: testClone2.cpp:383
const Point aPoint(3, 4)

References aPoint(), 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().

◆ shiftOriginPoint()

template<typename TDomain3D , typename TInteger = DGtal::Z3i::Integer>
void DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::shiftOriginPoint ( const typename Space::RealPoint shift)
inline

Shift the image plane center of the functor (without modify the the image plane direction).

Parameters
[in]shiftdirection.

Definition at line 541 of file BasicPointFunctors.h.

542  {
543  for( Dimension i=0; i<myOriginPointEmbeddedIn3D.size(); i++){
545  }
546  }
static Dimension size()

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

Referenced by testProjector().

Field Documentation

◆ myDefaultPoint

template<typename TDomain3D , typename TInteger = DGtal::Z3i::Integer>
Point DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myDefaultPoint
private

◆ myDomain

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

◆ myFirstAxisEmbeddedDirection

template<typename TDomain3D , typename TInteger = DGtal::Z3i::Integer>
Space::RealPoint DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::myFirstAxisEmbeddedDirection
private

◆ myOriginPointEmbeddedIn3D

◆ mySecondAxisEmbeddedDirection

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: