File indexing completed on 2026-04-10 07:50:27
0001
0002
0003 #include <iostream>
0004 #include <iomanip>
0005 #include <sstream>
0006 #include <vector>
0007 #include <string>
0008 #include <cassert>
0009
0010 #include "G4ThreeVector.hh"
0011 #include "G4Orb.hh"
0012 #include "sgeomdefs.h"
0013 #include "ssolid.h"
0014
0015
0016 std::string Label( const char* soname, char p_l, char d_l, const char* meth )
0017 {
0018 std::stringstream ss ;
0019 ss << soname << "." << meth << "(" << p_l << ", " << d_l << ") " ;
0020 std::string str = ss.str();
0021 return str ;
0022 }
0023
0024 std::string Format(double v, int w=10)
0025 {
0026 std::stringstream ss ;
0027 if( v == kInfinity )
0028 {
0029 ss << std::setw(w) << "kInfinity" ;
0030 }
0031 else
0032 {
0033 ss << std::setw(w) << std::fixed << std::setprecision(4) << v ;
0034 }
0035 std::string str = ss.str();
0036 return str ;
0037 }
0038
0039 std::string Format(const G4ThreeVector* v)
0040 {
0041 std::stringstream ss ;
0042 ss << *v ;
0043 std::string str = ss.str();
0044 return str ;
0045 }
0046
0047 int main()
0048 {
0049 G4Orb solid("Orb", 100.) ;
0050
0051 std::cout << solid << std::endl ;
0052
0053 G4String soname_ = solid.GetName() ;
0054 const char* soname = soname_.c_str();
0055
0056 G4ThreeVector A(0.,0., 200.);
0057 G4ThreeVector B(0.,0., 150.);
0058 G4ThreeVector C(0.,0., 100.);
0059 G4ThreeVector D(0.,0., 50.);
0060 G4ThreeVector E(0.,0., 0.);
0061 G4ThreeVector F(0.,0., -50.);
0062 G4ThreeVector G(0.,0.,-100.);
0063 G4ThreeVector H(0.,0.,-150.);
0064 G4ThreeVector I(0.,0.,-200.);
0065
0066 G4ThreeVector Z(0.,0.,1.);
0067
0068 std::vector<G4ThreeVector*> PP = {&A, &B, &C, &D, &E, &F, &G, &H, &I } ;
0069 std::vector<char> PP_L = {'A','B','C','D','E','F','G','H','I'};
0070
0071 std::vector<G4ThreeVector*> DD = {&Z, &Z, &Z, &Z, &Z, &Z, &Z, &Z, &Z } ;
0072 std::vector<char> DD_L = {'Z','Z','Z','Z','Z','Z','Z','Z','Z' };
0073
0074 for(int i=0 ; i < int(PP.size()) ; i++)
0075 {
0076 G4ThreeVector* p = PP[i] ;
0077 G4ThreeVector* d = DD[i] ;
0078 const char p_l = PP_L[i] ;
0079 const char d_l = DD_L[i] ;
0080
0081 EInside in ;
0082 G4double dis = ssolid::Distance_(&solid, *p, *d, in );
0083 G4double d2o = solid.DistanceToOut( *p, *d ) ;
0084 G4double d2i = solid.DistanceToIn( *p, *d ) ;
0085
0086 std::cout
0087 << p_l << " "
0088 << std::setw(10) << Format(p)
0089 << std::setw(30) << Label( soname, p_l, d_l, "DistanceToOut")
0090 << " : " << Format(d2o)
0091 << " | "
0092 << std::setw(30) << Label( soname, p_l, d_l, "DistanceToIn")
0093 << " : "
0094 << " : " << Format(d2i)
0095 << std::setw(30) << Label( soname, p_l, d_l, "Distance_")
0096 << " : " << Format(dis)
0097 << " " << sgeomdefs::EInside_(in)
0098 << std::endl
0099 ;
0100 }
0101
0102 return 0 ;
0103 }
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169