X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Region.cxx;h=a381e208358302290c6d044ebfe52abe73e59ee6;hb=f09552db523068b952c3e6e64c5f8acb165d243d;hp=80c005cc4ad8b8ff1e6a443e587074745221b421;hpb=41550a623dca7d2de1b388c9832fe3642d2b8753;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index 80c005cc..a381e208 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -51,6 +51,9 @@ #include "gp_Pln.hxx" #include "BRepTools_ReShape.hxx" +//#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + //#define DEB_GET_REGION_SHAPE IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Entity) @@ -98,7 +101,7 @@ HYDROData_SequenceOfObjects HYDROData_Region::GetAllReferenceObjects() const bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone ) { - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document(); if ( theZone.IsNull() ) return false; @@ -134,7 +137,7 @@ HYDROData_SequenceOfObjects HYDROData_Region::GetZones() const return GetReferenceObjects( DataTag_Zone ); } -void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone ) +void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone, bool removeRegion ) { if ( theZone.IsNull() ) return; @@ -147,10 +150,13 @@ void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone ) if ( !aFatherRegion.IsNull() && aFatherRegion->Label() == myLab ) theZone->Remove(); - // If the last zone has been removed from region we remove this region - HYDROData_SequenceOfObjects aRefZones = GetZones(); - if ( aRefZones.IsEmpty() ) - Remove(); + if (removeRegion) + { + // If the last zone has been removed from region we remove this region + HYDROData_SequenceOfObjects aRefZones = GetZones(); + if ( aRefZones.IsEmpty() ) + Remove(); + } } void HYDROData_Region::RemoveZones() @@ -182,7 +188,7 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone( const Handle(HYDROData_Docu Handle(HYDROData_Entity) aRefObject = theDoc->FindObjectByName( anObjName ); if ( aRefObject.IsNull() ) continue; - + DEBTRACE("aRefObject name: " << aRefObject->GetName()); aNewZone->AddObject( aRefObject ); } @@ -246,6 +252,7 @@ void getUsedGroups( const TopoDS_Shape& theShape, TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups, const TopTools_SequenceOfShape* IntSh ) const { + DEBTRACE("GetShape"); HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroups; HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfUsedGroups; if ( theSeqOfGroups ) @@ -285,11 +292,15 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* getUsedGroups( aZoneFace, aSeqOfGroups, aSeqOfUsedGroups ); } // zones iterator - for (int i = 1; i <= IntSh->Length(); i++) + DEBTRACE("--- IntSh->Length():" << IntSh->Length()); + if (IntSh) { - const TopoDS_Shape& CS = (*IntSh)(i); - if (AllE.Contains(CS)) - IE.Add(CS); + for (int i = 1; i <= IntSh->Length(); i++) + { + const TopoDS_Shape& CS = (*IntSh)(i); + if (AllE.Contains(CS)) + IE.Add(CS); + } } if ( aRegionFacesList.IsEmpty() ) @@ -299,6 +310,7 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* if ( aRegionFacesList.Extent() == 1 ) { + DEBTRACE("--- aRegionFacesList.Extent() == 1 "); aResShape = TopoDS::Face( aRegionFacesList.First() ); } else @@ -330,6 +342,7 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* //update history of internal edges TopTools_IndexedMapOfShape DIE; TopTools_ListOfShape newSh1, newSh2; + DEBTRACE("IE.Extent():" << IE.Extent()); for (int i = 1; i <= IE.Extent(); i++) { const TopoDS_Shape& CSH = IE(i); @@ -364,42 +377,25 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* aFuseShape = HYDROData_Tool::RebuildCmp(aFuseShape); - BRep_Builder BB; - TopoDS_Face DF; + ShapeUpgrade_UnifySameDomain unif( aFuseShape, Standard_False, Standard_True, Standard_False ); if (!IE.IsEmpty()) { - //add dummy face to existing shell - //this face contains all internal edges - //USD algo will skip such edges and will not perform unifying through them - //(more than 2 faces are connected to one edge + non same domain surfaces) - TopoDS_Wire DW; - Handle(Geom_Plane) DPl = new Geom_Plane(gp_Pln (gp_Pnt(0,0,0), gp_Dir(0,1,0))); //non same domain with the main surf - BB.MakeFace(DF, DPl, Precision::Confusion()); - BB.MakeWire(DW); + TopTools_MapOfShape IEM; for (int i = 1; i <= IE.Extent(); i++) - BB.Add(DW, IE(i)); - BB.Add(DF, DW); - BB.Add(aFuseShape, DF); + IEM.Add(IE(i)); + unif.KeepShapes(IEM); } - ShapeUpgrade_UnifySameDomain unif( aFuseShape, Standard_False, Standard_True, Standard_False ); unif.Build(); TopoDS_Shape anUnitedShape; - const TopoDS_Shape& out = unif.Shape(); + anUnitedShape = unif.Shape(); HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &unif ); - if (!IE.IsEmpty()) - { - //remove dummy face from shell; shell becomes valid - const TopoDS_Shape& NDF = unif.History()->Modified(DF).First(); - BRepTools_ReShape ReShaper; - ReShaper.Remove(NDF); - anUnitedShape = ReShaper.Apply(out); - HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &ReShaper ); - } - else - anUnitedShape = out; + //cout << "inif: fuseshape: " << aFuseShape.TShape().get() << "unifS " << anUnitedShape.TShape().get() << endl; +#ifdef DEB_GET_REGION_SHAPE + HYDROData_ShapesGroup::GroupDefinition::Dump( std::cout, aSeqOfUsedGroups ); +#endif TopTools_SequenceOfShape aShapeFaces; HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_FACE, aShapeFaces ); @@ -443,7 +439,7 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* *theSeqOfGroups = aSeqOfGroups; } } - + return aResShape; }