00001
00002 #ifndef Type
00003 #error "Type is not defined."
00004 #endif
00005
00006 #ifndef FType
00007 #error "FType is not defined."
00008 #endif
00009
00010 #ifndef JPoint
00011 #error "JPoint is not defined."
00012 #endif
00013
00014 #ifndef JPoint_t
00015 #error "JPoint_t is not defined."
00016 #endif
00017
00018 #ifndef JCircle
00019 #error "JCircle is not defined."
00020 #endif
00021
00022 #ifndef JCircle_t
00023 #error "JCircle_t is not defined."
00024 #endif
00025
00026 #ifndef JCylinder
00027 #error "JCylinder is not defined."
00028 #endif
00029
00030 #ifndef JCylinder_t
00031 #error "JCylinder_t is not defined."
00032 #endif
00033
00034 struct JCylinder_t {
00035 FType height;
00036 FType area_cache;
00037 FType volume_cache;
00038 };
00039
00040 class JCylinder : public JCircle {
00041 public:
00042 inline JCylinder() : JCircle( 0, 0, 0 )
00043 {
00044 memset( &cyl, 0, sizeof( JCylinder_t ) );
00045 }
00046
00047 inline JCylinder( Type X ) : JCircle( X, 0, 0 )
00048 {
00049 memset( &cyl, 0, sizeof( JCylinder_t ) );
00050 }
00051
00052 inline JCylinder( Type X, Type Y ) : JCircle( X, Y, 0 )
00053 {
00054 memset( &cyl, 0, sizeof( JCylinder_t ) );
00055 }
00056
00057 inline JCylinder( Type X, Type Y, FType radius )
00058 : JCircle( X, Y, radius )
00059 {
00060 memset( &cyl, 0, sizeof( JCylinder_t ) );
00061 cyl.area_cache = -1;
00062 cyl.volume_cache = -1;
00063 }
00064
00065 inline JCylinder( Type X, Type Y, FType Radius, FType Height )
00066 : JCircle( X, Y, Radius )
00067 {
00068 memset( &cyl, 0, sizeof( JCylinder_t ) );
00069 cyl.height = Height;
00070 cyl.area_cache = -1;
00071 cyl.volume_cache = -1;
00072 }
00073
00074 inline JCylinder( const JCylinder& src )
00075 : JCircle( (const JCircle&) src )
00076 {
00077 memcpy( &cyl, &src.cyl, sizeof( JCylinder_t ) );
00078 }
00079
00080 inline const JCircle& operator=( const JCircle& src )
00081 {
00082 memcpy( &pt, &src.pt, sizeof( JPoint_t ) );
00083 memcpy( &c, &src.c, sizeof( JCircle_t ) );
00084 memcpy( &cyl, &src.cyl, sizeof( JCylinder_t ) );
00085 return *this;
00086 }
00087
00088
00089
00090
00091
00092
00093 inline const JCylinder& setHeight( FType Height )
00094 {
00095 cyl.height = Height;
00096 return *this;
00097 }
00098
00099
00100 inline FType getHeight() const {
00101 return cyl.height;
00102 }
00103
00104
00105 inline FType area() const
00106 {
00107 if ( cyl.area_cache < 0 ) {
00108 FType a = JCircle::area();
00109 FType r = JCircle::getRadius();
00110
00111 cyl.area_cache = ( 2 * a ) + \
00112 ( 2 * Math_PI * r * cyl.height );
00113 }
00114 return area_cache;
00115 }
00116
00117
00118 inline FType volume() const
00119 {
00120 if ( cyl.volume_cache < 0 ) {
00121 FType a = JCircle::area();
00122 cyl.volume_cache = a * cyl.height;
00123 }
00124 return cyl.volume_cache;
00125 }
00126
00127
00128
00129
00130
00131
00132 inline const JCylinder& setRadius( FType r )
00133 {
00134 JCircle::setRadius( r );
00135 return *this;
00136 }
00137
00138
00139
00140
00141
00142
00143 inline const JCylinder& setPoint( Type X, Type Y )
00144 {
00145 JCircle::setPoint( X, Y );
00146 return *this;
00147 }
00148
00149
00150 inline const JCylinder& setPolar( FType R, FType Theta )
00151 {
00152 JCircle::setPolar( R, Theta );
00153 return *this;
00154 }
00155
00156
00157 inline const JCylinder& setCircle( Type X, Type Y, FType Radius )
00158 {
00159 JCircle::setCircle( X, Y, Radius );
00160 return *this;
00161 }
00162
00163 inline const JCylinder& setX( Type X )
00164 {
00165 JCircle::setX( X );
00166 return *this;
00167 }
00168
00169 inline const JCylinder& setY( Type Y )
00170 {
00171 JCircle::setY( Y );
00172 return *this;
00173 }
00174
00175 inline const JCylinder& setR( FType R )
00176 {
00177 JCircle::setR( R );
00178 return *this;
00179 }
00180
00181 inline const JCylinder& setAngle( FType Theta )
00182 {
00183 JCircle::setAngle( Theta );
00184 return *this;
00185 }
00186
00187
00188 friend ostream& operator<<( ostream& os, const JCylinder& Cyl )
00189 {
00190 os << (const JCircle&)Cyl << "; Height = " << Cyl.cyl.height;
00191 return os;
00192 }
00193
00194 protected:
00195 struct JCylinder_t cyl;
00196 };