Geant4  10.01.p03
G4UMultiUnion.cc
Go to the documentation of this file.
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:$
28 //
29 //
30 // Implementation of G4UMultiUnion wrapper class
31 // --------------------------------------------------------------------
32 
33 #include "G4UMultiUnion.hh"
34 #include "G4Polyhedron.hh"
35 #include "G4DisplacedSolid.hh"
36 #include "G4RotationMatrix.hh"
37 
39 //
40 // Constructor (generic parameters)
41 //
43  : G4USolid(name, new UMultiUnion(name))
44 {
45 }
46 
47 
49 //
50 // Fake default constructor - sets only member data and allocates memory
51 // for usage restricted to object persistency.
52 //
54  : G4USolid(a)
55 {
56 }
57 
58 
60 //
61 // Destructor
62 //
64 {
65 }
66 
67 
69 //
70 // Copy constructor
71 //
73  : G4USolid(source)
74 {
75 }
76 
77 
79 //
80 // Assignment operator
81 //
83 {
84  if (this == &source) return *this;
85 
86  G4USolid::operator=( source );
87 
88  return *this;
89 }
90 
91 
93 //
94 // CreatePolyhedron
95 //
97 {
98 
99  HepPolyhedronProcessor processor;
100  HepPolyhedronProcessor::Operation operation = HepPolyhedronProcessor::UNION;
101 
102  G4VSolid* solidA = GetSolid(0);
103  const G4Transform3D* transform0=GetTransformation(0);
104  G4RotationMatrix rot0=(*transform0).getRotation();
105  const G4ThreeVector transl0 = (*transform0).getTranslation();
106  G4DisplacedSolid dispSolidA("placedA",solidA,&rot0,transl0);
107  delete transform0;
108 
109  G4Polyhedron* top = new G4Polyhedron(*dispSolidA.GetPolyhedron());
110 
111  for(G4int i=1; i<GetNumberOfSolids(); ++i)
112  {
113  G4VSolid* solidB = GetSolid(i);
114  const G4Transform3D* transform=GetTransformation(i);
115  G4RotationMatrix rot=(*transform).getRotation();
116  const G4ThreeVector transl = (*transform).getTranslation();
117  G4DisplacedSolid dispSolidB("placedB",solidB,&rot,transl);
118  G4Polyhedron* operand = dispSolidB.GetPolyhedron();
119  processor.push_back (operation, *operand);
120  delete transform;
121  }
122 
123  if (processor.execute(*top)) { return top; }
124  else { return 0; }
125 }
G4Polyhedron * GetPolyhedron() const
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4String name
Definition: TRTMaterials.hh:40
G4Polyhedron * CreatePolyhedron() const
G4double a
Definition: TRTMaterials.hh:39
VUSolid * GetSolid() const
Definition: G4USolid.hh:171
int G4int
Definition: G4Types.hh:78
G4Transform3D * GetTransformation(G4int index) const
static int operand(pchar begin, pchar end, double &result, pchar &endp, const dic_type &dictionary)
Definition: Evaluator.cc:162
G4UMultiUnion & operator=(const G4UMultiUnion &source)
HepGeom::Transform3D G4Transform3D
#define processor
Definition: xmlparse.cc:600
G4USolid & operator=(const G4USolid &rhs)
Definition: G4USolid.cc:377
G4UMultiUnion(const G4String &name)
int GetNumberOfSolids() const