Import Geant4 11.2.0.beta source tree
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// John Allison 5th April 2001
|
||||
// A template for a simplest possible graphics driver.
|
||||
//?? Lines beginning like this require specialisation for your driver.
|
||||
@@ -35,12 +35,13 @@
|
||||
|
||||
#include "G4VGraphicsSystem.hh"
|
||||
|
||||
class G4Vtk: public G4VGraphicsSystem {
|
||||
public:
|
||||
G4Vtk();
|
||||
virtual ~G4Vtk();
|
||||
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
|
||||
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
|
||||
class G4Vtk : public G4VGraphicsSystem
|
||||
{
|
||||
public:
|
||||
G4Vtk();
|
||||
~G4Vtk() override = default;
|
||||
G4VSceneHandler* CreateSceneHandler(const G4String& name = "") override;
|
||||
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "") override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
|
||||
|
||||
#ifndef G4VTKQT_HH
|
||||
#define G4VTKQT_HH
|
||||
|
||||
#include "G4VGraphicsSystem.hh"
|
||||
|
||||
class G4VtkQt: public G4VGraphicsSystem {
|
||||
public:
|
||||
G4VtkQt();
|
||||
virtual ~G4VtkQt();
|
||||
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
|
||||
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
|
||||
G4bool IsUISessionCompatible () const;
|
||||
class G4VtkQt : public G4VGraphicsSystem
|
||||
{
|
||||
public:
|
||||
G4VtkQt();
|
||||
~G4VtkQt() override = default;
|
||||
G4VSceneHandler* CreateSceneHandler(const G4String& name = "") override;
|
||||
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "") override;
|
||||
G4bool IsUISessionCompatible() const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,171 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// John Allison 5th April 2001
|
||||
// A template for a simplest possible graphics driver.
|
||||
//?? Lines or sections marked like this require specialisation for your driver.
|
||||
|
||||
#ifndef G4VTKSCENEHANDLER_HH
|
||||
#define G4VTKSCENEHANDLER_HH
|
||||
|
||||
|
||||
#include "G4VSceneHandler.hh"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "G4VtkViewer.hh"
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wextra-semi"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkLine.h"
|
||||
#include "vtkNamedColors.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkTextProperty.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkActor.h"
|
||||
#include "vtkFollower.h"
|
||||
#include "vtkTextActor.h"
|
||||
#include "vtkBillboardTextActor3D.h"
|
||||
#include "vtkRegularPolygonSource.h"
|
||||
#include "vtkSphereSource.h"
|
||||
#include "vtkFeatureEdges.h"
|
||||
#include "vtkCleanPolyData.h"
|
||||
#include "vtkPolyDataNormals.h"
|
||||
#include "vtkGlyph2D.h"
|
||||
#include "vtkGlyph3D.h"
|
||||
#include "vtkVertexGlyphFilter.h"
|
||||
#include "vtkMatrix4x4.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkPointData.h"
|
||||
#include "vtkTriangleFilter.h"
|
||||
#include "vtkTensorGlyph.h"
|
||||
#include "vtkTensorGlyphColor.h"
|
||||
#include "vtkScalarsToColors.h"
|
||||
#include "vtkImageData.h"
|
||||
#include "vtkVolume.h"
|
||||
#include "vtkOpenGLGPUVolumeRayCastMapper.h"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
class G4VtkSceneHandler: public G4VSceneHandler {
|
||||
friend class G4VtkViewer;
|
||||
|
||||
public:
|
||||
G4VtkSceneHandler(G4VGraphicsSystem& system, const G4String& name);
|
||||
virtual ~G4VtkSceneHandler() = default;
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Required implementation of pure virtual functions...
|
||||
|
||||
void AddPrimitive(const G4Polyline&);
|
||||
void AddPrimitive(const G4Text&);
|
||||
void AddPrimitive(const G4Circle&);
|
||||
void AddPrimitive(const G4Square&);
|
||||
void AddPrimitive(const G4Polyhedron&);
|
||||
void AddPrimitiveTensorGlyph(const G4Polyhedron&);
|
||||
void AddPrimitiveBakedTransform(const G4Polyhedron&);
|
||||
|
||||
// Further optional AddPrimitive methods. Explicitly invoke base
|
||||
// class methods if not otherwise defined to avoid warnings about
|
||||
// hiding of base class methods.
|
||||
void AddPrimitive(const G4Polymarker& polymarker)
|
||||
{
|
||||
#ifdef G4VTKDEBUG
|
||||
G4cout << "=================================" << G4endl;
|
||||
G4cout << "G4VtkSceneHandler::AddPrimitive(const G4Polymarker& polymarker) called." << G4endl;
|
||||
#endif
|
||||
G4VSceneHandler::AddPrimitive (polymarker);
|
||||
}
|
||||
/*
|
||||
void AddPrimitive(const G4Scale& scale)
|
||||
{
|
||||
#ifdef G4VTKDEBUG
|
||||
G4cout << "=================================" << G4endl;
|
||||
G4cout << "G4VtkSceneHandler::AddScale(const G4Scale& scale) called." <<
|
||||
G4endl; #endif G4VSceneHandler::AddPrimitive(scale);
|
||||
}
|
||||
*/
|
||||
|
||||
void AddSolid(const G4Box& box);
|
||||
void AddCompound(const G4Mesh& mesh);
|
||||
|
||||
void Modified();
|
||||
void Clear();
|
||||
|
||||
protected:
|
||||
static G4int fSceneIdCount; // Counter for Vtk scene handlers.
|
||||
|
||||
// maps for polylines
|
||||
std::map<std::size_t, const G4VisAttributes*> polylineVisAttributesMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPoints>> polylineDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkCellArray>> polylineLineMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyData>> polylinePolyDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyDataMapper>> polylinePolyDataMapperMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkActor>> polylinePolyDataActorMap;
|
||||
|
||||
// maps for circles
|
||||
std::map<std::size_t, const G4VisAttributes*> circleVisAttributesMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPoints>> circleDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyData>> circlePolyDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkVertexGlyphFilter>> circleFilterMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyDataMapper>> circlePolyDataMapperMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkActor>> circlePolyDataActorMap;
|
||||
|
||||
// maps for squares
|
||||
std::map<std::size_t, const G4VisAttributes*> squareVisAttributesMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPoints>> squareDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyData>> squarePolyDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkVertexGlyphFilter>> squareFilterMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyDataMapper>> squarePolyDataMapperMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkActor>> squarePolyDataActorMap;
|
||||
|
||||
// map for polyhedra
|
||||
std::map<std::size_t, const G4VisAttributes*> polyhedronVisAttributesMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPoints>> polyhedronDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkCellArray>> polyhedronPolyMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyData>> polyhedronPolyDataMap;
|
||||
std::map<std::size_t, std::size_t> polyhedronPolyDataCountMap;
|
||||
|
||||
// map for polyhedra instances
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPoints>> instancePositionMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkDoubleArray>> instanceRotationMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkDoubleArray>> instanceColoursMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkPolyData>> instancePolyDataMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkTensorGlyphColor>> instanceTensorGlyphMap;
|
||||
std::map<std::size_t, vtkSmartPointer<vtkActor>> instanceActorMap;
|
||||
|
||||
|
||||
private:
|
||||
#ifdef G4VTKDEBUG
|
||||
void PrintThings();
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,194 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// John Allison 5th April 2001
|
||||
// A template for a simplest possible graphics driver.
|
||||
//?? Lines or sections marked like this require specialisation for your driver.
|
||||
|
||||
#ifndef G4VTKVIEWER_HH
|
||||
#define G4VTKVIEWER_HH
|
||||
|
||||
// #define G4VTKDEBUG // Comment this out to suppress debug code.
|
||||
|
||||
#include "G4VViewer.hh"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wextra-semi"
|
||||
#include "vtkObject.h"
|
||||
#include "vtkAutoInit.h"
|
||||
#include "vtkCamera.h"
|
||||
#include "vtkLight.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkRenderWindow.h"
|
||||
#include "vtkRenderWindowInteractor.h"
|
||||
#include "vtkInteractorStyleTrackballCamera.h"
|
||||
#include "vtkInteractorStyleTerrain.h"
|
||||
#include "vtkTextActor.h"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
VTK_MODULE_INIT(vtkRenderingOpenGL2)
|
||||
VTK_MODULE_INIT(vtkInteractionStyle);
|
||||
VTK_MODULE_INIT(vtkRenderingFreeType)
|
||||
|
||||
class vtkGeant4Callback : public vtkCommand
|
||||
{
|
||||
public:
|
||||
static vtkGeant4Callback* New() {return new vtkGeant4Callback;}
|
||||
|
||||
vtkGeant4Callback() { fVP = nullptr; }
|
||||
void SetGeant4ViewParameters(G4ViewParameters *VP) { fVP = VP;}
|
||||
void SetVtkInitialValues(G4double parallelScaleIn, G4double cameraDistanceIn)
|
||||
{
|
||||
parallelScale = parallelScaleIn;
|
||||
cameraDistance = cameraDistanceIn;
|
||||
}
|
||||
virtual void Execute(vtkObject *caller, unsigned long, void*)
|
||||
{
|
||||
vtkRenderer *ren = static_cast<vtkRenderer *>(caller);
|
||||
vtkCamera *cam = ren->GetActiveCamera();
|
||||
//G4cout << cam->GetFocalPoint()[0] << " " << cam->GetFocalPoint()[1] << " " << cam->GetFocalPoint()[2] << G4endl;
|
||||
//
|
||||
// G4cout << cam->GetPosition()[0] << " " << cam->GetPosition()[1] << " " << cam->GetPosition()[2] << G4endl;
|
||||
|
||||
auto cp = cam->GetPosition();
|
||||
auto fp = cam->GetFocalPoint();
|
||||
auto ud = cam->GetViewUp();
|
||||
|
||||
fVP->SetCurrentTargetPoint(G4Point3D(fp[0],fp[1],fp[2]));
|
||||
fVP->SetViewpointDirection((G4Point3D(cp[0],cp[1],cp[2]) -
|
||||
G4Point3D(fp[0],fp[1],fp[2])).unit());
|
||||
fVP->SetUpVector(G4Vector3D(ud[0],ud[1], ud[2]));
|
||||
|
||||
if(cam->GetParallelProjection()) {
|
||||
fVP->SetZoomFactor(parallelScale/cam->GetParallelScale());
|
||||
}
|
||||
else {
|
||||
auto cd = std::sqrt(std::pow(cp[0]-fp[0],2) +
|
||||
std::pow(cp[1]-cp[1],2) +
|
||||
std::pow(cp[2]-cp[2],2));
|
||||
fVP->SetZoomFactor(cameraDistance/cd);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
G4ViewParameters *fVP;
|
||||
G4double parallelScale;
|
||||
G4double cameraDistance;
|
||||
};
|
||||
|
||||
class vtkInfoCallback : public vtkCommand
|
||||
{
|
||||
public:
|
||||
static vtkInfoCallback *New() { return new vtkInfoCallback; }
|
||||
|
||||
vtkInfoCallback() {
|
||||
t1 = std::chrono::steady_clock::now();
|
||||
t2 = std::chrono::steady_clock::now();
|
||||
}
|
||||
void SetTextActor(vtkTextActor *txt) { this->TextActor = txt; }
|
||||
|
||||
virtual void Execute(vtkObject *caller, unsigned long, void*)
|
||||
{
|
||||
vtkRenderer *ren = static_cast<vtkRenderer *>(caller);
|
||||
int nActors = ren->GetActors()->GetNumberOfItems();
|
||||
vtkCamera *cam = ren->GetActiveCamera();
|
||||
if(!cam) return;
|
||||
|
||||
double *pos = cam->GetPosition();
|
||||
double *foc = cam->GetFocalPoint();
|
||||
double viewAngle = cam->GetViewAngle();
|
||||
double distance = cam->GetDistance();
|
||||
double parallelScale = cam->GetParallelScale();
|
||||
|
||||
if(!pos) return;
|
||||
|
||||
// Get current time
|
||||
t2 = std::chrono::steady_clock::now();
|
||||
|
||||
// Frame rate calculation
|
||||
std::chrono::duration<double> tdiff = t2-t1;
|
||||
t1 = t2;
|
||||
float fps = 1.0/tdiff.count();
|
||||
|
||||
// String for display
|
||||
snprintf(this->TextBuff,sizeof this->TextBuff,
|
||||
"camera position : %.1f %.1f %.1f \n"
|
||||
"camera focal point : %.1f %.1f %.1f \n"
|
||||
"view angle : %.1f\n"
|
||||
"distance : %.1f\n"
|
||||
"parallel scale : %.1f\n"
|
||||
"number actors : %i\n"
|
||||
"fps : %.1f",pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, parallelScale, nActors, fps);
|
||||
if(this->TextActor) {
|
||||
this->TextActor->SetInput(this->TextBuff);
|
||||
}
|
||||
}
|
||||
protected:
|
||||
vtkTextActor *TextActor;
|
||||
char TextBuff[256];
|
||||
std::chrono::time_point<std::chrono::steady_clock> t1;
|
||||
std::chrono::time_point<std::chrono::steady_clock> t2;
|
||||
};
|
||||
|
||||
class G4VtkViewer: public G4VViewer {
|
||||
public:
|
||||
G4VtkViewer(G4VSceneHandler&, const G4String& name);
|
||||
void Initialise();
|
||||
virtual ~G4VtkViewer();
|
||||
|
||||
void SetView();
|
||||
void ClearView();
|
||||
void DrawView();
|
||||
void ShowView();
|
||||
void FinishView();
|
||||
|
||||
void DrawViewHUD();
|
||||
void DrawShadows();
|
||||
|
||||
void ExportScreenShot(G4String, G4String);
|
||||
void ExportOBJScene(G4String);
|
||||
void ExportVRMLScene(G4String );
|
||||
void ExportVTPScene(G4String );
|
||||
|
||||
void ExportView(){};
|
||||
void SetGeant4View(){};
|
||||
|
||||
vtkNew<vtkTextActor> infoTextActor;
|
||||
vtkNew<vtkInfoCallback> infoCallback;
|
||||
vtkNew<vtkGeant4Callback> geant4Callback;
|
||||
vtkSmartPointer<vtkLight> light;
|
||||
vtkNew<vtkCamera> camera;
|
||||
vtkNew<vtkRenderer> renderer;
|
||||
vtkRenderWindow* _renderWindow;
|
||||
vtkRenderWindowInteractor* renderWindowInteractor;
|
||||
|
||||
private:
|
||||
G4bool firstSetView = true;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,192 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VVTKPIPELINE_HH
|
||||
#define G4VVTKPIPELINE_HH
|
||||
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4String.hh"
|
||||
#include "G4Types.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4VtkVisContext.hh"
|
||||
|
||||
#include "vtkRenderer.h"
|
||||
|
||||
namespace std
|
||||
{
|
||||
inline void hash_combine(std::size_t) {}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
inline void hash_combine(std::size_t& seed, const T& v, Rest... rest)
|
||||
{
|
||||
std::hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
std::hash_combine(seed, rest...);
|
||||
}
|
||||
|
||||
template<>
|
||||
struct hash<G4String>
|
||||
{
|
||||
std::size_t operator()(const G4String& string) const
|
||||
{
|
||||
using std::hash;
|
||||
using std::size_t;
|
||||
|
||||
std::size_t h = 0;
|
||||
|
||||
for (char const& c : string) {
|
||||
std::hash_combine(h, c);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<G4VisAttributes>
|
||||
{
|
||||
std::size_t operator()(const G4VisAttributes& va) const
|
||||
{
|
||||
using std::hash;
|
||||
using std::size_t;
|
||||
|
||||
std::size_t h = 0;
|
||||
|
||||
std::hash_combine(h, va.IsVisible());
|
||||
std::hash_combine(h, va.IsDaughtersInvisible());
|
||||
std::hash_combine(h, va.GetColour().GetRed());
|
||||
std::hash_combine(h, va.GetColour().GetGreen());
|
||||
std::hash_combine(h, va.GetColour().GetBlue());
|
||||
std::hash_combine(h, va.GetColour().GetAlpha());
|
||||
std::hash_combine(h, static_cast<int>(va.GetLineStyle()));
|
||||
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<G4Polyhedron>
|
||||
{
|
||||
std::size_t operator()(const G4Polyhedron& ph) const
|
||||
{
|
||||
using std::hash;
|
||||
using std::size_t;
|
||||
|
||||
G4bool notLastFace;
|
||||
G4Point3D vertex[4];
|
||||
G4int edgeFlag[4];
|
||||
G4Normal3D normals[4];
|
||||
G4int nEdges;
|
||||
|
||||
std::size_t h = 0;
|
||||
|
||||
do {
|
||||
notLastFace = ph.GetNextFacet(nEdges, vertex, edgeFlag, normals);
|
||||
|
||||
for (int i = 0; i < nEdges; i++) {
|
||||
std::size_t hx = std::hash<double>()(vertex[i].x());
|
||||
std::size_t hy = std::hash<double>()(vertex[i].y());
|
||||
std::size_t hz = std::hash<double>()(vertex[i].z());
|
||||
std::hash_combine(h, hx);
|
||||
std::hash_combine(h, hy);
|
||||
std::hash_combine(h, hz);
|
||||
}
|
||||
} while (notLastFace);
|
||||
|
||||
return h;
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
class G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VVtkPipeline() : name("none"), type("G4VVtkPipeline"), disableParent(false), renderer(nullptr)
|
||||
{}
|
||||
G4VVtkPipeline(G4String nameIn, G4String typeIn, const G4VtkVisContext& vcIn,
|
||||
G4bool disableParentIn = false,
|
||||
vtkSmartPointer<vtkRenderer> rendererIn = nullptr)
|
||||
: name(nameIn), type(typeIn), disableParent(disableParentIn), renderer(rendererIn), vc(vcIn)
|
||||
{}
|
||||
virtual ~G4VVtkPipeline()
|
||||
{
|
||||
for (auto i : childPipelines)
|
||||
delete i;
|
||||
}
|
||||
|
||||
virtual void Enable() = 0;
|
||||
virtual void Disable() = 0;
|
||||
|
||||
virtual void Print()
|
||||
{
|
||||
G4cout << "children (";
|
||||
for (auto i : childPipelines)
|
||||
G4cout << i->GetName() << "-" << i->GetTypeName() << ",";
|
||||
G4cout << ")" << G4endl;
|
||||
};
|
||||
virtual void Modified()
|
||||
{
|
||||
for (auto i : childPipelines)
|
||||
i->Modified();
|
||||
}
|
||||
virtual void Clear()
|
||||
{
|
||||
for (auto i : childPipelines)
|
||||
i->Clear();
|
||||
}
|
||||
|
||||
void SetDisableParent(G4bool disableParentIn) { disableParent = disableParentIn; }
|
||||
bool GetDisableParent() { return disableParent; }
|
||||
|
||||
void SetName(G4String nameIn) { name = nameIn; }
|
||||
const G4String GetName() { return name; }
|
||||
|
||||
void SetTypeName(G4String typeNameIn) { type = typeNameIn; }
|
||||
G4String GetTypeName() { return type; }
|
||||
|
||||
G4VtkVisContext& GetVtkVisContext() { return vc; }
|
||||
|
||||
void AddChildPipeline(G4VVtkPipeline* child)
|
||||
{
|
||||
childPipelines.push_back(child);
|
||||
if (child->GetDisableParent()) {
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
G4VVtkPipeline* GetChildPipeline(G4int iPipeline) { return childPipelines[iPipeline]; }
|
||||
G4int GetNumberOfChildPipelines() { return (G4int)childPipelines.size(); }
|
||||
std::vector<G4VVtkPipeline*> GetChildPipelines() { return childPipelines; }
|
||||
void ClearChildPipeline() { childPipelines.clear(); }
|
||||
|
||||
protected:
|
||||
G4String name;
|
||||
G4String type;
|
||||
G4bool disableParent;
|
||||
std::vector<G4VVtkPipeline*> childPipelines;
|
||||
vtkSmartPointer<vtkRenderer> renderer;
|
||||
G4VtkVisContext vc;
|
||||
};
|
||||
|
||||
#endif // G4VVTKPIPELINE_HH
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKCLIPPERPIPELINE_HH
|
||||
#define G4VTKCLIPPERPIPELINE_HH
|
||||
|
||||
#include "G4VVtkPipeline.hh"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
class G4VtkVisContext;
|
||||
|
||||
class vtkPlane;
|
||||
class vtkPolyDataMapper;
|
||||
class vtkClipClosedSurface;
|
||||
class vtkPolyDataAlgorithm;
|
||||
class vtkActor;
|
||||
|
||||
class G4VtkClipClosedSurfacePipeline : public G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkClipClosedSurfacePipeline(G4String name, const G4VtkVisContext& vc,
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> filter,
|
||||
G4bool useVcColour = false);
|
||||
~G4VtkClipClosedSurfacePipeline() override = default;
|
||||
|
||||
void SetPlane(const G4Plane3D& plane);
|
||||
void SetPlane(G4double x, G4double y, G4double z, G4double nx, G4double ny, G4double nz);
|
||||
void TransformPlane(G4double dx, G4double dy, G4double dz, G4double r00, G4double r01,
|
||||
G4double r02, G4double r10, G4double r11, G4double r12, G4double r20,
|
||||
G4double r21, G4double r22);
|
||||
|
||||
void Enable() override;
|
||||
void Disable() override;
|
||||
|
||||
void Print() override { G4VVtkPipeline::Print(); };
|
||||
void Modified() override { G4VVtkPipeline::Modified(); };
|
||||
void Clear() override
|
||||
{
|
||||
if (renderer != nullptr) {
|
||||
renderer->RemoveActor(actor);
|
||||
}
|
||||
G4VVtkPipeline::Clear();
|
||||
};
|
||||
|
||||
vtkSmartPointer<vtkActor> GetActor() { return actor; }
|
||||
|
||||
private:
|
||||
vtkSmartPointer<vtkPlane> plane;
|
||||
vtkSmartPointer<vtkClipClosedSurface> clipper;
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper;
|
||||
vtkSmartPointer<vtkActor> actor;
|
||||
};
|
||||
|
||||
#endif // G4VTKCLIPPERPIPELINE_HH
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKCLIPOPENPIPELINE_HH
|
||||
#define G4VTKCLIPOPENPIPELINE_HH
|
||||
|
||||
#include "G4VVtkPipeline.hh"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
class G4VtkVisContext;
|
||||
|
||||
class vtkPlane;
|
||||
class vtkClipPolyData;
|
||||
class vtkPolyDataMapper;
|
||||
class vtkPolyDataAlgorithm;
|
||||
class vtkActor;
|
||||
|
||||
class G4VtkClipOpenPipeline : public G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkClipOpenPipeline(G4String name, const G4VtkVisContext& vc,
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> filter, G4bool useVcColour = false);
|
||||
~G4VtkClipOpenPipeline() override = default;
|
||||
|
||||
void SetPlane(G4Plane3D& plane);
|
||||
void SetPlane(G4double x, G4double y, G4double z, G4double nx, G4double ny, G4double nz);
|
||||
void TransformPlane(G4double dx, G4double dy, G4double dz, G4double r00, G4double r01,
|
||||
G4double r02, G4double r10, G4double r11, G4double r12, G4double r20,
|
||||
G4double r21, G4double r22);
|
||||
|
||||
void Enable() override;
|
||||
void Disable() override;
|
||||
|
||||
void Print() override { G4VVtkPipeline::Print(); }
|
||||
void Modified() override { G4VVtkPipeline::Modified(); }
|
||||
void Clear() override
|
||||
{
|
||||
if (renderer != nullptr) {
|
||||
renderer->RemoveActor(actor);
|
||||
}
|
||||
G4VVtkPipeline::Clear();
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkActor> GetActor() { return actor; }
|
||||
|
||||
private:
|
||||
vtkSmartPointer<vtkPlane> plane;
|
||||
vtkSmartPointer<vtkClipPolyData> clipper;
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper;
|
||||
vtkSmartPointer<vtkActor> actor;
|
||||
};
|
||||
|
||||
#endif // G4VTKCLIPOPENPIPELINE_HH
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKCLIPPERCLOSEDPIPELINE_HH
|
||||
#define G4VTKCLIPPERCLOSEDPIPELINE_HH
|
||||
|
||||
#include "G4VtkClipClosedSurfacePipeline.hh"
|
||||
|
||||
class vtkAppendPolyData;
|
||||
|
||||
class G4VtkClipperClosedPipeline : public G4VtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkClipperClosedPipeline(vtkSmartPointer<vtkPolyDataAlgorithm> filter);
|
||||
~G4VtkClipperClosedPipeline() override = default;
|
||||
|
||||
void Print(){};
|
||||
void Modified();
|
||||
void Clear(){};
|
||||
|
||||
private:
|
||||
vtkSmartPointer<vtkPlane> plane;
|
||||
vtkSmartPointer<vtkClipPolyData> clipper;
|
||||
vtkSmartPointer<vtkAppendPolyData> appendFilter;
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper;
|
||||
};
|
||||
|
||||
#endif // G4VTKCLIPPERCLOSEDPIPELINE_HH
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKCUTTERPIPELINE_HH
|
||||
#define G4VTKCUTTERPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataPipeline.hh"
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
|
||||
class vtkPlane;
|
||||
class vtkCutter;
|
||||
class vtkPolyDataMapper;
|
||||
class vtkActor;
|
||||
|
||||
class G4VtkCutterPipeline : public G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkCutterPipeline(G4String name, const G4VtkVisContext& vc,
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> filter, G4bool useVcColour = false);
|
||||
~G4VtkCutterPipeline() override = default;
|
||||
|
||||
void SetPlane(const G4Plane3D& plane);
|
||||
void SetPlane(G4double x, G4double y, G4double z, G4double nx, G4double ny, G4double nz);
|
||||
void TransformPlane(G4double dx, G4double dy, G4double dz, G4double r00, G4double r01,
|
||||
G4double r02, G4double r10, G4double r11, G4double r12, G4double r20,
|
||||
G4double r21, G4double r22);
|
||||
|
||||
void Enable() override;
|
||||
void Disable() override;
|
||||
|
||||
void Print() override { G4VVtkPipeline::Print(); }
|
||||
void Modified() override { G4VVtkPipeline::Modified(); }
|
||||
void Clear() override
|
||||
{
|
||||
if (renderer != nullptr) {
|
||||
renderer->RemoveActor(actor);
|
||||
}
|
||||
G4VVtkPipeline::Clear();
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkActor> GetActor() { return actor; }
|
||||
|
||||
private:
|
||||
vtkSmartPointer<vtkPlane> plane;
|
||||
vtkSmartPointer<vtkCutter> cutter;
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper;
|
||||
vtkSmartPointer<vtkActor> actor;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKIMAGEPIPELINE_HH
|
||||
#define G4VTKIMAGEPIPELINE_HH
|
||||
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4Types.hh"
|
||||
#include "G4VVtkPipeline.hh"
|
||||
|
||||
#include "vtkImageData.h"
|
||||
#include "vtkImageReader2.h"
|
||||
#include "vtkImageReader2Factory.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class vtkImageAlgorithm;
|
||||
class vtkImageActor;
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
|
||||
class G4VtkImagePipeline : G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkImagePipeline(const G4String& name, const G4VtkVisContext& vc);
|
||||
~G4VtkImagePipeline() override = default;
|
||||
void AddFilter(vtkSmartPointer<vtkImageAlgorithm> f) { filters.push_back(f); }
|
||||
vtkSmartPointer<vtkImageAlgorithm> GetFilter(G4int iFilter) { return filters[iFilter]; }
|
||||
vtkSmartPointer<vtkImageAlgorithm> GetFinalFilter() { return *filters.end(); }
|
||||
|
||||
void AddChildPipeline(G4VtkImagePipeline* child)
|
||||
{
|
||||
childPipelines.push_back(child);
|
||||
if (child->GetDisableParent()) {
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
G4VtkImagePipeline* GetChildPipeline(G4int iPipeline) { return childPipelines[iPipeline]; }
|
||||
|
||||
virtual void SetImage(const G4String& fileName);
|
||||
virtual void SetTransformation(const G4Transform3D& transformation);
|
||||
|
||||
void Print() override;
|
||||
void Modified() override;
|
||||
void Clear() override;
|
||||
|
||||
virtual vtkSmartPointer<vtkImageActor> GetActor() { return actor; }
|
||||
|
||||
void Disable() override;
|
||||
void Enable() override;
|
||||
|
||||
private:
|
||||
std::vector<vtkSmartPointer<vtkImageAlgorithm>>
|
||||
filters; // derived types can store filters in this vector
|
||||
std::vector<G4VtkImagePipeline*> childPipelines;
|
||||
vtkSmartPointer<vtkImageActor> actor; // all pipelines require an actor
|
||||
};
|
||||
|
||||
#endif // G4VTKIMAGEPIPELINE_HH
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Created by Stewart Boogert on 28/02/2023.
|
||||
//
|
||||
|
||||
#ifndef G4VTKINTERACTORSTYLE_HH
|
||||
#define G4VTKINTERACTORSTYLE_HH
|
||||
|
||||
#include "vtkInteractionStyleModule.h" // For export macro
|
||||
#include "vtkInteractorStyleTrackballCamera.h"
|
||||
#include <vtkObjectFactory.h>
|
||||
|
||||
// Define interaction style
|
||||
class VTKINTERACTIONSTYLE_EXPORT G4VtkInteractorStyle : public vtkInteractorStyleTrackballCamera
|
||||
{
|
||||
public:
|
||||
static G4VtkInteractorStyle* New();
|
||||
vtkTypeMacro(G4VtkInteractorStyle, vtkInteractorStyleTrackballCamera)
|
||||
|
||||
void OnLeftButtonDown() override
|
||||
{
|
||||
// Forward events
|
||||
vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
|
||||
}
|
||||
|
||||
void OnMiddleButtonDown() override
|
||||
{
|
||||
// Forward events
|
||||
vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
|
||||
}
|
||||
|
||||
void OnRightButtonDown() override
|
||||
{
|
||||
// Forward events
|
||||
vtkInteractorStyleTrackballCamera::OnRightButtonDown();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // G4VTKINTERACTORSTYLE_HH
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4GVTKMESSENGER_HH
|
||||
#define G4GVTKMESSENGER_HH 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithABool;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcommand;
|
||||
class G4UIcmdWithoutParameter;
|
||||
|
||||
class G4VtkMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
static G4VtkMessenger* GetInstance();
|
||||
~G4VtkMessenger() override;
|
||||
|
||||
G4String GetCurrentValue(G4UIcommand* command) override;
|
||||
void SetNewValue(G4UIcommand* command, G4String newValue) override;
|
||||
|
||||
private:
|
||||
static G4VtkMessenger* fpInstance;
|
||||
G4VtkMessenger();
|
||||
|
||||
G4UIdirectory* fpDirectory;
|
||||
G4UIcommand* fpCommandClearNonG4;
|
||||
G4UIcommand* fpCommandExport;
|
||||
G4UIcommand* fpCommandExportCutter;
|
||||
G4UIcommand* fpCommandDebugPrint;
|
||||
|
||||
G4UIdirectory* fpDirectorySet;
|
||||
G4UIcommand* fpCommandPolyhedronPipeline;
|
||||
G4UIcmdWithABool* fpCommandWarnings;
|
||||
G4UIcmdWithABool* fpCommandHUD;
|
||||
G4UIcommand* fpCommandClipper;
|
||||
G4UIcommand* fpCommandCutter;
|
||||
G4UIcommand* fpCommandShadow;
|
||||
|
||||
G4UIdirectory* fpDirectoryAdd;
|
||||
G4UIcommand* fpCommandImageOverlay;
|
||||
};
|
||||
|
||||
#endif
|
||||
+6
-23
@@ -22,28 +22,11 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Created by Stewart Boogert on 27/02/2023.
|
||||
//
|
||||
|
||||
#ifndef G4VTKQTSCENEHANDLER_HH
|
||||
#define G4VTKQTSCENEHANDLER_HH
|
||||
#ifndef GEANT4_G4VTKPOLYDATACUBEPIPELINE_HH
|
||||
#define GEANT4_G4VTKPOLYDATACUBEPIPELINE_HH
|
||||
|
||||
|
||||
#include "G4VSceneHandler.hh"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "G4VtkQtViewer.hh"
|
||||
#include "G4VtkSceneHandler.hh"
|
||||
|
||||
class G4VtkQtSceneHandler: public G4VtkSceneHandler {
|
||||
friend class G4VtkQtViewer;
|
||||
|
||||
public:
|
||||
G4VtkQtSceneHandler(G4VGraphicsSystem& system, const G4String& name);
|
||||
virtual ~G4VtkQtSceneHandler();
|
||||
|
||||
protected:
|
||||
static G4int fSceneIdCount; // Counter for Vtk scene handlers.
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // GEANT4_G4VTKPOLYDATACUBEPIPELINE_HH
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKPOLYDATAINSTANCEAPPENDPIPELINE_HH
|
||||
#define G4VTKPOLYDATAINSTANCEAPPENDPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataInstancePipeline.hh"
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
|
||||
class vtkTransformPolyDataFilter;
|
||||
class vtkAppendPolyData;
|
||||
|
||||
class G4VtkPolydataInstanceAppendPipeline : public G4VtkPolydataInstancePipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataInstanceAppendPipeline(G4String name, const G4VtkVisContext& vc);
|
||||
~G4VtkPolydataInstanceAppendPipeline() override = default;
|
||||
|
||||
void Print() override;
|
||||
|
||||
void 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) override;
|
||||
void removeInstance(const G4String& name) override;
|
||||
|
||||
static std::size_t MakeHash(const G4Polyhedron& p, const G4VtkVisContext& vc);
|
||||
|
||||
protected:
|
||||
std::map<G4String, vtkSmartPointer<vtkTransformPolyDataFilter>> transformFilterMap;
|
||||
vtkSmartPointer<vtkAppendPolyData> appendFilter;
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATAINSTANCEAPPENDPIPELINE_HH
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKPOLYDATAINSTANCEBAKEPIPELINE_HH
|
||||
#define G4VTKPOLYDATAINSTANCEBAKEPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataInstancePipeline.hh"
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
|
||||
class G4VtkPolydataInstanceBakePipeline : public G4VtkPolydataInstancePipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataInstanceBakePipeline(G4String name, const G4VtkVisContext& vc);
|
||||
~G4VtkPolydataInstanceBakePipeline() override = default;
|
||||
|
||||
void Print() override;
|
||||
|
||||
void SetPolydata(const G4Polyhedron& polyhedron) override;
|
||||
void 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) override;
|
||||
void removeInstance(const G4String& name) override;
|
||||
|
||||
static std::size_t MakeHash(const G4Polyhedron& p, const G4VtkVisContext& vc);
|
||||
|
||||
protected:
|
||||
// point colour data
|
||||
vtkSmartPointer<vtkDoubleArray> polydataPointData;
|
||||
|
||||
// prototype of single polyhedron
|
||||
const G4Polyhedron* polyhedronPrototype;
|
||||
|
||||
// counters as the final polydata is built
|
||||
G4int iVert;
|
||||
G4int iFace;
|
||||
|
||||
// maps to keep indicies for rebuild
|
||||
std::map<G4String, std::pair<vtkIdType, vtkIdType>> instanceVertexMap;
|
||||
std::map<G4String, std::pair<vtkIdType, vtkIdType>> instanceFaceMap;
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATAINSTANCEBAKEPIPELINE_HH
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKPOLYDATAINSTANCEPIPELINE_HH
|
||||
#define G4VTKPOLYDATAINSTANCEPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataPipeline.hh"
|
||||
|
||||
#include <map>
|
||||
|
||||
class vtkPoints;
|
||||
class vtkDoubleArray;
|
||||
|
||||
class G4VtkPolydataInstancePipeline : public G4VtkPolydataPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataInstancePipeline(G4String name, const G4VtkVisContext& vc);
|
||||
~G4VtkPolydataInstancePipeline() override = default;
|
||||
|
||||
virtual void 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);
|
||||
virtual void 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);
|
||||
virtual void removeInstance(const G4String& name);
|
||||
|
||||
protected:
|
||||
vtkSmartPointer<vtkDoubleArray> instanceColour;
|
||||
vtkSmartPointer<vtkPoints> instancePosition;
|
||||
vtkSmartPointer<vtkDoubleArray> instanceTransform;
|
||||
std::map<G4String, vtkIdType> instanceMap;
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATAINSTANCEPIPELINE_HH
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKPOLYDATAINSTANCETENSORPIPELINE_HH
|
||||
#define G4VTKPOLYDATAINSTANCETENSORPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataInstancePipeline.hh"
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
class vtkTensorGlyphColor;
|
||||
|
||||
class G4VtkPolydataInstanceTensorPipeline : public G4VtkPolydataInstancePipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataInstanceTensorPipeline(G4String name, const G4VtkVisContext& vc);
|
||||
~G4VtkPolydataInstanceTensorPipeline() override = default;
|
||||
|
||||
void Print() override;
|
||||
|
||||
static std::size_t MakeHash(const G4Polyhedron& p, const G4VtkVisContext& vc);
|
||||
|
||||
protected:
|
||||
vtkSmartPointer<vtkPolyData> instancePolydata;
|
||||
vtkSmartPointer<vtkTensorGlyphColor> instanceTensorGlyph;
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATAINSTANCETENSORPIPELINE_HH
|
||||
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKPOLYDATAPIPELINE_HH
|
||||
#define G4VTKPOLYDATAPIPELINE_HH
|
||||
|
||||
#include "G4Point3D.hh"
|
||||
#include "G4VVtkPipeline.hh"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
class G4Polyhedron;
|
||||
class G4Polyline;
|
||||
|
||||
class vtkPoints;
|
||||
class vtkCellArray;
|
||||
class vtkPolyData;
|
||||
class vtkPolyDataAlgorithm;
|
||||
class vtkPolyDataMapper;
|
||||
class vtkActor;
|
||||
|
||||
class G4VtkPolydataPipeline : public G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataPipeline(G4String name, const G4VtkVisContext& vc);
|
||||
~G4VtkPolydataPipeline() override = default;
|
||||
|
||||
void AddFilter(vtkSmartPointer<vtkPolyDataAlgorithm> f) { filters.push_back(f); }
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> GetFilter(G4int iFilter) { return filters[iFilter]; }
|
||||
G4int GetNumberOfFilters() { return (G4int)filters.size(); }
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> GetFinalFilter() { return filters[filters.size() - 1]; }
|
||||
|
||||
void Enable() override;
|
||||
void Disable() override;
|
||||
|
||||
void Print() override;
|
||||
void Modified() override;
|
||||
void Clear() override;
|
||||
|
||||
virtual vtkSmartPointer<vtkActor> GetActor() { return actor; }
|
||||
|
||||
virtual void SetPolydata(const G4Polyhedron& polyhedron);
|
||||
virtual void SetPolydata(const G4Polyline& polyline);
|
||||
virtual void SetPolydataData(const G4Point3D& p);
|
||||
virtual void SetPolydataData(double x, double y, double z);
|
||||
|
||||
virtual void SetActorTransform(G4double dx, G4double dy, G4double dz, G4double r00,
|
||||
G4double r01, G4double r02, G4double r10, G4double r11,
|
||||
G4double r12, G4double r20, G4double r21, G4double r22);
|
||||
virtual void SetActorColour(G4double r, G4double g, G4double b, G4double a);
|
||||
|
||||
virtual vtkSmartPointer<vtkPolyData> GetPolydata() { return polydata; }
|
||||
|
||||
virtual G4double* GetBounds() { return actor->GetBounds(); }
|
||||
|
||||
static std::size_t MakeHash(const G4Polyhedron& p, const G4VtkVisContext& vc);
|
||||
|
||||
protected:
|
||||
vtkSmartPointer<vtkPoints> polydataPoints;
|
||||
vtkSmartPointer<vtkCellArray> polydataCells;
|
||||
vtkSmartPointer<vtkPolyData> polydata;
|
||||
|
||||
std::vector<vtkSmartPointer<vtkPolyDataAlgorithm>>
|
||||
filters; // derived types can store filters in this vector
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper; // polydagta mapper
|
||||
vtkSmartPointer<vtkActor> actor; // all pipelines require an actor
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATAPIPELINE_HH
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4POLYDATAPOLYGONPIPELINE_HH
|
||||
#define G4POLYDATAPOLYGONPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataPipeline.hh"
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
class G4VisAttributes;
|
||||
|
||||
class G4VtkPolydataPolygonPipeline : public G4VtkPolydataPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataPolygonPipeline(G4String name, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVA);
|
||||
~G4VtkPolydataPolygonPipeline() override = default;
|
||||
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
};
|
||||
|
||||
#endif // GEANT4_G4POLYDATAPOLYGONPIPELINE_HH
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKPOLYDATAPOLYLINE2DPIPELINE_HH
|
||||
#define G4VTKPOLYDATAPOLYLINE2DPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataPipeline.hh"
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
class G4VisAttributes;
|
||||
class G4Polyline;
|
||||
|
||||
class vtkPolyDataMapper2D;
|
||||
class vtkActor2D;
|
||||
|
||||
class G4VtkPolydataPolyline2DPipeline : public G4VtkPolydataPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataPolyline2DPipeline(G4String name, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVA);
|
||||
~G4VtkPolydataPolyline2DPipeline() override = default;
|
||||
|
||||
void Modified() override;
|
||||
void SetPolydata(const G4Polyline& polyline) override;
|
||||
|
||||
vtkSmartPointer<vtkActor2D> GetActor2D() { return actor2D; }
|
||||
|
||||
void Clear() override;
|
||||
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
vtkSmartPointer<vtkPolyDataMapper2D> mapper2D;
|
||||
vtkSmartPointer<vtkActor2D> actor2D;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKPOLYDATAPOLYLINEPIPELINE_HH
|
||||
#define G4VTKPOLYDATAPOLYLINEPIPELINE_HH
|
||||
|
||||
#include "G4VtkPolydataPipeline.hh"
|
||||
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
class G4VisAttributes;
|
||||
|
||||
class G4VtkPolydataPolylinePipeline : public G4VtkPolydataPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataPolylinePipeline(G4String name, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVA);
|
||||
~G4VtkPolydataPolylinePipeline() override = default;
|
||||
|
||||
void Print() override;
|
||||
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATAPOLYLINEPIPELINE_HH
|
||||
+17
-23
@@ -23,34 +23,28 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4GVTKMESSENGER_HH
|
||||
#define G4GVTKMESSENGER_HH 1
|
||||
#ifndef G4VTKPOLYDATASPHEREPIPELINE_HH
|
||||
#define G4VTKPOLYDATASPHEREPIPELINE_HH
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include <vector>
|
||||
#include "G4VtkPolydataPipeline.hh"
|
||||
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithABool;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcommand;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4String;
|
||||
class G4VtkVisContext;
|
||||
class G4VisAttributes;
|
||||
|
||||
class G4VtkMessenger : public G4UImessenger {
|
||||
class G4VtkPolydataSpherePipeline : public G4VtkPolydataPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkPolydataSpherePipeline(G4String name, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVA);
|
||||
~G4VtkPolydataSpherePipeline() override = default;
|
||||
|
||||
public:
|
||||
void Print() override;
|
||||
|
||||
static G4VtkMessenger* GetInstance();
|
||||
virtual ~G4VtkMessenger();
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
virtual G4String GetCurrentValue(G4UIcommand * command);
|
||||
virtual void SetNewValue(G4UIcommand * command, G4String newValue);
|
||||
|
||||
private:
|
||||
static G4VtkMessenger* fpInstance;
|
||||
G4VtkMessenger();
|
||||
G4UIdirectory* fpDirectory;
|
||||
G4UIcommand* fpCommandExport;
|
||||
G4UIcmdWithABool* fpCommandWarnings;
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // G4VTKPOLYDATASPHEREPIPELINE_HH
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKQTSCENEHANDLER_HH
|
||||
#define G4VTKQTSCENEHANDLER_HH
|
||||
|
||||
#include "G4VSceneHandler.hh"
|
||||
#include "G4VtkQtViewer.hh"
|
||||
#include "G4VtkSceneHandler.hh"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class G4VtkQtSceneHandler : public G4VtkSceneHandler
|
||||
{
|
||||
public:
|
||||
G4VtkQtSceneHandler(G4VGraphicsSystem& system, const G4String& name);
|
||||
~G4VtkQtSceneHandler() override = default;
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Implementation of pure virtual functions...
|
||||
void AddPrimitive(const G4Polyline&) override;
|
||||
void AddPrimitive(const G4Text&) override;
|
||||
void AddPrimitive(const G4Circle&) override;
|
||||
void AddPrimitive(const G4Square&) override;
|
||||
void AddPrimitive(const G4Polyhedron&) override;
|
||||
|
||||
protected:
|
||||
static G4int fSceneIdCount; // Counter for Vtk scene handlers.
|
||||
|
||||
private:
|
||||
friend class G4VtkQtViewer;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKQTVIEWER_HH
|
||||
#define G4VTKQTVIEWER_HH
|
||||
|
||||
// #define G4VTKDEBUG // Comment this out to suppress debug code.
|
||||
|
||||
#include "G4VViewer.hh"
|
||||
|
||||
class G4UIManager;
|
||||
class G4UIQt;
|
||||
|
||||
class QString;
|
||||
class QWidget;
|
||||
class QLineEdit;
|
||||
class QSlider;
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
#include "G4VtkViewer.hh"
|
||||
|
||||
#include "QVTKOpenGLNativeWidget.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class G4VtkQtViewer : public QVTKOpenGLNativeWidget, public G4VtkViewer
|
||||
{
|
||||
public:
|
||||
using PVNodeID = G4PhysicalVolumeModel::G4PhysicalVolumeNodeID;
|
||||
using PVPath = std::vector<PVNodeID>;
|
||||
|
||||
public:
|
||||
G4VtkQtViewer(G4VSceneHandler&, const G4String& name);
|
||||
~G4VtkQtViewer() override;
|
||||
void Initialise() override;
|
||||
virtual void CreateMainWindow(QVTKOpenGLNativeWidget*, const QString&);
|
||||
#ifdef G4MULTITHREADED
|
||||
// In MT mode these functions are called in the following order for each run:
|
||||
// Called on the master thread before starting the vis sub-thread.
|
||||
void DoneWithMasterThread() override;
|
||||
// Called on the master thread after starting the vis sub-thread.
|
||||
void MovingToVisSubThread() override;
|
||||
// Called on the vis sub-thread when waiting for events.
|
||||
void SwitchToVisSubThread() override;
|
||||
// Called on the vis sub-thread when all events have been processed.
|
||||
void DoneWithVisSubThread() override;
|
||||
// Called on the vis sub-thread when all events have been processed.
|
||||
// virtual void MovingToMasterThread (); Not used in G4OpenGLQtViewer.
|
||||
// Called on the master thread after the vis sub-thread has terminated.
|
||||
void SwitchToMasterThread() override;
|
||||
|
||||
inline void SetQGLContextVisSubThread(QThread* th) { fQGLContextVisSubThread = th; }
|
||||
inline void SetQGLContextMainThread(QThread* th) { fQGLContextMainThread = th; }
|
||||
#endif
|
||||
|
||||
void FinishView() override;
|
||||
void createSceneTreeWidget();
|
||||
void createSceneTreeComponent();
|
||||
QTreeWidgetItem* createTreeWidgetItem(const PVPath& fullPath, const QString& name, int copyNb,
|
||||
int POIndex, const QString& logicalName,
|
||||
Qt::CheckState state, QTreeWidgetItem* parentTreeNode,
|
||||
const G4Colour& color);
|
||||
void addNonPVSceneTreeElement(const G4String& model, G4Visible& visible, int currentPOIndex);
|
||||
void addPVSceneTreeElement(const G4String& model, G4PhysicalVolumeModel* pPVModel,
|
||||
int currentPOIndex);
|
||||
|
||||
QString getModelShortName(const G4String& model);
|
||||
bool parseAndInsertInSceneTree(QTreeWidgetItem* parentItem, G4PhysicalVolumeModel* pPVModel,
|
||||
unsigned int fullPathIndex, const QString& parentRoot,
|
||||
unsigned int currentIndexInTreeSceneHandler,
|
||||
int currentPVPOIndex);
|
||||
|
||||
void EnableClipperWidget() override;
|
||||
|
||||
void SetWidgetInteractor(vtkAbstractWidget* widget) override;
|
||||
|
||||
private:
|
||||
G4UIQt* fUiQt;
|
||||
QWidget* fGLWidget;
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
QThread* fQGLContextVisSubThread;
|
||||
QThread* fQGLContextMainThread;
|
||||
#endif
|
||||
|
||||
// safe to use in serial mode
|
||||
G4AutoLock* lWaitForVisSubThreadQtOpenGLContextInitialized;
|
||||
G4AutoLock* lWaitForVisSubThreadQtOpenGLContextMoved;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,125 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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.
|
||||
|
||||
#ifndef G4VTKSCENEHANDLER_HH
|
||||
#define G4VTKSCENEHANDLER_HH
|
||||
|
||||
#include "G4VSceneHandler.hh"
|
||||
#include "G4VtkStore.hh"
|
||||
#include "G4VtkViewer.hh"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wextra-semi"
|
||||
#include "vtkActor.h"
|
||||
#include "vtkBillboardTextActor3D.h"
|
||||
#include "vtkCleanPolyData.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkFeatureEdges.h"
|
||||
#include "vtkFollower.h"
|
||||
#include "vtkGlyph2D.h"
|
||||
#include "vtkGlyph3D.h"
|
||||
#include "vtkImageData.h"
|
||||
#include "vtkLine.h"
|
||||
#include "vtkMatrix4x4.h"
|
||||
#include "vtkNamedColors.h"
|
||||
#include "vtkOpenGLGPUVolumeRayCastMapper.h"
|
||||
#include "vtkPointData.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkPolyDataNormals.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkRegularPolygonSource.h"
|
||||
#include "vtkScalarsToColors.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkSphereSource.h"
|
||||
#include "vtkTensorGlyph.h"
|
||||
#include "vtkTensorGlyphColor.h"
|
||||
#include "vtkTextActor.h"
|
||||
#include "vtkTextProperty.h"
|
||||
#include "vtkTriangleFilter.h"
|
||||
#include "vtkVertexGlyphFilter.h"
|
||||
#include "vtkVolume.h"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
class G4VtkSceneHandler : public G4VSceneHandler
|
||||
{
|
||||
public:
|
||||
G4VtkSceneHandler(G4VGraphicsSystem& system, const G4String& name);
|
||||
~G4VtkSceneHandler() override = default;
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Required implementation of pure virtual functions...
|
||||
|
||||
void AddPrimitive(const G4Polyline&) override;
|
||||
void AddPrimitive(const G4Text&) override;
|
||||
void AddPrimitive(const G4Circle&) override;
|
||||
void AddPrimitive(const G4Square&) override;
|
||||
void AddPrimitive(const G4Polyhedron&) override;
|
||||
|
||||
// Further optional AddPrimitive methods. Explicitly invoke base
|
||||
// class methods if not otherwise defined to avoid warnings about
|
||||
// hiding of base class methods.
|
||||
void AddPrimitive(const G4Polymarker& polymarker) override
|
||||
{
|
||||
G4VSceneHandler::AddPrimitive(polymarker);
|
||||
}
|
||||
|
||||
void AddSolid(const G4Box& box) override;
|
||||
void AddCompound(const G4Mesh& mesh) override;
|
||||
|
||||
void Modified();
|
||||
void ClearStore() override;
|
||||
void ClearTransientStore() override;
|
||||
G4VtkVisContext MakeDefaultVisContext();
|
||||
G4VtkStore& GetStore() { return store; }
|
||||
G4VtkStore& GetTransientStore() { return transientStore; }
|
||||
|
||||
virtual void Print();
|
||||
|
||||
void SetPolyhedronPipeline(const G4String& str);
|
||||
|
||||
protected:
|
||||
static G4int fSceneIdCount; // Counter for Vtk scene handlers.
|
||||
|
||||
G4VtkStore store = G4VtkStore("perm");
|
||||
G4VtkStore transientStore = G4VtkStore("trans");
|
||||
|
||||
G4String polyhedronPipelineType;
|
||||
|
||||
private:
|
||||
friend class G4VtkViewer;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Created by Stewart Boogert on 13/11/2021.
|
||||
//
|
||||
|
||||
#ifndef G4VTKSTORE_HH
|
||||
#define G4VTKSTORE_HH
|
||||
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4ViewParameters.hh"
|
||||
|
||||
#include "vtkActor.h"
|
||||
#include "vtkActor2D.h"
|
||||
#include "vtkCellArray.h"
|
||||
#include "vtkCellData.h"
|
||||
#include "vtkCleanPolyData.h"
|
||||
#include "vtkClipClosedSurface.h"
|
||||
#include "vtkClipPolyData.h"
|
||||
#include "vtkDataSetMapper.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkFeatureEdges.h"
|
||||
#include "vtkNamedColors.h"
|
||||
#include "vtkPlane.h"
|
||||
#include "vtkPlaneCollection.h"
|
||||
#include "vtkPointData.h"
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkPolyDataAlgorithm.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkPolyDataMapper2D.h"
|
||||
#include "vtkPolyDataNormals.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkStripper.h"
|
||||
#include "vtkStructuredGrid.h"
|
||||
#include "vtkTensorGlyphColor.h"
|
||||
#include "vtkTriangleFilter.h"
|
||||
#include "vtkVertexGlyphFilter.h"
|
||||
#include <vtkSmartPointer.h>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class G4VViewer;
|
||||
class G4VtkViewer;
|
||||
class G4Polyline;
|
||||
class G4Text;
|
||||
class G4Circle;
|
||||
class G4Square;
|
||||
class G4Polyhedron;
|
||||
class G4VisAttributes;
|
||||
class G4VtkVisContext;
|
||||
class G4Mesh;
|
||||
|
||||
class G4VtkPolydataPipeline;
|
||||
class G4VtkPolydataPolylinePipeline;
|
||||
class G4VtkPolydataPolyline2DPipeline;
|
||||
class G4VtkPolydataSpherePipeline;
|
||||
class G4VtkPolydataPolygonPipeline;
|
||||
class G4VtkPolydataInstanceTensorPipeline;
|
||||
class G4VtkPolydataInstanceAppendPipeline;
|
||||
class G4VtkPolydataInstanceBakePipeline;
|
||||
class G4VtkClipCloseSurfacePipeline;
|
||||
class G4VtkImagePipeline;
|
||||
class G4VtkTextPipeline;
|
||||
class G4VtkText2DPipeline;
|
||||
class G4VtkUnstructuredGridPipeline;
|
||||
|
||||
template<typename>
|
||||
class vtkSmartPointer;
|
||||
|
||||
class G4VtkTensorGlyphPolydataPipeline;
|
||||
|
||||
class G4VtkStore
|
||||
{
|
||||
public:
|
||||
G4VtkStore(G4String name);
|
||||
~G4VtkStore();
|
||||
|
||||
void Modified();
|
||||
void Clear();
|
||||
void ClearNonG4();
|
||||
void Print();
|
||||
|
||||
void AddPrimitive(const G4Polyline& polyline, const G4VtkVisContext& vc);
|
||||
void AddPrimitive(const G4Text& text, const G4VtkVisContext& vc);
|
||||
void AddPrimitive(const G4Circle& circle, const G4VtkVisContext& vc);
|
||||
void AddPrimitive(const G4Square& square, const G4VtkVisContext& vc);
|
||||
void AddPrimitiveSeparate(const G4Polyhedron& polyhedron, const G4VtkVisContext& vc);
|
||||
void AddPrimitiveTensorGlyph(const G4Polyhedron& polyhedron, const G4VtkVisContext& vc);
|
||||
void AddPrimitiveAppend(const G4Polyhedron& polyhedron, const G4VtkVisContext& vc);
|
||||
void AddPrimitiveTransformBake(const G4Polyhedron& polyhedron, const G4VtkVisContext& vc);
|
||||
void AddCompound(const G4Mesh& mesh, const G4VtkVisContext& vc);
|
||||
|
||||
void UpdatePlanePipelines(G4String name, G4String type, const G4Plane3D);
|
||||
|
||||
void AddClipper(G4String name, const G4Plane3D& plane);
|
||||
void UpdateClipper(G4String name, const G4Plane3D& plane);
|
||||
void RemoveClipper(G4String name);
|
||||
|
||||
void AddCutter(G4String name, const G4Plane3D& plane);
|
||||
void UpdateCutter(G4String name, const G4Plane3D& plane);
|
||||
void RemoveCutter(G4String name);
|
||||
|
||||
void AddNonG4ObjectImage(const G4String& fileName, const G4VtkVisContext& vc);
|
||||
void AddNonG4ObjectPolydata(const G4String fileName, const G4VtkVisContext& vc);
|
||||
|
||||
void GetBounds(G4double maxBound[6]);
|
||||
|
||||
void AddToRenderer(vtkRenderer* renderer);
|
||||
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPolylinePipeline>>& GetPolylinePipeMap()
|
||||
{
|
||||
return polylinePipeMap;
|
||||
}
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPolyline2DPipeline>>& GetPolyline2DPipeMap()
|
||||
{
|
||||
return polyline2DPipeMap;
|
||||
}
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataSpherePipeline>>& GetPolydataSpherePipeMap()
|
||||
{
|
||||
return circlePipeMap;
|
||||
}
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPolygonPipeline>>&
|
||||
GetPolydataPolygonPipeMap()
|
||||
{
|
||||
return squarePipeMap;
|
||||
}
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPipeline>>& GetSeparatePipeMap()
|
||||
{
|
||||
return separatePipeMap;
|
||||
}
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataInstanceTensorPipeline>>& GetTensorPipeMap()
|
||||
{
|
||||
return tensorGlyphPipeMap;
|
||||
}
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataInstanceAppendPipeline>>& GetAppendPipeMap()
|
||||
{
|
||||
return appendPipeMap;
|
||||
}
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataInstanceBakePipeline>>& GetBakePipeMap()
|
||||
{
|
||||
return bakePipeMap;
|
||||
}
|
||||
|
||||
private:
|
||||
G4String name;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPolylinePipeline>> polylinePipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPolyline2DPipeline>> polyline2DPipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataSpherePipeline>> circlePipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPolygonPipeline>> squarePipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkTextPipeline>> textPipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkText2DPipeline>> text2DPipeMap;
|
||||
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPipeline>> separatePipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataInstanceTensorPipeline>> tensorGlyphPipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataInstanceAppendPipeline>> appendPipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataInstanceBakePipeline>> bakePipeMap;
|
||||
|
||||
std::map<G4String, std::shared_ptr<G4VtkUnstructuredGridPipeline>> ugridPipeMap;
|
||||
|
||||
std::map<G4String, std::shared_ptr<G4VtkImagePipeline>> imagePipeMap;
|
||||
std::map<std::size_t, std::shared_ptr<G4VtkPolydataPipeline>> sideloadPipeMap;
|
||||
};
|
||||
|
||||
#endif // G4VTKSTORE_HH
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Created by Stewart Boogert on 28/02/2023.
|
||||
//
|
||||
|
||||
#ifndef G4VTKGRIDPIPELINE_HH
|
||||
#define G4VTKGRIDPIPELINE_HH
|
||||
|
||||
class G4VtkStructuredGridPipeline
|
||||
{
|
||||
G4VtkStructuredGridPipeline(G4int nxIn, G4int nyIn, G4int nzIn) : nx(nxIn), ny(nyIn), nz(nzIn)
|
||||
{
|
||||
structuredGrid->SetDimensions(nx, ny, nz);
|
||||
structuredGrid->SetPoints(points);
|
||||
structuredGrid->GetCellData()->SetScalars(cellValues);
|
||||
structuredGrid->GetPointData()->SetScalars(pointValues);
|
||||
|
||||
mapper->SetInputData(structuredGrid);
|
||||
actor->SetMapper(mapper);
|
||||
}
|
||||
|
||||
void Modified(){};
|
||||
void Clear(){};
|
||||
void Print(){};
|
||||
|
||||
G4int nx, ny, nz;
|
||||
vtkSmartPointer<vtkPoints> points;
|
||||
vtkSmartPointer<vtkDoubleArray> pointValues;
|
||||
vtkSmartPointer<vtkDoubleArray> cellValues;
|
||||
vtkSmartPointer<vtkStructuredGrid> structuredGrid;
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper;
|
||||
vtkSmartPointer<vtkActor> actor;
|
||||
};
|
||||
|
||||
#endif // G4VTKGRIDPIPELINE_HH
|
||||
@@ -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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Created by Stewart Boogert on 05/03/2023.
|
||||
//
|
||||
|
||||
#ifndef G4VTKTEXT2DPIPELINE_HH
|
||||
#define G4VTKTEXT2DPIPELINE_HH
|
||||
|
||||
#include "G4VVtkPipeline.hh"
|
||||
|
||||
class G4Text;
|
||||
class G4VtkVisContext;
|
||||
class vtkTextActor;
|
||||
|
||||
class G4VtkText2DPipeline : public G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkText2DPipeline(const G4Text& text, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVisAttributes);
|
||||
~G4VtkText2DPipeline() override = default;
|
||||
|
||||
void Enable() override;
|
||||
void Disable() override;
|
||||
|
||||
void Print() override;
|
||||
void Modified() override;
|
||||
void Clear() override;
|
||||
|
||||
virtual vtkSmartPointer<vtkTextActor> GetActor() { return actor; }
|
||||
|
||||
virtual void SetText(const G4String& text);
|
||||
|
||||
static std::size_t MakeHash(const G4Text& text, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVA);
|
||||
|
||||
protected:
|
||||
vtkSmartPointer<vtkTextActor> actor;
|
||||
};
|
||||
|
||||
#endif // G4VTKTEXT2DPIPELINE_HH
|
||||
@@ -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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Created by Stewart Boogert on 05/03/2023.
|
||||
//
|
||||
|
||||
#ifndef G4VTKTEXTPIPELINE_HH
|
||||
#define G4VTKTEXTPIPELINE_HH
|
||||
|
||||
#include "G4VVtkPipeline.hh"
|
||||
|
||||
class G4Text;
|
||||
class G4VtkVisContext;
|
||||
class vtkBillboardTextActor3D;
|
||||
|
||||
class G4VtkTextPipeline : public G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkTextPipeline(const G4Text& text, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVisAttributes);
|
||||
~G4VtkTextPipeline() override = default;
|
||||
|
||||
void Enable() override;
|
||||
void Disable() override;
|
||||
|
||||
void Print() override;
|
||||
void Modified() override;
|
||||
void Clear() override;
|
||||
|
||||
virtual vtkSmartPointer<vtkBillboardTextActor3D> GetActor() { return actor; }
|
||||
|
||||
virtual void SetText(const G4String& text);
|
||||
|
||||
static std::size_t MakeHash(const G4Text& text, const G4VtkVisContext& vc,
|
||||
const G4VisAttributes* pVA);
|
||||
|
||||
protected:
|
||||
vtkSmartPointer<vtkBillboardTextActor3D> actor;
|
||||
};
|
||||
|
||||
#endif // G4VTKTEXTPIPELINE_HH
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKUNSTRUCTUREDGRIDPIPELINE_HH
|
||||
#define G4VTKUNSTRUCTUREDGRIDPIPELINE_HH
|
||||
|
||||
#include "G4VVtkPipeline.hh"
|
||||
#include "G4PseudoScene.hh"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
#include "vtkStaticCleanUnstructuredGrid.h"
|
||||
|
||||
class vtkDoubleArray;
|
||||
class vtkDataSetMapper;
|
||||
class vtkActor;
|
||||
|
||||
class G4Mesh;
|
||||
|
||||
class G4VtkUnstructuredGridPipeline : public G4VVtkPipeline
|
||||
{
|
||||
public:
|
||||
G4VtkUnstructuredGridPipeline(G4String name, const G4VtkVisContext& vc);
|
||||
|
||||
~G4VtkUnstructuredGridPipeline() = default;
|
||||
|
||||
void Modified() {};
|
||||
void Clear() {};
|
||||
void Print() {};
|
||||
|
||||
void Enable() {};
|
||||
void Disable() {};
|
||||
|
||||
void SetUnstructuredGridData(const G4Mesh &mesh);
|
||||
|
||||
protected:
|
||||
class PseudoSceneVtkBase: public G4PseudoScene {
|
||||
public:
|
||||
PseudoSceneVtkBase(G4PhysicalVolumeModel* pvModel, // input
|
||||
G4int depth,
|
||||
vtkPoints *points,
|
||||
vtkDoubleArray *cellValues,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: fpPVModel(pvModel), fDepth(depth), fpPoints(points),
|
||||
fpGrid(unstructuredGrid), fpCellValues(cellValues)
|
||||
{}
|
||||
protected:
|
||||
using G4PseudoScene::AddSolid; // except for...
|
||||
void AddSolid(const G4VSolid& /*solid*/) override {};
|
||||
void AddSolid(const G4Box& /*box*/) override{};
|
||||
void ProcessVolume(const G4VSolid&) override {
|
||||
// Do nothing if uninteresting solids found, e.g., the container if not marked invisible.
|
||||
}
|
||||
G4PhysicalVolumeModel* fpPVModel;
|
||||
G4int fDepth;
|
||||
vtkSmartPointer<vtkPoints> fpPoints;
|
||||
vtkSmartPointer<vtkUnstructuredGrid> fpGrid;
|
||||
vtkSmartPointer<vtkDoubleArray> fpCellValues;
|
||||
G4int iCell = 0;
|
||||
};
|
||||
class PseudoSceneForTetCells: public PseudoSceneVtkBase {
|
||||
public:
|
||||
PseudoSceneForTetCells(G4PhysicalVolumeModel* pvModel, // input
|
||||
G4int depth,
|
||||
vtkPoints *points,
|
||||
vtkDoubleArray *cellValues,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: PseudoSceneVtkBase(pvModel,depth,points,cellValues,unstructuredGrid)
|
||||
{}
|
||||
private:
|
||||
using G4PseudoScene::AddSolid; // except for...
|
||||
void AddSolid(const G4VSolid& solid) override;
|
||||
void ProcessVolume(const G4VSolid&) override {}
|
||||
};
|
||||
class PseudoSceneForCubicalCells: public PseudoSceneVtkBase {
|
||||
public:
|
||||
PseudoSceneForCubicalCells(G4PhysicalVolumeModel* pvModel, // input
|
||||
G4int depth,
|
||||
vtkPoints *points,
|
||||
vtkDoubleArray *cellValues,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: PseudoSceneVtkBase(pvModel,depth,points,cellValues,unstructuredGrid)
|
||||
{}
|
||||
private:
|
||||
using G4PseudoScene::AddSolid; // except for...
|
||||
void AddSolid(const G4Box& box) override;
|
||||
void ProcessVolume(const G4VSolid&) override {}
|
||||
};
|
||||
|
||||
private:
|
||||
vtkSmartPointer<vtkPoints> points;
|
||||
vtkSmartPointer<vtkDoubleArray> pointValues;
|
||||
vtkSmartPointer<vtkDoubleArray> cellValues;
|
||||
vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid;
|
||||
vtkSmartPointer<vtkStaticCleanUnstructuredGrid> cleanUnstructuredGrid;
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper;
|
||||
vtkSmartPointer<vtkActor> actor;
|
||||
};
|
||||
|
||||
#endif // G4VTKUNSTRUCTUREDGRIDPIPELINE_HH
|
||||
+18
-21
@@ -22,31 +22,28 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Created by Stewart Boogert on 05/03/2023.
|
||||
//
|
||||
|
||||
#ifndef G4VTKQTVIEWER_HH
|
||||
#define G4VTKQTVIEWER_HH
|
||||
#ifndef G4VTKUTILITY_HH
|
||||
#define G4VTKUTILITY_HH
|
||||
|
||||
// #define G4VTKDEBUG // Comment this out to suppress debug code.
|
||||
#include "G4Normal3D.hh"
|
||||
#include "G4Plane3D.hh"
|
||||
#include "G4Point3D.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4Types.hh"
|
||||
|
||||
#include "G4VViewer.hh"
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
class G4UIManager;
|
||||
class G4UIQt;
|
||||
class vtkMatrix4x4;
|
||||
class vtkPlane;
|
||||
|
||||
#include "QVTKOpenGLNativeWidget.h"
|
||||
#include "G4VtkViewer.hh"
|
||||
vtkSmartPointer<vtkMatrix4x4> G4Transform3DToVtkMatrix4x4(const G4Transform3D& g4Transformation);
|
||||
|
||||
class G4VtkQtViewer: public QVTKOpenGLNativeWidget, public G4VtkViewer {
|
||||
public:
|
||||
G4VtkQtViewer(G4VSceneHandler &, const G4String &name);
|
||||
virtual ~G4VtkQtViewer();
|
||||
void Initialise();
|
||||
virtual void CreateMainWindow(QVTKOpenGLNativeWidget*, const QString&);
|
||||
void FinishView();
|
||||
vtkSmartPointer<vtkPlane> G4Plane3DToVtkPlane(const G4Plane3D& g4plane);
|
||||
G4Plane3D VtkPlaneToG4Plane3D(vtkPlane* vtkPlane);
|
||||
void MaxBounds(G4double* maxBound, G4double* boundToCheck);
|
||||
|
||||
private:
|
||||
|
||||
G4UIQt* fUiQt;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // G4VTKUTILITY_HH
|
||||
@@ -0,0 +1,287 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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.
|
||||
|
||||
#ifndef G4VTKVIEWER_HH
|
||||
#define G4VTKVIEWER_HH
|
||||
|
||||
#include "G4VViewer.hh"
|
||||
#include "G4VtkInteractorStyle.hh"
|
||||
#include "G4VtkStore.hh"
|
||||
#include "G4VtkUtility.hh"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wextra-semi"
|
||||
#include "vtkAutoInit.h"
|
||||
#include "vtkCamera.h"
|
||||
#include "vtkCameraOrientationWidget.h"
|
||||
#include "vtkImplicitPlaneRepresentation.h"
|
||||
#include "vtkImplicitPlaneWidget2.h"
|
||||
#include "vtkInteractorStyleTerrain.h"
|
||||
#include "vtkInteractorStyleTrackballCamera.h"
|
||||
#include "vtkLight.h"
|
||||
#include "vtkNew.h"
|
||||
#include "vtkObject.h"
|
||||
#include "vtkPlane.h"
|
||||
#include "vtkRenderWindow.h"
|
||||
#include "vtkRenderWindowInteractor.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkTextActor.h"
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
VTK_MODULE_INIT(vtkRenderingOpenGL2)
|
||||
VTK_MODULE_INIT(vtkInteractionStyle);
|
||||
VTK_MODULE_INIT(vtkRenderingFreeType)
|
||||
|
||||
class vtkGeant4Callback : public vtkCommand
|
||||
{
|
||||
public:
|
||||
static vtkGeant4Callback* New() { return new vtkGeant4Callback; }
|
||||
|
||||
vtkGeant4Callback() { fVP = nullptr; }
|
||||
void SetGeant4ViewParameters(G4ViewParameters* VP) { fVP = VP; }
|
||||
void SetVtkInitialValues(G4double parallelScaleIn, G4double cameraDistanceIn)
|
||||
{
|
||||
parallelScale = parallelScaleIn;
|
||||
cameraDistance = cameraDistanceIn;
|
||||
}
|
||||
void Execute(vtkObject* caller, unsigned long, void*) override
|
||||
{
|
||||
auto ren = static_cast<vtkRenderer*>(caller);
|
||||
vtkCamera* cam = ren->GetActiveCamera();
|
||||
|
||||
auto cp = cam->GetPosition();
|
||||
auto fp = cam->GetFocalPoint();
|
||||
auto ud = cam->GetViewUp();
|
||||
|
||||
fVP->SetCurrentTargetPoint(G4Point3D(fp[0], fp[1], fp[2]));
|
||||
fVP->SetViewpointDirection(
|
||||
(G4Point3D(cp[0], cp[1], cp[2]) - G4Point3D(fp[0], fp[1], fp[2])).unit());
|
||||
fVP->SetUpVector(G4Vector3D(ud[0], ud[1], ud[2]));
|
||||
|
||||
if (cam->GetParallelProjection() != 0) {
|
||||
fVP->SetZoomFactor(parallelScale / cam->GetParallelScale());
|
||||
}
|
||||
else {
|
||||
auto cd = std::sqrt(std::pow(cp[0] - fp[0], 2) + std::pow(cp[1] - cp[1], 2)
|
||||
+ std::pow(cp[2] - cp[2], 2));
|
||||
fVP->SetZoomFactor(cameraDistance / cd);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
G4ViewParameters* fVP;
|
||||
G4double parallelScale;
|
||||
G4double cameraDistance;
|
||||
};
|
||||
|
||||
class vtkInfoCallback : public vtkCommand
|
||||
{
|
||||
public:
|
||||
static vtkInfoCallback* New() { return new vtkInfoCallback; }
|
||||
|
||||
vtkInfoCallback()
|
||||
{
|
||||
t1 = std::chrono::steady_clock::now();
|
||||
t2 = std::chrono::steady_clock::now();
|
||||
}
|
||||
void SetTextActor(vtkTextActor* txt) { this->TextActor = txt; }
|
||||
|
||||
void Execute(vtkObject* caller, unsigned long, void*) override
|
||||
{
|
||||
auto ren = static_cast<vtkRenderer*>(caller);
|
||||
int nActors = ren->GetActors()->GetNumberOfItems();
|
||||
vtkCamera* cam = ren->GetActiveCamera();
|
||||
if (cam == nullptr) return;
|
||||
|
||||
double* pos = cam->GetPosition();
|
||||
double* foc = cam->GetFocalPoint();
|
||||
double viewAngle = cam->GetViewAngle();
|
||||
double distance = cam->GetDistance();
|
||||
double parallelScale = cam->GetParallelScale();
|
||||
|
||||
if (pos == nullptr) return;
|
||||
|
||||
// Get current time
|
||||
t2 = std::chrono::steady_clock::now();
|
||||
|
||||
// Frame rate calculation
|
||||
std::chrono::duration<double> tdiff = t2 - t1;
|
||||
t1 = t2;
|
||||
float fps = 1.0 / tdiff.count();
|
||||
|
||||
// String for display
|
||||
snprintf(this->TextBuff, sizeof this->TextBuff,
|
||||
"camera position : %.1f %.1f %.1f \n"
|
||||
"camera focal point : %.1f %.1f %.1f \n"
|
||||
"view angle : %.1f\n"
|
||||
"distance : %.1f\n"
|
||||
"parallel scale : %.1f\n"
|
||||
"number actors : %i\n"
|
||||
"fps : %.1f",
|
||||
pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, parallelScale,
|
||||
nActors, fps);
|
||||
if (this->TextActor != nullptr) {
|
||||
this->TextActor->SetInput(this->TextBuff);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
vtkTextActor* TextActor;
|
||||
char TextBuff[256];
|
||||
std::chrono::time_point<std::chrono::steady_clock> t1;
|
||||
std::chrono::time_point<std::chrono::steady_clock> t2;
|
||||
};
|
||||
|
||||
class vtkIPWCallback : public vtkCommand
|
||||
{
|
||||
public:
|
||||
static vtkIPWCallback* New() { return new vtkIPWCallback; }
|
||||
|
||||
vtkIPWCallback() = default;
|
||||
|
||||
void SetStore(G4VtkStore* storeIn) { store = storeIn; }
|
||||
|
||||
void SetUpdatePipelineName(G4String nameIn, G4String typeIn)
|
||||
{
|
||||
pipelineToUpdateName = nameIn;
|
||||
pipelineToUpdateType = typeIn;
|
||||
}
|
||||
|
||||
void Execute(vtkObject* caller, unsigned long, void*) override
|
||||
{
|
||||
if (this->plane == nullptr) {
|
||||
this->plane = vtkPlane::New();
|
||||
}
|
||||
|
||||
if (pipelineToUpdateName.empty() || pipelineToUpdateType.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto planeWidget = reinterpret_cast<vtkImplicitPlaneWidget2*>(caller);
|
||||
auto rep =
|
||||
reinterpret_cast<vtkImplicitPlaneRepresentation*>(planeWidget->GetRepresentation());
|
||||
rep->GetPlane(this->plane);
|
||||
G4Plane3D g4p = VtkPlaneToG4Plane3D(this->plane);
|
||||
store->UpdatePlanePipelines(pipelineToUpdateName, pipelineToUpdateType, g4p);
|
||||
}
|
||||
|
||||
vtkPlane* plane{nullptr};
|
||||
G4VtkStore* store{nullptr};
|
||||
G4String pipelineToUpdateName;
|
||||
G4String pipelineToUpdateType;
|
||||
};
|
||||
|
||||
class G4VtkViewer : public G4VViewer
|
||||
{
|
||||
public:
|
||||
G4VtkViewer(G4VSceneHandler&, const G4String& name);
|
||||
void Initialise() override;
|
||||
~G4VtkViewer() override;
|
||||
|
||||
void SetView() override;
|
||||
void ClearView() override;
|
||||
void DrawView() override;
|
||||
void ShowView() override;
|
||||
void FinishView() override;
|
||||
|
||||
void ExportScreenShot(G4String, G4String);
|
||||
void ExportOBJScene(G4String);
|
||||
void ExportVRMLScene(G4String);
|
||||
void ExportVTPScene(G4String);
|
||||
void ExportGLTFScene(G4String);
|
||||
void ExportVTPCutter(G4String fileName);
|
||||
void ExportFormatStore(G4String fileName, G4String store);
|
||||
|
||||
void DrawShadows();
|
||||
|
||||
void EnableShadows();
|
||||
void DisableShadows();
|
||||
|
||||
void AddViewHUD();
|
||||
void EnableHUD();
|
||||
void DisableHUD();
|
||||
|
||||
virtual void AddClipperPlaneWidget(const G4Plane3D& plane);
|
||||
void EnableClipper(const G4Plane3D& plane, G4bool widget);
|
||||
void DisableClipper();
|
||||
virtual void EnableClipperWidget();
|
||||
virtual void DisableClipperWidget();
|
||||
|
||||
virtual void AddCutterPlaneWidget(const G4Plane3D& plane);
|
||||
void EnableCutter(const G4Plane3D& plane, G4bool bWidget);
|
||||
void DisableCutter(G4String name);
|
||||
virtual void EnableCutterWidget();
|
||||
virtual void DisableCutterWidget();
|
||||
|
||||
virtual void AddCameraOrientationWidget();
|
||||
virtual void EnableCameraOrientationWidget();
|
||||
virtual void DisableCameraOrientationWidget();
|
||||
|
||||
void AddImageOverlay(const G4String& fileName, const G4double alpha,
|
||||
const G4double imageBottomLeft[2], const G4double worldBottomLeft[2],
|
||||
const G4double imageTopRight[2], const G4double worldTopRight[2],
|
||||
const G4double rot[3], const G4double trans[3]);
|
||||
void Add3DOverlay(const G4String& fileName, const G4double colour[3], const G4double alpha,
|
||||
const G4double scale[3], const G4double rotation[3],
|
||||
const G4double translation[3]);
|
||||
|
||||
void Print();
|
||||
|
||||
void SetPolyhedronPipeline(const G4String& t);
|
||||
|
||||
virtual void SetWidgetInteractor(vtkAbstractWidget* widget);
|
||||
|
||||
void ExportView(){};
|
||||
void SetGeant4View(){};
|
||||
|
||||
vtkNew<vtkTextActor> infoTextActor;
|
||||
vtkNew<vtkInfoCallback> infoCallback;
|
||||
vtkNew<vtkGeant4Callback> geant4Callback;
|
||||
vtkSmartPointer<vtkLight> light;
|
||||
vtkNew<vtkCamera> camera;
|
||||
vtkNew<vtkRenderer> renderer;
|
||||
vtkRenderWindow* _renderWindow;
|
||||
vtkRenderWindowInteractor* renderWindowInteractor;
|
||||
|
||||
protected:
|
||||
G4bool firstSetView = true;
|
||||
vtkNew<vtkImplicitPlaneRepresentation> cutterPlaneRepresentation;
|
||||
vtkNew<vtkImplicitPlaneWidget2> cutterPlaneWidget;
|
||||
|
||||
vtkNew<vtkImplicitPlaneRepresentation> clipperPlaneRepresentation;
|
||||
vtkNew<vtkImplicitPlaneWidget2> clipperPlaneWidget;
|
||||
|
||||
vtkNew<vtkCameraOrientationWidget> camOrientWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKVISCONTEXT_HH
|
||||
#define G4VTKVISCONTEXT_HH
|
||||
|
||||
#include "G4ViewParameters.hh"
|
||||
|
||||
class G4VtkViewer;
|
||||
class G4VisAttributes;
|
||||
|
||||
class G4VtkVisContext
|
||||
{
|
||||
public:
|
||||
const G4VtkViewer* fViewer;
|
||||
const G4VisAttributes* fVisAtt;
|
||||
G4bool fProcessing2D;
|
||||
const G4Transform3D& fTransform;
|
||||
G4int fDepth = -1;
|
||||
G4String fDescription;
|
||||
G4double red, green, blue, alpha;
|
||||
|
||||
G4double fSize;
|
||||
G4ViewParameters::DrawingStyle fDrawingStyle;
|
||||
|
||||
G4VtkVisContext()
|
||||
: fViewer(nullptr),
|
||||
fVisAtt(nullptr),
|
||||
fProcessing2D(false),
|
||||
fTransform(G4Transform3D::Identity),
|
||||
fDepth(0),
|
||||
fDescription(""),
|
||||
red(0),
|
||||
green(0),
|
||||
blue(0),
|
||||
alpha(0)
|
||||
{}
|
||||
|
||||
G4VtkVisContext(const G4VtkViewer* viewer, const G4VisAttributes* visAtt, bool processing2D,
|
||||
const G4Transform3D& transform)
|
||||
: fViewer(viewer), fVisAtt(visAtt), fProcessing2D(processing2D), fTransform(transform)
|
||||
{}
|
||||
|
||||
G4VtkVisContext(const G4VtkVisContext& vc2)
|
||||
: fViewer(vc2.fViewer),
|
||||
fVisAtt(vc2.fVisAtt),
|
||||
fProcessing2D(vc2.fProcessing2D),
|
||||
fTransform(vc2.fTransform),
|
||||
fDepth(vc2.fDepth),
|
||||
fDescription(vc2.fDescription),
|
||||
red(vc2.red),
|
||||
green(vc2.green),
|
||||
blue(vc2.blue),
|
||||
alpha(vc2.alpha),
|
||||
fDrawingStyle(vc2.fDrawingStyle)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,260 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: Visualization Toolkit
|
||||
Module: vtkTensorGlyphColor.h
|
||||
|
||||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
/**
|
||||
* @class vtkTensorGlyphColor
|
||||
* @brief scale and orient glyph(s) according to eigenvalues and eigenvectors of symmetrical part
|
||||
* of tensor
|
||||
*
|
||||
* vtkTensorGlyphColor is a filter that copies a geometric representation
|
||||
* (specified as polygonal data) to every input point. The geometric
|
||||
* representation, or glyph, can be scaled and/or rotated according to
|
||||
* the tensor at the input point. Scaling and rotation is controlled
|
||||
* by the eigenvalues/eigenvectors of the symmetrical part of the tensor
|
||||
* as follows:
|
||||
* For each tensor, the eigenvalues (and associated eigenvectors) are sorted
|
||||
* to determine the major, medium, and minor eigenvalues/eigenvectors.
|
||||
* The eigenvalue decomposition only makes sense for symmetric tensors,
|
||||
* hence the need to only consider the symmetric part of the tensor, which is
|
||||
* 1/2 (T + T.transposed()).
|
||||
*
|
||||
* If the boolean variable ThreeGlyphs is not set the major eigenvalue
|
||||
* scales the glyph in the x-direction, the medium in the y-direction,
|
||||
* and the minor in the z-direction. Then, the glyph is rotated so
|
||||
* that the glyph's local x-axis lies along the major eigenvector,
|
||||
* y-axis along the medium eigenvector, and z-axis along the minor.
|
||||
*
|
||||
* If the boolean variable ThreeGlyphs is set three glyphs are produced,
|
||||
* each of them oriented along an eigenvector and scaled according to the
|
||||
* corresponding eigenvector.
|
||||
*
|
||||
* If the boolean variable Symmetric is set each glyph is mirrored (2 or 6
|
||||
* glyphs will be produced)
|
||||
*
|
||||
* The x-axis of the source glyph will correspond to the eigenvector
|
||||
* on output. Point (0,0,0) in the source will be placed in the data point.
|
||||
* Variable Length will normally correspond to the distance from the
|
||||
* origin to the tip of the source glyph along the x-axis,
|
||||
* but can be changed to produce other results when Symmetric is on,
|
||||
* e.g. glyphs that do not touch or that overlap.
|
||||
*
|
||||
* Please note that when Symmetric is false it will generally be better
|
||||
* to place the source glyph from (-0.5,0,0) to (0.5,0,0), i.e. centred
|
||||
* at the origin. When symmetric is true the placement from (0,0,0) to
|
||||
* (1,0,0) will generally be more convenient.
|
||||
*
|
||||
* A scale factor is provided to control the amount of scaling. Also, you
|
||||
* can turn off scaling completely if desired. The boolean variable
|
||||
* ClampScaling controls the maximum scaling (in conjunction with
|
||||
* MaxScaleFactor.) This is useful in certain applications where
|
||||
* singularities or large order of magnitude differences exist in
|
||||
* the eigenvalues.
|
||||
*
|
||||
* If the boolean variable ColorGlyphs is set to true the glyphs are
|
||||
* colored. The glyphs can be colored using the input scalars
|
||||
* (SetColorModeToScalars), which is the default, or colored using the
|
||||
* eigenvalues (SetColorModeToEigenvalues).
|
||||
*
|
||||
* Another instance variable, ExtractEigenvalues, has been provided to
|
||||
* control extraction of eigenvalues/eigenvectors. If this boolean is
|
||||
* false, then eigenvalues/eigenvectors are not extracted, and the
|
||||
* columns of the tensor are taken as the eigenvectors (the norm of
|
||||
* column, always positive, is the eigenvalue). This allows
|
||||
* additional capability over the vtkGlyph3D object. That is, the
|
||||
* glyph can be oriented in three directions instead of one.
|
||||
*
|
||||
* @par Thanks:
|
||||
* Thanks to Jose Paulo Moitinho de Almeida for enhancements.
|
||||
*
|
||||
* @sa
|
||||
* vtkGlyph3D vtkPointLoad vtkHyperStreamline
|
||||
*/
|
||||
|
||||
#ifndef vtkTensorGlyphColor_h
|
||||
#define vtkTensorGlyphColor_h
|
||||
|
||||
#include "vtkFiltersCoreModule.h" // For export macro
|
||||
#include "vtkPolyDataAlgorithm.h"
|
||||
|
||||
class VTKFILTERSCORE_EXPORT vtkTensorGlyphColor : public vtkPolyDataAlgorithm
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkTensorGlyphColor,
|
||||
vtkPolyDataAlgorithm) void PrintSelf(ostream& os, vtkIndent indent) override;
|
||||
|
||||
/**
|
||||
* Construct object with scaling on and scale factor 1.0. Eigenvalues are
|
||||
* extracted, glyphs are colored with input scalar data, and logarithmic
|
||||
* scaling is turned off.
|
||||
*/
|
||||
static vtkTensorGlyphColor* New();
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Specify the geometry to copy to each point.
|
||||
* Note that this method does not connect the pipeline. The algorithm will
|
||||
* work on the input data as it is without updating the producer of the data.
|
||||
* See SetSourceConnection for connecting the pipeline.
|
||||
*/
|
||||
void SetSourceData(vtkPolyData* source);
|
||||
vtkPolyData* GetSource();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Specify a source object at a specified table location. New style.
|
||||
* Source connection is stored in port 1. This method is equivalent
|
||||
* to SetInputConnection(1, id, outputPort).
|
||||
*/
|
||||
void SetSourceConnection(int id, vtkAlgorithmOutput* algOutput);
|
||||
void SetSourceConnection(vtkAlgorithmOutput* algOutput)
|
||||
{
|
||||
this->SetSourceConnection(0, algOutput);
|
||||
}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off scaling of glyph with eigenvalues.
|
||||
*/
|
||||
vtkSetMacro(Scaling, vtkTypeBool);
|
||||
vtkGetMacro(Scaling, vtkTypeBool);
|
||||
vtkBooleanMacro(Scaling, vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Specify scale factor to scale object by. (Scale factor always affects
|
||||
* output even if scaling is off.)
|
||||
*/
|
||||
vtkSetMacro(ScaleFactor, double);
|
||||
vtkGetMacro(ScaleFactor, double);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off drawing three glyphs
|
||||
*/
|
||||
vtkSetMacro(ThreeGlyphs, vtkTypeBool);
|
||||
vtkGetMacro(ThreeGlyphs, vtkTypeBool);
|
||||
vtkBooleanMacro(ThreeGlyphs, vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off drawing a mirror of each glyph
|
||||
*/
|
||||
vtkSetMacro(Symmetric, vtkTypeBool);
|
||||
vtkGetMacro(Symmetric, vtkTypeBool);
|
||||
vtkBooleanMacro(Symmetric, vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Set/Get the distance, along x, from the origin to the end of the
|
||||
* source glyph. It is used to draw the symmetric glyphs.
|
||||
*/
|
||||
vtkSetMacro(Length, double);
|
||||
vtkGetMacro(Length, double);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off extraction of eigenvalues from tensor.
|
||||
*/
|
||||
vtkSetMacro(ExtractEigenvalues, vtkTypeBool);
|
||||
vtkBooleanMacro(ExtractEigenvalues, vtkTypeBool);
|
||||
vtkGetMacro(ExtractEigenvalues, vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off coloring of glyph with input scalar data or
|
||||
* eigenvalues. If false, or input scalar data not present, then the
|
||||
* scalars from the source object are passed through the filter.
|
||||
*/
|
||||
vtkSetMacro(ColorGlyphs, vtkTypeBool);
|
||||
vtkGetMacro(ColorGlyphs, vtkTypeBool);
|
||||
vtkBooleanMacro(ColorGlyphs, vtkTypeBool);
|
||||
//@}
|
||||
|
||||
enum
|
||||
{
|
||||
COLOR_BY_SCALARS,
|
||||
COLOR_BY_EIGENVALUES
|
||||
};
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Set the color mode to be used for the glyphs. This can be set to
|
||||
* use the input scalars (default) or to use the eigenvalues at the
|
||||
* point. If ThreeGlyphs is set and the eigenvalues are chosen for
|
||||
* coloring then each glyph is colored by the corresponding
|
||||
* eigenvalue and if not set the color corresponding to the largest
|
||||
* eigenvalue is chosen. The recognized values are:
|
||||
* COLOR_BY_SCALARS = 0 (default)
|
||||
* COLOR_BY_EIGENVALUES = 1
|
||||
*/
|
||||
vtkSetClampMacro(ColorMode, int, COLOR_BY_SCALARS, COLOR_BY_EIGENVALUES);
|
||||
vtkGetMacro(ColorMode, int);
|
||||
void SetColorModeToScalars() { this->SetColorMode(COLOR_BY_SCALARS); };
|
||||
void SetColorModeToEigenvalues() { this->SetColorMode(COLOR_BY_EIGENVALUES); };
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off scalar clamping. If scalar clamping is on, the ivar
|
||||
* MaxScaleFactor is used to control the maximum scale factor. (This is
|
||||
* useful to prevent uncontrolled scaling near singularities.)
|
||||
*/
|
||||
vtkSetMacro(ClampScaling, vtkTypeBool);
|
||||
vtkGetMacro(ClampScaling, vtkTypeBool);
|
||||
vtkBooleanMacro(ClampScaling, vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Set/Get the maximum allowable scale factor. This value is compared to the
|
||||
* combination of the scale factor times the eigenvalue. If less, the scale
|
||||
* factor is reset to the MaxScaleFactor. The boolean ClampScaling has to
|
||||
* be "on" for this to work.
|
||||
*/
|
||||
vtkSetMacro(MaxScaleFactor, double);
|
||||
vtkGetMacro(MaxScaleFactor, double);
|
||||
//@}
|
||||
|
||||
protected:
|
||||
vtkTensorGlyphColor();
|
||||
~vtkTensorGlyphColor() override;
|
||||
vtkTensorGlyphColor(const vtkTensorGlyphColor&) = delete;
|
||||
void operator=(const vtkTensorGlyphColor&) = delete;
|
||||
|
||||
int RequestUpdateExtent(vtkInformation*, vtkInformationVector**,
|
||||
vtkInformationVector*) override;
|
||||
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
|
||||
int FillInputPortInformation(int port, vtkInformation* info) override;
|
||||
|
||||
vtkTypeBool Scaling; // Determine whether scaling of geometry is performed
|
||||
double ScaleFactor; // Scale factor to use to scale geometry
|
||||
vtkTypeBool ExtractEigenvalues; // Boolean controls eigenfunction extraction
|
||||
vtkTypeBool ColorGlyphs; // Boolean controls coloring with input scalar data
|
||||
int ColorMode; // The coloring mode to use for the glyphs.
|
||||
vtkTypeBool ClampScaling; // Boolean controls whether scaling is clamped.
|
||||
double MaxScaleFactor; // Maximum scale factor (ScaleFactor*eigenvalue)
|
||||
vtkTypeBool ThreeGlyphs; // Boolean controls drawing 1 or 3 glyphs
|
||||
vtkTypeBool Symmetric; // Boolean controls drawing a "mirror" of each glyph
|
||||
double Length; // Distance, in x, from the origin to the end of the glyph
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,261 +0,0 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: Visualization Toolkit
|
||||
Module: vtkTensorGlyphColor.h
|
||||
|
||||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
/**
|
||||
* @class vtkTensorGlyphColor
|
||||
* @brief scale and orient glyph(s) according to eigenvalues and eigenvectors of symmetrical part of tensor
|
||||
*
|
||||
* vtkTensorGlyphColor is a filter that copies a geometric representation
|
||||
* (specified as polygonal data) to every input point. The geometric
|
||||
* representation, or glyph, can be scaled and/or rotated according to
|
||||
* the tensor at the input point. Scaling and rotation is controlled
|
||||
* by the eigenvalues/eigenvectors of the symmetrical part of the tensor
|
||||
* as follows:
|
||||
* For each tensor, the eigenvalues (and associated eigenvectors) are sorted
|
||||
* to determine the major, medium, and minor eigenvalues/eigenvectors.
|
||||
* The eigenvalue decomposition only makes sense for symmetric tensors,
|
||||
* hence the need to only consider the symmetric part of the tensor, which is
|
||||
* 1/2 (T + T.transposed()).
|
||||
*
|
||||
* If the boolean variable ThreeGlyphs is not set the major eigenvalue
|
||||
* scales the glyph in the x-direction, the medium in the y-direction,
|
||||
* and the minor in the z-direction. Then, the glyph is rotated so
|
||||
* that the glyph's local x-axis lies along the major eigenvector,
|
||||
* y-axis along the medium eigenvector, and z-axis along the minor.
|
||||
*
|
||||
* If the boolean variable ThreeGlyphs is set three glyphs are produced,
|
||||
* each of them oriented along an eigenvector and scaled according to the
|
||||
* corresponding eigenvector.
|
||||
*
|
||||
* If the boolean variable Symmetric is set each glyph is mirrored (2 or 6
|
||||
* glyphs will be produced)
|
||||
*
|
||||
* The x-axis of the source glyph will correspond to the eigenvector
|
||||
* on output. Point (0,0,0) in the source will be placed in the data point.
|
||||
* Variable Length will normally correspond to the distance from the
|
||||
* origin to the tip of the source glyph along the x-axis,
|
||||
* but can be changed to produce other results when Symmetric is on,
|
||||
* e.g. glyphs that do not touch or that overlap.
|
||||
*
|
||||
* Please note that when Symmetric is false it will generally be better
|
||||
* to place the source glyph from (-0.5,0,0) to (0.5,0,0), i.e. centred
|
||||
* at the origin. When symmetric is true the placement from (0,0,0) to
|
||||
* (1,0,0) will generally be more convenient.
|
||||
*
|
||||
* A scale factor is provided to control the amount of scaling. Also, you
|
||||
* can turn off scaling completely if desired. The boolean variable
|
||||
* ClampScaling controls the maximum scaling (in conjunction with
|
||||
* MaxScaleFactor.) This is useful in certain applications where
|
||||
* singularities or large order of magnitude differences exist in
|
||||
* the eigenvalues.
|
||||
*
|
||||
* If the boolean variable ColorGlyphs is set to true the glyphs are
|
||||
* colored. The glyphs can be colored using the input scalars
|
||||
* (SetColorModeToScalars), which is the default, or colored using the
|
||||
* eigenvalues (SetColorModeToEigenvalues).
|
||||
*
|
||||
* Another instance variable, ExtractEigenvalues, has been provided to
|
||||
* control extraction of eigenvalues/eigenvectors. If this boolean is
|
||||
* false, then eigenvalues/eigenvectors are not extracted, and the
|
||||
* columns of the tensor are taken as the eigenvectors (the norm of
|
||||
* column, always positive, is the eigenvalue). This allows
|
||||
* additional capability over the vtkGlyph3D object. That is, the
|
||||
* glyph can be oriented in three directions instead of one.
|
||||
*
|
||||
* @par Thanks:
|
||||
* Thanks to Jose Paulo Moitinho de Almeida for enhancements.
|
||||
*
|
||||
* @sa
|
||||
* vtkGlyph3D vtkPointLoad vtkHyperStreamline
|
||||
*/
|
||||
|
||||
#ifndef vtkTensorGlyphColor_h
|
||||
#define vtkTensorGlyphColor_h
|
||||
|
||||
#include "vtkFiltersCoreModule.h" // For export macro
|
||||
#include "vtkPolyDataAlgorithm.h"
|
||||
|
||||
class VTKFILTERSCORE_EXPORT vtkTensorGlyphColor : public vtkPolyDataAlgorithm
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkTensorGlyphColor,vtkPolyDataAlgorithm)
|
||||
void PrintSelf(ostream& os, vtkIndent indent) override;
|
||||
|
||||
/**
|
||||
* Construct object with scaling on and scale factor 1.0. Eigenvalues are
|
||||
* extracted, glyphs are colored with input scalar data, and logarithmic
|
||||
* scaling is turned off.
|
||||
*/
|
||||
static vtkTensorGlyphColor *New();
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Specify the geometry to copy to each point.
|
||||
* Note that this method does not connect the pipeline. The algorithm will
|
||||
* work on the input data as it is without updating the producer of the data.
|
||||
* See SetSourceConnection for connecting the pipeline.
|
||||
*/
|
||||
void SetSourceData(vtkPolyData *source);
|
||||
vtkPolyData *GetSource();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Specify a source object at a specified table location. New style.
|
||||
* Source connection is stored in port 1. This method is equivalent
|
||||
* to SetInputConnection(1, id, outputPort).
|
||||
*/
|
||||
void SetSourceConnection(int id, vtkAlgorithmOutput* algOutput);
|
||||
void SetSourceConnection(vtkAlgorithmOutput* algOutput)
|
||||
{
|
||||
this->SetSourceConnection(0, algOutput);
|
||||
}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off scaling of glyph with eigenvalues.
|
||||
*/
|
||||
vtkSetMacro(Scaling,vtkTypeBool);
|
||||
vtkGetMacro(Scaling,vtkTypeBool);
|
||||
vtkBooleanMacro(Scaling,vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Specify scale factor to scale object by. (Scale factor always affects
|
||||
* output even if scaling is off.)
|
||||
*/
|
||||
vtkSetMacro(ScaleFactor,double);
|
||||
vtkGetMacro(ScaleFactor,double);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off drawing three glyphs
|
||||
*/
|
||||
vtkSetMacro(ThreeGlyphs,vtkTypeBool);
|
||||
vtkGetMacro(ThreeGlyphs,vtkTypeBool);
|
||||
vtkBooleanMacro(ThreeGlyphs,vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off drawing a mirror of each glyph
|
||||
*/
|
||||
vtkSetMacro(Symmetric,vtkTypeBool);
|
||||
vtkGetMacro(Symmetric,vtkTypeBool);
|
||||
vtkBooleanMacro(Symmetric,vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Set/Get the distance, along x, from the origin to the end of the
|
||||
* source glyph. It is used to draw the symmetric glyphs.
|
||||
*/
|
||||
vtkSetMacro(Length,double);
|
||||
vtkGetMacro(Length,double);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off extraction of eigenvalues from tensor.
|
||||
*/
|
||||
vtkSetMacro(ExtractEigenvalues,vtkTypeBool);
|
||||
vtkBooleanMacro(ExtractEigenvalues,vtkTypeBool);
|
||||
vtkGetMacro(ExtractEigenvalues,vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off coloring of glyph with input scalar data or
|
||||
* eigenvalues. If false, or input scalar data not present, then the
|
||||
* scalars from the source object are passed through the filter.
|
||||
*/
|
||||
vtkSetMacro(ColorGlyphs,vtkTypeBool);
|
||||
vtkGetMacro(ColorGlyphs,vtkTypeBool);
|
||||
vtkBooleanMacro(ColorGlyphs,vtkTypeBool);
|
||||
//@}
|
||||
|
||||
enum
|
||||
{
|
||||
COLOR_BY_SCALARS,
|
||||
COLOR_BY_EIGENVALUES
|
||||
};
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Set the color mode to be used for the glyphs. This can be set to
|
||||
* use the input scalars (default) or to use the eigenvalues at the
|
||||
* point. If ThreeGlyphs is set and the eigenvalues are chosen for
|
||||
* coloring then each glyph is colored by the corresponding
|
||||
* eigenvalue and if not set the color corresponding to the largest
|
||||
* eigenvalue is chosen. The recognized values are:
|
||||
* COLOR_BY_SCALARS = 0 (default)
|
||||
* COLOR_BY_EIGENVALUES = 1
|
||||
*/
|
||||
vtkSetClampMacro(ColorMode, int, COLOR_BY_SCALARS, COLOR_BY_EIGENVALUES);
|
||||
vtkGetMacro(ColorMode, int);
|
||||
void SetColorModeToScalars()
|
||||
{this->SetColorMode(COLOR_BY_SCALARS);};
|
||||
void SetColorModeToEigenvalues()
|
||||
{this->SetColorMode(COLOR_BY_EIGENVALUES);};
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Turn on/off scalar clamping. If scalar clamping is on, the ivar
|
||||
* MaxScaleFactor is used to control the maximum scale factor. (This is
|
||||
* useful to prevent uncontrolled scaling near singularities.)
|
||||
*/
|
||||
vtkSetMacro(ClampScaling,vtkTypeBool);
|
||||
vtkGetMacro(ClampScaling,vtkTypeBool);
|
||||
vtkBooleanMacro(ClampScaling,vtkTypeBool);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Set/Get the maximum allowable scale factor. This value is compared to the
|
||||
* combination of the scale factor times the eigenvalue. If less, the scale
|
||||
* factor is reset to the MaxScaleFactor. The boolean ClampScaling has to
|
||||
* be "on" for this to work.
|
||||
*/
|
||||
vtkSetMacro(MaxScaleFactor,double);
|
||||
vtkGetMacro(MaxScaleFactor,double);
|
||||
//@}
|
||||
|
||||
protected:
|
||||
vtkTensorGlyphColor();
|
||||
~vtkTensorGlyphColor() override;
|
||||
|
||||
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
|
||||
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
|
||||
int FillInputPortInformation(int port, vtkInformation *info) override;
|
||||
|
||||
vtkTypeBool Scaling; // Determine whether scaling of geometry is performed
|
||||
double ScaleFactor; // Scale factor to use to scale geometry
|
||||
vtkTypeBool ExtractEigenvalues; // Boolean controls eigenfunction extraction
|
||||
vtkTypeBool ColorGlyphs; // Boolean controls coloring with input scalar data
|
||||
int ColorMode; // The coloring mode to use for the glyphs.
|
||||
vtkTypeBool ClampScaling; // Boolean controls whether scaling is clamped.
|
||||
double MaxScaleFactor; // Maximum scale factor (ScaleFactor*eigenvalue)
|
||||
vtkTypeBool ThreeGlyphs; // Boolean controls drawing 1 or 3 glyphs
|
||||
vtkTypeBool Symmetric; // Boolean controls drawing a "mirror" of each glyph
|
||||
double Length; // Distance, in x, from the origin to the end of the glyph
|
||||
private:
|
||||
vtkTensorGlyphColor(const vtkTensorGlyphColor&) = delete;
|
||||
void operator=(const vtkTensorGlyphColor&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user