mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0030876: Data Exchange - StepToTopoDS edge translation should be resistant to malformed parameter values
Corrected misprint in the method CheckPCurves of the class StepToTopoDS_TranslateEdgeLoop for case when higher bound of the range of pcurve on the edge greater then last parameter of the pcurve. Added check on the not periodic flag for pcurve when range pcurve on the edge is adjusted to parameters pcurve.
This commit is contained in:
parent
f9c58d7c4e
commit
a90dd15e6b
@ -105,7 +105,7 @@ static void RemovePCurves(const TopoDS_Wire& aWire, const TopoDS_Face& aFace)
|
||||
TopExp_Explorer EdgeExp(aWire, TopAbs_EDGE);
|
||||
while (EdgeExp.More()) {
|
||||
const TopoDS_Edge& myEdge = TopoDS::Edge(EdgeExp.Current());
|
||||
RemoveSinglePCurve(myEdge,aFace);
|
||||
RemoveSinglePCurve(myEdge, aFace);
|
||||
EdgeExp.Next();
|
||||
}
|
||||
}
|
||||
@ -117,14 +117,14 @@ static void RemovePCurves(const TopoDS_Wire& aWire, const TopoDS_Face& aFace)
|
||||
// ============================================================================
|
||||
|
||||
static void CheckPCurves (TopoDS_Wire& aWire, const TopoDS_Face& aFace,
|
||||
const Standard_Boolean isPlane,const Standard_Real preci )
|
||||
const Standard_Boolean isPlane, const Standard_Real preci)
|
||||
{
|
||||
if (isPlane) { RemovePCurves (aWire,aFace);return; }
|
||||
if (isPlane) { RemovePCurves (aWire, aFace);return; }
|
||||
BRep_Builder B;
|
||||
Standard_Real w1, w2, cf, cl;
|
||||
Handle(Geom_Surface) mySurf = BRep_Tool::Surface(aFace);
|
||||
|
||||
Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData ( aWire );
|
||||
Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData (aWire);
|
||||
for (Standard_Integer i = 1; i <= sbwd->NbEdges(); i++) {
|
||||
const TopoDS_Edge& myEdge = sbwd->Edge(i);
|
||||
|
||||
@ -135,42 +135,46 @@ static void CheckPCurves (TopoDS_Wire& aWire, const TopoDS_Face& aFace,
|
||||
|
||||
Handle(Geom2d_Curve) thePC;
|
||||
ShapeAnalysis_Edge sae;
|
||||
if (!sae.PCurve (myEdge, aFace, thePC, w1, w2, Standard_False )) {
|
||||
if (!sae.PCurve (myEdge, aFace, thePC, w1, w2, Standard_False)) {
|
||||
continue;
|
||||
}
|
||||
cf = thePC->FirstParameter();
|
||||
cl = thePC->LastParameter();
|
||||
|
||||
if (w1 == w2) {
|
||||
RemoveSinglePCurve(myEdge,aFace);
|
||||
RemoveSinglePCurve(myEdge, aFace);
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cout<<"Removing pcuve w1=w2"<<std::endl;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (w1 < cf) {
|
||||
B.Range(myEdge, aFace, cf, w2);
|
||||
w1 = cf;
|
||||
}
|
||||
if (w2 > cl) {
|
||||
B.Range(myEdge, aFace, w1, cl);
|
||||
w2 = cf;
|
||||
//check parameters of range only for not periodic curves
|
||||
if (!thePC->IsPeriodic())
|
||||
{
|
||||
if (w1 < cf) {
|
||||
B.Range(myEdge, aFace, cf, w2);
|
||||
w1 = cf;
|
||||
}
|
||||
if (w2 > cl) {
|
||||
B.Range(myEdge, aFace, w1, cl);
|
||||
w2 = cl;
|
||||
}
|
||||
}
|
||||
|
||||
if (w1 > w2 && mySurf->IsUPeriodic())
|
||||
{
|
||||
Standard_Real u1,u2,v1,v2;
|
||||
mySurf->Bounds(u1,u2,v1,v2);
|
||||
Standard_Real u1, u2, v1, v2;
|
||||
mySurf->Bounds(u1, u2, v1, v2);
|
||||
ElCLib::AdjustPeriodic(u1, u2,
|
||||
Min(Abs(w2-w1)/2,Precision::PConfusion()),
|
||||
Min(Abs(w2-w1)/2, Precision::PConfusion()),
|
||||
w1, w2);
|
||||
B.Range(myEdge, aFace, w1, w2);
|
||||
}
|
||||
|
||||
|
||||
// advanced check
|
||||
XSAlgo::AlgoContainer()->CheckPCurve (myEdge, aFace, preci, sbwd->IsSeam(i) );
|
||||
XSAlgo::AlgoContainer()->CheckPCurve (myEdge, aFace, preci, sbwd->IsSeam(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,12 +194,12 @@ StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop()
|
||||
// ============================================================================
|
||||
|
||||
StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop(const Handle(StepShape_FaceBound)& FB,
|
||||
const TopoDS_Face& Face,
|
||||
const Handle(Geom_Surface)& GeomSurf,
|
||||
const Handle(StepGeom_Surface)& StepSurf,
|
||||
const Standard_Boolean sameSense,
|
||||
StepToTopoDS_Tool& T,
|
||||
StepToTopoDS_NMTool& NMTool) {
|
||||
const TopoDS_Face& Face,
|
||||
const Handle(Geom_Surface)& GeomSurf,
|
||||
const Handle(StepGeom_Surface)& StepSurf,
|
||||
const Standard_Boolean sameSense,
|
||||
StepToTopoDS_Tool& T,
|
||||
StepToTopoDS_NMTool& NMTool) {
|
||||
Init(FB, Face, GeomSurf, StepSurf, sameSense, T, NMTool);
|
||||
}
|
||||
|
||||
@ -205,12 +209,12 @@ StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop(const Handle(Step
|
||||
// ============================================================================
|
||||
|
||||
void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& FaceBound,
|
||||
const TopoDS_Face& Face,
|
||||
const Handle(Geom_Surface)& GeomSurf,
|
||||
const Handle(StepGeom_Surface)& StepSurf,
|
||||
const Standard_Boolean sameSense,
|
||||
StepToTopoDS_Tool& aTool,
|
||||
StepToTopoDS_NMTool& NMTool) {
|
||||
const TopoDS_Face& Face,
|
||||
const Handle(Geom_Surface)& GeomSurf,
|
||||
const Handle(StepGeom_Surface)& StepSurf,
|
||||
const Standard_Boolean sameSense,
|
||||
StepToTopoDS_Tool& aTool,
|
||||
StepToTopoDS_NMTool& NMTool) {
|
||||
done = Standard_True;
|
||||
Handle(StepShape_EdgeLoop) EL =
|
||||
Handle(StepShape_EdgeLoop)::DownCast(FaceBound->Bound());
|
||||
@ -222,7 +226,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
return;
|
||||
}
|
||||
Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode");
|
||||
// 0,1 : suivre le code, 2 : ne prendre que pcurve, 3 : ne prendre que C3D
|
||||
// 0,1 : suivre le code, 2 : ne prendre que pcurve, 3 : ne prendre que C3D
|
||||
|
||||
BRep_Builder B;
|
||||
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
|
||||
@ -243,13 +247,13 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
TopoDS_Edge suspectE; //:f1, degEdge;
|
||||
|
||||
Standard_Integer j, NbEdge = EL->NbEdgeList();
|
||||
if( NbEdge == 0) {
|
||||
TP->AddWarning(EL,"Wire not done. EdgeLoop does not contain edges.");
|
||||
if (NbEdge == 0) {
|
||||
TP->AddWarning(EL, "Wire not done. EdgeLoop does not contain edges.");
|
||||
done = Standard_False;
|
||||
return;
|
||||
}
|
||||
// PTV 16.09.2000
|
||||
// default value set as Standard_True (if not correct see logic of algorithm).
|
||||
// PTV 16.09.2000
|
||||
// default value set as Standard_True (if not correct see logic of algorithm).
|
||||
Standard_Boolean hasPcurve = Standard_True;
|
||||
Standard_Boolean isPlane = GeomSurf->IsKind(STANDARD_TYPE(Geom_Plane));
|
||||
Handle(Geom_Surface) ConvSurf = GeomSurf;
|
||||
@ -278,14 +282,14 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
// -----------------------------------------------
|
||||
// Standard_Integer theSame = 1; //gka 15.12.98
|
||||
|
||||
for (j=1; j<=NbEdge; j++ ) {
|
||||
for (j=1; j<=NbEdge; j++) {
|
||||
OrEdge1 = EL->EdgeListValue(j);
|
||||
StepEdge = OrEdge1->EdgeElement();
|
||||
// if(j>1 && StepEdge == StepEdge1) theSame++; //gka 15.12.98
|
||||
// if(j>1 && StepEdge == StepEdge1) theSame++; //gka 15.12.98
|
||||
StepEdge1 = StepEdge; //
|
||||
Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(StepEdge);
|
||||
Handle(StepGeom_Curve) C = EC->EdgeGeometry();
|
||||
if (!C.IsNull()){
|
||||
if (!C.IsNull()) {
|
||||
if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve))) {
|
||||
Handle(StepGeom_SurfaceCurve) Sc = Handle(StepGeom_SurfaceCurve)::DownCast(C);
|
||||
C = Sc->Curve3d();
|
||||
@ -296,13 +300,13 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
C1 = Handle(Geom_Curve)::DownCast (TP->FindTransient(C));
|
||||
C1 = Handle(Geom_Curve)::DownCast (TP->FindTransient(C));
|
||||
if (C1.IsNull()) {
|
||||
C1 = StepToGeom::MakeCurve (C);
|
||||
if (! C1.IsNull())
|
||||
TP->BindTransient (C,C1);
|
||||
TP->BindTransient (C, C1);
|
||||
else
|
||||
TP->AddWarning(C,"Could not convert a curve. Curve definition is incorrect");
|
||||
TP->AddWarning(C, "Could not convert a curve. Curve definition is incorrect");
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure const& anException) {
|
||||
@ -311,7 +315,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
anException.Print(std::cout); std::cout << std::endl;
|
||||
#endif
|
||||
(void)anException;
|
||||
TP->AddFail(C,"Exeption was raised. Curve geometry definition is incorrect");
|
||||
TP->AddFail(C, "Exeption was raised. Curve geometry definition is incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,14 +342,14 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
V2 = TopoDS::Vertex(myTranVertex2.Value());
|
||||
gp_Pnt p1 = BRep_Tool::Pnt(V1);
|
||||
gp_Pnt p2 = BRep_Tool::Pnt(V2);
|
||||
if (p1.Distance(p2) <= Precision::Confusion() ) { //:S4136: preci) {
|
||||
Standard_Boolean Fixed = Standard_True;
|
||||
if(!iseV) aTool.Bind(Vend,V1); //gka 21.08.1998 bug PRO7656
|
||||
else if(!istV) aTool.Bind (Vstart,V2);
|
||||
else aTool.Bind (Vend,V1);
|
||||
if (!C1.IsNull() && !C1->IsClosed() && Fixed)
|
||||
TP->AddWarning(EL->EdgeListValue(j),
|
||||
"Vertex of same coordinates, set confused");
|
||||
if (p1.Distance(p2) <= Precision::Confusion()) { //:S4136: preci) {
|
||||
Standard_Boolean Fixed = Standard_True;
|
||||
if (!iseV) aTool.Bind(Vend, V1); //gka 21.08.1998 bug PRO7656
|
||||
else if (!istV) aTool.Bind (Vstart, V2);
|
||||
else aTool.Bind (Vend, V1);
|
||||
if (!C1.IsNull() && !C1->IsClosed() && Fixed)
|
||||
TP->AddWarning(EL->EdgeListValue(j),
|
||||
"Vertex of same coordinates, set confused");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -355,52 +359,52 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
// and make it be one vertex
|
||||
// NOTE: this is done only for the case if at least one of edges
|
||||
// was not yet translated; else nothing will help
|
||||
for (j=1; j<=NbEdge; j++ ) {
|
||||
OrEdge1 = EL->EdgeListValue ( j );
|
||||
OrEdge2 = EL->EdgeListValue ( j < NbEdge ? j + 1 : 1 );
|
||||
for (j=1; j<=NbEdge; j++) {
|
||||
OrEdge1 = EL->EdgeListValue (j);
|
||||
OrEdge2 = EL->EdgeListValue (j < NbEdge ? j + 1 : 1);
|
||||
Handle(StepShape_EdgeCurve) EC1 =
|
||||
Handle(StepShape_EdgeCurve)::DownCast ( OrEdge1->EdgeElement() );
|
||||
Handle(StepShape_EdgeCurve)::DownCast (OrEdge1->EdgeElement());
|
||||
Handle(StepShape_EdgeCurve) EC2 =
|
||||
Handle(StepShape_EdgeCurve)::DownCast ( OrEdge2->EdgeElement() );
|
||||
Handle(StepShape_EdgeCurve)::DownCast (OrEdge2->EdgeElement());
|
||||
|
||||
Handle(StepShape_Vertex) Vs1, Vs2,Vs11,Vs22;
|
||||
Vs1 = ( OrEdge1->Orientation() ? EC1->EdgeEnd() : EC1->EdgeStart() );
|
||||
Vs2 = ( OrEdge2->Orientation() ? EC2->EdgeStart() : EC2->EdgeEnd() );
|
||||
Handle(StepShape_Vertex) Vs1, Vs2, Vs11, Vs22;
|
||||
Vs1 = (OrEdge1->Orientation() ? EC1->EdgeEnd() : EC1->EdgeStart());
|
||||
Vs2 = (OrEdge2->Orientation() ? EC2->EdgeStart() : EC2->EdgeEnd());
|
||||
|
||||
Vs11 = ( OrEdge1->Orientation() ? EC1->EdgeStart() : EC1->EdgeEnd());
|
||||
Vs22 = ( OrEdge2->Orientation() ? EC2->EdgeEnd() : EC2->EdgeStart() );
|
||||
Vs11 = (OrEdge1->Orientation() ? EC1->EdgeStart() : EC1->EdgeEnd());
|
||||
Vs22 = (OrEdge2->Orientation() ? EC2->EdgeEnd() : EC2->EdgeStart());
|
||||
|
||||
if((Vs1 == Vs2) || (Vs1 == Vs22) || (Vs2 == Vs11) || (Vs22 == Vs11)) continue;
|
||||
if ((Vs1 == Vs2) || (Vs1 == Vs22) || (Vs2 == Vs11) || (Vs22 == Vs11)) continue;
|
||||
|
||||
StepToTopoDS_TranslateVertex myTranVertex1 (Vs1, aTool, NMTool);
|
||||
StepToTopoDS_TranslateVertex myTranVertex2 (Vs2, aTool, NMTool);
|
||||
|
||||
TopoDS_Vertex V1, V2;
|
||||
if ( myTranVertex1.IsDone() )
|
||||
V1 = TopoDS::Vertex ( myTranVertex1.Value() );
|
||||
if ( myTranVertex2.IsDone() )
|
||||
V2 = TopoDS::Vertex ( myTranVertex2.Value() );
|
||||
if ( V1.IsNull() || V2.IsNull() ) continue; // not treated
|
||||
if ( V1.IsSame(V2) ) continue; // OK
|
||||
if (myTranVertex1.IsDone())
|
||||
V1 = TopoDS::Vertex (myTranVertex1.Value());
|
||||
if (myTranVertex2.IsDone())
|
||||
V2 = TopoDS::Vertex (myTranVertex2.Value());
|
||||
if (V1.IsNull() || V2.IsNull()) continue; // not treated
|
||||
if (V1.IsSame(V2)) continue; // OK
|
||||
|
||||
gp_Pnt p1 = BRep_Tool::Pnt(V1);
|
||||
gp_Pnt p2 = BRep_Tool::Pnt(V2);
|
||||
Standard_Boolean locFixed = Standard_True;
|
||||
if (p1.Distance(p2) <= preci) {
|
||||
if ( ! aTool.IsBound ( EC1 ) ) aTool.Bind ( Vs1, V2 );
|
||||
else if ( ! aTool.IsBound ( EC2 ) ) aTool.Bind ( Vs2, V1 );
|
||||
if (! aTool.IsBound (EC1)) aTool.Bind (Vs1, V2);
|
||||
else if (! aTool.IsBound (EC2)) aTool.Bind (Vs2, V1);
|
||||
else locFixed = Standard_False;
|
||||
}
|
||||
else locFixed = Standard_False;
|
||||
if ( locFixed ) TP->AddWarning(EL,"Adjacent edges do not have common vertex; set confused");
|
||||
else TP->AddWarning(EL,"Adjacent edges are not connected");
|
||||
if (locFixed) TP->AddWarning(EL, "Adjacent edges do not have common vertex; set confused");
|
||||
else TP->AddWarning(EL, "Adjacent edges are not connected");
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
// Iteration on each Oriented Edge of the EdgeLoop
|
||||
// -----------------------------------------------
|
||||
|
||||
for (j=1; j<=NbEdge; j++ ) {
|
||||
for (j=1; j<=NbEdge; j++) {
|
||||
|
||||
Standard_Boolean ThereIsLikeSeam = Standard_False;
|
||||
|
||||
@ -430,9 +434,9 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
Handle(StepGeom_Curve) C = EC->EdgeGeometry();
|
||||
|
||||
if (OrEdge1->Orientation() && EC->SameSense())
|
||||
E.Orientation(TopAbs_FORWARD);
|
||||
E.Orientation(TopAbs_FORWARD);
|
||||
else if (!OrEdge1->Orientation() && !EC->SameSense())
|
||||
E.Orientation(TopAbs_FORWARD);
|
||||
E.Orientation(TopAbs_FORWARD);
|
||||
else E.Orientation(TopAbs_REVERSED);
|
||||
|
||||
isSeam = isLikeSeam = Standard_False;
|
||||
@ -630,19 +634,19 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
}
|
||||
}
|
||||
else { // The Edge is Not mapped => switch to next wire ?
|
||||
TP->AddFail(StepEdge," an Edge not mapped");
|
||||
TP->AddFail(StepEdge, " an Edge not mapped");
|
||||
done = Standard_False;
|
||||
myError = StepToTopoDS_TranslateEdgeLoopOther;
|
||||
}
|
||||
|
||||
if (done) B.Add (W,E); // on le fait ici. Sauf si erreur rencontree ... !
|
||||
if (done) B.Add (W, E); // on le fait ici. Sauf si erreur rencontree ... !
|
||||
else {
|
||||
Handle(StepShape_Vertex) Vs1, Vs2;
|
||||
Vs1 = StepEdge->EdgeStart();
|
||||
Vs2 = StepEdge->EdgeEnd();
|
||||
if(!Vs1.IsNull() && !Vs2.IsNull() && Vs1==Vs2) {
|
||||
if (!Vs1.IsNull() && !Vs2.IsNull() && Vs1==Vs2) {
|
||||
done = Standard_True;
|
||||
TP->AddFail(EL," Edge with equal vertices failed, scipped");
|
||||
TP->AddFail(EL, " Edge with equal vertices failed, scipped");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -650,7 +654,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
// The EdgeLoop is binded in the Wire
|
||||
|
||||
if (!done) {
|
||||
TP->AddFail(EL,"At least one edge failed : wire not done");
|
||||
TP->AddFail(EL, "At least one edge failed : wire not done");
|
||||
return;
|
||||
}
|
||||
W.Closed (BRep_Tool::IsClosed (W));
|
||||
@ -661,7 +665,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
// ----------------------------------------------
|
||||
//pdn compute parameter of Vertices using projecting
|
||||
if (!aTool.ComputePCurve())
|
||||
for (TopoDS_Iterator EdgeIt(W);EdgeIt.More();EdgeIt.Next()){
|
||||
for (TopoDS_Iterator EdgeIt(W);EdgeIt.More();EdgeIt.Next()) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(EdgeIt.Value());
|
||||
Handle(ShapeFix_EdgeProjAux) myEdgePro = ShapeAlgo::AlgoContainer()->ToolContainer()->EdgeProjAux();
|
||||
myEdgePro->Init (Face, edge);
|
||||
@ -669,7 +673,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
if (myEdgePro->IsFirstDone() && myEdgePro->IsLastDone()) {
|
||||
if (Abs (myEdgePro->FirstParam() - myEdgePro->LastParam()) < Precision::PConfusion())
|
||||
continue;
|
||||
B.Range(edge, Face,myEdgePro->FirstParam(), myEdgePro->LastParam());
|
||||
B.Range(edge, Face, myEdgePro->FirstParam(), myEdgePro->LastParam());
|
||||
}
|
||||
else {
|
||||
RemoveSinglePCurve(edge, Face);
|
||||
@ -683,7 +687,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
|
||||
myError = StepToTopoDS_TranslateEdgeLoopDone;
|
||||
done = Standard_True;
|
||||
// Check des PCurves SYSTEMATIQUE, s il n y en a que quelques unes
|
||||
CheckPCurves (W, Face,isPlane,preci);
|
||||
CheckPCurves (W, Face, isPlane, preci);
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user