diff --git a/src/Geom/Geom_BSplineSurface.cxx b/src/Geom/Geom_BSplineSurface.cxx index 5316b0c385..7b5c9f5ef3 100644 --- a/src/Geom/Geom_BSplineSurface.cxx +++ b/src/Geom/Geom_BSplineSurface.cxx @@ -300,48 +300,37 @@ void Geom_BSplineSurface::ExchangeUV () Standard_Integer LR = poles->LowerRow(); Standard_Integer UR = poles->UpperRow(); - Handle(TColgp_HArray2OfPnt) npoles = - new TColgp_HArray2OfPnt (LC, UC, LR, UR); - Handle(TColStd_HArray2OfReal) nweights = - new TColStd_HArray2OfReal (LC, UC, LR, UR); - - const TColgp_Array2OfPnt & spoles = poles->Array2(); - const TColStd_Array2OfReal & sweights = weights->Array2(); - - TColgp_Array2OfPnt& snpoles = npoles->ChangeArray2(); - TColStd_Array2OfReal& snweights = nweights->ChangeArray2(); - - Standard_Integer i, j; - for (i = LC; i <= UC; i++) { - for (j = LR; j <= UR; j++) { - snpoles (i,j) = spoles (j,i); - snweights (i,j) = sweights (j,i); - } + Handle(TColgp_HArray2OfPnt) npoles = new TColgp_HArray2OfPnt (LC, UC, LR, UR); + Handle(TColStd_HArray2OfReal) nweights; + if (!weights.IsNull()) + { + nweights = new TColStd_HArray2OfReal (LC, UC, LR, UR); } + const TColgp_Array2OfPnt& spoles = poles->Array2(); + const TColStd_Array2OfReal* sweights = !weights.IsNull() ? &weights->Array2() : NULL; + + TColgp_Array2OfPnt& snpoles = npoles->ChangeArray2(); + TColStd_Array2OfReal* snweights = !nweights.IsNull() ? &nweights->ChangeArray2() : NULL; + for (Standard_Integer i = LC; i <= UC; i++) + { + for (Standard_Integer j = LR; j <= UR; j++) + { + snpoles (i, j) = spoles (j, i); + if (snweights != NULL) + { + snweights->ChangeValue (i, j) = sweights->Value (j, i); + } + } + } poles = npoles; weights = nweights; - Standard_Boolean temp = urational; - urational = vrational; - vrational = temp; - - temp = uperiodic; - uperiodic = vperiodic; - vperiodic = temp; - - Standard_Integer tempdeg = udeg; - udeg = vdeg; - vdeg = tempdeg; - - - Handle(TColStd_HArray1OfReal) tempknots = uknots; - uknots = vknots; - vknots = tempknots; - - Handle(TColStd_HArray1OfInteger) tempmults = umults; - umults = vmults; - vmults = tempmults; + std::swap (urational, vrational); + std::swap (uperiodic, vperiodic); + std::swap (udeg, vdeg); + std::swap (uknots, vknots); + std::swap (umults, vmults); UpdateUKnots(); UpdateVKnots(); diff --git a/src/Geom/Geom_BezierSurface.cxx b/src/Geom/Geom_BezierSurface.cxx index 9e14f232a3..664fd90495 100644 --- a/src/Geom/Geom_BezierSurface.cxx +++ b/src/Geom/Geom_BezierSurface.cxx @@ -505,31 +505,33 @@ void Geom_BezierSurface::ExchangeUV () Standard_Integer LR = poles->LowerRow(); Standard_Integer UR = poles->UpperRow(); - Handle(TColgp_HArray2OfPnt) npoles = - new TColgp_HArray2OfPnt (LC, UC, LR, UR); - Handle(TColStd_HArray2OfReal) nweights = - new TColStd_HArray2OfReal (LC, UC, LR, UR); - - const TColgp_Array2OfPnt & spoles = poles->Array2(); - const TColStd_Array2OfReal & sweights = weights->Array2(); - - TColgp_Array2OfPnt& snpoles = npoles->ChangeArray2(); - TColStd_Array2OfReal& snweights = nweights->ChangeArray2(); - - Standard_Integer i, j; - for (i = LC; i <= UC; i++) { - for (j = LR; j <= UR; j++) { - snpoles (i,j) = spoles (j,i); - snweights (i,j) = sweights (j,i); - } + Handle(TColgp_HArray2OfPnt) npoles = new TColgp_HArray2OfPnt (LC, UC, LR, UR); + Handle(TColStd_HArray2OfReal) nweights; + if (!weights.IsNull()) + { + nweights = new TColStd_HArray2OfReal (LC, UC, LR, UR); } + const TColgp_Array2OfPnt& spoles = poles->Array2(); + const TColStd_Array2OfReal* sweights = !weights.IsNull() ? &weights->Array2() : NULL; + + TColgp_Array2OfPnt& snpoles = npoles->ChangeArray2(); + TColStd_Array2OfReal* snweights = !nweights.IsNull() ? &nweights->ChangeArray2() : NULL; + for (Standard_Integer i = LC; i <= UC; i++) + { + for (Standard_Integer j = LR; j <= UR; j++) + { + snpoles (i, j) = spoles (j, i); + if (snweights != NULL) + { + snweights->ChangeValue (i, j) = sweights->Value (j, i); + } + } + } poles = npoles; weights = nweights; - Standard_Boolean temp = urational; - urational = vrational; - vrational = temp; + std::swap (urational, vrational); } //======================================================================= diff --git a/tests/bugs/moddata_3/bug32041 b/tests/bugs/moddata_3/bug32041 new file mode 100644 index 0000000000..5d592ad3f8 --- /dev/null +++ b/tests/bugs/moddata_3/bug32041 @@ -0,0 +1,12 @@ +puts "=========" +puts "0032041: Modeling Data - Access v i o l a t i o n ExchangeUV in Geom_BezierSurface" +puts "=========" +puts "" + +pload MODELING +beziersurf bs 4 4 0 0 0 4 0 0 8 0 0 12 0 0 0 4 0 4 4 1 8 4 0 12 4 0 0 8 0 4 8 0 8 8 -1 12 8 0 0 12 0 4 12 0 8 12 0 12 12 0 +smallview +fit +xwd ${imagedir}/${casename}_1.png +exchuv bs +xwd ${imagedir}/${casename}_2.png