18#include "VecGeom/volumes/PlacedVolume.h"
19#include "VecGeom/volumes/UnplacedVolume.h"
20#include "VecGeom/volumes/UnplacedBox.h"
21#include "VecGeom/volumes/UnplacedTube.h"
22#include "VecGeom/volumes/UnplacedCone.h"
23#include "VecGeom/volumes/UnplacedParaboloid.h"
24#include "VecGeom/volumes/UnplacedParallelepiped.h"
25#include "VecGeom/volumes/UnplacedPolyhedron.h"
26#include "VecGeom/volumes/UnplacedTrd.h"
27#include "VecGeom/volumes/UnplacedOrb.h"
28#include "VecGeom/volumes/UnplacedSphere.h"
29#include "VecGeom/volumes/UnplacedBooleanVolume.h"
30#include "VecGeom/volumes/UnplacedTorus2.h"
31#include "VecGeom/volumes/UnplacedTrapezoid.h"
32#include "VecGeom/volumes/UnplacedPolycone.h"
33#include "VecGeom/volumes/UnplacedScaledShape.h"
34#include "VecGeom/volumes/UnplacedGenTrap.h"
35#include "VecGeom/volumes/UnplacedSExtruVolume.h"
36#include "VecGeom/volumes/UnplacedTessellated.h"
37#include "VecGeom/volumes/UnplacedEllipticalTube.h"
38#include "VecGeom/volumes/UnplacedHype.h"
39#include "VecGeom/volumes/UnplacedCutTube.h"
69 :
TGeoBBox(shape->GetName(), 0, 0, 0), fVGShape(vgshape),
fShape(shape)
105 vecgeom::cxx::VUnplacedVolume *unplaced =
Convert(shape);
110 vecgeom::cxx::LogicalVolume *lvol =
new vecgeom::cxx::LogicalVolume(
"", unplaced);
111 return (lvol->Place());
121 vecgeom::cxx::Transformation3D *
const transformation =
122 new vecgeom::cxx::Transformation3D(t[0], t[1], t[2],
r[0],
r[1],
r[2],
r[3],
r[4],
r[5],
r[6],
r[7],
r[8]);
123 return transformation;
132 using Vector3D = vecgeom::cxx::Vector3D<Precision>;
133 VUnplacedVolume *unplaced_volume =
nullptr;
138 unplaced_volume = GeoManager::MakeInstance<UnplacedBox>(
box->GetDX(),
box->GetDY(),
box->GetDZ());
145 GeoManager::MakeInstance<UnplacedTube>(tube->
GetRmin(), tube->
GetRmax(), tube->
GetDz(), 0., kTwoPi);
151 unplaced_volume = GeoManager::MakeInstance<UnplacedTube>(tube->
GetRmin(), tube->
GetRmax(), tube->
GetDz(),
159 unplaced_volume = GeoManager::MakeInstance<UnplacedCone>(
174 unplaced_volume = GeoManager::MakeInstance<UnplacedParaboloid>(
p->GetRlo(),
p->GetRhi(),
p->GetDz());
180 unplaced_volume = GeoManager::MakeInstance<UnplacedParallelepiped>(
p->GetX(),
p->GetY(),
p->GetZ(),
p->GetAlpha(),
181 p->GetTheta(),
p->GetPhi());
187 unplaced_volume = GeoManager::MakeInstance<UnplacedPolyhedron>(pgon->
GetPhi1(),
201 GeoManager::MakeInstance<UnplacedTrd>(
p->GetDx1(),
p->GetDx2(),
p->GetDy1(),
p->GetDy2(),
p->GetDz());
207 unplaced_volume = GeoManager::MakeInstance<UnplacedTrd>(
p->GetDx1(),
p->GetDx2(),
p->GetDy(),
p->GetDz());
213 unplaced_volume = GeoManager::MakeInstance<UnplacedTrapezoid>(
214 p->GetDz(),
p->GetTheta() * kDegToRad,
p->GetPhi() * kDegToRad,
p->GetH1(),
p->GetBl1(),
p->GetTl1(),
215 std::tan(
p->GetAlpha1() * kDegToRad),
p->GetH2(),
p->GetBl2(),
p->GetTl2(),
216 std::tan(
p->GetAlpha2() * kDegToRad));
223 if (
p->GetRmin() == 0. &&
p->GetTheta2() -
p->GetTheta1() == 180. &&
p->GetPhi2() -
p->GetPhi1() == 360.) {
224 unplaced_volume = GeoManager::MakeInstance<UnplacedOrb>(
p->GetRmax());
226 unplaced_volume = GeoManager::MakeInstance<UnplacedSphere>(
227 p->GetRmin(),
p->GetRmax(),
p->GetPhi1() * kDegToRad, (
p->GetPhi2() -
p->GetPhi1()) * kDegToRad,
228 p->GetTheta1() * kDegToRad, (
p->GetTheta2() -
p->GetTheta1()) * kDegToRad);
242 if (!leftunplaced || !rightunplaced) {
247 delete rightunplaced;
251 assert(leftunplaced !=
nullptr);
252 assert(rightunplaced !=
nullptr);
255 VPlacedVolume *
const leftplaced = (
new LogicalVolume(
"inner_virtual", leftunplaced))->Place(lefttrans);
257 VPlacedVolume *
const rightplaced = (
new LogicalVolume(
"inner_virtual", rightunplaced))->Place(righttrans);
262 GeoManager::MakeInstance<UnplacedBooleanVolume<kSubtraction>>(kSubtraction, leftplaced, rightplaced);
265 GeoManager::MakeInstance<UnplacedBooleanVolume<kIntersection>>(kIntersection, leftplaced, rightplaced);
267 unplaced_volume = GeoManager::MakeInstance<UnplacedBooleanVolume<kUnion>>(kUnion, leftplaced, rightplaced);
275 unplaced_volume = GeoManager::MakeInstance<UnplacedTorus2>(
p->GetRmin(),
p->GetRmax(),
p->GetR(),
276 p->GetPhi1() * kDegToRad,
p->GetDphi() * kDegToRad);
282 unplaced_volume = GeoManager::MakeInstance<UnplacedPolycone>(
p->GetPhi1() * kDegToRad,
p->GetDphi() * kDegToRad,
283 p->GetNz(),
p->GetZ(),
p->GetRmin(),
p->GetRmax());
290 VUnplacedVolume *referenced_shape =
Convert(
p->GetShape());
291 if (!referenced_shape)
293 const double *scale_root =
p->GetScale()->GetScale();
295 GeoManager::MakeInstance<UnplacedScaledShape>(referenced_shape, scale_root[0], scale_root[1], scale_root[2]);
301 auto low =
p->GetNlow();
302 auto high =
p->GetNhigh();
303 auto const bottomNormal = Vector3D{low[0], low[1], low[2]};
304 auto const topNormal = Vector3D{high[0], high[1], high[2]};
307 GeoManager::MakeInstance<UnplacedCutTube>(
p->GetRmin(),
p->GetRmax(),
p->GetDz(), kDegToRad *
p->GetPhi1(),
308 kDegToRad * (
p->GetPhi2() -
p->GetPhi1()), bottomNormal, topNormal);
314 unplaced_volume = GeoManager::MakeInstance<UnplacedEllipticalTube>(
p->GetA(),
p->GetB(),
p->GetDz());
320 unplaced_volume = GeoManager::MakeInstance<UnplacedHype>(
p->GetRmin(),
p->GetRmax(), kDegToRad *
p->GetStIn(),
321 kDegToRad *
p->GetStOut(),
p->GetDz());
328 const double *vertices =
p->GetVertices();
329 Precision verticesx[8], verticesy[8];
330 for (
auto ivert = 0; ivert < 8; ++ivert) {
331 verticesx[ivert] = vertices[2 * ivert];
332 verticesy[ivert] = vertices[2 * ivert + 1];
334 unplaced_volume = GeoManager::MakeInstance<UnplacedGenTrap>(verticesx, verticesy,
p->GetDz());
341 if (
p->GetNz() == 2) {
343 size_t Nvert = (size_t)
p->GetNvert();
344 double *
x =
new double[Nvert];
345 double *
y =
new double[Nvert];
346 for (
size_t i = 0; i < Nvert; ++i) {
351 if (PlanarPolygon::GetOrientation(
x,
y, Nvert) > 0.) {
353 for (
size_t i = 0; i < Nvert; ++i) {
354 x[Nvert - 1 - i] =
p->GetX(i);
355 y[Nvert - 1 - i] =
p->GetY(i);
359 GeoManager::MakeInstance<UnplacedSExtruVolume>(
p->GetNvert(),
x,
y,
p->GetZ()[0],
p->GetZ()[1]);
368 unplaced_volume = GeoManager::MakeInstance<UnplacedTessellated>();
369 auto vtsl =
static_cast<UnplacedTessellated *
>(unplaced_volume);
371 for (
auto i = 0; i < tsl->
GetNfacets(); ++i) {
372 auto const &facet = tsl->
GetFacet(i);
374 auto const &
v0 = facet.GetVertex(0);
375 auto const &
v1 = facet.GetVertex(1);
376 auto const &
v2 = facet.GetVertex(2);
378 vtsl->AddTriangularFacet(Vector3D(
v0[0],
v0[1],
v0[2]), Vector3D(
v1[0],
v1[1],
v1[2]),
379 Vector3D(
v2[0],
v2[1],
v2[2]));
380 }
else if (nvert == 4) {
381 auto const &
v3 = facet.GetVertex(3);
382 vtsl->AddQuadrilateralFacet(Vector3D(
v0[0],
v0[1],
v0[2]), Vector3D(
v1[0],
v1[1],
v1[2]),
383 Vector3D(
v2[0],
v2[1],
v2[2]), Vector3D(
v3[0],
v3[1],
v3[2]));
392 if (!unplaced_volume) {
393 printf(
"Unsupported shape for ROOT shape \"%s\" of type %s. "
394 "Using ROOT implementation.\n",
399 return (unplaced_volume);
423 vecgeom::cxx::Vector3D<Double_t> vnorm;
424 fVGShape->Normal(vecgeom::cxx::Vector3D<Double_t>(point[0], point[1], point[2]), vnorm);
426 norm[1] = vnorm.y(), norm[2] = vnorm.z();
434 return (
fVGShape->Contains(vecgeom::cxx::Vector3D<Double_t>(point[0], point[1], point[2])));
442 Double_t dist =
fVGShape->DistanceToOut(vecgeom::cxx::Vector3D<Double_t>(point[0], point[1], point[2]),
443 vecgeom::cxx::Vector3D<Double_t>(dir[0], dir[1], dir[2]), step);
444 return ((dist < 0.) ? 0. : dist);
452 Double_t dist =
fVGShape->DistanceToIn(vecgeom::cxx::Vector3D<Double_t>(point[0], point[1], point[2]),
453 vecgeom::cxx::Vector3D<Double_t>(dir[0], dir[1], dir[2]), step);
454 return ((dist < 0.) ? 0. : dist);
461 Double_t safety = (in) ?
fVGShape->SafetyToOut(vecgeom::cxx::Vector3D<Double_t>(point[0], point[1], point[2]))
462 :
fVGShape->SafetyToIn(vecgeom::cxx::Vector3D<Double_t>(point[0], point[1], point[2]));
463 return ((safety < 0.) ? 0. : safety);
471 fVGShape->GetUnplacedVolume()->Print();
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
An arbitrary trapezoid with less than 8 vertices standing on two parallel planes perpendicular to Z a...
void SetBoxDimensions(Double_t dx, Double_t dy, Double_t dz, Double_t *origin=nullptr)
Set parameters of the box.
Base class for Boolean operations between two shapes.
virtual EGeoBoolType GetBooleanOperator() const =0
TGeoMatrix * GetRightMatrix() const
TGeoShape * GetLeftShape() const
TGeoMatrix * GetLeftMatrix() const
TGeoShape * GetRightShape() const
Composite shapes are Boolean combinations of two or more shape components.
TGeoBoolNode * GetBoolNode() const
A cone segment is a cone having a range in phi.
The cones are defined by 5 parameters:
virtual Double_t GetRmax2() const
virtual Double_t GetDz() const
virtual Double_t GetRmin2() const
virtual Double_t GetRmin1() const
virtual Double_t GetRmax1() const
The cut tubes constructor has the form:
An elliptical tube is defined by the two semi-axes A and B.
A hyperboloid is represented as a solid limited by two planes perpendicular to the Z axis (top and bo...
Geometrical transformation package.
virtual const Double_t * GetTranslation() const =0
virtual const Double_t * GetRotationMatrix() const =0
A paraboloid is defined by the revolution surface generated by a parabola and is bounded by two plane...
A polycone is represented by a sequence of tubes/cones, glued together at defined Z planes.
Double_t * GetRmax() const
Double_t * GetRmin() const
Polygons are defined in the same way as polycones, the difference being just that the segments betwee...
A shape scaled by a TGeoScale transformation.
Base abstract class for all shapes.
virtual TClass * IsA() const
virtual const char * GetName() const
Get the shape name.
virtual void ComputeBBox()=0
TGeoSphere are not just balls having internal and external radii, but sectors of a sphere having defi...
const TGeoFacet & GetFacet(int i) const
The torus is defined by its axial radius, its inner and outer radius.
A trapezoid with only X varying with Z.
A trapezoid with only X varying with Z.
A tube segment is a tube having a range in phi.
virtual Double_t GetRmin() const
virtual Double_t GetDz() const
virtual Double_t GetRmax() const
Bridge class for using a VecGeom solid as TGeoShape.
static vecgeom::cxx::VPlacedVolume * CreateVecGeomSolid(TGeoShape *shape)
Conversion method to create VecGeom solid corresponding to TGeoShape.
static TGeoVGShape * Create(TGeoShape *shape)
Factory creating TGeoVGShape from a Root shape.
virtual void ComputeBBox()
Compute bounding box.
virtual Bool_t Contains(const Double_t *point) const
Test if point is inside this shape.
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const
Compute distance from inside point to surface of the box.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Normal computation.
virtual ~TGeoVGShape()
Destructor.
virtual Double_t Capacity() const
Returns analytic capacity of the solid.
vecgeom::cxx::VPlacedVolume * fVGShape
virtual void InspectShape() const
Print info about the VecGeom solid.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Computes the closest distance from given point to this shape.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const
Compute distance from outside point to surface of the box.
static vecgeom::cxx::Transformation3D * Convert(TGeoMatrix const *const geomatrix)
Convert a TGeoMatrix to a TRansformation3D.
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
virtual const char * ClassName() const
Returns name of class to which the object belongs.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)