Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
+31 -20
View File
@@ -16,19 +16,30 @@ committal in the source repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
30-April-2021 G.Cosmo (geom-specific-V10-06-12)
25-June-2021 G.Cosmo (geom-specific-V10-07-06)
- Added missing accessor in G4UTet.
12-May-2021 E.Tcherniaev (geom-specific-V10-07-05)
- Reimplemented CreatePolyhedron() in
G4Polyhedra, G4Polycone, G4GenericPolycone,
G4UPolyhedra, G4UPolycone, G4UGenericPolycone
30-April-2021 G.Cosmo (geom-specific-V10-07-04)
- Fixed use of conversion factor in G4UPolyhedra wrapper for "generic"
polyhedra constructs.
19-April-2021 E.Tcherniaev
19-April-2021 E.Tcherniaev (geom-specific-V10-07-03)
- G4Polyhedra, G4Polycone: Fix calculation of endPhi for the case
of negative phiStart, it addresses also problem report #2362
18-March-2021 E.Tcherniaev
30-March-2021 B.Morgan (geom-specific-V10-07-02)
- Migrate sources.cmake to modular build API
18-March-2021 E.Tcherniaev (geom-specific-V10-07-01)
- Fix calculation of bounding box position in G4Voxelizer::BuildVoxelLimits(),
it addresses problem report #2301
13-January-2021 G.Cosmo (geom-specific-V10-06-11)
13-January-2021 G.Cosmo (geom-specific-V10-07-00)
- Reduce cases of bad speculation in G4PolyhedraSide::Inside() and
G4PolyPhiFace::InsideEdges(), based on report in profiling analysis
by G.Amadio.
@@ -76,7 +87,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
16-December-2019 E.Tcherniaev (geom-specific-V10-06-02)
- Complete revision of G4Ellipsoid, it fixes issues with former
implementation, in particular it addresses problem report #2206.
30%-70% speed-up in all main methods.
30%-70% speed-up in all main methods.
11-December-2019 B.Morgan (geom-specific-V10-06-01)
- Cleanup CMake build, removing obsolete granular library options and
@@ -223,7 +234,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
- Enabled VecGeom wrappers for G4ExtrudedSolid and G4Hype.
13-December-2017 E.Tcherniaev (geom-specific-V10-04-01)
- Removed redundant data initialistion in G4ExtrudedSolid constructors.
- Removed redundant data initialistion in G4ExtrudedSolid constructors.
11-December-2017 E.Tcherniaev (geom-specific-V10-04-00)
- Added missing initialisation of two data-members in copy-ctor and
@@ -502,8 +513,8 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
- Renamed DistanceAwayForInside() to DistanceAway() and use polymorphism.
26-Jan-2015 T.Nikitina (geom-specific-V10-01-03, 02)
- Added special method for Inside 'DistanceAwayForInside()' in order to fix
precision problem of calculation of DistanceToSide() in G4PolyconeSide.
- Added special method for Inside 'DistanceAwayForInside()' in order to fix
precision problem of calculation of DistanceToSide() in G4PolyconeSide.
21-Jan-2015 T.Nikitina (geom-specific-V10-01-01)
- Fixed triangularisation method AddGeneralPOlygoneFacets() in
@@ -544,7 +555,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
12-Feb-2014 G.Cosmo (geom-specific-V10-00-04)
- Simply reset polyhedron pointer to zero for modifiers of G4U* wrappers
in parameterisation. Resolves crash in MT visualization when using USolids.
in parameterisation. Resolves crash in MT visualization when using USolids.
12-Feb-2014 G.Cosmo (geom-specific-V10-00-03 [and -02])
- Added correct cloning mechanism in G4U* wrappers.
@@ -585,10 +596,10 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
12-Nov-2013 G.Cosmo (geom-specific-V09-06-28)
- Correction to USolids switch mechanism for G4Polycone.
08-Nov-2013 J.Apostolakis (geom-specific-V09-06-27)
- G4SolidsWorkspace: cleanup of verbosity.
Reduced verbosity by making it optional.
Reduced verbosity by making it optional.
Added Set/Get Verbose methods to toggle and view it.
Added parameter to constructor for verbosity (default=off).
@@ -621,7 +632,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
16-Oct-2013 J.Apostolakis/A.Dotti (geom-specific-V09-06-20)
- Created G4SolidsWorkspacePool class, to manage Workspaces
Fixed Singleton G4SolidsWorkspacePool for thread safe creation of object.
Fixed Singleton G4SolidsWorkspacePool for thread safe creation of object.
04-Oct-2013 J.Apostolakis (geom-specific-V09-06-19)
- Retagged.
@@ -661,9 +672,9 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
22-Apr-2013 J.Apostolakis (geom-specific-V09-06-11)
- Revised G4ExtrudedSolid::IsSameLine to use the perpendicular
distance to a line when deciding - not the y-intercept difference.
( Issue responsible for a problem in Subtraction Solid in Atlas.
( Issue responsible for a problem in Subtraction Solid in Atlas.
Tatiana & Ivana contributed to debugging. )
- Changed GNUmakefile in test directory to work with Cmake and granular
- Changed GNUmakefile in test directory to work with Cmake and granular
builds.
16-Apr-2013 T.Nikitina (geom-specific-V09-06-10)
@@ -915,7 +926,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
- Use INT_MAX as initialisation for max limits in G4SolidExtentList.
12-Jul-2010 G.Cosmo (geom-specific-V09-03-09)
- Added dummy initialization to members in struct
- Added dummy initialization to members in struct
G4PolyPhiFace::G4PolyPhiFaceEdge, struct G4ReduciblePolygon::ABVertex.
G4Ellipsoid, G4EllipticalTube, G4EnclosingCylinder, G4ExtrudedSolid, G4Hype,
G4IntersectingCone, G4Paraboloid, G4PolyPhiFace, G4Polycone, G4PolyconeSide,
@@ -1126,7 +1137,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
02-Feb-2008, I.Hrivnacova (geom-specific-V09-01-01)
- Corrected triangularization of polygon, now correctly handling case
of concave shapes.
- Corrected order of arguments in G4Paraboloid constructor.
- Corrected order of arguments in G4Paraboloid constructor.
16-Jan-2008, I.Hrivnacova (geom-specific-V09-01-00)
- In G4ExtrudedSolid::MakeFacets(), now adding triangular facets before quadrangular
@@ -1168,7 +1179,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
p on the surface.
o DistanceToOut(p,v): now returning positive solution or zero when crossing
the elliptical surface.
o Fix in DistanceToOut(p) which was giving always zero.
o Fix in DistanceToOut(p) which was giving always zero.
o Corrected visualisation error of solid in graphics_reps.
o Added some formulas on how to pre-calculate 'SemiAxis' and 'zheight'.
o Added checkDistanceToOut() method to unit test.
@@ -1368,7 +1379,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
o added GetPointOnSurface() method
- G4Hype:
o corrected surface area calculation used in GetPointOnSurface()
17-Nov-2005, G.Cosmo (geom-specific-V07-01-09)
- More fixes required for direct object persistency to G4Polycone,
G4polyhedra and related utility classes.
@@ -1472,7 +1483,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
- Added G4TwistedBox - a twisted box with twist angle alpha,
length a/2,b/2,L/2.
- Added G4TwistedTrap - a twisted trapezoid (still in debug state)
- Changed in G4VSurface.icc:
- Changed in G4VSurface.icc:
- GetNeighbours(): corrected axiscode (was returning the wrong neighbours)
- SetNeighbours(): fixed problem #685 (index out of range)
- Added tests for G4TwistedBox and G4TwistedTrap in specific/test.
@@ -1592,7 +1603,7 @@ May 21, 2020 Guilherme Lima (geom-specific-V10-06-08)
- Migration to STL vector:
o In G4ClippablePolygon, migrated G4ThreeVectorList typedef and
made private to class.
03-Apr-2001, D.Williams (geom-solids-specific-V03-00-01)
-----------------------
- G4IntersectingCone.cc: make small adjustment to help with roundoff error
@@ -87,6 +87,10 @@ class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
G4Polyhedron* CreatePolyhedron() const;
void GetVertices(G4ThreeVector& anchor,
G4ThreeVector& p1,
G4ThreeVector& p2,
G4ThreeVector& p3) const;
std::vector<G4ThreeVector> GetVertices() const;
// Return the four vertices of the shape.
};
+8 -25
View File
@@ -1,13 +1,8 @@
#------------------------------------------------------------------------------
# Module : G4specsolids
# Package: Geant4.src.G4geometry.G4specsolids
#------------------------------------------------------------------------------
# - G4specsolids module build definition
#
# Define the Geant4 Module.
#
geant4_define_module(NAME G4specsolids
HEADERS
geant4_add_module(G4specsolids
PUBLIC_HEADERS
G4ClippablePolygon.hh
G4ClippablePolygon.icc
G4Ellipsoid.hh
@@ -134,21 +129,9 @@ geant4_define_module(NAME G4specsolids
G4VFacet.cc
G4Voxelizer.cc
G4VTwistSurface.cc
G4VTwistedFaceted.cc
GRANULAR_DEPENDENCIES
G4csg
G4geometrymng
G4globman
G4graphics_reps
G4hepnumerics
G4intercoms
G4volumes
GLOBAL_DEPENDENCIES
G4global
G4graphics_reps
G4intercoms
LINK_LIBRARIES
${VECGEOM_LIBRARIES}
)
G4VTwistedFaceted.cc)
geant4_module_link_libraries(G4specsolids
PUBLIC G4csg G4geometrymng G4hepnumerics G4graphics_reps G4globman G4hepgeometry ${VECGEOM_LIBRARIES}
PRIVATE G4heprandom)
# List any source specific properties here
@@ -824,283 +824,10 @@ G4ThreeVector G4GenericPolycone::GetPointOnSurface() const
G4Polyhedron* G4GenericPolycone::CreatePolyhedron() const
{
// The following code prepares for:
// HepPolyhedron::createPolyhedron(int Nnodes, int Nfaces,
// const double xyz[][3],
// const int faces_vec[][4])
// Here is an extract from the header file HepPolyhedron.h:
/**
* Creates user defined polyhedron.
* This function allows to the user to define arbitrary polyhedron.
* The faces of the polyhedron should be either triangles or planar
* quadrilateral. Nodes of a face are defined by indexes pointing to
* the elements in the xyz array. Numeration of the elements in the
* array starts from 1 (like in fortran). The indexes can be positive
* or negative. Negative sign means that the corresponding edge is
* invisible. The normal of the face should be directed to exterior
* of the polyhedron.
*
* @param Nnodes number of nodes
* @param Nfaces number of faces
* @param xyz nodes
* @param faces_vec faces (quadrilaterals or triangles)
* @return status of the operation - is non-zero in case of problem
*/
const G4int numSide =
G4int(G4Polyhedron::GetNumberOfRotationSteps()
* (endPhi - startPhi) / twopi) + 1;
G4int nNodes;
G4int nFaces;
typedef G4double double3[3];
double3* xyz;
typedef G4int int4[4];
int4* faces_vec;
if (phiIsOpen)
{
// Triangulate open ends. Simple ear-chopping algorithm...
// I'm not sure how robust this algorithm is (J.Allison).
//
std::vector<G4bool> chopped(numCorner, false);
std::vector<G4int*> triQuads;
G4int remaining = numCorner;
G4int iStarter = 0;
while (remaining >= 3) // Loop checking, 13.08.2015, G.Cosmo
{
// Find unchopped corners...
//
G4int A = -1, B = -1, C = -1;
G4int iStepper = iStarter;
do // Loop checking, 13.08.2015, G.Cosmo
{
if (A < 0) { A = iStepper; }
else if (B < 0) { B = iStepper; }
else if (C < 0) { C = iStepper; }
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStepper >= numCorner) { iStepper = 0; }
}
while (chopped[iStepper]);
}
while (C < 0 && iStepper != iStarter);
// Check triangle at B is pointing outward (an "ear").
// Sign of z cross product determines...
//
G4double BAr = corners[A].r - corners[B].r;
G4double BAz = corners[A].z - corners[B].z;
G4double BCr = corners[C].r - corners[B].r;
G4double BCz = corners[C].z - corners[B].z;
if (BAr * BCz - BAz * BCr < kCarTolerance)
{
G4int* tq = new G4int[3];
tq[0] = A + 1;
tq[1] = B + 1;
tq[2] = C + 1;
triQuads.push_back(tq);
chopped[B] = true;
--remaining;
}
else
{
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStarter >= numCorner) { iStarter = 0; }
}
while (chopped[iStarter]);
}
}
// Transfer to faces...
//
nNodes = (numSide + 1) * numCorner;
nFaces = numSide * numCorner + 2 * triQuads.size();
faces_vec = new int4[nFaces];
G4int iface = 0;
G4int addition = numCorner * numSide;
G4int d = numCorner - 1;
for (G4int iEnd = 0; iEnd < 2; ++iEnd)
{
for (size_t i = 0; i < triQuads.size(); ++i)
{
// Negative for soft/auxiliary/normally invisible edges...
//
G4int a, b, c;
if (iEnd == 0)
{
a = triQuads[i][0];
b = triQuads[i][1];
c = triQuads[i][2];
}
else
{
a = triQuads[i][0] + addition;
b = triQuads[i][2] + addition;
c = triQuads[i][1] + addition;
}
G4int ab = std::abs(b - a);
G4int bc = std::abs(c - b);
G4int ca = std::abs(a - c);
faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
faces_vec[iface][3] = 0;
++iface;
}
}
// Continue with sides...
xyz = new double3[nNodes];
const G4double dPhi = (endPhi - startPhi) / numSide;
G4double phi = startPhi;
G4int ixyz = 0;
for (G4int iSide = 0; iSide < numSide; ++iSide)
{
for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
{
xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
xyz[ixyz][2] = corners[iCorner].z;
if (iSide == 0) // startPhi
{
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + numCorner + 1);
faces_vec[iface][2] = ixyz + numCorner + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + numCorner + 1);
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = ixyz - numCorner + 2;
}
}
else if (iSide == numSide - 1) // endPhi
{
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + numCorner + 1;
faces_vec[iface][2] = ixyz + numCorner + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + numCorner + 1;
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = -(ixyz - numCorner + 2);
}
}
else
{
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + numCorner + 1);
faces_vec[iface][2] = ixyz + numCorner + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + numCorner + 1);
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = -(ixyz - numCorner + 2);
}
}
++iface;
++ixyz;
}
phi += dPhi;
}
// Last corners...
for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
{
xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
xyz[ixyz][2] = corners[iCorner].z;
++ixyz;
}
}
else // !phiIsOpen - i.e., a complete 360 degrees.
{
nNodes = numSide * numCorner;
nFaces = numSide * numCorner;;
xyz = new double3[nNodes];
faces_vec = new int4[nFaces];
const G4double dPhi = (endPhi - startPhi) / numSide;
G4double phi = startPhi;
G4int ixyz = 0, iface = 0;
for (G4int iSide = 0; iSide < numSide; ++iSide)
{
for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
{
xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
xyz[ixyz][2] = corners[iCorner].z;
if (iSide < numSide - 1)
{
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + numCorner + 1);
faces_vec[iface][2] = ixyz + numCorner + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + numCorner + 1);
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = -(ixyz - numCorner + 2);
}
}
else // Last side joins ends...
{
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + numCorner - nFaces + 1);
faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz - nFaces + numCorner + 1);
faces_vec[iface][2] = ixyz - nFaces + 2;
faces_vec[iface][3] = -(ixyz - numCorner + 2);
}
}
++ixyz;
++iface;
}
phi += dPhi;
}
}
G4Polyhedron* polyhedron = new G4Polyhedron;
G4int prob = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
delete [] faces_vec;
delete [] xyz;
if (prob)
{
std::ostringstream message;
message << "Problem creating G4Polyhedron for: " << GetName();
G4Exception("G4GenericPolycone::CreatePolyhedron()", "GeomSolids1002",
JustWarning, message);
delete polyhedron;
return nullptr;
}
else
{
return polyhedron;
}
std::vector<G4TwoVector> rz(numCorner);
for (G4int i = 0; i < numCorner; ++i)
rz[i].set(corners[i].r, corners[i].z);
return new G4PolyhedronPcon(startPhi, endPhi - startPhi, rz);
}
#endif
@@ -221,10 +221,8 @@ void G4Polycone::Create( G4double phiStart,
numCorner = rz->NumVertices();
startPhi = phiStart;
while( startPhi < 0. ) // Loop checking, 13.08.2015, G.Cosmo
startPhi += twopi;
//
// Phi opening? Account for some possible roundoff, and interpret
// nonsense value as representing no phi opening
@@ -952,16 +950,10 @@ G4ThreeVector G4Polycone::GetPointOnSurface() const
G4Polyhedron* G4Polycone::CreatePolyhedron() const
{
//
// This has to be fixed in visualization. Fake it for the moment.
//
return new G4PolyhedronPcon( original_parameters->Start_angle,
original_parameters->Opening_angle,
original_parameters->Num_z_planes,
original_parameters->Z_values,
original_parameters->Rmin,
original_parameters->Rmax );
std::vector<G4TwoVector> rz(numCorner);
for (G4int i = 0; i < numCorner; ++i)
rz[i].set(corners[i].r, corners[i].z);
return new G4PolyhedronPcon(startPhi, endPhi - startPhi, rz);
}
// SetOriginalParameters
@@ -1030,258 +1030,10 @@ G4ThreeVector G4Polyhedra::GetPointOnSurface() const
G4Polyhedron* G4Polyhedra::CreatePolyhedron() const
{
if (!genericPgon)
{
return new G4PolyhedronPgon( original_parameters->Start_angle,
original_parameters->Opening_angle,
original_parameters->numSide,
original_parameters->Num_z_planes,
original_parameters->Z_values,
original_parameters->Rmin,
original_parameters->Rmax);
}
else
{
// The following code prepares for:
// HepPolyhedron::createPolyhedron(int Nnodes, int Nfaces,
// const double xyz[][3],
// const int faces_vec[][4])
// Here is an extract from the header file HepPolyhedron.h:
/**
* Creates user defined polyhedron.
* This function allows to the user to define arbitrary polyhedron.
* The faces of the polyhedron should be either triangles or planar
* quadrilateral. Nodes of a face are defined by indexes pointing to
* the elements in the xyz array. Numeration of the elements in the
* array starts from 1 (like in fortran). The indexes can be positive
* or negative. Negative sign means that the corresponding edge is
* invisible. The normal of the face should be directed to exterior
* of the polyhedron.
*
* @param Nnodes number of nodes
* @param Nfaces number of faces
* @param xyz nodes
* @param faces_vec faces (quadrilaterals or triangles)
* @return status of the operation - is non-zero in case of problem
*/
G4int nNodes;
G4int nFaces;
typedef G4double double3[3];
double3* xyz;
typedef G4int int4[4];
int4* faces_vec;
if (phiIsOpen)
{
// Triangulate open ends. Simple ear-chopping algorithm...
// I'm not sure how robust this algorithm is (J.Allison).
//
std::vector<G4bool> chopped(numCorner, false);
std::vector<G4int*> triQuads;
G4int remaining = numCorner;
G4int iStarter = 0;
while (remaining >= 3) // Loop checking, 13.08.2015, G.Cosmo
{
// Find unchopped corners...
//
G4int A = -1, B = -1, C = -1;
G4int iStepper = iStarter;
do // Loop checking, 13.08.2015, G.Cosmo
{
if (A < 0) { A = iStepper; }
else if (B < 0) { B = iStepper; }
else if (C < 0) { C = iStepper; }
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStepper >= numCorner) iStepper = 0;
}
while (chopped[iStepper]);
}
while (C < 0 && iStepper != iStarter);
// Check triangle at B is pointing outward (an "ear").
// Sign of z cross product determines...
G4double BAr = corners[A].r - corners[B].r;
G4double BAz = corners[A].z - corners[B].z;
G4double BCr = corners[C].r - corners[B].r;
G4double BCz = corners[C].z - corners[B].z;
if (BAr * BCz - BAz * BCr < kCarTolerance)
{
G4int* tq = new G4int[3];
tq[0] = A + 1;
tq[1] = B + 1;
tq[2] = C + 1;
triQuads.push_back(tq);
chopped[B] = true;
--remaining;
}
else
{
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStarter >= numCorner) { iStarter = 0; }
}
while (chopped[iStarter]);
}
}
// Transfer to faces...
nNodes = (numSide + 1) * numCorner;
nFaces = numSide * numCorner + 2 * triQuads.size();
faces_vec = new int4[nFaces];
G4int iface = 0;
G4int addition = numCorner * numSide;
G4int d = numCorner - 1;
for (G4int iEnd = 0; iEnd < 2; ++iEnd)
{
for (size_t i = 0; i < triQuads.size(); ++i)
{
// Negative for soft/auxiliary/normally invisible edges...
//
G4int a, b, c;
if (iEnd == 0)
{
a = triQuads[i][0];
b = triQuads[i][1];
c = triQuads[i][2];
}
else
{
a = triQuads[i][0] + addition;
b = triQuads[i][2] + addition;
c = triQuads[i][1] + addition;
}
G4int ab = std::abs(b - a);
G4int bc = std::abs(c - b);
G4int ca = std::abs(a - c);
faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
faces_vec[iface][3] = 0;
++iface;
}
}
// Continue with sides...
xyz = new double3[nNodes];
const G4double dPhi = (endPhi - startPhi) / numSide;
G4double phi = startPhi;
G4int ixyz = 0;
for (G4int iSide = 0; iSide < numSide; ++iSide)
{
for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
{
xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
xyz[ixyz][2] = corners[iCorner].z;
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + numCorner + 1;
faces_vec[iface][2] = ixyz + numCorner + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + numCorner + 1;
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = ixyz - numCorner + 2;
}
++iface;
++ixyz;
}
phi += dPhi;
}
// Last corners...
for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
{
xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
xyz[ixyz][2] = corners[iCorner].z;
++ixyz;
}
}
else // !phiIsOpen - i.e., a complete 360 degrees.
{
nNodes = numSide * numCorner;
nFaces = numSide * numCorner;;
xyz = new double3[nNodes];
faces_vec = new int4[nFaces];
// const G4double dPhi = (endPhi - startPhi) / numSide;
const G4double dPhi = twopi / numSide;
// !phiIsOpen endPhi-startPhi = 360 degrees.
G4double phi = startPhi;
G4int ixyz = 0, iface = 0;
for (G4int iSide = 0; iSide < numSide; ++iSide)
{
for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
{
xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
xyz[ixyz][2] = corners[iCorner].z;
if (iSide < numSide - 1)
{
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + numCorner + 1;
faces_vec[iface][2] = ixyz + numCorner + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + numCorner + 1;
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = ixyz - numCorner + 2;
}
}
else // Last side joins ends...
{
if (iCorner < numCorner - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + numCorner - nFaces + 1;
faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz - nFaces + numCorner + 1;
faces_vec[iface][2] = ixyz - nFaces + 2;
faces_vec[iface][3] = ixyz - numCorner + 2;
}
}
++ixyz;
++iface;
}
phi += dPhi;
}
}
G4Polyhedron* polyhedron = new G4Polyhedron;
G4int problem = polyhedron->createPolyhedron(nNodes,nFaces,xyz,faces_vec);
delete [] faces_vec;
delete [] xyz;
if (problem)
{
std::ostringstream message;
message << "Problem creating G4Polyhedron for: " << GetName();
G4Exception("G4Polyhedra::CreatePolyhedron()", "GeomSolids1002",
JustWarning, message);
delete polyhedron;
return nullptr;
}
else
{
return polyhedron;
}
}
std::vector<G4TwoVector> rz(numCorner);
for (G4int i = 0; i < numCorner; ++i)
rz[i].set(corners[i].r, corners[i].z);
return new G4PolyhedronPgon(startPhi, endPhi - startPhi, numSide, rz);
}
// SetOriginalParameters
@@ -46,14 +46,14 @@ using namespace CLHEP;
//
// Constructor (generic parameters)
//
G4UGenericPolycone::G4UGenericPolycone(const G4String& name,
G4UGenericPolycone::G4UGenericPolycone(const G4String& name,
G4double phiStart,
G4double phiTotal,
G4int numRZ,
const G4double r[],
const G4double z[] )
: Base_t(name, phiStart, phiTotal, numRZ, r, z)
{
{
wrStart = phiStart; while (wrStart < 0) wrStart += twopi;
wrDelta = phiTotal;
if (wrDelta <= 0 || wrDelta >= twopi*(1-DBL_EPSILON))
@@ -112,7 +112,7 @@ G4UGenericPolycone&
G4UGenericPolycone::operator=(const G4UGenericPolycone& source)
{
if (this == &source) return *this;
Base_t::operator=( source );
wrStart = source.wrStart;
wrDelta = source.wrDelta;
@@ -374,285 +374,7 @@ G4UGenericPolycone::CalculateExtent(const EAxis pAxis,
G4Polyhedron* G4UGenericPolycone::CreatePolyhedron() const
{
// The following code prepares for:
// HepPolyhedron::createPolyhedron(int Nnodes, int Nfaces,
// const double xyz[][3],
// const int faces_vec[][4])
// Here is an extract from the header file HepPolyhedron.h:
/**
* Creates user defined polyhedron.
* This function allows one to the user to define arbitrary polyhedron.
* The faces of the polyhedron should be either triangles or planar
* quadrilateral. Nodes of a face are defined by indexes pointing to
* the elements in the xyz array. Numeration of the elements in the
* array starts from 1 (like in fortran). The indexes can be positive
* or negative. Negative sign means that the corresponding edge is
* invisible. The normal of the face should be directed to exterior
* of the polyhedron.
*
* @param Nnodes number of nodes
* @param Nfaces number of faces
* @param xyz nodes
* @param faces_vec faces (quadrilaterals or triangles)
* @return status of the operation - is non-zero in case of problem
*/
const G4int numSide =
G4int(G4Polyhedron::GetNumberOfRotationSteps()
* (GetEndPhi() - GetStartPhi()) / twopi) + 1;
G4int nNodes;
G4int nFaces;
typedef G4double double3[3];
double3* xyz;
typedef G4int int4[4];
int4* faces_vec;
if (IsOpen())
{
// Triangulate open ends. Simple ear-chopping algorithm...
// I'm not sure how robust this algorithm is (J.Allison).
//
std::vector<G4bool> chopped(GetNumRZCorner(), false);
std::vector<G4int*> triQuads;
G4int remaining = GetNumRZCorner();
G4int iStarter = 0;
while (remaining >= 3) // Loop checking, 13.08.2015, G.Cosmo
{
// Find unchopped corners...
//
G4int A = -1, B = -1, C = -1;
G4int iStepper = iStarter;
do // Loop checking, 13.08.2015, G.Cosmo
{
if (A < 0) { A = iStepper; }
else if (B < 0) { B = iStepper; }
else if (C < 0) { C = iStepper; }
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStepper >= GetNumRZCorner()) { iStepper = 0; }
}
while (chopped[iStepper]);
}
while (C < 0 && iStepper != iStarter);
// Check triangle at B is pointing outward (an "ear").
// Sign of z cross product determines...
//
G4double BAr = GetCorner(A).r - GetCorner(B).r;
G4double BAz = GetCorner(A).z - GetCorner(B).z;
G4double BCr = GetCorner(C).r - GetCorner(B).r;
G4double BCz = GetCorner(C).z - GetCorner(B).z;
if (BAr * BCz - BAz * BCr < kCarTolerance)
{
G4int* tq = new G4int[3];
tq[0] = A + 1;
tq[1] = B + 1;
tq[2] = C + 1;
triQuads.push_back(tq);
chopped[B] = true;
--remaining;
}
else
{
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStarter >= GetNumRZCorner()) { iStarter = 0; }
}
while (chopped[iStarter]);
}
}
// Transfer to faces...
//
nNodes = (numSide + 1) * GetNumRZCorner();
nFaces = numSide * GetNumRZCorner() + 2 * triQuads.size();
faces_vec = new int4[nFaces];
G4int iface = 0;
G4int addition = GetNumRZCorner() * numSide;
G4int d = GetNumRZCorner() - 1;
for (G4int iEnd = 0; iEnd < 2; ++iEnd)
{
for (size_t i = 0; i < triQuads.size(); ++i)
{
// Negative for soft/auxiliary/normally invisible edges...
//
G4int a, b, c;
if (iEnd == 0)
{
a = triQuads[i][0];
b = triQuads[i][1];
c = triQuads[i][2];
}
else
{
a = triQuads[i][0] + addition;
b = triQuads[i][2] + addition;
c = triQuads[i][1] + addition;
}
G4int ab = std::abs(b - a);
G4int bc = std::abs(c - b);
G4int ca = std::abs(a - c);
faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
faces_vec[iface][3] = 0;
++iface;
}
}
// Continue with sides...
xyz = new double3[nNodes];
const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
G4double phi = GetStartPhi();
G4int ixyz = 0;
for (G4int iSide = 0; iSide < numSide; ++iSide)
{
for (G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
{
xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
xyz[ixyz][2] = GetCorner(iCorner).z;
if (iSide == 0) // startPhi
{
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
}
}
else if (iSide == numSide - 1) // endPhi
{
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
}
}
else
{
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
}
}
++iface;
++ixyz;
}
phi += dPhi;
}
// Last corners...
for (G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
{
xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
xyz[ixyz][2] = GetCorner(iCorner).z;
++ixyz;
}
}
else // !phiIsOpen - i.e., a complete 360 degrees.
{
nNodes = numSide * GetNumRZCorner();
nFaces = numSide * GetNumRZCorner();;
xyz = new double3[nNodes];
faces_vec = new int4[nFaces];
const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
G4double phi = GetStartPhi();
G4int ixyz = 0, iface = 0;
for (G4int iSide = 0; iSide < numSide; ++iSide)
{
for (G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
{
xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
xyz[ixyz][2] = GetCorner(iCorner).z;
if (iSide < numSide - 1)
{
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
}
}
else // Last side joins ends...
{
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz + GetNumRZCorner() - nFaces + 1);
faces_vec[iface][2] = ixyz + GetNumRZCorner() - nFaces + 2;
faces_vec[iface][3] = -(ixyz + 2);
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = -(ixyz - nFaces + GetNumRZCorner() + 1);
faces_vec[iface][2] = ixyz - nFaces + 2;
faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
}
}
++ixyz;
++iface;
}
phi += dPhi;
}
}
G4Polyhedron* polyhedron = new G4Polyhedron;
G4int prob = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
delete [] faces_vec;
delete [] xyz;
if (prob)
{
std::ostringstream message;
message << "Problem creating G4Polyhedron for: " << GetName();
G4Exception("G4GenericPolycone::CreatePolyhedron()", "GeomSolids1002",
JustWarning, message);
delete polyhedron;
return nullptr;
}
else
{
return polyhedron;
}
return new G4PolyhedronPcon(wrStart, wrDelta, rzcorners);
}
#endif // G4GEOM_USE_USOLIDS
@@ -43,8 +43,8 @@ using namespace CLHEP;
////////////////////////////////////////////////////////////////////////
//
// Constructor (GEANT3 style parameters)
//
G4UPolycone::G4UPolycone( const G4String& name,
//
G4UPolycone::G4UPolycone( const G4String& name,
G4double phiStart,
G4double phiTotal,
G4int numZPlanes,
@@ -88,14 +88,14 @@ G4UPolycone::G4UPolycone( const G4String& name,
//
// Constructor (generic parameters)
//
G4UPolycone::G4UPolycone(const G4String& name,
G4UPolycone::G4UPolycone(const G4String& name,
G4double phiStart,
G4double phiTotal,
G4int numRZ,
const G4double r[],
const G4double z[] )
: Base_t(name, phiStart, phiTotal, numRZ, r, z)
{
{
fGenericPcon = true;
SetOriginalParameters();
wrStart = phiStart; while (wrStart < 0) wrStart += twopi;
@@ -157,7 +157,7 @@ G4UPolycone::G4UPolycone( const G4UPolycone& source )
G4UPolycone& G4UPolycone::operator=( const G4UPolycone& source )
{
if (this == &source) return *this;
Base_t::operator=( source );
fGenericPcon = source.fGenericPcon;
fOriginalParameters = source.fOriginalParameters;
@@ -563,14 +563,7 @@ G4bool G4UPolycone::CalculateExtent(const EAxis pAxis,
//
G4Polyhedron* G4UPolycone::CreatePolyhedron() const
{
G4PolyhedronPcon*
polyhedron = new G4PolyhedronPcon( fOriginalParameters.Start_angle,
fOriginalParameters.Opening_angle,
fOriginalParameters.Num_z_planes,
fOriginalParameters.Z_values,
fOriginalParameters.Rmin,
fOriginalParameters.Rmax );
return polyhedron;
return new G4PolyhedronPcon(wrStart, wrDelta, rzcorners);
}
#endif // G4GEOM_USE_USOLIDS
@@ -46,11 +46,11 @@ using namespace CLHEP;
// Constructor (GEANT3 style parameters)
//
// GEANT3 PGON radii are specified in the distance to the norm of each face.
//
G4UPolyhedra::G4UPolyhedra(const G4String& name,
//
G4UPolyhedra::G4UPolyhedra(const G4String& name,
G4double phiStart,
G4double phiTotal,
G4int numSide,
G4int numSide,
G4int numZPlanes,
const G4double zPlane[],
const G4double rInner[],
@@ -94,10 +94,10 @@ G4UPolyhedra::G4UPolyhedra(const G4String& name,
//
// Constructor (generic parameters)
//
G4UPolyhedra::G4UPolyhedra(const G4String& name,
G4UPolyhedra::G4UPolyhedra(const G4String& name,
G4double phiStart,
G4double phiTotal,
G4int numSide,
G4int numSide,
G4int numRZ,
const G4double r[],
const G4double z[] )
@@ -445,9 +445,9 @@ void G4UPolyhedra::BoundingLimits(G4ThreeVector& pMin,
//
if (checkPhi)
{
if (GetStartPhi() != GetPhiStart() ||
GetEndPhi() != GetPhiEnd() ||
GetNumSide() != GetSideCount() ||
if (GetStartPhi() != GetPhiStart() ||
GetEndPhi() != GetPhiEnd() ||
GetNumSide() != GetSideCount() ||
IsOpen() != (Base_t::GetPhiDelta() < twopi))
{
std::ostringstream message;
@@ -595,258 +595,7 @@ G4UPolyhedra::CalculateExtent(const EAxis pAxis,
//
G4Polyhedron* G4UPolyhedra::CreatePolyhedron() const
{
if (!IsGeneric())
{
return new G4PolyhedronPgon( fOriginalParameters.Start_angle,
fOriginalParameters.Opening_angle,
fOriginalParameters.numSide,
fOriginalParameters.Num_z_planes,
fOriginalParameters.Z_values,
fOriginalParameters.Rmin,
fOriginalParameters.Rmax);
}
else
{
// The following code prepares for:
// HepPolyhedron::createPolyhedron(int Nnodes, int Nfaces,
// const double xyz[][3],
// const int faces_vec[][4])
// Here is an extract from the header file HepPolyhedron.h:
/**
* Creates user defined polyhedron.
* This function allows the user to define arbitrary polyhedron.
* The faces of the polyhedron should be either triangles or planar
* quadrilateral. Nodes of a face are defined by indexes pointing to
* the elements in the xyz array. Numeration of the elements in the
* array starts from 1 (like in fortran). The indexes can be positive
* or negative. Negative sign means that the corresponding edge is
* invisible. The normal of the face should be directed to exterior
* of the polyhedron.
*
* @param Nnodes number of nodes
* @param Nfaces number of faces
* @param xyz nodes
* @param faces_vec faces (quadrilaterals or triangles)
* @return status of the operation - is non-zero in case of problem
*/
G4int nNodes;
G4int nFaces;
typedef G4double double3[3];
double3* xyz;
typedef G4int int4[4];
int4* faces_vec;
if (IsOpen())
{
// Triangulate open ends. Simple ear-chopping algorithm...
// I'm not sure how robust this algorithm is (J.Allison).
//
std::vector<G4bool> chopped(GetNumRZCorner(), false);
std::vector<G4int*> triQuads;
G4int remaining = GetNumRZCorner();
G4int iStarter = 0;
while (remaining >= 3) // Loop checking, 13.08.2015, G.Cosmo
{
// Find unchopped corners...
//
G4int A = -1, B = -1, C = -1;
G4int iStepper = iStarter;
do // Loop checking, 13.08.2015, G.Cosmo
{
if (A < 0) { A = iStepper; }
else if (B < 0) { B = iStepper; }
else if (C < 0) { C = iStepper; }
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStepper >= GetNumRZCorner()) iStepper = 0;
}
while (chopped[iStepper]);
}
while (C < 0 && iStepper != iStarter);
// Check triangle at B is pointing outward (an "ear").
// Sign of z cross product determines...
G4double BAr = GetCorner(A).r - GetCorner(B).r;
G4double BAz = GetCorner(A).z - GetCorner(B).z;
G4double BCr = GetCorner(C).r - GetCorner(B).r;
G4double BCz = GetCorner(C).z - GetCorner(B).z;
if (BAr * BCz - BAz * BCr < kCarTolerance)
{
G4int* tq = new G4int[3];
tq[0] = A + 1;
tq[1] = B + 1;
tq[2] = C + 1;
triQuads.push_back(tq);
chopped[B] = true;
--remaining;
}
else
{
do // Loop checking, 13.08.2015, G.Cosmo
{
if (++iStarter >= GetNumRZCorner()) { iStarter = 0; }
}
while (chopped[iStarter]);
}
}
// Transfer to faces...
G4int numSide=GetNumSide();
nNodes = (numSide + 1) * GetNumRZCorner();
nFaces = numSide * GetNumRZCorner() + 2 * triQuads.size();
faces_vec = new int4[nFaces];
G4int iface = 0;
G4int addition = GetNumRZCorner() * numSide;
G4int d = GetNumRZCorner() - 1;
for (G4int iEnd = 0; iEnd < 2; ++iEnd)
{
for (size_t i = 0; i < triQuads.size(); ++i)
{
// Negative for soft/auxiliary/normally invisible edges...
//
G4int a, b, c;
if (iEnd == 0)
{
a = triQuads[i][0];
b = triQuads[i][1];
c = triQuads[i][2];
}
else
{
a = triQuads[i][0] + addition;
b = triQuads[i][2] + addition;
c = triQuads[i][1] + addition;
}
G4int ab = std::abs(b - a);
G4int bc = std::abs(c - b);
G4int ca = std::abs(a - c);
faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
faces_vec[iface][3] = 0;
++iface;
}
}
// Continue with sides...
xyz = new double3[nNodes];
const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
G4double phi = GetStartPhi();
G4int ixyz = 0;
for (G4int iSide = 0; iSide < numSide; ++iSide)
{
for (G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
{
xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
xyz[ixyz][2] = GetCorner(iCorner).z;
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
}
++iface;
++ixyz;
}
phi += dPhi;
}
// Last GetCorner...
for (G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
{
xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
xyz[ixyz][2] = GetCorner(iCorner).z;
++ixyz;
}
}
else // !phiIsOpen - i.e., a complete 360 degrees.
{
nNodes = GetNumSide() * GetNumRZCorner();
nFaces = GetNumSide() * GetNumRZCorner();;
xyz = new double3[nNodes];
faces_vec = new int4[nFaces];
// const G4double dPhi = (endPhi - startPhi) / numSide;
const G4double dPhi = twopi / GetNumSide();
// !phiIsOpen endPhi-startPhi = 360 degrees.
G4double phi = GetStartPhi();
G4int ixyz = 0, iface = 0;
for (G4int iSide = 0; iSide < GetNumSide(); ++iSide)
{
for (G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
{
xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
xyz[ixyz][2] = GetCorner(iCorner).z;
if (iSide < GetNumSide() - 1)
{
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
faces_vec[iface][2] = ixyz + 2;
faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
}
}
else // Last side joins ends...
{
if (iCorner < GetNumRZCorner() - 1)
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz + GetNumRZCorner() - nFaces + 1;
faces_vec[iface][2] = ixyz + GetNumRZCorner() - nFaces + 2;
faces_vec[iface][3] = ixyz + 2;
}
else
{
faces_vec[iface][0] = ixyz + 1;
faces_vec[iface][1] = ixyz - nFaces + GetNumRZCorner() + 1;
faces_vec[iface][2] = ixyz - nFaces + 2;
faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
}
}
++ixyz;
++iface;
}
phi += dPhi;
}
}
G4Polyhedron* polyhedron = new G4Polyhedron;
G4int prob = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
delete [] faces_vec;
delete [] xyz;
if (prob)
{
std::ostringstream message;
message << "Problem creating G4Polyhedron for: " << GetName();
G4Exception("G4Polyhedra::CreatePolyhedron()", "GeomSolids1002",
JustWarning, message);
delete polyhedron;
return nullptr;
}
else
{
return polyhedron;
}
}
return new G4PolyhedronPgon(wrStart, wrDelta, wrNumSide, rzcorners);
}
#endif // G4GEOM_USE_USOLIDS
@@ -158,6 +158,19 @@ G4VSolid* G4UTet::Clone() const
//
// Accessors
//
void G4UTet::GetVertices(G4ThreeVector& anchor,
G4ThreeVector& p1,
G4ThreeVector& p2,
G4ThreeVector& p3) const
{
std::vector<U3Vector> vec(4);
Base_t::GetVertices(vec[0], vec[1], vec[2], vec[3]);
anchor = G4ThreeVector(vec[0].x(), vec[0].y(), vec[0].z());
p1 = G4ThreeVector(vec[1].x(), vec[1].y(), vec[1].z());
p2 = G4ThreeVector(vec[2].x(), vec[2].y(), vec[2].z());
p3 = G4ThreeVector(vec[3].x(), vec[3].y(), vec[3].z());
}
std::vector<G4ThreeVector> G4UTet::GetVertices() const
{
std::vector<U3Vector> vec(4);