Wm4Mapper2.h

Go to the documentation of this file.
00001 // Wild Magic Source Code
00002 // David Eberly
00003 // http://www.geometrictools.com
00004 // Copyright (c) 1998-2007
00005 //
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Lesser General Public License as published by
00008 // the Free Software Foundation; either version 2.1 of the License, or (at
00009 // your option) any later version.  The license is available for reading at
00010 // either of the locations:
00011 //     http://www.gnu.org/copyleft/lgpl.html
00012 //     http://www.geometrictools.com/License/WildMagicLicense.pdf
00013 // The license applies to versions 0 through 4 of Wild Magic.
00014 //
00015 // Version: 4.0.0 (2006/06/28)
00016 
00017 #ifndef WM4MAPPER2_H
00018 #define WM4MAPPER2_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Vector2.h"
00022 
00023 namespace Wm4
00024 {
00025 
00026 template <class Real>
00027 class Mapper2
00028 {
00029 public:
00030     // Construction and destruction.  The value of epsilon is used as a
00031     // relative error when computing the dimension of the point set.
00032     Mapper2 (int iVQuantity, const Vector2<Real>* akVertex, Real fEpsilon);
00033     ~Mapper2 ();
00034 
00035     // Axis-aligned bounding box of the input points.
00036     const Vector2<Real>& GetMin () const;
00037     const Vector2<Real>& GetMax () const;
00038     Real GetMaxRange () const;
00039 
00040     // Dimension d of the set (0, 1, or 2).
00041     int GetDimension () const;
00042 
00043     // Coordinate system.  The origin is valid for any dimension d.  The
00044     // unit-length direction vector is valid only for 0 <= i < d.  The extreme
00045     // index is relative to the array of input points, and is also valid only
00046     // for 0 <= i < d.  If d = 0, all points are effectively the same, but the
00047     // use of an epsilon may lead to an extreme index that is not zero.  If
00048     // d = 1, all points effectively lie on a line segment.  The extreme
00049     // indices correspond to input points that are the end points of the
00050     // segment.  If d = 2, the first two extreme indices correspond to a
00051     // line segment.  The next extreme index corresponds to the input point
00052     // that is farthest from this line segment in the direction perpendicular
00053     // to the segment.
00054     const Vector2<Real>& GetOrigin () const;
00055     const Vector2<Real>& GetDirection (int i) const;
00056     int GetExtremeIndex (int i) const;
00057 
00058     // If d = 2, the direction vectors {U0,U1} form a right-handed set.  The
00059     // three extreme points form a triangle.  This function indicates if that
00060     // triangle is counterclockwise ordered.
00061     bool GetExtremeCCW () const;
00062 
00063 private:
00064     // Axis-aligned bounding box of input points.  The maximum range is the
00065     // larger of max[0]-min[0] and max[1]-min[1].
00066     Vector2<Real> m_kMin, m_kMax;
00067     Real m_fMaxRange;
00068 
00069     // The intrinsic dimension of the input set.  The parameter fEpsilon to
00070     // the constructor is used to provide a tolerance when determining the
00071     // dimension.
00072     int m_iDimension;
00073 
00074     // The indices that define the maximum dimensional extents.  The values
00075     // m_aiExtreme[0] and m_aiExtreme[1] are the indices for the vertices
00076     // which define the largest extent in one of the coordinate axis
00077     // directions.  If the intrinsic dimensionality is 2, then m_aiExtreme[2]
00078     // is the index for the vertex which causes the largest extent in the
00079     // direction perpendicular to the line through the vertices corresponding
00080     // to m_aiExtreme[0] and m_aiExtreme[1].  The triangle
00081     // <V[extreme0],V[extreme1],V[extreme2]> can be clockwise or
00082     // counterclockwise, the condition stored in m_bExtremeCCW.
00083     int m_aiExtreme[3];
00084     bool m_bExtremeCCW;
00085 
00086     // See the comments describing the member functions which return these
00087     // values.
00088     Vector2<Real> m_kOrigin;
00089     Vector2<Real> m_akDirection[2];
00090 };
00091 
00092 } //namespace Wm4
00093 
00094 #include "Wm4Mapper2.inl"
00095 
00096 namespace Wm4
00097 {
00098 typedef Mapper2<float> Mapper2f;
00099 typedef Mapper2<double> Mapper2d;
00100 }
00101 
00102 #endif

Generated on Wed Nov 23 19:01:04 2011 for FreeCAD by  doxygen 1.6.1