Package org.bzdev.p3d

Class SteppedGrid

java.lang.Object
org.bzdev.p3d.SteppedGrid
All Implemented Interfaces:
Shape3D

public class SteppedGrid extends Object implements Shape3D
Stepped Grid Class. An open stepped grid consists of an n by m grid of horizontal rectangles whose vertices, when projected onto the X-Y plane, have the values (xs[i],ys[i]) where xs and ys are one-dimensional arrays. A grid consists of one or two layers, and each layer has a base height zbase and each rectangle's height is specified by an offset from the base height. These rectangles are called components and have an index (i,j) such that their diagonals connect the vertices (xs[i], ys[i], z) and (xs[i+1], ys[i+1], z). The maximum index (in the X or Y direction, and exclusive) is one less than the size of the arrays xs and ys respectively.

A closed step grid consists of two layers, an upper layer and a lower layer. Their outwards-facing sides point in opposite directions and they are connected to form a closed 2 dimensional manifold. Stepped grids are either open or closed.

The indices (i,j), where i ∈ [0, xs.length-2] and j ∈ [0, ys.length-2], specify components. A component has a height, can be filled, and if filled, can be a placeholder. When a rectangle is a placeholder, it is not filled, and it is assumed that the caller will attach another surface in its place. Rectangular components are treated as follows:

  • A unfilled component is ignored.
  • A filled component that is not a placeholder will contain a horizontal, rectangular, plane surface.
  • A filled component that is a placeholder does not provide a a horizontal, rectangular, plane surface. Instead, whatever surface is desired must be provided by the caller.
  • For the upper and lower layers separately, when a filled rectangular component that is not a placeholder is adjacent to filled component, meeting at two parallel edges, a vertical rectangular surface will attach these two horizontal rectangles. Vertical rectangles will similarly join pairs of horizontal components at edges for which there is no adjacent filled component. A vertical surface will often contain multiple rectangles, as shown in the following example (the triangles making up the model are shown as green lines):

    Surface example

    If the Z components of all of the horizontal rectangles are sorted, each vertical rectangle will have a lower edge at one Z coordinate in this sorted list and an upper edge at the next highest Z coordinate. While this results in more rectangles than are actually necessary, it trivially ensures that all triangles will meet at vertices, a requirement that a printable model must satisfy.

    This class also supports half rectangles. A half rectangle will treat one half of the rectangle as filled, and the other half as either unfilled or a placeholder. The halves are separated by a diagonal edge. The filled part of a half rectangle is the half that has two edges, one vertical and one horizontal, in common with adjacent filled components. The other components that share this vertex must be filled components. The opposite vertex (the one at the opposite end of the diagonal passing through this vertex) must have adjacent components that either are not filled or are placeholders.

    For a closed grid using half rectangles for the upper and lower layers at a given set of indices (i, j),

    • if neither half rectangle is a placeholder, a vertical rectangle will connect matching diagonals. The vertices for these diagonals will be the ends of horizontal and vertical edges for adjacent filled rectangles.
    • If both half rectangles are placeholders, there will be vertical rectangles attaching those edges adjacent to unfilled rectangles.
    • If one half rectangle is a placeholder and the other half rectangle is not, there will be vertical rectangles attaching those edges adjacent to unfilled rectangles. For the placeholder, half of the rectangle will be left out and the other, which is not a placeholder, will be filled as if it was a simple rectangle.
    Finally, components are added to open grids by calling the methods addComponent(int, int, double), addHalfComponent(int,int,double), addComponent(int,int,double,boolean), or addHalfComponent(int,int,double,boolean). Components are added to closed grids by calling addComponent(int,int,double,double), addHalfComponent(int,int,double,double), addComponent(int,int,double,double,boolean,boolean), or addHalfComponent(int,int,double,double,boolean,boolean)

    Using placeholder

    Placeholders are meaningful for closed stepped grids, not open step grids - for open step grids, the shape created is the same regardless of whether a component is a placeholder or not provided. When a placeholder is provided for a closed grid, one will need to to extend the model to make it a closed 2D manifold for 3D printing. The attachment edges can be found easily because the SteppedGrid class implements the Shape3D interface, and that interface includes a method for computing the boundary of a shape.

    The algorithm used to find the boundary of a stepped grid is to first "flatten" the layers by setting the heights above the base Z value to 0, and finding the boundary of this object, which will only include horizontal lines (ones where Z is the same at the ends). The actual boundary is then computed by setting the edges to the correct Z values (e.g., the one defined by a placeholder) and connecting the edges with vertical segments. Frequently there will be multiple vertical segments adjacent to each other so that an existing vertex does not appear in the middle of a segment.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Build a SteppedGrid specified by a set of rectangles and half rectangles.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SteppedGrid(Model3DOps<?> m3d, double[] xs, double[] ys, double z, boolean isUpper)
    Constructor for an open stepped grid.
    SteppedGrid(Model3DOps<?> m3d, double[] xs, double[] ys, double zUpper, double zLower)
    Constructor for a closed stepped grid.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addComponent(int i, int j, double height)
    Add a component to an open stepped grid.
    void
    addComponent(int i, int j, double height, boolean placeholder)
    Add a component to an open stepped grid, specifying if the component is a placeholder.
    void
    addComponent(int i, int j, double upperHeight, double lowerHeight)
    Add two components to a grid.
    void
    addComponent(int i, int j, double upperHeight, double lowerHeight, boolean upperIsPlaceholder, boolean lowerIsPlaceholder)
    Add two components to a grid, specifying if the components are placeholders.
    void
    addHalfComponent(int i, int j, double height)
    Add a half component to an open stepped grid.
    void
    addHalfComponent(int i, int j, double height, boolean placeholder)
    Add a half component to an open stepped grid, specifying if the component is a placeholder.
    void
    addHalfComponent(int i, int j, double upperHeight, double lowerHeight)
    Add two half components to a grid.
    void
    addHalfComponent(int i, int j, double upperHeight, double lowerHeight, boolean upperIsPlaceholder, boolean lowerIsPlaceholder)
    Add two half components to a grid, specifying if the components are placeholders.
    void
    Indicate that all components have been added and add this object to its model.
    int
    Get the number of X indices for this grid's components.
    int
    Get the number of X indices for this grid's components.
    Get the boundary for this Shape3D.
    Get a bounding rectangular cuboid for a 3D shape.
    getComponent(int i)
    Get a component of this shape.
    double
    Get the maximum spacing between vertices in the Z direction.
    Get a surface iterator for this Shape3D.
    getSurfaceIterator(Transform3D tform, int level)
    Get a surface iterator for this Shape3D, subdividing the surface.
    double
    getX(int i)
    Get the X value of the vertex of the lower or upper grid with a specified index
    double
    getY(int j)
    Get the Y value of the vertex of the lower or upper grid with a specified index
    double
    getZ(int i, int j, boolean isUpper)
    Get the Z value of the vertex of the lower or upper grid with specified indices (i, j).
    double[]
    getZs(int i, int j)
    Get the Z values for all vertices associated with an ordered pair of indices (i, j) for the upper and lower grids.
    double[]
    getZs(int i, int j, boolean isUpper)
    Get the Z values for all vertices associated with an ordered pair of indices (i, j) for the upper or lower grid.
    int
    Get the number of X indices for this grid.
    int
    Get the number of Y indices for this grid.
    boolean
    Determine if a stepped grid has a lower grid.
    boolean
    Determine if this stepped grid has a maximum spacing in the Z direction.
    boolean
    Determine if a stepped grid has an upper grid.
    boolean
    Determine if this Shape3D is a closed two-dimensional manifold.
    boolean
    isComponentFilled(int i, int j, boolean isUpper)
    Determine if a component of a stepped grid is filled.
    boolean
    isComponentPlaceholder(int i, int j, boolean isUpper)
    Determine if a component of a stepped grid is a placeholder.
    boolean
    Determine if a surface is oriented.
    int
    Get the number of components for this shape.
    void
    setMaxZSpacing(double spacing)
    Set the maximum spacing between vertices in the Z direction.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.bzdev.geom.Shape3D

    getBoundary
  • Constructor Details

    • SteppedGrid

      public SteppedGrid(Model3DOps<?> m3d, double[] xs, double[] ys, double z, boolean isUpper)
      Constructor for an open stepped grid.

      The surface consists of a number of horizontal rectangles, connected by vertical rectangles. Heights specified for individual components are relative to the grid's base height.

      Parameters:
      m3d - the model to which the grid will be added
      xs - the X coordinates for the grid
      ys - the Y coordinates for the grid
      z - the base height for the grid
      isUpper - true if the outside direction faces up; false if the outside direction faces down
      See Also:
    • SteppedGrid

      public SteppedGrid(Model3DOps<?> m3d, double[] xs, double[] ys, double zUpper, double zLower)
      Constructor for a closed stepped grid.

      The surface consists of two connected open stepped grids, one facing in the positive Z direction and the other in the negative Z direction. These open grids are connected by vertical rectangles.

      Parameters:
      m3d - the model to which the grid will be added
      xs - the X coordinates for the grid
      ys - the Y coordinates for the grid
      zUpper - the base height for the open grid oriented so its outside faces up
      zLower - the base height for the open grid oriented so its outside faces down
      See Also:
  • Method Details

    • getBoundary

      public Path3D getBoundary()
      Get the boundary for this Shape3D. For a closed surface, the boundary will be an empty path.

      Typically, a boundary will consist of a series of distinct closed subpaths. Subpaths are separated by segments whose type is {link PathIterator3D#SEG_MOVETO}. For a closed manifold, the boundary will be an empty path.

      A stepped grid can be printed, but may not be a two-dimensional manifold: if the lower left and upper right components at a point on the grid are at a different height than the upper left and lower right components, four surfaces will be joined along a single line. As a result, a boundary has to be computed using class-specific information. There are two cases.

      • For an open stepped grid, the horizontal line segments for a boundary are the edges between adjacent components, one of which is filled and not a placeholder, and the other of which is either not filled or is both filled and a placeholder. The height of this horizontal line is the height of the placeholder component, if there is one, and otherwise the height of the filled component. A half component is assumed to consist of filled component that is not a placeholder and a second half the is either unfilled or a placeholder. In both cases, the heights are identical—the height of the component and the horizontal components of the line lie along a diagonal.
      • For a closed stepped grid, the horizontal line segments are at the boundary between a filled placeholder component and a filled component that is not a placeholder. For half components, which must be a placeholder, this line lies along the diagonal at the height specified for that component.
      These horizontal components are connected by sequences of vertical line segments, with each segment terminating at the vertex of a triangle.
      Specified by:
      getBoundary in interface Shape3D
      Returns:
      the boundary of this surface; null if a boundary cannot be computed
      See Also:
    • getBounds

      public Rectangle3D getBounds()
      Description copied from interface: Shape3D
      Get a bounding rectangular cuboid for a 3D shape. The edges will be aligned with the X, Y and Z axes. The cuboid created may not be the smallest one possible (for example, shapes defined by Bézier surfaces may just use the control points to determine the cuboid as the convex hull for the control points includes all of the surface for parameters in the normal range [0,1]).
      Specified by:
      getBounds in interface Shape3D
      Returns:
      a bounding rectangular cuboid for this Shape3D; null if the shape does not contain any points
    • getSurfaceIterator

      public SurfaceIterator getSurfaceIterator(Transform3D tform)
      Description copied from interface: Shape3D
      Get a surface iterator for this Shape3D. The surface iterator will represent the shape as a sequence of Bézier patches and Bézier triangles, with the order of the sequence arbitrary.

      Unless the transform is an affine transform, the transformation is not exact. In this case, the patches and triangles that constitute the surface should be small enough that the transform can be approximated by an affine transform over the region containing the control points.

      Specified by:
      getSurfaceIterator in interface Shape3D
      Parameters:
      tform - a transform to apply to each control point; null for the identity transform
      Returns:
      a surface iterator
    • getSurfaceIterator

      public SurfaceIterator getSurfaceIterator(Transform3D tform, int level)
      Description copied from interface: Shape3D
      Get a surface iterator for this Shape3D, subdividing the surface. The surface iterator will represent the shape as a sequence of Bézier patches and Bézier triangles, with the order of the sequence arbitrary.

      Unless the transform is an affine transform, the transformation is not exact. In this case, the patches and triangles that constitute the surface after each is subdivided should be small enough that the transform can be approximated by an affine transform over the region containing the control points.

      Specified by:
      getSurfaceIterator in interface Shape3D
      Parameters:
      tform - a transform to apply to each control point; null for the identity transform
      level - the number of levels of partitioning (each additional level splits the previous level into quarters)
      Returns:
      a surface iterator
    • isClosedManifold

      public boolean isClosedManifold()
      Description copied from interface: Shape3D
      Determine if this Shape3D is a closed two-dimensional manifold.
      Specified by:
      isClosedManifold in interface Shape3D
      Returns:
      true if the surface is a closed two-dimensional manifold; false otherwise
    • isOriented

      public boolean isOriented()
      Description copied from interface: Shape3D
      Determine if a surface is oriented.
      Specified by:
      isOriented in interface Shape3D
      Returns:
      true if the surface has an orientation; false if it does not
    • numberOfComponents

      public int numberOfComponents()
      Description copied from interface: Shape3D
      Get the number of components for this shape. Components are connected shapes - surfaces for which every point can connect to any other point.
      Specified by:
      numberOfComponents in interface Shape3D
      Returns:
      the number of components for this shape
    • getComponent

      public Shape3D getComponent(int i)
      Description copied from interface: Shape3D
      Get a component of this shape. Components are connected shapes - surfaces for which every point can connect to any other point. The components are referenced by an index, specified as an integer in the range [0,n), where n is the number of manifold components. If n is zero, no index is valid.
      Specified by:
      getComponent in interface Shape3D
      Parameters:
      i - the component's index
      Returns:
      a model containing the specified component
      See Also:
    • gridDimX

      public int gridDimX()
      Get the number of X indices for this grid. The indices's values are in the interval [0, n) where n is the value returned by this method.
      Returns:
      the number of X indices
    • gridDimY

      public int gridDimY()
      Get the number of Y indices for this grid. The indices's values are in the interval [0, n) where n is the value returned by this method.
      Returns:
      the number of Y indices
    • compDimX

      public int compDimX()
      Get the number of X indices for this grid's components. The indices's values are in the interval [0, n) where n is the value returned by this method.
      Returns:
      the number of X indices
    • compDimY

      public int compDimY()
      Get the number of X indices for this grid's components. The indices's values are in the interval [0, n) where n is the value returned by this method.
      Returns:
      the number of X indices
    • addComponent

      public void addComponent(int i, int j, double height) throws IllegalStateException, IllegalArgumentException
      Add a component to an open stepped grid. The component describes a horizontal rectangle whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices at (xs[i], ys[j]) and (xs[i+1], ys[j+1]), where xs and ys are the arrays passed to the constructor.
      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      height - the relative height for the component added to the grid
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is a closed grid
      IllegalArgumentException - the indices were out of range
    • addHalfComponent

      public void addHalfComponent(int i, int j, double height) throws IllegalStateException, IllegalArgumentException
      Add a half component to an open stepped grid. The component describes a horizontal rectangle whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices either at (xs[i], ys[j]) and (xs[i+1], ys[j+1]) or at (xs[i], ys[j+1]) and (xs[i+1], ys[j]), where xs and ys are the arrays passed to the constructor.

      The component is split along a diagonal. For the vertices not along this diagonal, one vertex will have two and only two edges that are shared with components that are not placeholders, and this half of this component is treated as a component that is not a placeholder. If any edge that ends at the the other vertex is shared with another component, that component must be a placeholder.

      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      height - the relative height for the component added to the grid
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is a closed one
      IllegalArgumentException - the indices were out of range
    • addComponent

      public void addComponent(int i, int j, double height, boolean placeholder) throws IllegalStateException, IllegalArgumentException
      Add a component to an open stepped grid, specifying if the component is a placeholder. The component describes a horizontal rectangle whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices either at (xs[i], ys[j]) and (xs[i+1], ys[j+1]), where xs and ys are the arrays passed to the constructor.

      When placeholder is true, the caller is responsible for providing a surface attached to the component's vertices.

      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      height - the relative height for the component added to the grid
      placeholder - true if the component to be added to the grid is a placeholder; false if it is not
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is a closed grid
      IllegalArgumentException - the indices were out of range
    • addHalfComponent

      public void addHalfComponent(int i, int j, double height, boolean placeholder) throws IllegalStateException, IllegalArgumentException
      Add a half component to an open stepped grid, specifying if the component is a placeholder. The component describes a horizontal rectangle whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices either at (xs[i], ys[j]) and (xs[i+1], ys[j+1]) or at (xs[i], ys[j+1]) and (xs[i+1], ys[j]), where xs and ys are the arrays passed to the constructor.

      The component is split along a diagonal. For the vertices not along this diagonal, one vertex will have two and only two edges that are shared with components that are not placeholders, and this half of this component is treated as a component that is not a placeholder. If any edge that ends at the the other vertex is shared with another component, that component must be a placeholder. The half of this component containing this other vertex is the half to which the argument placeholder applies.

      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      height - the relative height for the component added to the grid
      placeholder - true if the component to be added to the grid is a placeholder; false if it is not
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is a closed one
      IllegalArgumentException - the indices were out of range
    • addComponent

      public void addComponent(int i, int j, double upperHeight, double lowerHeight) throws IllegalStateException, IllegalArgumentException
      Add two components to a grid. The components describes horizontal rectangles whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. There is a component for the upper grid and a corresponding component for the lower grid, each with its own base height. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices at (xs[i], ys[j]) and (xs[i+1], ys[j+1]), where xs and ys are the arrays passed to the constructor.

      The value of upperHeight + upperBaseHeight must be larger than the value of lowerHeight + lowerBaseHeight, where upperBaseHeight is the base height of the upper grid and lowerBaseHeight is the base height of the lower grid (these are set by a constructor).

      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      upperHeight - the relative height for the component added to the upper grid
      lowerHeight - the relative height for the component added to the lower grid
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is a not closed grid
      IllegalArgumentException - the indices were out of range
    • addHalfComponent

      public void addHalfComponent(int i, int j, double upperHeight, double lowerHeight) throws IllegalStateException, IllegalArgumentException
      Add two half components to a grid. The components describes horizontal rectangles whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. There is a component for the upper grid and a corresponding component for the lower grid, each with its own base height. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices either at (xs[i], ys[j]) and (xs[i+1], ys[j+1]) or at (xs[i], ys[j+1]) and (xs[i+1], ys[j]), where xs and ys are the arrays passed to the constructor.

      The value of upperHeight + upperBaseHeight must be larger than the value of lowerHeight + lowerBaseHeight, where upperBaseHeight is the base height of the upper grid and lowerBaseHeight is the base height of the lower grid (these are set by a constructor).

      The component is split along a diagonal. For the vertices not along this diagonal, one vertex will have two and only two edges that are shared with components that are not placeholders, and this half of this component is treated as a component that is not a placeholder. If any edge that ends at the the other vertex is shared with another component, that component must be a placeholder.

      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      upperHeight - the relative height for the component added to the upper grid
      lowerHeight - the relative height for the component added to the lower grid
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is a not closed grid
      IllegalArgumentException - the indices were out of range
    • addComponent

      public void addComponent(int i, int j, double upperHeight, double lowerHeight, boolean upperIsPlaceholder, boolean lowerIsPlaceholder) throws IllegalStateException, IllegalArgumentException
      Add two components to a grid, specifying if the components are placeholders. The components describes horizontal rectangles whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. There is a component for the upper grid and a corresponding component for the lower grid, each with its own base height. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices at (xs[i], ys[j]) and (xs[i+1], ys[j+1]), where xs and ys are the arrays passed to the constructor.

      When upperIsPlaceholder or lowerIsPlaceholder is true, the caller is responsible for providing a surface attached to the vertices of the upper-grid component or lower-grid component respectively.

      The value of upperHeight + upperBaseHeight must be larger than the value of lowerHeight + lowerBaseHeight, where upperBaseHeight is the base height of the upper grid and lowerBaseHeight is the base height of the lower grid (these are set by a constructor).

      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      upperHeight - the relative height for the component added to the upper grid
      lowerHeight - the relative height for the component added to the lower grid
      upperIsPlaceholder - true if the component to be added to the upper grid is a placeholder; false if it is not
      lowerIsPlaceholder - true if the component to be added to the lower grid is a placeholder; false if it is not
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is not a closed grid
      IllegalArgumentException - the indices were out of range
    • addHalfComponent

      public void addHalfComponent(int i, int j, double upperHeight, double lowerHeight, boolean upperIsPlaceholder, boolean lowerIsPlaceholder) throws IllegalStateException, IllegalArgumentException
      Add two half components to a grid, specifying if the components are placeholders. The components describes horizontal rectangles whose edges are parallel to the X and Y axes, vertically positioned a distance height above the grid's base height that was provided by the constructor. There is a component for the upper grid and a corresponding component for the lower grid, each with its own base height. The diagonal of the component's rectangle, projected onto the X-Y plane, has vertices either at (xs[i], ys[j]) and (xs[i+1], ys[j+1]) or at (xs[i], ys[j+1]) and (xs[i+1], ys[j]), where xs and ys are the arrays passed to the constructor.

      The value of upperHeight + upperBaseHeight must be larger than the value of lowerHeight + lowerBaseHeight, where upperBaseHeight is the base height of the upper grid and lowerBaseHeight is the base height of the lower grid (these are set by a constructor).

      The component is split along a diagonal. For the vertices not along this diagonal, one vertex will have two and only two edges that are shared with components that are not placeholders, and this half of this component is treated as a component that is not a placeholder. If any edge that ends at the the other vertex is shared with another component, that component must be a placeholder. The half of this component containing this other vertex is the half to which the arguments upperIsPlaceholder and lowerIsPlacehloder apply.

      If upperPlaceholder is true and lowerPlaceholder is false, the entry in the lower rid is changed to a full component instead of a half component. Similarly, if lowerPlaceholder is true and upperPlaceholder is false, the entry in the upper rid is changed to a full component instead of a half component. When both upperPlaceholder and lowerPlaceholder are false,

      Parameters:
      i - the index for a component's position along the X axis
      j - the index for a component's position along the Y axis
      upperHeight - the relative height for the component added to the upper grid
      lowerHeight - the relative height for the component added to the lower grid
      upperIsPlaceholder - true if the component to be added to the upper grid is a placeholder; false if it is not
      lowerIsPlaceholder - true if the component to be added to the lower grid is a placeholder; false if it is not
      Throws:
      IllegalStateException - addsCompleted() was called or this stepped grid is not a closed grid
      IllegalArgumentException - the indices were out of range
    • setMaxZSpacing

      public void setMaxZSpacing(double spacing)
      Set the maximum spacing between vertices in the Z direction.

      This method is intended for cases where a model is configured with an instance of Transform3D, when that transform does not map straight lines to straight lines. In that case, one will typically configure a grid as collection of small rectangles. This method will ensure that the spacing between vertices is small in the Z direction as well.

      Parameters:
      spacing - the maximum spacing; 0.0 or a negative value if there is none
    • hasMaxZSpacing

      public boolean hasMaxZSpacing()
      Determine if this stepped grid has a maximum spacing in the Z direction.
      Returns:
      true if a maximum spacing exists; false otherwise
    • getMaxZSpacing

      public double getMaxZSpacing()
      Get the maximum spacing between vertices in the Z direction.
      Returns:
      the maximum spacing; 0.0 if none is defined.
    • addsCompleted

      public void addsCompleted() throws IllegalStateException
      Indicate that all components have been added and add this object to its model.
      Throws:
      IllegalStateException - the components of this stepped grid were incorrectly configured.
    • hasUpperGrid

      public boolean hasUpperGrid()
      Determine if a stepped grid has an upper grid.
      Returns:
      true if this stepped grid has an upper grid; false otherwise
    • hasLowerGrid

      public boolean hasLowerGrid()
      Determine if a stepped grid has a lower grid.
      Returns:
      true if this stepped grid has a lower grid; false otherwise
    • isComponentFilled

      public boolean isComponentFilled(int i, int j, boolean isUpper) throws IllegalArgumentException, IllegalStateException
      Determine if a component of a stepped grid is filled.
      Parameters:
      i - the index for this component's position along the X axis
      j - the index for this component's position along the Y axis
      isUpper - true if the outside direction faces up; false if the outside direction faces down
      Returns:
      true if this component is filled; false if it is not filled
      Throws:
      IllegalStateException - addsCompleted() was called
      IllegalArgumentException - the indices were out of range
    • isComponentPlaceholder

      public boolean isComponentPlaceholder(int i, int j, boolean isUpper) throws IllegalArgumentException, IllegalStateException
      Determine if a component of a stepped grid is a placeholder. A component that is a placeholder is a filled component whose horizontal rectangle is not created by this stepped grid. Instead, the user is responsible for creating a set of triangles whose edges include the edges of the rectangle that would otherwise have been added.
      Parameters:
      i - the index for this component's position along the X axis
      j - the index for this component's position along the Y axis
      isUpper - true if the outside direction faces up; false if the outside direction faces down
      Returns:
      true if this component is a placeholder; false if it is not a placeholder
      Throws:
      IllegalStateException - addsCompleted() was called
      IllegalArgumentException - the indices were out of range
    • getX

      public double getX(int i) throws IllegalArgumentException
      Get the X value of the vertex of the lower or upper grid with a specified index
      Parameters:
      i - the X index for the vertex
      Returns:
      the X value
      Throws:
      IllegalArgumentException - the index were out of range
    • getY

      public double getY(int j) throws IllegalArgumentException
      Get the Y value of the vertex of the lower or upper grid with a specified index
      Parameters:
      j - the Y index for the vertex
      Returns:
      the Y value
      Throws:
      IllegalArgumentException - the index were out of range
    • getZ

      public double getZ(int i, int j, boolean isUpper) throws IllegalArgumentException, IllegalStateException
      Get the Z value of the vertex of the lower or upper grid with specified indices (i, j).
      Parameters:
      i - the X index for the vertex
      j - the Y index for the vertex
      isUpper - true if the returned value is for the upper grid; false for the lower grid
      Returns:
      the Z value
      Throws:
      IllegalStateException - addsCompleted() was called
      IllegalArgumentException - the indices were out of range
    • getZs

      public double[] getZs(int i, int j, boolean isUpper) throws IllegalArgumentException
      Get the Z values for all vertices associated with an ordered pair of indices (i, j) for the upper or lower grid.

      When adjacent components have different heights, a set of vertical rectangles will be added to this object's model. This method returns the Z values of each vertex along the vertical line connecting the components with a vertex at the point corresponding to the index (i, j).

      If there are no filled components adjacent to the vertex associated with the indices (i,j), a zero-length array will be returned.

      Parameters:
      i - the X index for the vertex
      j - the Y index for the vertex
      isUpper - true if the returned value is for the upper grid; false for the lower grid
      Returns:
      the Z values
      Throws:
      IllegalArgumentException
    • getZs

      public double[] getZs(int i, int j)
      Get the Z values for all vertices associated with an ordered pair of indices (i, j) for the upper and lower grids.

      When adjacent components have different heights, a set of vertical rectangles will be added to this object's model. This method returns the Z values of each vertex along the vertical line connecting the components with a vertex at the point corresponding to the index (i, j).

      If there are no filled components adjacent to the vertex associated with the indices (i,j), a zero-length array will be returned.

      Parameters:
      i - the X index for the vertex
      j - the Y index for the vertex
      Returns:
      the Z values