ITK  5.0.0
Insight Segmentation and Registration Toolkit
SphinxExamples/src/Core/Common/CreateAPointSet/Code.py
1 #!/usr/bin/env python
2 
3 # ==========================================================================
4 #
5 # Copyright Insight Software Consortium
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License")
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0.txt
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 # ==========================================================================*/
20 
21 import itk
22 
23 PixelType = itk.F
24 Dimension = 3
25 
26 MeshTraits = itk.DefaultStaticMeshTraits[PixelType, Dimension, Dimension]
27 PointSetType = itk.PointSet[PixelType, Dimension, MeshTraits]
28 PointSet = PointSetType.New()
29 
30 points = PointSet.GetPoints()
31 
32 # Create points
33 p0 = itk.Point[PixelType, Dimension]()
34 p1 = itk.Point[PixelType, Dimension]()
35 p2 = itk.Point[PixelType, Dimension]()
36 
37 p0[0] = 0.0
38 p0[1] = 0.0
39 p0[2] = 0.0
40 p1[0] = 0.1
41 p1[1] = 0.0
42 p1[2] = 0.0
43 p2[0] = 0.0
44 p2[1] = 0.1
45 p2[2] = 0.0
46 
47 points.InsertElement(0, p0)
48 points.InsertElement(1, p1)
49 points.InsertElement(2, p2)