Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

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