Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuselage lofting issues with guide curves #891

Open
joergbrech opened this issue Mar 30, 2022 · 0 comments
Open

fuselage lofting issues with guide curves #891

joergbrech opened this issue Mar 30, 2022 · 0 comments
Labels

Comments

@joergbrech
Copy link
Contributor

The lofting of a fuselage fails if

  • a segment contains guide curves, but none is located at relative circumference 0.
  • a segment contains a single guide curve.

This issue can be reproduced using the following test case: ColaGuideCurve.zip. Without any modifications, the test case should work (TiGL creates the expected fuselage loft). The fuselage consists of a single segment with guide curves at relative circumference 0 and 0.5. Commenting out either of the two guide curves will cause TiGL to not successfully create the loft and return the following error:

ERR 03/30 12:09:05 CTiglMakeLoft.cpp:229] Could not create loft with guide curves. Error code = 2

It seems like the error originates in src/contrib/MakeLoops.cxx.

Click for some first debugging insights.

Case 1: A segment contains guide curves, but none is located at relative circumference 0

This can be reproduced with the test case by commenting out or deleting the guide curve with uID Duct_9_upperGuideCurveSegment1. This leaves a single guide curve at relative circumference 0.5.

ERR 03/30 12:09:05 CTiglMakeLoft.cpp:229] Could not create loft with guide curves. Error code = 2

Debugging reveals that the source of the error lies in this piece of code:

bool foundStartingCorner = false;
for (i = 1; i <= GridVertices.Extent(); i++) {
Standard_Integer anExtent = GridVertices(i).Extent();
if (anExtent == MinExtent) {
// set current vertex as starting corner
StartCorner = TopoDS::Vertex(GridVertices.FindKey(i));
Standard_Boolean ForwardSectionFound = Standard_False;
Standard_Boolean ForwardGuideFound = Standard_False;
// iterate through all edges attached to the current grid vertex
TopTools_ListIteratorOfListOfShape iter(GridVertices(i));
for (; iter.More(); iter.Next()) {
const TopoDS_Edge& anEdge = TopoDS::Edge(iter.Value());
// get first vertex of the edge and check if it is the
// same as the current starting corner
TopoDS_Vertex aFirstVertex = TopExp::FirstVertex(anEdge, Standard_True);
if (aFirstVertex.IsSame(StartCorner)) {
// check if the edge is contained in the profiles
if (myProfileEdges.Contains(anEdge)) {
ForwardSectionFound = Standard_True;
}
// otherwise check if the edge is contained in the guides
else { //<anEdge> is in <myGuideEdges>
ForwardGuideFound = Standard_True;
}
}
}
// if the current vertex is attached to a guide and a profile edge,
// both starting at the vertex, it is considered to be the starting corner
if (ForwardSectionFound && ForwardGuideFound) {
foundStartingCorner = true;
break;
}
}
}
if (!foundStartingCorner) {
myStatus = MAKELOOPS_FAIL_STARTINGPOINT;
return;
}

TiGL searches the grid of profiles and guide curves for a starting corner, which is a vertex with minimum neighboring edges. At this vertex, TiGL finds a "ForwardSection", i.e. the fuselage profile, but no "ForwardGuide" (presumably because none is defined at relative circumference 0). As a consequence, MakeLoops returns with status MAKELOOPS_FAIL_STARTINGPOINT.

Case 2: A segment contains a single guide curve.

Case 1 is a special case of this one. This can be reproduced by commenting out either of the two guide curves Duct_9_upperGuideCurveSegment1 or Duct_9_lowerGuideCurveSegment1. Let's assume that we comment out the second guide curve and keep the guide curve Duct_9_upperGuideCurveSegment1 at relative circumference 0, as this reveals a different bug.

Debugging reveals that in the first pass of the while-loop starting in

while (true) {

the code will enter the true-branch of this if-clause:

if (NextCorner.IsSame(StartCorner)) {
StartCorner = NextStartCorner;
NextCorner = StartCorner;
if (IsFirstRow) {
RowLength = myCells.Extent();
IsFirstRow = Standard_False;
}
}
}

But at this time, NextStartCorner is null, so that for the second pass of the while-loop, both StartCorner and NextCorner are null as well. At the beginning of the second pass of the while-loop

// the four edges of the patch
TopoDS_Edge E1, E2, E3, E4;
// set current starting corner as the NextCorner from the previous iteration
TopoDS_Vertex Corner = NextCorner;

Corner will be null, so that we never enter the true-branch of

if (GridVertices.Contains(Corner)) {
iter.Initialize(GridVertices.FindFromKey(Corner));
for (; iter.More(); iter.Next()) {
const TopoDS_Edge& anEdge = TopoDS::Edge(iter.Value());
if (myProfileEdges.Contains(anEdge)) {
TopoDS_Vertex aFirstVertex = TopExp::FirstVertex(anEdge, Standard_True);
if (aFirstVertex.IsSame(Corner)) {
E1 = anEdge;
// save current vertex
// however, since the orientation may have changed, get the object from the
// gritVertices map (here, the Contains function seems to be orientation insensitive)
vertex41 = TopoDS::Vertex(GridVertices.FindKey(GridVertices.FindIndex(Corner)));
break;
}
}
}
}

and therefore E1 will remain null. Finally, this causes MakeLoops to fail here:

if (E1.IsNull()) {
if (NextStartCorner.IsNull()) {
myStatus = MAKELOOPS_FAIL_FIRSTEDGE;
break;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant