[529] | 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: SoCons.h,v 1.3 2006/06/29 21:21:20 gunter Exp $ |
---|
[593] | 28 | // GEANT4 tag $Name: geant4-09-00-ref-01 $ |
---|
[529] | 29 | // |
---|
| 30 | /*-----------------------------Hepvis----------------------------------------*/ |
---|
| 31 | /* */ |
---|
| 32 | /* Node: SoCons */ |
---|
| 33 | /* Description: Represents the G4Cons Geant Geometry entity */ |
---|
| 34 | /* Author: Joe Boudreau Nov 11 1996 */ |
---|
| 35 | /* */ |
---|
| 36 | /*---------------------------------------------------------------------------*/ |
---|
| 37 | #ifndef HEPVis_SoCons_h |
---|
| 38 | #define HEPVis_SoCons_h |
---|
| 39 | |
---|
| 40 | #include <Inventor/fields/SoSFFloat.h> |
---|
| 41 | #include <Inventor/fields/SoSFNode.h> |
---|
| 42 | #include <Inventor/fields/SoSFBool.h> |
---|
| 43 | #include <Inventor/nodes/SoShape.h> |
---|
| 44 | |
---|
| 45 | class SoSFNode; |
---|
| 46 | //! SoCons - Inventor version of the G4Cons Geant Geometry entity |
---|
| 47 | /*! |
---|
| 48 | * Node: SoCons |
---|
| 49 | * |
---|
| 50 | * Description: The Inventor version of the G4Cons Geant Geometry entity |
---|
| 51 | * |
---|
| 52 | * Author: Joe Boudreau Nov 11 1996 |
---|
| 53 | * |
---|
| 54 | * A G4Cons is, in the general case, a Phi segment of a cone, with half-length |
---|
| 55 | * fDz, inner and outer radii specified at -fDz and +fDz. The Phi segment is |
---|
| 56 | * described by a starting fSPhi angle, and the +fDPhi delta angle for the shape. |
---|
| 57 | * If the delta angle is >=2*M_PI, the shape is treated as continuous in Phi |
---|
| 58 | * |
---|
| 59 | * Member Data: |
---|
| 60 | * |
---|
| 61 | * fRmin1 inside radius at -fDz |
---|
| 62 | * fRmin2 inside radius at +fDz |
---|
| 63 | * fRmax1 outside radius at -fDz |
---|
| 64 | * fRmax2 outside radius at +fDz |
---|
| 65 | * fDz half length in z |
---|
| 66 | * |
---|
| 67 | * fSPhi starting angle of the segment in radians |
---|
| 68 | * fDPhi delta angle of the segment in radians |
---|
| 69 | */ |
---|
| 70 | |
---|
| 71 | #define SoCons Geant4_SoCons |
---|
| 72 | |
---|
| 73 | class SoCons:public SoShape { |
---|
| 74 | |
---|
| 75 | // The following is required: |
---|
| 76 | SO_NODE_HEADER(SoCons); |
---|
| 77 | |
---|
| 78 | public: |
---|
| 79 | |
---|
| 80 | // |
---|
| 81 | //! Inside radius at -fDz |
---|
| 82 | // |
---|
| 83 | SoSFFloat fRmin1; |
---|
| 84 | // |
---|
| 85 | //! Inside radius at +fDz |
---|
| 86 | // |
---|
| 87 | SoSFFloat fRmin2; |
---|
| 88 | // |
---|
| 89 | //! Outside radius at -fDz |
---|
| 90 | // |
---|
| 91 | SoSFFloat fRmax1; |
---|
| 92 | // |
---|
| 93 | //! Outside radius at +fDz |
---|
| 94 | // |
---|
| 95 | SoSFFloat fRmax2; |
---|
| 96 | // |
---|
| 97 | //! Half-length along Z |
---|
| 98 | // |
---|
| 99 | SoSFFloat fDz; |
---|
| 100 | // |
---|
| 101 | //! Starting angle, in radians |
---|
| 102 | // |
---|
| 103 | SoSFFloat fSPhi; |
---|
| 104 | // |
---|
| 105 | //! Delta-angle, in radians |
---|
| 106 | // |
---|
| 107 | SoSFFloat fDPhi; |
---|
| 108 | // |
---|
| 109 | //! An Inventor option - slightly better render, worse performance |
---|
| 110 | // |
---|
| 111 | SoSFBool smoothDraw; |
---|
| 112 | // |
---|
| 113 | //! Alternate rep required - for use by users without HEPVis shared objects |
---|
| 114 | // |
---|
| 115 | SoSFNode alternateRep; |
---|
| 116 | |
---|
| 117 | // |
---|
| 118 | //! Constructor, required |
---|
| 119 | // |
---|
| 120 | SoCons(); |
---|
| 121 | |
---|
| 122 | // |
---|
| 123 | //! Class Initializer, required |
---|
| 124 | // |
---|
| 125 | static void initClass(); |
---|
| 126 | |
---|
| 127 | // |
---|
| 128 | //! Generate AlternateRep, required. Generating an alternate representation |
---|
| 129 | //! must be done upon users request. It allows an Inventor program to read |
---|
| 130 | //! back the file without requiring *this* code to be dynamically linked. |
---|
| 131 | //! If the users expects that *this* code will be dynamically linked, he |
---|
| 132 | //! need not invoke this method. |
---|
| 133 | // |
---|
| 134 | virtual void generateAlternateRep(); |
---|
| 135 | |
---|
| 136 | // |
---|
| 137 | //! We better be able to clear it, too! |
---|
| 138 | // |
---|
| 139 | virtual void clearAlternateRep(); |
---|
| 140 | |
---|
| 141 | protected: |
---|
| 142 | |
---|
| 143 | // |
---|
| 144 | //! compute bounding Box, required |
---|
| 145 | // |
---|
| 146 | virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er ); |
---|
| 147 | |
---|
| 148 | // |
---|
| 149 | //! Generate Primitives, required |
---|
| 150 | // |
---|
| 151 | virtual void generatePrimitives(SoAction *action); |
---|
| 152 | |
---|
| 153 | // |
---|
| 154 | //! GetChildList, required whenever the class has hidden children |
---|
| 155 | // |
---|
| 156 | virtual SoChildList *getChildren() const; |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | protected: |
---|
| 160 | // |
---|
| 161 | //! Destructor, required |
---|
| 162 | // |
---|
| 163 | virtual ~SoCons(); |
---|
| 164 | |
---|
| 165 | private: |
---|
| 166 | |
---|
| 167 | // |
---|
| 168 | //! Generate Children. Used to create the hidden children. Required whenever |
---|
| 169 | //! the node has hidden children. |
---|
| 170 | // |
---|
| 171 | void generateChildren(); |
---|
| 172 | |
---|
| 173 | // |
---|
| 174 | //! Used to modify hidden children when a data field is changed. Required |
---|
| 175 | //! whenever the class has hidden children. |
---|
| 176 | // |
---|
| 177 | void updateChildren(); |
---|
| 178 | |
---|
| 179 | // |
---|
| 180 | //! ChildList. Required whenever the class has hidden children. |
---|
| 181 | // |
---|
| 182 | SoChildList *children; |
---|
| 183 | |
---|
| 184 | // |
---|
| 185 | //! help with trigonometry. increments sines an cosines by an angle. |
---|
| 186 | // |
---|
| 187 | void inc(double & sinPhi, double & cosPhi, double sinDeltaPhi, double cosDeltaPhi) const { |
---|
| 188 | double oldSin=sinPhi,oldCos=cosPhi; |
---|
| 189 | sinPhi = oldSin*cosDeltaPhi+oldCos*sinDeltaPhi; |
---|
| 190 | cosPhi = oldCos*cosDeltaPhi-oldSin*sinDeltaPhi; |
---|
| 191 | } |
---|
| 192 | }; |
---|
| 193 | |
---|
| 194 | #endif |
---|