Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (14 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
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/geometry/solids/Boolean/History

    r831 r1315  
    11
    2 $Id: History,v 1.62 2007/10/24 08:19:11 gcosmo Exp $
     2$Id: History,v 1.64 2010/05/11 15:04:01 gcosmo Exp $
    33-------------------------------------------------------------------
    44
     
    2020     * Reverse chronological order (last date on top), please *
    2121     ----------------------------------------------------------
     22
     23 May 11, 2010  J.Allison                  geom-bool-V09-03-00
     24  - Introduced recursive algorithm in CreatePolyhedron(): it uses
     25    HepPolyhedronProcessor from 'graphics_reps', which tries small shifts
     26    in an attempt to avoid numerical problems in the calculation of the
     27    polyhedron in BooleanProcessor. Recursion allows HepPolyhedronProcessor
     28    to try all permutations, also for Booleans of Booleans.
     29    Helps in reducing the number of cases of "Error in Boolean processor" for
     30    visualization, but still some stubborn cases are left.
    2231
    2332 Oct 24, 2007  V.Grichine                 geom-bool-V09-00-00
  • trunk/source/geometry/solids/Boolean/include/G4BooleanSolid.hh

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4BooleanSolid.hh,v 1.15 2006/10/19 15:34:49 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     27// $Id: G4BooleanSolid.hh,v 1.17 2010/05/11 15:03:45 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030//
     
    5050#include "G4Transform3D.hh"
    5151
    52 class G4VSolid;
     52class HepPolyhedronProcessor;
    5353
    5454class G4BooleanSolid : public G4VSolid
     
    111111    G4VSolid* fPtrSolidB;
    112112
     113    G4Polyhedron* StackPolyhedron(HepPolyhedronProcessor&,
     114                                  const G4VSolid*) const;
     115      // Stack polyhedra for processing. Return top polyhedron.
     116
    113117  private:
    114118
  • 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.