Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:37

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 #include <cstring>
0021 #include <string>
0022 #include <sstream>
0023 #include <algorithm>
0024 #include "SSys.hh"
0025 #include "SGDML.hh"
0026 
0027 std::string SGDML::GenerateName(const char* name, const void* const ptr, bool addPointerToName )
0028 {
0029     // HUH: this could easily end up with multiple 0x... in the name 
0030 
0031     std::stringstream ss; 
0032     ss << name;
0033     if(addPointerToName) ss << ptr ; 
0034     std::string nameOut = ss.str();
0035 
0036     if(nameOut.find(' ') != std::string::npos)
0037          nameOut.erase(std::remove(nameOut.begin(),nameOut.end(),' '),nameOut.end());
0038 
0039     //  std::remove 
0040     //         Removes all elements satisfying specific criteria from the range [first, last) 
0041     //         and returns a past-the-end iterator for the new end of the range.
0042     //
0043 
0044     return nameOut;
0045 }
0046 
0047 /**
0048 SGDML::PREFIX
0049 ---------------
0050 
0051 Provides a common prefix to be stripped from the names of Geant4 object types.
0052 Used from:
0053 
0054 * ggeo/GPropertyMap.cc
0055 * extg4/X4.cc
0056 
0057 **/
0058 
0059 const char* SGDML::PREFIX(const char* ekey)  // static 
0060 {
0061     const char* prefix = nullptr ; 
0062     if( strcmp(ekey, "OPTICKS_SGDML_PREFIX_G4Material") == 0 )
0063     {
0064         prefix = SSys::getenvvar(ekey, "_dd_Materials_") ;
0065     }
0066     return prefix ; 
0067 }
0068 
0069 
0070 // after G4GDMLRead::Strip
0071 std::string SGDML::Strip(const std::string& name)  // static 
0072 {
0073     std::string sname = name.substr(0, name.find("0x")) ;
0074     return sname ;
0075 }
0076 
0077 
0078 std::string SGDML::Strip(const char* name_)  // static 
0079 {
0080     std::string name(name_); 
0081     std::string sname = name.substr(0, name.find("0x")) ;
0082     return sname ;
0083 }
0084 
0085 
0086 
0087 
0088 
0089