From c2fd3dc272eeea6c21a333b3768d377fea0ca479 Mon Sep 17 00:00:00 2001 From: nbv Date: Wed, 2 Apr 2014 14:18:07 +0400 Subject: [PATCH] 0023675: P-curves of a face are out of the domain of the face. Analyzing of 2D-curves' boundaries. Tolerance range computing was changed. 1. Function Validate(...) returns BRepCheck_Status. 2. For faces, whose pcurves is out of domain, status BRepCheck_OutOfSurfaceBoundary is returned. 3. For edges, which is out of face's boundary, status BRepCheck_PCurveIsOutOfDomainFace is returned. 4. Print warning, if status is not defined. 5. BRepCheck_Face::SetStatus(...) and BRepCheck_Wire::SetStatus(...) functions added. 6. ShapeFix::RefineFace(...) function and it draw-commands (ffixpcu and sfixpcu) are added. Command "ffixpcu" fixes a face with BRepCheck_OutOfSurfaceBoundary status. Command "sfixpcu" fixes a shape, which contains a face with BRepCheck_OutOfSurfaceBoundary status. 7. Trimming algorithm for surfaces changed (ForceTrim method is added). 8. Small correction of output of "checkshape" command result. 9. MinMax() and RealMod() functions are added. 10. Fixing of some shapes from test base. Faces, which based on periodic or closed surfaces, are not controlled. --- src/BRep/BRep_Builder.cdl | 45 +- src/BRep/BRep_Builder.cxx | 233 ++- src/BRep/BRep_Builder.lxx | 5 +- src/BRepCheck/BRepCheck.cdl | 2 + src/BRepCheck/BRepCheck.cxx | 8 + src/BRepCheck/BRepCheck_Analyzer.cxx | 496 +++--- src/BRepCheck/BRepCheck_Edge.cxx | 885 ++++++---- src/BRepCheck/BRepCheck_Face.cdl | 7 + src/BRepCheck/BRepCheck_Face.cxx | 9 + src/BRepCheck/BRepCheck_Wire.cxx | 6 +- src/BRepLib/BRepLib.cxx | 1606 +++++++++---------- src/BRepTest/BRepTest_CheckCommands.cxx | 126 +- src/Geom/Geom_RectangularTrimmedSurface.cdl | 57 + src/Geom/Geom_RectangularTrimmedSurface.cxx | 333 ++-- src/GeomTools/GeomTools_SurfaceSet.cxx | 7 + src/SWDRAW/SWDRAW_ShapeFix.cxx | 180 ++- src/ShapeBuild/ShapeBuild.cdl | 5 +- src/ShapeFix/ShapeFix.cdl | 11 +- src/ShapeFix/ShapeFix.cxx | 206 ++- src/Standard/Standard_Integer.hxx | 14 + src/Standard/Standard_Real.cxx | 11 + src/Standard/Standard_Real.hxx | 17 + tests/blend/complex/D3 | 7 + tests/boolean/bcut_complex/E7 | 7 + tests/boolean/bcut_complex/G2 | 6 + tests/boolean/bcut_complex/H8 | 13 + tests/boolean/bcut_complex/M2 | 7 + tests/boolean/bfuse_complex/E6 | 7 + tests/boolean/bfuse_complex/R8 | 6 + tests/bugs/modalg_2/bug263 | 6 + tests/bugs/modalg_4/bug6272_5 | 6 + tests/bugs/modalg_4/bug6272_6 | 7 + tests/bugs/modalg_4/bug6272_710 | 6 + tests/bugs/modalg_4/bug6272_77 | 6 + tests/bugs/modalg_4/bug6272_78 | 6 + tests/bugs/modalg_4/bug6272_79 | 6 + tests/bugs/moddata_1/bug15 | 5 +- tests/bugs/moddata_2/bug956_1 | 5 + tests/feat/featlf/B8 | 6 + tests/feat/featprism/K7 | 7 + tests/feat/featprism/R1 | 6 + tests/heal/data/advanced/G9 | 5 +- tests/heal/data/advanced/H9 | 5 +- tests/heal/data/advanced/I4 | 5 +- tests/heal/data/advanced/I5 | 6 +- tests/heal/data/advanced/M7 | 5 +- tests/heal/data/advanced/ZF1 | 4 + tests/heal/data/advanced/ZF2 | 4 + tests/heal/data/advanced/ZF7 | 4 + tests/heal/data/advanced/ZF8 | 5 +- tests/heal/data/standard/I5 | 5 + tests/heal/split_closed_faces/end | 1 + tests/heal/surface_to_bspline/B5 | 5 + tests/heal/surface_to_bspline/C5 | 5 + tests/heal/surface_to_bspline/C7 | 5 + tests/heal/surface_to_bspline/D6 | 5 + tests/heal/surface_to_bspline/D7 | 5 + tests/heal/surface_to_bspline/D8 | 5 + 58 files changed, 2882 insertions(+), 1591 deletions(-) diff --git a/src/BRep/BRep_Builder.cdl b/src/BRep/BRep_Builder.cdl index 2d7d48fe4e..c58f3f4b1e 100644 --- a/src/BRep/BRep_Builder.cdl +++ b/src/BRep/BRep_Builder.cdl @@ -232,11 +232,13 @@ is UpdateEdge(me; E : Edge from TopoDS; C1,C2 : Curve from Geom2d; F : Face from TopoDS; - Tol : Real); + Tol : Real; + theContinuity : Shape from GeomAbs = GeomAbs_C0); ---C++: inline - ---Purpose: Sets pcurves for the edge on the closed face. If - -- or is a null handle, remove any existing + ---Purpose: Sets pcurves (with theContinuity) for the edge on + -- the closed face. + -- If or is a null handle, remove any existing -- pcurve. UpdateEdge(me; E : Edge from TopoDS; @@ -248,7 +250,20 @@ is ---Purpose: Sets a pcurve for the edge on the face. -- If is a null handle, remove any existing pcurve. - UpdateEdge(me; E : Edge from TopoDS; + UpdateEdge(me; E : Edge from TopoDS; + C : Curve from Geom2d; + newSurf : Surface from Geom; + newL : Location from TopLoc; + theFace : Face from TopoDS; + Tol : Real from Standard); + + ---Purpose: Sets a pcurve for the edge on the face. + -- If is a null handle, remove any existing pcurve. + -- New edge will be in the face , which + -- based on surface newSurf. Old surface must be + -- deleted from later. + + UpdateEdge(me; E : Edge from TopoDS; C : Curve from Geom2d; S : Surface from Geom; L : Location from TopLoc; @@ -263,12 +278,28 @@ is C1,C2 : Curve from Geom2d; S : Surface from Geom; L : Location from TopLoc; - Tol : Real); + Tol : Real from Standard; + theContinuity : Shape from GeomAbs = GeomAbs_C0); - ---Purpose: Sets pcurves for the edge on the closed surface. - -- or is a null handle, remove any existing + ---Purpose: Sets pcurves (with theContinuity) for the edge on the + -- closed surface. + -- If or is a null handle, remove any existing -- pcurve. + UpdateEdge(me; E : Edge from TopoDS; + C1,C2 : Curve from Geom2d; + newSurf : Surface from Geom; + newL : Location from TopLoc; + theFace : Face from TopoDS; + Tol : Real from Standard); + + ---Purpose: Sets pcurves for the edge on the closed surface. + -- If or is a null handle, remove any + -- existing pcurve. + -- New edge will be in the face , which + -- based on surface newSurf. Old surface must be + -- deleted from later. + UpdateEdge(me; E : Edge from TopoDS; C1,C2 : Curve from Geom2d; S : Surface from Geom; diff --git a/src/BRep/BRep_Builder.cxx b/src/BRep/BRep_Builder.cxx index 26997eae80..84b02b71fa 100644 --- a/src/BRep/BRep_Builder.cxx +++ b/src/BRep/BRep_Builder.cxx @@ -228,7 +228,8 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, const Handle(Geom2d_Curve)& C1, const Handle(Geom2d_Curve)& C2, const Handle(Geom_Surface)& S, - const TopLoc_Location& L) + const TopLoc_Location& L, + const GeomAbs_Shape theContinuity = GeomAbs_C0) { BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); Handle(BRep_CurveRepresentation) cr; @@ -254,7 +255,7 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, if ( !C1.IsNull() && !C2.IsNull() ) { Handle(BRep_CurveOnClosedSurface) COS = - new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0); + new BRep_CurveOnClosedSurface(C1,C2,S,L,theContinuity); // test if there is already a range if (!GC.IsNull()) { COS->SetRange(f,l); @@ -275,7 +276,8 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, const Handle(Geom_Surface)& S, const TopLoc_Location& L, const gp_Pnt2d& Pf, - const gp_Pnt2d& Pl) + const gp_Pnt2d& Pl, + const GeomAbs_Shape theContinuity = GeomAbs_C0) { BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); Handle(BRep_CurveRepresentation) cr; @@ -301,7 +303,7 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, if ( !C1.IsNull() && !C2.IsNull() ) { Handle(BRep_CurveOnClosedSurface) COS = - new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0); + new BRep_CurveOnClosedSurface(C1,C2,S,L,theContinuity); // test if there is already a range if (!GC.IsNull()) { COS->SetRange(f,l); @@ -338,6 +340,167 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, } } +//======================================================================= +//function : UpdateCurves +//purpose : Insert two pcurves on surface with +// location in the list of curve representations . +// Deletes curves, which belong to because +// will not be used later (presumably). +// Remove the pcurves on from if or is null +//======================================================================= + +static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, + const Handle(Geom2d_Curve)& C1, + const Handle(Geom2d_Curve)& C2, + const Handle(Geom_Surface)& newSurf, + const TopLoc_Location& newL, + const Handle(Geom_Surface)& oldSurf, + const TopLoc_Location oldL, + const GeomAbs_Shape theContinuity = GeomAbs_C0) +{ + BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); + + Handle(BRep_GCurve) GC; + Standard_Real aFirst = 0.0, aLast = 0.0; + + Standard_Boolean rangeFound = Standard_False; + Standard_Boolean isModified = Standard_False; + + while (itcr.More()) + { + Handle(BRep_CurveRepresentation) cr = itcr.Value(); + GC = Handle(BRep_GCurve)::DownCast(cr); + + if ( !GC.IsNull() ) + { + GC->Range(aFirst, aLast); + + Standard_Boolean undefined = (Precision::IsPositiveInfinite(aLast) || + Precision::IsNegativeInfinite(aFirst)); + + if (!undefined) + { + rangeFound = Standard_True; + } + + Standard_Boolean cond = Standard_False; + cond = cond || GC->IsCurveOnSurface(oldSurf, oldL); + + if(!cond) + { + if(GC->IsCurveOnClosedSurface()) + { + Handle(BRep_CurveOnSurface) aCS = Handle(BRep_CurveOnSurface)::DownCast(GC); + cond = aCS->IsCurveOnSurface(oldSurf, oldL); + } + } + + if (cond) + { + lcr.Remove(itcr); + isModified = Standard_True; + } + else + { + itcr.Next(); + } + }//if ( !GC.IsNull() ) + else + { + if (cr->IsPolygonOnSurface(oldSurf, oldL)) + { + lcr.Remove(itcr); + isModified = Standard_True; + } + else + { + itcr.Next(); + } + } + } + + if ( !C1.IsNull() && !C2.IsNull() ) { + Handle(BRep_CurveOnClosedSurface) COS = + new BRep_CurveOnClosedSurface(C1,C2,newSurf,newL,theContinuity); + // test if there is already a range + if (rangeFound) { + COS->SetRange(aFirst,aLast); + } + lcr.Append(COS); + } +} + +//======================================================================= +//function : UpdateCurves +//purpose : Insert the pcurve on surface with +// location in the list of curve representations . +// Remove the pcurves on from if is null +//======================================================================= +static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, + const Handle(Geom2d_Curve)& C, + const Handle(Geom_Surface)& newSurf, + const TopLoc_Location& newL, + const Handle(Geom_Surface)& oldSurf, + const TopLoc_Location oldL) +{ + BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); + Handle(BRep_CurveRepresentation) cr; + Handle(BRep_GCurve) GC; + Standard_Real f = 0.0, l = 0.0; + Standard_Boolean rangeFound = Standard_False; + + // search the range of the 3d curve + // and remove any existing representation + + while (itcr.More()) { + GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); + if (!GC.IsNull()) { + if (GC->IsCurve3D()) { + GC->Range(f, l); + Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) || + Precision::IsNegativeInfinite(f)); + + if (!undefined) { + rangeFound = Standard_True; + } + } + if (GC->IsCurveOnSurface(oldSurf,oldL)) + { + GC->Range(f, l); + Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) || + Precision::IsNegativeInfinite(f)); + + if (!undefined) + { + rangeFound = Standard_True; + } + + // remove existing curve on surface + // cr is used to keep a reference on the curve representation + // this avoid deleting it as its content may be referenced by C or S + cr = itcr.Value(); + lcr.Remove(itcr); + } + else { + itcr.Next(); + } + } + else { + itcr.Next(); + } + } + + if (! C.IsNull()) { + Handle(BRep_CurveOnSurface) COS = new BRep_CurveOnSurface(C,newSurf,newL); + // test if there is already a range + if (rangeFound) { + COS->SetRange(f,l); + } + lcr.Append(COS); + } +} + + static void UpdatePoints(BRep_ListOfPointRepresentation& lpr, Standard_Real p, const Handle(Geom_Curve)& C, @@ -573,6 +736,33 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, TE->Modified(Standard_True); } +//======================================================================= +//function : UpdateEdge +//purpose : +//======================================================================= +void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, + const Handle(Geom2d_Curve)& C, + const Handle(Geom_Surface)& newSurf, + const TopLoc_Location& newL, + const TopoDS_Face& theFace, + const Standard_Real Tol) const +{ + const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + const TopLoc_Location l = newL.Predivided(E.Location()); + + const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &theFace.TShape()); + const TopLoc_Location &L = theFace.Location() * TF->Location(); + const Handle(Geom_Surface) &S = TF->Surface(); + + //BRep_Tool::Degenerated(E); + + UpdateCurves(TE->ChangeCurves(), + C, newSurf, l, S, + L.Predivided(E.Location())); + + TE->UpdateTolerance(Tol); + TE->Modified(Standard_True); +} //======================================================================= //function : UpdateEdge @@ -607,12 +797,13 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C2, const Handle(Geom_Surface)& S, const TopLoc_Location& L, - const Standard_Real Tol) const + const Standard_Real Tol, + const GeomAbs_Shape theContinuity) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); const TopLoc_Location l = L.Predivided(E.Location()); - UpdateCurves(TE->ChangeCurves(),C1,C2,S,l); + UpdateCurves(TE->ChangeCurves(),C1,C2,S,l,theContinuity); if (!C1.IsNull() && !C2.IsNull()) TE->Closed(C1->IsClosed() && C2->IsClosed()); @@ -894,6 +1085,36 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, TE->Modified(Standard_True); } +//======================================================================= +//function : UpdateEdge +//purpose : +//======================================================================= +void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, + const Handle(Geom2d_Curve)& C1, + const Handle(Geom2d_Curve)& C2, + const Handle(Geom_Surface)& newSurf, + const TopLoc_Location& newL, + const TopoDS_Face& theFace, + const Standard_Real Tol) const +{ + const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + const TopLoc_Location l = newL.Predivided(E.Location()); + + const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &theFace.TShape()); + const TopLoc_Location &L = theFace.Location() * TF->Location(); + const Handle(Geom_Surface) &S = TF->Surface(); + + + UpdateCurves(TE->ChangeCurves(), + C1,C2,newSurf,l,S, + L.Predivided(E.Location())); + + if (!C1.IsNull() && !C2.IsNull()) + TE->Closed(C1->IsClosed() && C2->IsClosed()); + + TE->UpdateTolerance(Tol); + TE->Modified(Standard_True); +} //======================================================================= //function : Continuity diff --git a/src/BRep/BRep_Builder.lxx b/src/BRep/BRep_Builder.lxx index 1a4fd54327..22e76b2625 100644 --- a/src/BRep/BRep_Builder.lxx +++ b/src/BRep/BRep_Builder.lxx @@ -140,10 +140,11 @@ inline void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const Handle(Geom2d_Curve)& C1, const Handle(Geom2d_Curve)& C2, const TopoDS_Face& F, - const Standard_Real Tol) const + const Standard_Real Tol, + const GeomAbs_Shape theContinuity) const { TopLoc_Location l; - UpdateEdge(E,C1,C2,BRep_Tool::Surface(F,l),l,Tol); + UpdateEdge(E,C1,C2,BRep_Tool::Surface(F,l),l,Tol, theContinuity); } diff --git a/src/BRepCheck/BRepCheck.cdl b/src/BRepCheck/BRepCheck.cdl index 71343e200f..500e3dfc2f 100644 --- a/src/BRepCheck/BRepCheck.cdl +++ b/src/BRepCheck/BRepCheck.cdl @@ -69,6 +69,7 @@ is FreeEdge, InvalidMultiConnexity, InvalidRange, + PCurveIsOutOfDomainFace, -- for wires @@ -78,6 +79,7 @@ is -- for faces NoSurface, + OutOfSurfaceBoundary, InvalidWire, RedundantWire, IntersectingWires, diff --git a/src/BRepCheck/BRepCheck.cxx b/src/BRepCheck/BRepCheck.cxx index 958f6129e5..69d21a78b4 100644 --- a/src/BRepCheck/BRepCheck.cxx +++ b/src/BRepCheck/BRepCheck.cxx @@ -175,7 +175,15 @@ void BRepCheck::Print(const BRepCheck_Status stat, case BRepCheck_CheckFail: OS << "BRepCheck_CheckFail\n"; break; + case BRepCheck_PCurveIsOutOfDomainFace: + OS << "BRepCheck_PCurveIsOutOfDomainFace\n"; + break; + case BRepCheck_OutOfSurfaceBoundary: + OS << "BRepCheck_OutOfSurfaceBoundary\n"; + break; + default: + OS << "BRepCheck::Print(...): Undefined status!\n"; break; } } diff --git a/src/BRepCheck/BRepCheck_Analyzer.cxx b/src/BRepCheck/BRepCheck_Analyzer.cxx index 44e1e5728c..21d16672f2 100644 --- a/src/BRepCheck/BRepCheck_Analyzer.cxx +++ b/src/BRepCheck/BRepCheck_Analyzer.cxx @@ -103,57 +103,64 @@ void BRepCheck_Analyzer::Put(const TopoDS_Shape& S, void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) { - for(TopoDS_Iterator theIterator(S);theIterator.More();theIterator.Next()) { + for(TopoDS_Iterator theIterator(S);theIterator.More();theIterator.Next()) Perform(theIterator.Value()); - } + // TopAbs_ShapeEnum styp; TopExp_Explorer exp; // styp = S.ShapeType(); - switch (styp) { - case TopAbs_VERTEX: + + switch (styp) + { + case TopAbs_VERTEX: // modified by NIZHNY-MKK Wed May 19 16:56:16 2004.BEGIN // There is no need to check anything. // if (myShape.IsSame(S)) { // myMap(S)->Blind(); // } // modified by NIZHNY-MKK Wed May 19 16:56:23 2004.END - + break; - case TopAbs_EDGE: { + case TopAbs_EDGE: + { // Modified by skv - Tue Apr 27 11:38:08 2004 Begin // There is no need to check anything except vertices on single edge. // if (myShape.IsSame(S)) { // myMap(S)->Blind(); // } // Modified by skv - Tue Apr 27 11:38:09 2004 End - TopTools_MapOfShape MapS; - - for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) { - const TopoDS_Shape& aVertex = exp.Current(); - try { - OCC_CATCH_SIGNALS - if (MapS.Add(aVertex)) { - myMap(aVertex)->InContext(S); - } - } - catch(Standard_Failure) { + + TopTools_MapOfShape MapS; + for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) + { + const TopoDS_Shape& aVertex = exp.Current(); + try + { + OCC_CATCH_SIGNALS + if (MapS.Add(aVertex)) + myMap(aVertex)->InContext(S); + } + catch(Standard_Failure) + { #ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<Print(cout); + cout<SetFailStatus(S); - } - Handle(BRepCheck_Result) aRes = myMap(aVertex); - if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(aVertex); - aRes->SetFailStatus(S); - } - } - } + if ( ! myMap(S).IsNull() ) + myMap(S)->SetFailStatus(S); + + Handle(BRepCheck_Result) aRes = myMap(aVertex); + + if ( ! aRes.IsNull() ) + { + aRes->SetFailStatus(aVertex); + aRes->SetFailStatus(S); + } + }//catch(Standard_Failure) + }//for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) } break; case TopAbs_WIRE: @@ -171,257 +178,234 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) case TopAbs_FACE: { TopTools_MapOfShape MapS; - for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) { - try { - OCC_CATCH_SIGNALS - if (MapS.Add(exp.Current())) { - myMap(exp.Current())->InContext(S); - } - } - catch(Standard_Failure) { + for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) + { + try + { + OCC_CATCH_SIGNALS + if (MapS.Add(exp.Current())) + myMap(exp.Current())->InContext(S); + } + catch(Standard_Failure) + { #ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<Print(cout); + cout<SetFailStatus(S); - } - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + if ( ! myMap(S).IsNull() ) + myMap(S)->SetFailStatus(S); + + Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + + if ( ! aRes.IsNull() ) + { + aRes->SetFailStatus(exp.Current()); + aRes->SetFailStatus(S); + } + }//catch(Standard_Failure) + }//for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) - if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - } - } - } Standard_Boolean performwire = Standard_True; + Standard_Boolean isFaceOutBoundary = Standard_False; + MapS.Clear(); - for (exp.Init(S,TopAbs_EDGE);exp.More(); exp.Next()) { - try { - OCC_CATCH_SIGNALS - if (MapS.Add(exp.Current())) { - Handle(BRepCheck_Result)& res = myMap(exp.Current()); - res->InContext(S); - if (performwire) { - for (res->InitContextIterator(); - res->MoreShapeInContext(); - res->NextShapeInContext()) { - if(res->ContextualShape().IsSame(S)) { - break; - } - } - BRepCheck_ListIteratorOfListOfStatus itl(res->StatusOnShape()); - for (; itl.More(); itl.Next()) { - BRepCheck_Status ste = itl.Value(); - if (ste == BRepCheck_NoCurveOnSurface || - ste == BRepCheck_InvalidCurveOnSurface || - ste == BRepCheck_InvalidRange || - ste == BRepCheck_InvalidCurveOnClosedSurface) { - performwire = Standard_False; - break; - } - } - } - } - } - catch(Standard_Failure) { + for (exp.Init(S,TopAbs_EDGE);exp.More(); exp.Next()) + { + try + { + OCC_CATCH_SIGNALS + if (MapS.Add(exp.Current())) + { + Handle(BRepCheck_Result)& res = myMap(exp.Current()); + res->InContext(S); + if (performwire) + { + for (res->InitContextIterator(); + res->MoreShapeInContext(); + res->NextShapeInContext()) + { + if(res->ContextualShape().IsSame(S)) + break; + } + + BRepCheck_ListIteratorOfListOfStatus itl(res->StatusOnShape()); + for (; itl.More(); itl.Next()) + { + BRepCheck_Status ste = itl.Value(); + if (ste == BRepCheck_NoCurveOnSurface || + ste == BRepCheck_InvalidCurveOnSurface || + ste == BRepCheck_InvalidRange || + ste == BRepCheck_InvalidCurveOnClosedSurface) + { + performwire = Standard_False; + break; + } + + if(ste == BRepCheck_PCurveIsOutOfDomainFace) + { + isFaceOutBoundary = Standard_True; + break; + } + }//for (; itl.More(); itl.Next()) + }//if (performwire) + }//if (MapS.Add(exp.Current())) + } + catch(Standard_Failure) + { #ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<Print(cout); + cout<SetFailStatus(S); + + Handle(BRepCheck_Result) aRes = myMap(exp.Current()); - if ( ! myMap(S).IsNull() ) { - myMap(S)->SetFailStatus(S); - } - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + if ( ! aRes.IsNull() ) + { + aRes->SetFailStatus(exp.Current()); + aRes->SetFailStatus(S); + } + }//catch(Standard_Failure) + }//for (exp.Init(S,TopAbs_EDGE);exp.More(); exp.Next()) - if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - } - } - } Standard_Boolean orientofwires = performwire; - for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) { - try { - OCC_CATCH_SIGNALS - Handle(BRepCheck_Result)& res = myMap(exp.Current()); - res->InContext(S); - if (orientofwires) { - for (res->InitContextIterator(); - res->MoreShapeInContext(); - res->NextShapeInContext()) { - if(res->ContextualShape().IsSame(S)) { - break; - } - } - BRepCheck_ListIteratorOfListOfStatus itl(res->StatusOnShape()); - for (; itl.More(); itl.Next()) { - BRepCheck_Status ste = itl.Value(); - if (ste != BRepCheck_NoError) { - orientofwires = Standard_False; - break; - } - } - } - } - catch(Standard_Failure) { -#ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<SetFailStatus(S); - } - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) + { + try + { + OCC_CATCH_SIGNALS + Handle(BRepCheck_Result)& res = myMap(exp.Current()); + res->InContext(S); + if (orientofwires) + { + for (res->InitContextIterator(); + res->MoreShapeInContext(); + res->NextShapeInContext()) + { + if(res->ContextualShape().IsSame(S)) + break; + } - if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - } - } - } - - try { + BRepCheck_ListIteratorOfListOfStatus itl(res->StatusOnShape()); + for (; itl.More(); itl.Next()) + { + BRepCheck_Status ste = itl.Value(); + if (ste != BRepCheck_NoError) + { + orientofwires = Standard_False; + break; + } + } + }//if (orientofwires) + } + catch(Standard_Failure) + { +#ifdef DEB + cout<<"BRepCheck_Analyzer : "; + Standard_Failure::Caught()->Print(cout); + cout<SetFailStatus(S); + + Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + + if ( ! aRes.IsNull() ) + { + aRes->SetFailStatus(exp.Current()); + aRes->SetFailStatus(S); + } + } + }//for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) + + try + { OCC_CATCH_SIGNALS - if (performwire) { - if (orientofwires) { - Handle(BRepCheck_Face)::DownCast(myMap(S))-> - OrientationOfWires(Standard_True);// on enregistre - } - // else { - // Handle(BRepCheck_Face)::DownCast(myMap(S))-> - // IntersectWires(Standard_True); // on enregistre - // } - else { - Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable(); - } - } - else { - Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable(); - } + if (performwire) + { + if (isFaceOutBoundary) + Handle(BRepCheck_Face)::DownCast(myMap(S))-> + SetStatus(BRepCheck_OutOfSurfaceBoundary); + else if (orientofwires) + Handle(BRepCheck_Face)::DownCast(myMap(S))-> + OrientationOfWires(Standard_True);// on enregistre + else + Handle(BRepCheck_Face)::DownCast(myMap(S))-> + SetUnorientable(); + }//if (performwire) + else + Handle(BRepCheck_Face)::DownCast(myMap(S))-> + SetUnorientable(); } - catch(Standard_Failure) { + catch(Standard_Failure) + { #ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<Print(cout); + cout<SetFailStatus(S); - } - - for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) { - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + if ( ! myMap(S).IsNull() ) + { + myMap(S)->SetFailStatus(S); + } - if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - myMap(S)->SetFailStatus(exp.Current()); - } - } - } + for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) + { + Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + + if ( ! aRes.IsNull() ) + { + aRes->SetFailStatus(exp.Current()); + aRes->SetFailStatus(S); + myMap(S)->SetFailStatus(exp.Current()); + } + }//for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) + }//catch(Standard_Failure) } break; - - case TopAbs_SHELL: + case TopAbs_SHELL: //modified by NIZNHY-PKV Mon Oct 13 14:23:53 2008f - /* { - Standard_Boolean VerifyOrientation, bFlag; - // - VerifyOrientation = Standard_True; - // - exp.Init(S,TopAbs_FACE); - for (; exp.More(); exp.Next()) { - const TopoDS_Shape& aF=exp.Current(); - try { - OCC_CATCH_SIGNALS - bFlag= !(Handle(BRepCheck_Face)::DownCast(myMap(aF))->IsUnorientable()); - VerifyOrientation = (VerifyOrientation && bFlag); - } - catch(Standard_Failure) { -#ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<SetFailStatus(S); - } - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); - - if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - } - } - } // - try { - OCC_CATCH_SIGNALS - if (VerifyOrientation) { - Handle(BRepCheck_Shell)::DownCast(myMap(S))->Orientation(Standard_True); - } - else { - Handle(BRepCheck_Shell)::DownCast(myMap(S))->SetUnorientable(); - } - } - catch(Standard_Failure) { -#ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<SetFailStatus(S); - } - exp.Init(S,TopAbs_FACE); - for (; exp.More(); exp.Next()) { - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); - if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - myMap(S)->SetFailStatus(exp.Current()); - } - } - } - } - */ //modified by NIZNHY-PKV Mon Oct 13 14:24:04 2008t break; - // - case TopAbs_SOLID: { - exp.Init(S,TopAbs_SHELL); - for (; exp.More(); exp.Next()) { - const TopoDS_Shape& aShell=exp.Current(); - try { - OCC_CATCH_SIGNALS - myMap(aShell)->InContext(S); - } - catch(Standard_Failure) { + + case TopAbs_SOLID: + { + exp.Init(S,TopAbs_SHELL); + for (; exp.More(); exp.Next()) + { + const TopoDS_Shape& aShell=exp.Current(); + try + { + OCC_CATCH_SIGNALS + myMap(aShell)->InContext(S); + } + catch(Standard_Failure) + { #ifdef DEB - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<Print(cout); + cout<SetFailStatus(S); - } - // - Handle(BRepCheck_Result) aRes = myMap(aShell); - if (!aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - } - } + if ( ! myMap(S).IsNull() ) + { + myMap(S)->SetFailStatus(S); + } + + // + Handle(BRepCheck_Result) aRes = myMap(aShell); + if (!aRes.IsNull() ) + { + aRes->SetFailStatus(exp.Current()); + aRes->SetFailStatus(S); + } + }//catch(Standard_Failure) + }//for (; exp.More(); exp.Next()) } - } - break;//case TopAbs_SOLID + break;//case TopAbs_SOLID default: break; }//switch (styp) { diff --git a/src/BRepCheck/BRepCheck_Edge.cxx b/src/BRepCheck/BRepCheck_Edge.cxx index 1d42883571..1b75221597 100644 --- a/src/BRepCheck/BRepCheck_Edge.cxx +++ b/src/BRepCheck/BRepCheck_Edge.cxx @@ -58,12 +58,14 @@ #include -//modified by NIZNHY-PKV Thu May 05 09:01:57 2011f static - Standard_Boolean Validate(const Adaptor3d_Curve&, - const Adaptor3d_CurveOnSurface&, - const Standard_Real, - const Standard_Boolean); + BRepCheck_Status Validate(const Adaptor3d_Curve&, + const Adaptor3d_CurveOnSurface&, + const Standard_Real, + const Standard_Boolean, + const Standard_Boolean theSurfIsUPeriodic, + const Standard_Boolean theSurfIsVPeriodic); + static void PrintProblematicPoint(const gp_Pnt&, const Standard_Real, @@ -77,13 +79,9 @@ static static Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS); -//static Standard_Boolean Validate(const Adaptor3d_Curve&, -// const Adaptor3d_Curve&, -// const Standard_Real, -// const Standard_Boolean); //modified by NIZNHY-PKV Thu May 05 09:02:01 2011t -#define NCONTROL 23 +static const Standard_Integer aNbControl = 23; //======================================================================= //function : BRepCheck_Edge @@ -213,9 +211,9 @@ void BRepCheck_Edge::Minimum() void BRepCheck_Edge::InContext(const TopoDS_Shape& S) { - if (myMap.IsBound(S)) { + if (myMap.IsBound(S)) return; - } + BRepCheck_ListOfStatus thelist; myMap.Bind(S, thelist); BRepCheck_ListOfStatus& lst = myMap(S); @@ -224,191 +222,238 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S) Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape)); TopAbs_ShapeEnum styp = S.ShapeType(); -// for (TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next()) { TopExp_Explorer exp(S,TopAbs_EDGE) ; - for ( ; exp.More(); exp.Next()) { - if (exp.Current().IsSame(myShape)) { + for ( ; exp.More(); exp.Next()) + { + if (exp.Current().IsSame(myShape)) break; - } } - if (!exp.More()) { + + if (!exp.More()) + { BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape); return; } - - switch (styp) { - case TopAbs_FACE: - if (!myCref.IsNull()) { - - Standard_Boolean SameParameter = TE->SameParameter(); - Standard_Boolean SameRange = TE->SameRange(); -// Modified by skv - Tue Apr 27 11:48:13 2004 Begin - if (!SameParameter || !SameRange) { - if (!SameParameter) - BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); - if (!SameRange) - BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag); - return; - } -// Modified by skv - Tue Apr 27 11:48:14 2004 End - Standard_Real First = myHCurve->FirstParameter(); - Standard_Real Last = myHCurve->LastParameter(); + switch (styp) + { + case TopAbs_FACE: + if (myCref.IsNull()) + break; - Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape()); - const TopLoc_Location& Floc = S.Location(); - const TopLoc_Location& TFloc = TF->Location(); - const Handle(Geom_Surface)& Su = TF->Surface(); - TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location()); - Standard_Boolean pcurvefound = Standard_False; + { + Standard_Boolean SameParameter = TE->SameParameter(); + Standard_Boolean SameRange = TE->SameRange(); - BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); - while (itcr.More()) { - const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); - if (cr != myCref && cr->IsCurveOnSurface(Su,L)) { - pcurvefound = Standard_True; - const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr); - Standard_Real f,l; - GC->Range(f,l); - // gka OCC -// Modified by skv - Tue Apr 27 11:50:35 2004 Begin -// if (SameRange && (fabs(f-First) > Precision::PConfusion() || fabs(l-Last)> Precision::PConfusion())) { //f != First || l != Last)) { gka OCC - if (fabs(f-First) > Precision::PConfusion() || - fabs(l-Last) > Precision::PConfusion()) { - BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag); - BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); -// if (SameParameter) { -// BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); -// } - } -// Modified by skv - Tue Apr 27 11:50:37 2004 End - if (myGctrl) { - Handle(Geom_Surface) Sb = cr->Surface(); - Sb = Handle(Geom_Surface)::DownCast -// (Su->Transformed(L.Transformation())); - (Su->Transformed(/*L*/(Floc * TFloc).Transformation())); - Handle(Geom2d_Curve) PC = cr->PCurve(); - Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb); - Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l); - Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); - Standard_Boolean ok = - Validate(myHCurve->Curve(),ACS,Tol,SameParameter); - if (!ok) { - if (cr->IsCurveOnClosedSurface()) { - BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); - } - else { - BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); - } -// Modified by skv - Tue Apr 27 11:53:00 2004 Begin - BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); -// if (SameParameter) { -// BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); -// } -// Modified by skv - Tue Apr 27 11:53:01 2004 End - } - if (cr->IsCurveOnClosedSurface()) { - GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds - ACS.Load(GAHS); // sans doute inutile - ACS.Load(GHPC); // meme remarque... - ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter); - if (!ok) { - BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); -// Modified by skv - Tue Apr 27 11:53:20 2004 Begin - if (SameParameter) { - BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); - } -// Modified by skv - Tue Apr 27 11:53:23 2004 End - } - } - } - } - itcr.Next(); - } + if (!SameParameter || !SameRange) + { + if (!SameParameter) + BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); - if (!pcurvefound) { - Handle(Geom_Plane) P; - Handle(Standard_Type) dtyp = Su->DynamicType(); - if (dtyp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { - P = Handle(Geom_Plane)::DownCast - (Handle(Geom_RectangularTrimmedSurface):: - DownCast(Su)->BasisSurface()); - } - else { - P = Handle(Geom_Plane)::DownCast(Su); - } - if (P.IsNull()) { // not a plane - BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface); - } - else { // on fait la projection a la volee, comme BRep_Tool - // plan en position - if (myGctrl) { - P = Handle(Geom_Plane):: - DownCast(P->Transformed(/*L*/(Floc * TFloc).Transformation()));// eap occ332 - //on projette Cref sur ce plan - Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P); + if (!SameRange) + BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag); - // Dub - Normalement myHCurve est une GeomAdaptor_HCurve - GeomAdaptor_Curve& Gac = - Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve(); - Handle(Geom_Curve) C3d = Gac.Curve(); - Handle(Geom_Curve) ProjOnPlane = - GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,First,Last), - P, P->Position().Direction(), - Standard_True); - Handle(GeomAdaptor_HCurve) aHCurve = - new GeomAdaptor_HCurve(ProjOnPlane); + return; + }//if (!SameParameter || !SameRange) - ProjLib_ProjectedCurve proj(GAHS,aHCurve); - Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj); - Handle(Geom2dAdaptor_HCurve) GHPC = - new Geom2dAdaptor_HCurve(PC, - myHCurve->FirstParameter(), - myHCurve->LastParameter()); + const Standard_Real First = myHCurve->FirstParameter(); + const Standard_Real Last = myHCurve->LastParameter(); - Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); - - Standard_Boolean ok = Validate(myHCurve->Curve(),ACS, - Tol,Standard_True); // voir dub... - if (!ok) { - BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); - } - } - } + Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape()); + const TopLoc_Location& Floc = S.Location(); + const TopLoc_Location& TFloc = TF->Location(); + const Handle(Geom_Surface)& Su = TF->Surface(); + TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location()); + Standard_Boolean pcurvefound = Standard_False; + + BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); + + while (itcr.More()) + { + const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); + if (cr != myCref && cr->IsCurveOnSurface(Su,L)) + { + pcurvefound = Standard_True; + const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr); + Standard_Real f,l; + GC->Range(f,l); + + if (fabs(f-First) > Precision::PConfusion() || + fabs(l-Last) > Precision::PConfusion()) + { + BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag); + BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); + } + + if (myGctrl) + { + Handle(Geom_Surface) Sb = cr->Surface(); + { + Standard_Real U1Su, U2Su, V1Su, V2Su; + Standard_Real U1Sb, U2Sb, V1Sb, V2Sb; + + Standard_Boolean isTrimU = Standard_False, isTrimV = Standard_False; + if(Su->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { + Handle(Geom_RectangularTrimmedSurface) TS = + Handle(Geom_RectangularTrimmedSurface)::DownCast(Su); + + TS->GetTrimmedFlags(isTrimU, isTrimV); + } + + Su->Bounds(U1Su, U2Su, V1Su, V2Su); + Sb = Handle(Geom_Surface)::DownCast + (Su->Transformed((Floc * TFloc).Transformation())); + + Sb->Bounds(U1Sb, U2Sb, V1Sb, V2Sb); + Standard_Boolean isUtr = ((Abs(U1Su - U1Sb) + Abs(U2Su - U2Sb)) > Precision::PConfusion()), + isVtr = ((Abs(V1Su - V1Sb) + Abs(V2Su - V2Sb)) > Precision::PConfusion()); + + if(isUtr || isVtr) + { + Handle(Geom_Surface) St = Handle(Geom_RectangularTrimmedSurface)::DownCast(Sb)->BasisSurface(); + Sb = new Geom_RectangularTrimmedSurface(St, isTrimU || isUtr, isVtr || isTrimV, U1Su, U2Su, V1Su, V2Su); + } + } + + Handle(Geom2d_Curve) PC = cr->PCurve(); + Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb); + Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l); + Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); + BRepCheck_Status aStatus = Validate(myHCurve->Curve(),ACS,Tol,SameParameter, + Sb->IsUPeriodic(),Sb->IsVPeriodic()); + + if(aStatus == BRepCheck_PCurveIsOutOfDomainFace) + BRepCheck::Add(lst,BRepCheck_PCurveIsOutOfDomainFace); + else if(aStatus == BRepCheck_InvalidCurveOnSurface) + { + if (cr->IsCurveOnClosedSurface()) + BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); + else + BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); + + BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); + } + else if(aStatus != BRepCheck_NoError) + BRepCheck::Add(lst,aStatus); + + if (cr->IsCurveOnClosedSurface()) + { + GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds + ACS.Load(GAHS); // sans doute inutile + ACS.Load(GHPC); // meme remarque... + aStatus = Validate(myHCurve->Curve(),ACS,Tol,SameParameter, + Sb->IsUPeriodic(),Sb->IsVPeriodic()); + + if(aStatus == BRepCheck_PCurveIsOutOfDomainFace) + BRepCheck::Add(lst,BRepCheck_PCurveIsOutOfDomainFace); + else if(aStatus == BRepCheck_InvalidCurveOnSurface) + { + BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); + if (SameParameter) + BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); + } + else if(aStatus != BRepCheck_NoError) + BRepCheck::Add(lst,aStatus); + }//if (cr->IsCurveOnClosedSurface()) + }//if (myGctrl) + }//if (cr != myCref && cr->IsCurveOnSurface(Su,L)) + itcr.Next(); + }//while (itcr.More()) + + if (!pcurvefound) + { + Handle(Geom_Plane) P; + Handle(Standard_Type) dtyp = Su->DynamicType(); + if (dtyp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) + { + P = Handle(Geom_Plane)::DownCast + (Handle(Geom_RectangularTrimmedSurface):: + DownCast(Su)->BasisSurface()); + } + else + P = Handle(Geom_Plane)::DownCast(Su); + + if (P.IsNull()) // not a plane + BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface); + else + { + // on fait la projection a la volee, comme BRep_Tool plan en position + if (myGctrl) + { + P = Handle(Geom_Plane)::DownCast( + P->Transformed((Floc * TFloc).Transformation()));// eap occ332 + + //on projette Cref sur ce plan + Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P); + + // Dub - Normalement myHCurve est une GeomAdaptor_HCurve + GeomAdaptor_Curve& Gac = + Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve(); + + Handle(Geom_Curve) C3d = Gac.Curve(); + Handle(Geom_Curve) ProjOnPlane = + GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,First,Last), + P, P->Position().Direction(),Standard_True); + + Handle(GeomAdaptor_HCurve) aHCurve = + new GeomAdaptor_HCurve(ProjOnPlane); + + ProjLib_ProjectedCurve proj(GAHS,aHCurve); + Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj); + Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC, + myHCurve->FirstParameter(), + myHCurve->LastParameter()); + + Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); + + BRepCheck_Status aStatus = Validate(myHCurve->Curve(),ACS,Tol, + Standard_True, P->IsUPeriodic(),P->IsVPeriodic()); // voir dub... + + if (aStatus != BRepCheck_NoError) + BRepCheck::Add(lst,aStatus); + }//if (myGctrl) + }//else of "if (P.IsNull())" condition + }//if (!pcurvefound) + + break; } - } - break; - case TopAbs_SOLID: - { - // on verifie que l`edge est bien connectee 2 fois (pas de bord libre) - Standard_Integer nbconnection = 0; - //TopExp_Explorer exp; - for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) { - const TopoDS_Face& fac = TopoDS::Face(exp.Current()); - TopExp_Explorer exp2; - for (exp2.Init(fac,TopAbs_EDGE); exp2.More(); exp2.Next()) { - if (exp2.Current().IsSame(myShape)) { - nbconnection++; - } - } + case TopAbs_SOLID: + { + // on verifie que l`edge est bien connectee 2 fois (pas de bord libre) + Standard_Integer nbconnection = 0; + + //TopExp_Explorer exp; + for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) + { + const TopoDS_Face& fac = TopoDS::Face(exp.Current()); + TopExp_Explorer exp2; + + for (exp2.Init(fac,TopAbs_EDGE); exp2.More(); exp2.Next()) + { + if (exp2.Current().IsSame(myShape)) + nbconnection++; + }//for (exp2.Init(fac,TopAbs_EDGE); exp2.More(); exp2.Next()) + }//for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) + + if (nbconnection < 2 && !TE->Degenerated()) + BRepCheck::Add(myMap(S),BRepCheck_FreeEdge); + else if (nbconnection > 2) + { + BRepCheck::Add(myMap(S),BRepCheck_InvalidMultiConnexity); + } + else + BRepCheck::Add(myMap(S),BRepCheck_NoError); + } - if (nbconnection < 2 && !TE->Degenerated()) { - BRepCheck::Add(myMap(S),BRepCheck_FreeEdge); - } - else if (nbconnection > 2) { - BRepCheck::Add(myMap(S),BRepCheck_InvalidMultiConnexity); - } - else { - BRepCheck::Add(myMap(S),BRepCheck_NoError); - } - } - break; - default: - break; - } - if (myMap(S).IsEmpty()) { + break; + + default: + break; + }//switch (styp) + + if (myMap(S).IsEmpty()) myMap(S).Append(BRepCheck_NoError); - } } @@ -530,8 +575,8 @@ Standard_Real BRepCheck_Edge::Tolerance() Standard_Real dist2, tol2, tolCal=0., prm; gp_Pnt center, othP; Standard_Integer i; - for (i= 0; i< NCONTROL; i++) { - prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1); + for (i= 0; i< aNbControl; i++) { + prm = ((aNbControl-1-i)*First + i*Last)/(aNbControl-1); tol2=dist2=0.; center=(*(Handle(Adaptor3d_HCurve)*)&theRep(1))->Value(prm); for (iRep=2; iRep<=nbRep; iRep++) { @@ -549,74 +594,383 @@ Standard_Real BRepCheck_Edge::Tolerance() //======================================================================= //function : Validate -//purpose : +//purpose : +//Remark : If the original surface is not periodic in U or V direction +// (for example, rectangular trimmed on periodic surface), +// the surface that contains +// can be periodic. +// To use true values of flags, the parameters +// and have been added. //======================================================================= -Standard_Boolean Validate(const Adaptor3d_Curve& CRef, - const Adaptor3d_CurveOnSurface& Other, - const Standard_Real Tol, - const Standard_Boolean SameParameter) +BRepCheck_Status Validate (const Adaptor3d_Curve& CRef, + const Adaptor3d_CurveOnSurface& Other, + const Standard_Real Tol, + const Standard_Boolean SameParameter, + const Standard_Boolean theSurfIsUPeriodic, + const Standard_Boolean theSurfIsVPeriodic) { - Standard_Boolean Status, proj; - Standard_Real aPC, First, Last, Error; - gp_Pnt problematic_point ; - // - Status = Standard_True; - Error = 0.; - First = CRef.FirstParameter(); - Last = CRef.LastParameter(); - // - aPC=Precision::PConfusion(); - proj = (!SameParameter || - fabs(Other.FirstParameter()-First) > aPC || - fabs( Other.LastParameter()-Last) > aPC); - if (!proj) { - Standard_Integer i; - Standard_Real Tol2, prm, dD; - gp_Pnt pref, pother; + BRepCheck_Status Status = BRepCheck_NoError; + const Standard_Real aPC = Precision::PConfusion(), + First = CRef.FirstParameter(), + Last = CRef.LastParameter(); + + const Standard_Boolean proj = (!SameParameter || + fabs(Other.FirstParameter()-First) > aPC || + fabs(Other.LastParameter()-Last) > aPC); + + if (!proj) + { //modified by NIZNHY-PKV Thu May 05 09:06:41 2011f //OCC22428 - dD=Prec(CRef, Other);//3.e-15; - Tol2=Tol+dD; + const Standard_Real dD = Prec(CRef, Other);//3.e-15; + Standard_Real Tol2=Tol+dD; Tol2=Tol2*Tol2; + //Tol2=Tol*Tol; //modified by NIZNHY-PKV Thu May 05 09:06:47 2011t + + const Standard_Real uf = Other.GetSurface()->FirstUParameter (); + const Standard_Real ul = Other.GetSurface()->LastUParameter (); + const Standard_Real vf = Other.GetSurface()->FirstVParameter(); + const Standard_Real vl = Other.GetSurface()->LastVParameter(); - for (i = 0; i< NCONTROL; ++i) { - prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1); - pref = CRef.Value(prm); - pother = Other.Value(prm); - if (pref.SquareDistance(pother) > Tol2) { - problematic_point = pref ; - Status = Standard_False; - Error = pref.Distance(pother); - PrintProblematicPoint(problematic_point, Error, Tol); - return Status; - //goto FINISH ; + //These values are used for estimation of toleranves of + //"plane-like" surfaces + const Standard_Real aDeltaU = (ul - uf); + const Standard_Real aDeltaV = (vl - vf); + + //(for Rectangular trimmed surface for example) + const Standard_Boolean isBaseSurfUPeriodic = Other.GetSurface()->IsUPeriodic() && !theSurfIsUPeriodic; + const Standard_Boolean isBaseSurfVPeriodic = Other.GetSurface()->IsVPeriodic() && !theSurfIsVPeriodic; + + const Standard_Boolean isUPeriodic = isBaseSurfUPeriodic || theSurfIsUPeriodic; + const Standard_Boolean isVPeriodic = isBaseSurfVPeriodic || theSurfIsVPeriodic; + + const Standard_Boolean isUClosedOrPeriodic = Other.GetSurface()->IsUClosed() || theSurfIsUPeriodic; + const Standard_Boolean isVClosedOrPeriodic = Other.GetSurface()->IsVClosed() || theSurfIsVPeriodic; + + const Standard_Real UResSt =Other.GetSurface()->UResolution(Tol); + const Standard_Real VResSt =Other.GetSurface()->VResolution(Tol); + +// if(isUClosedOrPeriodic) +// { +// const Standard_Real aF = Other.GetCurve()->Value(First).X(); +// const Standard_Real aL = Other.GetCurve()->Value(Last).X(); +// const Standard_Real aDim = theSurfIsUPeriodic ? +// Other.GetSurface()->UPeriod() : +// aDeltaU; +// +// if(Abs(aL - aF) - aDim > 2 * UResSt) +// { +//#ifdef DEB +// cout << endl << "----\nFunction Validate(...); file: " +// "BRepCheck_Edge.cxx" << endl; +// if(theSurfIsUPeriodic) +// cout << "The surface is U-periodic." << endl; +// else +// cout << "The surface is U-closed." << endl; +// +// cout << "P1.X() = " << aF << "; P2.X() = " << aL << endl; +// cout << "Surface dimension D = " << aDim << +// ". (P2.X() - P1.X()) > D." << "\n-----" << endl; +//#endif +// Status = BRepCheck_PCurveIsOutOfDomainFace; +// return Status; +// }//if(aL - aF - aT > 2* URes) +// }//if(theSurfIsUPeriodic) +// +// if(isVClosedOrPeriodic) +// { +// const Standard_Real aF = Other.GetCurve()->Value(First).Y(); +// const Standard_Real aL = Other.GetCurve()->Value(Last).Y(); +// const Standard_Real aDim = theSurfIsVPeriodic ? +// Other.GetSurface()->VPeriod() : +// aDeltaV; +// +// if(Abs(aL - aF) - aDim > 2 * VResSt) +// { +//#ifdef DEB +// cout << endl << "----\nFunction Validate(...); file: " +// "RepCheck_Edge.cxx" << endl; +// if(theSurfIsVPeriodic) +// cout << "The surface is V-periodic." << endl; +// else +// cout << "The surface is V-closed." << endl; +// +// cout << "P1.Y() = " << aF << "; P2.Y() = " << aL << endl; +// cout << "Surface dimension D = " << aDim << +// ". (P2.Y() - P1.Y()) > D." << "\n-----" << endl; +//#endif +// Status = BRepCheck_PCurveIsOutOfDomainFace; +// return Status; +// }//if(aL - aF - aT > 2* VRes) +// }//if(theSurfIsVPeriodic) + + Standard_Real aCriticalParameterU = First, + aCriticalParameterV = First; + + Standard_Real aDeltaUmax = 0.0, + aDeltaVmax = 0.0; + + Standard_Real dUmaxU = 0.0, dUmaxV = 0.0; + Standard_Real dVmaxU = 0.0, dVmaxV = 0.0; + + Standard_Boolean isIntoBoundaries = Standard_True; + + for (Standard_Integer i = 0; i < aNbControl; ++i) + { + const Standard_Real prm = ((aNbControl-1-i)*First + i*Last)/(aNbControl-1); + const gp_Pnt pref = CRef.Value(prm); + const gp_Pnt pother = Other.Value(prm); + + if (pref.SquareDistance(pother) > Tol2) + { + const gp_Pnt problematic_point(pref) ; + Status = BRepCheck_InvalidCurveOnSurface; + const Standard_Real Error = pref.Distance(pother); + PrintProblematicPoint(problematic_point, Error, Tol); + return Status; } - } - } - else { + + const gp_Pnt2d CP = Other.GetCurve()->Value(prm); + + if(isUClosedOrPeriodic && isVClosedOrPeriodic) + continue; + + const Standard_Real u = Max(uf, Min(CP.X(), ul)); + const Standard_Real v = Max(vf, Min(CP.Y(), vl)); + + const Standard_Boolean isUbound = ((uf <= CP.X()) && (CP.X() <= ul)) || isUClosedOrPeriodic, + isVbound = ((vf <= CP.Y()) && (CP.Y() <= vl)) || isVClosedOrPeriodic; + + //Point CP is in surface boundary. + if(isUbound && isVbound) + continue; + + isIntoBoundaries = Standard_False; + + //Values of overrun of surface boundaries + const Standard_Real dUpar = (isUPeriodic || isUbound) ? 0.0 : CP.X() - u, + dVpar = (isVPeriodic || isVbound) ? 0.0 : CP.Y() - v; + + if(Abs(dUpar) > aDeltaUmax) + { + aCriticalParameterU = prm; + aDeltaUmax = Abs(dUpar); + dUmaxU = dUpar; + dUmaxV = dVpar; + } + + if(Abs(dVpar) > aDeltaVmax) + { + aCriticalParameterV = prm; + aDeltaVmax = Abs(dVpar); + dVmaxU = dUpar; + dVmaxV = dVpar; + } + }//for (i = 0; i< aNbControl; ++i) + + if(!isIntoBoundaries) + { + // Max U(V) resolution is calculated from condition: + // |S'|*dU > aCoeff*(0.5*|S"|dU*dU), it means that + // first order differential of surface >> second order one + const Standard_Real aCoeff = 10.; + //Value to check modulus of derivatives against zero + const Standard_Real eps = 1.e-16; + //Value for estimation Max resolution if |S"| < eps + const Standard_Real aFactor = 10.; + + for(Standard_Integer anIndex = 0; anIndex < 2; anIndex++) + { + const Standard_Real aParam = !anIndex ? aCriticalParameterU : aCriticalParameterV; + const Standard_Real du = !anIndex ? dUmaxU : dUmaxV; + const Standard_Real dv = !anIndex ? dVmaxU : dVmaxV; + + const gp_Pnt2d CP = Other.GetCurve()->Value(aParam); + + const Standard_Real u = Max(uf, Min(CP.X(), ul)); + const Standard_Real v = Max(vf, Min(CP.Y(), vl)); + + gp_Pnt aPref; + gp_Vec aDSdu, aDSdv, aD2Sdu2, aD2Sdv2, aD2Sdudv; + Other.GetSurface()->D2(u, v, aPref, aDSdu, aDSdv, aD2Sdu2, aD2Sdv2, aD2Sdudv); + + Standard_Real UResMax = 0.0, VResMax = 0.0; + const Standard_Real aModDSdu = aDSdu.Magnitude(); + const Standard_Real aModDSdv = aDSdv.Magnitude(); + const Standard_Real aModD2Sdu2 = aD2Sdu2.Magnitude(); + const Standard_Real aModD2Sdv2 = aD2Sdv2.Magnitude(); + + if(aModDSdu > eps) + { + if(aModD2Sdu2 > aModDSdu / aCoeff) + { + UResMax = aModDSdu / (.5 * aCoeff * aModD2Sdu2); + } + else + { + //Surface seems to be "plane-like" in U direction + UResMax = aDeltaU / aFactor; + } + } + else + { + UResMax = aFactor * UResSt; + } + + if(aModDSdv > eps) + { + if(aModD2Sdv2 > aModDSdv / aCoeff) + { + VResMax = aModDSdv / (5. * aModD2Sdv2); + } + else + { + //Surface seems to be "plane-like" in V direction + VResMax = aDeltaV / aFactor; + } + } + else + { + VResMax = aFactor * VResSt; + } + + const Standard_Real anURes = isBaseSurfUPeriodic ? UResSt : UResMax, + aVRes = isBaseSurfVPeriodic ? VResSt : VResMax; + + const Standard_Boolean isUbound = ((uf - anURes <= CP.X()) && (CP.X() <= ul + anURes)) || isUClosedOrPeriodic, + isVbound = ((vf - aVRes <= CP.Y()) && (CP.Y() <= vl + aVRes)) || isVClosedOrPeriodic; + + if(isUbound && isVbound) + continue; + +#ifdef DEB + if(!isUbound) + { + cout << endl << "----\nFunction Validate(...); file: " + "BRepCheck_Edge.cxx" << endl; + + if(isBaseSurfUPeriodic) + cout << "RTS from U-periodic" << endl; + else if(theSurfIsUPeriodic) + cout << "U-periodic surface" << endl; + else if(isUClosedOrPeriodic) + cout << "U-closed surface" << endl; + + + cout << "Point(prm = " << aParam << "): (" << + CP.X() << "; " << CP.Y() <<")." << endl; + cout << "u = (" << uf << ")...(" << ul << "). " + "Delta = " << Max(uf - CP.X(),CP.X()-ul) << " Tol3D = " << Tol << + ". URes = " << anURes << "\n-----" << endl; + } + + if(!isVbound) + { + cout << endl << "----\nFunction Validate(...); file: " + "BRepCheck_Edge.cxx" << endl; + + if(isBaseSurfVPeriodic) + cout << "RTS from V-periodic" << endl; + else if(theSurfIsVPeriodic) + cout << "V-periodic surface" << endl; + else if(isVClosedOrPeriodic) + cout << "V-closed surface" << endl; + + cout << "Point(prm = " << aParam << "): (" << + CP.X() << "; " << CP.Y() <<")." << endl; + cout << "v = (" << vf << ")...(" << vl << "). " + "Delta = " << Max(vf - CP.Y(),CP.Y()-vl) << " Tol3D = " << Tol << + ". VRes = " << aVRes << "\n-----" << endl; + } +#endif + + //Expected and real point + gp_Pnt aPe, aPf; + //1st degree estimation + aPe.SetXYZ(gp_XYZ(aPref.X() + (aDSdu.X()*du+aDSdv.X()*dv), + aPref.Y() + (aDSdu.Y()*du+aDSdv.Y()*dv), + aPref.Z() + (aDSdu.Z()*du+aDSdv.Z()*dv))); + + Other.GetSurface()->D0(CP.X(), CP.Y(), aPf); + const Standard_Real aTol = Tol2; + Standard_Real dist = aPe.SquareDistance(aPf); + + if(dist < aTol) + continue; + +#ifdef DEB + cout << endl << "++++\nFunction Validate(...); file: " + "BRepCheck_Edge.cxx (1st degree)" << endl; + cout << "Exp. point: (" << aPe.X() << ", " << aPe.Y() << ", " << + aPe.Z() << ")." << endl; + cout << "Real point: (" << aPf.X() << ", " << aPf.Y() << ", " << + aPf.Z() << ")." << endl; + cout << "dist**2 = " << dist << + "; Tol = " << aTol << "\n-----" << endl; +#endif + + const Standard_Real dUpar2 = du*du; + const Standard_Real dVpar2 = dv*dv; + const Standard_Real dUVpar = du*dv; + + //2nd degree estimation + aPe.SetXYZ(gp_XYZ(aPe.X() + (aD2Sdu2.X()*dUpar2 + + 2.0*aD2Sdudv.X()*dUVpar + aD2Sdv2.X()*dVpar2)/2.0, + aPe.Y() + (aD2Sdu2.Y()*dUpar2 + + 2.0*aD2Sdudv.Y()*dUVpar + aD2Sdv2.Y()*dVpar2)/2.0, + aPe.Z() + (aD2Sdu2.Z()*dUpar2 + + 2.0*aD2Sdudv.Z()*dUVpar + aD2Sdv2.Z()*dVpar2)/2.0)); + + dist = aPe.SquareDistance(aPf); + + if(dist > aTol) + { +#ifdef DEB + cout << endl << "++++\nFunction Validate(...); file: " + "BRepCheck_Edge.cxx (2nd degree)" << endl; + cout << "Exp. point: (" << aPe.X() << ", " << aPe.Y() << ", " << + aPe.Z() << ")." << endl; + cout << "Real point: (" << aPf.X() << ", " << aPf.Y() << ", " << + aPf.Z() << ")." << endl; + cout << "dist**2 = " << dist << + "; Tol = " << aTol << "\n-----" << endl; +#endif + Status = BRepCheck_PCurveIsOutOfDomainFace; + return Status; + } + }//for(Standard_Integer anIndex = 0; anIndex < 2; anIndex++) + }//if(!isIntoBoundaries) + }//if (!proj) + else + { Extrema_LocateExtPC refd,otherd; Standard_Real OFirst = Other.FirstParameter(); Standard_Real OLast = Other.LastParameter(); gp_Pnt pd = CRef.Value(First); gp_Pnt pdo = Other.Value(OFirst); Standard_Real distt = pd.SquareDistance(pdo); - if (distt > Tol*Tol) { - problematic_point = pd ; - Status = Standard_False ; - Error = Sqrt(distt); + + if (distt > Tol*Tol) + { + const gp_Pnt problematic_point(pd); + Status = BRepCheck_InvalidCurveOnSurface ; + const Standard_Real Error = Sqrt(distt); PrintProblematicPoint(problematic_point, Error, Tol); return Status; //goto FINISH ; } + pd = CRef.Value(Last); pdo = Other.Value(OLast); distt = pd.SquareDistance(pdo); - if (distt > Tol*Tol) { - problematic_point = pd ; - Status = Standard_False ; - Error = Sqrt(distt); + + if (distt > Tol*Tol) + { + const gp_Pnt problematic_point(pd); + Status = BRepCheck_InvalidCurveOnSurface ; + const Standard_Real Error = Sqrt(distt); PrintProblematicPoint(problematic_point, Error, Tol); return Status; //goto FINISH ; @@ -624,57 +978,50 @@ Standard_Boolean Validate(const Adaptor3d_Curve& CRef, refd.Initialize(CRef,First,Last,CRef.Resolution(Tol)); otherd.Initialize(Other,OFirst,OLast,Other.Resolution(Tol)); - for (Standard_Integer i = 2; i< NCONTROL-1; i++) { - Standard_Real rprm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1); + + for (Standard_Integer i = 2; i< aNbControl-1; i++) + { + Standard_Real rprm = ((aNbControl-1-i)*First + i*Last)/(aNbControl-1); gp_Pnt pref = CRef.Value(rprm); - Standard_Real oprm = ((NCONTROL-1-i)*OFirst + i*OLast)/(NCONTROL-1); + Standard_Real oprm = ((aNbControl-1-i)*OFirst + i*OLast)/(aNbControl-1); gp_Pnt pother = Other.Value(oprm); refd.Perform(pother,rprm); - if (!refd.IsDone() || refd.SquareDistance() > Tol * Tol) { - problematic_point = pref ; - Status = Standard_False ; - if (refd.IsDone()) { - Error = sqrt (refd.SquareDistance()); - } - else { - Error = RealLast(); - } - PrintProblematicPoint(problematic_point, Error, Tol); - return Status; + + if (!refd.IsDone() || refd.SquareDistance() > Tol * Tol) + { + const gp_Pnt problematic_point(pref); + Status = BRepCheck_InvalidCurveOnSurface ; + + const Standard_Real Error = refd.IsDone() ? + sqrt (refd.SquareDistance()) : + RealLast(); + + PrintProblematicPoint(problematic_point, Error, Tol); + return Status; //goto FINISH ; } + otherd.Perform(pref,oprm); - if (!otherd.IsDone() || otherd.SquareDistance() > Tol * Tol) { - problematic_point = pref ; - Status = Standard_False ; - if (otherd.IsDone()) { - Error = sqrt (otherd.SquareDistance()); - } - else { - Error = RealLast(); - } - PrintProblematicPoint(problematic_point, Error, Tol); - return Status; - //goto FINISH ; + + if (!otherd.IsDone() || otherd.SquareDistance() > Tol * Tol) + { + const gp_Pnt problematic_point(pref); + Status = BRepCheck_InvalidCurveOnSurface ; + + const Standard_Real Error = otherd.IsDone() ? + sqrt (otherd.SquareDistance()) : + RealLast(); + + PrintProblematicPoint(problematic_point, Error, Tol); + return Status; + //goto FINISH ; } } } - //FINISH : -/* -#ifdef DEB - if (! Status) { - cout << " **** probleme de SameParameter au point :" << endl; - cout << " " << problematic_point.Coord(1) << " " - << problematic_point.Coord(2) << " " - << problematic_point.Coord(3) << endl ; - cout << " Erreur detectee :" << Error << " Tolerance :" << Tol << endl; - } -#endif -*/ - - return Status ; + return Status ; } + //======================================================================= //function : Prec //purpose : diff --git a/src/BRepCheck/BRepCheck_Face.cdl b/src/BRepCheck/BRepCheck_Face.cdl index 5e40a93f53..fe6aea5341 100644 --- a/src/BRepCheck/BRepCheck_Face.cdl +++ b/src/BRepCheck/BRepCheck_Face.cdl @@ -66,6 +66,13 @@ is is static; + SetStatus(me: mutable; + theStatus:Status from BRepCheck) + + --- Purpose: Sets status of Face; + is static; + + IsUnorientable(me) diff --git a/src/BRepCheck/BRepCheck_Face.cxx b/src/BRepCheck/BRepCheck_Face.cxx index c971583a1c..62e45528b4 100644 --- a/src/BRepCheck/BRepCheck_Face.cxx +++ b/src/BRepCheck/BRepCheck_Face.cxx @@ -494,6 +494,15 @@ void BRepCheck_Face::SetUnorientable() BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape); } +//======================================================================= +//function : SetStatus +//purpose : +//======================================================================= + +void BRepCheck_Face::SetStatus(const BRepCheck_Status theStatus) +{ + BRepCheck::Add(myMap(myShape),theStatus); +} //======================================================================= //function : IsUnorientable diff --git a/src/BRepCheck/BRepCheck_Wire.cxx b/src/BRepCheck/BRepCheck_Wire.cxx index c4c8d202a9..740ab7449a 100644 --- a/src/BRepCheck/BRepCheck_Wire.cxx +++ b/src/BRepCheck/BRepCheck_Wire.cxx @@ -384,7 +384,7 @@ Standard_Boolean IsDistanceIn3DTolerance (const BRepAdaptor_Surface& /*aFaceSurf #ifdef DEB cout << endl; cout << "--------Function IsDistanceIn3DTolerance(...)----------" << endl; - cout << "--- BRepCheck Wire: Closed3d -> Error" << endl; + cout << "--- BRepCheck Wire: Not closed in 3D" << endl; cout << "--- Dist (" << Dist << ") > Tol3d (" << aTol3d << ")" << endl; cout << "Pnt1(" << thePnt_f.X() << "; " << thePnt_f.Y() << "; " << thePnt_f.Z() << ")" << endl; cout << "Pnt2(" << thePnt_l.X() << "; " << thePnt_l.Y() << "; " << thePnt_l.Z() << ")" << endl; @@ -422,7 +422,7 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac { cout << endl; cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl; - cout << "--- BRepCheck Wire: Not closed in 2d" << endl; + cout << "--- BRepCheck Wire: Not closed in 2D" << endl; cout << "*****************************************************" << endl; cout << "*dumin = " << dumin << "; dumax = " << dumax << endl; cout << "* dvmin = " << dvmin << "; dvmax = " << dvmax << endl; @@ -471,7 +471,7 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac { cout << endl; cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl; - cout << "--- BRepCheck Wire: Not closed in 2d" << endl; + cout << "--- BRepCheck Wire: Not closed in 2D" << endl; cout << "*****************************************************" << endl; cout << "* Dist = " << Dist << " > Tol2d = " << aTol2d << endl; cout << "*****************************************************" << endl; diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index f339ab5828..881d06f6f3 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -16,72 +16,49 @@ //pmn 26/09/97 Add parameters of approximation in BuildCurve3d // Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 - #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include +#include // TODO - not thread-safe static variables static Standard_Real thePrecision = Precision::Confusion(); @@ -134,14 +111,14 @@ const Handle(Geom_Plane)& BRepLib::Plane() //======================================================================= Standard_Boolean BRepLib::CheckSameRange(const TopoDS_Edge& AnEdge, - const Standard_Real Tolerance) + const Standard_Real Tolerance) { Standard_Boolean IsSameRange = Standard_True, - first_time_in = Standard_True ; + first_time_in = Standard_True ; BRep_ListIteratorOfListOfCurveRepresentation an_Iterator ((*((Handle(BRep_TEdge)*)&AnEdge.TShape()))->ChangeCurves()); - + Standard_Real first, last; Standard_Real current_first =0., current_last =0. ; Handle(BRep_GCurve) geometric_representation_ptr ; @@ -150,115 +127,115 @@ Standard_Boolean BRepLib::CheckSameRange(const TopoDS_Edge& AnEdge, geometric_representation_ptr = Handle(BRep_GCurve)::DownCast(an_Iterator.Value()); if (!geometric_representation_ptr.IsNull()) { - - first = geometric_representation_ptr->First(); - last = geometric_representation_ptr->Last(); - if (first_time_in ) { - current_first = first ; - current_last = last ; - first_time_in = Standard_False ; + + first = geometric_representation_ptr->First(); + last = geometric_representation_ptr->Last(); + if (first_time_in ) { + current_first = first ; + current_last = last ; + first_time_in = Standard_False ; + } + else { + IsSameRange = (Abs(current_first - first) <= Tolerance) + && (Abs(current_last -last) <= Tolerance ) ; + } } - else { - IsSameRange = (Abs(current_first - first) <= Tolerance) - && (Abs(current_last -last) <= Tolerance ) ; - } - } an_Iterator.Next() ; } return IsSameRange ; } - + //======================================================================= //function : SameRange //purpose : //======================================================================= void BRepLib::SameRange(const TopoDS_Edge& AnEdge, - const Standard_Real Tolerance) + const Standard_Real Tolerance) { BRep_ListIteratorOfListOfCurveRepresentation an_Iterator ((*((Handle(BRep_TEdge)*)&AnEdge.TShape()))->ChangeCurves()); - + Handle(Geom2d_Curve) Curve2dPtr, Curve2dPtr2, NewCurve2dPtr, NewCurve2dPtr2; TopLoc_Location LocalLoc ; Standard_Boolean first_time_in = Standard_True, - has_curve, - has_closed_curve ; + has_curve, + has_closed_curve ; Handle(BRep_GCurve) geometric_representation_ptr ; Standard_Real first, - current_first, - last, - current_last ; + current_first, + last, + current_last ; const Handle(Geom_Curve) C = BRep_Tool::Curve(AnEdge, - LocalLoc, - current_first, - current_last); + LocalLoc, + current_first, + current_last); if (!C.IsNull()) { first_time_in = Standard_False ; } - + while (an_Iterator.More()) { geometric_representation_ptr = Handle(BRep_GCurve)::DownCast(an_Iterator.Value()); if (! geometric_representation_ptr.IsNull()) { has_closed_curve = - has_curve = Standard_False ; + has_curve = Standard_False ; first = geometric_representation_ptr->First(); last = geometric_representation_ptr->Last(); if (geometric_representation_ptr->IsCurveOnSurface()) { - Curve2dPtr = geometric_representation_ptr->PCurve() ; - has_curve = Standard_True ; + Curve2dPtr = geometric_representation_ptr->PCurve() ; + has_curve = Standard_True ; } if (geometric_representation_ptr->IsCurveOnClosedSurface()) { - Curve2dPtr2 = geometric_representation_ptr->PCurve2() ; - has_closed_curve = Standard_True ; + Curve2dPtr2 = geometric_representation_ptr->PCurve2() ; + has_closed_curve = Standard_True ; } if (has_curve || has_closed_curve) { - if (first_time_in) { - current_first = first ; - current_last = last ; - first_time_in = Standard_False ; + if (first_time_in) { + current_first = first ; + current_last = last ; + first_time_in = Standard_False ; } - + if (Abs(first - current_first) > Precision::Confusion() || - Abs(last - current_last) > Precision::Confusion() ) - { - if (has_curve) - { - GeomLib::SameRange(Tolerance, - Curve2dPtr, - geometric_representation_ptr->First(), - geometric_representation_ptr->Last(), - current_first, - current_last, - NewCurve2dPtr); - geometric_representation_ptr->PCurve(NewCurve2dPtr) ; - } - if (has_closed_curve) - { - GeomLib::SameRange(Tolerance, - Curve2dPtr2, - geometric_representation_ptr->First(), - geometric_representation_ptr->Last(), - current_first, - current_last, - NewCurve2dPtr2); - geometric_representation_ptr->PCurve2(NewCurve2dPtr2) ; - } - } + Abs(last - current_last) > Precision::Confusion() ) + { + if (has_curve) + { + GeomLib::SameRange(Tolerance, + Curve2dPtr, + geometric_representation_ptr->First(), + geometric_representation_ptr->Last(), + current_first, + current_last, + NewCurve2dPtr); + geometric_representation_ptr->PCurve(NewCurve2dPtr) ; + } + if (has_closed_curve) + { + GeomLib::SameRange(Tolerance, + Curve2dPtr2, + geometric_representation_ptr->First(), + geometric_representation_ptr->Last(), + current_first, + current_last, + NewCurve2dPtr2); + geometric_representation_ptr->PCurve2(NewCurve2dPtr2) ; + } + } } } an_Iterator.Next() ; } BRep_Builder B; B.Range(TopoDS::Edge(AnEdge), - current_first, - current_last) ; + current_first, + current_last) ; B.SameRange(AnEdge, - Standard_True) ; + Standard_True) ; } //======================================================================= @@ -267,7 +244,7 @@ void BRepLib::SameRange(const TopoDS_Edge& AnEdge, //======================================================================= static Standard_Integer evaluateMaxSegment(const Standard_Integer aMaxSegment, - const Adaptor3d_CurveOnSurface& aCurveOnSurface) + const Adaptor3d_CurveOnSurface& aCurveOnSurface) { if (aMaxSegment != 0) return aMaxSegment; @@ -275,7 +252,7 @@ static Standard_Integer evaluateMaxSegment(const Standard_Integer aMaxSegment, Handle(Adaptor2d_HCurve2d) aCurv2d = aCurveOnSurface.GetCurve(); Standard_Real aNbSKnots = 0, aNbC2dKnots = 0; - + if (aSurf->GetType() == GeomAbs_BSplineSurface) { Handle(Geom_BSplineSurface) aBSpline = aSurf->BSpline(); aNbSKnots = Max(aBSpline->NbUKnots(), aBSpline->NbVKnots()); @@ -293,22 +270,22 @@ static Standard_Integer evaluateMaxSegment(const Standard_Integer aMaxSegment, //======================================================================= Standard_Boolean BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, - const Standard_Real Tolerance, - const GeomAbs_Shape Continuity, - const Standard_Integer MaxDegree, - const Standard_Integer MaxSegment) + const Standard_Real Tolerance, + const GeomAbs_Shape Continuity, + const Standard_Integer MaxDegree, + const Standard_Integer MaxSegment) { Standard_Integer //ErrorCode, - // ReturnCode = 0, - ii, - // num_knots, - jj; +// ReturnCode = 0, + ii, +// num_knots, + jj; TopLoc_Location LocalLoc,L[2],LC; Standard_Real f,l,fc,lc, first[2], last[2], - tolerance, - max_deviation, - average_deviation ; + tolerance, + max_deviation, + average_deviation ; Handle(Geom2d_Curve) Curve2dPtr, Curve2dArray[2] ; Handle(Geom_Surface) SurfacePtr, SurfaceArray[2] ; @@ -319,17 +296,17 @@ Standard_Boolean BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, const Handle(Geom_Curve) C = BRep_Tool::Curve(AnEdge,LocalLoc,f,l); if (!C.IsNull()) return Standard_True; - // - // this should not exists but UpdateEdge makes funny things - // if the edge is not same range - // +// +// this should not exists but UpdateEdge makes funny things +// if the edge is not same range +// if (! CheckSameRange(AnEdge, - Precision::Confusion())) { - SameRange(AnEdge, - Tolerance) ; + Precision::Confusion())) { + SameRange(AnEdge, + Tolerance) ; } - + // search a curve on a plane Handle(Geom_Surface) S; @@ -362,8 +339,8 @@ Standard_Boolean BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, BRep_Builder B; Standard_Boolean is_closed ; - is_closed = AnEdge.Closed() ; - + is_closed = AnEdge.Closed() ; + B.UpdateEdge(AnEdge,C3d,LocalLoc,0.0e0); BRep_Tool::Range(AnEdge, S, LC, First, Last); B.Range(AnEdge, First, Last); //Do not forget 3D range.(PRO6412) @@ -380,49 +357,49 @@ Standard_Boolean BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, if (!BRep_Tool::Degenerated(AnEdge)) { jj = 0 ; for (ii = 0 ; ii < 3 ; ii++ ) { - BRep_Tool::CurveOnSurface(TopoDS::Edge(AnEdge), - Curve2dPtr, - SurfacePtr, - LocalLoc, - fc, - lc, - ii) ; - - if (!Curve2dPtr.IsNull() && jj < 2){ - Curve2dArray[jj] = Curve2dPtr ; - SurfaceArray[jj] = SurfacePtr ; - L[jj] = LocalLoc ; - first[jj] = fc ; - last[jj] = lc ; - jj += 1 ; - } + BRep_Tool::CurveOnSurface(TopoDS::Edge(AnEdge), + Curve2dPtr, + SurfacePtr, + LocalLoc, + fc, + lc, + ii) ; + + if (!Curve2dPtr.IsNull() && jj < 2){ + Curve2dArray[jj] = Curve2dPtr ; + SurfaceArray[jj] = SurfacePtr ; + L[jj] = LocalLoc ; + first[jj] = fc ; + last[jj] = lc ; + jj += 1 ; + } } f = first[0] ; l = last[0] ; Curve2dPtr = Curve2dArray[0] ; SurfacePtr = SurfaceArray[0] ; - + Geom2dAdaptor_Curve AnAdaptor3dCurve2d (Curve2dPtr, f, l) ; GeomAdaptor_Surface AnAdaptor3dSurface (SurfacePtr) ; Handle(Geom2dAdaptor_HCurve) AnAdaptor3dCurve2dPtr = - new Geom2dAdaptor_HCurve(AnAdaptor3dCurve2d) ; + new Geom2dAdaptor_HCurve(AnAdaptor3dCurve2d) ; Handle(GeomAdaptor_HSurface) AnAdaptor3dSurfacePtr = - new GeomAdaptor_HSurface (AnAdaptor3dSurface) ; + new GeomAdaptor_HSurface (AnAdaptor3dSurface) ; Adaptor3d_CurveOnSurface CurveOnSurface( AnAdaptor3dCurve2dPtr, - AnAdaptor3dSurfacePtr) ; - + AnAdaptor3dSurfacePtr) ; + Handle(Geom_Curve) NewCurvePtr ; GeomLib::BuildCurve3d(Tolerance, - CurveOnSurface, - f, - l, - NewCurvePtr, - max_deviation, - average_deviation, - Continuity, - MaxDegree, - evaluateMaxSegment(MaxSegment,CurveOnSurface)) ; + CurveOnSurface, + f, + l, + NewCurvePtr, + max_deviation, + average_deviation, + Continuity, + MaxDegree, + evaluateMaxSegment(MaxSegment,CurveOnSurface)) ; BRep_Builder B; tolerance = BRep_Tool::Tolerance(AnEdge) ; //Patch @@ -433,24 +410,24 @@ Standard_Boolean BRepLib::BuildCurve3d(const TopoDS_Edge& AnEdge, Standard_Boolean is_closed ; is_closed = AnEdge.Closed() ; B.UpdateEdge(TopoDS::Edge(AnEdge), - NewCurvePtr, - L[0], - max_deviation) ; + NewCurvePtr, + L[0], + max_deviation) ; TopoDS_Edge E = AnEdge ; E.Closed(is_closed) ; if (jj == 1 ) { - // - // if there is only one curve on surface attached to the edge - // than it can be qualified sameparameter - // - B.SameParameter(TopoDS::Edge(AnEdge), - Standard_True) ; +// +// if there is only one curve on surface attached to the edge +// than it can be qualified sameparameter +// + B.SameParameter(TopoDS::Edge(AnEdge), + Standard_True) ; } } else { return Standard_False ; } - + } return Standard_True; } @@ -463,7 +440,7 @@ Standard_Boolean BRepLib::BuildCurves3d(const TopoDS_Shape& S) { return BRepLib::BuildCurves3d(S, - 1.0e-5) ; + 1.0e-5) ; } //======================================================================= @@ -472,22 +449,22 @@ Standard_Boolean BRepLib::BuildCurves3d(const TopoDS_Shape& S) //======================================================================= Standard_Boolean BRepLib::BuildCurves3d(const TopoDS_Shape& S, - const Standard_Real Tolerance, - const GeomAbs_Shape Continuity, - const Standard_Integer MaxDegree, - const Standard_Integer MaxSegment) + const Standard_Real Tolerance, + const GeomAbs_Shape Continuity, + const Standard_Integer MaxDegree, + const Standard_Integer MaxSegment) { Standard_Boolean boolean_value, - ok = Standard_True; + ok = Standard_True; TopTools_MapOfShape a_counter ; TopExp_Explorer ex(S,TopAbs_EDGE); while (ex.More()) { if (a_counter.Add(ex.Current())) { boolean_value = - BuildCurve3d(TopoDS::Edge(ex.Current()), - Tolerance, Continuity, - MaxDegree, MaxSegment); + BuildCurve3d(TopoDS::Edge(ex.Current()), + Tolerance, Continuity, + MaxDegree, MaxSegment); ok = ok && boolean_value ; } ex.Next(); @@ -500,216 +477,216 @@ Standard_Boolean BRepLib::BuildCurves3d(const TopoDS_Shape& S, //======================================================================= Standard_Boolean BRepLib::UpdateEdgeTol(const TopoDS_Edge& AnEdge, - const Standard_Real MinToleranceRequested, - const Standard_Real MaxToleranceToCheck) -{ - - Standard_Integer curve_on_surface_index, - curve_index, - not_done, - has_closed_curve, - has_curve, - jj, - ii, - geom_reference_curve_flag = 0, - max_sampling_points = 90, - min_sampling_points = 30 ; - - Standard_Real factor = 100.0e0, - // sampling_array[2], - safe_factor = 1.4e0, - current_last, - current_first, - max_distance, - coded_edge_tolerance, - edge_tolerance = 0.0e0 ; - Handle(TColStd_HArray1OfReal) parameters_ptr ; - Handle(BRep_GCurve) geometric_representation_ptr ; - - if (BRep_Tool::Degenerated(AnEdge)) return Standard_False ; - coded_edge_tolerance = BRep_Tool::Tolerance(AnEdge) ; - if (coded_edge_tolerance > MaxToleranceToCheck) return Standard_False ; - - const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&AnEdge.TShape()); - BRep_ListOfCurveRepresentation& list_curve_rep = TE->ChangeCurves() ; - BRep_ListIteratorOfListOfCurveRepresentation an_iterator(list_curve_rep), - second_iterator(list_curve_rep) ; - Handle(Geom2d_Curve) curve2d_ptr, new_curve2d_ptr; - Handle(Geom_Surface) surface_ptr ; - TopLoc_Location local_location ; - GCPnts_QuasiUniformDeflection a_sampler ; - GeomAdaptor_Curve geom_reference_curve ; - Adaptor3d_CurveOnSurface curve_on_surface_reference ; - Handle(Geom_Curve) C = BRep_Tool::Curve(AnEdge, - local_location, - current_first, - current_last); - curve_on_surface_index = -1 ; - if (!C.IsNull()) { - if (! local_location.IsIdentity()) { - C = Handle(Geom_Curve):: - DownCast(C-> Transformed(local_location.Transformation()) ) ; - } - geom_reference_curve.Load(C) ; - geom_reference_curve_flag = 1 ; - a_sampler.Initialize(geom_reference_curve, - MinToleranceRequested * factor, + const Standard_Real MinToleranceRequested, + const Standard_Real MaxToleranceToCheck) + { + + Standard_Integer curve_on_surface_index, + curve_index, + not_done, + has_closed_curve, + has_curve, + jj, + ii, + geom_reference_curve_flag = 0, + max_sampling_points = 90, + min_sampling_points = 30 ; + + Standard_Real factor = 100.0e0, + // sampling_array[2], + safe_factor = 1.4e0, + current_last, current_first, - current_last) ; - } - else { - not_done = 1 ; - curve_on_surface_index = 0 ; + max_distance, + coded_edge_tolerance, + edge_tolerance = 0.0e0 ; + Handle(TColStd_HArray1OfReal) parameters_ptr ; + Handle(BRep_GCurve) geometric_representation_ptr ; - while (not_done && an_iterator.More()) { - geometric_representation_ptr = - Handle(BRep_GCurve)::DownCast(second_iterator.Value()); - if (!geometric_representation_ptr.IsNull() - && geometric_representation_ptr->IsCurveOnSurface()) { - curve2d_ptr = geometric_representation_ptr->PCurve() ; - local_location = geometric_representation_ptr->Location() ; - current_first = geometric_representation_ptr->First(); - //first = geometric_representation_ptr->First(); - current_last = geometric_representation_ptr->Last(); - // must be inverted - // - if (! local_location.IsIdentity() ) { - surface_ptr = Handle(Geom_Surface):: - DownCast( geometric_representation_ptr->Surface()-> - Transformed(local_location.Transformation()) ) ; - } - else { - surface_ptr = - geometric_representation_ptr->Surface() ; - } - not_done = 0 ; + if (BRep_Tool::Degenerated(AnEdge)) return Standard_False ; + coded_edge_tolerance = BRep_Tool::Tolerance(AnEdge) ; + if (coded_edge_tolerance > MaxToleranceToCheck) return Standard_False ; + + const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&AnEdge.TShape()); + BRep_ListOfCurveRepresentation& list_curve_rep = TE->ChangeCurves() ; + BRep_ListIteratorOfListOfCurveRepresentation an_iterator(list_curve_rep), + second_iterator(list_curve_rep) ; + Handle(Geom2d_Curve) curve2d_ptr, new_curve2d_ptr; + Handle(Geom_Surface) surface_ptr ; + TopLoc_Location local_location ; + GCPnts_QuasiUniformDeflection a_sampler ; + GeomAdaptor_Curve geom_reference_curve ; + Adaptor3d_CurveOnSurface curve_on_surface_reference ; + Handle(Geom_Curve) C = BRep_Tool::Curve(AnEdge, + local_location, + current_first, + current_last); + curve_on_surface_index = -1 ; + if (!C.IsNull()) { + if (! local_location.IsIdentity()) { + C = Handle(Geom_Curve):: + DownCast(C-> Transformed(local_location.Transformation()) ) ; } - curve_on_surface_index += 1 ; + geom_reference_curve.Load(C) ; + geom_reference_curve_flag = 1 ; + a_sampler.Initialize(geom_reference_curve, + MinToleranceRequested * factor, + current_first, + current_last) ; } - Geom2dAdaptor_Curve AnAdaptor3dCurve2d (curve2d_ptr) ; - GeomAdaptor_Surface AnAdaptor3dSurface (surface_ptr) ; - Handle(Geom2dAdaptor_HCurve) AnAdaptor3dCurve2dPtr = - new Geom2dAdaptor_HCurve(AnAdaptor3dCurve2d) ; - Handle(GeomAdaptor_HSurface) AnAdaptor3dSurfacePtr = - new GeomAdaptor_HSurface (AnAdaptor3dSurface) ; - curve_on_surface_reference.Load( AnAdaptor3dCurve2dPtr) ; - curve_on_surface_reference.Load( AnAdaptor3dSurfacePtr) ; - a_sampler.Initialize(curve_on_surface_reference, - MinToleranceRequested * factor, - current_first, - current_last) ; - } - TColStd_Array1OfReal sampling_parameters(1,a_sampler.NbPoints()) ; - for (ii = 1 ; ii <= a_sampler.NbPoints() ; ii++) { - sampling_parameters(ii) = a_sampler.Parameter(ii) ; - } - if (a_sampler.NbPoints() < min_sampling_points) { - GeomLib::DensifyArray1OfReal(min_sampling_points, - sampling_parameters, - parameters_ptr) ; - } - else if (a_sampler.NbPoints() > max_sampling_points) { - GeomLib::RemovePointsFromArray(max_sampling_points, - sampling_parameters, - parameters_ptr) ; - } - else { - jj = 1 ; - parameters_ptr = - new TColStd_HArray1OfReal(1,sampling_parameters.Length()) ; - for (ii = sampling_parameters.Lower() ; ii <= sampling_parameters.Upper() ; ii++) { - parameters_ptr->ChangeArray1()(jj) = - sampling_parameters(ii) ; - jj +=1 ; + else { + not_done = 1 ; + curve_on_surface_index = 0 ; + + while (not_done && an_iterator.More()) { + geometric_representation_ptr = + Handle(BRep_GCurve)::DownCast(second_iterator.Value()); + if (!geometric_representation_ptr.IsNull() + && geometric_representation_ptr->IsCurveOnSurface()) { + curve2d_ptr = geometric_representation_ptr->PCurve() ; + local_location = geometric_representation_ptr->Location() ; + current_first = geometric_representation_ptr->First(); + //first = geometric_representation_ptr->First(); + current_last = geometric_representation_ptr->Last(); + // must be inverted + // + if (! local_location.IsIdentity() ) { + surface_ptr = Handle(Geom_Surface):: + DownCast( geometric_representation_ptr->Surface()-> + Transformed(local_location.Transformation()) ) ; + } + else { + surface_ptr = + geometric_representation_ptr->Surface() ; + } + not_done = 0 ; + } + curve_on_surface_index += 1 ; + } + Geom2dAdaptor_Curve AnAdaptor3dCurve2d (curve2d_ptr) ; + GeomAdaptor_Surface AnAdaptor3dSurface (surface_ptr) ; + Handle(Geom2dAdaptor_HCurve) AnAdaptor3dCurve2dPtr = + new Geom2dAdaptor_HCurve(AnAdaptor3dCurve2d) ; + Handle(GeomAdaptor_HSurface) AnAdaptor3dSurfacePtr = + new GeomAdaptor_HSurface (AnAdaptor3dSurface) ; + curve_on_surface_reference.Load( AnAdaptor3dCurve2dPtr) ; + curve_on_surface_reference.Load( AnAdaptor3dSurfacePtr) ; + a_sampler.Initialize(curve_on_surface_reference, + MinToleranceRequested * factor, + current_first, + current_last) ; } - } - - curve_index = 0 ; - - while (second_iterator.More()) { - geometric_representation_ptr = - Handle(BRep_GCurve)::DownCast(second_iterator.Value()); - if (! geometric_representation_ptr.IsNull() && - curve_index != curve_on_surface_index) { - has_closed_curve = - has_curve = Standard_False ; - // first = geometric_representation_ptr->First(); - // last = geometric_representation_ptr->Last(); - local_location = geometric_representation_ptr->Location() ; - if (geometric_representation_ptr->IsCurveOnSurface()) { - curve2d_ptr = geometric_representation_ptr->PCurve() ; - has_curve = Standard_True ; - } - if (geometric_representation_ptr->IsCurveOnClosedSurface()) { - curve2d_ptr = geometric_representation_ptr->PCurve2() ; - has_closed_curve = Standard_True ; - } - - if (has_curve || - has_closed_curve) { - if (! local_location.IsIdentity() ) { - surface_ptr = Handle(Geom_Surface):: - DownCast( geometric_representation_ptr->Surface()-> - Transformed(local_location.Transformation()) ) ; - } - else { - surface_ptr = - geometric_representation_ptr->Surface() ; - } - Geom2dAdaptor_Curve an_adaptor_curve2d (curve2d_ptr) ; - GeomAdaptor_Surface an_adaptor_surface(surface_ptr) ; - Handle(Geom2dAdaptor_HCurve) an_adaptor_curve2d_ptr = - new Geom2dAdaptor_HCurve(an_adaptor_curve2d) ; - Handle(GeomAdaptor_HSurface) an_adaptor_surface_ptr = - new GeomAdaptor_HSurface (an_adaptor_surface) ; - Adaptor3d_CurveOnSurface a_curve_on_surface(an_adaptor_curve2d_ptr, - an_adaptor_surface_ptr) ; - - if (BRep_Tool::SameParameter(AnEdge)) { - - GeomLib::EvalMaxParametricDistance(a_curve_on_surface, - geom_reference_curve, - MinToleranceRequested, - parameters_ptr->Array1(), - max_distance) ; - } - else if (geom_reference_curve_flag) { - GeomLib::EvalMaxDistanceAlongParameter(a_curve_on_surface, - geom_reference_curve, - MinToleranceRequested, - parameters_ptr->Array1(), - max_distance) ; - } - else { - - GeomLib::EvalMaxDistanceAlongParameter(a_curve_on_surface, - curve_on_surface_reference, - MinToleranceRequested, - parameters_ptr->Array1(), - max_distance) ; - } - max_distance *= safe_factor ; - edge_tolerance = Max(max_distance, edge_tolerance) ; - } - - + TColStd_Array1OfReal sampling_parameters(1,a_sampler.NbPoints()) ; + for (ii = 1 ; ii <= a_sampler.NbPoints() ; ii++) { + sampling_parameters(ii) = a_sampler.Parameter(ii) ; } - curve_index += 1 ; - second_iterator.Next() ; + if (a_sampler.NbPoints() < min_sampling_points) { + GeomLib::DensifyArray1OfReal(min_sampling_points, + sampling_parameters, + parameters_ptr) ; + } + else if (a_sampler.NbPoints() > max_sampling_points) { + GeomLib::RemovePointsFromArray(max_sampling_points, + sampling_parameters, + parameters_ptr) ; + } + else { + jj = 1 ; + parameters_ptr = + new TColStd_HArray1OfReal(1,sampling_parameters.Length()) ; + for (ii = sampling_parameters.Lower() ; ii <= sampling_parameters.Upper() ; ii++) { + parameters_ptr->ChangeArray1()(jj) = + sampling_parameters(ii) ; + jj +=1 ; + } + } + + curve_index = 0 ; + + while (second_iterator.More()) { + geometric_representation_ptr = + Handle(BRep_GCurve)::DownCast(second_iterator.Value()); + if (! geometric_representation_ptr.IsNull() && + curve_index != curve_on_surface_index) { + has_closed_curve = + has_curve = Standard_False ; +// first = geometric_representation_ptr->First(); +// last = geometric_representation_ptr->Last(); + local_location = geometric_representation_ptr->Location() ; + if (geometric_representation_ptr->IsCurveOnSurface()) { + curve2d_ptr = geometric_representation_ptr->PCurve() ; + has_curve = Standard_True ; + } + if (geometric_representation_ptr->IsCurveOnClosedSurface()) { + curve2d_ptr = geometric_representation_ptr->PCurve2() ; + has_closed_curve = Standard_True ; + } + + if (has_curve || + has_closed_curve) { + if (! local_location.IsIdentity() ) { + surface_ptr = Handle(Geom_Surface):: + DownCast( geometric_representation_ptr->Surface()-> + Transformed(local_location.Transformation()) ) ; + } + else { + surface_ptr = + geometric_representation_ptr->Surface() ; + } + Geom2dAdaptor_Curve an_adaptor_curve2d (curve2d_ptr) ; + GeomAdaptor_Surface an_adaptor_surface(surface_ptr) ; + Handle(Geom2dAdaptor_HCurve) an_adaptor_curve2d_ptr = + new Geom2dAdaptor_HCurve(an_adaptor_curve2d) ; + Handle(GeomAdaptor_HSurface) an_adaptor_surface_ptr = + new GeomAdaptor_HSurface (an_adaptor_surface) ; + Adaptor3d_CurveOnSurface a_curve_on_surface(an_adaptor_curve2d_ptr, + an_adaptor_surface_ptr) ; + + if (BRep_Tool::SameParameter(AnEdge)) { + + GeomLib::EvalMaxParametricDistance(a_curve_on_surface, + geom_reference_curve, + MinToleranceRequested, + parameters_ptr->Array1(), + max_distance) ; + } + else if (geom_reference_curve_flag) { + GeomLib::EvalMaxDistanceAlongParameter(a_curve_on_surface, + geom_reference_curve, + MinToleranceRequested, + parameters_ptr->Array1(), + max_distance) ; + } + else { + + GeomLib::EvalMaxDistanceAlongParameter(a_curve_on_surface, + curve_on_surface_reference, + MinToleranceRequested, + parameters_ptr->Array1(), + max_distance) ; + } + max_distance *= safe_factor ; + edge_tolerance = Max(max_distance, edge_tolerance) ; + } + + + } + curve_index += 1 ; + second_iterator.Next() ; + } + + TE->Tolerance(edge_tolerance); + return Standard_True ; + } - - TE->Tolerance(edge_tolerance); - return Standard_True ; - -} //======================================================================= //function : UpdateEdgeTolerance //purpose : //======================================================================= Standard_Boolean BRepLib::UpdateEdgeTolerance(const TopoDS_Shape& S, - const Standard_Real MinToleranceRequested, - const Standard_Real MaxToleranceToCheck) + const Standard_Real MinToleranceRequested, + const Standard_Real MaxToleranceToCheck) { TopExp_Explorer ex(S,TopAbs_EDGE); TopTools_MapOfShape a_counter ; @@ -720,11 +697,11 @@ Standard_Boolean BRepLib::UpdateEdgeTolerance(const TopoDS_Shape& S, while (ex.More()) { if (a_counter.Add(ex.Current())) { local_flag = - BRepLib::UpdateEdgeTol(TopoDS::Edge(ex.Current()), - MinToleranceRequested, - MaxToleranceToCheck) ; + BRepLib::UpdateEdgeTol(TopoDS::Edge(ex.Current()), + MinToleranceRequested, + MaxToleranceToCheck) ; if (local_flag && ! return_status) { - return_status = Standard_True ; + return_status = Standard_True ; } } ex.Next(); @@ -738,7 +715,7 @@ Standard_Boolean BRepLib::UpdateEdgeTolerance(const TopoDS_Shape& S, //======================================================================= static void SetEdgeTol(const TopoDS_Edge& E, - const TopoDS_Face& F) + const TopoDS_Face& F) { TopLoc_Location L; const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L); @@ -763,7 +740,7 @@ static void SetEdgeTol(const TopoDS_Edge& E, Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(); Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(); - + TopLoc_Location LC; Standard_Real First, Last; GeomAdaptor_Curve& GAC = HC->ChangeCurve(); @@ -772,11 +749,11 @@ static void SetEdgeTol(const TopoDS_Edge& E, if (!LC.IsIdentity()) { GP = Handle(Geom_Plane)::DownCast( - GP->Transformed(LC.Transformation())); + GP->Transformed(LC.Transformation())); } GeomAdaptor_Surface& GAS = HS->ChangeSurface(); GAS.Load(GP); - + ProjLib_ProjectedCurve Proj(HS,HC); Handle(Geom2d_Curve) pc = Geom2dAdaptor::MakeCurve(Proj); @@ -802,8 +779,8 @@ static void SetEdgeTol(const TopoDS_Edge& E, //purpose : //======================================================================= void BRepLib::SameParameter(const TopoDS_Shape& S, - const Standard_Real Tolerance, - const Standard_Boolean forced) + const Standard_Real Tolerance, + const Standard_Boolean forced) { TopExp_Explorer ex(S,TopAbs_EDGE); TopTools_MapOfShape Done; @@ -812,8 +789,8 @@ void BRepLib::SameParameter(const TopoDS_Shape& S, while (ex.More()) { if (Done.Add(ex.Current())) { if (forced) { - brB.SameRange(TopoDS::Edge(ex.Current()), Standard_False); - brB.SameParameter(TopoDS::Edge(ex.Current()), Standard_False); + brB.SameRange(TopoDS::Edge(ex.Current()), Standard_False); + brB.SameParameter(TopoDS::Edge(ex.Current()), Standard_False); } BRepLib::SameParameter(TopoDS::Edge(ex.Current()),Tolerance); } @@ -843,10 +820,10 @@ void BRepLib::SameParameter(const TopoDS_Shape& S, // for vertex extremities it is required to find something else //================================================================ static Standard_Boolean EvalTol(const Handle(Geom2d_Curve)& pc, - const Handle(Geom_Surface)& s, - const GeomAdaptor_Curve& gac, - const Standard_Real tol, - Standard_Real& tolbail) + const Handle(Geom_Surface)& s, + const GeomAdaptor_Curve& gac, + const Standard_Real tol, + Standard_Real& tolbail) { Standard_Integer ok = 0; Standard_Real f = gac.FirstParameter(); @@ -872,9 +849,9 @@ static Standard_Boolean EvalTol(const Handle(Geom2d_Curve)& pc, } static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d, - const Handle(Adaptor2d_HCurve2d)& c2d, - const Handle(Adaptor3d_HSurface)& surf, - const Standard_Integer nbp) + const Handle(Adaptor2d_HCurve2d)& c2d, + const Handle(Adaptor3d_HSurface)& surf, + const Standard_Integer nbp) { @@ -892,10 +869,10 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d, gp_Pnt Pc3d = c3d->Value(u); gp_Pnt Pcons = cons.Value(u); if (Precision::IsInfinite(Pcons.X()) || - Precision::IsInfinite(Pcons.Y()) || - Precision::IsInfinite(Pcons.Z())) { - d2=Precision::Infinite(); - break; + Precision::IsInfinite(Pcons.Y()) || + Precision::IsInfinite(Pcons.Z())) { + d2=Precision::Infinite(); + break; } Standard_Real temp = Pc3d.SquareDistance(Pcons); @@ -919,23 +896,23 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d, else N2++; } - if( N1 > N2 && N2 != 0 ) N3 = 100*N2/(N1+N2); - if( N3 < 10 && N3 != 0 ) { - ana = Standard_True; - for( i = 1; i<= nbp+10; i++) - if( dist(i) > 0 && dist(i) < 1.0 ) - if( dist(i) > D2 ) D2 = dist(i); - } + if( N1 > N2 && N2 != 0 ) N3 = 100*N2/(N1+N2); + if( N3 < 10 && N3 != 0 ) { + ana = Standard_True; + for( i = 1; i<= nbp+10; i++) + if( dist(i) > 0 && dist(i) < 1.0 ) + if( dist(i) > D2 ) D2 = dist(i); + } - //d2 = 1.5*sqrt(d2); - d2 = (!ana) ? 1.5*sqrt(d2) : 1.5*sqrt(D2); - if(d2<1.e-7) d2 = 1.e-7; + //d2 = 1.5*sqrt(d2); + d2 = (!ana) ? 1.5*sqrt(d2) : 1.5*sqrt(D2); + if(d2<1.e-7) d2 = 1.e-7; - return d2; + return d2; } void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, - const Standard_Real Tolerance) + const Standard_Real Tolerance) { if (BRep_Tool::SameParameter(AnEdge)) return; @@ -954,7 +931,7 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &AnEdge.TShape()); BRep_ListOfCurveRepresentation& CList = TE->ChangeCurves(); BRep_ListIteratorOfListOfCurveRepresentation It(CList); - + Standard_Boolean NotDone = Standard_True; while (NotDone && It.More()) { @@ -975,10 +952,10 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, Standard_Boolean m_TrimmedPeriodical = Standard_False; Handle(Standard_Type) TheType = C3d->DynamicType(); if( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) - { - const Handle(Geom_Curve)& gtC = (*((Handle(Geom_TrimmedCurve)*)&C3d))->BasisCurve(); - m_TrimmedPeriodical = gtC->IsPeriodic(); - } + { + const Handle(Geom_Curve)& gtC = (*((Handle(Geom_TrimmedCurve)*)&C3d))->BasisCurve(); + m_TrimmedPeriodical = gtC->IsPeriodic(); + } // modified by NIZHNY-OCC486 Tue Aug 27 17:15:17 2002 . BRep_Builder B; @@ -989,10 +966,10 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, //if (Udeb > f3d) f3d = Udeb; //if (l3d > Ufin) l3d = Ufin; if(!m_TrimmedPeriodical) - { - if (Udeb > f3d) f3d = Udeb; - if (l3d > Ufin) l3d = Ufin; - } + { + if (Udeb > f3d) f3d = Udeb; + if (l3d > Ufin) l3d = Ufin; + } // modified by NIZHNY-OCC486 Tue Aug 27 17:17:55 2002 . } if(!L3d.IsIdentity()){ @@ -1003,9 +980,9 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, Standard_Boolean IsSameP = 1; Standard_Real maxdist = 0.; - // Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 Begin +// Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 Begin Standard_Real anEdgeTol = BRep_Tool::Tolerance(AnEdge); - // Modified by skv - Thu Jun 3 12:39:20 2004 OCC5898 End +// Modified by skv - Thu Jun 3 12:39:20 2004 OCC5898 End Standard_Boolean SameRange = BRep_Tool::SameRange(AnEdge); Standard_Boolean YaPCu = Standard_False; It.Initialize(CList); @@ -1022,253 +999,253 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, TopLoc_Location PCLoc = GCurve->Location(); S = GCurve->Surface(); if (!PCLoc.IsIdentity() ) { - S = Handle(Geom_Surface)::DownCast(S->Transformed(PCLoc.Transformation())); + S = Handle(Geom_Surface)::DownCast(S->Transformed(PCLoc.Transformation())); } GAS.Load(S); if (GCurve->IsCurveOnClosedSurface()) { - PC[1] = GCurve->PCurve2(); + PC[1] = GCurve->PCurve2(); } - + // Eval tol2d to compute SameRange Standard_Real UResol = Max(GAS.UResolution(Tolerance), Precision::PConfusion()); Standard_Real VResol = Max(GAS.VResolution(Tolerance), Precision::PConfusion()); Standard_Real Tol2d = Min(UResol, VResol); for(Standard_Integer i = 0; i < 2; i++){ - Handle(Geom2d_Curve) curPC = PC[i]; - Standard_Boolean updatepc = 0; - if(curPC.IsNull()) break; - if(!SameRange){ - GeomLib::SameRange(Tol2d, - PC[i],GCurve->First(),GCurve->Last(), - f3d,l3d,curPC); + Handle(Geom2d_Curve) curPC = PC[i]; + Standard_Boolean updatepc = 0; + if(curPC.IsNull()) break; + if(!SameRange){ + GeomLib::SameRange(Tol2d, + PC[i],GCurve->First(),GCurve->Last(), + f3d,l3d,curPC); - updatepc = (curPC != PC[i]); + updatepc = (curPC != PC[i]); - } - Standard_Boolean goodpc = 1; - GAC2d.Load(curPC,f3d,l3d); + } + Standard_Boolean goodpc = 1; + GAC2d.Load(curPC,f3d,l3d); - Standard_Real error = ComputeTol(HC, HC2d, HS, NCONTROL); + Standard_Real error = ComputeTol(HC, HC2d, HS, NCONTROL); - if(GAC2d.GetType() == GeomAbs_BSplineCurve && - GAC2d.Continuity() == GeomAbs_C0) { - Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline(); - Handle(Geom2d_BSplineCurve) bs2dsov = bs2d; - Standard_Real fC0 = bs2d->FirstParameter(), lC0 = bs2d->LastParameter(); - Standard_Boolean repar = Standard_True; - gp_Pnt2d OriginPoint; - bs2d->D0(fC0, OriginPoint); - Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, Tol2d); - isBSP = Standard_True; + if(GAC2d.GetType() == GeomAbs_BSplineCurve && + GAC2d.Continuity() == GeomAbs_C0) { + Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline(); + Handle(Geom2d_BSplineCurve) bs2dsov = bs2d; + Standard_Real fC0 = bs2d->FirstParameter(), lC0 = bs2d->LastParameter(); + Standard_Boolean repar = Standard_True; + gp_Pnt2d OriginPoint; + bs2d->D0(fC0, OriginPoint); + Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, Tol2d); + isBSP = Standard_True; - if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000 - gp_Pnt2d NewOriginPoint; - bs2d->D0(bs2d->FirstParameter(), NewOriginPoint); - if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || - Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) { + if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000 + gp_Pnt2d NewOriginPoint; + bs2d->D0(bs2d->FirstParameter(), NewOriginPoint); + if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || + Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) { - TColStd_Array1OfReal Knotbs2d (1, bs2d->NbKnots()); - bs2d->Knots(Knotbs2d); + TColStd_Array1OfReal Knotbs2d (1, bs2d->NbKnots()); + bs2d->Knots(Knotbs2d); - for(Standard_Integer Index = 1; Index <= bs2d->NbKnots(); Index++) { - bs2d->D0(Knotbs2d(Index), NewOriginPoint); - if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || - Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) continue; + for(Standard_Integer Index = 1; Index <= bs2d->NbKnots(); Index++) { + bs2d->D0(Knotbs2d(Index), NewOriginPoint); + if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || + Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) continue; + + bs2d->SetOrigin(Index); + break; + } + } + } - bs2d->SetOrigin(Index); - break; - } - } - } + if(bs2d->Continuity() == GeomAbs_C0) { + Standard_Real tolbail; + if(EvalTol(curPC,S,GAC,Tolerance,tolbail)){ + bs2d = bs2dsov; + Standard_Real UResbail = GAS.UResolution(tolbail); + Standard_Real VResbail = GAS.VResolution(tolbail); + Standard_Real Tol2dbail = Min(UResbail,VResbail); + bs2d->D0(bs2d->FirstParameter(), OriginPoint); - if(bs2d->Continuity() == GeomAbs_C0) { - Standard_Real tolbail; - if(EvalTol(curPC,S,GAC,Tolerance,tolbail)){ - bs2d = bs2dsov; - Standard_Real UResbail = GAS.UResolution(tolbail); - Standard_Real VResbail = GAS.VResolution(tolbail); - Standard_Real Tol2dbail = Min(UResbail,VResbail); - bs2d->D0(bs2d->FirstParameter(), OriginPoint); + Standard_Integer nbp = bs2d->NbPoles(); + TColgp_Array1OfPnt2d poles(1,nbp); + bs2d->Poles(poles); + gp_Pnt2d p = poles(1), p1; + Standard_Real d = Precision::Infinite(); + for(Standard_Integer ip = 2; ip <= nbp; ip++) { + p1 = poles(ip); + d = Min(d,p.SquareDistance(p1)); + p = p1; + } + d = sqrt(d)*.1; - Standard_Integer nbp = bs2d->NbPoles(); - TColgp_Array1OfPnt2d poles(1,nbp); - bs2d->Poles(poles); - gp_Pnt2d p = poles(1), p1; - Standard_Real d = Precision::Infinite(); - for(Standard_Integer ip = 2; ip <= nbp; ip++) { - p1 = poles(ip); - d = Min(d,p.SquareDistance(p1)); - p = p1; - } - d = sqrt(d)*.1; + Tol2dbail = Max(Min(Tol2dbail,d),Tol2d); - Tol2dbail = Max(Min(Tol2dbail,d),Tol2d); + Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d,Tol2dbail); - Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d,Tol2dbail); + if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000 + gp_Pnt2d NewOriginPoint; + bs2d->D0(bs2d->FirstParameter(), NewOriginPoint); + if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || + Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) { - if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000 - gp_Pnt2d NewOriginPoint; - bs2d->D0(bs2d->FirstParameter(), NewOriginPoint); - if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || - Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) { + TColStd_Array1OfReal Knotbs2d (1, bs2d->NbKnots()); + bs2d->Knots(Knotbs2d); - TColStd_Array1OfReal Knotbs2d (1, bs2d->NbKnots()); - bs2d->Knots(Knotbs2d); + for(Standard_Integer Index = 1; Index <= bs2d->NbKnots(); Index++) { + bs2d->D0(Knotbs2d(Index), NewOriginPoint); + if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || + Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) continue; + + bs2d->SetOrigin(Index); + break; + } + } + } + + + if(bs2d->Continuity() == GeomAbs_C0) { + goodpc = 1; + bs2d = bs2dsov; + repar = Standard_False; + } + } + else goodpc = 0; + } - for(Standard_Integer Index = 1; Index <= bs2d->NbKnots(); Index++) { - bs2d->D0(Knotbs2d(Index), NewOriginPoint); - if(Abs(OriginPoint.X() - NewOriginPoint.X()) > Precision::PConfusion() || - Abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion() ) continue; + if(goodpc){ + if(repar) { + Standard_Integer NbKnots = bs2d->NbKnots(); + TColStd_Array1OfReal Knots(1,NbKnots); + bs2d->Knots(Knots); + // BSplCLib::Reparametrize(f3d,l3d,Knots); + BSplCLib::Reparametrize(fC0,lC0,Knots); + bs2d->SetKnots(Knots); + GAC2d.Load(bs2d,f3d,l3d); + curPC = bs2d; + Standard_Boolean updatepcsov = updatepc; + updatepc = Standard_True; - bs2d->SetOrigin(Index); - break; - } - } - } + Standard_Real error1 = ComputeTol(HC, HC2d, HS, NCONTROL); + if(error1 > error) { + bs2d = bs2dsov; + GAC2d.Load(bs2d,f3d,l3d); + curPC = bs2d; + updatepc = updatepcsov; + isANA = Standard_True; + } + else { + error = error1; + } + } + + //check, if new BSpline "good" or not --------- IFV, Jan of 2000 + GeomAbs_Shape cont = bs2d->Continuity(); + Standard_Boolean IsBad = Standard_False; + + if(cont > GeomAbs_C0 && error > Max(1.e-3,Tolerance)) { + Standard_Integer NbKnots = bs2d->NbKnots(); + TColStd_Array1OfReal Knots(1,NbKnots); + bs2d->Knots(Knots); + Standard_Real critratio = 10.; + Standard_Real dtprev = Knots(2) - Knots(1), dtratio = 1.; + Standard_Real dtmin = dtprev; + Standard_Real dtcur; + for(Standard_Integer j = 2; j < NbKnots; j++) { + dtcur = Knots(j+1) - Knots(j); + dtmin = Min(dtmin, dtcur); + + if(IsBad) continue; + + if(dtcur > dtprev) dtratio = dtcur/dtprev; + else dtratio = dtprev/dtcur; + if(dtratio > critratio) {IsBad = Standard_True;} + dtprev = dtcur; + + } + if(IsBad) { + // To avoid failures in Approx_CurvilinearParameter + bs2d->Resolution(Max(1.e-3,Tolerance), dtcur); + if(dtmin < dtcur) IsBad = Standard_False; + } + } - if(bs2d->Continuity() == GeomAbs_C0) { - goodpc = 1; - bs2d = bs2dsov; - repar = Standard_False; - } - } - else goodpc = 0; - } + if(IsBad ) { //if BSpline "bad", try to reparametrize it + // by its curve length - if(goodpc){ - if(repar) { - Standard_Integer NbKnots = bs2d->NbKnots(); - TColStd_Array1OfReal Knots(1,NbKnots); - bs2d->Knots(Knots); - // BSplCLib::Reparametrize(f3d,l3d,Knots); - BSplCLib::Reparametrize(fC0,lC0,Knots); - bs2d->SetKnots(Knots); - GAC2d.Load(bs2d,f3d,l3d); - curPC = bs2d; - Standard_Boolean updatepcsov = updatepc; - updatepc = Standard_True; +// GeomAbs_Shape cont = bs2d->Continuity(); + if(cont > GeomAbs_C2) cont = GeomAbs_C2; + Standard_Integer maxdeg = bs2d->Degree(); + if(maxdeg == 1) maxdeg = 14; + Approx_CurvilinearParameter AppCurPar(HC2d, HS, Max(1.e-3,Tolerance), + cont, maxdeg, 10); + if(AppCurPar.IsDone() || AppCurPar.HasResult()) { + bs2d = AppCurPar.Curve2d1(); + GAC2d.Load(bs2d,f3d,l3d); + curPC = bs2d; - Standard_Real error1 = ComputeTol(HC, HC2d, HS, NCONTROL); - if(error1 > error) { - bs2d = bs2dsov; - GAC2d.Load(bs2d,f3d,l3d); - curPC = bs2d; - updatepc = updatepcsov; - isANA = Standard_True; - } - else { - error = error1; - } - } + if(Abs(bs2d->FirstParameter() - fC0) > Tol2d || + Abs(bs2d->LastParameter() - lC0) > Tol2d ) { + Standard_Integer NbKnots = bs2d->NbKnots(); + TColStd_Array1OfReal Knots(1,NbKnots); + bs2d->Knots(Knots); +// BSplCLib::Reparametrize(f3d,l3d,Knots); + BSplCLib::Reparametrize(fC0,lC0,Knots); + bs2d->SetKnots(Knots); + GAC2d.Load(bs2d,f3d,l3d); + curPC = bs2d; - //check, if new BSpline "good" or not --------- IFV, Jan of 2000 - GeomAbs_Shape cont = bs2d->Continuity(); - Standard_Boolean IsBad = Standard_False; + } + } + } - if(cont > GeomAbs_C0 && error > Max(1.e-3,Tolerance)) { - Standard_Integer NbKnots = bs2d->NbKnots(); - TColStd_Array1OfReal Knots(1,NbKnots); - bs2d->Knots(Knots); - Standard_Real critratio = 10.; - Standard_Real dtprev = Knots(2) - Knots(1), dtratio = 1.; - Standard_Real dtmin = dtprev; - Standard_Real dtcur; - for(Standard_Integer j = 2; j < NbKnots; j++) { - dtcur = Knots(j+1) - Knots(j); - dtmin = Min(dtmin, dtcur); - - if(IsBad) continue; - - if(dtcur > dtprev) dtratio = dtcur/dtprev; - else dtratio = dtprev/dtcur; - if(dtratio > critratio) {IsBad = Standard_True;} - dtprev = dtcur; - - } - if(IsBad) { - // To avoid failures in Approx_CurvilinearParameter - bs2d->Resolution(Max(1.e-3,Tolerance), dtcur); - if(dtmin < dtcur) IsBad = Standard_False; - } - } + + } + } - if(IsBad ) { //if BSpline "bad", try to reparametrize it - // by its curve length + if(goodpc){ +// Approx_SameParameter SameP(HC,HC2d,HS,Tolerance); + Standard_Real aTol = (isANA && isBSP) ? 1.e-7 : Tolerance; + Approx_SameParameter SameP(HC,HC2d,HS,aTol); + + if (SameP.IsSameParameter()) { + maxdist = Max(maxdist,SameP.TolReached()); + if(updatepc){ + if (i == 0) GCurve->PCurve(curPC); + else GCurve->PCurve2(curPC); + } + } + else if (SameP.IsDone()) { + Standard_Real tolreached = SameP.TolReached(); + if(tolreached < error) { + curPC = SameP.Curve2d(); + updatepc = Standard_True; + maxdist = Max(maxdist,tolreached); + } + else { + maxdist = Max(maxdist, error); + } + if(updatepc){ + if (i == 0) GCurve->PCurve(curPC); + else GCurve->PCurve2(curPC); + } + } + else IsSameP = 0; + + } + else IsSameP = 0; - // GeomAbs_Shape cont = bs2d->Continuity(); - if(cont > GeomAbs_C2) cont = GeomAbs_C2; - Standard_Integer maxdeg = bs2d->Degree(); - if(maxdeg == 1) maxdeg = 14; - Approx_CurvilinearParameter AppCurPar(HC2d, HS, Max(1.e-3,Tolerance), - cont, maxdeg, 10); - if(AppCurPar.IsDone() || AppCurPar.HasResult()) { - bs2d = AppCurPar.Curve2d1(); - GAC2d.Load(bs2d,f3d,l3d); - curPC = bs2d; - - if(Abs(bs2d->FirstParameter() - fC0) > Tol2d || - Abs(bs2d->LastParameter() - lC0) > Tol2d ) { - Standard_Integer NbKnots = bs2d->NbKnots(); - TColStd_Array1OfReal Knots(1,NbKnots); - bs2d->Knots(Knots); - // BSplCLib::Reparametrize(f3d,l3d,Knots); - BSplCLib::Reparametrize(fC0,lC0,Knots); - bs2d->SetKnots(Knots); - GAC2d.Load(bs2d,f3d,l3d); - curPC = bs2d; - - } - } - } - - - } - } - - - if(goodpc){ - // Approx_SameParameter SameP(HC,HC2d,HS,Tolerance); - Standard_Real aTol = (isANA && isBSP) ? 1.e-7 : Tolerance; - Approx_SameParameter SameP(HC,HC2d,HS,aTol); - - if (SameP.IsSameParameter()) { - maxdist = Max(maxdist,SameP.TolReached()); - if(updatepc){ - if (i == 0) GCurve->PCurve(curPC); - else GCurve->PCurve2(curPC); - } - } - else if (SameP.IsDone()) { - Standard_Real tolreached = SameP.TolReached(); - if(tolreached < error) { - curPC = SameP.Curve2d(); - updatepc = Standard_True; - maxdist = Max(maxdist,tolreached); - } - else { - maxdist = Max(maxdist, error); - } - if(updatepc){ - if (i == 0) GCurve->PCurve(curPC); - else GCurve->PCurve2(curPC); - } - } - else IsSameP = 0; - - } - else IsSameP = 0; - - // Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 Begin - if (!IsSameP) { - if (anEdgeTol > error) { - maxdist = Max(maxdist, anEdgeTol); - IsSameP = Standard_True; - } - } - // Modified by skv - Thu Jun 3 12:39:20 2004 OCC5898 End +// Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898 Begin + if (!IsSameP) { + if (anEdgeTol > error) { + maxdist = Max(maxdist, anEdgeTol); + IsSameP = Standard_True; + } + } +// Modified by skv - Thu Jun 3 12:39:20 2004 OCC5898 End } } It.Next() ; @@ -1287,9 +1264,9 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, TopoDS_Vertex V1,V2; TopExp::Vertices(AnEdge,V1,V2); if (!V1.IsNull()) - B.UpdateVertex(V1,maxdist); + B.UpdateVertex(V1,maxdist); if (!V2.IsNull()) - B.UpdateVertex(V2,maxdist); + B.UpdateVertex(V2,maxdist); TE->Modified(Standard_True); TE->Tolerance(maxdist); } @@ -1302,11 +1279,11 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, //purpose : //======================================================================= void BRepLib::UpdateTolerances(const TopoDS_Shape& aShape, - const Standard_Boolean verifyTolerance) + const Standard_Boolean verifyTolerance) { - // Harmonize tolerances - // with rule Tolerance(VERTEX)>=Tolerance(EDGE)>=Tolerance(FACE) +// Harmonize tolerances +// with rule Tolerance(VERTEX)>=Tolerance(EDGE)>=Tolerance(FACE) BRep_Builder B; Standard_Real tol=0; if (verifyTolerance) { @@ -1320,47 +1297,47 @@ void BRepLib::UpdateTolerances(const TopoDS_Shape& aShape, const TopoDS_Face& curf=TopoDS::Face(ex.Current()); S = BRep_Tool::Surface(curf, l); if (!S.IsNull()) { - aB.SetVoid(); - BRepBndLib::Add(curf,aB); - if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { - S = (*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(); - } - GeomAdaptor_Surface AS(S); - switch (AS.GetType()) { - case GeomAbs_Plane: - case GeomAbs_Cylinder: - case GeomAbs_Cone: - { - tol=Precision::Confusion(); - break; - } - case GeomAbs_Sphere: - case GeomAbs_Torus: - { - tol=Precision::Confusion()*2; - break; - } - default: - tol=Precision::Confusion()*4; - } - if (!aB.IsWhole()) { - aB.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - dMax=1.; - if (!aB.IsOpenXmin() && !aB.IsOpenXmax()) dMax=aXmax-aXmin; - if (!aB.IsOpenYmin() && !aB.IsOpenYmax()) aYmin=aYmax-aYmin; - if (!aB.IsOpenZmin() && !aB.IsOpenZmax()) aZmin=aZmax-aZmin; - if (aYmin>dMax) dMax=aYmin; - if (aZmin>dMax) dMax=aZmin; - tol=tol*dMax; - // Do not process tolerances > 1. - if (tol>1.) tol=0.99; - } - const Handle(BRep_TFace)& Tf = *((Handle(BRep_TFace)*)&curf.TShape()); - Tf->Tolerance(tol); + aB.SetVoid(); + BRepBndLib::Add(curf,aB); + if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { + S = (*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(); + } + GeomAdaptor_Surface AS(S); + switch (AS.GetType()) { + case GeomAbs_Plane: + case GeomAbs_Cylinder: + case GeomAbs_Cone: + { + tol=Precision::Confusion(); + break; + } + case GeomAbs_Sphere: + case GeomAbs_Torus: + { + tol=Precision::Confusion()*2; + break; + } + default: + tol=Precision::Confusion()*4; + } + if (!aB.IsWhole()) { + aB.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + dMax=1.; + if (!aB.IsOpenXmin() && !aB.IsOpenXmax()) dMax=aXmax-aXmin; + if (!aB.IsOpenYmin() && !aB.IsOpenYmax()) aYmin=aYmax-aYmin; + if (!aB.IsOpenZmin() && !aB.IsOpenZmax()) aZmin=aZmax-aZmin; + if (aYmin>dMax) dMax=aYmin; + if (aZmin>dMax) dMax=aZmin; + tol=tol*dMax; + // Do not process tolerances > 1. + if (tol>1.) tol=0.99; + } + const Handle(BRep_TFace)& Tf = *((Handle(BRep_TFace)*)&curf.TShape()); + Tf->Tolerance(tol); } } } - + //Process edges TopTools_IndexedDataMapOfShapeListOfShape parents; TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, parents); @@ -1399,37 +1376,37 @@ void BRepLib::UpdateTolerances(const TopoDS_Shape& aShape, BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); const TopLoc_Location& Eloc = E.Location(); while (itcr.More()) { - // For each CurveRepresentation, check the provided parameter - const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); - const TopLoc_Location& loc = cr->Location(); - TopLoc_Location L = (Eloc * loc); - if (cr->IsCurve3D()) { - const Handle(Geom_Curve)& C = cr->Curve3D(); - if (!C.IsNull()) { // edge non degenerated - p3d = C->Value(par); - p3d.Transform(L.Transformation()); - box.Add(p3d); - } - } - else if (cr->IsCurveOnSurface()) { - const Handle(Geom_Surface)& Su = cr->Surface(); - const Handle(Geom2d_Curve)& PC = cr->PCurve(); - Handle(Geom2d_Curve) PC2; - if (cr->IsCurveOnClosedSurface()) { - PC2 = cr->PCurve2(); - } - gp_Pnt2d p2d = PC->Value(par); - p3d = Su->Value(p2d.X(),p2d.Y()); - p3d.Transform(L.Transformation()); - box.Add(p3d); - if (!PC2.IsNull()) { - p2d = PC2->Value(par); - p3d = Su->Value(p2d.X(),p2d.Y()); - p3d.Transform(L.Transformation()); - box.Add(p3d); - } - } - itcr.Next(); + // For each CurveRepresentation, check the provided parameter + const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); + const TopLoc_Location& loc = cr->Location(); + TopLoc_Location L = (Eloc * loc); + if (cr->IsCurve3D()) { + const Handle(Geom_Curve)& C = cr->Curve3D(); + if (!C.IsNull()) { // edge non degenerated + p3d = C->Value(par); + p3d.Transform(L.Transformation()); + box.Add(p3d); + } + } + else if (cr->IsCurveOnSurface()) { + const Handle(Geom_Surface)& Su = cr->Surface(); + const Handle(Geom2d_Curve)& PC = cr->PCurve(); + Handle(Geom2d_Curve) PC2; + if (cr->IsCurveOnClosedSurface()) { + PC2 = cr->PCurve2(); + } + gp_Pnt2d p2d = PC->Value(par); + p3d = Su->Value(p2d.X(),p2d.Y()); + p3d.Transform(L.Transformation()); + box.Add(p3d); + if (!PC2.IsNull()) { + p2d = PC2->Value(par); + p3d = Su->Value(p2d.X(),p2d.Y()); + p3d.Transform(L.Transformation()); + box.Add(p3d); + } + } + itcr.Next(); } } Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; @@ -1442,13 +1419,13 @@ void BRepLib::UpdateTolerances(const TopoDS_Shape& aShape, // Attention to sharing of the vertex by other shapes const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*)&V.TShape()); if (Initialized.Add(TV)) - TV->Tolerance(tol); + TV->Tolerance(tol); else - B.UpdateVertex(V, tol); + B.UpdateVertex(V, tol); } else { - // Update can only increase tolerance, so if the edge has a greater - // tolerance than its faces it is not concerned + // Update can only increase tolerance, so if the edge has a greater + // tolerance than its faces it is not concerned B.UpdateVertex(V, tol); } } @@ -1460,7 +1437,7 @@ void BRepLib::UpdateTolerances(const TopoDS_Shape& aShape, //======================================================================= Standard_Boolean BRepLib::OrientClosedSolid(TopoDS_Solid& solid) { - // Set material inside the solid +// Set material inside the solid BRepClass3d_SolidClassifier where(solid); where.PerformInfinitePoint(Precision::Confusion()); if (where.State()==TopAbs_IN) { @@ -1479,10 +1456,10 @@ Standard_Boolean BRepLib::OrientClosedSolid(TopoDS_Solid& solid) //======================================================================= static Standard_Boolean tgtfaces(const TopoDS_Edge& Ed, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Real ta, - const Standard_Boolean couture) + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Real ta, + const Standard_Boolean couture) { Standard_Real u; TopoDS_Edge E = Ed; @@ -1509,7 +1486,7 @@ static Standard_Boolean tgtfaces(const TopoDS_Edge& Ed, BRep_Tool::Range(E,f,l); Extrema_LocateExtPC ext; Standard_Boolean IsInitialized = Standard_False; - + eps = (l - f)/100.; f += eps; // to avoid calculations on l -= eps; // points of pointed squares. @@ -1544,28 +1521,28 @@ static Standard_Boolean tgtfaces(const TopoDS_Edge& Ed, if (Nok &&(ang > ta)) { // Refine by projection if (! IsInitialized ) { - ext.Initialize(C2,f,l,Precision::PConfusion()); - IsInitialized = Standard_True; + ext.Initialize(C2,f,l,Precision::PConfusion()); + IsInitialized = Standard_True; } ext.Perform(pp1,u); if(ext.IsDone() && ext.IsMin()){ - Extrema_POnCurv poc = ext.Point(); - Standard_Real v = poc.Parameter(); + Extrema_POnCurv poc = ext.Point(); + Standard_Real v = poc.Parameter(); - HC2d2->D0(v,p); - p.Coord(uu,vv); - HS2->D1(p.X(), p.Y(), pp2, du, dv); - d2 = (du.Crossed(dv)); - norm = d2.Magnitude(); - if (norm> 1.e-12) d2 /= norm; - else Nok = Standard_False; - if(rev2) d2.Reverse(); - if (Nok) ang = d1.Angle(d2); + HC2d2->D0(v,p); + p.Coord(uu,vv); + HS2->D1(p.X(), p.Y(), pp2, du, dv); + d2 = (du.Crossed(dv)); + norm = d2.Magnitude(); + if (norm> 1.e-12) d2 /= norm; + else Nok = Standard_False; + if(rev2) d2.Reverse(); + if (Nok) ang = d1.Angle(d2); } } if(ang >= angmax) angmax = ang; } - + return (angmax<=ta); } @@ -1578,7 +1555,7 @@ static Standard_Boolean tgtfaces(const TopoDS_Edge& Ed, //======================================================================= void BRepLib::EncodeRegularity(const TopoDS_Shape& S, - const Standard_Real TolAng) + const Standard_Real TolAng) { BRep_Builder B; TopTools_IndexedDataMapOfShapeListOfShape M; @@ -1594,30 +1571,30 @@ void BRepLib::EncodeRegularity(const TopoDS_Shape& S, for(It.Initialize(M.FindFromIndex(i));It.More() && !found;It.Next()){ if(F1.IsNull()) { F1 = TopoDS::Face(It.Value()); } else { - if(!F1.IsSame(TopoDS::Face(It.Value()))){ - found = Standard_True; - F2 = TopoDS::Face(It.Value()); - } + if(!F1.IsSame(TopoDS::Face(It.Value()))){ + found = Standard_True; + F2 = TopoDS::Face(It.Value()); + } } } if (!found && !F1.IsNull()){//is it a sewing edge? TopAbs_Orientation orE = E.Orientation(); TopoDS_Edge curE; for(Ex.Init(F1,TopAbs_EDGE);Ex.More() && !found;Ex.Next()){ - curE= TopoDS::Edge(Ex.Current()); - if(E.IsSame(curE) && orE != curE.Orientation()) { - found = Standard_True; - couture = Standard_True; - F2 = F1; - } + curE= TopoDS::Edge(Ex.Current()); + if(E.IsSame(curE) && orE != curE.Orientation()) { + found = Standard_True; + couture = Standard_True; + F2 = F1; + } } } if(found){ if(BRep_Tool::Continuity(E,F1,F2)<=GeomAbs_C0){ try { - if(tgtfaces(E, F1, F2, TolAng, couture)){ - B.Continuity(E,F1,F2,GeomAbs_G1); + if(tgtfaces(E, F1, F2, TolAng, couture)){ + B.Continuity(E,F1,F2,GeomAbs_G1); } } catch(Standard_Failure) @@ -1634,9 +1611,9 @@ void BRepLib::EncodeRegularity(const TopoDS_Shape& S, //======================================================================= void BRepLib::EncodeRegularity(TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Real TolAng) + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Real TolAng) { BRep_Builder B; if(BRep_Tool::Continuity(E,F1,F2)<=GeomAbs_C0){ @@ -1648,7 +1625,7 @@ void BRepLib::EncodeRegularity(TopoDS_Edge& E, catch(Standard_Failure) { } - } + } } //======================================================================= @@ -1657,7 +1634,7 @@ void BRepLib::EncodeRegularity(TopoDS_Edge& E, //======================================================================= void BRepLib::SortFaces (const TopoDS_Shape& Sh, - TopTools_ListOfShape& LF) + TopTools_ListOfShape& LF) { LF.Clear(); TopTools_ListOfShape LTri,LPlan,LCyl,LCon,LSphere,LTor,LOther; @@ -1670,37 +1647,37 @@ void BRepLib::SortFaces (const TopoDS_Shape& Sh, S = BRep_Tool::Surface(F, l); if (!S.IsNull()) { if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { - S = (*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(); + S = (*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(); } GeomAdaptor_Surface AS(S); switch (AS.GetType()) { case GeomAbs_Plane: - { - LPlan.Append(F); - break; - } + { + LPlan.Append(F); + break; + } case GeomAbs_Cylinder: - { - LCyl.Append(F); - break; - } + { + LCyl.Append(F); + break; + } case GeomAbs_Cone: - { - LCon.Append(F); - break; - } + { + LCon.Append(F); + break; + } case GeomAbs_Sphere: - { - LSphere.Append(F); - break; - } + { + LSphere.Append(F); + break; + } case GeomAbs_Torus: - { - LTor.Append(F); - break; - } + { + LTor.Append(F); + break; + } default: - LOther.Append(F); + LOther.Append(F); } } else LTri.Append(F); @@ -1715,56 +1692,55 @@ void BRepLib::SortFaces (const TopoDS_Shape& Sh, //======================================================================= void BRepLib::ReverseSortFaces (const TopoDS_Shape& Sh, - TopTools_ListOfShape& LF) + TopTools_ListOfShape& LF) { LF.Clear(); TopTools_ListOfShape LTri,LPlan,LCyl,LCon,LSphere,LTor,LOther; TopExp_Explorer exp(Sh,TopAbs_FACE); TopLoc_Location l; Handle(Geom_Surface) S; - + for (; exp.More(); exp.Next()) { const TopoDS_Face& F = TopoDS::Face(exp.Current()); S = BRep_Tool::Surface(F, l); if (!S.IsNull()) { if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { - S = (*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(); + S = (*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(); } GeomAdaptor_Surface AS(S); switch (AS.GetType()) { case GeomAbs_Plane: - { - LPlan.Append(F); - break; - } + { + LPlan.Append(F); + break; + } case GeomAbs_Cylinder: - { - LCyl.Append(F); - break; - } + { + LCyl.Append(F); + break; + } case GeomAbs_Cone: - { - LCon.Append(F); - break; - } + { + LCon.Append(F); + break; + } case GeomAbs_Sphere: - { - LSphere.Append(F); - break; - } + { + LSphere.Append(F); + break; + } case GeomAbs_Torus: - { - LTor.Append(F); - break; - } + { + LTor.Append(F); + break; + } default: - LOther.Append(F); + LOther.Append(F); } } else LTri.Append(F); } LF.Append(LTri); LF.Append(LOther); LF.Append(LTor ); LF.Append(LSphere); LF.Append(LCon); LF.Append(LCyl ); LF.Append(LPlan); - + } - diff --git a/src/BRepTest/BRepTest_CheckCommands.cxx b/src/BRepTest/BRepTest_CheckCommands.cxx index 701aca3232..d1abfc2420 100644 --- a/src/BRepTest/BRepTest_CheckCommands.cxx +++ b/src/BRepTest/BRepTest_CheckCommands.cxx @@ -76,6 +76,12 @@ # include #endif +//Number of BRepCheck_Statuses in BRepCheck_Status.hxx file +//(BRepCheck_NoError is not considered, i.e. general status +//is smaller by one specified in file) +static const Standard_Integer NumberOfStatus = 35; + + static char* checkfaultyname = NULL; Standard_EXPORT void BRepTest_CheckCommands_SetFaultyName(const char* name) { @@ -511,40 +517,46 @@ static void FillProblems(const BRepCheck_Status stat, NbProblems->SetValue(14,NbProblems->Value(14)+1); break; case BRepCheck_InvalidRange: NbProblems->SetValue(15,NbProblems->Value(15)+1); break; - case BRepCheck_EmptyWire: + case BRepCheck_PCurveIsOutOfDomainFace: NbProblems->SetValue(16,NbProblems->Value(16)+1); break; - case BRepCheck_RedundantEdge: + case BRepCheck_EmptyWire: NbProblems->SetValue(17,NbProblems->Value(17)+1); break; - case BRepCheck_SelfIntersectingWire: + case BRepCheck_RedundantEdge: NbProblems->SetValue(18,NbProblems->Value(18)+1); break; - case BRepCheck_NoSurface: + case BRepCheck_SelfIntersectingWire: NbProblems->SetValue(19,NbProblems->Value(19)+1); break; - case BRepCheck_InvalidWire: + case BRepCheck_NoSurface: NbProblems->SetValue(20,NbProblems->Value(20)+1); break; - case BRepCheck_RedundantWire: + case BRepCheck_OutOfSurfaceBoundary: NbProblems->SetValue(21,NbProblems->Value(21)+1); break; - case BRepCheck_IntersectingWires: + case BRepCheck_InvalidWire: NbProblems->SetValue(22,NbProblems->Value(22)+1); break; - case BRepCheck_InvalidImbricationOfWires: + case BRepCheck_RedundantWire: NbProblems->SetValue(23,NbProblems->Value(23)+1); break; - case BRepCheck_EmptyShell: + case BRepCheck_IntersectingWires: NbProblems->SetValue(24,NbProblems->Value(24)+1); break; - case BRepCheck_RedundantFace: + case BRepCheck_InvalidImbricationOfWires: NbProblems->SetValue(25,NbProblems->Value(25)+1); break; - case BRepCheck_UnorientableShape: + case BRepCheck_EmptyShell: NbProblems->SetValue(26,NbProblems->Value(26)+1); break; - case BRepCheck_NotClosed: + case BRepCheck_RedundantFace: NbProblems->SetValue(27,NbProblems->Value(27)+1); break; - case BRepCheck_NotConnected: + case BRepCheck_UnorientableShape: NbProblems->SetValue(28,NbProblems->Value(28)+1); break; - case BRepCheck_SubshapeNotInShape: + case BRepCheck_NotClosed: NbProblems->SetValue(29,NbProblems->Value(29)+1); break; - case BRepCheck_BadOrientation: + case BRepCheck_NotConnected: NbProblems->SetValue(30,NbProblems->Value(30)+1); break; - case BRepCheck_BadOrientationOfSubshape: + case BRepCheck_SubshapeNotInShape: NbProblems->SetValue(31,NbProblems->Value(31)+1); break; - case BRepCheck_CheckFail: + case BRepCheck_BadOrientation: NbProblems->SetValue(32,NbProblems->Value(32)+1); break; + case BRepCheck_BadOrientationOfSubshape: + NbProblems->SetValue(33,NbProblems->Value(33)+1); break; + case BRepCheck_InvalidToleranceValue: + NbProblems->SetValue(34,NbProblems->Value(34)+1); break; + case BRepCheck_CheckFail: + NbProblems->SetValue(35,NbProblems->Value(35)+1); break; default: break; } @@ -670,8 +682,9 @@ void StructuralDump(Draw_Interpretor& theCommands, theCommands<<" Check Count"<<"\n"; theCommands<<" ------------------------------------------------"<<"\n"; - Handle(TColStd_HArray1OfInteger) NbProblems = new TColStd_HArray1OfInteger(1,32); - for(i=1; i<=32; i++) NbProblems->SetValue(i,0); + Handle(TColStd_HArray1OfInteger) NbProblems = new + TColStd_HArray1OfInteger(1,NumberOfStatus); + for(i=1; i<=NumberOfStatus; i++) NbProblems->SetValue(i,0); Handle(TopTools_HSequenceOfShape) sl,slv,sle,slw,slf,sls,slo; sl = new TopTools_HSequenceOfShape(); theMap.Clear(); @@ -724,55 +737,64 @@ void StructuralDump(Draw_Interpretor& theCommands, theCommands<<" Invalid Range ............................ "<Value(15)<<"\n"; //cout<<" Invalid Range ............................ "<Value(15)<Value(16)>0) - theCommands<<" Empty Wire ............................... "<Value(16)<<"\n"; - //cout<<" Empty Wire ............................... "<Value(16)<Value(16)<<"\n"; + //cout<<" Invalid Range ............................ "<Value(15)<Value(17)>0) - theCommands<<" Redundant Edge ........................... "<Value(17)<<"\n"; - //cout<<" Redundant Edge ........................... "<Value(17)<Value(17)<<"\n"; + //cout<<" Empty Wire ............................... "<Value(16)<Value(18)>0) - theCommands<<" Self Intersecting Wire ................... "<Value(18)<<"\n"; - //cout<<" Self Intersecting Wire ................... "<Value(18)<Value(18)<<"\n"; + //cout<<" Redundant Edge ........................... "<Value(17)<Value(19)>0) - theCommands<<" No Surface ............................... "<Value(19)<<"\n"; - //cout<<" No Surface ............................... "<Value(19)<Value(19)<<"\n"; + //cout<<" Self Intersecting Wire ................... "<Value(18)<Value(20)>0) - theCommands<<" Invalid Wire ............................. "<Value(20)<<"\n"; - //cout<<" Invalid Wire ............................. "<Value(20)<Value(20)<<"\n"; + //cout<<" No Surface ............................... "<Value(19)<Value(21)>0) - theCommands<<" Redundant Wire ........................... "<Value(21)<<"\n"; - //cout<<" Redundant Wire ........................... "<Value(21)<Value(21)<<"\n"; + //cout<<" Invalid Wire ............................. "<Value(20)<Value(22)>0) - theCommands<<" Intersecting Wires ....................... "<Value(22)<<"\n"; - //cout<<" Intersecting Wires ....................... "<Value(22)<Value(22)<<"\n"; + //cout<<" Invalid Wire ............................. "<Value(20)<Value(23)>0) - theCommands<<" Invalid Imbrication of Wires ............. "<Value(23)<<"\n"; - //cout<<" Invalid Imbrication of Wires ............. "<Value(23)<Value(23)<<"\n"; + //cout<<" Redundant Wire ........................... "<Value(21)<Value(24)>0) - theCommands<<" Empty Shell .............................. "<Value(24)<<"\n"; - //cout<<" Empty Shell .............................. "<Value(24)<Value(24)<<"\n"; + //cout<<" Intersecting Wires ....................... "<Value(22)<Value(25)>0) - theCommands<<" Redundant Face ........................... "<Value(25)<<"\n"; - //cout<<" Redundant Face ........................... "<Value(25)<Value(25)<<"\n"; + //cout<<" Invalid Imbrication of Wires ............. "<Value(23)<Value(26)>0) - theCommands<<" Unorientable Shape ....................... "<Value(26)<<"\n"; - //cout<<" Unorientable Shape ....................... "<Value(26)<Value(26)<<"\n"; + //cout<<" Empty Shell .............................. "<Value(24)<Value(27)>0) - theCommands<<" Not Closed ............................... "<Value(27)<<"\n"; - //cout<<" Not Closed ............................... "<Value(27)<Value(27)<<"\n"; + //cout<<" Redundant Face ........................... "<Value(25)<Value(28)>0) - theCommands<<" Not Connected ............................ "<Value(28)<<"\n"; - //cout<<" Not Connected ............................ "<Value(28)<Value(28)<<"\n"; + //cout<<" Unorientable Shape ....................... "<Value(26)<Value(29)>0) - theCommands<<" Subshape not in Shape .................... "<Value(29)<<"\n"; - //cout<<" Subshape not in Shape .................... "<Value(29)<Value(29)<<"\n"; + //cout<<" Not Closed ............................... "<Value(27)<Value(30)>0) - theCommands<<" Bad Orientation .......................... "<Value(30)<<"\n"; - //cout<<" Bad Orientation .......................... "<Value(30)<Value(30)<<"\n"; + //cout<<" Not Connected ............................ "<Value(28)<Value(31)>0) - theCommands<<" Bad Orientation of Subshape .............. "<Value(31)<<"\n"; - //cout<<" Bad Orientation of Subshape .............. "<Value(31)<Value(31)<<"\n"; + //cout<<" Subshape not in Shape .................... "<Value(29)<Value(32)>0) - theCommands<<" checkshape failure......... .............. "<Value(32)<<"\n"; + theCommands<<" Bad Orientation .......................... "<Value(32)<<"\n"; + //cout<<" Bad Orientation .......................... "<Value(30)<Value(33)>0) + theCommands<<" Bad Orientation of Subshape .............. "<Value(33)<<"\n"; + //cout<<" Bad Orientation of Subshape .............. "<Value(31)<Value(34)>0) + theCommands<<" Invalid tolerance......................... "<Value(34)<<"\n"; + //cout<<" checkshape failure......... .............. "<Value(32)<Value(35)>0) + theCommands<<" checkshape failure........................ "<Value(35)<<"\n"; //cout<<" checkshape failure......... .............. "<Value(32)< and members values. + fields basisSurf : Surface from Geom; diff --git a/src/Geom/Geom_RectangularTrimmedSurface.cxx b/src/Geom/Geom_RectangularTrimmedSurface.cxx index c247e3124e..9119241d68 100644 --- a/src/Geom/Geom_RectangularTrimmedSurface.cxx +++ b/src/Geom/Geom_RectangularTrimmedSurface.cxx @@ -83,6 +83,45 @@ Handle(Geom_Geometry) Geom_RectangularTrimmedSurface::Copy () const { return S; } +//======================================================================= +//function : Geom_RectangularTrimmedSurface +//purpose : +//======================================================================= + +Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface( + const Handle(Geom_Surface)& S, + const Standard_Boolean isUTrim, + const Standard_Boolean isVTrim, + const Standard_Real U1, + const Standard_Real U2, + const Standard_Real V1, + const Standard_Real V2): utrim1(U1), + vtrim1(V1), + utrim2(U2), + vtrim2(V2), + isutrimmed (isUTrim), + isvtrimmed (isVTrim) +{ + // kill trimmed basis surfaces + Handle(Geom_RectangularTrimmedSurface) T = + Handle(Geom_RectangularTrimmedSurface)::DownCast(S); + if (!T.IsNull()) + basisSurf = Handle(Surface)::DownCast(T->BasisSurface()->Copy()); + else + basisSurf = Handle(Surface)::DownCast(S->Copy()); + + Handle(Geom_OffsetSurface) O = + Handle(Geom_OffsetSurface)::DownCast(basisSurf); + if (!O.IsNull()) + { + Handle(Geom_RectangularTrimmedSurface) S2 = + new Geom_RectangularTrimmedSurface( O->BasisSurface(),U1,U2, V1, V2, isUTrim, isVTrim); + Handle(Geom_OffsetSurface) OS = new Geom_OffsetSurface(S2, O->Offset()); + basisSurf = Handle(Surface)::DownCast(OS); + } + + ForceTrim( U1, U2, V1, V2, isUTrim, isVTrim); +} //======================================================================= //function : Geom_RectangularTrimmedSurface @@ -164,6 +203,172 @@ Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface ( SetTrim(Param1, Param2, UTrim, Sense); } +//======================================================================= +//function : SetUTrim +//purpose : +//======================================================================= +void Geom_RectangularTrimmedSurface::SetUTrim(const Standard_Real theU1, + const Standard_Real theU2) +{ + const Standard_Real Udeb = utrim1, Ufin = utrim2; + + utrim1 = theU1; + utrim2 = theU2; + + if ( utrim1 == utrim2) + Standard_ConstructionError::Raise + ("Geom_RectangularTrimmedSurface::U1==U2"); + + if (basisSurf->IsUPeriodic()) + { + ElCLib::AdjustPeriodic(Udeb, Ufin, + Min(Abs(utrim2-utrim1)/2,Precision::PConfusion()), utrim1, utrim2); + }//if (basisSurf->IsUPeriodic()) + else + { + if (utrim1 > utrim2) + { + //change some places of theUTrim1 and theUTrim2 + Standard_Real ut = utrim1; + utrim1 = utrim2; + utrim2 = ut; + } + + if ( (Udeb-utrim1 > Precision::PConfusion()) || + (utrim2-Ufin > Precision::PConfusion())) + { + Standard_ConstructionError::Raise + ("Geom_RectangularTrimmedSurface::Uparameters out of range"); + } + } +} + +//======================================================================= +//function : SetVTrim +//purpose : +//======================================================================= +void Geom_RectangularTrimmedSurface::SetVTrim(const Standard_Real theV1, + const Standard_Real theV2) +{ + const Standard_Real Vdeb = vtrim1, Vfin = vtrim2; + + vtrim1 = theV1; + vtrim2 = theV2; + + if ( vtrim1 == vtrim2) + Standard_ConstructionError::Raise + ("Geom_RectangularTrimmedSurface::V1==V2"); + + if (basisSurf->IsVPeriodic()) + { + ElCLib::AdjustPeriodic(Vdeb, Vfin, + Min(Abs(vtrim2-vtrim1)/2,Precision::PConfusion()),vtrim1, vtrim2); + }//if (basisSurf->IsVPeriodic()) + else + { + if (vtrim1 > vtrim2) + { + Standard_Real vt = vtrim1; + vtrim1 = vtrim2; + vtrim2 = vt; + } + + if ( (Vdeb-vtrim1 > Precision::PConfusion()) || + (vtrim2-Vfin > Precision::PConfusion())) + { + Standard_ConstructionError::Raise + ("Geom_RectangularTrimmedSurface::V parameters out of range"); + } + } +} + +//======================================================================= +//function : ForceTrim +//purpose : +//======================================================================= +void Geom_RectangularTrimmedSurface::ForceTrim(const Standard_Real theU1, + const Standard_Real theU2, + const Standard_Real theV1, + const Standard_Real theV2, + const Standard_Boolean isUTrim, + const Standard_Boolean isVTrim) +{ + basisSurf->Bounds(utrim1, utrim2, vtrim1, vtrim2); + + isutrimmed = isUTrim; + isvtrimmed = isVTrim; + + // Trimming along U-Direction + if (isutrimmed) + { + utrim1 = theU1; + utrim2 = theU2; + + if((utrim1 > utrim2) || !(basisSurf->IsUPeriodic())) + { + //Standard_ConstructionError::Raise + // ("Geom_RectangularTrimmedSurface::ForceTrim(...). " + // "utrim1 > utrim2"); + + SetUTrim(theU1,theU2); + } + else + { + const Standard_Real aTolPeriodicFactor = 1.0e-7; + const Standard_Real aT = basisSurf->UPeriod(); + const Standard_Real aTol = aTolPeriodicFactor * aT; + if(utrim2 - utrim1 - aT > 2.0*aTol) + { + Standard_Integer n = RealToInt((utrim2 - utrim1)/aT); + utrim2 -= (n * aT); + + if(utrim2 - utrim1 < aTol) + utrim2 += aT; + } + + //if(utrim2 - utrim1 < aTol) + // Standard_ConstructionError::Raise + // ("Geom_RectangularTrimmedSurface::SetTrim(...)." + // "ERROR in adjust U-parameter!"); + } + } + + // Trimming along V-Direction + if (isvtrimmed) + { + vtrim1 = theV1; + vtrim2 = theV2; + + if ((vtrim1 > vtrim2) || !(basisSurf->IsVPeriodic())) + { + //Standard_ConstructionError::Raise + // ("Geom_RectangularTrimmedSurface::ForceTrim(...). " + // "vtrim1 > vtrim2"); + + SetVTrim(theV1,theV2); + } + else + { + const Standard_Real aTolPeriodicFactor = 1.0e-7; + const Standard_Real aT = basisSurf->VPeriod(); + const Standard_Real aTol = aTolPeriodicFactor * aT; + + if(vtrim2 - vtrim1 - aT > 2.0*aTol) + { + Standard_Integer n = RealToInt((vtrim2 - vtrim1)/aT); + vtrim2 -= (n * aT); + + if(vtrim2 - vtrim1 < aTol) + vtrim2 += aT; + } + + //if(vtrim2 - vtrim1 < aTol) + // Standard_ConstructionError::Raise + // ("Geom_RectangularTrimmedSurface::SetTrim(...)." + // "ERROR in adjust V-parameter!"); + } + } +} //======================================================================= //function : SetTrim @@ -217,107 +422,36 @@ void Geom_RectangularTrimmedSurface::SetTrim (const Standard_Real Param1, //purpose : //======================================================================= -void Geom_RectangularTrimmedSurface::SetTrim(const Standard_Real U1, - const Standard_Real U2, - const Standard_Real V1, - const Standard_Real V2, - const Standard_Boolean UTrim, - const Standard_Boolean VTrim, - const Standard_Boolean USense, - const Standard_Boolean VSense) { - - Standard_Boolean UsameSense = Standard_True; - Standard_Boolean VsameSense = Standard_True; - Standard_Real Udeb, Ufin, Vdeb, Vfin; +void Geom_RectangularTrimmedSurface::SetTrim( + const Standard_Real theU1, + const Standard_Real theU2, + const Standard_Real theV1, + const Standard_Real theV2, + const Standard_Boolean isUTrim, + const Standard_Boolean isVTrim, + const Standard_Boolean isUSense, + const Standard_Boolean isVSense) +{ + Standard_Boolean UsameSense = !(isUSense && (theU1 > theU2)); + Standard_Boolean VsameSense = !(isVSense && (theV1 > theV2)); - basisSurf->Bounds(Udeb, Ufin, Vdeb, Vfin); + basisSurf->Bounds(utrim1, utrim2, vtrim1, vtrim2); + + isutrimmed = isUTrim; + isvtrimmed = isVTrim; // Trimming the U-Direction - isutrimmed = UTrim; - if (!UTrim) { - utrim1 = Udeb; - utrim2 = Ufin; - } - else { - if ( U1 == U2) - Standard_ConstructionError::Raise - ("Geom_RectangularTrimmedSurface::U1==U2"); - - if (basisSurf->IsUPeriodic()) { - UsameSense = USense; - - // set uTrim1 in the range Udeb , Ufin - // set uTrim2 in the range uTrim1 , uTrim1 + Period() - utrim1 = U1; - utrim2 = U2; - ElCLib::AdjustPeriodic(Udeb, Ufin, - Min(Abs(utrim2-utrim1)/2,Precision::PConfusion()), - utrim1, utrim2); - } - else { - if (U1 < U2) { - UsameSense = USense; - utrim1 = U1; - utrim2 = U2; - } - else { - UsameSense = !USense; - utrim1 = U2; - utrim2 = U1; - } - - if ((Udeb-utrim1 > Precision::PConfusion()) || - (utrim2-Ufin > Precision::PConfusion())) - Standard_ConstructionError::Raise - ("Geom_RectangularTrimmedSurface::U parameters out of range"); - - } - } + if (isutrimmed) + SetUTrim(theU1,theU2); // Trimming the V-Direction - isvtrimmed = VTrim; - if (!VTrim) { - vtrim1 = Vdeb; - vtrim2 = Vfin; - } - else { - if ( V1 == V2) - Standard_ConstructionError::Raise - ("Geom_RectangularTrimmedSurface::V1==V2"); + if (isvtrimmed) + SetVTrim(theV1,theV2); - if (basisSurf->IsVPeriodic()) { - VsameSense = VSense; - - // set vTrim1 in the range Vdeb , Vfin - // set vTrim2 in the range vTrim1 , vTrim1 + Period() - vtrim1 = V1; - vtrim2 = V2; - ElCLib::AdjustPeriodic(Vdeb, Vfin, - Min(Abs(vtrim2-vtrim1)/2,Precision::PConfusion()), - vtrim1, vtrim2); - } - else { - if (V1 < V2) { - VsameSense = VSense; - vtrim1 = V1; - vtrim2 = V2; - } - else { - VsameSense = !VSense; - vtrim1 = V2; - vtrim2 = V1; - } - - if ((Vdeb-vtrim1 > Precision::PConfusion()) || - (vtrim2-Vfin > Precision::PConfusion())) - Standard_ConstructionError::Raise - ("Geom_RectangularTrimmedSurface::V parameters out of range"); - - } - } - - if (!UsameSense) UReverse(); - if (!VsameSense) VReverse(); + if (!UsameSense) + UReverse(); + if (!VsameSense) + VReverse(); } @@ -662,3 +796,12 @@ gp_GTrsf2d Geom_RectangularTrimmedSurface::ParametricTransformation return basisSurf->ParametricTransformation(T); } +//======================================================================= +//function : GetTrimmedFlags +//purpose : +//======================================================================= +void Geom_RectangularTrimmedSurface::GetTrimmedFlags(Standard_Boolean& isU, Standard_Boolean& isV) const +{ + isU = isutrimmed; + isV = isvtrimmed; +} diff --git a/src/GeomTools/GeomTools_SurfaceSet.cxx b/src/GeomTools/GeomTools_SurfaceSet.cxx index bdedce937c..f1578d0057 100644 --- a/src/GeomTools/GeomTools_SurfaceSet.cxx +++ b/src/GeomTools/GeomTools_SurfaceSet.cxx @@ -523,7 +523,14 @@ static void Print(const Handle(Geom_RectangularTrimmedSurface)& S, if (compact) OS << RECTANGULAR << " "; else + { OS << "RectangularTrimmedSurface"; + + Standard_Boolean isUtr, isVtr; + S->GetTrimmedFlags(isUtr, isVtr); + + OS << " (uTrim = " << isUtr << ", vTrim = " << isVtr << ")"; + } Standard_Real U1,U2,V1,V2; S->Bounds(U1,U2,V1,V2); diff --git a/src/SWDRAW/SWDRAW_ShapeFix.cxx b/src/SWDRAW/SWDRAW_ShapeFix.cxx index 8dc75e556c..ddb07afbbd 100644 --- a/src/SWDRAW/SWDRAW_ShapeFix.cxx +++ b/src/SWDRAW/SWDRAW_ShapeFix.cxx @@ -16,55 +16,51 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include - -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include #ifdef AIX #include @@ -753,6 +749,102 @@ static Standard_Integer connectedges(Draw_Interpretor& di, Standard_Integer n, c } +//======================================================================= +//function : FixPCurveOfFace +//purpose : +//======================================================================= +static Standard_Integer FixPCurveOfFace(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char** theArg) +{ + if(theNArg < 2) + { + theDI << "use \"ffixpcu face\".\n"; + return 1; + } + + TopoDS_Shape aS=DBRep::Get(theArg[1]); + if (aS.IsNull()) { + theDI << "null shapes is not allowed here\n"; + return 1; + } + + if (aS.ShapeType()!=TopAbs_FACE) { + char buff[256]; + Sprintf ( buff, "shape %s must be a face\n", theArg[1]); + theDI << buff; + return 1; + } + + TopoDS_Face aF=*((TopoDS_Face*)&aS); + + BRepCheck_Analyzer anAna(aF); + + if(anAna.IsValid()) + { + theDI << "Face is valid!\n"; + return 0; + } + + BRepCheck_ListIteratorOfListOfStatus itl; + itl.Initialize(anAna.Result(aF)->Status()); + + if (itl.Value() != BRepCheck_OutOfSurfaceBoundary) + { + theDI << "Other Status!\n"; + return 0; + } + + ShapeFix::RefineFace(aF); + DBRep::Set(theArg[1], aF); + + return 0; +} + +//======================================================================= +//function : FixPCurveOfShape +//purpose : +//======================================================================= +static Standard_Integer FixPCurveOfShape(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char** theArg) +{ + if(theNArg < 3) + { + theDI << "use \"sfixpcu result shape\".\n"; + return 1; + } + + TopoDS_Shape aS=DBRep::Get(theArg[2]); + + if (aS.IsNull()) { + theDI << "null shapes is not allowed here\n"; + return 1; + } + + TopExp_Explorer exp; + for (exp.Init(aS,TopAbs_FACE); exp.More();exp.Next()) + { + const TopoDS_Shape& aS1 = exp.Current(); + TopoDS_Face aF=*((TopoDS_Face*)&aS1); + + BRepCheck_Analyzer anAna(aF); + if(anAna.IsValid()) + continue; + + BRepCheck_ListIteratorOfListOfStatus itl; + itl.Initialize(anAna.Result(aF)->Status()); + if (itl.Value() != BRepCheck_OutOfSurfaceBoundary) + continue; + + ShapeFix::RefineFace(aF); + } + + DBRep::Set(theArg[1],aS); + + return 0; +} + //======================================================================= //function : InitCommands //purpose : @@ -789,6 +881,10 @@ static Standard_Integer connectedges(Draw_Interpretor& di, Standard_Integer n, c __FILE__,checkfclass2d,g); theCommands.Add ("connectedges","res shape [toler shared]", __FILE__,connectedges,g); - + theCommands.Add ("ffixpcu"," ffixpcu face (to fix face with " + "\"BRepCheck_OutOfSurfaceBoundary\" status) ", __FILE__,FixPCurveOfFace,g); + + theCommands.Add ("sfixpcu"," sfixpcu result shape (to fix shape, which contains face with " + "\"BRepCheck_OutOfSurfaceBoundary\" status) ", __FILE__,FixPCurveOfShape,g); } diff --git a/src/ShapeBuild/ShapeBuild.cdl b/src/ShapeBuild/ShapeBuild.cdl index 739b9f33aa..54c402ad6e 100644 --- a/src/ShapeBuild/ShapeBuild.cdl +++ b/src/ShapeBuild/ShapeBuild.cdl @@ -29,8 +29,9 @@ uses TopTools, BRep, ShapeExtend, - BRepTools - + BRepTools, + GeomAbs + is class Vertex; diff --git a/src/ShapeFix/ShapeFix.cdl b/src/ShapeFix/ShapeFix.cdl index 87e9f83ddd..7d79b4b8ef 100644 --- a/src/ShapeFix/ShapeFix.cdl +++ b/src/ShapeFix/ShapeFix.cdl @@ -149,6 +149,15 @@ is LeastEdgeSize(theshape: in out Shape from TopoDS) returns Real; ---Purpose: Calculate size of least edge; - + RefineFace (theF : Face from TopoDS); + ---Purpose: It is created for fixing faces with + -- BRepCheck_OutOfSurfaceBoundary status. + + ReTrimmedFace(theF : in out Face from TopoDS; + theNewRTSurf: RectangularTrimmedSurface from Geom) + + ---Purpose: Replace the surface in theF with theNewRTSurf. + is private; + end ShapeFix; diff --git a/src/ShapeFix/ShapeFix.cxx b/src/ShapeFix/ShapeFix.cxx index 816ccc3520..3fcd7afdf3 100644 --- a/src/ShapeFix/ShapeFix.cxx +++ b/src/ShapeFix/ShapeFix.cxx @@ -21,54 +21,50 @@ //szv#9:S4244:19Aug99: Added method FixWireGaps //szv#10:S4244:23Aug99: Added method FixFaceGaps +#include #include #include - -#include +#include +#include #include - +#include +#include +#include +#include +#include +#include +#include +#include #include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include - +#include +#include +#include #include #include #include #include #include -#include - -//:i2 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include #include -#include -#include -#include - -#include -#include #include -#include -#include -#include -#include -#include #include -#include - -#include +#include +#include +#include +#include //======================================================================= //function : SameParameter @@ -712,3 +708,145 @@ Standard_Real ShapeFix::LeastEdgeSize(TopoDS_Shape& theShape) aRes = sqrt(aRes); return aRes; } + +//======================================================================= +//function : RefineFace +//purpose : +//======================================================================= +void ShapeFix::RefineFace(const TopoDS_Face& theF) +{ + Standard_Real anUFf, anUFl, aVFf, aVFl; + + Standard_Boolean isUtrim = Standard_True, + isVtrim = Standard_True; + + TopoDS_Face aF = theF; + + Handle(Geom_Surface) aS=BRep_Tool::Surface(aF); + Standard_Boolean isRectangularTrimmed = (aS->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)); + + if (!isRectangularTrimmed) + return; + + BRepTools::UVBounds(aF, anUFf, anUFl, aVFf, aVFl); + + if(aS->IsUPeriodic()) + { + const Standard_Real aT = aS->UPeriod(); + +#ifdef DEB + const Standard_Real dU = anUFl - anUFf; + if(dU > aT) + { + cout << "dU = " << dU << " > T = " << aT << ". Delta = " << dU - aT << endl; + } +#endif + + anUFl = anUFf + aT; + } + + if(aS->IsVPeriodic()) + { + const Standard_Real aT = aS->VPeriod(); + +#ifdef DEB + const Standard_Real dv = aVFl - aVFf; + if(dv > aT) + { + cout << "++dV = " << dv << " > T = " << aT << ". Delta = " << dv - aT << endl; + } + +#endif + + aVFl = aVFf + aT; + } + +#ifdef DEB + if(isUtrim) + cout << "Trimming U: (" << anUFf << ")...(" << anUFl << ")" << endl; + + if(isVtrim) + cout << "Trimming V: (" << aVFf << ")...(" << aVFl << ")" << endl; +#endif + + Handle(Geom_RectangularTrimmedSurface) aRTS=new Geom_RectangularTrimmedSurface(aS,isUtrim, + isVtrim, anUFf, anUFl, aVFf, aVFl); + + ReTrimmedFace(aF, aRTS); +} + +//======================================================================= +//function : ReTrimmedFace +//purpose : +//======================================================================= +void ShapeFix::ReTrimmedFace(TopoDS_Face& theF, + const Handle(Geom_RectangularTrimmedSurface)& theNewRTSurf) +{ + TopExp_Explorer aExp; + TopTools_MapOfShape aME; + BRep_Builder aBB; + + aExp.Init(theF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) + { + Standard_Real aT1, aT2; + const TopoDS_Edge& aE=*((TopoDS_Edge*)&aExp.Current()); + if (!aME.Add(aE)) + continue; + + TopLoc_Location aLocE; + Standard_Real aTolE=BRep_Tool::Tolerance(aE); + Handle(Geom2d_Curve) aC2D1=BRep_Tool::CurveOnSurface(aE, theF, aT1, aT2); + Standard_Boolean bIsClosed = BRep_Tool::IsClosed(aE, theF); + + if (!bIsClosed) + { + aBB.UpdateEdge(aE, aC2D1, theNewRTSurf, aLocE, theF, aTolE); + } + else + { + Standard_Boolean bIsLeft; + Standard_Real aScPr; + Handle(Geom2d_Curve) aC2D2; + TopoDS_Edge aE2; + aE2=aE; + aE2.Reverse(); + aC2D2=BRep_Tool::CurveOnSurface(aE2, theF, aT1, aT2); + { + Standard_Real aT, aU1, aU2; + gp_Pnt2d aP2D1, aP2D2; + gp_Vec2d aV2D1, aV2D2; + + const Standard_Real PAR_T = 0.43213918; + aT=(1.-PAR_T)*aT1 + PAR_T*aT2; + aC2D1->D1(aT, aP2D1, aV2D1); + aC2D2->D1(aT, aP2D2, aV2D2); + + aU1=aP2D1.X(); + aU2=aP2D2.X(); + bIsLeft=(aU1 theParMAX) + { + const Standard_Integer aux = theParMAX; + theParMAX = theParMIN; + theParMIN = aux; + } +} + // ------------------------------------------------------------------ // Modulus : Returns the remainder of division between two integers // ------------------------------------------------------------------ diff --git a/src/Standard/Standard_Real.cxx b/src/Standard/Standard_Real.cxx index 0993656635..185c06f590 100644 --- a/src/Standard/Standard_Real.cxx +++ b/src/Standard/Standard_Real.cxx @@ -299,3 +299,14 @@ Standard_Real Sqrt (const Standard_Real Value) return sqrt(Value); } +//======================================================================= +//function : RealMod +//purpose : Returns the remainder of theDivident on theDivisor. +// Quotient is always integer number. +//======================================================================= +Standard_Real RealMod(const Standard_Real theDivident, + const Standard_Real theDivisor) +{ + const Standard_Integer n = RealToInt(theDivident/theDivisor); + return theDivident - n * theDivisor; +} diff --git a/src/Standard/Standard_Real.hxx b/src/Standard/Standard_Real.hxx index 735f5344e8..4bdcb61165 100644 --- a/src/Standard/Standard_Real.hxx +++ b/src/Standard/Standard_Real.hxx @@ -51,6 +51,8 @@ __Standard_API Standard_Real ATanh (const Standard_Real ); __Standard_API Standard_Real ACosh (const Standard_Real ); __Standard_API Standard_Real Log (const Standard_Real ); __Standard_API Standard_Real Sqrt (const Standard_Real ); +__Standard_API Standard_Real RealMod (const Standard_Real theDivident, + const Standard_Real theDivisor); //class Standard_OStream; //void ShallowDump(const Standard_Real, Standard_OStream& ); @@ -253,6 +255,21 @@ inline Standard_Real Min (const Standard_Real Val1, return Val1 <= Val2 ? Val1 : Val2; } +// ------------------------------------------------------------------ +// MinMax : Replaces theParMIN = MIN(theParMIN, theParMAX), +// theParMAX = MAX(theParMIN, theParMAX). +// ------------------------------------------------------------------ +inline void MinMax(Standard_Real& theParMIN, Standard_Real& theParMAX) +{ + if(theParMIN > theParMAX) + { + const Standard_Real aux = theParMAX; + theParMAX = theParMIN; + theParMIN = aux; + } +} + + //------------------------------------------------------------------- // Pow : Returns a real to a given power //------------------------------------------------------------------- diff --git a/tests/blend/complex/D3 b/tests/blend/complex/D3 index 73430d6ec5..1470d56ab2 100644 --- a/tests/blend/complex/D3 +++ b/tests/blend/complex/D3 @@ -4,7 +4,14 @@ ## Comment : from fra60610 ## ==================================== +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file CFI_fra60610.rle] a + +sfixpcu a a +checkshape a + nexplode a e blend result a 2 a_69 diff --git a/tests/boolean/bcut_complex/E7 b/tests/boolean/bcut_complex/E7 index bc2857ace5..bb8aa2a665 100644 --- a/tests/boolean/bcut_complex/E7 +++ b/tests/boolean/bcut_complex/E7 @@ -1,9 +1,16 @@ # Original bug : ger60065 # Date : 11mar98 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file CTO900_ger60065-part.rle] part restore [locate_data_file CTO900_ger60065-tool.rle] tool +sfixpcu part part +sfixpcu tool tool + bcut result part tool diff --git a/tests/boolean/bcut_complex/G2 b/tests/boolean/bcut_complex/G2 index 08b9141cb1..e35f6e2f63 100644 --- a/tests/boolean/bcut_complex/G2 +++ b/tests/boolean/bcut_complex/G2 @@ -1,9 +1,15 @@ # Original bug : pro12663 # Date : 24mar98 +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file CTO900_pro12663-part.rle] part restore [locate_data_file CTO900_pro12663-tool.rle] tool +sfixpcu part part +sfixpcu tool tool + bcut result part tool diff --git a/tests/boolean/bcut_complex/H8 b/tests/boolean/bcut_complex/H8 index b574030360..ae8ae2d5c6 100644 --- a/tests/boolean/bcut_complex/H8 +++ b/tests/boolean/bcut_complex/H8 @@ -1,14 +1,27 @@ # Original bug : cts20736 # Date : 28Sept97 +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file CTO900_cts20736a.rle] part restore [locate_data_file cts20736b.rle] aface +sfixpcu part part +sfixpcu aface aface + +checkshape aface + btolx part btolx aface +checkshape aface + prism tool aface 0 0 -12 +checkshape part +checkshape tool + bcut result part tool set square 36087.8 diff --git a/tests/boolean/bcut_complex/M2 b/tests/boolean/bcut_complex/M2 index d3c36f8e4d..4072a73a50 100644 --- a/tests/boolean/bcut_complex/M2 +++ b/tests/boolean/bcut_complex/M2 @@ -1,9 +1,16 @@ # Original bug : fra61199 # Date : 29June98 + +# for "sfixpcu" command +pload XSDRAW + cpulimit 3000 restore [locate_data_file CTO904_fra61199a.rle] a restore [locate_data_file CTO904_fra61199b.rle] b +sfixpcu a a +sfixpcu b b + bcut result a b set square 1.21952e+06 diff --git a/tests/boolean/bfuse_complex/E6 b/tests/boolean/bfuse_complex/E6 index 9822946a3c..2c2bbf2a6e 100644 --- a/tests/boolean/bfuse_complex/E6 +++ b/tests/boolean/bfuse_complex/E6 @@ -1,9 +1,16 @@ # Original bug : pro10505 # Date : 20mar98 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file CTO900_pro10505a.rle] a restore [locate_data_file CTO900_pro10505b.rle] b +sfixpcu a a +sfixpcu b b + bfuse result a b set square 302396 diff --git a/tests/boolean/bfuse_complex/R8 b/tests/boolean/bfuse_complex/R8 index cf50989098..3ecafdcf62 100644 --- a/tests/boolean/bfuse_complex/R8 +++ b/tests/boolean/bfuse_complex/R8 @@ -2,9 +2,15 @@ puts "PRO16769" puts "Fuse" puts "" +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file CFE900_pro16gff.rle] base restore [locate_data_file pro16769b.rle] tool +sfixpcu base base +sfixpcu tool tool + bfuse result base tool fsameparameter result diff --git a/tests/bugs/modalg_2/bug263 b/tests/bugs/modalg_2/bug263 index 35d5f52d13..dbb0121f5a 100755 --- a/tests/bugs/modalg_2/bug263 +++ b/tests/bugs/modalg_2/bug263 @@ -1,12 +1,18 @@ puts "TODO OCC11111 ALL: Faulty OCC263: here is shading problem" puts "TODO OCC11111 ALL: Error : The square of result shape is" +# for "sfixpcu" command +pload XSDRAW + + puts "========" puts "OCC263" puts "========" restore [locate_data_file OCC263.brep] result +sfixpcu result result + isos result 0 tclean result diff --git a/tests/bugs/modalg_4/bug6272_5 b/tests/bugs/modalg_4/bug6272_5 index fc46efeeb1..100ae17b27 100755 --- a/tests/bugs/modalg_4/bug6272_5 +++ b/tests/bugs/modalg_4/bug6272_5 @@ -8,8 +8,14 @@ puts "" set BugNumber OCC6272 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file OCC6272_bridge2.brep] a1 +sfixpcu a1 a1 + explode a1 bop a1_1 a1_2 diff --git a/tests/bugs/modalg_4/bug6272_6 b/tests/bugs/modalg_4/bug6272_6 index 4bc54718e4..0653004fe0 100755 --- a/tests/bugs/modalg_4/bug6272_6 +++ b/tests/bugs/modalg_4/bug6272_6 @@ -11,9 +11,16 @@ puts "" set BugNumber OCC6272 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file OCC6272_bridge2.brep] a1 restore [locate_data_file OCC6272_revolution.brep] a2 +sfixpcu a1 a1 +sfixpcu a2 a2 + bop a1 a2 bopfuse result diff --git a/tests/bugs/modalg_4/bug6272_710 b/tests/bugs/modalg_4/bug6272_710 index 12b3ca8ffb..2372040b77 100755 --- a/tests/bugs/modalg_4/bug6272_710 +++ b/tests/bugs/modalg_4/bug6272_710 @@ -8,8 +8,14 @@ puts "" set BugNumber OCC6272 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file OCC6272_bridge2.brep] a1 +sfixpcu a1 a1 + # # a1 is compound. It containes a_3, a_5, a_1, a_2, a_4, a_6 solids # diff --git a/tests/bugs/modalg_4/bug6272_77 b/tests/bugs/modalg_4/bug6272_77 index 05d7c48819..9f34dce106 100755 --- a/tests/bugs/modalg_4/bug6272_77 +++ b/tests/bugs/modalg_4/bug6272_77 @@ -8,8 +8,14 @@ puts "" set BugNumber OCC6272 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file OCC6272_bridge2.brep] a1 +sfixpcu a1 a1 + # # a1 is compound. It containes a_3, a_5, a_1, a_2, a_4, a_6 solids # diff --git a/tests/bugs/modalg_4/bug6272_78 b/tests/bugs/modalg_4/bug6272_78 index 7ed242a4f8..e6702ffda0 100755 --- a/tests/bugs/modalg_4/bug6272_78 +++ b/tests/bugs/modalg_4/bug6272_78 @@ -8,8 +8,14 @@ puts "" set BugNumber OCC6272 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file OCC6272_bridge2.brep] a1 +sfixpcu a1 a1 + # # a1 is compound. It containes a_3, a_5, a_1, a_2, a_4, a_6 solids # diff --git a/tests/bugs/modalg_4/bug6272_79 b/tests/bugs/modalg_4/bug6272_79 index 987aa25e56..06fa517367 100755 --- a/tests/bugs/modalg_4/bug6272_79 +++ b/tests/bugs/modalg_4/bug6272_79 @@ -8,8 +8,14 @@ puts "" set BugNumber OCC6272 +# for "sfixpcu" command +pload XSDRAW + + restore [locate_data_file OCC6272_bridge2.brep] a1 +sfixpcu a1 a1 + # # a1 is compound. It containes a_3, a_5, a_1, a_2, a_4, a_6 solids # diff --git a/tests/bugs/moddata_1/bug15 b/tests/bugs/moddata_1/bug15 index 044e6e6ac1..b305e9f6fd 100755 --- a/tests/bugs/moddata_1/bug15 +++ b/tests/bugs/moddata_1/bug15 @@ -4,8 +4,11 @@ puts "OCC15" puts "================" puts "" -restore [locate_data_file OCC15.brep] result +# for "sfixpcu" command +pload XSDRAW +restore [locate_data_file OCC15.brep] result +sfixpcu result result checkshape result vinit diff --git a/tests/bugs/moddata_2/bug956_1 b/tests/bugs/moddata_2/bug956_1 index 10edaf1033..0e84a6e9a5 100755 --- a/tests/bugs/moddata_2/bug956_1 +++ b/tests/bugs/moddata_2/bug956_1 @@ -8,8 +8,13 @@ puts "" ##possible regression in KAS:dev on checkshape. Fails on valid shape ############################################### +# for sfixpcu command +pload XSDRAW + restore [locate_data_file OCC956_1.brep] result +sfixpcu result result + decho off set che [checkshape result] decho on diff --git a/tests/feat/featlf/B8 b/tests/feat/featlf/B8 index 8f31d324c8..f39d63c42c 100644 --- a/tests/feat/featlf/B8 +++ b/tests/feat/featlf/B8 @@ -1,9 +1,15 @@ # Original bug : cts21832 # Date : 26 Nov 98 +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file cts21832_base.brep] base restore [locate_data_file cts21832_cont.brep] cont +sfixpcu base base +sfixpcu base base + explode cont wire copy cont_1 wire plane plan 0 0 0 -1 0 0 diff --git a/tests/feat/featprism/K7 b/tests/feat/featprism/K7 index 0fdeecba16..515da068d4 100644 --- a/tests/feat/featprism/K7 +++ b/tests/feat/featprism/K7 @@ -1,10 +1,17 @@ # Original bug : cts20722 # Date : 21August98 +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file CTO900_cts20722c.rle] base restore [locate_data_file cts20722b.rle] cont restore [locate_data_file cts20722c.rle] funtil +sfixpcu base base +sfixpcu cont cont +sfixpcu funtil funtil + explode cont face #explode base face #copy base_14 funtil diff --git a/tests/feat/featprism/R1 b/tests/feat/featprism/R1 index 51fea72bdc..7a6351e2cf 100644 --- a/tests/feat/featprism/R1 +++ b/tests/feat/featprism/R1 @@ -1,9 +1,15 @@ # Original bug : pro16769 # Date : 02 Dec 98 +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file CFE900_pro16gff.rle] base restore [locate_data_file pro16769_face.brep] cont +sfixpcu base base +sfixpcu cont cont + explode base face mksurface p28 base_28 diff --git a/tests/heal/data/advanced/G9 b/tests/heal/data/advanced/G9 index 47fd996896..70755f4e72 100644 --- a/tests/heal/data/advanced/G9 +++ b/tests/heal/data/advanced/G9 @@ -1,2 +1,5 @@ -restore [locate_data_file CTO900_ger60065-part.rle] a +# for "sfixpcu" command +pload XSDRAW +restore [locate_data_file CTO900_ger60065-part.rle] a +sfixpcu a a diff --git a/tests/heal/data/advanced/H9 b/tests/heal/data/advanced/H9 index e6a48fb4c9..2be94f1de8 100644 --- a/tests/heal/data/advanced/H9 +++ b/tests/heal/data/advanced/H9 @@ -1,2 +1,5 @@ -restore [locate_data_file CTO900_pro10505b.rle] a +# for "sfixpcu" command +pload XSDRAW +restore [locate_data_file CTO900_pro10505b.rle] a +sfixpcu a a diff --git a/tests/heal/data/advanced/I4 b/tests/heal/data/advanced/I4 index f1d220d48d..15eaabb8b8 100644 --- a/tests/heal/data/advanced/I4 +++ b/tests/heal/data/advanced/I4 @@ -1,2 +1,5 @@ -restore [locate_data_file CTO900_pro12663-part.rle] a +# for "sfixpcu" command +pload XSDRAW +restore [locate_data_file CTO900_pro12663-part.rle] a +sfixpcu a a diff --git a/tests/heal/data/advanced/I5 b/tests/heal/data/advanced/I5 index b8a62e96b2..136732fdcd 100644 --- a/tests/heal/data/advanced/I5 +++ b/tests/heal/data/advanced/I5 @@ -1,2 +1,6 @@ -restore [locate_data_file CTO900_pro12663-tool.rle] a +# for "sfixpcu" command +pload XSDRAW +restore [locate_data_file CTO900_pro12663-tool.rle] a +sfixpcu a a +checkshape a \ No newline at end of file diff --git a/tests/heal/data/advanced/M7 b/tests/heal/data/advanced/M7 index b13bd89f4f..8b62847758 100644 --- a/tests/heal/data/advanced/M7 +++ b/tests/heal/data/advanced/M7 @@ -1,2 +1,5 @@ -restore [locate_data_file CTO904_fra61199a.rle] a +# for "sfixpcu" command +pload XSDRAW +restore [locate_data_file CTO904_fra61199a.rle] a +sfixpcu a a diff --git a/tests/heal/data/advanced/ZF1 b/tests/heal/data/advanced/ZF1 index d382115be1..e9c0498923 100644 --- a/tests/heal/data/advanced/ZF1 +++ b/tests/heal/data/advanced/ZF1 @@ -1,3 +1,6 @@ +# for "sfixpcu" command +pload XSDRAW + if {[string compare $command "SplitAngle"] == 0 } { set os "ALL" if {[array get env os_type] != ""} { @@ -13,3 +16,4 @@ if {[string compare $command "SplitAngle"] == 0 } { restore [locate_data_file cd.brep] a +sfixpcu a a diff --git a/tests/heal/data/advanced/ZF2 b/tests/heal/data/advanced/ZF2 index 948a8bbabc..f98efbf32b 100644 --- a/tests/heal/data/advanced/ZF2 +++ b/tests/heal/data/advanced/ZF2 @@ -1,3 +1,6 @@ +# for "sfixpcu" command +pload XSDRAW + if {[string compare $command "SplitAngle"] == 0 } { set os "ALL" if {[array get env os_type] != ""} { @@ -13,3 +16,4 @@ if {[string compare $command "SplitAngle"] == 0 } { restore [locate_data_file cg.brep] a +sfixpcu a a diff --git a/tests/heal/data/advanced/ZF7 b/tests/heal/data/advanced/ZF7 index 349893a696..4bba2c4a6d 100644 --- a/tests/heal/data/advanced/ZF7 +++ b/tests/heal/data/advanced/ZF7 @@ -1,2 +1,6 @@ +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file pd.brep] a +sfixpcu a a diff --git a/tests/heal/data/advanced/ZF8 b/tests/heal/data/advanced/ZF8 index c0e3420db7..23f2476406 100644 --- a/tests/heal/data/advanced/ZF8 +++ b/tests/heal/data/advanced/ZF8 @@ -1,2 +1,5 @@ -restore [locate_data_file pg.brep] a +# for "sfixpcu" command +pload XSDRAW +restore [locate_data_file pg.brep] a +sfixpcu a a diff --git a/tests/heal/data/standard/I5 b/tests/heal/data/standard/I5 index 64893d370a..a9390c8816 100644 --- a/tests/heal/data/standard/I5 +++ b/tests/heal/data/standard/I5 @@ -1,2 +1,7 @@ +# for "sfixpcu" command +pload XSDRAW + restore [locate_data_file CTO900_cts20736a.rle] a +sfixpcu a a +checkshape a diff --git a/tests/heal/split_closed_faces/end b/tests/heal/split_closed_faces/end index 0f6b114402..7717cd49f7 100644 --- a/tests/heal/split_closed_faces/end +++ b/tests/heal/split_closed_faces/end @@ -1,2 +1,3 @@ puts [DT_ClosedSplit result a] +sfixpcu result result puts [checkshape result] diff --git a/tests/heal/surface_to_bspline/B5 b/tests/heal/surface_to_bspline/B5 index e14c28f568..54728a3afe 100644 --- a/tests/heal/surface_to_bspline/B5 +++ b/tests/heal/surface_to_bspline/B5 @@ -1,2 +1,7 @@ +# for "fixshape" command +pload XSDRAW restore [locate_data_file CFI_cfi90fjb.rle] a + +fixshape a a +checkshape a diff --git a/tests/heal/surface_to_bspline/C5 b/tests/heal/surface_to_bspline/C5 index 36e84fbd41..2689a5105a 100644 --- a/tests/heal/surface_to_bspline/C5 +++ b/tests/heal/surface_to_bspline/C5 @@ -1,2 +1,7 @@ +# for "fixshape" command +pload XSDRAW restore [locate_data_file CFI_pro5807.rle] a + +fixshape a a +checkshape a diff --git a/tests/heal/surface_to_bspline/C7 b/tests/heal/surface_to_bspline/C7 index 75ee2947c9..7ce7ba6f3c 100644 --- a/tests/heal/surface_to_bspline/C7 +++ b/tests/heal/surface_to_bspline/C7 @@ -1,2 +1,7 @@ +# for "fixshape" command +pload XSDRAW restore [locate_data_file CHE_cc4.rle] a + +fixshape a a +checkshape a diff --git a/tests/heal/surface_to_bspline/D6 b/tests/heal/surface_to_bspline/D6 index 6046a93494..b5b908915d 100644 --- a/tests/heal/surface_to_bspline/D6 +++ b/tests/heal/surface_to_bspline/D6 @@ -1,2 +1,7 @@ +# for "fixshape" command +pload XSDRAW restore [locate_data_file CTO900_ger60054a.rle] a + +fixshape a a +checkshape a diff --git a/tests/heal/surface_to_bspline/D7 b/tests/heal/surface_to_bspline/D7 index 3182473304..fba9dd2cfb 100644 --- a/tests/heal/surface_to_bspline/D7 +++ b/tests/heal/surface_to_bspline/D7 @@ -1,2 +1,7 @@ +# for "fixshape" command +pload XSDRAW restore [locate_data_file CTS18683.rle] a + +fixshape a a +checkshape a diff --git a/tests/heal/surface_to_bspline/D8 b/tests/heal/surface_to_bspline/D8 index 0d6574308c..9cc95a01ba 100644 --- a/tests/heal/surface_to_bspline/D8 +++ b/tests/heal/surface_to_bspline/D8 @@ -1,2 +1,7 @@ +# for "fixshape" command +pload XSDRAW restore [locate_data_file CTS18826.rle] a + +fixshape a a +checkshape a