DiscussionsIssue archiveModeling Data and Algorithms

Archived discussion

Exception Unhandled: using NCollection_BaseVector

Modeling Data and AlgorithmsTue, 05/02/2023 - 17:471 reply

Browse this forum
QuestionAuthor

I'm working on triangles to quads in occ at the moment, I am getting this error:

Unhandled exception at 0x00007FF9217AFDEC in quad-remeshing.exe: Microsoft C++ exception: Standard_OutOfRange at memory location 0x000000AC3AF3F700.

pointing to the line:

Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex >= myLength,
                                  "NCollection_BaseVector::findV");

after using this iterator

for (NCollection_Vector<Poly_CoherentLink>::Iterator anIterL(myLinks); anIterL.More(); anIterL.Next())

,it should be noted that this manages to cycle through a decent amount of iterations before breaking my base class, which i have named BRepMesh_PolyRemesh to atempt to keep with OCC naming convetions, inherits from the Poly_CoherentTriangulation class, its initialiser iterates through the brep's faces and adds all the mesh elements to one coherent mesh, then calls the calculate links function:

if (aFaceTriangulation.IsNull() == Standard_False) {
            const Standard_Integer nNodes = aFaceTriangulation->NbNodes();
            Standard_Integer i;

            // Copy the nodes
            for (i = 0; i < nNodes; i++) {
                this->SetNode(aFaceTriangulation->Node(i+1).XYZ()/*, i + aPreviousNodeCount*/);
                aNextNodeCount++;
            }

            // Copy the triangles
            for (i = 1; i <= aFaceTriangulation->NbTriangles(); i++) {
                Standard_Integer iNode[3];
                aFaceTriangulation->Triangle(i).Get(iNode[0], iNode[1], iNode[2]);
                if (iNode[0] != iNode[1] && iNode[1] != iNode[2] && iNode[2] != iNode[0]) 
                {
                    if(aOrientation == TopAbs_REVERSED)
                        AddTriangle(iNode[0] - 1 + aPreviousNodeCount, iNode[2] - 1 + aPreviousNodeCount, iNode[1] - 1 + aPreviousNodeCount);
                    else
                        AddTriangle(iNode[0] - 1 + aPreviousNodeCount, iNode[1] - 1 + aPreviousNodeCount, iNode[2] - 1 + aPreviousNodeCount);
                }
            }
aPreviousNodeCount += aNextNodeCount;
}
ComputeLinks();

is this issue likely to do with how the memory is reserved by the function : this->SetNode(aFaceTriangulation->Node(i+1).XYZ()); or something else?

Discussion

1 archived reply

Posts are displayed in their archived order.

01Commenter-1

This error says about an attempt to read from vector with index that is out of valid range for that vector. It is not obvious from the information you gave where to look at. It is needed to analyze the code under debugger.