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

cvs update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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...
Note: See TracChangeset for help on using the changeset viewer.