37#include <vtkCleanPolyData.h>
39#include <vtkMatrix4x4.h>
40#include <vtkPolyDataAlgorithm.h>
41#include <vtkPolyDataMapper.h>
42#include <vtkPolyDataNormals.h>
43#include <vtkProperty.h>
44#include <vtkTriangleFilter.h>
49 std::size_t hash = std::hash<G4Polyhedron>{}(polyhedron);
71 :
G4VVtkPipeline(nameIn,
"G4VtkPolydataPipeline", vcIn, false, vcIn.fViewer->renderer)
85 filterClean->PointMergingOn();
91 filterTriangle->SetInputConnection(filterClean->GetOutputPort());
96 filterNormals->SetFeatureAngle(45);
97 filterNormals->SetInputConnection(filterTriangle->GetOutputPort());
103 mapper->SetColorModeToDirectScalars();
108 actor->SetVisibility(1);
116 actor->GetProperty()->SetRepresentationToWireframe();
125 actor->SetVisibility(1);
130 actor->SetVisibility(0);
135 G4cout <<
"G4VtkPolydataPipeline filters (";
137 G4cout << f->GetInformation() <<
",";
167 notLastFace = polyhedron.
GetNextFacet(nEdges, vertex, edgeFlag, normals);
171 for (
int i = 0; i < nEdges; i++) {
172 polydataPoints->InsertNextPoint(vertex[i].x(), vertex[i].y(), vertex[i].z());
173 poly->InsertNextId(iVert);
178 }
while (notLastFace);
189 const size_t nLines = polyline.size();
191 for (
size_t i = 0; i < nLines; ++i) {
192 auto id =
polydataPoints->InsertNextPoint(polyline[i].x(), polyline[i].y(), polyline[i].z());
194 if (i < nLines - 1) {
196 line->GetPointIds()->SetId(0,
id);
197 line->GetPointIds()->SetId(1,
id + 1);
220 double transformArray[16] = {r00, r01, r02, dx, r10, r11, r12, dy,
221 r20, r21, r22, dz, 0., 0., 0., 1.};
222 transform->DeepCopy(transformArray);
223 actor->SetUserMatrix(transform);
228 actor->GetProperty()->SetColor(r, g, b);
229 actor->GetProperty()->SetOpacity(a);
G4GLOB_DLL std::ostream G4cout
void SetTypeName(G4String typeNameIn)
vtkSmartPointer< vtkRenderer > renderer
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)
vtkSmartPointer< vtkPolyDataAlgorithm > GetFinalFilter()
static std::size_t MakeHash(const G4Polyhedron &p, const G4VtkVisContext &vc)
virtual void SetPolydata(const G4Polyhedron &polyhedron)
vtkSmartPointer< vtkCellArray > polydataCells
vtkSmartPointer< vtkPolyData > polydata
vtkSmartPointer< vtkPoints > polydataPoints
vtkSmartPointer< vtkActor > actor
vtkSmartPointer< vtkPolyDataMapper > mapper
virtual vtkSmartPointer< vtkActor > GetActor()
std::vector< vtkSmartPointer< vtkPolyDataAlgorithm > > filters
virtual void SetActorColour(G4double r, G4double g, G4double b, G4double a)
void AddFilter(vtkSmartPointer< vtkPolyDataAlgorithm > f)
virtual void SetPolydataData(const G4Point3D &p)
G4VtkPolydataPipeline(G4String name, const G4VtkVisContext &vc)
vtkNew< vtkRenderer > renderer
G4ViewParameters::DrawingStyle fDrawingStyle
const G4Transform3D & fTransform
const G4VtkViewer * fViewer
G4bool GetNextFacet(G4int &n, G4Point3D *nodes, G4int *edgeFlags=nullptr, G4Normal3D *normals=nullptr) const
void hash_combine(std::size_t)