All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Attributes
QGpCoreTools::Parallelepiped Class Reference

Brief description of class still missing. More...

#include <Parallelepiped.h>

List of all members.

Public Member Functions

void add (const Point &p)
double dx () const
double dy () const
double dz () const
bool includes (const Point &p) const
bool includes (double x1, double y1, double z1, double x2, double y2, double z2) const
bool includes (const Point &p1, const Point &p2) const
 Parallelepiped ()
 Parallelepiped (const Point &p1, const Point &p2)
 Parallelepiped (double nx1, double ny1, double nz1, double nx2, double ny2, double nz2)
 Parallelepiped (const Parallelepiped &o)
void setLimits (double nx1, double ny1, double nz1, double nx2, double ny2, double nz2)
QList< Pointvertice () const
double x1 () const
double x2 () const
double y1 () const
double y2 () const
double z1 () const
double z2 () const

Protected Attributes

double _x1
double _x2
double _y1
double _y2
double _z1
double _z2

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

References _x1, _x2, _y1, _y2, _z1, and _z2.

  {
    _x1=INFINITY;
    _y1=INFINITY;
    _z1=INFINITY;
    _x2=-INFINITY;
    _y2=-INFINITY;
    _z2=-INFINITY;
  }
QGpCoreTools::Parallelepiped::Parallelepiped ( const Point p1,
const Point p2 
) [inline]

References setLimits(), QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and QGpCoreTools::Point::z().

  {
    setLimits(p1.x(), p1.y(), p1.z(),
              p2.x(), p2.y(), p2.z());
  }
QGpCoreTools::Parallelepiped::Parallelepiped ( double  nx1,
double  ny1,
double  nz1,
double  nx2,
double  ny2,
double  nz2 
) [inline]

References setLimits().

  {
    setLimits(nx1, ny1, nz1,
              nx2, ny2, nz2);
  }

References _x1, _x2, _y1, _y2, _z1, and _z2.

  {
    _x1=o._x1;
    _y1=o._y1;
    _z1=o._z1;
    _x2=o._x2;
    _y2=o._y2;
    _z2=o._z2;
  }

Member Function Documentation

References _x1, _x2, _y1, _y2, _z1, _z2, QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and QGpCoreTools::Point::z().

  {
    if((p.x()>-INFINITY && p.x()<_x1) || _x1==-INFINITY) _x1=p.x();
    if((p.x()<INFINITY && p.x()>_x2) || _x2==INFINITY) _x2=p.x();
    if((p.y()>-INFINITY && p.y()<_y1) || _y1==-INFINITY) _y1=p.y();
    if((p.y()<INFINITY && p.y()>_y2) || _y2==INFINITY) _y2=p.y();
    if((p.z()>-INFINITY && p.z()<_z1) || _z1==-INFINITY) _z1=p.z();
    if((p.z()<INFINITY && p.z()>_z2) || _z2==INFINITY) _z2=p.z();
  }
double QGpCoreTools::Parallelepiped::dx ( ) const [inline]
{return _x2-_x1;}
double QGpCoreTools::Parallelepiped::dy ( ) const [inline]
{return _y2-_y1;}
double QGpCoreTools::Parallelepiped::dz ( ) const [inline]
{return _z2-_z1;}
bool QGpCoreTools::Parallelepiped::includes ( const Point p) const

Tests if the point is inside the rectangle

References _x1, _x2, _y1, _y2, _z1, _z2, TRACE, QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and QGpCoreTools::Point::z().

Referenced by includes(), QGpCoreTools::Segment::includes(), and QGpCoreTools::Segment::intersects().

  {
    TRACE;
    return (_x1<=p.x() && p.x()<=_x2 &&
            _y1<=p.y() && p.y()<=_y2 &&
            _z1<=p.z() && p.z()<=_z2);
  }
bool QGpCoreTools::Parallelepiped::includes ( double  x1,
double  y1,
double  z1,
double  x2,
double  y2,
double  z2 
) const

Tests if the segment defined by x1, y1, z1 and x2, y2, z2 is inside or crosses the rectangle

References _x1, _x2, _y1, _y2, _z1, _z2, QGpCoreTools::Rect::includes(), TRACE, QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and QGpCoreTools::Point::z().

  {
    TRACE;
    if(x1>_x1 && x1<_x2 &&
       y1>_y1 && y1<_y2 &&
       z1>_z1 && z1<_z2) return true;
    if(x2>_x1 && x2<_x2 &&
       y2>_y1 && y2<_y2 &&
       z2>_z1 && z2<_z2) return true;
    // p1 is outside, p2 is outside
    // Try to find one intersection with sides of the rectangle
    Point u(x2-x1, y2-y1, z2-z1);
    Point p0(x1, y1, z1);
    Rect rx(_y1, _z1, _y2, _z2);
    Rect ry(_x1, _z1, _x2, _z2);
    Rect rz(_x1, _y1, _x2, _y2);
    double k;
    Point p;

    if(u.x()!=0.0) {
      k=(_x1-p0.x())/u.x();
      p=u*k+p0;
      if(rx.includes(Point2D(p.y(), p.z()))) return true;
      k=(_x2-p0.x())/u.x();
      p=u*k+p0;
      if(rx.includes(Point2D(p.y(), p.z()))) return true;
    }

    if(u.y()!=0.0) {
      k=(_y1-p0.y())/u.y();
      p=u*k+p0;
      if(ry.includes(Point2D(p.x(), p.z()))) return true;
      k=(_y2-p0.y())/u.y();
      p=u*k+p0;
      if(ry.includes(Point2D(p.x(), p.z()))) return true;
    }

    if(u.z()!=0.0) {
      k=(_z1-p0.y())/u.z();
      p=u*k+p0;
      if(rz.includes(Point2D(p.x(), p.y()))) return true;
      k=(_z2-p0.y())/u.z();
      p=u*k+p0;
      if(rz.includes(Point2D(p.x(), p.y()))) return true;
    }

    return false;
  }
bool QGpCoreTools::Parallelepiped::includes ( const Point p1,
const Point p2 
) const [inline]

References includes(), QGpCoreTools::Point2D::x(), QGpCoreTools::Point2D::y(), and QGpCoreTools::Point::z().

  {
    return includes(p1.x(), p1.y(), p1.z(),
                    p2.x(), p2.y(), p2.z());
  }
void QGpCoreTools::Parallelepiped::setLimits ( double  nx1,
double  ny1,
double  nz1,
double  nx2,
double  ny2,
double  nz2 
)

Adjust the top-left-front and the bottom-rigth-back corners to include the points (nx1, ny1, nz1), and (nx2, ny2, nz2).

References _x1, _x2, _y1, _y2, _z1, _z2, and TRACE.

Referenced by Parallelepiped(), and QGpCoreTools::Segment::set().

  {
    TRACE;
    _x1=nx1;
    _y1=ny1;
    _z1=nz1;
    _x2=nx2;
    _y2=ny2;
    _z2=nz2;
    if(_x2<_x1) {
      std::swap(_x1, _x2);
    }
    if(_y2<_y1) {
      std::swap(_y1, _y2);
    }
    if(_z2<_z1) {
      std::swap(_z1, _z2);
    }
  }

References _x1, _x2, _y1, _y2, _z1, _z2, and TRACE.

  {
    TRACE;
    QList<Point> l;
    l.append(Point(_x1, _y1, _z1));
    l.append(Point(_x1, _y1, _z2));
    l.append(Point(_x1, _y2, _z1));
    l.append(Point(_x1, _y2, _z2));
    l.append(Point(_x2, _y1, _z1));
    l.append(Point(_x2, _y1, _z2));
    l.append(Point(_x2, _y2, _z1));
    l.append(Point(_x2, _y2, _z2));
    return l;
  }
double QGpCoreTools::Parallelepiped::x1 ( ) const [inline]
{return _x1;}
double QGpCoreTools::Parallelepiped::x2 ( ) const [inline]
{return _x2;}
double QGpCoreTools::Parallelepiped::y1 ( ) const [inline]
{return _y1;}
double QGpCoreTools::Parallelepiped::y2 ( ) const [inline]
{return _y2;}
double QGpCoreTools::Parallelepiped::z1 ( ) const [inline]
{return _z1;}
double QGpCoreTools::Parallelepiped::z2 ( ) const [inline]
{return _z2;}

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines