cgma
Cubit2DPoint.hpp
Go to the documentation of this file.
00001 //- Class: Cubit2DPoint
00002 //-
00003 //- Description: This file defines the Cubit2DPoint class which is a
00004 //- standard two-dimensional point in space. 
00005 //-
00006 //- Owner: Steve Storm
00007 
00008 #ifndef CUBIT2DPOINT_HPP
00009 #define CUBIT2DPOINT_HPP
00010 
00011 #include "CubitDefines.h"
00012 #include "CGMUtilConfigure.h"
00013 
00014 template <class X> class DLIList;
00015 
00016 class CUBIT_UTIL_EXPORT Cubit2DPoint
00017 {
00018 public:
00019   
00020     //- Heading: Constructors and Destructor
00021   Cubit2DPoint();  //- Default constructor.
00022   
00023   Cubit2DPoint( const double x, const double y );
00024     //- Constructor: create point from two components
00025 
00026   Cubit2DPoint( const double xy[2] );
00027     //- Constructor: create point from array
00028 
00029   Cubit2DPoint( const Cubit2DPoint& copy_from );  //- Copy Constructor
00030   Cubit2DPoint( const Cubit2DPoint* copy_from );  //- Copy Constructor
00031   
00032     //- Heading: Set and Inquire Functions
00033   void set( const double x, const double y );
00034     //- Change point components to {x}, {y}
00035   
00036   void set( const double xy[2] );
00037     //- Change point components to xy[0], xy[1]
00038   
00039   void set( const Cubit2DPoint& to_copy );
00040     //- Same as operator=(const Cubit2DPoint&)
00041   
00042   double x() const; //- Return x component of point
00043   double y() const; //- Return y component of point
00044   
00045   void get_xy( double &x, double &y ); //- Get x, y components
00046   void get_xy( double xy[3] ); //- Get xy array
00047   
00048   void x( const double x ); //- Set x component of point
00049   void y( const double y ); //- Set y component of point
00050 
00051   void print_me();
00052     //- Prints out the coordinates of this point.
00053 
00054   void min_max( const Cubit2DPoint &pnt2,
00055                 double &xmin, double &xmax,
00056                 double &ymin, double &ymax ) const;
00057     //- Get min & max coordinates between this point & the
00058     //- passed-in point.  Analogous to a 2D bounding box.
00059 
00060   void update_min_max( Cubit2DPoint &min, Cubit2DPoint &max ) const;
00061     //- Include this points coordinates in the given min-max bounding box.
00062 
00063   CubitBoolean is_on_line_segment( const Cubit2DPoint &end1,
00064                                    const Cubit2DPoint &end2,
00065                                    double tol = 1e-10 ) const;
00066     //- Determine if this point is on the line segment defined by end1 
00067     //- and end2.  Uses a triangle method for speed.  Note that in this 
00068     //- implementation the tolerance is not how close the point is to 
00069     //- the line - rather, it is how small a triangle area needs to be
00070     //- in order to consider its three points co-linear.
00071 
00072   Cubit2DPoint &operator=(const Cubit2DPoint &from);
00073 
00074 private:
00075   
00076   double xVal;  //- x component of point.
00077   double yVal;  //- y component of point.
00078 };
00079 
00080 inline Cubit2DPoint::Cubit2DPoint(const Cubit2DPoint& copy_from)
00081     : xVal(copy_from.xVal), yVal(copy_from.yVal)
00082 {}
00083 
00084 inline Cubit2DPoint::Cubit2DPoint(const Cubit2DPoint* copy_from)
00085     : xVal(copy_from->xVal), yVal(copy_from->yVal)
00086 {}
00087 
00088 inline Cubit2DPoint::Cubit2DPoint()
00089     : xVal(0.0), yVal(0.0)
00090 {}
00091 
00092 inline Cubit2DPoint::Cubit2DPoint( const double x,
00093                                    const double y )
00094     : xVal(x), yVal(y)
00095 {}
00096 
00097 inline double Cubit2DPoint::x() const
00098 { return xVal; }
00099 inline double Cubit2DPoint::y() const
00100 { return yVal; }
00101 
00102 inline void Cubit2DPoint::x( const double x )
00103 { xVal = x; }
00104 inline void Cubit2DPoint::y( const double y )
00105 { yVal = y; }
00106 
00107 inline void Cubit2DPoint::set( const double x,
00108                                const double y )
00109 {
00110   xVal = x;
00111   yVal = y;
00112 }
00113 
00114 inline void Cubit2DPoint::set( const double xy[2] )
00115 {
00116   xVal = xy[0];
00117   yVal = xy[1];
00118 }
00119 
00120 inline Cubit2DPoint& Cubit2DPoint::operator=(const Cubit2DPoint &from)  
00121 {
00122   xVal = from.xVal; 
00123   yVal = from.yVal;
00124   return *this;
00125 }
00126 
00127 inline void Cubit2DPoint::set(const Cubit2DPoint& to_copy)
00128 {
00129   *this = to_copy;
00130 }
00131 
00132 #endif
00133 
00134 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines