Skip to content

Commit 438627c

Browse files
authored
Merge pull request #2615 from Kitware/fix-edgelocator-ts
docs(EdgeLocator): fix parse and update types
2 parents 61c25d9 + e2752c2 commit 438627c

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

Sources/Common/DataModel/EdgeLocator/index.d.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import { Nullable } from "../../../types";
2+
13
/**
24
*
35
*/
46
export interface IEdgeLocatorInitialValues {
57
oriented?: boolean;
68
}
79

10+
export interface IEdge<T = unknown> {
11+
key: number;
12+
edgeId: number;
13+
value?: T;
14+
}
15+
816
export interface vtkEdgeLocator {
917
/**
1018
* Remove all the edges previously added.
@@ -15,26 +23,22 @@ export interface vtkEdgeLocator {
1523
* Returns the inserted edge or null if no edge was inserted.
1624
* @param {Number} pointId0 Edge first point id
1725
* @param {Number} pointId1 Edge last point id
18-
* @return {key, edgeId, value} or null
26+
* @return {IEdge|null} an edge object ({ key, edgeId, value }) or null
1927
*/
20-
isInsertedEdge(pointId0: number, pointId1: number): { key: any; edgeId: number; value?: any } | null;
28+
isInsertedEdge<T = unknown>(pointId0: number, pointId1: number): Nullable<IEdge<T>>;
2129

2230
/**
2331
* Insert edge if it does not already exist.
2432
* Returns the existing or newly inserted edge.
2533
*
2634
* @param {Number} pointId0 Edge first point id
2735
* @param {Number} pointId1 Edge last point id
28-
* @param {any} value Optional value option
29-
* @return {key, edgeId, value}
36+
* @param {unknown} value Optional value option
37+
* @return {IEdge|null} an edge object ({ key, edgeId, value }) or null
3038
* @see insertEdge()
3139
* @see isInsertedEdge()
3240
*/
33-
insertUniqueEdge(
34-
pointId0: number,
35-
pointId1: number,
36-
value?: any
37-
): { key: any; edgeId: number; value?: any };
41+
insertUniqueEdge<T>(pointId0: number, pointId1: number, value?: T): IEdge<T>;
3842

3943
/**
4044
* Insert edge. If the edge already exists, it is overwritten by this
@@ -43,15 +47,12 @@ export interface vtkEdgeLocator {
4347
* Returns the newly inserted edge.
4448
* @param {Number} pointId0 Edge first point id
4549
* @param {Number} pointId1 Edge last point id
46-
* @param {any} value Optional value option
47-
* @return {key, edgeId, value} or null
50+
* @param {unknown} value Optional value option
51+
* @return {Edge|null} an edge object ({ key, edgeId, value }) or null
4852
* @see isInsertedEdge
4953
* @see insertUniqueEdge
5054
*/
51-
insertEdge(pointId0: number,
52-
pointId1: number,
53-
value?: any
54-
): { key: any; edgeId: number; value?: any };
55+
insertEdge<T>(pointId0: number, pointId1: number, value?: T): IEdge<T>;
5556
}
5657

5758
// ----------------------------------------------------------------------------

Sources/Common/DataModel/EdgeLocator/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class EdgeLocator {
3030
insertEdge(pointId0, pointId1, newEdgeValue) {
3131
// Generate a unique key
3232
const key = this.computeEdgeKey(pointId0, pointId1);
33-
// Didn't find key, so add a new edge entry
3433
const node = { key, edgeId: this.edgeMap.size, value: newEdgeValue };
3534
this.edgeMap.set(key, node);
3635
return node;

0 commit comments

Comments
 (0)