Archived issue #0032926
Coding, StdPrs_ToolTriangulatedShape::Normal() - range of "for" not correspond to the NCollection index which run in "for"
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)
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);
}
/*
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.
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.
[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.
Patch removing this obsolete method is ready for review
- OCCT: branch CR32926;
- OCC Products: branch CR32926.
http://jenkins-test-occt/view/CR32926-master-KGV/
- OCCT: branch CR32926;
- OCC Products: branch CR32926.
http://jenkins-test-occt/view/CR32926-master-KGV/
It would be worth to provide information about it in upgrade guide.
Branch [archived branch] has been updated forcibly by Commenter 2.
[revision removed]
[revision removed]
For integration:
occt - CR32926
products - CR32926
occt - CR32926
products - CR32926
Branch [archived branch] has been updated forcibly by Commenter 2.
[revision removed]
[revision removed]
Branch [archived branch] has been updated forcibly by Commenter 2.
[revision removed]
[revision removed]
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
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
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]