ContourLayers

Package: Libraries.Fabrication.Geometry · Inherits from: Libraries.Language.Object

The ContourLayers class groups a list of contours by slice plane once, so the contours of any one layer can then be fetched without scanning the whole list.

Example Code

use Libraries.Containers.Array
use Libraries.Fabrication.Geometry.Contour
use Libraries.Fabrication.Geometry.ContourLayers

class Main
    action Main
        Array<Contour> all      // contours from ContourGenerator, say
        ContourLayers layers
        layers:Index(all, 100, true)
        Array<Contour> third = layers:GetLayer(2)
    end
end

Actions

GetLayer(integer plane)

The contours of one plane, in their original order.

Parameters

  • plane integer: The plane.

Returns

Libraries.Containers.Array<Libraries.Fabrication.Geometry.Contour>: A new array; empty for a plane outside the indexed range.

Example

use Libraries.Containers.Array
use Libraries.Fabrication.Geometry.Contour
use Libraries.Fabrication.Geometry.ContourLayers

Array<Contour> outlines      // from ContourGenerator:Build
ContourLayers layers
layers:Index(outlines, 100, false)
Array<Contour> first = layers:GetLayer(0)
output first:GetSize() + " loops on the first layer"

GetPlaneCount()

The number of planes given to Index.

Returns

integer: The number of planes given to Index.

Example

use Libraries.Containers.Array
use Libraries.Fabrication.Geometry.Contour
use Libraries.Fabrication.Geometry.ContourLayers

Array<Contour> outlines
ContourLayers layers
layers:Index(outlines, 100, false)
output layers:GetPlaneCount()       // 100

Index(Libraries.Containers.Array<Libraries.Fabrication.Geometry.Contour> contours, integer planeCount, boolean usableLoopsOnly)

Groups the contours by their planeIndex. Contours on planes outside 0 to planeCount - 1 are left out.

Parameters

Example

use Libraries.Containers.Array
use Libraries.Fabrication.Geometry.Contour
use Libraries.Fabrication.Geometry.ContourLayers

Contour square
square:AddPoint(0, 0)
square:AddPoint(20, 0)
square:AddPoint(20, 20)
square:AddPoint(0, 20)
square:closed = true
square:planeIndex = 3
Array<Contour> outlines
outlines:Add(square)
ContourLayers layers
layers:Index(outlines, 10, true)
Array<Contour> third = layers:GetLayer(3)
output third:GetSize()      // 1

Inherited Actions

3 actions from Libraries.Language.Object