Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Colour.cc,v 2.1 1998/07/13 16:56:14 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 20th October 1996
|
||||
|
||||
#include "G4Colour.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
ostream& operator << (ostream& os, const G4Colour& c) {
|
||||
return os << '(' << c.red << ',' << c.green << ',' << c.blue
|
||||
<< ',' << c.alpha << ')';
|
||||
}
|
||||
|
||||
G4bool operator != (const G4Colour& c1, const G4Colour& c2) {
|
||||
if (
|
||||
(c1.red != c2.red) ||
|
||||
(c1.green != c2.green) ||
|
||||
(c1.blue != c2.blue) ||
|
||||
(c1.alpha != c2.alpha)
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,735 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4NURBS.cc,v 2.3 1998/12/01 13:36:42 evc Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// Olivier Crumeyrolle 12 September 1996
|
||||
|
||||
// G4NURBS.cc
|
||||
// Implementation of class G4NURBS
|
||||
// OC 100796
|
||||
|
||||
|
||||
#include "G4NURBS.hh"
|
||||
|
||||
// G4NURBS.hh includes globals.hh which includes a lot of others
|
||||
// so no more includes required here
|
||||
|
||||
// stdlib required for the exit function
|
||||
//#include <stdlib.h>
|
||||
|
||||
// memcpy
|
||||
//#include <string.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Here start the real world. Please, check your armored jacket. //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
ostream & operator << (ostream & inout_outStream, const G4NURBS & in_kNurb)
|
||||
{
|
||||
inout_outStream
|
||||
// the magic could be changed for good reasons only
|
||||
<< "##ojc{NURBS}def[1.01.96.7] Just a magic. Could be added to /etc/magic"
|
||||
<< "\n# NURBS Definition File (human and computer readable format)"
|
||||
<< "\n# :" << in_kNurb.Whoami()
|
||||
<< "\n# U order\tV order : "
|
||||
<< '\n' << in_kNurb.GetUorder() << "\t\t" << in_kNurb.GetVorder();
|
||||
// number of knots and knots themselves for U and V
|
||||
for (G4NURBS::t_direction dir = G4NURBS::U; dir < G4NURBS::NofD; /*(*(int *)(&dir))++*/ dir=(G4NURBS::t_direction)(((int)(dir))+1) )
|
||||
{
|
||||
inout_outStream
|
||||
<< "\n# Number of knots along " << G4NURBS::Tochar(dir)
|
||||
<< '\n' << in_kNurb.GetnbrKnots(dir)
|
||||
<< "\n# " << G4NURBS::Tochar(dir) << " knots vector (as a column)";
|
||||
{ // begin knots iteration
|
||||
G4double oneKnot;
|
||||
G4NURBS::KnotsIterator knotI(in_kNurb,dir);
|
||||
G4bool otherKnots;
|
||||
do
|
||||
{
|
||||
otherKnots = knotI.pick(&oneKnot);
|
||||
inout_outStream << "\n\t\t" << oneKnot;
|
||||
}
|
||||
while (otherKnots);
|
||||
} // end of knots iteration
|
||||
}; // end of direction loop
|
||||
// number of control points in U and V direction
|
||||
// and controlpoints
|
||||
inout_outStream
|
||||
<< "\n# Number of control points along U and V"
|
||||
<< '\n' << in_kNurb.GetUnbrCtrlPts()
|
||||
<< " " << in_kNurb.GetVnbrCtrlPts()
|
||||
<< "\n# Control Points (one by line, U increasing first)";
|
||||
{ // begin of control points iteration
|
||||
G4NURBS::t_doubleCtrlPt oneCP;
|
||||
G4NURBS::CtrlPtsIterator cpI(in_kNurb);
|
||||
G4bool otherCPs;
|
||||
do
|
||||
{
|
||||
otherCPs = cpI.pick(&oneCP);
|
||||
inout_outStream
|
||||
<< "\n\t" << oneCP[G4NURBS::X]
|
||||
<< "\t" << oneCP[G4NURBS::Y]
|
||||
<< "\t" << oneCP[G4NURBS::Z]
|
||||
<< "\t" << oneCP[G4NURBS::W];
|
||||
}
|
||||
while (otherCPs);
|
||||
} // end of control point iteration
|
||||
inout_outStream << "\n# That's all!" << endl; // endl do an \n and a flush
|
||||
return inout_outStream;
|
||||
}
|
||||
|
||||
// the CC compiler issue some "maybe no value returned"
|
||||
// but everything is ok
|
||||
|
||||
G4float G4NURBS::GetfloatKnot(t_direction in_dir, t_indKnot in_index) const
|
||||
{
|
||||
in_dir = (t_direction)(in_dir & DMask);
|
||||
if ( in_index < m[in_dir].nbrKnots )
|
||||
return ((G4float)(m[in_dir].pKnots[in_index]));
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::GetfloatKnot: index out of range\n"
|
||||
<< "\n\t in_dir : " << in_dir << ", in_index : " << in_index
|
||||
<< "m[in_dir].nbrKnots : " << m[in_dir].nbrKnots << endl;
|
||||
return ((G4float)m[in_dir].pKnots[m[in_dir].nbrKnots-1]);
|
||||
};
|
||||
}
|
||||
|
||||
G4double G4NURBS::GetdoubleKnot(t_direction in_dir, t_indKnot in_index) const
|
||||
{
|
||||
in_dir = (t_direction)(in_dir & DMask);
|
||||
if ( in_index < m[in_dir].nbrKnots )
|
||||
return (G4double)(m[in_dir].pKnots[in_index]);
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::GetdoubleKnot: index out of range"
|
||||
<< "\n\t in_dir : " << in_dir << ", in_index : " << in_index
|
||||
<< "m[in_dir].nbrKnots : " << m[in_dir].nbrKnots << endl;
|
||||
return (G4double)(m[in_dir].pKnots[m[in_dir].nbrKnots-1]);
|
||||
};
|
||||
}
|
||||
|
||||
G4NURBS::t_floatCtrlPt* G4NURBS::GetfloatCtrlPt(t_indCtrlPt in_onedimindex) const
|
||||
{
|
||||
if (in_onedimindex < mtotnbrCtrlPts)
|
||||
return TofloatCtrlPt(mpCtrlPts[in_onedimindex]);
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::GetfloatCtrlPt: index out of range"
|
||||
<< "\n\t in_onedimindex : " << in_onedimindex
|
||||
<< " , mtotnbrCtrlPts : " << mtotnbrCtrlPts << endl;
|
||||
return TofloatCtrlPt(mpCtrlPts[mtotnbrCtrlPts-1]);
|
||||
};
|
||||
}
|
||||
|
||||
G4NURBS::t_floatCtrlPt* G4NURBS::GetfloatCtrlPt(t_inddCtrlPt in_Uindex, t_inddCtrlPt in_Vindex) const
|
||||
{
|
||||
if (
|
||||
(in_Uindex < m[U].nbrCtrlPts)
|
||||
&& (in_Vindex < m[V].nbrCtrlPts)
|
||||
)
|
||||
return TofloatCtrlPt(mpCtrlPts[To1d(in_Uindex, in_Vindex)]);
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::GetfloatCtrlPt: index(s) out of range"
|
||||
<< "\n\t in_Uindex : " << in_Uindex
|
||||
<< " , in_Vindex : " << in_Vindex
|
||||
<< " , UnbrCtrlPts : " << m[U].nbrCtrlPts
|
||||
<< " , VnbrCtrlPts : " << m[V].nbrCtrlPts << endl;
|
||||
return TofloatCtrlPt(mpCtrlPts[mtotnbrCtrlPts-1]);
|
||||
};
|
||||
}
|
||||
|
||||
G4NURBS::t_doubleCtrlPt* G4NURBS::GetdoubleCtrlPt(t_indCtrlPt in_onedimindex) const
|
||||
{
|
||||
if ( in_onedimindex < mtotnbrCtrlPts )
|
||||
return TodoubleCtrlPt(mpCtrlPts[in_onedimindex]);
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::getdoubleCtrlPts: index out of range"
|
||||
<< "\n\t in_onedimindex : " << in_onedimindex
|
||||
<< " , mtotnbrCtrlPts : " << mtotnbrCtrlPts << endl;
|
||||
return TodoubleCtrlPt(mpCtrlPts[mtotnbrCtrlPts-1]);
|
||||
};
|
||||
}
|
||||
|
||||
G4NURBS::t_doubleCtrlPt* G4NURBS::GetdoubleCtrlPt(t_inddCtrlPt in_Uindex, t_inddCtrlPt in_Vindex) const
|
||||
{
|
||||
if (
|
||||
(in_Uindex < m[U].nbrCtrlPts)
|
||||
&& (in_Vindex < m[V].nbrCtrlPts)
|
||||
)
|
||||
return TodoubleCtrlPt(mpCtrlPts[To1d(in_Uindex, in_Vindex)]);
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::GetdoubleCtrlPt: index(s) out of range"
|
||||
<< "\n\t in_Uindex : " << in_Uindex
|
||||
<< " , in_Vindex : " << in_Vindex
|
||||
<< " , UnbrCtrlPts : " << m[U].nbrCtrlPts
|
||||
<< " , VnbrCtrlPts : " << m[V].nbrCtrlPts << endl;
|
||||
return TodoubleCtrlPt(mpCtrlPts[mtotnbrCtrlPts-1]);
|
||||
};
|
||||
}
|
||||
|
||||
// Total copy
|
||||
G4float * G4NURBS::GetfloatAllKnots(t_direction in_dir) const
|
||||
{
|
||||
in_dir = (t_direction)(in_dir & DMask);
|
||||
G4float * p = new G4float [m[in_dir].nbrKnots];
|
||||
for (t_indKnot i = 0; i < m[in_dir].nbrKnots; i++)
|
||||
p[i] = (G4float)m[in_dir].pKnots[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
G4double * G4NURBS::GetdoubleAllKnots(t_direction in_dir) const
|
||||
{
|
||||
in_dir = (t_direction)(in_dir & DMask);
|
||||
G4double * p = new G4double [m[in_dir].nbrKnots];
|
||||
for (t_indKnot i = 0; i < m[in_dir].nbrKnots; i++)
|
||||
p[i] = (G4double)m[in_dir].pKnots[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4float * G4NURBS::GetfloatAllCtrlPts() const
|
||||
{
|
||||
G4float * p = new G4float [mtotnbrCtrlPts*NofC];
|
||||
for (t_indKnot i = 0; i < mtotnbrCtrlPts*NofC; i++)
|
||||
p[i] = (G4float)(((t_Coord *)mpCtrlPts)[i]);
|
||||
return p;
|
||||
}
|
||||
|
||||
G4double * G4NURBS::GetdoubleAllCtrlPts() const
|
||||
{
|
||||
G4double * p = new G4double [mtotnbrCtrlPts*NofC];
|
||||
for (t_indKnot i = 0; i < mtotnbrCtrlPts*NofC; i++)
|
||||
p[i] = (G4double)(((t_Coord *)mpCtrlPts)[i]);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Iterators
|
||||
|
||||
G4NURBS::KnotsIterator::KnotsIterator(const G4NURBS & in_rNurb, G4NURBS::t_direction in_dir, t_indKnot in_startIndex)
|
||||
: kmdir((G4NURBS::t_direction)(in_dir & G4NURBS::DMask)),
|
||||
kmpMax(in_rNurb.m[kmdir].pKnots + in_rNurb.m[kmdir].nbrKnots)
|
||||
|
||||
{
|
||||
if (in_startIndex < in_rNurb.m[kmdir].nbrKnots)
|
||||
mp = in_rNurb.m[kmdir].pKnots + in_startIndex;
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::KnotsIterator: in_startIndex out of range"
|
||||
<< "\n\tin_startIndex : " << in_startIndex
|
||||
<< ", nbr of knots : " << in_rNurb.m[kmdir].nbrKnots
|
||||
<< "\n\t mp set to NULL, calls to picking functions will fail"
|
||||
<< endl;
|
||||
mp = NULL;
|
||||
};
|
||||
}
|
||||
|
||||
G4bool G4NURBS::KnotsIterator::pick(G4double * inout_pDbl)
|
||||
{
|
||||
(*inout_pDbl) = (G4double)(*mp);
|
||||
return (G4bool)((++mp)<kmpMax);
|
||||
}
|
||||
|
||||
G4bool G4NURBS::KnotsIterator::pick(G4float * inout_pFlt)
|
||||
{
|
||||
(*inout_pFlt) = (G4float)(*mp);
|
||||
return (G4bool)((++mp)<kmpMax);
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4NURBS::CtrlPtsCoordsIterator::CtrlPtsCoordsIterator(const G4NURBS & in_rNurb, t_indCtrlPt in_startCtrlPtIndex)
|
||||
: kmpMax((const t_Coord *)(in_rNurb.mpCtrlPts + in_rNurb.mtotnbrCtrlPts))
|
||||
{
|
||||
if (in_startCtrlPtIndex < in_rNurb.mtotnbrCtrlPts )
|
||||
mp = (const t_Coord *)(in_rNurb.mpCtrlPts + in_startCtrlPtIndex);
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::CtrlPtsCoordsIterator: in_startCtrlPtIndex out of range"
|
||||
<< "\n\tin_startCtrlPtIndex : " << in_startCtrlPtIndex
|
||||
<< ", nbr of CtrlPts : " << in_rNurb.mtotnbrCtrlPts
|
||||
<< "\n\t mp set to NULL, calls to picking functions will fail"
|
||||
<< endl;
|
||||
mp = NULL;
|
||||
};
|
||||
}
|
||||
|
||||
G4bool G4NURBS::CtrlPtsCoordsIterator::pick(G4double * inout_pDbl)
|
||||
{
|
||||
(*inout_pDbl) = (G4double)((*mp));
|
||||
return (G4bool)((++mp)<kmpMax);
|
||||
}
|
||||
|
||||
G4bool G4NURBS::CtrlPtsCoordsIterator::pick(G4float * inout_pFlt)
|
||||
{
|
||||
(*inout_pFlt) = (G4float)((*mp));
|
||||
return (G4bool)((++mp)<kmpMax);
|
||||
}
|
||||
|
||||
G4NURBS::CtrlPtsIterator::CtrlPtsIterator(const G4NURBS & in_rNurb, t_indCtrlPt in_startIndex)
|
||||
: kmpMax(in_rNurb.mpCtrlPts + in_rNurb.mtotnbrCtrlPts)
|
||||
{
|
||||
if (in_startIndex < in_rNurb.mtotnbrCtrlPts )
|
||||
mp = (in_rNurb.mpCtrlPts + in_startIndex);
|
||||
else
|
||||
{
|
||||
G4cerr << "\nERROR: G4NURBS::CtrlPtsIterator: in_startIndex out of range"
|
||||
<< "\n\tin_startIndex : " << in_startIndex
|
||||
<< ", nbr of CtrlPts : " << in_rNurb.mtotnbrCtrlPts
|
||||
<< "\n\t mp set to NULL, calls to picking functions will fail"
|
||||
<< endl;
|
||||
mp = NULL;
|
||||
};
|
||||
}
|
||||
|
||||
G4bool G4NURBS::CtrlPtsIterator::pick(t_doubleCtrlPt * inout_pDblCtrlPt)
|
||||
{
|
||||
for (t_indCoord i = G4NURBS::X; i < G4NURBS::NofC; i++)
|
||||
(*inout_pDblCtrlPt)[i] = (G4double)((*mp)[i]);
|
||||
return (G4bool)((++mp)<kmpMax);
|
||||
}
|
||||
|
||||
G4bool G4NURBS::CtrlPtsIterator::pick(t_floatCtrlPt * inout_pFltCtrlPt)
|
||||
{
|
||||
for (t_indCoord i = G4NURBS::X; i < G4NURBS::NofC; i++)
|
||||
(*inout_pFltCtrlPt)[i] = (G4float)((*mp)[i]);
|
||||
return (G4bool)((++mp)<kmpMax);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Building functions
|
||||
|
||||
|
||||
G4bool G4NURBS::MakeKnotVector(t_Dir & io_d, t_KnotVectorGenFlag in_KVGFlag)
|
||||
{
|
||||
G4bool isgood = (io_d.order + io_d.nbrCtrlPts == io_d.nbrKnots)
|
||||
&& (io_d.pKnots == NULL);
|
||||
if ( isgood )
|
||||
{
|
||||
io_d.pKnots = new t_Knot [io_d.nbrKnots];
|
||||
if (in_KVGFlag != UserDefined)
|
||||
{ // let's do the knots
|
||||
t_indKnot indKnot = 0;
|
||||
t_index nbrCentralDistinctKnots = io_d.nbrCtrlPts-io_d.order;
|
||||
if ( (nbrCentralDistinctKnots % in_KVGFlag) == 0)
|
||||
{
|
||||
nbrCentralDistinctKnots /= in_KVGFlag;
|
||||
// first and last knots repeated 'order' Times
|
||||
for (t_index i=0; i < io_d.order; indKnot++,i++)
|
||||
{
|
||||
io_d.pKnots[indKnot] = 0;
|
||||
io_d.pKnots[indKnot+io_d.nbrCtrlPts] = 1;
|
||||
};
|
||||
|
||||
t_Knot stepKnot = 1.0/(t_Knot)(nbrCentralDistinctKnots+1);
|
||||
t_Knot valKnot = stepKnot;
|
||||
|
||||
// central knots
|
||||
for (t_indKnot j=0; j < nbrCentralDistinctKnots; valKnot += stepKnot, j++)
|
||||
{
|
||||
for (t_indKnot k=0; k < in_KVGFlag; indKnot++, k++)
|
||||
io_d.pKnots[indKnot] = valKnot;
|
||||
};
|
||||
}
|
||||
else isgood = false;
|
||||
}; // end of knots making
|
||||
};
|
||||
return isgood;
|
||||
}
|
||||
|
||||
|
||||
ostream & operator << (ostream & io_ostr, G4NURBS::t_KnotVectorGenFlag in_f)
|
||||
{
|
||||
switch (in_f)
|
||||
{
|
||||
case G4NURBS::UserDefined: io_ostr << "UserDefined"; break;
|
||||
case G4NURBS::Regular: io_ostr << "Regular"; break;
|
||||
case G4NURBS::RegularRep: io_ostr << "RegularRep"; break;
|
||||
default: io_ostr << (int)in_f;
|
||||
};
|
||||
return io_ostr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Constructors and co
|
||||
|
||||
void G4NURBS::Conscheck() const
|
||||
{
|
||||
G4int dummy;
|
||||
t_direction dir;
|
||||
for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
|
||||
{
|
||||
if (m[dir].order<=0)
|
||||
{
|
||||
G4cerr << "\nFATAL ERROR: G4NURBS::G4NURBS: The order in the "
|
||||
<< G4NURBS::Tochar(dir)
|
||||
<< " direction must be >= 1" << endl;
|
||||
exit(-1);
|
||||
};
|
||||
if (m[dir].nbrCtrlPts<=0)
|
||||
{
|
||||
G4cerr << "\nFATAL ERROR: G4NURBS::G4NURBS: The number of control points "
|
||||
<< G4NURBS::Tochar(dir)
|
||||
<< " direction must be >= 1" << endl;
|
||||
exit(-1);
|
||||
};
|
||||
}; // end of dummy
|
||||
}
|
||||
|
||||
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, t_Knot * in_pVKnots,
|
||||
t_CheckFlag in_CheckFlag
|
||||
)
|
||||
{
|
||||
|
||||
m[U].order=in_Uorder; m[V].order=in_Vorder;
|
||||
m[U].nbrCtrlPts=in_UnbrCtrlPts; m[V].nbrCtrlPts=in_VnbrCtrlPts;
|
||||
|
||||
mtotnbrCtrlPts = m[U].nbrCtrlPts * m[V].nbrCtrlPts;
|
||||
m[U].nbrKnots = m[U].order + m[U].nbrCtrlPts;
|
||||
m[V].nbrKnots = m[V].order + m[V].nbrCtrlPts;
|
||||
|
||||
if (in_CheckFlag)
|
||||
Conscheck();
|
||||
|
||||
// CtrlPts
|
||||
if (! (mpCtrlPts = in_pCtrlPts) )
|
||||
{
|
||||
G4cerr << "\nFATAL ERROR: G4NURBS::G4NURBS: A NURBS MUST HAVE CONTROL POINTS!\n\teven if they are defined later, the array must be allocated."
|
||||
<< "\n\tgood bye. Have a nice debuging." << endl;
|
||||
exit(-1);
|
||||
};
|
||||
//mnbralias = 0;
|
||||
|
||||
// Knots
|
||||
t_direction dir;
|
||||
G4int dummy;
|
||||
for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
|
||||
{
|
||||
if ( !(m[dir].pKnots = (dummy?in_pVKnots:in_pUKnots)) )
|
||||
{ // make some regular knots between 0 & 1
|
||||
if(!MakeKnotVector(m[dir], Regular))
|
||||
{
|
||||
G4cerr << "\nFATAL ERROR: G4NURBS::G4NURBS: Unable to make a Regular knot vector along "
|
||||
<< G4NURBS::Tochar(dir)
|
||||
<< " direction."
|
||||
<< "\n\tgood bye. Have a nice debuging."
|
||||
<< endl;
|
||||
exit(-1);
|
||||
|
||||
};
|
||||
//m[dir].nbralias = 0;
|
||||
}; // end of knots-making
|
||||
};// end for dummy
|
||||
|
||||
} // end of G4NURBS::G4NURBS
|
||||
|
||||
|
||||
// second constructor
|
||||
|
||||
G4NURBS::G4NURBS(
|
||||
t_order in_Uorder, t_order in_Vorder,
|
||||
t_inddCtrlPt in_UnbrCtrlPts, t_inddCtrlPt in_VnbrCtrlPts,
|
||||
t_KnotVectorGenFlag in_UKVGFlag,
|
||||
t_KnotVectorGenFlag in_VKVGFlag,
|
||||
t_CheckFlag in_CheckFlag
|
||||
)
|
||||
{
|
||||
|
||||
m[U].order=in_Uorder; m[V].order=in_Vorder;
|
||||
m[U].nbrCtrlPts=in_UnbrCtrlPts; m[V].nbrCtrlPts=in_VnbrCtrlPts;
|
||||
|
||||
mtotnbrCtrlPts = m[U].nbrCtrlPts * m[V].nbrCtrlPts;
|
||||
m[U].nbrKnots = m[U].order + m[U].nbrCtrlPts;
|
||||
m[V].nbrKnots = m[V].order + m[V].nbrCtrlPts;
|
||||
|
||||
if (in_CheckFlag)
|
||||
Conscheck();
|
||||
|
||||
// Allocate CtrlPts
|
||||
mpCtrlPts = new t_CtrlPt [mtotnbrCtrlPts];
|
||||
//mnbralias = 0;
|
||||
|
||||
// Knots
|
||||
t_direction dir;
|
||||
G4int dummy;
|
||||
for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
|
||||
{
|
||||
t_KnotVectorGenFlag flag = (dummy?in_VKVGFlag:in_UKVGFlag);
|
||||
m[dir].pKnots = NULL; // (allocation under our control)
|
||||
if ( flag && !MakeKnotVector(m[dir], flag) )
|
||||
{
|
||||
G4cerr << "\nFATAL ERROR: G4NURBS::G4NURBS: Unable to make knot vector along "
|
||||
<< G4NURBS::Tochar(dir)
|
||||
<< " direction. (" << m[dir].nbrKnots
|
||||
<< " knots requested for a "
|
||||
<< flag
|
||||
<< " knots vector)"
|
||||
<< "\n\tgood bye. Have a nice debuging."
|
||||
<< endl;
|
||||
exit(-1);
|
||||
};
|
||||
//m[dir].nbralias = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4NURBS::G4NURBS(const G4NURBS & in_krNurb)
|
||||
{
|
||||
// we assume the in nurbs is ok
|
||||
|
||||
// the number of CtrlPts can be copied straightly
|
||||
mtotnbrCtrlPts = in_krNurb.mtotnbrCtrlPts;
|
||||
|
||||
// the main datas
|
||||
|
||||
// but as m is an array of t_Dir and as t_Dir
|
||||
// is just a structure and not a class with a copy cons
|
||||
// whe need to duplicate the knots
|
||||
t_direction dir;
|
||||
G4int dummy;
|
||||
for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
|
||||
{
|
||||
// first we do a 'stupid' copy of m[dir]
|
||||
m[dir] = in_krNurb.m[dir];
|
||||
// but as m is an array of t_Dir and as t_Dir
|
||||
// is just a structure and not a class with a copy cons
|
||||
// whe need to duplicate the knots
|
||||
m[dir].pKnots = new G4double [m[dir].nbrKnots];
|
||||
// we copy the knots with memcpy. This function should be the fastest
|
||||
memcpy(m[dir].pKnots, in_krNurb.m[dir].pKnots, m[dir].nbrKnots * sizeof(G4double));
|
||||
}; // end of dummy loop
|
||||
|
||||
// the control points
|
||||
// once again we need to do the copy
|
||||
mpCtrlPts = new t_CtrlPt [mtotnbrCtrlPts];
|
||||
memcpy(mpCtrlPts, in_krNurb.mpCtrlPts, mtotnbrCtrlPts*sizeof(t_CtrlPt));
|
||||
|
||||
// and as it's very strange to copy a nurbs in G4
|
||||
// we issue a warning :
|
||||
G4cerr << "\nWARNING: G4NURBS::G4NURBS(const G4NURBS &) used" << endl;
|
||||
} // end of G4NURBS::G4NURBS(const G4NURBS &)
|
||||
|
||||
|
||||
G4NURBS::~G4NURBS()
|
||||
{
|
||||
// we must free the two knots vector
|
||||
t_direction dir;
|
||||
G4int dummy;
|
||||
for (dummy=0; (dummy?(dir=V):(dir=U)),(dummy < NofD); dummy++)
|
||||
{
|
||||
if (m[dir].pKnots)
|
||||
delete m[dir].pKnots; // [m[dir].nbrKnots] if t_Knot become a class
|
||||
m[dir].pKnots = NULL;
|
||||
};
|
||||
// now we free the CtrlPts array
|
||||
if (mpCtrlPts)
|
||||
delete [] mpCtrlPts; // [mtotnbrCtrlPts] if t_CtrlPt become a class
|
||||
mpCtrlPts = NULL;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Return the current knot the parameter u is less than or equal to. *
|
||||
* Find this "breakpoint" allows the evaluation routines to concentrate *
|
||||
* on only those control points actually effecting the curve around u.] *
|
||||
* *
|
||||
* m is the number of points on the curve (or surface direction) *
|
||||
* k is the order of the curve (or surface direction) *
|
||||
* kv is the knot vector ([0..m+k-1]) to find the break point in. *
|
||||
* *
|
||||
************************************************************************/
|
||||
static int FindBreakPoint(double u, const Float *kv, int m, int k)
|
||||
{
|
||||
int i;
|
||||
if (u == kv[m+1]) return m; /* Special case for closed interval */
|
||||
i = m + k;
|
||||
while ((u < kv[i]) && (i > 0)) i--;
|
||||
return(i);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Compute Bi,k(u), for i = 0..k. *
|
||||
* u the parameter of the spline to find the basis functions for*
|
||||
* brkPoint the start of the knot interval ("segment") *
|
||||
* kv the knot vector *
|
||||
* k the order of the curve *
|
||||
* bvals the array of returned basis values. *
|
||||
* *
|
||||
* (From Bartels, Beatty & Barsky, p.387) *
|
||||
* *
|
||||
************************************************************************/
|
||||
static void BasisFunctions(double u, int brkPoint,
|
||||
const Float *kv, int k, double *bvals)
|
||||
{
|
||||
int r, s, i;
|
||||
double omega;
|
||||
|
||||
bvals[0] = 1.0;
|
||||
for (r=2; r <= k; r++) {
|
||||
i = brkPoint - r + 1;
|
||||
bvals[r-1] = 0.0;
|
||||
for (s=r-2; s >= 0; s--) {
|
||||
i++;
|
||||
if (i < 0) {
|
||||
omega = 0.0;
|
||||
}else{
|
||||
omega = (u - kv[i]) / (kv[i+r-1] - kv[i]);
|
||||
}
|
||||
bvals[s+1] = bvals[s+1] + (1.0-omega) * bvals[s];
|
||||
bvals[s] = omega * bvals[s];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Compute derivatives of the basis functions Bi,k(u)' *
|
||||
* *
|
||||
************************************************************************/
|
||||
static void BasisDerivatives(double u, int brkPoint,
|
||||
const Float *kv, int k, double *dvals)
|
||||
{
|
||||
int s, i;
|
||||
double omega, knotScale;
|
||||
|
||||
BasisFunctions(u, brkPoint, kv, k-1, dvals);
|
||||
|
||||
dvals[k-1] = 0.0; /* BasisFunctions misses this */
|
||||
|
||||
knotScale = kv[brkPoint+1] - kv[brkPoint];
|
||||
|
||||
i = brkPoint - k + 1;
|
||||
for (s=k-2; s >= 0; s--) {
|
||||
i++;
|
||||
omega = knotScale * ((double)(k-1)) / (kv[i+k-1] - kv[i]);
|
||||
dvals[s+1] += -omega * dvals[s];
|
||||
dvals[s] *= omega;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* *
|
||||
* Calculate a point p on NurbSurface n at a specific u, v *
|
||||
* using the tensor product. *
|
||||
* *
|
||||
* Note the valid parameter range for u and v is *
|
||||
* (kvU[orderU] <= u < kvU[numU), (kvV[orderV] <= v < kvV[numV]) *
|
||||
* *
|
||||
***********************************************************************/
|
||||
void G4NURBS::CalcPoint(double u, double v, G4Point3D &p,
|
||||
G4Vector3D &utan, G4Vector3D &vtan) const
|
||||
{
|
||||
#define MAXORDER 50
|
||||
struct Point4 {
|
||||
double x, y, z, w;
|
||||
};
|
||||
|
||||
int i, j, ri, rj;
|
||||
int ubrkPoint, ufirst;
|
||||
double bu[MAXORDER], buprime[MAXORDER];
|
||||
int vbrkPoint, vfirst;
|
||||
double bv[MAXORDER], bvprime[MAXORDER];
|
||||
Point4 r, rutan, rvtan;
|
||||
|
||||
r.x = 0.0; r.y = 0.0; r.z = 0.0; r.w = 0.0;
|
||||
rutan = r; rvtan = r;
|
||||
|
||||
int numU = GetUnbrCtrlPts();
|
||||
int numV = GetVnbrCtrlPts();
|
||||
int orderU = GetUorder();
|
||||
int orderV = GetVorder();
|
||||
|
||||
/* Evaluate non-uniform basis functions (and derivatives) */
|
||||
|
||||
ubrkPoint = FindBreakPoint(u, m[U].pKnots, numU-1, orderU);
|
||||
ufirst = ubrkPoint - orderU + 1;
|
||||
BasisFunctions (u, ubrkPoint, m[U].pKnots, orderU, bu);
|
||||
BasisDerivatives(u, ubrkPoint, m[U].pKnots, orderU, buprime);
|
||||
|
||||
vbrkPoint = FindBreakPoint(v, m[V].pKnots, numV-1, orderV);
|
||||
vfirst = vbrkPoint - orderV + 1;
|
||||
BasisFunctions (v, vbrkPoint, m[V].pKnots, orderV, bv);
|
||||
BasisDerivatives(v, vbrkPoint, m[V].pKnots, orderV, bvprime);
|
||||
|
||||
/* Weight control points against the basis functions */
|
||||
|
||||
t_doubleCtrlPt *cpoint;
|
||||
Point4 cp;
|
||||
double tmp;
|
||||
|
||||
for (i=0; i<orderV; i++) {
|
||||
for (j=0; j<orderU; j++) {
|
||||
ri = orderV - 1 - i;
|
||||
rj = orderU - 1 - j;
|
||||
|
||||
tmp = bu[rj] * bv[ri];
|
||||
cpoint = GetdoubleCtrlPt(j+ufirst, i+vfirst);
|
||||
cp.x = *cpoint[G4NURBS::X];
|
||||
cp.y = *cpoint[G4NURBS::Y];
|
||||
cp.z = *cpoint[G4NURBS::Z];
|
||||
cp.w = *cpoint[G4NURBS::W];
|
||||
r.x += cp.x * tmp;
|
||||
r.y += cp.y * tmp;
|
||||
r.z += cp.z * tmp;
|
||||
r.w += cp.w * tmp;
|
||||
|
||||
tmp = buprime[rj] * bv[ri];
|
||||
rutan.x += cp.x * tmp;
|
||||
rutan.y += cp.y * tmp;
|
||||
rutan.z += cp.z * tmp;
|
||||
rutan.w += cp.w * tmp;
|
||||
|
||||
tmp = bu[rj] * bvprime[ri];
|
||||
rvtan.x += cp.x * tmp;
|
||||
rvtan.y += cp.y * tmp;
|
||||
rvtan.z += cp.z * tmp;
|
||||
rvtan.w += cp.w * tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Project tangents, using the quotient rule for differentiation */
|
||||
|
||||
double wsqrdiv = 1.0 / (r.w * r.w);
|
||||
|
||||
utan.setX((r.w * rutan.x - rutan.w * r.x) * wsqrdiv);
|
||||
utan.setY((r.w * rutan.y - rutan.w * r.y) * wsqrdiv);
|
||||
utan.setZ((r.w * rutan.z - rutan.w * r.z) * wsqrdiv);
|
||||
|
||||
vtan.setX((r.w * rvtan.x - rvtan.w * r.x) * wsqrdiv);
|
||||
vtan.setY((r.w * rvtan.y - rvtan.w * r.y) * wsqrdiv);
|
||||
vtan.setZ((r.w * rvtan.z - rvtan.w * r.z) * wsqrdiv);
|
||||
|
||||
p.setX(r.x / r.w);
|
||||
p.setY(r.y / r.w);
|
||||
p.setZ(r.z / r.w);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4NURBSbox.cc,v 2.1 1998/07/12 02:59:19 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// Olivier Crumeyrolle 12 September 1996
|
||||
|
||||
// Box builder implementation (KidBox)
|
||||
// OC 060996
|
||||
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
G4NURBSbox::G4NURBSbox(G4double DX, G4double DY, G4double DZ)
|
||||
:
|
||||
G4NURBS (
|
||||
2, 2, // linear along U and V
|
||||
4, 5 // line with two 90 degrees folds along U
|
||||
// rectangle along V (3 folds)
|
||||
)
|
||||
// let's it Generate regular knots vector
|
||||
// (note we are calling the second constructor)
|
||||
{
|
||||
t_indCtrlPt i = 0;
|
||||
|
||||
|
||||
CP(mpCtrlPts[i++], DX, DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX, DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX, DY,-DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX, DY,-DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[i++], DX, DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++],-DX, DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++],-DX, DY,-DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX, DY,-DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[i++], DX,-DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++],-DX,-DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++],-DX,-DY,-DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX,-DY,-DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[i++], DX,-DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX,-DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX,-DY,-DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX,-DY,-DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[i++], DX, DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX, DY, DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX, DY,-DZ, 1 );
|
||||
CP(mpCtrlPts[i++], DX, DY,-DZ, 1 );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char* G4NURBSbox::Whoami() const
|
||||
{
|
||||
return "Box (as a folded piece)";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4NURBScylinder.cc,v 2.1 1998/07/12 02:59:20 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// Olivier Crumeyrolle 12 September 1996
|
||||
|
||||
// Cylinder builder implementation
|
||||
// OC 090796
|
||||
|
||||
#include "G4NURBScylinder.hh"
|
||||
|
||||
// for sqrt
|
||||
//#include <math.h>
|
||||
// math.h included in template.hh included in globals.hh included in
|
||||
// G4NURBS.hh included in G4NURBScylinder.hh
|
||||
|
||||
// the cylinder constructor use the first G4NURBS constructor
|
||||
// look in G4NURBStube if you want to see how to use the second one.
|
||||
|
||||
G4NURBScylinder::G4NURBScylinder(G4double R, G4double DZ)
|
||||
:
|
||||
G4NURBS (
|
||||
2, 3, // linear along U, quadratic along V
|
||||
4, 9, // half rectangle along U, circle along V
|
||||
(new t_CtrlPt [ 4 * 9 ]), // the array for CtrlPts
|
||||
NULL, // the knot vector along U will be generated
|
||||
(new t_Knot [ 3 + 9 ]) // knot vector for the circle
|
||||
)
|
||||
{
|
||||
// define the V knot vector
|
||||
m[V].pKnots[ 0] = 0;
|
||||
m[V].pKnots[ 1] = 0;
|
||||
m[V].pKnots[ 2] = 0;
|
||||
m[V].pKnots[ 3] = 0.25;
|
||||
m[V].pKnots[ 4] = 0.25;
|
||||
m[V].pKnots[ 5] = 0.5;
|
||||
m[V].pKnots[ 6] = 0.5;
|
||||
m[V].pKnots[ 7] = 0.75;
|
||||
m[V].pKnots[ 8] = 0.75;
|
||||
m[V].pKnots[ 9] = 1;
|
||||
m[V].pKnots[10] = 1;
|
||||
m[V].pKnots[11] = 1;
|
||||
|
||||
// define control points
|
||||
|
||||
const G4double sr2o2 = sqrt(2.)/2. ;
|
||||
|
||||
CP(mpCtrlPts[ 0] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[ 1] , R, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[ 2] , R, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[ 3] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[ 4] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[ 5] , R, R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[ 6] , R, R,-DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[ 7] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[ 8] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[ 9] , 0, R, DZ, 1 );
|
||||
CP(mpCtrlPts[10] , 0, R, -DZ, 1 );
|
||||
CP(mpCtrlPts[11] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[12] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[13] , -R, R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[14] , -R, R,-DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[15] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[16] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[17] , -R, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[18] , -R, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[19] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[20] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[21] , -R,-R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[22] , -R,-R,-DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[23] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[24] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[25] , 0, -R, DZ, 1 );
|
||||
CP(mpCtrlPts[26] , 0, -R,-DZ, 1 );
|
||||
CP(mpCtrlPts[27] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[28] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[29] , R,-R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[30] , R,-R,-DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[31] , 0, 0, -DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[32] , 0, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[33] , R, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[34] , R, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[35] , 0, 0, -DZ, 1 );
|
||||
|
||||
}
|
||||
|
||||
const char* G4NURBScylinder::Whoami() const
|
||||
{
|
||||
return "Cylinder";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4NURBShexahedron.cc,v 2.1 1998/07/12 02:59:21 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// hexahedron implementation
|
||||
// OC 17 9 96
|
||||
|
||||
#include "G4NURBShexahedron.hh"
|
||||
|
||||
G4NURBShexahedron::G4NURBShexahedron(const G4ThreeVector c [8])
|
||||
:
|
||||
G4NURBS (
|
||||
2, 2, // linear along U and V
|
||||
5, 4 // Square x polyline
|
||||
)
|
||||
// let's it Generate regular knots vector
|
||||
{
|
||||
// we need to define control points, indeed
|
||||
|
||||
|
||||
CP(mpCtrlPts[To1d(0,0)] , c[0].x(), c[0].y(), c[0].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(1,0)] , c[1].x(), c[1].y(), c[1].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(2,0)] , c[1].x(), c[1].y(), c[1].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(3,0)] , c[0].x(), c[0].y(), c[0].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(4,0)] , c[0].x(), c[0].y(), c[0].z(), 1 );
|
||||
|
||||
|
||||
CP(mpCtrlPts[To1d(0,1)] , c[0].x(), c[0].y(), c[0].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(1,1)] , c[1].x(), c[1].y(), c[1].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(2,1)] , c[2].x(), c[2].y(), c[2].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(3,1)] , c[3].x(), c[3].y(), c[3].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(4,1)] , c[0].x(), c[0].y(), c[0].z(), 1 );
|
||||
|
||||
|
||||
CP(mpCtrlPts[To1d(0,2)] , c[4].x(), c[4].y(), c[4].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(1,2)] , c[5].x(), c[5].y(), c[5].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(2,2)] , c[6].x(), c[6].y(), c[6].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(3,2)] , c[7].x(), c[7].y(), c[7].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(4,2)] , c[4].x(), c[4].y(), c[4].z(), 1 );
|
||||
|
||||
|
||||
CP(mpCtrlPts[To1d(0,3)] , c[4].x(), c[4].y(), c[4].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(1,3)] , c[5].x(), c[5].y(), c[5].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(2,3)] , c[5].x(), c[5].y(), c[5].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(3,3)] , c[4].x(), c[4].y(), c[4].z(), 1 );
|
||||
CP(mpCtrlPts[To1d(4,3)] , c[4].x(), c[4].y(), c[4].z(), 1 );
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char* G4NURBShexahedron::Whoami() const
|
||||
{
|
||||
return "Hexahedron";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4NURBStube.cc,v 2.1 1998/07/12 02:59:22 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// Olivier Crumeyrolle 12 September 1996
|
||||
|
||||
// Tube builder implementation
|
||||
// OC 090796
|
||||
|
||||
#include "G4NURBStube.hh"
|
||||
|
||||
// for sqrt
|
||||
//#include <math.h>
|
||||
// cf cylinder
|
||||
|
||||
G4NURBStube::G4NURBStube(G4double r, G4double R, G4double DZ)
|
||||
:
|
||||
G4NURBS (
|
||||
2, 3, // linear along U, quadratic along V
|
||||
5, 9, // rectangle along U, circle along V
|
||||
Regular, // the knot vector along U will be generated
|
||||
RegularRep // knot vector for the circle also
|
||||
)
|
||||
{
|
||||
// define control points
|
||||
|
||||
const G4double sr2o2 = sqrt(2.)/2.;
|
||||
|
||||
CP(mpCtrlPts[ 0] , r, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[ 1] , R, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[ 2] , R, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[ 3] , r, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[ 4] , r, 0, DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[ 5] , r, r, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[ 6] , R, R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[ 7] , R, R, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[ 8] , r, r, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[ 9] , r, r, DZ, 1 , sr2o2);
|
||||
|
||||
CP(mpCtrlPts[10] , 0, r, DZ, 1 );
|
||||
CP(mpCtrlPts[11] , 0, R, DZ, 1 );
|
||||
CP(mpCtrlPts[12] , 0, R, -DZ, 1 );
|
||||
CP(mpCtrlPts[13] , 0, r, -DZ, 1 );
|
||||
CP(mpCtrlPts[14] , 0, r, DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[15] , -r, r, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[16] , -R, R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[17] , -R, R, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[18] , -r, r, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[19] , -r, r, DZ, 1 , sr2o2);
|
||||
|
||||
CP(mpCtrlPts[20] , -r, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[21] , -R, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[22] , -R, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[23] , -r, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[24] , -r, 0, DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[25] , -r,-r, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[26] , -R,-R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[27] , -R,-R, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[28] , -r,-r, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[29] , -r,-R, DZ, 1 , sr2o2);
|
||||
|
||||
CP(mpCtrlPts[30] , 0,-r, DZ, 1 );
|
||||
CP(mpCtrlPts[31] , 0,-R, DZ, 1 );
|
||||
CP(mpCtrlPts[32] , 0,-R, -DZ, 1 );
|
||||
CP(mpCtrlPts[33] , 0,-r, -DZ, 1 );
|
||||
CP(mpCtrlPts[34] , 0,-r, DZ, 1 );
|
||||
|
||||
CP(mpCtrlPts[35] , r,-r, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[36] , R,-R, DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[37] , R,-R, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[38] , r,-r, -DZ, 1 , sr2o2);
|
||||
CP(mpCtrlPts[39] , r,-r, DZ, 1 , sr2o2);
|
||||
|
||||
CP(mpCtrlPts[40] , r, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[41] , R, 0, DZ, 1 );
|
||||
CP(mpCtrlPts[42] , R, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[43] , r, 0, -DZ, 1 );
|
||||
CP(mpCtrlPts[44] , r, 0, DZ, 1 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const char* G4NURBStube::Whoami() const
|
||||
{
|
||||
return "Tube";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4NURBStubesector.cc,v 2.2 1998/07/13 16:56:16 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// Olivier Crumeyrolle 12 September 1996
|
||||
|
||||
// Tubesector builder implementation
|
||||
// OC 290896
|
||||
|
||||
#include "G4NURBStubesector.hh"
|
||||
|
||||
// for sqrt
|
||||
//#include <math.h>
|
||||
// cf cylinder
|
||||
|
||||
// for ostrstream
|
||||
#ifdef WIN32
|
||||
# include <Strstrea.h>
|
||||
#else
|
||||
# include <strstream.h>
|
||||
#endif
|
||||
|
||||
|
||||
G4NURBStubesector::G4NURBStubesector(G4double r, G4double R, G4double DZ, G4double PHI1, G4double PHI2)
|
||||
:
|
||||
G4NURBS (
|
||||
2, 3, // linear along U, quadratic along V
|
||||
5, DecideNbrCtrlPts(PHI1, PHI2),
|
||||
// rectangle along U, required stuff along V
|
||||
// we must use a static function which
|
||||
// take the two angles because the
|
||||
// mother constructor is initialised
|
||||
// before everything
|
||||
Regular, // the knot vector along U will be generated
|
||||
RegularRep // circular like knot vector also
|
||||
)
|
||||
{
|
||||
|
||||
// check angles
|
||||
G4double deltaPHI = PHI2-PHI1;
|
||||
while (deltaPHI <= 0) { PHI2 += 2*M_PI; deltaPHI += 2*M_PI; };
|
||||
|
||||
G4int f = (int)floor(deltaPHI / (M_PI_2)); //number of pi/2 arcs
|
||||
|
||||
const G4double mr = (r+R)/2;
|
||||
|
||||
const G4double cp1 = cos(PHI1);
|
||||
const G4double sp1 = sin(PHI1);
|
||||
const G4double cp2 = cos(PHI2);
|
||||
const G4double sp2 = sin(PHI2);
|
||||
|
||||
|
||||
// define control points
|
||||
CP(mpCtrlPts[ 0] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 1] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 2] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 3] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 4] , cp1*mr, sp1*mr, 0, 1 );
|
||||
|
||||
CP(mpCtrlPts[ 5] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 6] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 7] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 8] , cp1*mr, sp1*mr, 0, 1 );
|
||||
CP(mpCtrlPts[ 9] , cp1*mr, sp1*mr, 0, 1 );
|
||||
|
||||
CP(mpCtrlPts[10] , cp1*r, sp1*r, DZ, 1 );
|
||||
CP(mpCtrlPts[11] , cp1*R, sp1*R, DZ, 1 );
|
||||
CP(mpCtrlPts[12] , cp1*R, sp1*R, -DZ, 1 );
|
||||
CP(mpCtrlPts[13] , cp1*r, sp1*r, -DZ, 1 );
|
||||
CP(mpCtrlPts[14] , cp1*r, sp1*r, DZ, 1 );
|
||||
|
||||
t_indCtrlPt i = 15;
|
||||
G4double srcAngle = PHI1;
|
||||
G4double deltaAngleo2;
|
||||
|
||||
G4double destAngle = M_PI_2 + PHI1;
|
||||
|
||||
for(; f > 0; f--)
|
||||
{
|
||||
|
||||
// the first arc CP is already Done
|
||||
|
||||
deltaAngleo2 = (destAngle - srcAngle) / 2;
|
||||
const G4double csa = cos(srcAngle);
|
||||
const G4double ssa = sin(srcAngle);
|
||||
const G4double tdao2 = tan(deltaAngleo2);
|
||||
|
||||
// to calculate the intermediate CP :
|
||||
// rotate by srcAngle the (1, tdao2) point
|
||||
const t_Coord x = csa - ssa*tdao2;
|
||||
const t_Coord y = ssa + csa*tdao2;
|
||||
|
||||
// weight of the CP
|
||||
const G4Float weight = (cos(deltaAngleo2));
|
||||
|
||||
// initialization. postfix ++ because i initialized to 15
|
||||
CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*R, y*R, DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*R, y*R, -DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*r, y*r, -DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
|
||||
|
||||
// end CP (which is the first CP of the next arc)
|
||||
const G4double cda = cos(destAngle);
|
||||
const G4double sda = sin(destAngle);
|
||||
CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*R, sda*R, DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*R, sda*R, -DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*r, sda*r, -DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
|
||||
|
||||
// prepare next arc
|
||||
srcAngle = destAngle;
|
||||
destAngle += M_PI_2;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// f == 0, final Arc
|
||||
// could be handled in the loops
|
||||
|
||||
destAngle = PHI2;
|
||||
deltaAngleo2 = (destAngle - srcAngle) / 2;
|
||||
const G4double csa = cos(srcAngle);
|
||||
const G4double ssa = sin(srcAngle);
|
||||
const G4double tdao2 = tan(deltaAngleo2);
|
||||
|
||||
// to calculate the intermediate CP :
|
||||
// rotate by srcAngle the (1, tdao2) point
|
||||
const t_Coord x = csa - ssa*tdao2;
|
||||
const t_Coord y = ssa + csa*tdao2;
|
||||
|
||||
// weight of the CP
|
||||
const G4Float weight = (cos(deltaAngleo2));
|
||||
|
||||
// initialization.
|
||||
CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*R, y*R, DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*R, y*R, -DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*r, y*r, -DZ, 1, weight);
|
||||
CP(mpCtrlPts[i++], x*r, y*r, DZ, 1, weight);
|
||||
|
||||
// end CP
|
||||
const G4double cda = cos(destAngle);
|
||||
const G4double sda = sin(destAngle);
|
||||
CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*R, sda*R, DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*R, sda*R, -DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*r, sda*r, -DZ, 1);
|
||||
CP(mpCtrlPts[i++], cda*r, sda*r, DZ, 1);
|
||||
|
||||
|
||||
/**/ if (i != (mtotnbrCtrlPts - 10) )
|
||||
{ G4cerr
|
||||
<< "\nERROR: G4NURBStubesector::G4NURBStubesector: wrong index,"
|
||||
<< i << " instead of " << (mtotnbrCtrlPts - 10)
|
||||
<< "\n\tIt sounds very strange. The tubesector won't be correct. Have a nice debuging!"
|
||||
<< endl;
|
||||
};
|
||||
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
|
||||
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
CP(mpCtrlPts[i++] , cp2*mr, sp2*mr, 0, 1);
|
||||
|
||||
// possible to put a DZ DZ -DZ -DZ DZ column to scratch to a line instead of a point
|
||||
|
||||
// creating the nurbs identity
|
||||
mpwhoami = new char [200];
|
||||
ostrstream tmpstr(mpwhoami, 200);
|
||||
tmpstr << "Tubs" << " \tPHI1=" << PHI1 << " ; PHI2=" << PHI2 << '\0';
|
||||
// could be more sophisticated, reallocating
|
||||
// mpwhoami to the exact length
|
||||
|
||||
}
|
||||
|
||||
|
||||
const char* G4NURBStubesector::Whoami() const
|
||||
{
|
||||
return mpwhoami;
|
||||
}
|
||||
|
||||
G4NURBStubesector::~G4NURBStubesector()
|
||||
{
|
||||
if (mpwhoami) { delete mpwhoami; mpwhoami = NULL; };
|
||||
}
|
||||
|
||||
|
||||
G4NURBStubesector::t_inddCtrlPt G4NURBStubesector::DecideNbrCtrlPts(G4double PHI1, G4double PHI2)
|
||||
{
|
||||
// check angles
|
||||
G4double deltaPHI = PHI2-PHI1;
|
||||
while (deltaPHI <= 0) { PHI2 += 2*M_PI; deltaPHI += 2*M_PI; };
|
||||
G4double k = deltaPHI / (M_PI_2);
|
||||
|
||||
// G4cerr << " k " << k << endl;
|
||||
// G4cerr << " fk " << floor(k) << endl;
|
||||
// G4cerr << " ifk " << ((int)(floor(k))) << endl;
|
||||
// G4cerr << " n " << (2*((int)(floor(k))) + 7) << endl;
|
||||
|
||||
return ( 2*((int)(floor(k))) + 7 );
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Point3DList.cc,v 2.1 1998/07/13 16:56:18 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison July 1995
|
||||
|
||||
#include "G4Point3DList.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
ostream& operator << (ostream& os, const G4Point3DList& points)
|
||||
{
|
||||
os << "G4Point3DList[" << points.entries() << "]: ";
|
||||
for (int i = 0; i < points.entries(); i++) os << points(i);
|
||||
return os;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Polyline.cc,v 2.0 1998/07/02 17:30:57 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison July 1995
|
||||
|
||||
#include "G4Polyline.hh"
|
||||
|
||||
G4Polyline::G4Polyline (const G4VVisPrim& prim):
|
||||
G4VVisPrim (prim)
|
||||
{}
|
||||
|
||||
ostream& operator << (ostream& os, const G4Polyline& line) {
|
||||
os << "G4Polyline: ";
|
||||
os << '\n' << (G4VVisPrim) line;
|
||||
os << '\n' << (G4Point3DList) line;
|
||||
return os;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Polymarker.cc,v 2.0 1998/07/02 17:30:59 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison November 1996
|
||||
|
||||
#include "G4Polymarker.hh"
|
||||
|
||||
// Forward declaration for g++ linker.
|
||||
#ifdef GNU_GCC
|
||||
#include <rw/tvvector.h>
|
||||
#include "G4Point3D.hh"
|
||||
template class RWTValVector<G4Point3D>;
|
||||
#endif
|
||||
|
||||
G4Polymarker::G4Polymarker ():
|
||||
fMarkerType (line)
|
||||
{}
|
||||
|
||||
ostream& operator << (ostream& os, const G4Polymarker& marker) {
|
||||
os << "G4Polymarker: type: ";
|
||||
switch (marker.fMarkerType) {
|
||||
case G4Polymarker::line:
|
||||
os << "line"; break;
|
||||
case G4Polymarker::dots:
|
||||
os << "dots"; break;
|
||||
case G4Polymarker::circles:
|
||||
os << "circles"; break;
|
||||
case G4Polymarker::squares:
|
||||
os << "squares"; break;
|
||||
default:
|
||||
os << "unrecognised"; break;
|
||||
}
|
||||
os << "\n ";
|
||||
os << (G4VMarker) marker;
|
||||
os << (G4Point3DList) marker;
|
||||
return os;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Text.cc,v 2.0 1998/07/02 17:30:41 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 17/11/96.
|
||||
|
||||
#include "G4Text.hh"
|
||||
|
||||
G4Text::G4Text (const G4String& text):
|
||||
fText (text),
|
||||
fLayout (left),
|
||||
fXOffset(0.) , fYOffset(0.)
|
||||
{}
|
||||
|
||||
G4Text::G4Text (const G4String& text, const G4Point3D& pos):
|
||||
G4VMarker (pos),
|
||||
fText (text),
|
||||
fLayout (left),
|
||||
fXOffset(0.) , fYOffset(0.)
|
||||
{}
|
||||
|
||||
G4Text::G4Text (const G4VMarker& marker):
|
||||
G4VMarker (marker),
|
||||
fText ("") ,
|
||||
fLayout (left) ,
|
||||
fXOffset(0.) , fYOffset(0.)
|
||||
{}
|
||||
@@ -0,0 +1,48 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VMarker.cc,v 2.0 1998/07/02 17:31:01 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
|
||||
#include "G4VMarker.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
ostream& operator << (ostream& os, const G4VMarker& marker) {
|
||||
os << "G4VMarker: position: " << marker.fPosition
|
||||
<< ", world size: " << marker.fWorldSize
|
||||
<< ", screen size: " << marker.fScreenSize << '\n'
|
||||
<< " fill style: ";
|
||||
switch (marker.fFillStyle) {
|
||||
case G4VMarker::noFill:
|
||||
os << "no fill";
|
||||
break;
|
||||
case G4VMarker::hashed:
|
||||
os << "hashed";
|
||||
break;
|
||||
case G4VMarker::filled:
|
||||
os << "filled";
|
||||
break;
|
||||
default:
|
||||
os << "unrecognised"; break;
|
||||
}
|
||||
os << "\n " << (G4VVisPrim) marker;
|
||||
return os;
|
||||
}
|
||||
|
||||
G4bool operator != (const G4VMarker& m1, const G4VMarker& m2) {
|
||||
if (
|
||||
(m1.fWorldSize != m2.fWorldSize) ||
|
||||
(m1.fScreenSize != m2.fScreenSize) ||
|
||||
(m1.fFillStyle != m2.fFillStyle) ||
|
||||
!(m1.fPosition == m2.fPosition)
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VVisManager.cc,v 2.0 1998/07/02 17:31:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// Abstract interface for GEANT4 Visualization Manager.
|
||||
// John Allison 19/Oct/1996.
|
||||
|
||||
#include "G4VVisManager.hh"
|
||||
|
||||
G4VVisManager* G4VVisManager::fpConcreteInstance = 0;
|
||||
@@ -0,0 +1,20 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VVisPrim.cc,v 2.1 1998/07/13 16:56:21 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison August 1995
|
||||
|
||||
#include "G4VVisPrim.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
ostream& operator << (ostream& os, const G4VVisPrim& prim) {
|
||||
return os << (G4Visible) prim;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VisAttributes.cc,v 2.0 1998/07/02 17:31:05 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 23rd October 1996
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
G4VisAttributes::G4VisAttributes ():
|
||||
fVisible (true),
|
||||
fColour (G4Colour ()),
|
||||
fLineStyle (unbroken),
|
||||
fLineWidth (1.),
|
||||
fForceDrawingStyle (false)
|
||||
{}
|
||||
|
||||
G4VisAttributes::G4VisAttributes (G4bool visibility):
|
||||
fVisible (visibility),
|
||||
fColour (G4Colour ()),
|
||||
fLineStyle (unbroken),
|
||||
fLineWidth (1.),
|
||||
fForceDrawingStyle (false)
|
||||
{}
|
||||
|
||||
G4VisAttributes::G4VisAttributes (const G4Colour& colour):
|
||||
fVisible (true),
|
||||
fColour (colour),
|
||||
fLineStyle (unbroken),
|
||||
fLineWidth (1.),
|
||||
fForceDrawingStyle (false)
|
||||
{}
|
||||
|
||||
G4VisAttributes::G4VisAttributes (G4bool visibility,
|
||||
const G4Colour& colour):
|
||||
fVisible (visibility),
|
||||
fColour (colour),
|
||||
fLineStyle (unbroken),
|
||||
fLineWidth (1.),
|
||||
fForceDrawingStyle (false)
|
||||
{}
|
||||
|
||||
const G4VisAttributes G4VisAttributes::Invisible = G4VisAttributes (false);
|
||||
|
||||
ostream& operator << (ostream& os, const G4VisAttributes& a) {
|
||||
|
||||
os << "G4VisAttributes: ";
|
||||
if (&a){
|
||||
if (!a.fVisible) os << " in";
|
||||
os << "visible, colour: " << a.fColour;
|
||||
os << "\n linestyle: ";
|
||||
switch (a.fLineStyle) {
|
||||
case G4VisAttributes::unbroken:
|
||||
os << "solid"; break;
|
||||
case G4VisAttributes::dashed:
|
||||
os << "dashed"; break;
|
||||
case G4VisAttributes::dotted: os << "dotted"; break;
|
||||
default: os << "unrecognised"; break;
|
||||
}
|
||||
os << ", line width: " << a.fLineWidth;
|
||||
os << "\n drawing style ";
|
||||
if (a.fForceDrawingStyle) {
|
||||
os << "forced to: ";
|
||||
switch (a.fForcedStyle) {
|
||||
case G4VisAttributes::wireframe:
|
||||
os << "wireframe"; break;
|
||||
case G4VisAttributes::solid:
|
||||
os << "solid"; break;
|
||||
default: os << "unrecognised"; break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
os << "unforced";
|
||||
}
|
||||
}
|
||||
else os << " The pointer is zero ";
|
||||
return os;
|
||||
|
||||
}
|
||||
|
||||
G4bool operator != (const G4VisAttributes& a1,
|
||||
const G4VisAttributes& a2) {
|
||||
|
||||
if (
|
||||
(a1.fVisible != a2.fVisible) ||
|
||||
(a1.fColour != a2.fColour) ||
|
||||
(a1.fLineStyle != a2.fLineStyle) ||
|
||||
(a1.fLineWidth != a2.fLineWidth) ||
|
||||
(a1.fForceDrawingStyle != a2.fForceDrawingStyle)
|
||||
)
|
||||
return true;
|
||||
|
||||
if (a1.fForceDrawingStyle) {
|
||||
if (a1.fForcedStyle != a2.fForcedStyle) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VisExtent.cc,v 2.2 1998/08/22 16:20:43 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// A.Walkden 28/11/95
|
||||
// G4VisExtent.cc - to return parameters useful to the drawing window
|
||||
// employed by Visualization code.
|
||||
|
||||
#include "G4VisExtent.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4VisExtent::G4VisExtent (G4double xmin, G4double xmax,
|
||||
G4double ymin, G4double ymax,
|
||||
G4double zmin, G4double zmax)
|
||||
:fXmin(xmin), fXmax(xmax), fYmin(ymin), fYmax(ymax), fZmin(zmin), fZmax(zmax)
|
||||
{}
|
||||
|
||||
G4VisExtent::G4VisExtent (const G4Point3D& centre, G4double radius) {
|
||||
// Use inscribed radius to define G3VisExtent so that
|
||||
// GetExtentRadius gets radius back again. The one is the "inverse"
|
||||
// of the other, so to speak.
|
||||
G4double inscribedRadius = radius / sqrt (3.);
|
||||
fXmin = centre.x () - inscribedRadius;
|
||||
fXmax = centre.x () + inscribedRadius;
|
||||
fYmin = centre.y () - inscribedRadius;
|
||||
fYmax = centre.y () + inscribedRadius;
|
||||
fZmin = centre.z () - inscribedRadius;
|
||||
fZmax = centre.z () + inscribedRadius;
|
||||
}
|
||||
|
||||
G4VisExtent::~G4VisExtent () {}
|
||||
|
||||
G4Point3D G4VisExtent::GetExtentCentre () const {
|
||||
return G4Point3D (((fXmin + fXmax) / 2.),
|
||||
((fYmin + fYmax) / 2.),
|
||||
((fZmin + fZmax) / 2.));
|
||||
}
|
||||
|
||||
G4double G4VisExtent::GetExtentRadius () const {
|
||||
return sqrt (((fXmax - fXmin) * (fXmax - fXmin)) +
|
||||
((fYmax - fYmin) * (fYmax - fYmin)) +
|
||||
((fZmax - fZmin) * (fZmax - fZmin))) / 2;
|
||||
}
|
||||
|
||||
ostream& operator << (ostream& os, const G4VisExtent& e) {
|
||||
os << "G4VisExtent (bounding box):";
|
||||
os << "\n X limits: " << e.fXmin << ' ' << e.fXmax;
|
||||
os << "\n Y limits: " << e.fYmin << ' ' << e.fYmax;
|
||||
os << "\n Z limits: " << e.fZmin << ' ' << e.fZmax;
|
||||
return os;
|
||||
}
|
||||
|
||||
G4bool operator != (const G4VisExtent& e1, const G4VisExtent& e2) {
|
||||
return ((e1.fXmin != e2.fXmin) ||
|
||||
(e1.fXmax != e2.fXmax) ||
|
||||
(e1.fYmin != e2.fYmin) ||
|
||||
(e1.fYmax != e2.fYmax) ||
|
||||
(e1.fZmin != e2.fZmin) ||
|
||||
(e1.fZmax != e2.fZmax));
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Visible.cc,v 2.1 1998/07/13 16:56:24 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 30th October 1996
|
||||
// Base class for all things visible, i.e., which have Vis Attributes.
|
||||
|
||||
#include "G4Visible.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
ostream& operator << (ostream& os, const G4Visible& v) {
|
||||
if (v.fpVisAttributes) return os << *(v.fpVisAttributes);
|
||||
else return os << "No Visualization Attributes";
|
||||
}
|
||||
Reference in New Issue
Block a user