source: trunk/source/geometry/volumes/src/G4ReflectionFactory.cc @ 1202

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

file release beta

File size: 26.3 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: G4ReflectionFactory.cc,v 1.9 2008/11/13 09:33:20 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30//
31// Class G4ReflectionFactory Implementation
32//
33// Decomposition of a general transformation
34// that can include reflection in a "reflection-free" transformation:
35//
36// x(inM') = TG*x(inM)         TG - general transformation
37//         = T*(R*x(inM))      T  - "reflection-free" transformation
38//         = T* x(inReflM)   
39//
40// Daughters transformation:
41// When a volume V containing daughter D with transformation TD
42// is placed in mother M with a general tranformation TGV,
43// the TGV is decomposed,
44// new reflected volume ReflV containing a new daughter ReflD
45// with reflected transformation ReflTD is created:
46//
47// x(inV) = TD * x(inD);
48// x(inM) = TGV * x(inV)
49//        = TV * R * x(inV)
50//        = TV * R * TD * x(inD)
51//        = TV * R*TD*R-1 * R*x(inD)
52//        = TV * ReflTD * x(inReflD)
53
54// Author: Ivana Hrivnacova, 16.10.2001  (Ivana.Hrivnacova@cern.ch)
55// --------------------------------------------------------------------
56
57#include "G4ReflectionFactory.hh"
58#include "G4ReflectedSolid.hh"
59#include "G4Region.hh"
60#include "G4LogicalVolume.hh" 
61#include "G4PVPlacement.hh" 
62#include "G4PVReplica.hh" 
63#include "G4VPVDivisionFactory.hh"
64#include "G4GeometryTolerance.hh"
65
66G4ReflectionFactory* G4ReflectionFactory::fInstance = 0;
67const G4String  G4ReflectionFactory::fDefaultNameExtension = "_refl";
68const G4Scale3D G4ReflectionFactory::fScale = G4ScaleZ3D(-1.0);
69
70//_____________________________________________________________________________
71
72G4ReflectionFactory* G4ReflectionFactory::Instance() 
73{
74  // Static singleton access method.
75  // ---
76
77  if (!fInstance) { fInstance = new G4ReflectionFactory(); }
78
79  return fInstance;
80} 
81
82//_____________________________________________________________________________
83
84G4ReflectionFactory::G4ReflectionFactory()
85  : fVerboseLevel(0),
86    fNameExtension(fDefaultNameExtension)   
87{
88  // Protected singleton constructor.
89  // ---
90
91  fScalePrecision = 10.
92                  * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
93  fInstance = this;
94}
95
96//_____________________________________________________________________________
97
98G4ReflectionFactory::~G4ReflectionFactory()
99{
100  delete fInstance;
101}
102
103//
104// public methods
105//
106
107//_____________________________________________________________________________
108
109G4PhysicalVolumesPair
110G4ReflectionFactory::Place( const G4Transform3D& transform3D,
111                            const G4String&      name,
112                                  G4LogicalVolume* LV,
113                                  G4LogicalVolume* motherLV,
114                                  G4bool  isMany, 
115                                  G4int   copyNo,
116                                  G4bool  surfCheck)
117{
118  // Evaluates the passed transformation; if it contains reflection
119  // it performs its decomposition, creates new reflected solid and
120  // logical volume (or retrieves them from a map if the reflected
121  // objects were already created), transforms the daughters (if present)
122  // and place it in the given mother.
123  // The result is a pair of physical volumes;
124  // the second physical volume is a placement in a reflected mother
125  // - or 0 if mother LV was not reflected.
126  // ---
127
128  if (fVerboseLevel>0)
129  {
130    G4cout << "Place " << name << " lv " << LV << " "
131           << LV->GetName() << G4endl;
132  } 
133
134  // decompose transformation
135  G4Scale3D     scale;
136  G4Rotate3D    rotation;
137  G4Translate3D translation;
138
139  transform3D.getDecomposition(scale, rotation, translation);
140  G4Transform3D pureTransform3D = translation * rotation;
141 
142  //PrintTransform(transform3D);
143  //PrintTransform(pureTransform3D);
144
145  // check that scale correspond to fScale
146  //
147  CheckScale(scale);
148 
149  //
150  // reflection IS NOT present in transform3D
151  //
152
153  if (! IsReflection(scale))
154  {
155    if (fVerboseLevel>0)
156      G4cout << "Scale positive" << G4endl;
157
158    G4VPhysicalVolume* pv1
159      =  new G4PVPlacement(pureTransform3D, LV, name,
160                           motherLV, isMany, copyNo, surfCheck);
161 
162    G4VPhysicalVolume* pv2 = 0;
163    if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
164    {
165      // if mother was reflected
166      // reflect this LV and place it in reflected mother
167     
168      pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
169                              ReflectLV(LV, surfCheck), name, reflMotherLV,
170                              isMany, copyNo, surfCheck);
171    }
172   
173    return G4PhysicalVolumesPair(pv1, pv2);           
174  }         
175           
176  //
177  //  reflection IS present in transform3D
178  //
179
180  if (fVerboseLevel>0)
181    G4cout << "scale negative" << G4endl;
182
183  G4VPhysicalVolume* pv1
184    = new G4PVPlacement(pureTransform3D, ReflectLV(LV, surfCheck), name,
185                        motherLV, isMany, copyNo, surfCheck);
186
187  G4VPhysicalVolume* pv2 = 0;
188  if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
189  {
190
191    // if mother was reflected
192    // place the refLV consituent in reflected mother
193
194    pv2 =  new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
195                             LV, name, reflMotherLV, isMany, copyNo, surfCheck);
196  }
197
198  return G4PhysicalVolumesPair(pv1, pv2); 
199}           
200
201
202//_____________________________________________________________________________
203
204G4PhysicalVolumesPair
205G4ReflectionFactory::Replicate(const G4String& name, 
206                                     G4LogicalVolume* LV,
207                                     G4LogicalVolume* motherLV,
208                                     EAxis axis, 
209                                     G4int nofReplicas, 
210                                     G4double width,
211                                     G4double offset)
212{
213  // Creates replica in given mother.
214  // The result is a pair of physical volumes;
215  // the second physical volume is a replica in a reflected mother
216  // - or 0 if mother LV was not reflected.
217  // ---
218
219  if (fVerboseLevel>0)
220  {
221    G4cout << "Replicate " << name << " lv " << LV << " " 
222           << LV->GetName() << G4endl;
223  } 
224
225  G4VPhysicalVolume* pv1
226    = new G4PVReplica(name, LV, motherLV, axis, nofReplicas, width, offset);
227 
228  G4VPhysicalVolume* pv2 = 0;
229  if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
230  {
231    // if mother was reflected
232    // reflect the LV and replicate it in reflected mother
233   
234    pv2 = new G4PVReplica(name, ReflectLV(LV), reflMotherLV, 
235                          axis, nofReplicas, width, offset); 
236  }
237   
238  return G4PhysicalVolumesPair(pv1, pv2);           
239}         
240       
241//_____________________________________________________________________________
242
243G4PhysicalVolumesPair
244G4ReflectionFactory::Divide(const G4String& name, 
245                                  G4LogicalVolume* LV,
246                                  G4LogicalVolume* motherLV,
247                                  EAxis axis, 
248                                  G4int nofDivisions, 
249                                  G4double width,
250                                  G4double offset)
251{
252  // Creates division in the given mother.
253  // The result is a pair of physical volumes;
254  // the second physical volume is a division in a reflected mother
255  // or 0 if mother LV was not reflected.
256  // ---
257
258  if (fVerboseLevel>0)
259  {
260    G4cout << "Divide " << name << " lv " << LV << " " 
261           << LV->GetName() << G4endl;
262  } 
263
264  G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
265
266  G4VPhysicalVolume* pv1 = divisionFactory
267      ->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, width, offset);
268 
269  G4VPhysicalVolume* pv2 = 0;
270  if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
271  {
272    // if mother was reflected
273    // reflect the LV and replicate it in reflected mother
274   
275    pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV, 
276                                            axis, nofDivisions, width, offset); 
277  }
278   
279  return G4PhysicalVolumesPair(pv1, pv2);           
280}         
281       
282             
283//_____________________________________________________________________________
284
285G4PhysicalVolumesPair
286G4ReflectionFactory::Divide(const G4String& name, 
287                                  G4LogicalVolume* LV,
288                                  G4LogicalVolume* motherLV,
289                                  EAxis axis, 
290                                  G4int nofDivisions, 
291                                  G4double offset)
292{
293  // Creates division in the given mother.
294  // The result is a pair of physical volumes;
295  // the second physical volume is a division in a reflected mother
296  // or 0 if mother LV was not reflected.
297  // ---
298
299  if (fVerboseLevel>0)
300  {
301    G4cout << "Divide " << name << " lv " << LV << " " 
302           << LV->GetName() << G4endl;
303  } 
304
305  G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
306
307  G4VPhysicalVolume* pv1 = divisionFactory
308      ->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, offset);
309 
310  G4VPhysicalVolume* pv2 = 0;
311  if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
312  {
313    // if mother was reflected
314    // reflect the LV and replicate it in reflected mother
315   
316    pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV, 
317                                            axis, nofDivisions, offset); 
318  }
319   
320  return G4PhysicalVolumesPair(pv1, pv2);           
321}         
322       
323             
324//_____________________________________________________________________________
325
326G4PhysicalVolumesPair
327G4ReflectionFactory::Divide(const G4String& name, 
328                                  G4LogicalVolume* LV,
329                                  G4LogicalVolume* motherLV,
330                                  EAxis axis, 
331                                  G4double width,
332                                  G4double offset)
333{
334  // Creates division in the given mother.
335  // The result is a pair of physical volumes;
336  // the second physical volume is a division in a reflected mother
337  // or 0 if mother LV was not reflected.
338  // ---
339
340  if (fVerboseLevel>0)
341  {
342    G4cout << "Divide " << name << " lv " << LV << " " 
343           << LV->GetName() << G4endl;
344  } 
345
346  G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
347
348  G4VPhysicalVolume* pv1 = divisionFactory
349    -> CreatePVDivision(name, LV, motherLV, axis, width, offset);
350 
351  G4VPhysicalVolume* pv2 = 0;
352  if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
353  {
354    // if mother was reflected
355    // reflect the LV and replicate it in reflected mother
356   
357    pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV, 
358                                            axis, width, offset); 
359  }
360   
361  return G4PhysicalVolumesPair(pv1, pv2);           
362}         
363       
364             
365//
366// private methods
367//
368
369//_____________________________________________________________________________
370
371G4LogicalVolume* G4ReflectionFactory::ReflectLV(G4LogicalVolume* LV,
372                                                G4bool surfCheck) 
373{
374  // Gets/creates the reflected solid and logical volume
375  // and copies + transforms LV daughters.
376  // ---
377
378  G4LogicalVolume* refLV = GetReflectedLV(LV);
379
380  if (!refLV)
381  {
382
383    // create new (reflected) objects
384    //
385    refLV = CreateReflectedLV(LV);
386       
387    // process daughters 
388    //
389    ReflectDaughters(LV, refLV, surfCheck);
390
391    // check if to be set as root region
392    //
393    if (LV->IsRootRegion())
394    {
395       LV->GetRegion()->AddRootLogicalVolume(refLV);
396    }
397  }
398
399  return refLV;
400}
401
402//_____________________________________________________________________________
403
404G4LogicalVolume* G4ReflectionFactory::CreateReflectedLV(G4LogicalVolume* LV) 
405{
406  // Creates the reflected solid and logical volume
407  // and add the logical volumes pair in the maps.
408  // ---
409
410  // consistency check
411  //
412  if (fReflectedLVMap.find(LV) != fReflectedLVMap.end())
413  {
414    G4cerr << "ERROR - G4ReflectionFactory::CreateReflectedLV(..): "
415           << LV->GetName() << G4endl
416           << "        Cannot be applied to an already reflected volume !"
417           << G4endl;
418    G4Exception("G4ReflectionFactory::CreateReflectedLV(..)",
419                "NotApplicable", FatalException,
420                "Cannot be applied to a volume already reflected.");
421  }       
422             
423  G4VSolid* refSolid
424    = new G4ReflectedSolid(LV->GetSolid()->GetName() + fNameExtension,
425                           LV->GetSolid(), fScale);
426     
427  G4LogicalVolume* refLV
428    = new G4LogicalVolume(refSolid, 
429                          LV->GetMaterial(),                 
430                          LV->GetName() + fNameExtension,
431                          LV->GetFieldManager(),
432                          LV->GetSensitiveDetector(),
433                          LV->GetUserLimits());
434  refLV->SetVisAttributes(LV->GetVisAttributes());  // vis-attributes
435  refLV->SetBiasWeight(LV->GetBiasWeight());        // biasing weight
436  if (LV->IsRegion())
437  {
438    refLV->SetRegion(LV->GetRegion());              // set a region in case
439  }
440
441  fConstituentLVMap[LV] = refLV;
442  fReflectedLVMap[refLV] = LV;
443
444  return refLV;       
445}
446
447//_____________________________________________________________________________
448
449void G4ReflectionFactory::ReflectDaughters(G4LogicalVolume* LV, 
450                                           G4LogicalVolume* refLV,
451                                           G4bool surfCheck)
452{
453  // Reflects daughters recursively.
454  // ---
455
456  if (fVerboseLevel>0)
457  {
458    G4cout << "G4ReflectionFactory::ReflectDaughters(): " 
459           << LV->GetNoDaughters() << " of " << LV->GetName() << G4endl;
460  }     
461
462  for (G4int i=0; i<LV->GetNoDaughters(); i++)
463  {
464    G4VPhysicalVolume* dPV = LV->GetDaughter(i);
465   
466    if (! dPV->IsReplicated())
467    {
468      ReflectPVPlacement(dPV, refLV, surfCheck); 
469    } 
470    else if (! dPV->GetParameterisation())
471    {
472      ReflectPVReplica(dPV, refLV); 
473    } 
474    else if (G4VPVDivisionFactory::Instance() &&
475             G4VPVDivisionFactory::Instance()->IsPVDivision(dPV))
476    {
477      ReflectPVDivision(dPV, refLV); 
478    } 
479    else
480    {
481      ReflectPVParameterised(dPV, refLV, surfCheck); 
482    }
483  }
484}
485
486//_____________________________________________________________________________
487
488void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV, 
489                                             G4LogicalVolume* refLV,
490                                             G4bool surfCheck)
491{
492  // Copies and transforms daughter of PVPlacement type of
493  // a constituent volume into a reflected volume.
494  // ---
495
496  G4LogicalVolume* dLV = dPV->GetLogicalVolume();
497
498  // update daughter transformation
499  //
500  G4Transform3D dt(dPV->GetObjectRotationValue(), dPV->GetObjectTranslation());
501  dt = fScale * (dt * fScale.inverse());
502
503  G4LogicalVolume* refDLV;
504 
505  if (fVerboseLevel>0) 
506    G4cout << "Daughter: " << dPV << "  " << dLV->GetName();
507 
508  if (!IsReflected(dLV))
509  {
510
511    if (fVerboseLevel>0) 
512      G4cout << " will be reflected." << G4endl;
513
514    // get reflected volume if already created    //
515    refDLV = GetReflectedLV(dLV); 
516
517    if (!refDLV)
518    {
519      // create new daughter solid and logical volume
520      //
521      refDLV = CreateReflectedLV(dLV); 
522 
523      // recursive call
524      //
525      ReflectDaughters(dLV, refDLV, surfCheck);   
526    } 
527
528    // create new daughter physical volume
529    // with updated transformation
530
531    new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV, 
532                      dPV->IsMany(), dPV->GetCopyNo(), surfCheck); 
533
534  } 
535  else
536  {
537    if (fVerboseLevel>0) 
538      G4cout << " will be reconstitued." << G4endl;
539
540    refDLV = GetConstituentLV(dLV); 
541
542    new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV, 
543                      dPV->IsMany(), dPV->GetCopyNo(), surfCheck); 
544  }       
545}   
546
547//_____________________________________________________________________________
548
549void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV, 
550                                           G4LogicalVolume* refLV)
551{
552  // Copies and transforms daughter of PVReplica type of
553  // a constituent volume into a reflected volume.
554  // ---
555
556  G4LogicalVolume* dLV = dPV->GetLogicalVolume();
557
558  // get replication data
559  //
560  EAxis axis;
561  G4int nofReplicas;
562  G4double width;
563  G4double offset;
564  G4bool consuming;
565
566  dPV->GetReplicationData(axis, nofReplicas, width, offset, consuming);
567
568  G4LogicalVolume* refDLV;
569 
570  if (fVerboseLevel>0) 
571    G4cout << "Daughter: " << dPV << "  " << dLV->GetName();
572 
573  if (!IsReflected(dLV))
574  {
575    if (fVerboseLevel>0) 
576      G4cout << " will be reflected." << G4endl;
577
578    // get reflected volume if already created
579    //
580    refDLV = GetReflectedLV(dLV); 
581
582    if (!refDLV)
583    {
584      // create new daughter solid and logical volume
585      //
586      refDLV = CreateReflectedLV(dLV); 
587 
588      // recursive call
589      //
590      ReflectDaughters(dLV, refDLV); 
591    }     
592       
593    // create new daughter replica
594    //
595    new G4PVReplica(dPV->GetName(), refDLV, refLV, 
596                    axis, nofReplicas, width, offset);
597  }
598  else
599  {
600    if (fVerboseLevel>0) 
601      G4cout << " will be reconstitued." << G4endl;
602
603    refDLV = GetConstituentLV(dLV); 
604
605    new G4PVReplica(dPV->GetName(), refDLV, refLV, 
606                    axis, nofReplicas, width, offset); 
607  }       
608}
609
610//_____________________________________________________________________________
611
612void G4ReflectionFactory::ReflectPVDivision(G4VPhysicalVolume* dPV, 
613                                            G4LogicalVolume* refLV)
614{
615  // Copies and transforms daughter of PVDivision type of
616  // a constituent volume into a reflected volume.
617  // ---
618
619  G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
620
621  G4LogicalVolume* dLV = dPV->GetLogicalVolume();
622
623  // get parameterisation data
624  //
625  G4VPVParameterisation* param = dPV->GetParameterisation();
626
627  G4LogicalVolume* refDLV;
628 
629  if (fVerboseLevel>0) 
630    G4cout << "Daughter: " << dPV << "  " << dLV->GetName();
631 
632  if (!IsReflected(dLV))
633  {
634    if (fVerboseLevel>0) 
635      G4cout << " will be reflected." << G4endl;
636
637    // get reflected volume if already created
638    //
639    refDLV = GetReflectedLV(dLV); 
640
641    if (!refDLV)
642    {
643      // create new daughter solid and logical volume
644      //
645      refDLV = CreateReflectedLV(dLV); 
646 
647      // recursive call
648      //
649      ReflectDaughters(dLV, refDLV); 
650    }     
651       
652    // create new daughter replica
653    //
654    divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param);
655  }
656  else
657  {
658    if (fVerboseLevel>0) 
659      G4cout << " will be reconstitued." << G4endl;
660
661    refDLV = GetConstituentLV(dLV); 
662
663    divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param); 
664  }       
665}
666
667//_____________________________________________________________________________
668
669void G4ReflectionFactory::ReflectPVParameterised(G4VPhysicalVolume* dPV, 
670                                                 G4LogicalVolume*, G4bool)
671{
672  // Not implemented.
673  // Should copy and transform daughter of PVReplica type of
674  // a constituent volume into a reflected volume.
675  // ---
676
677  G4cerr << "ERROR - G4ReflectionFactory::ReflectPVParameterised(...): "
678         << dPV->GetName() << G4endl
679         << "        Reflection of parameterised volumes "
680         << "is not yet implemented." << G4endl;
681  G4Exception("G4ReflectionFactory::ReflectPVParameterised(...)",
682              "NotImplemented", FatalException,
683              "Sorry, not yet implemented.");
684}
685
686//_____________________________________________________________________________
687
688G4LogicalVolume*
689G4ReflectionFactory::GetConstituentLV(G4LogicalVolume* reflLV) const
690{             
691  // Returns the consituent volume of the given reflected volume,
692  // 0 if the given reflected volume was not found.
693  // ---
694
695  LogicalVolumesMapIterator it = fReflectedLVMap.find(reflLV);
696
697  if (it == fReflectedLVMap.end()) return 0;
698
699  return (*it).second;
700}       
701
702//_____________________________________________________________________________
703
704G4LogicalVolume*
705G4ReflectionFactory::GetReflectedLV(G4LogicalVolume* lv) const
706{             
707  // Returns the reflected volume of the given consituent volume,
708  // 0 if the given volume was not reflected.
709  // ---
710
711  LogicalVolumesMapIterator it = fConstituentLVMap.find(lv);
712
713  if (it == fConstituentLVMap.end()) return 0;
714
715  return (*it).second;
716}       
717
718//_____________________________________________________________________________
719
720G4bool G4ReflectionFactory::IsConstituent(G4LogicalVolume* lv) const
721{
722  // Returns true if the given volume has been already reflected
723  // (is in the map of constituent volumes).
724  // ---
725
726  return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
727} 
728
729//_____________________________________________________________________________
730
731G4bool G4ReflectionFactory::IsReflected(G4LogicalVolume* lv) const
732{
733  // Returns true if the given volume is a reflected volume
734  // (is in the map reflected  volumes).
735  // ---
736
737  return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
738} 
739
740//_____________________________________________________________________________
741
742G4bool G4ReflectionFactory::IsReflection(const G4Scale3D& scale) const
743{
744  // Returns true if the scale is negative, false otherwise.
745  // ---
746
747  if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)
748    return true;
749  else 
750    return false; 
751}
752
753//_____________________________________________________________________________
754
755const G4ReflectedVolumesMap&
756G4ReflectionFactory::GetReflectedVolumesMap() const
757{
758  return fReflectedLVMap;
759}
760
761//_____________________________________________________________________________
762
763void G4ReflectionFactory::PrintConstituentLVMap()
764{
765  // temporary - for debugging purpose
766  // ---
767
768  LogicalVolumesMapIterator it;
769  for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); it++)
770  {
771    G4cout << "lv: " << (*it).first << "  lv_refl: " << (*it).second << G4endl;
772  }
773  G4cout << G4endl;
774} 
775
776//_____________________________________________________________________________
777
778void G4ReflectionFactory::CheckScale(const G4Scale3D& scale) const
779{
780  // Check if scale correspond to fScale,
781  // if not give exception.
782  // ---
783
784  if (!IsReflection(scale)) return;
785 
786  G4double diff = 0.;
787  for (G4int i=0; i<4; i++)
788    for (G4int j=0; j<4; j++) 
789      diff += std::abs(scale(i,j) - fScale(i,j)); 
790
791  if (diff > fScalePrecision)
792  {
793    G4cerr << "ERROR - G4ReflectionFactory::CheckScale(..)" << G4endl
794           << "        Unexpected scale. Difference: " << diff << G4endl;
795    G4Exception("G4ReflectionFactory::CheckScale(..)",
796                "WrongArgumentValue", FatalException,
797                "Unexpected scale in input !");
798  }
799}   
800
801//_____________________________________________________________________________
802
803G4VPVDivisionFactory* G4ReflectionFactory::GetPVDivisionFactory() const
804{
805  // Returns the G4PVDivisionFactory instance if it exists,
806  // otherwise gives exception
807  // ---
808
809  G4VPVDivisionFactory* divisionFactory = G4VPVDivisionFactory::Instance();
810  if (!divisionFactory)
811  {
812     G4cerr << "ERROR - G4ReflectionFactory::GetPVDivisionFactory()" << G4endl
813            << "        It has been requested to reflect divided volumes."
814            << G4endl
815            << "        In this case, it is required to instantiate a concrete"
816            << G4endl
817            << "        factory G4PVDivisionFactory in your program -before-"
818            << G4endl
819            << "        executing the reflection !" << G4endl;
820     G4Exception("G4ReflectionFactory::GetPVDivisionFactory()",
821                 "WrongSetup", FatalException,
822                 "A concrete G4PVDivisionFactory instantiated is required !");
823  }
824 
825  return divisionFactory;
826} 
827
828//_____________________________________________________________________________
829
830void G4ReflectionFactory::SetScalePrecision(G4double scaleValue)
831{
832  fScalePrecision = scaleValue;
833}
834
835//_____________________________________________________________________________
836
837G4double G4ReflectionFactory::GetScalePrecision() const
838{
839  return fScalePrecision;
840}
841
842//_____________________________________________________________________________
843
844void G4ReflectionFactory::SetVerboseLevel(G4int verboseLevel)
845{
846  fVerboseLevel = verboseLevel;
847}
848         
849//_____________________________________________________________________________
850
851G4int G4ReflectionFactory::GetVerboseLevel() const
852{
853  return fVerboseLevel;
854}
855
856//_____________________________________________________________________________
857
858void G4ReflectionFactory::SetVolumesNameExtension(const G4String& nameExtension)
859{
860  fNameExtension = nameExtension;
861}
862         
863//_____________________________________________________________________________
864
865const G4String& G4ReflectionFactory::GetVolumesNameExtension() const
866{
867  return fNameExtension;
868}
869         
870/*
871  // placement with decomposed transformation
872
873  G4VPhysicalVolume* pv1
874    =  new G4PVPlacement(new G4RotationMatrix(rotation.getRotation().inverse()),
875                         translation.getTranslation(),
876            refLV, name, motherLV, isMany, copyNo);
877*/
Note: See TracBrowser for help on using the repository browser.