Archived issue #0032926

Coding, StdPrs_ToolTriangulatedShape::Normal() - range of "for" not correspond to the NCollection index which run in "for"

CommunityOCCT:Codingclosed10 public notes

Search issues

Description

void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace,
                                           Poly_Connect& thePolyConnect,
                                           TColgp_Array1OfDir& theNormals)
{
  const Handle(Poly_Triangulation)& aPolyTri = thePolyConnect.Triangulation();
  if (!aPolyTri->HasNormals())
  {
    ComputeNormals (theFace, aPolyTri, thePolyConnect);
  }

  gp_Vec3f aNormal;
** for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
  {
** aPolyTri->Normal (aNodeIter, aNormal);
    theNormals.ChangeValue (aNodeIter).SetCoord (aNormal.x(), aNormal.y(), aNormal.z());
  }

  if (theFace.Orientation() == TopAbs_REVERSED)
  {
** for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
    {
** theNormals.ChangeValue (aNodeIter).Reverse();
    }
  }
}

code crash at line start with *
thr "for" take range between (1,aPolyTri->NbNodes())
but inside "for", theNormals,ChangeValue take range between (0,aPolyTri->NbNodes()-1)

Steps to reproduce

TopoDs_Shape currentShape;
/*
do somethine to initialize shape to a solid shell
*/
TopoDS_Face myFace = TopoDS::Face(currentShape);
TopLoc_Location aLocation;
Handle(Poly_Triangulation) myT = BRep_Tool::Triangulation(myFace, aLocation);

if (!myT.IsNull()) {
    Poly_Connect pc(myT);
    const Poly_ArrayOfNodes& Nodes= myT->InternalNodes();
        TColgp_Array1OfDir myNormal(Nodes.Lower(), Nodes.Upper());
    SST.Normal(myFace, pc, myNormal);
}

Public activity

10 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Branch [archived branch] has been created by Commenter 2.

[revision removed]


Detailed log of new commits:

Author: Commenter 2
Date: Sat Apr 9 15:04:23 2022 +0300

    0032926: Coding, StdPrs_ToolTriangulatedShape::Normal() - range of "for" not correspond to the NCollection index which run in "for"
    
    Obsolete method has been removed.
02Commenter 2
Patch removing this obsolete method is ready for review
- OCCT: branch CR32926;
- OCC Products: branch CR32926.

http://jenkins-test-occt/view/CR32926-master-KGV/
03Commenter 3
It would be worth to provide information about it in upgrade guide.
04Commenter 1
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
05Commenter 2
Commenter 3, added section to Upgrade Guide.
06Commenter 6
For integration:
occt - CR32926
products - CR32926
07Commenter 1
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
08Commenter 1
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
09Commenter 9
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18524.440000000686 / 18453.560000000383 [+0.38%]
Products
Total CPU difference: 11765.190000000111 / 11767.510000000153 [-0.02%]
Windows-64-VC14:
OCCT
Total CPU difference: 20542.0625 / 20540.40625 [+0.01%]
Products
Total CPU difference: 13266.890625 / 13255.140625 [+0.09%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
10Commenter 1
Branch [archived branch] has been deleted by Participant.

[revision removed]