After we extruded the shape, we split it. comp(f){front:fa}
I want to find the face of fa with the largest area
Solved! Go to Solution.
Hello @biaozeng
Thank you for this interesting question!
Here are some CGA helper functions that will give you the index of the face with the largest area:
version "2024.1"
sizes = comp(f){ all : geometry.area() }
indices = sortIndices(sizes)
largestIndex = indices[size(indices)-1]
@StartRule // Apply on a shape with multiple front faces
Generate -->
comp(f) { front = comp(f) { largestIndex : color(1,0,1) fa. } }
How are the remaining faces selected
Hello @biaozeng
Thank you for this interesting question!
Here are some CGA helper functions that will give you the index of the face with the largest area:
version "2024.1"
sizes = comp(f){ all : geometry.area() }
indices = sortIndices(sizes)
largestIndex = indices[size(indices)-1]
@StartRule // Apply on a shape with multiple front faces
Generate -->
comp(f) { front = comp(f) { largestIndex : color(1,0,1) fa. } }
Great answer, I would also like to know if they can be sorted by the position of each face in space, for example by the x-direction of world coordinates, or by the X-axis of scope; For example I want to find the most prominent aspect of the shape in your picture.
How are the remaining faces selected
You can rewrite the rule to get a sequence of the largest faces like that:
Generate --> comp(f) { front = fa1 }
fa1 --> comp(f) { largestIndex : color(1,0,1) fa1. | all = fa2 }
fa2 --> comp(f) { largestIndex : color(1,1,0) fa2. | all = fa3 }
fa3 --> comp(f) { largestIndex : color(0,1,1) fa3. | all : faRemaining. }