From 6b8f3bdc36daf45396261fed51839064be893cff Mon Sep 17 00:00:00 2001 From: msv Date: Tue, 25 Oct 2016 11:54:34 +0300 Subject: [PATCH] 0025214: HLR fails to project edges Avoid getting non-existing array items. Use reference to array items instead of pointers where it is possible. Create test case. Before the fix this test raised exception in debug mode. --- src/HLRBRep/HLRBRep_Data.cxx | 190 +++++++++++++-------------- src/HLRBRep/HLRBRep_InternalAlgo.cxx | 170 ++++++++++++------------ tests/bugs/modalg_6/bug25214 | 20 +++ 3 files changed, 193 insertions(+), 187 deletions(-) create mode 100644 tests/bugs/modalg_6/bug25214 diff --git a/src/HLRBRep/HLRBRep_Data.cxx b/src/HLRBRep/HLRBRep_Data.cxx index 0167524a04..1a98f5295b 100644 --- a/src/HLRBRep/HLRBRep_Data.cxx +++ b/src/HLRBRep/HLRBRep_Data.cxx @@ -608,21 +608,18 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) HLRAlgo::InitMinMax(Precision::Infinite(), (Standard_Address)TotMin, (Standard_Address)TotMax); - HLRBRep_EdgeData* ed; - HLRBRep_FaceData* fd; - ed = &(myEData.ChangeValue(1)); // compute the global MinMax // ************************* // for (Standard_Integer edge = 1; edge <= myNbEdges; edge++) { Standard_Integer edge; for ( edge = 1; edge <= myNbEdges; edge++) { - HLRBRep_Curve& EC = ed->ChangeGeometry(); + HLRBRep_EdgeData& ed = myEData.ChangeValue(edge); + HLRBRep_Curve& EC = ed.ChangeGeometry(); EC.Projector(&myProj); Standard_Real enl =EC.Update((Standard_Address)TotMin, (Standard_Address)TotMax); if (enl > tolMinMax) tolMinMax = enl; - ed++; } HLRAlgo::EnlargeMinMax(tolMinMax, (Standard_Address)TotMin, @@ -647,22 +644,20 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) Standard_Real tol; Standard_Boolean ver1,ver2; - ed = &(myEData.ChangeValue(1)); - fd = &(myFData.ChangeValue(1)); - // update the edges // **************** for (edge = 1; edge <= myNbEdges; edge++) { - HLRBRep_Curve& EC = ed->ChangeGeometry(); + HLRBRep_EdgeData& ed = myEData.ChangeValue(edge); + HLRBRep_Curve& EC = ed.ChangeGeometry(); HLRAlgo::InitMinMax(Precision::Infinite(), (Standard_Address)TotMin, (Standard_Address)TotMax); tolMinMax = EC.UpdateMinMax((Standard_Address)TotMin, (Standard_Address)TotMax); - tol = (Standard_Real)(ed->Tolerance()); - ed->Vertical(TotMax[0] - TotMin[0] < tol && + tol = (Standard_Real)(ed.Tolerance()); + ed.Vertical(TotMax[0] - TotMin[0] < tol && TotMax[1] - TotMin[1] < tol && TotMax[2] - TotMin[2] < tol && TotMax[3] - TotMin[3] < tol && @@ -709,28 +704,27 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) HLRAlgo::EncodeMinMax((Standard_Address)EdgeMin, (Standard_Address)EdgeMax, (Standard_Address)MinMaxEdge); - ed->UpdateMinMax((Standard_Address)MinMaxEdge); - if (ed->Vertical()) { + ed.UpdateMinMax((Standard_Address)MinMaxEdge); + if (ed.Vertical()) { ver1 = Standard_True; ver2 = Standard_True; - Standard_Integer vsta = ed->VSta(); - Standard_Integer vend = ed->VEnd(); - Standard_Boolean vout = ed->OutLVSta() || ed->OutLVEnd(); - Standard_Boolean vcut = ed->CutAtSta() || ed->CutAtEnd(); - HLRBRep_EdgeData* eb = &(myEData.ChangeValue(1)); + Standard_Integer vsta = ed.VSta(); + Standard_Integer vend = ed.VEnd(); + Standard_Boolean vout = ed.OutLVSta() || ed.OutLVEnd(); + Standard_Boolean vcut = ed.CutAtSta() || ed.CutAtEnd(); for (Standard_Integer ebis = 1; ebis <= myNbEdges; ebis++) { - if (vsta == eb->VSta()) { - eb->VSta (vend); - eb->OutLVSta(vout); - eb->CutAtSta(vcut); + HLRBRep_EdgeData& eb = myEData.ChangeValue(ebis); + if (vsta == eb.VSta()) { + eb.VSta (vend); + eb.OutLVSta(vout); + eb.CutAtSta(vcut); } - else if (vsta == eb->VEnd()) { - eb->VEnd (vend); - eb->OutLVEnd(vout); - eb->CutAtEnd(vcut); + else if (vsta == eb.VEnd()) { + eb.VEnd (vend); + eb.OutLVEnd(vout); + eb.CutAtEnd(vcut); } - eb++; } } else { @@ -751,11 +745,10 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) ver2 = Abs(Dir2.X()) + Abs(Dir2.Y()) < myToler * 10; } } - ed->VerAtSta(ed->Vertical() || ver1); - ed->VerAtEnd(ed->Vertical() || ver2); - ed->AutoIntersectionDone(Standard_True); - ed->Simple(Standard_True); - ed++; + ed.VerAtSta(ed.Vertical() || ver1); + ed.VerAtEnd(ed.Vertical() || ver2); + ed.AutoIntersectionDone(Standard_True); + ed.Simple(Standard_True); } // update the faces @@ -763,8 +756,9 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) for (Standard_Integer face = 1; face <= myNbFaces; face++) { - HLRBRep_Surface& FS = fd->Geometry(); - iFaceGeom = &(fd->Geometry()); + HLRBRep_FaceData& fd = myFData.ChangeValue(face); + HLRBRep_Surface& FS = fd.Geometry(); + iFaceGeom = &(fd.Geometry()); mySLProps.SetSurface(iFaceGeom); FS.Projector(&myProj); iFaceType = FS.GetType(); @@ -774,7 +768,7 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) Standard_Boolean cut = Standard_False; Standard_Boolean withOutL = Standard_False; - for (myFaceItr1.InitEdge(*fd); + for (myFaceItr1.InitEdge(fd); myFaceItr1.MoreEdge(); myFaceItr1.NextEdge()) { if (myFaceItr1.Internal()) { @@ -786,8 +780,8 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) if (myFaceItr1.Double()) cut = Standard_True; } } - fd->Cut (cut); - fd->WithOutL(withOutL); + fd.Cut (cut); + fd.WithOutL(withOutL); // Is the face simple = no auto-hiding // not cut and simple surface @@ -797,31 +791,31 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) iFaceType == GeomAbs_Cylinder || iFaceType == GeomAbs_Cone || iFaceType == GeomAbs_Sphere || - iFaceType == GeomAbs_Torus )) fd->Simple(Standard_True ); - else fd->Simple(Standard_False); - - fd->Plane (iFaceType == GeomAbs_Plane ); - fd->Cylinder(iFaceType == GeomAbs_Cylinder); - fd->Cone (iFaceType == GeomAbs_Cone ); - fd->Sphere (iFaceType == GeomAbs_Sphere ); - fd->Torus (iFaceType == GeomAbs_Torus ); - tol = (Standard_Real)(fd->Tolerance()); - fd->Side(FS.IsSide(tol,myToler*10)); + iFaceType == GeomAbs_Torus )) fd.Simple(Standard_True ); + else fd.Simple(Standard_False); + + fd.Plane (iFaceType == GeomAbs_Plane ); + fd.Cylinder(iFaceType == GeomAbs_Cylinder); + fd.Cone (iFaceType == GeomAbs_Cone ); + fd.Sphere (iFaceType == GeomAbs_Sphere ); + fd.Torus (iFaceType == GeomAbs_Torus ); + tol = (Standard_Real)(fd.Tolerance()); + fd.Side(FS.IsSide(tol,myToler*10)); Standard_Boolean inverted = Standard_False; - if (fd->WithOutL() && !fd->Side()) { - inverted = OrientOutLine(face,*fd); - OrientOthEdge(face,*fd); + if (fd.WithOutL() && !fd.Side()) { + inverted = OrientOutLine(face,fd); + OrientOthEdge(face,fd); } - if (fd->Side()) { - fd->Hiding(Standard_False); - fd->Back(Standard_False); + if (fd.Side()) { + fd.Hiding(Standard_False); + fd.Back(Standard_False); } - else if (!fd->WithOutL()) { + else if (!fd.WithOutL()) { Standard_Real p,pu,pv,r; - fd->Back(Standard_False); + fd.Back(Standard_False); Standard_Boolean found = Standard_False; - for (myFaceItr1.InitEdge(*fd); + for (myFaceItr1.InitEdge(fd); myFaceItr1.MoreEdge() && !found; myFaceItr1.NextEdge()) { myFE = myFaceItr1.Edge (); @@ -829,12 +823,12 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) myFEOutLine = myFaceItr1.OutLine (); myFEInternal = myFaceItr1.Internal (); myFEDouble = myFaceItr1.Double (); - HLRBRep_EdgeData* EDataFE1 = &(myEData(myFE)); + HLRBRep_EdgeData& EDataFE1 = myEData(myFE); if (!myFEDouble && (myFEOri == TopAbs_FORWARD || myFEOri == TopAbs_REVERSED)) { - myFEGeom = &(EDataFE1->ChangeGeometry()); - const HLRBRep_Curve& EC = EDataFE1->Geometry(); + myFEGeom = &(EDataFE1.ChangeGeometry()); + const HLRBRep_Curve& EC = EDataFE1.Geometry(); p = EC.Parameter3d((EC.LastParameter () + EC.FirstParameter()) / 2); if (HLRBRep_EdgeFaceTool::UVPoint(p,myFEGeom,iFaceGeom,pu,pv)) { @@ -852,7 +846,7 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) } else r = Nm.Z(); if (Abs(r) > myToler*10) { - fd->Back( r < 0 ); + fd.Back( r < 0 ); found = Standard_True; break; } @@ -862,40 +856,40 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) } if (!found) { - fd->Side(Standard_True); - fd->Hiding(Standard_False); - fd->Back(Standard_False); + fd.Side(Standard_True); + fd.Hiding(Standard_False); + fd.Back(Standard_False); } - else if (fd->Closed()) { - switch (fd->Orientation()) { - case TopAbs_REVERSED : fd->Hiding( fd->Back() ); break; - case TopAbs_FORWARD : fd->Hiding(!fd->Back() ); break; - case TopAbs_EXTERNAL : fd->Hiding(Standard_True ); break; - case TopAbs_INTERNAL : fd->Hiding(Standard_False); break; + else if (fd.Closed()) { + switch (fd.Orientation()) { + case TopAbs_REVERSED : fd.Hiding( fd.Back() ); break; + case TopAbs_FORWARD : fd.Hiding(!fd.Back() ); break; + case TopAbs_EXTERNAL : fd.Hiding(Standard_True ); break; + case TopAbs_INTERNAL : fd.Hiding(Standard_False); break; } } - else fd->Hiding(Standard_True); + else fd.Hiding(Standard_True); } else { if (inverted) { - fd->Hiding(Standard_False); - fd->Back(Standard_True); + fd.Hiding(Standard_False); + fd.Back(Standard_True); } else { - fd->Hiding(Standard_True); - fd->Back(Standard_False); + fd.Hiding(Standard_True); + fd.Back(Standard_False); } } Standard_Boolean FirstTime = Standard_True; - for (myFaceItr1.InitEdge(*fd); + for (myFaceItr1.InitEdge(fd); myFaceItr1.MoreEdge(); myFaceItr1.NextEdge()) { myFE = myFaceItr1.Edge(); - HLRBRep_EdgeData* EDataFE2 = &(myEData(myFE)); - if (!fd->Simple()) EDataFE2->AutoIntersectionDone(Standard_False); - HLRAlgo::DecodeMinMax(EDataFE2->MinMax(), + HLRBRep_EdgeData& EDataFE2 = myEData(myFE); + if (!fd.Simple()) EDataFE2.AutoIntersectionDone(Standard_False); + HLRAlgo::DecodeMinMax(EDataFE2.MinMax(), (Standard_Address)EdgeMin, (Standard_Address)EdgeMax); if (myFaceItr1.BeginningOfWire()) @@ -930,9 +924,8 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) HLRAlgo::EncodeMinMax((Standard_Address)FaceMin, (Standard_Address)FaceMax, (Standard_Address)MinMaxFace); - fd->Wires()->UpdateMinMax((Standard_Address)MinMaxFace); - fd->Size(HLRAlgo::SizeBox(FaceMin,FaceMax)); - fd++; + fd.Wires()->UpdateMinMax((Standard_Address)MinMaxFace); + fd.Size(HLRAlgo::SizeBox(FaceMin,FaceMax)); } } @@ -947,12 +940,12 @@ HLRBRep_Data::InitBoundSort (const Standard_Address MinMaxTot, const Standard_Integer e2) { myNbrSortEd = 0; - HLRBRep_EdgeData* ed = &(myEData(e1)); Standard_Address MinMaxShap = MinMaxTot; for (Standard_Integer e = e1; e <= e2; e++) { - if (!ed->Status().AllHidden()) { - myLEMinMax = ed->MinMax(); + HLRBRep_EdgeData& ed = myEData(e); + if (!ed.Status().AllHidden()) { + myLEMinMax = ed.MinMax(); if (((MaxShap1 - MinLEdg1) & 0x80008000) == 0 && ((MaxLEdg1 - MinShap1) & 0x80008000) == 0 && ((MaxShap2 - MinLEdg2) & 0x80008000) == 0 && @@ -972,7 +965,6 @@ HLRBRep_Data::InitBoundSort (const Standard_Address MinMaxTot, myEdgeIndices(myNbrSortEd) = e; } } - ed++; } } @@ -1652,18 +1644,18 @@ Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer I, HLRBRep_ for (ie1 = 1; ie1 <= ne1; ie1++) { myFE = eb1->Edge(ie1); - HLRBRep_EdgeData* ed1 = &(myEData(myFE)); + HLRBRep_EdgeData& ed1 = myEData(myFE); if (eb1->Double (ie1) || eb1->IsoLine(ie1) || - ed1->Vertical()) ed1->Used(Standard_True ); - else ed1->Used(Standard_False); + ed1.Vertical()) ed1.Used(Standard_True ); + else ed1.Used(Standard_False); if ((eb1->OutLine(ie1) || eb1->Internal(ie1)) && - !ed1->Vertical()) { + !ed1.Vertical()) { Standard_Real p,pu,pv,r; - myFEGeom = &(ed1->ChangeGeometry()); - const HLRBRep_Curve& EC = ed1->Geometry(); - Standard_Integer vsta = ed1->VSta(); - Standard_Integer vend = ed1->VEnd(); + myFEGeom = &(ed1.ChangeGeometry()); + const HLRBRep_Curve& EC = ed1.Geometry(); + Standard_Integer vsta = ed1.VSta(); + Standard_Integer vend = ed1.VEnd(); if (vsta == 0 && vend == 0) p = 0; else if (vsta == 0) p = EC.Parameter3d(EC.LastParameter ()); @@ -1730,7 +1722,7 @@ Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer I, HLRBRep_ cout << "UVPoint not found, OutLine not Oriented" << endl; #endif } - ed1->Used(Standard_True); + ed1.Used(Standard_True); } } } @@ -1758,12 +1750,12 @@ void HLRBRep_Data::OrientOthEdge (const Standard_Integer I, for (ie1 = 1; ie1 <= ne1; ie1++) { myFE = eb1->Edge (ie1); myFEOri = eb1->Orientation(ie1); - HLRBRep_EdgeData* ed1 = &(myEData(myFE)); + HLRBRep_EdgeData& ed1 = myEData(myFE); - if (!ed1->Used()) { - ed1->Used(Standard_True); - myFEGeom = &(ed1->ChangeGeometry()); - const HLRBRep_Curve& EC = ed1->Geometry(); + if (!ed1.Used()) { + ed1.Used(Standard_True); + myFEGeom = &(ed1.ChangeGeometry()); + const HLRBRep_Curve& EC = ed1.Geometry(); p = EC.Parameter3d((EC.LastParameter () + EC.FirstParameter()) / 2); if (HLRBRep_EdgeFaceTool::UVPoint(p,myFEGeom,iFaceGeom,pu,pv)) { diff --git a/src/HLRBRep/HLRBRep_InternalAlgo.cxx b/src/HLRBRep/HLRBRep_InternalAlgo.cxx index 63a149dfbc..c4f35c656a 100644 --- a/src/HLRBRep/HLRBRep_InternalAlgo.cxx +++ b/src/HLRBRep/HLRBRep_InternalAlgo.cxx @@ -190,6 +190,8 @@ void HLRBRep_InternalAlgo::Update () Standard_Integer ShapMin[16],ShapMax[16],MinMaxShap[16]; Standard_Integer TheMin[16],TheMax[16]; + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); + HLRBRep_Array1OfFData& aFDataArray = myDS->FDataArray(); for (i = 1; i <= n; i++) { Standard_Boolean FirstTime = Standard_True; @@ -197,13 +199,9 @@ void HLRBRep_InternalAlgo::Update () Standard_Integer v1,v2,e1,e2,f1,f2; SB.Bounds(v1,v2,e1,e2,f1,f2); - HLRBRep_EdgeData* ed = &(myDS->EDataArray (). ChangeValue(e1 - 1)); - HLRBRep_FaceData* fd = &(myDS->FDataArray (). ChangeValue(f1 - 1)); - ed++; - fd++; - for (Standard_Integer e = e1; e <= e2; e++) { - HLRAlgo::DecodeMinMax(ed->MinMax(), + HLRBRep_EdgeData ed = aEDataArray.ChangeValue(e); + HLRAlgo::DecodeMinMax(ed.MinMax(), (Standard_Address)TheMin, (Standard_Address)TheMax); if (FirstTime) { @@ -218,18 +216,17 @@ void HLRBRep_InternalAlgo::Update () (Standard_Address)TheMax, (Standard_Address)ShapMin, (Standard_Address)ShapMax); - ed++; } for (Standard_Integer f = f1; f <= f2; f++) { - HLRAlgo::DecodeMinMax(fd->Wires()->MinMax(), + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + HLRAlgo::DecodeMinMax(fd.Wires()->MinMax(), (Standard_Address)TheMin, (Standard_Address)TheMax); HLRAlgo::AddMinMax((Standard_Address)TheMin, (Standard_Address)TheMax, (Standard_Address)ShapMin, (Standard_Address)ShapMax); - fd++; } HLRAlgo::EncodeMinMax((Standard_Address)ShapMin, (Standard_Address)ShapMax, @@ -354,40 +351,39 @@ void HLRBRep_InternalAlgo::InitEdgeStatus () Standard_Boolean visible; HLRBRep_FaceIterator faceIt; - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); - HLRBRep_FaceData* fd = &(myDS->FDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); + HLRBRep_Array1OfFData& aFDataArray = myDS->FDataArray(); Standard_Integer ne = myDS->NbEdges(); Standard_Integer nf = myDS->NbFaces(); for (Standard_Integer e = 1; e <= ne; e++) { - if (ed->Selected()) ed->Status().ShowAll(); - ed++; + HLRBRep_EdgeData ed = aEDataArray.ChangeValue(e); + if (ed.Selected()) ed.Status().ShowAll(); } // for (Standard_Integer f = 1; f <= nf; f++) { Standard_Integer f; for ( f = 1; f <= nf; f++) { - if (fd->Selected()) { + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + if (fd.Selected()) { - for (faceIt.InitEdge(*fd); + for (faceIt.InitEdge(fd); faceIt.MoreEdge(); faceIt.NextEdge()) { HLRBRep_EdgeData* edf = &(myDS->EDataArray().ChangeValue(faceIt.Edge())); if (edf->Selected()) edf->Status().HideAll(); } } - fd++; } - fd = &(myDS->FDataArray().ChangeValue(1)); - for (f = 1; f <= nf; f++) { + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); visible = Standard_True; - if (fd->Selected() && fd->Closed()) { - if ( fd->Side()) visible = Standard_False; - else if ( !fd->WithOutL()) { - switch (fd->Orientation()) { - case TopAbs_REVERSED : visible = fd->Back() ; break; - case TopAbs_FORWARD : visible = !fd->Back() ; break; + if (fd.Selected() && fd.Closed()) { + if ( fd.Side()) visible = Standard_False; + else if ( !fd.WithOutL()) { + switch (fd.Orientation()) { + case TopAbs_REVERSED : visible = fd.Back() ; break; + case TopAbs_FORWARD : visible = !fd.Back() ; break; case TopAbs_EXTERNAL : case TopAbs_INTERNAL : visible = Standard_True; break; } @@ -395,7 +391,7 @@ void HLRBRep_InternalAlgo::InitEdgeStatus () } if (visible) { - for (faceIt.InitEdge(*fd); + for (faceIt.InitEdge(fd); faceIt.MoreEdge(); faceIt.NextEdge()) { Standard_Integer E = faceIt.Edge(); @@ -405,7 +401,6 @@ void HLRBRep_InternalAlgo::InitEdgeStatus () edf->Status().ShowAll(); } } - fd++; } } @@ -417,19 +412,19 @@ void HLRBRep_InternalAlgo::InitEdgeStatus () void HLRBRep_InternalAlgo::Select () { if (!myDS.IsNull()) { - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); - HLRBRep_FaceData* fd = &(myDS->FDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); + HLRBRep_Array1OfFData& aFDataArray = myDS->FDataArray(); Standard_Integer ne = myDS->NbEdges(); Standard_Integer nf = myDS->NbFaces(); for (Standard_Integer e = 1; e <= ne; e++) { - ed->Selected(Standard_True); - ed++; + HLRBRep_EdgeData ed = aEDataArray.ChangeValue(e); + ed.Selected(Standard_True); } for (Standard_Integer f = 1; f <= nf; f++) { - fd->Selected(Standard_True); - fd++; + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + fd.Selected(Standard_True); } } } @@ -449,19 +444,19 @@ void HLRBRep_InternalAlgo::Select (const Standard_Integer I) Standard_Integer v1,v2,e1,e2,f1,f2; myShapes(I).Bounds(v1,v2,e1,e2,f1,f2); - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); - HLRBRep_FaceData* fd = &(myDS->FDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); + HLRBRep_Array1OfFData& aFDataArray = myDS->FDataArray(); Standard_Integer ne = myDS->NbEdges(); Standard_Integer nf = myDS->NbFaces(); for (Standard_Integer e = 1; e <= ne; e++) { - ed->Selected(e >= e1 && e <= e2); - ed++; + HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); + ed.Selected(e >= e1 && e <= e2); } for (Standard_Integer f = 1; f <= nf; f++) { - fd->Selected(f >= f1 && f <= f2); - fd++; + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + fd.Selected(f >= f1 && f <= f2); } } } @@ -481,12 +476,12 @@ void HLRBRep_InternalAlgo::SelectEdge (const Standard_Integer I) Standard_Integer v1,v2,e1,e2,f1,f2; myShapes(I).Bounds(v1,v2,e1,e2,f1,f2); - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); Standard_Integer ne = myDS->NbEdges(); for (Standard_Integer e = 1; e <= ne; e++) { - ed->Selected(e >= e1 && e <= e2); - ed++; + HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); + ed.Selected(e >= e1 && e <= e2); } } } @@ -506,12 +501,12 @@ void HLRBRep_InternalAlgo::SelectFace (const Standard_Integer I) Standard_Integer v1,v2,e1,e2,f1,f2; myShapes(I).Bounds(v1,v2,e1,e2,f1,f2); - HLRBRep_FaceData* fd = &(myDS->FDataArray().ChangeValue(1)); + HLRBRep_Array1OfFData& aFDataArray = myDS->FDataArray(); Standard_Integer nf = myDS->NbFaces(); for (Standard_Integer f = 1; f <= nf; f++) { - fd->Selected(f >= f1 && f <= f2); - fd++; + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + fd.Selected(f >= f1 && f <= f2); } } } @@ -524,12 +519,12 @@ void HLRBRep_InternalAlgo::SelectFace (const Standard_Integer I) void HLRBRep_InternalAlgo::ShowAll () { if (!myDS.IsNull()) { - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); Standard_Integer ne = myDS->NbEdges(); for (Standard_Integer ie = 1; ie <= ne; ie++) { - ed->Status().ShowAll(); - ed++; + HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(ie); + ed.Status().ShowAll(); } } } @@ -548,12 +543,12 @@ void HLRBRep_InternalAlgo::ShowAll (const Standard_Integer I) Select(I); - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); Standard_Integer ne = myDS->NbEdges(); for (Standard_Integer e = 1; e <= ne; e++) { - if (ed->Selected()) ed->Status().ShowAll(); - ed++; + HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); + if (ed.Selected()) ed.Status().ShowAll(); } } } @@ -566,12 +561,12 @@ void HLRBRep_InternalAlgo::ShowAll (const Standard_Integer I) void HLRBRep_InternalAlgo::HideAll () { if (!myDS.IsNull()) { - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); Standard_Integer ne = myDS->NbEdges(); for (Standard_Integer ie = 1; ie <= ne; ie++) { - ed->Status().HideAll(); - ed++; + HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(ie); + ed.Status().HideAll(); } } } @@ -590,12 +585,12 @@ void HLRBRep_InternalAlgo::HideAll (const Standard_Integer I) Select(I); - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); Standard_Integer ne = myDS->NbEdges(); for (Standard_Integer e = 1; e <= ne; e++) { - if (ed->Selected()) ed->Status().HideAll(); - ed++; + HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); + if (ed.Selected()) ed.Status().HideAll(); } } } @@ -741,8 +736,8 @@ void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I, if (e2 >= e1) { myDS->InitBoundSort(SB.MinMax(),e1,e2); HLRBRep_Hider Cache(myDS); - HLRBRep_EdgeData* ed = &(myDS->EDataArray().ChangeValue(1)); - HLRBRep_FaceData* fd = &(myDS->FDataArray().ChangeValue(1)); + HLRBRep_Array1OfEData& aEDataArray = myDS->EDataArray(); + HLRBRep_Array1OfFData& aFDataArray = myDS->FDataArray(); Standard_Integer ne = myDS->NbEdges(); Standard_Integer nf = myDS->NbFaces(); @@ -755,21 +750,21 @@ void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I, nbFSimp = 0; for (e = 1; e <= ne; e++) { - if (ed->Selected()) { + HLRBRep_EdgeData& ed = aEDataArray.ChangeValue(e); + if (ed.Selected()) { nbSelEdges++; - if (!ed->Status().AllHidden()) nbVisEdges++; + if (!ed.Status().AllHidden()) nbVisEdges++; } - ed++; } for (f = 1; f <= nf; f++) { - if (fd->Selected()) { + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + if (fd.Selected()) { nbSelFaces++; - if (fd->Hiding()) nbCache++; - if (fd->Side ()) nbFSide++; - if (fd->Simple()) nbFSimp++; + if (fd.Hiding()) nbCache++; + if (fd.Side ()) nbFSide++; + if (fd.Simple()) nbFSimp++; } - fd++; } if (myDebug) @@ -788,16 +783,19 @@ void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I, } } + if (nf == 0) + return; + Standard_Integer QWE=0,QWEQWE; QWEQWE=nf/10; if (SideFace) { j = 0; - fd = &(myDS->FDataArray().ChangeValue(1)); for (f = 1; f <= nf; f++) { - if (fd->Selected()) { - if (fd->Side()) { + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + if (fd.Selected()) { + if (fd.Side()) { if(TRACE10) { if(++QWE>QWEQWE) { QWE=0; @@ -814,7 +812,6 @@ void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I, Cache.OwnHiding(f); } } - fd++; } } @@ -825,20 +822,19 @@ void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I, TColStd_Array1OfInteger Index(1, nf); - fd = &(myDS->FDataArray().ChangeValue(1)); for (f = 1; f <= nf; f++) { - if(fd->Plane()) Val(f)=10; - else if(fd->Cylinder()) Val(f)=9; - else if(fd->Cone()) Val(f)=8; - else if(fd->Sphere()) Val(f)=7; - else if(fd->Torus()) Val(f)=6; + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + if (fd.Plane()) Val(f) = 10; + else if(fd.Cylinder()) Val(f)=9; + else if(fd.Cone()) Val(f)=8; + else if(fd.Sphere()) Val(f)=7; + else if(fd.Torus()) Val(f)=6; else Val(f)=0; - if(fd->Cut()) Val(f)-=10; - if(fd->Side()) Val(f)-=100; - if(fd->WithOutL()) Val(f)-=20; + if(fd.Cut()) Val(f)-=10; + if(fd.Side()) Val(f)-=100; + if(fd.WithOutL()) Val(f)-=20; - Size(f)=fd->Size(); - fd++; + Size(f)=fd.Size(); } for(Standard_Integer tt=1;tt<=nf;tt++) { @@ -913,14 +909,13 @@ void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I, } j = 0; - HLRBRep_Array1OfFData& FD = myDS->FDataArray(); QWE=0; for (f = 1; f <= nf; f++) { Standard_Integer fi = Index(f); - fd=&(FD.ChangeValue(fi)); - if (fd->Selected()) { - if (fd->Hiding()) { + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(fi); + if (fd.Selected()) { + if (fd.Hiding()) { if(TRACE10 && TRACE==Standard_False) { if(++QWE>QWEQWE) { if (myDebug) @@ -941,13 +936,12 @@ void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I, #ifdef OCCT_DEBUG if (myDebug) { - fd = &(myDS->FDataArray().ChangeValue(1)); nbFSimp = 0; for (f = 1; f <= nf; f++) { - if (fd->Selected() && fd->Simple()) + HLRBRep_FaceData& fd = aFDataArray.ChangeValue(f); + if (fd.Selected() && fd.Simple()) nbFSimp++; - fd++; } cout << "\n"; diff --git a/tests/bugs/modalg_6/bug25214 b/tests/bugs/modalg_6/bug25214 new file mode 100644 index 0000000000..ffe439cc99 --- /dev/null +++ b/tests/bugs/modalg_6/bug25214 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC25214" +puts "============" +puts "" +############################### +## HLR fails to project edges +############################### + +polyline Line 0 0 0 10 10 10 + +hprj Shape2DView_proj 0 0 0 0 0 1 1 0 0 +houtl Shape2DView_outl Line +hfill Shape2DView_outl Shape2DView_proj 0 +hload Shape2DView_outl +hsetprj Shape2DView_proj +hupdate +hhide +hres2d + +checknbshapes vl -edge 1 -m "HLRToShape" -- 2.39.5