Geant4  10.02.p01
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 
35 #if defined(G4GEOM_USE_USOLIDS)
36 
37 #include "G4Polyhedron.hh"
38 #include "G4DisplacedSolid.hh"
39 #include "G4RotationMatrix.hh"
40 
42 //
43 // Constructor (generic parameters)
44 //
45 G4UMultiUnion::G4UMultiUnion(const G4String& name)
46  : G4USolid(name, new UMultiUnion(name))
47 {
48 }
49 
50 
52 //
53 // Fake default constructor - sets only member data and allocates memory
54 // for usage restricted to object persistency.
55 //
56 G4UMultiUnion::G4UMultiUnion(__void__& a)
57  : G4USolid(a)
58 {
59 }
60 
61 
63 //
64 // Destructor
65 //
66 G4UMultiUnion::~G4UMultiUnion()
67 {
68 }
69 
70 
72 //
73 // Copy constructor
74 //
75 G4UMultiUnion::G4UMultiUnion(const G4UMultiUnion &source)
76  : G4USolid(source)
77 {
78 }
79 
80 
82 //
83 // Assignment operator
84 //
85 G4UMultiUnion& G4UMultiUnion::operator=(const G4UMultiUnion &source)
86 {
87  if (this == &source) return *this;
88 
89  G4USolid::operator=( source );
90 
91  return *this;
92 }
93 
94 
96 //
97 // CreatePolyhedron
98 //
99 G4Polyhedron* G4UMultiUnion::CreatePolyhedron() const
100 {
101 
102  HepPolyhedronProcessor processor;
103  HepPolyhedronProcessor::Operation operation = HepPolyhedronProcessor::UNION;
104 
105  G4VSolid* solidA = GetSolid(0);
106  const G4Transform3D* transform0=GetTransformation(0);
107  G4RotationMatrix rot0=(*transform0).getRotation();
108  const G4ThreeVector transl0 = (*transform0).getTranslation();
109  G4DisplacedSolid dispSolidA("placedA",solidA,&rot0,transl0);
110  delete transform0;
111 
112  G4Polyhedron* top = new G4Polyhedron(*dispSolidA.GetPolyhedron());
113 
114  for(G4int i=1; i<GetNumberOfSolids(); ++i)
115  {
116  G4VSolid* solidB = GetSolid(i);
117  const G4Transform3D* transform=GetTransformation(i);
118  G4RotationMatrix rot=(*transform).getRotation();
119  const G4ThreeVector transl = (*transform).getTranslation();
120  G4DisplacedSolid dispSolidB("placedB",solidB,&rot,transl);
121  G4Polyhedron* operand = dispSolidB.GetPolyhedron();
122  processor.push_back (operation, *operand);
123  delete transform;
124  }
125 
126  if (processor.execute(*top)) { return top; }
127  else { return 0; }
128 }
129 
130 #endif // G4GEOM_USE_USOLIDS
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4String name
Definition: TRTMaterials.hh:40
G4double a
Definition: TRTMaterials.hh:39
int G4int
Definition: G4Types.hh:78
static int operand(pchar begin, pchar end, double &result, pchar &endp, const dic_type &dictionary)
Definition: Evaluator.cc:162
HepGeom::Transform3D G4Transform3D
#define processor
Definition: xmlparse.cc:617