PolygonInitializer Steppable

PolygonInitializer is used to lay out any shape of cells you like on the lattice.

Example Syntax: 2D Equilateral Triangle

<Steppable Type="PolygonInitializer">
   <Region>
      <Gap>0</Gap>
      <Width>4</Width>
      <Types>Condensing,NonCondensing</Types>
      <EdgeList>
         <Edge>
            <From x="50" y="60" />
            <To x="20" y="10" />
         </Edge>
         <Edge>
            <From x="20" y="10" />
            <To x="80" y="10" />
         </Edge>
         <Edge>
            <From x="80" y="10" />
            <To x="50" y="60" />
         </Edge>
      </EdgeList>
   </Region>
</Steppable>

The vertices are specified by a group called EdgeList. Each Edge connects exactly one From tag and one To tag, creating a line in 2D space. Notice that each coordinate is listed twice to make it clear which are connected. CompuCell assumes that your shape is fully connected. If your shape is missing or incorrect, check your coordinates!

Note

From and To tags in PolygonInitializer do not support z-coordinates.

Warning

Known Bug: Shapes generated by PolygonInitializer may be missing some cells, most often near the vertices. If you encounter this, adjust your From and To points to make your shape slightly larger near the missing area.

3D Hexagon

Add a tag inside Region to extrude the shape along the z-axis: <Extrude zMin=”0” zMax=”100” />

Full example:

<Steppable Type="PolygonInitializer">
   <Region>
      <Gap>0</Gap>
      <Width>4</Width>
      <Types>Condensing,NonCondensing</Types>
      <Extrude zMin="0" zMax="100" />
      <EdgeList>
         <Edge>
            <From x="70" y="46" />
            <To x="60" y="67.32" />
         </Edge>
         <Edge>
            <From x="60" y="67.32" />
            <To x="40" y="67.32" />
         </Edge>
         <Edge>
            <From x="40" y="67.32" />
            <To x="30" y="46" />
         </Edge>
         <Edge>
            <From x="30" y="46" />
            <To x="40" y="32.68" />
         </Edge>
         <Edge>
            <From x="40" y="32.68" />
            <To x="60" y="32.68" />
         </Edge>
         <Edge>
            <From x="60" y="32.68" />
            <To x="70" y="46" />
         </Edge>
      </EdgeList>
   </Region>
</Steppable>
images/polygoninit_3Dhexagon.png

Tip for Generating Hexagons

You may like to use Python to generate your coordinates, then write them into XML manually. Here is an example of a script that can be used to print hexagon coordinates:

from math import pi, cos, sin

center_x = 50
center_y = 50
radius = 20

for i in range(6):
    x_val = (center_x + radius * cos(i * 2 * pi / 6.0))
    y_val = (center_y + radius * sin(i * 2 * pi / 6.0))
    print(x_val, y_val)