Calculate true face area of faces made of arcs and lines


#1

I have a face that was created using both arcs and lines.
I want to select the face and calculate its true area: NOT the area within the line and arc segments.
How can I find which arcs make up part of the face?


#2

I think I figured it out.
Sequence is: I select face1:

Face.outer_loop
Loop.edges
then for each edge: Edge.curve
for each arc edge: calculate area above chord.
for each straight edge add to list of straight edges to create temp face2. Calculate area of that.
for each arc use Face.classify_point to see if midpoint of chord is on face1.
If yes, arc is convex so add to area,
if not, arc is concave so subtract from area.

Done. Any comments?


#3

I won’t do the area calculation for you, I’ll assume you know how to do that since that isn’t what you asked. So here’s how to analyze the perimeter of the Face:

  • use Face#edges to get the Array of Edges bounding the Face
  • for each Edge, use Edge#curve to find out if it belongs to a Curve or ArcCurve (nil is returned if not)
  • if it belongs to an ArcCurve, you can use ArcCurve methods to get its theoretical geometry for your calculation
  • you cull the rest of the ArcCurve’s Edges from the Array and continue.
  • if the Edge belongs to a Curve that is not an ArcCurve, you must handle it as a polyline

#4

We crossed messages! Your outline is very similar to mine, though if you simply accumulate the non-curve edges, you will end up with a discontinuous line that does not bound a Face! You need to close it by drawing the chord across the base of each ArcCurve.


#5

Yes I understand.
The api documentation implies that I need to use
Face.outer_loop then Loop.edges to get edges in proper sequence.


#6

probably true (pad to >20 chars)


#7

Yes - Loops return edges in order. Though for area calculation you also need to take into account possible inner loops as well.