Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -40,10 +40,10 @@
#include <vtkClipClosedSurface.h>
G4VtkClipClosedSurfacePipeline::G4VtkClipClosedSurfacePipeline(
G4String nameIn, const G4VtkVisContext& vc, vtkSmartPointer<vtkPolyDataAlgorithm> filter,
G4String nameIn, const G4VtkVisContext& vcIn, vtkSmartPointer<vtkPolyDataAlgorithm> filter,
G4bool useVcColour)
: G4VVtkPipeline(nameIn, G4String("G4VtkClipClosedSurfacePipeline"), vc, true,
vc.fViewer->renderer)
: G4VVtkPipeline(nameIn, G4String("G4VtkClipClosedSurfacePipeline"), vcIn, true,
vcIn.fViewer->renderer)
{
// create implicit function for clipping
plane = vtkSmartPointer<vtkPlane>::New();
@@ -38,10 +38,10 @@
#include "vtkSmartPointer.h"
#include <vtkClipClosedSurface.h>
G4VtkClipOpenPipeline::G4VtkClipOpenPipeline(G4String nameIn, const G4VtkVisContext& vc,
G4VtkClipOpenPipeline::G4VtkClipOpenPipeline(G4String nameIn, const G4VtkVisContext& vcIn,
vtkSmartPointer<vtkPolyDataAlgorithm> filter,
G4bool useVcColour)
: G4VVtkPipeline(nameIn, G4String("G4VtkClipOpenPipeline"), vc, true, vc.fViewer->renderer)
: G4VVtkPipeline(nameIn, G4String("G4VtkClipOpenPipeline"), vcIn, true, vcIn.fViewer->renderer)
{
// create implicit function for clipping
plane = vtkSmartPointer<vtkPlane>::New();
@@ -79,8 +79,10 @@ G4VtkClipOpenPipeline::G4VtkClipOpenPipeline(G4String nameIn, const G4VtkVisCont
// set actor properties from vis context
if (vc.fDrawingStyle == G4ViewParameters::hsr) {
actor->GetProperty()->SetRepresentationToSurface();
}
else if (vc.fDrawingStyle == G4ViewParameters::hlr) {
actor->GetProperty()->SetRepresentationToSurface();
}
else if (vc.fDrawingStyle == G4ViewParameters::wireframe) {
actor->GetProperty()->SetRepresentationToWireframe();
@@ -96,7 +98,7 @@ G4VtkClipOpenPipeline::G4VtkClipOpenPipeline(G4String nameIn, const G4VtkVisCont
vc.fViewer->renderer->AddActor(actor);
}
void G4VtkClipOpenPipeline::SetPlane(G4Plane3D& planeIn)
void G4VtkClipOpenPipeline::SetPlane(const G4Plane3D& planeIn)
{
auto normal = planeIn.normal();
auto point = planeIn.point();
@@ -1,106 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
#include "G4VtkClipperClosedPipeline.hh"
#include "vtkActor.h"
#include "vtkAppendPolyData.h"
#include "vtkClipPolyData.h"
#include "vtkFeatureEdges.h"
#include "vtkPlane.h"
#include "vtkPolyDataAlgorithm.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataNormals.h"
#include "vtkSmartPointer.h"
#include "vtkStripper.h"
#include "vtkTriangleFilter.h"
G4VtkClipperClosedPipeline::G4VtkClipperClosedPipeline(
vtkSmartPointer<vtkPolyDataAlgorithm> filterIn)
{
finalFilter = filterIn;
// create implicit function for clipping
plane = vtkSmartPointer<vtkPlane>::New();
plane->SetOrigin(0, 0, 0);
plane->SetNormal(1, 0, 0);
// clipper
clipper = vtkSmartPointer<vtkClipPolyData>::New();
clipper->SetClipFunction(plane);
clipper->SetInputConnection(finalFilter->GetOutputPort());
// calculate normals with a feature angle of 45 degrees
auto filterNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
filterNormals->SetFeatureAngle(45);
filterNormals->SetInputConnection(clipper->GetOutputPort());
// boundary edges
auto boundaryEdges = vtkSmartPointer<vtkFeatureEdges>::New();
boundaryEdges->SetInputConnection(clipper->GetOutputPort());
boundaryEdges->BoundaryEdgesOn();
boundaryEdges->FeatureEdgesOff();
boundaryEdges->NonManifoldEdgesOff();
boundaryEdges->ManifoldEdgesOff();
// boundary strips
auto boundaryStrips = vtkSmartPointer<vtkStripper>::New();
boundaryStrips->SetInputConnection(boundaryEdges->GetOutputPort());
// boundary polygon
auto boundaryPoly = vtkSmartPointer<vtkPolyData>::New();
boundaryPoly->SetPoints(boundaryStrips->GetOutput()->GetPoints());
boundaryPoly->SetPolys(boundaryStrips->GetOutput()->GetLines());
// boundary triangle filter
auto boundaryTriangle = vtkSmartPointer<vtkTriangleFilter>::New();
boundaryTriangle->AddInputData(boundaryPoly);
// calculate normals with a feature angle of 45 degrees
auto boundaryNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
boundaryNormals->SetFeatureAngle(45);
boundaryNormals->SetInputConnection(boundaryTriangle->GetOutputPort());
// append filter
appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
appendFilter->AddInputConnection(boundaryNormals->GetOutputPort());
appendFilter->AddInputConnection(filterNormals->GetOutputPort());
// mapper
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(appendFilter->GetOutputPort());
mapper->SetColorModeToDirectScalars();
mapper->ScalarVisibilityOn();
// add to actor
actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->SetVisibility(1);
}
void G4VtkClipperClosedPipeline::Modified()
{
appendFilter->Update();
};
@@ -37,10 +37,10 @@
#include "vtkProperty.h"
#include "vtkSmartPointer.h"
G4VtkCutterPipeline::G4VtkCutterPipeline(G4String nameIn, const G4VtkVisContext& vc,
G4VtkCutterPipeline::G4VtkCutterPipeline(G4String nameIn, const G4VtkVisContext& vcIn,
vtkSmartPointer<vtkPolyDataAlgorithm> filter,
G4bool useVcColour)
: G4VVtkPipeline(nameIn, G4String("G4VtkCutterPipeline"), vc, false, vc.fViewer->renderer)
: G4VVtkPipeline(nameIn, G4String("G4VtkCutterPipeline"), vcIn, false, vcIn.fViewer->renderer)
{
// cutter plane
plane = vtkSmartPointer<vtkPlane>::New();
@@ -39,6 +39,7 @@
#include "vtkImageReader2Factory.h"
#include "vtkMatrix4x4.h"
#include "vtkSmartPointer.h"
#include "vtkImageFlip.h"
G4VtkImagePipeline::G4VtkImagePipeline(const G4String& nameIn, const G4VtkVisContext& vcIn)
: G4VVtkPipeline(nameIn, "G4VtkImagePipeline", vcIn, false, vcIn.fViewer->renderer)
@@ -66,6 +67,7 @@ G4VtkImagePipeline::G4VtkImagePipeline(const G4String& nameIn, const G4VtkVisCon
1.};
transform->DeepCopy(transformArray);
actor->SetUserMatrix(transform);
actor->GetProperty()->SetOpacity(vc.alpha);
vc.fViewer->renderer->AddActor(GetActor());
}
@@ -78,7 +80,11 @@ void G4VtkImagePipeline::SetImage(const G4String& fileName)
imageReader->SetFileName(fileName.c_str());
imageReader->Update();
actor->GetMapper()->SetInputConnection(imageReader->GetOutputPort());
vtkNew<vtkImageFlip> flip;
flip->SetInputConnection(imageReader->GetOutputPort());
flip->SetFilteredAxis(1);
actor->GetMapper()->SetInputConnection(flip->GetOutputPort());
AddFilter(imageReader);
}
+108 -2
View File
@@ -85,6 +85,10 @@ G4VtkMessenger::G4VtkMessenger()
fpCommandDebugPrint = new G4UIcommand("/vis/vtk/printDebug", this);
fpCommandDebugPrint->SetGuidance("Debug print of pipelines");
// start interactor in native mode
fpCommandInteractorStart = new G4UIcommand("/vis/vtk/startInteraction", this);
fpCommandInteractorStart->SetGuidance("Start VtkNative window interaction");
/***************************** Set directory *****************************/
fpDirectorySet = new G4UIdirectory("/vis/vtk/set/", true);
fpDirectorySet->SetGuidance("G4VtkViewer set commands");
@@ -98,6 +102,10 @@ G4VtkMessenger::G4VtkMessenger()
fpCommandHUD = new G4UIcmdWithABool("/vis/vtk/set/hud", this);
fpCommandHUD->SetGuidance("Enable or disable HUD for VTK");
// Camera orientation widget
fpCameraOrientation = new G4UIcmdWithABool("/vis/vtk/set/orientation", this);
fpCameraOrientation->SetGuidance("Enable or disable camera orientation widget");
// Clipper command
fpCommandClipper = new G4UIcommand("/vis/vtk/set/clipper", this);
fpCommandClipper->SetGuidance("Enable a cutaway plane (clipper) in VTK");
@@ -121,7 +129,7 @@ G4VtkMessenger::G4VtkMessenger()
// Shadows command
fpCommandShadow = new G4UIcommand("/vis/vtk/set/shadows", this);
fpCommandClipper->SetGuidance("Enable/disable shadows in VTK");
fpCommandShadow->SetGuidance("Enable/disable shadows in VTK");
auto fpCommandShadowParam = new G4UIparameter("enable", 'b', omitable = true);
fpCommandShadowParam->SetDefaultValue(1);
fpCommandShadow->SetParameter(fpCommandShadowParam);
@@ -201,6 +209,66 @@ G4VtkMessenger::G4VtkMessenger()
parameterImageOverlay->SetGuidance("alpha");
parameterImageOverlay->SetDefaultValue(0.5);
fpCommandImageOverlay->SetParameter(parameterImageOverlay);
fpCommandGeometryOverlay = new G4UIcommand("/vis/vtk/add/geometryOverlay", this);
auto parameterGeometryOverlay = new G4UIparameter("filename", 's', omitable = false);
parameterGeometryOverlay->SetGuidance("Geometry file name ");
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("xScale", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("scale in x");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("yScale", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("scale in y");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("zScale", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("scale in z");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("xRotation", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("rotation in x");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("yRotation", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("rotation in y");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("zRotation", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("rotation in z");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("xTranslation", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("translation in x");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("yTranslation", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("translation in y");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("zTranslation", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("translation in z");
parameterGeometryOverlay->SetDefaultValue(0.0);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("alpha", 'd', omitable = true);
parameterGeometryOverlay->SetGuidance("alpha");
parameterGeometryOverlay->SetDefaultValue(0.5);
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
parameterGeometryOverlay = new G4UIparameter("representation", 's', omitable = true);
parameterGeometryOverlay->SetGuidance("representation of mesh");
parameterGeometryOverlay->SetDefaultValue("s");
fpCommandGeometryOverlay->SetParameter(parameterGeometryOverlay);
}
G4VtkMessenger::~G4VtkMessenger()
@@ -214,6 +282,7 @@ G4VtkMessenger::~G4VtkMessenger()
delete fpCommandDebugPrint;
delete fpCommandPolyhedronPipeline;
delete fpCommandImageOverlay;
delete fpCommandGeometryOverlay;
}
G4String G4VtkMessenger::GetCurrentValue(G4UIcommand* /*command*/)
@@ -289,6 +358,15 @@ void G4VtkMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
pVtkViewer->DisableHUD();
}
}
else if (command == fpCameraOrientation) {
G4cout << newValue << G4endl;
if (G4UIcommand::ConvertToBool(newValue)) {
pVtkViewer->EnableCameraOrientationWidget();
}
else {
pVtkViewer->DisableCameraOrientationWidget();
}
}
else if (command == fpCommandDebugPrint) {
pVtkViewer->Print();
}
@@ -312,7 +390,7 @@ void G4VtkMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
G4double worldTopRight[2] = {1, 1};
G4double rotation[3] = {0, 0, 0};
G4double translation[3] = {0, 0, 0};
G4double alpha = 0;
G4double alpha = 0.5;
std::istringstream iss(newValue);
@@ -324,6 +402,31 @@ void G4VtkMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
pVtkViewer->AddImageOverlay(fileName, alpha, imageBottomLeft, worldBottomLeft, imageTopRight,
worldTopRight, rotation, translation);
}
else if (command == fpCommandGeometryOverlay) {
G4String temp;
G4String fileName;
G4double scale[3] = {1, 1, 1};
G4double rotation[3] = {0,0,0};
G4double translation[3] = {0,0,0};
G4double colour[3] = {0.5, 0.5, 0.5};
G4double alpha = 1.0;
G4String representation = "w";
std::istringstream iss(newValue);
iss >> fileName
>> scale[0] >> scale[1] >> scale[2]
>> rotation[0] >> rotation[1] >> rotation[2]
>> translation[0] >> translation[1] >> translation[2]
>> alpha >> representation;
G4cout << fileName << G4endl;
pVtkViewer->AddGeometryOverlay(fileName, colour, alpha, representation,
scale, rotation, translation);
}
else if (command == fpCommandClipper) {
pVtkViewer->EnableClipper(G4Plane3D(), true);
}
@@ -333,4 +436,7 @@ void G4VtkMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
else if (command == fpCommandShadow) {
pVtkViewer->EnableShadows();
}
else if (command == fpCommandInteractorStart) {
pVtkViewer->StartInteractor();
}
}
@@ -0,0 +1,63 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// John Allison 5th April 2001
// A template for a simplest possible graphics driver.
//?? Lines or sections marked like this require specialisation for your driver.
#include "G4VtkOffscreen.hh"
#include "G4VtkMessenger.hh"
#include "G4VtkSceneHandler.hh"
#include "G4VtkOffscreenViewer.hh"
G4VtkOffscreen::G4VtkOffscreen()
: G4VGraphicsSystem("VtkOffscreen", "VTK_OFFSCREEN", "Vtk with offscreen rendering",
G4VGraphicsSystem::noFunctionality)
{
G4VtkMessenger::GetInstance();
}
G4VSceneHandler* G4VtkOffscreen::CreateSceneHandler(const G4String& name)
{
return new G4VtkSceneHandler(*this, name);
}
G4VViewer* G4VtkOffscreen::CreateViewer(G4VSceneHandler& scene, const G4String& name)
{
G4VViewer* pView = new G4VtkOffscreenViewer((G4VtkSceneHandler&)scene, name);
if (pView->GetViewId() < 0) {
G4cerr << "G4Vtk::CreateViewer: ERROR flagged by negative"
" view id in G4VtkViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = nullptr;
}
return pView;
}
@@ -0,0 +1,63 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
#include "G4VtkOffscreenViewer.hh"
#include "G4VtkSceneHandler.hh"
#include "G4VSceneHandler.hh"
#include "vtkWindowToImageFilter.h"
#include "vtkPNGWriter.h"
G4VtkOffscreenViewer::G4VtkOffscreenViewer(G4VSceneHandler& sceneHandler, const G4String& name)
: G4VtkViewer(sceneHandler, name)
{
}
G4VtkOffscreenViewer::~G4VtkOffscreenViewer()
{
}
void G4VtkOffscreenViewer::Initialise()
{
G4VtkViewer::Initialise();
_renderWindow->SetOffScreenRendering(1);
}
void G4VtkOffscreenViewer::FinishView()
{
auto& fVtkSceneHandler = dynamic_cast<G4VtkSceneHandler&>(fSceneHandler);
fVtkSceneHandler.Modified();
_renderWindow->Render();
vtkNew<vtkWindowToImageFilter> windowToImageFilter;
windowToImageFilter->SetInput(_renderWindow);
windowToImageFilter->Update();
vtkNew<vtkPNGWriter> writer;
writer->SetFileName("offscreen.png");
writer->SetInputConnection(windowToImageFilter->GetOutputPort());
writer->Write();
}
@@ -66,8 +66,8 @@ std::size_t G4VtkPolydataInstanceAppendPipeline::MakeHash(const G4Polyhedron& po
}
G4VtkPolydataInstanceAppendPipeline::G4VtkPolydataInstanceAppendPipeline(G4String nameIn,
const G4VtkVisContext& vc)
: G4VtkPolydataInstancePipeline(nameIn, vc)
const G4VtkVisContext& vcIn)
: G4VtkPolydataInstancePipeline(nameIn, vcIn)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataInstanceAppendPipeline"));
@@ -108,11 +108,11 @@ void G4VtkPolydataInstanceAppendPipeline::addInstance(G4double dx, G4double dy,
G4double r10, G4double r11, G4double r12,
G4double r20, G4double r21, G4double r22,
G4double r, G4double g, G4double b,
G4double a, const G4String& name)
G4double a, const G4String& nameIn)
{
// Add to base class
G4VtkPolydataInstancePipeline::addInstance(dx, dy, dz, r00, r01, r02, r10, r11, r12, r20, r21,
r22, r, g, b, a, name);
r22, r, g, b, a, nameIn);
// create transform
auto transform = vtkSmartPointer<vtkGeneralTransform>::New();
@@ -133,14 +133,14 @@ void G4VtkPolydataInstanceAppendPipeline::addInstance(G4double dx, G4double dy,
GetFinalFilter()->AddInputConnection(tf->GetOutputPort());
}
void G4VtkPolydataInstanceAppendPipeline::removeInstance(const G4String& name)
void G4VtkPolydataInstanceAppendPipeline::removeInstance(const G4String& nameIn)
{
// Remove from base class
G4VtkPolydataInstancePipeline::removeInstance(name);
G4VtkPolydataInstancePipeline::removeInstance(nameIn);
// Remove transform filter from append filter
appendFilter->RemoveInputConnection(0, transformFilterMap[name]->GetOutputPort());
// Remove from local filter map
transformFilterMap.erase(name);
transformFilterMap.erase(nameIn);
}
@@ -55,8 +55,8 @@ std::size_t G4VtkPolydataInstanceBakePipeline::MakeHash(const G4Polyhedron& poly
}
G4VtkPolydataInstanceBakePipeline::G4VtkPolydataInstanceBakePipeline(G4String nameIn,
const G4VtkVisContext& vc)
: G4VtkPolydataInstancePipeline(nameIn, vc)
const G4VtkVisContext& vcIn)
: G4VtkPolydataInstancePipeline(nameIn, vcIn)
{
iVert = 0;
iFace = 0;
@@ -86,10 +86,10 @@ void G4VtkPolydataInstanceBakePipeline::addInstance(G4double dx, G4double dy, G4
G4double r10, G4double r11, G4double r12,
G4double r20, G4double r21, G4double r22,
G4double r, G4double g, G4double b, G4double a,
const G4String& name)
const G4String& nameIn)
{
G4VtkPolydataInstancePipeline::addInstance(dx, dy, dz, r00, r01, r02, r10, r11, r12, r20, r21,
r22, r, g, b, a, name);
r22, r, g, b, a, nameIn);
vtkIdType vStart;
vtkIdType vEnd;
@@ -29,8 +29,8 @@
#include "vtkPoints.h"
G4VtkPolydataInstancePipeline::G4VtkPolydataInstancePipeline(G4String nameIn,
const G4VtkVisContext& vc)
: G4VtkPolydataPipeline(nameIn, vc)
const G4VtkVisContext& vcIn)
: G4VtkPolydataPipeline(nameIn, vcIn)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataInstancePipeline"));
@@ -49,22 +49,22 @@ G4VtkPolydataInstancePipeline::G4VtkPolydataInstancePipeline(G4String nameIn,
void G4VtkPolydataInstancePipeline::addInstance(G4double dx, G4double dy, G4double dz, G4double r00,
G4double r01, G4double r02, G4double r10,
G4double r11, G4double r12, G4double r20,
G4double r21, G4double r22, const G4String& name)
G4double r21, G4double r22, const G4String& nameIn)
{
// add the instance without colour or alpha
addInstance(dx, dy, dz, r00, r01, r02, r10, r11, r12, r20, r21, r22, 0, 0, 0, 0, name);
addInstance(dx, dy, dz, r00, r01, r02, r10, r11, r12, r20, r21, r22, 0, 0, 0, 0, nameIn);
}
void G4VtkPolydataInstancePipeline::addInstance(G4double dx, G4double dy, G4double dz, G4double r00,
G4double r01, G4double r02, G4double r10,
G4double r11, G4double r12, G4double r20,
G4double r21, G4double r22, G4double r, G4double g,
G4double b, G4double a, const G4String& name)
G4double b, G4double a, const G4String& nameIn)
{
instanceColour->InsertNextTuple4(r, g, b, a);
auto idp = instancePosition->InsertNextPoint(dx, dy, dz);
instanceTransform->InsertNextTuple9(r00, r01, r02, r10, r11, r12, r20, r21, r22);
instanceMap[name] = idp;
instanceMap[nameIn] = idp;
}
void G4VtkPolydataInstancePipeline::removeInstance(const G4String& /*name*/)
@@ -57,8 +57,8 @@ std::size_t G4VtkPolydataInstanceTensorPipeline::MakeHash(const G4Polyhedron& po
}
G4VtkPolydataInstanceTensorPipeline::G4VtkPolydataInstanceTensorPipeline(G4String nameIn,
const G4VtkVisContext& vc)
: G4VtkPolydataInstancePipeline(nameIn, vc)
const G4VtkVisContext& vcIn)
: G4VtkPolydataInstancePipeline(nameIn, vcIn)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataInstanceTensorPipeline"));
@@ -67,8 +67,8 @@ std::size_t G4VtkPolydataPipeline::MakeHash(const G4Polyhedron& polyhedron,
return hash;
}
G4VtkPolydataPipeline::G4VtkPolydataPipeline(G4String nameIn, const G4VtkVisContext& vc)
: G4VVtkPipeline(nameIn, "G4VtkPolydataPipeline", vc, false, vc.fViewer->renderer)
G4VtkPolydataPipeline::G4VtkPolydataPipeline(G4String nameIn, const G4VtkVisContext& vcIn)
: G4VVtkPipeline(nameIn, "G4VtkPolydataPipeline", vcIn, false, vcIn.fViewer->renderer)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataPipeline"));
@@ -178,6 +178,11 @@ void G4VtkPolydataPipeline::SetPolydata(const G4Polyhedron& polyhedron)
} while (notLastFace);
}
void G4VtkPolydataPipeline::SetPolydata(vtkPolyData *polydataIn) {
polydata->DeepCopy(polydataIn);
}
void G4VtkPolydataPipeline::SetPolydata(const G4Polyline& polyline)
{
// Data data
@@ -41,9 +41,9 @@ std::size_t G4VtkPolydataPolygonPipeline::MakeHash(const G4VisAttributes* pVA)
}
G4VtkPolydataPolygonPipeline::G4VtkPolydataPolygonPipeline(G4String nameIn,
const G4VtkVisContext& vc,
const G4VtkVisContext& vcIn,
const G4VisAttributes* pVisAttributes)
: G4VtkPolydataPipeline(nameIn, vc)
: G4VtkPolydataPipeline(nameIn, vcIn)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataSpherePipeline"));
@@ -46,8 +46,8 @@ std::size_t G4VtkPolydataPolyline2DPipeline::MakeHash(const G4VisAttributes* pVA
}
G4VtkPolydataPolyline2DPipeline::G4VtkPolydataPolyline2DPipeline(
G4String nameIn, const G4VtkVisContext& vc, const G4VisAttributes* pVisAttributes)
: G4VtkPolydataPipeline(nameIn, vc)
G4String nameIn, const G4VtkVisContext& vcIn, const G4VisAttributes* pVisAttributes)
: G4VtkPolydataPipeline(nameIn, vcIn)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataPolyline2DPipeline"));
@@ -36,9 +36,9 @@ std::size_t G4VtkPolydataPolylinePipeline::MakeHash(const G4VisAttributes* pVA)
}
G4VtkPolydataPolylinePipeline::G4VtkPolydataPolylinePipeline(G4String nameIn,
const G4VtkVisContext& vc,
const G4VtkVisContext& vcIn,
const G4VisAttributes* pVisAttributes)
: G4VtkPolydataPipeline(nameIn, vc)
: G4VtkPolydataPipeline(nameIn, vcIn)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataPolylinePipeline"));
@@ -39,9 +39,9 @@ std::size_t G4VtkPolydataSpherePipeline::MakeHash(const G4VisAttributes* pVA)
return std::hash<G4VisAttributes>{}(*pVA);
}
G4VtkPolydataSpherePipeline::G4VtkPolydataSpherePipeline(G4String nameIn, const G4VtkVisContext& vc,
G4VtkPolydataSpherePipeline::G4VtkPolydataSpherePipeline(G4String nameIn, const G4VtkVisContext& vcIn,
const G4VisAttributes* pVisAttributes)
: G4VtkPolydataPipeline(nameIn, vc)
: G4VtkPolydataPipeline(nameIn, vcIn)
{
// Set pipeline type
SetTypeName(G4String("G4VtkPolydataSpherePipeline"));
@@ -65,7 +65,7 @@ G4VtkPolydataSpherePipeline::G4VtkPolydataSpherePipeline(G4String nameIn, const
GetActor()->SetVisibility(1);
GetActor()->GetProperty()->SetRenderPointsAsSpheres(true);
GetActor()->GetProperty()->SetPointSize(vc.fSize * 5);
GetActor()->GetProperty()->SetPointSize(vc.fSize * 2);
vc.fViewer->renderer->AddActor(GetActor());
}
+4 -16
View File
@@ -56,19 +56,7 @@ G4VViewer* G4VtkQt::CreateViewer(G4VSceneHandler& scene, const G4String& name)
G4bool G4VtkQt::IsUISessionCompatible() const
{
G4UImanager* ui = G4UImanager::GetUIpointer();
G4UIsession* session = ui->GetSession();
// If session is a batch session, it may be:
// a) this is a batch job (the user has not instantiated any UI session);
// b) we are currently processing a UI command, in which case the UI
// manager creates a temporary batch session and to find out if there is
// a genuine UI session that the user has instantiated we must drill
// down through previous sessions to a possible non-batch session.
while (auto batch = dynamic_cast<G4UIbatch*>(session)) {
session = batch->GetPreviousSession();
}
// Qt windows are only appropriate in a Qt session.
return dynamic_cast<G4UIQt*>(session) != nullptr;
}
// Qt windows require a Qt session.
G4UIsession* baseSession = G4UImanager::GetUIpointer()->GetBaseSession();
return dynamic_cast<G4UIQt*>(baseSession) != nullptr;
}
@@ -75,6 +75,7 @@ G4VtkQtViewer::G4VtkQtViewer(G4VSceneHandler& sceneHandler, const G4String& name
new G4AutoLock(mWaitForVisSubThreadQtOpenGLContextMoved, std::defer_lock);
G4Qt::getInstance();
//this->setFormat(QVTKOpenGLNativeWidget::defaultFormat());
}
G4VtkQtViewer::~G4VtkQtViewer()
@@ -89,7 +90,6 @@ void G4VtkQtViewer::Initialise()
// Specific GL render window and interactor for Qt
_renderWindow = vtkGenericOpenGLRenderWindow::New();
renderWindowInteractor = vtkRenderWindowInteractor::New();
_renderWindow->AddRenderer(renderer);
this->setRenderWindow(_renderWindow);
@@ -104,7 +104,8 @@ void G4VtkQtViewer::Initialise()
// Shadows
renderer->SetUseShadows(0);
vtkSmartPointer<G4VtkInteractorStyle> style = vtkSmartPointer<G4VtkInteractorStyle>::New();
vtkSmartPointer<G4VtkInteractorStyle> style =
vtkSmartPointer<G4VtkInteractorStyle>::New();
this->interactor()->SetInteractorStyle(style);
}
@@ -113,6 +114,7 @@ void G4VtkQtViewer::CreateMainWindow(QVTKOpenGLNativeWidget* vtkWidget, const QS
G4UImanager* UI = G4UImanager::GetUIpointer();
fUiQt = static_cast<G4UIQt*>(UI->GetG4UIWindow());
fUiQt->AddTabWidget((QWidget*)vtkWidget, name);
vtkWidget->setAttribute(Qt::WA_AcceptTouchEvents, false);
fGLWidget = vtkWidget;
createSceneTreeWidget();
}
@@ -221,6 +223,7 @@ void G4VtkQtViewer::FinishView()
fVtkSceneHandler.Modified();
_renderWindow->Render();
auto qGLW = dynamic_cast<QVTKOpenGLNativeWidget*>(fGLWidget);
qGLW->interactor()->Initialize();
qGLW->interactor()->Start();
+86 -30
View File
@@ -59,17 +59,18 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wextra-semi"
#include "vtkNew.h"
#include "vtkSmartPointer.h"
#include "vtkBillboardTextActor3D.h"
#include "vtkLine.h"
#include "vtkMatrix3x3.h"
#include "vtkOBJReader.h"
#include "vtkPLYReader.h"
#include "vtkSTLReader.h"
#include "vtkPolyDataReader.h"
#include "vtkProperty.h"
#include "vtkProperty2D.h"
#include "vtkRegularPolygonSource.h"
#include "vtkSTLReader.h"
#include "vtkSmartPointer.h"
#include "vtkTextProperty.h"
#pragma GCC diagnostic pop
@@ -415,9 +416,9 @@ void G4VtkStore::AddPrimitiveSeparate(const G4Polyhedron& polyhedron, const G4Vt
G4Transform3D fInvObjTrans = vc.fTransform.inverse();
pl->SetActorTransform(vc.fTransform.dx(), vc.fTransform.dy(), vc.fTransform.dz(),
fInvObjTrans.xx(), fInvObjTrans.xy(), fInvObjTrans.xz(), fInvObjTrans.yx(),
fInvObjTrans.yy(), fInvObjTrans.yz(), fInvObjTrans.zx(), fInvObjTrans.zy(),
fInvObjTrans.zz());
fInvObjTrans.xx(), fInvObjTrans.xy(), fInvObjTrans.xz(),
fInvObjTrans.yx(), fInvObjTrans.yy(), fInvObjTrans.yz(),
fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz());
pl->SetActorColour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), colour.GetAlpha());
}
@@ -428,26 +429,37 @@ void G4VtkStore::AddPrimitiveTensorGlyph(const G4Polyhedron& polyhedron, const G
return;
}
auto hash = G4VtkPolydataInstanceTensorPipeline::MakeHash(polyhedron, vc);
// Possible the polyhedron already has a transform baked in (definitely the case
// for scoring meshes. Remove them here
auto centre = polyhedron.vertexUnweightedMean();
auto transform = G4Translate3D(-centre.x(), -centre.y(), -centre.z());
auto polyhedronNew = G4Polyhedron(polyhedron);
auto fTransformNew = G4Transform3D(vc.fTransform*transform.inverse());
polyhedronNew.Transform(transform);
auto hash = G4VtkPolydataInstanceTensorPipeline::MakeHash(polyhedronNew, vc);
std::shared_ptr<G4VtkPolydataInstanceTensorPipeline> pl;
if (tensorGlyphPipeMap.find(hash) == tensorGlyphPipeMap.end()) {
pl = std::make_shared<G4VtkPolydataInstanceTensorPipeline>(G4String("name"), vc);
pl->SetPolydata(polyhedron);
pl->SetPolydata(polyhedronNew);
tensorGlyphPipeMap.insert(std::make_pair(hash, pl));
}
else {
pl = tensorGlyphPipeMap[hash];
}
G4Transform3D fInvObjTrans = vc.fTransform.inverse();
G4Transform3D fInvObjTrans = fTransformNew.inverse();
const G4VisAttributes* pVA =
vc.fViewer->GetApplicableVisAttributes(polyhedron.GetVisAttributes());
G4Color colour = pVA->GetColour();
pl->addInstance(vc.fTransform.dx(), vc.fTransform.dy(), vc.fTransform.dz(), fInvObjTrans.xx(),
fInvObjTrans.xy(), fInvObjTrans.xz(), fInvObjTrans.yx(), fInvObjTrans.yy(),
fInvObjTrans.yz(), fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz(),
pl->addInstance(fTransformNew.dx(), fTransformNew.dy(), fTransformNew.dz(),
fInvObjTrans.xx(), fInvObjTrans.xy(), fInvObjTrans.xz(),
fInvObjTrans.yx(), fInvObjTrans.yy(), fInvObjTrans.yz(),
fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz(),
colour.GetRed(), colour.GetGreen(), colour.GetBlue(), colour.GetAlpha(),
G4String("null"));
}
@@ -459,25 +471,35 @@ void G4VtkStore::AddPrimitiveAppend(const G4Polyhedron& polyhedron, const G4VtkV
return;
}
auto hash = G4VtkPolydataInstanceAppendPipeline::MakeHash(polyhedron, vc);
// Possible the polyhedron already has a transform baked in (definitely the case
// for scoring meshes. Remove them here
auto centre = polyhedron.vertexUnweightedMean();
auto transform = G4Translate3D(-centre.x(), -centre.y(), -centre.z());
auto polyhedronNew = G4Polyhedron(polyhedron);
auto fTransformNew = G4Transform3D(vc.fTransform*transform.inverse());
polyhedronNew.Transform(transform);
auto hash = G4VtkPolydataInstanceAppendPipeline::MakeHash(polyhedronNew, vc);
std::shared_ptr<G4VtkPolydataInstanceAppendPipeline> pl;
if (appendPipeMap.find(hash) == appendPipeMap.end()) {
pl = std::make_shared<G4VtkPolydataInstanceAppendPipeline>(G4String("name"), vc);
pl->SetPolydata(polyhedron);
pl->SetPolydata(polyhedronNew);
appendPipeMap.insert(std::make_pair(hash, pl));
}
else {
pl = appendPipeMap[hash];
}
G4Transform3D fInvObjTrans = vc.fTransform.inverse();
G4Transform3D fInvObjTrans = fTransformNew.inverse();
pl->addInstance(vc.fTransform.dx(), vc.fTransform.dy(), vc.fTransform.dz(), fInvObjTrans.xx(),
fInvObjTrans.xy(), fInvObjTrans.xz(), fInvObjTrans.yx(), fInvObjTrans.yy(),
fInvObjTrans.yz(), fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz(), 0, 0,
0, 0, G4String("null"));
pl->addInstance(fTransformNew.dx(), fTransformNew.dy(), fTransformNew.dz(),
fInvObjTrans.xx(), fInvObjTrans.xy(), fInvObjTrans.xz(),
fInvObjTrans.yx(), fInvObjTrans.yy(), fInvObjTrans.yz(),
fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz(),
0, 0, 0, 0, G4String("null"));
};
void G4VtkStore::AddPrimitiveTransformBake(const G4Polyhedron& polyhedron,
@@ -488,6 +510,16 @@ void G4VtkStore::AddPrimitiveTransformBake(const G4Polyhedron& polyhedron,
return;
}
// Possible the polyhedron already has a transform baked in (definitely the case
// for scoring meshes. Remove them here
auto centre = polyhedron.vertexUnweightedMean();
auto transform = G4Translate3D(-centre.x(), -centre.y(), -centre.z());
auto polyhedronNew = G4Polyhedron(polyhedron);
auto fTransformNew = G4Transform3D(vc.fTransform*transform.inverse());
polyhedronNew.Transform(transform);
// Get vis attributes - pick up defaults if none.
const G4VisAttributes* pVA =
vc.fViewer->GetApplicableVisAttributes(polyhedron.GetVisAttributes());
@@ -496,7 +528,7 @@ void G4VtkStore::AddPrimitiveTransformBake(const G4Polyhedron& polyhedron,
G4Colour colour = pVA->GetColour();
// Hash the vis (alpha) attributes and polyhedron
std::size_t hash = G4VtkPolydataInstanceBakePipeline::MakeHash(polyhedron, vc);
std::size_t hash = G4VtkPolydataInstanceBakePipeline::MakeHash(polyhedronNew, vc);
std::shared_ptr<G4VtkPolydataInstanceBakePipeline> pl;
if (bakePipeMap.find(hash) == bakePipeMap.end()) {
@@ -508,12 +540,13 @@ void G4VtkStore::AddPrimitiveTransformBake(const G4Polyhedron& polyhedron,
pl = bakePipeMap[hash];
}
G4Transform3D fInvObjTrans = vc.fTransform.inverse();
pl->SetPolydata(polyhedron);
G4Transform3D fInvObjTrans = fTransformNew.inverse();
pl->SetPolydata(polyhedronNew);
pl->addInstance(vc.fTransform.dx(), vc.fTransform.dy(), vc.fTransform.dz(), fInvObjTrans.xx(),
fInvObjTrans.xy(), fInvObjTrans.xz(), fInvObjTrans.yx(), fInvObjTrans.yy(),
fInvObjTrans.yz(), fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz(),
pl->addInstance(fTransformNew.dx(), fTransformNew.dy(), fTransformNew.dz(),
fInvObjTrans.xx(), fInvObjTrans.xy(), fInvObjTrans.xz(),
fInvObjTrans.yx(), fInvObjTrans.yy(), fInvObjTrans.yz(),
fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz(),
colour.GetRed(), colour.GetGreen(), colour.GetBlue(), colour.GetAlpha(),
G4String("null"));
};
@@ -696,20 +729,43 @@ void G4VtkStore::AddNonG4ObjectImage(const G4String& fileName, const G4VtkVisCon
imagePipeMap.insert(std::make_pair(fileName, pl));
}
void G4VtkStore::AddNonG4ObjectPolydata(const G4String fileName, const G4VtkVisContext& /*vc*/)
void G4VtkStore::AddNonG4ObjectPolydata(const G4String fileName, const G4VtkVisContext& vc)
{
vtkSmartPointer<vtkPolyData> pd;
if (fileName.find("obj") != G4String::npos) {
vtkSmartPointer<vtkOBJReader> objReader;
vtkNew<vtkOBJReader> objReader;
objReader->SetFileName(fileName.c_str());
objReader->Update();
pd = objReader->GetOutput();
}
else if (fileName.find("ply") != G4String::npos) {
vtkSmartPointer<vtkPLYReader> plyReader;
vtkNew<vtkPLYReader> plyReader;
plyReader->SetFileName(fileName.c_str());
plyReader->Update();
pd = plyReader->GetOutput();
}
else if (fileName.find("stl") != G4String::npos) {
vtkSmartPointer<vtkSTLReader> stlReader;
vtkNew<vtkSTLReader> stlReader;
stlReader->SetFileName(fileName.c_str());
stlReader->Update();
pd = stlReader->GetOutput();
}
else if (fileName.find("vtp") != G4String::npos && fileName.find("vtu") != G4String::npos) {
vtkSmartPointer<vtkPolyDataReader> pldReader;
G4cout << "G4VtkStore::AddNonG4ObjectPolydata> vtp/vtu Warning not yet implemented" << G4endl;
}
auto pl = std::make_shared<G4VtkPolydataPipeline>(G4String("name"), vc);
G4Transform3D fInvObjTrans = vc.fTransform.inverse();
pl->SetPolydata(pd);
pl->SetActorTransform(vc.fTransform.dx(), vc.fTransform.dy(), vc.fTransform.dz(),
fInvObjTrans.xx(), fInvObjTrans.xy(), fInvObjTrans.xz(),
fInvObjTrans.yx(), fInvObjTrans.yy(), fInvObjTrans.yz(),
fInvObjTrans.zx(), fInvObjTrans.zy(), fInvObjTrans.zz());
pl->SetActorColour(vc.red, vc.green, vc.blue, vc.alpha);
}
void G4VtkStore::GetBounds(G4double maxBoundIn[6])
@@ -50,9 +50,9 @@ std::size_t G4VtkText2DPipeline::MakeHash(const G4Text& text, const G4VtkVisCont
return hash;
}
G4VtkText2DPipeline::G4VtkText2DPipeline(const G4Text& text, const G4VtkVisContext& vc,
G4VtkText2DPipeline::G4VtkText2DPipeline(const G4Text& text, const G4VtkVisContext& vcIn,
const G4VisAttributes* pVA)
: G4VVtkPipeline(text.GetText().c_str(), "G4VtkText2DPipeline", vc, false, vc.fViewer->renderer)
: G4VVtkPipeline(text.GetText().c_str(), "G4VtkText2DPipeline", vcIn, false, vcIn.fViewer->renderer)
{
G4double x = text.GetPosition().x();
G4double y = text.GetPosition().y();
@@ -52,9 +52,9 @@ std::size_t G4VtkTextPipeline::MakeHash(const G4Text& text, const G4VtkVisContex
return hash;
}
G4VtkTextPipeline::G4VtkTextPipeline(const G4Text& text, const G4VtkVisContext& vc,
G4VtkTextPipeline::G4VtkTextPipeline(const G4Text& text, const G4VtkVisContext& vcIn,
const G4VisAttributes* pVA)
: G4VVtkPipeline(text.GetText().c_str(), "G4VtkTextPipeline", vc, false, vc.fViewer->renderer)
: G4VVtkPipeline(text.GetText().c_str(), "G4VtkTextPipeline", vcIn, false, vcIn.fViewer->renderer)
{
G4double x = text.GetPosition().x();
G4double y = text.GetPosition().y();
@@ -25,13 +25,25 @@
#include "vtkPoints.h"
#include "vtkCellArray.h"
#include "vtkCharArray.h"
#include "vtkUnstructuredGrid.h"
#include "vtkDataSetMapper.h"
#include "vtkUnstructuredGridVolumeMapper.h"
#include "vtkUnstructuredGridVolumeRayCastMapper.h"
#include "vtkUnstructuredGridVolumeZSweepMapper.h"
#include "vtkOpenGLProjectedTetrahedraMapper.h"
#include "vtkActor.h"
#include "vtkColorTransferFunction.h"
#include "vtkPiecewiseFunction.h"
#include "vtkLookupTable.h"
#include "vtkVolumeProperty.h"
#include "vtkVolume.h"
#include "vtkNew.h"
#include "vtkTetra.h"
#include "vtkVoxel.h"
#include "vtkStaticCleanUnstructuredGrid.h"
// #include "vtkCleanUnstructuredGrid.h"
#include "vtkDataSetTriangleFilter.h"
#include "vtkClipDataSet.h"
#include "G4VtkUnstructuredGridPipeline.hh"
#include "G4VtkVisContext.hh"
@@ -48,32 +60,78 @@
#include "G4Tet.hh"
#include "G4Material.hh"
G4VtkUnstructuredGridPipeline::G4VtkUnstructuredGridPipeline(G4String nameIn, const G4VtkVisContext& vc) :
G4VVtkPipeline(nameIn, "G4VtkUnstructuredPipeline", vc, false, vc.fViewer->renderer) {
G4VtkUnstructuredGridPipeline::G4VtkUnstructuredGridPipeline(G4String nameIn, const G4VtkVisContext& vcIn) :
G4VVtkPipeline(nameIn, "G4VtkUnstructuredPipeline", vcIn, false, vcIn.fViewer->renderer) {
points = vtkSmartPointer<vtkPoints>::New();
pointValues = vtkSmartPointer<vtkDoubleArray>::New();
cellValues = vtkSmartPointer<vtkDoubleArray>::New();
cellValues->SetNumberOfComponents(4);
cellValues->SetName("Colors");
pointColourValues = vtkSmartPointer<vtkDoubleArray>::New();
cellColourValues = vtkSmartPointer<vtkDoubleArray>::New();
pointColourValues->SetNumberOfComponents(4);
cellColourValues->SetNumberOfComponents(4);
pointColourIndices = vtkSmartPointer<vtkDoubleArray>::New();
cellColourIndices = vtkSmartPointer<vtkDoubleArray>::New();
pointColourIndices->SetNumberOfComponents(1);
cellColourIndices->SetNumberOfComponents(1);
colourLUT = vtkSmartPointer<vtkDiscretizableColorTransferFunction>::New();
colourLUT->DiscretizeOn();
unstructuredGrid = vtkSmartPointer<vtkUnstructuredGrid>::New();
unstructuredGrid->SetPoints(points);
unstructuredGrid->GetCellData()->SetScalars(cellValues);
unstructuredGrid->GetPointData()->SetScalars(pointColourValues);
unstructuredGrid->GetCellData()->SetScalars(cellColourValues);
// clean filter
#if 0
clean = vtkSmartPointer<vtkStaticCleanUnstructuredGrid>::New();
clean->SetInputData(unstructuredGrid);
clean->ToleranceIsAbsoluteOff();
clean->SetTolerance(1e-6);
#endif
// Clip filter
clip = vtkSmartPointer<vtkClipDataSet>::New();
vtkNew<vtkPlane> plane;
clip->SetClipFunction(plane);
clip->SetInputData(unstructuredGrid);
// Triangle filter
auto tri = vtkSmartPointer<vtkDataSetTriangleFilter>::New();
tri->SetInputData(unstructuredGrid);
// create dataset mapper
mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetScalarModeToUseCellData();
mapper->SetColorModeToDirectScalars();
mapper->SetInputData(unstructuredGrid);
//mapper->SetInputConnection(clip->GetOutputPort());
//mapper->SetInputConnection(tri->GetOutputPort());
// create volume mapper
volumeMapper = vtkSmartPointer<vtkUnstructuredGridVolumeRayCastMapper>::New();
volumeMapper->SetScalarModeToUseCellData();
volumeMapper->SetInputConnection(tri->GetOutputPort());
// create volume properties
auto volumeProp = vtkSmartPointer<vtkVolumeProperty>::New();
volumeProp->SetColor(colourLUT);
// create actor
actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->SetVisibility(1);
// create volume
volume = vtkSmartPointer<vtkVolume>::New();
volume->SetMapper(volumeMapper);
//volume->SetProperty(volumeProp);
volume->SetVisibility(1);
// add to renderer
vc.fViewer->renderer->AddActor(actor);
//vc.fViewer->renderer->AddVolume(volume);
}
void G4VtkUnstructuredGridPipeline::PseudoSceneForTetCells::AddSolid(const G4VSolid& solid) {
@@ -85,29 +143,67 @@ void G4VtkUnstructuredGridPipeline::PseudoSceneForTetCells::AddSolid(const G4VSo
const auto& colour = pVisAtts->GetColour();
G4ThreeVector p0, p1, p2, p3;
tet.GetVertices(p0, p1,p2, p3);
tet.GetVertices(p0, p1, p2, p3);
fpPoints->InsertNextPoint(p0.x(),p0.y(),p0.z());
fpPoints->InsertNextPoint(p1.x(),p1.y(),p1.z());
fpPoints->InsertNextPoint(p2.x(),p2.y(),p2.z());
fpPoints->InsertNextPoint(p3.x(),p3.y(),p3.z());
G4int idx[4] = {-1, -1, -1, -1};
vtkNew<vtkTetra> tetra;
tetra->GetPointIds()->SetId(0, 4*iCell);
tetra->GetPointIds()->SetId(1, 4*iCell+1);
tetra->GetPointIds()->SetId(2, 4*iCell+2);
tetra->GetPointIds()->SetId(3, 4*iCell+3);
if (iCell > 0 && iCell < 100000000) {
#if 0
G4ThreeVector pts[4] = {p0, p1, p2, p3};
for (G4int i = 0; i < 4; i++) {
auto h = MakeHash(pts[i]);
if (fpPointMap.find(h) == fpPointMap.end()) {
fpPointMap.insert(std::make_pair(h, iPoint));
fpPoints->InsertNextPoint(pts[i].x(), pts[i].y(), pts[i].z());
fpPointVector.push_back(pts[i]);
idx[i] = iPoint;
iPoint++;
}
else {
idx[i] = fpPointMap[h];
}
}
#endif
fpGrid->InsertNextCell(tetra->GetCellType(), tetra->GetPointIds());
#if 1
fpPoints->InsertNextPoint(p0.x(), p0.y(), p0.z());
fpPoints->InsertNextPoint(p1.x(), p1.y(), p1.z());
fpPoints->InsertNextPoint(p2.x(), p2.y(), p2.z());
fpPoints->InsertNextPoint(p3.x(), p3.y(), p3.z());
iPoint += 4;
double cols[] = {colour.GetRed(),
colour.GetGreen(),
colour.GetBlue(),
colour.GetAlpha()};
fpCellValues->InsertNextTuple(cols);
idx[0] = 4 * iCellAdd;
idx[1] = 4 * iCellAdd + 1;
idx[2] = 4 * iCellAdd + 2;
idx[3] = 4 * iCellAdd + 3;
#endif
vtkNew<vtkTetra> tetra;
tetra->GetPointIds()->SetId(0, idx[0]);
tetra->GetPointIds()->SetId(1, idx[1]);
tetra->GetPointIds()->SetId(2, idx[2]);
tetra->GetPointIds()->SetId(3, idx[3]);
fpGrid->InsertNextCell(tetra->GetCellType(), tetra->GetPointIds());
auto hash = MakeHash(colour);
unsigned short int iColour = 0;
if (fpColourMap.find(hash) == fpColourMap.end()) {
iColour = fpColourMap.size();
fpColourMap.insert(std::make_pair(hash,iColour));
double c[4] = {colour.GetRed(), colour.GetGreen(), colour.GetBlue(), colour.GetAlpha()};
fpColourLUT->SetIndexedColorRGBA(iColour,c);
}
else {
iColour = fpColourMap[hash];
}
fpCellColourValues->InsertNextTuple4(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), colour.GetAlpha());
fpCellColourIndices->InsertNextTuple1(iColour);
iCellAdd++;
}
iCell++;
}
catch (const std::bad_cast&) {
G4ExceptionDescription ed;
@@ -126,13 +222,13 @@ void G4VtkUnstructuredGridPipeline::PseudoSceneForCubicalCells::AddSolid(const G
fpPoints->InsertNextPoint(position.x()-box.GetXHalfLength(),position.y()-box.GetYHalfLength(),position.z()-box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()-box.GetXHalfLength(),position.y()+box.GetYHalfLength(),position.z()-box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()+box.GetXHalfLength(),position.y()+box.GetYHalfLength(),position.z()-box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()+box.GetXHalfLength(),position.y()-box.GetYHalfLength(),position.z()-box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()+box.GetXHalfLength(),position.y()+box.GetYHalfLength(),position.z()-box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()-box.GetXHalfLength(),position.y()-box.GetYHalfLength(),position.z()+box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()-box.GetXHalfLength(),position.y()+box.GetYHalfLength(),position.z()+box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()+box.GetXHalfLength(),position.y()+box.GetYHalfLength(),position.z()+box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()+box.GetXHalfLength(),position.y()-box.GetYHalfLength(),position.z()+box.GetZHalfLength());
fpPoints->InsertNextPoint(position.x()+box.GetXHalfLength(),position.y()+box.GetYHalfLength(),position.z()+box.GetZHalfLength());
vtkNew<vtkVoxel> voxel;
voxel->GetPointIds()->SetId(0, 8*iCell);
@@ -150,7 +246,9 @@ void G4VtkUnstructuredGridPipeline::PseudoSceneForCubicalCells::AddSolid(const G
colour.GetGreen(),
colour.GetBlue(),
colour.GetAlpha()};
fpCellValues->InsertNextTuple(cols);
fpCellColourValues->InsertNextTuple(cols);
//fpCellColourIndices->InsertNextTuple1(iColour);
iCell++;
@@ -181,19 +279,26 @@ void G4VtkUnstructuredGridPipeline::SetUnstructuredGridData(const G4Mesh &mesh)
// Graphics scene
if(mesh.GetMeshType() == G4Mesh::tetrahedron) {
PseudoSceneForTetCells pseudoScene(&tmpPVModel, mesh.GetMeshDepth(), points, cellValues,
unstructuredGrid);
PseudoSceneForTetCells pseudoScene(&tmpPVModel, mesh.GetMeshDepth(), points,
pointColourValues, cellColourValues,
pointColourIndices, cellColourIndices,
colourLUT, unstructuredGrid);
tmpPVModel.DescribeYourselfTo(pseudoScene);
//G4cout << pseudoScene.GetNumberOfPoints() << " " << pseudoScene.GetNumberOfCells() << " " << pseudoScene.GetNumberOfAddedCells() << G4endl;
//pseudoScene.DumpColourMap();
}
else if(mesh.GetMeshType() == G4Mesh::nested3DRectangular) {
PseudoSceneForCubicalCells pseudoScene(&tmpPVModel, mesh.GetMeshDepth(), points, cellValues,
unstructuredGrid);
PseudoSceneForCubicalCells pseudoScene(&tmpPVModel, mesh.GetMeshDepth(), points,
pointColourValues, cellColourValues,
pointColourIndices, cellColourIndices,
colourLUT, unstructuredGrid);
tmpPVModel.DescribeYourselfTo(pseudoScene);
}
else if(mesh.GetMeshType() == G4Mesh::rectangle) {
PseudoSceneForCubicalCells pseudoScene(&tmpPVModel, mesh.GetMeshDepth(), points, cellValues,
unstructuredGrid);
PseudoSceneForCubicalCells pseudoScene(&tmpPVModel, mesh.GetMeshDepth(), points,
pointColourValues, cellColourValues,
pointColourIndices, cellColourIndices,
colourLUT, unstructuredGrid);
tmpPVModel.DescribeYourselfTo(pseudoScene);
}
@@ -26,9 +26,11 @@
// Created by Stewart Boogert on 05/03/2023.
//
#include "G4VVtkPipeline.hh" // Move basic hashing functionality to G4VtkUtility.(hh/cc
#include "G4VtkUtility.hh"
#include "G4Transform3D.hh"
#include "G4Colour.hh"
#include "vtkMatrix4x4.h"
#include "vtkPlane.h"
@@ -79,3 +81,32 @@ void MaxBounds(G4double* maxBound, G4double* boundToCheck)
if (boundToCheck[4] < maxBound[4]) maxBound[4] = boundToCheck[4];
if (boundToCheck[5] > maxBound[5]) maxBound[5] = boundToCheck[5];
}
std::size_t MakeHash(const G4ThreeVector &v)
{
std::size_t xhash = std::hash<G4double>{}(v.x());
std::size_t yhash = std::hash<G4double>{}(v.y());
std::size_t zhash = std::hash<G4double>{}(v.z());
std::hash_combine(xhash, yhash);
std::hash_combine(yhash, zhash);
return xhash;
}
std::size_t MakeHash(const G4Colour &c)
{
std::size_t rhash = std::hash<G4double>{}(c.GetRed());
std::size_t ghash = std::hash<G4double>{}(c.GetGreen());
std::size_t bhash = std::hash<G4double>{}(c.GetBlue());
std::size_t ahash = std::hash<G4double>{}(c.GetAlpha());
std::hash_combine(rhash, ghash);
std::hash_combine(rhash, bhash);
std::hash_combine(rhash, ahash);
return rhash;
}
+90 -46
View File
@@ -23,6 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
#include <cmath>
#include "G4VtkViewer.hh"
#include "G4Transform3D.hh"
@@ -46,7 +48,11 @@
#include "vtkLightCollection.h"
#include "vtkOBJExporter.h"
#include "vtkOBJImporter.h"
#include "vtkGLTFExporter.h"
#include "vtkOOGLExporter.h"
#include "vtkJSONRenderWindowExporter.h"
#include "vtkVtkJSSceneGraphSerializer.h"
//#include "vtkBufferedArchiver.h"
#include "vtkPNGWriter.h"
#include "vtkPNMWriter.h"
#include "vtkPOVExporter.h"
@@ -160,36 +166,35 @@ void G4VtkViewer::SetView()
if (radius <= 0.) {
radius = 1.;
}
G4double cameraDistance = fVP.GetCameraDistance(radius);
if (firstSetView) cameraDistance = fVP.GetCameraDistance(radius);
G4Point3D viewpointDirection = fVP.GetViewpointDirection();
G4Point3D targetPoint = fVP.GetCurrentTargetPoint();
G4Point3D cameraPosition = targetPoint + viewpointDirection.unit() * cameraDistance;
renderer->GetActiveCamera()->SetFocalPoint(targetPoint.x(), targetPoint.y(), targetPoint.z());
renderer->GetActiveCamera()->SetPosition(cameraPosition.x(), cameraPosition.y(),
cameraPosition.z());
renderer->GetActiveCamera()->SetParallelScale(cameraDistance);
G4Point3D targetPosition = fVP.GetCurrentTargetPoint();
G4double zoomFactor = fVP.GetZoomFactor();
G4double fieldHalfAngle = fVP.GetFieldHalfAngle();
G4Point3D cameraPosition = targetPosition + viewpointDirection.unit() /zoomFactor * cameraDistance;
vtkCamera* activeCamera = renderer->GetActiveCamera();
activeCamera->SetFocalPoint(targetPosition.x(), targetPosition.y(), targetPosition.z());
activeCamera->SetViewAngle(2*fieldHalfAngle / M_PI * 180);
activeCamera->SetPosition(cameraPosition.x(), cameraPosition.y(), cameraPosition.z());
activeCamera->SetParallelScale(cameraDistance / zoomFactor);
if (fieldHalfAngle == 0) {
activeCamera->SetParallelProjection(1);
}
else {
activeCamera->SetParallelProjection(0);
}
// need to set camera distance and parallel scale on first set view
if (firstSetView) {
geant4Callback->SetVtkInitialValues(cameraDistance, cameraDistance);
activeCamera->SetParallelScale(cameraDistance);
firstSetView = false;
}
// projection type and view angle and zoom factor
G4double fieldHalfAngle = fVP.GetFieldHalfAngle();
G4double zoomFactor = fVP.GetZoomFactor();
vtkCamera* activeCamera = renderer->GetActiveCamera();
if (fieldHalfAngle == 0) {
activeCamera->SetParallelProjection(1);
activeCamera->SetParallelScale(activeCamera->GetParallelScale() / zoomFactor);
}
else {
activeCamera->SetParallelProjection(0);
activeCamera->SetViewAngle(2 * fieldHalfAngle / M_PI * 180);
activeCamera->SetPosition(cameraPosition.x() / zoomFactor, cameraPosition.y() / zoomFactor,
cameraPosition.z() / zoomFactor);
}
// camera up direction
const G4Vector3D upVector = fVP.GetUpVector();
renderer->GetActiveCamera()->SetViewUp(upVector.x(), upVector.y(), upVector.z());
@@ -197,7 +202,7 @@ void G4VtkViewer::SetView()
// Light
const G4Vector3D lightDirection = fVP.GetLightpointDirection();
G4bool lightsMoveWithCamera = fVP.GetLightsMoveWithCamera();
G4Vector3D lightPosition = targetPoint + lightDirection.unit() * cameraDistance;
G4Vector3D lightPosition = targetPosition + lightDirection.unit() * cameraDistance;
vtkLightCollection* currentLights = renderer->GetLights();
if (currentLights->GetNumberOfItems() != 0) {
@@ -323,7 +328,13 @@ void G4VtkViewer::FinishView()
_renderWindow->GetInteractor()->Initialize();
_renderWindow->Render();
_renderWindow->GetInteractor()->Start();
if (firstFinishView) {
firstFinishView = false;
}
else {
_renderWindow->GetInteractor()->Start();
}
}
void G4VtkViewer::ExportScreenShot(G4String path, G4String format)
@@ -349,7 +360,7 @@ void G4VtkViewer::ExportScreenShot(G4String path, G4String format)
imWriter = vtkPostScriptWriter::New();
}
else {
imWriter = vtkPNGWriter::New();
return;
}
_renderWindow->Render();
@@ -374,35 +385,43 @@ void G4VtkViewer::ExportScreenShot(G4String path, G4String format)
void G4VtkViewer::ExportOBJScene(G4String path)
{
vtkSmartPointer<vtkRenderWindow> _rw1 = vtkSmartPointer<vtkRenderWindow>::New();
_rw1->AddRenderer(_renderWindow->GetRenderers()->GetFirstRenderer());
vtkSmartPointer<vtkOBJExporter> exporter = vtkSmartPointer<vtkOBJExporter>::New();
exporter->SetRenderWindow(_rw1);
exporter->SetRenderWindow(_renderWindow);
exporter->SetFilePrefix(path.c_str());
exporter->Write();
}
void G4VtkViewer::ExportVRMLScene(G4String path)
{
vtkSmartPointer<vtkRenderWindow> _rw1 = vtkSmartPointer<vtkRenderWindow>::New();
_rw1->AddRenderer(_renderWindow->GetRenderers()->GetFirstRenderer());
vtkSmartPointer<vtkVRMLExporter> exporter = vtkSmartPointer<vtkVRMLExporter>::New();
exporter->SetRenderWindow(_rw1);
exporter->SetRenderWindow(_renderWindow);
exporter->SetFileName((path + ".vrml").c_str());
exporter->Write();
}
void G4VtkViewer::ExportVTPScene(G4String path)
{
vtkSmartPointer<vtkRenderWindow> _rw1 = vtkSmartPointer<vtkRenderWindow>::New();
_rw1->AddRenderer(_renderWindow->GetRenderers()->GetFirstRenderer());
vtkSmartPointer<vtkSingleVTPExporter> exporter = vtkSmartPointer<vtkSingleVTPExporter>::New();
exporter->SetRenderWindow(_rw1);
exporter->SetRenderWindow(_renderWindow);
exporter->SetFileName((path + ".vtp").c_str());
exporter->Write();
}
void G4VtkViewer::ExportGLTFScene(G4String /*fileName*/) {}
void G4VtkViewer::ExportGLTFScene(G4String fileName) {
vtkSmartPointer<vtkGLTFExporter> exporter = vtkSmartPointer<vtkGLTFExporter>::New();
exporter->SetRenderWindow(_renderWindow);
exporter->SetFileName((fileName+".gltf").c_str());
exporter->InlineDataOn();
exporter->Write();
}
void G4VtkViewer::ExportJSONRenderWindowScene(G4String /*fileName*/) {
vtkSmartPointer<vtkJSONRenderWindowExporter> exporter = vtkSmartPointer<vtkJSONRenderWindowExporter>::New();
vtkSmartPointer<vtkVtkJSSceneGraphSerializer> serializer = vtkSmartPointer<vtkVtkJSSceneGraphSerializer>::New();
exporter->SetRenderWindow(_renderWindow);
exporter->SetSerializer(serializer);
exporter->Write();
}
void G4VtkViewer::ExportVTPCutter(G4String fileName)
{
@@ -505,6 +524,13 @@ void G4VtkViewer::ExportFormatStore(G4String fileName, G4String storeName)
exporter->SetFileName(fileName.c_str());
exporter->Write();
}
else if (fileName.find("gltf") != std::string::npos) {
vtkNew<vtkGLTFExporter> exporter;
exporter->SetRenderWindow(tempRenderWindow);
exporter->SetFileName(fileName.c_str());
exporter->InlineDataOn();
exporter->Write();
}
}
void G4VtkViewer::AddViewHUD()
@@ -537,6 +563,10 @@ void G4VtkViewer::AddClipperPlaneWidget(const G4Plane3D& plane)
clipperPlaneRepresentation->PlaceWidget(bounds);
clipperPlaneRepresentation->SetNormal(vplane->GetNormal());
vtkNew<vtkPropCollection> planeRepActors;
clipperPlaneRepresentation->GetActors(planeRepActors);
planeRepActors->InitTraversal();
SetWidgetInteractor(clipperPlaneWidget);
clipperPlaneWidget->SetRepresentation(clipperPlaneRepresentation);
clipperPlaneWidget->AddObserver(vtkCommand::InteractionEvent, clipperCallback);
@@ -634,6 +664,7 @@ void G4VtkViewer::DisableCutter(G4String /*name*/)
void G4VtkViewer::EnableCutterWidget()
{
G4cout << "enable cutter widget" << G4endl;
cutterPlaneWidget->SetEnabled(1);
}
@@ -646,7 +677,7 @@ void G4VtkViewer::AddCameraOrientationWidget()
{
camOrientWidget->SetParentRenderer(renderer);
// Enable the widget.
camOrientWidget->On();
camOrientWidget->Off();
}
void G4VtkViewer::EnableCameraOrientationWidget()
@@ -666,18 +697,25 @@ void G4VtkViewer::AddImageOverlay(const G4String& fileName, const G4double alpha
const G4double rotation[3], const G4double translation[3])
{
auto xScale = (worldTopRight[0] - worldBottomLeft[0]) / (imageTopRight[0] - imageBottomLeft[0]);
auto yScale = (worldTopRight[1] - worldBottomLeft[1]) / (imageTopRight[1] - imageBottomLeft[1]);
auto yScale = -(worldTopRight[1] - worldBottomLeft[1]) / (imageTopRight[1] - imageBottomLeft[1]);
G4cout << xScale << " " << yScale << G4endl;
auto transformation = G4Transform3D::Identity;
auto scal = G4Scale3D(xScale, yScale, 1);
auto rotx = G4RotateX3D(rotation[0]);
auto roty = G4RotateY3D(rotation[1]);
auto rotz = G4RotateZ3D(rotation[2]);
auto tran = G4Translate3D(translation[0] - xScale * (imageBottomLeft[0] + imageTopRight[0]) / 2.0,
translation[1] - yScale * (imageBottomLeft[1] + imageTopRight[1]) / 2.0,
auto rotx = G4RotateX3D(rotation[0]/180*M_PI);
auto roty = G4RotateY3D(rotation[1]/180*M_PI);
auto rotz = G4RotateZ3D(rotation[2]/180*M_PI);
auto tranImg = G4Translate3D( -std::fabs(imageBottomLeft[0] + imageTopRight[0]) / 2.0,
-std::fabs(imageBottomLeft[1] + imageTopRight[1]) / 2.0,
0);
auto tran = G4Translate3D(translation[0],
translation[1],
translation[2]);
transformation = tran * rotz * roty * rotx * scal * transformation;
G4cout << translation[0] << " " << translation[1] << " " << translation[2] << G4endl;
transformation = tran * rotz * roty * rotx * scal * tranImg * transformation;
G4cout << transformation.dx() << " " << transformation.dy() << " " << transformation.dz() << G4endl;
auto& fVtkSceneHandler = dynamic_cast<G4VtkSceneHandler&>(fSceneHandler);
G4VtkStore& st = fVtkSceneHandler.GetTransientStore();
@@ -686,9 +724,10 @@ void G4VtkViewer::AddImageOverlay(const G4String& fileName, const G4double alpha
st.AddNonG4ObjectImage(fileName, vc);
}
void G4VtkViewer::Add3DOverlay(const G4String& fileName, const G4double colour[3],
const G4double alpha, const G4double scale[3],
const G4double rotation[3], const G4double translation[3])
void G4VtkViewer::AddGeometryOverlay(const G4String& fileName, const G4double colour[3],
const G4double alpha, const G4String& representation,
const G4double scale[3], const G4double rotation[3],
const G4double translation[3])
{
auto transformation = G4Transform3D::Identity;
auto scal = G4Scale3D(scale[0], scale[1], scale[2]);
@@ -702,7 +741,12 @@ void G4VtkViewer::Add3DOverlay(const G4String& fileName, const G4double colour[3
auto& fVtkSceneHandler = dynamic_cast<G4VtkSceneHandler&>(fSceneHandler);
G4VtkStore& st = fVtkSceneHandler.GetTransientStore();
G4VtkVisContext vc = G4VtkVisContext(this, nullptr, false, transformation);
if (representation == "w")
vc.fDrawingStyle = G4ViewParameters::wireframe;
else if (representation == "s")
vc.fDrawingStyle = G4ViewParameters::hlhsr;
vc.alpha = alpha;
vc.red = colour[0];
vc.green = colour[1];