cgma
|
00001 #ifndef FACETERFACETDATA_HPP 00002 #define FACETERFACETDATA_HPP 00003 00004 // Include for CubitBoolean 00005 #include "CubitDefines.h" 00006 #include "MemoryManager.hpp" 00007 #include "CubitPoint.hpp" 00008 #include "DLIList.hpp" 00009 #include "CubitBox.hpp" 00010 #include "CubitFacet.hpp" 00011 class CubitVector; 00012 class CubitBox; 00013 class CubitPlane; 00014 class CubitFacetEdge; 00015 class RefEntity; 00016 00017 class FaceterFacetData : public CubitFacet 00018 { 00019 private: 00020 CubitPoint *pointArray[3]; 00021 CubitFacetEdge *edgeArray[3]; 00022 int edgeUse[3]; 00023 static MemoryManager memoryManager; 00024 //- memory management object 00025 int entityId; 00026 RefEntity *myOwner; 00027 00028 //- for debug tracking... 00029 00030 public: 00031 FaceterFacetData(CubitPoint *p1, CubitPoint *p2, CubitPoint *p3); 00032 ~FaceterFacetData(); 00033 virtual int id(){return entityId;} 00034 virtual void set_id(int ii){entityId = ii;} 00035 00036 void owner(RefEntity *owner) 00037 {myOwner = owner;} 00038 RefEntity* owner() 00039 {return myOwner;} 00040 SetDynamicMemoryAllocation(memoryManager) 00041 //- class specific new and delete operators 00042 CubitStatus closest_point( const CubitVector &point, 00043 CubitVector &closest_point); 00044 //- Sets the closest point on the plane defined by 00045 //- this facet to the point in space. 00046 //- If the normal length to the facet is 0, it will return CUBIT_FAILURE. 00047 00048 CubitPoint* point( int index ); 00049 //Get the point at the specified index. 00050 //asserts that the index is in range, for a 00051 //triangle, 0 <= index <= 2. 00052 00053 00054 void set_point( CubitPoint *the_point, int index ) { pointArray[index] = the_point; } 00055 //- sets the point into the facet. 00056 00057 CubitFacetEdge *edge( int index ); 00058 void edge( CubitFacetEdge *the_edge, int index ) 00059 { edgeArray[index] = the_edge; }; 00060 //- get and set edge pointers 00061 00062 void edge_use( int direction, int index ) { edgeUse[index] = direction; }; 00063 int edge_use( int index ); 00064 //- get and set the edge uses 00065 00066 CubitPoint* split_edge( CubitPoint* edge_pt1, 00067 CubitPoint* edge_pt2, 00068 const CubitVector& position ); 00069 //R CubitPoint 00070 //R- The new CubitPoint created. 00071 //I edge_pt1, edge_pt2 00072 //I- The end points of an edge of this triangle. 00073 //I position 00074 //I- The position at which to split the edge. 00075 //O new_facet1 00076 //O- The new facet resulting from splitting the edge on 00077 //O- this triangle. 00078 //O new_facet2 00079 //O- The new facet resulting from splitting the same edge 00080 //O- on the ajacent triangle. If there is no other 00081 //O- triangle sharing the edge, NULL will be passed back. 00082 //- Split an edge on this triangle and the other triangle 00083 //- sharing the edge, if it exists. 00084 //- 00085 //- Note: No check is done on the location of the split 00086 //- position. 00087 00088 CubitPoint* insert_point( const CubitVector& position, 00089 CubitFacet*& new_tri1, 00090 CubitFacet*& new_tri2 ); 00091 //R CubitPoint 00092 //R- The new CubitPoint created. 00093 //I position 00094 //I- The position at which to insert a point in the triangle. 00095 //O new_facet1, new_facet2 00096 //O- The two new facets created. 00097 //- Insert a point in the interior of this triangle. 00098 //- 00099 //- Note: No check is done on the location of the split 00100 //- position. 00101 00102 void flip(); 00103 //- reorient the facet 00104 }; 00105 00106 inline CubitPoint* FaceterFacetData::point( int index ) 00107 { 00108 assert( (index >= 0) && (index < 3) ); 00109 if (!is_backwards()) 00110 return pointArray[index]; 00111 else 00112 { 00113 switch(index) 00114 { 00115 case 0: return pointArray[0]; 00116 case 1: return pointArray[2]; 00117 case 2: return pointArray[1]; 00118 } 00119 } 00120 return NULL; 00121 } 00122 00123 inline CubitFacetEdge* FaceterFacetData::edge( int index ) 00124 { 00125 assert( (index >= 0) && (index < 3) ); 00126 if (!is_backwards()) 00127 return edgeArray[index]; 00128 else 00129 { 00130 switch(index) 00131 { 00132 case 0: return edgeArray[0]; 00133 case 1: return edgeArray[2]; 00134 case 2: return edgeArray[1]; 00135 } 00136 } 00137 return NULL; 00138 } 00139 00140 inline int FaceterFacetData::edge_use( int index ) 00141 { 00142 assert( (index >= 0) && (index < 3) ); 00143 if (!is_backwards()) 00144 return edgeUse[index]; 00145 else 00146 { 00147 switch(index) 00148 { 00149 case 0: return -edgeUse[0]; 00150 case 1: return -edgeUse[2]; 00151 case 2: return -edgeUse[1]; 00152 } 00153 } 00154 return 0; 00155 } 00156 00157 00158 #endif