Skip to content

Commit 19c26e8

Browse files
David Bergerjoannacirillo
authored andcommitted
feat(vtkClipClosedSurface): Add vtkClipClosedSurface
1 parent ad4ada0 commit 19c26e8

File tree

27 files changed

+6096
-7
lines changed

27 files changed

+6096
-7
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { vtkObject } from "../../../interfaces";
2+
import { Bounds } from "../../../types";
3+
import { ILocatorInitialValues } from "../Locator";
4+
5+
/**
6+
*
7+
*/
8+
export interface IAbstractPointLocatorInitialValues
9+
extends ILocatorInitialValues {
10+
bounds?: Bounds;
11+
numberOfBuckets: number;
12+
}
13+
14+
export interface vtkAbstractPointLocator extends vtkObject {
15+
/**
16+
* Set the bounds of this object.
17+
* @param {Bounds} input
18+
*/
19+
setBounds(input: Bounds): void;
20+
21+
/**
22+
* Get the bounds of this object.
23+
* @returns {Bounds}
24+
*/
25+
getBounds(): Bounds;
26+
}
27+
28+
// ----------------------------------------------------------------------------
29+
// Static API
30+
// ----------------------------------------------------------------------------
31+
32+
/**
33+
* Method use to decorate a given object (publicAPI+model) with vtkAbstractPointLocator characteristics.
34+
*
35+
* @param publicAPI object on which methods will be bounds (public)
36+
* @param model object on which data structure will be bounds (protected)
37+
* @param {IAbstractPointLocatorInitialValues} [initialValues] (default: {})
38+
*/
39+
export function extend(
40+
publicAPI: object,
41+
model: object,
42+
initialValues?: IAbstractPointLocatorInitialValues
43+
): void;
44+
45+
// ----------------------------------------------------------------------------
46+
47+
/**
48+
* vtkAbstractPointLocator
49+
*/
50+
export declare const vtkAbstractPointLocator: {
51+
extend: typeof extend;
52+
};
53+
54+
export default vtkAbstractPointLocator;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import macro from 'vtk.js/Sources/macros';
2+
import vtkLocator from 'vtk.js/Sources/Common/DataModel/Locator';
3+
4+
function vtkAbstractPointLocator(publicAPI, model) {
5+
// Set our className
6+
model.classHierarchy.push('vtkAbstractPointLocator');
7+
}
8+
9+
// ----------------------------------------------------------------------------
10+
// Object factory
11+
// ----------------------------------------------------------------------------
12+
13+
function defaultValues(initialValues) {
14+
return {
15+
bounds: null,
16+
numberOfBuckets: 0,
17+
...initialValues,
18+
};
19+
}
20+
21+
// ----------------------------------------------------------------------------
22+
23+
export function extend(publicAPI, model, initialValues = {}) {
24+
vtkLocator.extend(publicAPI, model, defaultValues(initialValues));
25+
26+
// Make this a VTK object
27+
macro.obj(publicAPI, model);
28+
29+
macro.get(publicAPI, model, ['numberOfBuckets']);
30+
31+
macro.setGetArray(publicAPI, model, ['bounds'], 6);
32+
33+
// Object specific methods
34+
vtkAbstractPointLocator(publicAPI, model);
35+
}
36+
37+
// ----------------------------------------------------------------------------
38+
39+
export default { extend };
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import test from 'tape-catch';
2+
import vtkAbstractPointLocator from 'vtk.js/Sources/Common/DataModel/AbstractPointLocator';
3+
4+
test('Test vtkAbstractPointLocator instance', (t) => {
5+
t.ok(vtkAbstractPointLocator, 'Make sure the class definition exists');
6+
t.ok(
7+
vtkAbstractPointLocator.newInstance === undefined,
8+
'Make sure class is abstract'
9+
);
10+
t.end();
11+
});
Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
import { vtkAlgorithm, vtkObject } from "../../../interfaces";
2+
import { Bounds, Vector3 } from "../../../types";
3+
import vtkCellArray from "vtk.js/Sources/Common/DataModel/CellArray";
4+
import vtkPolyData from "vtk.js/Sources/Common/DataModel/PolyData";
5+
import vtkPoints from "vtk.js/Sources/Common/Core/Points";
6+
7+
/**
8+
*
9+
*/
10+
export interface IIncrementalOctreeNodeInitialValues {
11+
pointIdSet?: number[];
12+
minBounds?: Bounds;
13+
maxBounds?: Bounds;
14+
minDataBounds?: Bounds;
15+
maxDataBounds?: Bounds;
16+
parent?: vtkIncrementalOctreeNode;
17+
children?: vtkIncrementalOctreeNode[];
18+
}
19+
20+
export interface vtkIncrementalOctreeNode extends vtkObject {
21+
/**
22+
* Create a list object for storing point indices.
23+
*/
24+
createPointIdSet(): void;
25+
26+
/**
27+
* Set the spatial bounding box of the node. This function sets a default
28+
* data bounding box.
29+
*
30+
* @param {Number} x1
31+
* @param {Number} x2
32+
* @param {Number} y1
33+
* @param {Number} y2
34+
* @param {Number} z1
35+
* @param {Number} z2
36+
*/
37+
setBounds(
38+
x1: number,
39+
x2: number,
40+
y1: number,
41+
y2: number,
42+
z1: number,
43+
z2: number
44+
): void;
45+
46+
/**
47+
* Get the spatial bounding box of the node. The values are returned via
48+
* an array in order of: x_min, x_max, y_min, y_max, z_min, z_max.
49+
*
50+
* @param {Bounds} bounds
51+
*/
52+
getBounds(bounds: Bounds): void;
53+
54+
/**
55+
* Given a point inserted to either this node (a leaf node) or a descendant
56+
* leaf (of this node --- when this node is a non-leaf node), update the
57+
* counter and the data bounding box for this node only. The data bounding box
58+
* is considered only if updateData is non-zero. The returned value indicates
59+
* whether (1) or not (0) the data bounding box is actually updated. Note that
60+
* argument nHits must be 1 unless this node is updated with a number (nHits)
61+
* of exactly duplicate points as a whole via a single call to this function.
62+
*
63+
* @param {Vector3} point
64+
* @param {Number} nHits
65+
* @param {Boolean} updateData
66+
*/
67+
updateCounterAndDataBounds(
68+
point: Vector3,
69+
nHits: number,
70+
updateData: boolean
71+
): boolean;
72+
73+
/**
74+
* Given a point inserted to either this node (a leaf node) or a descendant
75+
* leaf (of this node --- when this node is a non-leaf node), update the
76+
* counter and the data bounding box recursively bottom-up until a specified
77+
* node. The data bounding box is considered only if updateData is non-zero.
78+
* The returned value indicates whether (true) or not (false) the data bounding box
79+
* is actually updated. Note that argument nHits must be 1 unless this node
80+
* is updated with a number (nHits) of exactly duplicate points as a whole
81+
* via a single call to this function.
82+
*
83+
* @param {Vector3} point
84+
* @param {Number} nHits
85+
* @param {Boolean} updateData
86+
* @param {vtkIncrementalOctreeNode} endNode
87+
*/
88+
updateCounterAndDataBoundsRecursively(
89+
point: Vector3,
90+
nHits: number,
91+
updateData: boolean,
92+
endNode: vtkIncrementalOctreeNode
93+
): boolean;
94+
95+
/**
96+
* Given a point, determine whether (true) or not (false) it is an exact duplicate
97+
* of all the points, if any, maintained in this node. In other words, to
98+
* check if this given point and all existing points, if any, of this node
99+
* are exactly duplicate with one another.
100+
*
101+
* @param {Vector3} point
102+
*/
103+
containsDuplicatePointsOnly(point: Vector3): boolean;
104+
105+
/**
106+
* Determine whether or not this node is a leaf.
107+
*/
108+
isLeaf(): boolean;
109+
110+
/**
111+
* Get the child at the given index i.
112+
* i must be an int between 0 and 7.
113+
*
114+
* @param {Number} i
115+
*/
116+
getChild(i: number): vtkIncrementalOctreeNode;
117+
118+
/**
119+
* Given a number (>= threshold) of all exactly duplicate points (accessible
120+
* via points and pntIds, but with exactly the same 3D coordinate) maintained
121+
* in this leaf node and a point (absolutely not a duplicate any more, with
122+
* pntIdx storing the index in points)) to be inserted to this node, separate
123+
* all the duplicate points from this new point by means of usually recursive
124+
* node sub-division such that the former points are inserted to a descendant
125+
* leaf while the new point is inserted to a sibling of this descendant leaf.
126+
* Argument ptMode specifies whether the point is not inserted at all but only
127+
* the point index is provided upon 0, the point is inserted via vtkPoints::
128+
* InsertPoint() upon 1, or this point is instead inserted through vtkPoints::
129+
* InsertNextPoint() upon 2.
130+
*
131+
* @param {vtkPoints} points
132+
* @param {Number[]} pntIds
133+
* @param {Vector3} newPnt
134+
* @param {Number} pntIdx
135+
* @param {Number} maxPts
136+
* @param {Number} ptMode
137+
*/
138+
separateExactlyDuplicatePointsFromNewInsertion(
139+
points: vtkPoints,
140+
pntIds: number[],
141+
newPnt: Vector3,
142+
pntIdx: number,
143+
maxPts: number,
144+
ptMode: number
145+
): void;
146+
147+
/**
148+
* Divide this LEAF node into eight child nodes as the number of points
149+
* maintained by this leaf node has reached the threshold maxPts while
150+
* another point newPnt is just going to be inserted to it. The available
151+
* point-indices pntIds are distributed to the child nodes based on the
152+
* point coordinates (available through points). Note that this function
153+
* can incur recursive node-division to determine the specific leaf node
154+
* for accepting the new point (with pntIdx storing the index in points)
155+
* because the existing maxPts points may fall within only one of the eight
156+
* child nodes to make a radically imbalanced layout within the node (to
157+
* be divided). Argument ptMode specifies whether the point is not inserted
158+
* at all but instead only the point index is provided upon 0, the point is
159+
* inserted via vtkPoints.InsertPoint() upon 1, or the point is inserted by
160+
* vtkPoints.InsertNextPoint() upon 2. The returned value of this function
161+
* indicates whether pntIds needs to be destroyed (1) or just unregistered
162+
* from this node as it has been attached to another node (0).
163+
* numberOfNodes in the tree is updated with new created nodes
164+
*
165+
* @param {vtkPoints} points
166+
* @param {Number[]} pntIds
167+
* @param {Vector3} newPnt
168+
* @param {Number} pntIdx
169+
* @param {Number} maxPts
170+
* @param {Number} ptMode
171+
* @param {Number} numberOfNodes
172+
*/
173+
createChildNodes(
174+
points: vtkPoints,
175+
pntIds: number[],
176+
newPnt: Vector3,
177+
pntIdx: number,
178+
maxPts: number,
179+
ptMode: number,
180+
numberOfNodes: number
181+
): { success: boolean; numberOfNodes: number; pointIdx: number };
182+
183+
/**
184+
* This function is called after a successful point-insertion check and
185+
* only applies to a leaf node. Prior to a call to this function, the
186+
* octree should have been retrieved top-down to find the specific leaf
187+
* node in which this new point (newPt) will be inserted. The actual index
188+
* of the new point (to be inserted to points) is stored in pntId. Argument
189+
* ptMode specifies whether the point is not inserted at all but instead only
190+
* the point index is provided upon 0, the point is inserted via vtkPoints.
191+
* insertPoint() upon 1, or it is inserted via vtkPoints.insertNextPoint()
192+
* upon 2. For case 0, pntId needs to be specified. For cases 1 and 2, the
193+
* actual point index is returned via pntId. Note that this function always
194+
* returns 1 to indicate the success of point insertion.
195+
* numberOfNodes is the number of nodes present in the tree at this time.
196+
* it is used to assign an ID to each node which can be used to associate
197+
* application specific information with each node. It is updated if new nodes
198+
* are added to the tree.
199+
*
200+
* @param {Number} points
201+
* @param {Number} newPnt
202+
* @param {Number} maxPts
203+
* @param {Number} pntId
204+
* @param {Number} ptMode
205+
* @param {Number} numberOfNodes
206+
*/
207+
insertPoint(
208+
points: number,
209+
newPnt: number,
210+
maxPts: number,
211+
pntId: number,
212+
ptMode: number,
213+
numberOfNodes: number
214+
): { numberOfNodes: number; pointIdx: number };
215+
216+
/**
217+
* Compute the minimum squared distance from a point to this node, with all
218+
* six boundaries considered. The data bounding box is checked if checkData
219+
* is non-zero. The closest on-boundary point is returned via closest.
220+
*
221+
* @param {Vector3} point
222+
* @param {Vector3} closest
223+
* @param {Boolean} innerOnly
224+
* @param {vtkIncrementalOctreeNode} rootNode
225+
* @param {Boolean} checkData
226+
* @returns {Number}
227+
*/
228+
getDistance2ToBoundary(
229+
point: Vector3,
230+
closest: Vector3,
231+
innerOnly: boolean,
232+
rootNode: vtkIncrementalOctreeNode,
233+
checkData: boolean
234+
): number;
235+
236+
/**
237+
* Given a point inside this node, get the minimum squared distance to all
238+
* inner boundaries. An inner boundary is a node's face that is shared by
239+
* another non-root node.
240+
*
241+
* @param {Vector3} point
242+
* @param {vtkIncrementalOctreeNode} rootNode
243+
*/
244+
getDistance2ToInnerBoundary(
245+
point: Vector3,
246+
rootNode: vtkIncrementalOctreeNode
247+
): number;
248+
}
249+
250+
// ----------------------------------------------------------------------------
251+
// Static API
252+
// ----------------------------------------------------------------------------
253+
254+
/**
255+
* Method use to decorate a given object (publicAPI+model) with vtkIncrementalOctreeNode characteristics.
256+
*
257+
* @param publicAPI object on which methods will be bounds (public)
258+
* @param model object on which data structure will be bounds (protected)
259+
* @param {object} [initialValues] (default: {})
260+
*/
261+
export function extend(
262+
publicAPI: object,
263+
model: object,
264+
initialValues?: IIncrementalOctreeNodeInitialValues
265+
): void;
266+
267+
// ----------------------------------------------------------------------------
268+
269+
/**
270+
* Method use to create a new instance of vtkIncrementalOctreeNode
271+
* @param {IIncrementalOctreeNodeInitialValues} [initialValues] for pre-setting some of its content
272+
*/
273+
export function newInstance(
274+
initialValues?: IIncrementalOctreeNodeInitialValues
275+
): vtkIncrementalOctreeNode;
276+
277+
/**
278+
* vtkIncrementalOctreeNode
279+
*/
280+
export declare const vtkIncrementalOctreeNode: {
281+
newInstance: typeof newInstance;
282+
extend: typeof extend;
283+
};
284+
285+
export default vtkIncrementalOctreeNode;

0 commit comments

Comments
 (0)