cgma
|
00001 //------------------------------------------------------------------------- 00002 // Filename : PartitionEngine.hpp 00003 // 00004 // Purpose : 00005 // 00006 // Special Notes : 00007 // 00008 // Creator : Jason Kraftcheck 00009 // 00010 // Creation Date : 04/23/02 00011 //------------------------------------------------------------------------- 00012 00013 #ifndef PARTITION_ENGINE_HPP 00014 #define PARTITION_ENGINE_HPP 00015 00016 #include "CubitDefines.h" 00017 #include "VGDefines.h" 00018 #include <map> 00019 #include "IntermediateGeomEngine.hpp" 00020 #include "DLIList.hpp" 00021 00022 class TopologyBridge; 00023 class TBPoint; 00024 class Curve; 00025 class Surface; 00026 class Lump; 00027 class LoopSM; 00028 class BodySM; 00029 00030 class SubSurface; 00031 class SubCurve; 00032 class SegmentedCurve; 00033 00034 class PartitionEntity; 00035 class PartitionBody; 00036 class PartitionLump; 00037 class PartitionShell; 00038 class PartitionCoSurf; 00039 class PartitionSurface; 00040 class PartitionCurve; 00041 class PartitionPoint; 00042 class PartitionLoop; 00043 class PartitionCoEdge; 00044 class PartPTCurve; 00045 00046 class PST_Point; 00047 class SubEntitySet; 00048 class FacetProjectTool; 00049 class CubitSimpleAttrib; 00050 00051 class CubitPoint; 00052 class CubitFacet; 00053 class CubitPointData; 00054 class CubitFacetData; 00055 class CubitFacetEdgeData; 00056 class Body; 00057 00058 class CubitVector; 00059 class CubitTransformMatrix; 00060 template <class X> class DLIList; 00061 00062 class PartitionEngine : public IntermediateGeomEngine 00063 { 00064 00065 public: 00066 bool is_partition(TBOwner *bridge_owner); 00067 bool is_composite(TBOwner *bridge_owner); 00068 bool is_composite(TopologyBridge *bridge); 00069 virtual void remove_imprint_attributes_after_modify 00070 ( DLIList<BodySM*> &old_sms, 00071 DLIList<BodySM*> &new_sms ){}; 00072 virtual void push_imprint_attributes_before_modify 00073 ( DLIList<BodySM*> &body_sms ){}; 00074 virtual void push_named_attributes_to_curves_and_points 00075 ( DLIList<TopologyBridge*> &tb_list, const char *name_in ){}; 00076 virtual void attribute_after_imprinting(DLIList<TopologyBridge*> &tb_list, 00077 DLIList<Body*> &old_bodies){}; 00078 virtual void remove_attributes_from_unmodifed_virtual(DLIList<TopologyBridge*> &bridges){}; 00079 00080 00081 00082 virtual ~PartitionEngine(); 00083 00085 static PartitionEngine& instance(); 00086 static void delete_instance(); 00087 00088 int level() const { return SUBCOMP_PARTITION_LAYER; } 00089 00090 void notify_deactivated (PartitionBody* body); 00091 void notify_deactivated( PartitionLump* vol); 00092 void notify_deactivated (PartitionSurface* surface); 00093 void notify_deactivated (PartitionCurve* curve); 00094 void notify_deactivated (PartitionPoint* point); 00095 void add_to_deactivated_list(PartitionBody* body); 00096 void add_to_deactivated_list(PartitionLump* vol); 00097 void add_to_deactivated_list(PartitionSurface* sur); 00098 void add_to_deactivated_list(PartitionCurve* cur); 00099 void add_to_deactivated_list(PartitionPoint* pt); 00106 CubitStatus import_geometry( DLIList<TopologyBridge*>& imported_geometry ); 00107 00115 CubitStatus export_geometry( DLIList<TopologyBridge*>& geometry_to_save ); 00116 00123 TBPoint* insert_point( Curve* curve, double u ); 00124 00133 Curve* remove_point( PartitionPoint* point, 00134 PartitionCurve* dead_curves[2] = 0 ); 00135 00140 Surface* insert_curve( Surface* surface, 00141 DLIList<CubitVector*>& segment_points, 00142 DLIList<Curve*>& new_curves, 00143 const double *tolerance_length = NULL); 00144 00154 CubitStatus insert_curve( DLIList<Surface*>& surfaces, 00155 DLIList<CubitVector*>& polyline, 00156 DLIList<Surface*>& new_surfaces, 00157 DLIList<Curve*>& polyline_curves, 00158 const double *tolerance_length = NULL, 00159 DLIList<Surface*>* surfs_to_reverse = NULL); 00160 00169 TBPoint* insert_point_curve( Surface* surf, 00170 const CubitVector& position, 00171 Surface *&partitioned_surf ); 00172 00184 Lump* insert_surface( Surface* surf_to_copy, Lump* lump ); 00185 00197 Surface* insert_surface( DLIList<CubitFacet*>& facets, Lump* lump ); 00198 00199 00208 Surface* remove_curve( PartitionCurve* curve, 00209 PartitionSurface* dead_surfs[2] = 0 ); 00210 00217 Lump* remove_surface( PartitionSurface* surface ); 00218 00220 int layer() { return SUBCOMP_PARTITION_LAYER; } 00221 00222 //static void destroy_facet( CubitFacetData* facet ); 00223 00225 CubitStatus add_to_id_map( SubEntitySet* set, int unique_id ); 00226 00228 CubitStatus remove_from_id_map( SubEntitySet* set, int unique_id ); 00229 00231 SubEntitySet* get_from_id_map( int unique_id ); 00232 00247 PartitionEntity* entity_from_id( int set_id, int geom_id, 00248 SubEntitySet& default_set ); 00249 00250 00256 CubitStatus destroy_surface( PartitionSurface* surface ); 00257 00263 CubitStatus destroy_lump( PartitionLump* lump ); 00264 00265 static void delete_facet( CubitFacet* ); 00266 00267 CubitStatus delete_solid_model_entities( PartitionBody* body, 00268 BodySM*& real_body ); 00269 CubitStatus delete_solid_model_entities( PartitionSurface* surface, 00270 Surface*& real_surface ); 00271 CubitStatus delete_solid_model_entities( PartitionCurve* curve, 00272 Curve*& real_curve ); 00273 00274 static void curves_from_surfaces( const DLIList<PartitionSurface*>& input_surfs, 00275 DLIList<PartitionCurve*>& output_curves ); 00276 00277 void clean_out_deactivated_geometry(); 00278 00279 CubitStatus translate( PartitionBody* ent, const CubitVector& delta ); 00280 CubitStatus rotate( PartitionBody* ent, const CubitVector& axis, double degrees ); 00281 CubitStatus scale( PartitionBody* ent, const CubitVector& factors ); 00282 CubitStatus reflect( PartitionBody* ent, const CubitVector& axis ); 00283 CubitStatus restore_transform( PartitionBody* ent ); 00284 00285 CubitStatus translate( PartitionEntity* ent, const CubitVector& delta ); 00286 CubitStatus rotate( PartitionEntity* ent, const CubitVector& axis, double degrees ); 00287 CubitStatus scale( PartitionEntity* ent, const CubitVector& factors ); 00288 CubitStatus reflect( PartitionEntity* ent, const CubitVector& axis ); 00289 00290 CubitStatus notify_transform( TopologyBridge* bridge, 00291 const CubitTransformMatrix& xform ); 00292 00293 void remove_attributes( DLIList<TopologyBridge*> &bridge_list ); 00294 //remove Composite attributes off of topology bridges 00295 virtual void remove_modified(DLIList<Surface*> &all_surfs, 00296 DLIList<Curve*> &all_curves, DLIList<TBPoint*> &all_pts); 00297 00298 void get_tbs_with_bridge_manager_as_owner( TopologyBridge *source_bridge, 00299 DLIList<TopologyBridge*> &tbs ); 00300 private: 00301 00302 CubitStatus notify_transform_internal( TopologyBridge* bridge, 00303 const CubitTransformMatrix& xform ); 00304 00305 PartitionEngine(); 00306 00307 friend class PartitionLumpImprint; 00308 00321 CubitStatus find_coedges( PartitionSurface* surface, 00322 PartitionCurve* curve, 00323 PartitionPoint* point, 00324 PartitionCoEdge*& previous, 00325 PartitionCoEdge*& next ); 00326 00337 PartitionCurve* next_curve_around_point( PartitionSurface *const surface, 00338 CubitFacetEdgeData *const edge, 00339 CubitPointData *const point, 00340 const bool backwards ); 00341 00342 00344 CubitStatus remove_point_curve( PartitionPoint* point ); 00345 00355 PartitionPoint* insert_point_curve( PartitionSurface* surface, 00356 CubitPointData* point ); 00357 CubitStatus insert_point_curve( PartitionSurface* surface, 00358 PartPTCurve* curve, 00359 bool update_topology = true ); 00360 00361 00373 PartitionCurve* insert_point( PartitionCurve* curve, PartitionPoint* point ); 00374 00384 CubitStatus insert_curve( DLIList<PartitionSurface*>& surfaces, 00385 DLIList<CubitVector*>& polyline, 00386 DLIList<PartitionSurface*>& new_surfaces, 00387 DLIList<PartitionCurve*>& polyline_curves, 00388 const double *tolerance_length = NULL); 00389 00409 PartitionSurface* insert_curve( PartitionSurface* surface, 00410 SegmentedCurve* curve ); 00411 00427 SegmentedCurve* insert_curve( DLIList<CubitFacetEdgeData*>& facet_edges, 00428 DLIList<CubitVector*>* curve_segments = 0 ); 00429 00442 CubitPointData* project_to_surface( PartitionSurface* surface, 00443 const CubitVector& position ); 00444 00464 CubitStatus project_to_surface( DLIList<CubitFacetData*>& facets, 00465 DLIList<CubitVector*>& polyline_in, 00466 DLIList<CubitFacetEdgeData*>& polyline_out, 00467 DLIList<CubitPointData*>& polyline_pts, 00468 const double *tolerance_length = NULL); 00469 00482 PartitionLump* insert_surface( PartitionLump* lump, PartitionSurface* surf ); 00483 00484 00486 PartitionBody* make_body( PartitionPoint* pt ); 00488 PartitionBody* make_body( PartitionCurve* curve ); 00490 PartitionBody* make_body( PartitionSurface* surf ); 00492 PartitionBody* make_body( PartitionLump* lump ); 00494 PartitionBody* make_body_internal( TopologyBridge* child_ptr ); 00495 00497 PartitionLump* replace_lump( Lump* lump ); 00499 Lump* restore_lump( PartitionLump* lump ); 00501 CubitStatus destroy_shell( PartitionShell* shell ); 00502 00503 00504 public: /* temporarily public for debugging */ 00506 SubSurface* replace_surface( Surface* surface ); 00507 private: 00509 Surface* restore_surface( SubSurface* surface ); 00510 00512 SubCurve* replace_curve( Curve* curve ); 00514 Curve* restore_curve( SubCurve* curve ); 00515 00517 PartitionPoint* replace_point( TBPoint* point ); 00519 TBPoint* restore_point( PartitionPoint* point ); 00520 00538 PartitionSurface* split_surface( PartitionSurface* surface, 00539 PartitionCoEdge* new_curve ); 00540 00555 PartitionLump* split_lump( PartitionShell* shell ); 00556 00563 PartitionShell* split_shell( PartitionShell* shell ); 00564 00578 void insert_nonmanifold_surfaces( DLIList<PartitionSurface*>& surfaces, 00579 PartitionShell* shell1, PartitionShell* shell2); 00580 00590 CubitStatus inside_shell( PartitionShell* const shell, 00591 PartitionSurface* const surf, 00592 bool& result ); 00593 00595 CubitStatus save_curves( SubEntitySet* curve_set ); 00597 CubitStatus save_surfaces( SubEntitySet* surface_set ); 00599 CubitStatus save_lumps( SubEntitySet* lump_set ); 00600 00602 CubitStatus restore_from_attrib( Curve* partitioned_curve ); 00604 CubitStatus restore_from_attrib( Surface* partitioned_surface ); 00606 CubitStatus restore_from_attrib( Lump* partitioned_lump ); 00607 00608 static PartitionEngine* instance_; 00609 00611 std::map<int,SubEntitySet*> uniqueIdMap; 00612 00613 DLIList<TopologyBridge*> deactivatedList; 00614 }; 00615 00616 #endif