cgma
GeomMeasureTool.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //Class: GeomMeasureTool
00003 //Description:  Calculates measurements and statistics for a given entity.
00004 //Author: David R. White
00005 //Date: May 28, 2002
00006 //-------------------------------------------------------------
00007 #ifndef GEOM_MEASURE_TOOL_HPP
00008 #define GEOM_MEASURE_TOOL_HPP
00009 class RefEntity;
00010 class RefVertex;
00011 class RefEdge;
00012 class RefFace;
00013 class RefVolume;
00014 class Body;
00015 class RefGroup;
00016 class TopologyEntity;
00017 class CubitVector;
00018 #include "DLIList.hpp"
00019 template <class X> class DLIList;
00020 class GeomPoint;
00021 class GeomSeg;
00022 #include "CGMGeomConfigure.h"
00023 #include <vector>
00024 #include <map>
00025 
00026 typedef DLIList <GeomPoint*> PointList;
00027 typedef DLIList <PointList*> PointLoopList;
00028 typedef DLIList <GeomSeg*> SegList;
00029 typedef DLIList <SegList*> SegLoopList;
00030 
00031 const double GEOM_END_LOWER = 87.0;
00032 const double GEOM_END_UPPER = 93.0;
00033 const double GEOM_SIDE_LOWER = 177.0;
00034 const double GEOM_SIDE_UPPER = 183.0;
00035 const double GEOM_CORNER_LOWER = 267.0;
00036 const double GEOM_CORNER_UPPER = 273.0;
00037 const double GEOM_REVERSAL_LOWER = 355.0;
00038 
00039 struct dist_vert_struct
00040 {
00041   double dist;
00042   RefVertex *v1;
00043   RefVertex *v2;
00044   RefVolume *vol2;
00045 };
00046 
00047 class AreaHashTuple 
00048 {
00049 public:
00050   AreaHashTuple()
00051     {}
00052   ~AreaHashTuple()
00053     {}
00054   RefFace *myFace;
00055   double myArea;
00056 };
00057 
00059 class CUBIT_GEOM_EXPORT GeomMeasureTool
00060 {
00061 private:
00062   static void get_edges_from_list(DLIList <RefEntity*> &entity_list,
00063                                   DLIList <RefEdge*> &ref_edges );
00064   static void get_faces_from_list(DLIList <RefEntity*> &entity_list,
00065                                   DLIList <RefFace*> &ref_faces );
00066   static void get_volumes_from_list(DLIList <RefEntity*> &entity_list,
00067                                     DLIList <RefVolume*> &ref_volumes );
00068   static void get_bodies_from_list(DLIList <RefVolume*> &entity_list,
00069                                    DLIList <Body*> &ref_bodies );
00074 
00075   static double dist_sq_point_data( CubitVector &curr_point,
00076                                     GeomSeg *&curr_seg );
00080 
00081   static CubitStatus interior_angle(GeomSeg *first_seg,
00082                                     GeomSeg *next_seg,
00083                                     RefFace *face,
00084                                     double &angle );
00090 
00091    static void find_index(DLIList<AreaHashTuple*> *hash_table,
00092                           int table_size,
00093                           RefFace *ref_face,
00094                           AreaHashTuple *&curr_tuple );
00099 
00100    static void get_adjacent_faces(RefFace* curr_face,
00101                                   DLIList<RefFace*> &adjacent_faces);
00105 
00106    
00107    static CubitBoolean find_opposite_edge( RefEdge* ref_edge,
00108                                            RefFace* ref_face,
00109                                            RefEdge *&other_edge,
00110                                            CubitVector &closest_point);
00119    
00120    static CubitBoolean is_equal(double v1, double v2);
00125 
00126   static RefFace* valid_start( DLIList <RefFace*> &all_faces );
00127 
00128   static void face_list_from_volume_list( DLIList <RefVolume*> &input_vols,
00129                                           DLIList <RefFace*> &all_faces );
00130 
00131  public:
00132   GeomMeasureTool()
00133     {}
00134   
00135   ~GeomMeasureTool()
00136     {}
00137 
00139   static bool is_surface_narrow(RefFace *face, double small_curve_size);
00140 
00142   static void find_split_points_for_narrow_regions(RefFace *face,
00143                                         double size, 
00144                                         DLIList<CubitVector> &split_pos1_list,
00145                                         DLIList<CubitVector> &split_pos2_list);
00146   
00149   static void measure_curve_length(DLIList <RefEntity*> &entity_list,
00150                                    double &smallest,
00151                                    RefEdge *&smallest_edge,
00152                                    double &largest,
00153                                    RefEdge *&largest_edge,
00154                                    double &average,
00155                                    double &sum);
00156 
00159   static void measure_curve_length(DLIList <RefEdge*> &ref_edges,
00160                                    double &smallest,
00161                                    RefEdge *&smallest_edge,
00162                                    double &largest,
00163                                    RefEdge *&largest_edge,
00164                                    double &average,
00165                                    double &sum);
00166 
00170   static void measure_face_curves( RefFace *ref_face,
00171                                    double &min_curve_length,
00172                                    double &max_curve_ratio,
00173                                    RefEdge *&min_ref_edge);
00174 
00179   static int narrow_region_exists(RefFace *face,
00180                                   RefEdge *edge,
00181                                   const double &tol);
00193   static int narrow_region_exists(
00194                           RefEdge *e1,
00195                           RefEdge *e2,
00196                           RefFace *face,
00197                           const double &tol,
00198                           DLIList<CubitVector*> &e1_pos_list,
00199                           DLIList<CubitVector*> &e2_pos_list,
00200                           DLIList<RefVertex*> &e1_vert_list,
00201                           DLIList<RefVertex*> &e2_vert_list);
00205   static int narrow_region_exists(RefFace *face,
00206                            const double &tol);
00214   static int is_narrow_region_at_point(RefEdge *e1,
00215                                       RefFace *face,
00216                                       const CubitVector &pt_on_e1,
00217                                       RefEdge *e2,
00218                                       const double &tol_sq,
00219                                       CubitVector &closest);
00220 
00226   static CubitStatus measure_face_loops(RefFace *face,
00227                                         double &min_distance_between_loops,
00228                                         double &min_distance_in_one_loop,
00229                                         double &min_angle, double &max_angle,
00230                                         double tolerance);
00231 
00234   static void  measure_face_area (DLIList <RefEntity*> &entity_list,
00235                                   double &smallest,
00236                                   RefFace *&smallest_face,
00237                                   double &largest,
00238                                   RefFace *&largest_face,
00239                                   double &average,
00240                                   double &sum);
00241 
00244   static void  measure_face_area (DLIList <RefFace*> &ref_faces,
00245                                   double &smallest,
00246                                   RefFace *&smallest_face,
00247                                   double &largest,
00248                                   RefFace *&largest_face,
00249                                   double &average,
00250                                   double &sum);
00251   
00254   static void  measure_volume_volume (DLIList <RefEntity*> &entity_list,
00255                                       double &smallest,
00256                                       RefVolume *&smallest_volume,
00257                                       double &largest,
00258                                       RefVolume *&largest_volume,
00259                                       double &average,
00260                                       double &sum);
00261 
00264   static void  measure_volume_volume (DLIList <RefVolume*> &ref_volumes,
00265                                       double &smallest,
00266                                       RefVolume *&smallest_volume,
00267                                       double &largest,
00268                                       RefVolume *&largest_volume,
00269                                       double &average,
00270                                       double &sum);
00271 
00272   static void measure_face_area_and_hydraulic_radius(RefFace *curr_face,
00273                                                      double &face_area,
00274                                                      double &face_hydraulic_radius);
00275 
00276   static void measure_volume_volume_and_hydraulic_radius(RefVolume *curr_volume,
00277                                                          double &volume_volume,
00278                                                          double &volume_hydraulic_radius);
00279   
00280   static void angles_between_volume_surfaces(RefVolume *curr_volume,
00281                                              double &min_angle,
00282                                              double &max_angle,
00283                                              RefFace *&face_min_1,
00284                                              RefFace *&face_min_2,
00285                                              RefFace *&face_max_1,
00286                                              RefFace *&face_max_2);
00287 
00290   static void merged_unmerged_surface_ratio(DLIList <RefVolume*> &ref_volumes,
00291                                             int &merged, int &unmerged,
00292                                             double &ratio);
00293 
00295   static void report_intersected_volumes(DLIList <RefVolume*> &volume_list,
00296                                         DLIList <RefVolume*> &intersection_list);
00297   
00299   static void report_intersected_bodies(DLIList <Body*> &ref_bodies,
00300                                         DLIList <Body*> &intersection_list);
00301   
00303   static void find_shells( DLIList <RefVolume*> &input_vols,
00304                            RefGroup *&owner_groups,
00305                            int &number_of_shells);
00306   
00309   static CubitStatus get_boundary_points( RefFace *ref_face,
00310                                           PointLoopList &boundary_point_loops,
00311                                           double seg_length_tol);
00312 
00314   static CubitStatus get_curve_facets( RefEdge* curve,
00315                                        PointList &segments,
00316                                        double seg_length_tol );
00317 
00321   static CubitStatus convert_to_lines(PointLoopList &boundary_point_loops,
00322                                       SegLoopList &boundary_line_loops,
00323                                       RefFace *ref_face );
00324 
00329   static void print_surface_measure_summary( DLIList <RefFace*> &ref_faces );
00330 
00334   static void print_volume_measure_summary(DLIList <RefVolume*> &ref_volumes);
00335 
00338   static void find_adjacent_face_ratios(RefVolume *curr_volume,
00339                                         double &max_face_ratio,
00340                                         RefFace *&big_face,
00341                                         RefFace *&small_face);
00342   
00344   static void find_narrow_faces(DLIList<RefVolume*> &ref_vols,
00345                                         double small_curve_size,
00346                                         DLIList<RefFace*> &narrow_faces,
00347                                         DLIList<RefFace*> &surfs_to_ignore);
00348 
00350   static void find_closed_narrow_faces( DLIList <RefVolume*> &ref_vols,
00351                                         double tol,
00352                                         DLIList <RefFace*> &face_list);
00353 
00354   static void get_narrow_regions(DLIList <RefVolume*> &ref_vols,
00355                                  double tol,
00356                                  DLIList <RefFace*> &surfs_with_narrow_regions);
00357 
00359   static RefEdge* find_first_small_curve(RefVolume* vol,
00360                                          double tol);
00361 
00363   static void find_small_curves( DLIList <RefVolume*> &ref_vols,
00364                                  double tol,
00365                                  DLIList <RefEdge*> &small_curves,
00366                                  DLIList <double> &small_lengths);
00367 
00369   static void find_surfs_with_narrow_regions( DLIList <RefVolume*> &ref_vols,
00370                                  double tol,
00371                                  DLIList <RefFace*> &surfs_with_narrow_regions);
00372 
00374   static void find_small_faces( DLIList <RefVolume*> &ref_vols,
00375                                 double tol,
00376                                 DLIList <RefFace*> &small_faces);
00377 
00385   static void find_small_faces_hydraulic_radius( DLIList <RefVolume*> &ref_vols,
00386                                                  double tol,
00387                                                  DLIList <RefFace*> &small_faces,
00388                                                  DLIList <double> &small_hyd_rad,
00389                                                  double &percent_planar,
00390                                                  double &percent_pl_co);
00391   
00393   static void find_small_volumes( DLIList <RefVolume*> &ref_vols,
00394                                   double tol,
00395                                   DLIList <RefVolume*> &small_volumes);
00396 
00401   static void find_small_volumes_hydraulic_radius( DLIList <RefVolume*> &ref_vols,
00402                                                    double tol,
00403                                                    DLIList <RefVolume*> &small_volumes,
00404                                                    DLIList <double> &small_hyd_rad);
00405   
00413   static void find_interior_curve_angles( RefVolume* ref_volume,
00414                                           double upper_bound,
00415                                           double lower_bound,
00416                                           DLIList <RefEdge*> &large_edge_angles,
00417                                           DLIList <RefEdge*> &small_edge_angles,
00418                                           DLIList <double> &large_angles,
00419                                           DLIList <double> &small_angles,
00420                                           int &total_interior,
00421                                           int &total_fuzzy);
00422   
00435   static void find_sharp_tangential_meets( RefVolume *ref_volume,
00436                                            DLIList <RefEdge*> &small_angle_edge_pairs,
00437                                            DLIList <RefFace*> &tangential_surface_pairs );
00438 
00441   static void find_dihedral_angles( DLIList<RefVolume*> &ref_vols,
00442                                     double upper_bound,
00443                                     double lower_bound,
00444                                     DLIList <RefFace*> &large_face_angles,
00445                                     DLIList <RefFace*> &small_face_angles,
00446                                     DLIList <double> &large_angles,
00447                                     DLIList <double> &small_angles,
00448                                     int &total_interior,
00449                                     int &total_fuzzy,
00450                                     int &total_not_flat);
00451   
00452 
00457   static void find_dihedral_angles( RefVolume *curr_volume,
00458                                     double lower_bound,
00459                                     double upper_bound,
00460                                     DLIList <RefFace*> &large_face_angles,
00461                                     DLIList <RefFace*> &small_face_angles,
00462                                     DLIList <double> &large_angles,
00463                                     DLIList <double> &small_angles,
00464                                     int &total_interior,
00465                                     int &total_fuzzy,
00466                                     int &total_not_flat);
00467 
00476   static void find_close_loops(DLIList <RefVolume*> &ref_vols,
00477                                DLIList <RefEdge*> &close_edges,
00478                                DLIList <RefFace*> &close_loop_faces,
00479                                DLIList <double> &small_lengths,
00480                                double tol);
00481 
00487   static void find_close_loops(RefFace *face,
00488                                DLIList <RefEdge*> &close_edges,
00489                                DLIList <double> &small_lengths,
00490                                double tol);
00491 
00497   static double measure_area(RefFace* curr_face);
00498 
00502   static void find_bad_geometry(RefVolume *volume,
00503                                 DLIList <RefEntity*> &bad_ents);
00504 
00506 
00507 
00508 
00509   static void find_irregular_valence( DLIList <RefVolume*> &ref_volumes,
00510                                       DLIList <RefVertex*> &irregular_vertices);
00511   static void find_irregular_valence( RefVolume* ref_volume,
00512                                       DLIList <RefVertex*> &irregular_vertices);
00514 
00521   static void find_blends( RefVolume *ref_volume,
00522                            DLIList <RefFace*> &blend_faces,
00523                            DLIList<DLIList<RefFace*>*> &blend_groups);
00524 
00532   static CubitBoolean is_face_blend(RefFace *ref_face,
00533                                     RefVolume *ref_volume,
00534                                     RefEdge *&ref_edge,
00535                                     RefEdge *&other_edge);
00536 
00541   static CubitBoolean is_vertex_blend(RefFace *ref_face, 
00542                                       RefVolume *ref_volume);
00543 
00549   static CubitStatus find_blend_chains( RefFace *start_face,
00550                              std::vector<std::vector< RefFace*> > &blend_chains);
00551 
00555   static void find_blends_from_edge( RefVolume* ref_volume, 
00556                                          RefFace *start_face, 
00557                                          RefEdge* start_edge,
00558                                          std::vector <RefFace*> &blend_faces);
00559 
00564   static CubitStatus get_centroid( RefFace *ref_face, 
00565                                    CubitVector &centroid, double &tot_area );
00566   
00568   static CubitStatus center( DLIList<RefFace*> ref_faces );
00569  
00571   static CubitStatus find_closest_vertex_vertex_pairs(
00572                                   DLIList<RefVolume*> &vol_list,
00573                                   int &num_to_return,
00574                                   DLIList<RefVertex*> &vert_list1,
00575                                   DLIList<RefVertex*> &vert_list2,
00576                                   DLIList<double> &distances);
00577 
00579   static CubitStatus find_closest_vertex_curve_pairs(
00580                                   DLIList<RefVolume*> &vol_list,
00581                                   int &num_to_return,
00582                                   DLIList<RefVertex*> &vert_list,
00583                                   DLIList<RefEdge*> &curve_list,
00584                                   DLIList<double> &distances);
00585 
00588   static CubitStatus find_near_coincident_vertices_unique( 
00589                             DLIList<RefVolume*> &ref_volumes,
00590                             double high_tol,
00591                             std::map <RefVertex*, DLIList<dist_vert_struct*>*> &vert_dist_map);
00592 
00595   static CubitStatus find_near_coincident_vertices( 
00596                                         DLIList<RefVolume*> &ref_volumes,
00597                                         DLIList<RefVertex*> &ref_vertices_out,
00598                                         DLIList<double> &distances,
00599                                         double low_tol,
00600                                         double high_tol,
00601                                         bool filter_same_volume_cases = false);
00602 
00605   static CubitStatus find_near_coincident_vertex_curve_pairs( 
00606                                 DLIList<RefVolume*> &ref_vols,
00607                                 DLIList<RefEdge*> &ref_edges,
00608                                 DLIList<RefVertex*> &ref_verts,
00609                                 DLIList<double> &distances,
00610                                 double low_tol,
00611                                 double high_tol,
00612                                 bool filter_same_volume_cases = false);
00613 
00616   static CubitStatus find_near_coincident_vertex_surface_pairs( 
00617                                 DLIList<RefVolume*> &ref_vols,
00618                                 DLIList<RefFace*> &ref_faces,
00619                                 DLIList<RefVertex*> &ref_verts,
00620                                 DLIList<double> &distances,
00621                                 double low_tol,
00622                                 double high_tol,
00623                                 bool filter_same_volume_cases = false);
00624 
00625 };
00626 #endif
00627 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines