Wm4IntrTriangle3Triangle3.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.1 (2006/07/25)
00016 
00017 #ifndef WM4INTRTRIANGLE3TRIANGLE3_H
00018 #define WM4INTRTRIANGLE3TRIANGLE3_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Intersector.h"
00022 #include "Wm4Triangle3.h"
00023 #include "Wm4Line3.h"
00024 #include "Wm4Plane3.h"
00025 
00026 namespace Wm4
00027 {
00028 
00029 template <class Real>
00030 class WM4_FOUNDATION_ITEM IntrTriangle3Triangle3
00031     : public Intersector<Real,Vector3<Real> >
00032 {
00033 public:
00034     IntrTriangle3Triangle3 (const Triangle3<Real>& rkTriangle0,
00035         const Triangle3<Real>& rkTriangle1);
00036 
00037     // object access
00038     const Triangle3<Real>& GetTriangle0 () const;
00039     const Triangle3<Real>& GetTriangle1 () const;
00040 
00041     bool ReportCoplanarIntersections;  // default 'true'
00042 
00043     // static queries
00044     virtual bool Test ();
00045     virtual bool Find ();
00046 
00047     // dynamic queries
00048     virtual bool Test (Real fTMax, const Vector3<Real>& rkVelocity0,
00049         const Vector3<Real>& rkVelocity1);
00050     virtual bool Find (Real fTMax, const Vector3<Real>& rkVelocity0,
00051         const Vector3<Real>& rkVelocity1);
00052 
00053     // information about the intersection set
00054     int GetQuantity () const;
00055     const Vector3<Real>& GetPoint (int i) const;
00056 
00057 private:
00058     using Intersector<Real,Vector3<Real> >::m_fContactTime;
00059 
00060     static void ProjectOntoAxis (const Triangle3<Real>& rkTri,
00061         const Vector3<Real>& rkAxis, Real& rfMin, Real& rfMax);
00062 
00063     static void TrianglePlaneRelations (const Triangle3<Real>& rkTriangle,
00064         const Plane3<Real>& rkPlane, Real afDistance[3], int aiSign[3],
00065         int& riPositive, int& riNegative, int& riZero);
00066 
00067     static void GetInterval (const Triangle3<Real>& rkTriangle,
00068         const Line3<Real>& rkLine, const Real afDistance[3],
00069         const int aiSign[3], Real afParam[2]);
00070 
00071     bool ContainsPoint (const Triangle3<Real>& rkTriangle,
00072         const Plane3<Real>& rkPlane, const Vector3<Real>& rkPoint);
00073 
00074     bool IntersectsSegment (const Triangle3<Real>& rkTriangle,
00075         const Vector3<Real>& rkEnd0, const Vector3<Real>& rkEnd1);
00076 
00077     bool GetCoplanarIntersection (const Plane3<Real>& rkPlane,
00078         const Triangle3<Real>& rkTri0, const Triangle3<Real>& rkTri1);
00079 
00080     static bool TestOverlap (const Vector3<Real>& rkAxis, Real fTMax,
00081         Real fSpeed, Real fUMin, Real fUMax, Real fVMin, Real fVMax,
00082         Real& rfTFirst, Real& rfTLast);
00083 
00084     bool TestOverlap (const Vector3<Real>& rkAxis, Real fTMax,
00085         const Vector3<Real>& rkVelocity, Real& rfTFirst, Real& rfTLast);
00086 
00087     enum ProjectionMap
00088     {
00089         M2, M11,                // lines
00090         M3, M21, M12, M111,     // triangles
00091         M44, M2_2, M1_1         // boxes
00092     };
00093 
00094     enum ContactSide
00095     {
00096         CS_LEFT,
00097         CS_RIGHT,
00098         CS_NONE
00099     };
00100 
00101     class WM4_FOUNDATION_ITEM Configuration
00102     {
00103     public:
00104         ProjectionMap Map;  // how vertices map to the projection interval
00105         int Index[8];       // the sorted indices of the vertices
00106         Real Min, Max;      // the interval is [min,max]
00107     };
00108 
00109     static void ProjectOntoAxis (const Triangle3<Real>& rkTri,
00110         const Vector3<Real>& rkAxis, Configuration& rkCfg);
00111 
00112     bool FindOverlap (const Vector3<Real>& rkAxis, Real fTMax, Real fSpeed,
00113         const Configuration& rkUC, const Configuration& rkVC,
00114         ContactSide& reSide, Configuration& rkTUC, Configuration& rkTVC,
00115         Real& rfTFirst, Real& rfTLast);
00116 
00117     bool FindOverlap (const Vector3<Real>& rkAxis, Real fTMax,
00118         const Vector3<Real>& rkVelocity, ContactSide& reSide,
00119         Configuration& rkTCfg0, Configuration& rkTCfg1, Real& rfTFirst,
00120         Real& rfTLast);
00121 
00122     void FindContactSet (const Triangle3<Real>& rkTri0,
00123         const Triangle3<Real>& rkTri1, ContactSide& reSide,
00124         Configuration& rkCfg0, Configuration& rkCfg1);
00125 
00126     void GetEdgeEdgeIntersection (const Vector3<Real>& rkU0,
00127         const Vector3<Real>& rkU1, const Vector3<Real>& rkV0,
00128         const Vector3<Real>& rkV1);
00129 
00130     // the objects to intersect
00131     const Triangle3<Real>& m_rkTriangle0;
00132     const Triangle3<Real>& m_rkTriangle1;
00133 
00134     // information about the intersection set
00135     int m_iQuantity;
00136     Vector3<Real> m_akPoint[6];
00137 };
00138 
00139 typedef IntrTriangle3Triangle3<float> IntrTriangle3Triangle3f;
00140 typedef IntrTriangle3Triangle3<double> IntrTriangle3Triangle3d;
00141 
00142 }
00143 
00144 #endif

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