Changeset 1258 for trunk/source/visualization/modeling/src
- Timestamp:
- May 20, 2010, 11:49:26 AM (14 years ago)
- Location:
- trunk/source/visualization/modeling/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/modeling/src/G4ModelingParameters.cc
r954 r1258 25 25 // 26 26 // 27 // $Id: G4ModelingParameters.cc,v 1.1 5 2006/11/14 14:42:08allison Exp $27 // $Id: G4ModelingParameters.cc,v 1.16 2010/05/11 11:13:35 allison Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 37 37 #include "G4VisAttributes.hh" 38 38 #include "G4ExceptionSeverity.hh" 39 #include "G4 Polyhedron.hh"39 #include "G4VSolid.hh" 40 40 41 41 G4ModelingParameters::G4ModelingParameters (): … … 50 50 fExplodeFactor (1.), 51 51 fNoOfSides (24), 52 fpSection Polyhedron(0),53 fpCutaway Polyhedron(0),52 fpSectionSolid (0), 53 fpCutawaySolid (0), 54 54 fpEvent (0) 55 55 {} … … 75 75 fExplodeFactor (1.), 76 76 fNoOfSides (noOfSides), 77 fpSection Polyhedron(0),78 fpCutaway Polyhedron(0),79 fpEvent 77 fpSectionSolid (0), 78 fpCutawaySolid (0), 79 fpEvent (0) 80 80 {} 81 81 82 82 G4ModelingParameters::~G4ModelingParameters () 83 83 { 84 delete fpSection Polyhedron;85 delete fpCutaway Polyhedron;84 delete fpSectionSolid; 85 delete fpCutawaySolid; 86 86 } 87 87 … … 114 114 fNoOfSides = nSides; 115 115 return fNoOfSides; 116 } 117 118 void G4ModelingParameters::SetSectionSolid 119 (G4VSolid* pSectionSolid) { 120 delete fpSectionSolid; 121 fpSectionSolid = pSectionSolid; 122 } 123 124 void G4ModelingParameters::SetCutawaySolid 125 (G4VSolid* pCutawaySolid) { 126 delete fpCutawaySolid; 127 fpCutawaySolid = pCutawaySolid; 116 128 } 117 129 … … 166 178 << mp.fNoOfSides; 167 179 168 os << "\n Section (DCUT) polyhedronpointer: ";169 if (!mp.fpSection Polyhedron) os << "non-";180 os << "\n Section (DCUT) shape (G4VSolid) pointer: "; 181 if (!mp.fpSectionSolid) os << "non-"; 170 182 os << "null"; 171 183 172 os << "\n Cutaway (DCUT) polyhedronpointer: ";173 if (!mp.fpCutaway Polyhedron) os << "non-";184 os << "\n Cutaway (DCUT) shape (G4VSolid) pointer: "; 185 if (!mp.fpCutawaySolid) os << "non-"; 174 186 os << "null"; 175 187 … … 192 204 (fExplodeCentre != mp.fExplodeCentre) || 193 205 (fNoOfSides != mp.fNoOfSides) || 194 (fpSection Polyhedron != mp.fpSectionPolyhedron) ||195 (fpCutaway Polyhedron != mp.fpCutawayPolyhedron) ||206 (fpSectionSolid != mp.fpSectionSolid) || 207 (fpCutawaySolid != mp.fpCutawaySolid) || 196 208 (fpEvent != mp.fpEvent) 197 209 ) -
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... -
trunk/source/visualization/modeling/src/G4TrajectoriesModel.cc
r954 r1258 25 25 // 26 26 // 27 // $Id: G4TrajectoriesModel.cc,v 1.2 4 2006/11/14 14:42:08allison Exp $27 // $Id: G4TrajectoriesModel.cc,v 1.25 2010/05/11 11:21:52 allison Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 41 41 #include "G4AttCheck.hh" 42 42 43 G4TrajectoriesModel::G4TrajectoriesModel (): 44 fDrawingModeSet(false), 45 fDrawingMode(0), 46 fpCurrentTrajectory(0) 47 { 48 fGlobalTag = "G4TrajectoriesModel for all trajectories."; 49 fGlobalDescription = fGlobalTag; 50 } 51 43 52 G4TrajectoriesModel::G4TrajectoriesModel (G4int drawingMode): 44 fDrawingMode(drawingMode), fpCurrentTrajectory(0) { 53 fDrawingModeSet(true), 54 fDrawingMode(drawingMode), 55 fpCurrentTrajectory(0) { 45 56 fGlobalTag = "G4TrajectoriesModel for all trajectories."; 46 57 fGlobalDescription = fGlobalTag; … … 66 77 } 67 78 } 79 } 80 } 81 82 G4bool G4TrajectoriesModel::IsDrawingModeSet() const 83 { 84 return fDrawingModeSet; 85 } 86 87 G4int G4TrajectoriesModel::GetDrawingMode() const 88 { 89 if (fDrawingModeSet) return fDrawingMode; 90 else { 91 G4Exception 92 ("G4TrajectoriesModel::GetDrawingMode", 93 "", 94 FatalException, 95 "Illegal attempt to obtain i_mode." 96 "\n i_mode is an old trajectories parameter that is DEPRECATED" 97 "\n and will be removed at the next major release." 98 ); 99 return 0; 100 } 101 } 102 103 void G4TrajectoriesModel::SetDrawingMode(G4int drawingMode) 104 { 105 if (fDrawingModeSet) fDrawingMode = drawingMode; 106 else { 107 G4Exception 108 ("G4TrajectoriesModel::SetDrawingMode", 109 "", 110 FatalException, 111 "Illegal attempt to set i_mode." 112 "\n i_mode is an old trajectories parameter that is DEPRECATED" 113 "\n and will be removed at the next major release." 114 ); 68 115 } 69 116 } -
trunk/source/visualization/modeling/src/G4TrajectoryDrawByAttribute.cc
r954 r1258 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4TrajectoryDrawByAttribute.cc,v 1. 3 2006/09/14 15:41:42 tinslayExp $26 // $Id: G4TrajectoryDrawByAttribute.cc,v 1.4 2010/05/11 11:31:31 allison Exp $ 27 27 // GEANT4 tag $Name: $ 28 28 // … … 62 62 63 63 void 64 G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object, const G4int&, 64 G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object, 65 const G4int& i_mode, 66 const G4bool& visible) const 67 { 68 Draw(object, visible); 69 } 70 71 void 72 G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object, 65 73 const G4bool& visible) const 66 74 { -
trunk/source/visualization/modeling/src/G4TrajectoryDrawByCharge.cc
r954 r1258 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4TrajectoryDrawByCharge.cc,v 1. 8 2006/06/29 21:33:06 gunterExp $26 // $Id: G4TrajectoryDrawByCharge.cc,v 1.9 2010/05/11 11:31:31 allison Exp $ 27 27 // GEANT4 tag $Name: $ 28 28 // … … 57 57 58 58 void 59 G4TrajectoryDrawByCharge::Draw(const G4VTrajectory& traj, const G4int& i_mode, const G4bool& visible) const 59 G4TrajectoryDrawByCharge::Draw(const G4VTrajectory& object, 60 const G4int& i_mode, 61 const G4bool& visible) const 62 { 63 Draw(object, visible); 64 } 65 66 void 67 G4TrajectoryDrawByCharge::Draw(const G4VTrajectory& traj, const G4bool& visible) const 60 68 { 61 69 G4Colour colour; … … 79 87 } 80 88 81 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext , i_mode);89 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext); 82 90 } 83 91 -
trunk/source/visualization/modeling/src/G4TrajectoryDrawByOriginVolume.cc
r954 r1258 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4TrajectoryDrawByOriginVolume.cc,v 1. 4 2006/06/29 21:33:08 gunterExp $26 // $Id: G4TrajectoryDrawByOriginVolume.cc,v 1.5 2010/05/11 11:31:31 allison Exp $ 27 27 // GEANT4 tag $Name: $ 28 28 // … … 45 45 46 46 void 47 G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& traj, const G4int& i_mode, const G4bool& visible) const 47 G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& object, 48 const G4int& i_mode, 49 const G4bool& visible) const 50 { 51 Draw(object, visible); 52 } 53 54 void 55 G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& traj, const G4bool& visible) const 48 56 { 49 57 G4Colour colour(fDefault); … … 79 87 } 80 88 81 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext , i_mode);89 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext); 82 90 } 83 91 -
trunk/source/visualization/modeling/src/G4TrajectoryDrawByParticleID.cc
r954 r1258 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4TrajectoryDrawByParticleID.cc,v 1. 8 2006/06/29 21:33:10 gunterExp $26 // $Id: G4TrajectoryDrawByParticleID.cc,v 1.9 2010/05/11 11:31:31 allison Exp $ 27 27 // GEANT4 tag $Name: $ 28 28 // … … 43 43 44 44 void 45 G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& traj, const G4int& i_mode, const G4bool& visible) const 45 G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& object, 46 const G4int& i_mode, 47 const G4bool& visible) const 48 { 49 Draw(object, visible); 50 } 51 52 void 53 G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& traj, const G4bool& visible) const 46 54 { 47 55 G4Colour colour(fDefault); … … 62 70 } 63 71 64 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext , i_mode);72 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext); 65 73 } 66 74 -
trunk/source/visualization/modeling/src/G4TrajectoryDrawerUtils.cc
r1247 r1258 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4TrajectoryDrawerUtils.cc,v 1.1 3 2010/04/27 15:46:18 lgarnierExp $26 // $Id: G4TrajectoryDrawerUtils.cc,v 1.14 2010/05/11 11:58:18 allison Exp $ 27 27 // GEANT4 tag $Name: $ 28 28 // … … 40 40 #include "G4UIcommand.hh" 41 41 #include "G4AttValue.hh" 42 #include <sstream> 42 43 43 44 namespace G4TrajectoryDrawerUtils { … … 79 80 } 80 81 } 81 82 83 /*** 82 84 void DrawLineAndPoints(const G4VTrajectory& traj, const G4int& i_mode, const G4Colour& colour, const G4bool& visible) { 83 85 // If i_mode>=0, draws a trajectory as a polyline (default is blue for … … 87 89 // given by std::abs(i_mode)/1000. E.g: i_mode = 5000 gives easily 88 90 // visible markers. 91 92 static G4bool warnedAboutIMode = false; 93 std::ostringstream oss; 94 oss << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode 95 << "). Feature will be removed at a future major release."; 96 if (!warnedAboutIMode) { 97 G4Exception 98 ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, i_mode, colour, visible)", 99 "", 100 JustWarning, 101 oss.str().c_str()); 102 warnedAboutIMode = true; 103 } 89 104 90 105 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); … … 130 145 131 146 } 147 ***/ 132 148 133 149 static void GetTimes(const G4VTrajectory& traj, … … 146 162 147 163 // Pre- and Post-Point times from the trajectory point... 148 G4double trajectoryPointPreTime = - DBL_MAX;149 G4double trajectoryPointPostTime = DBL_MAX;164 G4double trajectoryPointPreTime = -std::numeric_limits<double>::max(); 165 G4double trajectoryPointPostTime = std::numeric_limits<double>::max(); 150 166 std::vector<G4AttValue>* trajectoryPointAttValues = 151 167 aTrajectoryPoint->CreateAttValues(); … … 356 372 void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context, const G4int& i_mode) 357 373 { 374 static G4bool warnedAboutIMode = false; 375 std::ostringstream oss; 376 oss << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode 377 << "). Feature will be removed at a future major release."; 378 if (!warnedAboutIMode) { 379 G4Exception 380 ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, context, i_mode)", 381 "", 382 JustWarning, 383 oss.str().c_str()); 384 warnedAboutIMode = true; 385 } 386 358 387 // Extra copy while i_mode is still around 359 388 G4VisTrajContext myContext(context); … … 370 399 myContext.SetAuxPtsSize(markerSize); 371 400 myContext.SetStepPtsSize(markerSize); 372 373 static G4bool warnedAboutIMode = false;374 375 if (!warnedAboutIMode) {376 G4cout<<"Trajectory drawing configuration will be based on imode value of "<<i_mode<<G4endl;377 warnedAboutIMode = true;378 }379 401 } 380 402 … … 421 443 } 422 444 } 445 446 void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context) 447 { 448 // Return if don't need to do anything 449 if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return; 450 451 // Get points to draw 452 G4Polyline trajectoryLine; 453 G4Polymarker stepPoints; 454 G4Polymarker auxiliaryPoints; 455 456 GetPoints(traj, trajectoryLine, auxiliaryPoints, stepPoints); 457 458 if (context.GetTimeSliceInterval()) { 459 460 // Get corresponding track time information, if any 461 std::vector<G4double> trajectoryLineTimes; 462 std::vector<G4double> stepPointTimes; 463 std::vector<G4double> auxiliaryPointTimes; 464 465 GetTimes(traj, trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes); 466 467 // Check validity 468 if (trajectoryLineTimes.size() != trajectoryLine.size() || 469 stepPointTimes.size() != stepPoints.size() || 470 auxiliaryPointTimes.size() != auxiliaryPoints.size()) { 471 472 // Revert to drawing without time information... 473 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints); 474 } else { 475 476 SliceLine(context.GetTimeSliceInterval(), 477 trajectoryLine, trajectoryLineTimes); 478 479 DrawWithTime(context, 480 trajectoryLine, auxiliaryPoints, stepPoints, 481 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes); 482 } 483 484 } else { 485 486 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints); 487 488 } 489 } 423 490 } -
trunk/source/visualization/modeling/src/G4TrajectoryGenericDrawer.cc
r954 r1258 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4TrajectoryGenericDrawer.cc,v 1. 2 2006/06/29 21:33:16 gunterExp $26 // $Id: G4TrajectoryGenericDrawer.cc,v 1.3 2010/05/11 11:31:31 allison Exp $ 27 27 // GEANT4 tag $Name: $ 28 28 // … … 57 57 58 58 void 59 G4TrajectoryGenericDrawer::Draw(const G4VTrajectory& traj, const G4bool& visible) const 60 { 61 G4VisTrajContext myContext(GetContext()); 62 myContext.SetVisible(visible); 63 64 if (GetVerbose()) { 65 G4cout<<"G4TrajectoryGenericDrawer named "<<Name(); 66 G4cout<<", drawing trajectory with configuration: "<<G4endl; 67 myContext.Print(G4cout); 68 } 69 70 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext); 71 } 72 73 void 59 74 G4TrajectoryGenericDrawer::Print(std::ostream& ostr) const 60 75 {
Note: See TracChangeset
for help on using the changeset viewer.