1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
|
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkRTStructSetProperties.h"
#include "vtkObjectFactory.h"
#include "gdcmDirectory.h"
#include "gdcmScanner.h"
#include "gdcmDataSet.h"
#include "gdcmReader.h"
#include <string>
#include <map>
#include <vector>
#include <set>
#include <time.h> // for strftime
#include <ctype.h> // for isdigit
#include <assert.h>
//----------------------------------------------------------------------------
//vtkCxxRevisionMacro(vtkRTStructSetProperties, "1.21")
vtkStandardNewMacro(vtkRTStructSetProperties)
struct StructureSetROI
{
int ROINumber;
std::string RefFrameRefUID;
std::string ROIName;
std::string ROIGenerationAlgorithm;
std::string ROIDescription;
// (3006,0080) SQ (Sequence with undefine)# u/l, 1 RTROIObservationsSequence
// (3006,0082) IS [0] # 2, 1 ObservationNumber
// (3006,0084) IS [0] # 2, 1 ReferencedROINumber
// (3006,0085) SH [Station 4L] # 10, 1 ROIObservationLabel
// (3006,00a4) CS [ORGAN] # 6, 1 RTROIInterpretedType
// (3006,00a6) PN (no value available) # 0, 0 ROIInterpreter
int ObservationNumber;
// RefROI is AFAIK simply ROINumber
std::string RTROIInterpretedType;
std::string ROIInterpreter;
std::string ROIObservationLabel;
};
//----------------------------------------------------------------------------
class vtkRTStructSetPropertiesInternals
{
public:
void Print(ostream &os, vtkIndent indent)
{
(void)os;
(void)indent;
}
void DeepCopy(vtkRTStructSetPropertiesInternals *p)
{
ReferencedFrameOfReferences = p->ReferencedFrameOfReferences;
}
vtkIdType GetNumberOfContourReferencedFrameOfReferences()
{
return ContourReferencedFrameOfReferences.size();
}
vtkIdType GetNumberOfContourReferencedFrameOfReferences(vtkIdType pdnum)
{
return ContourReferencedFrameOfReferences[pdnum].size();
}
const char *GetContourReferencedFrameOfReferenceClassUID( vtkIdType pdnum, vtkIdType id )
{
return ContourReferencedFrameOfReferences[pdnum][ id ].first.c_str();
}
const char *GetContourReferencedFrameOfReferenceInstanceUID( vtkIdType pdnum, vtkIdType id )
{
return ContourReferencedFrameOfReferences[pdnum][ id ].second.c_str();
}
vtkIdType GetNumberOfReferencedFrameOfReferences()
{
return ReferencedFrameOfReferences.size();
}
const char *GetReferencedFrameOfReferenceClassUID( vtkIdType id )
{
return ReferencedFrameOfReferences[ id ].first.c_str();
}
const char *GetReferencedFrameOfReferenceInstanceUID(vtkIdType id )
{
return ReferencedFrameOfReferences[ id ].second.c_str();
}
void AddContourReferencedFrameOfReference( vtkIdType pdnum, const char *classuid , const char * instanceuid )
{
ContourReferencedFrameOfReferences.resize(pdnum+1);
ContourReferencedFrameOfReferences[pdnum].push_back(
std::make_pair( classuid, instanceuid ) );
}
std::vector< std::vector < std::pair< std::string, std::string > > > ContourReferencedFrameOfReferences;
void AddReferencedFrameOfReference( const char *classuid , const char * instanceuid )
{
ReferencedFrameOfReferences.push_back(
std::make_pair( classuid, instanceuid ) );
}
std::vector < std::pair< std::string, std::string > > ReferencedFrameOfReferences;
void AddStructureSetROIObservation( int refnumber,
int observationnumber,
const char *rtroiinterpretedtype,
const char *roiinterpreter,
const char *roiobservationlabel
)
{
//std::cout << "AddStructureSetROIObservation: " << refnumber << std::endl;
std::vector<StructureSetROI>::iterator it = StructureSetROIs.begin();
bool found = false;
for( ; it != StructureSetROIs.end(); ++it )
{
if( it->ROINumber == refnumber )
{
assert( !found );
found = true;
it->ObservationNumber = observationnumber;
if( rtroiinterpretedtype )
it->RTROIInterpretedType = rtroiinterpretedtype;
if( roiinterpreter )
it->ROIInterpreter = roiinterpreter;
if( roiobservationlabel )
it->ROIObservationLabel = roiobservationlabel;
}
}
// postcond
assert( found );
}
void AddStructureSetROI( int roinumber,
const char* refframerefuid,
const char* roiname,
const char* roigenerationalgorithm,
const char* roidescription
)
{
StructureSetROI structuresetroi;
structuresetroi.ROINumber = roinumber;
if( refframerefuid )
structuresetroi.RefFrameRefUID = refframerefuid;
if( roiname )
structuresetroi.ROIName = roiname;
if( roigenerationalgorithm )
structuresetroi.ROIGenerationAlgorithm = roigenerationalgorithm;
if( roidescription )
structuresetroi.ROIDescription = roidescription;
StructureSetROIs.push_back( structuresetroi );
}
vtkIdType GetNumberOfStructureSetROIs()
{
return StructureSetROIs.size();
}
int GetStructureSetObservationNumber(vtkIdType id)
{
return StructureSetROIs[id].ObservationNumber;
}
int GetStructureSetROINumber(vtkIdType id)
{
return StructureSetROIs[id].ROINumber;
}
const char *GetStructureSetRTROIInterpretedType(vtkIdType id)
{
return StructureSetROIs[id].RTROIInterpretedType.c_str();
}
const char *GetStructureSetROIObservationLabel(vtkIdType id)
{
return StructureSetROIs[id].ROIObservationLabel.c_str();
}
const char *GetStructureSetROIRefFrameRefUID(vtkIdType id)
{
return StructureSetROIs[id].RefFrameRefUID.c_str();
}
const char *GetStructureSetROIName(vtkIdType id)
{
return StructureSetROIs[id].ROIName.c_str();
}
const char *GetStructureSetROIGenerationAlgorithm(vtkIdType id)
{
return StructureSetROIs[id].ROIGenerationAlgorithm.c_str();
}
const char *GetStructureSetROIDescription(vtkIdType id)
{
return StructureSetROIs[id].ROIDescription.c_str();
}
std::vector<StructureSetROI> StructureSetROIs;
};
//----------------------------------------------------------------------------
vtkRTStructSetProperties::vtkRTStructSetProperties()
{
this->Internals = new vtkRTStructSetPropertiesInternals;
this->StructureSetLabel = NULL;
this->StructureSetName = NULL;
this->StructureSetDate = NULL;
this->StructureSetTime = NULL;
this->SOPInstanceUID= NULL;
this->StudyInstanceUID = NULL;
this->SeriesInstanceUID = NULL;
this->ReferenceSeriesInstanceUID = NULL;
this->ReferenceFrameOfReferenceUID = NULL;
}
//----------------------------------------------------------------------------
vtkRTStructSetProperties::~vtkRTStructSetProperties()
{
delete this->Internals;
this->Clear();
}
//----------------------------------------------------------------------------
void vtkRTStructSetProperties::AddContourReferencedFrameOfReference(vtkIdType pdnum, const char *classuid , const char * instanceuid )
{
this->Internals->AddContourReferencedFrameOfReference(pdnum, classuid, instanceuid );
}
const char *vtkRTStructSetProperties::GetContourReferencedFrameOfReferenceClassUID( vtkIdType pdnum, vtkIdType id )
{
return this->Internals->GetContourReferencedFrameOfReferenceClassUID(pdnum, id );
}
const char *vtkRTStructSetProperties::GetContourReferencedFrameOfReferenceInstanceUID( vtkIdType pdnum, vtkIdType id )
{
return this->Internals->GetContourReferencedFrameOfReferenceInstanceUID(pdnum ,id );
}
vtkIdType vtkRTStructSetProperties::GetNumberOfContourReferencedFrameOfReferences()
{
return this->Internals->GetNumberOfContourReferencedFrameOfReferences();
}
vtkIdType vtkRTStructSetProperties::GetNumberOfContourReferencedFrameOfReferences(vtkIdType pdnum)
{
return this->Internals->GetNumberOfContourReferencedFrameOfReferences(pdnum);
}
void vtkRTStructSetProperties::AddReferencedFrameOfReference( const char *classuid , const char * instanceuid )
{
this->Internals->AddReferencedFrameOfReference( classuid, instanceuid );
}
const char *vtkRTStructSetProperties::GetReferencedFrameOfReferenceClassUID( vtkIdType id )
{
return this->Internals->GetReferencedFrameOfReferenceClassUID(id );
}
const char *vtkRTStructSetProperties::GetReferencedFrameOfReferenceInstanceUID( vtkIdType id )
{
return this->Internals->GetReferencedFrameOfReferenceInstanceUID(id );
}
vtkIdType vtkRTStructSetProperties::GetNumberOfReferencedFrameOfReferences()
{
return this->Internals->GetNumberOfReferencedFrameOfReferences();
}
void vtkRTStructSetProperties::AddStructureSetROIObservation( int refnumber,
int observationnumber,
const char *rtroiinterpretedtype,
const char *roiinterpreter,
const char *roiobservationlabel
)
{
this->Internals->AddStructureSetROIObservation( refnumber, observationnumber, rtroiinterpretedtype, roiinterpreter, roiobservationlabel );
}
void vtkRTStructSetProperties::AddStructureSetROI( int roinumber,
const char* refframerefuid,
const char* roiname,
const char* roigenerationalgorithm,
const char* roidescription
)
{
this->Internals->AddStructureSetROI( roinumber, refframerefuid, roiname, roigenerationalgorithm, roidescription );
}
vtkIdType vtkRTStructSetProperties::GetNumberOfStructureSetROIs()
{
return this->Internals->GetNumberOfStructureSetROIs();
}
int vtkRTStructSetProperties::GetStructureSetObservationNumber(vtkIdType id)
{
return this->Internals->GetStructureSetObservationNumber(id);
}
int vtkRTStructSetProperties::GetStructureSetROINumber(vtkIdType id)
{
return this->Internals->GetStructureSetROINumber(id);
}
const char *vtkRTStructSetProperties::GetStructureSetRTROIInterpretedType(vtkIdType id)
{
return this->Internals->GetStructureSetRTROIInterpretedType(id);
}
const char *vtkRTStructSetProperties::GetStructureSetROIObservationLabel(vtkIdType id)
{
return this->Internals->GetStructureSetROIObservationLabel(id);
}
const char *vtkRTStructSetProperties::GetStructureSetROIRefFrameRefUID(vtkIdType id)
{
return this->Internals->GetStructureSetROIRefFrameRefUID(id);
}
const char *vtkRTStructSetProperties::GetStructureSetROIName(vtkIdType id)
{
return this->Internals->GetStructureSetROIName(id);
}
const char *vtkRTStructSetProperties::GetStructureSetROIGenerationAlgorithm(vtkIdType id)
{
return this->Internals->GetStructureSetROIGenerationAlgorithm(id);
}
const char *vtkRTStructSetProperties::GetStructureSetROIDescription(vtkIdType id)
{
return this->Internals->GetStructureSetROIDescription(id);
}
//----------------------------------------------------------------------------
void vtkRTStructSetProperties::Clear()
{
this->SetStructureSetLabel(NULL);
this->SetStructureSetName(NULL);
this->SetStructureSetDate(NULL);
this->SetStructureSetTime(NULL);
this->SetSOPInstanceUID( NULL );
this->SetStudyInstanceUID ( NULL );
this->SetSeriesInstanceUID ( NULL );
this->SetReferenceSeriesInstanceUID ( NULL );
this->SetReferenceFrameOfReferenceUID ( NULL );
}
//----------------------------------------------------------------------------
void vtkRTStructSetProperties::DeepCopy(vtkRTStructSetProperties *p)
{
if (p == NULL)
{
return;
}
this->Clear();
this->SetStructureSetDate(p->GetStructureSetDate());
this->SetStructureSetTime(p->GetStructureSetTime());
this->Internals->DeepCopy( p->Internals );
}
//----------------------------------------------------------------------------
void vtkRTStructSetProperties::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << "\n" << indent << "StructureSetDate: ";
if (this->StructureSetDate)
{
os << this->StructureSetDate;
}
os << "\n" << indent << "StructureSetTime: ";
if (this->StructureSetTime)
{
os << this->StructureSetTime;
}
this->Internals->Print(os << "\n", indent.GetNextIndent() );
}
|