cgma
SurfaceOverlapTool.hpp
Go to the documentation of this file.
00001 //- Class:       SurfaceOverlapTool
00002 //- Description: Utilities to debug imprinting/merging problems
00003 //- Owner:       Steve Storm
00004 //- Created:     22 October 1999
00005 
00006 #ifndef SurfaceOverlapTool_HPP
00007 #define SurfaceOverlapTool_HPP
00008 
00009 #include <map>
00010 #include "GMem.hpp"
00011 #include "AnalyticGeometryTool.hpp"
00012 #include "CGMGeomConfigure.h"
00013 #include "CurveOverlapFacet.hpp"
00014 #include "SurfaceOverlapFacet.hpp"
00015 #include "AbstractTree.hpp"
00016 
00017 template <class X> class DLIList;
00018 class RefFace;
00019 
00021 class CUBIT_GEOM_EXPORT SurfaceOverlapTool
00022 {
00023 
00024 public :   
00025 
00027    CubitStatus find_overlapping_surfaces( DLIList<RefFace*> &ref_face_list, 
00028                                           DLIList<RefEntity*> &faces_to_draw,
00029                                           bool filter_slivers = false );
00030 
00032    CubitStatus find_overlapping_surfaces( DLIList<Body*> &body_list,
00033                                           DLIList<RefEntity*> &faces_to_draw,
00034                                           bool filter_slivers = false );
00035 
00037    CubitStatus find_overlapping_surfaces( DLIList<RefFace*> &ref_face_list,
00038                                           DLIList<RefFace*> &ref_face_list1,
00039                                           DLIList<RefFace*> &ref_face_list2,
00040                                           DLIList<RefEntity*> &faces_to_draw,
00041                                           CubitBoolean show_messages = CUBIT_FALSE,
00042                                           bool filter_slivers = false);
00043 
00045    CubitStatus find_overlapping_surfaces( DLIList<Body*> &body_list,
00046                                           DLIList<RefFace*> &ref_face_list1,
00047                                           DLIList<RefFace*> &ref_face_list2,
00048                                           DLIList<RefEntity*> &faces_to_draw,
00049                                           CubitBoolean show_messages = CUBIT_FALSE,
00050                                           bool filter_slivers = false);
00051 
00053    CubitStatus find_candidate_surfaces_for_imprinting( DLIList<BodySM*> &body_list,
00054                                           DLIList<Surface*> &surface_list1,
00055                                           DLIList<Surface*> &surface_list2,
00056                                           double overlap_tol = -1.0,
00057                                           bool filter_slivers = false );
00058 
00059    // Searches for surfaces that overlap each other and are good
00060    // candidates for imprinting.  It can even find those with gaps
00061    // between them (according to settings).
00062    // First method is for interactive use.  They print messages and
00063    // draw the surfaces as it finds them, as dictated by settings.
00064    // The second method is for non-interactive use.  It simply returns the
00065    // surface pairs in lists.  Note that the same surface can occur 
00066    // multiple times in the lists.  The first list will contain sequential
00067    // surfaces - ie., if surface 1 overlaps with 2 other surfaces, list1
00068    // will contain surface 1, then surface 1, then the next surface, 
00069    // etc..  If show_messages is CUBIT_TRUE, you will see "Finding surface
00070    // overlap...", and groupResults, listPairs and displayPairs will be
00071    // used, otherwise they will be false (default).
00072 
00074    CubitStatus find_overlapping_curves( DLIList<Surface*> &surf_list,
00075                                 DLIList< DLIList<Curve*> *> &overlapping_curve_lists,
00076                                 std::map<Curve*, DLIList<Curve*>* > &curve_to_list_map,
00077                                 std::multimap<BodySM*, CubitVector> &body_point_imprint_map);
00078 
00080    CubitStatus find_overlapping_curves( DLIList<Curve*> &curve_list,
00081                                 DLIList< DLIList<Curve*> *> &overlapping_curve_lists,
00082                                 std::map<Curve*, DLIList<Curve*>* > &curve_to_list_map,
00083                                 std::multimap<BodySM*, CubitVector> &body_point_imprint_map, double overlap_tol=-1.0);
00084 
00086    CubitStatus find_overlapping_curves( DLIList<Body*> &bodies,
00087                    std::multimap<RefEdge*, RefEdge*> &overlapping_edge_map,
00088                    double maxgap = -1);
00089 
00091    CubitStatus find_overlapping_curves( DLIList<BodySM*> &bodies,
00092                                 DLIList< DLIList<Curve*> *> &overlapping_curve_lists,
00093                                 std::map<Curve*, DLIList<Curve*>* > &curve_to_list_map,
00094                                 std::multimap<BodySM*, CubitVector> &body_vertex_imprint_map,
00095                                 double overlap_tol);
00096 
00098    CubitStatus find_overlapping_curves( DLIList<RefFace*> &faces,
00099                         std::multimap<RefEdge*, 
00100                         RefEdge*> &overlapping_edge_map,
00101                         double maxgap = -1);
00102 
00103 
00105    CubitStatus find_overlapping_curves( DLIList<RefEdge*> &edgelist,
00106                         std::multimap<RefEdge*, RefEdge*> &overlapping_edge_map,
00107                         double maxgap = -1);
00108 
00110    CubitStatus find_overlapping_curves( DLIList<RefEdge*> &edges1, DLIList<RefEdge*> &edges2,
00111                     std::multimap<RefEdge*, RefEdge*> &overlapping_edge_map,
00112                     double maxgap = -1);
00113 
00115   CubitBoolean check_overlap( SurfaceOverlapFacet *facet1, SurfaceOverlapFacet *facet2, const double facet_compare_tol );
00116 
00118    CubitBoolean check_overlap( RefEdge *edge1, RefEdge *edge2, 
00119                std::map<RefEdge*, DLIList<CurveOverlapFacet*>* > *facet_map, 
00120                double *overlap_tol = NULL );
00121 
00123    CubitBoolean check_overlap( RefFace *ref_face_ptr1,
00124                                RefFace *ref_face_ptr2,
00125                                CubitBoolean abort,
00126                                CubitBoolean draw_overlap = CUBIT_FALSE,
00127                                double *overlap_area = NULL );
00128 
00130    CubitBoolean check_overlap( Curve *curve1, Curve *curve2, 
00131                std::map<Curve*, DLIList<CurveOverlapFacet*>* > *facet_map, 
00132                std::multimap<BodySM*, CubitVector > *body_point_imprint_map = NULL,
00133                double overlap_tol = -1.0);
00134 
00136    CubitBoolean check_boundary_contact(  
00137                                 DLIList<SurfaceOverlapFacet*> *facet_list1, 
00138                                 DLIList<SurfaceOverlapFacet*> *facet_list2, 
00139                                 AbstractTree<SurfaceOverlapFacet*> *a_tree, 
00140                                 const double facet_compare_tol, 
00141                                 const double tmp_overlap_tol );
00142 
00143    
00144   // swap surfaces and facets to keep the smaller surface first
00145   CubitBoolean check_size_and_swap_surfs( 
00146                                 Surface *&tmp_surf1, 
00147                                 Surface *&tmp_surf2, 
00148                                 const double tolerance,
00149                                 const double facet_tol,
00150                                 DLIList<SurfaceOverlapFacet*> *&facet_list1, 
00151                                 DLIList<SurfaceOverlapFacet*> *&facet_list2, 
00152                                 std::map<Surface*, AbstractTree<SurfaceOverlapFacet*>* > *&a_tree_map,
00153                                 AbstractTree<SurfaceOverlapFacet*> *&a_tree2 );
00154 
00155   // extract facets if not already available 
00156    CubitBoolean extract_surf_facets( 
00157                                Surface *surface1, 
00158                                Surface *surface2, 
00159                                std::map<Surface*, DLIList<SurfaceOverlapFacet*>* > *facet_map,
00160                                const double tolerance,
00161                                const double facet_tol,
00162                                DLIList<SurfaceOverlapFacet*> *&facet_list1,
00163                                DLIList<SurfaceOverlapFacet*> *&facet_list2 );
00164 
00166    CubitBoolean calculate_tolerances_for_surf_intersection( 
00167                                 Surface *tmp_surf1, 
00168                                 Surface *tmp_surf2, 
00169                                 DLIList<SurfaceOverlapFacet*> *facet_list1, 
00170                                 DLIList<SurfaceOverlapFacet*> *facet_list2, 
00171                                 std::map<Surface*, double > *area_map, 
00172                                 double &facet_compare_tol, 
00173                                 double &overlap_tolerance );
00174 
00176    CubitBoolean check_overlap(  DLIList<SurfaceOverlapFacet*> *facet_list1, 
00177                                 DLIList<SurfaceOverlapFacet*> *facet_list2, 
00178                                 AbstractTree<SurfaceOverlapFacet*> *a_tree, 
00179                                 const double facet_tol, 
00180                                 const double tolerance );   
00181 
00183    CubitBoolean check_overlap( DLIList<SurfaceOverlapFacet*> *facet_list1,
00184                                DLIList<SurfaceOverlapFacet*> *facet_list2,
00185                                AbstractTree<SurfaceOverlapFacet*> *a_tree, 
00186                                CubitBoolean abort, 
00187                                CubitBoolean draw_overlap,
00188                                double *overlap_area );
00189 
00191    CubitBoolean draw_overlapping_surface_pair( RefFace *ref_face_1,
00192                                                RefFace *ref_face_2);
00193 
00194 
00196    void list_settings();
00197 
00198    unsigned short get_facet_ang_tol();
00199    void set_facet_ang_tol( unsigned short angle_tol );
00200 
00201 
00202    //Initialize all settings in this class
00203    static void initialize_settings();
00204 
00205    static int get_facet_ang_tol_setting();
00206    static void set_facet_ang_tol_setting( int angle_tol );
00207    
00208    static double get_facet_abs_tol();
00209    static void set_facet_abs_tol( double absolute_tol );
00210 
00211    static double get_gap_min();
00212    static void set_gap_min( double val );
00213 
00214    static double get_gap_max();
00215    static void set_gap_max( double val );
00216 
00217    static double get_angle_min();
00218    static void set_angle_min( double val );
00219 
00220    static double get_angle_max();
00221    static void set_angle_max( double val );
00222 
00223    static double get_overlap_tolerance();
00224    static void set_overlap_tolerance( double val );
00225 
00226    static int get_normal_type(); //
00227    static void set_normal_type( int type ); //
00228 
00229    static CubitString get_normal_type_setting();
00230    static void set_normal_type_setting( CubitString type );
00231 
00232    static CubitBoolean get_group_results(); //
00233    static void set_group_results( CubitBoolean setting ); //
00234 
00235    static CubitBoolean get_list_pairs(); //
00236    static void set_list_pairs( CubitBoolean setting ); //
00237 
00238    static CubitBoolean get_display_pairs(); //
00239    static void set_display_pairs( CubitBoolean setting ); //
00240 
00241    static int get_group_results_setting();
00242    static void set_group_results_setting( int setting );
00243 
00244    static int get_list_pairs_setting();
00245    static  void set_list_pairs_setting( int setting );
00246 
00247    static  int get_display_pairs_setting();
00248    static  void set_display_pairs_setting( int setting );
00249 
00250    static CubitBoolean get_imprint();
00251    static void set_imprint( CubitBoolean setting );
00252 
00253    static CubitBoolean get_check_within_bodies();
00254    static void set_check_within_bodies( CubitBoolean setting );
00255 
00256    static CubitBoolean get_check_across_bodies();
00257    static void set_check_across_bodies( CubitBoolean setting );
00258    CubitBoolean get_skip_facing_surfaces();
00259    void set_skip_facing_surfaces( CubitBoolean setting );
00260    static SurfaceOverlapTool* instance();
00261      // Returns a static pointer to unique instance of this class.
00262    static void delete_instance()
00263    {
00264      if(instance_)
00265        delete instance_;
00266      instance_ = NULL;
00267    };
00268    
00269    ~SurfaceOverlapTool();
00270      //- Destructor.
00271 
00272 protected :
00273    
00274 private :
00275 
00276 
00277 
00278   CubitStatus find_overlapping_surfaces( DLIList<RefFace*> &ref_face_list,
00279                                          DLIList<RefFace*> &ref_face_list1,
00280                                          DLIList<RefFace*> &ref_face_list2,
00281                                          DLIList<RefEntity*> &pair_list,
00282                                          CubitBoolean list_pairs,
00283                                          int prog_step,
00284                                          bool filter_slivers = false);
00285   // Private workhorse function for finding the overlapping surfaces. Here 
00286   // pair_list is a list of all the surfaces that were found that overlap.
00287   // If prog_step == -1 it does not step the progress bar. 
00288 
00289   double find_area_overlap( SurfaceOverlapFacet *facet1, SurfaceOverlapFacet *facet2, const double facet_compare_tol );
00290 
00291   
00292   CubitBoolean check_surfs_for_imprinting( Surface *surface1,
00293                                Surface *surface2,
00294               std::map<Surface*, DLIList<SurfaceOverlapFacet*>* > *facet_map,
00295               std::map<Surface*, double > *area_map,
00296               std::map<Surface*, AbstractTree<SurfaceOverlapFacet*>* > *a_tree_map,
00297               double overlap_tol=-1.0); 
00298 
00299                                 
00300    //CubitStatus draw_facets( GMem* gMem, int color = 2 );
00301    //void draw_triangle( Triangle3 &T, int color = 2 );
00302 
00303    CubitStatus imprint(DLIList<RefFace*> &ref_face_list1,
00304                        DLIList<RefFace*> &ref_face_list2);
00305    //- Imprints the bodies containing the lists of surfaces.  Also
00306    //- uses the edges imprinting rather than the normal imprint.
00307 
00308    int num_descendants(Body *body);
00309     //- Counts the total number of descendants of the body.
00310     //- Only counts Ref* entities.
00311   
00312    CubitStatus copy_edges_in_list(DLIList<RefEdge*> &old_list,
00313                                   DLIList<RefEdge*> &new_list );
00314     //- copy's each of the edges in the old list, and puts the
00315     //- stand alone edges in the new list.
00316     //- NOTE: THESE ARE NEWLY CREATED EDGES AND SHOULD BE DELETED
00317     //-       BY THE CALLING FUNCTION.
00318 
00319    CubitStatus delete_edges_in_list(DLIList<RefEdge*> &edge_list);
00320     //- Deletes the RefEdges in the list via GeometryQueryTool.
00321 
00322    static SurfaceOverlapTool* instance_;
00323      // Static pointer to unique instance of this class
00324    
00325    SurfaceOverlapTool();
00326      //- Constructor for the SurfaceOverlapTool object
00327 
00333    static  unsigned short facetAngTol;
00334 
00339    static  double facetAbsTol;
00340 
00343    static  double gapMin;
00344    static  double gapMax;
00345 
00347 
00350    static  double angleMin;
00351    static  double angleMax;
00353   
00356    static  int normalType; // 1=any, 2=opposite, 3=same
00357   
00359    static  CubitBoolean groupResults;
00360    
00362    static  CubitBoolean listPairs;
00363 
00365    static  CubitBoolean displayPairs;
00366   
00368    static  CubitBoolean imprintResults;
00369   
00372    static  double overlapTolerance;
00373 
00375    static CubitBoolean skipFacingSurfaces;
00376 
00381    static  CubitBoolean checkWithinBodies;
00382   
00387    static  CubitBoolean checkAcrossBodies;
00388 };
00389 
00390 inline
00391 void SurfaceOverlapTool::set_facet_ang_tol( unsigned short val )
00392 {facetAngTol=val;}
00393 
00394 inline
00395 double SurfaceOverlapTool::get_facet_abs_tol()
00396 {return facetAbsTol;}
00397 inline
00398 void SurfaceOverlapTool::set_facet_abs_tol( double val )
00399 {facetAbsTol=val;}
00400 
00401 inline
00402 double SurfaceOverlapTool::get_gap_min()
00403 {return gapMin;}
00404 inline
00405 void SurfaceOverlapTool::set_gap_min( double val )
00406 {gapMin=val;}
00407 
00408 inline
00409 double SurfaceOverlapTool::get_gap_max()
00410 {return gapMax;}
00411 inline
00412 void SurfaceOverlapTool::set_gap_max( double val )
00413 {gapMax=val;}
00414 
00415 inline
00416 double SurfaceOverlapTool::get_angle_min()
00417 {return angleMin;}
00418 inline
00419 void SurfaceOverlapTool::set_angle_min( double val )
00420 {angleMin=val;}
00421 
00422 inline
00423 double SurfaceOverlapTool::get_angle_max()
00424 {return angleMax;}
00425 inline
00426 void SurfaceOverlapTool::set_angle_max( double val )
00427 {angleMax=val;}
00428 
00429 inline
00430 double SurfaceOverlapTool::get_overlap_tolerance()
00431 {return overlapTolerance;}
00432 inline
00433 void SurfaceOverlapTool::set_overlap_tolerance( double val )
00434 {overlapTolerance=val;}
00435 
00436 inline
00437 int SurfaceOverlapTool::get_normal_type()
00438 {return normalType;}
00439 inline
00440 void SurfaceOverlapTool::set_normal_type( int type )
00441 {normalType=type;}
00442 
00443 inline
00444 CubitBoolean SurfaceOverlapTool::get_group_results()
00445 {return groupResults;}
00446 inline
00447 void SurfaceOverlapTool::set_group_results( CubitBoolean setting )
00448 {groupResults=setting;}
00449 
00450 inline
00451 CubitBoolean SurfaceOverlapTool::get_list_pairs()
00452 {return listPairs;}
00453 inline
00454 void SurfaceOverlapTool::set_list_pairs( CubitBoolean setting )
00455 {listPairs=setting;}
00456 
00457 inline
00458 CubitBoolean SurfaceOverlapTool::get_display_pairs()
00459 {return displayPairs;}
00460 inline
00461 void SurfaceOverlapTool::set_display_pairs( CubitBoolean setting )
00462 {displayPairs=setting;}
00463 inline
00464 CubitBoolean SurfaceOverlapTool::get_imprint()
00465 {return imprintResults;}
00466 inline
00467 void SurfaceOverlapTool::set_imprint( CubitBoolean setting )
00468 {imprintResults=setting;}
00469 inline
00470 CubitBoolean SurfaceOverlapTool::get_check_within_bodies()
00471 {return checkWithinBodies;}
00472 inline
00473 void SurfaceOverlapTool::set_check_within_bodies( CubitBoolean setting )
00474 {checkWithinBodies=setting;}
00475 inline
00476 CubitBoolean SurfaceOverlapTool::get_check_across_bodies()
00477 {return checkAcrossBodies;}
00478 inline
00479 void SurfaceOverlapTool::set_check_across_bodies( CubitBoolean setting )
00480 {checkAcrossBodies=setting;}  
00481 inline
00482 CubitBoolean SurfaceOverlapTool::get_skip_facing_surfaces()
00483 {return skipFacingSurfaces;}
00484 inline
00485 void SurfaceOverlapTool::set_skip_facing_surfaces( CubitBoolean setting )
00486 {skipFacingSurfaces=setting;}  
00487 #endif
00488 
00489 
00490 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines