Import Geant4 5.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:57:27 +02:00
parent 330b82b769
commit 37fff30d2e
5733 changed files with 263867 additions and 74574 deletions
+14 -1
View File
@@ -1,5 +1,5 @@
$Id: History,v 1.32 2002/05/13 06:56:49 gcosmo Exp $
$Id: History,v 1.34 2002/10/29 14:16:22 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,19 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Oct 29 2002 Gabriele Cosmo geom-bool-V04-01-01
- Added method CleanTransformations() to G4DisplacedSolid and corrected
implementation in destructor of G4BooleanSolid to not call for deletion
of G4VSolid in the case where displacement is used.
This fixes a problem noticed on Linux-g++ at application closeout for
double deletion of a solid in such special case.
Oct 28 2002 Gabriele Cosmo geom-bool-V04-01-00
- Added implementation of StreamInfo() to comply with new interface for
G4VSolid in "geommng-V04-01-03".
- Some cosmetic changes to code formatting.
- Extended unit tests to include new user test-cases (V.Grichine).
May 11 2002 Vladimir Grichine geom-bool-V04-00-05
- G4ReflectedSolid.cc: bounding-box like algorithm for CalculateExtent().
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.hh,v 1.5 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4BooleanSolid.hh,v 1.6 2002/10/28 11:36:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// class G4BooleanSolid
@@ -34,7 +34,9 @@
// History:
//
// 10.09.98 V.Grichine, creation according J. Apostolakis's recommendations.
// 10.09.98 V.Grichine, created
//
// ********************************************************************
#ifndef G4BOOLEANSOLID_HH
@@ -75,6 +77,10 @@ class G4BooleanSolid : public G4VSolid
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0.
virtual G4GeometryType GetEntityType() const;
G4std::ostream& StreamInfo(G4std::ostream& os) const;
protected:
G4VSolid* fPtrSolidA ;
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4DisplacedSolid.hh,v 1.11 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4DisplacedSolid.hh,v 1.13 2002/10/29 14:13:53 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// class G4DisplacedSolid
@@ -35,8 +35,10 @@
// History:
//
// 28.10.98 V.Grichine, creation according J. Apostolakis's recommendations
// 22.11.00 V.Grichine, new set methods for matrix/vectors
// 28.10.98 V.Grichine: created
// 22.11.00 V.Grichine: new set methods for matrix/vectors
//
// ********************************************************************
#ifndef G4DisplacedSolid_HH
#define G4DisplacedSolid_HH
@@ -97,7 +99,9 @@ class G4DisplacedSolid : public G4VSolid
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep ) ;
void CleanTransformations();
public: // with description
virtual G4GeometryType GetEntityType() const;
@@ -130,6 +134,8 @@ class G4DisplacedSolid : public G4VSolid
void SetObjectTranslation(const G4ThreeVector&);
// Get/Set the rotation/translation, as applied to the object.
G4std::ostream& StreamInfo(G4std::ostream& os) const;
public: // without description
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
@@ -151,7 +157,3 @@ class G4DisplacedSolid : public G4VSolid
} ;
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4IntersectionSolid.hh,v 1.5 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4IntersectionSolid.hh,v 1.6 2002/10/28 11:36:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// class G4IntersectionSolid
@@ -33,9 +33,10 @@
// History:
//
// 12.09.98 V. Grichine, initial design according to J.Apostolakis's
// recommendations
// 28.10.98 V. Grichine, addition of two constructors with G4PlacedSolid
// 12.09.98 V.Grichine: initial design and implementation
// 28.10.98 V.Grichine: addition of two constructors with G4PlacedSolid
//
// ********************************************************************
#ifndef G4INTERSECTIONSOLID_HH
#define G4INTERSECTIONSOLID_HH
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ReflectedSolid.hh,v 1.5 2002/02/15 15:55:25 grichine Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4ReflectedSolid.hh,v 1.6 2002/10/28 11:36:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// class G4ReflectedSolid
@@ -34,8 +34,10 @@
// History:
//
// 23.07.01 V.Grichine, creation according John/Gabriele recommendations
// 15.02.02 V.Grichine, get/set methods for fPtr(Direct)Transform3D
// 23.07.01 V.Grichine: created
// 15.02.02 V.Grichine: get/set methods for fPtr(Direct)Transform3D
//
// ********************************************************************
#ifndef G4ReflectedSolid_HH
#define G4ReflectedSolid_HH
@@ -64,10 +66,10 @@ class G4ReflectedSolid : public G4VSolid
EInside Inside( const G4ThreeVector& p ) const ;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const ;
G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const ;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const ;
@@ -77,16 +79,15 @@ class G4ReflectedSolid : public G4VSolid
G4double DistanceToIn( const G4ThreeVector& p) const ;
G4double DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const ;
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const ;
G4double DistanceToOut( const G4ThreeVector& p ) const ;
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep ) ;
public: // with description
@@ -106,6 +107,7 @@ class G4ReflectedSolid : public G4VSolid
void SetDirectTransform3D(G4Transform3D&);
// Accessors methods.
G4std::ostream& StreamInfo(G4std::ostream& os) const;
public: // without description
@@ -148,11 +150,3 @@ class G4ReflectedSolid : public G4VSolid
} ;
#endif
@@ -22,7 +22,7 @@
//
//
// $Id: G4ReflectionFactory.hh,v 1.1 2001/10/18 10:05:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// class G4Reflection
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4SubtractionSolid.hh,v 1.5 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4SubtractionSolid.hh,v 1.6 2002/10/28 11:36:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// class G4SubtractionSolid
@@ -33,8 +33,9 @@
// History:
//
// 14.10.98 V.Grichine - first implementation.
// 14.10.98 V.Grichine: first implementation
//
// ********************************************************************
#ifndef G4SUBTRACTIONSOLID_HH
#define G4SUBTRACTIONSOLID_HH
@@ -74,9 +75,9 @@ class G4SubtractionSolid : public G4BooleanSolid
public: // without description
G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const ;
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const ;
EInside Inside( const G4ThreeVector& p ) const ;
@@ -88,16 +89,16 @@ class G4SubtractionSolid : public G4BooleanSolid
G4double DistanceToIn( const G4ThreeVector& p) const ;
G4double DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const ;
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const ;
G4double DistanceToOut( const G4ThreeVector& p ) const ;
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep ) ;
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
@@ -107,4 +108,3 @@ class G4SubtractionSolid : public G4BooleanSolid
};
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.hh,v 1.6 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4UnionSolid.hh,v 1.7 2002/10/28 11:36:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// class G4UnionSolid
@@ -33,7 +33,9 @@
// History:
//
// 12.09.98 V.Grichine, created.
// 12.09.98 V.Grichine: created
//
// ********************************************************************
#ifndef G4UNIONSOLID_HH
#define G4UNIONSOLID_HH
@@ -72,9 +74,9 @@ class G4UnionSolid : public G4BooleanSolid
public: // without description
G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const ;
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax ) const ;
EInside Inside( const G4ThreeVector& p ) const ;
@@ -83,19 +85,19 @@ class G4UnionSolid : public G4BooleanSolid
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const ;
G4double DistanceToIn( const G4ThreeVector& p) const ;
G4double DistanceToIn( const G4ThreeVector& p ) const ;
G4double DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const ;
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const ;
G4double DistanceToOut( const G4ThreeVector& p ) const ;
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep ) ;
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
@@ -105,4 +107,3 @@ class G4UnionSolid : public G4BooleanSolid
};
#endif
@@ -21,15 +21,17 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.cc,v 1.6 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4BooleanSolid.cc,v 1.8 2002/10/29 14:15:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Implementation for the abstract base class for solids created by boolean
// operations between other solids
//
// History:
//
// 10.09.98 V.Grichine, creation according J. Apostolakis's recommendations
// 10.09.98 V.Grichine, created
//
// ********************************************************************
#include "G4BooleanSolid.hh"
#include "G4DisplacedSolid.hh"
@@ -41,7 +43,7 @@
//////////////////////////////////////////////////////////////////
//
//
// Constructor
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidA ,
@@ -55,7 +57,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
//////////////////////////////////////////////////////////////////
//
//
// Constructor
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidA ,
@@ -71,7 +73,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
//////////////////////////////////////////////////////////////////
//
//
// Constructor
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidA ,
@@ -86,11 +88,14 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
///////////////////////////////////////////////////////////////
//
// Destructor deletes second pointer created by 'new'
// Destructor deletes transformation contents of the created displaced solid
G4BooleanSolid::~G4BooleanSolid()
{
if(createdDisplacedSolid) delete fPtrSolidB ;
if(createdDisplacedSolid)
{
((G4DisplacedSolid*)fPtrSolidB)->CleanTransformations();
}
}
///////////////////////////////////////////////////////////////
@@ -98,6 +103,7 @@ G4BooleanSolid::~G4BooleanSolid()
// If Solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0
const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
{
const G4VSolid* subSolid=0;
@@ -106,12 +112,21 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
else if( no == 1 )
subSolid = fPtrSolidB;
else
G4Exception("G4BooleanSolid::GetConstituentSolid() - invalid subsolid index");
{
DumpInfo();
G4Exception("G4BooleanSolid::GetConstituentSolid() - invalid solid index");
}
return subSolid;
}
G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no)
///////////////////////////////////////////////////////////////
//
// If Solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0
G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no)
{
G4VSolid* subSolid=0;
if( no == 0 )
@@ -119,11 +134,38 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
else if( no == 1 )
subSolid = fPtrSolidB;
else
G4Exception("G4BooleanSolid::GetConstituentSolid() - invalid subsolid index");
{
DumpInfo();
G4Exception("G4BooleanSolid::GetConstituentSolid() - invalid solid index");
}
return subSolid;
}
//////////////////////////////////////////////////////////////////////////
//
// Returns entity type
G4GeometryType G4BooleanSolid::GetEntityType() const
{
return G4String("G4BooleanSolid");
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
G4std::ostream& G4BooleanSolid::StreamInfo(G4std::ostream& os) const
{
os << "-----------------------------------------------------------\n"
<< " *** Dump for Boolean solid - " << GetName() << " ***\n"
<< " ===================================================\n"
<< " Solid type: " << GetEntityType() << "\n"
<< " Parameters of constituent solids: \n"
<< "===========================================================\n";
fPtrSolidA->StreamInfo(os);
fPtrSolidB->StreamInfo(os);
os << "===========================================================\n";
return os;
}
@@ -21,21 +21,22 @@
// ********************************************************************
//
//
// $Id: G4DisplacedSolid.cc,v 1.14 2001/07/11 09:59:52 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4DisplacedSolid.cc,v 1.16 2002/10/29 14:13:53 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Implementation for G4DisplacedSolid class for boolean
// operations between other solids
//
// History:
//
// 28.10.98 V.Grichine, creation according J. Apostolakis's recommendations
// 14.11.99 V.Grichine, modifications in CalculateExtent(...) method
// 22.11.00 V.Grichine, new set methods for matrix/vectors
// 28.10.98 V.Grichine: created
// 14.11.99 V.Grichine: modifications in CalculateExtent(...) method
// 22.11.00 V.Grichine: new set methods for matrix/vectors
//
// ********************************************************************
#include "G4DisplacedSolid.hh"
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -48,15 +49,14 @@
////////////////////////////////////////////////////////////////
//
// Constractor for transformation like rotation of frame then translation
// Constructor for transformation like rotation of frame then translation
// in new frame. It is similar to 1st constractor in G4PVPlacement
G4DisplacedSolid::
G4DisplacedSolid( const G4String& pName,
G4VSolid* pSolid ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector )
: G4VSolid(pName)
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
G4VSolid* pSolid ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector )
: G4VSolid(pName)
{
fPtrSolid = pSolid ;
fPtrTransform = new G4AffineTransform(rotMatrix,transVector) ;
@@ -66,11 +66,12 @@ G4DisplacedSolid( const G4String& pName,
/////////////////////////////////////////////////////////////////////////////////
//
//
// Constructor
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4Transform3D& transform ) :
G4VSolid(pName)
const G4Transform3D& transform )
: G4VSolid(pName)
{
fPtrSolid = pSolid ;
fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
@@ -81,14 +82,15 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
fPtrTransform->Invert() ;
}
/////////////////////////////////////////////////////////////////////////////////
// Constructor for use with creation of Transient object from Persistent object
///////////////////////////////////////////////////////////////////
//
// Constructor for use with creation of Transient object
// from Persistent object
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4AffineTransform directTransform ) :
G4VSolid(pName)
G4VSolid* pSolid ,
const G4AffineTransform directTransform )
: G4VSolid(pName)
{
fPtrSolid = pSolid ;
fDirectTransform = new G4AffineTransform( directTransform );
@@ -97,26 +99,36 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
///////////////////////////////////////////////////////////////////
//
// Destructor
G4DisplacedSolid::~G4DisplacedSolid()
{
if(fPtrTransform)
{
delete fPtrTransform ;
delete fDirectTransform;
}
CleanTransformations();
}
G4GeometryType G4DisplacedSolid::GetEntityType() const
{
return G4String("G4DisplacedSolid");
return G4String("G4DisplacedSolid");
}
void G4DisplacedSolid::CleanTransformations()
{
if(fPtrTransform)
{
delete fPtrTransform; fPtrTransform=0;
delete fDirectTransform; fDirectTransform=0;
}
}
const G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr() const
{ return this; }
{
return this;
}
G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr()
{ return this; }
G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr()
{
return this;
}
G4VSolid* G4DisplacedSolid::GetConstituentMovedSolid() const
{
@@ -127,46 +139,46 @@ G4VSolid* G4DisplacedSolid::GetConstituentMovedSolid() const
G4AffineTransform G4DisplacedSolid::GetTransform() const
{
G4AffineTransform aTransform = *fPtrTransform;
return aTransform;
G4AffineTransform aTransform = *fPtrTransform;
return aTransform;
}
void G4DisplacedSolid::SetTransform(G4AffineTransform& transform)
{
fPtrTransform = &transform ;
fPtrTransform = &transform ;
}
//////////////////////////////////////////////////////////////////////////////
G4AffineTransform G4DisplacedSolid::GetDirectTransform() const
{
G4AffineTransform aTransform= *fDirectTransform;
return aTransform;
G4AffineTransform aTransform= *fDirectTransform;
return aTransform;
}
void G4DisplacedSolid::SetDirectTransform(G4AffineTransform& transform)
{
fDirectTransform = &transform ;
fDirectTransform = &transform ;
}
/////////////////////////////////////////////////////////////////////////////
G4RotationMatrix G4DisplacedSolid::GetFrameRotation() const
{
G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
return InvRotation;
G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
return InvRotation;
}
void G4DisplacedSolid::SetFrameRotation(const G4RotationMatrix& matrix)
{
fDirectTransform->SetNetRotation(matrix);
fDirectTransform->SetNetRotation(matrix);
}
/////////////////////////////////////////////////////////////////////////////
G4ThreeVector G4DisplacedSolid::GetFrameTranslation() const
{
return fPtrTransform->NetTranslation();
return fPtrTransform->NetTranslation();
}
void G4DisplacedSolid::SetFrameTranslation(const G4ThreeVector& vector)
@@ -178,20 +190,20 @@ void G4DisplacedSolid::SetFrameTranslation(const G4ThreeVector& vector)
G4RotationMatrix G4DisplacedSolid::GetObjectRotation() const
{
G4RotationMatrix Rotation= fPtrTransform->NetRotation();
return Rotation;
G4RotationMatrix Rotation= fPtrTransform->NetRotation();
return Rotation;
}
void G4DisplacedSolid::SetObjectRotation(const G4RotationMatrix& matrix)
{
fPtrTransform->SetNetRotation(matrix);
fPtrTransform->SetNetRotation(matrix);
}
///////////////////////////////////////////////////////////////////////
G4ThreeVector G4DisplacedSolid::GetObjectTranslation() const
{
return fDirectTransform->NetTranslation();
return fDirectTransform->NetTranslation();
}
void G4DisplacedSolid::SetObjectTranslation(const G4ThreeVector& vector)
@@ -205,15 +217,14 @@ void G4DisplacedSolid::SetObjectTranslation(const G4ThreeVector& vector)
G4bool
G4DisplacedSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
G4AffineTransform sumTransform ;
sumTransform.Product(*fDirectTransform,pTransform) ;
return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform,
pMin,pMax) ;
return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform,pMin,pMax) ;
}
/////////////////////////////////////////////////////
@@ -236,7 +247,6 @@ G4DisplacedSolid::SurfaceNormal( const G4ThreeVector& p ) const
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
G4ThreeVector normal = fPtrSolid->SurfaceNormal(newPoint) ;
return fDirectTransform->TransformAxis(normal) ;
}
/////////////////////////////////////////////////////////////
@@ -245,7 +255,7 @@ G4DisplacedSolid::SurfaceNormal( const G4ThreeVector& p ) const
G4double
G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
const G4ThreeVector& v ) const
{
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
@@ -258,7 +268,7 @@ G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p,
// two solids
G4double
G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p) const
G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p ) const
{
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
return fPtrSolid->DistanceToIn(newPoint) ;
@@ -270,16 +280,16 @@ G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p) const
G4double
G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
G4ThreeVector solNorm ;
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection,
calcNorm,validNorm,&solNorm) ;
calcNorm,validNorm,&solNorm) ;
if(calcNorm)
{
*n = fDirectTransform->TransformAxis(solNorm) ;
@@ -303,13 +313,38 @@ G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p ) const
//
void
G4DisplacedSolid::ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep )
G4DisplacedSolid::ComputeDimensions( G4VPVParameterisation*,
const G4int,
const G4VPhysicalVolume* )
{
// fPtrSolid->ComputeDimensions(p,n,pRep);
DumpInfo();
G4Exception("G4DisplacedSolid::ComputeDimensions() - has no meaning!");
}
G4Exception("ERROR: ComputeDimensions has no meaning for a G4DisplacedSolid. It cannot be called.");
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
G4std::ostream& G4DisplacedSolid::StreamInfo(G4std::ostream& os) const
{
os << "-----------------------------------------------------------\n"
<< " *** Dump for Displaced solid - " << GetName() << " ***\n"
<< " ===================================================\n"
<< " Solid type: " << GetEntityType() << "\n"
<< " Parameters of constituent solid: \n"
<< "===========================================================\n";
fPtrSolid->StreamInfo(os);
os << "===========================================================\n"
<< " Transformations: \n"
<< " Direct transformation - translation : \n"
<< " " << fDirectTransform->NetTranslation() << "\n"
<< " - rotation : \n"
<< " ";
fDirectTransform->NetRotation().print(os);
os << "\n"
<< "===========================================================\n";
return os;
}
/////////////////////////////////////////////////
@@ -330,8 +365,8 @@ G4Polyhedron*
G4DisplacedSolid::CreatePolyhedron () const
{
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
polyhedron->Transform
(G4Transform3D(GetObjectRotation(),GetObjectTranslation()));
polyhedron
->Transform(G4Transform3D(GetObjectRotation(),GetObjectTranslation()));
return polyhedron;
}
@@ -340,7 +375,7 @@ G4DisplacedSolid::CreatePolyhedron () const
//
G4NURBS*
G4DisplacedSolid::CreateNURBS () const
G4DisplacedSolid::CreateNURBS () const
{
// Take into account local transformation - see CreatePolyhedron.
// return fPtrSolid->CreateNURBS() ;
@@ -21,22 +21,21 @@
// ********************************************************************
//
//
// $Id: G4IntersectionSolid.cc,v 1.17 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4IntersectionSolid.cc,v 1.18 2002/10/28 11:36:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Implementation of methods for the class G4IntersectionSolid
//
// History:
//
// 29.05.01 V.Grichine, bug was fixed in DistanceToIn(p,v)
// 16.03.01 V.Grichine, modifications in CalculateExtent() and Inside()
// based on D.Williams proposal
// 29.07.99 V.Grichine, modifications in DistanceToIn(p,v)
// 12.09.98 V.Grichine, implementation based on discussions with J. Apostolakis and
// S. Giani
// 12.09.98 V.Grichine: first implementation
// 29.07.99 V.Grichine: modifications in DistanceToIn(p,v)
// 16.03.01 V.Grichine: modifications in CalculateExtent() and Inside()
// 29.05.01 V.Grichine: bug was fixed in DistanceToIn(p,v)
//
// ********************************************************************
#include "G4IntersectionSolid.hh"
// #include "G4DisplacedSolid.hh"
#include "G4RotationMatrix.hh"
#include "G4ThreeVector.hh"
@@ -57,47 +56,40 @@
// for them. pName will be in turn sent to G4VSolid
//
G4IntersectionSolid:: G4IntersectionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ):
G4BooleanSolid(pName,pSolidA,pSolidB)
G4IntersectionSolid::G4IntersectionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB )
: G4BooleanSolid(pName,pSolidA,pSolidB)
{
;
}
///////////////////////////////////////////////////////////////////
//
G4IntersectionSolid::
G4IntersectionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector ):
G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
G4IntersectionSolid::G4IntersectionSolid( const G4String& pName,
G4VSolid* pSolidA,
G4VSolid* pSolidB,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector )
: G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
{
;
}
//////////////////////////////////////////////////////////////////
//
//
G4IntersectionSolid::
G4IntersectionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
const G4Transform3D& transform ):
G4BooleanSolid(pName,pSolidA,pSolidB,transform)
G4IntersectionSolid::G4IntersectionSolid( const G4String& pName,
G4VSolid* pSolidA,
G4VSolid* pSolidB,
const G4Transform3D& transform )
: G4BooleanSolid(pName,pSolidA,pSolidB,transform)
{
;
}
G4IntersectionSolid::~G4IntersectionSolid()
{
;
}
///////////////////////////////////////////////////////////////
@@ -106,15 +98,18 @@ G4IntersectionSolid::~G4IntersectionSolid()
G4bool
G4IntersectionSolid::CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax) const
{
G4bool retA, retB, out ;
G4double minA, minB, maxA, maxB ;
retA= fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit, pTransform, minA, maxA);
retB= fPtrSolidB->CalculateExtent( pAxis, pVoxelLimit, pTransform, minB, maxB);
retA= fPtrSolidA
->CalculateExtent( pAxis, pVoxelLimit, pTransform, minA, maxA);
retB= fPtrSolidB
->CalculateExtent( pAxis, pVoxelLimit, pTransform, minB, maxB);
if(retA && retB)
{
pMin = G4std::max( minA, minB ) ;
@@ -170,13 +165,16 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
insideB= fPtrSolidB->Inside(p);
#ifdef G4BOOLDEBUG
// if( Inside(p) == kOutside )
if( (insideA == kOutside) || (insideB == kOutside) )
{
G4cout << "WARNING - Invalid call in G4IntersectionSolid::SurfaceNormal(p),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), p is outside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cerr << " p = " << p << G4endl;
}
#endif
@@ -184,9 +182,9 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
// On the surface of both is difficult ... treat it like on A now!
//
// if( (insideA == kSurface) && (insideB == kSurface) )
// normal= fPtrSolidA->SurfaceNormal(p) ;
// else
// if( (insideA == kSurface) && (insideB == kSurface) )
// normal= fPtrSolidA->SurfaceNormal(p) ;
// else
if( insideA == kSurface )
{
normal= fPtrSolidA->SurfaceNormal(p) ;
@@ -195,18 +193,22 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
{
normal= fPtrSolidB->SurfaceNormal(p) ;
}
// We are on neither surface, so we should generate an exception
// We are on neither surface, so we should generate an exception
else
{
if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
normal= fPtrSolidA->SurfaceNormal(p) ;
normal= fPtrSolidA->SurfaceNormal(p) ;
else
normal= fPtrSolidB->SurfaceNormal(p) ;
normal= fPtrSolidB->SurfaceNormal(p) ;
#ifdef G4BOOLDEBUG
G4cout << "WARNING - Invalid call in G4IntersectionSolid::SurfaceNormal(p),"
<< " point p is outsurface" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is out of surface !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), p is outsurface") ;
G4cerr << "WARNING - Invalid call in "
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is out of surface !" << G4endl;
G4cerr << " p = " << p << G4endl;
#endif
}
@@ -225,11 +227,16 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
if( Inside(p) == kInside )
{
#ifdef G4BOOLDEBUG
G4cout << "WARNING - Invalid call in G4IntersectionSolid::DistanceToIn(p,v),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p,v), p is inside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
G4cerr << " v = " << v << G4endl;
#endif
}
else
@@ -238,40 +245,40 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
{
do
{
if( fPtrSolidB->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
}
else
{
if( fPtrSolidB->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
}
else
{
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
}
}
if( disTmp != kInfinity )
{
dist += disTmp ;
if(Inside(p+dist*v) == kOutside )
{
if( fPtrSolidA->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
}
else
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
}
if( disTmp != kInfinity )
{
dist += disTmp ;
}
{
if( fPtrSolidA->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
}
else
{
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
}
if( disTmp != kInfinity )
{
dist += disTmp ;
}
else
{
return kInfinity ;
}
}
}
}
else
{
{
break ;
}
}
}
else
{
@@ -285,40 +292,40 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
{
do
{
if( fPtrSolidA->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
}
else
{
if( fPtrSolidA->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
}
else
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
}
}
if( disTmp != kInfinity )
{
dist += disTmp ;
if(Inside(p+dist*v) == kOutside )
{
if( fPtrSolidB->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
}
else
{
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
}
if( disTmp != kInfinity )
{
dist += disTmp ;
}
{
if( fPtrSolidB->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
}
else
{
{
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
}
if( disTmp != kInfinity )
{
dist += disTmp ;
}
else
{
return kInfinity ;
}
}
}
}
else
{
{
break ;
}
}
}
else
{
@@ -331,40 +338,40 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
{
do
{
if( fPtrSolidB->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
}
else
{
if( fPtrSolidB->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
}
else
{
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
}
}
if( disTmp != kInfinity )
{
dist += disTmp ;
if(Inside(p+dist*v) == kOutside )
{
if( fPtrSolidA->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
}
else
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
}
if( disTmp != kInfinity )
{
dist += disTmp ;
}
{
if( fPtrSolidA->Inside(p+dist*v) == kInside )
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
}
else
{
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
}
if( disTmp != kInfinity )
{
dist += disTmp ;
}
else
{
return kInfinity ;
}
}
}
}
else
{
{
break ;
}
}
}
else
{
@@ -388,23 +395,27 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p) const
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cout << "WARNING - Invalid call in G4IntersectionSolid::DistanceToIn(p),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToIn(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p), p is inside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToIn(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
}
#endif
EInside sideA = fPtrSolidA->Inside(p) ;
EInside sideB = fPtrSolidB->Inside(p) ;
G4double dist ;
if( sideA != kInside && sideB != kOutside )
if( sideA != kInside && sideB != kOutside )
{
dist = fPtrSolidA->DistanceToIn(p) ;
}
else
{
if( sideB != kInside && sideA != kOutside )
if( sideB != kInside && sideA != kOutside )
{
dist = fPtrSolidB->DistanceToIn(p) ;
}
@@ -423,10 +434,10 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p) const
G4double
G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
G4bool validNormA, validNormB;
G4ThreeVector nA, nB;
@@ -442,11 +453,16 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.x() = " << v.x() << G4endl;
G4cout << "v.y() = " << v.y() << G4endl;
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "WARNING - Invalid call in G4IntersectionSolid::DistanceToOut(p,v),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl
<< " Point p is outside !" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p,v), p is outside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl
<< " Point p is outside !" << G4endl;
G4cerr << " p = " << p << G4endl;
G4cerr << " v = " << v << G4endl;
}
#endif
G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,&validNormA,&nA) ;
@@ -454,19 +470,21 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
G4double dist = G4std::min(distA,distB) ;
if( calcNorm ){
if (distA < distB ) {
*validNorm = validNormA;
*n = nA;
}else{
*validNorm = validNormB;
*n = nB;
}
if( calcNorm )
{
if ( distA < distB )
{
*validNorm = validNormA;
*n = nA;
}
else
{
*validNorm = validNormB;
*n = nB;
}
}
return dist ;
// return G4std::min(fPtrSolidA->DistanceToOut(p,v,calcNorm,validNorm,n),
// fPtrSolidB->DistanceToOut(p,v,calcNorm,validNorm,n) ) ;
}
//////////////////////////////////////////////////////////////
@@ -479,10 +497,14 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p ) const
#ifdef G4BOOLDEBUG
if( Inside(p) == kOutside )
{
G4cout << "WARNING - Invalid call in G4IntersectionSolid::DistanceToOut(p),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToOut(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p), p is outside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4IntersectionSolid::DistanceToOut(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cerr << " p = " << p << G4endl;
}
#endif
@@ -496,11 +518,10 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p ) const
//
void
G4IntersectionSolid::ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep )
G4IntersectionSolid::ComputeDimensions( G4VPVParameterisation*,
const G4int,
const G4VPhysicalVolume* )
{
return ;
}
/////////////////////////////////////////////////
@@ -21,14 +21,16 @@
// ********************************************************************
//
//
// $Id: G4ReflectedSolid.cc,v 1.8 2002/05/11 14:10:38 grichine Exp $
// $Id: G4ReflectedSolid.cc,v 1.9 2002/10/28 11:36:29 gcosmo Exp $
//
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
// Implementation for G4ReflectedSolid class for boolean
// operations between other solids
//
// Author: Vladimir Grichine, 23.07.01 (Vladimir.Grichine@cern.ch)
//
// ********************************************************************
#include "G4ReflectedSolid.hh"
#include "G4Point3D.hh"
@@ -46,64 +48,28 @@
#include "G4NURBSbox.hh"
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
//
// Constructor using HepTransform3D, in fact HepReflect3D
G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4Transform3D& transform ) :
G4VSolid(pName)
const G4Transform3D& transform )
: G4VSolid(pName)
{
fPtrSolid = pSolid ;
G4RotationMatrix rotMatrix ;
fDirectTransform = new G4AffineTransform(rotMatrix, transform.getTranslation()) ;
fPtrTransform = new G4AffineTransform(rotMatrix, transform.getTranslation()) ;
fDirectTransform =
new G4AffineTransform(rotMatrix, transform.getTranslation()) ;
fPtrTransform =
new G4AffineTransform(rotMatrix, transform.getTranslation()) ;
fPtrTransform->Invert() ;
fDirectTransform3D = new G4Transform3D(transform) ;
fPtrTransform3D = new G4Transform3D(transform.inverse()) ;
}
/* **************************************************************
////////////////////////////////////////////////////////////////
//
// Constractor for transformation like rotation of frame then translation
// in new frame. It is similar to 1st constractor in G4PVPlacement
G4ReflectedSolid::
G4ReflectedSolid( const G4String& pName,
G4VSolid* pSolid ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector )
: G4VSolid(pName)
{
fPtrSolid = pSolid ;
fPtrTransform = new G4AffineTransform(rotMatrix,transVector) ;
fPtrTransform->Invert() ;
fDirectTransform = new G4AffineTransform(rotMatrix,transVector) ;
}
/////////////////////////////////////////////////////////////////////////////////
// Constructor for use with creation of Transient object from Persistent object
//
G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4AffineTransform directTransform ) :
G4VSolid(pName)
{
fPtrSolid = pSolid ;
fDirectTransform = new G4AffineTransform( directTransform );
fPtrTransform = new G4AffineTransform( directTransform.Inverse() ) ;
}
********************************************************** */
///////////////////////////////////////////////////////////////////
//
@@ -118,14 +84,18 @@ G4ReflectedSolid::~G4ReflectedSolid()
G4GeometryType G4ReflectedSolid::GetEntityType() const
{
return G4String("G4ReflectedSolid");
return G4String("G4ReflectedSolid");
}
const G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr() const
{ return this; }
{
return this;
}
G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr()
{ return this; }
G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr()
{
return this;
}
G4VSolid* G4ReflectedSolid::GetConstituentMovedSolid() const
{
@@ -149,65 +119,59 @@ void G4ReflectedSolid::SetTransform(G4AffineTransform& transform)
G4AffineTransform G4ReflectedSolid::GetDirectTransform() const
{
G4AffineTransform aTransform= *fDirectTransform;
return aTransform;
G4AffineTransform aTransform= *fDirectTransform;
return aTransform;
}
void G4ReflectedSolid::SetDirectTransform(G4AffineTransform& transform)
{
fDirectTransform = &transform ;
fDirectTransform = &transform ;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
G4Transform3D G4ReflectedSolid::GetTransform3D() const
{
G4Transform3D aTransform = *fPtrTransform3D;
return aTransform;
G4Transform3D aTransform = *fPtrTransform3D;
return aTransform;
}
void G4ReflectedSolid::SetTransform3D(G4Transform3D& transform)
{
fPtrTransform3D = &transform ;
fPtrTransform3D = &transform ;
}
//////////////////////////////////////////////////////////////////////////////
G4Transform3D G4ReflectedSolid::GetDirectTransform3D() const
{
G4Transform3D aTransform= *fDirectTransform3D;
return aTransform;
G4Transform3D aTransform= *fDirectTransform3D;
return aTransform;
}
void G4ReflectedSolid::SetDirectTransform3D(G4Transform3D& transform)
{
fDirectTransform3D = &transform ;
fDirectTransform3D = &transform ;
}
/////////////////////////////////////////////////////////////////////////////
G4RotationMatrix G4ReflectedSolid::GetFrameRotation() const
{
G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
return InvRotation;
G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
return InvRotation;
}
void G4ReflectedSolid::SetFrameRotation(const G4RotationMatrix& matrix)
{
fDirectTransform->SetNetRotation(matrix);
fDirectTransform->SetNetRotation(matrix);
}
/////////////////////////////////////////////////////////////////////////////
G4ThreeVector G4ReflectedSolid::GetFrameTranslation() const
{
return fPtrTransform->NetTranslation();
return fPtrTransform->NetTranslation();
}
void G4ReflectedSolid::SetFrameTranslation(const G4ThreeVector& vector)
@@ -219,20 +183,20 @@ void G4ReflectedSolid::SetFrameTranslation(const G4ThreeVector& vector)
G4RotationMatrix G4ReflectedSolid::GetObjectRotation() const
{
G4RotationMatrix Rotation= fPtrTransform->NetRotation();
return Rotation;
G4RotationMatrix Rotation= fPtrTransform->NetRotation();
return Rotation;
}
void G4ReflectedSolid::SetObjectRotation(const G4RotationMatrix& matrix)
{
fPtrTransform->SetNetRotation(matrix);
fPtrTransform->SetNetRotation(matrix);
}
///////////////////////////////////////////////////////////////////////
G4ThreeVector G4ReflectedSolid::GetObjectTranslation() const
{
return fDirectTransform->NetTranslation();
return fDirectTransform->NetTranslation();
}
void G4ReflectedSolid::SetObjectTranslation(const G4ThreeVector& vector)
@@ -246,9 +210,9 @@ void G4ReflectedSolid::SetObjectTranslation(const G4ThreeVector& vector)
G4bool
G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
@@ -260,9 +224,12 @@ G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
z1 = -kInfinity, z2 = kInfinity;
G4bool existsAfterClip = false ;
existsAfterClip = fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
existsAfterClip = fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
existsAfterClip = fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
existsAfterClip =
fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
existsAfterClip =
fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
existsAfterClip =
fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
existsAfterClip = false;
pMin = +kInfinity ;
@@ -324,202 +291,76 @@ G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
}
else
{
G4Exception("G4ReflectedSolid::CalculateExtent - Out of memory !");
DumpInfo();
G4Exception("G4ReflectedSolid::CalculateExtent() - Out of memory !");
}
ClipCrossSection(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
ClipCrossSection(vertices,4,pVoxelLimit,pAxis,pMin,pMax) ;
ClipBetweenSections(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
if (pVoxelLimit.IsLimited(pAxis) == false)
{
{
if ( pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
existsAfterClip = true ;
// Add 2*tolerance to avoid precision troubles
// Add 2*tolerance to avoid precision troubles
pMin -= kCarTolerance;
pMax += kCarTolerance;
pMin -= kCarTolerance;
pMax += kCarTolerance;
}
}
}
else
{
G4ThreeVector clipCentre(
( pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
( pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
( pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
( pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
if ( pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
// Check to see if endpoints are in the solid
clipCentre(pAxis) = pVoxelLimit.GetMinExtent(pAxis);
clipCentre(pAxis) = pVoxelLimit.GetMinExtent(pAxis);
if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
// if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMin = pVoxelLimit.GetMinExtent(pAxis);
pMin = pVoxelLimit.GetMinExtent(pAxis);
}
else
else
{
pMin -= kCarTolerance;
pMin -= kCarTolerance;
}
clipCentre(pAxis) = pVoxelLimit.GetMaxExtent(pAxis);
clipCentre(pAxis) = pVoxelLimit.GetMaxExtent(pAxis);
if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
// if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMax = pVoxelLimit.GetMaxExtent(pAxis);
pMax = pVoxelLimit.GetMaxExtent(pAxis);
}
else
else
{
pMax += kCarTolerance;
}
}
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
else if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
// else if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
existsAfterClip = true ;
pMin = pVoxelLimit.GetMinExtent(pAxis) ;
pMax = pVoxelLimit.GetMaxExtent(pAxis) ;
}
}
delete vertices;
return existsAfterClip;
/* ******************************************
// General rotated case from G4Tube
G4int i, noEntries, noBetweenSections4 ;
G4bool existsAfterClip = false ;
G4Point3D refPoint;
G4ThreeVector point;
G4ThreeVectorList* vertices = new G4ThreeVectorList() ;
G4ThreeVectorList* tmpVertices = fPtrSolid->CreateRotatedVertices(pTransform) ;
pMin = +kInfinity ;
pMax = -kInfinity ;
noEntries = tmpVertices->size() ;
for(i = 0 ; i < noEntries ; i++ )
{
point = (*tmpVertices)[i];
// G4Point3D refPoint = (*fDirectTransform3D)*G4Point3D(point) ;
G4Point3D refPoint = (*fPtrTransform3D)*G4Point3D(point) ;
point = G4ThreeVector(refPoint.x(),refPoint.y(),refPoint.z());
vertices->push_back(point);
}
noBetweenSections4 = noEntries - 4 ;
G4cout<<G4endl;
for(i = 0 ; i < noBetweenSections4 ; i++ )
{
G4cout<<i<<"\t"<<"v.x = "<<((*vertices)[i]).x()<<"\t"
<<"v.y = "<<((*vertices)[i]).y()<<"\t"
<<"v.z = "<<((*vertices)[i]).z()<<"\t"
<<G4endl;
}
G4cout<<G4endl;
for (i = 0 ; i < noEntries ; i += 4 )
{
ClipCrossSection(vertices,i,pVoxelLimit,pAxis,pMin,pMax) ;
}
for (i = 0 ; i < noBetweenSections4 ; i += 4 )
{
ClipBetweenSections(vertices,i,pVoxelLimit,pAxis,pMin,pMax) ;
}
if (pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
pMin -= kCarTolerance ; // Add 2*tolerance to avoid precision troubles
pMax += kCarTolerance ;
}
else
{
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
G4ThreeVector clipCentre(
(pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
(pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
(pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5 ) ;
if ( Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside )
{
existsAfterClip = true ;
pMin = pVoxelLimit.GetMinExtent(pAxis) ;
pMax = pVoxelLimit.GetMaxExtent(pAxis) ;
}
}
}
delete vertices;
delete tmpVertices;
return existsAfterClip;
/////////////////
G4AffineTransform sumTransform ;
G4Transform3D sumT, pt3d ;
G4ReflectX3D tX ;
G4ReflectY3D tY ;
G4ReflectZ3D tZ ;
G4bool extentR ;
G4double minR, maxR ;
pt3d = G4Transform3D(pTransform.NetRotation().inverse(),
pTransform.NetTranslation() );
sumT = pt3d * (*fDirectTransform3D) ;
sumT = ((sumT*tX)*tY)*tZ;
sumTransform = G4AffineTransform( sumT.getRotation(),
// sumT.getRotation().inverse(),
sumT.getTranslation() );
// sumTransform.Product(*fDirectTransform,pTransform) ;
// extent = fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,pTransform,min,max) ;
extentR = fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform,
minR,maxR) ;
// Additional extension, just in case:
// if( maxR > 0 ) pMax = 2.0*maxR ;
// else pMax = 0.5*maxR ;
// if( minR > 0 ) pMin = 0.5*minR ;
// else pMin = 2.0*minR ;
// maxR = pMax;
// minR = pMin;
// and John's trick:
pMin = -maxR ; // minR ;
pMax = -minR ; // maxR ;
return extentR ;
****************************************** */
}
/////////////////////////////////////////////////////
//
@@ -531,7 +372,9 @@ EInside G4ReflectedSolid::Inside(const G4ThreeVector& p) const
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
// G4Point3D newPoint = (*fPtrTransform3D)*G4Point3D(p) ;
return fPtrSolid->Inside(G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z())) ;
return fPtrSolid->Inside(G4ThreeVector(newPoint.x(),
newPoint.y(),
newPoint.z())) ;
}
//////////////////////////////////////////////////////////////
@@ -542,14 +385,14 @@ G4ThreeVector
G4ReflectedSolid::SurfaceNormal( const G4ThreeVector& p ) const
{
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
G4ThreeVector normal = fPtrSolid->SurfaceNormal(G4ThreeVector(newPoint.x(),
newPoint.y(),
newPoint.z() ) ) ;
G4ThreeVector normal =
fPtrSolid->SurfaceNormal(G4ThreeVector(newPoint.x(),
newPoint.y(),
newPoint.z() ) ) ;
G4Point3D newN = (*fDirectTransform3D)*G4Point3D(normal) ;
newN.unit() ;
return G4ThreeVector(newN.x(),newN.y(),newN.z()) ;
return G4ThreeVector(newN.x(),newN.y(),newN.z()) ;
}
/////////////////////////////////////////////////////////////
@@ -587,10 +430,10 @@ G4ReflectedSolid::DistanceToIn( const G4ThreeVector& p) const
G4double
G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
G4ThreeVector solNorm ;
@@ -598,10 +441,11 @@ G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p,
G4Point3D newDirection = (*fDirectTransform3D)*G4Point3D(v) ;
newDirection.unit() ;
G4double dist = fPtrSolid->DistanceToOut(
G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z()),
G4ThreeVector(newDirection.x(),newDirection.y(),newDirection.z()),
calcNorm,validNorm,&solNorm) ;
G4double dist =
fPtrSolid->DistanceToOut(
G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z()),
G4ThreeVector(newDirection.x(),newDirection.y(),newDirection.z()),
calcNorm, validNorm, &solNorm) ;
if(calcNorm)
{
G4Point3D newN = (*fDirectTransform3D)*G4Point3D(solNorm) ;
@@ -628,13 +472,38 @@ G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p ) const
//
void
G4ReflectedSolid::ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep )
G4ReflectedSolid::ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep )
{
// fPtrSolid->ComputeDimensions(p,n,pRep);
DumpInfo();
G4Exception("G4ReflectedSolid::ComputeDimensions() - has no meaning!");
}
G4Exception("ERROR: ComputeDimensions has no meaning for a G4ReflectedSolid. It cannot be called.");
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
G4std::ostream& G4ReflectedSolid::StreamInfo(G4std::ostream& os) const
{
os << "-----------------------------------------------------------\n"
<< " *** Dump for Reflected solid - " << GetName() << " ***\n"
<< " ===================================================\n"
<< " Solid type: " << GetEntityType() << "\n"
<< " Parameters of constituent solid: \n"
<< "===========================================================\n";
fPtrSolid->StreamInfo(os);
os << "===========================================================\n"
<< " Transformations: \n"
<< " Direct transformation - translation : \n"
<< " " << fDirectTransform->NetTranslation() << "\n"
<< " - rotation : \n"
<< " ";
fDirectTransform->NetRotation().print(os);
os << "\n"
<< "===========================================================\n";
return os;
}
/////////////////////////////////////////////////
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ReflectionFactory.cc,v 1.3 2002/02/07 13:15:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4ReflectionFactory.cc,v 1.4 2002/10/28 11:36:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
@@ -46,10 +46,10 @@
// x(inV) = TD * x(inD);
// x(inM) = TGV * x(inV)
// = TV * R * x(inV)
// = TV * R * TD * x(inD)
// = TV * R*TD*R-1 * R*x(inD)
// = TV * ReflTD * x(inReflD)
// = TV * R * TD * x(inD)
// = TV * R*TD*R-1 * R*x(inD)
// = TV * ReflTD * x(inReflD)
// ********************************************************************
#include "G4ReflectionFactory.hh"
#include "G4ReflectedSolid.hh"
@@ -62,10 +62,11 @@ const G4String G4ReflectionFactory::fNameExtension = "_refl";
const G4Scale3D G4ReflectionFactory::fScale = G4ScaleZ3D(-1.0);
//_____________________________________________________________________________
G4ReflectionFactory* G4ReflectionFactory::Instance()
{
// Static singleton access method.
// ---
// Static singleton access method.
// ---
if (!fInstance) new G4ReflectionFactory();
@@ -73,17 +74,20 @@ G4ReflectionFactory* G4ReflectionFactory::Instance()
}
//_____________________________________________________________________________
G4ReflectionFactory::G4ReflectionFactory()
: fVerboseLevel(0)
{
// Protected singleton constructor.
// ---
// Protected singleton constructor.
// ---
fInstance = this;
}
//_____________________________________________________________________________
G4ReflectionFactory::~G4ReflectionFactory() {
G4ReflectionFactory::~G4ReflectionFactory()
{
}
//
@@ -91,26 +95,28 @@ G4ReflectionFactory::~G4ReflectionFactory() {
//
//_____________________________________________________________________________
G4PhysicalVolumesPair G4ReflectionFactory::Place(
const G4Transform3D& transform3D,
const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
G4bool isMany,
G4int copyNo)
{
// Evaluates the passed transformation; if it contains reflection
// it performs its decomposition, creates new reflected solid and
// logical volume (or retrieves them from a map if the reflected
// objects were already created), transforms the daughters (if present)
// and place it in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a placement in a reflected mother
// - or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0) {
G4cout << "Place " << name << " lv " << LV << " "
G4PhysicalVolumesPair
G4ReflectionFactory::Place( const G4Transform3D& transform3D,
const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
G4bool isMany,
G4int copyNo)
{
// Evaluates the passed transformation; if it contains reflection
// it performs its decomposition, creates new reflected solid and
// logical volume (or retrieves them from a map if the reflected
// objects were already created), transforms the daughters (if present)
// and place it in the given mother.
// The result is a pair of physical volumes;
// the second physical volume is a placement in a reflected mother
// - or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0)
{
G4cout << "Place " << name << " lv " << LV << " "
<< LV->GetName() << G4endl;
}
@@ -126,33 +132,34 @@ G4PhysicalVolumesPair G4ReflectionFactory::Place(
//PrintTransform(pureTransform3D);
// check that scale correspond to fScale
//
CheckScale(scale);
//
// reflection IS NOT present in transform3D
//
if (! IsReflection(scale)) {
if (! IsReflection(scale))
{
if (fVerboseLevel>0)
G4cout << "scale positive" << G4endl;
G4cout << "Scale positive" << G4endl;
G4VPhysicalVolume* pv1
= new G4PVPlacement(pureTransform3D, LV, name, motherLV, isMany, copyNo);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV)) {
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// reflect this LV and place it in reflected mother
pv2 = new G4PVPlacement(
fScale * (pureTransform3D * fScale.inverse()),
ReflectLV(LV), name, reflMotherLV, isMany, copyNo);
pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
ReflectLV(LV),name,reflMotherLV,isMany,copyNo);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//
// reflection IS present in transform3D
//
@@ -165,33 +172,36 @@ G4PhysicalVolumesPair G4ReflectionFactory::Place(
ReflectLV(LV), name, motherLV, isMany, copyNo);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV)) {
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// place the refLV consituent in reflected mother
pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
LV, name, reflMotherLV, isMany, copyNo);
}
}
return G4PhysicalVolumesPair(pv1, pv2);
}
}
//_____________________________________________________________________________
G4PhysicalVolumesPair G4ReflectionFactory::Replicate(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofReplicas,
G4double width,
G4double offset)
G4PhysicalVolumesPair
G4ReflectionFactory::Replicate(const G4String& name,
G4LogicalVolume* LV,
G4LogicalVolume* motherLV,
EAxis axis,
G4int nofReplicas,
G4double width,
G4double offset)
{
// Creates replica in given mother.
// The result is a pair of physical volumes;
// the second physical volume is a replica in a reflected mother
// - or 0 if mother LV was not reflected.
// ---
// Creates replica in given mother.
// The result is a pair of physical volumes;
// the second physical volume is a replica in a reflected mother
// - or 0 if mother LV was not reflected.
// ---
if (fVerboseLevel>0) {
G4cout << "Replicate " << name << " lv " << LV << " "
@@ -202,114 +212,135 @@ G4PhysicalVolumesPair G4ReflectionFactory::Replicate(const G4String& name,
= new G4PVReplica(name, LV, motherLV, axis, nofReplicas, width, offset);
G4VPhysicalVolume* pv2 = 0;
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV)) {
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
{
// if mother was reflected
// reflect the LV and replicate it in reflected mother
pv2 = new G4PVReplica(name, ReflectLV(LV), reflMotherLV,
axis, nofReplicas, width, offset);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
return G4PhysicalVolumesPair(pv1, pv2);
}
//
// private methods
//
//_____________________________________________________________________________
G4LogicalVolume* G4ReflectionFactory::ReflectLV(G4LogicalVolume* LV)
{
// Gets/creates the reflected solid and logical volume
// and copies + transforms LV daughters.
// ---
// Gets/creates the reflected solid and logical volume
// and copies + transforms LV daughters.
// ---
G4LogicalVolume* refLV = GetReflectedLV(LV);
if (!refLV) {
if (!refLV)
{
// create new (reflected) objects
//
refLV = CreateReflectedLV(LV);
// process daughters
//
ReflectDaughters(LV, refLV);
}
return refLV;
}
}
//_____________________________________________________________________________
G4LogicalVolume* G4ReflectionFactory::CreateReflectedLV(G4LogicalVolume* LV)
{
// Creates the reflected solid and logical volume
// and add the logical volumes pair in the maps.
// ---
// Creates the reflected solid and logical volume
// and add the logical volumes pair in the maps.
// ---
// consistency check
if (fReflectedLVMap.find(LV) != fReflectedLVMap.end()) {
G4Exception(
"G4ReflectionFactory::CreateReflectedLV: called for already reflected volume!");
//
if (fReflectedLVMap.find(LV) != fReflectedLVMap.end())
{
G4cout << "ERROR - G4ReflectionFactory::CreateReflectedLV(): "
<< LV->GetName() << G4endl
<< " Cannot be applied to an already reflected volume !"
<< G4endl;
G4cerr << "ERROR - G4ReflectionFactory::CreateReflectedLV(): "
<< LV->GetName() << G4endl
<< " Cannot be applied to an already reflected volume !"
<< G4endl;
G4Exception("G4ReflectionFactory::CreateReflectedLV() - Invalid call");
}
G4VSolid* refSolid
= new G4ReflectedSolid(LV->GetSolid()->GetName() + fNameExtension,
LV->GetSolid(), fScale);
G4LogicalVolume* refLV
= new G4LogicalVolume(refSolid,
LV->GetMaterial(),
LV->GetName() + fNameExtension,
LV->GetFieldManager(),
LV->GetSensitiveDetector(),
LV->GetUserLimits());
LV->GetMaterial(),
LV->GetName() + fNameExtension,
LV->GetFieldManager(),
LV->GetSensitiveDetector(),
LV->GetUserLimits());
fConstituentLVMap[LV] = refLV;
fReflectedLVMap[refLV] = LV;
return refLV;
return refLV;
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectDaughters(G4LogicalVolume* LV,
G4LogicalVolume* refLV)
{
// Reflects daughters recursively.
// ---
// Reflects daughters recursively.
// ---
if (fVerboseLevel>0) {
G4cout << "G4ReflectionFactory::ReflectDaughters: "
if (fVerboseLevel>0)
{
G4cout << "G4ReflectionFactory::ReflectDaughters(): "
<< LV->GetNoDaughters() << " of " << LV->GetName() << G4endl;
}
}
for (G4int i=0; i<LV->GetNoDaughters(); i++) {
for (G4int i=0; i<LV->GetNoDaughters(); i++)
{
G4VPhysicalVolume* dPV = LV->GetDaughter(i);
if (! dPV->IsReplicated()) {
if (! dPV->IsReplicated())
{
ReflectPVPlacement(dPV, refLV);
}
else if (! dPV->GetParameterisation()) {
ReflectPVReplica(dPV, refLV);
}
else {
ReflectPVParameterised(dPV, refLV);
}
}
}
else if (! dPV->GetParameterisation())
{
ReflectPVReplica(dPV, refLV);
}
else
{
ReflectPVParameterised(dPV, refLV);
}
}
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
G4LogicalVolume* refLV)
{
// Copies and transforms daughter of PVPlacement type of
// a constituent volume into a reflected volume.
// ---
// Copies and transforms daughter of PVPlacement type of
// a constituent volume into a reflected volume.
// ---
G4LogicalVolume* dLV = dPV->GetLogicalVolume();
// update daughter transformation
//
G4Transform3D dt(dPV->GetObjectRotationValue(), dPV->GetObjectTranslation());
dt = fScale * (dt * fScale.inverse());
@@ -318,19 +349,24 @@ void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
if (fVerboseLevel>0)
G4cout << "Daughter: " << dPV << " " << dLV->GetName();
if (!IsReflected(dLV)) {
if (!IsReflected(dLV))
{
if (fVerboseLevel>0)
G4cout << " will be reflected." << G4endl;
// get reflected volume if already created
//
refDLV = GetReflectedLV(dLV);
if (!refDLV) {
if (!refDLV)
{
// create new daughter solid and logical volume
//
refDLV = CreateReflectedLV(dLV);
// recursive call
//
ReflectDaughters(dLV, refDLV);
}
@@ -341,9 +377,10 @@ void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
dPV->IsMany(), dPV->GetCopyNo());
}
else {
else
{
if (fVerboseLevel>0)
G4cout << " will be reconstited." << G4endl;
G4cout << " will be reconstitued." << G4endl;
refDLV = GetConstituentLV(dLV);
@@ -353,16 +390,18 @@ void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
G4LogicalVolume* refLV)
{
// Copies and transforms daughter of PVReplica type of
// a constituent volume into a reflected volume.
// ---
// Copies and transforms daughter of PVReplica type of
// a constituent volume into a reflected volume.
// ---
G4LogicalVolume* dLV = dPV->GetLogicalVolume();
// get replication data
//
EAxis axis;
G4int nofReplicas;
G4double width;
@@ -376,31 +415,35 @@ void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
if (fVerboseLevel>0)
G4cout << "Daughter: " << dPV << " " << dLV->GetName();
if (!IsReflected(dLV)) {
if (!IsReflected(dLV))
{
if (fVerboseLevel>0)
G4cout << " will be reflected." << G4endl;
// get reflected volume if already created
//
refDLV = GetReflectedLV(dLV);
if (!refDLV) {
if (!refDLV)
{
// create new daughter solid and logical volume
//
refDLV = CreateReflectedLV(dLV);
// recursive call
//
ReflectDaughters(dLV, refDLV);
}
// create new daughter replica
//
new G4PVReplica(dPV->GetName(), refDLV, refLV,
axis, nofReplicas, width, offset);
}
else {
axis, nofReplicas, width, offset);
}
else
{
if (fVerboseLevel>0)
G4cout << " will be reconstited." << G4endl;
G4cout << " will be reconstitued." << G4endl;
refDLV = GetConstituentLV(dLV);
@@ -410,74 +453,86 @@ void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
}
//_____________________________________________________________________________
void G4ReflectionFactory::ReflectPVParameterised(G4VPhysicalVolume* dPV,
G4LogicalVolume* refLV)
G4LogicalVolume* refLV)
{
// Not implemented.
// Should copy and transform daughter of PVReplica type of
// a constituent volume into a reflected volume.
// ---
G4Exception(
"G4ReflectionFactory: Parameterised volumes cannot be reflected yet.");
// Not implemented.
// Should copy and transform daughter of PVReplica type of
// a constituent volume into a reflected volume.
// ---
G4cout << "ERROR - G4ReflectionFactory::ReflectPVParameterised(): "
<< dPV->GetName() << G4endl
<< " Reflection of parameterised volumes "
<< "is not yet implemented." << G4endl;
G4cerr << "ERROR - G4ReflectionFactory::ReflectPVParameterised(): "
<< dPV->GetName() << G4endl
<< " Reflection of parameterised volumes "
<< "is not yet implemented." << G4endl;
G4Exception("G4ReflectionFactory::ReflectPVParameterised() - not implemented");
}
//_____________________________________________________________________________
G4LogicalVolume* G4ReflectionFactory::GetConstituentLV(
G4LogicalVolume* reflLV) const
{
// Returns the consituent volume of the given reflected volume,
// 0 if the given reflected volume was not found.
// ---
G4LogicalVolume*
G4ReflectionFactory::GetConstituentLV(G4LogicalVolume* reflLV) const
{
// Returns the consituent volume of the given reflected volume,
// 0 if the given reflected volume was not found.
// ---
LogicalVolumesMapIterator it = fReflectedLVMap.find(reflLV);
if (it == fReflectedLVMap.end()) return 0;
return (*it).second;
}
}
//_____________________________________________________________________________
G4LogicalVolume* G4ReflectionFactory::GetReflectedLV(
G4LogicalVolume* lv) const
{
// Returns the reflected volume of the given consituent volume,
// 0 if the given volume was not reflected.
// ---
G4LogicalVolume*
G4ReflectionFactory::GetReflectedLV(G4LogicalVolume* lv) const
{
// Returns the reflected volume of the given consituent volume,
// 0 if the given volume was not reflected.
// ---
LogicalVolumesMapIterator it = fConstituentLVMap.find(lv);
if (it == fConstituentLVMap.end()) return 0;
return (*it).second;
}
}
//_____________________________________________________________________________
G4bool G4ReflectionFactory::IsConstituent(G4LogicalVolume* lv) const
{
// Returns true if the given volume has been already reflected
// (is in the map of constituent volumes).
// ---
// Returns true if the given volume has been already reflected
// (is in the map of constituent volumes).
// ---
return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
}
//_____________________________________________________________________________
G4bool G4ReflectionFactory::IsReflected(G4LogicalVolume* lv) const
{
// Returns true if the given volume is a reflected volume
// (is in the map reflected volumes).
// ---
// Returns true if the given volume is a reflected volume
// (is in the map reflected volumes).
// ---
return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
}
//_____________________________________________________________________________
G4bool G4ReflectionFactory::IsReflection(const G4Scale3D& scale) const
{
// Returns true if the scale is negative, false otherwise.
// ---
// Returns true if the scale is negative, false otherwise.
// ---
if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)
return true;
@@ -486,24 +541,27 @@ G4bool G4ReflectionFactory::IsReflection(const G4Scale3D& scale) const
}
//_____________________________________________________________________________
void G4ReflectionFactory::PrintConstituentLVMap()
{
// temporary - for debugging purpose
// ---
// temporary - for debugging purpose
// ---
LogicalVolumesMapIterator it;
for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); it++) {
G4cout << "lv: " << (*it).first << " lv_refl: " << (*it).second << G4endl;
for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); it++)
{
G4cout << "lv: " << (*it).first << " lv_refl: " << (*it).second << G4endl;
}
G4cout << G4endl;
}
//_____________________________________________________________________________
void G4ReflectionFactory::CheckScale(const G4Scale3D& scale) const
{
// Check if scale correspond to fScale,
// if not give exception.
// ---
// Check if scale correspond to fScale,
// if not give exception.
// ---
if (!IsReflection(scale)) return;
@@ -513,14 +571,20 @@ void G4ReflectionFactory::CheckScale(const G4Scale3D& scale) const
diff += abs(scale(i,j) - fScale(i,j));
if (diff > kCarTolerance)
G4Exception("G4ReflectionFactory::CheckScale: unexpected scale has occured.");
{
G4cout << "ERROR - G4ReflectionFactory::CheckScale()" << G4endl
<< " Unexpected scale. Difference: " << diff << G4endl;
G4cerr << "ERROR - G4ReflectionFactory::CheckScale()" << G4endl
<< " Unexpected scale. Difference: " << diff << G4endl;
G4Exception("G4ReflectionFactory::CheckScale() - unexpected scale");
}
}
void G4ReflectionFactory::SetVerboseLevel(G4int verboseLevel)
{
fVerboseLevel = verboseLevel;
}
G4int G4ReflectionFactory::GetVerboseLevel() const
{
return fVerboseLevel;
@@ -532,5 +596,5 @@ G4int G4ReflectionFactory::GetVerboseLevel() const
G4VPhysicalVolume* pv1
= new G4PVPlacement(new G4RotationMatrix(rotation.getRotation().inverse()),
translation.getTranslation(),
refLV, name, motherLV, isMany, copyNo);
*/
refLV, name, motherLV, isMany, copyNo);
*/
@@ -21,24 +21,22 @@
// ********************************************************************
//
//
// $Id: G4SubtractionSolid.cc,v 1.16 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4SubtractionSolid.cc,v 1.17 2002/10/28 11:36:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Implementation of methods for the class G4IntersectionSolid
//
// History:
//
// 14.10.98 V.Grichine, implementation of the first version
// 19.10.98 V.Grichine, new algorithm of DistanceToIn(p,v) according to
// J.Apostolakis recommendations (while loops)
// 02.08.99 V.Grichine, bugs fixed in DistanceToOut(p,v,...)
// 14.10.98 V.Grichine: implementation of the first version
// 19.10.98 V.Grichine: new algorithm of DistanceToIn(p,v)
// 02.08.99 V.Grichine: bugs fixed in DistanceToOut(p,v,...)
// while -> do-while & surfaceA limitations
// 13.09.00 V.Grichine, bug fixed in SurfaceNormal(p), p can be inside
//
// 13.09.00 V.Grichine: bug fixed in SurfaceNormal(p), p can be inside
//
// ********************************************************************
#include "G4SubtractionSolid.hh"
// #include "G4DisplacedSolid.hh"
#include "G4RotationMatrix.hh"
#include "G4ThreeVector.hh"
@@ -58,71 +56,70 @@
// Transfer all data members to G4BooleanSolid which is responsible
// for them. pName will be in turn sent to G4VSolid
G4SubtractionSolid:: G4SubtractionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ):
G4BooleanSolid(pName,pSolidA,pSolidB)
G4SubtractionSolid::G4SubtractionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB )
: G4BooleanSolid(pName,pSolidA,pSolidB)
{
;
}
///////////////////////////////////////////////////////////////
//
//
// Constructor
G4SubtractionSolid::
G4SubtractionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector ):
G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
G4SubtractionSolid::G4SubtractionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector )
: G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
{
;
}
///////////////////////////////////////////////////////////////
//
//
// Constructor
G4SubtractionSolid::
G4SubtractionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
const G4Transform3D& transform ):
G4BooleanSolid(pName,pSolidA,pSolidB,transform)
G4SubtractionSolid::G4SubtractionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
const G4Transform3D& transform )
: G4BooleanSolid(pName,pSolidA,pSolidB,transform)
{
;
}
}
///////////////////////////////////////////////////////////////
//
// Destructor
G4SubtractionSolid::~G4SubtractionSolid()
{
;
}
///////////////////////////////////////////////////////////////
//
//
// CalculateExtent
G4bool
G4SubtractionSolid::CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
G4SubtractionSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
// Since we cannot be sure how much the second solid subtracts
// from the first, we must use the first solid's extent!
return fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit,
pTransform, pMin, pMax);
pTransform, pMin, pMax );
}
/////////////////////////////////////////////////////
//
// Touching ? Empty subtraction ?
EInside G4SubtractionSolid::Inside(const G4ThreeVector& p) const
EInside G4SubtractionSolid::Inside( const G4ThreeVector& p ) const
{
EInside positionA = fPtrSolidA->Inside(p) ;
EInside positionB = fPtrSolidB->Inside(p) ;
@@ -148,7 +145,7 @@ EInside G4SubtractionSolid::Inside(const G4ThreeVector& p) const
//////////////////////////////////////////////////////////////
//
//
// SurfaceNormal
G4ThreeVector
G4SubtractionSolid::SurfaceNormal( const G4ThreeVector& p ) const
@@ -157,10 +154,14 @@ G4SubtractionSolid::SurfaceNormal( const G4ThreeVector& p ) const
if( Inside(p) == kOutside )
{
#ifdef G4BOOLDEBUG
G4cout << "WARNING - Invalid call in G4SubtractionSolid::SurfaceNormal(p),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call [1] in "
<< "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::SurfaceNormal(p), p is outside") ;
G4cerr << "WARNING - Invalid call [1] in "
<< "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
#endif
}
else
@@ -186,7 +187,14 @@ G4SubtractionSolid::SurfaceNormal( const G4ThreeVector& p ) const
normal = -fPtrSolidB->SurfaceNormal(p) ;
}
#ifdef G4BOOLDEBUG
G4cout << "G4SubtractionSolid::SurfaceNormal(p), point p is inside" << G4endl ;
G4cout << "WARNING - Invalid call [2] in "
<< "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
G4cerr << "WARNING - Invalid call [2] in "
<< "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
#endif
}
}
@@ -206,17 +214,21 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cout << "WARNING - Invalid call in G4SubtractionSolid::DistanceToIn(p,v),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToIn(p,v)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p,v), p is inside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToIn(p,v)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
G4cerr << " v = " << v << G4endl;
}
#endif
if( // ( fPtrSolidA->Inside(p) != kOutside) && // case1:p in both A&B
( fPtrSolidB->Inside(p) != kOutside) ) // start: out of B
// if( // ( fPtrSolidA->Inside(p) != kOutside) && // case1:p in both A&B
if ( fPtrSolidB->Inside(p) != kOutside ) // start: out of B
{
dist = fPtrSolidB->DistanceToOut(p,v) ; // ,calcNorm,validNorm,n) ;
@@ -229,19 +241,19 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
if(disTmp == kInfinity)
{
return kInfinity ;
}
}
dist += disTmp ;
if( Inside(p+dist*v) == kOutside )
{
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
dist += disTmp ;
}
}
}
while( Inside(p+dist*v) == kOutside ) ;
}
}
else // p outside A, start in A
else // p outside A, start in A
{
dist = fPtrSolidA->DistanceToIn(p,v) ;
@@ -251,24 +263,22 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
}
else
{
while( Inside(p+dist*v) == kOutside ) // pushing loop
// do
{
while( Inside(p+dist*v) == kOutside ) // pushing loop
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
dist += disTmp ;
if( Inside(p+dist*v) == kOutside )
{
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
if(disTmp == kInfinity) // past A, hence past A\B
{
return kInfinity ;
}
}
dist += disTmp ;
}
}
// while( Inside(p+dist*v) == kOutside ) ;
}
}
}
}
@@ -282,17 +292,21 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
// isotropic safety
G4double
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p) const
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p ) const
{
G4double dist;
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cout << "WARNING - Invalid call in G4SubtractionSolid::DistanceToIn(p),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToIn(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p), p is inside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToIn(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
}
#endif
@@ -315,10 +329,10 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p) const
G4double
G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
#ifdef G4BOOLDEBUG
if( Inside(p) == kOutside )
@@ -331,11 +345,16 @@ G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.x() = " << v.x() << G4endl;
G4cout << "v.y() = " << v.y() << G4endl;
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "WARNING - Invalid call in G4SubtractionSolid::DistanceToOut(p,v),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToOut(p,v)" << G4endl
<< " Point p is outside !" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p,v), p is outside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToOut(p,v)" << G4endl
<< " Point p is outside !" << G4endl;
G4cerr << " p = " << p << G4endl;
G4cerr << " v = " << v << G4endl;
}
#endif
@@ -370,10 +389,14 @@ G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p ) const
if( Inside(p) == kOutside )
{
#ifdef G4BOOLDEBUG
G4cout << "WARNING - Invalid call in G4SubtractionSolid::DistanceToOut(p),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToOut(p)" << G4endl
<< " Point p is outside" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p), p is outside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4SubtractionSolid::DistanceToOut(p)" << G4endl
<< " Point p is outside" << G4endl;
G4cerr << " p = " << p << G4endl;
#endif
}
else
@@ -398,11 +421,10 @@ G4GeometryType G4SubtractionSolid::GetEntityType() const
//
void
G4SubtractionSolid::ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep )
G4SubtractionSolid::ComputeDimensions( G4VPVParameterisation*,
const G4int,
const G4VPhysicalVolume* )
{
return ;
}
/////////////////////////////////////////////////
@@ -435,7 +457,7 @@ G4SubtractionSolid::CreatePolyhedron () const
//
G4NURBS*
G4SubtractionSolid::CreateNURBS () const
G4SubtractionSolid::CreateNURBS () const
{
// Take into account boolean operation - see CreatePolyhedron.
// return new G4NURBSbox (1.0, 1.0, 1.0);
@@ -21,22 +21,21 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.cc,v 1.20 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4UnionSolid.cc,v 1.21 2002/10/28 11:36:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Implementation of methods for the class G4IntersectionSolid
//
// History:
//
// 12.09.98 V.Grichine, implementation
// 28.11.98 V.Grichine, J. Apostolakis, while loops in DistToIn/Out
// 27.07.99 V.Grichine, modifications in Distance ToOut(p,v,...)
// while -> do-while
// 16.03.01 V.Grichine, modifications in CalculateExtent()
// based on D.Williams proposal
// 12.09.98 V.Grichine: first implementation
// 28.11.98 V.Grichine: fix while loops in DistToIn/Out
// 27.07.99 V.Grichine: modifications in DistToOut(p,v,...), while -> do-while
// 16.03.01 V.Grichine: modifications in CalculateExtent()
//
// ********************************************************************
#include "G4UnionSolid.hh"
// #include "G4PlacedSolid.hh"
#include "G4RotationMatrix.hh"
#include "G4ThreeVector.hh"
@@ -57,47 +56,45 @@
// for them. pName will be in turn sent to G4VSolid
G4UnionSolid:: G4UnionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ):
G4BooleanSolid(pName,pSolidA,pSolidB)
G4VSolid* pSolidA ,
G4VSolid* pSolidB )
: G4BooleanSolid(pName,pSolidA,pSolidB)
{
;
}
/////////////////////////////////////////////////////////////////////
//
//
// Constructor
G4UnionSolid:: G4UnionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector ):
G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
G4UnionSolid::G4UnionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector )
: G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
{
;
}
///////////////////////////////////////////////////////////
//
//
// Constructor
G4UnionSolid:: G4UnionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
const G4Transform3D& transform ):
G4BooleanSolid(pName,pSolidA,pSolidB,transform)
G4UnionSolid::G4UnionSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
const G4Transform3D& transform )
: G4BooleanSolid(pName,pSolidA,pSolidB,transform)
{
;
}
///////////////////////////////////////////////////////////
//
// Destructor
G4UnionSolid::~G4UnionSolid()
{
;
}
///////////////////////////////////////////////////////////////
@@ -105,10 +102,11 @@ G4UnionSolid::~G4UnionSolid()
//
G4bool
G4UnionSolid::CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
G4UnionSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
G4bool touchesA, touchesB, out ;
G4double minA = kInfinity, minB = kInfinity,
@@ -135,7 +133,7 @@ G4UnionSolid::CalculateExtent(const EAxis pAxis,
// surface the surface points will be considered as kSurface, while points
// located around will correspond to kInside
EInside G4UnionSolid::Inside(const G4ThreeVector& p) const
EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const
{
EInside positionA = fPtrSolidA->Inside(p) ;
EInside positionB = fPtrSolidB->Inside(p) ;
@@ -171,10 +169,14 @@ G4UnionSolid::SurfaceNormal( const G4ThreeVector& p ) const
#ifdef G4BOOLDEBUG
if( Inside(p) == kOutside )
{
G4cout << "WARNING - Invalid call in G4UnionSolid::SurfaceNormal(p),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4UnionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), p is outside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4UnionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cerr << " p = " << p << G4endl;
}
#endif
@@ -191,10 +193,14 @@ G4UnionSolid::SurfaceNormal( const G4ThreeVector& p ) const
{
normal= fPtrSolidA->SurfaceNormal(p) ;
#ifdef G4BOOLDEBUG
G4cout << "WARNING - Invalid call in G4UnionSolid::SurfaceNormal(p),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4UnionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), p is inside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4UnionSolid::SurfaceNormal(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
#endif
}
return normal;
@@ -211,11 +217,16 @@ G4UnionSolid::DistanceToIn( const G4ThreeVector& p,
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cout << "WARNING - Invalid call in G4UnionSolid::DistanceToIn(p,v),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToIn(p,v)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p,v), point p is intside");
G4cerr << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToIn(p,v)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
G4cerr << " v = " << v << G4endl;
}
#endif
@@ -234,10 +245,14 @@ G4UnionSolid::DistanceToIn( const G4ThreeVector& p) const
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cout << "WARNING - Invalid call in G4UnionSolid::DistanceToIn(p),"
<< " point p is inside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToIn(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p), p is inside") ;
G4cerr << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToIn(p)" << G4endl
<< " Point p is inside !" << G4endl;
G4cerr << " p = " << p << G4endl;
}
#endif
G4double distA = fPtrSolidA->DistanceToIn(p) ;
@@ -253,10 +268,10 @@ G4UnionSolid::DistanceToIn( const G4ThreeVector& p) const
G4double
G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
G4double dist = 0.0, disTmp = 0.0 ;
G4ThreeVector normTmp;
@@ -273,11 +288,16 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.x() = " << v.x() << G4endl;
G4cout << "v.y() = " << v.y() << G4endl;
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "WARNING - Invalid call in G4UnionSolid::DistanceToOut(p,v),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToOut(p,v)" << G4endl
<< " Point p is outside !" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p,v), point p is outside");
G4cerr << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToOut(p,v)" << G4endl
<< " Point p is outside !" << G4endl;
G4cerr << " p = " << p << G4endl;
G4cerr << " v = " << v << G4endl;
#endif
}
else
@@ -294,11 +314,11 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
dist += disTmp ;
if(fPtrSolidB->Inside(p+dist*v) != kOutside)
{
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
validNorm,nTmp) ;
dist += disTmp ;
}
}
}
// while( Inside(p+dist*v) == kInside ) ;
while( fPtrSolidA->Inside(p+dist*v) != kOutside &&
@@ -313,15 +333,15 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
dist += disTmp ;
if(fPtrSolidA->Inside(p+dist*v) != kOutside)
{
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
validNorm,nTmp) ;
dist += disTmp ;
}
}
}
// while( Inside(p+dist*v) == kInside ) ;
while( fPtrSolidB->Inside(p+dist*v) != kOutside &&
disTmp > 0.5*kCarTolerance ) ;
while( (fPtrSolidB->Inside(p+dist*v) != kOutside)
&& (disTmp > 0.5*kCarTolerance) ) ;
}
}
if( calcNorm )
@@ -343,10 +363,14 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p ) const
if( Inside(p) == kOutside )
{
#ifdef G4BOOLDEBUG
G4cout << "WARNING - Invalid call in G4UnionSolid::DistanceToOut(p),"
<< " point p is outside" << G4endl;
G4cout << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToOut(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p), p is outtside");
G4cerr << "WARNING - Invalid call in "
<< "G4UnionSolid::DistanceToOut(p)" << G4endl
<< " Point p is outside !" << G4endl;
G4cerr << " p = " << p << G4endl;
#endif
}
else
@@ -362,7 +386,7 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p ) const
(positionA == kSurface && positionB == kInside ) )
{
distout= G4std::max(fPtrSolidA->DistanceToOut(p),
fPtrSolidB->DistanceToOut(p) ) ;
fPtrSolidB->DistanceToOut(p) ) ;
}
else
{
@@ -393,11 +417,10 @@ G4GeometryType G4UnionSolid::GetEntityType() const
//
void
G4UnionSolid::ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep )
G4UnionSolid::ComputeDimensions( G4VPVParameterisation*,
const G4int,
const G4VPhysicalVolume* )
{
return ;
}
/////////////////////////////////////////////////