- Timestamp:
- May 20, 2010, 11:49:26 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/modeling/src/G4PhysicalVolumeModel.cc
r1171 r1258 25 25 // 26 26 // 27 // $Id: G4PhysicalVolumeModel.cc,v 1.6 6 2009/10/23 08:08:19allison Exp $27 // $Id: G4PhysicalVolumeModel.cc,v 1.67 2010/05/11 11:16:51 allison Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 40 40 #include "G4LogicalVolume.hh" 41 41 #include "G4VSolid.hh" 42 #include "G4SubtractionSolid.hh" 43 #include "G4IntersectionSolid.hh" 42 44 #include "G4Material.hh" 43 45 #include "G4VisAttributes.hh" … … 73 75 fpCurrentTransform (0), 74 76 fCurtailDescent (false), 75 fpClipping Polyhedron(0),77 fpClippingSolid (0), 76 78 fClippingMode (subtraction) 77 79 { … … 86 88 G4PhysicalVolumeModel::~G4PhysicalVolumeModel () 87 89 { 88 delete fpClipping Polyhedron;90 delete fpClippingSolid; 89 91 } 90 92 … … 500 502 sceneHandler.PreAddSolid (theAT, *pVisAttribs); 501 503 502 const G4Polyhedron* pSectionPolyhedron = fpMP->GetSectionPolyhedron();503 const G4Polyhedron* pCutawayPolyhedron = fpMP->GetCutawayPolyhedron();504 505 if (!fpClipping Polyhedron && !pSectionPolyhedron && !pCutawayPolyhedron) {504 G4VSolid* pSectionSolid = fpMP->GetSectionSolid(); 505 G4VSolid* pCutawaySolid = fpMP->GetCutawaySolid(); 506 507 if (!fpClippingSolid && !pSectionSolid && !pCutawaySolid) { 506 508 507 509 pSol -> DescribeYourselfTo (sceneHandler); // Standard treatment. … … 509 511 } else { 510 512 511 // Clipping, etc., performed by Boolean operations on polyhedron objects.513 // Clipping, etc., performed by Boolean operations. 512 514 513 515 // First, get polyhedron for current solid... … … 517 519 else 518 520 G4Polyhedron::SetNumberOfRotationSteps(fpMP->GetNoOfSides()); 519 G4Polyhedron* pOriginal = pSol->GetPolyhedron();521 const G4Polyhedron* pOriginal = pSol->GetPolyhedron(); 520 522 G4Polyhedron::ResetNumberOfRotationSteps(); 521 523 … … 532 534 } else { 533 535 534 G4Polyhedron resultant = *pOriginal;536 G4Polyhedron resultant(*pOriginal); 535 537 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) { 541 541 switch (fClippingMode) { 542 542 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; 545 551 } 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; 594 578 595 579 // Finally, force polyhedron drawing...
Note: See TracChangeset
for help on using the changeset viewer.