Geant4  10.03
DicomROIContour.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 #include "DicomROIContour.hh"
27 
28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 {
31 }
32 
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 void DicomROIContour::SetData( std::vector<G4ThreeVector> data )
35 {
36  thePoints = data;
37  if( theGeomType == "CLOSED_PLANAR" ){
38  //add a last point to close the circle
39  thePoints.push_back( thePoints[0] );
40  for( size_t ii = 1; ii < thePoints.size(); ii++ ){
41  theDirections.push_back( thePoints[ii] - thePoints[ii-1] );
42  }
43  theDirections.push_back( thePoints[0] - thePoints[thePoints.size()-1] ); // (0,0)
44  }
45 }
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 {
50  if( thePoints.size() == 0 ) {
51  G4Exception("DicomROIContour::GetZ",
52  "DRC001",
54  "No Point in contour");
55  Print(G4cout);
56  return DBL_MAX;
57  }
58  return thePoints[0].z();
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 void DicomROIContour::AddPoints( std::vector<G4ThreeVector> points )
63 {
64  points.push_back( points[0] );
65  size_t npold = thePoints.size();
66  for( size_t ii = 0; ii < points.size(); ii++ ) {
67  thePoints.push_back( points[ii] );
68  }
69 
70  for( size_t ii = npold+1; ii < thePoints.size(); ii++ ){
71  theDirections.push_back( thePoints[ii] - thePoints[ii-1] );
72  }
73  theDirections.push_back( thePoints[npold] - thePoints[thePoints.size()-1] );
74 
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 void DicomROIContour::Print( std::ostream& out )
79 {
80 
81  out << this << "@@@ NUMBER OF ContourImageSequences " << theImageIUIDs.size() << G4endl;
82  for( size_t ii = 0; ii < theImageIUIDs.size(); ii++ ) {
83  out << "ContourImageSequence I= " << theImageIUIDs[ii] << G4endl;
84  }
85  out << "@@@ GeomType " << theGeomType << " NPOINTS " << thePoints.size() << G4endl;
86  for( size_t ii = 0; ii < thePoints.size(); ii++ ) {
87  out << "(" << thePoints[ii].x()<< "," << thePoints[ii].y()<< "," << thePoints[ii].z()
88  << ")" << G4endl;
89  }
90 
91 }
void Print(std::ostream &out)
void SetData(std::vector< G4ThreeVector > data)
G4GLOB_DLL std::ostream G4cout
std::vector< OFString > theImageIUIDs
std::vector< G4ThreeVector > thePoints
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::vector< G4ThreeVector > theDirections
#define G4endl
Definition: G4ios.hh:61
void AddPoints(std::vector< G4ThreeVector > points)
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83