61 fRebuildPolyhedron(false), fpPolyhedron(0)
92 :
G4VSolid(rhs),fCubicVolume (rhs.fCubicVolume),
93 fSurfaceArea (rhs.fSurfaceArea),
94 kRadTolerance(rhs.kRadTolerance), fAccurate(false),
95 fRebuildPolyhedron(false), fpPolyhedron(0)
102 :
G4VSolid(a), fCubicVolume (0.), fSurfaceArea (0.), kRadTolerance(0.),
103 fAccurate(false), fRebuildPolyhedron(false), fpPolyhedron(0)
134 G4int inside = 0, generated;
136 d = (extentMax - extentMin) / 2.;
137 p = (extentMax + extentMin) / 2.;
140 for (generated = 0; generated < 10000; generated++)
145 length.
z()*rvec.
z());
148 G4double vbox = (2 * d.x()) * (2 * d.y()) * (2 * d.z());
164 for (
G4int i = 0 ; i < numNodes ; ++i)
173 if (minDistance > distance) minDistance = distance;
181 std::vector<G4int>& candidates,
184 G4int candidatesCount = candidates.size();
188 for (
G4int i = 0 ; i < candidatesCount; ++i)
190 G4int candidate = candidates[i];
197 if (minDistance > distance) minDistance = distance;
199 if (minDistance == 0)
break;
224 if (shift) currentPoint += direction * shift;
227 std::vector<G4int> candidates, curVoxel(3);
236 candidates, exclusion);
237 if (minDistance > distance) minDistance = distance;
238 if (distance < shift)
break;
243 while (minDistance > shift);
263 G4int ignoredSolid = -1;
268 for (
G4int i = 0; i < numNodes; ++i)
270 if (i != ignoredSolid)
283 if (resultDistToOut ==
kInfinity) resultDistToOut = 0;
287 + distance*localDirection);
288 resultDistToOut += distance;
296 return resultDistToOut;
329 std::vector<G4int> candidates;
348 G4int maxCandidate = 0;
351 G4int limit = candidates.size();
352 for (
G4int i = 0 ; i < limit ; ++i)
354 G4int candidate = candidates[i];
378 false, 0, &localNormal);
379 if (maxDistance < shift)
382 maxCandidate = candidate;
383 maxNormal = localNormal;
395 distance += maxDistance;
396 currentPoint += maxDistance * direction;
397 if(maxDistance == 0.) count++;
400 exclusion.SetBitNumber(maxCandidate);
422 exclusion.ResetBitNumber(maxCandidate);
425 while ((notOutside) && (count < numNodes));
449 std::vector<G4int> candidates;
450 std::vector<G4MultiUnionSurface> surfaces;
460 for (
G4int i = 0 ; i < limit ; ++i)
462 G4int candidate = candidates[i];
469 location = solid.
Inside(localPoint);
474 surface.
point = localPoint;
475 surface.
solid = &solid;
476 surfaces.push_back(surface);
485 G4int size = surfaces.size();
486 for (
G4int i = 0; i < size - 1; ++i)
489 for (
G4int j = i + 1; j < size; ++j)
530 G4int countSurface = 0;
533 for (
G4int i = 0 ; i < numNodes ; ++i)
542 location = solid.
Inside(localPoint);
560 for (
G4int i = 0 ; i < numNodes ; ++i)
655 std::vector<G4int> candidates;
667 G4int limit = candidates.size();
668 for (
G4int i = 0 ; i < limit ; ++i)
670 G4int candidate = candidates[i];
683 return normal.
unit();
704 return normal.
unit();
721 return normal.
unit();
733 std::vector<G4int> candidates;
741 G4int limit = candidates.size();
742 for (
G4int i = 0; i < limit; ++i)
744 G4int candidate = candidates[i];
754 if (safetyMin > safety) safetyMin = safety;
757 if (safetyMin ==
kInfinity) safetyMin = 0;
776 for (
G4int j = 0; j < numNodes; ++j)
783 for (
G4int i = 0; i <= 2; ++i)
786 if ((dxyz[i] = std::abs(point[i] - pos[i]) - hlen[i]) > safetyMin)
790 for (
G4int i = 0; i <= 2; ++i)
791 if (dxyz[i] > 0) d2xyz += dxyz[i] * dxyz[i];
796 if (d2xyz >= safetyMin * safetyMin)
806 if (safety <= 0)
return safety;
808 if (safetyMin > safety) safetyMin = safety;
839 G4int safetyNode = 0;
843 for (
G4int i = 0; i < numNodes; ++i)
846 G4double dxyz0 = std::abs(aPoint.
x() - boxes[i].pos.x()) - boxes[i].hlen.x();
847 if (dxyz0 > safetyMin)
continue;
848 G4double dxyz1 = std::abs(aPoint.
y() - boxes[i].pos.y()) - boxes[i].hlen.y();
849 if (dxyz1 > safetyMin)
continue;
850 G4double dxyz2 = std::abs(aPoint.
z() - boxes[i].pos.z()) - boxes[i].hlen.z();
851 if (dxyz2 > safetyMin)
continue;
853 if (dxyz0 > 0) d2xyz += dxyz0 * dxyz0;
854 if (dxyz1 > 0) d2xyz += dxyz1 * dxyz1;
855 if (dxyz2 > 0) d2xyz += dxyz2 * dxyz2;
856 if (d2xyz >= safetyMin * safetyMin)
continue;
864 if (safetyMin > safety)
898 for (
G4int i = 0 ; i < limit; ++i)
905 if (current.
x() > max.
x()) max.
setX(current.
x());
906 if (current.
x() < min.
x()) min.
setX(current.
x());
908 if (current.
y() > max.
y()) max.
setY(current.
y());
909 if (current.
y() < min.
y()) min.
setY(current.
y());
911 if (current.
z() > max.
z()) max.
setZ(current.
z());
912 if (current.
z() < min.
z()) min.
setZ(current.
z());
920 G4int oldprc = os.precision(16);
921 os <<
"-----------------------------------------------------------\n"
922 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
923 <<
" ===================================================\n"
924 <<
" Solid type: G4MultiUnion\n"
925 <<
" Parameters: \n";
927 for (
G4int i = 0 ; i < numNodes ; ++i)
933 os <<
" Rotation is :" <<
" \n";
937 <<
"-----------------------------------------------------------\n";
938 os.precision(oldprc);
988 processor.
push_back (operation, *operand);
991 if (processor.
execute(*top)) {
return top; }
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4Polyhedron * GetPolyhedron() const
CLHEP::Hep3Vector G4ThreeVector
G4VSolid * GetSolid(G4int index) const
void Voxelize(std::vector< G4VSolid * > &solids, std::vector< G4Transform3D > &transforms)
std::vector< ExP01TrackerHit * > a
static const G4double pos
G4Polyhedron * CreatePolyhedron() const
std::vector< G4Transform3D > fTransformObjs
virtual void AddSolid(const G4Box &)=0
static const G4double kInfinity
G4ThreeVector GetGlobalPoint(const G4Transform3D &trans, const G4ThreeVector &lpoint) const
G4int GetCandidatesVoxelArray(const G4ThreeVector &point, std::vector< G4int > &list, G4SurfBits *crossed=0) const
void AddNode(G4VSolid &solid, G4Transform3D &trans)
G4ThreeVector SurfaceNormal(const G4ThreeVector &aPoint) const
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
std::ostream & StreamInfo(std::ostream &os) const
G4ThreeVector GetPointOnSurface() const
G4double DistanceToInNoVoxels(const G4ThreeVector &aPoint, const G4ThreeVector &aDirection) const
virtual G4ThreeVector GetPointOnSurface() const
G4Polyhedron * GetPolyhedron() const
static double normal(HepRandomEngine *eptr)
G4double GetRadialTolerance() const
G4double DistanceToIn(const G4ThreeVector &aPoint) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
EInside InsideNoVoxels(const G4ThreeVector &aPoint) const
void push_back(Operation, const HepPolyhedron &)
G4double GetSurfaceArea()
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
G4ThreeVector GetLocalPoint(const G4Transform3D &trans, const G4ThreeVector &gpoint) const
G4ThreeVector GetGlobalVector(const G4Transform3D &trans, const G4ThreeVector &lvec) const
virtual EInside Inside(const G4ThreeVector &p) const =0
G4VSolid & operator=(const G4VSolid &rhs)
G4double DistanceToFirst(const G4ThreeVector &point, const G4ThreeVector &direction) const
G4double DistanceToOutNoVoxels(const G4ThreeVector &aPoint, const G4ThreeVector &aDirection, G4ThreeVector *aNormalVector) const
#define G4MUTEX_INITIALIZER
void BoundingLimits(G4ThreeVector &aMin, G4ThreeVector &aMax) const
void TransformLimits(G4ThreeVector &min, G4ThreeVector &max, const G4Transform3D &transformation) const
const G4Transform3D & GetTransformation(G4int index) const
void SetName(const G4String &name)
bool execute(HepPolyhedron &)
virtual std::ostream & StreamInfo(std::ostream &os) const =0
const std::vector< G4VoxelBox > & GetBoxes() const
G4double GetCubicVolume()
static G4int GetNumberOfRotationSteps()
G4bool fRebuildPolyhedron
EInside InsideWithExclusion(const G4ThreeVector &aPoint, G4SurfBits *bits=0) const
G4ThreeVector GetLocalVector(const G4Transform3D &trans, const G4ThreeVector &gvec) const
G4Polyhedron * fpPolyhedron
G4double DistanceToNext(const G4ThreeVector &point, const G4ThreeVector &direction, std::vector< G4int > &curVoxel) const
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4double DistanceToOutVoxels(const G4ThreeVector &aPoint, const G4ThreeVector &aDirection, G4ThreeVector *aNormalVector) const
std::vector< G4VSolid * > fSolids
G4double EstimateSurfaceArea(G4int nStat, G4double ell) const
G4int GetBitsPerSlice() const
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4MultiUnion & operator=(const G4MultiUnion &rhs)
static G4GeometryTolerance * GetInstance()
void SetBitNumber(unsigned int bitnumber, G4bool value=true)
G4double DistanceToBoundingBox(const G4ThreeVector &point) const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
void Extent(EAxis aAxis, G4double &aMin, G4double &aMax) const
EInside Inside(const G4ThreeVector &aPoint) const
void GetVoxel(std::vector< G4int > &curVoxel, const G4ThreeVector &point) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4double DistanceToOut(const G4ThreeVector &aPoint) const
G4int GetNumberOfSolids() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static int operand(pchar begin, pchar end, double &result, pchar &endp, const dic_type &dictionary)
G4double DistanceToInCandidates(const G4ThreeVector &aPoint, const G4ThreeVector &aDirection, std::vector< G4int > &candidates, G4SurfBits &bits) const
G4int SafetyFromOutsideNumberNode(const G4ThreeVector &aPoint, G4double &safety) const