Import Geant4 11.1.0.beta source tree
This commit is contained in:
@@ -67,16 +67,16 @@ G4BoundingEnvelope(const std::vector<const G4ThreeVectorList*>& polygons)
|
||||
G4double xmin = kInfinity, ymin = kInfinity, zmin = kInfinity;
|
||||
G4double xmax = -kInfinity, ymax = -kInfinity, zmax = -kInfinity;
|
||||
for (auto ibase = fPolygons->cbegin(); ibase != fPolygons->cend(); ++ibase)
|
||||
{
|
||||
{
|
||||
for (auto ipoint = (*ibase)->cbegin(); ipoint != (*ibase)->cend(); ++ipoint)
|
||||
{
|
||||
G4double x = ipoint->x();
|
||||
G4double x = ipoint->x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
G4double y = ipoint->y();
|
||||
G4double y = ipoint->y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
G4double z = ipoint->z();
|
||||
G4double z = ipoint->z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ G4BoundingEnvelope( const G4ThreeVector& pMin,
|
||||
: fMin(pMin), fMax(pMax), fPolygons(&polygons)
|
||||
{
|
||||
// Check correctness of bounding box and polygons
|
||||
//
|
||||
//
|
||||
CheckBoundingBox();
|
||||
CheckBoundingPolygons();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ void G4BoundingEnvelope::CheckBoundingBox()
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Badly defined bounding box (min >= max)!"
|
||||
<< "\npMin = " << fMin
|
||||
<< "\npMin = " << fMin
|
||||
<< "\npMax = " << fMax;
|
||||
G4Exception("G4BoundingEnvelope::CheckBoundingBox()",
|
||||
"GeomMgt0001", JustWarning, message);
|
||||
@@ -135,7 +135,7 @@ void G4BoundingEnvelope::CheckBoundingPolygons()
|
||||
std::ostringstream message;
|
||||
message << "Wrong number of polygons in the sequence: " << nbases
|
||||
<< "\nShould be at least two!";
|
||||
G4Exception("G4BoundingEnvelope::CheckBoundingPolygons()",
|
||||
G4Exception("G4BoundingEnvelope::CheckBoundingPolygons()",
|
||||
"GeomMgt0001", FatalException, message);
|
||||
return;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ void G4BoundingEnvelope::CheckBoundingPolygons()
|
||||
<< "\nPolygon #0 size: " << (*fPolygons)[0]->size()
|
||||
<< "\nPolygon #1 size: " << (*fPolygons)[1]->size()
|
||||
<< "\n...";
|
||||
G4Exception("G4BoundingEnvelope::CheckBoundingPolygons()",
|
||||
G4Exception("G4BoundingEnvelope::CheckBoundingPolygons()",
|
||||
"GeomMgt0001", FatalException, message);
|
||||
return;
|
||||
}
|
||||
@@ -165,10 +165,10 @@ void G4BoundingEnvelope::CheckBoundingPolygons()
|
||||
<< "\nNumber of polygons: " << nbases
|
||||
<< "\nPolygon #" << k << " size: " << np
|
||||
<< "\nexpected size: " << nsize;
|
||||
G4Exception("G4BoundingEnvelope::SetBoundingPolygons()",
|
||||
G4Exception("G4BoundingEnvelope::SetBoundingPolygons()",
|
||||
"GeomMgt0001", FatalException, message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@@ -218,7 +218,7 @@ BoundingBoxVsVoxelLimits(const EAxis pAxis,
|
||||
{
|
||||
pMin = (xmin-kCarTolerance < xminlim) ? xminlim : xmin;
|
||||
pMax = (xmax+kCarTolerance > xmaxlim) ? xmaxlim : xmax;
|
||||
}
|
||||
}
|
||||
else if (pAxis == kYAxis)
|
||||
{
|
||||
pMin = (ymin-kCarTolerance < yminlim) ? yminlim : ymin;
|
||||
@@ -235,11 +235,11 @@ BoundingBoxVsVoxelLimits(const EAxis pAxis,
|
||||
}
|
||||
}
|
||||
|
||||
// Find max scale factor of the transformation, set delta
|
||||
// Find max scale factor of the transformation, set delta
|
||||
// equal to kCarTolerance multiplied by the scale factor
|
||||
//
|
||||
G4double scale = FindScaleFactor(pTransform3D);
|
||||
G4double delta = kCarTolerance*scale;
|
||||
G4double delta = kCarTolerance*scale;
|
||||
|
||||
// Set the sphere surrounding the bounding box
|
||||
//
|
||||
@@ -301,7 +301,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
{
|
||||
pMin = (xmin-kCarTolerance < xminlim) ? xminlim : xmin;
|
||||
pMax = (xmax+kCarTolerance > xmaxlim) ? xmaxlim : xmax;
|
||||
}
|
||||
}
|
||||
else if (pAxis == kYAxis)
|
||||
{
|
||||
pMin = (ymin-kCarTolerance < yminlim) ? yminlim : ymin;
|
||||
@@ -318,11 +318,11 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
}
|
||||
}
|
||||
|
||||
// Find max scale factor of the transformation, set delta
|
||||
// Find max scale factor of the transformation, set delta
|
||||
// equal to kCarTolerance multiplied by the scale factor
|
||||
//
|
||||
G4double scale = FindScaleFactor(pTransform3D);
|
||||
G4double delta = kCarTolerance*scale;
|
||||
G4double delta = kCarTolerance*scale;
|
||||
|
||||
// Set the sphere surrounding the bounding box
|
||||
//
|
||||
@@ -338,28 +338,28 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
{
|
||||
G4double cx, cy, cz, cd;
|
||||
if (pAxis == kXAxis)
|
||||
{
|
||||
cx = pTransform3D.xx();
|
||||
{
|
||||
cx = pTransform3D.xx();
|
||||
cy = pTransform3D.xy();
|
||||
cz = pTransform3D.xz();
|
||||
cd = pTransform3D.dx();
|
||||
}
|
||||
else if (pAxis == kYAxis)
|
||||
{
|
||||
cx = pTransform3D.yx();
|
||||
{
|
||||
cx = pTransform3D.yx();
|
||||
cy = pTransform3D.yy();
|
||||
cz = pTransform3D.yz();
|
||||
cd = pTransform3D.dy();
|
||||
}
|
||||
else if (pAxis == kZAxis)
|
||||
{
|
||||
cx = pTransform3D.zx();
|
||||
{
|
||||
cx = pTransform3D.zx();
|
||||
cy = pTransform3D.zy();
|
||||
cz = pTransform3D.zz();
|
||||
cd = pTransform3D.dz();
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
cx = cy = cz = cd = kInfinity;
|
||||
}
|
||||
G4double emin = kInfinity, emax = -kInfinity;
|
||||
@@ -394,7 +394,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
else
|
||||
{
|
||||
for (auto ibase=fPolygons->cbegin(); ibase!=fPolygons->cend(); ++ibase)
|
||||
{
|
||||
{
|
||||
for (auto ipoint=(*ibase)->cbegin(); ipoint!=(*ibase)->cend(); ++ipoint)
|
||||
{
|
||||
G4double coor = ipoint->x()*cx + ipoint->y()*cy + ipoint->z()*cz + cd;
|
||||
@@ -406,7 +406,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
pMin = emin - delta;
|
||||
pMax = emax + delta;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the sphere surrounding the bounding box is outside
|
||||
// the voxel limits
|
||||
@@ -418,33 +418,19 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
if (center.y()+radius < yminlim) return false;
|
||||
if (center.z()+radius < zminlim) return false;
|
||||
|
||||
// Allocate memory for transformed polygons
|
||||
// Transform polygons
|
||||
//
|
||||
G4int nbases = (fPolygons == nullptr) ? 2 : fPolygons->size();
|
||||
std::vector<G4Polygon3D*> bases(nbases);
|
||||
if (fPolygons == nullptr)
|
||||
{
|
||||
bases[0] = new G4Polygon3D(4);
|
||||
bases[1] = new G4Polygon3D(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (G4int i=0; i<nbases; ++i)
|
||||
{
|
||||
bases[i] = new G4Polygon3D((*fPolygons)[i]->size());
|
||||
}
|
||||
}
|
||||
std::vector<G4Point3D> vertices;
|
||||
std::vector<std::pair<G4int, G4int>> bases;
|
||||
TransformVertices(pTransform3D, vertices, bases);
|
||||
G4int nbases = bases.size();
|
||||
|
||||
// Transform vertices
|
||||
//
|
||||
TransformVertices(pTransform3D, bases);
|
||||
|
||||
// Create adjusted G4VoxelLimits box. New limits are extended by
|
||||
// Create adjusted G4VoxelLimits box. New limits are extended by
|
||||
// delta, kCarTolerance multiplied by max scale factor of
|
||||
// the transformation
|
||||
//
|
||||
EAxis axis[] = { kXAxis,kYAxis,kZAxis };
|
||||
G4VoxelLimits limits; // default is unlimited
|
||||
EAxis axis[] = { kXAxis, kYAxis, kZAxis };
|
||||
G4VoxelLimits limits; // default is unlimited
|
||||
for (auto i=0; i<3; ++i)
|
||||
{
|
||||
if (pVoxelLimits.IsLimited(axis[i]))
|
||||
@@ -457,16 +443,23 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
|
||||
// Main loop along the set of prisms
|
||||
//
|
||||
G4Polygon3D baseA, baseB;
|
||||
G4Segment3D extent;
|
||||
extent.first = G4Point3D( kInfinity, kInfinity, kInfinity);
|
||||
extent.second = G4Point3D(-kInfinity,-kInfinity,-kInfinity);
|
||||
for (G4int k=0; k<nbases-1; ++k)
|
||||
{
|
||||
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
|
||||
G4Polygon3D* baseA = bases[k];
|
||||
G4Polygon3D* baseB = bases[k+1];
|
||||
G4Segment3D prismAABB;
|
||||
GetPrismAABB(*baseA, *baseB, prismAABB);
|
||||
GetPrismAABB(baseA, baseB, prismAABB);
|
||||
|
||||
// Check if prismAABB is completely within the voxel limits
|
||||
if (prismAABB.first.x() >= limits.GetMinXExtent() &&
|
||||
@@ -474,21 +467,21 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
prismAABB.first.z() >= limits.GetMinZExtent() &&
|
||||
prismAABB.second.x()<= limits.GetMaxXExtent() &&
|
||||
prismAABB.second.y()<= limits.GetMaxYExtent() &&
|
||||
prismAABB.second.z()<= limits.GetMaxZExtent())
|
||||
prismAABB.second.z()<= limits.GetMaxZExtent())
|
||||
{
|
||||
if (extent.first.x() > prismAABB.first.x())
|
||||
extent.first.setX( prismAABB.first.x() );
|
||||
extent.first.setX( prismAABB.first.x() );
|
||||
if (extent.first.y() > prismAABB.first.y())
|
||||
extent.first.setY( prismAABB.first.y() );
|
||||
extent.first.setY( prismAABB.first.y() );
|
||||
if (extent.first.z() > prismAABB.first.z())
|
||||
extent.first.setZ( prismAABB.first.z() );
|
||||
extent.first.setZ( prismAABB.first.z() );
|
||||
if (extent.second.x() < prismAABB.second.x())
|
||||
extent.second.setX(prismAABB.second.x());
|
||||
extent.second.setX(prismAABB.second.x());
|
||||
if (extent.second.y() < prismAABB.second.y())
|
||||
extent.second.setY(prismAABB.second.y());
|
||||
extent.second.setY(prismAABB.second.y());
|
||||
if (extent.second.z() < prismAABB.second.z())
|
||||
extent.second.setZ(prismAABB.second.z());
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if prismAABB is outside the voxel limits
|
||||
@@ -500,13 +493,13 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
if (prismAABB.second.z() < limits.GetMinZExtent()) continue;
|
||||
|
||||
// Clip edges of the prism by adjusted G4VoxelLimits box
|
||||
std::vector<G4Segment3D> vecEdges;
|
||||
CreateListOfEdges(*baseA, *baseB, vecEdges);
|
||||
std::vector<G4Segment3D> vecEdges;
|
||||
CreateListOfEdges(baseA, baseB, vecEdges);
|
||||
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
|
||||
// by the prism
|
||||
G4int bits = 0x000;
|
||||
if (limits.GetMinXExtent() < prismAABB.first.x())
|
||||
bits |= 0x988; // 1001 1000 1000
|
||||
@@ -524,17 +517,13 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
bits |= 0x0F0; // 0000 1111 0000
|
||||
if (bits == 0xFFF) continue;
|
||||
|
||||
std::vector<G4Plane3D> vecPlanes;
|
||||
CreateListOfPlanes(*baseA, *baseB, vecPlanes);
|
||||
std::vector<G4Plane3D> vecPlanes;
|
||||
CreateListOfPlanes(baseA, baseB, vecPlanes);
|
||||
ClipVoxelByPlanes(bits, limits, vecPlanes, prismAABB, extent);
|
||||
} // End of the main loop
|
||||
|
||||
// Free memory
|
||||
//
|
||||
for (G4int i=0; i<nbases; ++i) { delete bases[i]; bases[i] = nullptr; }
|
||||
|
||||
// Final adjustment of the extent
|
||||
//
|
||||
//
|
||||
G4double emin = 0, emax = 0;
|
||||
if (pAxis == kXAxis) { emin = extent.first.x(); emax = extent.second.x(); }
|
||||
if (pAxis == kYAxis) { emin = extent.first.y(); emax = extent.second.y(); }
|
||||
@@ -550,7 +539,6 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find max scale factor of the transformation
|
||||
@@ -583,12 +571,15 @@ G4BoundingEnvelope::FindScaleFactor(const G4Transform3D& pTransform3D) const
|
||||
// Transform polygonal bases
|
||||
//
|
||||
void
|
||||
G4BoundingEnvelope::TransformVertices(const G4Transform3D& pTransform3D,
|
||||
std::vector<G4Polygon3D*>& pBases) const
|
||||
G4BoundingEnvelope::
|
||||
TransformVertices(const G4Transform3D& pTransform3D,
|
||||
std::vector<G4Point3D>& pVertices,
|
||||
std::vector<std::pair<G4int, G4int>>& pBases) const
|
||||
{
|
||||
G4ThreeVectorList baseA(4), baseB(4);
|
||||
std::vector<const G4ThreeVectorList*> aabb(2);
|
||||
aabb[0] = &baseA; aabb[1] = &baseB;
|
||||
aabb[0] = &baseA;
|
||||
aabb[1] = &baseB;
|
||||
if (fPolygons == nullptr)
|
||||
{
|
||||
baseA[0].set(fMin.x(),fMin.y(),fMin.z());
|
||||
@@ -600,32 +591,35 @@ G4BoundingEnvelope::TransformVertices(const G4Transform3D& pTransform3D,
|
||||
baseB[2].set(fMax.x(),fMax.y(),fMax.z());
|
||||
baseB[3].set(fMin.x(),fMax.y(),fMax.z());
|
||||
}
|
||||
std::vector<const G4ThreeVectorList*>::const_iterator ia, iaend;
|
||||
auto ib = pBases.begin();
|
||||
ia = (fPolygons == nullptr) ? aabb.cbegin() : fPolygons->cbegin();
|
||||
iaend = (fPolygons == nullptr) ? aabb.cend() : fPolygons->cend();
|
||||
auto ia = (fPolygons == nullptr) ? aabb.cbegin() : fPolygons->cbegin();
|
||||
auto iaend = (fPolygons == nullptr) ? aabb.cend() : fPolygons->cend();
|
||||
|
||||
if (pTransform3D.xx()==1 && pTransform3D.yy()==1 && pTransform3D.zz()==1)
|
||||
// Fill vector of bases
|
||||
//
|
||||
G4int index = 0;
|
||||
for (auto i = ia; i != iaend; ++i)
|
||||
{
|
||||
G4int nv = (*i)->size();
|
||||
pBases.push_back(std::make_pair(index, nv));
|
||||
index += nv;
|
||||
}
|
||||
|
||||
// Fill vector of transformed vertices
|
||||
//
|
||||
if (pTransform3D.xx() == 1. &&
|
||||
pTransform3D.yy() == 1. &&
|
||||
pTransform3D.zz() == 1.)
|
||||
{
|
||||
G4ThreeVector offset = pTransform3D.getTranslation();
|
||||
for ( ; ia != iaend; ++ia, ++ib)
|
||||
{
|
||||
auto ka = (*ia)->cbegin();
|
||||
auto kb = (*ib)->begin();
|
||||
for ( ; ka != (*ia)->cend(); ++ka, ++kb) { (*kb) = (*ka) + offset; }
|
||||
}
|
||||
for (auto i = ia; i != iaend; ++i)
|
||||
for (auto k = (*i)->cbegin(); k != (*i)->cend(); ++k)
|
||||
pVertices.push_back(G4Point3D((*k) + offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ; ia != iaend; ++ia, ++ib)
|
||||
{
|
||||
auto ka = (*ia)->cbegin();
|
||||
auto kb = (*ib)->begin();
|
||||
for ( ; ka != (*ia)->cend(); ++ka, ++kb)
|
||||
{
|
||||
(*kb) = pTransform3D*G4Point3D(*ka);
|
||||
}
|
||||
}
|
||||
for (auto i = ia; i != iaend; ++i)
|
||||
for (auto k = (*i)->cbegin(); k != (*i)->cend(); ++k)
|
||||
pVertices.push_back(pTransform3D*G4Point3D(*k));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,14 +638,14 @@ G4BoundingEnvelope::GetPrismAABB(const G4Polygon3D& pBaseA,
|
||||
// First base
|
||||
//
|
||||
for (auto it1 = pBaseA.cbegin(); it1 != pBaseA.cend(); ++it1)
|
||||
{
|
||||
{
|
||||
G4double x = it1->x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
G4double y = it1->y();
|
||||
G4double y = it1->y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
G4double z = it1->z();
|
||||
G4double z = it1->z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
}
|
||||
@@ -659,14 +653,14 @@ G4BoundingEnvelope::GetPrismAABB(const G4Polygon3D& pBaseA,
|
||||
// Second base
|
||||
//
|
||||
for (auto it2 = pBaseB.cbegin(); it2 != pBaseB.cend(); ++it2)
|
||||
{
|
||||
G4double x = it2->x();
|
||||
{
|
||||
G4double x = it2->x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
G4double y = it2->y();
|
||||
G4double y = it2->y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
G4double z = it2->z();
|
||||
G4double z = it2->z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
}
|
||||
@@ -817,7 +811,7 @@ G4BoundingEnvelope::CreateListOfPlanes(const G4Polygon3D& baseA,
|
||||
{
|
||||
pPlanes[i] = G4Plane3D(-pPlanes[i].a(),-pPlanes[i].b(),
|
||||
-pPlanes[i].c(),-pPlanes[i].d());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,7 +819,7 @@ G4BoundingEnvelope::CreateListOfPlanes(const G4Polygon3D& baseA,
|
||||
//
|
||||
// Clip edges of a prism by G4VoxelLimits box. Return true if all edges
|
||||
// are inside or intersect the voxel, in this case further calculations
|
||||
// are not needed
|
||||
// are not needed
|
||||
//
|
||||
G4bool
|
||||
G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
@@ -846,8 +840,8 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
std::abs(p1.z()-p2.z()) < kCarTolerance) continue;
|
||||
G4double d1, d2;
|
||||
// Clip current edge by X min
|
||||
d1 = pBox.GetMinXExtent() - p1.x();
|
||||
d2 = pBox.GetMinXExtent() - p2.x();
|
||||
d1 = pBox.GetMinXExtent() - p1.x();
|
||||
d2 = pBox.GetMinXExtent() - p2.x();
|
||||
if (d1 > 0.0)
|
||||
{
|
||||
if (d2 > 0.0) { done = false; continue; } // go to next edge
|
||||
@@ -859,8 +853,8 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
}
|
||||
|
||||
// Clip current edge by X max
|
||||
d1 = p1.x() - pBox.GetMaxXExtent();
|
||||
d2 = p2.x() - pBox.GetMaxXExtent();
|
||||
d1 = p1.x() - pBox.GetMaxXExtent();
|
||||
d2 = p2.x() - pBox.GetMaxXExtent();
|
||||
if (d1 > 0.)
|
||||
{
|
||||
if (d2 > 0.) { done = false; continue; } // go to next edge
|
||||
@@ -872,8 +866,8 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
}
|
||||
|
||||
// Clip current edge by Y min
|
||||
d1 = pBox.GetMinYExtent() - p1.y();
|
||||
d2 = pBox.GetMinYExtent() - p2.y();
|
||||
d1 = pBox.GetMinYExtent() - p1.y();
|
||||
d2 = pBox.GetMinYExtent() - p2.y();
|
||||
if (d1 > 0.)
|
||||
{
|
||||
if (d2 > 0.) { done = false; continue; } // go to next edge
|
||||
@@ -885,8 +879,8 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
}
|
||||
|
||||
// Clip current edge by Y max
|
||||
d1 = p1.y() - pBox.GetMaxYExtent();
|
||||
d2 = p2.y() - pBox.GetMaxYExtent();
|
||||
d1 = p1.y() - pBox.GetMaxYExtent();
|
||||
d2 = p2.y() - pBox.GetMaxYExtent();
|
||||
if (d1 > 0.)
|
||||
{
|
||||
if (d2 > 0.) { done = false; continue; } // go to next edge
|
||||
@@ -898,8 +892,8 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
}
|
||||
|
||||
// Clip current edge by Z min
|
||||
d1 = pBox.GetMinZExtent() - p1.z();
|
||||
d2 = pBox.GetMinZExtent() - p2.z();
|
||||
d1 = pBox.GetMinZExtent() - p1.z();
|
||||
d2 = pBox.GetMinZExtent() - p2.z();
|
||||
if (d1 > 0.)
|
||||
{
|
||||
if (d2 > 0.) { done = false; continue; } // go to next edge
|
||||
@@ -911,8 +905,8 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
}
|
||||
|
||||
// Clip current edge by Z max
|
||||
d1 = p1.z() - pBox.GetMaxZExtent();
|
||||
d2 = p2.z() - pBox.GetMaxZExtent();
|
||||
d1 = p1.z() - pBox.GetMaxZExtent();
|
||||
d2 = p2.z() - pBox.GetMaxZExtent();
|
||||
if (d1 > 0.)
|
||||
{
|
||||
if (d2 > 0.) { done = false; continue; } // go to next edge
|
||||
@@ -924,13 +918,13 @@ G4BoundingEnvelope::ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
|
||||
}
|
||||
|
||||
// Adjust current extent
|
||||
emin.setX(std::min(std::min(p1.x(),p2.x()),emin.x()));
|
||||
emin.setY(std::min(std::min(p1.y(),p2.y()),emin.y()));
|
||||
emin.setZ(std::min(std::min(p1.z(),p2.z()),emin.z()));
|
||||
emin.setX(std::min(std::min(p1.x(),p2.x()),emin.x()));
|
||||
emin.setY(std::min(std::min(p1.y(),p2.y()),emin.y()));
|
||||
emin.setZ(std::min(std::min(p1.z(),p2.z()),emin.z()));
|
||||
|
||||
emax.setX(std::max(std::max(p1.x(),p2.x()),emax.x()));
|
||||
emax.setY(std::max(std::max(p1.y(),p2.y()),emax.y()));
|
||||
emax.setZ(std::max(std::max(p1.z(),p2.z()),emax.z()));
|
||||
emax.setX(std::max(std::max(p1.x(),p2.x()),emax.x()));
|
||||
emax.setY(std::max(std::max(p1.y(),p2.y()),emax.y()));
|
||||
emax.setZ(std::max(std::max(p1.z(),p2.z()),emax.z()));
|
||||
}
|
||||
|
||||
// Return true if all edges (at least partially) are inside
|
||||
@@ -970,8 +964,8 @@ G4BoundingEnvelope::ClipVoxelByPlanes(G4int pBits,
|
||||
std::vector<G4Segment3D> edges(12);
|
||||
G4int i = 0, bits = pBits;
|
||||
if (!(bits & 0x001))
|
||||
{
|
||||
edges[i ].first.set( xmin,ymin,zmin);
|
||||
{
|
||||
edges[i ].first.set( xmin,ymin,zmin);
|
||||
edges[i++].second.set(xmax,ymin,zmin);
|
||||
}
|
||||
if (!(bits & 0x002))
|
||||
@@ -987,12 +981,12 @@ G4BoundingEnvelope::ClipVoxelByPlanes(G4int pBits,
|
||||
if (!(bits & 0x008))
|
||||
{
|
||||
edges[i ].first.set( xmin,ymax,zmin);
|
||||
edges[i++].second.set(xmin,ymin,zmin);
|
||||
edges[i++].second.set(xmin,ymin,zmin);
|
||||
}
|
||||
|
||||
if (!(bits & 0x010))
|
||||
{
|
||||
edges[i ].first.set( xmin,ymin,zmax);
|
||||
{
|
||||
edges[i ].first.set( xmin,ymin,zmax);
|
||||
edges[i++].second.set(xmax,ymin,zmax);
|
||||
}
|
||||
if (!(bits & 0x020))
|
||||
@@ -1008,13 +1002,13 @@ G4BoundingEnvelope::ClipVoxelByPlanes(G4int pBits,
|
||||
if (!(bits & 0x080))
|
||||
{
|
||||
edges[i ].first.set( xmin,ymax,zmax);
|
||||
edges[i++].second.set(xmin,ymin,zmax);
|
||||
edges[i++].second.set(xmin,ymin,zmax);
|
||||
}
|
||||
|
||||
if (!(bits & 0x100))
|
||||
{
|
||||
edges[i ].first.set( xmin,ymin,zmin);
|
||||
edges[i++].second.set(xmin,ymin,zmax);
|
||||
{
|
||||
edges[i ].first.set( xmin,ymin,zmin);
|
||||
edges[i++].second.set(xmin,ymin,zmax);
|
||||
}
|
||||
if (!(bits & 0x200))
|
||||
{
|
||||
@@ -1043,8 +1037,8 @@ G4BoundingEnvelope::ClipVoxelByPlanes(G4int pBits,
|
||||
for (auto iplane = pPlanes.cbegin(); iplane != pPlanes.cend(); ++iplane)
|
||||
{
|
||||
// Clip current edge
|
||||
G4double d1 = iplane->distance(p1);
|
||||
G4double d2 = iplane->distance(p2);
|
||||
G4double d1 = iplane->distance(p1);
|
||||
G4double d2 = iplane->distance(p2);
|
||||
if (d1 > 0.0)
|
||||
{
|
||||
if (d2 > 0.0) { exist = false; break; } // go to next edge
|
||||
@@ -1058,13 +1052,13 @@ G4BoundingEnvelope::ClipVoxelByPlanes(G4int pBits,
|
||||
// Adjust the extent
|
||||
if (exist)
|
||||
{
|
||||
emin.setX(std::min(std::min(p1.x(),p2.x()),emin.x()));
|
||||
emin.setY(std::min(std::min(p1.y(),p2.y()),emin.y()));
|
||||
emin.setZ(std::min(std::min(p1.z(),p2.z()),emin.z()));
|
||||
emin.setX(std::min(std::min(p1.x(),p2.x()),emin.x()));
|
||||
emin.setY(std::min(std::min(p1.y(),p2.y()),emin.y()));
|
||||
emin.setZ(std::min(std::min(p1.z(),p2.z()),emin.z()));
|
||||
|
||||
emax.setX(std::max(std::max(p1.x(),p2.x()),emax.x()));
|
||||
emax.setY(std::max(std::max(p1.y(),p2.y()),emax.y()));
|
||||
emax.setZ(std::max(std::max(p1.z(),p2.z()),emax.z()));
|
||||
emax.setX(std::max(std::max(p1.x(),p2.x()),emax.x()));
|
||||
emax.setY(std::max(std::max(p1.y(),p2.y()),emax.y()));
|
||||
emax.setZ(std::max(std::max(p1.z(),p2.z()),emax.z()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -348,6 +348,24 @@ G4ReflectedSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
"Method not applicable in this context!");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return volume
|
||||
|
||||
G4double G4ReflectedSolid::GetCubicVolume()
|
||||
{
|
||||
return fPtrSolid->GetCubicVolume();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return surface area
|
||||
|
||||
G4double G4ReflectedSolid::GetSurfaceArea()
|
||||
{
|
||||
return fPtrSolid->GetSurfaceArea();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return a point (G4ThreeVector) randomly and uniformly selected
|
||||
|
||||
Reference in New Issue
Block a user