int StdMeshers_Hexa_3D::GetFaceIndex(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, const vector < SMESH_subMesh * >&meshFaces, const TopoDS_Vertex & V0, const TopoDS_Vertex & V1, const TopoDS_Vertex & V2, const TopoDS_Vertex & V3) { //MESSAGE("StdMeshers_Hexa_3D::GetFaceIndex"); int faceIndex = -1; for (int i = 1; i < 6; i++) { const TopoDS_Shape & aFace = meshFaces[i]->GetSubShape(); //const TopoDS_Face& F = TopoDS::Face(aFace); TopTools_IndexedMapOfShape M; TopExp::MapShapes(aFace, TopAbs_VERTEX, M); bool verticesInShape = false; if (M.Contains(V0)) if (M.Contains(V1)) if (M.Contains(V2)) if (M.Contains(V3)) verticesInShape = true; if (verticesInShape) { faceIndex = i; break; } } //IPAL21120 ASSERT(faceIndex > 0); //SCRUTE(faceIndex); return faceIndex; }
TopoDS_Vertex StdMeshers_Hexa_3D::OppositeVertex(const TopoDS_Vertex& aVertex, const TopTools_IndexedMapOfShape& aQuads0Vertices, FaceQuadStruct* aQuads[6]) { int i, j; for ( i = 1; i < 6; ++i ) { TopoDS_Vertex VV[] = { aQuads[i]->side[0]->FirstVertex(), aQuads[i]->side[0]->LastVertex() , aQuads[i]->side[2]->LastVertex() , aQuads[i]->side[2]->FirstVertex() }; for ( j = 0; j < 4; ++j ) if ( aVertex.IsSame( VV[ j ])) break; if ( j < 4 ) { int jPrev = j ? j - 1 : 3; int jNext = (j + 1) % 4; if ( aQuads0Vertices.Contains( VV[ jPrev ] )) return VV[ jNext ]; else return VV[ jPrev ]; } } return TopoDS_Vertex(); }
PyObject* TopoShapeFacePy::validate(PyObject *args) { if (!PyArg_ParseTuple(args, "")) return 0; try { const TopoDS_Face& face = TopoDS::Face(getTopoShapePtr()->getShape()); BRepCheck_Analyzer aChecker(face); if (!aChecker.IsValid()) { TopoDS_Wire outerwire = ShapeAnalysis::OuterWire(face); TopTools_IndexedMapOfShape myMap; myMap.Add(outerwire); TopExp_Explorer xp(face,TopAbs_WIRE); ShapeFix_Wire fix; fix.SetFace(face); fix.Load(outerwire); fix.Perform(); BRepBuilderAPI_MakeFace mkFace(fix.WireAPIMake()); while (xp.More()) { if (!myMap.Contains(xp.Current())) { fix.Load(TopoDS::Wire(xp.Current())); fix.Perform(); mkFace.Add(fix.WireAPIMake()); } xp.Next(); } aChecker.Init(mkFace.Face()); if (!aChecker.IsValid()) { ShapeFix_Shape fix(mkFace.Face()); fix.SetPrecision(Precision::Confusion()); fix.SetMaxTolerance(Precision::Confusion()); fix.SetMaxTolerance(Precision::Confusion()); fix.Perform(); fix.FixWireTool()->Perform(); fix.FixFaceTool()->Perform(); getTopoShapePtr()->setShape(fix.Shape()); } else { getTopoShapePtr()->setShape(mkFace.Face()); } } Py_Return; } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); return 0; } }
//======================================================================= //function : IsGrowthWire //purpose : //======================================================================= Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire, const TopTools_IndexedMapOfShape& theMHE) { Standard_Boolean bRet; TopoDS_Iterator aIt; // bRet=Standard_False; if (theMHE.Extent()) { aIt.Initialize(theWire); for(; aIt.More(); aIt.Next()) { const TopoDS_Shape& aE=aIt.Value(); if (theMHE.Contains(aE)) { return !bRet; } } } return bRet; }
TopoDS_Face FaceMakerCheese::validateFace(const TopoDS_Face& face) { BRepCheck_Analyzer aChecker(face); if (!aChecker.IsValid()) { TopoDS_Wire outerwire = ShapeAnalysis::OuterWire(face); TopTools_IndexedMapOfShape myMap; myMap.Add(outerwire); TopExp_Explorer xp(face,TopAbs_WIRE); ShapeFix_Wire fix; fix.SetFace(face); fix.Load(outerwire); fix.Perform(); BRepBuilderAPI_MakeFace mkFace(fix.WireAPIMake()); while (xp.More()) { if (!myMap.Contains(xp.Current())) { fix.Load(TopoDS::Wire(xp.Current())); fix.Perform(); mkFace.Add(fix.WireAPIMake()); } xp.Next(); } aChecker.Init(mkFace.Face()); if (!aChecker.IsValid()) { ShapeFix_Shape fix(mkFace.Face()); fix.SetPrecision(Precision::Confusion()); fix.SetMaxTolerance(Precision::Confusion()); fix.SetMaxTolerance(Precision::Confusion()); fix.Perform(); fix.FixWireTool()->Perform(); fix.FixFaceTool()->Perform(); TopoDS_Face fixedFace = TopoDS::Face(fix.Shape()); aChecker.Init(fixedFace); if (!aChecker.IsValid()) Standard_Failure::Raise("Failed to validate broken face"); return fixedFace; } return mkFace.Face(); } return face; }
//======================================================================= // function: ComputeState // purpose: //======================================================================= TopAbs_State GEOMAlgo_Tools3D::ComputeState(const TopoDS_Face& theF, const TopoDS_Solid& theRef, const Standard_Real theTol, const TopTools_IndexedMapOfShape& theBounds, IntTools_Context& theCtx) { TopAbs_State aState; TopExp_Explorer aExp; TopoDS_Edge aE1; gp_Pnt2d aP2D; gp_Pnt aP3D; // aState=TopAbs_UNKNOWN; // aExp.Init(theF, TopAbs_EDGE); for (; aExp.More(); aExp.Next()) { const TopoDS_Edge& aSE=TopoDS::Edge(aExp.Current()); if (BRep_Tool::Degenerated(aSE)) { continue; } // if (!theBounds.Contains(aSE)) { const TopoDS_Edge& aE=TopoDS::Edge(aSE); aState= GEOMAlgo_Tools3D::ComputeState(aE, theRef, theTol, theCtx); return aState; } if (aE1.IsNull()) { aE1=TopoDS::Edge(aSE); } } // !!<- process edges that are all on theRef if (!aE1.IsNull()) { BOPTools_Tools3D::PointNearEdge(aE1, theF, aP2D, aP3D); aState=GEOMAlgo_Tools3D::ComputeState(aP3D, theRef, theTol, theCtx); } // return aState; }
TopoShape SimpleBoxWithNaming(){ // We'll do this like freecad, first create TopoDS_Shape const TopoDS_Shape& Box = BRepPrimAPI_MakeBox(10., 10., 10.); // create Base Shape that gets passed to FilletFeature TopoShape BaseShape(Box); //std::clog << "Dumping deep TDF tree\n"; //std::clog << BaseShape.DeepDeepDumpTopoHistory(); // create blank TopoShape in FilletFeature and add Base Shape TopoShape BoxShape; BoxShape.addShape(Box); // Finaly, 'Select' the edge std::cout << "Trying to select the first time" << std::endl; std::string selectionLabel = BoxShape.selectEdge(3); //std::cout << "Trying to select a second time" << std::endl; //std::string selectionLabel2 = BoxShape.selectEdge(3); //std::clog << "Dumping tree" << std::endl; //std::clog << BoxShape.DumpTopoHistory(); //std::clog << "|____________________|" << std::endl; // And fillet the box std::clog << "Running makeTopoShape" << std::endl; BoxShape.makeTopoShapeFillet(2., 2., selectionLabel); //std::clog << "-------------------------" << std::endl; std::clog << "------------ REBUILDING ----------" << std::endl; //std::clog << "-------------------------" << std::endl; // make box taller const TopoDS_Shape& Box2 = BRepPrimAPI_MakeBox(10., 20., 20.); BoxShape.modifyShape("0:2", Box2); std::clog << BoxShape.DumpTopoHistory(); // try re-building the box TopoDS_Edge recoveredEdge = TopoDS::Edge(BoxShape.getSelectedEdge(selectionLabel)); //TopoDS_Shape recoveredBase = BoxShape.getSelectedBaseShape(selectionLabel); //TopoDS_Shape recoveredBase = BoxShape.getNodeShape("0:4"); TopoDS_Shape recoveredBase = BoxShape.getTipShape(); //if (recoveredBase.IsNull()){ //std::cout << "BaseShape is NULL....\n"; //} //else{ //std::cout << "BaseShape is not NULL!!!!\n"; //} //if (recoveredEdge.IsNull()){ //std::cout << "recoveredEdge is Nul..." << std::endl; //} //else{ //std::cout << "recoveredEdge is NOT NULL!!!!" << std::endl; //} TopTools_IndexedMapOfShape edges; TopExp::MapShapes(recoveredBase, TopAbs_EDGE, edges); if (edges.Contains(recoveredEdge)){ std::cout << "Yes the Edge is in the box...\n"; } else{ std::cout << "No, the Edge is not in the Box...\n"; } //BoxShape.makeTopoShapeFillet(2., 2., selectionLabel); return BoxShape; }
int OCCWire::chamfer(std::vector<OCCVertex *> vertices, std::vector<double> distances) { int vertices_size = vertices.size(); int distances_size = distances.size(); BRepFilletAPI_MakeFillet2d MF; try { if (this->getShape().IsNull()) { StdFail_NotDone::Raise("Shapes is Null"); } MF.Init(BRepBuilderAPI_MakeFace(this->getWire())); // creat map of vertices TopTools_IndexedMapOfShape vertMap; for (unsigned i=0; i<vertices.size(); i++) vertMap.Add(vertices[i]->getShape()); bool first = true; TopoDS_Edge firstEdge, nextEdge; TopoDS_Vertex vertex; BRepTools_WireExplorer Ex1; for (Ex1.Init(this->getWire()); Ex1.More(); ) { if(first == true) { firstEdge = Ex1.Current(); first = false; } Ex1.Next(); //if the number of edges is odd don't proceed if(Ex1.More() == Standard_False) break; nextEdge = Ex1.Current(); //get the common vertex of the two edges if (!TopExp::CommonVertex(firstEdge, nextEdge, vertex)) { // disconnected wire first = true; continue; } if (vertMap.Contains(vertex)) { int i = vertMap.FindIndex(vertex) - 1; if (distances_size == 1) { // single distance MF.AddChamfer(firstEdge, nextEdge, distances[0], distances[0]); } else if (distances_size == vertices_size) { // distance given for each vertex MF.AddChamfer(firstEdge, nextEdge, distances[i], distances[i]); } else { StdFail_NotDone::Raise("distances argument has wrong size"); } } firstEdge = nextEdge; } // special case for closed wire if (isClosed()) { // find seam vertex TopoDS_Vertex aV1; TopExp::Vertices(this->getWire(), vertex, aV1); // check if seam vertex has chamfer value if (vertMap.Contains(vertex)) { int i = vertMap.FindIndex(vertex) - 1; // map vertices to edges to find edge pair TopTools_IndexedDataMapOfShapeListOfShape mapVertexEdge; TopExp::MapShapesAndAncestors(this->getWire(), TopAbs_VERTEX, TopAbs_EDGE, mapVertexEdge); const TopTools_ListOfShape& edges = mapVertexEdge.FindFromKey(vertex); firstEdge = TopoDS::Edge(edges.First()); nextEdge = TopoDS::Edge(edges.Last()); if (distances_size == 1) { // single distance MF.AddChamfer(firstEdge, nextEdge, distances[0], distances[0]); } else if (distances_size == vertices_size) { // distance given for each vertex MF.AddChamfer(firstEdge, nextEdge, distances[i], distances[i]); } else { StdFail_NotDone::Raise("distances argument has wrong size"); } } } if(MF.Status() != ChFi2d_IsDone) StdFail_NotDone::Raise("chamfer operation failed"); TopTools_IndexedMapOfShape aMap; TopExp::MapShapes(MF.Shape(), TopAbs_WIRE, aMap); if(aMap.Extent() != 1) StdFail_NotDone::Raise("chamfer result did not result in single wire");; //add edges to the wire BRepBuilderAPI_MakeWire wire; BRepTools_WireExplorer Ex2; for(Ex2.Init(TopoDS::Wire(aMap(1))); Ex2.More(); Ex2.Next()) { wire.Add(Ex2.Current()); } this->setShape(wire.Shape()); // possible fix shape if (!this->fixShape()) StdFail_NotDone::Raise("Shapes not valid"); } catch(Standard_Failure &err) { Handle_Standard_Failure e = Standard_Failure::Caught(); const Standard_CString msg = e->GetMessageString(); if (msg != NULL && strlen(msg) > 1) { setErrorMessage(msg); } else { setErrorMessage("Failed to chamfer wire"); } return 0; } return 1; }
TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape, const Standard_Real Tol) { myContext = new ShapeBuild_ReShape; myTolerance = Tol; TopoDS_Shape aResult = myContext->Apply(Shape); // processing each solid TopAbs_ShapeEnum aType = TopAbs_SOLID; TopExp_Explorer exps (Shape, aType); if (!exps.More()) { aType = TopAbs_SHELL; exps.Init(Shape, aType); } for (; exps.More(); exps.Next()) { //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); TopoDS_Shape aSolid = exps.Current(); TopTools_IndexedMapOfShape ChangedFaces; // creating map of edge faces TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; TopoDS_Shape aRes = aSolid; aRes = aContext->Apply(aSolid); // processing each face TopExp_Explorer exp; for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { TopoDS_Face aFace = TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { TopoDS_Edge edge = TopoDS::Edge(expe.Current()); if (!aMapEdgeFaces.Contains(edge)) continue; const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); TopTools_ListIteratorOfListOfShape anIter(aList); for ( ; anIter.More(); anIter.Next()) { TopoDS_Face face = TopoDS::Face(anIter.Value()); TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value())); if (face1.IsSame(aFace)) continue; if (aMapFacesEdges.Contains(face)) { aMapFacesEdges.ChangeFromKey(face).Append(edge); } else { TopTools_ListOfShape ListEdges; ListEdges.Append(edge); aMapFacesEdges.Add(face,ListEdges); } } } for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); TopTools_SequenceOfShape SeqEdges; TopTools_ListIteratorOfListOfShape anIter(ListEdges); for ( ; anIter.More(); anIter.Next()) { SeqEdges.Append(anIter.Value()); } if (SeqEdges.Length()==1) continue; TopoDS_Edge E; if ( MergeEdges(SeqEdges,aFace,Tol,E) ) { // now we have only one edge - aChain.Value(1) // we have to replace old ListEdges with this new edge aContext->Replace(SeqEdges(1),E); for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) { aContext->Remove(SeqEdges(j)); } TopoDS_Face tmpF = TopoDS::Face(exp.Current()); if ( !ChangedFaces.Contains(tmpF) ) ChangedFaces.Add(tmpF); tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); if ( !ChangedFaces.Contains(tmpF) ) ChangedFaces.Add(tmpF); } } } // end processing each face // fix changed faces and replace them in the local context for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); sff->SetContext(myContext); sff->SetPrecision(myTolerance); sff->SetMinTolerance(myTolerance); sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); sff->Perform(); aContext->Replace(aFace,sff->Face()); } if (ChangedFaces.Extent() > 0) { // fix changed shell and replace it in the local context TopoDS_Shape aRes1 = aContext->Apply(aRes); TopExp_Explorer expsh; for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; sfsh->FixFaceOrientation(aShell); aContext->Replace(aShell,sfsh->Shell()); } TopoDS_Shape aRes2 = aContext->Apply(aRes1); // put new solid into global context myContext->Replace(aSolid,aRes2); } } // end processing each solid aResult = myContext->Apply(Shape); return aResult; }
// //======================================================================= // function: PerformEF // purpose: //======================================================================= void NMTTools_PaveFiller::PerformEF() { Standard_Boolean bJustAdd; Standard_Integer n1, n2, anIndexIn, nE, nF, aNbEFs, aBlockLength; Standard_Integer aDiscretize; Standard_Real aTolE, aTolF, aDeflection; BooleanOperations_IndexedDataMapOfShapeInteger aMapVI; BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB; BOPTools_IMapOfPaveBlock aIMPBx; // myIsDone=Standard_False; aDeflection=0.01; aDiscretize=35; // BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences(); // myDSIt->Initialize(TopAbs_EDGE, TopAbs_FACE); // // BlockLength correction aNbEFs=myDSIt->BlockLength(); aBlockLength=aEFs.BlockLength(); if (aNbEFs > aBlockLength) { aEFs.SetBlockLength(aNbEFs); } // for (; myDSIt->More(); myDSIt->Next()) { myDSIt->Current(n1, n2, bJustAdd); // if(bJustAdd) { continue; } // anIndexIn = 0; // nE=n1; nF=n2; if (myDS->GetShapeType(n2)==TopAbs_EDGE) { nE=n2; nF=n1; } // // all Common Blocks for face nF NMTTools_ListOfCommonBlock aLCBF; CommonBlocksFace(nF, aLCBF); NMTTools_CommonBlockAPI aCBAPIF(aLCBF); // // Edge const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE)); if (BRep_Tool::Degenerated(aE)){ continue; } // // Face const TopoDS_Face aF=TopoDS::Face(myDS->Shape(nF)); // TopTools_IndexedMapOfShape aME; TopExp::MapShapes(aF, TopAbs_EDGE, aME); if (aME.Contains(aE)) { continue; } // aTolF=BRep_Tool::Tolerance(aF); aTolE=BRep_Tool::Tolerance(aE); const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); // // Process each PaveBlock on edge nE BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); // BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); for (; anIt.More(); anIt.Next()) { BOPTools_PaveBlock& aPB=anIt.Value(); if (aCBAPIF.IsCommonBlock(aPB)) { continue; } // const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange(); const IntTools_Range& aSR =aShrunkRange.ShrunkRange(); const Bnd_Box& aBBE=aShrunkRange.BndBox(); // if (aBBF.IsOut (aBBE)) { continue; } // // EF IntTools_EdgeFace aEF; aEF.SetEdge (aE); aEF.SetFace (aF); aEF.SetTolE (aTolE); aEF.SetTolF (aTolF); aEF.SetDiscretize (aDiscretize); aEF.SetDeflection (aDeflection); // aEF.SetContext((IntTools_PContext)&myContext); // IntTools_Range anewSR = aSR; // // Correction of the Shrunk Range BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR); aEF.SetRange (anewSR); // aEF.Perform(); // if (aEF.IsDone()) { Standard_Boolean bCoinsideFlag; Standard_Integer i, aNbCPrts; TopAbs_ShapeEnum aType; // const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts(); // aNbCPrts=aCPrts.Length(); for (i=1; i<=aNbCPrts; ++i) { anIndexIn=0; // const IntTools_CommonPrt& aCPart=aCPrts(i); aType=aCPart.Type(); // switch (aType) { // case TopAbs_VERTEX: { Standard_Boolean bIsOnPave1, bIsOnPave2; Standard_Integer nVF; Standard_Real aT, aTolToDecide; TopoDS_Vertex aNewVertex; // const IntTools_Range& aR=aCPart.Range1(); // // New Vertex VertexParameter(aCPart, aT); BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex); // //decide to add pave or not aTolToDecide=5.e-8; bIsOnPave1=IsOnPave(anewSR.First(), aR, aTolToDecide); bIsOnPave2=IsOnPave(anewSR.Last() , aR, aTolToDecide); // if (!bIsOnPave1 && !bIsOnPave2) { nVF=CheckFacePaves(aNewVertex, nF); if (!nVF) { // really new vertex // Add Interference to the Pool BOPTools_ESInterference anInterf (nE, nF, aCPart); anIndexIn=aEFs.Append(anInterf); anInterf.SetNewShape(0); // aMapVI.Add(aNewVertex, anIndexIn); aIMPBx.Add(aPB); // myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF); // }// if (!nVF) }// if (!bIsOnPave1 && !bIsOnPave2) // //modified by NIZNHY-PKV Fri Apr 18 10:55:38 2008f else { const BOPTools_Pave& aPave=(bIsOnPave1)? aPB.Pave1() : aPB.Pave2(); nVF=aPave.Index(); const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); BOPTools_Tools::UpdateVertex (aVF, aNewVertex); } //modified by NIZNHY-PKV Fri Apr 18 10:55:40 2008t // }// case TopAbs_VERTEX: break; // case TopAbs_EDGE: { bCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); if (!bCoinsideFlag) { break; } // // Fill aMapCB if (aMapCB.Contains(aPB)) { TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB); aMapF.Add(nF); } else { TColStd_IndexedMapOfInteger aMapF; aMapF.Add(nF); aMapCB.Add(aPB, aMapF); } // aIMPBx.Add(aPB); myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF); }// case TopAbs_EDGE: break; default: break; } // switch (aType) } // for (i=1; i<=aNbCPrts; i++) } //if (aEF.IsDone()) } // for (; anIt.More(); anIt.Next()) }// for (; myDSIt.More(); myDSIt.Next()) // // Treat New vertices EFNewVertices(aMapVI); // // Add draft Common Blocks of EF type EFCommonBlocks(aMapCB); // // Collect all CB we suspected to split by new vertices NMTTools_ListOfCommonBlock aLCBx; { Standard_Integer i, aNbPBx, nEx; BOPTools_IMapOfPaveBlock aMx; // aNbPBx=aIMPBx.Extent(); for (i=1; i<=aNbPBx; ++i) { const BOPTools_PaveBlock& aPBx=aIMPBx(i); nEx=aPBx.OriginalEdge(); NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nEx)); if (aLCB.Extent()) { NMTTools_CommonBlockAPI aCBAPIx(aLCB); if (aCBAPIx.IsCommonBlock(aPBx)) { NMTTools_CommonBlock& aCBx=aCBAPIx.CommonBlock(aPBx); const BOPTools_PaveBlock& aPB1=aCBx.PaveBlock1(); if (!aMx.Contains(aPB1)){ aMx.Add(aPB1); aLCBx.Append(aCBx); } } } } } // // Split the common blocks above if (aLCBx.Extent()) { ReplaceCommonBlocks(aLCBx); } // myIsDone=Standard_True; }
//======================================================================= // function: MakeConnexityBlock. // purpose: //======================================================================= void GEOMAlgo_Tools3D::MakeConnexityBlock (const TopTools_ListOfShape& theLFIn, const TopTools_IndexedMapOfShape& theMEAvoid, TopTools_ListOfShape& theLCB) { Standard_Integer aNbF, aNbAdd1; TopExp_Explorer aExp; TopTools_IndexedDataMapOfShapeListOfShape aMEF; TopTools_MapIteratorOfMapOfShape aItM, aItM1; TopTools_MapOfShape aMCB, aMAdd, aMAdd1; TopTools_ListIteratorOfListOfShape aIt; // // 1. aMEF aNbF=theLFIn.Extent(); aIt.Initialize(theLFIn); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aF=aIt.Value(); TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); } // // 2. aMCB const TopoDS_Shape& aF1=theLFIn.First(); aMAdd.Add(aF1); // while(1) { aMAdd1.Clear(); aItM.Initialize(aMAdd); for (; aItM.More(); aItM.Next()) { const TopoDS_Shape& aF=aItM.Key(); // //aMAdd1.Clear(); aExp.Init(aF, TopAbs_EDGE); for (; aExp.More(); aExp.Next()) { const TopoDS_Shape& aE=aExp.Current(); if (theMEAvoid.Contains(aE)){ continue; } // const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE); aIt.Initialize(aLF); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aFx=aIt.Value(); if (aFx.IsSame(aF)) { continue; } if (aMCB.Contains(aFx)) { continue; } aMAdd1.Add(aFx); } }//for (; aExp.More(); aExp.Next()){ aMCB.Add(aF); }// for (; aItM.More(); aItM.Next()) { // aNbAdd1=aMAdd1.Extent(); if (!aNbAdd1) { break; } // aMAdd.Clear(); aItM1.Initialize(aMAdd1); for (; aItM1.More(); aItM1.Next()) { const TopoDS_Shape& aFAdd=aItM1.Key(); aMAdd.Add(aFAdd); } // }//while(1) { // aNbF=aMCB.Extent(); aItM.Initialize(aMCB); for (; aItM.More(); aItM.Next()) { const TopoDS_Shape& aF=aItM.Key(); theLCB.Append(aF); } }