import { CurveCollection } from "../curve/CurveCollection";
import { CurveLocationDetailPair } from "../curve/CurveLocationDetail";
import { CurvePrimitive } from "../curve/CurvePrimitive";
import { Point3d } from "../geometry3d/Point3dVector3d";
import { ClipPlane } from "./ClipPlane";
import { PolygonClipper } from "./ClipUtils";
import { ConvexClipPlaneSet } from "./ConvexClipPlaneSet";
import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
import { GrowableXYZArrayCache } from "../geometry3d/ReusableObjectCache";
/**
* An AlternatingConvexClipTreeNode is a node in a tree structure in which
*
* - Each node contains a ConvexClipPlaneSet
*
- Each node contains an array of children which are also AlternatingConvexClipTreeNode.
*
- The rule for an in/out decision is that a point is IN the subtree under a node if
*
* - It is IN the node's ConvexClipPlaneSet.
*
- It is NOT IN any of the children.
*
* - Applying "NOT IN any of the children" locally to children at each level means that the ConvexClipPlaneSet
* at adjacent levels flip between being positive areas and holes.
*
- Use an AlternatingConvexClipTreeNodeBuilder to construct the tree from a polygon.
*
- It is possible for the root clip plane set to be empty. An empty clip plane set returns "true"
* for all point tests, so the meaning is just that holes are to be subtracted from the rest
* of space.
*
- Although the interpretation of in/out alternates with tree levels, the ConvexClipPlaneSets
* at each level are all "enclosing" planes in the usual way.
*
*/
export declare class AlternatingCCTreeNode implements PolygonClipper {
points: Point3d[];
planes: ConvexClipPlaneSet;
children: AlternatingCCTreeNode[];
startIdx: number;
numPoints: number;
private constructor();
/** Initialize this node with index data referencing the parent polygon. */
static createWithIndices(index0: number, numPoints: number, result?: AlternatingCCTreeNode): AlternatingCCTreeNode;
/**
*
* - Build the tree for a polygon.
*
- Caller creates the root node with empty constructor AlternatingConvexClipTreeNode.
*
*/
static createTreeForPolygon(points: Point3d[], result?: AlternatingCCTreeNode): AlternatingCCTreeNode;
/** Resets this AlternatingConvexClipTreeNode to a newly-created state */
empty(): void;
/** Creates a deep copy of this node (expensive - copies Geometry, and is recursive for children array). */
clone(result?: AlternatingCCTreeNode): AlternatingCCTreeNode;
/** Add a new child that has an empty plane set and given indices. */
addEmptyChild(index0: number, numPoints: number): void;
/** Add a plane to the ConvexClipPlaneSet */
addPlane(plane: ClipPlane): void;
/** Search with alternating in and out semantics. */
isPointOnOrInside(point: Point3d): boolean;
/** Add an AlternatingConvexClipTreeNode as a child of this one -- i.e. a hole.
* * The child pointer is pushed directly to the tree -- not cloned.
*/
captureConvexClipPlaneSetAsVoid(child: AlternatingCCTreeNode): void;
/** Append start-end positions for curve intervals classified as inside or outside. */
appendCurvePrimitiveClipIntervals(curve: CurvePrimitive, insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[]): void;
/** Append start-end positions for curve intervals classified as inside or outside. */
appendCurveCollectionClipIntervals(curves: CurveCollection, insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[]): void;
/**
*
* @param xyz input polygon. This is not changed.
* @param insideFragments Array to receive "inside" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.
* @param outsideFragments Array to receive "outside" fragments. Each fragment is a GrowableXYZArray grabbed from the cache. This is NOT cleared.
* @param arrayCache cache for reusable GrowableXYZArray.
*/
appendPolygonClip(xyz: GrowableXYZArray, insideFragments: GrowableXYZArray[], outsideFragments: GrowableXYZArray[], arrayCache: GrowableXYZArrayCache): void;
/**
*
*/
depth(): number;
}
/**
* Context structure for building an AlternatingConvexClipTreeNode from a polygon.
*
* - The polygon is copied to the local m_points structure.
*
- During construction, m_stack contains indices of a sequence of points with uniform concavity.
*
*/
export declare class AlternatingCCTreeBuilder {
private _points;
private _stack;
private constructor();
static createPointsRef(points: Point3d[], result?: AlternatingCCTreeBuilder): AlternatingCCTreeBuilder;
get period(): number;
indexAfter(i: number): number;
indexBefore(i: number): number;
pushIndex(primaryPointIndex: number): void;
private static cross;
cyclicStackPoint(cyclicIndex: number): Point3d;
signFromStackTip(pointIndex: number, sign: number): 1 | -1;
get indexOfMaxX(): number;
/** Pop from the stack until the sign condition is satisfied */
extendHullChain(k: number, sign: number, pushAfterPops: boolean): void;
collectHullChain(kStart: number, numK: number, sign: number): void;
private buildHullTreeGo;
/**
*
* - Input a ClipTreeRoot that has start and count data
*
- Build the hull for that data range
*
- Store the hull points in the root
*
- Add children with start and count data
*
- Recursively move to children
*
*/
buildHullTree(root: AlternatingCCTreeNode): boolean;
}
export declare class AlternatingCCTreeNodeCurveClipper {
private _curve;
private _intervalStack;
private _stackDepth;
constructor();
private setCurveRef;
private popSegmentFrame;
private clearSegmentStack;
private pushEmptySegmentFrame;
private get _topOfStack();
private set _topOfStack(value);
/** Access entry [topOfStack() - numSkip] */
private stackEntry;
private isTopOfStackEmpty;
private static _fractionIntervals;
private appendSingleClipToStack;
/**
* Run one level of recursion. On return, the stack is one level deeper than at entry and the new top of the stack has clip for this node
* (expensive -- must clone items of arrays during "swaps")
*/
private recurse;
/**
* Modifies the insideIntervals array given in place.
* Note: curve given is passed by reference and stored.
*/
appendSingleClipPrimitive(root: AlternatingCCTreeNode, curve: CurvePrimitive, insideIntervals: CurveLocationDetailPair[], _outsideIntervals: CurveLocationDetailPair[]): void;
/**
* Modifies the insideIntervals array given in place.
* Note: curve given is passed by reference and stored.
*/
appendCurveCollectionClip(root: AlternatingCCTreeNode, curve: CurveCollection, insideIntervals: CurveLocationDetailPair[], outsideIntervals: CurveLocationDetailPair[]): void;
}
//# sourceMappingURL=AlternatingConvexClipTree.d.ts.map