Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (15 years ago)
Author:
garnier
Message:

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

Location:
trunk/source/geometry/solids/Boolean/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/geometry/solids/Boolean/src/G4BooleanSolid.cc

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4BooleanSolid.cc,v 1.21 2006/10/19 15:34:49 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     27// $Id: G4BooleanSolid.cc,v 1.23 2010/05/11 15:03:45 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030// Implementation for the abstract base class for solids created by boolean
     
    4040#include "G4VSolid.hh"
    4141#include "G4Polyhedron.hh"
     42#include "HepPolyhedronProcessor.h"
    4243#include "Randomize.hh"
    4344
     
    231232  return fpPolyhedron;
    232233}
     234
     235//////////////////////////////////////////////////////////////////////////
     236//
     237// Stacks polyhedra for processing. Returns top polyhedron.
     238
     239G4Polyhedron*
     240G4BooleanSolid::StackPolyhedron(HepPolyhedronProcessor& processor,
     241                                const G4VSolid* solid) const
     242{
     243  HepPolyhedronProcessor::Operation operation;
     244  const G4String& type = solid->GetEntityType();
     245  if (type == "G4UnionSolid")
     246    { operation = HepPolyhedronProcessor::UNION; }
     247  else if (type == "G4IntersectionSolid")
     248    { operation = HepPolyhedronProcessor::INTERSECTION; }
     249  else if (type == "G4SubtractionSolid")
     250    { operation = HepPolyhedronProcessor::SUBTRACTION; }
     251  else
     252  {
     253    std::ostringstream oss;
     254    oss << "Solid - " << solid->GetName()
     255        << " - Unrecognised composite solid"
     256        << "\n  Returning NULL !";
     257    G4Exception("StackPolyhedron()", "InvalidSetup",
     258                JustWarning, oss.str().c_str());
     259    return 0;
     260  }
     261
     262  G4Polyhedron* top = 0;
     263  const G4VSolid* solidA = solid->GetConstituentSolid(0);
     264  const G4VSolid* solidB = solid->GetConstituentSolid(1);
     265
     266  if (solidA->GetConstituentSolid(0))
     267  {
     268    top = StackPolyhedron(processor, solidA);
     269  }
     270  else
     271  {
     272    top = solidA->GetPolyhedron();
     273  }
     274  G4Polyhedron* operand = solidB->GetPolyhedron();
     275  processor.push_back (operation, *operand);
     276
     277  return top;
     278}
  • trunk/source/geometry/solids/Boolean/src/G4IntersectionSolid.cc

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4IntersectionSolid.cc,v 1.30 2006/11/08 09:37:41 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     27// $Id: G4IntersectionSolid.cc,v 1.32 2010/05/11 15:03:45 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030// Implementation of methods for the class G4IntersectionSolid
     
    5050#include "G4VGraphicsScene.hh"
    5151#include "G4Polyhedron.hh"
     52#include "HepPolyhedronProcessor.h"
    5253#include "G4NURBS.hh"
    5354// #include "G4NURBSbox.hh"
     
    502503G4IntersectionSolid::CreatePolyhedron () const
    503504{
    504   G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
    505   G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
    506   if (pA && pB)
    507   {
    508     G4Polyhedron* resultant = new G4Polyhedron (pA->intersect(*pB));
    509     return resultant;
    510   }
    511   else
    512   {
    513     std::ostringstream oss;
    514     oss << "Solid - " << GetName()
    515         << " - one of the Boolean components has no" << G4endl
    516         << " corresponding polyhedron. Returning NULL !";
    517     G4Exception("G4IntersectionSolid::CreatePolyhedron()", "InvalidSetup",
    518                 JustWarning, oss.str().c_str());
    519     return 0;
    520   }
     505  HepPolyhedronProcessor processor;
     506  // Stack components and components of components recursively
     507  // See G4BooleanSolid::StackPolyhedron
     508  G4Polyhedron* top = StackPolyhedron(processor, this);
     509  G4Polyhedron* result = new G4Polyhedron(*top);
     510  if (processor.execute(*result)) { return result; }
     511  else { return 0; }
    521512}
    522513
  • trunk/source/geometry/solids/Boolean/src/G4SubtractionSolid.cc

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4SubtractionSolid.cc,v 1.31 2007/10/23 14:42:31 grichine Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     27// $Id: G4SubtractionSolid.cc,v 1.33 2010/05/11 15:03:45 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030// Implementation of methods for the class G4IntersectionSolid
     
    4848#include "G4VGraphicsScene.hh"
    4949#include "G4Polyhedron.hh"
     50#include "HepPolyhedronProcessor.h"
    5051#include "G4NURBS.hh"
    5152// #include "G4NURBSbox.hh"
     
    463464G4SubtractionSolid::CreatePolyhedron () const
    464465{
    465   G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
    466   G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
    467   if (pA && pB)
    468   {
    469     G4Polyhedron* resultant = new G4Polyhedron (pA->subtract(*pB));
    470     return resultant;
    471   }
    472   else
    473   {
    474     std::ostringstream oss;
    475     oss << "Solid - " << GetName()
    476         << " - one of the Boolean components has no" << G4endl
    477         << " corresponding polyhedron. Returning NULL !";
    478     G4Exception("G4SubtractionSolid::CreatePolyhedron()", "InvalidSetup",
    479                 JustWarning, oss.str().c_str());
    480     return 0;
    481   }
     466  HepPolyhedronProcessor processor;
     467  // Stack components and components of components recursively
     468  // See G4BooleanSolid::StackPolyhedron
     469  G4Polyhedron* top = StackPolyhedron(processor, this);
     470  G4Polyhedron* result = new G4Polyhedron(*top);
     471  if (processor.execute(*result)) { return result; }
     472  else { return 0; }
    482473}
    483474
  • trunk/source/geometry/solids/Boolean/src/G4UnionSolid.cc

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4UnionSolid.cc,v 1.35 2007/10/23 14:42:31 grichine Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     27// $Id: G4UnionSolid.cc,v 1.37 2010/05/11 15:03:45 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030// Implementation of methods for the class G4IntersectionSolid
     
    4949#include "G4VGraphicsScene.hh"
    5050#include "G4Polyhedron.hh"
     51#include "HepPolyhedronProcessor.h"
    5152#include "G4NURBS.hh"
    5253// #include "G4NURBSbox.hh"
     
    454455G4UnionSolid::CreatePolyhedron () const
    455456{
    456   G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
    457   G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
    458   if (pA && pB) {
    459     G4Polyhedron* resultant = new G4Polyhedron (pA->add(*pB));
    460     return resultant;
    461   } else {
    462     std::ostringstream oss;
    463     oss << GetName() <<
    464       ": one of the Boolean components has no corresponding polyhedron.";
    465     G4Exception("G4UnionSolid::CreatePolyhedron",
    466                 "", JustWarning, oss.str().c_str());
    467     return 0;
    468   }
     457  HepPolyhedronProcessor processor;
     458  // Stack components and components of components recursively
     459  // See G4BooleanSolid::StackPolyhedron
     460  G4Polyhedron* top = StackPolyhedron(processor, this);
     461  G4Polyhedron* result = new G4Polyhedron(*top);
     462  if (processor.execute(*result)) { return result; }
     463  else { return 0; }
    469464}
    470465
Note: See TracChangeset for help on using the changeset viewer.