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::G4KnotVector (  ) 

Definition at line 39 of file G4KnotVector.cc.

References G4GeometryTolerance::GetInstance(), and G4GeometryTolerance::GetSurfaceTolerance().

Referenced by MultiplyKnotVector().

00040   : k_size(0), knots(0)
00041 {
00042   kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
00043 }

G4KnotVector::G4KnotVector ( G4int  sz  ) 

Definition at line 45 of file G4KnotVector.cc.

References G4GeometryTolerance::GetInstance(), and G4GeometryTolerance::GetSurfaceTolerance().

00046 {
00047   k_size=sz; 
00048   knots = new G4double[k_size]; 
00049   for(G4int a=0;a<k_size;a++)
00050     { knots[a]=0; }
00051   kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
00052 }

G4KnotVector::~G4KnotVector (  ) 

Definition at line 55 of file G4KnotVector.cc.

00056 {
00057   delete [] knots;
00058 }  

G4KnotVector::G4KnotVector ( const G4KnotVector orig  ) 

Definition at line 60 of file G4KnotVector.cc.

References k_size, kCarTolerance, and knots.

00061 {
00062   delete [] knots;
00063   k_size = orig.k_size;
00064   knots = new G4double[k_size];
00065   for(register G4int a=0; a < orig.k_size; a++)
00066     { knots[a] = orig.knots[a]; }
00067   kCarTolerance = orig.kCarTolerance;
00068 }


Member Function Documentation

G4int G4KnotVector::CheckKnotVector ( G4double  val  )  const

Definition at line 170 of file G4KnotVector.cc.

Referenced by MultiplyKnotVector().

00171 {
00172   G4int num = 0;
00173   
00174   for ( G4int i = 0; i < k_size; i++) 
00175   {
00176     //    if ( std::abs(val - knots[i]) < kCarTolerance)
00177     if ( val == knots[i] )
00178       num++;
00179   }
00180 
00181   return num;
00182 }

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

Definition at line 185 of file G4KnotVector.cc.

References k_size, and knots.

00187 {
00188   delete[] kv->knots;
00189   kv->k_size = upper-lower;
00190   kv->knots  = new G4double[kv->k_size];
00191   
00192   for ( G4int i = lower; i < upper; i++)
00193     kv->knots[i-lower] = knots[i];
00194 }

G4double G4KnotVector::GetKnot ( G4int  knot_number  )  const [inline]

Definition at line 44 of file G4KnotVector.icc.

Referenced by G4BezierSurface::BIntersect().

00045 {
00046   return knots[knot_number];
00047 }

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

Definition at line 83 of file G4KnotVector.cc.

00084 {
00085   G4int    i, knot_index;
00086   G4double knt;
00087 
00088   knt = knots[order - 1];
00089   if ( k_value < knt )
00090   {
00091     if (ApxEq( k_value, knt)) 
00092       k_value = knt;
00093     else
00094       return -1;
00095   }
00096   
00097   knt = knots[k_size - order + 1];
00098   if ( k_value > knt )
00099   {
00100     if (ApxEq( k_value, knt)) 
00101       k_value = knt;
00102     else
00103       return -1;
00104   }
00105 
00106   if ( k_value == knots[k_size - order + 1] )
00107     knot_index = k_size - order - 1;
00108   else if ( k_value == knots[ order - 1] )
00109     knot_index = order - 1;
00110   else
00111   {
00112     knot_index = 0;
00113     
00114     for ( i = 0; i < k_size - 1; i++)
00115       if((knots[i]<k_value) && (k_value <= knots[i+1]))
00116         knot_index = i;  
00117   }
00118 
00119   return knot_index;
00120 }

G4int G4KnotVector::GetSize (  )  const [inline]

Definition at line 38 of file G4KnotVector.icc.

Referenced by G4BezierSurface::BIntersect(), and MultiplyKnotVector().

00039 {
00040   return k_size;
00041 }

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

Definition at line 145 of file G4KnotVector.cc.

Referenced by MultiplyKnotVector().

00147 {
00148   G4double *newknots;
00149   G4int kv1_ptr = 0, 
00150         kv2_ptr = 0, 
00151         newptr;
00152   G4int old_size = k_size;
00153 
00154   newknots = new G4double[k_size + add_size];
00155     
00156   for ( newptr = 0; newptr < k_size+add_size; newptr++) 
00157     if ( kv1_ptr >= add_size )
00158       newknots[newptr] = knots[kv2_ptr++];
00159     else if ( kv2_ptr >= old_size )
00160       newknots[newptr] = knots_to_add[kv1_ptr++];
00161     else if ( knots_to_add[kv1_ptr] < knots[kv2_ptr])
00162       newknots[newptr] = knots_to_add[kv1_ptr++];
00163     else
00164       newknots[newptr] = knots[kv2_ptr++];
00165   
00166   return newknots;
00167 }

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

Definition at line 123 of file G4KnotVector.cc.

References CheckKnotVector(), G4KnotVector(), GetSize(), k_size, knots, MergeKnotVector(), and CLHEP::detail::n.

00125 {
00126   G4int n;
00127   G4double* knots_to_add;
00128   
00129   n            = CheckKnotVector( val );
00130   knots_to_add = new G4double[num-n];   
00131   
00132   for (G4int i = 0; i < num - n; i++)
00133     knots_to_add[i] = val;
00134   
00135   G4KnotVector* new_kv = new G4KnotVector();
00136   new_kv->k_size = num - n + GetSize();
00137   new_kv->knots  = MergeKnotVector(knots_to_add, num-n);
00138   
00139   delete [] knots_to_add;
00140   
00141   return new_kv;
00142 }

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

Definition at line 70 of file G4KnotVector.cc.

References k_size, kCarTolerance, and knots.

00071 {
00072   if (&right == this) return *this;
00073   delete [] knots;
00074   k_size = right.k_size;
00075   knots = new G4double[k_size];
00076   for(register G4int a=0; a < right.k_size; a++)
00077     knots[a] = right.knots[a];
00078   kCarTolerance = right.kCarTolerance;
00079 
00080   return *this;
00081 }

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

Definition at line 50 of file G4KnotVector.icc.

00051 {
00052   knots[knot_number]=value;
00053 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:21 2013 for Geant4 by  doxygen 1.4.7