LCOV - code coverage report
Current view: top level - geom/facet/cgm - CubitOctree.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 0 8 0.0 %
Date: 2020-06-30 00:58:45 Functions: 0 8 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : //-------------------------------------------------------------------------
       2                 :            : // Filename      : CubitOctree.hpp
       3                 :            : //CubitOctree
       4                 :            : // Purpose       : CubitOctree model of the input solids/surfaces is generated. 
       5                 :            : //                 
       6                 :            : //
       7                 :            : // Creator       : William Roshan Quadros
       8                 :            : //
       9                 :            : // Creation Date :  09/01/2013
      10                 :            : //
      11                 :            : // Owner         : 
      12                 :            : //-------------------------------------------------------------------------
      13                 :            : #ifndef CUBITOCTREE_H
      14                 :            : #define CUBITOCTREE_H
      15                 :            : 
      16                 :            : #include "CubitVector.hpp"
      17                 :            : #include "CubitOctreeConstants.hpp"
      18                 :            : #include "DLIList.hpp"
      19                 :            : #include "CubitDefines.h"
      20                 :            : 
      21                 :            : 
      22                 :            : class RefVolume;
      23                 :            : class RefVolume;
      24                 :            : class RefFace;
      25                 :            : class RefEdge;
      26                 :            : class RefVertex;
      27                 :            : 
      28                 :            : 
      29                 :            : class CubitOctreeNode;
      30                 :            : class CubitOctreeCell;
      31                 :            : class FaceAdjacency;
      32                 :            : class VertexFaceIncident;
      33                 :            : class CubitFacet;
      34                 :            : class CubitFacetEdge;
      35                 :            : class FacetEntity;
      36                 :            : class CubitPoint;
      37                 :            : class CubitBox;
      38                 :            : class TDSkeletonCubitPoint;
      39                 :            : class CubitOctreeGenerator;
      40                 :            : class OctreeFacetPointData;
      41                 :            : 
      42                 :            : 
      43                 :            : // Generation of CubitOctree model of the CAD model:
      44                 :            : // Graphics Facets are used to detect curvature changes in surface and curves.
      45                 :            : // Vertices and Centroid of the Facets are used to generate the CubitOctree.
      46                 :            : // Bounding Box of the facets, Edge Length etc can be used.
      47                 :            : // Each Cell is made to contain only one point.
      48                 :            : 
      49                 :            : class CubitOctree
      50                 :            : {
      51                 :            :   
      52                 :            : public:
      53                 :            :          
      54                 :            :   CubitOctree( CubitOctreeGenerator *lattice_gen );
      55                 :            :     //- Constructor
      56                 :            :   
      57                 :            :   virtual ~CubitOctree();
      58                 :            :     //- Distructor
      59                 :            : 
      60                 :            :   void release_memory( void );
      61                 :            :     //- clears the memory for assembly
      62                 :            : 
      63                 :          0 :   inline int get_max_depth( void){ return maxDepth;}
      64                 :          0 :   inline int get_min_depth( void){ return minDepth;}
      65                 :          0 :   inline void set_max_depth( int max_depth ) { maxDepth = max_depth; }
      66                 :          0 :   inline void set_min_depth( int min_depth ) { minDepth = min_depth; }
      67                 :            :   
      68                 :          0 :   inline DLIList<CubitOctreeNode*> *get_whitenodelist( void ){ return &boundaryWhiteGridNodeList; }
      69                 :            : 
      70                 :            :   inline DLIList<CubitOctreeCell*> *get_greycelllist( void ){ return &greyCellList; }
      71                 :            :   
      72                 :            :   inline DLIList<CubitOctreeCell*> *get_blackcelllist() {return &blackCellList;}
      73                 :            : 
      74                 :            :   inline DLIList<CubitOctreeNode*> *get_gridnodevector( void ){ return &gridNodeVector; }
      75                 :            : 
      76                 :          0 :   inline void set_status_octree_coloring( CubitBoolean type ){ statusCubitOctreeColoring = type; }
      77                 :            :   
      78                 :            :   // Methods related to CubitOctree Generation 
      79                 :          0 :   inline CubitOctreeCell *get_root( void ){ return root; }
      80                 :            : 
      81                 :            :   void color_octreecell( void );
      82                 :            :   //- NOTE: during CubitOctree generation only the points at the facets are marked white and black
      83                 :            :   //- during mat generation whole interior points are colored BLACK and the later the cells' are colored
      84                 :            :   //- Identifies boundary (GREY), interior (BLACK) and exterior cells (WHITE)
      85                 :            :   
      86                 :            :   
      87                 :            :   CubitOctreeCell *find_octreecell( const CubitVector &pnt );
      88                 :            :   //- Returns a cell containing point pnt
      89                 :            :   
      90                 :            :   CubitBoolean initialize_octree_generation( void );
      91                 :            :   //- Initializes the root cell which is equal to bbox
      92                 :            :   
      93                 :            :   CubitBoolean build_octree_till_min_depth( CubitOctreeCell *ptr_cell );
      94                 :            :   //- Builds the CubitOctree till the minimum depth
      95                 :            :   
      96                 :            :   CubitBoolean subdivide_octree_cell( CubitOctreeCell *ptr_cell, DLIList<CubitOctreeNode*> *ptr_queue, int max_depth);
      97                 :            :   //- subdivides the cell
      98                 :            :   
      99                 :            :   CubitBoolean subdivide_octree_based_on_facet_point( OctreeFacetPointData *ptr_facet_point_data, int max_depth );
     100                 :            :   //- use the facet center and vertices to subdivide the CubitOctree
     101                 :            :   
     102                 :            :   double size_at_a_point( const CubitVector &point, int size_type );
     103                 :            : 
     104                 :            :   CubitPointContainment point_containment( CubitVector tmp_vec, double tolerance );
     105                 :            :   
     106                 :            :   
     107                 :            :   inline double get_max_size_grid_node( void ){ return maxSizeGridNode; }
     108                 :            :   //- Returns maximum size
     109                 :            :   
     110                 :            :   inline double get_min_size_grid_node( void ) const{ return minSizeGridNode; }
     111                 :            :   //- Returns minimum size
     112                 :            :   
     113                 :            :   void display( const int mode, int opt = 0 );
     114                 :            :   //- Display of CubitOctree
     115                 :            :   
     116                 :            :   
     117                 :            :   // For better 3D medial resolution near adjacent surfaces with a large dihedral angle (outward normals) between them,
     118                 :            :   // CubitOctree cells intersecting with the shared curve can be refined to the maximum allowable depth.
     119                 :            :   // First call find_cells... to build the list of cells to refine, then call refine_cells_to_target_depth on them
     120                 :            :   CubitBoolean find_cells_based_on_surface_angle(DLIList<CubitOctreeCell*> &refine_cell_list, DLIList<CubitFacetEdge*> &crease_edges,
     121                 :            :                                                  DLIList<CubitFacet*> &crease_facets, RefFace *one, RefFace *two,
     122                 :            :                                                  const CubitBoolean draw_facets=CUBIT_FALSE, double dihedral_angle_thresh=CUBIT_PI/2.0);
     123                 :            :   
     124                 :            :   
     125                 :            :   CubitBoolean find_octree_cells_contained_inside_bbox( CubitFacet *ptr_facet, DLIList<CubitOctreeCell*> &CubitOctree_cell_list );
     126                 :            :   
     127                 :            :   //- output: CubitOctree cells which intersect with the bbox are stored in CubitOctree_cell_list
     128                 :            :   
     129                 :            :   CubitBoolean mark_positive_and_negative_octree_grid_nodes( CubitFacet *ptr_facet, DLIList<CubitOctreeCell*> &CubitOctree_cell_list, DLIList< CubitOctreeNode *> &CubitOctree_grid_node_list );
     130                 :            :   
     131                 :            :   //- output: the nodes of cells that intersect with the bbox are stored in octee_cell_list
     132                 :            :   
     133                 :            :   CubitBoolean find_intersection_between_grid_edges_and_facet( CubitOctreeType type, RefFace *ptr_face, CubitFacet *ptr_facet, DLIList<CubitOctreeNode *> &CubitOctree_grid_node_list  );
     134                 :            :   //- finds intersection between line segment (edge ) incident at every grid_node contained inside bbox and triangle ( facet)
     135                 :            :   
     136                 :            :   
     137                 :            :   void find_cell_list_intersecting_line_segment(const CubitVector &p0, const CubitVector &p1, DLIList<CubitOctreeCell*> &cell_list);
     138                 :            :   //- returns the list of CubitOctree cells intersecting with line segment defined by end points
     139                 :            :   
     140                 :            :   double get_scaled_from_wrld_size_grid_node( double wrld_size );
     141                 :            : 
     142                 :            :   
     143                 :            :   static double capsule_distance_to_facet(const CubitVector &point, CubitFacet *lp_facet, CubitVector &int_point, CubitBoolean use_projection_only = CUBIT_FALSE);
     144                 :            :   
     145                 :            :   CubitBoolean establish_smooth_transition_of_cells( int max_depth ); 
     146                 :            : 
     147                 :            : private:
     148                 :            :   
     149                 :            :   inline CubitBoolean apd_vector_item( CubitOctreeNode *ptr_grid_node );
     150                 :            :     //- appends the ptr_grid_node in the CubitOctreeNodeList
     151                 :            :   
     152                 :            :   double calculate_depth_based_on_size( double size );
     153                 :            : 
     154                 :          0 :   inline double get_bbox_dimension( void ){ return bboxDimension; }
     155                 :            : 
     156                 :            :   
     157                 :            :   
     158                 :            :   void refine_cells_to_target_depth(DLIList<CubitOctreeCell*> &refine_cell_list, const int target_depth);
     159                 :            : 
     160                 :            :     // To optimize intersection between facet and CubitOctree cells, all the cells not intersecting with the plance containing facet are removed
     161                 :            :     // The nodes are marked with +ve or -ve half space info before calling this function
     162                 :            :   CubitBoolean mark_cells_that_intersect_facet_plane( /*CubitFacet *ptr_facet,*/ DLIList<CubitOctreeCell*> &CubitOctree_cell_list );
     163                 :            :   
     164                 :            :     // Stores the CubitOctree cells intersecting with the facet
     165                 :            :   CubitBoolean unmark_octree_cells_not_intersecting_with_facet( CubitFacet *ptr_facet, DLIList<CubitOctreeCell *> &CubitOctree_cell_list );
     166                 :            : 
     167                 :            :     //- CubitOctree is subdivided till skeleton max depth if size or scope of source entity is less than the dimention of
     168                 :            :     //- the cell containing it.
     169                 :            : 
     170                 :            :   CubitBoolean subdivide_octree_from_leaf_cell( CubitOctreeCell *ptr_cell, OctreeFacetPointData *ptr_facet_point_data, int max_depth );
     171                 :            :  
     172                 :            :     //- subdivides the CubitOctree starting from ptr_cell such that the ptr_new_point is contained in a uniue cell
     173                 :            :     //- if the maxDepth is not reached.
     174                 :            : 
     175                 :            :   void gather_initial_grid_nodes_for_smooth_transition( DLIList<CubitOctreeNode *> &queue );
     176                 :            :     //- queue hold potential nodes which has more than or equal to 2 cell depth difference
     177                 :            :  
     178                 :            :   
     179                 :            :     //- establishes smooth transition by keeping adjacent cells differing by 1 level
     180                 :            :   
     181                 :            :     //CubitBoolean find_intersection_between_octree_and_facets( DLIList<CubitOctreeNode *> &queue_for_mat_generation );
     182                 :            :     //- Finds the intersection between the CubitOctree line segments and the facets
     183                 :            : 
     184                 :            :   void reset_internal_node_size( float value, int type );
     185                 :            :     //- Resets the node size with value  
     186                 :            :         
     187                 :            :   void find_radius_at_boundary_node( void );
     188                 :            :         
     189                 :            :  
     190                 :            : 
     191                 :            :   void find_max_min_size_grid_node_for_scaling( void );
     192                 :            :     //- Finds maximum and minimum size used for scaling.
     193                 :            : 
     194                 :            : 
     195                 :            :   
     196                 :            :    static CubitStatus circumcenter(CubitVector &a, CubitVector &b, CubitVector &c, CubitVector &center, double &radius);
     197                 :            :     /*  
     198                 :            :         void build_boundary_white_node_list( void );
     199                 :            :           //- Uses grey CubitOctrees to find white boundary grid nodes;
     200                 :            :           */
     201                 :            : 
     202                 :            : 
     203                 :            :   void prepare_for_background_mesh();
     204                 :            :     // performs necessary actions on CubitOctree to make way for background mesh
     205                 :            : 
     206                 :            : #ifndef NDEBUG 
     207                 :            : 
     208                 :            :   void write_sizing_info_file( const char *file_name );
     209                 :            :     //- Writes sizing function at grid nodes to a file
     210                 :            : 
     211                 :            :   void write_octree_sizing_info_file( const char *file_name );
     212                 :            :     //- Writes sizing function stored in the CubitOctree on to a file.
     213                 :            : 
     214                 :            :   void write_matlab_sizing_info_file( const char *file_name );
     215                 :            :     //- Writes sizing function stored in the CubitOctree for visualization in matlab
     216                 :            : 
     217                 :            : #endif
     218                 :            :   
     219                 :            : private:
     220                 :            :         
     221                 :            :   CubitBoolean statusCubitOctreeColoring;
     222                 :            :   
     223                 :            : 
     224                 :            :     //- Maximum and minimum radius of source points and grid node
     225                 :            :     //- this is used in scaling the source points between 1 and 10 for display purpose
     226                 :            :                 
     227                 :            :   double bboxMinY; // minY
     228                 :            :   double bboxMaxY; // maxY
     229                 :            :   double bboxMaxZ; // maxZ
     230                 :            :   double bboxMinZ; // minZ 
     231                 :            :   double bboxMaxX; // maxX 
     232                 :            :   double bboxMinX; // minX
     233                 :            :     //- Limits of the bounding box of the volume
     234                 :            :  
     235                 :            :   CubitOctreeCell *root;
     236                 :            :     //- Root of the CubitOctree
     237                 :            :   
     238                 :            :   CubitVector bboxCenter;
     239                 :            :     //- Center of the bounding box
     240                 :            :   
     241                 :            :   double bboxDimension;
     242                 :            :     //- Dimension of the bounding box
     243                 :            :   
     244                 :            :   double epsilonBBox;
     245                 :            :     //- Actual bounding box is enlarged by epsilon_bbox in all directions
     246                 :            :    
     247                 :            :   DLIList<CubitOctreeCell *> greyCellList;
     248                 :            :     //- List of boundary CubitOctrees
     249                 :            : 
     250                 :            :   DLIList<CubitOctreeCell*> blackCellList;
     251                 :            :     //- List of internal CubitOctree cells
     252                 :            :   
     253                 :            :   DLIList<CubitOctreeNode *> boundaryWhiteGridNodeList;
     254                 :            :     //- List of white nodes of grey cells
     255                 :            :   
     256                 :            :   DLIList <CubitOctreeNode *> gridNodeVector;
     257                 :            :     //- Grid Nodes of CubitOctree
     258                 :            : 
     259                 :            :   DLIList <CubitOctreeNode*> greyGridNodeVector;
     260                 :            :   
     261                 :            :     
     262                 :            :   CubitOctreeGenerator *cubitOctreeGenerator;
     263                 :            : 
     264                 :            : 
     265                 :            :   double maxSizeGridNode;
     266                 :            :   double minSizeGridNode;
     267                 :            :   
     268                 :            :   int minDepth;
     269                 :            :   int maxDepth;
     270                 :            : 
     271                 :            : };
     272                 :            : 
     273                 :            : #endif
     274                 :            :     
     275                 :            : //EOF
     276                 :            : 
     277                 :            : 

Generated by: LCOV version 1.11