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.
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
- -- <C1> or <C2> is a null handle, remove any existing
+ ---Purpose: Sets pcurves (with theContinuity) for the edge on
+ -- the closed face.
+ -- If <C1> or <C2> is a null handle, remove any existing
-- pcurve.
UpdateEdge(me; E : Edge from TopoDS;
---Purpose: Sets a pcurve for the edge on the face.
-- If <C> 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 <C> is a null handle, remove any existing pcurve.
+ -- New edge will be in the face <theFace>, which
+ -- based on surface newSurf. Old surface must be
+ -- deleted from <theFace> later.
+
+ UpdateEdge(me; E : Edge from TopoDS;
C : Curve from Geom2d;
S : Surface from Geom;
L : Location from TopLoc;
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.
- -- <C1> or <C2> is a null handle, remove any existing
+ ---Purpose: Sets pcurves (with theContinuity) for the edge on the
+ -- closed surface.
+ -- If <C1> or <C2> 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 <C1> or <C2> is a null handle, remove any
+ -- existing pcurve.
+ -- New edge will be in the face <theFace>, which
+ -- based on surface newSurf. Old surface must be
+ -- deleted from <theFace> later.
+
UpdateEdge(me; E : Edge from TopoDS;
C1,C2 : Curve from Geom2d;
S : Surface from Geom;
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;
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);
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;
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);
}
}
+//=======================================================================
+//function : UpdateCurves
+//purpose : Insert two pcurves <C1,C2> on surface <newSurf> with
+// location <newL> in the list of curve representations <lcr>.
+// Deletes curves, which belong to <oldSurf> because <oldSurf>
+// will not be used later (presumably).
+// Remove the pcurves on <S> from <lcr> if <C1> or <C2> 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 <C> on surface <newSurf> with
+// location <newL> in the list of curve representations <lcr>.
+// Remove the pcurves on <oldSurf> from <lcr> if <C> 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,
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
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());
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
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);
}
FreeEdge,
InvalidMultiConnexity,
InvalidRange,
+ PCurveIsOutOfDomainFace,
-- for wires
-- for faces
NoSurface,
+ OutOfSurfaceBoundary,
InvalidWire,
RedundantWire,
IntersectingWires,
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;
}
}
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<<endl;
+ cout<<"BRepCheck_Analyzer : ";
+ Standard_Failure::Caught()->Print(cout);
+ cout<<endl;
#endif
- if ( ! myMap(S).IsNull() ) {
- myMap(S)->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:
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<<endl;
+ cout<<"BRepCheck_Analyzer : ";
+ Standard_Failure::Caught()->Print(cout);
+ cout<<endl;
#endif
- 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);
- }
- }
- }
+ 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())
+
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<<endl;
+ cout<<"BRepCheck_Analyzer : ";
+ Standard_Failure::Caught()->Print(cout);
+ cout<<endl;
#endif
+ if ( ! myMap(S).IsNull() )
+ myMap(S)->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) {
+ 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;
+ }
+ }
+ }//if (orientofwires)
+ }
+ catch(Standard_Failure)
+ {
#ifdef DEB
- cout<<"BRepCheck_Analyzer : ";
- Standard_Failure::Caught()->Print(cout);
- cout<<endl;
+ cout<<"BRepCheck_Analyzer : ";
+ Standard_Failure::Caught()->Print(cout);
+ cout<<endl;
#endif
- 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);
- }
- }
- }
-
- try {
+ 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);
+ }
+ }
+ }//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<<endl;
+ cout<<"BRepCheck_Analyzer : ";
+ Standard_Failure::Caught()->Print(cout);
+ cout<<endl;
#endif
- if ( ! myMap(S).IsNull() ) {
- myMap(S)->SetFailStatus(S);
- }
-
- 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());
- }
- }
- }
+ if ( ! myMap(S).IsNull() )
+ {
+ myMap(S)->SetFailStatus(S);
+ }
+
+ 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<<endl;
-#endif
-
- 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);
- }
- }
- } //
- 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<<endl;
-#endif
-
- if ( ! myMap(S).IsNull() ) {
- myMap(S)->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<<endl;
+ cout<<"BRepCheck_Analyzer : ";
+ Standard_Failure::Caught()->Print(cout);
+ cout<<endl;
#endif
- if ( ! myMap(S).IsNull() ) {
- myMap(S)->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) {
#include <Precision.hxx>
-//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,
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
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);
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();
-
- 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);
- // 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 (!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);
-
- // 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);
-
- Standard_Boolean ok = Validate(myHCurve->Curve(),ACS,
- Tol,Standard_True); // voir dub...
- if (!ok) {
- BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
- }
- }
- }
- }
- }
- 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++;
- }
- }
- }
- if (nbconnection < 2 && !TE->Degenerated()) {
- BRepCheck::Add(myMap(S),BRepCheck_FreeEdge);
- }
- else if (nbconnection > 2) {
- BRepCheck::Add(myMap(S),BRepCheck_InvalidMultiConnexity);
+ switch (styp)
+ {
+ case TopAbs_FACE:
+ if (myCref.IsNull())
+ break;
+
+ {
+ Standard_Boolean SameParameter = TE->SameParameter();
+ Standard_Boolean SameRange = TE->SameRange();
+
+ if (!SameParameter || !SameRange)
+ {
+ if (!SameParameter)
+ BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
+
+ if (!SameRange)
+ BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
+
+ return;
+ }//if (!SameParameter || !SameRange)
+
+ const Standard_Real First = myHCurve->FirstParameter();
+ const Standard_Real Last = myHCurve->LastParameter();
+
+ 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;
}
- else {
- BRepCheck::Add(myMap(S),BRepCheck_NoError);
+ 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);
+
}
- }
- break;
- default:
- break;
- }
- if (myMap(S).IsEmpty()) {
+ break;
+
+ default:
+ break;
+ }//switch (styp)
+
+ if (myMap(S).IsEmpty())
myMap(S).Append(BRepCheck_NoError);
- }
}
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++) {
//=======================================================================
//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 <Adaptor3d_CurveOnSurface> contains
+// can be periodic.
+// To use true values of flags, the parameters
+// <theSurfIsUPeriodic> and <theSurfIsVPeriodic> 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 ;
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 :
is static;
+ SetStatus(me: mutable;
+ theStatus:Status from BRepCheck)
+
+ --- Purpose: Sets status of Face;
+ is static;
+
+
IsUnorientable(me)
BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape);
}
+//=======================================================================
+//function : SetStatus
+//purpose :
+//=======================================================================
+
+void BRepCheck_Face::SetStatus(const BRepCheck_Status theStatus)
+{
+ BRepCheck::Add(myMap(myShape),theStatus);
+}
//=======================================================================
//function : IsUnorientable
#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;
{
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;
{
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;
//pmn 26/09/97 Add parameters of approximation in BuildCurve3d
// Modified by skv - Thu Jun 3 12:39:19 2004 OCC5898
-
#include <BRepLib.ixx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepAdaptor_HSurface.hxx>
-#include <BRepAdaptor_HCurve2d.hxx>
-#include <BRep_Tool.hxx>
+#include <Adaptor3d_CurveOnSurface.hxx>
+#include <AdvApprox_ApproxAFunction.hxx>
+#include <Approx_CurvilinearParameter.hxx>
+#include <Approx_SameParameter.hxx>
+#include <Bnd_Box.hxx>
#include <BRep_Builder.hxx>
-#include <Geom_Surface.hxx>
+#include <BRep_GCurve.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRepAdaptor_HCurve2d.hxx>
+#include <BRepAdaptor_HSurface.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+#include <BSplCLib.hxx>
+#include <ElSLib.hxx>
+#include <Extrema_LocateExtPC.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
+#include <Geom_BSplineSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_BSplineCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
-#include <Geom2d_Curve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAdaptor.hxx>
+#include <Geom2dAdaptor_HCurve.hxx>
+#include <Geom2dConvert.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAdaptor_HCurve.hxx>
+#include <GeomAdaptor_HSurface.hxx>
#include <GeomLib.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopExp.hxx>
-#include <gp.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Pln.hxx>
-#include <Standard_Real.hxx>
-#include <Precision.hxx>
-#include <BRep_GCurve.hxx>
-#include <BRep_TEdge.hxx>
-#include <BRep_TFace.hxx>
-#include <AppParCurves_MultiCurve.hxx>
-#include <AppParCurves_MultiBSpCurve.hxx>
-#include <BRep_ListOfCurveRepresentation.hxx>
-#include <BRep_CurveRepresentation.hxx>
-#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
-#include <BRep_TVertex.hxx>
-#include <AdvApprox_ApproxAFunction.hxx>
-#include <Approx_SameParameter.hxx>
+#include <ProjLib_ProjectedCurve.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_HSequenceOfReal.hxx>
#include <TColStd_MapOfTransient.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <GeomAdaptor_HCurve.hxx>
-#include <GeomAdaptor_Surface.hxx>
-#include <GeomAdaptor_HSurface.hxx>
-#include <Geom2dAdaptor_Curve.hxx>
-#include <Geom2dAdaptor_HCurve.hxx>
-#include <Geom2dAdaptor.hxx>
-#include <Geom2dConvert.hxx>
-#include <GCPnts_QuasiUniformDeflection.hxx>
-#include <BSplCLib.hxx>
-#include <ElSLib.hxx>
-#include <Adaptor3d_CurveOnSurface.hxx>
-#include <Extrema_LocateExtPC.hxx>
-#include <ProjLib_ProjectedCurve.hxx>
-#include <BRepClass3d_SolidClassifier.hxx>
-#include <Bnd_Box.hxx>
-#include <BRepBndLib.hxx>
-#include <Approx_CurvilinearParameter.hxx>
-#include <Geom_BSplineSurface.hxx>
-
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
// TODO - not thread-safe static variables
static Standard_Real thePrecision = Precision::Confusion();
//=======================================================================
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 ;
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) ;
}
//=======================================================================
//=======================================================================
static Standard_Integer evaluateMaxSegment(const Standard_Integer aMaxSegment,
- const Adaptor3d_CurveOnSurface& aCurveOnSurface)
+ const Adaptor3d_CurveOnSurface& aCurveOnSurface)
{
if (aMaxSegment != 0) return 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());
//=======================================================================
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] ;
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;
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)
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
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;
}
{
return BRepLib::BuildCurves3d(S,
- 1.0e-5) ;
+ 1.0e-5) ;
}
//=======================================================================
//=======================================================================
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();
//=======================================================================
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 ;
-
- 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 ;
+ 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()) ) ;
}
- 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) ;
+ }
+ 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() ;
}
- 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 ;
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();
//=======================================================================
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);
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();
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);
//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;
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);
}
// 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();
}
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)
{
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);
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;
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()) {
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;
//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()){
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);
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);
-
- updatepc = (curPC != PC[i]);
-
- }
- Standard_Boolean goodpc = 1;
- GAC2d.Load(curPC,f3d,l3d);
-
- 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(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);
-
- 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) {
- 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;
-
- Tol2dbail = Max(Min(Tol2dbail,d),Tol2d);
-
- 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() ) {
-
- 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;
- }
-
- 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;
-
- 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(IsBad ) { //if BSpline "bad", try to reparametrize it
- // by its curve length
-
- // 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
+ 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]);
+
+ }
+ Standard_Boolean goodpc = 1;
+ GAC2d.Load(curPC,f3d,l3d);
+
+ 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(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);
+
+ 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) {
+ 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;
+
+ Tol2dbail = Max(Min(Tol2dbail,d),Tol2d);
+
+ 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() ) {
+
+ 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;
+ }
+
+ 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;
+
+ 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(IsBad ) { //if BSpline "bad", try to reparametrize it
+ // by its curve length
+
+// 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
}
}
It.Next() ;
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);
}
//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) {
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);
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;
// 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);
}
}
//=======================================================================
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) {
//=======================================================================
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;
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.
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();
-
- 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);
+ 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);
}
}
if(ang >= angmax) angmax = ang;
}
-
+
return (angmax<=ta);
}
//=======================================================================
void BRepLib::EncodeRegularity(const TopoDS_Shape& S,
- const Standard_Real TolAng)
+ const Standard_Real TolAng)
{
BRep_Builder B;
TopTools_IndexedDataMapOfShapeListOfShape M;
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)
//=======================================================================
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){
catch(Standard_Failure)
{
}
- }
+ }
}
//=======================================================================
//=======================================================================
void BRepLib::SortFaces (const TopoDS_Shape& Sh,
- TopTools_ListOfShape& LF)
+ TopTools_ListOfShape& LF)
{
LF.Clear();
TopTools_ListOfShape LTri,LPlan,LCyl,LCon,LSphere,LTor,LOther;
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);
//=======================================================================
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);
-
+
}
-
# include <strings.h>
#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)
{
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;
}
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();
theCommands<<" Invalid Range ............................ "<<NbProblems->Value(15)<<"\n";
//cout<<" Invalid Range ............................ "<<NbProblems->Value(15)<<endl;
if(NbProblems->Value(16)>0)
- theCommands<<" Empty Wire ............................... "<<NbProblems->Value(16)<<"\n";
- //cout<<" Empty Wire ............................... "<<NbProblems->Value(16)<<endl;
+ theCommands<<" pcurve is out of domain face.............. "<<NbProblems->Value(16)<<"\n";
+ //cout<<" Invalid Range ............................ "<<NbProblems->Value(15)<<endl;
if(NbProblems->Value(17)>0)
- theCommands<<" Redundant Edge ........................... "<<NbProblems->Value(17)<<"\n";
- //cout<<" Redundant Edge ........................... "<<NbProblems->Value(17)<<endl;
+ theCommands<<" Empty Wire ............................... "<<NbProblems->Value(17)<<"\n";
+ //cout<<" Empty Wire ............................... "<<NbProblems->Value(16)<<endl;
if(NbProblems->Value(18)>0)
- theCommands<<" Self Intersecting Wire ................... "<<NbProblems->Value(18)<<"\n";
- //cout<<" Self Intersecting Wire ................... "<<NbProblems->Value(18)<<endl;
+ theCommands<<" Redundant Edge ........................... "<<NbProblems->Value(18)<<"\n";
+ //cout<<" Redundant Edge ........................... "<<NbProblems->Value(17)<<endl;
if(NbProblems->Value(19)>0)
- theCommands<<" No Surface ............................... "<<NbProblems->Value(19)<<"\n";
- //cout<<" No Surface ............................... "<<NbProblems->Value(19)<<endl;
+ theCommands<<" Self Intersecting Wire ................... "<<NbProblems->Value(19)<<"\n";
+ //cout<<" Self Intersecting Wire ................... "<<NbProblems->Value(18)<<endl;
if(NbProblems->Value(20)>0)
- theCommands<<" Invalid Wire ............................. "<<NbProblems->Value(20)<<"\n";
- //cout<<" Invalid Wire ............................. "<<NbProblems->Value(20)<<endl;
+ theCommands<<" No Surface ............................... "<<NbProblems->Value(20)<<"\n";
+ //cout<<" No Surface ............................... "<<NbProblems->Value(19)<<endl;
if(NbProblems->Value(21)>0)
- theCommands<<" Redundant Wire ........................... "<<NbProblems->Value(21)<<"\n";
- //cout<<" Redundant Wire ........................... "<<NbProblems->Value(21)<<endl;
+ theCommands<<" Face is out of it surface boundary........ "<<NbProblems->Value(21)<<"\n";
+ //cout<<" Invalid Wire ............................. "<<NbProblems->Value(20)<<endl;
if(NbProblems->Value(22)>0)
- theCommands<<" Intersecting Wires ....................... "<<NbProblems->Value(22)<<"\n";
- //cout<<" Intersecting Wires ....................... "<<NbProblems->Value(22)<<endl;
+ theCommands<<" Invalid Wire ............................. "<<NbProblems->Value(22)<<"\n";
+ //cout<<" Invalid Wire ............................. "<<NbProblems->Value(20)<<endl;
if(NbProblems->Value(23)>0)
- theCommands<<" Invalid Imbrication of Wires ............. "<<NbProblems->Value(23)<<"\n";
- //cout<<" Invalid Imbrication of Wires ............. "<<NbProblems->Value(23)<<endl;
+ theCommands<<" Redundant Wire ........................... "<<NbProblems->Value(23)<<"\n";
+ //cout<<" Redundant Wire ........................... "<<NbProblems->Value(21)<<endl;
if(NbProblems->Value(24)>0)
- theCommands<<" Empty Shell .............................. "<<NbProblems->Value(24)<<"\n";
- //cout<<" Empty Shell .............................. "<<NbProblems->Value(24)<<endl;
+ theCommands<<" Intersecting Wires ....................... "<<NbProblems->Value(24)<<"\n";
+ //cout<<" Intersecting Wires ....................... "<<NbProblems->Value(22)<<endl;
if(NbProblems->Value(25)>0)
- theCommands<<" Redundant Face ........................... "<<NbProblems->Value(25)<<"\n";
- //cout<<" Redundant Face ........................... "<<NbProblems->Value(25)<<endl;
+ theCommands<<" Invalid Imbrication of Wires ............. "<<NbProblems->Value(25)<<"\n";
+ //cout<<" Invalid Imbrication of Wires ............. "<<NbProblems->Value(23)<<endl;
if(NbProblems->Value(26)>0)
- theCommands<<" Unorientable Shape ....................... "<<NbProblems->Value(26)<<"\n";
- //cout<<" Unorientable Shape ....................... "<<NbProblems->Value(26)<<endl;
+ theCommands<<" Empty Shell .............................. "<<NbProblems->Value(26)<<"\n";
+ //cout<<" Empty Shell .............................. "<<NbProblems->Value(24)<<endl;
if(NbProblems->Value(27)>0)
- theCommands<<" Not Closed ............................... "<<NbProblems->Value(27)<<"\n";
- //cout<<" Not Closed ............................... "<<NbProblems->Value(27)<<endl;
+ theCommands<<" Redundant Face ........................... "<<NbProblems->Value(27)<<"\n";
+ //cout<<" Redundant Face ........................... "<<NbProblems->Value(25)<<endl;
if(NbProblems->Value(28)>0)
- theCommands<<" Not Connected ............................ "<<NbProblems->Value(28)<<"\n";
- //cout<<" Not Connected ............................ "<<NbProblems->Value(28)<<endl;
+ theCommands<<" Unorientable Shape ....................... "<<NbProblems->Value(28)<<"\n";
+ //cout<<" Unorientable Shape ....................... "<<NbProblems->Value(26)<<endl;
if(NbProblems->Value(29)>0)
- theCommands<<" Subshape not in Shape .................... "<<NbProblems->Value(29)<<"\n";
- //cout<<" Subshape not in Shape .................... "<<NbProblems->Value(29)<<endl;
+ theCommands<<" Not Closed ............................... "<<NbProblems->Value(29)<<"\n";
+ //cout<<" Not Closed ............................... "<<NbProblems->Value(27)<<endl;
if(NbProblems->Value(30)>0)
- theCommands<<" Bad Orientation .......................... "<<NbProblems->Value(30)<<"\n";
- //cout<<" Bad Orientation .......................... "<<NbProblems->Value(30)<<endl;
+ theCommands<<" Not Connected ............................ "<<NbProblems->Value(30)<<"\n";
+ //cout<<" Not Connected ............................ "<<NbProblems->Value(28)<<endl;
if(NbProblems->Value(31)>0)
- theCommands<<" Bad Orientation of Subshape .............. "<<NbProblems->Value(31)<<"\n";
- //cout<<" Bad Orientation of Subshape .............. "<<NbProblems->Value(31)<<endl;
+ theCommands<<" Subshape not in Shape .................... "<<NbProblems->Value(31)<<"\n";
+ //cout<<" Subshape not in Shape .................... "<<NbProblems->Value(29)<<endl;
if(NbProblems->Value(32)>0)
- theCommands<<" checkshape failure......... .............. "<<NbProblems->Value(32)<<"\n";
+ theCommands<<" Bad Orientation .......................... "<<NbProblems->Value(32)<<"\n";
+ //cout<<" Bad Orientation .......................... "<<NbProblems->Value(30)<<endl;
+ if(NbProblems->Value(33)>0)
+ theCommands<<" Bad Orientation of Subshape .............. "<<NbProblems->Value(33)<<"\n";
+ //cout<<" Bad Orientation of Subshape .............. "<<NbProblems->Value(31)<<endl;
+ if(NbProblems->Value(34)>0)
+ theCommands<<" Invalid tolerance......................... "<<NbProblems->Value(34)<<"\n";
+ //cout<<" checkshape failure......... .............. "<<NbProblems->Value(32)<<endl;
+ if(NbProblems->Value(35)>0)
+ theCommands<<" checkshape failure........................ "<<NbProblems->Value(35)<<"\n";
//cout<<" checkshape failure......... .............. "<<NbProblems->Value(32)<<endl;
//cout<<" ------------------------------------------------"<<endl;
raises ConstructionError;
+ Create (S : Surface from Geom;
+ isUTrim, isVTrim : Boolean;
+ U1, U2, V1, V2 : Real)
+ returns mutable RectangularTrimmedSurface
+ ---Purpose :
+ -- The U parametric direction of the surface is oriented from U1
+ -- to U2. The V parametric direction of the surface is oriented
+ -- from V1 to V2.
+ -- These two directions define the orientation of the surface
+ -- (normal). By default in this case the surface has the same
+ -- orientation as the basis surface S.
+ -- isUTrim and isVTrim arguments determine, if it is necessary to
+ -- trim S surface along corresponding direction.
+ -- The returned surface is not closed and not periodic.
+ -- ConstructionError Raised if
+ -- S is not periodic in the UDirection and U1 or U2 are out of the
+ -- bounds of S.
+ -- S is not periodic in the VDirection and V1 or V2 are out of the
+ -- bounds of S.
+ -- U1 = U2 or V1 = V2
+
+ raises ConstructionError;
+
Create (S : Surface from Geom;
Param1, Param2 : Real;
UTrim : Boolean;
-- Param1 or Param2 are out of the bounds of S.
-- Param1 = Param2
+ SetUTrim (me : mutable; U1, U2 : Real)
+ ---Purpose : Sets boundaries of basisSurf in U1 and U2
+ -- along U-direction.
+ -- For periodic surface boundary values can be changed
+ -- algorithmically.
+ raises ConstructionError;
+ ---Purpose : Raised if
+ -- The BasisSurface is not periodic in the U-direction and U1 or U2
+ -- are out of the bounds of the BasisSurface.
+ -- U1 = U2
+ SetVTrim (me : mutable; V1, V2 : Real)
+ ---Purpose : Sets boundaries of basisSurf in V1 and V2
+ -- along V-direction.
+ -- For periodic surface boundary values can be changed
+ -- algorithmically.
+ raises ConstructionError;
+ ---Purpose : Raised if
+ -- The BasisSurface is not periodic in the V-direction and V1 or V2
+ -- are out of the bounds of the BasisSurface.
+ -- V1 = V2
+
+ ForceTrim(me : mutable;
+ U1, U2, V1, V2 : Real;
+ UTrim, VTrim : Boolean = Standard_True);
+ ---Purpose : For periodic surface this method changes
+ -- (if it is necessary) U2 and V2, so that 0 < U2 - U1 < T and
+ -- 0 < V2 - V1 < T (where T is the period).
+ -- If surface is not periodic, boundaries do not chenge.
+ -- After that it trims basisSurf in new boundaries.
+
SetTrim (me : mutable;
U1, U2, V1, V2 : Real;
USense, VSense : Boolean = Standard_True)
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this patch.
+
+ GetTrimmedFlags(me; isUtrimmed,isVtrimmed : in out Boolean from Standard);
+ ---Purpose: Allows to get <isutrimmed> and <isvtrimmed> members values.
+
fields
basisSurf : Surface from Geom;
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
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
//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;
-
- basisSurf->Bounds(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));
- // Trimming the U-Direction
- isutrimmed = UTrim;
- if (!UTrim) {
- utrim1 = Udeb;
- utrim2 = Ufin;
- }
- else {
- if ( U1 == U2)
- Standard_ConstructionError::Raise
- ("Geom_RectangularTrimmedSurface::U1==U2");
+ basisSurf->Bounds(utrim1, utrim2, vtrim1, vtrim2);
- 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");
+ isutrimmed = isUTrim;
+ isvtrimmed = isVTrim;
- }
- }
+ // Trimming the U-Direction
+ 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 (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 (isvtrimmed)
+ SetVTrim(theV1,theV2);
- if (!UsameSense) UReverse();
- if (!VsameSense) VReverse();
+ if (!UsameSense)
+ UReverse();
+ if (!VsameSense)
+ VReverse();
}
return basisSurf->ParametricTransformation(T);
}
+//=======================================================================
+//function : GetTrimmedFlags
+//purpose :
+//=======================================================================
+void Geom_RectangularTrimmedSurface::GetTrimmedFlags(Standard_Boolean& isU, Standard_Boolean& isV) const
+{
+ isU = isutrimmed;
+ isV = isvtrimmed;
+}
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);
#include <SWDRAW_ShapeFix.ixx>
-#include <Draw.hxx>
-#include <DBRep.hxx>
-#include <SWDRAW.hxx>
-#include <gp_XYZ.hxx>
-#include <gp_Pnt2d.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopExp_Explorer.hxx>
-#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
#include <BRepBuilderAPI.hxx>
+#include <BRepCheck_Analyzer.hxx>
+#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
+#include <BRepCheck_Result.hxx>
+#include <BRepTools.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
-
-#include <ShapeBuild_ReShape.hxx>
+#include <DBRep.hxx>
+#include <Draw.hxx>
+#include <Draw_ProgressIndicator.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <gp_XYZ.hxx>
+#include <Message_ListIteratorOfListOfMsg.hxx>
+#include <Message_Msg.hxx>
#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeAnalysis_FreeBounds.hxx>
+#include <ShapeAnalysis_Wire.hxx>
#include <ShapeAnalysis_WireOrder.hxx>
#include <ShapeAnalysis_WireVertex.hxx>
-#include <ShapeAnalysis_Wire.hxx>
-#include <ShapeExtend_WireData.hxx>
+#include <ShapeBuild_ReShape.hxx>
+#include <ShapeExtend_CompositeSurface.hxx>
+#include <ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg.hxx>
+#include <ShapeExtend_MsgRegistrator.hxx>
#include <ShapeFix.hxx>
+#include <ShapeFix_ComposeShell.hxx>
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_Shape.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <ShapeFix_Wire.hxx>
-#include <ShapeFix_WireVertex.hxx>
#include <ShapeFix_Wireframe.hxx>
-#include <ShapeFix_Face.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <Precision.hxx>
-#include <ShapeExtend_DataMapOfShapeListOfMsg.hxx>
-#include <ShapeExtend_MsgRegistrator.hxx>
-#include <ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg.hxx>
-#include <Message_ListIteratorOfListOfMsg.hxx>
-#include <Message_Msg.hxx>
-#include <TCollection_AsciiString.hxx>
+#include <ShapeFix_WireVertex.hxx>
+#include <SWDRAW.hxx>
+#include <TColGeom_HArray2OfSurface.hxx>
#include <TColStd_DataMapIteratorOfDataMapOfAsciiStringInteger.hxx>
#include <TColStd_DataMapOfAsciiStringInteger.hxx>
-#include <TopTools_MapOfShape.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
-#include <TopAbs_State.hxx>
-
-#include <Draw_ProgressIndicator.hxx>
-#include <ShapeAnalysis_FreeBounds.hxx>
#include <TopTools_HSequenceOfShape.hxx>
-#include <BRep_Builder.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopExp.hxx>
#ifdef AIX
#include <strings.h>
}
+//=======================================================================
+//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 :
__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);
}
TopTools,
BRep,
ShapeExtend,
- BRepTools
-
+ BRepTools,
+ GeomAbs
+
is
class Vertex;
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;
//szv#9:S4244:19Aug99: Added method FixWireGaps
//szv#10:S4244:23Aug99: Added method FixFaceGaps
+#include <Adaptor3d_CurveOnSurface.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
-
-#include <Geom2d_Curve.hxx>
+#include <BRepLib.hxx>
+#include <BRepTools.hxx>
#include <Geom_Curve.hxx>
-
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom2dAdaptor_HCurve.hxx>
+#include <GeomAdaptor_HSurface.hxx>
+#include <gp_Pnt.hxx>
+#include <Message_ProgressSentry.hxx>
#include <Precision.hxx>
-
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeAnalysis_Surface.hxx>
+#include <ShapeBuild_Edge.hxx>
+#include <ShapeBuild_ReShape.hxx>
+#include <ShapeExtend_CompositeSurface.hxx>
+#include <ShapeFix.hxx>
+#include <ShapeFix_ComposeShell.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_Shape.hxx>
+#include <ShapeFix_Wire.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
-
+#include <TColGeom_HArray2OfSurface.hxx>
+#include <TColgp_SequenceOfPnt.hxx>
+#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
-#include <Geom_Surface.hxx>
-
-//:i2
-#include <gp_Pnt.hxx>
-#include <Geom_Plane.hxx>
-#include <ShapeFix_Edge.hxx>
-#include <Geom2dAdaptor_HCurve.hxx>
-#include <Adaptor3d_CurveOnSurface.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <ShapeAnalysis_Surface.hxx>
-
-#include <ShapeFix_Edge.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_Wire.hxx>
-#include <ShapeFix_Face.hxx>
#include <TopoDS_Iterator.hxx>
-#include <GeomAdaptor_HSurface.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <BRepLib.hxx>
-
-#include <ShapeAnalysis_Edge.hxx>
-#include <ShapeBuild_Edge.hxx>
#include <TopoDS_Vertex.hxx>
-#include <ShapeBuild_ReShape.hxx>
-#include <TColgp_SequenceOfPnt.hxx>
-#include <TopTools_ListOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopExp.hxx>
-
-#include <Message_ProgressSentry.hxx>
//=======================================================================
//function : SameParameter
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<aU2);
+
+ gp_Vec2d aDOY(0.,1.);
+ aScPr=aV2D1*aDOY;
+ }
+
+ if (!bIsLeft)
+ {
+ if (aScPr<0.)
+ aBB.UpdateEdge(aE, aC2D2, aC2D1, theNewRTSurf, aLocE, theF, aTolE);
+ else
+ aBB.UpdateEdge(aE, aC2D1, aC2D2, theNewRTSurf, aLocE, theF, aTolE);
+ }
+ else
+ {
+ if (aScPr<0.)
+ aBB.UpdateEdge(aE, aC2D1, aC2D2, theNewRTSurf, aLocE, theF, aTolE);
+ else
+ aBB.UpdateEdge(aE, aC2D2, aC2D1, theNewRTSurf, aLocE, theF, aTolE);
+ }
+ }
+ }
+
+ TopLoc_Location aLoc;
+ aBB.UpdateFace(theF, theNewRTSurf, aLoc, BRep_Tool::Tolerance(theF));
+}
return Val1 <= Val2 ? Val1 : Val2;
}
+// ------------------------------------------------------------------
+// MinMax : Replaces theParMIN = MIN(theParMIN, theParMAX),
+// theParMAX = MAX(theParMIN, theParMAX).
+// ------------------------------------------------------------------
+inline void MinMax(Standard_Integer& theParMIN, Standard_Integer& theParMAX)
+{
+ if(theParMIN > theParMAX)
+ {
+ const Standard_Integer aux = theParMAX;
+ theParMAX = theParMIN;
+ theParMIN = aux;
+ }
+}
+
// ------------------------------------------------------------------
// Modulus : Returns the remainder of division between two integers
// ------------------------------------------------------------------
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;
+}
__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& );
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
//-------------------------------------------------------------------
## 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
# 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
# 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
# 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
# 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
# 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
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
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
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
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
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
#
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
#
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
#
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
#
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
##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
# 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
# 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
# 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
-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
-restore [locate_data_file CTO900_pro10505b.rle] a
+# for "sfixpcu" command
+pload XSDRAW
+restore [locate_data_file CTO900_pro10505b.rle] a
+sfixpcu a a
-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
-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
-restore [locate_data_file CTO904_fra61199a.rle] a
+# for "sfixpcu" command
+pload XSDRAW
+restore [locate_data_file CTO904_fra61199a.rle] a
+sfixpcu a a
+# for "sfixpcu" command
+pload XSDRAW
+
if {[string compare $command "SplitAngle"] == 0 } {
set os "ALL"
if {[array get env os_type] != ""} {
restore [locate_data_file cd.brep] a
+sfixpcu a a
+# for "sfixpcu" command
+pload XSDRAW
+
if {[string compare $command "SplitAngle"] == 0 } {
set os "ALL"
if {[array get env os_type] != ""} {
restore [locate_data_file cg.brep] a
+sfixpcu a a
+# for "sfixpcu" command
+pload XSDRAW
+
restore [locate_data_file pd.brep] a
+sfixpcu a a
-restore [locate_data_file pg.brep] a
+# for "sfixpcu" command
+pload XSDRAW
+restore [locate_data_file pg.brep] a
+sfixpcu a a
+# for "sfixpcu" command
+pload XSDRAW
+
restore [locate_data_file CTO900_cts20736a.rle] a
+sfixpcu a a
+checkshape a
puts [DT_ClosedSplit result a]
+sfixpcu result result
puts [checkshape result]
+# for "fixshape" command
+pload XSDRAW
restore [locate_data_file CFI_cfi90fjb.rle] a
+
+fixshape a a
+checkshape a
+# for "fixshape" command
+pload XSDRAW
restore [locate_data_file CFI_pro5807.rle] a
+
+fixshape a a
+checkshape a
+# for "fixshape" command
+pload XSDRAW
restore [locate_data_file CHE_cc4.rle] a
+
+fixshape a a
+checkshape a
+# for "fixshape" command
+pload XSDRAW
restore [locate_data_file CTO900_ger60054a.rle] a
+
+fixshape a a
+checkshape a
+# for "fixshape" command
+pload XSDRAW
restore [locate_data_file CTS18683.rle] a
+
+fixshape a a
+checkshape a
+# for "fixshape" command
+pload XSDRAW
restore [locate_data_file CTS18826.rle] a
+
+fixshape a a
+checkshape a