//! file="amma/Surf3d/TriSet/Tri.hh" //! lib=tri //! userlevel=Default //! docentry="default.Adrian Hilton" //! rcsid="$Id: Tri.hh,v 1.8 2001/01/09 17:14:44 eep1rs Exp $" //! author="Adrian Hilton" //! date="04/02/97" // ------------------------------------------------------- // // Name : Tri.hh // Library : // Description: 3-gon // Dependancies: // Modified : // Created : 4.96 // Author : Adrian Hilton // // // ------------------------------------------------------- // // Notes on implementation of TriC/BodyTriSetC (1.97) // // 1. forward declare class BodyTriSetC // 2. declare class TriC (with pointer to BodyTriSetC) // 3. declare class TriSetC ( with SArray1dC) // 4. define inline functions for BodyTriSetC (used in inline of TriC) // 5. define inline functions for TriC // // 6. define class TriSetC with reference counding to enable arrays // of TriSetC // TriSetC contains a reference pointer to BodyTriSetC // all TriC in a BodyTriSetC contain ref pointers to the body // (ie assignment is invalid with BodyTriSetC // unless reference pointers in TriC are changes) // // this very specific ordering of class & inline declarations // is required to enable a loop with one class containing a pointer // to the other // ( a pointer must be used rather than an explicit variable to enable // loop to be broken) // NB: The above ordering is as used by RM in DList/Graph // only difference is here classes are defined in separate headers // rather than a single header file. // #ifndef TRI_HH #define TRI_HH #define TRI_INLINE inline #include "amma/Vector3d.hh" #include "amma/Vector2d.hh" #include "amma/OProj1a3.hh" #include "amma/OProj2a3.hh" #include "amma/SArray1d.hh" //#include "amma/TriSet.hh" //================================================================ class BodyTriSetC; #define TRI_DIM 3 //================================================================= class TriNearestPointC { public: TriNearestPointC(); RealT Distance() const; RealT& Distance(); RealT SignedDistance() const; RealT& SignedDistance(); RealT Weight() const; RealT& Weight(); Vector3dC Point() const; Vector3dC& Point(); Vector3dC Normal() const; Vector3dC& Normal(); BooleanT Bound() const; BooleanT& Bound(); // Bound information only available if TriSet().SetupBound() is called ? TriNearestPointC Nearest(const Vector3dC& v,const Vector3dC& p, const Vector3dC& n,const RealT& w, const BooleanT& b); // set 'this' nearest point to nearest of 'this' or 'v' // with normal 'n', weight 'w', boundary element status 'b' private: RealT distance; RealT signed_distance; RealT weight; Vector3dC point; Vector3dC normal; BooleanT bound; }; //================================================================= class TriC//: public OrthoProjection3to2dC { public: //--------------------------------------- Constructors TriC(); // default empty invalid Tri reqd for array construction //TriC(TriSetC& t); //TriC(Vector3dC *i,Vector3dC *j,Vector3dC *k); TriC(BodyTriSetC& ts,IntT i,IntT j, IntT k); // Construct tri between verticies i,j,k of BodyTriSetC // contains reference pointer to BodyTriSetC TriC(IntT i,IntT j, IntT k); // Construct temporary tri between verticies i,j,k without BodyTriSetC // Warning: cannot access verticies // reference to BodyTriSetC set on insertion using TriSetC::PutElement() TriC(const TriC& t); // Copy Constructor const TriC operator=(const TriC& t); // Assignment // Copies reference pointer to BodyTriSetC //--------------------------------------- Operations BooleanT IsValid() const; // test if this TriC is valid // ie not created by default constructor // (default constructor is required for array) IntT Index(const IntT i) const; // vertex index 0,1,2 //Vector3dC Normal(const TriSetC& tris) const; // Unit normal orthogonal to triangle plane BooleanT Bound() const; BooleanT& Bound(); // set/get boundary info. for element // Always FALSE unless TriSetC.SetupBound() is called Vector3dC Vertex(const IntT i) const; // vertex 0,1,2 Vector3dC Normal() const; // Unit normal orthogonal to triangle plane Vector3dC VertexNormal(const IntT i) const; // vertex normal 0,1,2 RealT EdgeLength(const IntT i, const IntT j) const; // Edge lenght vertex i to vertex j i,j=[0,1,2] RealT MinimumEdgeLength() const; // Minimum lenght of 'this' triangle edges RealT MaximumEdgeLength() const; // Maximum lenght of 'this' triangle edges //TriNearestPointC NearestPoint(TriSetC& t,const Vector3dC v); TriNearestPointC NearestPoint(const Vector3dC v) const; // nearest point on element void SetBodyTriSet(BodyTriSetC& ts); // set the pointer to BodyTriSetC for this TriC // use to change pointer when moving TriC between BodyTriSetC's // or when BodyTriSetC is not set on construction private: BodyTriSetC& BodyTriSet() const; // access to triset to which this tri belongs // for safety should always test if it's valid IsValid() BodyTriSetC* ptriset; // pointer to corresponding set (0) =invalid SArray1dC index; // List of vertex indicies BooleanT bound; // Only set if TriSet.SetupBound is called }; //================================================================= // triangle element + basis for orthogonal projection to 2D tri plane #ifndef AMMASUB class TriOrthoC: public OrthoProjection3to2dC, public TriC { public: TriOrthoC(); TriOrthoC(BodyTriSetC& tris,IntT i,IntT j, IntT k); TriOrthoC(const TriOrthoC& t); const TriOrthoC operator=(const TriOrthoC& t); private: }; #endif //===================================================================== //-------------------------------------------------------------------- // output external to class (ie only public acess) ostream & operator<<(ostream & s, const TriC & t); // Saves the list into the output stream. //-------------------------------------------------------------------- //================================================================== #include "amma/TriSet.hh" #ifdef TRI_INLINE //#include "amma/TriSet.icc" //#include "amma/TriSet.icc" #include "amma/Tri.icc" // uses Vertex(i) from TriSetC #endif #endif