00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef INC_MI32_TRANS3D_H
00042 #define INC_MI32_TRANS3D_H
00043
00044 #ifndef INC_MI32_CTRLPT_H
00045 #include <mi32/ctrlpt.h>
00046 #endif
00047
00048 #ifndef INC_STRING_H
00049 #include <string.h>
00050 #define INC_STRING_H
00051 #endif
00052
00053 #ifdef GEOMDLL
00054 #define GEOMLIBEXPORT MI_DLLEXPORT
00055 #else
00056 #define GEOMLIBEXPORT MI_DLLIMPORT
00057 #endif
00058
00059
00060
00061
00062
00063 class TRANS3D {
00064
00065 public:
00066
00067 enum AXIS {
00068 AXIS_X = 0,
00069 AXIS_Y = 1,
00070 AXIS_Z = 2
00071 };
00072
00073 enum PLANE {
00074 PLANE_XY = 0,
00075 PLANE_XZ = 1,
00076 PLANE_YZ = 2
00077 };
00078
00079
00080
00081
00082 TRANS3D (
00083 );
00084
00085
00086 TRANS3D (
00087 const TRANS3D& rhs
00088 ) :
00089 m_DoHomogeneous(rhs.m_DoHomogeneous)
00090 {
00091 memcpy(m_fwd,rhs.m_fwd,sizeof(m_fwd));
00092 memcpy(m_inv,rhs.m_inv,sizeof(m_inv));
00093 }
00094
00095
00096 TRANS3D (
00097 const TRANS3D& in1,
00098 const TRANS3D& in2
00099 );
00100
00101
00102 ~TRANS3D (
00103 ) {
00104 }
00105
00106
00107
00108
00109 TRANS3D& operator= (
00110 const TRANS3D& rhs
00111 ) {
00112 memcpy(m_fwd,rhs.m_fwd,sizeof(m_fwd));
00113 memcpy(m_inv,rhs.m_inv,sizeof(m_inv));
00114 m_DoHomogeneous = rhs.m_DoHomogeneous;
00115 return (*this);
00116 }
00117
00118
00119
00120
00121 void ApplyMatrices (
00122 const MAT4X4 fwd,
00123 const MAT4X4 inv
00124 ) {
00125 ApplyMatrix(fwd,false);
00126 ApplyMatrix(inv,true);
00127 return;
00128 }
00129
00130
00131 void ApplyOffset (
00132 double xoffset,
00133 double yoffset,
00134 double zoffset,
00135 bool inverse = false
00136 );
00137
00138
00139 void ApplyOffset (
00140 const DPOINT3D& point,
00141 bool inverse = false
00142 ) {
00143 ApplyOffset(point.x,point.y,point.z,inverse);
00144 return;
00145 }
00146
00147
00148 void ApplyRotation (
00149 double angle,
00150 AXIS axis,
00151 bool inverse = false
00152 );
00153
00154
00155 void ApplyScale (
00156 double xscale,
00157 double yscale,
00158 double zscale,
00159 bool inverse = false
00160 );
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 void ApplyShear (
00182 double shear1,
00183 double shear2,
00184 PLANE plane,
00185 bool inverse = false
00186 );
00187
00188
00189 void ConvertForward (
00190 const DPOINT3D *ipoints,
00191 DPOINT3D *opoints,
00192 INT32 numpoints
00193 ) const;
00194
00195
00196 DPOINT3D ConvertForward (
00197 const DPOINT3D ipoint
00198 ) const {
00199 DPOINT3D opoint;
00200 ConvertForward(&ipoint,&opoint,1);
00201 return (opoint);
00202 }
00203
00204
00205 void ConvertInverse (
00206 const DPOINT3D *ipoints,
00207 DPOINT3D *opoints,
00208 INT32 numpoints
00209 ) const;
00210
00211
00212 DPOINT3D ConvertInverse (
00213 const DPOINT3D ipoint
00214 ) const {
00215 DPOINT3D opoint;
00216 ConvertInverse(&ipoint,&opoint,1);
00217 return (opoint);
00218 }
00219
00220
00221 void ConvertForward (
00222 const DPOINT3DH *ipoints,
00223 DPOINT3DH *opoints,
00224 INT32 numpoints
00225 ) const;
00226
00227
00228 DPOINT3DH ConvertForward (
00229 const DPOINT3DH ipoint
00230 ) const {
00231 DPOINT3DH opoint;
00232 ConvertForward(&ipoint,&opoint,1);
00233 return (opoint);
00234 }
00235
00236
00237 void ConvertInverse (
00238 const DPOINT3DH *ipoints,
00239 DPOINT3DH *opoints,
00240 INT32 numpoints
00241 ) const;
00242
00243
00244 DPOINT3DH ConvertInverse (
00245 const DPOINT3DH ipoint
00246 ) const {
00247 DPOINT3DH opoint;
00248 ConvertInverse(&ipoint,&opoint,1);
00249 return (opoint);
00250 }
00251
00252
00253 void ConvertForward (
00254 const FPOINT3D *ipoints,
00255 FPOINT3D *opoints,
00256 INT32 numpoints
00257 ) const;
00258
00259
00260 FPOINT3D ConvertForward (
00261 const FPOINT3D ipoint
00262 ) const {
00263 FPOINT3D opoint;
00264 ConvertForward(&ipoint,&opoint,1);
00265 return (opoint);
00266 }
00267
00268
00269 void ConvertInverse (
00270 const FPOINT3D *ipoints,
00271 FPOINT3D *opoints,
00272 INT32 numpoints
00273 ) const;
00274
00275
00276 FPOINT3D ConvertInverse (
00277 const FPOINT3D ipoint
00278 ) const {
00279 FPOINT3D opoint;
00280 ConvertInverse(&ipoint,&opoint,1);
00281 return (opoint);
00282 }
00283
00284
00285 void ConvertForward (
00286 const FPOINT3DH *ipoints,
00287 FPOINT3DH *opoints,
00288 INT32 numpoints
00289 ) const;
00290
00291
00292 FPOINT3DH ConvertForward (
00293 const FPOINT3DH ipoint
00294 ) const {
00295 FPOINT3DH opoint;
00296 ConvertForward(&ipoint,&opoint,1);
00297 return (opoint);
00298 }
00299
00300
00301 void ConvertInverse (
00302 const FPOINT3DH *ipoints,
00303 FPOINT3DH *opoints,
00304 INT32 numpoints
00305 ) const;
00306
00307
00308 FPOINT3DH ConvertInverse (
00309 const FPOINT3DH ipoint
00310 ) const {
00311 FPOINT3DH opoint;
00312 ConvertInverse(&ipoint,&opoint,1);
00313 return (opoint);
00314 }
00315
00316
00317 void SetIdentity (
00318 );
00319
00320 const MAT4X4& GetForward (
00321 ) const {
00322 return m_fwd;
00323 }
00324
00325 const MAT4X4& GetInverse (
00326 ) const {
00327 return m_inv;
00328 }
00329
00330 private:
00331 #ifndef GENERATING_DOXYGEN_OUTPUT
00332
00333
00334 MAT4X4 m_fwd;
00335 MAT4X4 m_inv;
00336 bool m_DoHomogeneous;
00337
00338
00339
00340
00341 void ApplyMatrix (
00342 const MAT4X4 mat,
00343 bool inverse
00344 );
00345
00346
00347 void ChkNeedHomo (
00348 );
00349 #endif // GENERATING_DOXYGEN_OUTPUT
00350 };
00351
00352
00353
00354
00355
00356
00357 extern "C" {
00358
00359 GEOMLIBEXPORT int FindBestTrans3D (
00360 int NumPoints,
00361 CTRLPOINT3D *cp,
00362 MAT4X4 forward,
00363 MAT4X4 inverse
00364 );
00365
00366
00367 GEOMLIBEXPORT int FindBestTrans3D3 (
00368 int NumPoints,
00369 CTRLPOINT3 *cp3,
00370 MAT4X4 forward,
00371 MAT4X4 inverse
00372 );
00373
00374
00375 GEOMLIBEXPORT void trans3dinit (
00376 MAT4X4,
00377 MAT4X4
00378 );
00379
00380
00381 GEOMLIBEXPORT void trans3d (
00382 double ix,
00383 double iy,
00384 double iz,
00385 MAT4X4 TransMat,
00386 double *ox,
00387 double *oy,
00388 double *oz
00389 );
00390
00391
00392 GEOMLIBEXPORT void trans3dshift (
00393 MAT4X4 m,
00394 MAT4X4 n,
00395 double dx,
00396 double dy,
00397 double dz
00398 );
00399
00400
00401 GEOMLIBEXPORT void trans3dscale (
00402 MAT4X4 m,
00403 MAT4X4 n,
00404 double sx,
00405 double sy,
00406 double sz
00407 );
00408
00409
00410 GEOMLIBEXPORT void trans3drot (
00411 MAT4X4 m,
00412 MAT4X4 n,
00413 double z_axis,
00414 double x_axis,
00415 double y_axis
00416 );
00417 }
00418
00419 #endif
00420