Wm4Query3TRational.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 WM4QUERY3TRATIONAL_H
00018 #define WM4QUERY3TRATIONAL_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Query3.h"
00022 #include "Wm4RVector3.h"
00023 
00024 namespace Wm4
00025 {
00026 
00027 template <class Real>
00028 class Query3TRational : public Query3<Real>
00029 {
00030 public:
00031     // The components of the input vertices are represented exactly as
00032     // rational values.
00033     Query3TRational (int iVQuantity, const Vector3<Real>* akVertex);
00034     virtual ~Query3TRational ();
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 ToPlane (int i, int iV0, int iV1, int iV2) const;
00042     virtual int ToPlane (const Vector3<Real>& rkP, int iV0, int iV1, int iV2)
00043         const;
00044 
00045     virtual int ToTetrahedron (int i, int iV0, int iV1, int iV2, int iV3)
00046         const;
00047     virtual int ToTetrahedron (const Vector3<Real>& rkP, int iV0, int iV1,
00048         int iV2, int iV3) const;
00049 
00050     virtual int ToCircumsphere (int i, int iV0, int iV1, int iV2, int iV3)
00051         const;
00052     virtual int ToCircumsphere (const Vector3<Real>& rkP, int iV0, int iV1,
00053         int iV2, int iV3) const;
00054 
00055 private:
00056     using Query3<Real>::m_iVQuantity;
00057     using Query3<Real>::m_akVertex;
00058 
00059     // Caching for rational representations of the input.  The conversion of
00060     // floating-point numbers to TRational form is slow, so it is better to
00061     // keep track of which values have been converted.
00062     typedef TRational<8*sizeof(Real)> Rational;
00063     typedef RVector3<8*sizeof(Real)> RVector;
00064     mutable RVector* m_akRVertex;
00065     mutable bool* m_abEvaluated;
00066 
00067     void Convert (int iQuantity, int* aiIndex) const;
00068 
00069     int ToPlane (const RVector& rkRP, int iV0, int iV1, int iV2) const;
00070     int ToTetrahedron (const RVector& rkRP, int iV0, int iV1, int iV2,
00071         int iV3) const;
00072     int ToCircumsphere (const RVector& rkRP, int iV0, int iV1, int iV2,
00073         int iV3) const;
00074 
00075     static Rational Dot (Rational& rkX0, Rational& rkY0, Rational& rkZ0,
00076         Rational& rkX1, Rational& rkY1, Rational& rkZ1);
00077 
00078     static Rational Det3 (Rational& rkX0, Rational& rkY0, Rational& rkZ0,
00079         Rational& rkX1, Rational& rkY1, Rational& rkZ1, Rational& rkX2,
00080         Rational& rkY2, Rational& rkZ2);
00081 
00082     static Rational Det4 (Rational& rkX0, Rational& rkY0, Rational& rkZ0,
00083         Rational& rkW0, Rational& rkX1, Rational& rkY1, Rational& rkZ1,
00084         Rational& rkW1, Rational& rkX2, Rational& rkY2, Rational& rkZ2,
00085         Rational& rkW2, Rational& rkX3, Rational& rkY3, Rational& rkZ3,
00086         Rational& rkW3);
00087 };
00088 
00089 }
00090 
00091 #include "Wm4Query3TRational.inl"
00092 
00093 namespace Wm4
00094 {
00095 typedef Query3TRational<float> Query3TRationalf;
00096 typedef Query3TRational<double> Query3TRationald;
00097 
00098 }
00099 
00100 #endif

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