#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)
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;
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;
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()
Handle(HYDROData_Entity) aRefObject = theDoc->FindObjectByName( anObjName );
if ( aRefObject.IsNull() )
continue;
-
+ DEBTRACE("aRefObject name: " << aRefObject->GetName());
aNewZone->AddObject( aRefObject );
}
}
-
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 )
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() )
if ( aRegionFacesList.Extent() == 1 )
{
+ DEBTRACE("--- aRegionFacesList.Extent() == 1 ");
aResShape = TopoDS::Face( aRegionFacesList.First() );
}
else
//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);
HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Fused face edges:", aFuseShape, TopAbs_EDGE );
#endif
- BRep_Builder BB;
- TopoDS_Face DF;
+ aFuseShape = HYDROData_Tool::RebuildCmp(aFuseShape);
+
+ 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 );
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.Generated(DF);
- 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 );
*theSeqOfGroups = aSeqOfGroups;
}
}
-
+
return aResShape;
}