| 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: G4BSplineSurface.hh,v 1.11 2006/06/29 18:38:11 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $
|
|---|
| 29 | //
|
|---|
| 30 | // ----------------------------------------------------------------------
|
|---|
| 31 | // Class G4BSplineSurface
|
|---|
| 32 | //
|
|---|
| 33 | // Class description:
|
|---|
| 34 | //
|
|---|
| 35 | // Definition of a generic BSpline surface.
|
|---|
| 36 |
|
|---|
| 37 | // Authors: J.Sulkimo, P.Urban.
|
|---|
| 38 | // Revisions by: L.Broglia, G.Cosmo.
|
|---|
| 39 | // ----------------------------------------------------------------------
|
|---|
| 40 | #ifndef __BSPLINESURFACE_H
|
|---|
| 41 | #define __BSPLINESURFACE_H
|
|---|
| 42 |
|
|---|
| 43 | #include "G4Point3D.hh"
|
|---|
| 44 | #include "G4PointRat.hh"
|
|---|
| 45 | #include "G4Surface.hh"
|
|---|
| 46 | #include "G4ProjectedSurface.hh"
|
|---|
| 47 | #include "G4UVHit.hh"
|
|---|
| 48 |
|
|---|
| 49 | class G4BSplineSurface : public G4Surface
|
|---|
| 50 | {
|
|---|
| 51 |
|
|---|
| 52 | public: // with description
|
|---|
| 53 |
|
|---|
| 54 | G4BSplineSurface();
|
|---|
| 55 | G4BSplineSurface(const char* nurbfilename, G4Ray& rayref);
|
|---|
| 56 | G4BSplineSurface(G4int u, G4int v, G4KnotVector& u_kv, G4KnotVector& v_kv,
|
|---|
| 57 | G4ControlPoints& cp);
|
|---|
| 58 | virtual ~G4BSplineSurface();
|
|---|
| 59 | // Constructors & destructor.
|
|---|
| 60 |
|
|---|
| 61 | G4int Intersect(const G4Ray&);
|
|---|
| 62 | void CalcBBox();
|
|---|
| 63 | // Finds the bounds of the b-spline surface.
|
|---|
| 64 | // The bounding box is used for a preliminary check of intersection.
|
|---|
| 65 |
|
|---|
| 66 | inline G4double GetUHit() const;
|
|---|
| 67 | inline G4double GetVHit() const;
|
|---|
| 68 |
|
|---|
| 69 | G4double ClosestDistanceToPoint(const G4Point3D&);
|
|---|
| 70 |
|
|---|
| 71 | inline void Reset();
|
|---|
| 72 |
|
|---|
| 73 | inline G4int GetRows() const;
|
|---|
| 74 | inline G4int GetCols() const;
|
|---|
| 75 | inline G4Point3D GetControlPoint(G4int a, G4int b) const;
|
|---|
| 76 | // Accessors for control points.
|
|---|
| 77 |
|
|---|
| 78 | public:
|
|---|
| 79 |
|
|---|
| 80 | inline G4int MyType() const;
|
|---|
| 81 |
|
|---|
| 82 | private:
|
|---|
| 83 |
|
|---|
| 84 | G4BSplineSurface(const G4BSplineSurface&);
|
|---|
| 85 | G4BSplineSurface& operator=(const G4BSplineSurface&);
|
|---|
| 86 | // Private copy constructor and assignment operator.
|
|---|
| 87 |
|
|---|
| 88 | void FindIntersections(const G4Ray&);
|
|---|
| 89 |
|
|---|
| 90 | inline G4int GetOrder(G4int direction) const;
|
|---|
| 91 | inline void PutOrder(G4int direction, G4int value);
|
|---|
| 92 |
|
|---|
| 93 | void AddHit(G4double u, G4double v);
|
|---|
| 94 | void ProjectNURBSurfaceTo2D( const G4Plane& ,const G4Plane&,
|
|---|
| 95 | register G4ProjectedSurface*);
|
|---|
| 96 | // Projects the nurb surface so that the z-axis = ray.
|
|---|
| 97 |
|
|---|
| 98 | G4ProjectedSurface* CopyToProjectedSurface(const G4Ray&);
|
|---|
| 99 | G4Point3D FinalIntersection();
|
|---|
| 100 |
|
|---|
| 101 | // L. Broglia
|
|---|
| 102 | // Because G4BSplineSurface::Evaluate hides the virtual function
|
|---|
| 103 | // G4Surface::Evaluate(const G4Ray&), I modified the function name
|
|---|
| 104 | // G4Point3D Evaluate();
|
|---|
| 105 | G4Point3D BSEvaluate();
|
|---|
| 106 |
|
|---|
| 107 | G4PointRat& InternalEvalCrv(G4int i, G4ControlPoints *crv);
|
|---|
| 108 |
|
|---|
| 109 | G4Point3D Evaluation(const G4Ray&);
|
|---|
| 110 |
|
|---|
| 111 | inline G4Vector3D SurfaceNormal(const G4Point3D& Pt) const;
|
|---|
| 112 |
|
|---|
| 113 | private:
|
|---|
| 114 |
|
|---|
| 115 | G4SurfaceList bezier_list;
|
|---|
| 116 | G4SurfaceList projected_list;
|
|---|
| 117 | short dir;
|
|---|
| 118 | G4int order[2];
|
|---|
| 119 | G4KnotVector *u_knots;
|
|---|
| 120 | G4KnotVector *v_knots;
|
|---|
| 121 | G4KnotVector *tmp_knots;
|
|---|
| 122 | G4ControlPoints *ctl_points;
|
|---|
| 123 | G4UVHit* Hit;
|
|---|
| 124 | G4UVHit* first_hit;
|
|---|
| 125 | G4int ord;
|
|---|
| 126 | G4int k_index;
|
|---|
| 127 | G4double param;
|
|---|
| 128 | G4int Rational;
|
|---|
| 129 | };
|
|---|
| 130 |
|
|---|
| 131 | #include "G4BSplineSurface.icc"
|
|---|
| 132 |
|
|---|
| 133 | #endif
|
|---|