36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
49 const std::vector<G4TwoVector>& vertices)
50 : G4USolid(name, new UGenericTrap())
52 SetZHalfLength(halfZ);
53 std::vector<UVector2> v;
54 for (
size_t n=0;
n<vertices.size(); ++
n)
56 v.push_back(UVector2(vertices[
n].
x(),vertices[
n].y()));
58 GetShape()->SetName(name);
59 GetShape()->Initialise(v);
68 G4UGenericTrap::G4UGenericTrap(__void__&
a)
78 G4UGenericTrap::~G4UGenericTrap()
87 G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap &source)
98 G4UGenericTrap::operator=(
const G4UGenericTrap &source)
100 if (
this == &source)
return *
this;
102 G4USolid::operator=( source );
111 G4double G4UGenericTrap::GetZHalfLength()
const
113 return GetShape()->GetZHalfLength();
115 G4int G4UGenericTrap::GetNofVertices()
const
117 return GetShape()->GetNofVertices();
121 UVector2 v = GetShape()->GetVertex(index);
124 const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
127 std::vector<UVector2> v = GetShape()->GetVertices();
128 static std::vector<G4TwoVector> vertices; vertices.clear();
129 for (
size_t n=0;
n<v.size(); ++
n)
137 return GetShape()->GetTwistAngle(index);
139 G4bool G4UGenericTrap::IsTwisted()
const
141 return GetShape()->IsTwisted();
143 G4int G4UGenericTrap::GetVisSubdivisions()
const
145 return GetShape()->GetVisSubdivisions();
148 void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
150 GetShape()->SetVisSubdivisions(subdiv);
153 void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
155 GetShape()->SetZHalfLength(halfZ);
168 size_t nVertices, nFacets;
171 G4int subdivisions=0;
175 if ( GetVisSubdivisions()!= 0 )
177 subdivisions=GetVisSubdivisions();
186 if(GetTwistAngle(i)>maxTwist) { maxTwist=GetTwistAngle(i); }
192 UVector3 minBox = GetShape()->GetMinimumBBox();
193 UVector3 maxBox = GetShape()->GetMaximumBBox();
196 Dx = 0.5*(maxVec.x()- minVec.y());
197 Dy = 0.5*(maxVec.y()- minVec.y());
198 if (Dy > Dx) { Dx=Dy; }
200 subdivisions=8*
G4int(maxTwist/(Dx*Dx*Dx)*fDz);
201 if (subdivisions<4) { subdivisions=4; }
202 if (subdivisions>30) { subdivisions=30; }
205 G4int sub4=4*subdivisions;
206 nVertices = 8+subdivisions*4;
207 nFacets = 6+subdivisions*4;
216 GetVertex(i).y(),-fDz));
218 for( i=0;i<subdivisions;i++)
220 for(
G4int j=0;j<4;j++)
222 G4TwoVector u=GetVertex(j)+cf*(i+1)*( GetVertex(j+4)-GetVertex(j));
229 GetVertex(i).y(),fDz));
235 for (i=0;i<subdivisions+1;i++)
238 polyhedron->
AddFacet(5+is,8+is,4+is,1+is);
239 polyhedron->
AddFacet(8+is,7+is,3+is,4+is);
240 polyhedron->
AddFacet(7+is,6+is,2+is,3+is);
241 polyhedron->
AddFacet(6+is,5+is,1+is,2+is);
243 polyhedron->
AddFacet(5+sub4,6+sub4,7+sub4,8+sub4);
251 #endif // G4GEOM_USE_USOLIDS
CLHEP::Hep3Vector G4ThreeVector
#define G4MUTEX_INITIALIZER
void AddVertex(const G4ThreeVector &v)
const G4double x[NPOINTSGL]
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
CLHEP::Hep2Vector G4TwoVector