00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __UT_XformOrder_h__
00022 #define __UT_XformOrder_h__
00023
00024 #include "UT_API.h"
00025 #include <iostream.h>
00026 #include "UT_Assert.h"
00027
00028 class UT_API UT_XformOrder
00029 {
00030 public:
00031
00032
00033 enum xform { T=0, S=1, RX=2, RY=3, RZ=4};
00034
00035
00036
00037
00038 enum rstOrder { TRS, TSR, RTS, RST, STR, SRT };
00039 enum xyzOrder { XYZ, XZY, YXZ, YZX, ZXY, ZYX };
00040
00041
00042
00043
00044
00045
00046
00047 UT_XformOrder(rstOrder rst = UT_XformOrder::TSR,
00048 xyzOrder rot = UT_XformOrder::XYZ)
00049 {
00050 reorder(rst, rot);
00051 }
00052
00053 UT_XformOrder(xform xf1, xform xf2,
00054 xform xf3 = UT_XformOrder::RX,
00055 xform xf4 = UT_XformOrder::RY,
00056 xform xf5 = UT_XformOrder::RZ)
00057 {
00058 reorder(xf1, xf2, xf3, xf4, xf5);
00059 }
00060
00061
00062
00063
00064 UT_XformOrder(const char *rst, const char *rot = "xyz");
00065
00066
00067 UT_XformOrder(const UT_XformOrder &xf);
00068
00069
00070 ~UT_XformOrder() {}
00071
00072
00073
00074
00075
00076 void reorder(UT_XformOrder::xform xf1,
00077 UT_XformOrder::xform xf2, UT_XformOrder::xform xf3,
00078 UT_XformOrder::xform xf4, UT_XformOrder::xform xf5);
00079 void reorder(UT_XformOrder::rstOrder rst,
00080 UT_XformOrder::xyzOrder rot);
00081
00082
00083
00084
00085
00086
00087 UT_XformOrder::rstOrder mainOrder(void) const;
00088 void mainOrder(UT_XformOrder::rstOrder rst);
00089 bool mainOrder(const char *rst);
00090 UT_XformOrder::xyzOrder rotOrder (void) const;
00091 void rotOrder (UT_XformOrder::xyzOrder rot);
00092 bool rotOrder (const char *rot);
00093
00094
00095
00096 static void getRotOrderMapping(xyzOrder src, xyzOrder dst,
00097 int map[3]);
00098
00099
00100 void swap(UT_XformOrder::xform xf1,UT_XformOrder::xform xf2)
00101 {
00102 if (xf1 != xf2)
00103 {
00104 unsigned short i1 = prefList[xf1];
00105 unsigned short i2 = prefList[xf2];
00106 prefList[xf1] = i2; permList[i1] = xf2;
00107 prefList[xf2] = i1; permList[i2] = xf1;
00108 }
00109 }
00110
00111 void invert();
00112
00113
00114
00115
00116 unsigned short operator()(UT_XformOrder::xform xf) const
00117 {
00118 return prefList[xf];
00119 }
00120 UT_XformOrder::xform operator[](unsigned short i) const
00121 {
00122 UT_ASSERT_P(i < 5);
00123 return (i<5)
00124 ? (UT_XformOrder::xform)permList[i]
00125 : (UT_XformOrder::xform)permList[4];
00126 }
00127
00128
00129 int count(void) const { return 5; }
00130
00131
00132 UT_XformOrder &operator=(const UT_XformOrder &xf);
00133
00134
00135
00136 int save(ostream &os, int binary=0) const;
00137
00138 friend ostream &operator<<(ostream &os, const UT_XformOrder &t)
00139 {
00140 t.save(os);
00141 return os;
00142 }
00143 private:
00144
00145
00146 char permList[5];
00147
00148
00149
00150 unsigned short prefList[5];
00151
00152
00153
00154
00155 static bool rstFromString(const char *rst,
00156 UT_XformOrder::rstOrder &result);
00157 static bool xyzFromString(const char *rot,
00158 UT_XformOrder::xyzOrder &result);
00159
00160 static const char * theXYZNames[6];
00161 };
00162
00163 #endif