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

#include <G4NURBS.hh>

+ Inheritance diagram for G4NURBS:

Classes

class  CtrlPtsCoordsIterator
 
class  CtrlPtsIterator
 
class  KnotsIterator
 
struct  t_Dir
 

Public Types

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
 

Public Member Functions

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 &)
 

Static Public Member Functions

static char Tochar (t_direction in_dir)
 

Protected Types

enum  t_CheckFlag { NOcheck , check }
 
typedef Float G4Float
 
typedef G4Float t_Coord
 
typedef t_Coord t_CtrlPt[NofC]
 

Protected Member Functions

 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

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)
 

Protected Attributes

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

Friends

class KnotsIterator
 
class CtrlPtsCoordsIterator
 
class CtrlPtsIterator
 
std::ostream & operator<< (std::ostream &inout_OutStream, t_KnotVectorGenFlag in_KVGFlag)
 

Detailed Description

Definition at line 51 of file G4NURBS.hh.

Member Typedef Documentation

◆ G4Float

typedef Float G4NURBS::G4Float
protected

Definition at line 168 of file G4NURBS.hh.

◆ t_Coord

typedef G4Float G4NURBS::t_Coord
protected

Definition at line 181 of file G4NURBS.hh.

◆ t_CtrlPt

typedef t_Coord G4NURBS::t_CtrlPt[NofC]
protected

Definition at line 182 of file G4NURBS.hh.

◆ t_doubleCtrlPt

typedef G4double G4NURBS::t_doubleCtrlPt[NofC]

Definition at line 110 of file G4NURBS.hh.

◆ t_floatCtrlPt

typedef G4float G4NURBS::t_floatCtrlPt[NofC]

Definition at line 111 of file G4NURBS.hh.

◆ t_indCoord

typedef unsigned int G4NURBS::t_indCoord

Definition at line 90 of file G4NURBS.hh.

◆ t_indCtrlPt

typedef unsigned int G4NURBS::t_indCtrlPt

Definition at line 91 of file G4NURBS.hh.

◆ t_inddCtrlPt

Definition at line 92 of file G4NURBS.hh.

◆ t_index

typedef unsigned int G4NURBS::t_index

Definition at line 84 of file G4NURBS.hh.

◆ t_indKnot

Definition at line 87 of file G4NURBS.hh.

◆ t_Knot

Definition at line 176 of file G4NURBS.hh.

◆ t_order

Definition at line 173 of file G4NURBS.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NofC 

Definition at line 106 of file G4NURBS.hh.

106{ X, Y, Z, W, NofC }; // NofC : number of coordinates
@ NofC
Definition: G4NURBS.hh:106

◆ t_CheckFlag

enum G4NURBS::t_CheckFlag
protected
Enumerator
NOcheck 
check 

Definition at line 280 of file G4NURBS.hh.

t_CheckFlag
Definition: G4NURBS.hh:280
@ NOcheck
Definition: G4NURBS.hh:280
@ check
Definition: G4NURBS.hh:280

◆ t_direction

Enumerator
DMask 
NofD 

Definition at line 71 of file G4NURBS.hh.

72 {
73 U = 0,
74 V = 1,
75 DMask = 1, // NofD : Number of Directions
76 NofD = 2 // DMask : direction mask for fast range control,
77 }; // e.g. : m[a_dir & DMask]
@ NofD
Definition: G4NURBS.hh:76
@ DMask
Definition: G4NURBS.hh:75

◆ t_KnotVectorGenFlag

Enumerator
UserDefined 
Regular 
RegularRep 

Definition at line 319 of file G4NURBS.hh.

320 {
321 UserDefined, // The user will fill the array (in the child constructor
322 // for instance).
323
324 Regular, // First and last knot repeated order time
325 // other knots regularly spaced, unrepeated.
326 // Typically used for "linear" knots vector
327
328 RegularRep // First and last knot repeated order time
329 // other knots regularly spaced but repeated one time.
330 // Typically used for "circular" knots vector and alikes.
331 }; //t_KnotVectorGenFlag
@ Regular
Definition: G4NURBS.hh:324
@ UserDefined
Definition: G4NURBS.hh:321
@ RegularRep
Definition: G4NURBS.hh:328

Constructor & Destructor Documentation

◆ ~G4NURBS()

G4NURBS::~G4NURBS ( )
virtual

Definition at line 546 of file G4NURBS.cc.

547{
548 // we must free the two knots vector
549 t_direction dir;
550 G4int dummy;
551 for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
552 {
553 if (m[dir].pKnots)
554 delete m[dir].pKnots; // [m[dir].nbrKnots] if t_Knot become a class
555 m[dir].pKnots = 0;
556 }
557 // now we free the CtrlPts array
558 if (mpCtrlPts)
559 delete [] mpCtrlPts; // [mtotnbrCtrlPts] if t_CtrlPt become a class
560 mpCtrlPts = 0;
561}
int G4int
Definition: G4Types.hh:66
t_CtrlPt * mpCtrlPts
Definition: G4NURBS.hh:350
t_Dir m[NofD]
Definition: G4NURBS.hh:348
t_direction
Definition: G4NURBS.hh:72
t_Knot * pKnots
Definition: G4NURBS.hh:275

◆ G4NURBS() [1/2]

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 
)
protected

Definition at line 412 of file G4NURBS.cc.

417{
418 m[U].order=in_Uorder; m[V].order=in_Vorder;
419 m[U].nbrCtrlPts=in_UnbrCtrlPts; m[V].nbrCtrlPts=in_VnbrCtrlPts;
420
422 m[U].nbrKnots = m[U].order + m[U].nbrCtrlPts;
423 m[V].nbrKnots = m[V].order + m[V].nbrCtrlPts;
424
425 if (in_CheckFlag)
426 Conscheck();
427
428 // CtrlPts
429 if (! (mpCtrlPts = in_pCtrlPts) )
430 {
432 ed << "A NURBS MUST HAVE CONTROL POINTS!\n"
433 << "\teven if they are defined later, the array must be allocated."
434 << G4endl;
435 G4Exception("G4NURBS::G4NURBS()",
436 "greps9003", FatalException, ed);
437 }
438 //mnbralias = 0;
439
440 // Knots
441 t_direction dir;
442 G4int dummy;
443 for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
444 {
445 if ( !(m[dir].pKnots = (dummy?in_pVKnots:in_pUKnots)) )
446 { // make some regular knots between 0 & 1
447 if(!MakeKnotVector(m[dir], Regular))
448 {
450 ed << "Unable to make a Regular knot vector along "
451 << G4NURBS::Tochar(dir)
452 << " direction."
453 << G4endl;
454 G4Exception("G4NURBS::G4NURBS()",
455 "greps9004", FatalException, ed);
456 }
457 //m[dir].nbralias = 0;
458 } // end of knots-making
459 } // end for dummy
460} // end of G4NURBS::G4NURBS
@ FatalException
#define G4endl
Definition: G4ios.hh:52
static char Tochar(t_direction in_dir)
Definition: G4NURBS.hh:467
static G4bool MakeKnotVector(t_Dir &inout_dirdat, t_KnotVectorGenFlag in_KVGFlag)
Definition: G4NURBS.cc:331
t_indCtrlPt mtotnbrCtrlPts
Definition: G4NURBS.hh:349
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
t_indKnot nbrKnots
Definition: G4NURBS.hh:274
t_inddCtrlPt nbrCtrlPts
Definition: G4NURBS.hh:273
t_order order
Definition: G4NURBS.hh:272

◆ G4NURBS() [2/2]

G4NURBS::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 
)
protected

Definition at line 464 of file G4NURBS.cc.

469{
470 m[U].order=in_Uorder; m[V].order=in_Vorder;
471 m[U].nbrCtrlPts=in_UnbrCtrlPts; m[V].nbrCtrlPts=in_VnbrCtrlPts;
472
474 m[U].nbrKnots = m[U].order + m[U].nbrCtrlPts;
475 m[V].nbrKnots = m[V].order + m[V].nbrCtrlPts;
476
477 if (in_CheckFlag)
478 Conscheck();
479
480 // Allocate CtrlPts
482 //mnbralias = 0;
483
484 // Knots
485 t_direction dir;
486 G4int dummy;
487 for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
488 {
489 t_KnotVectorGenFlag flag = (dummy?in_VKVGFlag:in_UKVGFlag);
490 m[dir].pKnots = 0; // (allocation under our control)
491 if ( flag != UserDefined && !MakeKnotVector(m[dir], flag) )
492 {
494 ed << "Unable to make knot vector along "
495 << G4NURBS::Tochar(dir)
496 << " direction. (" << m[dir].nbrKnots
497 << " knots requested for a "
498 << flag
499 << " knots vector)"
500 << G4endl;
501 G4Exception("G4NURBS::G4NURBS()",
502 "greps9005", FatalException, ed);
503 }
504 //m[dir].nbralias = 0;
505 }
506}
t_Coord t_CtrlPt[NofC]
Definition: G4NURBS.hh:182
t_KnotVectorGenFlag
Definition: G4NURBS.hh:320

Member Function Documentation

◆ CalcPoint()

void G4NURBS::CalcPoint ( G4double  u,
G4double  v,
G4Point3D p,
G4Vector3D utan,
G4Vector3D vtan 
) const

Definition at line 659 of file G4NURBS.cc.

661{
662#define MAXORDER 50
663 struct Point4
664 {
665 G4double x, y, z, w;
666 };
667
668 G4int i, j, ri, rj;
669 G4int ubrkPoint, ufirst;
670 G4double bu[MAXORDER], buprime[MAXORDER];
671 G4int vbrkPoint, vfirst;
672 G4double bv[MAXORDER], bvprime[MAXORDER];
673 Point4 r, rutan, rvtan;
674
675 r.x = 0.0; r.y = 0.0; r.z = 0.0; r.w = 0.0;
676 rutan = r; rvtan = r;
677
678 G4int numU = GetUnbrCtrlPts();
679 G4int numV = GetVnbrCtrlPts();
680 G4int orderU = GetUorder();
681 G4int orderV = GetVorder();
682
683 /* Evaluate non-uniform basis functions (and derivatives) */
684
685 ubrkPoint = FindBreakPoint(u, m[U].pKnots, numU-1, orderU);
686 ufirst = ubrkPoint - orderU + 1;
687 BasisFunctions (u, ubrkPoint, m[U].pKnots, orderU, bu);
688 BasisDerivatives(u, ubrkPoint, m[U].pKnots, orderU, buprime);
689
690 vbrkPoint = FindBreakPoint(v, m[V].pKnots, numV-1, orderV);
691 vfirst = vbrkPoint - orderV + 1;
692 BasisFunctions (v, vbrkPoint, m[V].pKnots, orderV, bv);
693 BasisDerivatives(v, vbrkPoint, m[V].pKnots, orderV, bvprime);
694
695 /* Weight control points against the basis functions */
696
697 t_doubleCtrlPt *cpoint;
698 Point4 cp;
699 G4double tmp;
700
701 for (i=0; i<orderV; i++)
702 {
703 for (j=0; j<orderU; j++)
704 {
705 ri = orderV - 1 - i;
706 rj = orderU - 1 - j;
707
708 tmp = bu[rj] * bv[ri];
709
710 cpoint = GetdoubleCtrlPt(j+ufirst, i+vfirst);
711 cp.x = *cpoint[G4NURBS::X];
712 cp.y = *cpoint[G4NURBS::Y];
713 cp.z = *cpoint[G4NURBS::Z];
714 cp.w = *cpoint[G4NURBS::W];
715 delete [] cpoint;
716
717 r.x += cp.x * tmp;
718 r.y += cp.y * tmp;
719 r.z += cp.z * tmp;
720 r.w += cp.w * tmp;
721
722 tmp = buprime[rj] * bv[ri];
723 rutan.x += cp.x * tmp;
724 rutan.y += cp.y * tmp;
725 rutan.z += cp.z * tmp;
726 rutan.w += cp.w * tmp;
727
728 tmp = bu[rj] * bvprime[ri];
729 rvtan.x += cp.x * tmp;
730 rvtan.y += cp.y * tmp;
731 rvtan.z += cp.z * tmp;
732 rvtan.w += cp.w * tmp;
733 }
734 }
735
736 /* Project tangents, using the quotient rule for differentiation */
737
738 G4double wsqrdiv = 1.0 / (r.w * r.w);
739
740 utan.setX((r.w * rutan.x - rutan.w * r.x) * wsqrdiv);
741 utan.setY((r.w * rutan.y - rutan.w * r.y) * wsqrdiv);
742 utan.setZ((r.w * rutan.z - rutan.w * r.z) * wsqrdiv);
743
744 vtan.setX((r.w * rvtan.x - rvtan.w * r.x) * wsqrdiv);
745 vtan.setY((r.w * rvtan.y - rvtan.w * r.y) * wsqrdiv);
746 vtan.setZ((r.w * rvtan.z - rvtan.w * r.z) * wsqrdiv);
747
748 p.setX(r.x / r.w);
749 p.setY(r.y / r.w);
750 p.setZ(r.z / r.w);
751}
#define MAXORDER
double G4double
Definition: G4Types.hh:64
G4double t_doubleCtrlPt[NofC]
Definition: G4NURBS.hh:110
G4int GetUorder() const
Definition: G4NURBS.hh:431
G4int GetVorder() const
Definition: G4NURBS.hh:432
t_doubleCtrlPt * GetdoubleCtrlPt(t_indCtrlPt in_onedimindex) const
Definition: G4NURBS.cc:170
G4int GetUnbrCtrlPts() const
Definition: G4NURBS.hh:435
G4int GetVnbrCtrlPts() const
Definition: G4NURBS.hh:436

◆ CP() [1/2]

void G4NURBS::CP ( G4NURBS::t_CtrlPt rcp,
t_Coord  x,
t_Coord  y,
t_Coord  z,
t_Coord  w 
)
inlinestaticprotected

◆ CP() [2/2]

void G4NURBS::CP ( G4NURBS::t_CtrlPt rcp,
t_Coord  x,
t_Coord  y,
t_Coord  z,
t_Coord  w,
G4Float  factor 
)
inlinestaticprotected

Definition at line 530 of file G4NURBS.hh.

532{
533 rcp[G4NURBS::X]=factor*x;
534 rcp[G4NURBS::Y]=factor*y;
535 rcp[G4NURBS::Z]=factor*z;
536 rcp[G4NURBS::W]=factor*w;
537}

◆ GetdoubleAllCtrlPts()

G4double * G4NURBS::GetdoubleAllCtrlPts ( ) const

Definition at line 226 of file G4NURBS.cc.

227{
229 for (t_indKnot i = 0; i < mtotnbrCtrlPts*NofC; i++)
230 p[i] = (G4double)(((t_Coord *)mpCtrlPts)[i]);
231 return p;
232}
t_index t_indKnot
Definition: G4NURBS.hh:87
G4Float t_Coord
Definition: G4NURBS.hh:181

◆ GetdoubleAllKnots()

G4double * G4NURBS::GetdoubleAllKnots ( t_direction  in_dir) const

Definition at line 209 of file G4NURBS.cc.

210{
211 in_dir = (t_direction)(in_dir & DMask);
212 G4double * p = new G4double [m[in_dir].nbrKnots];
213 for (t_indKnot i = 0; i < m[in_dir].nbrKnots; i++)
214 p[i] = (G4double)m[in_dir].pKnots[i];
215 return p;
216}

◆ GetdoubleCtrlPt() [1/2]

G4NURBS::t_doubleCtrlPt * G4NURBS::GetdoubleCtrlPt ( t_indCtrlPt  in_onedimindex) const

Definition at line 170 of file G4NURBS.cc.

171{
172 if ( in_onedimindex < mtotnbrCtrlPts )
173 return TodoubleCtrlPt(mpCtrlPts[in_onedimindex]);
174 else
175 {
176 G4cerr << "\nERROR: G4NURBS::getdoubleCtrlPts: index out of range"
177 << "\n\t in_onedimindex : " << in_onedimindex
178 << " , mtotnbrCtrlPts : " << mtotnbrCtrlPts << G4endl;
180 }
181}
G4DLLIMPORT std::ostream G4cerr
static t_doubleCtrlPt * TodoubleCtrlPt(const t_CtrlPt &)
Definition: G4NURBS.hh:498

Referenced by CalcPoint().

◆ GetdoubleCtrlPt() [2/2]

G4NURBS::t_doubleCtrlPt * G4NURBS::GetdoubleCtrlPt ( t_inddCtrlPt  in_Uindex,
t_inddCtrlPt  in_Vindex 
) const

Definition at line 184 of file G4NURBS.cc.

185{
186 if ( (in_Uindex < m[U].nbrCtrlPts) && (in_Vindex < m[V].nbrCtrlPts) )
187 return TodoubleCtrlPt(mpCtrlPts[To1d(in_Uindex, in_Vindex)]);
188 else
189 {
190 G4cerr << "\nERROR: G4NURBS::GetdoubleCtrlPt: index(s) out of range"
191 << "\n\t in_Uindex : " << in_Uindex
192 << " , in_Vindex : " << in_Vindex
193 << " , UnbrCtrlPts : " << m[U].nbrCtrlPts
194 << " , VnbrCtrlPts : " << m[V].nbrCtrlPts << G4endl;
196 }
197}
t_indCtrlPt To1d(t_inddCtrlPt in_Uindex, t_inddCtrlPt in_Vindex) const
Definition: G4NURBS.hh:481

◆ GetdoubleKnot()

G4double G4NURBS::GetdoubleKnot ( t_direction  in_dir,
t_indKnot  in_index 
) const

Definition at line 123 of file G4NURBS.cc.

124{
125 in_dir = (t_direction)(in_dir & DMask);
126 if ( in_index < m[in_dir].nbrKnots )
127 return (G4double)(m[in_dir].pKnots[in_index]);
128 else
129 {
130 G4cerr << "\nERROR: G4NURBS::GetdoubleKnot: index out of range"
131 << "\n\t in_dir : " << G4int(in_dir)
132 << ", in_index : " << G4int(in_index)
133 << "m[in_dir].nbrKnots : " << m[in_dir].nbrKnots
134 << G4endl;
135 return (G4double)(m[in_dir].pKnots[m[in_dir].nbrKnots-1]);
136 }
137}

◆ GetfloatAllCtrlPts()

G4float * G4NURBS::GetfloatAllCtrlPts ( ) const

Definition at line 218 of file G4NURBS.cc.

219{
221 for (t_indKnot i = 0; i < mtotnbrCtrlPts*NofC; i++)
222 p[i] = (G4float)(((t_Coord *)mpCtrlPts)[i]);
223 return p;
224}
float G4float
Definition: G4Types.hh:65

◆ GetfloatAllKnots()

G4float * G4NURBS::GetfloatAllKnots ( t_direction  in_dir) const

Definition at line 200 of file G4NURBS.cc.

201{
202 in_dir = (t_direction)(in_dir & DMask);
203 G4float * p = new G4float [m[in_dir].nbrKnots];
204 for (t_indKnot i = 0; i < m[in_dir].nbrKnots; i++)
205 p[i] = (G4float)m[in_dir].pKnots[i];
206 return p;
207}

◆ GetfloatCtrlPt() [1/2]

G4NURBS::t_floatCtrlPt * G4NURBS::GetfloatCtrlPt ( t_indCtrlPt  in_onedimindex) const

Definition at line 140 of file G4NURBS.cc.

141{
142 if (in_onedimindex < mtotnbrCtrlPts)
143 return TofloatCtrlPt(mpCtrlPts[in_onedimindex]);
144 else
145 {
146 G4cerr << "\nERROR: G4NURBS::GetfloatCtrlPt: index out of range"
147 << "\n\t in_onedimindex : " << in_onedimindex
148 << " , mtotnbrCtrlPts : " << mtotnbrCtrlPts << G4endl;
150 }
151}
static t_floatCtrlPt * TofloatCtrlPt(const t_CtrlPt &)
Definition: G4NURBS.hh:488

◆ GetfloatCtrlPt() [2/2]

G4NURBS::t_floatCtrlPt * G4NURBS::GetfloatCtrlPt ( t_inddCtrlPt  in_Uindex,
t_inddCtrlPt  in_Vindex 
) const

Definition at line 154 of file G4NURBS.cc.

155{
156 if ( (in_Uindex < m[U].nbrCtrlPts) && (in_Vindex < m[V].nbrCtrlPts) )
157 return TofloatCtrlPt(mpCtrlPts[To1d(in_Uindex, in_Vindex)]);
158 else
159 {
160 G4cerr << "\nERROR: G4NURBS::GetfloatCtrlPt: index(s) out of range"
161 << "\n\t in_Uindex : " << in_Uindex
162 << " , in_Vindex : " << in_Vindex
163 << " , UnbrCtrlPts : " << m[U].nbrCtrlPts
164 << " , VnbrCtrlPts : " << m[V].nbrCtrlPts << G4endl;
166 }
167}

◆ GetfloatKnot()

G4float G4NURBS::GetfloatKnot ( t_direction  in_dir,
t_indKnot  in_index 
) const

Definition at line 108 of file G4NURBS.cc.

109{
110 in_dir = (t_direction)(in_dir & DMask);
111 if ( in_index < m[in_dir].nbrKnots )
112 return ((G4float)(m[in_dir].pKnots[in_index]));
113 else
114 {
115 G4cerr << "\nERROR: G4NURBS::GetfloatKnot: index out of range\n"
116 << "\n\t in_dir : " << G4int(in_dir)
117 << ", in_index : " << G4int(in_index)
118 << "m[in_dir].nbrKnots : " << m[in_dir].nbrKnots << G4endl;
119 return ((G4float)m[in_dir].pKnots[m[in_dir].nbrKnots-1]);
120 }
121}

◆ GetnbrCtrlPts()

G4int G4NURBS::GetnbrCtrlPts ( G4NURBS::t_direction  in_dir) const
inline

Definition at line 463 of file G4NURBS.hh.

463 {
464 return m[in_dir & DMask].nbrCtrlPts;
465}

◆ GetnbrKnots()

G4int G4NURBS::GetnbrKnots ( G4NURBS::t_direction  in_dir) const
inline

Definition at line 459 of file G4NURBS.hh.

459 {
460 return m[in_dir & DMask].nbrKnots;
461}

Referenced by operator<<().

◆ Getorder()

G4int G4NURBS::Getorder ( G4NURBS::t_direction  in_dir) const
inline

Definition at line 455 of file G4NURBS.hh.

455 {
456 return m[in_dir & DMask].order;
457}

◆ GettotalnbrCtrlPts()

G4int G4NURBS::GettotalnbrCtrlPts ( ) const
inline

Definition at line 437 of file G4NURBS.hh.

437{ return mtotnbrCtrlPts; }

◆ GetUmax()

G4double G4NURBS::GetUmax ( ) const
inline

Definition at line 443 of file G4NURBS.hh.

443 {
444 return (G4double) m[U].pKnots[GetUnbrCtrlPts()];
445}

◆ GetUmin()

G4double G4NURBS::GetUmin ( ) const
inline

Definition at line 439 of file G4NURBS.hh.

439 {
440 return (G4double) m[U].pKnots[GetUorder()-1];
441}

◆ GetUnbrCtrlPts()

G4int G4NURBS::GetUnbrCtrlPts ( ) const
inline

Definition at line 435 of file G4NURBS.hh.

435{ return m[U].nbrCtrlPts; }

Referenced by CalcPoint(), GetUmax(), and operator<<().

◆ GetUnbrKnots()

G4int G4NURBS::GetUnbrKnots ( ) const
inline

Definition at line 433 of file G4NURBS.hh.

433{ return m[U].nbrKnots; }

◆ GetUorder()

G4int G4NURBS::GetUorder ( ) const
inline

Definition at line 431 of file G4NURBS.hh.

431{ return m[U].order; }

Referenced by CalcPoint(), GetUmin(), and operator<<().

◆ GetVmax()

G4double G4NURBS::GetVmax ( ) const
inline

Definition at line 451 of file G4NURBS.hh.

451 {
452 return (G4double) m[V].pKnots[GetVnbrCtrlPts()];
453}

◆ GetVmin()

G4double G4NURBS::GetVmin ( ) const
inline

Definition at line 447 of file G4NURBS.hh.

447 {
448 return (G4double) m[V].pKnots[GetVorder()-1];
449}

◆ GetVnbrCtrlPts()

G4int G4NURBS::GetVnbrCtrlPts ( ) const
inline

Definition at line 436 of file G4NURBS.hh.

436{ return m[V].nbrCtrlPts; }

Referenced by CalcPoint(), GetVmax(), and operator<<().

◆ GetVnbrKnots()

G4int G4NURBS::GetVnbrKnots ( ) const
inline

Definition at line 434 of file G4NURBS.hh.

434{ return m[V].nbrKnots; }

◆ GetVorder()

G4int G4NURBS::GetVorder ( ) const
inline

Definition at line 432 of file G4NURBS.hh.

432{ return m[V].order; }

Referenced by CalcPoint(), GetVmin(), and operator<<().

◆ MakeKnotVector() [1/2]

G4bool G4NURBS::MakeKnotVector ( t_Dir inout_dirdat,
t_KnotVectorGenFlag  in_KVGFlag 
)
staticprotected

Definition at line 331 of file G4NURBS.cc.

332{
333 G4bool isgood = (io_d.order + io_d.nbrCtrlPts == io_d.nbrKnots)
334 && (io_d.pKnots == 0);
335 if ( isgood )
336 {
337 io_d.pKnots = new t_Knot [io_d.nbrKnots];
338 if (in_KVGFlag != UserDefined)
339 { // let's do the knots
340 t_indKnot indKnot = 0;
341 t_index nbrCentralDistinctKnots = io_d.nbrCtrlPts-io_d.order;
342 if ( (nbrCentralDistinctKnots % in_KVGFlag) == 0)
343 {
344 nbrCentralDistinctKnots /= in_KVGFlag;
345 // first and last knots repeated 'order' Times
346 for (t_index i=0; i < io_d.order; indKnot++,i++)
347 {
348 io_d.pKnots[indKnot] = 0;
349 io_d.pKnots[indKnot+io_d.nbrCtrlPts] = 1;
350 }
351
352 t_Knot stepKnot = 1.0/(t_Knot)(nbrCentralDistinctKnots+1);
353 t_Knot valKnot = stepKnot;
354
355 // central knots
356 for (t_indKnot j=0; j<nbrCentralDistinctKnots; valKnot+=stepKnot, j++)
357 {
358 for (t_indKnot k=0; k<t_indKnot(in_KVGFlag); indKnot++, k++)
359 io_d.pKnots[indKnot] = valKnot;
360 }
361 }
362 else isgood = false;
363 } // end of knots making
364 }
365 return isgood;
366}
bool G4bool
Definition: G4Types.hh:67
G4Float t_Knot
Definition: G4NURBS.hh:176
unsigned int t_index
Definition: G4NURBS.hh:84

Referenced by G4NURBS(), and MakeKnotVector().

◆ MakeKnotVector() [2/2]

G4bool G4NURBS::MakeKnotVector ( G4NURBS::t_Dir p_inoutdirdat,
G4NURBS::t_KnotVectorGenFlag  in_KVGFlag 
)
inlinestaticprotected

Definition at line 507 of file G4NURBS.hh.

509{
510 return MakeKnotVector(*p_inoutdirdat, in_KVGFlag);
511}

◆ To1d()

G4NURBS::t_indCtrlPt G4NURBS::To1d ( t_inddCtrlPt  in_Uindex,
t_inddCtrlPt  in_Vindex 
) const
inlineprotected

Definition at line 481 of file G4NURBS.hh.

482{
483 return in_Uindex + in_Vindex*m[U].nbrCtrlPts;
484}

Referenced by G4NURBShexahedron::G4NURBShexahedron(), GetdoubleCtrlPt(), and GetfloatCtrlPt().

◆ Tochar()

char G4NURBS::Tochar ( G4NURBS::t_direction  in_dir)
inlinestatic

Definition at line 467 of file G4NURBS.hh.

467 {
468 return (in_dir != U? 'V': 'U');
469}

Referenced by G4NURBS(), and operator<<().

◆ TodoubleCtrlPt()

G4NURBS::t_doubleCtrlPt * G4NURBS::TodoubleCtrlPt ( const t_CtrlPt in_krcp)
inlinestaticprotected

Definition at line 498 of file G4NURBS.hh.

499{
501 for (G4int indCoord = X; indCoord < NofC; indCoord++)
502 (*pcopy)[indCoord] = (G4double)in_krcp[indCoord];
503 return pcopy;
504}

Referenced by GetdoubleCtrlPt().

◆ TofloatCtrlPt()

G4NURBS::t_floatCtrlPt * G4NURBS::TofloatCtrlPt ( const t_CtrlPt in_krcp)
inlinestaticprotected

Definition at line 488 of file G4NURBS.hh.

489{
491 for (G4int indCoord = X; indCoord < NofC; indCoord++)
492 (*pcopy)[indCoord] = (G4float)in_krcp[indCoord];
493 return pcopy;
494}
G4float t_floatCtrlPt[NofC]
Definition: G4NURBS.hh:111

Referenced by GetfloatCtrlPt().

◆ Whoami()

virtual const char * G4NURBS::Whoami ( ) const
pure virtual

Friends And Related Function Documentation

◆ CtrlPtsCoordsIterator

friend class CtrlPtsCoordsIterator
friend

Definition at line 202 of file G4NURBS.hh.

◆ CtrlPtsIterator

friend class CtrlPtsIterator
friend

Definition at line 203 of file G4NURBS.hh.

◆ KnotsIterator

friend class KnotsIterator
friend

Definition at line 201 of file G4NURBS.hh.

◆ operator<<

std::ostream & operator<< ( std::ostream &  inout_OutStream,
G4NURBS::t_KnotVectorGenFlag  in_KVGFlag 
)
friend

Definition at line 369 of file G4NURBS.cc.

371{
372 switch (in_f)
373 {
374 case G4NURBS::UserDefined: io_ostr << "UserDefined"; break;
375 case G4NURBS::Regular: io_ostr << "Regular"; break;
376 case G4NURBS::RegularRep: io_ostr << "RegularRep"; break;
377 default: io_ostr << (G4int)in_f;
378 }
379 return io_ostr;
380}

Member Data Documentation

◆ m

◆ mpCtrlPts

◆ mtotnbrCtrlPts


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