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

#include <G4KnotVector.hh>

Public Member Functions

 G4KnotVector ()
 
 G4KnotVector (G4int sz)
 
 ~G4KnotVector ()
 
 G4KnotVector (const G4KnotVector &orig)
 
G4KnotVectoroperator= (const G4KnotVector &right)
 
G4int GetSize () const
 
G4double GetKnot (G4int knot_number) const
 
void PutKnot (G4int knot_number, G4double value)
 
G4KnotVectorMultiplyKnotVector (G4int num, G4double value)
 
G4doubleMergeKnotVector (const G4double *knots_to_add, G4int add_size)
 
G4int CheckKnotVector (G4double val) const
 
void ExtractKnotVector (G4KnotVector *kv, G4int upper, G4int lower)
 
G4int GetKnotIndex (G4double k_value, G4int order) const
 

Detailed Description

Definition at line 45 of file G4KnotVector.hh.

Constructor & Destructor Documentation

◆ G4KnotVector() [1/3]

G4KnotVector::G4KnotVector ( )

Definition at line 39 of file G4KnotVector.cc.

40 : k_size(0), knots(0)
41{
43}
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()

Referenced by MultiplyKnotVector().

◆ G4KnotVector() [2/3]

G4KnotVector::G4KnotVector ( G4int  sz)

Definition at line 45 of file G4KnotVector.cc.

46{
47 k_size=sz;
48 knots = new G4double[k_size];
49 for(G4int a=0;a<k_size;a++)
50 { knots[a]=0; }
52}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66

◆ ~G4KnotVector()

G4KnotVector::~G4KnotVector ( )

Definition at line 55 of file G4KnotVector.cc.

56{
57 delete [] knots;
58}

◆ G4KnotVector() [3/3]

G4KnotVector::G4KnotVector ( const G4KnotVector orig)

Definition at line 60 of file G4KnotVector.cc.

61{
62 delete [] knots;
63 k_size = orig.k_size;
64 knots = new G4double[k_size];
65 for(register G4int a=0; a < orig.k_size; a++)
66 { knots[a] = orig.knots[a]; }
67 kCarTolerance = orig.kCarTolerance;
68}

Member Function Documentation

◆ CheckKnotVector()

G4int G4KnotVector::CheckKnotVector ( G4double  val) const

Definition at line 170 of file G4KnotVector.cc.

171{
172 G4int num = 0;
173
174 for ( G4int i = 0; i < k_size; i++)
175 {
176 // if ( std::abs(val - knots[i]) < kCarTolerance)
177 if ( val == knots[i] )
178 num++;
179 }
180
181 return num;
182}

Referenced by MultiplyKnotVector().

◆ ExtractKnotVector()

void G4KnotVector::ExtractKnotVector ( G4KnotVector kv,
G4int  upper,
G4int  lower 
)

Definition at line 185 of file G4KnotVector.cc.

187{
188 delete[] kv->knots;
189 kv->k_size = upper-lower;
190 kv->knots = new G4double[kv->k_size];
191
192 for ( G4int i = lower; i < upper; i++)
193 kv->knots[i-lower] = knots[i];
194}

◆ GetKnot()

G4double G4KnotVector::GetKnot ( G4int  knot_number) const
inline

◆ GetKnotIndex()

G4int G4KnotVector::GetKnotIndex ( G4double  k_value,
G4int  order 
) const

Definition at line 83 of file G4KnotVector.cc.

84{
85 G4int i, knot_index;
86 G4double knt;
87
88 knt = knots[order - 1];
89 if ( k_value < knt )
90 {
91 if (ApxEq( k_value, knt))
92 k_value = knt;
93 else
94 return -1;
95 }
96
97 knt = knots[k_size - order + 1];
98 if ( k_value > knt )
99 {
100 if (ApxEq( k_value, knt))
101 k_value = knt;
102 else
103 return -1;
104 }
105
106 if ( k_value == knots[k_size - order + 1] )
107 knot_index = k_size - order - 1;
108 else if ( k_value == knots[ order - 1] )
109 knot_index = order - 1;
110 else
111 {
112 knot_index = 0;
113
114 for ( i = 0; i < k_size - 1; i++)
115 if((knots[i]<k_value) && (k_value <= knots[i+1]))
116 knot_index = i;
117 }
118
119 return knot_index;
120}

◆ GetSize()

G4int G4KnotVector::GetSize ( ) const
inline

◆ MergeKnotVector()

G4double * G4KnotVector::MergeKnotVector ( const G4double knots_to_add,
G4int  add_size 
)

Definition at line 145 of file G4KnotVector.cc.

147{
148 G4double *newknots;
149 G4int kv1_ptr = 0,
150 kv2_ptr = 0,
151 newptr;
152 G4int old_size = k_size;
153
154 newknots = new G4double[k_size + add_size];
155
156 for ( newptr = 0; newptr < k_size+add_size; newptr++)
157 if ( kv1_ptr >= add_size )
158 newknots[newptr] = knots[kv2_ptr++];
159 else if ( kv2_ptr >= old_size )
160 newknots[newptr] = knots_to_add[kv1_ptr++];
161 else if ( knots_to_add[kv1_ptr] < knots[kv2_ptr])
162 newknots[newptr] = knots_to_add[kv1_ptr++];
163 else
164 newknots[newptr] = knots[kv2_ptr++];
165
166 return newknots;
167}

Referenced by MultiplyKnotVector().

◆ MultiplyKnotVector()

G4KnotVector * G4KnotVector::MultiplyKnotVector ( G4int  num,
G4double  value 
)

Definition at line 123 of file G4KnotVector.cc.

125{
126 G4int n;
127 G4double* knots_to_add;
128
129 n = CheckKnotVector( val );
130 knots_to_add = new G4double[num-n];
131
132 for (G4int i = 0; i < num - n; i++)
133 knots_to_add[i] = val;
134
135 G4KnotVector* new_kv = new G4KnotVector();
136 new_kv->k_size = num - n + GetSize();
137 new_kv->knots = MergeKnotVector(knots_to_add, num-n);
138
139 delete [] knots_to_add;
140
141 return new_kv;
142}
G4int GetSize() const
G4double * MergeKnotVector(const G4double *knots_to_add, G4int add_size)
G4int CheckKnotVector(G4double val) const

◆ operator=()

G4KnotVector & G4KnotVector::operator= ( const G4KnotVector right)

Definition at line 70 of file G4KnotVector.cc.

71{
72 if (&right == this) return *this;
73 delete [] knots;
74 k_size = right.k_size;
75 knots = new G4double[k_size];
76 for(register G4int a=0; a < right.k_size; a++)
77 knots[a] = right.knots[a];
78 kCarTolerance = right.kCarTolerance;
79
80 return *this;
81}

◆ PutKnot()

void G4KnotVector::PutKnot ( G4int  knot_number,
G4double  value 
)
inline

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