Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NURBStubesector Class Reference

#include <G4NURBStubesector.hh>

+ Inheritance diagram for G4NURBStubesector:

Public Member Functions

 G4NURBStubesector (G4double RMIN, G4double RMAX, G4double DZ, G4double PHI1, G4double PHI2)
 
virtual ~G4NURBStubesector ()
 
virtual const char * Whoami () const
 
- Public Member Functions inherited from G4NURBS
virtual const char * Whoami () const =0
 
virtual ~G4NURBS ()
 
G4int GetUorder () const
 
G4int GetVorder () const
 
G4int GetUnbrKnots () const
 
G4int GetVnbrKnots () const
 
G4int GetUnbrCtrlPts () const
 
G4int GetVnbrCtrlPts () const
 
G4int GettotalnbrCtrlPts () const
 
G4double GetUmin () const
 
G4double GetUmax () const
 
G4double GetVmin () const
 
G4double GetVmax () const
 
void CalcPoint (G4double u, G4double v, G4Point3D &p, G4Vector3D &utan, G4Vector3D &vtan) const
 
G4int Getorder (t_direction in_dir) const
 
G4int GetnbrKnots (t_direction in_dir) const
 
G4int GetnbrCtrlPts (t_direction in_dir) const
 
G4float GetfloatKnot (t_direction in_dir, t_indKnot in_index) const
 
G4double GetdoubleKnot (t_direction in_dir, t_indKnot in_index) const
 
t_floatCtrlPtGetfloatCtrlPt (t_indCtrlPt in_onedimindex) const
 
t_floatCtrlPtGetfloatCtrlPt (t_inddCtrlPt in_Uindex, t_inddCtrlPt in_Vindex) const
 
t_doubleCtrlPtGetdoubleCtrlPt (t_indCtrlPt in_onedimindex) const
 
t_doubleCtrlPtGetdoubleCtrlPt (t_inddCtrlPt in_Uindex, t_inddCtrlPt in_Vindex) const
 
G4floatGetfloatAllKnots (t_direction in_dir) const
 
G4doubleGetdoubleAllKnots (t_direction in_dir) const
 
G4floatGetfloatAllCtrlPts () const
 
G4doubleGetdoubleAllCtrlPts () const
 
- Public Member Functions inherited from G4Visible
 G4Visible ()
 
 G4Visible (const G4Visible &)
 
 G4Visible (const G4VisAttributes *)
 
virtual ~G4Visible ()
 
G4Visibleoperator= (const G4Visible &)
 
G4bool operator!= (const G4Visible &right) const
 
const G4VisAttributesGetVisAttributes () const
 
void SetVisAttributes (const G4VisAttributes *)
 
void SetVisAttributes (const G4VisAttributes &)
 

Protected Attributes

char * mpwhoami
 
- Protected Attributes inherited from G4NURBS
t_Dir m [NofD]
 
t_indCtrlPt mtotnbrCtrlPts
 
t_CtrlPtmpCtrlPts
 
- Protected Attributes inherited from G4Visible
const G4VisAttributesfpVisAttributes
 
G4bool fAllocatedVisAttributes
 

Additional Inherited Members

- Public Types inherited from G4NURBS
enum  t_direction { U = 0 , V = 1 , DMask = 1 , NofD = 2 }
 
enum  {
  X , Y , Z , W ,
  NofC
}
 
enum  t_KnotVectorGenFlag { UserDefined , Regular , RegularRep }
 
typedef unsigned int t_index
 
typedef t_index t_indKnot
 
typedef unsigned int t_indCoord
 
typedef unsigned int t_indCtrlPt
 
typedef t_index t_inddCtrlPt
 
typedef G4double t_doubleCtrlPt[NofC]
 
typedef G4float t_floatCtrlPt[NofC]
 
typedef t_index t_order
 
typedef G4Float t_Knot
 
- Static Public Member Functions inherited from G4NURBS
static char Tochar (t_direction in_dir)
 
- Protected Types inherited from G4NURBS
enum  t_CheckFlag { NOcheck , check }
 
typedef Float G4Float
 
typedef G4Float t_Coord
 
typedef t_Coord t_CtrlPt[NofC]
 
- Protected Member Functions inherited from G4NURBS
 G4NURBS (t_order in_Uorder, t_order in_Vorder, t_inddCtrlPt in_UnbrCtrlPts, t_inddCtrlPt in_VnbrCtrlPts, t_CtrlPt *in_pCtrlPts, t_Knot *in_pUKnots=0, t_Knot *in_pVKnots=0, t_CheckFlag in_CheckFlag=check)
 
 G4NURBS (t_order in_Uorder, t_order in_Vorder, t_inddCtrlPt in_UnbrCtrlPts, t_inddCtrlPt in_VnbrCtrlPts, t_KnotVectorGenFlag in_UKVGFlag=Regular, t_KnotVectorGenFlag in_VKVGFlag=Regular, t_CheckFlag in_CheckFlag=check)
 
t_indCtrlPt To1d (t_inddCtrlPt in_Uindex, t_inddCtrlPt in_Vindex) const
 
- Static Protected Member Functions inherited from G4NURBS
static t_floatCtrlPtTofloatCtrlPt (const t_CtrlPt &)
 
static t_doubleCtrlPtTodoubleCtrlPt (const t_CtrlPt &)
 
static G4bool MakeKnotVector (t_Dir &inout_dirdat, t_KnotVectorGenFlag in_KVGFlag)
 
static G4bool MakeKnotVector (t_Dir *p_inoutdirdat, t_KnotVectorGenFlag in_KVGFlag)
 
static void CP (G4NURBS::t_CtrlPt &rcp, t_Coord x, t_Coord y, t_Coord z, t_Coord w)
 
static void CP (G4NURBS::t_CtrlPt &rcp, t_Coord x, t_Coord y, t_Coord z, t_Coord w, G4Float factor)
 

Detailed Description

Definition at line 44 of file G4NURBStubesector.hh.

Constructor & Destructor Documentation

◆ G4NURBStubesector()

G4NURBStubesector::G4NURBStubesector ( G4double  RMIN,
G4double  RMAX,
G4double  DZ,
G4double  PHI1,
G4double  PHI2 
)

Definition at line 40 of file G4NURBStubesector.cc.

42 : G4NURBS( 2, 3, // linear along U, quadratic along V
43 5, DecideNbrCtrlPts(PHI1, PHI2),
44 // rectangle along U, required stuff along V
45 // we must use a static function which
46 // take the two angles because the
47 // mother constructor is initialised
48 // before everything
49 Regular, // the knot vector along U will be generated
50 RegularRep ) // circular like knot vector also
51{
52 // check angles
53 G4double deltaPHI = PHI2-PHI1;
54 while (deltaPHI <= 0) { PHI2 += twopi; deltaPHI += twopi; };
55
56 G4int f = (int)floor(deltaPHI / (halfpi)); //number of pi/2 arcs
57
58 const G4double mr = (r+R)/2;
59
60 const G4double cp1 = std::cos(PHI1);
61 const G4double sp1 = std::sin(PHI1);
62 const G4double cp2 = std::cos(PHI2);
63 const G4double sp2 = std::sin(PHI2);
64
65
66 // define control points
67 CP(mpCtrlPts[ 0] , cp1*mr, sp1*mr, 0, 1 );
68 CP(mpCtrlPts[ 1] , cp1*mr, sp1*mr, 0, 1 );
69 CP(mpCtrlPts[ 2] , cp1*mr, sp1*mr, 0, 1 );
70 CP(mpCtrlPts[ 3] , cp1*mr, sp1*mr, 0, 1 );
71 CP(mpCtrlPts[ 4] , cp1*mr, sp1*mr, 0, 1 );
72
73 CP(mpCtrlPts[ 5] , cp1*mr, sp1*mr, 0, 1 );
74 CP(mpCtrlPts[ 6] , cp1*mr, sp1*mr, 0, 1 );
75 CP(mpCtrlPts[ 7] , cp1*mr, sp1*mr, 0, 1 );
76 CP(mpCtrlPts[ 8] , cp1*mr, sp1*mr, 0, 1 );
77 CP(mpCtrlPts[ 9] , cp1*mr, sp1*mr, 0, 1 );
78
79 CP(mpCtrlPts[10] , cp1*r, sp1*r, DZ, 1 );
80 CP(mpCtrlPts[11] , cp1*R, sp1*R, DZ, 1 );
81 CP(mpCtrlPts[12] , cp1*R, sp1*R, -DZ, 1 );
82 CP(mpCtrlPts[13] , cp1*r, sp1*r, -DZ, 1 );
83 CP(mpCtrlPts[14] , cp1*r, sp1*r, DZ, 1 );
84
85 t_indCtrlPt i = 15;
86 G4double srcAngle = PHI1;
87 G4double deltaAngleo2;
88
89 G4double destAngle = halfpi + PHI1;
90
91 for(; f > 0; f--)
92 {
93 // the first arc CP is already Done
94
95 deltaAngleo2 = (destAngle - srcAngle) / 2;
96 const G4double csa = std::cos(srcAngle);
97 const G4double ssa = std::sin(srcAngle);
98 const G4double tdao2 = std::tan(deltaAngleo2);
99
100 // to calculate the intermediate CP :
101 // rotate by srcAngle the (1, tdao2) point
102 const t_Coord x = csa - ssa*tdao2;
103 const t_Coord y = ssa + csa*tdao2;
104
105 // weight of the CP
106 const G4Float weight = (std::cos(deltaAngleo2));
107
108 // initialization. postfix ++ because i initialized to 15
109 CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
110 CP(mpCtrlPts[i++], x*R, y*R, DZ, 1, weight);
111 CP(mpCtrlPts[i++], x*R, y*R, -DZ, 1, weight);
112 CP(mpCtrlPts[i++], x*r, y*r, -DZ, 1, weight);
113 CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
114
115 // end CP (which is the first CP of the next arc)
116 const G4double cda = std::cos(destAngle);
117 const G4double sda = std::sin(destAngle);
118 CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
119 CP(mpCtrlPts[i++], cda*R, sda*R, DZ, 1);
120 CP(mpCtrlPts[i++], cda*R, sda*R, -DZ, 1);
121 CP(mpCtrlPts[i++], cda*r, sda*r, -DZ, 1);
122 CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
123
124 // prepare next arc
125 srcAngle = destAngle;
126 destAngle += halfpi;
127 }
128
129 // f == 0, final Arc
130 // could be handled in the loops
131
132 destAngle = PHI2;
133 deltaAngleo2 = (destAngle - srcAngle) / 2;
134 const G4double csa = std::cos(srcAngle);
135 const G4double ssa = std::sin(srcAngle);
136 const G4double tdao2 = std::tan(deltaAngleo2);
137
138 // to calculate the intermediate CP :
139 // rotate by srcAngle the (1, tdao2) point
140 const t_Coord x = csa - ssa*tdao2;
141 const t_Coord y = ssa + csa*tdao2;
142
143 // weight of the CP
144 const G4Float weight = (std::cos(deltaAngleo2));
145
146 // initialization.
147 CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
148 CP(mpCtrlPts[i++], x*R, y*R, DZ, 1, weight);
149 CP(mpCtrlPts[i++], x*R, y*R, -DZ, 1, weight);
150 CP(mpCtrlPts[i++], x*r, y*r, -DZ, 1, weight);
151 CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
152
153 // end CP
154 const G4double cda = std::cos(destAngle);
155 const G4double sda = std::sin(destAngle);
156 CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
157 CP(mpCtrlPts[i++], cda*R, sda*R, DZ, 1);
158 CP(mpCtrlPts[i++], cda*R, sda*R, -DZ, 1);
159 CP(mpCtrlPts[i++], cda*r, sda*r, -DZ, 1);
160 CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
161
162 if (i != (mtotnbrCtrlPts - 10) )
163 {
164 G4cerr << "\nERROR: G4NURBStubesector::G4NURBStubesector: wrong index,"
165 << i << " instead of " << (mtotnbrCtrlPts - 10)
166 << "\n\tThe tubesector won't be correct."
167 << G4endl;
168 }
169
170 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
171 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
172 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
173 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
174 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
175
176 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
177 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
178 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
179 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
180 CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
181
182 // possible to put a DZ DZ -DZ -DZ DZ column to scratch
183 // to a line instead of a point
184
185 // creating the nurbs identity
186 std::ostringstream tmpstr;
187 tmpstr << "Tubs" << " \tPHI1=" << PHI1 << " ; PHI2=" << PHI2;
188 mpwhoami = new char [tmpstr.str().length() + 1];
189 mpwhoami = std::strcpy(mpwhoami, tmpstr.str().c_str());
190}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
t_CtrlPt * mpCtrlPts
Definition: G4NURBS.hh:350
Float G4Float
Definition: G4NURBS.hh:168
t_indCtrlPt mtotnbrCtrlPts
Definition: G4NURBS.hh:349
static void CP(G4NURBS::t_CtrlPt &rcp, t_Coord x, t_Coord y, t_Coord z, t_Coord w)
Definition: G4NURBS.hh:520
unsigned int t_indCtrlPt
Definition: G4NURBS.hh:91
G4Float t_Coord
Definition: G4NURBS.hh:181
@ Regular
Definition: G4NURBS.hh:324
@ RegularRep
Definition: G4NURBS.hh:328

◆ ~G4NURBStubesector()

G4NURBStubesector::~G4NURBStubesector ( )
virtual

Definition at line 197 of file G4NURBStubesector.cc.

198{
199 if (mpwhoami) { delete [] mpwhoami; mpwhoami = 0; }
200}

Member Function Documentation

◆ Whoami()

const char * G4NURBStubesector::Whoami ( ) const
virtual

Implements G4NURBS.

Definition at line 192 of file G4NURBStubesector.cc.

193{
194 return mpwhoami;
195}

Member Data Documentation

◆ mpwhoami

char* G4NURBStubesector::mpwhoami
protected

Definition at line 61 of file G4NURBStubesector.hh.

Referenced by G4NURBStubesector(), Whoami(), and ~G4NURBStubesector().


The documentation for this class was generated from the following files: