cgma
CubitOctreeCell.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : CubitOctreeCell.hpp
00003 //
00004 // Purpose       : A cell of the CubitOctree model is defined   
00005 //
00006 // Creator       : William Roshan Quadros
00007 //
00008 // Creation Date :  01/01/2003
00009 //
00010 // Owner         : 
00011 //-------------------------------------------------------------------------
00012 #ifndef CUBITOCTREECELL_H
00013 #define CUBITOCTREECELL_H 
00014 
00015 #include "DLIList.hpp"
00016 #include "CubitVector.hpp"
00017 
00018 class CubitOctreeNode;
00019 class CubitOctree;
00020 class RefFace;
00021 class CubitBox;
00022 class CubitFacet;
00023 class CubitFacetEdge; 
00024 class CubitPoint;
00025 class OctreeIntersectionData;
00026 class OctreeFacetPointData;
00027 
00028 
00029 class CubitOctreeCell
00030 {
00031   
00032 public:
00033   CubitOctreeCell(){}
00034   CubitOctreeCell( CubitVector center, double dimension, int level, CubitOctreeCell *parent_cell );
00035     //- Constructor
00036   
00037   virtual ~CubitOctreeCell();
00038     //- Distructor
00039   
00040   void display( CubitOctree *ptr_octree, int opt);
00041     //- Display of cells
00042     
00043   void display_color_wireframe( CubitOctree *ptr_octree);
00044     //- diaplay cell in wireframe by color coding size at node
00045     
00046   void display_octreefacetpointdata( void );
00047     //-  Displays the facet point data contained in the list
00048 
00049   void release_octreefacetpointdata( void );
00050     //- Releases the facet point data stored at cells 
00051 
00052   void set_oct_grid_node(const int i, const int j, const int k, CubitOctreeNode *ptr_node );
00053   
00054   inline int get_depth( void ){ return depth; }
00055     //- returns depth
00056   
00057   inline double get_dimension( void ){ return dimension; }
00058     //- returns the dimension
00059   
00060   void set_child( int i, int j, int k, CubitOctreeCell *ptr_child_cell );
00061     //- updates the child of the cell
00062   
00063   inline CubitVector get_center( void ){ return mCenter; }
00064     //- returns the center of the cell
00065   
00066   inline CubitOctreeNode *get_octree_grid_node( const int i, const int j, const int k ){ return cubitOctreeNode[i][j][k]; }
00067     //- returns the node of the cell
00068   
00069   inline int id( void ){ return num; }
00070     //- returns the numbers
00071   
00072   CubitOctreeCell * get_child( const int i, const int j, const int k );
00073     //- returns the child at i,j,k
00074   
00075   inline void set_leaf( bool type ){ leaf = type; }
00076   
00077   CubitOctreeCell * find_leaf_octree_cell(const CubitVector &point );
00078     //- Find the leaf cell 
00079   
00080   void subdivide_octree_based_on_point( CubitPoint *ptr_point );
00081     //- subdivides the CubitOctree based on point ( either original point or centroid )
00082   
00083   bool is_leaf( void ){ return leaf; }
00084     //- returns the status of leaf 
00085   
00086   void distribute_facet_points_among_children( void );
00087     // distributes the facet points and associated face among the children
00088   
00089   int num_of_facet_point_data( void ){ return octreeFacetPointDataList.size(); }
00090     //- returns number of facet points and centroids
00091   
00092   CubitBoolean append_list_item( OctreeFacetPointData *ptr_facet_point_data );
00093     //- appends the arguments into the respective list
00094 
00095   inline DLIList<OctreeFacetPointData*>* get_facet_point_data_list() 
00096       {
00097         return &octreeFacetPointDataList;
00098       }
00099   
00100   
00101   inline void set_mark( CubitBoolean type ){ mark = type; }
00102   inline CubitBoolean get_mark( void ){ return mark; }
00103 
00104   inline void set_visit( CubitBoolean type ){ visit = type; }
00105   inline CubitBoolean get_visit( void ){ return visit; }
00106   
00107   CubitBoolean add_adjacent_unmarked_cells( DLIList< CubitOctreeCell *> &queue );
00108   
00109   CubitBoolean is_intersects_box(const CubitBox &box );
00110   
00111   CubitBoolean does_facet_intersect_octreecell( CubitFacet *ptr_facet );
00112 
00113 
00114   void set_color_and_intersection_datas(CubitFacet *ptr_facet, RefFace *ptr_Ref_face,
00115 #ifdef USE_octree_BGMESH
00116                                         DLIList<CubitOctreeCell*> *greyCellList,
00117 #endif
00118                                         CubitSense surf_sense=CUBIT_FORWARD);
00119     //- if cell intersects supplied facet call this function to color cell grey and attached OctreeIntersectionDatas to its nodes
00120     //- function assumes that grid nodes of cell still have halfspace settings corresponding to the supplied facet
00121   
00122     // The function assumes that nodes have half space information
00123   CubitBoolean does_contain_positive_and_negative_nodes();
00124 
00125   CubitBoolean is_facet_point_data_present( const CubitVector &coord );
00126   CubitBoolean is_facet_point_data_present( OctreeFacetPointData *new_facet_point_data );
00127     //- Currently CubitVector is passed and distance between existing points and coord is compared
00128     //- with SKL_EPSILON in determining if the coord already exists.  
00129     //- To avoid SKL_EPSILON CubitPoint srl number can be used.  This function is currently not used.
00130 
00131   CubitBoolean interpolate_grey_octreecell_node( void );
00132     //- Finds size at WHITE nodes of GREY cells
00133   
00134   void coloring( /*DLIList<CubitOctreeCell *> &grey_cell_list,*/ DLIList<CubitOctreeCell*> &black_cell_list);
00135     //- Colors the cells with WHITE (cell outside solid), BLACK (cell inside solid), and GREY (cell at the boundary)
00136 
00137     // Trilienar interpolation  
00138     // if number of nodes with zero size exceeds  MAX_NUM_ZERO_SIZE_NODES
00139     // then average size is used instead of zero
00140     // Even GREY grid nodes are consided 
00141     // If a node has zero size then that node is not considered
00142     // Therefore color is not important but the size
00143   double trilinear_interpolation(const CubitVector &point );
00144   
00145   double inverse_distance_interpolation(const CubitVector &point );
00146   double min_size_interpolation(const CubitVector &point );
00147   double min_distance_interpolation(const CubitVector &point );
00148   
00149   CubitStatus find_indices_in_parent( int *index );
00150 
00151 #ifndef NDEBUG
00152   void write_octreecell_sizing_info_file( FILE *pof, DLIList<CubitOctreeCell*> &stack );
00153 #endif
00154 
00155     /*
00156       void set_node( CubitOctreeNode *r_t_n_, CubitOctreeNode *r_t_f_, CubitOctreeNode *r_b_n_, CubitOctreeNode *r_b_f_, CubitOctreeNode *l_t_n_, CubitOctreeNode *l_t_f_, CubitOctreeNode *l_b_n_, CubitOctreeNode *l_b_f_ );
00157         //- Sets the eight nodes of the cell
00158     
00159         void set_octreecell( CubitOctreeCell *left_cell, CubitOctreeCell *right_cell, CubitOctreeCell *bottom_cell, CubitOctreeCell *top_cell, CubitOctreeCell *far_cell, CubitOctreeCell *near_cell );
00160           //- Sets the six adjacent cells
00161           */    
00162   inline void mark_color( int type ){ color = type; }
00163     //- Cell contained completely inside the solid is call BLACK
00164     //- Cell contained completely outside the solid is calle WHITE
00165     //- Cell at the boundary with some nodes inside and others outside
00166     //  are called GREY
00167 
00168   inline int get_color() {return color;}
00169     //- Returns the color of cell
00170 
00171 private:
00172   
00173   CubitVector mCenter;
00174     //- Center of cell
00175   
00176   double dimension;
00177     //- size of the CubitOctree cell
00178   
00179   int depth;
00180     //- depth of the node
00181   
00182   CubitBoolean leaf;
00183     //- to check leaf 
00184   
00185   int num;
00186     //- Serial number of cell
00187   
00188   int color;    
00189     //- WHITE (outside solid), BLACK (inside solid), and GREY (on boundary)
00190   
00191   CubitBoolean mark;
00192     //- Mark used for visiting cell;
00193 
00194   CubitBoolean visit;
00195   
00196     //CubitOctreeNode* (*CubitOctreeNode)[2][2];
00197   CubitOctreeNode* cubitOctreeNode[2][2][2];
00198   
00199     //- Eight corner nodes of cell
00200   
00201     //CubitOctree *CubitOctree;
00202     //- CubitOctree is currently not used
00203   
00204   CubitOctreeCell *parent;
00205   CubitOctreeCell *children[2][2][2];
00206     //- eight children
00207   
00208   DLIList< OctreeFacetPointData *> octreeFacetPointDataList;
00209     //- Stores the facet points 
00210   
00211   DLIList<OctreeIntersectionData*> *myFacetList;
00212   
00213 };
00214 
00215 #endif
00216 
00217 //EOF
00218 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines