66 fRequestedDepth (requestedDepth),
67 fUseFullExtent (useFullExtent),
71 fpCurrentMaterial (0),
72 fpCurrentTransform (0),
73 fCurtailDescent (false),
75 fClippingMode (subtraction)
79 fType =
"G4PhysicalVolumeModel";
139 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
143 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
154 startingTransformation,
165 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
168 "Path at start of modeling not equal to base path. Something badly"
169 "\nwrong. Please contact visualisation coordinator.");
177 std::ostringstream o;
182 return "WARNING: NO CURRENT VOLUME - global tag is " +
fGlobalTag;
193 G4int requestedDepth,
210 if (!(pVPV -> IsReplicated ())) {
212 pSol = pLV -> GetSolid ();
213 pMaterial = pLV -> GetMaterial ();
215 theAT, sceneHandler);
224 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
228 for (
int n = 0; n < nReplicas; n++) {
229 pSol = pP -> ComputeSolid (n, pVPV);
230 pP -> ComputeTransformation (n, pVPV);
231 pSol -> ComputeDimensions (pP, n, pVPV);
232 pVPV -> SetCopyNo (n);
237 pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
239 theAT, sceneHandler);
264 pSol = pLV -> GetSolid ();
265 pMaterial = pLV -> GetMaterial ();
266 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
268 G4double originalRMin = 0., originalRMax = 0.;
270 originalRMin = ((
G4Tubs*)pSol)->GetInnerRadius();
271 originalRMax = ((
G4Tubs*)pSol)->GetOuterRadius();
273 G4bool visualisable =
true;
274 for (
int n = 0; n < nReplicas; n++) {
281 translation =
G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
284 translation =
G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
287 translation =
G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
291 ((
G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
292 ((
G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
296 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
297 "\n built-in replicated volumes replicated in radius for "
299 "-type\n solids (your solid \""
301 "\") are not visualisable."
303 visualisable =
false;
307 rotation.
rotateZ (-(offset+(n+0.5)*width));
310 pRotation = &rotation;
313 pVPV -> SetTranslation (translation);
314 pVPV -> SetRotation (pRotation);
315 pVPV -> SetCopyNo (n);
318 theAT, sceneHandler);
322 pVPV -> SetTranslation (originalTranslation);
323 pVPV -> SetRotation (pOriginalRotation);
325 ((
G4Tubs*)pSol)->SetInnerRadius(originalRMin);
326 ((
G4Tubs*)pSol)->SetOuterRadius(originalRMax);
336 G4int requestedDepth,
349 const G4ThreeVector& translation = pVPV -> GetTranslation ();
366 G4bool visAttsCreated =
false;
369 visAttsCreated =
true;
374 G4bool thisToBeDrawn =
true;
383 G4bool copyForVAM =
false;
388 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
390 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
392 for (iModifier = vams.begin();
393 iModifier != vams.end();
396 iModifier->GetPVNameCopyNoPath();
401 std::vector<G4PhysicalVolumeNodeID>::const_iterator iPVNodeId;
402 for (iVAMNameCopyNo = vamPath.begin(), iPVNodeId =
fFullPVPath.begin();
403 iVAMNameCopyNo != vamPath.end();
404 ++iVAMNameCopyNo, ++iPVNodeId) {
412 iVAMNameCopyNo->GetName() ==
413 iPVNodeId->GetPhysicalVolume()->GetName() &&
414 iVAMNameCopyNo->GetCopyNo() ==
415 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
420 if (iVAMNameCopyNo == vamPath.end()) {
424 pVisAttribs = pModifiedVisAtts;
428 switch (iModifier->GetVisAttributesSignifier()) {
484 if (cullingInvisible) {
486 if (!markedVisible) thisToBeDrawn =
false;
489 if (cullingLowDensity) {
491 if (density < densityCut) thisToBeDrawn =
false;
516 explodeFactor * oldTranslation.
dy(),
517 explodeFactor * oldTranslation.
dz());
518 theNewAT = centering * newTranslation * oldRotation * oldScale;
530 G4bool daughtersToBeDrawn =
true;
532 if (!nDaughters) daughtersToBeDrawn =
false;
534 else if (requestedDepth == 0) daughtersToBeDrawn =
false;
559 if (cullingInvisible) {
561 if (daughtersInvisible) daughtersToBeDrawn =
false;
564 if (cullingCovered) {
566 if (surfaceDrawing) {
570 if (opaque) daughtersToBeDrawn =
false;
579 delete pModifiedVisAtts;
580 pVisAttribs = pUnmodifiedVisAtts;
584 if (visAttsCreated)
delete pVisAttribs;
586 if (daughtersToBeDrawn) {
587 for (
G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
593 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
640 "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
642 "\" has no polyhedron. Cannot by clipped."
668 (
"sectioned_solid", pSol, pSectionSolid, theAT.
inverse());
673 (
"cutaway_solid", pSol, pCutawaySolid, theAT.
inverse());
677 if (tmpResultant) resultant = *tmpResultant;
681 "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
682 "\n solid \"" << pSol->
GetName() <<
683 "\" not defined due to error during Boolean processing."
684 "\n Original will be drawn in red."
689 delete resultantSolid;
706 size_t nWorlds = transportationManager->
GetNoWorlds();
710 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
712 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
725 if (foundVolume !=
fpTopPV && warn) {
727 "G4PhysicalVolumeModel::Validate(): A volume of the same name and"
730 <<
") still exists and is being used."
731 "\n But it is not the same volume you originally specified"
732 "\n in /vis/scene/add/."
740 if (found)
return true;
744 "G4PhysicalVolumeModel::Validate(): No volume of name and"
757 std::map<G4String,G4AttDef>* store
761 G4AttDef(
"PVPath",
"Physical Volume Path",
"Physics",
"",
"G4String");
763 G4AttDef(
"LVol",
"Logical Volume",
"Physics",
"",
"G4String");
765 G4AttDef(
"Solid",
"Solid Name",
"Physics",
"",
"G4String");
767 G4AttDef(
"EType",
"Entity Type",
"Physics",
"",
"G4String");
769 G4AttDef(
"DmpSol",
"Dump of Solid properties",
"Physics",
"",
"G4String");
771 G4AttDef(
"Trans",
"Transformation of volume",
"Physics",
"",
"G4String");
772 (*store)[
"Material"] =
773 G4AttDef(
"Material",
"Material Name",
"Physics",
"",
"G4String");
774 (*store)[
"Density"] =
775 G4AttDef(
"Density",
"Material Density",
"Physics",
"G4BestUnit",
"G4double");
777 G4AttDef(
"State",
"Material State (enum undefined,solid,liquid,gas)",
"Physics",
"",
"G4String");
779 G4AttDef(
"Radlen",
"Material Radiation Length",
"Physics",
"G4BestUnit",
"G4double");
781 G4AttDef(
"Region",
"Cuts Region",
"Physics",
"",
"G4String");
782 (*store)[
"RootRegion"] =
783 G4AttDef(
"RootRegion",
"Root Region (0/1 = false/true)",
"Physics",
"",
"G4bool");
790static std::ostream& operator<< (std::ostream& o,
const G4Transform3D t)
802 o << setw(w) << t.
xx() << setw(w) << t.
xy() << setw(w) << t.
xz() << setw(w) << t.
dx() << endl;
803 o << setw(w) << t.
yx() << setw(w) << t.
yy() << setw(w) << t.
yz() << setw(w) << t.
dy() << endl;
804 o << setw(w) << t.
zx() << setw(w) << t.
zy() << setw(w) << t.
zz() << setw(w) << t.
dz() << endl;
807 o <<
"= translation:" << endl;
808 o << setw(w) << tl.
dx() << setw(w) << tl.
dy() << setw(w) << tl.
dz() << endl;
811 o <<
"* rotation:" << endl;
812 o << setw(w) << r.
xx() << setw(w) << r.
xy() << setw(w) << r.
xz() << endl;
813 o << setw(w) << r.
yx() << setw(w) << r.
yy() << setw(w) << r.
yz() << endl;
814 o << setw(w) << r.
zx() << setw(w) << r.
zy() << setw(w) << r.
zz() << endl;
817 o <<
"* scale:" << endl;
818 o << setw(w) << sc.
xx() << setw(w) << sc.
yy() << setw(w) << sc.
zz() << endl;
821 o <<
"Transformed axes:" << endl;
822 o <<
"x': " << r *
G4Vector3D(1., 0., 0.) << endl;
823 o <<
"y': " << r *
G4Vector3D(0., 1., 0.) << endl;
824 o <<
"z': " << r *
G4Vector3D(0., 0., 1.) << endl;
831 std::vector<G4AttValue>* values =
new std::vector<G4AttValue>;
832 std::ostringstream oss;
834 oss <<
fFullPVPath[i].GetPhysicalVolume()->GetName()
841 (
"G4PhysicalVolumeModel::CreateCurrentAttValues",
844 "Current logical volume not defined.");
848 values->push_back(
G4AttValue(
"PVPath", oss.str(),
""));
853 oss.str(
""); oss <<
'\n' << *pSol;
854 values->push_back(
G4AttValue(
"DmpSol", oss.str(),
""));
856 values->push_back(
G4AttValue(
"Trans", oss.str(),
""));
858 values->push_back(
G4AttValue(
"Material", matName,
""));
862 oss.str(
""); oss << matState;
863 values->push_back(
G4AttValue(
"State", oss.str(),
""));
868 values->push_back(
G4AttValue(
"Region", regionName,
""));
870 values->push_back(
G4AttValue(
"RootRegion", oss.str(),
""));
874G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
877 if (fpPV < right.fpPV)
return true;
878 if (fpPV == right.fpPV) {
879 if (fCopyNo < right.fCopyNo)
return true;
880 if (fCopyNo == right.fCopyNo)
881 return fNonCulledDepth < right.fNonCulledDepth;
886std::ostream&
operator<<
892 <<
':' << node.GetCopyNo()
893 <<
'[' << node.GetNonCulledDepth() <<
']'
894 <<
':' << node.GetTransform();
895 if (!node.GetDrawn()) os <<
" Not "; os <<
"drawn";
903(
const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
904 fFullPVPath(fullPVPath) {}
910 G4Exception(
"G4PhysicalVolumeModelTouchable::GetTranslation",
913 "Index out of range. Asking for non-existent depth");
916 tempTranslation =
fFullPVPath[i].GetTransform().getTranslation();
917 return tempTranslation;
924 G4Exception(
"G4PhysicalVolumeModelTouchable::GetRotation",
927 "Index out of range. Asking for non-existent depth");
930 tempRotation =
fFullPVPath[i].GetTransform().getRotation();
931 return &tempRotation;
938 G4Exception(
"G4PhysicalVolumeModelTouchable::GetVolume",
941 "Index out of range. Asking for non-existent depth");
950 G4Exception(
"G4PhysicalVolumeModelTouchable::GetSolid",
953 "Index out of range. Asking for non-existent depth");
955 return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
962 G4Exception(
"G4PhysicalVolumeModelTouchable::GetReplicaNumber",
965 "Index out of range. Asking for non-existent depth");
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Vector3D< G4double > G4Vector3D
G4DLLIMPORT std::ostream G4cout
HepRotation & rotateZ(double delta)
const G4Point3D & GetCentre() const
G4double GetRadius() const
G4double GetAlpha() const
G4VSolid * GetSolid() const
const G4VisAttributes * GetVisAttributes() const
G4int GetNoDaughters() const
G4bool IsRootRegion() const
G4Region * GetRegion() const
G4double GetDensity() const
G4double GetRadlen() const
const G4String & GetName() const
const G4VisAttributes * GetDefaultVisAttributes() const
G4VSolid * GetCutawaySolid() const
const std::vector< VisAttributesModifier > & GetVisAttributesModifiers() const
const G4Point3D & GetExplodeCentre() const
PVNameCopyNoPath::const_iterator PVNameCopyNoPathConstIterator
std::vector< PVNameCopyNo > PVNameCopyNoPath
G4bool IsCullingInvisible() const
G4int GetNoOfSides() const
@ VASForceLineSegmentsPerCircle
G4bool IsDensityCulling() const
void SetDefaultVisAttributes(const G4VisAttributes *pDefaultVisAttributes)
DrawingStyle GetDrawingStyle() const
G4double GetExplodeFactor() const
G4bool IsCullingCovered() const
G4VSolid * GetSectionSolid() const
G4VSolid * GetSolid(G4int depth) const
G4VPhysicalVolume * GetVolume(G4int depth) const
G4int GetReplicaNumber(G4int depth) const
const G4RotationMatrix * GetRotation(G4int depth) const
G4PhysicalVolumeModelTouchable(const std::vector< G4PhysicalVolumeNodeID > &fullPVPath)
const G4ThreeVector & GetTranslation(G4int depth) const
void DescribeAndDescend(G4VPhysicalVolume *, G4int requestedDepth, G4LogicalVolume *, G4VSolid *, G4Material *, const G4Transform3D &, G4VGraphicsScene &)
std::vector< G4PhysicalVolumeNodeID > fFullPVPath
G4VPhysicalVolume * fpTopPV
void VisitGeometryAndGetVisReps(G4VPhysicalVolume *, G4int requestedDepth, const G4Transform3D &, G4VGraphicsScene &)
std::vector< G4AttValue > * CreateCurrentAttValues() const
G4VSolid * fpClippingSolid
G4Material * fpCurrentMaterial
virtual ~G4PhysicalVolumeModel()
G4Transform3D * fpCurrentTransform
G4String GetCurrentTag() const
std::vector< G4PhysicalVolumeNodeID > fDrawnPVPath
G4bool Validate(G4bool warn)
virtual void DescribeSolid(const G4Transform3D &theAT, G4VSolid *pSol, const G4VisAttributes *pVisAttribs, G4VGraphicsScene &sceneHandler)
ClippingMode fClippingMode
G4String GetCurrentDescription() const
void DescribeYourselfTo(G4VGraphicsScene &)
std::vector< G4PhysicalVolumeNodeID > fBaseFullPVPath
G4PhysicalVolumeModel(G4VPhysicalVolume *=0, G4int requestedDepth=UNLIMITED, const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0, G4bool useFullExtent=false)
G4VPhysicalVolume * fpCurrentPV
const std::map< G4String, G4AttDef > * GetAttDefs() const
G4LogicalVolume * fpCurrentLV
G4VPhysicalVolume * GetFoundVolume() const
const G4String & GetName() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void PostAddSolid()=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
void SetModelingParameters(const G4ModelingParameters *)
G4String fGlobalDescription
const G4VisExtent & GetExtent() const
const G4ModelingParameters * fpMP
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
virtual G4Polyhedron * GetPolyhedron() const
virtual G4GeometryType GetEntityType() const =0
void SetForceAuxEdgeVisible(G4bool)
G4bool IsForceLineSegmentsPerCircle() const
G4double GetLineWidth() const
void SetVisibility(G4bool)
G4bool IsDaughtersInvisible() const
void SetColour(const G4Colour &)
void SetDaughtersInvisible(G4bool)
void SetForceWireframe(G4bool)
G4int GetForcedLineSegmentsPerCircle() const
void SetLineWidth(G4double)
LineStyle GetLineStyle() const
const G4Colour & GetColour() const
void SetForceSolid(G4bool)
G4bool IsForceAuxEdgeVisible() const
ForcedDrawingStyle GetForcedDrawingStyle() const
void SetLineStyle(LineStyle)
void SetForceLineSegmentsPerCircle(G4int nSegments)
G4bool IsForceDrawingStyle() const
void SetVisAttributes(const G4VisAttributes *)
static void SetNumberOfRotationSteps(G4int n)
static void ResetNumberOfRotationSteps()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::map< G4String, G4AttDef > * GetInstance(G4String storeKey, G4bool &isNew)