Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
geometry
solids
specific
include
G4ReduciblePolygon.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
//
27
// $Id: G4ReduciblePolygon.hh 67011 2013-01-29 16:17:41Z gcosmo $
28
//
29
//
30
// --------------------------------------------------------------------
31
// GEANT 4 class header file
32
//
33
//
34
// G4ReduciblePolygon.hh
35
//
36
// Class description:
37
//
38
// Utility class used to specify, test, reduce, and/or otherwise
39
// manipulate a 2D polygon.
40
//
41
// For this class, a polygon consists of n > 2 points in 2D
42
// space (a,b). The polygon is always closed by connecting the
43
// last point to the first. A G4ReduciblePolygon is guaranteed
44
// to fulfill this definition in all instances.
45
//
46
// Illegal manipulations (such that a valid polygon would be
47
// produced) result in an error return if possible and
48
// otherwise a G4Exception.
49
//
50
// The set of manipulations is limited currently to what
51
// is needed for G4Polycone and G4Polyhedra.
52
53
// Author:
54
// David C. Williams (davidw@scipp.ucsc.edu)
55
// --------------------------------------------------------------------
56
#ifndef G4ReduciblePolygon_hh
57
#define G4ReduciblePolygon_hh
58
59
#include "
G4Types.hh
"
60
61
class
G4ReduciblePolygon
62
{
63
friend
class
G4ReduciblePolygonIterator
;
64
65
public
:
66
//
67
// Creator: via simple a/b arrays
68
//
69
G4ReduciblePolygon
(
const
G4double
a
[],
const
G4double
b
[],
G4int
n
);
70
71
//
72
// Creator: a special version for G4Polygon and G4Polycone
73
// that takes two a points at planes of b
74
// (where a==r and b==z for the GEANT3 classic PCON and PGON)
75
//
76
G4ReduciblePolygon
(
const
G4double
rmin[],
const
G4double
rmax[],
77
const
G4double
z
[],
G4int
n
);
78
79
virtual
~G4ReduciblePolygon
();
80
81
//
82
// Queries
83
//
84
inline
G4int
NumVertices
()
const
{
return
numVertices
; }
85
86
inline
G4double
Amin
()
const
{
return
aMin
; }
87
inline
G4double
Amax
()
const
{
return
aMax
; }
88
inline
G4double
Bmin
()
const
{
return
bMin
; }
89
inline
G4double
Bmax
()
const
{
return
bMax
; }
90
91
void
CopyVertices
(
G4double
a
[],
G4double
b
[] )
const
;
92
93
//
94
// Manipulations
95
//
96
void
ScaleA
(
G4double
scale
);
97
void
ScaleB
(
G4double
scale
);
98
99
G4bool
RemoveDuplicateVertices
(
G4double
tolerance );
100
G4bool
RemoveRedundantVertices
(
G4double
tolerance );
101
102
void
ReverseOrder
();
103
104
//
105
// Tests
106
//
107
G4double
Area
();
108
G4bool
CrossesItself
(
G4double
tolerance );
109
G4bool
BisectedBy
(
G4double
a1,
G4double
b1,
110
G4double
a2,
G4double
b2,
G4double
tolerance );
111
112
void
Print
();
// Debugging only
113
114
public
:
// without description
115
116
G4ReduciblePolygon
(__void__&);
117
// Fake default constructor for usage restricted to direct object
118
// persistency for clients requiring preallocation of memory for
119
// persistifiable objects.
120
121
protected
:
122
123
void
Create
(
const
G4double
a
[],
const
G4double
b
[],
G4int
n
);
124
125
void
CalculateMaxMin
();
126
127
//
128
// Below are member values that are *always* kept up to date (please!)
129
//
130
G4double
aMin
,
aMax
,
bMin
,
bMax
;
131
G4int
numVertices
;
132
133
//
134
// A subclass which holds the vertices in a single-linked list
135
//
136
// Yeah, call me an old-fashioned c hacker, but I cannot make
137
// myself use the rogue tools for this trivial list.
138
//
139
struct
ABVertex
;
// Secret recipe for allowing
140
friend
struct
ABVertex
;
// protected nested structures
141
struct
ABVertex
142
{
143
ABVertex
() :
a
(0.),
b
(0.),
next
(0) {}
144
G4double
a
,
b
;
145
ABVertex
*
next
;
146
};
147
148
ABVertex
*
vertexHead
;
149
150
private
:
151
152
G4ReduciblePolygon
(
const
G4ReduciblePolygon
&);
153
G4ReduciblePolygon
& operator=(
const
G4ReduciblePolygon
&);
154
// Private copy constructor and assignment operator.
155
};
156
157
158
//
159
// A companion class for iterating over the vertices of our polygon.
160
// It is simple enough that all routines are declared inline here.
161
//
162
class
G4ReduciblePolygonIterator
163
{
164
public
:
165
166
G4ReduciblePolygonIterator
(
const
G4ReduciblePolygon
*theSubject )
167
{
subject
= theSubject;
current
=0; }
168
169
void
Begin
() {
current
=
subject
->
vertexHead
; }
170
G4bool
Next
() {
if
(
current
)
current
=
current
->
next
;
return
Valid
(); }
171
172
G4bool
Valid
()
const
{
return
current
!=0; }
173
174
G4double
GetA
()
const
{
return
current
->
a
; }
175
G4double
GetB
()
const
{
return
current
->
b
; }
176
177
protected
:
178
179
const
G4ReduciblePolygon
*
subject
;
// Who are we iterating over
180
G4ReduciblePolygon::ABVertex
*
current
;
// Current vertex
181
};
182
183
#endif
Generated on Sat May 25 2013 14:33:15 for Geant4 by
1.8.4