Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 32x 32x 32x 32x 32x 32x 32x 32x 720x 32x | import type { Point3, ContourData } from '../../types'; import type { ContourType } from '../../enums'; interface ContourProps { id: string; data: ContourData; color: Point3; segmentIndex: number; } /** * Represents a contour in 3D space. * * @remarks * Each Contour is part of a ContourSet, and each ContourSet is part of a Geometry. * It holds information about the contour's id, size in bytes, points, color, and type. */ export class Contour { /** Unique identifier for the contour */ readonly id: string; /** Size of the contour data in bytes */ readonly sizeInBytes: number; /** Array of 3D points defining the contour */ // Todo: we should use PointsManager: the efficiency of the contour access is // better because you can just get references to particular points, and the size // is just the native data type times the number of values total private _points: Point3[]; /** Color of the contour */ private _color: Point3; /** Type of the contour (closed or open) */ private _type: ContourType; /** Index of the segment this contour belongs to */ private _segmentIndex: number; /** * Creates an instance of Contour. * * @param props - The properties to initialize the Contour with */ constructor(props: ContourProps) { const { points, type } = props.data; this.id = props.id; this._points = points; this._type = type; this._color = props.color; this._segmentIndex = props.segmentIndex; this.sizeInBytes = this._getSizeInBytes(); } /** * Calculates the size of the contour in bytes. * * @returns The size of the contour in bytes * @private */ private _getSizeInBytes(): number { // Assuming each point is 1 byte return this._points.length * 3; } /** * Gets the points of the contour. * * @returns The points of the contour */ get points(): Point3[] { return this._points; } /** * Sets the points of the contour. * * @param value - The new points for the contour */ set points(value: Point3[]) { this._points = value; } /** * Gets the color of the contour. * * @returns The color of the contour */ get color(): Point3 { return this._color; } /** * Sets the color of the contour. * * @param value - The new color for the contour */ set color(value: Point3) { this._color = value; } /** * Gets the type of the contour (closed or open). * * @returns The type of the contour */ get type(): ContourType { return this._type; } /** * Sets the type of the contour. * * @param value - The new type for the contour */ set type(value: ContourType) { this._type = value; } /** * Gets the segment index of the contour. * * @returns The segment index of the contour */ get segmentIndex(): number { return this._segmentIndex; } /** * Sets the segment index of the contour. * * @param value - The new segment index for the contour */ set segmentIndex(value: number) { this._segmentIndex = value; } /** * Gets a flat array of all points. * * @returns A flat array of all points */ get flatPointsArray(): number[] { return this._points.map((point) => [...point]).flat(); } } export default Contour; |