Orfeo Toolbox  3.16
itkMetaGroupConverter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkMetaGroupConverter.txx,v $
5  Language: C++
6  Date: $Date: 2007-01-28 19:24:56 $
7  Version: $Revision: 1.4 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkMetaGroupConverter_txx
18 #define __itkMetaGroupConverter_txx
19 
20 #include "itkMetaGroupConverter.h"
21 
22 namespace itk
23 {
24 
26 template <unsigned int NDimensions>
29 {
30 
31 }
32 
33 
35 template <unsigned int NDimensions>
39 {
40  SpatialObjectPointer spatialObject = SpatialObjectType::New();
41  double spacing[NDimensions];
42  unsigned int i;
43  for(i=0; i<NDimensions; i++)
44  {
45  spacing[i] = group->ElementSpacing()[i];
46  }
47  spatialObject->GetIndexToObjectTransform()->SetScaleComponent(spacing);
48  spatialObject->GetProperty()->SetName(group->Name());
49  spatialObject->GetProperty()->SetRed(group->Color()[0]);
50  spatialObject->GetProperty()->SetGreen(group->Color()[1]);
51  spatialObject->GetProperty()->SetBlue(group->Color()[2]);
52  spatialObject->GetProperty()->SetAlpha(group->Color()[3]);
53  spatialObject->SetId(group->ID());
54  spatialObject->SetParentId(group->ParentID());
55  return spatialObject;
56 }
57 
59 template <unsigned int NDimensions>
60 MetaGroup*
63 {
64  MetaGroup* group = new MetaGroup(NDimensions);
65 
66  float color[4];
67  for(unsigned int i=0;i<4;i++)
68  {
69  color[i]=spatialObject->GetProperty()->GetColor()[i];
70  }
71  group->Color(color);
72 
73  for(unsigned int i=0;i<NDimensions;i++)
74  {
75  group->ElementSpacing(i,spatialObject->GetIndexToObjectTransform()
76  ->GetScaleComponent()[i]);
77  }
78 
79  if(spatialObject->GetParent())
80  {
81  group->ParentID(spatialObject->GetParent()->GetId());
82  }
83  group->ID(spatialObject->GetId());
84 
85  return group;
86 }
87 
88 
90 template <unsigned int NDimensions>
93 ::ReadMeta(const char* name)
94 {
95  SpatialObjectPointer spatialObject;
96  MetaGroup* group = new MetaGroup();
97  group->Read(name);
98  spatialObject = this->MetaGroupToGroupSpatialObject(group);
99 
100  return spatialObject;
101 }
102 
103 
105 template <unsigned int NDimensions>
106 bool
108 ::WriteMeta(SpatialObjectType* spatialObject,const char* name)
109 {
110  MetaGroup* group = this->GroupSpatialObjectToMetaGroup(spatialObject);
111  group->Write(name);
112  return true;
113 }
114 
115 } // end namespace itk
116 
117 #endif

Generated at Sat Feb 2 2013 23:52:44 for Orfeo Toolbox with doxygen 1.8.1.1