762 G4int nCandidates = pCandidates->size();
763 G4int nVol, nNode, targetVolNo;
766 #ifdef G4GEOMETRY_VOXELDEBUG
767 G4cout <<
"**** G4SmartVoxelHeader::BuildNodes" <<
G4endl
768 <<
" Limits = " << pLimits <<
G4endl
769 <<
" Axis = " << pAxis <<
G4endl
770 <<
" Candidates = " << nCandidates <<
G4endl;
779 motherMinExtent, motherMaxExtent) )
782 motherMinExtent, motherMaxExtent);
797 std::ostringstream message;
798 message <<
"PANIC! - Missing parameterisation." << G4endl
799 <<
" Replicated volume with no parameterisation object !";
800 G4Exception(
"G4SmartVoxelHeader::BuildNodes()",
"GeomMgt0003",
818 for (nVol=0; nVol<nCandidates; nVol++)
820 targetVolNo=(*pCandidates)[nVol];
821 if (replicated ==
false)
837 targetSolid = pParam->
ComputeSolid(targetVolNo,pDaughter);
841 targetSolid->ComputeDimensions(pParam,targetVolNo,pDaughter);
851 if(!targetSolid->CalculateExtent(pAxis, pLimits, targetTransform,
852 targetMinExtent, targetMaxExtent))
854 targetSolid->CalculateExtent(pAxis, noLimits, targetTransform,
855 targetMinExtent,targetMaxExtent);
857 minExtents[nVol] = targetMinExtent;
858 maxExtents[nVol] = targetMaxExtent;
860 #ifdef G4GEOMETRY_VOXELDEBUG
861 G4cout <<
"---------------------------------------------------" << G4endl
862 <<
" Volume = " << pDaughter->
GetName() << G4endl
863 <<
" Min Extent = " << targetMinExtent << G4endl
864 <<
" Max Extent = " << targetMaxExtent << G4endl
865 <<
"---------------------------------------------------" <<
G4endl;
870 if ( (!pLimits.
IsLimited()) && ((targetMaxExtent<=motherMinExtent)
871 ||(targetMinExtent>=motherMaxExtent)) )
873 std::ostringstream message;
874 message <<
"PANIC! - Overlapping daughter with mother volume." << G4endl
875 <<
" Daughter physical volume "
876 << pDaughter->
GetName() << G4endl
877 <<
" is entirely outside mother logical volume "
878 << pVolume->
GetName() <<
" !!";
879 G4Exception(
"G4SmartVoxelHeader::BuildNodes()",
"GeomMgt0002",
883 #ifdef G4GEOMETRY_VOXELDEBUG
891 G4int kStraddlePercent=5;
892 width = maxExtents[nVol]-minExtents[nVol];
893 if ( (((motherMinExtent-minExtents[nVol])*100/width) > kStraddlePercent)
894 ||(((maxExtents[nVol]-motherMaxExtent)*100/width) > kStraddlePercent) )
896 G4cout <<
"**** G4SmartVoxelHeader::BuildNodes" << G4endl
897 <<
" WARNING : Daughter # " << nVol
898 <<
" name = " << pDaughter->
GetName() << G4endl
899 <<
" Crosses mother boundary of logical volume, name = "
900 << pVolume->
GetName() << G4endl
901 <<
" by more than " << kStraddlePercent
914 for (nVol=0; nVol<nCandidates; nVol++)
920 currentWidth = std::abs(maxExtents[nVol]-minExtents[nVol]);
921 if ( (currentWidth<minWidth)
925 minWidth = currentWidth;
932 G4double noNodesExactD = ((motherMaxExtent-motherMinExtent)*2.0/minWidth)+1.0;
937 G4double smartlessComputed = noNodesExactD / nCandidates;
939 G4double smartless = (smartlessComputed <= smartlessUser)
940 ? smartlessComputed : smartlessUser;
941 G4double noNodesSmart = smartless*nCandidates;
943 G4int noNodes = ((noNodesSmart-noNodesExactI)>=0.5)
944 ? noNodesExactI+1 : noNodesExactI;
945 if( noNodes == 0 ) { noNodes=1; }
947 #ifdef G4GEOMETRY_VOXELDEBUG
948 G4cout <<
" Smartless computed = " << smartlessComputed << G4endl
949 <<
" Smartless volume = " << smartlessUser
950 <<
" => # Smartless = " << smartless <<
G4endl;
951 G4cout <<
" Min width = " << minWidth
952 <<
" => # Nodes = " << noNodes <<
G4endl;
958 #ifdef G4GEOMETRY_VOXELDEBUG
962 G4double nodeWidth = (motherMaxExtent-motherMinExtent)/noNodes;
969 G4Exception(
"G4SmartVoxelHeader::BuildNodes()",
"GeomMgt0003",
973 nodeList->reserve(noNodes);
975 for (nNode=0; nNode<noNodes; nNode++)
981 G4Exception(
"G4SmartVoxelHeader::BuildNodes()",
"GeomMgt0003",
985 nodeList->push_back(pNode);
992 for (nVol=0; nVol<nCandidates; nVol++)
994 G4int nodeNo, minContainingNode, maxContainingNode;
995 minContainingNode =
G4int((minExtents[nVol]-motherMinExtent)/nodeWidth);
996 maxContainingNode =
G4int((maxExtents[nVol]-motherMinExtent)/nodeWidth);
1000 if ( (maxContainingNode>=0) && (minContainingNode<noNodes) )
1005 if (maxContainingNode>=noNodes)
1007 maxContainingNode = noNodes-1;
1012 if (minContainingNode<0)
1014 minContainingNode=0;
1016 for (nodeNo=minContainingNode; nodeNo<=maxContainingNode; nodeNo++)
1018 (*nodeList)[nodeNo]->Insert((*pCandidates)[nVol]);
1031 G4Exception(
"G4SmartVoxelHeader::BuildNodes()",
"GeomMgt0003",
1035 proxyList->reserve(noNodes);
1040 for (nNode=0; nNode<noNodes; nNode++)
1044 ((*nodeList)[nNode])->Shrink();
1048 G4Exception(
"G4SmartVoxelHeader::BuildNodes()",
"GeomMgt0003",
1052 proxyList->push_back(pProxyNode);
G4double GetSmartless() const
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
static const G4double kInfinity
virtual G4bool IsReplicated() const =0
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
const G4int kMaxVoxelNodes
const G4RotationMatrix * GetRotation() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
virtual G4VPVParameterisation * GetParameterisation() const =0
G4int GetNoDaughters() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const G4ThreeVector & GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
const G4String & GetName() const
G4double GetMaxExtent(const EAxis pAxis) const
G4double GetMinExtent(const EAxis pAxis) const