Import Geant4 10.5.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2018-06-29 10:58:11 +02:00
parent fe81a77428
commit 6aa23be517
1581 changed files with 124288 additions and 83758 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GMocrenFileSceneHandler.cc 104291 2017-05-23 13:25:51Z gcosmo $
// $Id: G4GMocrenFileSceneHandler.cc 110513 2018-05-28 07:37:38Z gcosmo $
//
//
// Created: Mar. 31, 2009 Akinori Kimura
@@ -158,7 +158,8 @@ G4GMocrenFileSceneHandler::G4GMocrenFileSceneHandler(G4GMocrenFile& system,
if ( std::getenv( "G4GMocrenFile_MAX_FILE_NUM" ) != NULL ) {
char * pcFileNum = getenv("G4GMocrenFile_MAX_FILE_NUM");
char c10FileNum[10];
std::strncpy(c10FileNum, pcFileNum, 10);
std::strncpy(c10FileNum, pcFileNum, 9);
c10FileNum[9] = '\0';
kMaxFileNum = std::atoi(c10FileNum);
} else {
@@ -208,10 +209,12 @@ void G4GMocrenFileSceneHandler::SetGddFileName()
const G4int MAX_FILE_INDEX = kMaxFileNum - 1 ;
// dest directory (null if no environmental variables is set)
std::strncpy(kGddFileName, kGddDestDir, std::strlen(kGddDestDir)+1);
std::strncpy(kGddFileName, kGddDestDir, sizeof(kGddFileName)-1);
kGddFileName[sizeof(kGddFileName)-1] = '\0';
// create full path name (default)
std::strncat ( kGddFileName, DEFAULT_GDD_FILE_NAME, std::strlen(DEFAULT_GDD_FILE_NAME));
std::strncat ( kGddFileName, DEFAULT_GDD_FILE_NAME,
sizeof(kGddFileName) - std::strlen(kGddFileName) - 1);
// Automatic updation of file names
static G4int currentNumber = 0;
@@ -236,7 +239,8 @@ void G4GMocrenFileSceneHandler::SetGddFileName()
filename
<< kGddDestDir << GDD_FILE_HEADER
<< std::setw(2) << std::setfill('0') << i << ".wrl";
strncpy(kGddFileName,filename.str().c_str(),sizeof(kGddFileName));
strncpy(kGddFileName,filename.str().c_str(),sizeof(kGddFileName)-1);
kGddFileName[sizeof(kGddFileName)-1] = '\0';
// check validity of the file name
std::ifstream fin(kGddFileName);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GMocrenFileViewer.cc 87360 2014-12-01 16:07:16Z gcosmo $
// $Id: G4GMocrenFileViewer.cc 110513 2018-05-28 07:37:38Z gcosmo $
//
//
// Created: Mar. 31, 2009 Akinori Kimura
@@ -74,7 +74,8 @@ G4GMocrenFileViewer::G4GMocrenFileViewer (G4GMocrenFileSceneHandler& sceneHandle
"gMocren1000", FatalException,
"Invalid length of string set in G4GMocrenFile_VIEWER");
}
std::strncpy( kG4GddViewer, env, len);
std::strncpy( kG4GddViewer, env, sizeof(kG4GddViewer) - 1);
kG4GddViewer[sizeof(kG4GddViewer) - 1] = '\0';
//std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;
}
@@ -85,8 +86,11 @@ G4GMocrenFileViewer::G4GMocrenFileViewer (G4GMocrenFileSceneHandler& sceneHandle
kG4GddViewerInvocation[0] = '\0';
} else {
std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
std::strncat( kG4GddViewerInvocation, " ", 1);
std::strncpy( kG4GddViewerInvocation, kG4GddViewer,
sizeof(kG4GddViewerInvocation) - 1);
kG4GddViewerInvocation[sizeof(kG4GddViewerInvocation) - 1] = '\0';
std::strncat( kG4GddViewerInvocation, " ",
sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
const char * gddfname = kSceneHandler.GetGddFileName();
int len = std::strlen(gddfname);
if(len >= 64) {
@@ -94,7 +98,8 @@ G4GMocrenFileViewer::G4GMocrenFileViewer (G4GMocrenFileSceneHandler& sceneHandle
"gMocren1001", FatalException,
"Invalid length of the GDD file name");
}
std::strncat( kG4GddViewerInvocation, gddfname, len );
std::strncat( kG4GddViewerInvocation, gddfname,
sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
}
}
@@ -177,8 +182,11 @@ void G4GMocrenFileViewer::ShowView( void )
//std::strcpy( kG4GddViewerInvocation, "" );
} else {
std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
std::strncat( kG4GddViewerInvocation, " ", 1);
std::strncpy( kG4GddViewerInvocation, kG4GddViewer,
sizeof(kG4GddViewerInvocation) - 1);
kG4GddViewerInvocation[sizeof(kG4GddViewerInvocation) - 1] = '\0';
std::strncat( kG4GddViewerInvocation, " ",
sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
const char * gddfname = kSceneHandler.GetGddFileName();
int len = std::strlen(gddfname);
if(len >= 64) {
@@ -186,7 +194,8 @@ void G4GMocrenFileViewer::ShowView( void )
"gMocren1002", FatalException,
"Invalid length of the GDD file name");
}
std::strncat( kG4GddViewerInvocation, gddfname, len);
std::strncat( kG4GddViewerInvocation, gddfname,
sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GMocrenIO.cc 75179 2013-10-29 10:09:31Z gcosmo $
// $Id: G4GMocrenIO.cc 110513 2018-05-28 07:37:38Z gcosmo $
//
//
// File I/O manager class for writing or reading calcuated dose
@@ -506,13 +506,9 @@ bool G4GMocrenIO::storeData4() {
// comment
char cmt[1025];
for(int i = 0; i < 1025; i++) cmt[i] = '\0';
//std::strncpy(cmt, kComment.c_str(), 1024);
const char * cmnt = kComment.c_str();
size_t lcm = std::strlen(cmnt);
if(lcm > 1024) lcm = 1024;
std::strncpy(cmt, cmnt, lcm);
ofile.write((char *)cmt, 1024);
std::strncpy(cmt, kComment.c_str(), 1024);
cmt[1024] = '\0';
ofile.write(cmt, 1024);
if(DEBUG || kVerbose > 0) {
G4cout << "Data comment : "
<< kComment << G4endl;
@@ -737,12 +733,9 @@ bool G4GMocrenIO::storeData4() {
// dose distribution unit
char cdunit[13];
for(int i = 0; i < 13; i++) cdunit[i] = '\0';
const char * cu = kDoseUnit.c_str();
size_t lcu = std::strlen(cu);
if(lcu > 12) lcu = 12;
std::strncpy(cdunit, cu, lcu);
ofile.write((char *)cdunit, 12);
std::strncpy(cdunit, kDoseUnit.c_str(), 12);
cdunit[12] = '\0';
ofile.write(cdunit, 12);
if(DEBUG || kVerbose > 0) {
G4cout << "Dose dist. unit : " << kDoseUnit << G4endl;
}