Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:06:20

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 #include "DicomROIContour.hh"
0027 
0028 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0029 DicomROIContour::DicomROIContour() {}
0030 
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 void DicomROIContour::SetData(std::vector<G4ThreeVector> data)
0033 {
0034   thePoints = data;
0035   if (theGeomType == "CLOSED_PLANAR") {
0036     // add a last point to close the circle
0037     thePoints.push_back(thePoints[0]);
0038     for (size_t ii = 1; ii < thePoints.size(); ii++) {
0039       theDirections.push_back(thePoints[ii] - thePoints[ii - 1]);
0040     }
0041     theDirections.push_back(thePoints[0] - thePoints[thePoints.size() - 1]);  // (0,0)
0042   }
0043 }
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 G4double DicomROIContour::GetZ()
0047 {
0048   if (thePoints.size() == 0) {
0049     G4Exception("DicomROIContour::GetZ", "DRC001", FatalException, "No Point in contour");
0050     Print(G4cout);
0051     return DBL_MAX;
0052   }
0053   return thePoints[0].z();
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 void DicomROIContour::AddPoints(std::vector<G4ThreeVector> points)
0058 {
0059   points.push_back(points[0]);
0060   size_t npold = thePoints.size();
0061   for (size_t ii = 0; ii < points.size(); ii++) {
0062     thePoints.push_back(points[ii]);
0063   }
0064 
0065   for (size_t ii = npold + 1; ii < thePoints.size(); ii++) {
0066     theDirections.push_back(thePoints[ii] - thePoints[ii - 1]);
0067   }
0068   theDirections.push_back(thePoints[npold] - thePoints[thePoints.size() - 1]);
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 void DicomROIContour::Print(std::ostream& out)
0073 {
0074   out << this << "@@@ NUMBER OF ContourImageSequences " << theImageIUIDs.size() << G4endl;
0075   for (size_t ii = 0; ii < theImageIUIDs.size(); ii++) {
0076     out << "ContourImageSequence I= " << theImageIUIDs[ii] << G4endl;
0077   }
0078   out << "@@@ GeomType " << theGeomType << " NPOINTS " << thePoints.size() << G4endl;
0079   for (size_t ii = 0; ii < thePoints.size(); ii++) {
0080     out << "(" << thePoints[ii].x() << "," << thePoints[ii].y() << "," << thePoints[ii].z() << ")"
0081         << G4endl;
0082   }
0083 }