![]() |
|
|||
File indexing completed on 2025-02-23 09:22:48
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file visualization/standalone/src/StandaloneVisAction.cc 0027 /// \brief Implementation of the StandaloneVisAction class 0028 // 0029 // 0030 0031 #include "StandaloneVisAction.hh" 0032 0033 #include "G4Box.hh" 0034 #include "G4Polyhedron.hh" 0035 #include "G4SubtractionSolid.hh" 0036 #include "G4SystemOfUnits.hh" 0037 #include "G4VVisManager.hh" 0038 #include "G4VisAttributes.hh" 0039 0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0041 0042 StandaloneVisAction::StandaloneVisAction() 0043 { 0044 auto pA = G4Box("boxA", 3 * cm, 3 * cm, 3 * cm).CreatePolyhedron(); 0045 auto pB = G4Box("boxB", 1 * cm, 1 * cm, 1 * cm).CreatePolyhedron(); 0046 pB->Transform(G4Translate3D(3 * cm, 3 * cm, 3 * cm)); 0047 fpSubtractedPolyhedron = new G4Polyhedron(pA->subtract(*pB)); 0048 G4VisAttributes subVisAtts(G4Colour(0, 1, 1)); 0049 fpSubtractedPolyhedron->SetVisAttributes(subVisAtts); 0050 delete pA; 0051 delete pB; 0052 } 0053 0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0055 0056 StandaloneVisAction::~StandaloneVisAction() 0057 { 0058 delete fpSubtractedPolyhedron; 0059 } 0060 0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0062 0063 void StandaloneVisAction::Draw() 0064 { 0065 G4VVisManager* pVisManager = G4VVisManager::GetConcreteInstance(); 0066 if (pVisManager) { 0067 // Simple box... 0068 pVisManager->Draw(G4Box("box", 2 * cm, 2 * cm, 2 * cm), G4VisAttributes(G4Colour(1, 1, 0))); 0069 0070 // Boolean solid... 0071 G4Box boxA("boxA", 3 * cm, 3 * cm, 3 * cm); 0072 G4Box boxB("boxB", 1 * cm, 1 * cm, 1 * cm); 0073 G4SubtractionSolid subtracted("subtracted_boxes", &boxA, &boxB, 0074 G4Translate3D(3 * cm, 3 * cm, 3 * cm)); 0075 pVisManager->Draw(subtracted, G4VisAttributes(G4Colour(0, 1, 1)), 0076 G4Translate3D(-6 * cm, -6 * cm, -6 * cm)); 0077 0078 // Same, but explicit polyhedron... 0079 // The heavy work is done in the constructor 0080 pVisManager->Draw(*fpSubtractedPolyhedron, G4Translate3D(6 * cm, 6 * cm, 6 * cm)); 0081 } 0082 } 0083 0084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |