61#pragma GCC diagnostic push
62#pragma GCC diagnostic ignored "-Wextra-semi"
66#include <vtkSmartPointer.h>
67#include <vtkBillboardTextActor3D.h>
69#include <vtkMatrix3x3.h>
70#include <vtkOBJReader.h>
71#include <vtkPLYReader.h>
72#include <vtkSTLReader.h>
73#include <vtkPolyDataReader.h>
74#include <vtkProperty.h>
75#include <vtkProperty2D.h>
76#include <vtkRegularPolygonSource.h>
77#include <vtkTextProperty.h>
80#pragma GCC diagnostic pop
96 for (
const auto& it : polylinePipeMap)
97 it.second->Modified();
99 for (
const auto& it : polyline2DPipeMap)
100 it.second->Modified();
102 for (
const auto& it : circlePipeMap)
103 it.second->Modified();
105 for (
const auto& it : squarePipeMap)
106 it.second->Modified();
108 for (
const auto& it : textPipeMap)
109 it.second->Modified();
111 for (
const auto& it : text2DPipeMap)
112 it.second->Modified();
114 for (
const auto& it : separatePipeMap)
115 it.second->Modified();
117 for (
const auto& it : tensorGlyphPipeMap)
118 it.second->Modified();
120 for (
const auto& it : appendPipeMap)
121 it.second->Modified();
123 for (
const auto& it : bakePipeMap)
124 it.second->Modified();
133 for (
const auto& v : polylinePipeMap) {
136 polylinePipeMap.clear();
138 for (
const auto& v : polyline2DPipeMap) {
141 polyline2DPipeMap.clear();
143 for (
const auto& v : circlePipeMap) {
146 circlePipeMap.clear();
148 for (
const auto& v : squarePipeMap) {
151 squarePipeMap.clear();
153 for (
const auto& v : textPipeMap) {
158 for (
const auto& v : text2DPipeMap) {
161 text2DPipeMap.clear();
163 for (
const auto& v : separatePipeMap) {
166 separatePipeMap.clear();
168 for (
const auto& v : tensorGlyphPipeMap) {
171 tensorGlyphPipeMap.clear();
173 for (
const auto& v : appendPipeMap) {
176 appendPipeMap.clear();
178 for (
const auto& v : bakePipeMap) {
190 for (
const auto& v : imagePipeMap) {
193 imagePipeMap.clear();
195 for (
const auto& v : sideloadPipeMap) {
198 sideloadPipeMap.clear();
203 G4cout <<
"G4VtkStore::Print() " << name << std::endl;
204 G4cout <<
"G4VtkStore::Print() polylinePipeMap size > " << polylinePipeMap.size()
206 G4cout <<
"G4VtkStore::Print() polyline2DPipeMap size > " << polyline2DPipeMap.size()
208 G4cout <<
"G4VtkStore::Print() circlePipeMap size > " << circlePipeMap.size() <<
G4endl;
209 G4cout <<
"G4VtkStore::Print() squarePipeMap size > " << squarePipeMap.size() <<
G4endl;
210 G4cout <<
"G4VtkStore::Print() textPipeMap size > " << textPipeMap.size() <<
G4endl;
211 G4cout <<
"G4VtkStore::Print() text2DPipeMap size > " << text2DPipeMap.size() <<
G4endl;
212 G4cout <<
"G4VtkStore::Print() separatePipeMap size > " << separatePipeMap.size()
214 G4cout <<
"G4VtkStore::Print() tensorGlyphPipeMap size > " << tensorGlyphPipeMap.size()
216 G4cout <<
"G4VtkStore::Print() transformAppendPipeMap size > " << appendPipeMap.size() <<
G4endl;
217 G4cout <<
"G4VtkStore::Print() bakePipeMap size > " << bakePipeMap.size() <<
G4endl;
218 G4cout <<
"G4VtkStore::Print() ugridPipeMap size > " << ugridPipeMap.size() <<
G4endl;
219 G4cout <<
"G4VtkStore::Print() imagePipeMap size > " << imagePipeMap.size() <<
G4endl;
221 for (
const auto& it : polylinePipeMap)
224 for (
const auto& it : polyline2DPipeMap)
227 for (
const auto& it : circlePipeMap)
230 for (
const auto& it : squarePipeMap)
233 for (
const auto& it : separatePipeMap)
236 for (
const auto& it : tensorGlyphPipeMap)
239 for (
const auto& it : appendPipeMap)
242 for (
const auto& it : bakePipeMap)
245 for (
const auto& it : ugridPipeMap) {
250 for (
const auto& it : imagePipeMap)
269 std::shared_ptr<G4VtkPolydataPolylinePipeline> pl;
271 if (polylinePipeMap.find(hash) == polylinePipeMap.end()) {
273 pl = std::make_shared<G4VtkPolydataPolylinePipeline>(
G4String(
"name"), vc, pVA);
276 polylinePipeMap.insert(std::make_pair(hash, pl));
279 pl = polylinePipeMap[hash];
281 pl->SetPolydata(polyline);
286 std::shared_ptr<G4VtkPolydataPolyline2DPipeline> pl;
288 if (polyline2DPipeMap.find(hash) == polyline2DPipeMap.end()) {
290 pl = std::make_shared<G4VtkPolydataPolyline2DPipeline>(
G4String(
"name"), vc, pVA);
293 polyline2DPipeMap.insert(std::make_pair(hash, pl));
296 pl = polyline2DPipeMap[hash];
298 pl->SetPolydata(polyline);
318 auto pl = std::make_shared<G4VtkText2DPipeline>(text, vc, pVA);
319 text2DPipeMap.insert(std::make_pair(hash, pl));
324 auto pl = std::make_shared<G4VtkTextPipeline>(text, vc, pVA);
325 textPipeMap.insert(std::make_pair(hash, pl));
347 std::shared_ptr<G4VtkPolydataSpherePipeline> pl;
349 if (circlePipeMap.find(hash) == circlePipeMap.end()) {
351 pl = std::make_shared<G4VtkPolydataSpherePipeline>(
G4String(
"name"), vc, pVA);
354 circlePipeMap.insert(std::make_pair(hash, pl));
357 pl = circlePipeMap[hash];
383 std::size_t hash = std::hash<G4VisAttributes>{}(*pVA);
385 std::shared_ptr<G4VtkPolydataPolygonPipeline> pl;
386 if (squarePipeMap.find(hash) == squarePipeMap.end()) {
388 pl = std::make_shared<G4VtkPolydataPolygonPipeline>(
G4String(
"name"), vc, pVA);
391 squarePipeMap.insert(std::make_pair(hash, pl));
394 pl = squarePipeMap[hash];
414 auto pl = std::make_shared<G4VtkPolydataPipeline>(
G4String(
"name"), vc);
415 pl->SetPolydata(polyhedron);
417 separatePipeMap.insert(std::make_pair(hash, pl));
425 fInvObjTrans.
xx(), fInvObjTrans.
xy(), fInvObjTrans.
xz(),
426 fInvObjTrans.
yx(), fInvObjTrans.
yy(), fInvObjTrans.
yz(),
427 fInvObjTrans.
zx(), fInvObjTrans.
zy(), fInvObjTrans.
zz());
441 auto transform =
G4Translate3D(-centre.x(), -centre.y(), -centre.z());
446 polyhedronNew.Transform(transform);
449 std::shared_ptr<G4VtkPolydataInstanceTensorPipeline> pl;
451 if (tensorGlyphPipeMap.find(hash) == tensorGlyphPipeMap.end()) {
452 pl = std::make_shared<G4VtkPolydataInstanceTensorPipeline>(
G4String(
"name"), vc);
453 pl->SetPolydata(polyhedronNew);
454 tensorGlyphPipeMap.insert(std::make_pair(hash, pl));
457 pl = tensorGlyphPipeMap[hash];
465 pl->addInstance(fTransformNew.dx(), fTransformNew.dy(), fTransformNew.dz(),
466 fInvObjTrans.
xx(), fInvObjTrans.
xy(), fInvObjTrans.
xz(),
467 fInvObjTrans.
yx(), fInvObjTrans.
yy(), fInvObjTrans.
yz(),
468 fInvObjTrans.
zx(), fInvObjTrans.
zy(), fInvObjTrans.
zz(),
483 auto transform =
G4Translate3D(-centre.x(), -centre.y(), -centre.z());
488 polyhedronNew.Transform(transform);
491 std::shared_ptr<G4VtkPolydataInstanceAppendPipeline> pl;
493 if (appendPipeMap.find(hash) == appendPipeMap.end()) {
494 pl = std::make_shared<G4VtkPolydataInstanceAppendPipeline>(
G4String(
"name"), vc);
495 pl->SetPolydata(polyhedronNew);
496 appendPipeMap.insert(std::make_pair(hash, pl));
499 pl = appendPipeMap[hash];
504 pl->addInstance(fTransformNew.dx(), fTransformNew.dy(), fTransformNew.dz(),
505 fInvObjTrans.
xx(), fInvObjTrans.
xy(), fInvObjTrans.
xz(),
506 fInvObjTrans.
yx(), fInvObjTrans.
yy(), fInvObjTrans.
yz(),
507 fInvObjTrans.
zx(), fInvObjTrans.
zy(), fInvObjTrans.
zz(),
522 auto transform =
G4Translate3D(-centre.x(), -centre.y(), -centre.z());
527 polyhedronNew.Transform(transform);
539 std::shared_ptr<G4VtkPolydataInstanceBakePipeline> pl;
540 if (bakePipeMap.find(hash) == bakePipeMap.end()) {
541 pl = std::make_shared<G4VtkPolydataInstanceBakePipeline>(
G4String(
"none"), vc);
543 bakePipeMap.insert(std::make_pair(hash, pl));
546 pl = bakePipeMap[hash];
550 pl->SetPolydata(polyhedronNew);
552 pl->addInstance(fTransformNew.dx(), fTransformNew.dy(), fTransformNew.dz(),
553 fInvObjTrans.
xx(), fInvObjTrans.
xy(), fInvObjTrans.
xz(),
554 fInvObjTrans.
yx(), fInvObjTrans.
yy(), fInvObjTrans.
yz(),
555 fInvObjTrans.
zx(), fInvObjTrans.
zy(), fInvObjTrans.
zz(),
562 auto& containerName =
const_cast<G4String&
>(container->GetName());
564 auto pl = std::make_shared<G4VtkUnstructuredGridPipeline>(containerName,vc);
565 pl->SetUnstructuredGridData(mesh);
566 ugridPipeMap.insert(std::make_pair(
G4String(
"test"), pl));
571 if (type ==
"clipper") {
574 else if (type ==
"cutter") {
581 for (
const auto& v : separatePipeMap) {
583 v.second->GetFinalFilter(),
true);
584 clip_pl->SetPlane(plane);
585 v.second->AddChildPipeline(clip_pl);
588 for (
const auto& v : tensorGlyphPipeMap) {
590 v.second->GetFinalFilter());
591 clip_pl->SetPlane(plane);
592 v.second->AddChildPipeline(clip_pl);
595 for (
const auto& v : appendPipeMap) {
597 v.second->GetFinalFilter(),
true);
598 clip_pl->SetPlane(plane);
599 v.second->AddChildPipeline(clip_pl);
602 for (
const auto& v : bakePipeMap) {
604 v.second->GetFinalFilter(),
true);
605 clip_pl->SetPlane(plane);
606 v.second->AddChildPipeline(clip_pl);
612 for (
const auto& v : separatePipeMap) {
613 auto children = v.second->GetChildPipelines();
614 for (
auto c : children) {
615 if (c->GetName() == nameIn) {
622 for (
const auto& v : tensorGlyphPipeMap) {
623 auto children = v.second->GetChildPipelines();
624 for (
auto c : children) {
625 if (c->GetName() == nameIn) {
632 for (
const auto& v : appendPipeMap) {
633 auto children = v.second->GetChildPipelines();
634 for (
auto c : children) {
635 if (c->GetName() == nameIn) {
642 for (
const auto& v : bakePipeMap) {
643 auto children = v.second->GetChildPipelines();
644 for (
auto c : children) {
645 if (c->GetName() == nameIn) {
657 for (
const auto& v : separatePipeMap) {
659 v.second->GetFinalFilter(),
true);
660 cut_pl->SetPlane(plane);
661 v.second->AddChildPipeline(cut_pl);
664 for (
const auto& v : tensorGlyphPipeMap) {
667 cut_pl->SetPlane(plane);
668 v.second->AddChildPipeline(cut_pl);
671 for (
const auto& v : appendPipeMap) {
674 cut_pl->SetPlane(plane);
675 v.second->AddChildPipeline(cut_pl);
678 for (
const auto& v : bakePipeMap) {
681 cut_pl->SetPlane(plane);
682 v.second->AddChildPipeline(cut_pl);
688 for (
const auto& v : separatePipeMap) {
689 auto children = v.second->GetChildPipelines();
690 for (
auto c : children) {
691 if (c->GetName() == nameIn) {
698 for (
const auto& v : tensorGlyphPipeMap) {
699 auto children = v.second->GetChildPipelines();
700 for (
auto c : children) {
701 if (c->GetName() == nameIn) {
708 for (
const auto& v : appendPipeMap) {
709 auto children = v.second->GetChildPipelines();
710 for (
auto c : children) {
711 if (c->GetName() == nameIn) {
718 for (
const auto& v : bakePipeMap) {
719 auto children = v.second->GetChildPipelines();
720 for (
auto c : children) {
721 if (c->GetName() == nameIn) {
733 auto pl = std::make_shared<G4VtkImagePipeline>(
G4String(
"name"), vc);
734 pl->SetImage(fileName);
735 imagePipeMap.insert(std::make_pair(fileName, pl));
743 if (fileName.find(
"obj") != G4String::npos) {
744 vtkNew<vtkOBJReader> objReader;
745 objReader->SetFileName(fileName.c_str());
747 pd = objReader->GetOutput();
749 else if (fileName.find(
"ply") != G4String::npos) {
750 vtkNew<vtkPLYReader> plyReader;
751 plyReader->SetFileName(fileName.c_str());
753 pd = plyReader->GetOutput();
755 else if (fileName.find(
"stl") != G4String::npos) {
756 vtkNew<vtkSTLReader> stlReader;
757 stlReader->SetFileName(fileName.c_str());
759 pd = stlReader->GetOutput();
761 else if (fileName.find(
"vtp") != G4String::npos && fileName.find(
"vtu") != G4String::npos) {
762 G4cout <<
"G4VtkStore::AddNonG4ObjectPolydata> vtp/vtu Warning not yet implemented" <<
G4endl;
765 auto pl = std::make_shared<G4VtkPolydataPipeline>(
G4String(
"name"), vc);
771 fInvObjTrans.
xx(), fInvObjTrans.
xy(), fInvObjTrans.
xz(),
772 fInvObjTrans.
yx(), fInvObjTrans.
yy(), fInvObjTrans.
yz(),
773 fInvObjTrans.
zx(), fInvObjTrans.
zy(), fInvObjTrans.
zz());
779 G4double maxBound[6] = {1e99, -1e99, 1e99, -1e99, 1e99, -1e99};
781 for (
const auto& v : separatePipeMap) {
782 auto b = v.second->GetBounds();
786 for (
const auto& v : tensorGlyphPipeMap) {
787 auto b = v.second->GetBounds();
791 for (
const auto& v : appendPipeMap) {
792 auto b = v.second->GetBounds();
796 for (
const auto& v : bakePipeMap) {
797 auto b = v.second->GetBounds();
801 maxBoundIn[0] = maxBound[0];
802 maxBoundIn[1] = maxBound[1];
803 maxBoundIn[2] = maxBound[2];
804 maxBoundIn[3] = maxBound[3];
805 maxBoundIn[4] = maxBound[4];
806 maxBoundIn[5] = maxBound[5];
811 for (
const auto& it : polylinePipeMap)
812 renderer->AddActor(it.second->GetActor());
813 for (
const auto& it : polyline2DPipeMap)
814 renderer->AddActor(it.second->GetActor());
815 for (
const auto& it : circlePipeMap)
816 renderer->AddActor(it.second->GetActor());
817 for (
const auto& it : squarePipeMap)
818 renderer->AddActor(it.second->GetActor());
819 for (
const auto& it : textPipeMap)
820 renderer->AddActor(it.second->GetActor());
821 for (
const auto& it : text2DPipeMap)
822 renderer->AddActor(it.second->GetActor());
823 for (
const auto& it : separatePipeMap)
824 renderer->AddActor(it.second->GetActor());
825 for (
const auto& it : tensorGlyphPipeMap)
826 renderer->AddActor(it.second->GetActor());
827 for (
const auto& it : appendPipeMap)
828 renderer->AddActor(it.second->GetActor());
829 for (
const auto& it : bakePipeMap)
830 renderer->AddActor(it.second->GetActor());
void MaxBounds(G4double *maxBound, G4double *boundToCheck)
G4GLOB_DLL std::ostream G4cout
G4double GetAlpha() const
G4double GetGreen() const
G4VPhysicalVolume * GetContainerVolume() const
G4Point3D GetPosition() const
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
const G4Colour & GetColour() const
const G4VisAttributes * GetVisAttributes() const
void SetPlane(const G4Plane3D &plane)
void SetPlane(const G4Plane3D &plane)
static std::size_t MakeHash(const G4Polyhedron &p, const G4VtkVisContext &vc)
static std::size_t MakeHash(const G4Polyhedron &p, const G4VtkVisContext &vc)
static std::size_t MakeHash(const G4Polyhedron &p, const G4VtkVisContext &vc)
static std::size_t MakeHash(const G4Polyhedron &p, const G4VtkVisContext &vc)
static std::size_t MakeHash(const G4VisAttributes *va)
static std::size_t MakeHash(const G4VisAttributes *va)
static std::size_t MakeHash(const G4VisAttributes *va)
void UpdateCutter(G4String name, const G4Plane3D &plane)
void AddNonG4ObjectImage(const G4String &fileName, const G4VtkVisContext &vc)
G4VtkStore(G4String name)
void AddToRenderer(vtkRenderer *renderer)
void UpdateClipper(G4String name, const G4Plane3D &plane)
void AddClipper(G4String name, const G4Plane3D &plane)
void AddPrimitiveSeparate(const G4Polyhedron &polyhedron, const G4VtkVisContext &vc)
void RemoveCutter(G4String name)
void GetBounds(G4double maxBound[6])
void AddPrimitiveTensorGlyph(const G4Polyhedron &polyhedron, const G4VtkVisContext &vc)
void UpdatePlanePipelines(G4String name, G4String type, const G4Plane3D)
void AddPrimitiveTransformBake(const G4Polyhedron &polyhedron, const G4VtkVisContext &vc)
void AddPrimitiveAppend(const G4Polyhedron &polyhedron, const G4VtkVisContext &vc)
void AddCompound(const G4Mesh &mesh, const G4VtkVisContext &vc)
void AddPrimitive(const G4Polyline &polyline, const G4VtkVisContext &vc)
void AddCutter(G4String name, const G4Plane3D &plane)
void RemoveClipper(G4String name)
void AddNonG4ObjectPolydata(const G4String fileName, const G4VtkVisContext &vc)
static std::size_t MakeHash(const G4Text &text, const G4VtkVisContext &vc, const G4VisAttributes *pVA)
const G4Transform3D & fTransform
const G4VtkViewer * fViewer
G4Point3D vertexUnweightedMean() const
G4int GetNoFacets() const