Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoXtru.h
Go to the documentation of this file.
1// @(#)root/geom:$Id$
2// Author: Mihaela Gheata 24/01/04
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TGeoXtru
13#define ROOT_TGeoXtru
14
15#include "TGeoBBox.h"
16
17#include <mutex>
18#include <vector>
19
20class TGeoPolygon;
21
22class TGeoXtru : public TGeoBBox {
23public:
24 struct ThreadData_t {
25 Int_t fSeg; // !current segment [0,fNvert-1]
26 Int_t fIz; // !current z plane [0,fNz-1]
27 Double_t *fXc; // ![fNvert] current X positions for polygon vertices
28 Double_t *fYc; // ![fNvert] current Y positions for polygon vertices
29 TGeoPolygon *fPoly; // !polygon defining section shape
30
33 };
35 void ClearThreadData() const override;
36 void CreateThreadData(Int_t nthreads) override;
37
38protected:
39 // data members
40 Int_t fNvert; // number of vertices of the 2D polygon (at least 3)
41 Int_t fNz; // number of z planes (at least two)
42 Double_t fZcurrent; // current Z position
43 Double_t *fX; //[fNvert] X positions for polygon vertices
44 Double_t *fY; //[fNvert] Y positions for polygon vertices
45 Double_t *fZ; //[fNz] array of Z planes positions
46 Double_t *fScale; //[fNz] array of scale factors (for each Z)
47 Double_t *fX0; //[fNz] array of X offsets (for each Z)
48 Double_t *fY0; //[fNz] array of Y offsets (for each Z)
49
50 mutable std::vector<ThreadData_t *> fThreadData; //! Navigation data per thread
51 mutable Int_t fThreadSize; //! size of thread-specific array
52 mutable std::mutex fMutex; //! mutex for thread data
53
54 TGeoXtru(const TGeoXtru &) = delete;
55 TGeoXtru &operator=(const TGeoXtru &) = delete;
56
57 // methods
59 DistToPlane(const Double_t *point, const Double_t *dir, Int_t iz, Int_t ivert, Double_t stepmax, Bool_t in) const;
60 void GetPlaneVertices(Int_t iz, Int_t ivert, Double_t *vert) const;
61 void GetPlaneNormal(const Double_t *vert, Double_t *norm) const;
62 Bool_t IsPointInsidePlane(const Double_t *point, Double_t *vert, Double_t *norm) const;
63 Double_t SafetyToSector(const Double_t *point, Int_t iz, Double_t safmin, Bool_t in);
64 void SetIz(Int_t iz);
65 void SetSeg(Int_t iseg);
66
67public:
68 // constructors
69 TGeoXtru();
70 TGeoXtru(Int_t nz);
71 TGeoXtru(Double_t *param);
72 // destructor
73 ~TGeoXtru() override;
74 // methods
75 Double_t Capacity() const override;
76 void ComputeBBox() override;
77 void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override;
78 void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize) override;
79 Bool_t Contains(const Double_t *point) const override;
80 void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const override;
81 Bool_t DefinePolygon(Int_t nvert, const Double_t *xv, const Double_t *yv);
82 virtual void DefineSection(Int_t snum, Double_t z, Double_t x0 = 0., Double_t y0 = 0., Double_t scale = 1.);
83 Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact = 1, Double_t step = TGeoShape::Big(),
84 Double_t *safe = nullptr) const override;
85 void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize,
86 Double_t *step) const override;
87 Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact = 1,
88 Double_t step = TGeoShape::Big(), Double_t *safe = nullptr) const override;
89 void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize,
90 Double_t *step) const override;
91 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
92 void DrawPolygon(Option_t *option = "");
93 const TBuffer3D &GetBuffer3D(Int_t reqSections, Bool_t localFrame) const override;
94 // virtual Int_t GetByteCount() const {return 60+12*fNz;}
95 Int_t GetNz() const { return fNz; }
96 Int_t GetNvert() const { return fNvert; }
97 Double_t GetX(Int_t i) const { return (i < fNvert && i > -1 && fX) ? fX[i] : -1.0E10; }
98 Double_t GetY(Int_t i) const { return (i < fNvert && i > -1 && fY) ? fY[i] : -1.0E10; }
99 Double_t GetXOffset(Int_t i) const { return (i < fNz && i > -1 && fX0) ? fX0[i] : 0.0; }
100 Double_t GetYOffset(Int_t i) const { return (i < fNz && i > -1 && fY0) ? fY0[i] : 0.0; }
101 Double_t GetScale(Int_t i) const { return (i < fNz && i > -1 && fScale) ? fScale[i] : 1.0; }
102 Double_t *GetZ() const { return fZ; }
103 Double_t GetZ(Int_t ipl) const;
104 TGeoShape *GetMakeRuntimeShape(TGeoShape * /*mother*/, TGeoMatrix * /*mat*/) const override { return nullptr; }
105 void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const override;
106 Int_t GetNmeshVertices() const override;
107 void InspectShape() const override;
108 TBuffer3D *MakeBuffer3D() const override;
109 Double_t &Z(Int_t ipl) { return fZ[ipl]; }
110 Double_t Safety(const Double_t *point, Bool_t in = kTRUE) const override;
111 void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const override;
112 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
113 void SetCurrentZ(Double_t z, Int_t iz);
114 void SetCurrentVertices(Double_t x0, Double_t y0, Double_t scale);
115 void SetDimensions(Double_t *param) override;
116 void SetPoints(Double_t *points) const override;
117 void SetPoints(Float_t *points) const override;
118 void SetSegsAndPols(TBuffer3D &buff) const override;
119 void Sizeof3D() const override;
120
121 ClassDefOverride(TGeoXtru, 3) // extruded polygon class
122};
123
124#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Generic 3D primitive description class.
Definition TBuffer3D.h:18
Box class.
Definition TGeoBBox.h:17
Geometrical transformation package.
Definition TGeoMatrix.h:38
An arbitrary polygon defined by vertices.
Definition TGeoPolygon.h:19
Base abstract class for all shapes.
Definition TGeoShape.h:25
static Double_t Big()
Definition TGeoShape.h:87
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
Definition TGeoXtru.h:22
Double_t * fScale
Definition TGeoXtru.h:46
Int_t GetNmeshVertices() const override
Return number of vertices of the mesh representation.
Double_t * fX0
Definition TGeoXtru.h:47
void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Compute distance from array of input points having directions specified by dirs. Store output in dist...
TGeoXtru()
dummy ctor
Definition TGeoXtru.cxx:188
ThreadData_t & GetThreadData() const
Definition TGeoXtru.cxx:122
void ClearThreadData() const override
Definition TGeoXtru.cxx:132
Double_t Capacity() const override
Compute capacity [length^3] of this shape.
Definition TGeoXtru.cxx:297
Int_t fNz
Definition TGeoXtru.h:41
Double_t & Z(Int_t ipl)
Definition TGeoXtru.h:109
Double_t * fZ
Definition TGeoXtru.h:45
void ComputeBBox() override
compute bounding box of the pcon
Definition TGeoXtru.cxx:320
void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const override
Check the inside status for each of the points in the array.
Bool_t Contains(const Double_t *point) const override
test if point is inside this shape
Definition TGeoXtru.cxx:380
Int_t fThreadSize
Navigation data per thread.
Definition TGeoXtru.h:51
Int_t fNvert
Definition TGeoXtru.h:40
void SetCurrentVertices(Double_t x0, Double_t y0, Double_t scale)
Set current vertex coordinates according X0, Y0 and SCALE.
TGeoXtru(const TGeoXtru &)=delete
mutex for thread data
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override
Compute normal to closest surface from POINT.
Definition TGeoXtru.cxx:358
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void GetPlaneVertices(Int_t iz, Int_t ivert, Double_t *vert) const
Returns (x,y,z) of 3 vertices of the surface defined by Z sections (iz, iz+1) and polygon vertices (i...
Definition TGeoXtru.cxx:859
Double_t GetYOffset(Int_t i) const
Definition TGeoXtru.h:100
void InspectShape() const override
Print actual Xtru parameters.
Definition TGeoXtru.cxx:939
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
compute closest distance from point px,py to each corner
Definition TGeoXtru.cxx:416
Double_t * GetZ() const
Definition TGeoXtru.h:102
Bool_t IsPointInsidePlane(const Double_t *point, Double_t *vert, Double_t *norm) const
Check if the quadrilateral defined by VERT contains a coplanar POINT.
Definition TGeoXtru.cxx:914
void Sizeof3D() const override
fill size of this 3-D object
~TGeoXtru() override
destructor
Definition TGeoXtru.cxx:265
const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const override
Fills a static 3D buffer and returns a reference.
Int_t GetNvert() const
Definition TGeoXtru.h:96
Double_t * fY0
Definition TGeoXtru.h:48
Bool_t DefinePolygon(Int_t nvert, const Double_t *xv, const Double_t *yv)
Creates the polygon representing the blueprint of any Xtru section.
Definition TGeoXtru.cxx:759
void SetCurrentZ(Double_t z, Int_t iz)
Recompute current section vertices for a given Z position within range of section iz.
virtual void DefineSection(Int_t snum, Double_t z, Double_t x0=0., Double_t y0=0., Double_t scale=1.)
defines z position of a section plane, rmin and rmax at this z.
Definition TGeoXtru.cxx:793
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
computes the closest distance from given point to this shape, according to option.
void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize) override
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
Double_t GetY(Int_t i) const
Definition TGeoXtru.h:98
void SetDimensions(Double_t *param) override
void DrawPolygon(Option_t *option="")
Draw the section polygon.
Definition TGeoXtru.cxx:425
void SetPoints(Double_t *points) const override
create polycone mesh points
Double_t SafetyToSector(const Double_t *point, Int_t iz, Double_t safmin, Bool_t in)
Compute safety to sector iz, returning also the closest segment index.
Double_t * fY
Definition TGeoXtru.h:44
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 override
compute distance from inside point to surface of the polycone locate Z segment
Definition TGeoXtru.cxx:501
Double_t * fX
Definition TGeoXtru.h:43
void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Compute distance from array of input points having directions specified by dirs. Store output in dist...
TBuffer3D * MakeBuffer3D() const override
Creates a TBuffer3D describing this shape.
Definition TGeoXtru.cxx:957
std::vector< ThreadData_t * > fThreadData
Definition TGeoXtru.h:50
Double_t DistToPlane(const Double_t *point, const Double_t *dir, Int_t iz, Int_t ivert, Double_t stepmax, Bool_t in) const
Compute distance to a Xtru lateral surface.
Definition TGeoXtru.cxx:435
void SetSegsAndPols(TBuffer3D &buff) const override
Fill TBuffer3D structure for segments and polygons.
Definition TGeoXtru.cxx:978
Double_t GetScale(Int_t i) const
Definition TGeoXtru.h:101
void SetSeg(Int_t iseg)
Set current segment.
Definition TGeoXtru.cxx:180
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 override
compute distance from outside point to surface of the tube Warning("DistFromOutside",...
Definition TGeoXtru.cxx:626
TGeoShape * GetMakeRuntimeShape(TGeoShape *, TGeoMatrix *) const override
In case shape has some negative parameters, these has to be computed in order to fit the mother.
Definition TGeoXtru.h:104
std::mutex fMutex
size of thread-specific array
Definition TGeoXtru.h:52
Double_t GetXOffset(Int_t i) const
Definition TGeoXtru.h:99
void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const override
Returns numbers of vertices, segments and polygons composing the shape mesh.
void GetPlaneNormal(const Double_t *vert, Double_t *norm) const
Returns normal vector to the planar quadrilateral defined by vector VERT.
Definition TGeoXtru.cxx:832
void SetIz(Int_t iz)
Set current z-plane.
Definition TGeoXtru.cxx:173
Int_t GetNz() const
Definition TGeoXtru.h:95
void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const override
Compute safe distance from each of the points in the input array.
TGeoXtru & operator=(const TGeoXtru &)=delete
void CreateThreadData(Int_t nthreads) override
Create thread data for n threads max.
Definition TGeoXtru.cxx:147
Double_t GetX(Int_t i) const
Definition TGeoXtru.h:97
Double_t fZcurrent
Definition TGeoXtru.h:42
~ThreadData_t()
Destructor.
Definition TGeoXtru.cxx:113
TGeoPolygon * fPoly
Definition TGeoXtru.h:29
ThreadData_t()
Constructor.
Definition TGeoXtru.cxx:108