Changeset 1315 for trunk/source/geometry/solids/Boolean
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- Location:
- trunk/source/geometry/solids/Boolean
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/geometry/solids/Boolean/History
r831 r1315 1 1 2 $Id: History,v 1.6 2 2007/10/24 08:19:11 gcosmo Exp $2 $Id: History,v 1.64 2010/05/11 15:04:01 gcosmo Exp $ 3 3 ------------------------------------------------------------------- 4 4 … … 20 20 * Reverse chronological order (last date on top), please * 21 21 ---------------------------------------------------------- 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. 22 31 23 32 Oct 24, 2007 V.Grichine geom-bool-V09-00-00 -
trunk/source/geometry/solids/Boolean/include/G4BooleanSolid.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4BooleanSolid.hh,v 1.1 5 2006/10/19 15:34:49gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$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 $ 29 29 // 30 30 // … … 50 50 #include "G4Transform3D.hh" 51 51 52 class G4VSolid;52 class HepPolyhedronProcessor; 53 53 54 54 class G4BooleanSolid : public G4VSolid … … 111 111 G4VSolid* fPtrSolidB; 112 112 113 G4Polyhedron* StackPolyhedron(HepPolyhedronProcessor&, 114 const G4VSolid*) const; 115 // Stack polyhedra for processing. Return top polyhedron. 116 113 117 private: 114 118 -
trunk/source/geometry/solids/Boolean/src/G4BooleanSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4BooleanSolid.cc,v 1.2 1 2006/10/19 15:34:49gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$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 $ 29 29 // 30 30 // Implementation for the abstract base class for solids created by boolean … … 40 40 #include "G4VSolid.hh" 41 41 #include "G4Polyhedron.hh" 42 #include "HepPolyhedronProcessor.h" 42 43 #include "Randomize.hh" 43 44 … … 231 232 return fpPolyhedron; 232 233 } 234 235 ////////////////////////////////////////////////////////////////////////// 236 // 237 // Stacks polyhedra for processing. Returns top polyhedron. 238 239 G4Polyhedron* 240 G4BooleanSolid::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 25 25 // 26 26 // 27 // $Id: G4IntersectionSolid.cc,v 1.3 0 2006/11/08 09:37:41gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$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 $ 29 29 // 30 30 // Implementation of methods for the class G4IntersectionSolid … … 50 50 #include "G4VGraphicsScene.hh" 51 51 #include "G4Polyhedron.hh" 52 #include "HepPolyhedronProcessor.h" 52 53 #include "G4NURBS.hh" 53 54 // #include "G4NURBSbox.hh" … … 502 503 G4IntersectionSolid::CreatePolyhedron () const 503 504 { 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; } 521 512 } 522 513 -
trunk/source/geometry/solids/Boolean/src/G4SubtractionSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4SubtractionSolid.cc,v 1.3 1 2007/10/23 14:42:31 grichineExp $28 // GEANT4 tag $Name: geant4-09-0 3$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 $ 29 29 // 30 30 // Implementation of methods for the class G4IntersectionSolid … … 48 48 #include "G4VGraphicsScene.hh" 49 49 #include "G4Polyhedron.hh" 50 #include "HepPolyhedronProcessor.h" 50 51 #include "G4NURBS.hh" 51 52 // #include "G4NURBSbox.hh" … … 463 464 G4SubtractionSolid::CreatePolyhedron () const 464 465 { 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; } 482 473 } 483 474 -
trunk/source/geometry/solids/Boolean/src/G4UnionSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4UnionSolid.cc,v 1.3 5 2007/10/23 14:42:31 grichineExp $28 // GEANT4 tag $Name: geant4-09-0 3$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 $ 29 29 // 30 30 // Implementation of methods for the class G4IntersectionSolid … … 49 49 #include "G4VGraphicsScene.hh" 50 50 #include "G4Polyhedron.hh" 51 #include "HepPolyhedronProcessor.h" 51 52 #include "G4NURBS.hh" 52 53 // #include "G4NURBSbox.hh" … … 454 455 G4UnionSolid::CreatePolyhedron () const 455 456 { 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; } 469 464 } 470 465
Note: See TracChangeset
for help on using the changeset viewer.