source: trunk/source/geometry/volumes/test/testG4VoxelLimits.cc @ 1316

Last change on this file since 1316 was 1316, checked in by garnier, 14 years ago

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 4.4 KB
Line 
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: testG4VoxelLimits.cc,v 1.4 2006/06/29 18:59:02 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
29//
30
31// testG4VoxelLimits
32//             Ensure asserts are compiled in
33//
34// Test file for G4Voxellimit object
35//
36// o Each function called
37// o Complete line coverage where possible
38// o Main 3 logical cases for line clipper checked
39
40#include <assert.h>
41
42#include "globals.hh"
43#include "geomdefs.hh"
44#include "G4VoxelLimits.hh"
45#include "G4ThreeVector.hh"
46
47G4bool testG4VoxelLimits()
48{
49    G4VoxelLimits limit;
50    assert(!limit.IsXLimited());
51    assert(!limit.IsYLimited());
52    assert(!limit.IsZLimited());
53
54// Check line segment unchanged when no limits
55    G4ThreeVector v1(-100,-100,-100),v2(100,100,100);
56    assert(limit.ClipToLimits(v1,v2));
57    assert(v1==G4ThreeVector(-100,-100,-100));
58    assert(v2==G4ThreeVector(100,100,100));
59
60    limit.AddLimit(kXAxis,-10,20);
61    assert(limit.IsXLimited());
62    assert(!limit.IsYLimited());
63    assert(!limit.IsZLimited());
64    assert(limit.GetMinXExtent()==-10);
65    assert(limit.GetMaxXExtent()==20);
66
67    assert(limit.ClipToLimits(v1,v2));
68    assert(v1==G4ThreeVector(-10,-10,-10));
69    assert(v2==G4ThreeVector(20,20,20));
70
71    limit.AddLimit(kYAxis,-10,20);
72    assert(limit.IsXLimited());
73    assert(limit.IsYLimited());
74    assert(!limit.IsZLimited());
75    assert(limit.GetMinXExtent()==-10);
76    assert(limit.GetMaxXExtent()==20);
77    assert(limit.GetMinYExtent()==-10);
78    assert(limit.GetMaxYExtent()==20);
79    v1=G4ThreeVector(-100,-200,0);
80    v2=G4ThreeVector(100,200,0);
81    assert(limit.ClipToLimits(v1,v2));
82    assert(v1==G4ThreeVector(-5,-10,0));
83    assert(v2==G4ThreeVector(10,20,0));
84
85    limit.AddLimit(kZAxis,-10,20);
86    assert(limit.IsXLimited());
87    assert(limit.IsYLimited());
88    assert(limit.IsZLimited());
89    assert(limit.IsLimited(kXAxis));
90    assert(limit.IsLimited(kYAxis));
91    assert(limit.IsLimited(kZAxis));
92    assert(limit.GetMinXExtent()==-10);
93    assert(limit.GetMaxXExtent()==20);
94    assert(limit.GetMinYExtent()==-10);
95    assert(limit.GetMaxYExtent()==20);
96    assert(limit.GetMinZExtent()==-10);
97    assert(limit.GetMaxZExtent()==20);
98
99    assert(limit.GetMaxExtent(kXAxis)==20);
100    assert(limit.GetMaxExtent(kYAxis)==20);
101    assert(limit.GetMaxExtent(kZAxis)==20);
102    assert(limit.GetMinExtent(kXAxis)==-10);
103    assert(limit.GetMinExtent(kYAxis)==-10);
104    assert(limit.GetMinExtent(kZAxis)==-10);
105
106    v1=G4ThreeVector(-100,-200,-200);
107    v2=G4ThreeVector(100,200,200);
108    assert(limit.ClipToLimits(v1,v2));
109    assert(v1==G4ThreeVector(-5,-10,-10));
110    assert(v2==G4ThreeVector(10,20,20));
111
112    return true;
113}
114
115int main()
116{
117#ifdef NDEBUG
118    G4Exception("FAIL: *** Assertions must be compiled in! ***");
119#endif
120    assert(testG4VoxelLimits());
121    return 0;
122}
123
Note: See TracBrowser for help on using the repository browser.