DGtal 2.1.0
Loading...
Searching...
No Matches
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, and io/viewers/viewer3D-8bis-2Dimages.cpp.

Definition at line 379 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 385 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 384 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 383 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 397 of file BasicPointFunctors.h.

400 : myDomain(aDomain3DImg),
401 myOriginPointEmbeddedIn3D(anOriginPoint),
402 myDefaultPoint (aDefautPoint),
403 myFirstAxisEmbeddedDirection(Point(anUpperPointOnAxis1[0]-anOriginPoint[0],
404 anUpperPointOnAxis1[1]-anOriginPoint[1],
405 anUpperPointOnAxis1[2]-anOriginPoint[2])),
406 mySecondAxisEmbeddedDirection(Point(anUpperPointOnAxis2[0]-anOriginPoint[0],
407 anUpperPointOnAxis2[1]-anOriginPoint[1],
408 anUpperPointOnAxis2[2]-anOriginPoint[2]))
409
410
411 {
414 }
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 429 of file BasicPointFunctors.h.

432 : myDomain(aDomain3DImg),
433 myDefaultPoint (aDefautPoint)
434 {
435 double d = -aNormalVector[0]*anOriginPoint[0] - aNormalVector[1]*anOriginPoint[1] - aNormalVector[2]*anOriginPoint[2];
436 typename Space::RealPoint pRefOrigin;
437 if(aNormalVector[0]!=0){
438 pRefOrigin [0]= -d/aNormalVector[0];
439 pRefOrigin [1]= 0.0;
440 pRefOrigin [2]= 0.0;
441 if(pRefOrigin==anOriginPoint){
442 pRefOrigin[1]=-1.0;
443 }
444 }else if (aNormalVector[1]!=0){
445 pRefOrigin [0]= 0.0;
446 pRefOrigin [1]= -d/aNormalVector[1];
447 pRefOrigin [2]= 0.0;
448 if(pRefOrigin==anOriginPoint){
449 pRefOrigin[0]=-1.0;
450 }
451 }else if (aNormalVector[2]!=0){
452 pRefOrigin [0]= 0.0;
453 pRefOrigin [1]= 0.0;
454 pRefOrigin [2]= -d/aNormalVector[2];
455 if(pRefOrigin==anOriginPoint){
456 pRefOrigin[0]=-1.0;
457 }
458 }
459 typename Space::RealPoint uDir1;
460 uDir1=(pRefOrigin-anOriginPoint)/((pRefOrigin-anOriginPoint).norm());
461 typename Space::RealPoint uDir2;
462 uDir2[0] = uDir1[1]*aNormalVector[2]-uDir1[2]*aNormalVector[1];
463 uDir2[1] = uDir1[2]*aNormalVector[0]-uDir1[0]*aNormalVector[2];
464 uDir2[2] = uDir1[0]*aNormalVector[1]-uDir1[1]*aNormalVector[0];
465
466 uDir2/=uDir2.norm();
467
468 myOriginPointEmbeddedIn3D = anOriginPoint + Point(uDir1*aWidth/2) + Point(uDir2*aWidth/2);
471 }
PointVector< dim, double > RealPoint
Definition SpaceND.h:117
double norm() const

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

491 : myDomain(aDomain3DImg),
492 myDefaultPoint (aDefautPoint)
493 {
494
495 typename Space::RealPoint uDir1;
496 uDir1 = orientXaxisVector/orientXaxisVector.norm();
497 typename Space::RealPoint uDir2;
498 uDir2[0] = uDir1[1]*aNormalVector[2]-uDir1[2]*aNormalVector[1];
499 uDir2[1] = uDir1[2]*aNormalVector[0]-uDir1[0]*aNormalVector[2];
500 uDir2[2] = uDir1[0]*aNormalVector[1]-uDir1[1]*aNormalVector[0];
501 uDir2/=uDir2.norm();
502 myOriginPointEmbeddedIn3D = anOriginPoint + Point(-uDir1*aWidth/2) + Point(-uDir2*aWidth/2);
505 }

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

518 {
519 Point pt ;
520 for( Dimension i=0; i<pt.size(); i++){
521
522 pt[i] = static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[0])
524 pt[i] += static_cast<Integer>(floor(NumberTraits<Integer>::castToDouble(aPoint[1])
526 }
527
528 if(myDomain.isInside(pt)|| !checkInsideDomain)
529 {
530 return pt;
531 }
532 else
533 {
534#ifdef DEBUG_VERBOSE
535 trace.warning() << "Warning pt outside the 3D domain " << pt << std::endl;
536#endif
537 return myDefaultPoint;
538 }
539 }
std::ostream & warning()
DGtal::uint32_t Dimension
Definition Common.h:119
Trace trace
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 548 of file BasicPointFunctors.h.

549 {
550 for( Dimension i=0; i<myOriginPointEmbeddedIn3D.size(); i++){
552 }
553 }
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

◆ myOriginPointEmbeddedIn3D

◆ mySecondAxisEmbeddedDirection


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