#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <TopTools_MapOfShape.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <Geom2dAPI_ProjectPointOnCurve.hxx>
+
+#include <Geom_Surface.hxx>
static Standard_Boolean IsInside(const TopoDS_Face&,
const TopoDS_Wire&,
const TopTools_IndexedMapOfShape&,
TopoDS_Edge&,
gp_Pnt2d&,
- gp_Vec2d&,
- const Standard_Real tol);
+ gp_Vec2d&);
static TopoDS_Shape ChooseDirection(const TopoDS_Shape&,
const TopoDS_Vertex&,
return Standard_True;
}
+//=======================================================================
+//function : checkOverlapping
+//purpose :
+//=======================================================================
+
+static Standard_Boolean checkOverlapping(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2,
+ const TopoDS_Face& theFace)
+{
+
+ BRepAdaptor_Surface anAdS(theFace,Standard_False );
+
+ Standard_Real MaxTol = (BRep_Tool::Tolerance(theEdge1) + BRep_Tool::Tolerance(theEdge2));
+
+ Standard_Real aMaxTol2d = Max(anAdS.UResolution(MaxTol),anAdS.VResolution(MaxTol));
+ Standard_Real aTolAng = M_PI/180.;
+ Geom2dAPI_ProjectPointOnCurve proj;
+ Standard_Real aF1, aL1,aF2, aL2;
+
+ Handle(Geom2d_Curve) aCrv1 = BRep_Tool::CurveOnSurface(theEdge1, theFace, aF1, aL1);
+ Handle(Geom2d_Curve) aCrv2 = BRep_Tool::CurveOnSurface(theEdge2, theFace, aF2, aL2);
+ Standard_Integer j =1, nbP = 4;
+ Standard_Real aStep = ( aL2 - aF2)/nbP;
+ for( ; j < nbP; j++)
+ {
+ Standard_Real par2 = aF2 + aStep * j;
+ gp_Pnt2d aP2d;
+ gp_Vec2d aV2;
+ aCrv2->D1(par2, aP2d, aV2);
+
+ proj.Init(aP2d,aCrv1, aF1, aL1);
+ //check intermediate points
+ if(!proj.NbPoints() || proj.LowerDistance() > aMaxTol2d)
+ return Standard_False;
+ Standard_Real par1 = proj.LowerDistanceParameter();
+ gp_Pnt2d aP2d1;
+ gp_Vec2d aV1;
+ aCrv1->D1(par1, aP2d1, aV1);
+
+ if( !aV1.IsParallel(aV2, aTolAng))
+ return Standard_False;
+ }
+ return Standard_True;
+
+}
//=======================================================================
//function : AddOpenWire
TopoDS_Shape aLocalFaceTemp = FaceRef.Oriented(wfirst.Orientation());
if(!ChoixUV(LastEdge, TopoDS::Face(aLocalFaceTemp), PossE,
- aNextEdge, plast, dlast, toll))
+ aNextEdge, plast, dlast))
return Standard_False;
}
tol1 = Max(BAS.UResolution(tol1), BAS.VResolution(tol1));
}
-
+
+ Standard_Integer nbAddBound =0;
TopTools_ListIteratorOfListOfShape lexp(WiresFirst);
+ TopoDS_Shape anE1, anE2;
for (; lexp.More(); lexp.Next()) {
const TopoDS_Edge& edg = TopoDS::Edge(lexp.Value());
if (!MapE.Contains(edg)) {
B.Add(newW2,edg);
MapE.Add(edg);
+ nbAddBound++;
+ if(anE1.IsNull())
+ anE1 = edg;
+ else
+ anE2 = edg;
+
}
}
-
+ //check overlapping edges for second face
+ if(nbAddBound <2)
+ return Standard_False;
+ if(nbAddBound ==2 && !anE1.IsNull() && !anE2.IsNull())
+ {
+ if(checkOverlapping(TopoDS::Edge(anE1), TopoDS::Edge(anE2),FaceRef ))
+ return Standard_False;
+
+ }
+
+ nbAddBound =0;
+
+ TopoDS_Shape anE11, anE12;
+ TopoDS_Iterator anItE(newW1, Standard_False);
+ for( ; anItE.More(); anItE.Next())
+ {
+ if( anItE.Value().ShapeType() != TopAbs_EDGE)
+ continue;
+ nbAddBound++;
+ if(anE11.IsNull())
+ anE11 = anItE.Value();
+ else
+ anE12 = anItE.Value();
+
+ }
+ //check overlapping edges for first face
+ if(nbAddBound <2)
+ return Standard_False;
+ if(nbAddBound ==2 && !anE11.IsNull() && !anE12.IsNull())
+ {
+ if(checkOverlapping(TopoDS::Edge(anE11), TopoDS::Edge(anE12), FaceRef))
+ return Standard_False;
+
+ }
+
TopoDS_Face newF1,newF2;
aLocalFace = FaceRef.EmptyCopied();
newF1 = TopoDS::Face(aLocalFace);
}
}
+static void updateToleraces(const TopoDS_Face& theFace, const TopTools_DataMapOfShapeListOfShape& theMap)
+{
+ TopExp_Explorer aExpE(theFace, TopAbs_EDGE);
+ for (; aExpE.More(); aExpE.Next())
+ {
+ if (!theMap.IsBound(aExpE.Current()))
+ continue;
+ const TopTools_ListOfShape& lEdges = theMap(aExpE.Current());
+ if (lEdges.Extent() <= 1)
+ continue;
+
+ TopTools_ListIteratorOfListOfShape itrE(lEdges);
+ ShapeAnalysis_Edge aSae;
+
+ for (; itrE.More(); itrE.Next())
+ {
+ TopoDS_Edge aCurE = TopoDS::Edge(itrE.Value());
+ Standard_Real amaxdev = 0.;
+ if (aSae.CheckSameParameter(aCurE, theFace, amaxdev))
+ {
+ BRep_Builder aB;
+ aB.UpdateEdge(aCurE, amaxdev);
+ }
+ }
+ }
+}
//=======================================================================
//function : Rebuild
//purpose :
Standard_Boolean LocOpe_SplitShape::Rebuild(const TopoDS_Shape& S)
{
-
+ if (S.ShapeType() == TopAbs_FACE)
+ updateToleraces(TopoDS::Face(S), myMap);
TopTools_ListIteratorOfListOfShape itr(myMap(S));
if (itr.More()) {
if (itr.Value().IsSame(S)) {
const TopTools_IndexedMapOfShape& Poss,
TopoDS_Edge& theResEdge,
gp_Pnt2d& plst,
- gp_Vec2d& dlst,
- const Standard_Real toll)
+ gp_Vec2d& dlst)
{
gp_Pnt2d p2d;
gp_Vec2d v2d;
BRepAdaptor_Surface surf(F,Standard_False); // no restriction
surf.D0 (plst.X(), plst.Y(), aPlst);
- Standard_Real tol;
-
gp_Dir2d ref2d(dlst);
Handle(Geom2d_Curve) C2d;
Standard_Integer index = 0, imin=0;
- Standard_Real angmax = -M_PI, dist, ang;
+ Standard_Real angmax = -M_PI, ang;
for (index = 1; index <= Poss.Extent(); index++) {
TopoDS_Edge anEdge = TopoDS::Edge (Poss.FindKey (index));
- TopoDS_Vertex aVF = TopExp::FirstVertex(anEdge, Standard_True);
- if( aVF.IsNull())
- return 0;
- tol = BRep_Tool::Tolerance(aVF);
- GetDirection (anEdge, F, p2d, v2d, Standard_True);
+ GetDirection(anEdge, F, p2d, v2d, Standard_True);
surf.D0 (p2d.X(), p2d.Y(), aPCur);
- tol = Max(toll, tol); tol *= tol;
-
- dist = aPCur.SquareDistance(aPlst);
-
if (!Last.IsSame(anEdge)) {
ang = ref2d.Angle(gp_Dir2d(v2d));
}
ang = -M_PI;
}
- if ((dist - tol < Epsilon(1.0)) && (ang > angmax)) {
+ if ( (ang > angmax)) {
imin = index;
angmax = ang;
}
if (imin)
{
theResEdge = TopoDS::Edge (Poss.FindKey (imin));
- GetDirection (theResEdge, F, plst, dlst, Standard_False);
+ GetDirection(theResEdge, F, plst, dlst, Standard_False);
}
return (imin);
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
+#include <TopTools_DataMapOfShapeReal.hxx>
+#include <Extrema_ExtCC2d.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+
+#include <TopTools_SequenceOfShape.hxx>
+#include <BRepBndLib.hxx>
+#include <Bnd_Box.hxx>
+#include <Bnd_SeqOfBox.hxx>
+#include <NCollection_Handle.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
+#include <Extrema_ExtPS.hxx>
+
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <ShapeConstruct_ProjectCurveOnSurface.hxx>
IMPLEMENT_STANDARD_RTTIEXT(LocOpe_WiresOnShape,MMgt_TShared)
static void FindInternalIntersections(const TopoDS_Edge&,
const TopoDS_Face&,
- TopTools_IndexedDataMapOfShapeListOfShape&);
+ TopTools_IndexedDataMapOfShapeListOfShape&,
+ Standard_Boolean&);
//=======================================================================
//function : LocOpe_WiresOnShape
myShape(S),myCheckInterior(Standard_True),myDone(Standard_False)
{}
-
-
//=======================================================================
//function : Init
//purpose :
myMapEF.Clear();
}
-
-
//=======================================================================
//function : Bind
//purpose :
TopTools_IndexedDataMapOfShapeListOfShape Splits;
Standard_Integer Ind;
+ TopTools_MapOfShape anOverlappedEdges;
for (Ind = 1; Ind <= myMapEF.Extent(); Ind++)
{
const TopoDS_Edge& edg = TopoDS::Edge(myMapEF.FindKey(Ind));
continue;
if (myCheckInterior)
- FindInternalIntersections(edg, fac, Splits);
+ {
+ Standard_Boolean isOverlapped = Standard_False;
+ FindInternalIntersections(edg, fac, Splits, isOverlapped);
+ if(isOverlapped)
+ anOverlappedEdges.Add(edg);
+ }
}
for (Ind = 1; Ind <= Splits.Extent(); Ind++)
{
TopoDS_Shape anEdge = Splits.FindKey(Ind);
+ if(anOverlappedEdges.Contains(anEdge))
+ continue;
TopoDS_Shape aFace = myMapEF.FindFromKey(anEdge);
//Remove "anEdge" from "myMapEF"
TopoDS_Shape LastEdge = myMapEF.FindKey(myMapEF.Extent());
for (; itl.More(); itl.Next())
myMapEF.Add(itl.Value(), aFace);
}
-
-
+
+ TopTools_DataMapOfShapeReal aVertParam;
+
for (Ind = 1; Ind <= myMapEF.Extent(); Ind++) {
const TopoDS_Edge& edg = TopoDS::Edge(myMapEF.FindKey(Ind));
const TopoDS_Face& fac = TopoDS::Face(myMapEF(Ind));
Standard_Real vtx_param = BRep_Tool::Parameter(vtx, edg);
BRepAdaptor_Curve2d BAcurve2d(edg, fac);
- gp_Pnt2d p2d = BAcurve2d.Value(vtx_param);
+
+ gp_Pnt2d p2d = (!BAcurve2d.Curve().IsNull() ?
+ BAcurve2d.Value(vtx_param) : gp_Pnt2d(Precision::Infinite(), Precision::Infinite()));
TopoDS_Edge Epro;
- Standard_Real prm = 0.;
+ Standard_Real prm = Precision::Infinite();
+ Standard_Boolean isProjected = myMap.IsBound(vtx);
+
+ //if vertex was already projected on the current edge on the previous face
+ //it is necessary to check tolerance of the vertex in the 2D space on the current
+ //face without projection and update tolerance of vertex if it is necessary
+ if (isProjected)
+ {
+ TopoDS_Shape aSh = myMap.Find(vtx);
+ if (aSh.ShapeType() != TopAbs_EDGE)
+ continue;
+ Epro = TopoDS::Edge(myMap.Find(vtx));
+ if (aVertParam.IsBound(vtx))
+ prm = aVertParam.Find(vtx);
+ }
Standard_Boolean ok = Project(vtx, p2d, fac, Epro, prm);
- if (ok) {
-
- for (exp2.Init(Epro,TopAbs_VERTEX); exp2.More(); exp2.Next()) {
- const TopoDS_Vertex& vtx2 = TopoDS::Vertex(exp2.Current());
- if (vtx2.IsSame(vtx)) {
- break;
- }
- else if (BRepTools::Compare(vtx,vtx2)) {
+ if (ok && !isProjected) {
+
+ for (exp2.Init(Epro, TopAbs_VERTEX); exp2.More(); exp2.Next()) {
+ const TopoDS_Vertex& vtx2 = TopoDS::Vertex(exp2.Current());
+ if (vtx2.IsSame(vtx)) {
+ myMap.Bind(vtx, vtx2);
+ theMap.Add(vtx);
+ break;
+ }
+ else if (BRepTools::Compare(vtx, vtx2)) {
Standard_Real aF1, aL1;
BRep_Tool::Range(Epro, fac, aF1, aL1);
- if (!BRep_Tool::Degenerated(Epro) ||
- Abs(prm-aF1) <= Precision::PConfusion() ||
- Abs(prm-aL1) <= Precision::PConfusion())
+ if (!BRep_Tool::Degenerated(Epro) && (
+ Abs(prm - aF1) <= Precision::PConfusion() ||
+ Abs(prm - aL1) <= Precision::PConfusion()))
{
- myMap.Bind(vtx,vtx2);
+ myMap.Bind(vtx, vtx2);
+ theMap.Add(vtx);
break;
}
- }
- }
+ }
+ }
if (!exp2.More()) {
myMap.Bind(vtx,Epro);
- }
- theMap.Add(vtx);
+ aVertParam.Bind(vtx, prm);
+ }
}
}
}
return Standard_False;
TopoDS_Shape aShape = myMapEF.FindFromKey(EdgeFrom);
- if( aShape.ShapeType() == TopAbs_FACE)
+ Standard_Real aF, aL;
+ Handle(Geom_Curve) aC = BRep_Tool::Curve(Ed, aF, aL);
+ if (aC.IsNull() && aShape.ShapeType() == TopAbs_FACE)
{
TopoDS_Face aFace = TopoDS::Face(aShape);
TopoDS_Edge& theEdge,
Standard_Real& param)
{
- Handle(Geom2d_Curve) PC;
- //TopLoc_Location Loc;
- Standard_Real f,l;
-
- Standard_Real dmin = RealLast();
- //gp_Pnt toproj(BRep_Tool::Pnt(V));
+ Standard_Real aTolV = BRep_Tool::Tolerance(V);
+ Standard_Real dmin = (theEdge.IsNull() ? RealLast() : aTolV * aTolV);
+
Standard_Boolean valret = Standard_False;
- Geom2dAPI_ProjectPointOnCurve proj;
+
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
+
+ if (theEdge.IsNull())
+ {
+ gp_Pnt toproj(BRep_Tool::Pnt(V));
+ for (TopExp_Explorer exp(F.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
+ exp.More(); exp.Next()) {
+ const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
+ Standard_Real f, l;
+ Handle(Geom_Curve) C = BRep_Tool::Curve(edg, f, l);
+ Standard_Real aCurDist = Precision::Infinite();
+ Standard_Real aCurPar = Precision::Infinite();
+ if (!C.IsNull())
+ {
+ aCurPar = Project(V, edg);
+ if (Precision::IsInfinite(aCurPar))
+ continue;
+ gp_Pnt aCurPBound;
+ C->D0(aCurPar, aCurPBound);
+ aCurDist = aCurPBound.SquareDistance(toproj);
+ }
- for (TopExp_Explorer exp(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
- exp.More(); exp.Next()) {
- const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
- //C = BRep_Tool::Curve(edg,Loc,f,l);
- PC = BRep_Tool::CurveOnSurface(edg, F, f, l);
- proj.Init(p2d, PC, f, l);
- if (proj.NbPoints() > 0) {
- if (proj.LowerDistance() < dmin) {
+ else if(!Precision::IsInfinite(p2d.X()))
+ {
+ //Geom2dAPI_ProjectPointOnCurve proj;
+ Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(edg,F , f, l);
+ if(aC2d.IsNull())
+ continue;
+
+ aCurPar = Project(V, p2d, edg, F);
+ if (Precision::IsInfinite(aCurPar))
+ continue;
+ Handle(Geom2d_Curve) PC = BRep_Tool::CurveOnSurface(edg, F, f, l);
+ gp_Pnt2d aPProj;
+ PC->D0(aCurPar, aPProj);
+ gp_Pnt aCurPBound;
+ aSurf->D0(aPProj.X(), aPProj.Y(), aCurPBound);
+ aCurDist = aCurPBound.SquareDistance(toproj);
+
+ }
+
+ if (aCurDist < dmin) {
theEdge = edg;
theEdge.Orientation(edg.Orientation());
- dmin = proj.LowerDistance();
- param = proj.LowerDistanceParameter();
+ dmin = aCurDist;
+ param = aCurPar;
+
}
+
}
+ if (theEdge.IsNull())
+ return Standard_False;
}
+ else if (Precision::IsInfinite(param))
+ {
+ Standard_Real f, l;
+ Handle(Geom_Curve) C = BRep_Tool::Curve(theEdge, f, l);
+ param = (!C.IsNull() ? Project(V, theEdge) : Project(V, p2d, theEdge, F));
- if(theEdge.IsNull())
- return Standard_False;
- //compute distance in 3D space
-
- Handle(Geom2d_Curve) aCrvBound = BRep_Tool::CurveOnSurface(theEdge, F, f, l);
- gp_Pnt2d aPBound2d;
- aCrvBound->D0(param,aPBound2d);
- gp_Pnt aPBound;
- Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
- aSurf->D0(aPBound2d.X(), aPBound2d.Y(), aPBound);
-
- //point of vertex computed by pcurve of the splitting edge
- gp_Pnt aPV2d;
- aSurf->D0(p2d.X(), p2d.Y(), aPV2d);
- //point of vertex in 3D splace
- gp_Pnt aP3dV = BRep_Tool::Pnt(V);
+ }
- Standard_Real aDist3d2 = Max( aPV2d.SquareDistance(aPBound), aP3dV.SquareDistance(aPBound));
- Standard_Real aTolV = BRep_Tool::Tolerance(V);
Standard_Real ttol = aTolV + BRep_Tool::Tolerance(theEdge);
- if (aDist3d2 <= ttol* ttol) {
+ if (dmin <= ttol* ttol) {
valret = Standard_True;
+ GeomAdaptor_Surface adSurf(aSurf);
- BRep_Builder B;
- if( aTolV * aTolV < aDist3d2)
+ Standard_Real anUResolution = adSurf.UResolution(1.);
+ Standard_Real aVResolution = adSurf.UResolution(1.);
+
+ Standard_Real f, l;
+ Handle(Geom2d_Curve) aCrvBound = BRep_Tool::CurveOnSurface(theEdge, F, f, l);
+ if (!aCrvBound.IsNull())
{
- Standard_Real aNewTol = sqrt(aDist3d2) + Precision::Confusion();
- B.UpdateVertex(V, aNewTol);
+ gp_Pnt2d aPBound2d;
+ aCrvBound->D0(param, aPBound2d);
+
+ //distance in 2D space recomputed in the 3D space in order to tolerance of vertex
+ //cover gap in 2D space. For consistency with check of the validity in the BRepCheck_Wire
+ Standard_Real aDist3d = p2d.Distance(aPBound2d) / Min(anUResolution, aVResolution);
+
+ gp_Pnt aPBound;
+ aSurf->D0(aPBound2d.X(), aPBound2d.Y(), aPBound);
+ gp_Pnt aPV2d;
+ aSurf->D0(p2d.X(), p2d.Y(), aPV2d);
+ Standard_Real aDistPoints_3D = aPV2d.SquareDistance(aPBound);
+ Standard_Real aDist2d = Max(aDistPoints_3D, aDist3d * aDist3d);
+
+ BRep_Builder B;
+ if (aTolV * aTolV < aDist2d)
+ {
+ Standard_Real aNewTol = sqrt(aDist2d) + Precision::Confusion();
+ B.UpdateVertex(V, aNewTol);
+ }
}
}
#ifdef OCCT_DEBUG_MESH
proj.Init(toproj,C,f,l);
- return proj.LowerDistanceParameter();
+
+ return (proj.NbPoints() > 0 ? proj.LowerDistanceParameter() : Precision::Infinite());
}
//=======================================================================
const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace)
{
- //Handle(Geom_Curve) C;
+
+
Handle(Geom2d_Curve) PC;
- //TopLoc_Location Loc;
- Standard_Real f,l;
+
+ Standard_Real f, l;
Geom2dAPI_ProjectPointOnCurve proj;
PC = BRep_Tool::CurveOnSurface(theEdge, theFace, f, l);
- /*
- if (!Loc.IsIdentity()) {
- Handle(Geom_Geometry) GG = C->Transformed(Loc.Transformation());
- C = Handle(Geom_Curve)::DownCast (GG);
- }
- */
+
proj.Init(p2d, PC, f, l);
- return proj.LowerDistanceParameter();
+ return proj.NbPoints() > 0 ? proj.LowerDistanceParameter() : Precision::Infinite();
}
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(Edg,Fac,f,l);
if ( !aC2d.IsNull() ) {
gp_Pnt2d p2d;
- aC2d->D0(f,p2d);
+ aC2d->D0((f + l) *0.5, p2d);
Standard_Boolean IsIn = Standard_True;
if ( ( p2d.X() < Umin-Precision::PConfusion() ) ||
( p2d.X() > Umax+Precision::PConfusion() ) )
if ( ( p2d.Y() < Vmin-Precision::PConfusion() ) ||
( p2d.Y() > Vmax+Precision::PConfusion() ) )
IsIn = Standard_False;
- aC2d->D0(l,p2d);
- if ( ( p2d.X() < Umin-Precision::PConfusion() ) ||
- ( p2d.X() > Umax+Precision::PConfusion() ) )
- IsIn = Standard_False;
- if ( ( p2d.Y() < Vmin-Precision::PConfusion() ) ||
- ( p2d.Y() > Vmax+Precision::PConfusion() ) )
- IsIn = Standard_False;
+
if (IsIn)
return;
}
S = BRep_Tool::Surface(Fac);
- // Compute the tol2d
- Standard_Real tol3d = Max(BRep_Tool::Tolerance(Edg),
- BRep_Tool::Tolerance(Fac));
- GeomAdaptor_Surface Gas(S,Umin,Umax,Vmin,Vmax);
- Standard_Real TolU = Gas.UResolution(tol3d);
- Standard_Real TolV = Gas.VResolution(tol3d);
- Standard_Real tol2d = Max(TolU,TolV);
-
- Handle(Geom2d_Curve) C2d =
- GeomProjLib::Curve2d(C,S,Umin,Umax,Vmin,Vmax,tol2d);
- if(C2d.IsNull())
- return;
+ Standard_Real tol2d = Precision::Confusion();
+ Handle(Geom2d_Curve) C2d;
+ ShapeConstruct_ProjectCurveOnSurface aToolProj;
+ aToolProj.Init(S, tol2d);
+
+ aToolProj.Perform(C,f,l, C2d);
+ if (C2d.IsNull())
+ {
+ return;
+ }
+
gp_Pnt2d pf(C2d->Value(f));
gp_Pnt2d pl(C2d->Value(l));
gp_Pnt PF,PL;
nbtra--;
}
}
-/*
- if (theVmin > Vmax-tolv) {
- while (theVmin > Vmax-tolv) {
- theVmin -= vp;
- nbtra--;
- }
- }
- else if (theVmax < Vmin+tolv) {
- while (theVmax < Vmin+tolv) {
- theVmax += vp;
- nbtra++;
- }
- }
-*/
+
if (nbtra !=0) {
C2d->Translate(gp_Vec2d(0.,nbtra*vp));
}
void FindInternalIntersections(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
- TopTools_IndexedDataMapOfShapeListOfShape& Splits)
+ TopTools_IndexedDataMapOfShapeListOfShape& Splits,
+ Standard_Boolean& isOverlapped)
{
Standard_Real TolExt = Precision::PConfusion();
- Standard_Integer i, j, aNbExt;
+ Standard_Integer i, j;
+ BRepAdaptor_Surface anAdSurf(theFace, Standard_False);
TColStd_SequenceOfReal SplitPars;
TopoDS_Vertex theVertices [2];
GeomAdaptor_Curve aGAcurve(aCurve, aFpar, aLpar);
Extrema_ExtCC anExtrema(theGAcurve, aGAcurve, TolExt, TolExt);
- if (!anExtrema.IsDone())
+ if (!anExtrema.IsDone() || !anExtrema.NbExt())
continue;
- if (anExtrema.IsParallel())
- continue;
-
- aNbExt = anExtrema.NbExt();
- Standard_Real MaxTol = Max(BRep_Tool::Tolerance(theEdge), BRep_Tool::Tolerance(anEdge));
+
+ Standard_Integer aNbExt = anExtrema.NbExt();
+ Standard_Real MaxTol = BRep_Tool::Tolerance(anEdge);
Standard_Real aMaxTol2 = MaxTol * MaxTol;
+ if (anExtrema.IsParallel() && anExtrema.SquareDistance(1) <= aMaxTol2)
+ {
+ isOverlapped = Standard_True;
+ return;
+ }
for (i = 1; i <= aNbExt; i++)
{
Standard_Real aDist = anExtrema.SquareDistance(i);
if (j >= 2) //intersection is inside "theEdge" => split
{
gp_Pnt aPoint = aCurve->Value(anIntPar);
- if (aPoint.SquareDistance(thePnt[0]) > aTolV[0] * aTolV[0] &&
- aPoint.SquareDistance(thePnt[1]) > aTolV[1] * aTolV[1])
+ gp_Pnt aPointInt = theCurve->Value(theIntPar);
+
+ if (aPointInt.SquareDistance(thePnt[0]) > aTolV[0] * aTolV[0] &&
+ aPointInt.SquareDistance(thePnt[1]) > aTolV[1] * aTolV[1] &&
+ aPoint.SquareDistance(thePnt[0]) > aTolV[0] * aTolV[0] &&
+ aPoint.SquareDistance(thePnt[1]) > aTolV[1] * aTolV[1])
{
SplitPars.Append(theIntPar);
if( aDist > aDistMax)
BB.Add(NewEdge, FirstVertex);
BB.Add(NewEdge, LastVertex);
NewEdge.Orientation(anOrient);
- NewEdges.Append(NewEdge);
+ ShapeAnalysis_Edge aSae;
+ Standard_Real amaxdev =0.;
+ if (aSae.CheckSameParameter(NewEdge, theFace, amaxdev))
+ {
+ BRep_Builder aB;
+ aB.UpdateEdge(NewEdge, amaxdev);
+ }
+
+ if (anOrient == TopAbs_FORWARD)
+ NewEdges.Append(NewEdge);
+ else
+ NewEdges.Prepend(NewEdge);
FirstVertex = LastVertex;
FirstPar = LastPar;
}
if (!NewEdges.IsEmpty())
Splits.Add(theEdge, NewEdges);
}
+
+//=======================================================================
+//function : AddSplittingEdges
+//purpose :
+//=======================================================================
+
+Standard_Boolean LocOpe_WiresOnShape::Add(const TopTools_SequenceOfShape& theEdges)
+{
+ TopTools_SequenceOfShape anEdges;
+ Bnd_SeqOfBox anEdgeBoxes;
+ Standard_Integer i = 1, nb = theEdges.Length();
+ for (; i <= nb; i++)
+ {
+ const TopoDS_Shape& aCurSplit = theEdges(i);
+ TopExp_Explorer anExpE(aCurSplit, TopAbs_EDGE);
+ for (; anExpE.More(); anExpE.Next())
+ {
+ const TopoDS_Shape& aCurE = anExpE.Current();
+
+ Bnd_Box aBoxE;
+ BRepBndLib::AddClose(aCurE, aBoxE);
+ if (aBoxE.IsVoid())
+ continue;
+ Standard_Real aTolE = BRep_Tool::Tolerance(TopoDS::Edge(aCurE));
+ aBoxE.SetGap(aTolE);
+ anEdgeBoxes.Append(aBoxE);
+ anEdges.Append(aCurE);
+
+ }
+ }
+ TopExp_Explorer anExpFaces(myShape, TopAbs_FACE);
+ Standard_Integer numF = 1;
+ TColStd_PackedMapOfInteger anUsedEdges;
+ for (; anExpFaces.More(); anExpFaces.Next(), numF++)
+ {
+ const TopoDS_Face& aCurF = TopoDS::Face(anExpFaces.Current());
+ Bnd_Box aBoxF;
+ BRepBndLib::Add(aCurF, aBoxF);
+ if (aBoxF.IsVoid())
+ continue;
+ BRepAdaptor_Surface anAdF(aCurF, Standard_False);
+ NCollection_Handle<BRepTopAdaptor_FClass2d> aCheckStateTool;
+
+ i = 1;
+ nb = anEdgeBoxes.Length();
+ for (; i <= nb; i++)
+ {
+ if (anUsedEdges.Contains(i))
+ continue;
+
+ if (aBoxF.IsOut(anEdgeBoxes(i)))
+ continue;
+
+ const TopoDS_Edge& aCurE = TopoDS::Edge(anEdges(i));
+
+ Standard_Real aF, aL;
+ Handle(Geom_Curve) aC = BRep_Tool::Curve(aCurE, aF, aL);
+ if (aC.IsNull())
+ {
+ anUsedEdges.Add(i);
+ continue;
+ }
+ gp_Pnt aP = aC->Value((aF + aL)* 0.5);
+ Extrema_ExtPS anExtr(aP, anAdF, Precision::Confusion(), Precision::Confusion());
+
+ if (!anExtr.IsDone() || !anExtr.NbExt())
+ continue;
+ Standard_Real aTolE = BRep_Tool::Tolerance(TopoDS::Edge(aCurE));
+ Standard_Real aTol2 = (aTolE + Precision::Confusion()) * (aTolE + Precision::Confusion());
+ Standard_Integer n = 1;
+ for (; n <= anExtr.NbExt(); n++)
+ {
+ Standard_Real aDist2 = anExtr.SquareDistance(n);
+ if (aDist2 > aTol2)
+ continue;
+ const Extrema_POnSurf& aPS = anExtr.Point(n);
+ Standard_Real aU, aV;
+ aPS.Parameter(aU, aV);
+
+ if (aCheckStateTool.IsNull())
+ {
+ aCheckStateTool = new BRepTopAdaptor_FClass2d(aCurF, Precision::PConfusion());
+ }
+ if (aCheckStateTool->Perform(gp_Pnt2d(aU, aV)) == TopAbs_IN)
+ {
+ Bind(aCurE, aCurF);
+ anUsedEdges.Add(i);
+ }
+
+ }
+ }
+
+ }
+ return (anUsedEdges.Extent());
+}