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
00078 class fk_D3DXAnimation;
00079 class fk_BVHMotion;
00080 class fk_Solid;
00081
00083 enum fk_IFType {
00084 FK_IF_NONE,
00085 FK_IF_TRIANGLES,
00086 FK_IF_QUADS,
00087 FK_IF_POLYGON
00088 };
00089
00090
00092
00136 class fk_IndexFaceSet : public fk_ParserData {
00137
00138 friend class fk_PointDraw;
00139 friend class fk_LineDraw;
00140 friend class fk_FaceDraw;
00141 friend class fk_TextureDraw;
00142
00143 private:
00144
00145 fk_Palette localPalette;
00146 std::vector<fk_FVector> pos;
00147 std::vector<fk_FVector> timeOrgPos;
00148 std::vector<fk_FVector> vNorm;
00149 std::vector<fk_FVector> pNorm;
00150 std::vector<int> ifs;
00151 std::vector<int> edgeSet;
00152 std::vector< std::vector<int> > loopStack;
00153 bool modifyFlg;
00154 std::vector<char> vNormFlg;
00155 std::vector<char> pNormFlg;
00156 std::vector<int> modifyList;
00157 std::vector<int> colorID;
00158 bool colorFlg;
00159 fk_D3DXAnimation *anim;
00160
00161 int posSize;
00162 int faceSize;
00163 fk_IFType type;
00164
00165 void InitPNorm(void);
00166 void InitVNorm(void);
00167 void ModifyPNorm(void);
00168 void ModifyVNorm(void);
00169 void MakePNorm(int);
00170
00171 void ClearPFlg(void);
00172 void ClearVFlg(void);
00173
00174 fk_Vector CalcTriNorm(int *);
00175 fk_Vector CalcPolyNorm(int, int *);
00176 void MakeLoopTable(void);
00177 void MakeEdgeSet(void);
00178
00179 bool Init(int, int, int);
00180 void Init(void);
00181
00182 public:
00183
00185 fk_IndexFaceSet(void);
00186
00188 ~fk_IndexFaceSet();
00189
00190
00192
00194
00201 bool readSMFFile(std::string fileName);
00202
00204
00231 bool readVRMLFile(std::string fileName,
00232 bool materialFlg = true,
00233 bool solidFlg = true);
00234
00236
00256 bool readSTLFile(std::string fileName,
00257 bool solidFlg = true,
00258 double tolerance = 1.0e-08);
00259
00261
00268 bool readHRCFile(std::string fileName);
00269
00271
00283 bool readRDSFile(std::string fileName,
00284 bool solidFlg = true);
00285
00287
00299 bool readDXFFile(std::string fileName,
00300 bool solidFlg = true);
00301
00303
00338 bool readMQOFile(std::string fileName,
00339 std::string objName,
00340 bool solidFlg = true,
00341 bool contFlg = true,
00342 bool materialFlg = false);
00343
00345
00385 bool readMQOFile(std::string fileName,
00386 std::string objName,
00387 int materialID,
00388 bool solidFlg = true,
00389 bool contFlg = true,
00390 bool materialFlg = false);
00391
00393
00431 bool readMQOData(unsigned char *buffer,
00432 std::string objName,
00433 bool solidFlg = true,
00434 bool contFlg = true,
00435 bool materialFlg = false);
00436
00438
00481 bool readMQOData(unsigned char *buffer,
00482 std::string objName,
00483 int materialID,
00484 bool solidFlg = true,
00485 bool contFlg = true,
00486 bool materialFlg = false);
00487
00489
00515 bool readD3DXFile(std::string fileName,
00516 std::string objName,
00517 bool solidFlg = true);
00518
00520
00551 bool readD3DXFile(std::string fileName,
00552 std::string objName,
00553 int materialID,
00554 bool solidFlg = true);
00555
00556
00557
00559
00561
00573 bool writeVRMLFile(std::string fileName,
00574 fk_Material *material = NULL,
00575 bool triFlg = false);
00576
00578
00597 bool writeVRMLFile(std::string fileName,
00598 std::vector<double> *time,
00599 std::vector<fk_Vector> *pos,
00600 fk_Material *material = NULL,
00601 bool triFlg = false);
00602
00604
00611 bool writeSTLFile(std::string fileName);
00612
00614
00624 bool writeDXFFile(std::string fileName,
00625 bool triFlg = false);
00626
00628
00635 bool writeMQOFile(std::string fileName);
00636
00637
00639
00640
00642
00647 int getPosSize(void);
00648
00650
00655 int getFaceSize(void);
00656
00658
00669 fk_Vector getPosVec(int vertexID);
00670
00672
00681 std::vector<int> getFaceData(int faceID);
00682
00684
00698 int getFaceData(int faceID, int vertexNum);
00699
00701
00705 fk_IFType getFaceType(void);
00706
00708
00719 fk_Vector getPNorm(int faceID, int order = 0);
00720
00722
00733 fk_Vector getVNorm(int vertexID, int order = 0);
00734
00736
00748 int getElemMaterialID(int faceID);
00749
00750
00752
00753
00755
00770 bool moveVPosition(int vertexID,
00771 const fk_Vector &pos,
00772 int order = 0);
00773
00775
00792 bool moveVPosition(int vertexID,
00793 double x, double y, double z,
00794 int order = 0);
00795
00797
00813 bool moveVPosition(int vertexID,
00814 double *array,
00815 int order = 0);
00816
00818
00840 void makeIFSet(int faceNum,
00841 int polyNum,
00842 int *IFSet,
00843 int vertexNum,
00844 fk_Vector *posArray,
00845 int order = 0);
00846
00848
00871 bool setPNorm(int faceID,
00872 const fk_Vector &norm,
00873 int order = 0);
00874
00876
00899 bool setVNorm(int vertexID,
00900 const fk_Vector &norm,
00901 int order = 0);
00902
00904
00917 bool setElemMaterialID(int faceID,
00918 int materialID);
00919
00921
00936 void flush(void);
00937
00938
00939
00941
00943
00966 void makeBlock(double x, double y, double z);
00967
00969
00981 void setBlockSize(double x, double y, double z);
00982
00984
00998 void setBlockSize(double length, fk_Axis axis);
00999
01001
01011 void setBlockScale(double scale);
01012
01014
01028 void setBlockScale(double scale, fk_Axis axis);
01029
01031
01043 void setBlockScale(double x, double y, double z);
01044
01045
01047
01049
01068 void makeCircle(int div, double rad);
01069
01071
01081 void setCircleRadius(double rad);
01082
01084
01094 void setCircleDivide(int div);
01095
01097
01107 void setCircleScale(double scale);
01108
01109
01111
01113
01131 void makeSphere(int div, double rad);
01132
01134
01144 void setSphereRadius(double rad);
01145
01147
01157 void setSphereDivide(int div);
01158
01160
01170 void setSphereScale(double scale);
01171
01172
01174
01176
01196 void makePrism(int div, double top,
01197 double bottom, double height);
01198
01200
01210 void setPrismDivide(int div);
01211
01213
01223 void setPrismTopRadius(double top);
01224
01226
01236 void setPrismBottomRadius(double bottom);
01237
01239
01249 void setPrismHeight(double height);
01250
01251
01253
01255
01274 void makeCone(int div, double rad, double height);
01275
01277
01287 void setConeDivide(int div);
01288
01290
01300 void setConeRadius(double rad);
01301
01303
01313 void setConeHeight(double height);
01314
01315
01317
01318
01320
01330 void putSolid(fk_Solid *solid);
01331
01333
01342 void setAnimationTime(double time);
01343
01345
01352 void setBVHMotion(fk_BVHMotion *bvh);
01353
01354
01355 #ifndef FK_DOXYGEN_USER_PROCESS
01356
01357 bool MakeMesh(std::vector<fk_Vector> *,
01358 std::vector< std::vector<int> > *,
01359 std::vector<int> * = NULL, bool = true);
01360
01361 fk_D3DXAnimation * GetAnimation(void);
01362
01363 #endif
01364
01365 };
01366
01367 #endif // !__FK_INDEXFACE_HEADER__