- Main Page
- Related Pages
- Modules
- Classes
- Files

# DirectPositionImpl.h

Go to the documentation of this file.

    00001 #ifndef _DIRECTPOSITIONIMPL_H_
    00002 #define _DIRECTPOSITIONIMPL_H_
    00003
    00004 //
    00005 // Copyright (C) 2004-2006  Autodesk, Inc.
    00006 //
    00007 // This library is free software; you can redistribute it and/or
    00008 // modify it under the terms of version 2.1 of the GNU Lesser
    00009 // General Public License as published by the Free Software Foundation.
    00010 //
    00011 // This library is distributed in the hope that it will be useful,
    00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014 // Lesser General Public License for more details.
    00015 //
    00016 // You should have received a copy of the GNU Lesser General Public
    00017 // License along with this library; if not, write to the Free Software
    00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00019 //
    00020
    00021
    00022
    00023 #ifdef _WIN32
    00024 #pragma once
    00025 #endif
    00026
    00027 #include <FdoCommon.h>
    00028 #include <Common/Dimensionality.h>
    00029 #include <Geometry/IDirectPosition.h>
    00030
    00031 /// \brief
    00032 /// The FdoDirectPositionImpl class is a default implementation of FdoIDirectPosition.
    00033 /// FdoDirectPositionImpl implements accessors from FdoIDirectPosition, matching mutators, and simple data members.
    00034 /// Assignment and exact equality operators are also provided.
    00035 class FdoDirectPositionImpl : public FdoIDirectPosition
    00036 {
    00037
    00038 /// \cond DOXYGEN-IGNORE
    00039 protected:
    00040     /// Constructors
    00041
    00042     /// \brief
    00043     /// Constructs a default instance of a FdoDirectPositionImpl object.
    00044     ///
    00045     /// \remarks
    00046     ///  Ordinate values default to numeric_limits<double>::quiet_NaN().
    00047     /// Dimensionality defaults to FdoDimensionality_XY.
    00048     ///
    00049     /// \return
    00050     /// Returns nothing
    00051     ///
    00052     FDO_GEOM_API FdoDirectPositionImpl();
    00053
    00054     /// \brief
    00055     /// Constructs a 2D FdoDirectPositionImpl object from X and Y ordinates.
    00056     ///
    00057     /// \remarks
    00058     ///  Z and M ordinate values default to numeric_limits<double>::quiet_NaN().
    00059     /// Dimensionality is set to FdoDimensionality_XY.
    00060     ///
    00061     /// \param x
    00062     /// Input X ordinate value
    00063     /// \param y
    00064     /// Input Y ordinate value
    00065     ///
    00066     /// \return
    00067     /// Returns nothing
    00068     ///
    00069     FDO_GEOM_API FdoDirectPositionImpl(double x, double y);
    00070
    00071     /// \brief
    00072     /// Constructs a 3D FdoDirectPositionImpl object from X, Y and Z ordinates.
    00073     ///
    00074     /// \remarks
    00075     ///  M ordinate value defaults to numeric_limits<double>::quiet_NaN().
    00076     /// Dimensionality is set to FdoDimensionality_XYZ.
    00077     ///
    00078     /// \param x
    00079     /// Input X ordinate value
    00080     /// \param y
    00081     /// Input Y ordinate value
    00082     /// \param z
    00083     /// Input Z ordinate value
    00084     ///
    00085     /// \return
    00086     /// Returns nothing
    00087     ///
    00088     FDO_GEOM_API FdoDirectPositionImpl(double x, double y, double z);
    00089
    00090     /// \brief
    00091     /// Constructs a 4D FdoDirectPositionImpl object from X, Y, Z and M ordinates.
    00092     ///
    00093     /// \remarks
    00094     ///  Dimensionality is set to FdoDimensionality_XYZ|FdoDimensionality_M.
    00095     ///
    00096     /// \param x
    00097     /// Input X ordinate value
    00098     /// \param y
    00099     /// Input Y ordinate value
    00100     /// \param z
    00101     /// Input Z ordinate value
    00102     /// \param m
    00103     /// Input M ordinate value
    00104     ///
    00105     /// \return
    00106     /// Returns nothing
    00107     ///
    00108     FDO_GEOM_API FdoDirectPositionImpl(double x, double y, double z, double m);
    00109
    00110     /// \brief
    00111     /// Constructs a FdoDirectPositionImpl object by copying from an ordinate array.
    00112     ///
    00113     /// \param dimensionality
    00114     /// Input dimensionality of the ordinates (see FdoDimensionality)
    00115     /// \param ordinates
    00116     /// Input ordinate array
    00117     ///
    00118     /// \return
    00119     /// Returns a position
    00120     ///
    00121     FDO_GEOM_API FdoDirectPositionImpl(FdoInt32 dimensionality, const double * ordinates);
    00122
    00123     /// \brief
    00124     /// Copy constructor for FdoDirectPositionImpl
    00125     ///
    00126     /// \param position
    00127     /// Input position to copy
    00128     ///
    00129     /// \return
    00130     /// Returns nothing
    00131     ///
    00132     FDO_GEOM_API FdoDirectPositionImpl(const FdoDirectPositionImpl& position);
    00133
    00134     /// \brief
    00135     /// Pseudo-copy constructor for FdoDirectPositionImpl
    00136     ///
    00137     /// \remarks
    00138     ///  Copies position data using only public methods of FdoIDirectPosition,
    00139     /// thus supporting conversion from any implementation of the interface.
    00140     ///
    00141     /// \param pos
    00142     /// Input position to copy
    00143     ///
    00144     /// \return
    00145     /// Returns nothing
    00146     ///
    00147     FDO_GEOM_API FdoDirectPositionImpl(const FdoIDirectPosition* pos);
    00148
    00149     /// Destructor
    00150
    00151     /// \brief
    00152     /// Default destructor.
    00153     ///
    00154     /// \return
    00155     /// Returns nothing
    00156     ///
    00157     FDO_GEOM_API virtual ~FdoDirectPositionImpl();
    00158
    00159 /// \endcond
    00160
    00161 public:
    00162
    00163     /// \brief
    00164     /// Constructs a default instance of a FdoDirectPositionImpl object.
    00165     ///
    00166     /// \remarks
    00167     ///  Ordinate values default to numeric_limits<double>::quiet_NaN().
    00168     /// Dimensionality defaults to FdoDimensionality_XY.
    00169     ///
    00170     /// \return
    00171     /// Returns a position
    00172     ///
    00173     FDO_GEOM_API static FdoDirectPositionImpl* Create();
    00174
    00175     /// \brief
    00176     /// Constructs a 2D FdoDirectPositionImpl object from X and Y ordinates.
    00177     ///
    00178     /// \remarks
    00179     ///  Z and M ordinate values default to numeric_limits<double>::quiet_NaN().
    00180     /// Dimensionality is set to FdoDimensionality_XY.
    00181     ///
    00182     /// \param x
    00183     /// Input X ordinate value
    00184     /// \param y
    00185     /// Input Y ordinate value
    00186     ///
    00187     /// \return
    00188     /// Returns a position
    00189     ///
    00190     FDO_GEOM_API static FdoDirectPositionImpl* Create(double x, double y);
    00191
    00192     /// \brief
    00193     /// Constructs a 3D FdoDirectPositionImpl object from X, Y and Z ordinates.
    00194     ///
    00195     /// \remarks
    00196     ///  M ordinate value defaults to numeric_limits<double>::quiet_NaN().
    00197     /// Dimensionality is set to FdoDimensionality_XY|FdoDimensionality_Z.
    00198     ///
    00199     /// \param x
    00200     /// Input X ordinate value
    00201     /// \param y
    00202     /// Input Y ordinate value
    00203     /// \param z
    00204     /// Input Z ordinate value
    00205     ///
    00206     /// \return
    00207     /// Returns a position
    00208     ///
    00209     FDO_GEOM_API static FdoDirectPositionImpl* Create(double x, double y, double z);
    00210
    00211     /// \brief
    00212     /// Constructs a 4D FdoDirectPositionImpl object from X, Y, Z and M ordinates.
    00213     ///
    00214     /// \remarks
    00215     ///  Dimensionality is set to FdoDimensionality_XY|FdoDimensionality_Z|FdoDimensionality_M.
    00216     ///
    00217     /// \param x
    00218     /// Input X ordinate value
    00219     /// \param y
    00220     /// Input Y ordinate value
    00221     /// \param z
    00222     /// Input Z ordinate value
    00223     /// \param m
    00224     /// Input M ordinate value
    00225     ///
    00226     /// \return
    00227     /// Returns a position
    00228     ///
    00229     FDO_GEOM_API static FdoDirectPositionImpl* Create(double x, double y, double z, double m);
    00230
    00231     /// \brief
    00232     /// Constructs a FdoDirectPositionImpl object by copying from an ordinate array.
    00233     ///
    00234     /// \param dimensionality
    00235     /// Input dimensionality of the ordinates (see FdoDimensionality)
    00236     /// \param ordinates
    00237     /// Input ordinate array
    00238     ///
    00239     /// \return
    00240     /// Returns a position
    00241     ///
    00242     FDO_GEOM_API static FdoDirectPositionImpl* Create(FdoInt32 dimensionality, const double* ordinates);
    00243
    00244     /// \brief
    00245     /// Constructs a copy of a FdoDirectPositionImpl
    00246     ///
    00247     /// \param position
    00248     /// Input position to copy
    00249     ///
    00250     /// \return
    00251     /// Returns a position
    00252     ///
    00253     FDO_GEOM_API static FdoDirectPositionImpl* Create(const FdoDirectPositionImpl& position);
    00254
    00255     /// \brief
    00256     /// Constructs a copy of a FdoDirectPositionImpl
    00257     ///
    00258     /// \remarks
    00259     ///  Copies position data using only public methods of FdoIDirectPosition,
    00260     /// thus supporting conversion from any implementation of the interface.
    00261     ///
    00262     /// \param pos
    00263     /// Input position to copy
    00264     ///
    00265     /// \return
    00266     /// Returns a position
    00267     ///
    00268     FDO_GEOM_API static FdoDirectPositionImpl* Create(const FdoIDirectPosition* pos);
    00269
    00270     /// \brief
    00271     /// Assignment operator for FdoDirectPositionImpl.
    00272     ///
    00273     /// \param position
    00274     /// Input position to copy
    00275     ///
    00276     /// \return
    00277     /// Returns a position
    00278     ///
    00279     FDO_GEOM_API FdoDirectPositionImpl& operator=(const FdoDirectPositionImpl& position);
    00280
    00281     /// \brief
    00282     /// Assignment operator for FdoDirectPositionImpl from a FdoIDirectPosition, using public methods.
    00283     ///
    00284     /// \param position
    00285     /// Input position to copy
    00286     ///
    00287     /// \return
    00288     /// Returns a position
    00289     ///
    00290     FDO_GEOM_API FdoDirectPositionImpl& operator=(const FdoIDirectPosition& position);
    00291
    00292     /// \brief
    00293     /// Equality operator for FdoDirectPositionImpl.
    00294     ///
    00295     /// \param rhs
    00296     /// Input position for comparison (right-hand-side of equation)
    00297     ///
    00298     /// \return
    00299     /// Returns true if all ordinates and dimensionality are exactly equal.
    00300     ///
    00301     FDO_GEOM_API bool operator==(const FdoDirectPositionImpl& rhs) const;
    00302
    00303     /// \brief
    00304     /// Gets the X ordinate.
    00305     ///
    00306     /// \return
    00307     /// Returns the X ordinate; default is numeric_limits<double>::quiet_NaN()
    00308     ///
    00309     FDO_GEOM_API double GetX() const;
    00310
    00311     /// \brief
    00312     /// Gets the Y ordinate.
    00313     ///
    00314     /// \return
    00315     /// Returns the Y ordinate; default is numeric_limits<double>::quiet_NaN()
    00316     ///
    00317     FDO_GEOM_API double GetY() const;
    00318
    00319     /// \brief
    00320     /// Gets the Z ordinate.
    00321     ///
    00322     /// \return
    00323     /// Returns the Z ordinate; default is numeric_limits<double>::quiet_NaN()
    00324     ///
    00325     FDO_GEOM_API double GetZ() const;
    00326
    00327     /// \brief
    00328     /// Gets the M ordinate.
    00329     ///
    00330     /// \return
    00331     /// Returns the M ordinate; default is numeric_limits<double>::quiet_NaN()
    00332     ///
    00333     FDO_GEOM_API double GetM() const;
    00334
    00335     /// \brief
    00336     /// Gets the ordinates as an array.
    00337     ///
    00338     /// \remarks
    00339     /// The caller must not free the returned array.
    00340     /// The ordinates are in the order XYZM, with only those present
    00341     /// according to the dimensionality.
    00342     ///
    00343     /// \return
    00344     /// Returns the ordinates
    00345     ///
    00346     FDO_GEOM_API virtual const double * GetOrdinates();
    00347
    00348     /// \brief
    00349     /// Gets the dimensionality of ordinates in this position.
    00350     ///
    00351     /// \remarks
    00352     ///  Values are from the FdoDimensionality enumeration.
    00353     /// A return type of "FdoInt32" is used instead of the enumeration, catering to typical use with bit masking.
    00354     ///
    00355     /// \return
    00356     /// Returns the ordinate dimensionality
    00357     ///
    00358     FDO_GEOM_API FdoInt32 GetDimensionality() const;
    00359
    00360     /// \brief
    00361     /// Sets the X ordinate.
    00362     ///
    00363     /// \param x
    00364     /// Input X ordinate value
    00365     ///
    00366     /// \return
    00367     /// Returns nothing
    00368     ///
    00369     FDO_GEOM_API void SetX(double x);
    00370
    00371     /// \brief
    00372     /// Sets the Y ordinate.
    00373     ///
    00374     /// \param y
    00375     /// Input Y ordinate value
    00376     ///
    00377     /// \return
    00378     /// Returns nothing
    00379     ///
    00380     FDO_GEOM_API void SetY(double y);
    00381
    00382     /// \brief
    00383     /// Sets the Z ordinate.
    00384     ///
    00385     /// \param z
    00386     /// Input Z ordinate value
    00387     ///
    00388     /// \return
    00389     /// Returns nothing
    00390     ///
    00391     FDO_GEOM_API void SetZ(double z);
    00392
    00393     /// \brief
    00394     /// Sets the M ordinate.
    00395     ///
    00396     /// \param m
    00397     /// Input M ordinate value
    00398     ///
    00399     /// \return
    00400     /// Returns nothing
    00401     ///
    00402     FDO_GEOM_API void SetM(double m);
    00403
    00404     /// \brief
    00405     /// Sets the dimensionality.
    00406     ///
    00407     /// \remarks
    00408     ///  Use values (including bitwise combinations) from the FdoDimensionality enumeration.
    00409     ///
    00410     /// \param dimensionality
    00411     /// Input dimensionality value
    00412     ///
    00413     /// \return
    00414     /// Returns nothing
    00415     ///
    00416     FDO_GEOM_API void SetDimensionality(FdoInt32 dimensionality);
    00417
    00418 /// \cond DOXYGEN-IGNORE
    00419 protected:
    00420
    00421     void Dispose();
    00422
    00423     double      m_x;
    00424     double      m_y;
    00425     double      m_z;
    00426     double      m_m;
    00427     FdoInt32    m_dimensionality;
    00428
    00429     /// The following is just to retain ownership of the ordinate array in
    00430     /// case GetOrdinates() is called.  An alternative implementation might
    00431     /// optimise for GetOrdinates() by always using "double m_ordinates[4]"
    00432     /// instead of the m_x, m_y, ... above.
    00433     double *    m_ordinates;
    00434
    00435 /// \endcond
    00436 };
    00437 #endif
    00438
    00439

Please send us your comment about this page