It can be necessary to obtain points of the outer contour (or other components for working with a specific loop) of a multi-polygon, but it is unknown at what index this loop is stored in the multi-polygon. The following function allows you to determine the position (depth) of a loop in a multi-polygon.
virtual int getParentLoop(int curLoop) const
The function receives the loop index as a parameter and returns:
The following figure shows a simple multi-polygon composed of two loops.
To determine the order of loops for the above multi-polygon:
getParentLoop(0)
.getParentLoop()
as a parameter. The next figure shows a multi-polygon with four loops. The loop numbers are shown in red.
The table below shows the correlation between input and output values of
getParentLoop()
for the multi-polygon in the figure.
Input value | Return value |
---|---|
0 | -1 |
1 | 0 |
2 | 0 |
3 | 1 |
If the current loop has an intersection with the parent loop, the parent of
the parent loop is returned (if it exists). In the table above, getParentLoop()
returns "0" as the parent loop for the loop
number 2 because the number 2 and 1 loops intersect each other.
For loop number 3, it is also impossible to correctly determine the parent loop, since the parent loop has an intersection with the parent-parent loop.
In the following figure there are only two loops that intersect each other
and no more outer loops without intersections. For the number 0 and 1 loops,
getParentLoop()
returns "-3", which means the specified loop
intersects with a possible outer loop.
Working with Multi-Polygon Loops
Multi-Polygon Nesting Tree of Nodes
Examples of Working with Multi-Polygons
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|