1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0026570: Crash on attempt to rotate a shape.

An extended draw-command trotate (ttranslate, tmirror, ...) by an additional parameter "-copy".
New check of edge range is added in BRepCheck/BRepCheck_Edge.cxx
The same checking is added in ShapeAnalysis_Edge.cxx
Fixing this problem is added in ShapeFix_Wire.cxx
GeomLib::SameRange(...) and BRepTools_TrsfModification::NewCurve2d(...) are modified to avoid exception in TrimmedCurve
This commit is contained in:
vro
2015-08-19 10:25:11 +03:00
committed by bugmaster
parent 472433e2c7
commit 4e882c7153
13 changed files with 264 additions and 25 deletions

View File

@@ -42,6 +42,7 @@
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
@@ -171,6 +172,7 @@ void BRepCheck_Edge::Minimum()
if (!myCref.IsNull()) {
Handle(BRep_GCurve) GCref (Handle(BRep_GCurve)::DownCast (myCref));
Standard_Real eps = Precision::PConfusion();
Standard_Real First,Last;
GCref->Range(First,Last);
if (Last<=First) {
@@ -186,20 +188,82 @@ void BRepCheck_Edge::Minimum()
Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
(myCref->Curve3D()->Transformed
(/*myCref->Location()*/L.Transformation()));
GeomAdaptor_Curve GAC3d(C3d, C3d->TransformedParameter(First, L.Transformation()),
Standard_Boolean IsPeriodic = C3d->IsPeriodic();
Standard_Real aPeriod = RealLast();
if(IsPeriodic)
{
aPeriod = C3d->Period();
}
Standard_Real f = C3d->FirstParameter(), l = C3d->LastParameter();
if (C3d->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve))
{
const Handle(Geom_Curve)& aC = Handle(Geom_TrimmedCurve)::DownCast (C3d)->BasisCurve();
f = aC->FirstParameter();
l = aC->LastParameter();
IsPeriodic = aC->IsPeriodic();
if(IsPeriodic)
{
aPeriod = aC->Period();
}
}
if(IsPeriodic && (Last - First > aPeriod + eps))
{
myCref.Nullify();
BRepCheck::Add(lst,BRepCheck_InvalidRange);
}
else if(!IsPeriodic && (First < f - eps || Last > l + eps))
{
myCref.Nullify();
BRepCheck::Add(lst,BRepCheck_InvalidRange);
}
else
{
GeomAdaptor_Curve GAC3d(C3d, C3d->TransformedParameter(First, L.Transformation()),
C3d->TransformedParameter(Last, L.Transformation()));
myHCurve = new GeomAdaptor_HCurve(GAC3d);
myHCurve = new GeomAdaptor_HCurve(GAC3d);
}
}
else { // curve on surface
Handle(Geom_Surface) Sref = myCref->Surface();
Sref = Handle(Geom_Surface)::DownCast
(Sref->Transformed(myCref->Location().Transformation()));
const Handle(Geom2d_Curve)& PCref = myCref->PCurve();
Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
Handle(Geom2dAdaptor_HCurve) GHPCref =
new Geom2dAdaptor_HCurve(PCref,First,Last);
Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
myHCurve = new Adaptor3d_HCurveOnSurface(ACSref);
Standard_Boolean IsPeriodic = PCref->IsPeriodic();
Standard_Real aPeriod = RealLast();
if(IsPeriodic)
{
aPeriod = PCref->Period();
}
Standard_Real f = PCref->FirstParameter(), l = PCref->LastParameter();
if (PCref->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
const Handle(Geom2d_Curve)& aC = Handle(Geom2d_TrimmedCurve)::DownCast (PCref)->BasisCurve();
f = aC->FirstParameter();
l = aC->LastParameter();
IsPeriodic = aC->IsPeriodic();
if(IsPeriodic)
{
aPeriod = aC->Period();
}
}
if(IsPeriodic && (Last - First > aPeriod + eps))
{
myCref.Nullify();
BRepCheck::Add(lst,BRepCheck_InvalidRange);
}
else if(!IsPeriodic && (First < f - eps || Last > l + eps))
{
myCref.Nullify();
BRepCheck::Add(lst,BRepCheck_InvalidRange);
}
else
{
Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
Handle(Geom2dAdaptor_HCurve) GHPCref =
new Geom2dAdaptor_HCurve(PCref,First,Last);
Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
myHCurve = new Adaptor3d_HCurveOnSurface(ACSref);
}
}
}
}
@@ -276,6 +340,7 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
Standard_Boolean pcurvefound = Standard_False;
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
Standard_Real eps = Precision::PConfusion();
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr != myCref && cr->IsCurveOnSurface(Su,L)) {
@@ -291,12 +356,43 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
}
// gka OCC
// Modified by skv - Tue Apr 27 11:50:35 2004 Begin
if (Abs(ff-First) > Precision::PConfusion() ||
Abs(ll-Last) > Precision::PConfusion()) {
if (Abs(ff-First) > eps ||
Abs(ll-Last) > eps) {
BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
}
// Modified by skv - Tue Apr 27 11:50:37 2004 End
//
const Handle(Geom2d_Curve)& pc = cr->PCurve();
Standard_Boolean IsPeriodic = pc->IsPeriodic();
Standard_Real aPeriod = RealLast();
if(IsPeriodic)
{
aPeriod = pc->Period();
}
Standard_Real fp = pc->FirstParameter(), lp = pc->LastParameter();
if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
const Handle(Geom2d_Curve)& aC = Handle(Geom2d_TrimmedCurve)::DownCast (pc)->BasisCurve();
fp = aC->FirstParameter();
lp = aC->LastParameter();
IsPeriodic = aC->IsPeriodic();
if(IsPeriodic)
{
aPeriod = aC->Period();
}
}
if(IsPeriodic && (l - f > aPeriod + eps))
{
BRepCheck::Add(lst,BRepCheck_InvalidRange);
return;
}
else if(!IsPeriodic && (f < fp - eps || l > lp + eps))
{
BRepCheck::Add(lst,BRepCheck_InvalidRange);
return;
}
if (myGctrl) {
Handle(Geom_Surface) Sb = cr->Surface();
Sb = Handle(Geom_Surface)::DownCast