+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
// abv 30 Dec 98: code optimizations
//:o1 abv 16.02.99: updating vertices tolerance when edge is updated
// rln 03.03.99 S4135: removed unnecessary check for Geom_SphericalSurface (as not V-closed)
//:r4 abv 02.04.99 improving method FixSameParameter()
//:s5 abv 22.04.99 Adding debug printouts in catch {} blocks
// abv 05.05.99 S4137: method CopyPCurves moved to ShapeBuild_Edge
-#include <ShapeFix_Edge.ixx>
-
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
#include <BRep_Builder.hxx>
#include <BRep_GCurve.hxx>
-#include <BRep_TEdge.hxx>
-#include <BRep_Tool.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_Tool.hxx>
#include <BRepLib.hxx>
-
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_BoundedCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
-#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_OffsetCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
-#include <Geom2d_BezierCurve.hxx>
-
#include <Geom_Curve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_Surface.hxx>
#include <GeomLib.hxx>
-
#include <Precision.hxx>
-#include <TopExp.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS.hxx>
-
+#include <ShapeAnalysis_Curve.hxx>
#include <ShapeAnalysis_Edge.hxx>
-#include <ShapeExtend.hxx>
+#include <ShapeAnalysis_Surface.hxx>
#include <ShapeBuild_Edge.hxx>
+#include <ShapeConstruct_ProjectCurveOnSurface.hxx>
+#include <ShapeExtend.hxx>
+#include <ShapeFix_Edge.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
-#include <Geom2d_OffsetCurve.hxx>
-#include <ShapeAnalysis_Curve.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <Standard_Type.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <ShapeBuild_ReShape.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(ShapeFix_Edge,MMgt_TShared)
//=======================================================================
//function : ShapeFix_Edge
//purpose :
//=======================================================================
-
ShapeFix_Edge::ShapeFix_Edge()
{
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
const Standard_Boolean isSeam,
const Standard_Real prec)
{
- Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface (surface);
+ Handle(Geom_Surface) aTransSurf = surface;
+ if( !location.IsIdentity())
+ {
+ gp_Trsf aTrsf(location);
+ aTransSurf = Handle(Geom_Surface)::DownCast(surface->Transformed(aTrsf));
+ }
+ Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface (aTransSurf);
return FixAddPCurve (edge, surface, location, isSeam, sas, prec);
}
}
*/
// Other case not yet implemented
-#ifdef DEBUG
+#ifdef OCCT_DEBUG
cout << "TranslatePCurve not performed" << endl;
#endif
return theNewL2d;//*theL2d;
Handle(Geom2d_BSplineCurve)
aBC = Handle(Geom2d_BSplineCurve)::DownCast(aC2d);
if (aBC.IsNull()) {
-#ifdef DEBUG
+#ifdef OCCT_DEBUG
cout << "Untreated curve type in TranslatePCurve" << endl;
#endif
return aC2d;
}
*/
else if (theVector.IsParallel(VectIsoVF, aTol)) {
-//#ifdef DEBUG
-// cout << "other curve-VClosed Surface. TranslatePC not impl." << endl;
-//#endif
if (Abs(FirstPoint.Y() - vf) < Abs(FirstPoint.Y() - vl)) T.SetTranslation(p00, p01);
else T.SetTranslation(p01, p00);
newC->Transform(T);
return aC2d;
}
-//=======================================================================
-//static : Range3d
-//purpose : contournement du Range de BRep_Builder pour ne pas affecter
-// les ranges des pcurves.
-//=======================================================================
-
-static void Range3d (const TopoDS_Edge& E,
- const Standard_Real First, const Standard_Real Last,
- const Standard_Real myPrecision)
-{
- // set the range to all the representations
- const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
-
- BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
- BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
- Handle(BRep_GCurve) GC;
-
- while (itcr.More()) {
- GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
- if (!GC.IsNull()) {
- if (GC->IsCurve3D()) {
- GC->SetRange(First,Last);
- // Set the closedness flag to the correct value.
- Handle(Geom_Curve) C = GC->Curve3D();
- if ( !C.IsNull() ) {
- Standard_Boolean closed = C->Value(First).IsEqual(C->Value(Last),myPrecision);
- TE->Closed(closed);
- }
- }
- }
- itcr.Next();
- }
-
- TE->Modified(Standard_True);
-}
//=======================================================================
//function : SameRange (Temp)
//purpose :
Standard_Real preci = ( prec >0. ? prec : BRep_Tool::Tolerance(edge) );
Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge, /*Loc,*/ First, Last);
// Handle(Geom_Curve) c3d = BRep_Tool::Curve(E, First, Last);
- if (c3d.IsNull() || (Abs(Last-First) <Precision::PConfusion())) {
+ if (c3d.IsNull()) {
myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL1);
return Standard_False;
}
// step = 2;
- // adding by skl 28.03.2003 for usung Line instead of BSpline
- Standard_Real fp=0.,lp=0.;
- Standard_Boolean isLine=Standard_False;
- if(c2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) {
- Handle(Geom2d_TrimmedCurve) tc = Handle(Geom2d_TrimmedCurve)::DownCast(c2d);
- if(tc->BasisCurve()->IsKind(STANDARD_TYPE(Geom2d_Line))) {
- fp = tc->FirstParameter();
- lp = tc->LastParameter();
- isLine = Standard_True;
- }
- }
-
if (isSeam) {
// On ne sait pas laquelle est Forward. Au PIF. La geometrie Forward
// sera mise a jour dans ComputeWire
B.UpdateEdge (edge,c2d,surf,location, 0.); //#82 rln 16.03.99: preci
}
- if ( isLine ) {
- B.Range(edge,surf,location,fp,lp);
- B.SameParameter(edge,Standard_False);
- B.SameRange(edge,Standard_False);
- }
-
// Conclusion
// step = 3;
if ( myProjector->Status ( ShapeExtend_DONE3 ) ) {
Standard_Real G3dCFirst = c3d->FirstParameter();
Standard_Real G3dCLast = c3d->LastParameter();
B.UpdateEdge(edge, c3d, 0.);
- Range3d(edge, G3dCFirst, G3dCLast, 0.);
+ B.Range(edge, G3dCFirst, G3dCLast, Standard_True);
}
} // end try
catch(Standard_Failure) {
myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
-#ifdef DEB //:s5
+#ifdef OCCT_DEBUG //:s5
cout << "Warning: ShapeFix_Edge::FixAddPCurve(): Exception: ";
Standard_Failure::Caught()->Print(cout); cout << endl;
#endif
const TopoDS_Face& face)
{
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
+ TopoDS_Edge anEdgeCopy = edge;
ShapeAnalysis_Edge sae;
+ if (!Context().IsNull())
+ {
+ anEdgeCopy = TopoDS::Edge(Context()->Apply(edge));
+ }
+
Standard_Real toler1, toler2;
- if (!sae.CheckVertexTolerance (edge, face, toler1, toler2)) return Standard_False;
+ if (!sae.CheckVertexTolerance (anEdgeCopy, face, toler1, toler2)) return Standard_False;
if (sae.Status (ShapeExtend_DONE1))
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
if (sae.Status (ShapeExtend_DONE2))
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
BRep_Builder B;
- TopoDS_Vertex V1 = sae.FirstVertex(edge);
- TopoDS_Vertex V2 = sae.LastVertex(edge);
- B.UpdateVertex (V1, toler1);
- B.UpdateVertex (V2, toler2);
+ TopoDS_Vertex V1 = sae.FirstVertex(anEdgeCopy);
+ TopoDS_Vertex V2 = sae.LastVertex(anEdgeCopy);
+ if (! Context().IsNull())
+ {
+ Context()->CopyVertex(V1,toler1);
+ Context()->CopyVertex(V2,toler2);
+ }
+ else
+ {
+ B.UpdateVertex (V1, toler1);
+ B.UpdateVertex (V2, toler2);
+ }
return Standard_True;
}
Standard_Boolean ShapeFix_Edge::FixVertexTolerance(const TopoDS_Edge& edge)
{
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
+ TopoDS_Edge anEdgeCopy = edge;
ShapeAnalysis_Edge sae;
+ if (!Context().IsNull())
+ {
+ anEdgeCopy = TopoDS::Edge(Context()->Apply(edge));
+ }
Standard_Real toler1, toler2;
- if (!sae.CheckVertexTolerance (edge, toler1, toler2)) return Standard_False;
+ if (!sae.CheckVertexTolerance (anEdgeCopy, toler1, toler2)) return Standard_False;
if (sae.Status (ShapeExtend_DONE1))
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
if (sae.Status (ShapeExtend_DONE2))
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
BRep_Builder B;
- TopoDS_Vertex V1 = sae.FirstVertex(edge);
- TopoDS_Vertex V2 = sae.LastVertex(edge);
- B.UpdateVertex (V1, toler1);
- B.UpdateVertex (V2, toler2);
+ TopoDS_Vertex V1 = sae.FirstVertex(anEdgeCopy);
+ TopoDS_Vertex V2 = sae.LastVertex(anEdgeCopy);
+ if (! Context().IsNull())
+ {
+ Context()->CopyVertex(V1,toler1);
+ Context()->CopyVertex(V2,toler2);
+ }
+ else
+ {
+ B.UpdateVertex (V1, toler1);
+ B.UpdateVertex (V2, toler2);
+ }
return Standard_True;
}
return Standard_True;
}
+//=======================================================================
+//function : FixSameParameter
+//purpose :
+//=======================================================================
+
+Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
+ const Standard_Real tolerance)
+{
+ TopoDS_Face anEmptyFace;
+ return FixSameParameter(edge, anEmptyFace, tolerance);
+}
//=======================================================================
//function : FixSameParameter
//=======================================================================
Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
- const Standard_Real tolerance)
+ const TopoDS_Face& face,
+ const Standard_Real tolerance)
{
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
- if ( BRep_Tool::Degenerated ( edge ) ) {
+ if ( BRep_Tool::Degenerated ( edge ) )
+ {
BRep_Builder B;
if ( ! BRep_Tool::SameRange (edge) )
TempSameRange ( edge, Precision::PConfusion() );
B.SameParameter ( edge, Standard_True );
return Standard_False;
}
+
ShapeFix_ShapeTolerance SFST;
ShapeAnalysis_Edge sae;
BRep_Builder B;
TopoDS_Edge copyedge;
TopoDS_Vertex V1 = sae.FirstVertex (edge);
TopoDS_Vertex V2 = sae.LastVertex (edge);
- Standard_Real TolFV = ( V1.IsNull() ? 0. : BRep_Tool::Tolerance ( V1 ) );
- Standard_Real TolLV = ( V2.IsNull() ? 0. : BRep_Tool::Tolerance ( V2 ) );
+ Standard_Real TolFV = ( V1.IsNull() ? 0.0 : BRep_Tool::Tolerance ( V1 ) );
+ Standard_Real TolLV = ( V2.IsNull() ? 0.0 : BRep_Tool::Tolerance ( V2 ) );
Standard_Real tol = BRep_Tool::Tolerance (edge);
Standard_Boolean wasSP = BRep_Tool::SameParameter ( edge ), SP = Standard_False;
{
- try {
+ try
+ {
OCC_CATCH_SIGNALS
- if ( ! BRep_Tool::SameRange (edge) )
- TempSameRange ( edge, Precision::PConfusion() );
+ if ( ! BRep_Tool::SameRange (edge) )
+ TempSameRange ( edge, Precision::PConfusion() );
//#81 rln 15.03.99 S4135: for not SP edge choose the best result (either BRepLib or deviation only)
- if ( ! wasSP ) {
- //create copyedge as copy of edge with the same vertices and copy of pcurves on the same surface(s)
- copyedge = ShapeBuild_Edge().Copy ( edge, Standard_False );
- B.SameParameter ( copyedge, Standard_False );
+ if ( ! wasSP )
+ {
+ //create copyedge as copy of edge with the same vertices and copy of pcurves on the same surface(s)
+ copyedge = ShapeBuild_Edge().Copy ( edge, Standard_False );
+ B.SameParameter ( copyedge, Standard_False );
// ShapeBuild_Edge::Copy() may change 3D curve range (if it's outside of its period).
// In this case pcurves in BRepLib::SameParameter() will be changed as well
// and later ShapeBuild_Edge::CopyPCurves() will copy pcurves keeping original range.
Standard_Real aF, aL;
BRep_Tool::Range (edge, aF, aL);
B.Range (copyedge, aF, aL, Standard_True); // only 3D
- BRepLib::SameParameter ( copyedge, ( tolerance >= Precision::Confusion() ?
- tolerance : tol ) );
- SP = BRep_Tool::SameParameter ( copyedge );
- if ( ! SP ) myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
+ BRepLib::SameParameter ( copyedge, ( tolerance >= Precision::Confusion() ? tolerance : tol ) );
+ SP = BRep_Tool::SameParameter ( copyedge );
+ if ( ! SP ) myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
}
}
- catch(Standard_Failure) {
-#ifdef DEB
+ catch(Standard_Failure)
+ {
+#ifdef OCCT_DEBUG
cout << "\nWarning: ShapeFix_Edge: Exception in SameParameter: ";
Standard_Failure::Caught()->Print(cout); cout << endl;
#endif
// compute deviation on the original pcurves
Standard_Real maxdev;
B.SameParameter ( edge, Standard_True );
- sae.CheckSameParameter ( edge, maxdev );
+
+ // Should check all pcurves in case of non-sameparametrization input.
+ TopoDS_Face aFace = face;
+ if (!wasSP)
+ {
+ TopoDS_Face anEmptyFace;
+ aFace = anEmptyFace;
+ }
+
+ sae.CheckSameParameter ( edge, aFace, maxdev );
if ( sae.Status ( ShapeExtend_FAIL2 ) )
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
// if BRepLib was OK, compare and select the best variant
- if ( SP ) {
+ if ( SP )
+ {
Standard_Real BRLTol = BRep_Tool::Tolerance ( copyedge ), BRLDev;
sae.CheckSameParameter ( copyedge, BRLDev );
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 );
if ( BRLTol < BRLDev ) BRLTol = BRLDev;
//chose the best result
- if ( BRLTol < maxdev ) {
+ if ( BRLTol < maxdev )
+ {
if ( sae.Status ( ShapeExtend_FAIL2 ) )
- myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
+ myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
//copy pcurves and tolerances from copyedge
ShapeBuild_Edge().CopyPCurves ( edge, copyedge );
maxdev = BRLTol;
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE5 );
}
}
+
//restore tolerances because they could be modified by BRepLib
if ( ! V1.IsNull() ) SFST.SetTolerance ( V1, Max (maxdev, TolFV), TopAbs_VERTEX);
if ( ! V2.IsNull() ) SFST.SetTolerance ( V2, Max (maxdev, TolLV), TopAbs_VERTEX);
- if ( maxdev > tol ) {
+ if ( maxdev > tol )
+ {
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
B.UpdateEdge ( edge, maxdev );
FixVertexTolerance(edge);
{
return ShapeExtend::DecodeStatus (myStatus, status);
}
+
+//=======================================================================
+//function : Context
+//purpose :
+//=======================================================================
+
+inline Handle(ShapeBuild_ReShape) ShapeFix_Edge::Context() const
+{
+ return myContext;
+}
+
+//=======================================================================
+//function : SetContext
+//purpose :
+//=======================================================================
+
+void ShapeFix_Edge::SetContext (const Handle(ShapeBuild_ReShape)& context)
+{
+ myContext = context;
+}