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 #ifndef __FK_INDEXFACE_HEADER__
00073 #define __FK_INDEXFACE_HEADER__
00074
00075 #include <FK/ParserBase.H>
00076 #include <FK/ParserData.h>
00077 #include <list>
00078
00079 class fk_D3DXAnimation;
00080 class fk_BVHMotion;
00081 class fk_Solid;
00082
00084 enum fk_IFType {
00085 FK_IF_NONE,
00086 FK_IF_TRIANGLES,
00087 FK_IF_QUADS,
00088 FK_IF_POLYGON
00089 };
00090
00091
00093
00137 class fk_IndexFaceSet : public fk_ParserData {
00138
00139 friend class fk_PointDraw;
00140 friend class fk_LineDraw;
00141 friend class fk_FaceDraw;
00142 friend class fk_TextureDraw;
00143
00144 private:
00145
00146 fk_Palette localPalette;
00147 std::vector<fk_FVector> pos;
00148 std::vector<fk_FVector> timeOrgPos;
00149 std::vector<fk_FVector> vNorm;
00150 std::vector<fk_FVector> pNorm;
00151 std::vector<int> ifs;
00152 std::vector<int> edgeSet;
00153 std::vector< std::vector<int> > loopStack;
00154 bool modifyFlg;
00155 std::vector<char> vNormFlg;
00156 std::vector<char> pNormFlg;
00157 std::vector<int> modifyList;
00158 std::vector<int> colorID;
00159 bool colorFlg;
00160 fk_D3DXAnimation *anim;
00161
00162 int posSize;
00163 int faceSize;
00164 fk_IFType type;
00165
00166 bool cloneFlg;
00167 std::list<fk_IndexFaceSet *> cloneList;
00168 fk_IndexFaceSet *orgIFS;
00169
00170 void InitPNorm(void);
00171 void InitVNorm(void);
00172 void ModifyPNorm(void);
00173 void ModifyVNorm(void);
00174 void MakePNorm(int);
00175
00176 void ClearPFlg(void);
00177 void ClearVFlg(void);
00178
00179 fk_Vector CalcTriNorm(int *);
00180 fk_Vector CalcPolyNorm(int, int *);
00181 void MakeLoopTable(void);
00182 void MakeEdgeSet(void);
00183
00184 bool Init(int, int, int);
00185 void Init(void);
00186
00187 void DeleteCloneLink(fk_IndexFaceSet *);
00188
00189 public:
00190
00192 fk_IndexFaceSet(void);
00193
00195 ~fk_IndexFaceSet();
00196
00197
00199
00205 void cloneShape(fk_IndexFaceSet *ifs);
00206
00208
00210
00217 bool readSMFFile(std::string fileName);
00218
00220
00247 bool readVRMLFile(std::string fileName,
00248 bool materialFlg = true,
00249 bool solidFlg = true);
00250
00252
00272 bool readSTLFile(std::string fileName,
00273 bool solidFlg = true,
00274 double tolerance = 1.0e-08);
00275
00277
00284 bool readHRCFile(std::string fileName);
00285
00287
00299 bool readRDSFile(std::string fileName,
00300 bool solidFlg = true);
00301
00303
00315 bool readDXFFile(std::string fileName,
00316 bool solidFlg = true);
00317
00319
00354 bool readMQOFile(std::string fileName,
00355 std::string objName,
00356 bool solidFlg = true,
00357 bool contFlg = true,
00358 bool materialFlg = false);
00359
00361
00401 bool readMQOFile(std::string fileName,
00402 std::string objName,
00403 int materialID,
00404 bool solidFlg = true,
00405 bool contFlg = true,
00406 bool materialFlg = false);
00407
00409
00447 bool readMQOData(unsigned char *buffer,
00448 std::string objName,
00449 bool solidFlg = true,
00450 bool contFlg = true,
00451 bool materialFlg = false);
00452
00454
00497 bool readMQOData(unsigned char *buffer,
00498 std::string objName,
00499 int materialID,
00500 bool solidFlg = true,
00501 bool contFlg = true,
00502 bool materialFlg = false);
00503
00505
00531 bool readD3DXFile(std::string fileName,
00532 std::string objName,
00533 bool solidFlg = true);
00534
00536
00567 bool readD3DXFile(std::string fileName,
00568 std::string objName,
00569 int materialID,
00570 bool solidFlg = true);
00571
00572
00573
00575
00577
00589 bool writeVRMLFile(std::string fileName,
00590 fk_Material *material = NULL,
00591 bool triFlg = false);
00592
00594
00613 bool writeVRMLFile(std::string fileName,
00614 std::vector<double> *time,
00615 std::vector<fk_Vector> *pos,
00616 fk_Material *material = NULL,
00617 bool triFlg = false);
00618
00620
00627 bool writeSTLFile(std::string fileName);
00628
00630
00640 bool writeDXFFile(std::string fileName,
00641 bool triFlg = false);
00642
00644
00651 bool writeMQOFile(std::string fileName);
00652
00653
00655
00656
00658
00663 int getPosSize(void);
00664
00666
00671 int getFaceSize(void);
00672
00674
00685 fk_Vector getPosVec(int vertexID);
00686
00688
00697 std::vector<int> getFaceData(int faceID);
00698
00700
00714 int getFaceData(int faceID, int vertexNum);
00715
00717
00721 fk_IFType getFaceType(void);
00722
00724
00735 fk_Vector getPNorm(int faceID, int order = 0);
00736
00738
00749 fk_Vector getVNorm(int vertexID, int order = 0);
00750
00752
00764 int getElemMaterialID(int faceID);
00765
00766
00768
00769
00771
00786 bool moveVPosition(int vertexID,
00787 const fk_Vector &pos,
00788 int order = 0);
00789
00791
00808 bool moveVPosition(int vertexID,
00809 double x, double y, double z,
00810 int order = 0);
00811
00813
00829 bool moveVPosition(int vertexID,
00830 double *array,
00831 int order = 0);
00832
00834
00856 void makeIFSet(int faceNum,
00857 int polyNum,
00858 int *IFSet,
00859 int vertexNum,
00860 fk_Vector *posArray,
00861 int order = 0);
00862
00864
00887 bool setPNorm(int faceID,
00888 const fk_Vector &norm,
00889 int order = 0);
00890
00892
00915 bool setVNorm(int vertexID,
00916 const fk_Vector &norm,
00917 int order = 0);
00918
00920
00933 bool setElemMaterialID(int faceID,
00934 int materialID);
00935
00937
00952 void flush(void);
00953
00954
00955
00957
00959
00982 void makeBlock(double x, double y, double z);
00983
00985
00997 void setBlockSize(double x, double y, double z);
00998
01000
01014 void setBlockSize(double length, fk_Axis axis);
01015
01017
01027 void setBlockScale(double scale);
01028
01030
01044 void setBlockScale(double scale, fk_Axis axis);
01045
01047
01059 void setBlockScale(double x, double y, double z);
01060
01061
01063
01065
01084 void makeCircle(int div, double rad);
01085
01087
01097 void setCircleRadius(double rad);
01098
01100
01110 void setCircleDivide(int div);
01111
01113
01123 void setCircleScale(double scale);
01124
01125
01127
01129
01147 void makeSphere(int div, double rad);
01148
01150
01160 void setSphereRadius(double rad);
01161
01163
01173 void setSphereDivide(int div);
01174
01176
01186 void setSphereScale(double scale);
01187
01188
01190
01192
01212 void makePrism(int div, double top,
01213 double bottom, double height);
01214
01216
01226 void setPrismDivide(int div);
01227
01229
01239 void setPrismTopRadius(double top);
01240
01242
01252 void setPrismBottomRadius(double bottom);
01253
01255
01265 void setPrismHeight(double height);
01266
01267
01269
01271
01290 void makeCone(int div, double rad, double height);
01291
01293
01303 void setConeDivide(int div);
01304
01306
01316 void setConeRadius(double rad);
01317
01319
01329 void setConeHeight(double height);
01330
01331
01333
01334
01336
01346 void putSolid(fk_Solid *solid);
01347
01349
01358 void setAnimationTime(double time);
01359
01361
01368 void setBVHMotion(fk_BVHMotion *bvh);
01369
01370
01371 #ifndef FK_DOXYGEN_USER_PROCESS
01372
01373 bool MakeMesh(std::vector<fk_Vector> *,
01374 std::vector< std::vector<int> > *,
01375 std::vector<int> * = NULL, bool = true);
01376
01377 fk_D3DXAnimation * GetAnimation(void);
01378
01379 #endif
01380
01381 };
01382
01383 #endif // !__FK_INDEXFACE_HEADER__