50#if !defined(G4GEOM_USE_UTESSELLATEDSOLID)
110 fMinExtent.
set(0,0,0);
111 fMaxExtent.
set(0,0,0);
140 if (&ts ==
this)
return *
this;
156void G4TessellatedSolid::Initialize()
160 fRebuildPolyhedron =
false; fpPolyhedron =
nullptr;
161 fCubicVolume = 0.; fSurfaceArea = 0.;
163 fGeometryType =
"G4TessellatedSolid";
164 fSolidClosed =
false;
166 fMinExtent.
set(kInfinity,kInfinity,kInfinity);
167 fMaxExtent.
set(-kInfinity,-kInfinity,-kInfinity);
174void G4TessellatedSolid::DeleteObjects()
176 std::size_t size = fFacets.size();
177 for (std::size_t i = 0; i < size; ++i) {
delete fFacets[i]; }
179 delete fpPolyhedron; fpPolyhedron =
nullptr;
194 for (
G4int i = 0; i <
n; ++i)
213 G4Exception(
"G4TessellatedSolid::AddFacet()",
"GeomSolids1002",
214 JustWarning,
"Attempt to add facets when solid is closed.");
219 set<G4VertexInfo,G4VertexComparator>::iterator begin
220 = fFacetList.begin(), end = fFacetList.end(), pos, it;
223 value.
id = (
G4int)fFacetList.size();
224 value.
mag2 = p.
x() + p.
y() + p.
z();
230 pos = fFacetList.lower_bound(value);
233 while (!found && it != end)
238 if ((found = (facet == aFacet)))
break;
240 if (dif > kCarTolerance3)
break;
244 if (fFacets.size() > 1)
247 while (!found && it != begin)
253 found = (facet == aFacet);
256 if (dif > kCarTolerance3)
break;
263 fFacets.push_back(aFacet);
264 fFacetList.insert(value);
270 G4Exception(
"G4TessellatedSolid::AddFacet()",
"GeomSolids1002",
271 JustWarning,
"Attempt to add facet not properly defined.");
279G4int G4TessellatedSolid::SetAllUsingStack(
const std::vector<G4int>& voxel,
280 const std::vector<G4int>& max,
283 vector<G4int> xyz = voxel;
284 stack<vector<G4int> > pos;
288 vector<G4int> candidates;
305 for (
auto i = 0; i <= 2; ++i)
307 if (xyz[i] < max[i] - 1)
329void G4TessellatedSolid::PrecalculateInsides()
331 vector<G4int> voxel(3), maxVoxels(3);
332 for (
auto i = 0; i <= 2; ++i)
334 G4int size = maxVoxels[0] * maxVoxels[1] * maxVoxels[2];
341 for (voxel[2] = 0; voxel[2] < maxVoxels[2] - 1; ++voxel[2])
343 for (voxel[1] = 0; voxel[1] < maxVoxels[1] - 1; ++voxel[1])
345 for (voxel[0] = 0; voxel[0] < maxVoxels[0] - 1; ++voxel[0])
348 if (!checked[index] && fVoxels.
IsEmpty(index))
350 for (
auto i = 0; i <= 2; ++i)
355 SetAllUsingStack(voxel, maxVoxels, inside, checked);
365void G4TessellatedSolid::Voxelize ()
377 PrecalculateInsides();
393void G4TessellatedSolid::SetExtremeFacets()
396 std::size_t vsize = fVertexList.size();
397 std::vector<G4ThreeVector> vertices(vsize);
398 for (std::size_t i = 0; i < vsize; ++i) { vertices[i] = fVertexList[i]; }
401 std::mt19937 gen(12345678);
402 std::shuffle(vertices.begin(), vertices.end(), gen);
406 for (
G4int i=0; i < 6; ++i) { points[i] = vertices[0]; }
407 for (std::size_t i=1; i < vsize; ++i)
409 if (vertices[i].x() < points[0].x()) points[0] = vertices[i];
410 if (vertices[i].x() > points[1].x()) points[1] = vertices[i];
411 if (vertices[i].y() < points[2].y()) points[2] = vertices[i];
412 if (vertices[i].y() > points[3].y()) points[3] = vertices[i];
413 if (vertices[i].z() < points[4].z()) points[4] = vertices[i];
414 if (vertices[i].z() > points[5].z()) points[5] = vertices[i];
418 std::size_t size = fFacets.size();
419 for (std::size_t j = 0; j < size; ++j)
424 if (!facet.
IsInside(points[0]))
continue;
425 if (!facet.
IsInside(points[1]))
continue;
426 if (!facet.
IsInside(points[2]))
continue;
427 if (!facet.
IsInside(points[3]))
continue;
428 if (!facet.
IsInside(points[4]))
continue;
429 if (!facet.
IsInside(points[5]))
continue;
433 for (std::size_t i=0; i < vsize; ++i)
441 if (isExtreme) fExtremeFacets.insert(&facet);
447void G4TessellatedSolid::CreateVertexList()
459 set<G4VertexInfo,G4VertexComparator> vertexListSorted;
460 set<G4VertexInfo,G4VertexComparator>::iterator begin
461 = vertexListSorted.begin(), end = vertexListSorted.end(),
pos, it;
466 std::size_t size = fFacets.size();
470 vector<G4int> newIndex(100);
472 for (std::size_t k = 0; k < size; ++k)
480 value.
id = (
G4int)fVertexList.size();
481 value.
mag2 = p.
x() + p.
y() + p.
z();
487 pos = vertexListSorted.lower_bound(value);
494 found = (dif < kCarTolerance24);
496 dif = q.
x() + q.
y() + q.
z() - value.
mag2;
497 if (dif > kCarTolerance3)
break;
501 if (!found && (fVertexList.size() > 1))
510 found = (dif < kCarTolerance24);
512 dif = value.
mag2 - (q.
x() + q.
y() + q.
z());
513 if (dif > kCarTolerance3)
break;
522 G4cout <<
"Adding new vertex #" << i <<
" of facet " << k
526 fVertexList.push_back(p);
527 vertexListSorted.insert(value);
528 begin = vertexListSorted.begin();
529 end = vertexListSorted.end();
530 newIndex[i] = value.
id;
534 if (value.
id == 0) fMinExtent = fMaxExtent = p;
537 if (p.
x() > fMaxExtent.
x()) fMaxExtent.
setX(p.
x());
538 else if (p.
x() < fMinExtent.
x()) fMinExtent.
setX(p.
x());
539 if (p.
y() > fMaxExtent.
y()) fMaxExtent.
setY(p.
y());
540 else if (p.
y() < fMinExtent.
y()) fMinExtent.
setY(p.
y());
541 if (p.
z() > fMaxExtent.
z()) fMaxExtent.
setZ(p.
z());
542 else if (p.
z() < fMinExtent.
z()) fMinExtent.
setZ(p.
z());
549 G4cout <<
"Vertex #" << i <<
" of facet " << k
550 <<
" found, redirecting to " <<
id <<
G4endl;
562 vector<G4ThreeVector>(fVertexList).swap(fVertexList);
566 for (
auto res=vertexListSorted.cbegin(); res!=vertexListSorted.cend(); ++res)
568 G4int id = (*res).id;
571 if (previousValue && (previousValue - 1e-9 > mvalue))
572 G4cout <<
"Error in CreateVertexList: previousValue " << previousValue
573 <<
" is smaller than mvalue " << mvalue <<
G4endl;
574 previousValue = mvalue;
586 G4cout <<
"G4TessellatedSolid - Allocated memory without voxel overhead "
587 << without <<
"; with " << with <<
"; ratio: " << ratio <<
G4endl;
623 std::ostringstream message;
624 message <<
"Defects in solid: " <<
GetName()
625 <<
" - negative cubic volume, please check orientation of facets!";
626 G4Exception(
"G4TessellatedSolid::SetSolidClosed()",
631 std::ostringstream message;
632 message <<
"Defects in solid: " <<
GetName()
633 <<
" - some facets have wrong orientation!";
634 G4Exception(
"G4TessellatedSolid::SetSolidClosed()",
639 std::ostringstream message;
640 message <<
"Defects in solid: " <<
GetName()
641 <<
" - there are holes in the surface!";
642 G4Exception(
"G4TessellatedSolid::SetSolidClosed()",
674 std::size_t nface = fFacets.size();
679 for (std::size_t i = 0; i < nface; ++i)
685 G4int ivolume = (volume <= 0.);
689 std::vector<int64_t> iedge(nedge);
691 for (std::size_t i = 0; i < nface; ++i)
695 for (
G4int k = 0; k < nnode; ++k)
699 int64_t inverse = (i2 > i1);
700 if (inverse) std::swap(i1, i2);
701 iedge[kk++] = i1*1000000000 + i2*2 + inverse;
704 std::sort(iedge.begin(), iedge.end());
712 while (i < nedge - 1)
714 if (iedge[i + 1] - iedge[i] == 1)
718 else if (iedge[i + 1] == iedge[i])
729 return ivolume + iorder + ihole;
745 for (
G4int i = 0; i < size; ++i)
757 return (
G4int)fFacets.size();
771 vector<G4int> startingVoxel(3);
774 const G4double dirTolerance = 1.0E-14;
776 const vector<G4int> &startingCandidates =
778 std::size_t limit = startingCandidates.size();
779 if (limit == 0 && fInsides.
GetNbits())
788 for(std::size_t i = 0; i < limit; ++i)
790 G4int candidate = startingCandidates[i];
791 G4VFacet &facet = *fFacets[candidate];
793 if (dist < minDist) minDist = dist;
820 G4bool nearParallel =
false;
828 distOut = distIn = kInfinity;
840 vector<G4int> curVoxel(3);
841 curVoxel = startingVoxel;
849 const vector<G4int> &candidates =
850 started ? startingCandidates : fVoxels.
GetCandidates(curVoxel);
852 if (
G4int candidatesCount = (
G4int)candidates.size())
854 for (
G4int i = 0 ; i < candidatesCount; ++i)
856 G4int candidate = candidates[i];
858 G4VFacet& facet = *fFacets[candidate];
860 crossingO = facet.
Intersect(p,v,
true,distO,distFromSurfaceO,normalO);
861 crossingI = facet.
Intersect(p,v,
false,distI,distFromSurfaceI,normalI);
863 if (crossingO || crossingI)
867 nearParallel = (crossingO
868 && std::fabs(normalO.
dot(v))<dirTolerance)
869 || (crossingI && std::fabs(normalI.
dot(v))<dirTolerance);
872 if (crossingO && distO > 0.0 && distO < distOut)
874 if (crossingI && distI > 0.0 && distI < distIn)
880 if (nearParallel)
break;
887 G4bool inside = fInsides[index];
894 if (shift == kInfinity)
break;
896 currentPoint += direction * (shift + shiftBonus);
901 while (nearParallel && sm != fMaxTries);
915 std::ostringstream message;
916 G4long oldprc = message.precision(16);
917 message <<
"Cannot determine whether point is inside or outside volume!"
920 <<
"Geometry Type = " << fGeometryType <<
G4endl
921 <<
"Number of facets = " << fFacets.size() <<
G4endl
923 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
924 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
925 <<
"p.z() = " << p.
z()/mm <<
" mm";
926 message.precision(oldprc);
941 if (distIn == kInfinity && distOut == kInfinity)
962 const G4double dirTolerance = 1.0E-14;
968 std::size_t size = fFacets.size();
969 for (std::size_t i = 0; i < size; ++i)
973 if (dist < minDist) minDist = dist;
1003 G4bool crossingO =
false;
1004 G4bool crossingI =
false;
1009 for (
G4int i=0; i<nTry; ++i)
1011 G4bool nearParallel =
false;
1020 distOut = distIn = kInfinity;
1023 vector<G4VFacet*>::const_iterator f = fFacets.cbegin();
1032 crossingO = ((*f)->Intersect(p,v,
true,distO,distFromSurfaceO,normalO));
1033 crossingI = ((*f)->Intersect(p,v,
false,distI,distFromSurfaceI,normalI));
1034 if (crossingO || crossingI)
1036 nearParallel = (crossingO && std::fabs(normalO.
dot(v))<dirTolerance)
1037 || (crossingI && std::fabs(normalI.
dot(v))<dirTolerance);
1040 if (crossingO && distO > 0.0 && distO < distOut) distOut = distO;
1041 if (crossingI && distI > 0.0 && distI < distIn) distIn = distI;
1044 }
while (!nearParallel && ++f != fFacets.cend());
1045 }
while (nearParallel && sm != fMaxTries);
1048 if (sm == fMaxTries)
1055 std::ostringstream message;
1056 G4long oldprc = message.precision(16);
1057 message <<
"Cannot determine whether point is inside or outside volume!"
1060 <<
"Geometry Type = " << fGeometryType <<
G4endl
1061 <<
"Number of facets = " << fFacets.size() <<
G4endl
1063 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
1064 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
1065 <<
"p.z() = " << p.
z()/mm <<
" mm";
1066 message.precision(oldprc);
1081 if (distIn == kInfinity && distOut == kInfinity)
1088 if (i == 0) location = locationprime;
1105 vector<G4int> curVoxel(3);
1107 const vector<G4int> &candidates = fVoxels.
GetCandidates(curVoxel);
1111 for(
G4int i = 0 ; i < limit ; ++i)
1113 G4int candidate = candidates[i];
1114 G4VFacet& facet = *fFacets[candidate];
1128 std::size_t size = fFacets.size();
1129 for (std::size_t i = 0; i < size; ++i)
1156 vector<G4int> curVoxel(3);
1158 const vector<G4int> &candidates = fVoxels.
GetCandidates(curVoxel);
1163 minDist = kInfinity;
1164 for(
G4int i = 0 ; i < limit ; ++i)
1166 G4int candidate = candidates[i];
1167 G4VFacet &fct = *fFacets[candidate];
1169 if (dist < minDist) minDist = dist;
1177 minDist = MinDistanceFacet(p,
true, facet);
1181 minDist = kInfinity;
1182 std::size_t size = fFacets.size();
1183 for (std::size_t i = 0; i < size; ++i)
1195 if (minDist != kInfinity)
1203 std::ostringstream message;
1204 message <<
"Point p is not on surface !?" <<
G4endl
1205 <<
" No facets found for point: " << p <<
" !" <<
G4endl
1206 <<
" Returning approximated value for normal.";
1208 G4Exception(
"G4TessellatedSolid::SurfaceNormal(p)",
1227G4TessellatedSolid::DistanceToInNoVoxels (
const G4ThreeVector& p,
1239 std::ostringstream message;
1240 G4int oldprc = message.precision(16) ;
1241 message <<
"Point p is already inside!?" <<
G4endl
1243 <<
" p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
1244 <<
" p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
1245 <<
" p.z() = " << p.
z()/mm <<
" mm" <<
G4endl
1247 message.precision(oldprc) ;
1248 G4Exception(
"G4TriangularFacet::DistanceToIn(p,v)",
1253 std::size_t size = fFacets.size();
1254 for (std::size_t i = 0; i < size; ++i)
1257 if (facet.
Intersect(p,v,
false,dist,distFromSurface,normal))
1293G4TessellatedSolid::DistanceToOutNoVoxels (
const G4ThreeVector& p,
1307 std::ostringstream message;
1308 G4int oldprc = message.precision(16) ;
1309 message <<
"Point p is already outside!?" <<
G4endl
1311 <<
" p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
1312 <<
" p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
1313 <<
" p.z() = " << p.
z()/mm <<
" mm" <<
G4endl
1315 message.precision(oldprc) ;
1316 G4Exception(
"G4TriangularFacet::DistanceToOut(p)",
1321 G4bool isExtreme =
false;
1322 std::size_t size = fFacets.size();
1323 for (std::size_t i = 0; i < size; ++i)
1326 if (facet.
Intersect(p,v,
true,dist,distFromSurface,normal))
1332 aConvex = (fExtremeFacets.find(&facet) != fExtremeFacets.end());
1335 aNormalVector = normal;
1338 if (dist >= 0.0 && dist < minDist)
1342 isExtreme = (fExtremeFacets.find(&facet) != fExtremeFacets.end());
1346 if (minDist < kInfinity)
1348 aNormalVector = minNormal;
1349 aConvex = isExtreme;
1356 Normal(p, aNormalVector);
1363void G4TessellatedSolid::
1364DistanceToOutCandidates(
const std::vector<G4int>& candidates,
1368 G4int& minCandidate )
const
1370 G4int candidatesCount = (
G4int)candidates.size();
1375 for (
G4int i = 0 ; i < candidatesCount; ++i)
1377 G4int candidate = candidates[i];
1378 G4VFacet& facet = *fFacets[candidate];
1379 if (facet.
Intersect(aPoint,direction,
true,dist,distFromSurface,normal))
1388 minCandidate = candidate;
1391 if (dist >= 0.0 && dist < minDist)
1395 minCandidate = candidate;
1404G4TessellatedSolid::DistanceToOutCore(
const G4ThreeVector& aPoint,
1414 minDistance = kInfinity;
1419 vector<G4int> curVoxel(3);
1420 if (!fVoxels.
Contains(aPoint))
return 0.;
1422 fVoxels.
GetVoxel(curVoxel, currentPoint);
1426 const vector<G4int>* old =
nullptr;
1428 G4int minCandidate = -1;
1431 const vector<G4int>& candidates = fVoxels.
GetCandidates(curVoxel);
1432 if (old == &candidates)
1434 if (old != &candidates && candidates.size())
1436 DistanceToOutCandidates(candidates, aPoint, direction, minDistance,
1437 aNormalVector, minCandidate);
1438 if (minDistance <= totalShift)
break;
1442 if (shift == kInfinity)
break;
1444 totalShift += shift;
1445 if (minDistance <= totalShift)
break;
1447 currentPoint += direction * (shift + shiftBonus);
1453 if (minCandidate < 0)
1458 Normal(aPoint, aNormalVector);
1462 aConvex = (fExtremeFacets.find(fFacets[minCandidate])
1463 != fExtremeFacets.end());
1468 minDistance = DistanceToOutNoVoxels(aPoint, aDirection, aNormalVector,
1477DistanceToInCandidates(
const std::vector<G4int>& candidates,
1481 G4int candidatesCount = (
G4int)candidates.size();
1487 for (
G4int i = 0 ; i < candidatesCount; ++i)
1489 G4int candidate = candidates[i];
1490 G4VFacet& facet = *fFacets[candidate];
1491 if (facet.
Intersect(aPoint,direction,
false,dist,distFromSurface,normal))
1501 && (dist >= 0.0) && (dist < minDistance))
1525G4TessellatedSolid::DistanceToInCore(
const G4ThreeVector& aPoint,
1533 minDistance = kInfinity;
1537 if (shift == kInfinity)
return shift;
1540 currentPoint += direction * (shift + shiftBonus);
1545 vector<G4int> curVoxel(3);
1547 fVoxels.
GetVoxel(curVoxel, currentPoint);
1550 const vector<G4int>& candidates = fVoxels.
GetCandidates(curVoxel);
1551 if (candidates.size())
1553 G4double distance=DistanceToInCandidates(candidates, aPoint, direction);
1554 if (minDistance > distance) minDistance = distance;
1555 if (distance < totalShift)
break;
1558 shift = fVoxels.
DistanceToNext(currentPoint, direction, curVoxel);
1559 if (shift == kInfinity )
break;
1561 totalShift += shift;
1562 if (minDistance < totalShift)
break;
1564 currentPoint += direction * (shift + shiftBonus);
1570 minDistance = DistanceToInNoVoxels(aPoint, aDirection, aPstep);
1579G4TessellatedSolid::CompareSortedVoxel(
const std::pair<G4int, G4double>& l,
1580 const std::pair<G4int, G4double>& r)
1582 return l.second < r.second;
1595 vector<pair<G4int, G4double> > voxelsSorted(size);
1597 pair<G4int, G4double> info;
1599 for (
G4int i = 0; i < size; ++i)
1606 info.second = safety;
1607 voxelsSorted[i] = info;
1610 std::sort(voxelsSorted.begin(), voxelsSorted.end(),
1611 &G4TessellatedSolid::CompareSortedVoxel);
1613 for (
G4int i = 0; i < size; ++i)
1615 const pair<G4int,G4double>& inf = voxelsSorted[i];
1617 if (dist > minDist)
break;
1621 for (
G4int j = 0; j < csize; ++j)
1623 G4int candidate = candidates[j];
1624 G4VFacet& facet = *fFacets[candidate];
1625 dist = simple ? facet.
Distance(p,minDist)
1645 std::ostringstream message;
1646 G4int oldprc = message.precision(16) ;
1647 message <<
"Point p is already inside!?" <<
G4endl
1649 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
1650 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
1651 <<
"p.z() = " << p.
z()/mm <<
" mm" <<
G4endl
1653 message.precision(oldprc) ;
1668 vector<G4int> startingVoxel(3);
1669 fVoxels.
GetVoxel(startingVoxel, p);
1670 const vector<G4int> &candidates = fVoxels.
GetCandidates(startingVoxel);
1671 if (candidates.size() == 0 && fInsides.
GetNbits())
1674 if (fInsides[index])
return 0.;
1679 minDist = MinDistanceFacet(p,
true, facet);
1683 minDist = kInfinity;
1684 std::size_t size = fFacets.size();
1685 for (std::size_t i = 0; i < size; ++i)
1689 if (dist < minDist) minDist = dist;
1703 std::ostringstream message;
1704 G4int oldprc = message.precision(16) ;
1705 message <<
"Point p is already outside!?" <<
G4endl
1707 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
1708 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
1709 <<
"p.z() = " << p.
z()/mm <<
" mm" <<
G4endl
1711 message.precision(oldprc) ;
1712 G4Exception(
"G4TriangularFacet::DistanceToOut(p)",
1724 minDist = MinDistanceFacet(p,
true, facet);
1728 minDist = kInfinity;
1730 std::size_t size = fFacets.size();
1731 for (std::size_t i = 0; i < size; ++i)
1735 if (dist < minDist) minDist = dist;
1749 return fGeometryType;
1758 os <<
"Geometry Type = " << fGeometryType <<
G4endl;
1759 os <<
"Number of facets = " << fFacets.size() <<
G4endl;
1761 std::size_t size = fFacets.size();
1762 for (std::size_t i = 0; i < size; ++i)
1764 os <<
"FACET # = " << i + 1 <<
G4endl;
1798 location = InsideVoxels(aPoint);
1802 location = InsideNoVoxels(aPoint);
1833 G4double dist = DistanceToInCore(p,v,kInfinity);
1835 if (dist < kInfinity)
1839 std::ostringstream message;
1840 message <<
"Invalid response from facet in solid '" <<
GetName() <<
"',"
1842 <<
"at point: " << p <<
"and direction: " << v;
1843 G4Exception(
"G4TessellatedSolid::DistanceToIn(p,v)",
1890 G4double dist = DistanceToOutCore(p, v, n, valid);
1897 if (dist < kInfinity)
1901 std::ostringstream message;
1902 message <<
"Invalid response from facet in solid '" <<
GetName() <<
"',"
1904 <<
"at point: " << p <<
"and direction: " << v;
1905 G4Exception(
"G4TessellatedSolid::DistanceToOut(p,v,..)",
1927 for (
auto i = 0; i < nVertices; ++i)
1929 polyhedron->
SetVertex(i+1, fVertexList[i]);
1932 for (
auto i = 0; i < nFacets; ++i)
1938 for (
auto j = 0; j < n; ++j)
1942 polyhedron->
SetFacet(i+1, v[0], v[1], v[2], v[3]);
1955 if (fpPolyhedron ==
nullptr ||
1956 fRebuildPolyhedron ||
1961 delete fpPolyhedron;
1963 fRebuildPolyhedron =
false;
1966 return fpPolyhedron;
1981 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
1983 std::ostringstream message;
1984 message <<
"Bad bounding box (min >= max) for solid: "
1986 <<
"\npMin = " << pMin
1987 <<
"\npMax = " << pMax;
1988 G4Exception(
"G4TessellatedSolid::BoundingLimits()",
2020 return (pMin < pMax) ? true :
false;
2031 std::vector<const G4ThreeVectorList *> pyramid(2);
2034 apex[0] = (bmin+bmax)*0.5;
2051 if (!benv.
CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
2052 if (emin < pMin) pMin = emin;
2053 if (emax > pMax) pMax = emax;
2054 if (eminlim > pMin && emaxlim < pMax)
break;
2056 return (pMin < pMax);
2064 return fMinExtent.
x();
2071 return fMaxExtent.
x();
2078 return fMinExtent.
y();
2085 return fMaxExtent.
y();
2092 return fMinExtent.
z();
2099 return fMaxExtent.
z();
2107 fMinExtent.
y(), fMaxExtent.
y(),
2108 fMinExtent.
z(), fMaxExtent.
z());
2115 if (fCubicVolume != 0.)
return fCubicVolume;
2121 std::size_t size = fFacets.size();
2122 for (std::size_t i = 0; i < size; ++i)
2127 fCubicVolume += area * (facet.
GetVertex(0).
dot(unit_normal));
2130 return fCubicVolume;
2137 if (fSurfaceArea != 0.)
return fSurfaceArea;
2139 std::size_t size = fFacets.size();
2140 for (std::size_t i = 0; i < size; ++i)
2143 fSurfaceArea += facet.
GetArea();
2145 return fSurfaceArea;
2154 G4int i = (
G4int) G4RandFlat::shoot(0., fFacets.size());
2155 return fFacets[i]->GetPointOnFace();
2167void G4TessellatedSolid::SetRandomVectors ()
2171 G4ThreeVector(-0.9577428892113370, 0.2732676269591740, 0.0897405271949221);
2173 G4ThreeVector(-0.8331264504940770,-0.5162067214954600,-0.1985722492445700);
2175 G4ThreeVector(-0.1516671651108820, 0.9666292616127460, 0.2064580868390110);
2177 G4ThreeVector( 0.6570250350323190,-0.6944539025883300, 0.2933460081893360);
2179 G4ThreeVector(-0.4820456281280320,-0.6331060000098690,-0.6056474264406270);
2181 G4ThreeVector( 0.7629032554236800 , 0.1016854697539910,-0.6384658864065180);
2183 G4ThreeVector( 0.7689540409061150, 0.5034929891988220, 0.3939600142169160);
2185 G4ThreeVector( 0.5765188359255740, 0.5997271636278330,-0.5549354566343150);
2187 G4ThreeVector( 0.6660632777862070,-0.6362809868288380, 0.3892379937580790);
2189 G4ThreeVector( 0.3824415020414780, 0.6541792713761380,-0.6525243125110690);
2191 G4ThreeVector(-0.5107726564526760, 0.6020905056811610, 0.6136760679616570);
2193 G4ThreeVector( 0.7459135439578050, 0.6618796061649330, 0.0743530220183488);
2195 G4ThreeVector( 0.1536405855311580, 0.8117477913978260,-0.5634359711967240);
2197 G4ThreeVector( 0.0744395301705579,-0.8707110101772920,-0.4861286795736560);
2199 G4ThreeVector(-0.1665874645185400, 0.6018553940549240,-0.7810369397872780);
2201 G4ThreeVector( 0.7766902003633100, 0.6014617505959970,-0.1870724331097450);
2203 G4ThreeVector(-0.8710128685847430,-0.1434320216603030,-0.4698551243971010);
2205 G4ThreeVector( 0.8901082092766820,-0.4388411398893870, 0.1229871120030100);
2207 G4ThreeVector(-0.6430417431544370,-0.3295938228697690, 0.6912779675984150);
2209 G4ThreeVector( 0.6331124368380410, 0.6306211461665000, 0.4488714875425340);
2218 G4int base =
sizeof(*this);
2222 std::size_t limit = fFacets.size();
2223 for (std::size_t i = 0; i < limit; ++i)
2229 for (
auto it = fExtremeFacets.cbegin(); it != fExtremeFacets.cend(); ++it)
2244 size += sizeInsides + sizeVoxels;
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define G4MUTEX_INITIALIZER
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
double dot(const Hep3Vector &) const
void set(double x, double y, double z)
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
unsigned int GetNbits() const
unsigned int GetNbytes() const
void ResetBitNumber(unsigned int bitnumber)
void SetBitNumber(unsigned int bitnumber, G4bool value=true)
virtual G4bool Normal(const G4ThreeVector &p, G4ThreeVector &n) const
G4double GetMinYExtent() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4int CheckStructure() const
virtual G4Polyhedron * GetPolyhedron() const
virtual G4double GetSurfaceArea()
G4double GetMinZExtent() const
virtual std::ostream & StreamInfo(std::ostream &os) const
G4TessellatedSolid & operator=(const G4TessellatedSolid &right)
G4double kCarToleranceHalf
G4TessellatedSolid & operator+=(const G4TessellatedSolid &right)
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool AddFacet(G4VFacet *aFacet)
void DisplayAllocatedMemory()
G4int GetNumberOfFacets() const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMaxXExtent() const
G4bool GetSolidClosed() const
virtual G4double DistanceToOut(const G4ThreeVector &p) const
G4VFacet * GetFacet(G4int i) const
virtual G4double SafetyFromInside(const G4ThreeVector &p, G4bool aAccurate=false) const
G4double GetMinXExtent() const
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const
void SetSolidClosed(const G4bool t)
G4int AllocatedMemoryWithoutVoxels()
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
virtual G4VisExtent GetExtent() const
virtual G4Polyhedron * CreatePolyhedron() const
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
virtual G4GeometryType GetEntityType() const
virtual EInside Inside(const G4ThreeVector &p) const
G4int GetFacetIndex(const G4ThreeVector &p) const
virtual G4double SafetyFromOutside(const G4ThreeVector &p, G4bool aAccurate=false) const
virtual ~G4TessellatedSolid()
virtual G4double GetCubicVolume()
virtual G4VSolid * Clone() const
virtual G4ThreeVector GetPointOnSurface() const
virtual void SetVertexIndex(G4int i, G4int j)=0
virtual G4int AllocatedMemory()=0
virtual G4ThreeVector GetCircumcentre() const =0
std::ostream & StreamInfo(std::ostream &os) const
G4bool IsInside(const G4ThreeVector &p) const
virtual G4ThreeVector GetSurfaceNormal() const =0
virtual G4ThreeVector GetVertex(G4int i) const =0
virtual G4double GetArea() const =0
virtual G4int GetNumberOfVertices() const =0
virtual G4int GetVertexIndex(G4int i) const =0
virtual G4VFacet * GetClone()=0
virtual G4double Distance(const G4ThreeVector &, G4double)=0
virtual void SetVertices(std::vector< G4ThreeVector > *vertices)=0
virtual G4bool IsDefined() const =0
virtual G4bool Intersect(const G4ThreeVector &, const G4ThreeVector &, const G4bool, G4double &, G4double &, G4ThreeVector &)=0
virtual void AddSolid(const G4Box &)=0
G4VSolid & operator=(const G4VSolid &rhs)
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const
const G4SurfBits & Empty() const
G4double DistanceToBoundingBox(const G4ThreeVector &point) const
long long GetCountOfVoxels() const
const std::vector< G4double > & GetBoundary(G4int index) const
G4bool IsEmpty(G4int index) const
G4bool UpdateCurrentVoxel(const G4ThreeVector &point, const G4ThreeVector &direction, std::vector< G4int > &curVoxel) const
void GetVoxel(std::vector< G4int > &curVoxel, const G4ThreeVector &point) const
G4int GetMaxVoxels(G4ThreeVector &ratioOfReduction)
G4double DistanceToFirst(const G4ThreeVector &point, const G4ThreeVector &direction) const
G4int GetVoxelBoxesSize() const
static G4double MinDistanceToBox(const G4ThreeVector &aPoint, const G4ThreeVector &f)
void SetMaxVoxels(G4int max)
const G4VoxelBox & GetVoxelBox(G4int i) const
G4int GetPointIndex(const G4ThreeVector &p) const
G4double DistanceToNext(const G4ThreeVector &point, const G4ThreeVector &direction, std::vector< G4int > &curVoxel) const
void Voxelize(std::vector< G4VSolid * > &solids, std::vector< G4Transform3D > &transforms)
const std::vector< G4int > & GetVoxelBoxCandidates(G4int i) const
G4int GetVoxelsIndex(G4int x, G4int y, G4int z) const
G4bool Contains(const G4ThreeVector &point) const
const std::vector< G4int > & GetCandidates(std::vector< G4int > &curVoxel) const
static G4int GetNumberOfRotationSteps()
void SetVertex(G4int index, const G4Point3D &v)
void SetFacet(G4int index, G4int iv1, G4int iv2, G4int iv3, G4int iv4=0)
T max(const T t1, const T t2)
brief Return the largest of the two arguments