Skip to content

Commit d962330

Browse files
authored
Merge pull request #54 from tbirdso/bump-workflows
ENH: Bump ITK CI Reusable Workflow
2 parents 0f69d0a + f963101 commit d962330

File tree

3 files changed

+70
-93
lines changed

3 files changed

+70
-93
lines changed

.github/workflows/build-test-package.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on: [push,pull_request]
44

55
jobs:
66
cxx-build-workflow:
7-
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.3.0
7+
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@03626a23c22246e89e36c7e918a158c440f9b099
88

99
python-build-workflow:
10-
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/[email protected]
10+
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@03626a23c22246e89e36c7e918a158c440f9b099
11+
with:
12+
test-notebooks: true
1113
secrets:
1214
pypi_password: ${{ secrets.pypi_password }}

examples/itkPolyDataToMeshFilter.ipynb

Lines changed: 61 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -35,46 +35,68 @@
3535
"metadata": {},
3636
"outputs": [],
3737
"source": [
38-
"MESH_FILE = 'Input/cow.vtk'\n",
38+
"MESH_FILE = \"Input/cow.vtk\"\n",
3939
"\n",
4040
"# Download mesh\n",
41-
"os.makedirs('Input', exist_ok=True)\n",
41+
"os.makedirs(\"Input\", exist_ok=True)\n",
4242
"if not os.path.exists(MESH_FILE):\n",
43-
" url = 'https://data.kitware.com/api/v1/file/5c43feba8d777f072b0cd3da/download'\n",
43+
" url = \"https://data.kitware.com/api/v1/file/5c43feba8d777f072b0cd3da/download\"\n",
4444
" urlretrieve(url, MESH_FILE)"
4545
]
4646
},
4747
{
4848
"cell_type": "code",
49-
"execution_count": 3,
50-
"metadata": {},
51-
"outputs": [],
52-
"source": [
53-
"mesh_input = itk.meshread(MESH_FILE, itk.D)"
54-
]
55-
},
56-
{
57-
"cell_type": "code",
58-
"execution_count": 4,
49+
"execution_count": 5,
5950
"metadata": {},
6051
"outputs": [
6152
{
6253
"name": "stdout",
6354
"output_type": "stream",
6455
"text": [
65-
"2903\n",
66-
"3263\n"
56+
"Mesh (0000026EE123F310)\n",
57+
" RTTI typeinfo: class itk::Mesh<double,3,class itk::DefaultStaticMeshTraits<double,3,3,float,float,double> >\n",
58+
" Reference Count: 1\n",
59+
" Modified Time: 28464\n",
60+
" Debug: Off\n",
61+
" Object Name: \n",
62+
" Observers: \n",
63+
" none\n",
64+
" Source: (none)\n",
65+
" Source output name: (none)\n",
66+
" Release Data: Off\n",
67+
" Data Released: False\n",
68+
" Global Release Data: Off\n",
69+
" PipelineMTime: 19016\n",
70+
" UpdateMTime: 28463\n",
71+
" RealTimeStamp: 0 seconds \n",
72+
" Number Of Points: 2903\n",
73+
" Requested Number Of Regions: 1\n",
74+
" Requested Region: 0\n",
75+
" Buffered Region: 0\n",
76+
" Maximum Number Of Regions: 1\n",
77+
" Point Data Container pointer: 0000000000000000\n",
78+
" Size of Point Data Container: 0\n",
79+
" Number Of Points: 2903\n",
80+
" Number Of Cell Links: 0\n",
81+
" Number Of Cells: 3263\n",
82+
" Cell Data Container pointer: 0000000000000000\n",
83+
" Size of Cell Data Container: 0\n",
84+
" Number of explicit cell boundary assignments: 3\n",
85+
" CellsAllocationMethod: itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell\n",
86+
"\n"
6787
]
6888
}
6989
],
7090
"source": [
71-
"print(mesh_input.GetNumberOfPoints())\n",
72-
"print(mesh_input.GetNumberOfCells())"
91+
"mesh_input = itk.meshread(MESH_FILE, itk.D)\n",
92+
"\n",
93+
"assert type(mesh_input) == itk.Mesh[itk.D, 3]\n",
94+
"print(mesh_input)"
7395
]
7496
},
7597
{
7698
"cell_type": "code",
77-
"execution_count": 5,
99+
"execution_count": 6,
78100
"metadata": {},
79101
"outputs": [
80102
{
@@ -90,20 +112,20 @@
90112
}
91113
],
92114
"source": [
93-
"# Visualize points\n",
94-
"for i in range(0,5):\n",
115+
"# Inspect a few points\n",
116+
"for i in range(0, 5):\n",
95117
" print(mesh_input.GetPoints().GetElement(i))"
96118
]
97119
},
98120
{
99121
"cell_type": "code",
100-
"execution_count": 6,
122+
"execution_count": 7,
101123
"metadata": {},
102124
"outputs": [
103125
{
104126
"data": {
105127
"application/vnd.jupyter.widget-view+json": {
106-
"model_id": "9a86a686b49a44bb982404601090aa47",
128+
"model_id": "dd14dc2d3e1942c48e154f89573a872d",
107129
"version_major": 2,
108130
"version_minor": 0
109131
},
@@ -119,64 +141,28 @@
119141
"view(geometries=[mesh_input])"
120142
]
121143
},
122-
{
123-
"cell_type": "code",
124-
"execution_count": 7,
125-
"metadata": {},
126-
"outputs": [],
127-
"source": [
128-
"# Test preservation of point data\n",
129-
"mesh_input.GetPointData().Reserve(1)\n",
130-
"mesh_input.GetPointData().SetElement(0,500) #FIXME remove"
131-
]
132-
},
133144
{
134145
"cell_type": "markdown",
135146
"metadata": {},
136147
"source": [
137148
"### Convert to `itk.PolyData`"
138149
]
139150
},
140-
{
141-
"cell_type": "code",
142-
"execution_count": 8,
143-
"metadata": {},
144-
"outputs": [],
145-
"source": [
146-
"filter = itk.MeshToPolyDataFilter[type(mesh_input)].New(Input=mesh_input)"
147-
]
148-
},
149151
{
150152
"cell_type": "code",
151153
"execution_count": 9,
152154
"metadata": {},
153155
"outputs": [],
154156
"source": [
155-
"filter.Update()"
157+
"poly_data = itk.mesh_to_poly_data_filter(mesh_input)\n",
158+
"\n",
159+
"assert type(poly_data) == itk.PolyData[itk.D]"
156160
]
157161
},
158162
{
159163
"cell_type": "code",
160164
"execution_count": 10,
161165
"metadata": {},
162-
"outputs": [],
163-
"source": [
164-
"poly_data = filter.GetOutput()"
165-
]
166-
},
167-
{
168-
"cell_type": "code",
169-
"execution_count": 11,
170-
"metadata": {},
171-
"outputs": [],
172-
"source": [
173-
"assert(type(poly_data) == itk.PolyData[itk.D])"
174-
]
175-
},
176-
{
177-
"cell_type": "code",
178-
"execution_count": 12,
179-
"metadata": {},
180166
"outputs": [
181167
{
182168
"name": "stdout",
@@ -407,7 +393,7 @@
407393
"polygons = poly_data.GetPolygons()\n",
408394
"while i < 1000:\n",
409395
" x = list()\n",
410-
" for j in range(0,polygons.ElementAt(i)):\n",
396+
" for j in range(0, polygons.ElementAt(i)):\n",
411397
" x.append(polygons.ElementAt(i + 1 + j))\n",
412398
" print(x)\n",
413399
" i += polygons.ElementAt(i) + 1"
@@ -422,54 +408,38 @@
422408
},
423409
{
424410
"cell_type": "code",
425-
"execution_count": 13,
426-
"metadata": {},
427-
"outputs": [],
428-
"source": [
429-
"filter = itk.PolyDataToMeshFilter[type(poly_data)].New(Input=poly_data)"
430-
]
431-
},
432-
{
433-
"cell_type": "code",
434-
"execution_count": 14,
435-
"metadata": {},
436-
"outputs": [],
437-
"source": [
438-
"filter.Update()"
439-
]
440-
},
441-
{
442-
"cell_type": "code",
443-
"execution_count": 15,
411+
"execution_count": 12,
444412
"metadata": {},
445413
"outputs": [],
446414
"source": [
447-
"mesh_output = filter.GetOutput()"
415+
"mesh_output = itk.poly_data_to_mesh_filter(poly_data)\n",
416+
"\n",
417+
"assert type(mesh_output) == itk.Mesh[itk.D, 3]"
448418
]
449419
},
450420
{
451421
"cell_type": "code",
452-
"execution_count": 16,
422+
"execution_count": 13,
453423
"metadata": {
454424
"scrolled": true
455425
},
456426
"outputs": [],
457427
"source": [
458-
"assert(mesh_output.GetNumberOfPoints() == mesh_input.GetNumberOfPoints())\n",
459-
"assert(mesh_output.GetNumberOfCells() == mesh_input.GetNumberOfCells())\n",
460-
"for i in range(0,mesh_output.GetNumberOfPoints()):\n",
461-
" assert(mesh_output.GetPoint(i) == mesh_input.GetPoint(i))"
428+
"assert mesh_output.GetNumberOfPoints() == mesh_input.GetNumberOfPoints()\n",
429+
"assert mesh_output.GetNumberOfCells() == mesh_input.GetNumberOfCells()\n",
430+
"for i in range(0, mesh_output.GetNumberOfPoints()):\n",
431+
" assert mesh_output.GetPoint(i) == mesh_input.GetPoint(i)"
462432
]
463433
},
464434
{
465435
"cell_type": "code",
466-
"execution_count": 17,
436+
"execution_count": 14,
467437
"metadata": {},
468438
"outputs": [
469439
{
470440
"data": {
471441
"application/vnd.jupyter.widget-view+json": {
472-
"model_id": "de7f8f07558e443392b3dbd6859b2ef0",
442+
"model_id": "71ab9ed224294f46a4ecc1711b479cea",
473443
"version_major": 2,
474444
"version_minor": 0
475445
},
@@ -488,9 +458,9 @@
488458
],
489459
"metadata": {
490460
"kernelspec": {
491-
"display_name": "venv-itk4",
461+
"display_name": "Python 3",
492462
"language": "python",
493-
"name": "venv-itk4"
463+
"name": "python3"
494464
},
495465
"language_info": {
496466
"codemirror_mode": {

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
itk>=v5.3.0
2+
itk-meshtopolydata>=0.10.0
3+
traitlets<5.7.0
4+
ipywidgets>=7.1.2
5+
itkwidgets

0 commit comments

Comments
 (0)