Skip to content

Commit fa6838e

Browse files
committed
feat(PolyData): Initial addition
1 parent 18a8ef5 commit fa6838e

File tree

5 files changed

+69
-4
lines changed

5 files changed

+69
-4
lines changed

include/itkJSONToMeshFilter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ namespace itk
2626
/**
2727
*\class JSONToMeshFilter
2828
* \brief Convert an MeshJSON to an Mesh object.
29-
*
29+
*
3030
* TMesh must match the type stored in the JSON representation or an exception will be shown.
31-
*
31+
*
3232
* \ingroup WebAssemblyInterface
3333
*/
3434
template <typename TMesh>

include/itkMeshJSON.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ namespace itk
2828
* \brief JSON representation for an itk::Mesh
2929
*
3030
* JSON representation for an itk::Mesh for interfacing across programming languages and runtimes.
31-
*
31+
*
3232
* Point, CellBuffer, PointData, and CellData binary array buffer's are stored as strings with memory addresses or paths on disks or a virtual filesystem.
33-
*
33+
*
3434
* \ingroup WebAssemblyInterface
3535
*/
3636
template <typename TMesh>

src/core/PolyData.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class PolyData {
2+
name: string = 'PolyData'
3+
4+
points: Float32Array
5+
6+
vertices: null | Uint32Array
7+
8+
lines: null | Uint32Array
9+
10+
polygons: null | Uint32Array
11+
12+
triangleStrips: null | Uint32Array
13+
14+
constructor () {
15+
this.name = 'PolyData'
16+
17+
this.points = new Float32Array()
18+
this.lines = null
19+
this.vertices = null
20+
this.polygons = null
21+
this.triangleStrips = null
22+
}
23+
}
24+
25+
export default PolyData

src/core/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export { default as ImageType } from './ImageType.js'
1717
export { default as Mesh } from './Mesh.js'
1818
export { default as MeshType } from './MeshType.js'
1919

20+
export { default as PolyData } from './PolyData.js'
21+
// Todo: remove
2022
export { default as vtkPolyData } from './vtkPolyData.js'
2123

2224
export { default as bufferToTypedArray } from './bufferToTypedArray.js'

test/node/core/PolyDataTest.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import test from 'ava'
2+
3+
import { PolyData } from '../../../dist/index.js'
4+
5+
test('name should have the default value of "PolyData"', t => {
6+
const polyData = new PolyData()
7+
t.deepEqual(polyData.name, 'PolyData')
8+
})
9+
10+
test('points should be a Float32Array', t => {
11+
const polyData = new PolyData()
12+
t.assert(polyData.points instanceof Float32Array)
13+
})
14+
15+
test('points should have a default length of 0', t => {
16+
const polyData = new PolyData()
17+
t.is(polyData.points.length, 0)
18+
})
19+
20+
test('lines should have a default value of null', t => {
21+
const polyData = new PolyData()
22+
t.is(polyData.lines, null)
23+
})
24+
25+
test('vertices should have a default value of null', t => {
26+
const polyData = new PolyData()
27+
t.is(polyData.vertices, null)
28+
})
29+
30+
test('polygons should have a default value of null', t => {
31+
const polyData = new PolyData()
32+
t.is(polyData.polygons, null)
33+
})
34+
35+
test('triangleStrips should have a default value of null', t => {
36+
const polyData = new PolyData()
37+
t.is(polyData.triangleStrips, null)
38+
})

0 commit comments

Comments
 (0)