26#include "G4QuadrangularFacet.hh"
27#include "G4ReflectedSolid.hh"
28#include "G4TessellatedSolid.hh"
29#include "G4TriangularFacet.hh"
37 const std::string& name, std::vector<std::vector<VGM::ThreeVector> > facets)
39 VGM::ITessellatedSolid(),
48 fTessellatedSolid =
new G4TessellatedSolid(name);
52 for (G4int i = 0; i < G4int(facets.size()); i++) {
54 std::vector<VGM::ThreeVector> facet = facets[i];
57 if (facet.size() != 3 && facet.size() != 4) {
58 std::cerr <<
"+++ Error +++" << std::endl;
59 std::cerr <<
" Number of vertices in a facet = " << facet.size()
60 <<
" has to be == 3 or 4" << std::endl;
64 if (facet.size() == 3) {
69 fTessellatedSolid->AddFacet(
new G4TriangularFacet(
88 fTessellatedSolid->AddFacet(
new G4QuadrangularFacet(
104 fTessellatedSolid->SetSolidClosed(
true);
113 G4TessellatedSolid* tessellated, G4ReflectedSolid* reflTessellated)
115 VGM::ITessellatedSolid(),
117 fName(tessellated->GetName()),
119 fTessellatedSolid(tessellated)
123 if (reflTessellated) {
135 VGM::ITessellatedSolid(),
147 VGM::ITessellatedSolid(rhs),
148 BaseVGM::VTessellatedSolid(rhs),
163void Geant4GM::TessellatedSolid::CheckFacetIndex(
int ifacet)
const
165 if (ifacet < 0 || ifacet > NofFacets()) {
166 std::cerr <<
"+++ Error +++" << std::endl;
167 std::cerr <<
" Wrong facet index: " << ifacet << std::endl;
171 G4VFacet* facet = fTessellatedSolid->GetFacet(ifacet);
173 std::cerr <<
"+++ Error +++" << std::endl;
174 std::cerr <<
" Facet with index: " << ifacet <<
" not found."
181void Geant4GM::TessellatedSolid::CheckVertexIndex(
int ifacet,
int index)
const
183 CheckFacetIndex(ifacet);
185 if (index < 0 || index > NofVertices(ifacet)) {
186 std::cerr <<
"+++ Error +++" << std::endl;
187 std::cerr <<
" Wrong vertex index: " << index <<
" in " << ifacet
188 <<
" th facet." << std::endl;
196 return fTessellatedSolid->GetName();
202 return fTessellatedSolid->GetNumberOfFacets();
208 CheckFacetIndex(ifacet);
210 G4VFacet* facet = fTessellatedSolid->GetFacet(ifacet);
212 return facet->GetNumberOfVertices();
218 CheckVertexIndex(ifacet, index);
220 G4VFacet* facet = fTessellatedSolid->GetFacet(ifacet);
static double Length()
Return CLHEP default length unit in VGM units.
static SolidMap * Instance()
void AddSolid(VGM::ISolid *, G4VSolid *)
VGM implementation for Geant4 tessellated solid.
virtual int NofVertices(int ifacet) const
Return the number of vertices in the the ifacet-th facet.
virtual VGM::ThreeVector Vertex(int ifacet, int index) const
Return the index-th vertex in the ifacet-th facet.
virtual int NofFacets() const
Return the number of facets.
virtual std::string Name() const
Return the name of this solid.
virtual ~TessellatedSolid()
std::vector< double > ThreeVector