cgma
CompositeEngine.hpp
Go to the documentation of this file.
00001 #ifndef COMPOSITE_ENGINE_HPP
00002 #define COMPOSITE_ENGINE_HPP
00003 
00004 #include "CubitDefines.h"
00005 #include "GeometryDefines.h"
00006 #include "CubitString.hpp"
00007 #include <map>
00008 #include "DLIList.hpp"
00009 #include "IntermediateGeomEngine.hpp"
00010 #include "VGDefines.h"
00011 #include "TopologyBridge.hpp"
00012 
00013 class TBPoint;
00014 class Curve;
00015 class Surface;
00016 class Lump;
00017 
00018 class BodySM;
00019 class ShellSM;
00020 class LoopSM;
00021 class CoEdgeSM;
00022 
00023 class CompositePoint;
00024 class CompositeCurve;
00025 class CompositeSurface;
00026 class CompositeLump;
00027 class CompositeBody;
00028 class CompositeCoEdge;
00029 class CompositeLoop;
00030 class CompositeShell;
00031 class Body;
00032 
00033 class GeometryEntity;
00034 class TopologyBridge;
00035 class CubitSimpleAttrib;
00036 class CubitVector;
00037 class CubitTransformMatrix;
00038 
00039 class CompositeEngine : public IntermediateGeomEngine
00040 {
00041     public:
00042     void get_all_curves_and_points(DLIList<TopologyBridge*> &tb_list,
00043                                    DLIList<Curve*> &curves,
00044                                    DLIList<TBPoint*> &points);
00045     bool is_composite(TBOwner *bridge_owner);
00046     bool is_composite(TopologyBridge *bridge);
00047     bool is_partition(TBOwner *bridge_owner);
00048 
00049     virtual void remove_imprint_attributes_after_modify
00050                                 ( DLIList<BodySM*> &old_sms,
00051                                 DLIList<BodySM*> &new_sms );
00052     virtual void push_named_attributes_to_curves_and_points
00053                      ( DLIList<TopologyBridge*> &tb_list, const char *name_in);
00054     virtual void push_imprint_attributes_before_modify
00055                      ( DLIList<BodySM*> &body_sms );
00056     virtual void attribute_after_imprinting(DLIList<TopologyBridge*> &tb_list,
00057                                             DLIList<Body*> &old_bodies);
00058 
00059     // This is a copy of the function in MergeTool with the difference that it
00060     // accepts a layer flag to dictate at which level the topology is traversed
00061     // (solid modeler level or virtual level).
00062     CubitBoolean about_spatially_equal( Curve *curve_1, Curve *curve_2,
00063                                                   CubitSense &relative_sense, 
00064                                                   double tolerance_factor,
00065                                                   int layer = TopologyBridge::MAX_TB_LAYER);
00066     virtual void remove_attributes_from_unmodifed_virtual(DLIList<TopologyBridge*> &bridges);
00067 
00068     virtual ~CompositeEngine();
00069     
00070     static CompositeEngine& instance();
00071     static void delete_instance();
00072 
00073     int level() const { return COMPOSITE_LAYER; }
00074         
00075     CubitStatus import_geometry( DLIList<TopologyBridge*>& imported_geometry );
00076       //- Recreate saved composite geometry and update the passed
00077       //- list.
00078 
00079     int is_hidden(TopologyBridge *tb);
00080     
00081     CubitStatus export_geometry( DLIList<TopologyBridge*>& geometry_to_save );
00082       //- Save composite geometry and update the passed list such
00083       //- that it contains the underlying real geometry.
00084         
00085     CompositeCurve* composite( Curve* survivor, 
00086                                Curve* dead,
00087                                TBPoint* keep_point = 0,
00088                                bool remove_partitions = false );
00089       //- Combine two curves.  The curves share both end vertices,
00090       //- the retained vertex can be specified in keep_point.
00091       
00092     CompositePoint* stitch_points( TBPoint* point1, TBPoint* point2 );
00093     CompositeCurve* stitch_curves( Curve* curve1, Curve* curve2 );
00094     CompositeSurface* stitch_surfaces( Surface* surf, Surface* surf2 );
00095     
00096     CompositeCurve* remove_point( TBPoint* dead_point,
00097                                   bool remove_partitions = false,
00098                                   Curve* survivor = 0 );
00099       //- Create a composite curve by removing the specified TBPoint.
00100                                     
00101                                     
00102     CompositeSurface* remove_curve( Curve* dead_curve,
00103                                     bool remove_partitions = false,
00104                                     Surface* survivor = 0 );
00105       //- Create a composite surface by removing the specified Curve
00106     
00107     CompositeLump* remove_surface( Surface* dead_surf,
00108                                    Surface* stitch_partner = 0,
00109                                    bool remove_partitions = false );
00110       //- Create a composite lump by removing the specified Surface.
00111       //- Note:  If stitch_partner is non-null, you need to call
00112       //-        combine_bodies on the owning bodies first.
00113                                    
00114     CompositeBody* combine_bodies( BodySM* body1, BodySM* body2 );
00115       //- Combine two BodySMs into one Composite Body.
00116     
00117     CubitStatus split_body( CompositeBody* body_to_split,
00118                             DLIList<BodySM*>& resulting_bodies );
00119       //- Split a CompositeBody into several Bodies 
00120       //- as permissible by common child topology and 
00121       //- existing real Bodies.
00122     
00123     CubitStatus restore_point( TBPoint* point );
00124       //- Split a composite curve by restoring the
00125       //- passed, previously removed TBPoint.
00126     
00127     CubitStatus restore_curve( Curve* curve );
00128       //- Split a composite surface by restoring the
00129       //- passed, previously removed Curve.
00130     
00131     CubitStatus restore_surface( Surface* surface, Surface*& stitch_parnter );
00132       //- Split a composite lump by restoring the
00133       //- passed, previously removed surface.
00134       
00135 /*      
00136     static void fix_up_query_results( DLIList<TopologyBridge*>& list,
00137                                       bool keep_hidden_entities = false );
00138       //- Update TB-level query results obtained from calling 
00139       //- get_parents/children_virt such that the results are at the
00140       //- "composite level" of the TB graph.
00141 */    
00142     static CubitSimpleAttrib
00143     find_attribute_by_name( TopologyBridge* bridge, const CubitString name );     
00144       //- Find the attribute with the specified name.
00145       //- Caller is responsible for freeing the returned, heap-allocated
00146       //- CubitSimpleAttrib object.
00147       
00148     CompositePoint* replace_point( TBPoint* dead_point );
00149     CompositeCurve* replace_curve( Curve* dead_curve );
00150     CompositeSurface* replace_surface( Surface* surface );
00151     CompositeLump* replace_lump( Lump* lump );
00152     CompositeBody* replace_body( BodySM* body );
00153       //- These methods are public for use by other clases internal
00154       //- to the VG code.  
00155       
00156       /**************** To be called by PartitionEngine *****************/
00157       
00158     TBPoint* insert_point(CompositeCurve* curve, double u);
00159       //- Partition a composite curve.
00160       
00161     TBPoint* insert_point_curve( CompositeSurface* surface,
00162                                const CubitVector& position );
00163     
00164     CubitStatus insert_curve( DLIList<Surface*>& surfaces,
00165                               DLIList<CubitVector*>& polyline,
00166                               DLIList<Surface*>& new_surfaces,
00167                               DLIList<Curve*>& new_curves );
00168 
00169     void notify_deactivated (CompositeBody* body);
00170     void notify_deactivated (CompositeLump* volume);
00171     void notify_deactivated (CompositeSurface* surface);
00172     void notify_deactivated (CompositeCurve* curve);
00173     void notify_deactivated (CompositePoint* point);
00174     void clean_out_deactivated_geometry();
00175 
00176     CubitStatus restore_point_in_curve( TBPoint* point );
00177       //- Restore a point hidden by a curve, splitting the
00178       //- curve.
00179       
00180     CompositeCurve* restore_point_in_surface( TBPoint* point );
00181       //- Restore a point hidden by a surface, creating a 
00182       //- point-curve.
00183 
00184 
00185     CubitStatus translate( CompositeBody* body, const CubitVector& delta );
00186     CubitStatus rotate( CompositeBody* body, const CubitVector& axis, double degrees );
00187     CubitStatus scale( CompositeBody* body, const CubitVector& factors );
00188     CubitStatus reflect( CompositeBody* body, const CubitVector& axis );
00189     CubitStatus restore_transform( CompositeBody* body );
00190     
00191     CubitStatus translate( CompositeSurface* surface, const CubitVector& delta );
00192     CubitStatus rotate( CompositeSurface* surface, const CubitVector& axis, double degrees );
00193     CubitStatus scale( CompositeSurface* surface, const CubitVector& factors );
00194     CubitStatus reflect( CompositeSurface* surface, const CubitVector& axis );
00195     
00196     CubitStatus translate( CompositeCurve* curve, const CubitVector& delta );
00197     CubitStatus rotate( CompositeCurve* curve, const CubitVector& axis, double degrees );
00198     CubitStatus scale( CompositeCurve* curve, const CubitVector& factors );
00199     CubitStatus reflect( CompositeCurve* curve, const CubitVector& axis );
00200 
00201     CubitStatus notify_transform( TopologyBridge* bridge,
00202                                   const CubitTransformMatrix& xform );
00203 
00204     static void strip_attributes( TopologyBridge* bridge );
00205       // remove all attributes related to composite geometry
00206       // from passed bridge.
00207 
00208     void remove_attributes( DLIList<TopologyBridge*> &bridge_list );
00209       //remove Composite attributes off of topology bridges
00210     virtual void remove_modified(DLIList<Surface*> &all_surfs,
00211       DLIList<Curve*> &all_curves, DLIList<TBPoint*> &all_pts);
00212 
00213     void get_tbs_with_bridge_manager_as_owner( TopologyBridge *source_bridge, 
00214                                                DLIList<TopologyBridge*> &tbs );
00215     
00216     
00217   protected:
00218     
00219     TBPoint* remove_composite( CompositePoint* point );
00220     Curve* remove_composite( CompositeCurve* composite );
00221     Surface* remove_composite( CompositeSurface* composite );
00222     Lump* remove_composite( CompositeLump* composite );
00223     BodySM* remove_composite( CompositeBody* composite );
00224     
00225     CubitStatus remove_partition_point( CompositePoint* point_owner );
00226     CubitStatus remove_partition_curves( CompositeCurve* curve_owner );
00227     
00228     CompositePoint* destroy_point_curve( CompositeCurve* curve );
00229     
00230     CompositeCurve* combine( CompositeCurve* curve1,
00231                              CompositeCurve* curve2,
00232                              CompositePoint* keep_point = 0,
00233                              bool remove_partitions = false );
00234     CubitStatus split( CompositeCurve* curve, int after_index,
00235                        Curve*& result1, Curve*& resutl2 );
00236                        
00237       // Shell modification helpers for composite lump creation
00238     CompositeShell* split_shell( CompositeShell* shell );
00239     void insert_nonmanifold_surfaces( DLIList<CompositeSurface*>& surfs,
00240                                       CompositeShell* shell1,
00241                                       CompositeShell* shell2 );
00242     CubitStatus inside_shell( CompositeShell* const shell,
00243                               CompositeSurface* const surf,
00244                               bool& result );
00245     
00246     CubitStatus create_composites( DLIList<BodySM*>& );
00247     CubitStatus create_composites( DLIList<Surface*>& );
00248     CubitStatus create_composites( DLIList<Curve*>& );
00249     CubitStatus create_composites( DLIList<TBPoint*>& );
00250       //- Methods called by import(..) to re-create
00251       //- composites from saved attributes.
00252       
00253     CubitStatus save( CompositePoint* );
00254     CubitStatus save( CompositeCurve* );
00255     CubitStatus save( CompositeSurface* );
00256     CubitStatus save( CompositeLump* );
00257     CubitStatus save( CompositeBody* );
00258     
00259     static void append_attrib( TopologyBridge* bridge, 
00260                                const CubitSimpleAttrib& attrib );
00261     
00262     
00263     static CubitStatus find_coedges( CompositeSurface* surface,
00264                                      CompositeCurve* curve,
00265                                      CompositePoint* point,
00266                                      CompositeCoEdge*& previous,
00267                                      CompositeCoEdge*& next );
00268     static CompositeCoEdge* find_next_point_coedge( 
00269                                      CompositeSurface* const surface,
00270                                      CoEdgeSM* const coedge,
00271                                      CompositePoint* point,
00272                                      DLIList<CompositeCoEdge*>& point_coedges );
00273     
00274     static CompositeEngine* instance_;
00275         
00276   private:
00277     
00278     CompositeEngine();
00279   
00280     CompositeSurface* split_surface( CompositeSurface* surf_to_split,
00281                                      CompositeLoop* loop_on_surf,
00282                                      CompositeLoop* new_loop );
00283     
00284     CompositeLump* split_lump( CompositeShell* shell_to_split );
00285       // If a shell had a previously-hidden surface inserted into
00286       // it due to the un-hiding of that surface, test if the
00287       // shell is split by the surface, and if so, split the shell
00288       // and corresponding lump.  
00289     void process_curves_after_imprint(Curve *att_bridge, 
00290                                                    Curve *other_bridge,
00291                                                    DLIList<BodySM*> &new_sms);
00292     void process_points_after_imprint(TBPoint *att_bridge, 
00293                                                    TBPoint *other_bridge,
00294                                                    DLIList<BodySM*> &new_sms);
00295     
00296     DLIList<TopologyBridge*> deactivatedList;
00297 };
00298 
00299 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines