PyObject* TopoShapeVertexPy::setTolerance(PyObject *args) { double tol; if (!PyArg_ParseTuple(args, "d", &tol)) return 0; BRep_Builder aBuilder; const TopoDS_Vertex& v = TopoDS::Vertex(getTopoShapePtr()->getShape()); aBuilder.UpdateVertex(v, tol); Py_Return; }
void TopoShapeVertexPy::setTolerance(Py::Float tol) { BRep_Builder aBuilder; const TopoDS_Vertex& v = TopoDS::Vertex(getTopoShapePtr()->getShape()); aBuilder.UpdateVertex(v, (double)tol); }
//======================================================================= //function : MergeEdges //purpose : auxilary //======================================================================= static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, const TopoDS_Face& aFace, const Standard_Real Tol, TopoDS_Edge& anEdge) { // make chain for union BRep_Builder B; ShapeAnalysis_Edge sae; TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1)); TopoDS_Edge LastE = FirstE; TopoDS_Vertex VF = sae.FirstVertex(FirstE); TopoDS_Vertex VL = sae.LastVertex(LastE); TopTools_SequenceOfShape aChain; aChain.Append(FirstE); TColStd_MapOfInteger IndUsedEdges; IndUsedEdges.Add(1); Standard_Integer j; for(j=2; j<=SeqEdges.Length(); j++) { for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) { if(IndUsedEdges.Contains(k)) continue; TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k)); TopoDS_Vertex VF2 = sae.FirstVertex(edge); TopoDS_Vertex VL2 = sae.LastVertex(edge); if(sae.FirstVertex(edge).IsSame(VL)) { aChain.Append(edge); LastE = edge; VL = sae.LastVertex(LastE); IndUsedEdges.Add(k); } else if(sae.LastVertex(edge).IsSame(VF)) { aChain.Prepend(edge); FirstE = edge; VF = sae.FirstVertex(FirstE); IndUsedEdges.Add(k); } } } if(aChain.Length()<SeqEdges.Length()) { MESSAGE ("can not create correct chain..."); return Standard_False; } // union edges in chain // first step: union lines and circles TopLoc_Location Loc; Standard_Real fp1,lp1,fp2,lp2; for(j=1; j<aChain.Length(); j++) { TopoDS_Edge edge1 = TopoDS::Edge(aChain.Value(j)); Handle(Geom_Curve) c3d1 = BRep_Tool::Curve(edge1,Loc,fp1,lp1); if(c3d1.IsNull()) break; while(c3d1->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(c3d1); c3d1 = tc->BasisCurve(); } TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1)); Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2); if(c3d2.IsNull()) break; while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(c3d2); c3d2 = tc->BasisCurve(); } if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) { // union lines Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1); Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); gp_Dir Dir1 = L1->Position().Direction(); gp_Dir Dir2 = L2->Position().Direction(); //if(!Dir1.IsEqual(Dir2,Precision::Angular())) { //if(!Dir1.IsParallel(Dir2,Precision::Angular())) { if(!Dir1.IsParallel(Dir2,Tol)) { continue; } // can union lines => create new edge TopoDS_Vertex V1 = sae.FirstVertex(edge1); gp_Pnt PV1 = BRep_Tool::Pnt(V1); TopoDS_Vertex V2 = sae.LastVertex(edge2); gp_Pnt PV2 = BRep_Tool::Pnt(V2); gp_Vec Vec(PV1,PV2); Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); Standard_Real dist = PV1.Distance(PV2); Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); TopoDS_Edge E; B.MakeEdge (E,tc,Precision::Confusion()); B.Add (E,V1); B.Add (E,V2); B.UpdateVertex(V1, 0., E, 0.); B.UpdateVertex(V2, dist, E, 0.); //ShapeFix_Edge sfe; //sfe.FixAddPCurve(E,aFace,Standard_False); //sfe.FixSameParameter(E); aChain.Remove(j); aChain.SetValue(j,E); j--; } if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) { // union circles Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1); Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); gp_Pnt P01 = C1->Location(); gp_Pnt P02 = C2->Location(); if (P01.Distance(P02) > Precision::Confusion()) continue; // can union circles => create new edge TopoDS_Vertex V1 = sae.FirstVertex(edge1); gp_Pnt PV1 = BRep_Tool::Pnt(V1); TopoDS_Vertex V2 = sae.LastVertex(edge2); gp_Pnt PV2 = BRep_Tool::Pnt(V2); TopoDS_Vertex VM = sae.LastVertex(edge1); gp_Pnt PVM = BRep_Tool::Pnt(VM); GC_MakeCircle MC (PV1,PVM,PV2); Handle(Geom_Circle) C = MC.Value(); TopoDS_Edge E; if (!MC.IsDone() || C.IsNull()) { // jfa for Mantis issue 0020228 if (PV1.Distance(PV2) > Precision::Confusion()) continue; // closed chain C = C1; B.MakeEdge (E,C,Precision::Confusion()); B.Add(E,V1); B.Add(E,V2); } else { gp_Pnt P0 = C->Location(); gp_Dir D1(gp_Vec(P0,PV1)); gp_Dir D2(gp_Vec(P0,PV2)); Standard_Real fpar = C->XAxis().Direction().Angle(D1); if(fabs(fpar)>Precision::Confusion()) { // check orientation gp_Dir ND = C->XAxis().Direction().Crossed(D1); if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { fpar = -fpar; } } Standard_Real lpar = C->XAxis().Direction().Angle(D2); if(fabs(lpar)>Precision::Confusion()) { // check orientation gp_Dir ND = C->XAxis().Direction().Crossed(D2); if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { lpar = -lpar; } } if(lpar<fpar) lpar += 2*M_PI; Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); B.MakeEdge (E,tc,Precision::Confusion()); B.Add(E,V1); B.Add(E,V2); B.UpdateVertex(V1, fpar, E, 0.); B.UpdateVertex(V2, lpar, E, 0.); } aChain.Remove(j); aChain.SetValue(j,E); j--; } } if (j < aChain.Length()) { MESSAGE ("null curve3d in edge..."); return Standard_False; } if (aChain.Length() > 1) { // second step: union edges with various curves // skl for bug 0020052 from Mantis: perform such unions // only if curves are bspline or bezier bool NeedUnion = true; for(j=1; j<=aChain.Length(); j++) { TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1); if(c3d.IsNull()) continue; while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(c3d); c3d = tc->BasisCurve(); } if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue; NeedUnion = false; break; } if(NeedUnion) { MESSAGE ("can not make analitical union => make approximation"); TopoDS_Wire W; B.MakeWire(W); for(j=1; j<=aChain.Length(); j++) { TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); B.Add(W,edge); } Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); Handle(Geom_BSplineCurve) bc = Conv.Curve(); TopoDS_Edge E; B.MakeEdge (E,bc,Precision::Confusion()); B.Add (E,VF); B.Add (E,VL); aChain.SetValue(1,E); } else { MESSAGE ("can not make approximation for such types of curves"); return Standard_False; } } anEdge = TopoDS::Edge(aChain.Value(1)); return Standard_True; }
//======================================================================= // function: PerformVE // purpose: //======================================================================= void NMTTools_PaveFiller::PerformVE() { myIsDone=Standard_False; // Standard_Boolean bJustAdd; Standard_Integer n1, n2, anIndexIn, aFlag, aWhat; Standard_Integer aWith, aNbVEs, aBlockLength, iSDV, nV1; Standard_Real aT; #if OCC_VERSION_LARGE > 0x06030008 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method Standard_Boolean bToUpdateVertex; Standard_Real aDist; #endif TopoDS_Vertex aV1; TopoDS_Edge aE2; BOPTools_IndexedMapOfCoupleOfInteger aSnareMap; BOPTools_CoupleOfInteger aCouple; // BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences(); // myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE); // // BlockLength correction aNbVEs=myDSIt->BlockLength(); aBlockLength=aVEs.BlockLength(); if (aNbVEs > aBlockLength) { aVEs.SetBlockLength(aNbVEs); } // for (; myDSIt->More(); myDSIt->Next()) { myDSIt->Current(n1, n2, bJustAdd); if (!IsSuccessorsComputed(n1, n2)) { anIndexIn=0; aWhat=n1; // Vertex aWith=n2; // Edge if (myDS->GetShapeType(n1)==TopAbs_EDGE) { aWhat=n2; aWith=n1; } // if(bJustAdd) { continue; } // Edge aE2=TopoDS::Edge(myDS->Shape(aWith)); if (BRep_Tool::Degenerated(aE2)){ continue; } // Vertex nV1=aWhat; aV1=TopoDS::Vertex(myDS->Shape(aWhat)); // iSDV=FindSDVertex(aWhat); if (iSDV) { nV1=iSDV; aV1=TopoDS::Vertex(myDS->Shape(nV1)); // Modified to find same domain vertex Thu Sep 14 14:35:18 2006 // Contribution of Samtech www.samcef.com BEGIN Standard_Integer nVE, iSDVE, iRet; // BooleanOperations_OnceExplorer aExp(*myDS); iRet=0; aExp.Init(aWith, TopAbs_VERTEX); for (; aExp.More(); aExp.Next()) { nVE=aExp.Current(); iSDVE=FindSDVertex(nVE); if (iSDVE==iSDV) { iRet=1; break; } } if (iRet) { continue; } } else { if (Contains(aE2, aV1)) { continue; } // Contribution of Samtech www.samcef.com END } // //modified by NIZNHY-PKV Mon Dec 28 08:58:05 2009f #if OCC_VERSION_LARGE > 0x06030008 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method aFlag = myContext->ComputeVE (aV1, aE2, aT, bToUpdateVertex, aDist); #else aFlag = myContext->ComputeVE (aV1, aE2, aT); #endif //modified by NIZNHY-PKV Mon Dec 28 08:58:13 2009t // if (!aFlag) { // Add Interference to the Pool BOPTools_VEInterference anInterf (aWhat, aWith, aT); anIndexIn=aVEs.Append(anInterf); // // Add Pave to the Edge's myPavePool aCouple.SetCouple(nV1, aWith); if (!aSnareMap.Contains(aCouple)){ aSnareMap.Add(aCouple); // BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge); aPave.SetInterference(anIndexIn); BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith)); aPaveSet.Append(aPave); } // // State for the Vertex in DS; myDS->SetState (aWhat, BooleanOperations_ON); // Insert Vertex in Interference Object BOPTools_VEInterference& aVE=aVEs(anIndexIn); aVE.SetNewShape(aWhat); // myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE); // //modified by NIZNHY-PKV Mon Dec 28 09:00:54 2009f #if OCC_VERSION_LARGE > 0x06030008 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method if (bToUpdateVertex) { BRep_Builder aBB; // aBB.UpdateVertex(aV1, aDist); } #endif //modified by NIZNHY-PKV Mon Dec 28 09:00:57 2009t // } //if (!aFlag) { } } myIsDone=Standard_True; }