Ignore:
Timestamp:
Nov 3, 2009, 11:17:28 AM (16 years ago)
Author:
garnier
Message:

update to CVS

Location:
trunk/source/visualization/modeling
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/modeling/History

    r931 r1140  
    1 $Id: History,v 1.109 2009/02/25 14:21:45 allison Exp $
     1$Id: History,v 1.114 2009/10/22 15:40:00 allison Exp $
    22-------------------------------------------------------------------
    33
     
    2020History file for visualization/modeling
    2121---------------------------------------
     22
     2322nd October 2009  John Allison  (modeling-V09-02-05 coworks greps-V09-02-02)
     24- Added G4PSHitsModel for gMocren driver.
     25
     2621st October 2009  John Allison  (modeling-V09-02-04 coworks greps-V09-02-02)
     27- G4BoundingSphereScene, G4PhysicalVolumeMassScene,
     28  G4PhysicalVolumeSearchScene:
     29  o Added empty AddCompound (const G4THitsMap<G4double>&) methods.
     30
     3110th October 2009  John Allison  (modeling-V09-02-03)
     32- G4PhysicalVolumeModel: Added G4PhysicalVolumeModelTouchable.  Used in
     33  ComputeMaterial.  Effective for nested parameterisations.
     34
     3529th September 2009  John Allison  (modeling-V09-02-02)
     36- G4PhysicalVolumeModel.cc: Added warning if logical volume not defined.
    2237
    233825th February 2009  John Allison  (modeling-V09-02-01 - needs greps-V09-02-01)
  • trunk/source/visualization/modeling/include/G4BoundingSphereScene.hh

    r954 r1140  
    2525//
    2626//
    27 // $Id: G4BoundingSphereScene.hh,v 1.18 2008/01/04 21:59:15 allison Exp $
     27// $Id: G4BoundingSphereScene.hh,v 1.19 2009/10/21 14:17:33 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    7171  void AddCompound (const G4VTrajectory&) {}
    7272  void AddCompound (const G4VHit&) {}
     73  void AddCompound (const G4THitsMap<G4double>&) {}
    7374  G4VisExtent GetBoundingSphereExtent ();
    7475  const G4Point3D& GetCentre() const {return fCentre;}
  • trunk/source/visualization/modeling/include/G4PhysicalVolumeMassScene.hh

    r954 r1140  
    2525//
    2626//
    27 // $Id: G4PhysicalVolumeMassScene.hh,v 1.9 2008/01/04 21:59:15 allison Exp $
     27// $Id: G4PhysicalVolumeMassScene.hh,v 1.10 2009/10/21 14:17:33 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    109109  void AddCompound (const G4VTrajectory&) {}
    110110  void AddCompound (const G4VHit&) {}
     111  void AddCompound (const G4THitsMap<G4double>&) {}
    111112
    112113  ////////////////////////////////////////////////////////////////
  • trunk/source/visualization/modeling/include/G4PhysicalVolumeModel.hh

    r954 r1140  
    2525//
    2626//
    27 // $Id: G4PhysicalVolumeModel.hh,v 1.34 2007/04/03 13:46:49 allison Exp $
     27// $Id: G4PhysicalVolumeModel.hh,v 1.35 2009/10/10 14:29:59 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    4949
    5050#include "G4VModel.hh"
     51#include "G4VTouchable.hh"
    5152
    5253#include "G4Transform3D.hh"
     
    7677  public:
    7778    G4PhysicalVolumeNodeID
    78     (G4VPhysicalVolume* pPV = 0, G4int iCopyNo = 0, G4int depth = 0):
    79       fpPV(pPV), fCopyNo(iCopyNo), fNonCulledDepth(depth) {}
     79    (G4VPhysicalVolume* pPV = 0,
     80     G4int iCopyNo = 0,
     81     G4int depth = 0,
     82     const G4Transform3D& transform = G4Transform3D()):
     83      fpPV(pPV),
     84      fCopyNo(iCopyNo),
     85      fNonCulledDepth(depth),
     86      fTransform(transform) {}
    8087    G4VPhysicalVolume* GetPhysicalVolume() const {return fpPV;}
    8188    G4int GetCopyNo() const {return fCopyNo;}
    8289    G4int GetNonCulledDepth() const {return fNonCulledDepth;}
     90    const G4Transform3D& GetTransform() const {return fTransform;}
    8391    G4bool operator< (const G4PhysicalVolumeNodeID& right) const;
    8492  private:
     
    8694    G4int fCopyNo;
    8795    G4int fNonCulledDepth;
     96    G4Transform3D fTransform;
    8897  };
    8998  // Nested class for identifying physical volume nodes.
     99
     100  class G4PhysicalVolumeModelTouchable: public G4VTouchable {
     101  public:
     102    G4PhysicalVolumeModelTouchable
     103    (const std::vector<G4PhysicalVolumeNodeID>& fullPVPath);
     104    const G4ThreeVector& GetTranslation(G4int depth) const;
     105    const G4RotationMatrix* GetRotation(G4int depth) const;
     106    G4VPhysicalVolume* GetVolume(G4int depth) const;
     107    G4VSolid* GetSolid(G4int depth) const;
     108    G4int GetReplicaNumber(G4int depth) const;
     109    G4int GetHistoryDepth() const {return fFullPVPath.size();}
     110  private:
     111    const std::vector<G4PhysicalVolumeNodeID>& fFullPVPath;
     112  };
     113  // Nested class for handling nested parameterisations.
    90114
    91115  G4PhysicalVolumeModel
  • trunk/source/visualization/modeling/include/G4PhysicalVolumeSearchScene.hh

    r954 r1140  
    2525//
    2626//
    27 // $Id: G4PhysicalVolumeSearchScene.hh,v 1.18 2008/01/04 21:59:15 allison Exp $
     27// $Id: G4PhysicalVolumeSearchScene.hh,v 1.19 2009/10/21 14:17:33 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    7474  void AddCompound (const G4VTrajectory&) {}
    7575  void AddCompound (const G4VHit&) {}
     76  void AddCompound (const G4THitsMap<G4double>&) {}
    7677  G4int                GetFoundDepth          () const;
    7778  G4VPhysicalVolume*   GetFoundVolume         () const;
  • trunk/source/visualization/modeling/src/G4PhysicalVolumeModel.cc

    r1089 r1140  
    2525//
    2626//
    27 // $Id: G4PhysicalVolumeModel.cc,v 1.63 2007/11/10 14:56:36 allison Exp $
     27// $Id: G4PhysicalVolumeModel.cc,v 1.66 2009/10/23 08:08:19 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    4646#include "G4TransportationManager.hh"
    4747#include "G4Polyhedron.hh"
     48#include "HepPolyhedronProcessor.h"
    4849#include "G4AttDefStore.hh"
    4950#include "G4AttDef.hh"
     
    5354
    5455#include <sstream>
    55 
    56 G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
    57   (const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& right) const
    58 {
    59   if (fpPV < right.fpPV) return true;
    60   if (fpPV == right.fpPV) {
    61     if (fCopyNo < right.fCopyNo) return true;
    62     if (fCopyNo == right.fCopyNo)
    63       return fNonCulledDepth < right.fNonCulledDepth;
    64   }
    65   return false;
    66 }
    67 
    68 std::ostream& operator<<
    69   (std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID node)
    70 {
    71   G4VPhysicalVolume* pPV = node.GetPhysicalVolume();
    72   if (pPV) {
    73     os << pPV->GetName()
    74        << ':' << node.GetCopyNo()
    75        << '[' << node.GetNonCulledDepth() << ']';
    76   } else {
    77     os << "Null node";
    78   }
    79   return os;
    80 }
    8156
    8257G4PhysicalVolumeModel::G4PhysicalVolumeModel
     
    232207    G4VPVParameterisation* pP = pVPV -> GetParameterisation ();
    233208    if (pP) {  // Parametrised volume.
     209      if (fCurrentDepth == 0) nReplicas = 1;  // Just draw first
    234210      for (int n = 0; n < nReplicas; n++) {
    235211        pSol = pP -> ComputeSolid (n, pVPV);
    236         pMaterial = pP -> ComputeMaterial (n, pVPV);
    237212        pP -> ComputeTransformation (n, pVPV);
    238213        pSol -> ComputeDimensions (pP, n, pVPV);
    239214        pVPV -> SetCopyNo (n);
     215        // Create a touchable of current parent for ComputeMaterial.
     216        // fFullPVPath has not been updated yet so at this point it
     217        // corresponds to the parent.
     218        G4PhysicalVolumeModelTouchable parentTouchable(fFullPVPath);
     219        pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
    240220        DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
    241221                            theAT, sceneHandler);
     
    363343  fpCurrentTransform = &theNewAT;
    364344
    365   /********************************************************
    366   G4cout << "G4PhysicalVolumeModel::DescribeAndDescend: "
    367          << pVPV -> GetName () << "." << pVPV -> GetCopyNo ();
    368   G4cout << "\n  theAT: ";
    369   G4cout << "\n    Rotation: ";
    370   G4RotationMatrix rotation = theAT.getRotation ();
    371   G4cout << rotation.thetaX() << ", "
    372          << rotation.phiX() << ", "
    373          << rotation.thetaY() << ", "
    374          << rotation.phiY() << ", "
    375          << rotation.thetaZ() << ", "
    376          << rotation.phiZ();
    377   G4cout << "\n    Translation: " << theAT.getTranslation();
    378   G4cout << "\n  theNewAT: ";
    379   G4cout << "\n    Rotation: ";
    380   rotation = theNewAT.getRotation ();
    381   G4cout << rotation.thetaX() << ", "
    382          << rotation.phiX() << ", "
    383          << rotation.thetaY() << ", "
    384          << rotation.phiY() << ", "
    385          << rotation.thetaZ() << ", "
    386          << rotation.phiZ();
    387   G4cout << "\n    Translation: " << theNewAT.getTranslation();
    388   G4cout << G4endl;
    389   **********************************************************/
    390 
    391345  // Make decision to draw...
    392346  const G4VisAttributes* pVisAttribs = pLV->GetVisAttributes();
     
    429383  G4int copyNo = fpCurrentPV->GetCopyNo();
    430384  fFullPVPath.push_back
    431     (G4PhysicalVolumeNodeID(fpCurrentPV,copyNo,fCurrentDepth));
     385    (G4PhysicalVolumeNodeID
     386     (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
    432387
    433388  if (thisToBeDrawn) {
     
    436391    G4int copyNo = fpCurrentPV->GetCopyNo();
    437392    fDrawnPVPath.push_back
    438       (G4PhysicalVolumeNodeID(fpCurrentPV,copyNo,fCurrentDepth));
     393      (G4PhysicalVolumeNodeID
     394       (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
    439395
    440396    if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
     
    563519    G4Polyhedron* pOriginal = pSol->GetPolyhedron();
    564520    G4Polyhedron::ResetNumberOfRotationSteps();
     521
    565522    if (!pOriginal) {
    566         if (fpMP->IsWarning())
    567           G4cout <<
    568  "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n  \""
    569                  << pSol->GetName() <<
    570  "\" has no polyhedron.  Cannot by clipped."
    571                  << G4endl;
    572         pSol -> DescribeYourselfTo (sceneHandler);  // Standard treatment.
     523
     524      if (fpMP->IsWarning())
     525        G4cout <<
     526          "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n  \""
     527               << pSol->GetName() <<
     528          "\" has no polyhedron.  Cannot by clipped."
     529               << G4endl;
     530      pSol -> DescribeYourselfTo (sceneHandler);  // Standard treatment.
     531
    573532    } else {
    574533
    575534      G4Polyhedron resultant = *pOriginal;
     535      G4VisAttributes resultantVisAttribs(*pVisAttribs);
    576536
    577537      if (fpClippingPolyhedron) {
    578538        G4Polyhedron clipper = *fpClippingPolyhedron;  // Local copy.
    579539        clipper.Transform(theAT.inverse());
     540        HepPolyhedronProcessor processor;
    580541        switch (fClippingMode) {
    581542        default:
    582         case subtraction: resultant = resultant.subtract(clipper); break;
    583         case intersection: resultant = resultant.intersect(clipper); break;
     543        case subtraction: processor.push_back(HepPolyhedronProcessor::SUBTRACTION, clipper); break;
     544        case intersection: processor.push_back(HepPolyhedronProcessor::INTERSECTION, clipper); break;
    584545        }
    585         if(resultant.IsErrorBooleanProcess()) {
     546        if (!processor.execute(resultant)) {
    586547          if (fpMP->IsWarning())
    587548            G4cout <<
     
    589550 "\n  solid \"" << pSol->GetName() <<
    590551 "\" not defined due to error during Boolean processing."
     552 "\n  It will be drawn in red."
    591553                   << G4endl;
    592           // Nevertheless, keep resultant.
     554          // Nevertheless, keep resultant, but draw it in red
     555          resultantVisAttribs.SetColour(G4Colour::Red());
    593556        }
    594557      }
     
    597560        G4Polyhedron sectioner = *pSectionPolyhedron;  // Local copy.
    598561        sectioner.Transform(theAT.inverse());
    599         resultant = resultant.intersect(sectioner);
    600         if(resultant.IsErrorBooleanProcess()) {
     562        HepPolyhedronProcessor processor;
     563        processor.push_back(HepPolyhedronProcessor::INTERSECTION, sectioner);
     564        if (!processor.execute(resultant)) {
    601565          if (fpMP->IsWarning())
    602566            G4cout <<
     
    604568 "\n  solid \"" << pSol->GetName() <<
    605569 "\" not defined due to error during Boolean processing."
     570 "\n  It will be drawn in red."
    606571                   << G4endl;
    607           // Nevertheless, keep resultant.
     572          // Nevertheless, keep resultant, but draw it in red
     573          resultantVisAttribs.SetColour(G4Colour::Red());
    608574        }
    609575      }
     
    612578        G4Polyhedron cutter = *pCutawayPolyhedron;  // Local copy.
    613579        cutter.Transform(theAT.inverse());
    614         resultant = resultant.subtract(cutter);
    615         if(resultant.IsErrorBooleanProcess()) {
     580        HepPolyhedronProcessor processor;
     581        processor.push_back(HepPolyhedronProcessor::SUBTRACTION, cutter);
     582        if (!processor.execute(resultant)) {
    616583          if (fpMP->IsWarning())
    617584            G4cout <<
     
    619586 "\n  solid \"" << pSol->GetName() <<
    620587 "\" not defined due to error during Boolean processing."
     588 "\n  It will be drawn in red."
    621589                   << G4endl;
    622           // Nevertheless, keep resultant.
     590          // Nevertheless, keep resultant, but draw it in red
     591          resultantVisAttribs.SetColour(G4Colour::Red());
    623592        }
    624593      }
    625594
    626595      // Finally, force polyhedron drawing...
    627       resultant.SetVisAttributes(pVisAttribs);
     596      resultant.SetVisAttributes(resultantVisAttribs);
    628597      sceneHandler.BeginPrimitives(theAT);
    629598      sceneHandler.AddPrimitive(resultant);
     
    760729    if (i != fFullPVPath.size() - 1) oss << '/';
    761730  }
     731
     732  if (!fpCurrentLV) {
     733     G4Exception
     734        ("G4PhysicalVolumeModel::CreateCurrentAttValues",
     735         "",
     736         JustWarning,
     737         "Current logical volume not defined.");
     738     return values;
     739  }
     740
    762741  values->push_back(G4AttValue("PVPath", oss.str(),""));
    763742  if (fpCurrentLV) {
     
    787766  return values;
    788767}
     768
     769G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
     770  (const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& right) const
     771{
     772  if (fpPV < right.fpPV) return true;
     773  if (fpPV == right.fpPV) {
     774    if (fCopyNo < right.fCopyNo) return true;
     775    if (fCopyNo == right.fCopyNo)
     776      return fNonCulledDepth < right.fNonCulledDepth;
     777  }
     778  return false;
     779}
     780
     781std::ostream& operator<<
     782  (std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID node)
     783{
     784  G4VPhysicalVolume* pPV = node.GetPhysicalVolume();
     785  if (pPV) {
     786    os << pPV->GetName()
     787       << ':' << node.GetCopyNo()
     788       << '[' << node.GetNonCulledDepth() << ']'
     789       << ':' << node.GetTransform();
     790  } else {
     791    os << "Null node";
     792  }
     793  return os;
     794}
     795
     796G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::G4PhysicalVolumeModelTouchable
     797(const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
     798  fFullPVPath(fullPVPath) {}
     799
     800const G4ThreeVector& G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetTranslation(G4int depth) const
     801{
     802  size_t i = fFullPVPath.size() - depth - 1;
     803  if (i >= fFullPVPath.size()) {
     804    G4Exception("G4PhysicalVolumeModelTouchable::GetTranslation",
     805                "Index out of range",
     806                FatalErrorInArgument,
     807                "Asking for non-existent depth");
     808  }
     809  static G4ThreeVector tempTranslation;
     810  tempTranslation = fFullPVPath[i].GetTransform().getTranslation();
     811  return tempTranslation;
     812}
     813
     814const G4RotationMatrix* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetRotation(G4int depth) const
     815{
     816  size_t i = fFullPVPath.size() - depth - 1;
     817  if (i >= fFullPVPath.size()) {
     818    G4Exception("G4PhysicalVolumeModelTouchable::GetRotation",
     819                "Index out of range",
     820                FatalErrorInArgument,
     821                "Asking for non-existent depth");
     822  }
     823  static G4RotationMatrix tempRotation;
     824  tempRotation = fFullPVPath[i].GetTransform().getRotation();
     825  return &tempRotation;
     826}
     827
     828G4VPhysicalVolume* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetVolume(G4int depth) const
     829{
     830  size_t i = fFullPVPath.size() - depth - 1;
     831  if (i >= fFullPVPath.size()) {
     832    G4Exception("G4PhysicalVolumeModelTouchable::GetVolume",
     833                "Index out of range",
     834                FatalErrorInArgument,
     835                "Asking for non-existent depth");
     836  }
     837  return fFullPVPath[i].GetPhysicalVolume();
     838}
     839
     840G4VSolid* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetSolid(G4int depth) const
     841{
     842  size_t i = fFullPVPath.size() - depth - 1;
     843  if (i >= fFullPVPath.size()) {
     844    G4Exception("G4PhysicalVolumeModelTouchable::GetSolid",
     845                "Index out of range",
     846                FatalErrorInArgument,
     847                "Asking for non-existent depth");
     848  }
     849  return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
     850}
     851
     852G4int G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetReplicaNumber(G4int depth) const
     853{
     854  size_t i = fFullPVPath.size() - depth - 1;
     855  if (i >= fFullPVPath.size()) {
     856    G4Exception("G4PhysicalVolumeModelTouchable::GetReplicaNumber",
     857                "Index out of range",
     858                FatalErrorInArgument,
     859                "Asking for non-existent depth");
     860  }
     861  return fFullPVPath[i].GetCopyNo();
     862}
Note: See TracChangeset for help on using the changeset viewer.