Ignore:
Timestamp:
May 20, 2010, 11:49:26 AM (14 years ago)
Author:
garnier
Message:

cvs update

Location:
trunk/source/visualization/modeling/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/modeling/src/G4ModelingParameters.cc

    r954 r1258  
    2525//
    2626//
    27 // $Id: G4ModelingParameters.cc,v 1.15 2006/11/14 14:42:08 allison Exp $
     27// $Id: G4ModelingParameters.cc,v 1.16 2010/05/11 11:13:35 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    3737#include "G4VisAttributes.hh"
    3838#include "G4ExceptionSeverity.hh"
    39 #include "G4Polyhedron.hh"
     39#include "G4VSolid.hh"
    4040
    4141G4ModelingParameters::G4ModelingParameters ():
     
    5050  fExplodeFactor         (1.),
    5151  fNoOfSides             (24),
    52   fpSectionPolyhedron    (0),
    53   fpCutawayPolyhedron    (0),
     52  fpSectionSolid         (0),
     53  fpCutawaySolid         (0),
    5454  fpEvent                (0)
    5555{}
     
    7575  fExplodeFactor  (1.),
    7676  fNoOfSides      (noOfSides),
    77   fpSectionPolyhedron (0),
    78   fpCutawayPolyhedron (0),
    79   fpEvent             (0)
     77  fpSectionSolid (0),
     78  fpCutawaySolid (0),
     79  fpEvent         (0)
    8080{}
    8181
    8282G4ModelingParameters::~G4ModelingParameters ()
    8383{
    84   delete fpSectionPolyhedron;
    85   delete fpCutawayPolyhedron;
     84  delete fpSectionSolid;
     85  delete fpCutawaySolid;
    8686}
    8787
     
    114114  fNoOfSides = nSides;
    115115  return fNoOfSides;
     116}
     117
     118void G4ModelingParameters::SetSectionSolid
     119(G4VSolid* pSectionSolid) {
     120  delete fpSectionSolid;
     121  fpSectionSolid = pSectionSolid;
     122}
     123
     124void G4ModelingParameters::SetCutawaySolid
     125(G4VSolid* pCutawaySolid) {
     126  delete fpCutawaySolid;
     127  fpCutawaySolid = pCutawaySolid;
    116128}
    117129
     
    166178     << mp.fNoOfSides;
    167179
    168   os << "\n  Section (DCUT) polyhedron pointer: ";
    169   if (!mp.fpSectionPolyhedron) os << "non-";
     180  os << "\n  Section (DCUT) shape (G4VSolid) pointer: ";
     181  if (!mp.fpSectionSolid) os << "non-";
    170182  os << "null";
    171183
    172   os << "\n  Cutaway (DCUT) polyhedron pointer: ";
    173   if (!mp.fpCutawayPolyhedron) os << "non-";
     184  os << "\n  Cutaway (DCUT) shape (G4VSolid) pointer: ";
     185  if (!mp.fpCutawaySolid) os << "non-";
    174186  os << "null";
    175187
     
    192204      (fExplodeCentre          != mp.fExplodeCentre)          ||
    193205      (fNoOfSides              != mp.fNoOfSides)              ||
    194       (fpSectionPolyhedron     != mp.fpSectionPolyhedron)     ||
    195       (fpCutawayPolyhedron     != mp.fpCutawayPolyhedron)     ||
     206      (fpSectionSolid          != mp.fpSectionSolid)     ||
     207      (fpCutawaySolid          != mp.fpCutawaySolid)     ||
    196208      (fpEvent                 != mp.fpEvent)
    197209      )
  • trunk/source/visualization/modeling/src/G4PhysicalVolumeModel.cc

    r1171 r1258  
    2525//
    2626//
    27 // $Id: G4PhysicalVolumeModel.cc,v 1.66 2009/10/23 08:08:19 allison Exp $
     27// $Id: G4PhysicalVolumeModel.cc,v 1.67 2010/05/11 11:16:51 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    4040#include "G4LogicalVolume.hh"
    4141#include "G4VSolid.hh"
     42#include "G4SubtractionSolid.hh"
     43#include "G4IntersectionSolid.hh"
    4244#include "G4Material.hh"
    4345#include "G4VisAttributes.hh"
     
    7375  fpCurrentTransform (0),
    7476  fCurtailDescent (false),
    75   fpClippingPolyhedron (0),
     77  fpClippingSolid (0),
    7678  fClippingMode   (subtraction)
    7779{
     
    8688G4PhysicalVolumeModel::~G4PhysicalVolumeModel ()
    8789{
    88   delete fpClippingPolyhedron;
     90  delete fpClippingSolid;
    8991}
    9092
     
    500502  sceneHandler.PreAddSolid (theAT, *pVisAttribs);
    501503
    502   const G4Polyhedron* pSectionPolyhedron = fpMP->GetSectionPolyhedron();
    503   const G4Polyhedron* pCutawayPolyhedron = fpMP->GetCutawayPolyhedron();
    504 
    505   if (!fpClippingPolyhedron && !pSectionPolyhedron && !pCutawayPolyhedron) {
     504  G4VSolid* pSectionSolid = fpMP->GetSectionSolid();
     505  G4VSolid* pCutawaySolid = fpMP->GetCutawaySolid();
     506
     507  if (!fpClippingSolid && !pSectionSolid && !pCutawaySolid) {
    506508
    507509    pSol -> DescribeYourselfTo (sceneHandler);  // Standard treatment.
     
    509511  } else {
    510512
    511     // Clipping, etc., performed by Boolean operations on polyhedron objects.
     513    // Clipping, etc., performed by Boolean operations.
    512514
    513515    // First, get polyhedron for current solid...
     
    517519    else
    518520      G4Polyhedron::SetNumberOfRotationSteps(fpMP->GetNoOfSides());
    519     G4Polyhedron* pOriginal = pSol->GetPolyhedron();
     521    const G4Polyhedron* pOriginal = pSol->GetPolyhedron();
    520522    G4Polyhedron::ResetNumberOfRotationSteps();
    521523
     
    532534    } else {
    533535
    534       G4Polyhedron resultant = *pOriginal;
     536      G4Polyhedron resultant(*pOriginal);
    535537      G4VisAttributes resultantVisAttribs(*pVisAttribs);
    536 
    537       if (fpClippingPolyhedron) {
    538         G4Polyhedron clipper = *fpClippingPolyhedron;  // Local copy.
    539         clipper.Transform(theAT.inverse());
    540         HepPolyhedronProcessor processor;
     538      G4VSolid* resultantSolid = 0;
     539
     540      if (fpClippingSolid) {
    541541        switch (fClippingMode) {
    542542        default:
    543         case subtraction: processor.push_back(HepPolyhedronProcessor::SUBTRACTION, clipper); break;
    544         case intersection: processor.push_back(HepPolyhedronProcessor::INTERSECTION, clipper); break;
     543        case subtraction:
     544          resultantSolid = new G4SubtractionSolid
     545            ("resultant_solid", pSol, fpClippingSolid, theAT.inverse());
     546          break;
     547        case intersection:
     548          resultantSolid = new G4IntersectionSolid
     549            ("resultant_solid", pSol, fpClippingSolid, theAT.inverse());
     550          break;
    545551        }
    546         if (!processor.execute(resultant)) {
    547           if (fpMP->IsWarning())
    548             G4cout <<
    549  "WARNING: G4PhysicalVolumeModel::DescribeSolid: clipped polyhedron for"
    550  "\n  solid \"" << pSol->GetName() <<
    551  "\" not defined due to error during Boolean processing."
    552  "\n  It will be drawn in red."
    553                    << G4endl;
    554           // Nevertheless, keep resultant, but draw it in red
    555           resultantVisAttribs.SetColour(G4Colour::Red());
    556         }
    557       }
    558 
    559       if (pSectionPolyhedron) {
    560         G4Polyhedron sectioner = *pSectionPolyhedron;  // Local copy.
    561         sectioner.Transform(theAT.inverse());
    562         HepPolyhedronProcessor processor;
    563         processor.push_back(HepPolyhedronProcessor::INTERSECTION, sectioner);
    564         if (!processor.execute(resultant)) {
    565           if (fpMP->IsWarning())
    566             G4cout <<
    567  "WARNING: G4PhysicalVolumeModel::DescribeSolid: sectioned polyhedron for"
    568  "\n  solid \"" << pSol->GetName() <<
    569  "\" not defined due to error during Boolean processing."
    570  "\n  It will be drawn in red."
    571                    << G4endl;
    572           // Nevertheless, keep resultant, but draw it in red
    573           resultantVisAttribs.SetColour(G4Colour::Red());
    574         }
    575       }
    576 
    577       if (pCutawayPolyhedron) {
    578         G4Polyhedron cutter = *pCutawayPolyhedron;  // Local copy.
    579         cutter.Transform(theAT.inverse());
    580         HepPolyhedronProcessor processor;
    581         processor.push_back(HepPolyhedronProcessor::SUBTRACTION, cutter);
    582         if (!processor.execute(resultant)) {
    583           if (fpMP->IsWarning())
    584             G4cout <<
    585  "WARNING: G4PhysicalVolumeModel::DescribeSolid: cutaway polyhedron for"
    586  "\n  solid \"" << pSol->GetName() <<
    587  "\" not defined due to error during Boolean processing."
    588  "\n  It will be drawn in red."
    589                    << G4endl;
    590           // Nevertheless, keep resultant, but draw it in red
    591           resultantVisAttribs.SetColour(G4Colour::Red());
    592         }
    593       }
     552      }
     553
     554      if (pSectionSolid) {
     555        resultantSolid = new G4IntersectionSolid
     556          ("sectioned_solid", pSol, pSectionSolid, theAT.inverse());
     557      }
     558
     559      if (pCutawaySolid) {
     560        resultantSolid = new G4SubtractionSolid
     561          ("cutaway_solid", pSol, pCutawaySolid, theAT.inverse());
     562      }
     563
     564      G4Polyhedron* tmpResultant = resultantSolid->GetPolyhedron();
     565      if (tmpResultant) resultant = *tmpResultant;
     566      else {
     567        if (fpMP->IsWarning())
     568          G4cout <<
     569            "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
     570            "\n  solid \"" << pSol->GetName() <<
     571            "\" not defined due to error during Boolean processing."
     572            "\n  Original will be drawn in red."
     573                 << G4endl;
     574        resultantVisAttribs.SetColour(G4Colour::Red());
     575      }
     576
     577      delete resultantSolid;
    594578
    595579      // Finally, force polyhedron drawing...
  • trunk/source/visualization/modeling/src/G4TrajectoriesModel.cc

    r954 r1258  
    2525//
    2626//
    27 // $Id: G4TrajectoriesModel.cc,v 1.24 2006/11/14 14:42:08 allison Exp $
     27// $Id: G4TrajectoriesModel.cc,v 1.25 2010/05/11 11:21:52 allison Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    4141#include "G4AttCheck.hh"
    4242
     43G4TrajectoriesModel::G4TrajectoriesModel ():
     44  fDrawingModeSet(false),
     45  fDrawingMode(0),
     46  fpCurrentTrajectory(0)
     47{
     48  fGlobalTag = "G4TrajectoriesModel for all trajectories.";
     49  fGlobalDescription = fGlobalTag;
     50}
     51
    4352G4TrajectoriesModel::G4TrajectoriesModel (G4int drawingMode):
    44 fDrawingMode(drawingMode), fpCurrentTrajectory(0) {
     53  fDrawingModeSet(true),
     54  fDrawingMode(drawingMode),
     55  fpCurrentTrajectory(0) {
    4556  fGlobalTag = "G4TrajectoriesModel for all trajectories.";
    4657  fGlobalDescription = fGlobalTag;
     
    6677      }
    6778    }
     79  }
     80}
     81
     82G4bool G4TrajectoriesModel::IsDrawingModeSet() const
     83{
     84  return fDrawingModeSet;
     85}
     86
     87G4int G4TrajectoriesModel::GetDrawingMode() const
     88{
     89  if (fDrawingModeSet) return fDrawingMode;
     90  else {
     91    G4Exception
     92      ("G4TrajectoriesModel::GetDrawingMode",
     93       "",
     94       FatalException,
     95       "Illegal attempt to obtain i_mode."
     96       "\n  i_mode is an old trajectories parameter that is DEPRECATED"
     97       "\n  and will be removed at the next major release."
     98       );
     99    return 0;
     100  }
     101}
     102
     103void G4TrajectoriesModel::SetDrawingMode(G4int drawingMode)
     104{
     105  if (fDrawingModeSet) fDrawingMode = drawingMode;
     106  else {
     107    G4Exception
     108      ("G4TrajectoriesModel::SetDrawingMode",
     109       "",
     110       FatalException,
     111       "Illegal attempt to set i_mode."
     112       "\n  i_mode is an old trajectories parameter that is DEPRECATED"
     113       "\n  and will be removed at the next major release."
     114       );
    68115  }
    69116}
  • trunk/source/visualization/modeling/src/G4TrajectoryDrawByAttribute.cc

    r954 r1258  
    2424// ********************************************************************
    2525//
    26 // $Id: G4TrajectoryDrawByAttribute.cc,v 1.3 2006/09/14 15:41:42 tinslay Exp $
     26// $Id: G4TrajectoryDrawByAttribute.cc,v 1.4 2010/05/11 11:31:31 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    6262
    6363void
    64 G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object, const G4int&,
     64G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object,
     65                                  const G4int& i_mode,
     66                                  const G4bool& visible) const
     67{
     68  Draw(object, visible);
     69}
     70
     71void
     72G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object,
    6573                                  const G4bool& visible) const
    6674{
  • trunk/source/visualization/modeling/src/G4TrajectoryDrawByCharge.cc

    r954 r1258  
    2424// ********************************************************************
    2525//
    26 // $Id: G4TrajectoryDrawByCharge.cc,v 1.8 2006/06/29 21:33:06 gunter Exp $
     26// $Id: G4TrajectoryDrawByCharge.cc,v 1.9 2010/05/11 11:31:31 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    5757
    5858void
    59 G4TrajectoryDrawByCharge::Draw(const G4VTrajectory& traj, const G4int& i_mode, const G4bool& visible) const
     59G4TrajectoryDrawByCharge::Draw(const G4VTrajectory& object,
     60                               const G4int& i_mode,
     61                               const G4bool& visible) const
     62{
     63  Draw(object, visible);
     64}
     65
     66void
     67G4TrajectoryDrawByCharge::Draw(const G4VTrajectory& traj, const G4bool& visible) const
    6068{
    6169  G4Colour colour;
     
    7987  }
    8088
    81   G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext, i_mode);
     89  G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext);
    8290}
    8391
  • trunk/source/visualization/modeling/src/G4TrajectoryDrawByOriginVolume.cc

    r954 r1258  
    2424// ********************************************************************
    2525//
    26 // $Id: G4TrajectoryDrawByOriginVolume.cc,v 1.4 2006/06/29 21:33:08 gunter Exp $
     26// $Id: G4TrajectoryDrawByOriginVolume.cc,v 1.5 2010/05/11 11:31:31 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    4545
    4646void
    47 G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& traj, const G4int& i_mode, const G4bool& visible) const
     47G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& object,
     48                                     const G4int& i_mode,
     49                                     const G4bool& visible) const
     50{
     51  Draw(object, visible);
     52}
     53
     54void
     55G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& traj, const G4bool& visible) const
    4856{
    4957  G4Colour colour(fDefault);
     
    7987  }
    8088
    81   G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext, i_mode);
     89  G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext);
    8290}
    8391
  • trunk/source/visualization/modeling/src/G4TrajectoryDrawByParticleID.cc

    r954 r1258  
    2424// ********************************************************************
    2525//
    26 // $Id: G4TrajectoryDrawByParticleID.cc,v 1.8 2006/06/29 21:33:10 gunter Exp $
     26// $Id: G4TrajectoryDrawByParticleID.cc,v 1.9 2010/05/11 11:31:31 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    4343
    4444void
    45 G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& traj, const G4int& i_mode, const G4bool& visible) const
     45G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& object,
     46                                   const G4int& i_mode,
     47                                   const G4bool& visible) const
     48{
     49  Draw(object, visible);
     50}
     51
     52void
     53G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& traj, const G4bool& visible) const
    4654{
    4755  G4Colour colour(fDefault);
     
    6270  }
    6371
    64   G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext, i_mode);
     72  G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext);
    6573}
    6674
  • trunk/source/visualization/modeling/src/G4TrajectoryDrawerUtils.cc

    r1247 r1258  
    2424// ********************************************************************
    2525//
    26 // $Id: G4TrajectoryDrawerUtils.cc,v 1.13 2010/04/27 15:46:18 lgarnier Exp $
     26// $Id: G4TrajectoryDrawerUtils.cc,v 1.14 2010/05/11 11:58:18 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    4040#include "G4UIcommand.hh"
    4141#include "G4AttValue.hh"
     42#include <sstream>
    4243
    4344namespace G4TrajectoryDrawerUtils {
     
    7980    }
    8081  }
    81  
     82
     83  /***
    8284  void DrawLineAndPoints(const G4VTrajectory& traj, const G4int& i_mode, const G4Colour& colour, const G4bool& visible) {
    8385    // If i_mode>=0, draws a trajectory as a polyline (default is blue for
     
    8789    // given by std::abs(i_mode)/1000.  E.g: i_mode = 5000 gives easily
    8890    // visible markers.
     91
     92    static G4bool warnedAboutIMode = false;
     93    std::ostringstream oss;
     94    oss << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode
     95        << ").  Feature will be removed at a future major release.";
     96    if (!warnedAboutIMode) {
     97      G4Exception
     98        ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, i_mode, colour, visible)",
     99         "",
     100         JustWarning,
     101         oss.str().c_str());
     102      warnedAboutIMode = true;
     103    }
    89104   
    90105    G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
     
    130145   
    131146  }
     147  ***/
    132148 
    133149  static void GetTimes(const G4VTrajectory& traj,
     
    146162
    147163      // Pre- and Post-Point times from the trajectory point...
    148       G4double trajectoryPointPreTime = -DBL_MAX;
    149       G4double trajectoryPointPostTime = DBL_MAX;
     164      G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
     165      G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
    150166      std::vector<G4AttValue>* trajectoryPointAttValues =
    151167        aTrajectoryPoint->CreateAttValues();
     
    356372  void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context, const G4int& i_mode)
    357373  {
     374    static G4bool warnedAboutIMode = false;
     375    std::ostringstream oss;
     376    oss << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode
     377        << ").  Feature will be removed at a future major release.";
     378    if (!warnedAboutIMode) {
     379      G4Exception
     380        ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, context, i_mode)",
     381         "",
     382         JustWarning,
     383         oss.str().c_str());
     384      warnedAboutIMode = true;
     385    }
     386
    358387    // Extra copy while i_mode is still around
    359388    G4VisTrajContext myContext(context);
     
    370399      myContext.SetAuxPtsSize(markerSize);
    371400      myContext.SetStepPtsSize(markerSize);
    372 
    373       static G4bool warnedAboutIMode = false;
    374 
    375       if (!warnedAboutIMode) {
    376         G4cout<<"Trajectory drawing configuration will be based on imode value of "<<i_mode<<G4endl;
    377         warnedAboutIMode = true;
    378       }
    379401    }
    380402
     
    421443    }
    422444  }
     445
     446  void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context)
     447  {
     448    // Return if don't need to do anything
     449    if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return;
     450   
     451    // Get points to draw
     452    G4Polyline trajectoryLine;
     453    G4Polymarker stepPoints;
     454    G4Polymarker auxiliaryPoints;
     455   
     456    GetPoints(traj, trajectoryLine, auxiliaryPoints, stepPoints);
     457   
     458    if (context.GetTimeSliceInterval()) {
     459
     460      // Get corresponding track time information, if any
     461      std::vector<G4double> trajectoryLineTimes;
     462      std::vector<G4double> stepPointTimes;
     463      std::vector<G4double> auxiliaryPointTimes;
     464 
     465      GetTimes(traj, trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
     466
     467      // Check validity
     468      if (trajectoryLineTimes.size() != trajectoryLine.size() ||
     469          stepPointTimes.size() != stepPoints.size() ||
     470          auxiliaryPointTimes.size() != auxiliaryPoints.size()) {
     471
     472        // Revert to drawing without time information...
     473        DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
     474      } else {
     475
     476        SliceLine(context.GetTimeSliceInterval(),
     477                  trajectoryLine, trajectoryLineTimes);
     478
     479        DrawWithTime(context,
     480                     trajectoryLine, auxiliaryPoints, stepPoints,
     481                     trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
     482      }
     483
     484    } else {
     485
     486      DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
     487
     488    }
     489  }
    423490}
  • trunk/source/visualization/modeling/src/G4TrajectoryGenericDrawer.cc

    r954 r1258  
    2424// ********************************************************************
    2525//
    26 // $Id: G4TrajectoryGenericDrawer.cc,v 1.2 2006/06/29 21:33:16 gunter Exp $
     26// $Id: G4TrajectoryGenericDrawer.cc,v 1.3 2010/05/11 11:31:31 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    5757
    5858void
     59G4TrajectoryGenericDrawer::Draw(const G4VTrajectory& traj, const G4bool& visible) const
     60{
     61  G4VisTrajContext myContext(GetContext());
     62  myContext.SetVisible(visible);
     63
     64  if (GetVerbose()) {
     65    G4cout<<"G4TrajectoryGenericDrawer named "<<Name();
     66    G4cout<<", drawing trajectory with configuration: "<<G4endl;
     67    myContext.Print(G4cout);
     68  }
     69 
     70  G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext);
     71}
     72
     73void
    5974G4TrajectoryGenericDrawer::Print(std::ostream& ostr) const
    6075{
Note: See TracChangeset for help on using the changeset viewer.