Skip to content
Snippets Groups Projects
Commit cc5dd22d authored by Evgueni Tcherniaev's avatar Evgueni Tcherniaev
Browse files

Back to previous version of G4VPhysicalVolume

parent c39aad5f
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VPhysicalVolume.hh 103091 2017-03-15 13:42:43Z gcosmo $
// $Id: G4VPhysicalVolume.hh 83991 2014-09-26 09:22:26Z gcosmo $
//
//
// class G4VPhysicalVolume
......@@ -115,11 +115,11 @@ class G4VPhysicalVolume
// (They are the inverse of each other).
G4RotationMatrix* GetObjectRotation() const; // Obsolete
G4RotationMatrix GetObjectRotationValue() const; // Replacement
G4ThreeVector GetObjectTranslation() const;
inline G4RotationMatrix GetObjectRotationValue() const; // Replacement
inline G4ThreeVector GetObjectTranslation() const;
// Return the rotation/translation of the Object relative to the mother.
const G4RotationMatrix* GetFrameRotation() const;
G4ThreeVector GetFrameTranslation() const;
inline const G4RotationMatrix* GetFrameRotation() const;
inline G4ThreeVector GetFrameTranslation() const;
// Return the rotation/translation of the Frame used to position
// this volume in its mother volume (opposite of object rot/trans).
......@@ -132,9 +132,9 @@ class G4VPhysicalVolume
// Set functions
void SetTranslation(const G4ThreeVector &v);
inline void SetTranslation(const G4ThreeVector &v);
inline G4RotationMatrix* GetRotation();
void SetRotation(G4RotationMatrix*);
inline void SetRotation(G4RotationMatrix*);
// NOT INTENDED FOR GENERAL USE.
// Non constant versions of above. Used to change transformation
// for replication/parameterisation mechanism.
......@@ -212,9 +212,6 @@ class G4VPhysicalVolume
static const G4PVManager& GetSubInstanceManager();
// Returns the private data instance manager.
static void Clean();
// Clear memory allocated by sub-instance manager.
protected:
void InitialiseWorker(G4VPhysicalVolume *pMasterObject,
......@@ -242,13 +239,11 @@ class G4VPhysicalVolume
private:
G4LogicalVolume* flogical; // The logical volume representing the
G4LogicalVolume *flogical; // The logical volume representing the
// physical and tracking attributes of
// the volume
G4String fname; // The name of the volume
G4LogicalVolume* flmother; // The current mother logical volume
G4PVData* pvdata; // Shadow pointer for use of object persistency
G4LogicalVolume *flmother; // The current mother logical volume
};
// NOTE:
......
// -*- c++ -*-
//
// ********************************************************************
// * License and Disclaimer *
// * *
......@@ -24,13 +24,21 @@
// ********************************************************************
//
//
// $Id: G4VPhysicalVolume.icc 99377 2016-09-20 09:43:16Z gcosmo $
// $Id: G4VPhysicalVolume.icc 74466 2013-10-07 15:36:32Z gcosmo $
//
//
// class G4VPhysicalVolume Inline Implementation
//
// --------------------------------------------------------------------
// These macros change the references to fields that are now encapsulated
// in the class G4PVData.
//
#define G4MT_rot ((subInstanceManager.offset[instanceID]).frot)
#define G4MT_trans ((subInstanceManager.offset[instanceID]).ftrans)
#define G4MT_pvdata (subInstanceManager.offset[instanceID])
inline
G4bool G4VPhysicalVolume::operator == (const G4VPhysicalVolume& right) const
{
......@@ -43,6 +51,37 @@ G4int G4VPhysicalVolume::GetInstanceID() const
return instanceID;
}
inline
const G4ThreeVector& G4VPhysicalVolume::GetTranslation() const
{
return G4MT_trans;
}
inline
void G4VPhysicalVolume::SetTranslation(const G4ThreeVector &vec)
{
G4MT_trans=vec;
}
inline
const G4RotationMatrix* G4VPhysicalVolume::GetRotation() const
{
return G4MT_rot;
}
inline
G4RotationMatrix* G4VPhysicalVolume::GetRotation()
{
return G4MT_rot;
}
inline
void G4VPhysicalVolume::SetRotation(G4RotationMatrix *pRot)
{
G4MT_rot=pRot;
}
inline
G4LogicalVolume* G4VPhysicalVolume::GetLogicalVolume() const
{
......@@ -100,19 +139,35 @@ EVolume G4VPhysicalVolume::VolumeType() const
}
inline
const G4RotationMatrix* G4VPhysicalVolume::GetRotation() const
G4RotationMatrix G4VPhysicalVolume::GetObjectRotationValue() const
{
return (subInstanceManager.offset[instanceID]).frot;
G4RotationMatrix aRotM; // Initialised to identity
// Insure against G4MT_rot being a null pointer
if(G4MT_rot)
{
aRotM= G4MT_rot->inverse();
}
return aRotM;
}
inline
G4RotationMatrix* G4VPhysicalVolume::GetRotation()
G4ThreeVector G4VPhysicalVolume::GetObjectTranslation() const
{
return (subInstanceManager.offset[instanceID]).frot;
return G4MT_trans;
}
inline
const G4ThreeVector& G4VPhysicalVolume::GetTranslation() const
const G4RotationMatrix* G4VPhysicalVolume::GetFrameRotation() const
{
return (subInstanceManager.offset[instanceID]).ftrans;
return G4MT_rot;
}
inline
G4ThreeVector G4VPhysicalVolume::GetFrameTranslation() const
{
return -G4MT_trans;
}
#undef G4MT_rot
#undef G4MT_trans
......@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VPhysicalVolume.cc 103091 2017-03-15 13:42:43Z gcosmo $
// $Id: G4VPhysicalVolume.cc 83991 2014-09-26 09:22:26Z gcosmo $
//
//
// class G4VPhysicalVolume Implementation
......@@ -36,16 +36,48 @@
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
// This static member is thread local. For each thread, it points to the
// array of G4PVData instances.
//
template <class G4PVData> G4ThreadLocal
G4PVData* G4GeomSplitter<G4PVData>::offset = 0;
// This new field helps to use the class G4PVManager
//
G4PVManager G4VPhysicalVolume::subInstanceManager;
// These macros change the references to fields that are now encapsulated
// in the class G4PVData.
// This method is similar to the constructor. It is used by each worker
// thread to achieve the same effect as that of the master thread exept
// to register the new created instance. This method is invoked explicitly.
// It does not create a new G4VPhysicalVolume instance.
// It only assign the value for the fields encapsulated by the class G4PVData.
//
#define G4MT_rot ((subInstanceManager.offset[instanceID]).frot)
#define G4MT_trans ((subInstanceManager.offset[instanceID]).ftrans)
#define G4MT_pvdata (subInstanceManager.offset[instanceID])
void G4VPhysicalVolume::
InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
G4RotationMatrix *pRot,
const G4ThreeVector &tlate)
{
subInstanceManager.SlaveCopySubInstanceArray();
this->SetRotation( pRot ); // G4MT_rot = pRot;
this->SetTranslation( tlate ); // G4MT_trans = tlate;
// G4PhysicalVolumeStore::Register(this);
}
// This method is similar to the destructor. It is used by each worker
// thread to achieve the partial effect as that of the master thread.
// For G4VPhysicalVolume instances, nothing more to do here.
//
void G4VPhysicalVolume::TerminateWorker( G4VPhysicalVolume* /*pMasterObject*/)
{
}
// Returns the private data instance manager.
//
const G4PVManager& G4VPhysicalVolume::GetSubInstanceManager()
{
return subInstanceManager;
}
// Constructor: init parameters and register in Store
//
......@@ -61,12 +93,6 @@ G4VPhysicalVolume::G4VPhysicalVolume( G4RotationMatrix *pRot,
this->SetRotation( pRot ); // G4MT_rot = pRot;
this->SetTranslation( tlate ); // G4MT_trans = tlate;
// Initialize 'Shadow' data structure - for use by object persistency
pvdata = new G4PVData();
pvdata->frot = pRot;
pvdata->ftrans = G4ThreeVector(tlate);
G4PhysicalVolumeStore::Register(this);
}
......@@ -74,7 +100,7 @@ G4VPhysicalVolume::G4VPhysicalVolume( G4RotationMatrix *pRot,
// for usage restricted to object persistency.
//
G4VPhysicalVolume::G4VPhysicalVolume( __void__& )
: flogical(0), fname(""), flmother(0), pvdata(0)
: flogical(0), fname(""), flmother(0)
{
// Register to store
//
......@@ -87,65 +113,14 @@ G4VPhysicalVolume::G4VPhysicalVolume( __void__& )
//
G4VPhysicalVolume::~G4VPhysicalVolume()
{
delete pvdata;
G4PhysicalVolumeStore::DeRegister(this);
}
// This method is similar to the constructor. It is used by each worker
// thread to achieve the same effect as that of the master thread exept
// to register the new created instance. This method is invoked explicitly.
// It does not create a new G4VPhysicalVolume instance.
// It only assign the value for the fields encapsulated by the class G4PVData.
//
void G4VPhysicalVolume::
InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
G4RotationMatrix *pRot,
const G4ThreeVector &tlate)
{
subInstanceManager.SlaveCopySubInstanceArray();
this->SetRotation( pRot ); // G4MT_rot = pRot;
this->SetTranslation( tlate ); // G4MT_trans = tlate;
// G4PhysicalVolumeStore::Register(this);
}
// Release memory allocated for offset
//
void G4VPhysicalVolume::Clean()
{
subInstanceManager.FreeSlave();
}
// This method is similar to the destructor. It is used by each worker
// thread to achieve the partial effect as that of the master thread.
// For G4VPhysicalVolume instances, nothing more to do here.
//
void G4VPhysicalVolume::TerminateWorker( G4VPhysicalVolume* /*pMasterObject*/)
{
}
// Returns the private data instance manager.
//
const G4PVManager& G4VPhysicalVolume::GetSubInstanceManager()
{
return subInstanceManager;
}
G4int G4VPhysicalVolume::GetMultiplicity() const
{
return 1;
}
void G4VPhysicalVolume::SetTranslation(const G4ThreeVector &vec)
{
G4MT_trans=vec;
}
void G4VPhysicalVolume::SetRotation(G4RotationMatrix *pRot)
{
G4MT_rot=pRot;
}
G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
{
static G4RotationMatrix aRotM;
......@@ -162,33 +137,6 @@ G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
return retval;
}
G4RotationMatrix G4VPhysicalVolume::GetObjectRotationValue() const
{
G4RotationMatrix aRotM; // Initialised to identity
// Insure against G4MT_rot being a null pointer
if(G4MT_rot)
{
aRotM= G4MT_rot->inverse();
}
return aRotM;
}
G4ThreeVector G4VPhysicalVolume::GetObjectTranslation() const
{
return G4MT_trans;
}
const G4RotationMatrix* G4VPhysicalVolume::GetFrameRotation() const
{
return G4MT_rot;
}
G4ThreeVector G4VPhysicalVolume::GetFrameTranslation() const
{
return -G4MT_trans;
}
// Only implemented for placed and parameterised volumes.
// Not required for replicas.
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment