source: trunk/source/geometry/solids/specific/src/G4VFacet.cc @ 954

Last change on this file since 954 was 921, checked in by garnier, 16 years ago

en test de gl2ps. Problemes de libraries

File size: 5.7 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 and of QinetiQ Ltd,   *
20// * subject DEFCON 705 IPR conditions.                               *
21// * By using,  copying,  modifying or  distributing the software (or *
22// * any work based  on the software)  you  agree  to acknowledge its *
23// * use  in  resulting  scientific  publications,  and indicate your *
24// * acceptance of all terms of the Geant4 Software license.          *
25// ********************************************************************
26//
27// $Id: G4VFacet.cc,v 1.7 2008/09/12 07:16:22 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-02-cand-01 $
29//
30// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31//
32// MODULE:              G4VFacet.hh
33//
34// Date:                15/06/2005
35// Author:              P R Truscott
36// Organisation:        QinetiQ Ltd, UK
37// Customer:            UK Ministry of Defence : RAO CRP TD Electronic Systems
38// Contract:            C/MAT/N03517
39//
40// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41//
42// CHANGE HISTORY
43// --------------
44//
45// 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
46//
47// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48
49#include "G4VFacet.hh"
50#include "globals.hh"
51#include "G4GeometryTolerance.hh"
52
53///////////////////////////////////////////////////////////////////////////////
54//
55G4VFacet::G4VFacet ()
56{
57  dirTolerance = 1.0E-14;
58  kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
59
60  P.clear();
61  E.clear();
62   
63  circumcentre = G4ThreeVector(0.0,0.0,0.0);
64  radius    = 0.0;
65  radiusSqr = 0.0;
66  area      = 0.0;
67}
68
69///////////////////////////////////////////////////////////////////////////////
70//
71G4VFacet::~G4VFacet ()
72{
73  P.clear();
74  E.clear();
75}
76
77///////////////////////////////////////////////////////////////////////////////
78//
79G4bool G4VFacet::operator== (const G4VFacet &right) const
80{
81  G4double tolerance = kCarTolerance*kCarTolerance/4.0;
82  if (nVertices != right.GetNumberOfVertices())
83    { return false; }
84  else if ((circumcentre-right.GetCircumcentre()).mag2() > tolerance)
85    { return false; }
86  else if (std::fabs((right.GetSurfaceNormal()).dot(surfaceNormal)) < 0.9999999999)
87    { return false; }
88
89  G4bool coincident  = true;
90  size_t i           = 0;
91  do
92  {
93    coincident = false;
94    size_t j   = 0;
95    do
96    {
97      coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance;
98    } while (!coincident && ++j < nVertices);
99  } while (coincident && ++i < nVertices);
100 
101  return coincident;
102}
103
104///////////////////////////////////////////////////////////////////////////////
105//
106void G4VFacet::ApplyTranslation(const G4ThreeVector v)
107{
108  P0 += v;
109  for (G4ThreeVectorList::iterator it=P.begin(); it!=P.end(); it++)
110  {
111    (*it) += v;
112  }
113}
114
115///////////////////////////////////////////////////////////////////////////////
116//
117std::ostream &G4VFacet::StreamInfo(std::ostream &os) const
118{
119  os << G4endl;
120  os << "*********************************************************************"
121     << G4endl;
122  os << "FACET TYPE       = " << geometryType << G4endl;
123  os << "ABSOLUTE VECTORS = " << G4endl;
124  os << "P0               = " << P0 << G4endl;
125  for (G4ThreeVectorList::const_iterator it=P.begin(); it!=P.end(); it++)
126    { os << "P[" << it-P.begin()+1 << "]      = " << *it << G4endl; }
127
128  os << "RELATIVE VECTORS = " << G4endl;
129  for (G4ThreeVectorList::const_iterator it=E.begin(); it!=E.end(); it++)
130    { os << "E[" << it-E.begin()+1 << "]      = " << *it << G4endl; }
131
132  os << "*********************************************************************"
133     << G4endl;
134 
135  return os;
136}
137
138///////////////////////////////////////////////////////////////////////////////
139//
140G4VFacet* G4VFacet::GetClone ()
141  {return 0;}
142
143///////////////////////////////////////////////////////////////////////////////
144//
145G4double G4VFacet::Distance (const G4ThreeVector&, const G4double)
146  {return kInfinity;}
147
148///////////////////////////////////////////////////////////////////////////////
149//
150G4double G4VFacet::Distance (const G4ThreeVector&, const G4double,
151                                    const G4bool)
152  {return kInfinity;}
153
154///////////////////////////////////////////////////////////////////////////////
155//
156G4double G4VFacet::Extent (const G4ThreeVector)
157  {return 0.0;}
158
159///////////////////////////////////////////////////////////////////////////////
160//
161G4bool G4VFacet::Intersect (const G4ThreeVector&, const G4ThreeVector &,
162                            const G4bool , G4double &, G4double &,
163                                  G4ThreeVector &)
164  {return false;}
Note: See TracBrowser for help on using the repository browser.