//======================================================================= //function : StoreInMVE //purpose : //======================================================================= static void StoreInMVE (const TopoDS_Face& F, TopoDS_Edge& E, TopTools_DataMapOfShapeListOfShape& MVE ) { TopoDS_Vertex V1, V2; TopTools_ListOfShape Empty; TopExp::Vertices(E,V1,V2); if (!MVE.IsBound(V1)) { MVE.Bind(V1,Empty); } MVE(V1).Append(E); if (!MVE.IsBound(V2)) { MVE.Bind(V2,Empty); } MVE(V2).Append(E); }
//======================================================================= //function : PerformAreas //purpose : //======================================================================= void GEOMAlgo_BuilderFace::PerformAreas() { myErrorStatus=0; // Standard_Boolean bIsGrowth, bIsHole; Standard_Real aTol; TopTools_ListOfShape aNewFaces, aHoleWires; TopoDS_Shape anInfinitePointShape; TopTools_DataMapOfShapeShape aInOutMap; TopTools_DataMapOfShapeListOfShape aMSH; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH; TopTools_ListIteratorOfListOfShape aIt1, aIt2; TopTools_IndexedMapOfShape aMHE; BRep_Builder aBB; Handle(Geom_Surface) aS; TopLoc_Location aLoc; // aTol=BRep_Tool::Tolerance(myFace); aS=BRep_Tool::Surface(myFace, aLoc); // myAreas.Clear(); // // Draft faces [aNewFaces] aIt1.Initialize(myLoops); for ( ; aIt1.More(); aIt1.Next()) { const TopoDS_Shape& aWire=aIt1.Value(); // bIsGrowth=IsGrowthWire(aWire, aMHE); if (bIsGrowth) { // make a growth face from a wire TopoDS_Face aFace; aBB.MakeFace(aFace, aS, aLoc, aTol); aBB.Add (aFace, aWire); // aNewFaces.Append (aFace); } else{ // check if a wire is a hole //XX //bIsHole=IsHole(aWire, myFace, myContext); bIsHole=GEOMAlgo_BuilderTools::IsHole(aWire, myFace); //XX if (bIsHole) { aHoleWires.Append(aWire); TopExp::MapShapes(aWire, TopAbs_EDGE, aMHE); } else { // make a growth face from a wire TopoDS_Face aFace; aBB.MakeFace(aFace, aS, aLoc, aTol); aBB.Add (aFace, aWire); // aNewFaces.Append (aFace); } } } // // 2. Find outer growth shell that is most close to each hole shell aIt2.Initialize(aHoleWires); for (; aIt2.More(); aIt2.Next()) { const TopoDS_Shape& aHole = aIt2.Value(); // aIt1.Initialize(aNewFaces); for ( ; aIt1.More(); aIt1.Next()) { const TopoDS_Shape& aF=aIt1.Value(); // if (!IsInside(aHole, aF, myContext)){ continue; } // if ( aInOutMap.IsBound (aHole)){ const TopoDS_Shape& aF2=aInOutMap(aHole); if (IsInside(aF, aF2, myContext)) { aInOutMap.UnBind(aHole); aInOutMap.Bind (aHole, aF); } } else{ aInOutMap.Bind (aHole, aF); } } // // Add aHole to a map Face/ListOfHoles [aMSH] if (aInOutMap.IsBound(aHole)){ const TopoDS_Shape& aF=aInOutMap(aHole); if (aMSH.IsBound(aF)) { TopTools_ListOfShape& aLH=aMSH.ChangeFind(aF); aLH.Append(aHole); } else { TopTools_ListOfShape aLH; aLH.Append(aHole); aMSH.Bind(aF, aLH); } } }// for (; aIt2.More(); aIt2.Next()) // // 3. Add aHoles to Faces aItMSH.Initialize(aMSH); for (; aItMSH.More(); aItMSH.Next()) { TopoDS_Face aF=TopoDS::Face(aItMSH.Key()); // const TopTools_ListOfShape& aLH=aItMSH.Value(); aIt2.Initialize(aLH); for (; aIt2.More(); aIt2.Next()) { const TopoDS_Shape& aHole = aIt2.Value(); aBB.Add (aF, aHole); } // // update classifier aTol=BRep_Tool::Tolerance(aF); IntTools_FClass2d& aClsf=myContext->FClass2d(aF); aClsf.Init(aF, aTol); } // // These aNewFaces are draft faces that // do not contain any internal shapes // myAreas.Append(aNewFaces); }