Archived discussion

Please look at the code. The error continues.

VisualizationFri, 11/01/2024 - 08:115 replies

Browse this forum
QuestionAuthor

An exception occurs and I don't understand why.
All values ​​are entered, but an exception error occurs when the 581st for loop is executed. Please help.

for (int i = 1; i <= triangles.Length(); i++)
{
try
{
Poly_Triangle triangle = triangles.Value(i);

int n1 = 0, n2 = 0, n3 = 0;

triangle.Get(n1, n2, n3);

if (reversed)
{
int tmp = n1;
n1 = n2;
n2 = tmp;
}

gp_Pnt p1 = tri.Node(n1);
gp_Pnt p2 = tri.Node(n2);
gp_Pnt p3 = tri.Node(n3);

//Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(p1, p2);
//Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(p2, p3);
//Handle(Geom_TrimmedCurve) aSegment3 = GC_MakeSegment(p3, p1);

TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(p1, p2);
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(p2, p3);
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(p3, p1);

TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge1, anEdge2, anEdge3);

Handle(AIS_Shape) aShape = new AIS_Shape(aWire);
myAISContext()->Display(aShape, AIS_WireFrame, 0, true);
}

catch (const std::exception& ex)
{
std::cout << ex.what() << std::endl;
}

myView()->FitAll(0.1);
}

Discussion

5 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hello, could you share more details? What type of exception? On which line? Do you try OCCT debug version to check stack? Which OCCT version?

Best regards, Commenter-1.

02Author

The version is 7.8
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(p2, p3);
An error occurred at number 583, and proceeded to debug mode.

throw.cpp

RaiseException(EH_EXCEPTION_NUMBER, EXCEPTION_NONCONTINUABLE, _countof(parameters), parameters);

System.Runtime.InteropServices.SEHException: '외부 구성 요소에서 예외를 Throw했습니다.'

03Commenter-1

I suppose there issue with gp_Dir and (0 0 0) vector or similar mathematic issue. But could you share the value for P2 and P3 at this iteration?

04Author

I didn't understand the answer. However, there is a file with the error below. I need to change it to a triangle mesh and save it as igs, but an error occurs during the loop. Sorry for being a beginner.
Could you please write some example code?

05Commenter-1

 

There was no answer. I will need to know the value of the variables before crash. Could you share the variables (points) value on crash iteration?

581ss or 583 iteration. I need to know the values of (just in format X1 Y1 Z1 and X2 Y2 Z2)

gp_Pnt p2 = tri.Node(n2);
gp_Pnt p3 = tri.Node(n3);

In my prev message I just share the possible issue in case if points are similar and it is not possible to create an edge with them.

_

Additionally, if you trying to create a triagnles as a wire, you can use "BRepLib_MakePolygon" class.

Best regards, Commenter-1.