<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Split face into rectangular pieces in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1259798#M10892</link>
    <description>&lt;P&gt;Oh, what a pitty. And there is no way to align the scope such that it can work?&lt;BR /&gt;&lt;BR /&gt;I read about innerRectangle but don't see how it can be used to solve the example in the first post. Can you?&lt;/P&gt;</description>
    <pubDate>Mon, 20 Feb 2023 11:19:45 GMT</pubDate>
    <dc:creator>MagnusLundevall</dc:creator>
    <dc:date>2023-02-20T11:19:45Z</dc:date>
    <item>
      <title>Split face into rectangular pieces</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1256992#M10873</link>
      <description>&lt;P&gt;I have a planar face that I want to split along x into rectangular pieces, see enclosed figure. I have tried to examine the pivot pos of the edges with comp(fe) to find the x-positions for the split but without full success.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any suggestions for solution in CGA code? Is the question clear enough?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 14:34:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1256992#M10873</guid>
      <dc:creator>MagnusLundevall</dc:creator>
      <dc:date>2023-02-10T14:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Split face into rectangular pieces</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1257567#M10875</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/652629"&gt;@MagnusLundevall&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this interesting question. Please try this approach using &lt;EM&gt;comp(v)&lt;/EM&gt; and sorting the vertices by their&amp;nbsp;&lt;EM&gt;pivot.px&lt;/EM&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;version "2022.1"

XPos = comp(v) { all : pivot.px }

SortedXPos = 
	XPos[sortIndices(XPos)]

const EPS = 0.01
calcNextVertexLoc(positions, i) =
	case i &amp;lt; geometry.nVertices:
		case abs(positions[i] - positions[0]) &amp;lt; EPS: calcNextVertexLoc(positions, i+1) // check next vertex position
		else: positions[i] - positions[0]
	else: scope.sx
	
getSplitPos =
	calcNextVertexLoc(SortedXPos, 2)

@StartRule
SplitRecursive --&amp;gt;
	split(x) { getSplitPos : Rectangle | ~1 : SplitRecursive }
	
Rectangle --&amp;gt; color(rand, rand, rand)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 16:23:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1257567#M10875</guid>
      <dc:creator>ThomasFuchs</dc:creator>
      <dc:date>2023-02-13T16:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Split face into rectangular pieces</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1258019#M10882</link>
      <description>&lt;P&gt;Thanks for quick response. This is along the lines I have tried but much more elegant. It works in general but not for faces in certain orientations. I suspect I need to align the scope in some way. Any advice here?&lt;BR /&gt;&lt;BR /&gt;To isolate the orientation problem I have made a simple shape&amp;nbsp;where I try to apply SplitRecursive for each side face. Seems not possible to attach a scene here so I give the shape vertices instead. I have tried various kind of alignScope but without success.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MagnusLundevall_0-1676440871742.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62896i3338DA99E2BFFE21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MagnusLundevall_0-1676440871742.png" alt="MagnusLundevall_0-1676440871742.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;@StartRule
Init --&amp;gt;
	comp(f) {side: SplitRecursive | all: NIL} &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the current result. In this simple example I expect one Rectangle for each face.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MagnusLundevall_1-1676441020181.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62897i76EB7731DBFE801C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MagnusLundevall_1-1676441020181.png" alt="MagnusLundevall_1-1676441020181.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 06:36:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1258019#M10882</guid>
      <dc:creator>MagnusLundevall</dc:creator>
      <dc:date>2023-02-16T06:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Split face into rectangular pieces</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1258872#M10887</link>
      <description>&lt;P&gt;The approach only works for horizontal and planar Shapes like building footprints. The axis of pivot and scope must be aligned.&lt;/P&gt;&lt;P&gt;Generally, rectangles can be created with the &lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-inner-rectangle.htm" target="_blank" rel="noopener"&gt;innerRectangle&lt;/A&gt; operation.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 14:12:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1258872#M10887</guid>
      <dc:creator>ThomasFuchs</dc:creator>
      <dc:date>2023-02-16T14:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Split face into rectangular pieces</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1259798#M10892</link>
      <description>&lt;P&gt;Oh, what a pitty. And there is no way to align the scope such that it can work?&lt;BR /&gt;&lt;BR /&gt;I read about innerRectangle but don't see how it can be used to solve the example in the first post. Can you?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 11:19:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/split-face-into-rectangular-pieces/m-p/1259798#M10892</guid>
      <dc:creator>MagnusLundevall</dc:creator>
      <dc:date>2023-02-20T11:19:45Z</dc:date>
    </item>
  </channel>
</rss>

