Wm4Query2TRational.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 WM4QUERY2TRATIONAL_H
00018 #define WM4QUERY2TRATIONAL_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Query2.h"
00022 #include "Wm4RVector2.h"
00023 
00024 namespace Wm4
00025 {
00026 
00027 template <class Real>
00028 class Query2TRational : public Query2<Real>
00029 {
00030 public:
00031     // The components of the input vertices are represented exactly as
00032     // rational values.
00033     Query2TRational (int iVQuantity, const Vector2<Real>* akVertex);
00034     virtual ~Query2TRational ();
00035 
00036     // run-time type information
00037     virtual Query::Type GetType () const;
00038 
00039     // Queries about the relation of a point to various geometric objects.
00040 
00041     virtual int ToLine (int i, int iV0, int iV1) const;
00042     virtual int ToLine (const Vector2<Real>& rkP, int iV0, int iV1) const;
00043 
00044     virtual int ToTriangle (int i, int iV0, int iV1, int iV2) const;
00045     virtual int ToTriangle (const Vector2<Real>& rkP, int iV0, int iV1,
00046         int iV2) const;
00047 
00048     virtual int ToCircumcircle (int i, int iV0, int iV1, int iV2) const;
00049     virtual int ToCircumcircle (const Vector2<Real>& rkP, int iV0, int iV1,
00050         int iV2) const;
00051 
00052 private:
00053     using Query2<Real>::m_iVQuantity;
00054     using Query2<Real>::m_akVertex;
00055 
00056     // Caching for rational representations of the input.  The conversion of
00057     // floating-point numbers to TRational form is slow, so it is better to
00058     // keep track of which values have been converted.
00059     typedef TRational<4*sizeof(Real)> Rational;
00060     typedef RVector2<4*sizeof(Real)> RVector;
00061     mutable RVector* m_akRVertex;
00062     mutable bool* m_abEvaluated;
00063 
00064     void Convert (int iQuantity, int* aiIndex) const;
00065 
00066     int ToLine (const RVector& rkRP, int iV0, int iV1) const;
00067     int ToTriangle (const RVector& rkRP, int iV0, int iV1, int iV2) const;
00068     int ToCircumcircle (const RVector& rkRP, int iV0, int iV1, int iV2) const;
00069 
00070     static Rational Dot (Rational& rkX0, Rational& rkY0, Rational& rkX1,
00071         Rational& rkY1);
00072 
00073     static Rational Det2 (Rational& rkX0, Rational& rkY0, Rational& rkX1,
00074         Rational& rkY1);
00075 
00076     static Rational Det3 (Rational& rkX0, Rational& rkY0, Rational& rkZ0,
00077         Rational& rkX1, Rational& rkY1, Rational& rkZ1, Rational& rkX2,
00078         Rational& rkY2, Rational& rkZ2);
00079 };
00080 
00081 }
00082 
00083 #include "Wm4Query2TRational.inl"
00084 
00085 namespace Wm4
00086 {
00087 typedef Query2TRational<float> Query2TRationalf;
00088 typedef Query2TRational<double> Query2TRationald;
00089 
00090 }
00091 
00092 #endif

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