Import Geant4 11.4.0.beta source tree
This commit is contained in:
@@ -69,17 +69,17 @@ G4BoundingEnvelope(const std::vector<const G4ThreeVectorList*>& polygons)
|
||||
G4double xmax = -kInfinity, ymax = -kInfinity, zmax = -kInfinity;
|
||||
for (const auto & polygon : *fPolygons)
|
||||
{
|
||||
for (auto ipoint = polygon->cbegin(); ipoint != polygon->cend(); ++ipoint)
|
||||
for (const auto & ipoint : *polygon)
|
||||
{
|
||||
G4double x = ipoint->x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
G4double y = ipoint->y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
G4double z = ipoint->z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
G4double x = ipoint.x();
|
||||
if (x < xmin) { xmin = x; }
|
||||
if (x > xmax) { xmax = x; }
|
||||
G4double y = ipoint.y();
|
||||
if (y < ymin) { ymin = y; }
|
||||
if (y > ymax) { ymax = y; }
|
||||
G4double z = ipoint.z();
|
||||
if (z < zmin) { zmin = z; }
|
||||
if (z > zmax) { zmax = z; }
|
||||
}
|
||||
}
|
||||
fMin.set(xmin,ymin,zmin);
|
||||
@@ -158,9 +158,9 @@ void G4BoundingEnvelope::CheckBoundingPolygons()
|
||||
for (std::size_t k=0; k<nbases; ++k)
|
||||
{
|
||||
std::size_t np = (*fPolygons)[k]->size();
|
||||
if (np == nsize) continue;
|
||||
if (np == 1 && k==0) continue;
|
||||
if (np == 1 && k==nbases-1) continue;
|
||||
if (np == nsize) { continue; }
|
||||
if (np == 1 && k==0) { continue; }
|
||||
if (np == 1 && k==nbases-1) { continue; }
|
||||
std::ostringstream message;
|
||||
message << "Badly constructed polygons!"
|
||||
<< "\nNumber of polygons: " << nbases
|
||||
@@ -204,12 +204,12 @@ BoundingBoxVsVoxelLimits(const EAxis pAxis,
|
||||
G4double zmin = fMin.z() + pTransform3D.dz();
|
||||
G4double zmax = fMax.z() + pTransform3D.dz();
|
||||
|
||||
if (xmin-kCarTolerance > xmaxlim) return true;
|
||||
if (xmax+kCarTolerance < xminlim) return true;
|
||||
if (ymin-kCarTolerance > ymaxlim) return true;
|
||||
if (ymax+kCarTolerance < yminlim) return true;
|
||||
if (zmin-kCarTolerance > zmaxlim) return true;
|
||||
if (zmax+kCarTolerance < zminlim) return true;
|
||||
if (xmin-kCarTolerance > xmaxlim) { return true; }
|
||||
if (xmax+kCarTolerance < xminlim) { return true; }
|
||||
if (ymin-kCarTolerance > ymaxlim) { return true; }
|
||||
if (ymax+kCarTolerance < yminlim) { return true; }
|
||||
if (zmin-kCarTolerance > zmaxlim) { return true; }
|
||||
if (zmax+kCarTolerance < zminlim) { return true; }
|
||||
|
||||
if (xmin >= xminlim && xmax <= xmaxlim &&
|
||||
ymin >= yminlim && ymax <= ymaxlim &&
|
||||
@@ -250,12 +250,12 @@ BoundingBoxVsVoxelLimits(const EAxis pAxis,
|
||||
// Check if the sphere surrounding the bounding box is outside
|
||||
// the voxel limits
|
||||
//
|
||||
if (center.x()-radius > xmaxlim) return true;
|
||||
if (center.y()-radius > ymaxlim) return true;
|
||||
if (center.z()-radius > zmaxlim) return true;
|
||||
if (center.x()+radius < xminlim) return true;
|
||||
if (center.y()+radius < yminlim) return true;
|
||||
if (center.z()+radius < zminlim) return true;
|
||||
if (center.x()-radius > xmaxlim) { return true; }
|
||||
if (center.y()-radius > ymaxlim) { return true; }
|
||||
if (center.z()-radius > zmaxlim) { return true; }
|
||||
if (center.x()+radius < xminlim) { return true; }
|
||||
if (center.y()+radius < yminlim) { return true; }
|
||||
if (center.z()+radius < zminlim) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -289,12 +289,12 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
G4double zmin = fMin.z() + pTransform3D.dz();
|
||||
G4double zmax = fMax.z() + pTransform3D.dz();
|
||||
|
||||
if (xmin-kCarTolerance > xmaxlim) return false;
|
||||
if (xmax+kCarTolerance < xminlim) return false;
|
||||
if (ymin-kCarTolerance > ymaxlim) return false;
|
||||
if (ymax+kCarTolerance < yminlim) return false;
|
||||
if (zmin-kCarTolerance > zmaxlim) return false;
|
||||
if (zmax+kCarTolerance < zminlim) return false;
|
||||
if (xmin-kCarTolerance > xmaxlim) { return false; }
|
||||
if (xmax+kCarTolerance < xminlim) { return false; }
|
||||
if (ymin-kCarTolerance > ymaxlim) { return false; }
|
||||
if (ymax+kCarTolerance < yminlim) { return false; }
|
||||
if (zmin-kCarTolerance > zmaxlim) { return false; }
|
||||
if (zmax+kCarTolerance < zminlim) { return false; }
|
||||
|
||||
if (fPolygons == nullptr)
|
||||
{
|
||||
@@ -368,39 +368,39 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
{
|
||||
G4double coor;
|
||||
coor = cx*fMin.x() + cy*fMin.y() + cz*fMin.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
coor = cx*fMax.x() + cy*fMin.y() + cz*fMin.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
coor = cx*fMax.x() + cy*fMax.y() + cz*fMin.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
coor = cx*fMin.x() + cy*fMax.y() + cz*fMin.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
coor = cx*fMin.x() + cy*fMin.y() + cz*fMax.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
coor = cx*fMax.x() + cy*fMin.y() + cz*fMax.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
coor = cx*fMax.x() + cy*fMax.y() + cz*fMax.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
coor = cx*fMin.x() + cy*fMax.y() + cz*fMax.z() + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto & polygon : *fPolygons)
|
||||
{
|
||||
for (auto ipoint=polygon->cbegin(); ipoint!=polygon->cend(); ++ipoint)
|
||||
for (const auto & ipoint : *polygon)
|
||||
{
|
||||
G4double coor = ipoint->x()*cx + ipoint->y()*cy + ipoint->z()*cz + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
if (coor > emax) emax = coor;
|
||||
G4double coor = ipoint.x()*cx + ipoint.y()*cy + ipoint.z()*cz + cd;
|
||||
if (coor < emin) { emin = coor; }
|
||||
if (coor > emax) { emax = coor; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,12 +412,12 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
// Check if the sphere surrounding the bounding box is outside
|
||||
// the voxel limits
|
||||
//
|
||||
if (center.x()-radius > xmaxlim) return false;
|
||||
if (center.y()-radius > ymaxlim) return false;
|
||||
if (center.z()-radius > zmaxlim) return false;
|
||||
if (center.x()+radius < xminlim) return false;
|
||||
if (center.y()+radius < yminlim) return false;
|
||||
if (center.z()+radius < zminlim) return false;
|
||||
if (center.x()-radius > xmaxlim) { return false; }
|
||||
if (center.y()-radius > ymaxlim) { return false; }
|
||||
if (center.z()-radius > zmaxlim) { return false; }
|
||||
if (center.x()+radius < xminlim) { return false; }
|
||||
if (center.y()+radius < yminlim) { return false; }
|
||||
if (center.z()+radius < zminlim) { return false; }
|
||||
|
||||
// Transform polygons
|
||||
//
|
||||
@@ -452,11 +452,15 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
{
|
||||
baseA.resize(bases[k].second);
|
||||
for (G4int i = 0; i < bases[k].second; ++i)
|
||||
{
|
||||
baseA[i] = vertices[bases[k].first + i];
|
||||
}
|
||||
|
||||
baseB.resize(bases[k+1].second);
|
||||
for (G4int i = 0; i < bases[k+1].second; ++i)
|
||||
{
|
||||
baseB[i] = vertices[bases[k+1].first + i];
|
||||
}
|
||||
|
||||
// Find bounding box of current prism
|
||||
G4Segment3D prismAABB;
|
||||
@@ -471,52 +475,76 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
prismAABB.second.z()<= limits.GetMaxZExtent())
|
||||
{
|
||||
if (extent.first.x() > prismAABB.first.x())
|
||||
{
|
||||
extent.first.setX( prismAABB.first.x() );
|
||||
}
|
||||
if (extent.first.y() > prismAABB.first.y())
|
||||
{
|
||||
extent.first.setY( prismAABB.first.y() );
|
||||
}
|
||||
if (extent.first.z() > prismAABB.first.z())
|
||||
{
|
||||
extent.first.setZ( prismAABB.first.z() );
|
||||
}
|
||||
if (extent.second.x() < prismAABB.second.x())
|
||||
{
|
||||
extent.second.setX(prismAABB.second.x());
|
||||
}
|
||||
if (extent.second.y() < prismAABB.second.y())
|
||||
{
|
||||
extent.second.setY(prismAABB.second.y());
|
||||
}
|
||||
if (extent.second.z() < prismAABB.second.z())
|
||||
{
|
||||
extent.second.setZ(prismAABB.second.z());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if prismAABB is outside the voxel limits
|
||||
if (prismAABB.first.x() > limits.GetMaxXExtent()) continue;
|
||||
if (prismAABB.first.y() > limits.GetMaxYExtent()) continue;
|
||||
if (prismAABB.first.z() > limits.GetMaxZExtent()) continue;
|
||||
if (prismAABB.second.x() < limits.GetMinXExtent()) continue;
|
||||
if (prismAABB.second.y() < limits.GetMinYExtent()) continue;
|
||||
if (prismAABB.second.z() < limits.GetMinZExtent()) continue;
|
||||
if (prismAABB.first.x() > limits.GetMaxXExtent()) { continue; }
|
||||
if (prismAABB.first.y() > limits.GetMaxYExtent()) { continue; }
|
||||
if (prismAABB.first.z() > limits.GetMaxZExtent()) { continue; }
|
||||
if (prismAABB.second.x() < limits.GetMinXExtent()) { continue; }
|
||||
if (prismAABB.second.y() < limits.GetMinYExtent()) { continue; }
|
||||
if (prismAABB.second.z() < limits.GetMinZExtent()) { continue; }
|
||||
|
||||
// Clip edges of the prism by adjusted G4VoxelLimits box
|
||||
std::vector<G4Segment3D> vecEdges;
|
||||
CreateListOfEdges(baseA, baseB, vecEdges);
|
||||
if (ClipEdgesByVoxel(vecEdges, limits, extent)) continue;
|
||||
if (ClipEdgesByVoxel(vecEdges, limits, extent)) { continue; }
|
||||
|
||||
// Some edges of the prism are completely outside of the voxel
|
||||
// limits, clip selected edges (see bits) of adjusted G4VoxelLimits
|
||||
// by the prism
|
||||
G4int bits = 0x000;
|
||||
if (limits.GetMinXExtent() < prismAABB.first.x())
|
||||
{
|
||||
bits |= 0x988; // 1001 1000 1000
|
||||
}
|
||||
if (limits.GetMaxXExtent() > prismAABB.second.x())
|
||||
{
|
||||
bits |= 0x622; // 0110 0010 0010
|
||||
}
|
||||
|
||||
if (limits.GetMinYExtent() < prismAABB.first.y())
|
||||
{
|
||||
bits |= 0x311; // 0011 0001 0001
|
||||
}
|
||||
if (limits.GetMaxYExtent() > prismAABB.second.y())
|
||||
{
|
||||
bits |= 0xC44; // 1100 0100 0100
|
||||
}
|
||||
|
||||
if (limits.GetMinZExtent() < prismAABB.first.z())
|
||||
{
|
||||
bits |= 0x00F; // 0000 0000 1111
|
||||
}
|
||||
if (limits.GetMaxZExtent() > prismAABB.second.z())
|
||||
{
|
||||
bits |= 0x0F0; // 0000 1111 0000
|
||||
if (bits == 0xFFF) continue;
|
||||
}
|
||||
if (bits == 0xFFF) { continue; }
|
||||
|
||||
std::vector<G4Plane3D> vecPlanes;
|
||||
CreateListOfPlanes(baseA, baseB, vecPlanes);
|
||||
@@ -530,7 +558,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
if (pAxis == kYAxis) { emin = extent.first.y(); emax = extent.second.y(); }
|
||||
if (pAxis == kZAxis) { emin = extent.first.z(); emax = extent.second.z(); }
|
||||
|
||||
if (emin > emax) return false;
|
||||
if (emin > emax) { return false; }
|
||||
emin -= delta;
|
||||
emax += delta;
|
||||
G4double minlim = pVoxelLimits.GetMinExtent(pAxis);
|
||||
@@ -549,7 +577,7 @@ G4BoundingEnvelope::FindScaleFactor(const G4Transform3D& pTransform3D) const
|
||||
{
|
||||
if (pTransform3D.xx() == 1. &&
|
||||
pTransform3D.yy() == 1. &&
|
||||
pTransform3D.zz() == 1.) return 1.;
|
||||
pTransform3D.zz() == 1.) { return 1.; }
|
||||
|
||||
G4double xx = pTransform3D.xx();
|
||||
G4double yx = pTransform3D.yx();
|
||||
@@ -613,14 +641,22 @@ TransformVertices(const G4Transform3D& pTransform3D,
|
||||
{
|
||||
G4ThreeVector offset = pTransform3D.getTranslation();
|
||||
for (auto i = ia; i != iaend; ++i)
|
||||
{
|
||||
for (auto k = (*i)->cbegin(); k != (*i)->cend(); ++k)
|
||||
{
|
||||
pVertices.emplace_back((*k) + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto i = ia; i != iaend; ++i)
|
||||
{
|
||||
for (auto k = (*i)->cbegin(); k != (*i)->cend(); ++k)
|
||||
{
|
||||
pVertices.push_back(pTransform3D*G4Point3D(*k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,14 +677,14 @@ G4BoundingEnvelope::GetPrismAABB(const G4Polygon3D& pBaseA,
|
||||
for (const auto & it1 : pBaseA)
|
||||
{
|
||||
G4double x = it1.x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
if (x < xmin) { xmin = x; }
|
||||
if (x > xmax) { xmax = x; }
|
||||
G4double y = it1.y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
if (y < ymin) { ymin = y; }
|
||||
if (y > ymax) { ymax = y; }
|
||||
G4double z = it1.z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
if (z < zmin) { zmin = z; }
|
||||
if (z > zmax) { zmax = z; }
|
||||
}
|
||||
|
||||
// Second base
|
||||
@@ -656,14 +692,14 @@ G4BoundingEnvelope::GetPrismAABB(const G4Polygon3D& pBaseA,
|
||||
for (const auto & it2 : pBaseB)
|
||||
{
|
||||
G4double x = it2.x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
if (x < xmin) { xmin = x; }
|
||||
if (x > xmax) { xmax = x; }
|
||||
G4double y = it2.y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
if (y < ymin) { ymin = y; }
|
||||
if (y > ymax) { ymax = y; }
|
||||
G4double z = it2.z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
if (z < zmin) { zmin = z; }
|
||||
if (z > zmax) { zmax = z; }
|
||||
}
|
||||
|
||||
// Set bounding box
|
||||
@@ -735,8 +771,8 @@ G4BoundingEnvelope::CreateListOfPlanes(const G4Polygon3D& baseA,
|
||||
std::size_t nb = baseB.size();
|
||||
G4Point3D pa(0.,0.,0.), pb(0.,0.,0.), p0;
|
||||
G4Normal3D norm;
|
||||
for (std::size_t i=0; i<na; ++i) pa += baseA[i];
|
||||
for (std::size_t i=0; i<nb; ++i) pb += baseB[i];
|
||||
for (std::size_t i=0; i<na; ++i) { pa += baseA[i]; }
|
||||
for (std::size_t i=0; i<nb; ++i) { pb += baseB[i]; }
|
||||
pa /= na; pb /= nb; p0 = (pa+pb)/2.;
|
||||
|
||||
// Create list of planes
|
||||
@@ -838,7 +874,7 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
G4Point3D p2 = pEdges[k].second;
|
||||
if (std::abs(p1.x()-p2.x())+
|
||||
std::abs(p1.y()-p2.y())+
|
||||
std::abs(p1.z()-p2.z()) < kCarTolerance) continue;
|
||||
std::abs(p1.z()-p2.z()) < kCarTolerance) { continue; }
|
||||
G4double d1, d2;
|
||||
// Clip current edge by X min
|
||||
d1 = pBox.GetMinXExtent() - p1.x();
|
||||
|
||||
@@ -53,7 +53,7 @@ G4double G4GeomTools::TriangleArea(const G4TwoVector& A,
|
||||
const G4TwoVector& B,
|
||||
const G4TwoVector& C)
|
||||
{
|
||||
G4double Ax = A.x(), Ay = A.y();
|
||||
G4double Ax = A.x(), Ay = A.y();
|
||||
return ((B.x()-Ax)*(C.y()-Ay) - (B.y()-Ay)*(C.x()-Ax))*0.5;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ G4double G4GeomTools::QuadArea(const G4TwoVector& A,
|
||||
G4double G4GeomTools::PolygonArea(const G4TwoVectorList& p)
|
||||
{
|
||||
auto n = (G4int)p.size();
|
||||
if (n < 3) return 0.0; // degenerate polygon
|
||||
if (n < 3) { return 0.0; // degenerate polygon
|
||||
}
|
||||
G4double area = p[n-1].x()*p[0].y() - p[0].x()*p[n-1].y();
|
||||
for(G4int i=1; i<n; ++i)
|
||||
{
|
||||
@@ -97,15 +98,15 @@ G4bool G4GeomTools::PointInTriangle(G4double Ax, G4double Ay,
|
||||
{
|
||||
if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) > 0.)
|
||||
{
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) < 0.) return false;
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) < 0.) return false;
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) < 0.) return false;
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) < 0.) { return false; }
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) < 0.) { return false; }
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) < 0.) { return false; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) > 0.) return false;
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) > 0.) return false;
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) > 0.) return false;
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) > 0.) { return false; }
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) > 0.) { return false; }
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) > 0.) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -125,15 +126,15 @@ G4bool G4GeomTools::PointInTriangle(const G4TwoVector& A,
|
||||
G4double Px = P.x(), Py = P.y();
|
||||
if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) > 0.)
|
||||
{
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) < 0.) return false;
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) < 0.) return false;
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) < 0.) return false;
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) < 0.) { return false; }
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) < 0.) { return false; }
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) < 0.) { return false; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) > 0.) return false;
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) > 0.) return false;
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) > 0.) return false;
|
||||
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) > 0.) { return false; }
|
||||
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) > 0.) { return false; }
|
||||
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) > 0.) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -170,7 +171,7 @@ G4bool G4GeomTools::IsConvex(const G4TwoVectorList& polygon)
|
||||
G4bool gotNegative = false;
|
||||
G4bool gotPositive = false;
|
||||
auto n = (G4int)polygon.size();
|
||||
if (n <= 0) return false;
|
||||
if (n <= 0) { return false; }
|
||||
for (G4int icur=0; icur<n; ++icur)
|
||||
{
|
||||
G4int iprev = (icur == 0) ? n-1 : icur-1;
|
||||
@@ -178,10 +179,10 @@ G4bool G4GeomTools::IsConvex(const G4TwoVectorList& polygon)
|
||||
G4TwoVector e1 = polygon[icur] - polygon[iprev];
|
||||
G4TwoVector e2 = polygon[inext] - polygon[icur];
|
||||
G4double cross = e1.x()*e2.y() - e1.y()*e2.x();
|
||||
if (std::abs(cross) < kCarTolerance) return false;
|
||||
if (cross < 0) gotNegative = true;
|
||||
if (cross > 0) gotPositive = true;
|
||||
if (gotNegative && gotPositive) return false;
|
||||
if (std::abs(cross) < kCarTolerance) { return false; }
|
||||
if (cross < 0) { gotNegative = true; }
|
||||
if (cross > 0) { gotPositive = true; }
|
||||
if (gotNegative && gotPositive) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -198,7 +199,7 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
G4bool reply = TriangulatePolygon(polygon,triangles);
|
||||
|
||||
auto n = (G4int)triangles.size();
|
||||
for (G4int i=0; i<n; ++i) result.push_back(polygon[triangles[i]]);
|
||||
for (G4int i=0; i<n; ++i) { result.push_back(polygon[triangles[i]]); }
|
||||
return reply;
|
||||
}
|
||||
|
||||
@@ -214,19 +215,20 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
// allocate and initialize list of Vertices in polygon
|
||||
//
|
||||
auto n = (G4int)polygon.size();
|
||||
if (n < 3) return false;
|
||||
if (n < 3) { return false; }
|
||||
|
||||
// we want a counter-clockwise polygon in V
|
||||
//
|
||||
//
|
||||
G4double area = G4GeomTools::PolygonArea(polygon);
|
||||
auto V = new G4int[n];
|
||||
if (area > 0.)
|
||||
for (G4int i=0; i<n; ++i) V[i] = i;
|
||||
else
|
||||
for (G4int i=0; i<n; ++i) V[i] = (n-1)-i;
|
||||
if (area > 0.) {
|
||||
for (G4int i=0; i<n; ++i) { V[i] = i; }
|
||||
} else {
|
||||
for (G4int i=0; i<n; ++i) { V[i] = (n-1)-i; }
|
||||
}
|
||||
|
||||
// Triangulation: remove nv-2 Vertices, creating 1 triangle every time
|
||||
//
|
||||
//
|
||||
G4int nv = n;
|
||||
G4int count = 2*nv; // error detection counter
|
||||
for(G4int b=nv-1; nv>2; )
|
||||
@@ -235,8 +237,8 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
if ((count--) <= 0)
|
||||
{
|
||||
delete [] V;
|
||||
if (area < 0.) std::reverse(result.begin(),result.end());
|
||||
return false;
|
||||
if (area < 0.) { std::reverse(result.begin(),result.end()); }
|
||||
return false;
|
||||
}
|
||||
|
||||
// three consecutive vertices in current polygon, <a,b,c>
|
||||
@@ -253,13 +255,13 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
|
||||
// remove vertex b from remaining polygon
|
||||
nv--;
|
||||
for(G4int i=b; i<nv; ++i) V[i] = V[i+1];
|
||||
for(G4int i=b; i<nv; ++i) { V[i] = V[i+1]; }
|
||||
|
||||
count = 2*nv; // resest error detection counter
|
||||
}
|
||||
}
|
||||
delete [] V;
|
||||
if (area < 0.) std::reverse(result.begin(),result.end());
|
||||
if (area < 0.) { std::reverse(result.begin(),result.end()); }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -279,8 +281,8 @@ G4bool G4GeomTools::CheckSnip(const G4TwoVectorList& contour,
|
||||
G4double Ax = contour[V[a]].x(), Ay = contour[V[a]].y();
|
||||
G4double Bx = contour[V[b]].x(), By = contour[V[b]].y();
|
||||
G4double Cx = contour[V[c]].x(), Cy = contour[V[c]].y();
|
||||
if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) < kCarTolerance) return false;
|
||||
|
||||
if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) < kCarTolerance) { return false; }
|
||||
|
||||
// check that there is no point inside Triangle
|
||||
G4double xmin = std::min(std::min(Ax,Bx),Cx);
|
||||
G4double xmax = std::max(std::max(Ax,Bx),Cx);
|
||||
@@ -288,12 +290,12 @@ G4bool G4GeomTools::CheckSnip(const G4TwoVectorList& contour,
|
||||
G4double ymax = std::max(std::max(Ay,By),Cy);
|
||||
for (G4int i=0; i<n; ++i)
|
||||
{
|
||||
if((i == a) || (i == b) || (i == c)) continue;
|
||||
if((i == a) || (i == b) || (i == c)) { continue; }
|
||||
G4double Px = contour[V[i]].x();
|
||||
if (Px < xmin || Px > xmax) continue;
|
||||
if (Px < xmin || Px > xmax) { continue; }
|
||||
G4double Py = contour[V[i]].y();
|
||||
if (Py < ymin || Py > ymax) continue;
|
||||
if (PointInTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)) return false;
|
||||
if (Py < ymin || Py > ymax) { continue; }
|
||||
if (PointInTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -304,7 +306,7 @@ G4bool G4GeomTools::CheckSnip(const G4TwoVectorList& contour,
|
||||
|
||||
void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
std::vector<G4int>& iout,
|
||||
G4double tolerance)
|
||||
G4double tolerance)
|
||||
{
|
||||
iout.resize(0);
|
||||
// set tolerance squared
|
||||
@@ -317,7 +319,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
// Main loop: check every three consecutive points, if the points
|
||||
// are collinear then mark middle point for removal
|
||||
//
|
||||
G4int icur = 0, iprev = 0, inext = 0, nout = 0;
|
||||
G4int icur = 0, iprev = 0, inext = 0, nout = 0;
|
||||
for (G4int i=0; i<nv; ++i)
|
||||
{
|
||||
icur = i; // index of current point
|
||||
@@ -325,18 +327,18 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
for (G4int k=1; k<nv+1; ++k) // set index of previous point
|
||||
{
|
||||
iprev = icur - k;
|
||||
if (iprev < 0) iprev += nv;
|
||||
if (polygon[iprev].x() != removeIt) break;
|
||||
if (iprev < 0) { iprev += nv; }
|
||||
if (polygon[iprev].x() != removeIt) { break; }
|
||||
}
|
||||
|
||||
for (G4int k=1; k<nv+1; ++k) // set index of next point
|
||||
{
|
||||
inext = icur + k;
|
||||
if (inext >= nv) inext -= nv;
|
||||
if (polygon[inext].x() != removeIt) break;
|
||||
if (inext >= nv) { inext -= nv; }
|
||||
if (polygon[inext].x() != removeIt) { break; }
|
||||
}
|
||||
|
||||
if (iprev == inext) break; // degenerate polygon, stop
|
||||
if (iprev == inext) { break; } // degenerate polygon, stop
|
||||
|
||||
// Calculate parameters of triangle (iprev->icur->inext),
|
||||
// if triangle is too small or too narrow then mark current
|
||||
@@ -344,7 +346,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
G4TwoVector e1 = polygon[iprev] - polygon[icur];
|
||||
G4TwoVector e2 = polygon[inext] - polygon[icur];
|
||||
|
||||
// Check length of edges, then check height of the triangle
|
||||
// Check length of edges, then check height of the triangle
|
||||
G4double leng1 = e1.mag2();
|
||||
G4double leng2 = e2.mag2();
|
||||
G4double leng3 = (e2-e1).mag2();
|
||||
@@ -368,18 +370,18 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
icur = 0;
|
||||
if (nv - nout < 3) // degenerate polygon, remove all points
|
||||
{
|
||||
for (G4int i=0; i<nv; ++i) iout.push_back(i);
|
||||
for (G4int i=0; i<nv; ++i) { iout.push_back(i); }
|
||||
polygon.resize(0);
|
||||
nv = 0;
|
||||
}
|
||||
for (G4int i=0; i<nv; ++i) // move points, if required
|
||||
{
|
||||
if (polygon[i].x() != removeIt)
|
||||
if (polygon[i].x() != removeIt) {
|
||||
polygon[icur++] = polygon[i];
|
||||
else
|
||||
iout.push_back(i);
|
||||
} else {
|
||||
iout.push_back(i); }
|
||||
}
|
||||
if (icur < nv) polygon.resize(icur);
|
||||
if (icur < nv) { polygon.resize(icur); }
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -398,15 +400,15 @@ G4bool G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
//
|
||||
pmin.set(0,0);
|
||||
pmax.set(0,0);
|
||||
if (rmin < 0) return false;
|
||||
if (rmax <= rmin + kCarTolerance) return false;
|
||||
if (delPhi <= 0 + kCarTolerance) return false;
|
||||
if (rmin < 0) { return false; }
|
||||
if (rmax <= rmin + kCarTolerance) { return false; }
|
||||
if (delPhi <= 0 + kCarTolerance) { return false; }
|
||||
|
||||
// calculate extent
|
||||
//
|
||||
pmin.set(-rmax,-rmax);
|
||||
pmax.set( rmax, rmax);
|
||||
if (delPhi >= CLHEP::twopi) return true;
|
||||
if (delPhi >= CLHEP::twopi) { return true; }
|
||||
|
||||
DiskExtent(rmin,rmax,
|
||||
std::sin(startPhi),std::cos(startPhi),
|
||||
@@ -433,25 +435,25 @@ void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
pmin.set(-rmax,-rmax);
|
||||
pmax.set( rmax, rmax);
|
||||
|
||||
if (std::abs(sinEnd-sinStart) < kCarTolerance &&
|
||||
std::abs(cosEnd-cosStart) < kCarTolerance) return;
|
||||
if (std::abs(sinEnd-sinStart) < kCarTolerance &&
|
||||
std::abs(cosEnd-cosStart) < kCarTolerance) { return; }
|
||||
|
||||
// get start and end quadrants
|
||||
//
|
||||
// 1 | 0
|
||||
// ---+---
|
||||
// ---+---
|
||||
// 3 | 2
|
||||
//
|
||||
G4int icase = (cosEnd < 0) ? 1 : 0;
|
||||
if (sinEnd < 0) icase += 2;
|
||||
if (cosStart < 0) icase += 4;
|
||||
if (sinStart < 0) icase += 8;
|
||||
if (sinEnd < 0) { icase += 2; }
|
||||
if (cosStart < 0) { icase += 4; }
|
||||
if (sinStart < 0) { icase += 8; }
|
||||
|
||||
switch (icase)
|
||||
{
|
||||
// start quadrant 0
|
||||
case 0: // start->end : 0->0
|
||||
if (sinEnd < sinStart) break;
|
||||
if (sinEnd < sinStart) { break; }
|
||||
pmin.set(rmin*cosEnd,rmin*sinStart);
|
||||
pmax.set(rmax*cosStart,rmax*sinEnd );
|
||||
break;
|
||||
@@ -473,7 +475,7 @@ void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
pmax.set(rmax,std::max(rmax*sinStart,rmax*sinEnd));
|
||||
break;
|
||||
case 5: // start->end : 1->1
|
||||
if (sinEnd > sinStart) break;
|
||||
if (sinEnd > sinStart) { break; }
|
||||
pmin.set(rmax*cosEnd,rmin*sinEnd );
|
||||
pmax.set(rmin*cosStart,rmax*sinStart);
|
||||
break;
|
||||
@@ -495,7 +497,7 @@ void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
pmax.set(rmax,rmax);
|
||||
break;
|
||||
case 10: // start->end : 2->2
|
||||
if (sinEnd < sinStart) break;
|
||||
if (sinEnd < sinStart) { break; }
|
||||
pmin.set(rmin*cosStart,rmax*sinStart);
|
||||
pmax.set(rmax*cosEnd,rmin*sinEnd );
|
||||
break;
|
||||
@@ -517,7 +519,7 @@ void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
pmax.set(rmax*cosEnd,std::max(rmin*sinStart,rmin*sinEnd));
|
||||
break;
|
||||
case 15: // start->end : 3->3
|
||||
if (sinEnd > sinStart) break;
|
||||
if (sinEnd > sinStart) { break; }
|
||||
pmin.set(rmax*cosStart,rmax*sinEnd);
|
||||
pmax.set(rmin*cosEnd,rmin*sinStart);
|
||||
break;
|
||||
@@ -573,8 +575,8 @@ G4double G4GeomTools::comp_ellint_2(G4double e)
|
||||
|
||||
G4double a = 1.;
|
||||
G4double b = std::sqrt((1. - e)*(1. + e));
|
||||
if (b == 1.) return CLHEP::halfpi;
|
||||
if (b == 0.) return 1.;
|
||||
if (b == 1.) { return CLHEP::halfpi; }
|
||||
if (b == 0.) { return 1.; }
|
||||
|
||||
G4double x = 1.;
|
||||
G4double y = b;
|
||||
@@ -621,7 +623,7 @@ G4ThreeVector G4GeomTools::QuadAreaNormal(const G4ThreeVector& A,
|
||||
G4ThreeVector G4GeomTools::PolygonAreaNormal(const G4ThreeVectorList& p)
|
||||
{
|
||||
auto n = (G4int)p.size();
|
||||
if (n < 3) return {0,0,0}; // degerate polygon
|
||||
if (n < 3) { return {0,0,0}; } // degerate polygon
|
||||
G4ThreeVector normal = p[n-1].cross(p[0]);
|
||||
for(G4int i=1; i<n; ++i)
|
||||
{
|
||||
@@ -642,10 +644,10 @@ G4double G4GeomTools::DistancePointSegment(const G4ThreeVector& P,
|
||||
G4ThreeVector AB = B - A;
|
||||
|
||||
G4double u = AP.dot(AB);
|
||||
if (u <= 0) return AP.mag(); // closest point is A
|
||||
if (u <= 0) { return AP.mag(); } // closest point is A
|
||||
|
||||
G4double len2 = AB.mag2();
|
||||
if (u >= len2) return (B-P).mag(); // closest point is B
|
||||
if (u >= len2) { return (B-P).mag(); } // closest point is B
|
||||
|
||||
return ((u/len2)*AB - AP).mag(); // distance to line
|
||||
}
|
||||
@@ -663,10 +665,10 @@ G4GeomTools::ClosestPointOnSegment(const G4ThreeVector& P,
|
||||
G4ThreeVector AB = B - A;
|
||||
|
||||
G4double u = AP.dot(AB);
|
||||
if (u <= 0) return A; // closest point is A
|
||||
if (u <= 0) { return A; } // closest point is A
|
||||
|
||||
G4double len2 = AB.mag2();
|
||||
if (u >= len2) return B; // closest point is B
|
||||
if (u >= len2) { return B; } // closest point is B
|
||||
|
||||
G4double t = u/len2;
|
||||
return A + t*AB; // closest point on segment
|
||||
@@ -679,7 +681,7 @@ G4GeomTools::ClosestPointOnSegment(const G4ThreeVector& P,
|
||||
// The implementation is based on the algorithm published in
|
||||
// "Geometric Tools for Computer Graphics", Philip J Scheider and
|
||||
// David H Eberly, Elsevier Science (USA), 2003.
|
||||
//
|
||||
//
|
||||
// The algorithm is also available at:
|
||||
// http://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf
|
||||
|
||||
@@ -722,10 +724,11 @@ G4GeomTools::ClosestPointOnTriangle(const G4ThreeVector& P,
|
||||
*/
|
||||
|
||||
G4int region = -1;
|
||||
if (t0+t1 <= det)
|
||||
if (t0+t1 <= det) {
|
||||
region = (t0 < 0) ? ((t1 < 0) ? 4 : 3) : ((t1 < 0) ? 5 : 0);
|
||||
else
|
||||
} else {
|
||||
region = (t0 < 0) ? 2 : ((t1 < 0) ? 6 : 1);
|
||||
}
|
||||
|
||||
switch (region)
|
||||
{
|
||||
@@ -736,8 +739,8 @@ G4GeomTools::ClosestPointOnTriangle(const G4ThreeVector& P,
|
||||
}
|
||||
case 1: // edge BC
|
||||
{
|
||||
G4double numer = c + e - b - d;
|
||||
if (numer <= 0) return C;
|
||||
G4double numer = c + e - b - d;
|
||||
if (numer <= 0) { return C; }
|
||||
G4double denom = a - 2*b + c;
|
||||
return (numer >= denom) ? B : C + (numer/denom)*(edge0-edge1);
|
||||
}
|
||||
@@ -758,7 +761,7 @@ G4GeomTools::ClosestPointOnTriangle(const G4ThreeVector& P,
|
||||
return (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1);
|
||||
|
||||
case 4: // edge AB or AC
|
||||
if (d < 0) return (-d >= a) ? B : A + (-d/a)*edge0;
|
||||
if (d < 0) { return (-d >= a) ? B : A + (-d/a)*edge0; }
|
||||
return (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1);
|
||||
|
||||
case 5: // edge AB
|
||||
@@ -777,7 +780,7 @@ G4GeomTools::ClosestPointOnTriangle(const G4ThreeVector& P,
|
||||
// same: (d >= 0) ? A : ((-d >= a) ? B : A + (-d/a)*edge0)
|
||||
return (tmp1 <= 0) ? B : (( d >= 0) ? A : A + (-d/a)*edge0);
|
||||
}
|
||||
default: // impossible case
|
||||
default: // impossible case
|
||||
return {kInfinity,kInfinity,kInfinity};
|
||||
}
|
||||
}
|
||||
@@ -799,22 +802,22 @@ G4GeomTools::SphereExtent(G4double rmin, G4double rmax,
|
||||
//
|
||||
pmin.set(0,0,0);
|
||||
pmax.set(0,0,0);
|
||||
if (rmin < 0) return false;
|
||||
if (rmax <= rmin + kCarTolerance) return false;
|
||||
if (delTheta <= 0 + kCarTolerance) return false;
|
||||
if (delPhi <= 0 + kCarTolerance) return false;
|
||||
if (rmin < 0) { return false; }
|
||||
if (rmax <= rmin + kCarTolerance) { return false; }
|
||||
if (delTheta <= 0 + kCarTolerance) { return false; }
|
||||
if (delPhi <= 0 + kCarTolerance) { return false; }
|
||||
|
||||
G4double stheta = startTheta;
|
||||
G4double dtheta = delTheta;
|
||||
if (stheta < 0 && stheta > CLHEP::pi) return false;
|
||||
if (stheta + dtheta > CLHEP::pi) dtheta = CLHEP::pi - stheta;
|
||||
if (dtheta <= 0 + kCarTolerance) return false;
|
||||
if (stheta < 0 && stheta > CLHEP::pi) { return false; }
|
||||
if (stheta + dtheta > CLHEP::pi) { dtheta = CLHEP::pi - stheta; }
|
||||
if (dtheta <= 0 + kCarTolerance) { return false; }
|
||||
|
||||
// calculate extent
|
||||
//
|
||||
pmin.set(-rmax,-rmax,-rmax);
|
||||
pmax.set( rmax, rmax, rmax);
|
||||
if (dtheta >= CLHEP::pi && delPhi >= CLHEP::twopi) return true;
|
||||
if (dtheta >= CLHEP::pi && delPhi >= CLHEP::twopi) { return true; }
|
||||
|
||||
G4double etheta = stheta + dtheta;
|
||||
G4double sinStart = std::sin(stheta);
|
||||
@@ -824,8 +827,8 @@ G4GeomTools::SphereExtent(G4double rmin, G4double rmax,
|
||||
|
||||
G4double rhomin = rmin*std::min(sinStart,sinEnd);
|
||||
G4double rhomax = rmax;
|
||||
if (stheta > CLHEP::halfpi) rhomax = rmax*sinStart;
|
||||
if (etheta < CLHEP::halfpi) rhomax = rmax*sinEnd;
|
||||
if (stheta > CLHEP::halfpi) { rhomax = rmax*sinStart; }
|
||||
if (etheta < CLHEP::halfpi) { rhomax = rmax*sinEnd; }
|
||||
|
||||
G4TwoVector xymin,xymax;
|
||||
DiskExtent(rhomin,rhomax,
|
||||
@@ -839,3 +842,95 @@ G4GeomTools::SphereExtent(G4double rmin, G4double rmax,
|
||||
pmax.set(xymax.x(),xymax.y(),zmax);
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calculate hyperbolic surface stereo
|
||||
|
||||
G4double
|
||||
G4GeomTools::HypeStereo(G4double r0, G4double r, G4double h)
|
||||
{
|
||||
static const G4double kCarTolerance =
|
||||
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
if (std::abs(r - r0) < kCarTolerance) { return 0.; }
|
||||
return std::atan(std::sqrt((r - r0)*(r + r0))/std::abs(h));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find XY-coordinates of the corners of the bounding generic trap
|
||||
// for the specified twisted tube
|
||||
|
||||
void
|
||||
G4GeomTools::TwistedTubeBoundingTrap(G4double twistAng,
|
||||
G4double endInnerRad,
|
||||
G4double endOuterRad,
|
||||
G4double dPhi,
|
||||
G4TwoVectorList& vertices)
|
||||
{
|
||||
vertices.resize(8);
|
||||
G4double rmin = std::abs(endInnerRad);
|
||||
G4double rmax = std::abs(endOuterRad);
|
||||
|
||||
// Set untwisted vertices
|
||||
G4double phi = dPhi/2.;
|
||||
G4double sinphi = std::sin(phi);
|
||||
G4double cosphi = std::cos(phi);
|
||||
G4double tanphi = std::tan(phi);
|
||||
vertices[0].set(rmin*cosphi, rmin*sinphi);
|
||||
vertices[1].set(rmax, rmax*tanphi);
|
||||
vertices[2].set(rmax,-rmax*tanphi);
|
||||
vertices[3].set(rmin*cosphi,-rmin*sinphi);
|
||||
vertices[4] = vertices[0];
|
||||
vertices[5] = vertices[1];
|
||||
vertices[6] = vertices[2];
|
||||
vertices[7] = vertices[3];
|
||||
|
||||
// Twist vertices
|
||||
G4double ang = twistAng/2.;
|
||||
for(auto i = 0; i < 4; ++i)
|
||||
{
|
||||
vertices[i].rotate(-ang); // vertices at -halfz
|
||||
vertices[i + 4].rotate(ang); // vertices at +halfz
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calculate surface area of hyperboloid between zmin and zmax
|
||||
|
||||
G4double
|
||||
G4GeomTools::HyperboloidSurfaceArea(G4double dphi, G4double r0, G4double tanstereo,
|
||||
G4double zmin, G4double zmax)
|
||||
{
|
||||
static const G4double kCarTolerance =
|
||||
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
|
||||
G4double a = std::abs(r0); // radius at z = 0
|
||||
G4double t = std::abs(tanstereo); // tan(stereo)
|
||||
G4double phi = std::abs(dphi); // delta phi
|
||||
|
||||
// Check spesial cases: cylindrical and conical surfaces
|
||||
if (t < kCarTolerance) { return a*std::abs(zmax - zmin)*phi; } // cylinder
|
||||
G4double rmin = std::hypot(t*zmin, a); // radius at zmin
|
||||
G4double rmax = std::hypot(t*zmax, a); // radius at zmax
|
||||
if (a < kCarTolerance) // cone
|
||||
{
|
||||
G4double smin = rmin*std::hypot(rmin, zmin);
|
||||
G4double smax = rmax*std::hypot(rmax, zmax);
|
||||
return (zmin*zmax < 0.) ? (smin + smax)*phi/2. : std::abs(smax - smin)*phi/2.;
|
||||
}
|
||||
// Find surface area
|
||||
G4double tt = t*t;
|
||||
G4double aa = a*a;
|
||||
G4double cc = aa/tt;
|
||||
G4double k = std::sqrt(aa + cc)/cc;
|
||||
|
||||
G4double hmin = std::abs(zmin);
|
||||
G4double smin = a*(hmin*std::hypot(1., k*hmin) + std::asinh(k*hmin)/k);
|
||||
if (zmax == -zmin) { return smin*phi; }
|
||||
|
||||
G4double hmax = std::abs(zmax);
|
||||
G4double smax = a*(hmax*std::hypot(1., k*hmax) + std::asinh(k*hmax)/k);
|
||||
return (zmin*zmax < 0.) ? (smin + smax)*phi/2. :std::abs(smax - smin)*phi/2.;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace // Data structures / mutexes for parallel optimisation
|
||||
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = nullptr;
|
||||
|
||||
// Static *global* class data
|
||||
G4bool G4GeometryManager::fParallelVoxelOptimisationRequested = false;
|
||||
G4bool G4GeometryManager::fParallelVoxelOptimisationRequested = true;
|
||||
// Records User choice to use parallel voxel optimisation (or not)
|
||||
|
||||
G4bool G4GeometryManager::fOptimiseInParallelConfigured = false;
|
||||
|
||||
@@ -102,14 +102,14 @@ void G4LogicalCrystalVolume::SetMillerOrientation(G4int h,
|
||||
|
||||
G4ThreeVector norm = (h*GetBasis(0)+k*GetBasis(1)+l*GetBasis(2)).unit();
|
||||
|
||||
if (verboseLevel>1) G4cout << " norm = " << norm << G4endl;
|
||||
if (verboseLevel>1) { G4cout << " norm = " << norm << G4endl; }
|
||||
|
||||
// Aligns geometry +Z axis with lattice (hkl) normal
|
||||
fOrient = G4RotationMatrix::IDENTITY;
|
||||
fOrient.rotateZ(rot).rotateY(norm.theta()).rotateZ(norm.phi());
|
||||
fInverse = fOrient.inverse();
|
||||
|
||||
if (verboseLevel>1) G4cout << " fOrient = " << fOrient << G4endl;
|
||||
if (verboseLevel>1) { G4cout << " fOrient = " << fOrient << G4endl; }
|
||||
|
||||
// FIXME: Is this equivalent to (phi,theta,rot) Euler angles???
|
||||
}
|
||||
|
||||
@@ -512,10 +512,11 @@ G4LogicalVolume::IsAncestor(const G4VPhysicalVolume* aVolume) const
|
||||
G4bool isDaughter = IsDaughter(aVolume);
|
||||
if (!isDaughter)
|
||||
{
|
||||
for (auto itDau = fDaughters.cbegin(); itDau != fDaughters.cend(); ++itDau)
|
||||
for (const auto & daughter : fDaughters)
|
||||
{
|
||||
isDaughter = (*itDau)->GetLogicalVolume()->IsAncestor(aVolume);
|
||||
if (isDaughter) break;
|
||||
isDaughter = daughter->GetLogicalVolume()->IsAncestor(aVolume);
|
||||
if (isDaughter) { break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isDaughter;
|
||||
@@ -531,9 +532,8 @@ G4LogicalVolume::IsAncestor(const G4VPhysicalVolume* aVolume) const
|
||||
G4int G4LogicalVolume::TotalVolumeEntities() const
|
||||
{
|
||||
G4int vols = 1;
|
||||
for (auto itDau = fDaughters.cbegin(); itDau != fDaughters.cend(); ++itDau)
|
||||
for (auto physDaughter : fDaughters)
|
||||
{
|
||||
G4VPhysicalVolume* physDaughter = (*itDau);
|
||||
vols += physDaughter->GetMultiplicity()
|
||||
*physDaughter->GetLogicalVolume()->TotalVolumeEntities();
|
||||
}
|
||||
@@ -599,9 +599,8 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
|
||||
// and if required by the propagate flag, add the real daughter's
|
||||
// one computed recursively
|
||||
|
||||
for (auto itDau = fDaughters.cbegin(); itDau != fDaughters.cend(); ++itDau)
|
||||
for (const auto & physDaughter : fDaughters)
|
||||
{
|
||||
G4VPhysicalVolume* physDaughter = (*itDau);
|
||||
G4LogicalVolume* logDaughter = physDaughter->GetLogicalVolume();
|
||||
G4double subMass = 0.0;
|
||||
G4VSolid* daughterSolid = nullptr;
|
||||
@@ -679,7 +678,8 @@ G4bool G4LogicalVolume::ChangeDaughtersType(EVolume aType)
|
||||
//
|
||||
void G4LogicalVolume::SetVisAttributes (const G4VisAttributes& VA)
|
||||
{
|
||||
if (G4Threading::IsWorkerThread()) return;
|
||||
if (G4Threading::IsWorkerThread()) { return;
|
||||
}
|
||||
fVisAttributes = std::make_shared<const G4VisAttributes>(VA);
|
||||
}
|
||||
|
||||
@@ -689,6 +689,7 @@ void G4LogicalVolume::SetVisAttributes (const G4VisAttributes& VA)
|
||||
//
|
||||
void G4LogicalVolume::SetVisAttributes (const G4VisAttributes* pVA)
|
||||
{
|
||||
if (G4Threading::IsWorkerThread()) return;
|
||||
if (G4Threading::IsWorkerThread()) { return;
|
||||
}
|
||||
fVisAttributes = std::shared_ptr<const G4VisAttributes>(pVA,[](const G4VisAttributes*){});
|
||||
}
|
||||
|
||||
@@ -90,10 +90,10 @@ void G4LogicalVolumeStore::Clean()
|
||||
|
||||
G4LogicalVolumeStore* store = GetInstance();
|
||||
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
for(const auto & pos : *store)
|
||||
{
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos != nullptr) { (*pos)->Lock(); delete *pos; }
|
||||
if (pos != nullptr) { pos->Lock(); delete pos; }
|
||||
}
|
||||
|
||||
store->bmap.clear(); store->mvalid = false;
|
||||
@@ -118,19 +118,19 @@ void G4LogicalVolumeStore::SetNotifier(G4VStoreNotifier* pNotifier)
|
||||
void G4LogicalVolumeStore::UpdateMap()
|
||||
{
|
||||
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
|
||||
if (mvalid) return;
|
||||
if (mvalid) { return; }
|
||||
bmap.clear();
|
||||
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
|
||||
for(const auto & pos : *GetInstance())
|
||||
{
|
||||
const G4String& vol_name = (*pos)->GetName();
|
||||
const G4String& vol_name = pos->GetName();
|
||||
auto it = bmap.find(vol_name);
|
||||
if (it != bmap.cend())
|
||||
{
|
||||
it->second.push_back(*pos);
|
||||
it->second.push_back(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<G4LogicalVolume*> vol_vec { *pos };
|
||||
std::vector<G4LogicalVolume*> vol_vec { pos };
|
||||
bmap.insert(std::make_pair(vol_name, vol_vec));
|
||||
}
|
||||
}
|
||||
@@ -228,10 +228,7 @@ G4LogicalVolumeStore::GetVolume(const G4String& name, G4bool verbose,
|
||||
{
|
||||
return pos->second[pos->second.size()-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return pos->second[0];
|
||||
}
|
||||
return pos->second[0];
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
|
||||
@@ -92,10 +92,10 @@ void G4PhysicalVolumeStore::Clean()
|
||||
|
||||
G4PhysicalVolumeStore* store = GetInstance();
|
||||
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
for(const auto & pos : *store)
|
||||
{
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
delete *pos;
|
||||
delete pos;
|
||||
}
|
||||
|
||||
store->bmap.clear(); store->mvalid = false;
|
||||
@@ -120,19 +120,19 @@ void G4PhysicalVolumeStore::SetNotifier(G4VStoreNotifier* pNotifier)
|
||||
void G4PhysicalVolumeStore::UpdateMap()
|
||||
{
|
||||
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
|
||||
if (mvalid) return;
|
||||
if (mvalid) { return; }
|
||||
bmap.clear();
|
||||
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
|
||||
for(const auto & pos : *GetInstance())
|
||||
{
|
||||
const G4String& vol_name = (*pos)->GetName();
|
||||
const G4String& vol_name = pos->GetName();
|
||||
auto it = bmap.find(vol_name);
|
||||
if (it != bmap.cend())
|
||||
{
|
||||
it->second.push_back(*pos);
|
||||
it->second.push_back(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<G4VPhysicalVolume*> vol_vec { *pos };
|
||||
std::vector<G4VPhysicalVolume*> vol_vec { pos };
|
||||
bmap.insert(std::make_pair(vol_name, vol_vec));
|
||||
}
|
||||
}
|
||||
@@ -233,10 +233,7 @@ G4PhysicalVolumeStore::GetVolume(const G4String& name, G4bool verbose,
|
||||
{
|
||||
return pos->second[pos->second.size()-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return pos->second[0];
|
||||
}
|
||||
return pos->second[0];
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
|
||||
@@ -454,16 +454,13 @@ G4ReflectedSolid::CreatePolyhedron () const
|
||||
polyhedron->Transform(*fDirectTransform3D);
|
||||
return polyhedron;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Solid - " << GetName()
|
||||
<< " - original solid has no" << G4endl
|
||||
<< "corresponding polyhedron. Returning NULL!";
|
||||
G4Exception("G4ReflectedSolid::CreatePolyhedron()",
|
||||
"GeomMgt1001", JustWarning, message);
|
||||
return nullptr;
|
||||
}
|
||||
std::ostringstream message;
|
||||
message << "Solid - " << GetName()
|
||||
<< " - original solid has no" << G4endl
|
||||
<< "corresponding polyhedron. Returning NULL!";
|
||||
G4Exception("G4ReflectedSolid::CreatePolyhedron()",
|
||||
"GeomMgt1001", JustWarning, message);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
@@ -65,7 +65,6 @@ const G4RegionManager& G4Region::GetSubInstanceManager()
|
||||
G4Region::G4Region(const G4String& pName)
|
||||
: fName(pName)
|
||||
{
|
||||
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
G4MT_fsmanager = nullptr;
|
||||
G4MT_rsaction = nullptr;
|
||||
@@ -205,7 +204,7 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
|
||||
|
||||
// Stop recursion here if no further daughters are involved
|
||||
//
|
||||
if(noDaughters==0) return;
|
||||
if(noDaughters==0) { return; }
|
||||
|
||||
G4VPhysicalVolume* daughterPVol = lv->GetDaughter(0);
|
||||
if (daughterPVol->IsParameterised())
|
||||
@@ -397,9 +396,9 @@ void G4Region::UpdateMaterialList()
|
||||
// Loop over the root logical volumes and rebuild the list
|
||||
// of materials from scratch
|
||||
//
|
||||
for (auto pLV=fRootVolumes.cbegin(); pLV!=fRootVolumes.cend(); ++pLV)
|
||||
for (const auto & rootVolume : fRootVolumes)
|
||||
{
|
||||
ScanVolumeTree(*pLV, true);
|
||||
ScanVolumeTree(rootVolume, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,9 +411,13 @@ void G4Region::UpdateMaterialList()
|
||||
void G4Region::SetWorld(G4VPhysicalVolume* wp)
|
||||
{
|
||||
if(wp == nullptr)
|
||||
{ fWorldPhys = nullptr; }
|
||||
{
|
||||
fWorldPhys = nullptr;
|
||||
}
|
||||
else
|
||||
{ if(BelongsTo(wp)) fWorldPhys = wp; }
|
||||
{
|
||||
if(BelongsTo(wp)) { fWorldPhys = wp; }
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -487,16 +490,16 @@ G4Region* G4Region::GetParentRegion(G4bool& unique) const
|
||||
|
||||
// Loop over all logical volumes in the store
|
||||
//
|
||||
for(auto lvItr=lvStore->cbegin(); lvItr!=lvStore->cend(); ++lvItr)
|
||||
for(const auto & lvol : *lvStore)
|
||||
{
|
||||
std::size_t nD = (*lvItr)->GetNoDaughters();
|
||||
G4Region* aR = (*lvItr)->GetRegion();
|
||||
std::size_t nD = lvol->GetNoDaughters();
|
||||
G4Region* aR = lvol->GetRegion();
|
||||
|
||||
// Loop over all daughters of each logical volume
|
||||
//
|
||||
for(std::size_t iD=0; iD<nD; ++iD)
|
||||
{
|
||||
if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
|
||||
if(lvol->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
|
||||
{
|
||||
if(parent != nullptr)
|
||||
{
|
||||
|
||||
@@ -93,10 +93,10 @@ void G4RegionStore::Clean()
|
||||
|
||||
G4RegionStore* store = GetInstance();
|
||||
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
for(const auto & pos : *store)
|
||||
{
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
delete *pos;
|
||||
delete pos;
|
||||
}
|
||||
|
||||
store->bmap.clear(); store->mvalid = false;
|
||||
@@ -121,19 +121,19 @@ void G4RegionStore::SetNotifier(G4VStoreNotifier* pNotifier)
|
||||
void G4RegionStore::UpdateMap()
|
||||
{
|
||||
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
|
||||
if (mvalid) return;
|
||||
if (mvalid) { return; }
|
||||
bmap.clear();
|
||||
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
|
||||
for(const auto & pos : *GetInstance())
|
||||
{
|
||||
const G4String& reg_name = (*pos)->GetName();
|
||||
const G4String& reg_name = pos->GetName();
|
||||
auto it = bmap.find(reg_name);
|
||||
if (it != bmap.cend())
|
||||
{
|
||||
it->second.push_back(*pos);
|
||||
it->second.push_back(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<G4Region*> reg_vec { *pos };
|
||||
std::vector<G4Region*> reg_vec { pos };
|
||||
bmap.insert(std::make_pair(reg_name, reg_vec));
|
||||
}
|
||||
}
|
||||
@@ -226,9 +226,9 @@ G4RegionStore* G4RegionStore::GetInstance()
|
||||
//
|
||||
G4bool G4RegionStore::IsModified() const
|
||||
{
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
for (const auto & i : *GetInstance())
|
||||
{
|
||||
if ((*i)->IsModified()) { return true; }
|
||||
if (i->IsModified()) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -240,9 +240,9 @@ G4bool G4RegionStore::IsModified() const
|
||||
//
|
||||
void G4RegionStore::ResetRegionModified()
|
||||
{
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
for (const auto & i : *GetInstance())
|
||||
{
|
||||
(*i)->RegionModified(false);
|
||||
i->RegionModified(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,11 +252,11 @@ void G4RegionStore::ResetRegionModified()
|
||||
//
|
||||
void G4RegionStore::UpdateMaterialList(G4VPhysicalVolume* currentWorld)
|
||||
{
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
for (const auto & i : *GetInstance())
|
||||
{
|
||||
if((*i)->IsInMassGeometry() || (*i)->IsInParallelGeometry()
|
||||
if(i->IsInMassGeometry() || i->IsInParallelGeometry()
|
||||
|| (currentWorld != nullptr))
|
||||
{ (*i)->UpdateMaterialList(); }
|
||||
{ i->UpdateMaterialList(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +319,8 @@ void G4RegionStore::SetWorldVolume()
|
||||
{
|
||||
// Reset all pointers first
|
||||
//
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{ (*i)->SetWorld(nullptr); }
|
||||
for (const auto & i : *GetInstance())
|
||||
{ i->SetWorld(nullptr); }
|
||||
|
||||
// Find world volumes
|
||||
//
|
||||
@@ -334,8 +334,8 @@ void G4RegionStore::SetWorldVolume()
|
||||
|
||||
// Now 'fPhys' is a world volume, set it to regions that belong to it.
|
||||
//
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{ (*i)->SetWorld(fPhys); }
|
||||
for (const auto & i : *GetInstance())
|
||||
{ i->SetWorld(fPhys); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,14 +195,11 @@ G4bool G4SmartVoxelHeader::operator == (const G4SmartVoxelHeader& pHead) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
leftHeader = leftProxy->GetHeader();
|
||||
rightHeader = rightProxy->GetHeader();
|
||||
if (!(*leftHeader == *rightHeader))
|
||||
{
|
||||
leftHeader = leftProxy->GetHeader();
|
||||
rightHeader = rightProxy->GetHeader();
|
||||
if (!(*leftHeader == *rightHeader))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -211,23 +208,18 @@ G4bool G4SmartVoxelHeader::operator == (const G4SmartVoxelHeader& pHead) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
leftNode = leftProxy->GetNode();
|
||||
rightNode = rightProxy->GetNode();
|
||||
if (!(*leftNode == *rightNode))
|
||||
{
|
||||
leftNode = leftProxy->GetNode();
|
||||
rightNode = rightProxy->GetNode();
|
||||
if (!(*leftNode == *rightNode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
@@ -127,7 +127,7 @@ void G4SmartVoxelStat::CountHeadsAndNodes( const G4SmartVoxelHeader* head )
|
||||
for(std::size_t i=0; i<numSlices; ++i)
|
||||
{
|
||||
const G4SmartVoxelProxy *proxy = head->GetSlice(i);
|
||||
if (proxy == lastProxy) continue;
|
||||
if (proxy == lastProxy) { continue; }
|
||||
|
||||
lastProxy = proxy;
|
||||
|
||||
|
||||
@@ -89,10 +89,10 @@ void G4SolidStore::Clean()
|
||||
|
||||
G4SolidStore* store = GetInstance();
|
||||
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
for(const auto & pos : *store)
|
||||
{
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
delete *pos;
|
||||
delete pos;
|
||||
}
|
||||
|
||||
store->bmap.clear(); store->mvalid = false;
|
||||
@@ -117,19 +117,19 @@ void G4SolidStore::SetNotifier(G4VStoreNotifier* pNotifier)
|
||||
void G4SolidStore::UpdateMap()
|
||||
{
|
||||
G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
|
||||
if (mvalid) return;
|
||||
if (mvalid) { return; }
|
||||
bmap.clear();
|
||||
for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
|
||||
for(const auto & pos : *GetInstance())
|
||||
{
|
||||
const G4String& sol_name = (*pos)->GetName();
|
||||
const G4String& sol_name = pos->GetName();
|
||||
auto it = bmap.find(sol_name);
|
||||
if (it != bmap.cend())
|
||||
{
|
||||
it->second.push_back(*pos);
|
||||
it->second.push_back(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<G4VSolid*> sol_vec { *pos };
|
||||
std::vector<G4VSolid*> sol_vec { pos };
|
||||
bmap.insert(std::make_pair(sol_name, sol_vec));
|
||||
}
|
||||
}
|
||||
@@ -227,10 +227,7 @@ G4VSolid* G4SolidStore::GetSolid(const G4String& name, G4bool verbose,
|
||||
{
|
||||
return pos->second[pos->second.size()-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return pos->second[0];
|
||||
}
|
||||
return pos->second[0];
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
|
||||
@@ -65,12 +65,8 @@ G4TouchableHistory::GetTranslation(G4int depth) const
|
||||
{
|
||||
return ftlate;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ctrans =
|
||||
fhistory.GetTransform(CalculateHistoryIndex(depth)).NetTranslation();
|
||||
return *ctrans;
|
||||
}
|
||||
*ctrans = fhistory.GetTransform(CalculateHistoryIndex(depth)).NetTranslation();
|
||||
return *ctrans;
|
||||
}
|
||||
|
||||
const G4RotationMatrix*
|
||||
@@ -86,9 +82,6 @@ G4TouchableHistory::GetRotation(G4int depth) const
|
||||
{
|
||||
return &frot;
|
||||
}
|
||||
else
|
||||
{
|
||||
*rotM = fhistory.GetTransform(CalculateHistoryIndex(depth)).NetRotation();
|
||||
return rotM;
|
||||
}
|
||||
*rotM = fhistory.GetTransform(CalculateHistoryIndex(depth)).NetRotation();
|
||||
return rotM;
|
||||
}
|
||||
|
||||
@@ -224,22 +224,20 @@ G4double G4VSolid::EstimateCubicVolume(G4int nStat, G4double epsilon) const
|
||||
EInside in;
|
||||
|
||||
// values needed for CalculateExtent signature
|
||||
|
||||
G4VoxelLimits limit; // Unlimited
|
||||
G4VoxelLimits limit; // unlimited
|
||||
G4AffineTransform origin;
|
||||
|
||||
// min max extents of pSolid along X,Y,Z
|
||||
|
||||
CalculateExtent(kXAxis,limit,origin,minX,maxX);
|
||||
CalculateExtent(kYAxis,limit,origin,minY,maxY);
|
||||
CalculateExtent(kZAxis,limit,origin,minZ,maxZ);
|
||||
|
||||
// limits
|
||||
|
||||
if(nStat < 100) { nStat = 100; }
|
||||
if(epsilon > 0.01) { epsilon = 0.01; }
|
||||
halfepsilon = 0.5*epsilon;
|
||||
|
||||
G4QuickRand(1234567890); // set seed
|
||||
for(auto i = 0; i < nStat; ++i )
|
||||
{
|
||||
px = minX-halfepsilon+(maxX-minX+epsilon)*G4QuickRand();
|
||||
@@ -350,6 +348,7 @@ G4double G4VSolid::EstimateSurfaceArea(G4int nstat, G4double ell) const
|
||||
|
||||
// Calculate surface area
|
||||
//
|
||||
G4QuickRand(1234567890); // set seed
|
||||
G4int icount = 0;
|
||||
for(auto i = 0; i < npoints; ++i)
|
||||
{
|
||||
|
||||
@@ -43,20 +43,20 @@ void G4VoxelLimits::AddLimit( const EAxis pAxis,
|
||||
{
|
||||
if ( pAxis == kXAxis )
|
||||
{
|
||||
if ( pMin > fxAxisMin ) fxAxisMin = pMin ;
|
||||
if ( pMax < fxAxisMax ) fxAxisMax = pMax ;
|
||||
if ( pMin > fxAxisMin ) { fxAxisMin = pMin ; }
|
||||
if ( pMax < fxAxisMax ) { fxAxisMax = pMax ; }
|
||||
}
|
||||
else if ( pAxis == kYAxis )
|
||||
{
|
||||
if ( pMin > fyAxisMin ) fyAxisMin = pMin ;
|
||||
if ( pMax < fyAxisMax ) fyAxisMax = pMax ;
|
||||
if ( pMin > fyAxisMin ) { fyAxisMin = pMin ; }
|
||||
if ( pMax < fyAxisMax ) { fyAxisMax = pMax ; }
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( pAxis == kZAxis ) ;
|
||||
|
||||
if ( pMin > fzAxisMin ) fzAxisMin = pMin ;
|
||||
if ( pMax < fzAxisMax ) fzAxisMax = pMax ;
|
||||
if ( pMin > fzAxisMin ) { fzAxisMin = pMin ; }
|
||||
if ( pMax < fzAxisMax ) { fzAxisMax = pMax ; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,18 +223,18 @@ G4int G4VoxelLimits::OutCode( const G4ThreeVector& pVec ) const
|
||||
|
||||
if ( IsXLimited() )
|
||||
{
|
||||
if ( pVec.x() < fxAxisMin ) code |= 0x01 ;
|
||||
if ( pVec.x() > fxAxisMax ) code |= 0x02 ;
|
||||
if ( pVec.x() < fxAxisMin ) { code |= 0x01 ; }
|
||||
if ( pVec.x() > fxAxisMax ) { code |= 0x02 ; }
|
||||
}
|
||||
if ( IsYLimited() )
|
||||
{
|
||||
if ( pVec.y() < fyAxisMin ) code |= 0x04 ;
|
||||
if ( pVec.y() > fyAxisMax ) code |= 0x08 ;
|
||||
if ( pVec.y() < fyAxisMin ) { code |= 0x04 ; }
|
||||
if ( pVec.y() > fyAxisMax ) { code |= 0x08 ; }
|
||||
}
|
||||
if (IsZLimited())
|
||||
{
|
||||
if ( pVec.z() < fzAxisMin ) code |= 0x10 ;
|
||||
if ( pVec.z() > fzAxisMax ) code |= 0x20 ;
|
||||
if ( pVec.z() < fzAxisMin ) { code |= 0x10 ; }
|
||||
if ( pVec.z() > fzAxisMax ) { code |= 0x20 ; }
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user