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
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 #include "camtypes.h"
00111
00112
00113
00114 #include "nodershp.h"
00115 #include "cxftags.h"
00116
00117
00118 #include "cxfile.h"
00119
00120 #include "cxfrgshp.h"
00121 #include "cxfpoly.h"
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 BOOL CXaraFilePolygon::WritePolygon(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00145 {
00146 BOOL ok;
00147
00148
00149
00150
00151
00152 const INT32 REFORMED = 0x1;
00153 const INT32 STELLATED = 0x2;
00154 const INT32 ROUNDED = 0x4;
00155
00156 INT32 PolygonType = 0;
00157
00158 if (IsReformed(pShape)) PolygonType |= REFORMED;
00159 if (IsStellated(pShape)) PolygonType |= STELLATED;
00160 if (IsRounded(pShape)) PolygonType |= ROUNDED;
00161
00162 switch (PolygonType)
00163 {
00164 case 0 : ok = WritePolygonComplex(pFilter, pShape); break;
00165 case REFORMED : ok = WritePolygonComplexReformed(pFilter, pShape); break;
00166 case STELLATED : ok = WritePolygonComplexStellated(pFilter, pShape); break;
00167 case STELLATED|REFORMED : ok = WritePolygonComplexStellatedReformed(pFilter, pShape); break;
00168 case ROUNDED : ok = WritePolygonComplexRounded(pFilter, pShape); break;
00169 case ROUNDED|REFORMED : ok = WritePolygonComplexRoundedReformed(pFilter, pShape); break;
00170 case ROUNDED|STELLATED : ok = WritePolygonComplexRoundedStellated(pFilter, pShape); break;
00171 case ROUNDED|STELLATED|REFORMED : ok = WritePolygonComplexRoundedStellatedReformed(pFilter, pShape); break;
00172 default : ok = WriteShapeInvalid(pFilter, pShape); break;
00173 }
00174
00175 return ok;
00176 }
00177
00178 BOOL CXaraFilePolygon::WritePolygonComplex(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00179 {
00180 BOOL ok;
00181
00182 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX, TAG_POLYGON_COMPLEX_SIZE);
00183
00184 ok = Rec.Init();
00185 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00186 if (ok) ok = Rec.WriteCoord(GetCentrePoint(pShape));
00187 if (ok) ok = Rec.WriteCoordTrans(GetMajorAxis(pShape),0,0);
00188 if (ok) ok = Rec.WriteCoordTrans(GetMinorAxis(pShape),0,0);
00189 if (ok) ok = pFilter->Write(&Rec);
00190
00191 return ok;
00192 }
00193
00194 BOOL CXaraFilePolygon::WritePolygonComplexReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00195 {
00196 BOOL ok;
00197
00198 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_REFORMED, TAG_POLYGON_COMPLEX_REFORMED_SIZE);
00199
00200 ok = Rec.Init();
00201 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00202 if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0);
00203 if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0);
00204 if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape));
00205 if (ok) ok = Rec.WritePath(GetEdgePath(pShape));
00206 if (ok) ok = pFilter->Write(&Rec);
00207
00208 return ok;
00209 }
00210
00211 BOOL CXaraFilePolygon::WritePolygonComplexStellated(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00212 {
00213 BOOL ok;
00214
00215 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_STELLATED, TAG_POLYGON_COMPLEX_STELLATED_SIZE);
00216
00217 ok = Rec.Init();
00218 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00219 if (ok) ok = Rec.WriteCoord(GetCentrePoint(pShape));
00220 if (ok) ok = Rec.WriteCoordTrans(GetMajorAxis(pShape),0,0);
00221 if (ok) ok = Rec.WriteCoordTrans(GetMinorAxis(pShape),0,0);
00222 if (ok) ok = Rec.WriteDOUBLE(GetStellationRadius(pShape));
00223 if (ok) ok = Rec.WriteDOUBLE(GetStellationOffset(pShape));
00224 if (ok) ok = pFilter->Write(&Rec);
00225
00226 return ok;
00227 }
00228
00229 BOOL CXaraFilePolygon::WritePolygonComplexStellatedReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00230 {
00231 BOOL ok;
00232
00233 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_STELLATED_REFORMED, TAG_POLYGON_COMPLEX_STELLATED_REFORMED_SIZE);
00234
00235 ok = Rec.Init();
00236 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00237 if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0);
00238 if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0);
00239 if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape));
00240 if (ok) ok = Rec.WriteDOUBLE(GetStellationRadius(pShape));
00241 if (ok) ok = Rec.WriteDOUBLE(GetStellationOffset(pShape));
00242 if (ok) ok = Rec.WritePath(GetPrimaryEdgePath(pShape));
00243 if (ok) ok = Rec.WritePath(GetSecondaryEdgePath(pShape));
00244 if (ok) ok = pFilter->Write(&Rec);
00245
00246 return ok;
00247 }
00248
00249 BOOL CXaraFilePolygon::WritePolygonComplexRounded(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00250 {
00251 BOOL ok;
00252
00253 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_ROUNDED, TAG_POLYGON_COMPLEX_ROUNDED_SIZE);
00254
00255 ok = Rec.Init();
00256 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00257 if (ok) ok = Rec.WriteCoord(GetCentrePoint(pShape));
00258 if (ok) ok = Rec.WriteCoordTrans(GetMajorAxis(pShape),0,0);
00259 if (ok) ok = Rec.WriteCoordTrans(GetMinorAxis(pShape),0,0);
00260 if (ok) ok = Rec.WriteDOUBLE(GetCurvature(pShape));
00261 if (ok) ok = pFilter->Write(&Rec);
00262
00263 return ok;
00264 }
00265
00266 BOOL CXaraFilePolygon::WritePolygonComplexRoundedReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00267 {
00268 BOOL ok;
00269
00270 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_ROUNDED_REFORMED, TAG_POLYGON_COMPLEX_ROUNDED_REFORMED_SIZE);
00271
00272 ok = Rec.Init();
00273 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00274 if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0);
00275 if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0);
00276 if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape));
00277 if (ok) ok = Rec.WriteDOUBLE(GetCurvature(pShape));
00278 if (ok) ok = Rec.WritePath(GetEdgePath(pShape));
00279 if (ok) ok = pFilter->Write(&Rec);
00280
00281 return ok;
00282 }
00283
00284 BOOL CXaraFilePolygon::WritePolygonComplexRoundedStellated(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00285 {
00286 BOOL ok;
00287
00288 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_ROUNDED_STELLATED, TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_SIZE);
00289
00290 ok = Rec.Init();
00291 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00292 if (ok) ok = Rec.WriteCoord(GetCentrePoint(pShape));
00293 if (ok) ok = Rec.WriteCoordTrans(GetMajorAxis(pShape),0,0);
00294 if (ok) ok = Rec.WriteCoordTrans(GetMinorAxis(pShape),0,0);
00295 if (ok) ok = Rec.WriteDOUBLE(GetStellationRadius(pShape));
00296 if (ok) ok = Rec.WriteDOUBLE(GetStellationOffset(pShape));
00297 if (ok) ok = Rec.WriteDOUBLE(GetPrimaryCurvature(pShape));
00298 if (ok) ok = Rec.WriteDOUBLE(GetSecondaryCurvature(pShape));
00299 if (ok) ok = pFilter->Write(&Rec);
00300
00301 return ok;
00302 }
00303
00304 BOOL CXaraFilePolygon::WritePolygonComplexRoundedStellatedReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape)
00305 {
00306 BOOL ok;
00307
00308 CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_REFORMED, TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_REFORMED_SIZE);
00309
00310 ok = Rec.Init();
00311 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape));
00312 if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0);
00313 if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0);
00314 if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape));
00315 if (ok) ok = Rec.WriteDOUBLE(GetStellationRadius(pShape));
00316 if (ok) ok = Rec.WriteDOUBLE(GetStellationOffset(pShape));
00317 if (ok) ok = Rec.WriteDOUBLE(GetPrimaryCurvature(pShape));
00318 if (ok) ok = Rec.WriteDOUBLE(GetSecondaryCurvature(pShape));
00319 if (ok) ok = Rec.WritePath(GetPrimaryEdgePath(pShape));
00320 if (ok) ok = Rec.WritePath(GetSecondaryEdgePath(pShape));
00321 if (ok) ok = pFilter->Write(&Rec);
00322
00323 return ok;
00324 }
00325