source: trunk/source/geometry/divisions/src/G4PVDivisionFactory.cc @ 1202

Last change on this file since 1202 was 1010, checked in by garnier, 15 years ago

update

File size: 5.8 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4PVDivisionFactory.cc,v 1.2 2006/06/29 18:18:33 gunter Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30// class G4PVDivisionFactory Implementation file
31//
32// Author: Ivana Hrivnacova, 4.5.2004  (Ivana.Hrivnacova@cern.ch)
33// --------------------------------------------------------------------
34
35#include "G4PVDivisionFactory.hh"
36#include "G4PVDivision.hh"
37#include "G4VDivisionParameterisation.hh"
38
39//_____________________________________________________________________________
40
41G4PVDivisionFactory::G4PVDivisionFactory()
42  : G4VPVDivisionFactory()
43{
44  // Protected singleton constructor.
45  // ---
46}
47
48//_____________________________________________________________________________
49
50G4PVDivisionFactory::~G4PVDivisionFactory()
51{
52}
53
54//_____________________________________________________________________________
55
56G4PVDivisionFactory* G4PVDivisionFactory::GetInstance()
57{
58  static G4PVDivisionFactory theFactory;
59  if (!fgInstance)
60  {
61    fgInstance = &theFactory;
62  }
63  return &theFactory;
64} 
65
66//_____________________________________________________________________________
67
68G4VPhysicalVolume* 
69G4PVDivisionFactory::CreatePVDivision(const G4String& pName,
70                             G4LogicalVolume* pLogical,
71                             G4LogicalVolume* pMotherLogical,
72                             const EAxis pAxis,
73                             const G4int nReplicas,
74                             const G4double width,
75                             const G4double offset )
76{     
77  // Create division - with number of divisions and width
78  // ---
79
80  return new G4PVDivision(pName, pLogical, pMotherLogical, 
81                          pAxis, nReplicas, width, offset);
82}   
83
84//_____________________________________________________________________________
85
86G4VPhysicalVolume* 
87G4PVDivisionFactory::CreatePVDivision(const G4String& pName,
88                             G4LogicalVolume* pLogical,
89                             G4LogicalVolume* pMotherLogical,
90                             const EAxis pAxis,
91                             const G4int nReplicas,
92                             const G4double offset )
93{     
94  // Create division - with number of divisions
95  // ---
96
97  return new G4PVDivision(pName, pLogical, pMotherLogical, 
98                          pAxis, nReplicas, offset);
99}   
100
101//_____________________________________________________________________________
102
103G4VPhysicalVolume* 
104G4PVDivisionFactory::CreatePVDivision(const G4String& pName,
105                             G4LogicalVolume* pLogical,
106                             G4LogicalVolume* pMotherLogical,
107                             const EAxis pAxis,
108                             const G4double width,
109                             const G4double offset )
110{     
111  // Create division - with width
112  // ---
113
114  return new G4PVDivision(pName, pLogical, pMotherLogical, 
115                          pAxis, width, offset);
116}   
117
118//_____________________________________________________________________________
119
120G4VPhysicalVolume* 
121G4PVDivisionFactory::CreatePVDivision(const G4String& pName,
122                             G4LogicalVolume* pLogical,
123                             G4LogicalVolume* pMotherLogical,
124                             const G4VPVParameterisation* param)
125{     
126  // Create division - with parameterisation
127  // ---
128
129  // Get parameterisation data
130  //
131  const G4VDivisionParameterisation* divParam
132    = dynamic_cast<const G4VDivisionParameterisation*>(param);
133
134  if (!divParam)
135  {
136    G4Exception("G4PVDivisionFactory::CreatePVDivision()",
137                "WrongType", FatalException,
138                "Unexpected parameterisation type !");
139  }
140
141  EAxis axis = divParam->GetAxis();
142  G4int nofDivisions = divParam->GetNoDiv();
143  G4double width = divParam->GetWidth();
144  G4double offset = divParam->GetOffset();
145
146  return new G4PVDivision(pName, pLogical, pMotherLogical, 
147                          axis, nofDivisions, width, offset);
148}   
149
150//_____________________________________________________________________________
151
152G4bool G4PVDivisionFactory::IsPVDivision(const G4VPhysicalVolume* pv) const
153{ 
154  // Returns true if pv is division
155  // ---
156
157  if (dynamic_cast<const G4PVDivision*>(pv))
158    return true;
159  else
160    return false; 
161}
162
Note: See TracBrowser for help on using the repository browser.