bool Edgecluster::PerformEdges(gp_Pnt& point) { tMapPntEdge::iterator iter = m_vertices.find(point); if ( iter == m_vertices.end() ) return false; tEdgeVector& edges = iter->second; tEdgeVector::iterator edgeIt = edges.begin(); //no more edges. pb if ( edgeIt == edges.end() ) { //Delete also the current vertex m_vertices.erase(iter); return false; } TopoDS_Edge theEdge = *edgeIt; //we are storing the edge, so remove it from the vertex association edges.erase(edgeIt); //if no more edges, remove the vertex if ( edges.empty() ) m_vertices.erase(iter); TopoDS_Vertex V1,V2; TopExp::Vertices(theEdge,V1,V2); gp_Pnt P1 = BRep_Tool::Pnt(V1); gp_Pnt P2 = BRep_Tool::Pnt(V2); if ( theEdge.Orientation() == TopAbs_REVERSED ) { //switch the points gp_Pnt tmpP = P1; P1 = P2; P2 = tmpP; } gp_Pnt nextPoint; if ( P2.IsEqual(point,0.2) ) { //need to reverse the edge theEdge.Reverse(); nextPoint = P1; } else { nextPoint = P2; } //need to erase the edge from the second point iter = m_vertices.find(nextPoint); if ( iter != m_vertices.end() ) { tEdgeVector& nextEdges = iter->second; for ( edgeIt = nextEdges.begin() ; edgeIt != nextEdges.end(); ++edgeIt ) { if ( theEdge.IsSame(*edgeIt) ) { nextEdges.erase(edgeIt); break; } } } //put the edge at the end of the list m_edges.push_back(theEdge); //Update the point for the next do-while loop point = nextPoint; return true; }
//======================================================================= //function : GetApproxNormalToFaceOnEdge //purpose : //======================================================================= void GetApproxNormalToFaceOnEdge (const TopoDS_Edge& aEx, const TopoDS_Face& aFx, Standard_Real aT, gp_Pnt& aPF, gp_Dir& aDNF, IntTools_Context& aCtx) { Standard_Boolean bReverse; Standard_Real aT1, aT2, dT, aU, aV; gp_Dir aDTT, aDNFT, aDBT; gp_Pnt aPFT, aPFx; Handle(Geom_Curve) aC3D; Handle(Geom_Surface) aS; GeomAdaptor_Surface aGAS; GeomAbs_SurfaceType aTS; TopoDS_Face aF; TopoDS_Edge aE; // bReverse=Standard_False; aF=aFx; aE=aEx; if (aF.Orientation()==TopAbs_REVERSED){ bReverse=!bReverse; aE.Reverse(); // aF.Orientation(TopAbs_FORWARD); } // // Point at aT aC3D =BRep_Tool::Curve(aE, aT1, aT2); aC3D->D0(aT, aPFT); // // Normal at aT BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNFT); // Tangent at aT BOPTools_Tools3D::GetTangentToEdge(aE, aT, aDTT); // // Binormal at aT aDBT=aDNFT^aDTT; // dT=BOPTools_Tools3D::MinStepIn2d();//~1.e-5; dT=10.*dT; //---------------------------------------------- { aS=BRep_Tool::Surface(aF); aGAS.Load(aS); aTS=aGAS.GetType(); if (aTS==GeomAbs_BSplineSurface || aTS==GeomAbs_BezierSurface || aTS==GeomAbs_Plane) { Standard_Real aTolEx, aTolFx, aTol, dUR, dVR, dR; // aTolEx=BRep_Tool::Tolerance(aEx); aTolFx=BRep_Tool::Tolerance(aFx); aTol=2.*aTolEx+aTolFx; dUR=aGAS.UResolution(aTol); dVR=aGAS.VResolution(aTol); dR=(dUR>dVR)? dUR : dVR; if (dR>dT) { dT=dR; } } //modified by NIZNHY-PKV Thu Dec 02 10:39:09 2010f else if (GeomAbs_Torus || aTS==GeomAbs_Cylinder){ Standard_Real aTolEx, aTolFx, aTol; // aTolEx=BRep_Tool::Tolerance(aEx); aTolFx=BRep_Tool::Tolerance(aFx); aTol=2.*aTolEx+aTolFx; if (aTol>dT) { dT=aTol; } } //modified by NIZNHY-PKV Thu Dec 02 10:39:13 2010t } //---------------------------------------------- // aPFx.SetXYZ(aPFT.XYZ()+dT*aDBT.XYZ()); // aPF=aPFx; aDNF=aDNFT; if (bReverse) { aDNF.Reverse(); } // GeomAPI_ProjectPointOnSurf& aProjector=aCtx.ProjPS(aF); // aProjector.Perform(aPFx); if(aProjector.IsDone()) { aProjector.LowerDistanceParameters (aU, aV); aS->D0(aU, aV, aPF); BOPTools_Tools3D::GetNormalToSurface (aS, aU, aV, aDNF); if (bReverse){ aDNF.Reverse(); } } }