point.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00022 
00023 #if !defined POINT_HEADER
00024 #define POINT_HEADER
00025 
00026 #include "dwfcore/String.h"
00027 
00028 
00030 
00031 class WHIPTK_API WT_Point3D
00032 {
00033 public:
00034     double        m_x; 
00035     double        m_y; 
00036     double        m_z; 
00038 
00039     WT_Point3D() {}
00040 
00042     WT_Point3D(double x, double y, double z = 0.0)
00043         : m_x (x)
00044         , m_y (y)
00045         , m_z (z)
00046     { }
00047 
00049     WT_Boolean operator== (WT_Point3D const & p3d) const
00050     {
00051         if (m_x == p3d.m_x && m_y == p3d.m_y && m_z == p3d.m_z)
00052             return WD_True;
00053         else
00054             return WD_False;
00055     }
00056 };
00057 
00059 
00060 class WHIPTK_API WT_Point2D
00061 {
00062 private:
00063         char          m_zPointString[64];
00064     WT_Unsigned_Integer16 _nPrecision;
00065     double        _x; 
00066     double        _y; 
00067 public:
00068     double        m_x; 
00069     double        m_y; 
00071 
00072     WT_Point2D()
00073         :  _nPrecision(10)
00074         , _x(0.0)
00075         , _y(0.0) 
00076         , m_x(0.0)
00077         , m_y(0.0)  
00078     {
00079         m_zPointString[0] = '\0';
00080     }
00081 
00083     WT_Point2D(WT_Point2D const &r)
00084         : _nPrecision(r._nPrecision)
00085         , _x(r._x)
00086         , _y(r._y)  
00087         , m_x(r.m_x)
00088         , m_y(r.m_y)  
00089     {
00090         m_zPointString[0] = '\0';
00091     }
00092 
00094     WT_Point2D(double x, double y)
00095         : _nPrecision(10)
00096         , _x (x)
00097         , _y (y)
00098         , m_x (x)
00099         , m_y (y)
00100     { 
00101         m_zPointString[0] = '\0';
00102     }
00103 
00104         virtual~ WT_Point2D()
00105         {
00106         }
00107 
00109     WT_Point2D const &operator= (WT_Point2D const & rPt)
00110     {
00111         _x = rPt._x;
00112         _y = rPt._y;
00113         m_x = rPt.m_x;
00114         m_y = rPt.m_y;
00115         m_zPointString[0] = '\0';
00116         return *this;
00117     }
00118 
00120     WT_Boolean operator== (WT_Point2D const & rPt) const
00121     {
00122         if (m_x == rPt.m_x && m_y == rPt.m_y )
00123             return WD_True;
00124         else
00125             return WD_False;
00126     }
00127 
00129         const char * toString( WT_Unsigned_Integer16 nPrecision )
00130         {
00131         if (m_zPointString[0] == '\0' || _x != m_x || _y != m_y || _nPrecision != nPrecision)
00132         {
00133             _x = m_x;
00134             _y = m_y;
00135 
00136             if (nPrecision > 17)
00137                 nPrecision = 17;
00138 
00139             _nPrecision = nPrecision;
00140 
00141                     char cFormattedBuf[64];
00142             DWFCore::DWFString::DoubleToString( cFormattedBuf, 64, m_x, nPrecision );
00143             
00144                     DWFCORE_ASCII_STRING_COPY(m_zPointString, cFormattedBuf);
00145                     DWFCORE_ASCII_STRING_CONCATENATE(m_zPointString, ",");
00146 
00147             DWFCore::DWFString::DoubleToString( cFormattedBuf, 64, m_y, nPrecision );
00148                     DWFCORE_ASCII_STRING_CONCATENATE(m_zPointString, cFormattedBuf);
00149         }
00150 
00151                 return m_zPointString;
00152         }
00153 
00154 };
00155 
00156 #endif // POINT_HEADER

Generated on Tue Jan 6 22:41:13 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5