//======================================================================= //function : FillVertices //purpose : //======================================================================= void GEOMAlgo_Gluer2::FillVertices() { TopAbs_ShapeEnum aType; TopoDS_Vertex aVnew; TopTools_ListIteratorOfListOfShape aItLS; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; // myErrorStatus=0; myWarningStatus=0; // aItDMSLS.Initialize(myImagesToWork); for (; aItDMSLS.More(); aItDMSLS.Next()) { const TopoDS_Shape& aSkey=aItDMSLS.Key(); aType=aSkey.ShapeType(); if (aType!=TopAbs_VERTEX) { continue; } // const TopTools_ListOfShape& aLSD=aItDMSLS.Value(); // GEOMAlgo_Gluer2::MakeVertex(aLSD, aVnew); // myImages.Bind(aVnew, aLSD); // aItLS.Initialize(aLSD); for (; aItLS.More(); aItLS.Next()) { const TopoDS_Shape& aV=aItLS.Value(); myOrigins.Bind(aV, aVnew); } } }
//======================================================================= //function : CheckData //purpose : //======================================================================= void GEOMAlgo_Gluer2::CheckData() { Standard_Integer aNbSG, i; TopAbs_ShapeEnum aType, aTypeX; TopTools_ListIteratorOfListOfShape aItLS; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; // myErrorStatus=0; myWarningStatus=0; // aNbSG=myShapesToGlue.Extent(); if (aNbSG) { // Check myShapesToGlue aItDMSLS.Initialize(myShapesToGlue); for (; aItDMSLS.More(); aItDMSLS.Next()) { //const TopoDS_Shape& aSkey=aItDMSLS.Key(); const TopTools_ListOfShape& aLSG=aItDMSLS.Value(); aItLS.Initialize(aLSG); for (i=0; aItLS.More(); aItLS.Next(), ++i) { const TopoDS_Shape& aSG=aItLS.Value(); aTypeX=aSG.ShapeType(); if (!i) { aType=aTypeX; if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE || aType==TopAbs_FACE)) { myErrorStatus=21;// non-brep shapes return; } continue; } if (aTypeX!=aType) { myErrorStatus=20;// non-homogeneous shapes return; } } } }// if (aNbSG) { }
//======================================================================= //function : DetectSolids //purpose : //======================================================================= void GEOMAlgo_GlueAnalyser::DetectSolids() { myErrorStatus=0; // Standard_Integer i, aNbF, aNbS, aNbC, aNbX; TopoDS_Compound aCmp; BRep_Builder aBB; TopTools_IndexedDataMapOfShapeListOfShape aMFS; TopTools_IndexedMapOfShape aMx, aMS; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; GEOMAlgo_CoupleOfShapes aCS; // GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLS; GEOMAlgo_PassKeyShape aPKSx; // aBB.MakeCompound(aCmp); // TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS); // aItIm.Initialize(myImages); for (; aItIm.More(); aItIm.Next()) { const TopoDS_Shape& aIm=aItIm.Key(); if (aIm.ShapeType()!=TopAbs_FACE) { continue; } // const TopTools_ListOfShape& aLF=aItIm.Value(); aNbF=aLF.Extent(); if (aNbF!=2) { continue; } // TopoDS_Shape aSx[2], aFx[2]; // aFx[0]=aLF.First(); aFx[1]=aLF.Last(); for (i=0; i<2; ++i) { if (!aMFS.Contains(aFx[i])) { continue;// it must not be so } // const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aFx[i]); aNbS=aLS.Extent(); if (aNbS!=1) { continue; } aSx[i]=aLS.First(); } // if (aSx[0].IsNull() || aSx[1].IsNull()) { continue; } // //aPKSx.Clear();//qft //qf //aPKSx.SetIds(aSx[0], aSx[1]); aPKSx.SetShapes(aSx[0], aSx[1]); //qt // if (!aMPKLS.Contains(aPKSx)) { TopTools_ListOfShape aLSx; // aLSx.Append(aSx[0]); aLSx.Append(aSx[1]); // aMPKLS.Add(aPKSx, aLSx); } } // mySolidsToGlue.Clear(); mySolidsAlone.Clear(); // aNbC=aMPKLS.Extent(); if (!aNbC) { return; } // for (i=1; i<=aNbC; ++i) { const TopTools_ListOfShape& aLSx=aMPKLS(i); const TopoDS_Shape& aSx1=aLSx.First(); const TopoDS_Shape& aSx2=aLSx.Last(); aCS.SetShape1(aSx1); aCS.SetShape2(aSx2); mySolidsToGlue.Append(aCS); // if (!aMx.Contains(aSx1)) { aBB.Add(aCmp, aSx1); aMx.Add(aSx1); } if (!aMx.Contains(aSx2)) { aBB.Add(aCmp, aSx2); aMx.Add(aSx2); } } myResult=aCmp; // // check alone solids TopExp::MapShapes(myShape, TopAbs_SOLID, aMS); // aNbX=aMx.Extent(); for (i=1; i<=aNbX; ++i) { const TopoDS_Shape& aSx=aMx(i); if (!aMS.Contains(aSx)) { mySolidsAlone.Append(aSx); } } }
//======================================================================= //function : DetectVertices //purpose : //======================================================================= void GEOMAlgo_GlueAnalyser::DetectVertices() { myErrorStatus=0; // Standard_Integer j, i, aNbV, aIndex, aNbVSD; TColStd_ListIteratorOfListOfInteger aIt; Handle(Bnd_HArray1OfBox) aHAB; Bnd_BoundSortBox aBSB; TopoDS_Shape aSTmp, aVF; TopoDS_Vertex aVnew; TopTools_IndexedMapOfShape aMV, aMVProcessed; TopTools_ListIteratorOfListOfShape aItS; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; GEOMAlgo_IndexedDataMapOfShapeBox aMSB; // TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV); aNbV=aMV.Extent(); if (!aNbV) { myErrorStatus=2; // no vertices in source shape return; } // aHAB=new Bnd_HArray1OfBox(1, aNbV); // for (i=1; i<=aNbV; ++i) { const TopoDS_Shape& aV=aMV(i); Bnd_Box aBox; // aBox.SetGap(myTol); BRepBndLib::Add(aV, aBox); aHAB->SetValue(i, aBox); aMIS.Add(i, aV); aMSB.Add(aV, aBox); } // aBSB.Initialize(aHAB); // for (i=1; i<=aNbV; ++i) { const TopoDS_Shape& aV=aMV(i); // if (aMVProcessed.Contains(aV)) { continue; } // const Bnd_Box& aBoxV=aMSB.FindFromKey(aV); const TColStd_ListOfInteger& aLI=aBSB.Compare(aBoxV); aNbVSD=aLI.Extent(); if (!aNbVSD) { myErrorStatus=3; // it must not be return; } // // Images TopTools_ListOfShape aLVSD; // aIt.Initialize(aLI); for (j=0; aIt.More(); aIt.Next(), ++j) { aIndex=aIt.Value(); const TopoDS_Shape& aVx=aMIS.FindFromKey(aIndex); if(!j) { aVF=aVx; } aLVSD.Append(aVx); aMVProcessed.Add(aVx); } myImages.Bind(aVF, aLVSD); } // Origins aItIm.Initialize(myImages); for (; aItIm.More(); aItIm.Next()) { const TopoDS_Shape& aV=aItIm.Key(); const TopTools_ListOfShape& aLVSD=aItIm.Value(); // aItS.Initialize(aLVSD); for (; aItS.More(); aItS.Next()) { const TopoDS_Shape& aVSD=aItS.Value(); if (!myOrigins.IsBound(aVSD)) { myOrigins.Bind(aVSD, aV); } } } }
//======================================================================= //function : DetectVertices //purpose : //======================================================================= void GEOMAlgo_GlueDetector::DetectVertices() { Standard_Integer j, i, aNbV, aNbVSD; Standard_Real aTolV; gp_Pnt aPV; TColStd_ListIteratorOfListOfInteger aIt; TopoDS_Shape aVF; TopTools_IndexedMapOfShape aMV; TopTools_MapOfShape aMVProcessed; TopTools_ListIteratorOfListOfShape aItS; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; TopTools_DataMapOfShapeListOfShape aMVV; GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; NMTDS_IndexedDataMapOfShapeBndSphere aMSB; // NMTDS_BndSphereTreeSelector aSelector; NMTDS_BndSphereTree aBBTree; NCollection_UBTreeFiller <Standard_Integer, NMTDS_BndSphere> aTreeFiller(aBBTree); // myErrorStatus=0; // TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMV); aNbV=aMV.Extent(); if (!aNbV) { myErrorStatus=2; // no vertices in source shape return; } // for (i=1; i<=aNbV; ++i) { NMTDS_BndSphere aBox; // const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMV(i)); aPV=BRep_Tool::Pnt(aV); aTolV=BRep_Tool::Tolerance(aV); // aBox.SetGap(myTolerance); aBox.SetCenter(aPV); aBox.SetRadius(aTolV); // aTreeFiller.Add(i, aBox); // aMIS.Add(i, aV); aMSB.Add(aV, aBox); } // aTreeFiller.Fill(); // //--------------------------------------------------- // Chains for (i=1; i<=aNbV; ++i) { const TopoDS_Shape& aV=aMV(i); // if (aMVProcessed.Contains(aV)) { continue; } // Standard_Integer aNbIP, aIP, aNbIP1, aIP1; TopTools_ListOfShape aLVSD; TColStd_MapOfInteger aMIP, aMIP1, aMIPC; TColStd_MapIteratorOfMapOfInteger aIt1; // aMIP.Add(i); while(1) { aNbIP=aMIP.Extent(); aIt1.Initialize(aMIP); for(; aIt1.More(); aIt1.Next()) { aIP=aIt1.Key(); if (aMIPC.Contains(aIP)) { continue; } // const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); const NMTDS_BndSphere& aBoxVP=aMSB.FindFromKey(aVP); // aSelector.Clear(); aSelector.SetBox(aBoxVP); // aNbVSD=aBBTree.Select(aSelector); if (!aNbVSD) { continue; // it shoild not be so [at least IP itself] } // const TColStd_ListOfInteger& aLI=aSelector.Indices(); aIt.Initialize(aLI); for (; aIt.More(); aIt.Next()) { aIP1=aIt.Value(); if (aMIP.Contains(aIP1)) { continue; } aMIP1.Add(aIP1); } //for (; aIt.More(); aIt.Next()) { }//for(; aIt1.More(); aIt1.Next()) { // aNbIP1=aMIP1.Extent(); if (!aNbIP1) { break; } // aIt1.Initialize(aMIP); for(; aIt1.More(); aIt1.Next()) { aIP=aIt1.Key(); aMIPC.Add(aIP); } // aMIP.Clear(); aIt1.Initialize(aMIP1); for(; aIt1.More(); aIt1.Next()) { aIP=aIt1.Key(); aMIP.Add(aIP); } aMIP1.Clear(); }// while(1) // // Fill myImages aNbIP=aMIPC.Extent(); // if (!aNbIP) {// no SD vertices is found aMVProcessed.Add(aV); continue; } //else { // SD vertices founded [ aMIPC ] aIt1.Initialize(aMIPC); for(j=0; aIt1.More(); aIt1.Next(), ++j) { aIP=aIt1.Key(); const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); if (!j) { aVF=aVP; } aLVSD.Append(aVP); aMVProcessed.Add(aVP); } //} myImages.Bind(aVF, aLVSD); }// for (i=1; i<=aNbV; ++i) { //------------------------------ // Origins aItIm.Initialize(myImages); for (; aItIm.More(); aItIm.Next()) { const TopoDS_Shape& aV=aItIm.Key(); const TopTools_ListOfShape& aLVSD=aItIm.Value(); aItS.Initialize(aLVSD); for (; aItS.More(); aItS.Next()) { const TopoDS_Shape& aVSD=aItS.Value(); if (!myOrigins.IsBound(aVSD)) { myOrigins.Bind(aVSD, aV); } } } }
//======================================================================= //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); }