cgma
CubitOctreeNode.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : CubitOctree.hpp
00003 //
00004 // Purpose       : Defines the grid node of the CubitOctree model   
00005 //
00006 // Creator       : William Roshan Quadros
00007 //
00008 // Creation Date :  01/01/2003
00009 //
00010 // Owner         : 
00011 //-------------------------------------------------------------------------
00012 #ifndef CUBITOCTREENODE_H
00013 #define CUBITOCTREENODE_H
00014 #include "CubitVector.hpp"
00015 #include "DLIList.hpp"
00016 #include "PriorityQueue.hpp"
00017 #include <queue>
00018 #include "CubitDefines.h"
00019 //#include "MemoryManager.hpp"
00020 #include "OctreeIntersectionData.hpp"
00021 #include "CubitOctreeConstants.hpp"
00022 
00023 class RefFace;
00024 class CubitOctree;
00025 class CubitOctreeCell;
00026 class CubitFacet;
00027 class CubitOctreeNode;
00028 class CubitOctreeGenerator;
00029 
00030 
00031 class CubitOctreeNode{
00032   
00033 public:
00034   
00035   CubitOctreeNode( const CubitVector &cen, CubitOctreeCell *parent_cell, const int i, const int j, const int k );
00036   CubitOctreeNode( const double &x, const double &y, const double &z );
00037   void initialize_constructor( const double &x, const double &y, const double &z );
00038     //- Constructor
00039   
00040   ~CubitOctreeNode();
00041     //- Distructor
00042   
00043   void display( OctreeNodeConstant type = NODE_SIZE, float draw_size = -1 ); 
00044     //- Displays the grid nodes
00045   
00046   inline int get_color(){ return color; }
00047     //- Returns color
00048 
00049   inline void set_color (const int new_color) {color = new_color;}
00050   
00051   inline int get_num(){ return num; }
00052     //- Returns the serial number of the grid node
00053 
00054   inline CubitVector& get_coord(){ return coord; }
00055     //- Returns the cartesian coordinates
00056   
00057   double get_size( OctreeSourceEntityType type ) const;
00058     //- Returns size of the node
00059 
00060   int id(){ return num; }
00061 
00062   void set_size( double s, int type );
00063     //- Sets size at the node
00064   
00065   void set_adj_node( enum OctreePosition type, CubitOctreeNode *ptr_grid_node );
00066     //- sets the adjacent nodes
00067   
00068   void set_adj_node_distance( enum OctreePosition type, int dist );
00069     //- sets the adjacent nodes distance
00070   
00071   double manhattan_distance_adj_node( int index );
00072   inline double manhattan_distance_adj_node( CubitOctreeNode *ptr_adj_node );  
00073 
00074   inline double get_distance(){ return distance; }
00075   
00076   inline double x(){ return coord.x(); }
00077   inline double y(){ return coord.y(); }
00078   inline double z(){ return coord.z(); }
00079     //- Returns cartesian co-ordinates 
00080   
00081   inline void x( double value ){ coord.x( value ); }
00082   inline void y( double value ){ coord.y( value ); }
00083   inline void z( double value ){ coord.z( value ); }
00084     //- Sets cartician co-ordinates of node
00085   
00086   CubitOctreeNode *get_adj_node( int num );
00087     //- Returns one of the six adjacent nodes
00088   
00089   int get_adj_node_distance( enum OctreePosition type );
00090     //- returns the distance with the adj node in the direction of type
00091   
00092   void append_list_item( CubitVector facet_normal );
00093   
00094    void calc_facet_patch_distance_normal(DLIList<OctreeIntersectionData*> &idatas, int num_use_idatas, double &patch_distance, CubitVector &patch_normal, CubitBoolean sort, CubitBoolean set_Refface);
00095   void SAT_find_face_distance_average_normal ();
00096 
00097   inline CubitOctreeCell* get_min_depth_cell(){ return minDepthCell; }
00098     //- returns minimum depth cell
00099 
00100   inline int get_cell_depth_difference(){ return cellDepthDifference; }
00101   
00102 
00103   int get_counter();
00104     //- uses static counter to number the cell
00105 
00106   static inline void reset_counter() {mCounter = -1;}
00107 
00108   inline void update_adj_cell( CubitOctreeCell *ptr_cell, int i, int j, int k ) 
00109       {
00110         adjCell[i][j][k] = ptr_cell;
00111       }
00112     //- updates the cell at i, j, k location
00113   
00114   int find_min_depth_cell_and_depth_difference( void  );
00115     //- finds the maximum depth adjacent cell and difference in adj cells' depth
00116   
00117   void calculate_size_based_on_cell_dimension( double bbox_dimension );
00118     //- calculates size using 6 adj nodes distance
00119   
00120   inline CubitOctreeCell *get_adj_cell( const int i, const int j, const int k ) { return adjCell[i][j][k]; }
00121   
00122     // MARK is used in establishing connection between skl point and grid nodes contained in it using DFS
00123   inline void set_mark( CubitBoolean type ){ mark = type; }
00124   inline CubitBoolean get_mark(){ return mark; }
00125   
00126   inline void set_visit( CubitBoolean type ){ visit = type; }
00127     //- sets the visit with type ( CUBIT_FALSE or CUBIT_TRUE )
00128     
00129   inline CubitBoolean get_visit() const {return visit;}
00130     //- Returns visit
00131     
00132   inline CubitVector get_normal() const {return mNormal;}
00133 
00134 
00135   
00136   int find_half_space( CubitFacet *ptr_facet );
00137 
00138     //- returns half space direction
00139   
00140   inline CubitBoolean get_halfspace_direction(){ return halfspaceDirection; }
00141   inline void set_halfspace_direction( const CubitBoolean type ){ halfspaceDirection = type ; }
00142 
00143   void find_intersection_with_facet( CubitOctreeType type, RefFace *ptr_face, CubitFacet *ptr_facet,  DLIList<CubitOctreeNode*> &boundary_white_node_list);
00144     //- checks intesection between the lines joining grid node and adjacent nodes with the facet.
00145     //- queue_mat_generation stores the BLACK grinodes that contains distanace and normal for MAT generation.
00146   
00147   CubitBoolean find_intersection_point( int axis, CubitVector grid_node0, CubitVector grid_node1, CubitVector &facet_normal, CubitVector facet_vert0, CubitVector facet_vert1, CubitVector facet_vert2, CubitVector &int_point, double &para );
00148     //- returns true if the intersection between the line segment and facet takes place
00149     //- para stores the parameter of intersection point int_point
00150 
00151   static CubitBoolean is_same_side(const CubitVector &p1, const CubitVector &p2, const CubitVector &a, const CubitVector &b);
00152   static CubitBoolean is_intersection_point_contained_inside_facet( const CubitVector &int_point, const CubitVector &facet_vert0, const CubitVector &facet_vert1, const CubitVector &facet_vert2 );
00153     //- returns true if intersection point is contained inside the facet
00154     //- interior angle at the intersecton point should add up to 360 deg.
00155   
00156      
00157     //- Appends the source point
00158 
00159   inline void append_list_item( OctreeIntersectionData *ptr_int_data ) 
00160       {
00161         octreeIntersectionDataList.push( ptr_int_data );
00162       }
00163   
00164     //- Appends intesection data like, face, int_point, facet etc.
00165 
00166   DLIList<OctreeIntersectionData*>* get_idata_list() {return &octreeIntersectionDataList;}
00167   
00168   CubitBoolean bfs_to_find_contained_nodes(int max_onode_per_src);
00169   CubitBoolean dfs_to_find_contained_nodes(int max_onode_per_src);
00170     // Breadth first search is used to find nodes contained inside the box of skeleton source point  
00171 
00172     
00173     //- sizing function due to each type of source point is evaluated separately.
00174     //- then these function can be blended to find final sizing function.
00175     //- curently the minimum of all function is selected.
00176 
00177   static CubitBoolean compare_function( CubitOctreeNode *&a, CubitOctreeNode *&b );
00178 
00179   void find_distance_at_adj_node(PriorityQueue<CubitOctreeNode *> *heap );
00180   
00181   CubitBoolean find_size_using_adj_node();
00182   
00183   
00184     //static void set_scope_box_limits( double max_x, double min_x, double max_y, double min_y, double max_z, double min_z);
00185     //static void reset_scope_box_limits();
00186     //- To avoid the overflow of stack during linking source point and grid nodes
00187     //static double scpBoxMaxX, scpBoxMinX, scpBoxMaxY, scpBoxMinY, scpBoxMaxZ, scpBoxMinZ;
00188   //SetDynamicMemoryAllocation(memoryManager)
00189   //- class specific new and delete operators
00190   
00191 private:
00192   
00193 
00194   
00195   
00196 private:
00197   int num;
00198     //- Serial number of node
00199 
00200   static int mCounter;
00201   
00202   CubitBoolean visit;
00203   CubitBoolean mark;
00204   
00205   short color; 
00206     // in CubitOctree based approach
00207     //- GREY is default ( all nodes outside WHITE or Solid )
00208     //- BLACK (node inside solid), WHITE (node at the boundary during facet CubitOctree intersection)
00209 
00210   CubitBoolean halfspaceDirection;
00211   
00212   double size;
00213 
00214     //- Size at the grid node is initially set to 0.0
00215 
00216   
00217    // OPT: keep pointer to list and clear list after intersection
00218   DLIList<OctreeIntersectionData *> octreeIntersectionDataList;
00219   
00220   // OPT: use cubit hash to temp hold this data
00221   int cellDepthDifference;
00222     //- used in splitting CubitOctree cells during smooth transition
00223   
00224   
00225   CubitOctreeCell *minDepthCell;
00226     //- keeps the pointer to minimum depth adjacent cell
00227     
00228   double distance;
00229   
00230   CubitVector coord; 
00231   // Co-ordinates of the grid node
00232   
00233   CubitOctreeNode *adjGridNode[6]; 
00234     //0 to 5 LEFT, RIGHT, BOTTOM, TOP, BACK, FRONT
00235   
00236   int adjNodeDistance[6];  
00237     //- stores the lengths between adjacent nodes
00238   
00239   CubitOctreeCell *adjCell[2][2][2];
00240   
00241  
00242   RefFace *refFace;
00243     //- Face associated with the grid node used in wave propagation
00244   
00245   CubitVector mNormal;
00246     //- Normal at the grid_node is used in MAT generation.
00247 
00248   
00249   //static MemoryManager memoryManager;
00250     //- memory management object
00251 
00252 };
00253 
00254 #endif
00255 
00256 //EOF
00257 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines