cgma
CubitFacetData.hpp
Go to the documentation of this file.
00001 #ifndef CUBITFACETDATA_HPP 
00002 #define CUBITFACETDATA_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  
00016 class CubitFacetData : public CubitFacet 
00017 { 
00018 private: 
00019   CubitPoint *pointArray[3]; 
00020   CubitFacetEdge *edgeArray[3]; 
00021   int edgeUse[3]; 
00022   static MemoryManager memoryManager; 
00023     //- memory management object 
00024   int entityId; 
00025     //- for debug tracking...
00026   void allocate_edge(CubitPoint *p1, CubitPoint *p2, int edge_index);
00027   void define_point(CubitFacetEdge *e1, CubitFacetEdge *e2, 
00028                     int point_index);
00029   void define_bounding_box();
00030  
00031 public: 
00032   CubitFacetData( CubitPoint *p1, CubitPoint *p2, 
00033                   CubitPoint *p3);
00034   CubitFacetData( CubitPoint *p1, CubitPoint *p2,
00035                   CubitPoint *p3, int *tool_data);
00036   CubitFacetData( CubitFacetEdge *e1, CubitFacetEdge *e2, 
00037                   CubitFacetEdge *e3);
00038   ~CubitFacetData();
00039   
00040   void destruct_facet_internals();
00041   
00042   virtual int id(){return entityId;} 
00043   virtual void set_id( int ii ) { entityId = ii; }
00044        
00045   SetDynamicMemoryAllocation(memoryManager) 
00046     //- class specific new and delete operators 
00047   CubitStatus closest_point( const CubitVector &point,  
00048                                      CubitVector &closest_point); 
00049     //- Sets the closest point on the plane defined by  
00050     //- this facet to the point in space. 
00051     //- If the normal length to the facet is 0, it will return CUBIT_FAILURE. 
00052  
00053   CubitPoint* point( int index ); 
00054     //Get the point at the specified index. 
00055     //asserts that the index is in range, for a 
00056     //triangle, 0 <= index <= 2. 
00057  
00058    
00059   void set_point( CubitPoint *the_point, int index );  
00060     //- sets the point into the facet. 
00061  
00062   CubitFacetEdge *edge( int index ); 
00063   void edge( CubitFacetEdge *the_edge, int index ); 
00064     //- get and set edge pointers 
00065  
00066   void edge_use( int direction, int index ); 
00067   int edge_use( int index ); 
00068     //- get and set the edge uses 
00069   int sense(int index); 
00070  
00071   CubitPoint* split_edge( int edge_index, const CubitVector& position );
00072   CubitPoint* split_edge( CubitPoint* edge_pt1, CubitPoint* edge_pt2, 
00073                           const CubitVector& position ); 
00074     //R CubitPoint 
00075     //R- The new CubitPoint created. 
00076     //I edge_pt1, edge_pt2 
00077     //I- The end points of an edge of this triangle. 
00078     //I position 
00079     //I- The position at which to split the edge. 
00080     //O new_facet1 
00081     //O- The new facet resulting from splitting the edge on 
00082     //O- this triangle. 
00083     //O new_facet2 
00084     //O- The new facet resulting from splitting the same edge 
00085     //O- on the ajacent triangle.  If there is no other  
00086     //O- triangle sharing the edge, NULL will be passed back. 
00087     //- Split an edge on this triangle and the other triangle 
00088     //- sharing the edge, if it exists. 
00089     //- 
00090     //- Note:  No check is done on the location of the split 
00091     //-        position. 
00092      
00093   CubitPoint* insert_point( const CubitVector& position, 
00094                             CubitFacet*& new_tri1, 
00095                             CubitFacet*& new_tri2 ); 
00096     //R CubitPoint 
00097     //R- The new CubitPoint created. 
00098     //I position 
00099     //I- The position at which to insert a point in the triangle. 
00100     //O new_facet1, new_facet2 
00101     //O- The two new facets created. 
00102     //- Insert a point in the interior of this triangle. 
00103     //- 
00104     //- Note:  No check is done on the location of the split 
00105     //-        position. 
00106   
00107   CubitStatus flip_edge( int edge_index );
00108   CubitStatus flip_edge( CubitFacetEdge *edge );
00109     //- Given an edge shared by exactly two facets, 
00110     //- flip the edge such that it connects the 
00111     //- "other" two facet points instead.
00112     //-
00113     //-  *----*        *----*
00114     //-  |\   |        |   /|
00115     //-  | \  |  ==>   |  / |  
00116     //-  |  \ |        | /  |
00117     //-  |   \|        |/   |
00118     //-  *----*        *----*
00119     //-
00120     //- NOTE:  If you are trying to reverse the sense of
00121     //-        an edge, this is NOT the function you want!
00122    
00123   void flip(); 
00124     //- reorient the facet 
00125 
00126 }; 
00127 
00128 
00129 inline CubitPoint* CubitFacetData::point( int index ) 
00130 { 
00131   assert( (index >= 0) && (index < 3) ); 
00132   if (!is_backwards()) 
00133     return pointArray[index]; 
00134   else 
00135   { 
00136     switch(index) 
00137     { 
00138     case 0: return pointArray[0]; 
00139     case 1: return pointArray[2]; 
00140     case 2: return pointArray[1]; 
00141     } 
00142   } 
00143   return NULL; 
00144 } 
00145  
00146 inline void CubitFacetData::set_point( CubitPoint* the_point, int index ) 
00147 { 
00148   assert( (index >= 0) && (index < 3) ); 
00149   if (!is_backwards()) 
00150     pointArray[index] = the_point; 
00151   else 
00152   { 
00153     switch(index) 
00154     { 
00155     case 0: pointArray[0] = the_point; break; 
00156     case 1: pointArray[2] = the_point; break; 
00157     case 2: pointArray[1] = the_point; break; 
00158     } 
00159   } 
00160 } 
00161  
00162 inline CubitFacetEdge* CubitFacetData::edge( int index ) 
00163 { 
00164   assert( (index >= 0) && (index < 3) ); 
00165   if (!is_backwards()) { 
00166     return edgeArray[index]; 
00167   } 
00168   else 
00169   { 
00170     switch(index) 
00171     { 
00172     case 0:return edgeArray[0]; 
00173     case 1:return edgeArray[2]; 
00174     case 2:return edgeArray[1]; 
00175     } 
00176   } 
00177   return NULL; 
00178 } 
00179  
00180  
00181 inline void CubitFacetData::edge( CubitFacetEdge *the_edge, int index ) 
00182 { 
00183   assert( (index >= 0) && (index < 3) ); 
00184   if (!is_backwards()) 
00185     edgeArray[index] = the_edge; 
00186   else 
00187   { 
00188     switch(index) 
00189     { 
00190     case 0: edgeArray[0] = the_edge; break; 
00191     case 1: edgeArray[2] = the_edge; break; 
00192     case 2: edgeArray[1] = the_edge; break; 
00193     } 
00194   } 
00195 } 
00196  
00197 inline int CubitFacetData::edge_use( int index )  
00198 {  
00199   assert( (index >= 0) && (index < 3) ); 
00200   if (!is_backwards()) 
00201     return edgeUse[index];  
00202   else 
00203   { 
00204     switch(index) 
00205     { 
00206     case 0: return -edgeUse[0]; 
00207     case 1: return -edgeUse[2]; 
00208     case 2: return -edgeUse[1]; 
00209     } 
00210   } 
00211   return 0; 
00212 } 
00213 
00214 //- This function is defined so that Meshing and Geometry Entities 
00215 //- return the same values as needed in the FacetorTool
00216 inline int CubitFacetData::sense( int index ) { 
00217   if(edge_use(index) == 1)
00218     return CUBIT_FORWARD;
00219   else if(edge_use(index) == -1)
00220     return CUBIT_REVERSED;
00221   else 
00222     return CUBIT_UNKNOWN;
00223 } 
00224  
00225 inline void CubitFacetData::edge_use( int direction, int index )  
00226 {  
00227   assert( (index >= 0) && (index < 3) ); 
00228   if (!is_backwards()) 
00229     edgeUse[index] = direction;  
00230   else 
00231   { 
00232     switch(index) 
00233     { 
00234     case 0: edgeUse[0] = -direction; break; 
00235     case 1: edgeUse[2] = -direction; break; 
00236     case 2: edgeUse[1] = -direction; break; 
00237     } 
00238   } 
00239 } 
00240  
00241 #endif 
00242 
00243 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines