0
# Spatial Objects
1
2
ITK's spatial objects framework provides geometric primitives and spatial representations for modeling anatomical structures. These objects can be combined, transformed, and queried for geometric analysis and visualization.
3
4
## Base Spatial Object Classes
5
6
### SpatialObject
7
8
Base class for all spatial objects.
9
10
```cpp { .api }
11
template<unsigned int TDimension>
12
class SpatialObject : public DataObject
13
{
14
public:
15
typedef SpatialObject Self;
16
typedef DataObject Superclass;
17
typedef SmartPointer<Self> Pointer;
18
typedef SmartPointer<const Self> ConstPointer;
19
20
static Pointer New();
21
22
// Spatial queries
23
virtual bool IsInside(const PointType & point, unsigned int depth = 0, char * name = ITK_NULLPTR) const;
24
virtual bool IsInside(const PointType & point) const;
25
26
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth = 0, char * name = ITK_NULLPTR) const;
27
28
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth = 0, char * name = ITK_NULLPTR) const;
29
30
// Bounding box
31
virtual const BoundingBoxType * GetBoundingBox() const;
32
virtual bool ComputeLocalBoundingBox() const;
33
34
// Transform operations
35
void SetObjectToParentTransform(TransformType * transform);
36
itkGetConstObjectMacro(ObjectToParentTransform, TransformType);
37
38
void SetObjectToWorldTransform(TransformType * transform);
39
itkGetConstObjectMacro(ObjectToWorldTransform, TransformType);
40
41
// Hierarchy management
42
void SetChildren(ChildrenListType & children);
43
ChildrenListType * GetChildren(unsigned int depth = 0, char * name = ITK_NULLPTR);
44
const ChildrenListType & GetConstChildren(unsigned int depth = 0, char * name = ITK_NULLPTR) const;
45
46
void AddSpatialObject(Self * pointer);
47
void RemoveSpatialObject(Self * object);
48
49
// Object properties
50
void SetId(int id);
51
itkGetConstMacro(Id, int);
52
53
void SetParentId(int parentId);
54
itkGetConstMacro(ParentId, int);
55
56
// Type information
57
virtual const char * GetSpatialObjectTypeAsString() const;
58
59
// Depth and tree operations
60
unsigned int GetMaximumDepth() const;
61
void SetMaximumDepth(unsigned int depth);
62
63
protected:
64
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
65
virtual void ComputeObjectToWorldTransform();
66
};
67
```
68
69
### GroupSpatialObject
70
71
Container for grouping multiple spatial objects.
72
73
```cpp { .api }
74
template<unsigned int TDimension>
75
class GroupSpatialObject : public SpatialObject<TDimension>
76
{
77
public:
78
typedef GroupSpatialObject Self;
79
typedef SpatialObject<TDimension> Superclass;
80
typedef SmartPointer<Self> Pointer;
81
typedef SmartPointer<const Self> ConstPointer;
82
83
static Pointer New();
84
85
// Overridden spatial queries - delegates to children
86
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
87
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
88
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
89
90
// Bounding box computation
91
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
92
93
// Type identification
94
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "GroupSpatialObject"; }
95
96
protected:
97
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
98
};
99
```
100
101
## Geometric Primitives
102
103
### EllipseSpatialObject
104
105
Elliptical spatial object.
106
107
```cpp { .api }
108
template<unsigned int TDimension>
109
class EllipseSpatialObject : public SpatialObject<TDimension>
110
{
111
public:
112
typedef EllipseSpatialObject Self;
113
typedef SpatialObject<TDimension> Superclass;
114
typedef SmartPointer<Self> Pointer;
115
typedef SmartPointer<const Self> ConstPointer;
116
117
static Pointer New();
118
119
// Ellipse parameters
120
void SetRadius(double radius);
121
void SetRadius(const ArrayType & radii);
122
itkGetConstReferenceMacro(Radius, ArrayType);
123
124
// Spatial queries
125
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
126
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
127
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
128
129
// Bounding box computation
130
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
131
132
// Type identification
133
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "EllipseSpatialObject"; }
134
135
protected:
136
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
137
};
138
```
139
140
### BoxSpatialObject
141
142
Box (rectangular parallelepiped) spatial object.
143
144
```cpp { .api }
145
template<unsigned int TDimension>
146
class BoxSpatialObject : public SpatialObject<TDimension>
147
{
148
public:
149
typedef BoxSpatialObject Self;
150
typedef SpatialObject<TDimension> Superclass;
151
typedef SmartPointer<Self> Pointer;
152
typedef SmartPointer<const Self> ConstPointer;
153
154
static Pointer New();
155
156
// Box parameters
157
void SetSize(const SizeType & size);
158
itkGetConstReferenceMacro(Size, SizeType);
159
160
// Spatial queries
161
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
162
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
163
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
164
165
// Bounding box computation
166
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
167
168
// Type identification
169
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "BoxSpatialObject"; }
170
171
protected:
172
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
173
};
174
```
175
176
### CylinderSpatialObject
177
178
Cylindrical spatial object.
179
180
```cpp { .api }
181
template<unsigned int TDimension>
182
class CylinderSpatialObject : public SpatialObject<TDimension>
183
{
184
public:
185
typedef CylinderSpatialObject Self;
186
typedef SpatialObject<TDimension> Superclass;
187
typedef SmartPointer<Self> Pointer;
188
typedef SmartPointer<const Self> ConstPointer;
189
190
static Pointer New();
191
192
// Cylinder parameters
193
void SetRadius(double radius);
194
itkGetConstMacro(Radius, double);
195
196
void SetHeight(double height);
197
itkGetConstMacro(Height, double);
198
199
// Spatial queries
200
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
201
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
202
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
203
204
// Bounding box computation
205
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
206
207
// Type identification
208
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "CylinderSpatialObject"; }
209
210
protected:
211
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
212
};
213
```
214
215
## Complex Spatial Objects
216
217
### TubeSpatialObject
218
219
Represents tubular structures like blood vessels.
220
221
```cpp { .api }
222
template<unsigned int TDimension>
223
class TubeSpatialObject : public SpatialObject<TDimension>
224
{
225
public:
226
typedef TubeSpatialObject Self;
227
typedef SpatialObject<TDimension> Superclass;
228
typedef SmartPointer<Self> Pointer;
229
typedef SmartPointer<const Self> ConstPointer;
230
231
static Pointer New();
232
233
// Tube point management
234
typedef TubeSpatialObjectPoint<TDimension> TubePointType;
235
typedef std::vector<TubePointType> PointListType;
236
237
void SetPoints(const PointListType & points);
238
const PointListType & GetPoints() const;
239
PointListType & GetPoints();
240
241
// Point access
242
const TubePointType * GetPoint(IdentifierType id) const;
243
TubePointType * GetPoint(IdentifierType id);
244
SizeValueType GetNumberOfPoints() const;
245
246
// Tube properties
247
void SetEndType(unsigned int endType);
248
itkGetConstMacro(EndType, unsigned int);
249
250
void SetRoot(bool root);
251
itkGetConstMacro(Root, bool);
252
253
void SetArtery(bool artery);
254
itkGetConstMacro(Artery, bool);
255
256
// Spatial queries
257
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
258
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
259
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
260
261
// Bounding box computation
262
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
263
264
// Type identification
265
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "TubeSpatialObject"; }
266
267
protected:
268
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
269
};
270
```
271
272
### VesselTubeSpatialObject
273
274
Specialized tube for blood vessel representation.
275
276
```cpp { .api }
277
template<unsigned int TDimension>
278
class VesselTubeSpatialObject : public TubeSpatialObject<TDimension>
279
{
280
public:
281
typedef VesselTubeSpatialObject Self;
282
typedef TubeSpatialObject<TDimension> Superclass;
283
typedef SmartPointer<Self> Pointer;
284
typedef SmartPointer<const Self> ConstPointer;
285
286
static Pointer New();
287
288
// Vessel-specific point type
289
typedef VesselTubeSpatialObjectPoint<TDimension> VesselTubePointType;
290
typedef std::vector<VesselTubePointType> VesselTubePointListType;
291
292
// Type identification
293
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "VesselTubeSpatialObject"; }
294
295
protected:
296
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
297
};
298
```
299
300
### DTITubeSpatialObject
301
302
Diffusion tensor imaging tube representation.
303
304
```cpp { .api }
305
template<unsigned int TDimension>
306
class DTITubeSpatialObject : public TubeSpatialObject<TDimension>
307
{
308
public:
309
typedef DTITubeSpatialObject Self;
310
typedef TubeSpatialObject<TDimension> Superclass;
311
typedef SmartPointer<Self> Pointer;
312
typedef SmartPointer<const Self> ConstPointer;
313
314
static Pointer New();
315
316
// DTI-specific point type
317
typedef DTITubeSpatialObjectPoint<TDimension> DTITubePointType;
318
typedef std::vector<DTITubePointType> DTITubePointListType;
319
320
// Type identification
321
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "DTITubeSpatialObject"; }
322
323
protected:
324
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
325
};
326
```
327
328
## Point-Based Spatial Objects
329
330
### LandmarkSpatialObject
331
332
Represents anatomical landmarks.
333
334
```cpp { .api }
335
template<unsigned int TDimension>
336
class LandmarkSpatialObject : public SpatialObject<TDimension>
337
{
338
public:
339
typedef LandmarkSpatialObject Self;
340
typedef SpatialObject<TDimension> Superclass;
341
typedef SmartPointer<Self> Pointer;
342
typedef SmartPointer<const Self> ConstPointer;
343
344
static Pointer New();
345
346
// Landmark point management
347
typedef SpatialObjectPoint<TDimension> LandmarkPointType;
348
typedef std::vector<LandmarkPointType> PointListType;
349
350
void SetPoints(const PointListType & points);
351
const PointListType & GetPoints() const;
352
PointListType & GetPoints();
353
354
// Point access
355
const LandmarkPointType * GetPoint(IdentifierType id) const;
356
LandmarkPointType * GetPoint(IdentifierType id);
357
SizeValueType GetNumberOfPoints() const;
358
359
// Spatial queries
360
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
361
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
362
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
363
364
// Bounding box computation
365
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
366
367
// Type identification
368
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "LandmarkSpatialObject"; }
369
370
protected:
371
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
372
};
373
```
374
375
### LineSpatialObject
376
377
Represents line segments and polylines.
378
379
```cpp { .api }
380
template<unsigned int TDimension>
381
class LineSpatialObject : public SpatialObject<TDimension>
382
{
383
public:
384
typedef LineSpatialObject Self;
385
typedef SpatialObject<TDimension> Superclass;
386
typedef SmartPointer<Self> Pointer;
387
typedef SmartPointer<const Self> ConstPointer;
388
389
static Pointer New();
390
391
// Line point management
392
typedef LineSpatialObjectPoint<TDimension> LinePointType;
393
typedef std::vector<LinePointType> PointListType;
394
395
void SetPoints(const PointListType & points);
396
const PointListType & GetPoints() const;
397
PointListType & GetPoints();
398
399
// Point access
400
const LinePointType * GetPoint(IdentifierType id) const;
401
LinePointType * GetPoint(IdentifierType id);
402
SizeValueType GetNumberOfPoints() const;
403
404
// Spatial queries
405
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
406
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
407
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
408
409
// Bounding box computation
410
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
411
412
// Type identification
413
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "LineSpatialObject"; }
414
415
protected:
416
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
417
};
418
```
419
420
## Image-Based Spatial Objects
421
422
### ImageSpatialObject
423
424
Wraps an image as a spatial object.
425
426
```cpp { .api }
427
template<unsigned int TDimension, typename TPixelType>
428
class ImageSpatialObject : public SpatialObject<TDimension>
429
{
430
public:
431
typedef ImageSpatialObject Self;
432
typedef SpatialObject<TDimension> Superclass;
433
typedef SmartPointer<Self> Pointer;
434
typedef SmartPointer<const Self> ConstPointer;
435
436
static Pointer New();
437
438
// Image access
439
typedef Image<TPixelType, TDimension> ImageType;
440
typedef typename ImageType::Pointer ImagePointer;
441
typedef typename ImageType::ConstPointer ImageConstPointer;
442
443
void SetImage(const ImageType * image);
444
ImageType * GetImage();
445
const ImageType * GetImage() const;
446
447
// Spatial queries
448
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
449
virtual bool IsEvaluableAt(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
450
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
451
452
// Bounding box computation
453
virtual bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
454
455
// Slice access (for 3D images)
456
const ImageType * GetSlice(unsigned int dimension, unsigned int slicePosition) const;
457
458
// Type identification
459
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "ImageSpatialObject"; }
460
461
protected:
462
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
463
};
464
```
465
466
### ImageMaskSpatialObject
467
468
Binary mask spatial object.
469
470
```cpp { .api }
471
template<unsigned int TDimension>
472
class ImageMaskSpatialObject : public ImageSpatialObject<TDimension, unsigned char>
473
{
474
public:
475
typedef ImageMaskSpatialObject Self;
476
typedef ImageSpatialObject<TDimension, unsigned char> Superclass;
477
typedef SmartPointer<Self> Pointer;
478
typedef SmartPointer<const Self> ConstPointer;
479
480
static Pointer New();
481
482
// Spatial queries override for binary masks
483
virtual bool IsInside(const PointType & point, unsigned int depth, char * name) const ITK_OVERRIDE;
484
virtual bool ValueAt(const PointType & point, double & value, unsigned int depth, char * name) const ITK_OVERRIDE;
485
486
// Type identification
487
virtual const char * GetSpatialObjectTypeAsString() const ITK_OVERRIDE { return "ImageMaskSpatialObject"; }
488
489
protected:
490
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
491
};
492
```
493
494
## Spatial Object Points
495
496
### SpatialObjectPoint
497
498
Base class for spatial object points.
499
500
```cpp { .api }
501
template<unsigned int TPointDimension>
502
class SpatialObjectPoint
503
{
504
public:
505
typedef SpatialObjectPoint Self;
506
typedef Point<double, TPointDimension> PointType;
507
typedef Vector<double, TPointDimension> VectorType;
508
typedef CovariantVector<double, TPointDimension> CovariantVectorType;
509
510
// Constructors
511
SpatialObjectPoint();
512
virtual ~SpatialObjectPoint();
513
SpatialObjectPoint(const Self & other);
514
const Self & operator=(const Self & other);
515
516
// Position access
517
const PointType & GetPosition() const;
518
void SetPosition(const PointType & newPosition);
519
void SetPosition(double x0);
520
void SetPosition(double x0, double x1);
521
void SetPosition(double x0, double x1, double x2);
522
523
// Color
524
void SetColor(double red, double green, double blue, double alpha = 1);
525
void SetColor(const ColorType & color);
526
const ColorType & GetColor() const;
527
528
// Identification
529
void SetID(int id);
530
int GetID() const;
531
532
// Selection
533
void SetSelected(bool selected);
534
bool GetSelected() const;
535
536
// Printing
537
virtual void PrintSelf(std::ostream & os, Indent indent) const;
538
539
protected:
540
PointType m_Position;
541
ColorType m_Color;
542
int m_ID;
543
bool m_Selected;
544
};
545
```
546
547
### TubeSpatialObjectPoint
548
549
Point type for tube spatial objects.
550
551
```cpp { .api }
552
template<unsigned int TPointDimension>
553
class TubeSpatialObjectPoint : public SpatialObjectPoint<TPointDimension>
554
{
555
public:
556
typedef TubeSpatialObjectPoint Self;
557
typedef SpatialObjectPoint<TPointDimension> Superclass;
558
559
// Constructors
560
TubeSpatialObjectPoint();
561
virtual ~TubeSpatialObjectPoint();
562
TubeSpatialObjectPoint(const Self & other);
563
const Self & operator=(const Self & other);
564
565
// Radius
566
void SetRadius(double radius);
567
double GetRadius() const;
568
569
// Medialness
570
void SetMedialness(double medialness);
571
double GetMedialness() const;
572
573
// Ridgeness
574
void SetRidgeness(double ridgeness);
575
double GetRidgeness() const;
576
577
// Branchness
578
void SetBranchness(double branchness);
579
double GetBranchness() const;
580
581
// Mark
582
void SetMark(bool mark);
583
bool GetMark() const;
584
585
// Tangent
586
const VectorType & GetTangent() const;
587
void SetTangent(const VectorType & tangent);
588
void SetTangent(double t0, double t1);
589
void SetTangent(double t0, double t1, double t2);
590
591
// Normal vectors
592
const CovariantVectorType & GetNormal1() const;
593
void SetNormal1(const CovariantVectorType & normal);
594
void SetNormal1(double n0, double n1);
595
void SetNormal1(double n0, double n1, double n2);
596
597
const CovariantVectorType & GetNormal2() const;
598
void SetNormal2(const CovariantVectorType & normal);
599
void SetNormal2(double n0, double n1);
600
void SetNormal2(double n0, double n1, double n2);
601
602
// Printing
603
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
604
605
protected:
606
double m_Radius;
607
double m_Medialness;
608
double m_Ridgeness;
609
double m_Branchness;
610
bool m_Mark;
611
VectorType m_Tangent;
612
CovariantVectorType m_Normal1;
613
CovariantVectorType m_Normal2;
614
};
615
```
616
617
## Common Usage Patterns
618
619
### Creating Geometric Primitives
620
621
```cpp
622
// Create an ellipse spatial object
623
typedef itk::EllipseSpatialObject<3> EllipseType;
624
EllipseType::Pointer ellipse = EllipseType::New();
625
626
// Set ellipse parameters
627
EllipseType::ArrayType radii;
628
radii[0] = 10.0; // X radius
629
radii[1] = 5.0; // Y radius
630
radii[2] = 3.0; // Z radius
631
ellipse->SetRadius(radii);
632
633
// Create transform to position ellipse
634
typedef itk::AffineTransform<double, 3> TransformType;
635
TransformType::Pointer transform = TransformType::New();
636
TransformType::OutputVectorType translation;
637
translation[0] = 50.0;
638
translation[1] = 50.0;
639
translation[2] = 50.0;
640
transform->Translate(translation);
641
ellipse->SetObjectToParentTransform(transform);
642
643
// Test if points are inside
644
EllipseType::PointType testPoint;
645
testPoint[0] = 52.0;
646
testPoint[1] = 48.0;
647
testPoint[2] = 51.0;
648
649
if (ellipse->IsInside(testPoint)) {
650
std::cout << "Point is inside ellipse" << std::endl;
651
}
652
```
653
654
### Creating Tube Spatial Objects
655
656
```cpp
657
// Create vessel tube spatial object
658
typedef itk::VesselTubeSpatialObject<3> VesselTubeType;
659
VesselTubeType::Pointer vesselTube = VesselTubeType::New();
660
661
// Create vessel points
662
typedef VesselTubeType::VesselTubePointType VesselPointType;
663
typedef VesselTubeType::VesselTubePointListType PointListType;
664
665
PointListType pointList;
666
667
// Add centerline points with radii
668
for (int i = 0; i < 10; ++i) {
669
VesselPointType point;
670
point.SetPosition(i * 2.0, 0.0, 0.0); // Along X axis
671
point.SetRadius(1.0 + 0.1 * i); // Increasing radius
672
point.SetMedialness(0.8);
673
point.SetRidgeness(0.7);
674
pointList.push_back(point);
675
}
676
677
vesselTube->SetPoints(pointList);
678
vesselTube->SetArtery(true);
679
vesselTube->SetRoot(true);
680
681
std::cout << "Vessel tube has " << vesselTube->GetNumberOfPoints() << " points" << std::endl;
682
```
683
684
### Hierarchical Spatial Objects
685
686
```cpp
687
// Create group to contain multiple objects
688
typedef itk::GroupSpatialObject<3> GroupType;
689
GroupType::Pointer group = GroupType::New();
690
691
// Create multiple objects
692
typedef itk::BoxSpatialObject<3> BoxType;
693
BoxType::Pointer box1 = BoxType::New();
694
BoxType::Pointer box2 = BoxType::New();
695
696
// Configure boxes
697
BoxType::SizeType size;
698
size[0] = 10.0; size[1] = 10.0; size[2] = 10.0;
699
box1->SetSize(size);
700
box2->SetSize(size);
701
702
// Position boxes
703
TransformType::Pointer transform1 = TransformType::New();
704
TransformType::Pointer transform2 = TransformType::New();
705
706
TransformType::OutputVectorType translation1, translation2;
707
translation1.Fill(0.0);
708
translation2[0] = 15.0; translation2[1] = 0.0; translation2[2] = 0.0;
709
710
transform1->Translate(translation1);
711
transform2->Translate(translation2);
712
713
box1->SetObjectToParentTransform(transform1);
714
box2->SetObjectToParentTransform(transform2);
715
716
// Add to group
717
group->AddSpatialObject(box1);
718
group->AddSpatialObject(box2);
719
720
// Test spatial queries on group
721
GroupType::PointType queryPoint;
722
queryPoint[0] = 5.0; queryPoint[1] = 5.0; queryPoint[2] = 5.0;
723
724
if (group->IsInside(queryPoint)) {
725
std::cout << "Point is inside one of the boxes in the group" << std::endl;
726
}
727
```
728
729
## Type Definitions
730
731
```cpp { .api }
732
// Common spatial object instantiations
733
typedef SpatialObject<2> SpatialObject2D;
734
typedef SpatialObject<3> SpatialObject3D;
735
typedef GroupSpatialObject<2> GroupSpatialObject2D;
736
typedef GroupSpatialObject<3> GroupSpatialObject3D;
737
738
typedef EllipseSpatialObject<2> EllipseSpatialObject2D;
739
typedef EllipseSpatialObject<3> EllipseSpatialObject3D;
740
typedef BoxSpatialObject<2> BoxSpatialObject2D;
741
typedef BoxSpatialObject<3> BoxSpatialObject3D;
742
typedef CylinderSpatialObject<3> CylinderSpatialObject3D;
743
744
typedef TubeSpatialObject<2> TubeSpatialObject2D;
745
typedef TubeSpatialObject<3> TubeSpatialObject3D;
746
typedef VesselTubeSpatialObject<2> VesselTubeSpatialObject2D;
747
typedef VesselTubeSpatialObject<3> VesselTubeSpatialObject3D;
748
typedef DTITubeSpatialObject<3> DTITubeSpatialObject3D;
749
750
typedef LandmarkSpatialObject<2> LandmarkSpatialObject2D;
751
typedef LandmarkSpatialObject<3> LandmarkSpatialObject3D;
752
typedef LineSpatialObject<2> LineSpatialObject2D;
753
typedef LineSpatialObject<3> LineSpatialObject3D;
754
755
typedef ImageSpatialObject<2, unsigned char> BinaryImageSpatialObject2D;
756
typedef ImageSpatialObject<3, unsigned char> BinaryImageSpatialObject3D;
757
typedef ImageSpatialObject<2, float> FloatImageSpatialObject2D;
758
typedef ImageSpatialObject<3, float> FloatImageSpatialObject3D;
759
760
// Point types
761
typedef SpatialObjectPoint<2> SpatialObjectPoint2D;
762
typedef SpatialObjectPoint<3> SpatialObjectPoint3D;
763
typedef TubeSpatialObjectPoint<2> TubeSpatialObjectPoint2D;
764
typedef TubeSpatialObjectPoint<3> TubeSpatialObjectPoint3D;
765
typedef VesselTubeSpatialObjectPoint<2> VesselTubeSpatialObjectPoint2D;
766
typedef VesselTubeSpatialObjectPoint<3> VesselTubeSpatialObjectPoint3D;
767
768
// Container types
769
typedef std::vector<SpatialObjectPoint2D> PointList2D;
770
typedef std::vector<SpatialObjectPoint3D> PointList3D;
771
typedef std::list<SpatialObject2D::Pointer> ChildrenList2D;
772
typedef std::list<SpatialObject3D::Pointer> ChildrenList3D;
773
774
// Color type
775
typedef RGBAPixel<float> ColorType;
776
777
// Transform types
778
typedef AffineTransform<double, 2> AffineTransform2D;
779
typedef AffineTransform<double, 3> AffineTransform3D;
780
781
// Bounding box types
782
typedef BoundingBox<PointIdentifier, 2, double> BoundingBox2D;
783
typedef BoundingBox<PointIdentifier, 3, double> BoundingBox3D;
784
```
785
786
ITK's spatial objects framework provides a comprehensive system for geometric modeling and spatial analysis, enabling representation of complex anatomical structures and their relationships in medical imaging applications.