Select to view content in your preferred language

Find the face with the largest area

307
4
Jump to solution
02-16-2025 06:00 PM
Labels (1)
biaozeng
Regular Contributor

After we extruded the shape, we split it. comp(f){front:fa}

I want to find the face of fa with the largest area

2 Solutions

Accepted Solutions
ThomasFuchs
Esri Regular Contributor

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. } }

 

largestFrontFace.gif

View solution in original post

biaozeng
Regular Contributor

How are the remaining faces selected

View solution in original post

0 Kudos
4 Replies
ThomasFuchs
Esri Regular Contributor

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. } }

 

largestFrontFace.gif

biaozeng
Regular Contributor

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.

0 Kudos
biaozeng
Regular Contributor

How are the remaining faces selected

0 Kudos
ThomasFuchs
Esri Regular Contributor

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. }

 

ThomasFuchs_0-1740129469465.png

0 Kudos