Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ClippablePolygon.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4ClippablePolygon
27//
28// Class description:
29//
30// A utility class of a polygon that can be clipped by a voxel.
31
32// Author: David C. Williams (UCSC), 1998
33// --------------------------------------------------------------------
34#ifndef G4CLIPPABLEPOLYGON_HH
35#define G4CLIPPABLEPOLYGON_HH
36
37#include <vector>
38
39#include "G4Types.hh"
40#include "geomdefs.hh"
41#include "G4ThreeVector.hh"
42
44class G4VoxelLimits;
45
46/**
47 * @brief G4ClippablePolygon in a utility class defining a polygon
48 * that can be clipped by a voxel.
49 */
50
52{
53 using G4ThreeVectorList = std::vector<G4ThreeVector>;
54
55 public:
56
57 /**
58 * Default Constructor and Destructor.
59 */
62
63 /**
64 * Adds a vertex to collection.
65 */
66 void AddVertexInOrder( const G4ThreeVector& vertex );
67
68 /**
69 * Clears the collection of vertices.
70 */
71 void ClearAllVertices();
72
73 /**
74 * Accessor and setter for normal vector.
75 */
76 inline const G4ThreeVector GetNormal() const;
77 inline void SetNormal( const G4ThreeVector& newNormal );
78
79 /**
80 * Clips the polygon along the Cartesian axes, as specified in 'voxelLimit'.
81 * @returns true if the collection of vertices is not empty.
82 */
83 G4bool Clip( const G4VoxelLimits& voxelLimit );
84
85 /**
86 * Clips the polygon while ignoring the indicated axis.
87 * @returns true if the collection of vertices is not empty.
88 */
89 G4bool PartialClip( const G4VoxelLimits& voxelLimit,
90 const EAxis IgnoreMe );
91
92 /**
93 * Clips the polygon along just one axis, as specified in 'voxelLimit'.
94 */
95 void ClipAlongOneAxis( const G4VoxelLimits& voxelLimit,
96 const EAxis axis );
97
98 /**
99 * Computes the polygon extent along the specified 'axis'.
100 * @param[in] axis The Cartesian axis along which computing the extent.
101 * @param[out] min The minimum extent value.
102 * @param[out] max The maximum extent value.
103 * @returns false if invalid polygon (no vertices).
104 */
105 G4bool GetExtent( const EAxis axis,
106 G4double& min, G4double& max ) const;
107
108 /**
109 * Returns a pointer to the minimum or maximum point along specified 'axis'.
110 * Take care! Do not use pointer after destroying parent polygon.
111 */
112 const G4ThreeVector* GetMinPoint( const EAxis axis ) const;
113 const G4ThreeVector* GetMaxPoint( const EAxis axis ) const;
114
115 /**
116 * Returns the number of vertices in the polygon.
117 */
118 inline std::size_t GetNumVertices() const;
119
120 /**
121 * Returns true if collection of vertices is empty.
122 */
123 inline G4bool Empty() const;
124
125 /**
126 * Decides if the polygon is in "front" of another when viewed along the
127 * specified 'axis'. For our purposes here, it is sufficient to use the
128 * minimum extent of the polygon along the axis to determine this.
129 */
130 G4bool InFrontOf(const G4ClippablePolygon& other, EAxis axis) const;
131
132 /**
133 * Decides if this polygon is behind another.
134 * Remarks in previous method are valid here too.
135 */
136 G4bool BehindOf(const G4ClippablePolygon& other, EAxis axis) const;
137
138 /**
139 * Gets min/max vertices distance in or out of a plane.
140 * @param[in] pointOnPlane The point on the plane.
141 * @param[in] planeNormal The normal vector to the plane.
142 * @param[out] min The minimum distance from the plane.
143 * @param[out] max The maximum distance from the plane.
144 * @returns false if invalid polygon (no vertices).
145 */
146 G4bool GetPlanerExtent( const G4ThreeVector& pointOnPlane,
147 const G4ThreeVector& planeNormal,
148 G4double& min, G4double& max ) const;
149
150 private:
151
152 /**
153 * Clips 'pPolygon' according to 'pVoxelLimits', which must be only
154 * limited along one axis, and either the maximum along the axis must be
155 * +kInfinity, or the minimum -kInfinity.
156 * @param[in] pPolygon The polygon to clip.
157 * @param[out] outputPolygon The resulting clipped polygon.
158 * @param[in] pVoxelLimit The Cartesian limits.
159 */
160 void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
161 G4ThreeVectorList& outputPolygon,
162 const G4VoxelLimits& pVoxelLimit );
163
164 private:
165
166 G4ThreeVectorList vertices;
167 G4ThreeVector normal;
168 G4double kCarTolerance;
169};
170
171#include "G4ClippablePolygon.icc"
172
173#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4bool GetPlanerExtent(const G4ThreeVector &pointOnPlane, const G4ThreeVector &planeNormal, G4double &min, G4double &max) const
G4bool Clip(const G4VoxelLimits &voxelLimit)
~G4ClippablePolygon()=default
G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
void AddVertexInOrder(const G4ThreeVector &vertex)
std::size_t GetNumVertices() const
const G4ThreeVector * GetMinPoint(const EAxis axis) const
G4bool GetExtent(const EAxis axis, G4double &min, G4double &max) const
void ClipAlongOneAxis(const G4VoxelLimits &voxelLimit, const EAxis axis)
G4bool InFrontOf(const G4ClippablePolygon &other, EAxis axis) const
G4bool BehindOf(const G4ClippablePolygon &other, EAxis axis) const
G4bool Empty() const
const G4ThreeVector GetNormal() const
void SetNormal(const G4ThreeVector &newNormal)
const G4ThreeVector * GetMaxPoint(const EAxis axis) const
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668