DGtal  1.3.beta
Public Types | Public Member Functions | Private Attributes
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 &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 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/2]

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  }

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

◆ Point2DEmbedderIn3D() [2/2]

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

425  : myDomain(aDomain3DImg),
426  myDefaultPoint (aDefautPoint)
427  {
428  double d = -anNormalVector[0]*anOriginPoint[0] - anNormalVector[1]*anOriginPoint[1] - anNormalVector[2]*anOriginPoint[2];
429  typename Space::RealPoint pRefOrigin;
430  if(anNormalVector[0]!=0){
431  pRefOrigin [0]= -d/anNormalVector[0];
432  pRefOrigin [1]= 0.0;
433  pRefOrigin [2]= 0.0;
434  if(pRefOrigin==anOriginPoint){
435  pRefOrigin[1]=-1.0;
436  }
437  }else if (anNormalVector[1]!=0){
438  pRefOrigin [0]= 0.0;
439  pRefOrigin [1]= -d/anNormalVector[1];
440  pRefOrigin [2]= 0.0;
441  if(pRefOrigin==anOriginPoint){
442  pRefOrigin[0]=-1.0;
443  }
444  }else if (anNormalVector[2]!=0){
445  pRefOrigin [0]= 0.0;
446  pRefOrigin [1]= 0.0;
447  pRefOrigin [2]= -d/anNormalVector[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]*anNormalVector[2]-uDir1[2]*anNormalVector[1];
456  uDir2[1] = uDir1[2]*anNormalVector[0]-uDir1[0]*anNormalVector[2];
457  uDir2[2] = uDir1[0]*anNormalVector[1]-uDir1[1]*anNormalVector[0];
458 
459  uDir2/=uDir2.norm();
460 
461  myOriginPointEmbeddedIn3D = anOriginPoint + Point(uDir1*anWidth/2) + Point(uDir2*anWidth/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().

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

479  {
481  for( Dimension i=0; i<pt.size(); i++){
482 
483  pt[i] = pt[i]+static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[0])
485  pt[i] = pt[i]+static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[1])
487  }
488 
489  if(myDomain.isInside(pt)|| !checkInsideDomain)
490  {
491  return pt;
492  }
493  else
494  {
495 #ifdef DEBUG_VERBOSE
496  trace.warning() << "Warning pt outside the 3D domain " << pt << std::endl;
497 #endif
498  return myDefaultPoint;
499  }
500  }

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

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

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

◆ 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:
DGtal::functors::Point2DEmbedderIn3D::Point
Space::Point Point
Definition: BasicPointFunctors.h:377
DGtal::HyperRectDomain< Space >
aPoint
const Point aPoint(3, 4)
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:137
DGtal::functors::Point2DEmbedderIn3D::mySecondAxisEmbeddedDirection
Space::RealPoint mySecondAxisEmbeddedDirection
Definition: BasicPointFunctors.h:514
DGtal::functors::Identity
Aim: Define a simple default functor that just returns its argument.
Definition: BasicFunctors.h:287
DGtal::ConstImageAdapter
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Definition: ConstImageAdapter.h:105
DGtal::functors::Point2DEmbedderIn3D::myDefaultPoint
Point myDefaultPoint
Definition: BasicPointFunctors.h:508
DGtal::functors::Point2DEmbedderIn3D::myOriginPointEmbeddedIn3D
Point myOriginPointEmbeddedIn3D
Definition: BasicPointFunctors.h:506
DGtal::functors::Point2DEmbedderIn3D::myDomain
TDomain3D myDomain
Definition: BasicPointFunctors.h:503
Integer
Point::Coordinate Integer
Definition: examplePlaneProbingParallelepipedEstimator.cpp:44
DGtal::PointVector::norm
double norm(const NormType type=L_2) const
DGtal::NumberTraitsImpl< std::decay< Integer >::type >::castToDouble
static double castToDouble(const std::decay< Integer >::type &aT)
Cast method to double (for I/O or board export uses only).
Definition: NumberTraits.h:154
DGtal::PointVector< dim, Integer >
DGtal::ImageSelector::Type
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:75
DGtal::Trace::warning
std::ostream & warning()
Point
MyPointD Point
Definition: testClone2.cpp:383
IMAGE_PATCH_WIDTH
const int IMAGE_PATCH_WIDTH
Definition: extract2DImagesFrom3D.cpp:59
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::functors::Point2DEmbedderIn3D
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
Definition: BasicPointFunctors.h:372
DGtal::functors::Point2DEmbedderIn3D::myFirstAxisEmbeddedDirection
Space::RealPoint myFirstAxisEmbeddedDirection
Definition: BasicPointFunctors.h:511