|
|
|||
File indexing completed on 2026-09-09 08:29:47
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 StandaloneVisAction.cc 0027 /// \brief Implementation of the StandaloneVisAction class 0028 0029 #include "StandaloneVisAction.hh" 0030 0031 #include "G4Box.hh" 0032 #include "G4Polyhedron.hh" 0033 #include "G4SubtractionSolid.hh" 0034 #include "G4SystemOfUnits.hh" 0035 #include "G4VVisManager.hh" 0036 #include "G4VisAttributes.hh" 0037 0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0039 0040 StandaloneVisAction::StandaloneVisAction() 0041 { 0042 auto pA = G4Box("boxA", 3 * cm, 3 * cm, 3 * cm).CreatePolyhedron(); 0043 auto pB = G4Box("boxB", 1 * cm, 1 * cm, 1 * cm).CreatePolyhedron(); 0044 pB->Transform(G4Translate3D(3 * cm, 3 * cm, 3 * cm)); 0045 fpSubtractedPolyhedron = new G4Polyhedron(pA->subtract(*pB)); 0046 G4VisAttributes subVisAtts(G4Colour(0, 1, 1)); 0047 fpSubtractedPolyhedron->SetVisAttributes(subVisAtts); 0048 delete pA; 0049 delete pB; 0050 } 0051 0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0053 0054 StandaloneVisAction::~StandaloneVisAction() 0055 { 0056 delete fpSubtractedPolyhedron; 0057 } 0058 0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0060 0061 void StandaloneVisAction::Draw() 0062 { 0063 G4VVisManager* pVisManager = G4VVisManager::GetConcreteInstance(); 0064 if (pVisManager) { 0065 // Simple box... 0066 pVisManager->Draw(G4Box("box", 2 * cm, 2 * cm, 2 * cm), G4VisAttributes(G4Colour(1, 1, 0))); 0067 0068 // Boolean solid... 0069 G4Box boxA("boxA", 3 * cm, 3 * cm, 3 * cm); 0070 G4Box boxB("boxB", 1 * cm, 1 * cm, 1 * cm); 0071 G4SubtractionSolid subtracted("subtracted_boxes", &boxA, &boxB, 0072 G4Translate3D(3 * cm, 3 * cm, 3 * cm)); 0073 pVisManager->Draw(subtracted, G4VisAttributes(G4Colour(0, 1, 1)), 0074 G4Translate3D(-6 * cm, -6 * cm, -6 * cm)); 0075 0076 // Same, but explicit polyhedron... 0077 // The heavy work is done in the constructor 0078 pVisManager->Draw(*fpSubtractedPolyhedron, G4Translate3D(6 * cm, 6 * cm, 6 * cm)); 0079 } 0080 } 0081 0082 //....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 |
|