00001 // 00002 // Copyright (c) 2000 by Tech Soft 3D, LLC. 00003 // The information contained herein is confidential and proprietary to 00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 // civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 // and criminal remedies in the event of unauthorized use or misappropriation 00007 // of its trade secrets. Use of this information by anyone other than 00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 // written non-disclosure agreement, expressly prescribing the scope and 00010 // manner of such use. 00011 // 00012 // $Id$ 00013 // 00014 00015 #ifndef _HIOUTILITYPLY_H 00016 #define _HIOUTILITYPLY_H 00017 00018 #ifdef H_PACK_8 00019 #pragma pack(push) 00020 #pragma pack(8) 00021 #endif 00022 00023 #include "HTools.h" 00024 #include "HIOManager.h" 00025 #include "varray.h" 00026 #include <stdio.h> 00027 00031 class MVO_API HIOUtilityPly: public HInputHandler, public HOutputHandler 00032 { 00033 private: 00034 bool m_binary; 00035 bool m_bigendian; 00036 00037 bool m_vertex_colors; 00038 bool m_vertex_normals; 00039 bool m_face_colors; 00040 00041 bool read_ply_header( FILE *f, int *point_count, int *face_count, int *opcodes ); 00042 bool write_ply_header( FILE *f, int point_count, int face_count, HPoint *min=0, HPoint *max=0 ); 00043 00044 bool count( int *total_point_count, int *total_face_count ); 00045 bool write_points( FILE *f ); 00046 bool write_faces( FILE *f ); 00047 00048 bool count_recursive( int *total_point_count, int *total_face_count ); 00049 bool write_points_recursive( FILE *f, float *modelling_matrix_in ); 00050 bool write_faces_recursive( FILE *f, int *point_offset ); 00051 00052 bool write_one_int( FILE *f, int val ); 00053 bool write_one_byte( FILE *f, unsigned char val ); 00054 bool write_one_float( FILE *f, float val ); 00055 bool read_one_int( FILE *f, int *val ); 00056 bool read_one_byte( FILE *f, unsigned char *val ); 00057 bool read_one_float( FILE *f, float *val ); 00058 00059 class Color_Node { 00060 public: 00061 Color_Node() { entity_list = new VArray<int>; } 00062 ~Color_Node() { delete entity_list; } 00063 float rgb_color_f[3]; 00064 VArray<int> *entity_list; 00065 }; 00066 00067 public: 00068 00070 HIOUtilityPly() { 00071 m_binary = false; 00072 m_bigendian = false; 00073 SetInputOps(HInputOpFileInputByKey); 00074 SetOutputOps(HOutputOpFileOutputByKey); 00075 }; 00076 00077 virtual ~HIOUtilityPly() {;}; 00078 00081 const char * GetOutputName() { return "HIOUtilityPly"; } 00082 const char * GetInputName() { return "HIOUtilityPly"; } 00083 00085 void RegisterInputHandlerTypes() { 00086 HIORegisterInputType("ply",this); 00087 }; 00088 00090 void RegisterOutputHandlerTypes() { 00091 HIORegisterOutputType("ply",this); 00092 }; 00093 00095 const char * GetInputTypesString() {return "ply";}; 00096 00098 const char * GetOutputTypesString() {return "ply";}; 00099 00101 HInputHandlerStyle GetInputStyle() {return HInputHandlerStyleModel;}; 00102 00104 HOutputHandlerStyle GetOutputStyle() {return HOutputHandlerStyleModel;}; 00105 00115 HFileInputResult FileInputByKey(const __wchar_t * FileName, HC_KEY key, HInputHandlerOptions * options); 00116 00117 HFileInputResult FileInputByKey(const char * FileName, HC_KEY key, HInputHandlerOptions * options){ 00118 return FileInputByKey(H_WCS(FileName).encodedText(), key, options); 00119 }; 00120 00121 HFileInputResult FileInputByKey(const unsigned short * FileName, HC_KEY key, HInputHandlerOptions * options){ 00122 H_UTF16 utf16; 00123 utf16.encodedText((utf16_char const*) FileName); 00124 return FileInputByKey(H_WCS(utf16).encodedText(), key, options); 00125 }; 00126 00134 HFileOutputResult FileOutputByKey(const __wchar_t * filename, HC_KEY key, HOutputHandlerOptions * options); 00135 00136 HFileOutputResult FileOutputByKey(const unsigned short * filename, HC_KEY key, HOutputHandlerOptions * options){ 00137 H_UTF16 utf16; 00138 utf16.encodedText((utf16_char const*) filename); 00139 return FileOutputByKey(H_WCS(utf16).encodedText(), key, options); 00140 } 00141 00142 HFileOutputResult FileOutputByKey(const char * filename, HC_KEY key, HOutputHandlerOptions * options){ 00143 return FileOutputByKey(H_WCS(filename).encodedText(), key, options); 00144 } 00145 00146 }; 00147 00148 00149 #ifdef H_PACK_8 00150 #pragma pack(pop) 00151 #endif 00152 00153 #endif