1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-16 10:54:53 +03:00

0025028: BRepAlgo::ConcatenateWire raises an exception

Test case for issue CR25028
This commit is contained in:
ifv 2014-07-17 11:26:23 +04:00 committed by bugmaster
parent 347423b2c2
commit 0272e74033
2 changed files with 234 additions and 263 deletions

View File

@ -56,107 +56,107 @@
//======================================================================= //=======================================================================
TopoDS_Wire BRepAlgo::ConcatenateWire(const TopoDS_Wire& W, TopoDS_Wire BRepAlgo::ConcatenateWire(const TopoDS_Wire& W,
const GeomAbs_Shape Option, const GeomAbs_Shape Option,
const Standard_Real TolAngular) const Standard_Real TolAngular)
{ {
Standard_Integer nb_curve, //number of curves in the Wire Standard_Integer nb_curve, //number of curves in the Wire
index; index;
BRepTools_WireExplorer WExp(W) ; BRepTools_WireExplorer WExp(W) ;
TopoDS_Edge edge; TopoDS_Edge edge;
TopLoc_Location L ; TopLoc_Location L ;
Standard_Real First=0.,Last=0., //extremal values for the curve Standard_Real First=0.,Last=0., //extremal values for the curve
First0 =0., First0 = 0.,
toler =0., toler = 0.,
tolleft,tolright; //Vertex tolerances tolleft,tolright; //Vertex tolerances
TopoDS_Vertex Vfirst,Vlast; //Vertex of the Wire TopoDS_Vertex Vfirst,Vlast; //Vertex of the Wire
gp_Pnt Pfirst,Plast; //, Pint; corresponding points gp_Pnt Pfirst,Plast; //, Pint; corresponding points
BRepLib_MakeWire MakeResult; BRepLib_MakeWire MakeResult;
Standard_Real closed_tolerance =0.0; Standard_Real closed_tolerance =0.0;
Standard_Boolean closed_flag = Standard_False ; Standard_Boolean closed_flag = Standard_False ;
nb_curve = 0; nb_curve = 0;
while ( WExp.More()){ //computation of the curve number while ( WExp.More()){ //computation of the curve number
nb_curve++ ; nb_curve++ ;
WExp.Next(); WExp.Next();
} }
if (nb_curve > 1) { if (nb_curve > 1) {
TColGeom_Array1OfBSplineCurve tab(0,nb_curve-1); //array of the wire's curve TColGeom_Array1OfBSplineCurve tab(0,nb_curve-1); //array of the wire's curve
TColStd_Array1OfReal tabtolvertex(0,nb_curve-2); //array of the tolerance's vertex TColStd_Array1OfReal tabtolvertex(0,nb_curve-2); //array of the tolerance's vertex
WExp.Init(W); WExp.Init(W);
for (index=0 ;index<nb_curve; index++){ //main loop for (index=0 ;index<nb_curve; index++){ //main loop
edge = WExp.Current() ; edge = WExp.Current() ;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(edge, L, First, Last); const Handle(Geom_Curve)& aCurve = BRep_Tool::Curve(edge, L, First, Last);
Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, First, Last); Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, First, Last);
tab(index) = GeomConvert::CurveToBSplineCurve(aTrCurve); //storage in a array tab(index) = GeomConvert::CurveToBSplineCurve(aTrCurve); //storage in a array
tab(index)->Transform(L.Transformation()); tab(index)->Transform(L.Transformation());
GeomConvert::C0BSplineToC1BSplineCurve(tab(index),Precision::Confusion()); GeomConvert::C0BSplineToC1BSplineCurve(tab(index),Precision::Confusion());
if (index >= 1){ //continuity test loop if (index >= 1){ //continuity test loop
if (edge.Orientation()==TopAbs_REVERSED) if (edge.Orientation()==TopAbs_REVERSED)
tab(index)->Reverse(); tab(index)->Reverse();
tolleft=BRep_Tool::Tolerance(TopExp::LastVertex(edge)); tolleft=BRep_Tool::Tolerance(TopExp::LastVertex(edge));
tolright=BRep_Tool::Tolerance(TopExp::FirstVertex(edge)); tolright=BRep_Tool::Tolerance(TopExp::FirstVertex(edge));
tabtolvertex(index-1)=Max(tolleft,tolright); tabtolvertex(index-1)=Max(tolleft,tolright);
} }
if(index==0){ //storage of the first edge features if(index==0){ //storage of the first edge features
First0=First; First0=First;
if(edge.Orientation()==TopAbs_REVERSED){ //(usefull for the closed wire) if(edge.Orientation()==TopAbs_REVERSED){ //(usefull for the closed wire)
Vfirst=TopExp::LastVertex(edge); Vfirst=TopExp::LastVertex(edge);
tab(index)->Reverse(); tab(index)->Reverse();
} }
else else
Vfirst=TopExp::FirstVertex(edge); Vfirst=TopExp::FirstVertex(edge);
} }
if(index==nb_curve-1){ //storage of the last edge features if(index==nb_curve-1){ //storage of the last edge features
if(edge.Orientation()==TopAbs_REVERSED) if(edge.Orientation()==TopAbs_REVERSED)
Vlast=TopExp::FirstVertex(edge); Vlast=TopExp::FirstVertex(edge);
else else
Vlast=TopExp::LastVertex(edge); Vlast=TopExp::LastVertex(edge);
} }
WExp.Next() ; WExp.Next() ;
} }
if (BRep_Tool::Tolerance(Vfirst)>BRep_Tool::Tolerance(Vlast)) //computation of the closing tolerance if (BRep_Tool::Tolerance(Vfirst)>BRep_Tool::Tolerance(Vlast)) //computation of the closing tolerance
toler=BRep_Tool::Tolerance(Vfirst); toler=BRep_Tool::Tolerance(Vfirst);
else else
toler=BRep_Tool::Tolerance(Vlast); toler=BRep_Tool::Tolerance(Vlast);
Pfirst=BRep_Tool::Pnt(Vfirst); Pfirst=BRep_Tool::Pnt(Vfirst);
Plast=BRep_Tool::Pnt(Vlast); Plast=BRep_Tool::Pnt(Vlast);
if ((Pfirst.Distance(Plast)<=toler)&& //C0 continuity test at the closing point if ((Pfirst.Distance(Plast)<=toler)&& //C0 continuity test at the closing point
(GeomLProp::Continuity(tab(nb_curve-1),tab(0),Last,First0, (GeomLProp::Continuity(tab(nb_curve-1),tab(0),Last,First0,
Standard_True,Standard_True, Standard_True,Standard_True,
toler, TolAngular)>=GeomAbs_G1)) toler, TolAngular)>=GeomAbs_G1))
{ {
closed_tolerance =toler; //if ClosedG1!=0 it will be True and closed_tolerance =toler; //if ClosedG1!=0 it will be True and
closed_flag = Standard_True ; closed_flag = Standard_True ;
} //with the toler value } //with the toler value
Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves
Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex
if (Option==GeomAbs_G1) if (Option==GeomAbs_G1)
GeomConvert::ConcatG1(tab, GeomConvert::ConcatG1(tab,
tabtolvertex, tabtolvertex,
concatcurve, concatcurve,
closed_flag, closed_flag,
closed_tolerance) ; //G1 concatenation closed_tolerance) ; //G1 concatenation
else else
GeomConvert::ConcatC1(tab, GeomConvert::ConcatC1(tab,
tabtolvertex, tabtolvertex,
ArrayOfIndices, ArrayOfIndices,
concatcurve, concatcurve,
closed_flag, closed_flag,
closed_tolerance); //C1 concatenation closed_tolerance); //C1 concatenation
for (index=0;index<=(concatcurve->Length()-1);index++){ //building of the resulting Wire for (index=0;index<=(concatcurve->Length()-1);index++){ //building of the resulting Wire
BRepLib_MakeEdge EdgeBuilder(concatcurve->Value(index)); BRepLib_MakeEdge EdgeBuilder(concatcurve->Value(index));
edge = EdgeBuilder.Edge(); edge = EdgeBuilder.Edge();
@ -165,63 +165,25 @@ TopoDS_Wire BRepAlgo::ConcatenateWire(const TopoDS_Wire& W,
} }
else { else {
TColGeom_Array1OfBSplineCurve tab(0,0); //array of the wire's curve
TColStd_Array1OfReal tabtolvertex(0,0); //array of the tolerance's vertex
WExp.Init(W); WExp.Init(W);
edge = WExp.Current() ; edge = WExp.Current() ;
tab(0) = GeomConvert::CurveToBSplineCurve(new //storage in a array const Handle(Geom_Curve)& aC = BRep_Tool::Curve(edge,L,First,Last);
Geom_TrimmedCurve(BRep_Tool::Curve(edge,L,First,Last),First,Last)); Handle(Geom_BSplineCurve) aBS = GeomConvert::CurveToBSplineCurve(new Geom_TrimmedCurve(aC,First,Last));
tab(0)->Transform(L.Transformation()); aBS->Transform(L.Transformation());
GeomConvert::C0BSplineToC1BSplineCurve(tab(0),Precision::Confusion()); GeomConvert::C0BSplineToC1BSplineCurve(aBS, Precision::Confusion());
if (edge.Orientation()==TopAbs_REVERSED) if (edge.Orientation()==TopAbs_REVERSED)
tab(0)->Reverse(); {
tolleft=BRep_Tool::Tolerance(TopExp::LastVertex(edge)); aBS->Reverse();
tolright=BRep_Tool::Tolerance(TopExp::FirstVertex(edge));
tabtolvertex(0)=Max(tolleft,tolright);
if(edge.Orientation()==TopAbs_REVERSED){ //(usefull for the closed wire)
Vfirst=TopExp::LastVertex(edge);
Vlast=TopExp::FirstVertex(edge);
} }
else {
BRepLib_MakeEdge EdgeBuilder(aBS);
Vfirst=TopExp::FirstVertex(edge); edge = EdgeBuilder.Edge();
Vlast = TopExp::LastVertex(edge) ; MakeResult.Add(edge);
}
Pfirst=BRep_Tool::Pnt(Vfirst);
Plast=BRep_Tool::Pnt(Vlast);
if ((Pfirst.Distance(Plast)<=toler)&& //C0 continuity test at the closing point
(GeomLProp::Continuity(tab(0),tab(0),Last,First,
Standard_True,Standard_True,
toler, TolAngular)>=GeomAbs_G1))
{
closed_tolerance =toler; //if ClosedG1!=0 it will be True and
closed_flag = Standard_True ;
} //with the toler value
Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves
Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex
if (Option==GeomAbs_G1)
GeomConvert::ConcatG1(tab,
tabtolvertex,
concatcurve,
closed_flag,
closed_tolerance) ; //G1 concatenation
else
GeomConvert::ConcatC1(tab,
tabtolvertex,
ArrayOfIndices,
concatcurve,
closed_flag,
closed_tolerance); //C1 concatenation
for (index=0;index<=(concatcurve->Length()-1);index++){ //building of the resulting Wire
BRepLib_MakeEdge EdgeBuilder(concatcurve->Value(index));
edge = EdgeBuilder.Edge();
MakeResult.Add(edge);
}
} }
return MakeResult.Wire() ; return MakeResult.Wire() ;
} }
//======================================================================= //=======================================================================
@ -271,9 +233,6 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire)
ElCLib::AdjustPeriodic ElCLib::AdjustPeriodic
(aBasisCurve->FirstParameter(), aBasisCurve->LastParameter(), (aBasisCurve->FirstParameter(), aBasisCurve->LastParameter(),
Precision::PConfusion(), fpar, lpar); Precision::PConfusion(), fpar, lpar);
} }
if (CurveSeq.IsEmpty()) { if (CurveSeq.IsEmpty()) {
@ -293,102 +252,102 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire)
NewLpar = lpar; NewLpar = lpar;
isSameCurve = Standard_True; isSameCurve = Standard_True;
} else if (aType == CurType && } else if (aType == CurType &&
aType != GeomAbs_BezierCurve && aType != GeomAbs_BezierCurve &&
aType != GeomAbs_BSplineCurve && aType != GeomAbs_BSplineCurve &&
aType != GeomAbs_OtherCurve) { aType != GeomAbs_OtherCurve) {
switch (aType) { switch (aType) {
case GeomAbs_Line: case GeomAbs_Line:
{ {
gp_Lin aLine = aGACurve.Line(); gp_Lin aLine = aGACurve.Line();
gp_Lin PrevLine = GAprevcurve.Line(); gp_Lin PrevLine = GAprevcurve.Line();
if (aLine.Contains(PrevLine.Location(), LinTol) && if (aLine.Contains(PrevLine.Location(), LinTol) &&
aLine.Direction().IsParallel(PrevLine.Direction(), AngTol)) { aLine.Direction().IsParallel(PrevLine.Direction(), AngTol)) {
gp_Pnt P1 = ElCLib::Value(fpar, aLine); gp_Pnt P1 = ElCLib::Value(fpar, aLine);
gp_Pnt P2 = ElCLib::Value(lpar, aLine); gp_Pnt P2 = ElCLib::Value(lpar, aLine);
NewFpar = ElCLib::Parameter(PrevLine, P1); NewFpar = ElCLib::Parameter(PrevLine, P1);
NewLpar = ElCLib::Parameter(PrevLine, P2); NewLpar = ElCLib::Parameter(PrevLine, P2);
isSameCurve = Standard_True; isSameCurve = Standard_True;
} }
break; break;
} }
case GeomAbs_Circle: case GeomAbs_Circle:
{ {
gp_Circ aCircle = aGACurve.Circle(); gp_Circ aCircle = aGACurve.Circle();
gp_Circ PrevCircle = GAprevcurve.Circle(); gp_Circ PrevCircle = GAprevcurve.Circle();
if (aCircle.Location().Distance(PrevCircle.Location()) <= LinTol && if (aCircle.Location().Distance(PrevCircle.Location()) <= LinTol &&
Abs(aCircle.Radius() - PrevCircle.Radius()) <= LinTol && Abs(aCircle.Radius() - PrevCircle.Radius()) <= LinTol &&
aCircle.Axis().IsParallel(PrevCircle.Axis(), AngTol)) { aCircle.Axis().IsParallel(PrevCircle.Axis(), AngTol)) {
gp_Pnt P1 = ElCLib::Value(fpar, aCircle); gp_Pnt P1 = ElCLib::Value(fpar, aCircle);
gp_Pnt P2 = ElCLib::Value(lpar, aCircle); gp_Pnt P2 = ElCLib::Value(lpar, aCircle);
NewFpar = ElCLib::Parameter(PrevCircle, P1); NewFpar = ElCLib::Parameter(PrevCircle, P1);
NewLpar = ElCLib::Parameter(PrevCircle, P2); NewLpar = ElCLib::Parameter(PrevCircle, P2);
isSameCurve = Standard_True; isSameCurve = Standard_True;
} }
break; break;
} }
case GeomAbs_Ellipse: case GeomAbs_Ellipse:
{ {
gp_Elips anEllipse = aGACurve.Ellipse(); gp_Elips anEllipse = aGACurve.Ellipse();
gp_Elips PrevEllipse = GAprevcurve.Ellipse(); gp_Elips PrevEllipse = GAprevcurve.Ellipse();
if (anEllipse.Focus1().Distance(PrevEllipse.Focus1()) <= LinTol && if (anEllipse.Focus1().Distance(PrevEllipse.Focus1()) <= LinTol &&
anEllipse.Focus2().Distance(PrevEllipse.Focus2()) <= LinTol && anEllipse.Focus2().Distance(PrevEllipse.Focus2()) <= LinTol &&
Abs(anEllipse.MajorRadius() - PrevEllipse.MajorRadius()) <= LinTol && Abs(anEllipse.MajorRadius() - PrevEllipse.MajorRadius()) <= LinTol &&
Abs(anEllipse.MinorRadius() - PrevEllipse.MinorRadius()) <= LinTol && Abs(anEllipse.MinorRadius() - PrevEllipse.MinorRadius()) <= LinTol &&
anEllipse.Axis().IsParallel(PrevEllipse.Axis(), AngTol)) { anEllipse.Axis().IsParallel(PrevEllipse.Axis(), AngTol)) {
gp_Pnt P1 = ElCLib::Value(fpar, anEllipse); gp_Pnt P1 = ElCLib::Value(fpar, anEllipse);
gp_Pnt P2 = ElCLib::Value(lpar, anEllipse); gp_Pnt P2 = ElCLib::Value(lpar, anEllipse);
NewFpar = ElCLib::Parameter(PrevEllipse, P1); NewFpar = ElCLib::Parameter(PrevEllipse, P1);
NewLpar = ElCLib::Parameter(PrevEllipse, P2); NewLpar = ElCLib::Parameter(PrevEllipse, P2);
isSameCurve = Standard_True; isSameCurve = Standard_True;
} }
break; break;
} }
case GeomAbs_Hyperbola: case GeomAbs_Hyperbola:
{ {
gp_Hypr aHypr = aGACurve.Hyperbola(); gp_Hypr aHypr = aGACurve.Hyperbola();
gp_Hypr PrevHypr = GAprevcurve.Hyperbola(); gp_Hypr PrevHypr = GAprevcurve.Hyperbola();
if (aHypr.Focus1().Distance(PrevHypr.Focus1()) <= LinTol && if (aHypr.Focus1().Distance(PrevHypr.Focus1()) <= LinTol &&
aHypr.Focus2().Distance(PrevHypr.Focus2()) <= LinTol && aHypr.Focus2().Distance(PrevHypr.Focus2()) <= LinTol &&
Abs(aHypr.MajorRadius() - PrevHypr.MajorRadius()) <= LinTol && Abs(aHypr.MajorRadius() - PrevHypr.MajorRadius()) <= LinTol &&
Abs(aHypr.MinorRadius() - PrevHypr.MinorRadius()) <= LinTol && Abs(aHypr.MinorRadius() - PrevHypr.MinorRadius()) <= LinTol &&
aHypr.Axis().IsParallel(PrevHypr.Axis(), AngTol)) { aHypr.Axis().IsParallel(PrevHypr.Axis(), AngTol)) {
gp_Pnt P1 = ElCLib::Value(fpar, aHypr); gp_Pnt P1 = ElCLib::Value(fpar, aHypr);
gp_Pnt P2 = ElCLib::Value(lpar, aHypr); gp_Pnt P2 = ElCLib::Value(lpar, aHypr);
NewFpar = ElCLib::Parameter(PrevHypr, P1); NewFpar = ElCLib::Parameter(PrevHypr, P1);
NewLpar = ElCLib::Parameter(PrevHypr, P2); NewLpar = ElCLib::Parameter(PrevHypr, P2);
isSameCurve = Standard_True; isSameCurve = Standard_True;
} }
break; break;
} }
case GeomAbs_Parabola: case GeomAbs_Parabola:
{ {
gp_Parab aParab = aGACurve.Parabola(); gp_Parab aParab = aGACurve.Parabola();
gp_Parab PrevParab = GAprevcurve.Parabola(); gp_Parab PrevParab = GAprevcurve.Parabola();
if (aParab.Location().Distance(PrevParab.Location()) <= LinTol && if (aParab.Location().Distance(PrevParab.Location()) <= LinTol &&
aParab.Focus().Distance(PrevParab.Focus()) <= LinTol && aParab.Focus().Distance(PrevParab.Focus()) <= LinTol &&
Abs(aParab.Focal() - PrevParab.Focal()) <= LinTol && Abs(aParab.Focal() - PrevParab.Focal()) <= LinTol &&
aParab.Axis().IsParallel(PrevParab.Axis(), AngTol)) { aParab.Axis().IsParallel(PrevParab.Axis(), AngTol)) {
gp_Pnt P1 = ElCLib::Value(fpar, aParab); gp_Pnt P1 = ElCLib::Value(fpar, aParab);
gp_Pnt P2 = ElCLib::Value(lpar, aParab); gp_Pnt P2 = ElCLib::Value(lpar, aParab);
NewFpar = ElCLib::Parameter(PrevParab, P1); NewFpar = ElCLib::Parameter(PrevParab, P1);
NewLpar = ElCLib::Parameter(PrevParab, P2); NewLpar = ElCLib::Parameter(PrevParab, P2);
isSameCurve = Standard_True; isSameCurve = Standard_True;
} }
break; break;
} }
default: default:
break; break;
} //end of switch } //end of switch
} //end of else } //end of else
if (isSameCurve) { if (isSameCurve) {
@ -466,7 +425,7 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire)
FirstVtx_final.Orientation(TopAbs_FORWARD); FirstVtx_final.Orientation(TopAbs_FORWARD);
TopoDS_Vertex LastVtx_final = (isReverse)? FirstVertex : LastVertex; TopoDS_Vertex LastVtx_final = (isReverse)? FirstVertex : LastVertex;
LastVtx_final.Orientation(TopAbs_REVERSED); LastVtx_final.Orientation(TopAbs_REVERSED);
if (CurveSeq.IsEmpty()) if (CurveSeq.IsEmpty())
return ResEdge; return ResEdge;
@ -477,87 +436,87 @@ TopoDS_Edge BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire)
Standard_Integer i; Standard_Integer i;
if (nb_curve > 1) if (nb_curve > 1)
{
for (i = 1; i <= nb_curve; i++)
{ {
for (i = 1; i <= nb_curve; i++) if (CurveSeq(i)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
{ CurveSeq(i) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(i))))->BasisCurve();
if (CurveSeq(i)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
CurveSeq(i) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(i))))->BasisCurve();
Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(CurveSeq(i), FparSeq(i), LparSeq(i));
tab(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve);
GeomConvert::C0BSplineToC1BSplineCurve(tab(i-1), Precision::Confusion());
if (!IsFwdSeq(i)) { Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(CurveSeq(i), FparSeq(i), LparSeq(i));
tab(i-1)->Reverse(); tab(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve);
} GeomConvert::C0BSplineToC1BSplineCurve(tab(i-1), Precision::Confusion());
//Temporary
//char* name = new char[100];
//sprintf(name, "c%d", i);
//DrawTrSurf::Set(name, tab(i-1));
if (i > 1)
tabtolvertex(i-2) = TolSeq(i-1) * 5.;
}
tabtolvertex(nb_curve-1) = TolSeq(TolSeq.Length()) * 5.;
Standard_Boolean closed_flag = Standard_False;
Standard_Real closed_tolerance = 0.;
if (FirstVertex.IsSame(LastVertex) &&
GeomLProp::Continuity(tab(0), tab(nb_curve-1),
tab(0)->FirstParameter(),
tab(nb_curve-1)->LastParameter(),
Standard_False, Standard_False, LinTol, AngTol) >= GeomAbs_G1)
{
closed_flag = Standard_True ;
closed_tolerance = BRep_Tool::Tolerance(FirstVertex);
}
Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves
Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex
GeomConvert::ConcatC1(tab,
tabtolvertex,
ArrayOfIndices,
concatcurve,
closed_flag,
closed_tolerance); //C1 concatenation
if (concatcurve->Length() > 1) if (!IsFwdSeq(i)) {
{ tab(i-1)->Reverse();
Standard_Real MaxTolVer = LinTol; }
for (i = 1; i <= TolSeq.Length(); i++)
if (TolSeq(i) > MaxTolVer)
MaxTolVer = TolSeq(i);
MaxTolVer *= 5.;
GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower()));
for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++)
Concat.Add( concatcurve->Value(i), MaxTolVer, Standard_True );
concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve());
}
ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()), //Temporary
FirstVtx_final, LastVtx_final, //char* name = new char[100];
concatcurve->Value(concatcurve->Lower())->FirstParameter(), //sprintf(name, "c%d", i);
concatcurve->Value(concatcurve->Lower())->LastParameter()); //DrawTrSurf::Set(name, tab(i-1));
if (i > 1)
tabtolvertex(i-2) = TolSeq(i-1) * 5.;
} }
tabtolvertex(nb_curve-1) = TolSeq(TolSeq.Length()) * 5.;
Standard_Boolean closed_flag = Standard_False;
Standard_Real closed_tolerance = 0.;
if (FirstVertex.IsSame(LastVertex) &&
GeomLProp::Continuity(tab(0), tab(nb_curve-1),
tab(0)->FirstParameter(),
tab(nb_curve-1)->LastParameter(),
Standard_False, Standard_False, LinTol, AngTol) >= GeomAbs_G1)
{
closed_flag = Standard_True ;
closed_tolerance = BRep_Tool::Tolerance(FirstVertex);
}
Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves
Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex
GeomConvert::ConcatC1(tab,
tabtolvertex,
ArrayOfIndices,
concatcurve,
closed_flag,
closed_tolerance); //C1 concatenation
if (concatcurve->Length() > 1)
{
Standard_Real MaxTolVer = LinTol;
for (i = 1; i <= TolSeq.Length(); i++)
if (TolSeq(i) > MaxTolVer)
MaxTolVer = TolSeq(i);
MaxTolVer *= 5.;
GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower()));
for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++)
Concat.Add( concatcurve->Value(i), MaxTolVer, Standard_True );
concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve());
}
ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()),
FirstVtx_final, LastVtx_final,
concatcurve->Value(concatcurve->Lower())->FirstParameter(),
concatcurve->Value(concatcurve->Lower())->LastParameter());
}
else else
{ {
if (CurveSeq(1)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) if (CurveSeq(1)->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
CurveSeq(1) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(1))))->BasisCurve(); CurveSeq(1) = (*((Handle(Geom_TrimmedCurve)*)&(CurveSeq(1))))->BasisCurve();
Handle(Geom_Curve) aCopyCurve = Handle(Geom_Curve) aCopyCurve =
Handle(Geom_Curve)::DownCast(CurveSeq(1)->Copy()); Handle(Geom_Curve)::DownCast(CurveSeq(1)->Copy());
ResEdge = BRepLib_MakeEdge(aCopyCurve, ResEdge = BRepLib_MakeEdge(aCopyCurve,
FirstVtx_final, LastVtx_final, FirstVtx_final, LastVtx_final,
FparSeq(1), LparSeq(1)); FparSeq(1), LparSeq(1));
} }
if (isReverse) if (isReverse)
ResEdge.Reverse(); ResEdge.Reverse();
return ResEdge; return ResEdge;
} }

12
tests/bugs/modalg_5/bug25028 Executable file
View File

@ -0,0 +1,12 @@
puts "============"
puts "OCC25028"
puts "============"
puts ""
###############################
## BRepAlgo::ConcatenateWire raises an exception
###############################
restore [locate_data_file bug25028_profile.brep] s
checkshape s
whatis s
concatwire r s