Geant4 11.2.2
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// Declaration of a utility class of a polygon that can be
31// clipped by a voxel.
32
33// Author: David C. Williams ([email protected])
34// --------------------------------------------------------------------
35#ifndef G4CLIPPABLEPOLYGON_HH
36#define G4CLIPPABLEPOLYGON_HH
37
38#include <vector>
39
40#include "G4Types.hh"
41#include "geomdefs.hh"
42#include "G4ThreeVector.hh"
43
45class G4VoxelLimits;
46
48{
49 using G4ThreeVectorList = std::vector<G4ThreeVector>;
50
51 public:
52
55 // Constructor & virtual destructor.
56
57 virtual void AddVertexInOrder( const G4ThreeVector vertex );
58 virtual void ClearAllVertices();
59
60 inline void SetNormal( const G4ThreeVector& newNormal );
61 inline const G4ThreeVector GetNormal() const;
62
63 virtual G4bool Clip( const G4VoxelLimits& voxelLimit );
64
65 virtual G4bool PartialClip( const G4VoxelLimits& voxelLimit,
66 const EAxis IgnoreMe );
67 // Clip, while ignoring the indicated axis.
68
69 virtual void ClipAlongOneAxis( const G4VoxelLimits& voxelLimit,
70 const EAxis axis );
71 // Clip along just one axis, as specified in voxelLimit.
72
73 virtual G4bool GetExtent( const EAxis axis,
74 G4double& min, G4double& max ) const;
75
76 virtual const G4ThreeVector* GetMinPoint( const EAxis axis ) const;
77 // Returns pointer to minimum point along the specified axis.
78 // Take care! Do not use pointer after destroying parent polygon.
79
80 virtual const G4ThreeVector* GetMaxPoint( const EAxis axis ) const;
81 // Returns pointer to maximum point along the specified axis.
82 // Take care! Do not use pointer after destroying parent polygon.
83
84 inline std::size_t GetNumVertices() const;
85 inline G4bool Empty() const;
86
87 virtual G4bool InFrontOf(const G4ClippablePolygon& other, EAxis axis) const;
88 // Decide if the polygon is in "front" of another when
89 // viewed along the specified axis. For our purposes here,
90 // it is sufficient to use the minimum extent of the
91 // polygon along the axis to determine this.
92
93 virtual G4bool BehindOf(const G4ClippablePolygon& other, EAxis axis) const;
94 // Decide if this polygon is behind another.
95 // Remarks in method "InFrontOf" are valid here too.
96
97 virtual G4bool GetPlanerExtent( const G4ThreeVector& pointOnPlane,
98 const G4ThreeVector& planeNormal,
99 G4double& min, G4double& max ) const;
100 // Get min/max distance in or out of a plane.
101
102 protected:
103
104 void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
105 G4ThreeVectorList& outputPolygon,
106 const G4VoxelLimits& pVoxelLimit );
107 // pVoxelLimits must be only limited along one axis, and either
108 // the maximum along the axis must be +kInfinity, or the minimum
109 // -kInfinity
110
111 protected:
112
113 G4ThreeVectorList vertices;
116};
117
118#include "G4ClippablePolygon.icc"
119
120#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
virtual G4bool GetPlanerExtent(const G4ThreeVector &pointOnPlane, const G4ThreeVector &planeNormal, G4double &min, G4double &max) const
virtual G4bool Clip(const G4VoxelLimits &voxelLimit)
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
G4ThreeVectorList vertices
void ClipToSimpleLimits(G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit)
std::size_t GetNumVertices() const
virtual const G4ThreeVector * GetMinPoint(const EAxis axis) const
virtual ~G4ClippablePolygon()
virtual void AddVertexInOrder(const G4ThreeVector vertex)
virtual G4bool GetExtent(const EAxis axis, G4double &min, G4double &max) const
virtual void ClearAllVertices()
virtual void ClipAlongOneAxis(const G4VoxelLimits &voxelLimit, const EAxis axis)
virtual G4bool InFrontOf(const G4ClippablePolygon &other, EAxis axis) const
virtual G4bool BehindOf(const G4ClippablePolygon &other, EAxis axis) const
G4bool Empty() const
const G4ThreeVector GetNormal() const
void SetNormal(const G4ThreeVector &newNormal)
virtual const G4ThreeVector * GetMaxPoint(const EAxis axis) const
EAxis
Definition geomdefs.hh:54