FineKernelToolKit  2.8.10
FK/IndexFace.h
説明を見る。
00001 /****************************************************************************
00002  *
00003  *  Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved.
00004  *
00005  *  Redistribution and use in source and binary forms,
00006  *  with or without modification, are permitted provided that the
00007  *  following conditions are met:
00008  *
00009  *      - Redistributions of source code must retain the above
00010  *          copyright notice, this list of conditions and the
00011  *          following disclaimer.
00012  *
00013  *      - Redistributions in binary form must reproduce the above
00014  *          copyright notice, this list of conditions and the
00015  *          following disclaimer in the documentation and/or
00016  *          other materials provided with the distribution.
00017  *
00018  *      - Neither the name of the copyright holders nor the names
00019  *          of its contributors may be used to endorse or promote
00020  *          products derived from this software without specific
00021  *          prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00030  *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00031  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00032  *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00033  *  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE. 
00035  *
00036  ****************************************************************************/
00037 /****************************************************************************
00038  *
00039  *  Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved.
00040  *
00041  *  本ソフトウェアおよびソースコードのライセンスは、基本的に
00042  *  「修正 BSD ライセンス」に従います。以下にその詳細を記します。
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     virtual ~fk_IndexFaceSet();
00196 
00197 
00199 
00205     void                cloneShape(fk_IndexFaceSet *ifs);
00206 
00208     //@(
00210 
00217     bool                readSMFFile(std::string fileName);
00218 
00220 
00249     bool                readVRMLFile(std::string fileName,
00250                                      bool materialFlg = true,
00251                                      bool solidFlg = true);
00252 
00254 
00276     bool                readSTLFile(std::string fileName,
00277                                     bool solidFlg = true,
00278                                     double tolerance = 1.0e-08);
00279 
00281 
00288     bool                readHRCFile(std::string fileName);
00289 
00291 
00304     bool                readRDSFile(std::string fileName,
00305                                     bool solidFlg = true);
00306 
00308 
00320     bool                readDXFFile(std::string fileName,
00321                                     bool solidFlg = true);
00322 
00324 
00359     bool                readMQOFile(std::string fileName,
00360                                     std::string objName,
00361                                     bool solidFlg = true,
00362                                     bool contFlg = true,
00363                                     bool materialFlg = false);
00364 
00366 
00411     bool                readMQOFile(std::string fileName,
00412                                     std::string objName,
00413                                     int materialID,
00414                                     bool solidFlg = true,
00415                                     bool contFlg = true,
00416                                     bool materialFlg = false);
00417 
00419 
00461     bool                readMQOData(unsigned char *buffer,
00462                                     std::string objName,
00463                                     bool solidFlg = true,
00464                                     bool contFlg = true,
00465                                     bool materialFlg = false);
00466 
00468 
00516     bool                readMQOData(unsigned char *buffer,
00517                                     std::string objName,
00518                                     int materialID,
00519                                     bool solidFlg = true,
00520                                     bool contFlg = true,
00521                                     bool materialFlg = false);
00522 
00524 
00552     bool                readD3DXFile(std::string fileName,
00553                                      std::string objName,
00554                                      bool solidFlg = true);
00555 
00557 
00591     bool                readD3DXFile(std::string fileName,
00592                                      std::string objName,
00593                                      int materialID,
00594                                      bool solidFlg = true);
00595 
00596     //@)
00597 
00599     //@(
00601 
00613     bool                writeVRMLFile(std::string fileName,
00614                                       fk_Material *material = NULL,
00615                                       bool triFlg = false);
00616 
00618 
00637     bool                writeVRMLFile(std::string fileName,
00638                                       std::vector<double> *time,
00639                                       std::vector<fk_Vector> *pos,
00640                                       fk_Material *material = NULL,
00641                                       bool triFlg = false);
00642 
00644 
00651     bool                writeSTLFile(std::string fileName);
00652 
00654 
00664     bool                writeDXFFile(std::string fileName,
00665                                      bool triFlg = false);
00666 
00668 
00675     bool                writeMQOFile(std::string fileName);
00676     //@)
00677 
00679     //@(
00680 
00682 
00687     int                 getPosSize(void);
00688 
00690 
00695     int                 getFaceSize(void);
00696 
00698 
00709     fk_Vector           getPosVec(int vertexID);
00710 
00712 
00721     std::vector<int>    getFaceData(int faceID);
00722 
00724 
00738     int                 getFaceData(int faceID, int vertexNum);
00739 
00741 
00745     fk_IFType           getFaceType(void);
00746 
00748 
00759     fk_Vector           getPNorm(int faceID, int order = 0);
00760 
00762 
00773     fk_Vector           getVNorm(int vertexID, int order = 0);
00774 
00776 
00788     int                 getElemMaterialID(int faceID);
00789     //@)
00790 
00792     //@(
00793 
00795 
00810     bool                moveVPosition(int vertexID,
00811                                       const fk_Vector &pos,
00812                                       int order = 0);
00813 
00815 
00832     bool                moveVPosition(int vertexID,
00833                                       double x, double y, double z,
00834                                       int order = 0);
00835 
00837 
00853     bool                moveVPosition(int vertexID,
00854                                       double *array,
00855                                       int order = 0);
00856 
00858 
00880     void                makeIFSet(int faceNum,
00881                                   int polyNum,
00882                                   int *IFSet,
00883                                   int vertexNum,
00884                                   fk_Vector *posArray,
00885                                   int order = 0);
00886 
00888 
00911     bool                setPNorm(int faceID,
00912                                  const fk_Vector &norm,
00913                                  int order = 0);
00914 
00916 
00939     bool                setVNorm(int vertexID,
00940                                  const fk_Vector &norm,
00941                                  int order = 0);
00942 
00944 
00957     bool                setElemMaterialID(int faceID,
00958                                           int materialID);
00959 
00961 
00976     void                flush(void);
00977 
00978     //@)
00979 
00981     //@(
00983 
01006     void                makeBlock(double x, double y, double z);
01007 
01009 
01021     void                setBlockSize(double x, double y, double z);
01022 
01024 
01038     void                setBlockSize(double length, fk_Axis axis);
01039 
01041 
01051     void                setBlockScale(double scale);
01052 
01054 
01068     void                setBlockScale(double scale, fk_Axis axis);
01069 
01071 
01083     void                setBlockScale(double x, double y, double z);
01084     //@)
01085 
01087     //@(
01089 
01108     void                makeCircle(int div, double rad);
01109 
01111 
01121     void                setCircleRadius(double rad);
01122 
01124 
01134     void                setCircleDivide(int div);
01135 
01137 
01147     void                setCircleScale(double scale);
01148     //@)
01149 
01151     //@(
01153 
01171     void                makeSphere(int div, double rad);
01172 
01174 
01184     void                setSphereRadius(double rad);
01185 
01187 
01197     void                setSphereDivide(int div);
01198 
01200 
01210     void                setSphereScale(double scale);
01211     //@)
01212 
01214     //@(
01216 
01236     void                makePrism(int div, double top,
01237                                   double bottom, double height);
01238 
01240 
01250     void                setPrismDivide(int div);
01251 
01253 
01263     void                setPrismTopRadius(double top);
01264 
01266 
01276     void                setPrismBottomRadius(double bottom);
01277 
01279 
01289     void                setPrismHeight(double height);
01290     //@)
01291 
01293     //@(
01295 
01314     void                makeCone(int div, double rad, double height);
01315 
01317 
01327     void                setConeDivide(int div);
01328 
01330 
01340     void                setConeRadius(double rad);
01341 
01343 
01353     void                setConeHeight(double height);
01354     //@)
01355 
01357     //@(
01358 
01360 
01370     void                putSolid(fk_Solid *solid);
01371 
01373 
01382     void                setAnimationTime(double time);
01383 
01385 
01392     void                setBVHMotion(fk_BVHMotion *bvh);
01393     //@)
01394 
01395 #ifndef FK_DOXYGEN_USER_PROCESS
01396 
01397     bool                MakeMesh(std::vector<fk_Vector> *,
01398                                  std::vector< std::vector<int> > *,
01399                                  std::vector<int> * = NULL,
01400                                  bool = true);
01401 
01402     fk_D3DXAnimation *  GetAnimation(void);
01403 
01404     void                PosPrint(std::string);
01405 
01406 #endif
01407 
01408 };
01409 
01410 #endif // !__FK_INDEXFACE_HEADER__
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型 列挙型の値 フレンド マクロ定義