Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HIOUtilityStl.h

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: 0daf108e8fcc3997d24ad42413285c9b21bcd3e5 $
00013 //
00014 
00015 #ifndef _HIOUTILITYSTL_H
00016 #define _HIOUTILITYSTL_H
00017 
00018 
00019 #ifdef H_PACK_8
00020 #pragma pack(push)
00021 #pragma pack(8)
00022 #endif
00023 
00024 #include "HTools.h"
00025 #include "HIOManager.h"
00026 #include "varray.h"
00027 
00028 
00033 class MVO_API HIOUtilityStl: public HInputHandler, public HOutputHandler
00034 {
00035 
00036 public:
00037 
00039     HIOUtilityStl() {
00040         SetInputOps(HInputOpFileInputByKey);
00041         SetOutputOps(HOutputOpFileOutputByKey);
00042     };
00043     virtual ~HIOUtilityStl() {;};
00044 
00047     const char * GetOutputName() { return "HIOUtilityStl"; }
00048     const char * GetInputName() { return "HIOUtilityStl"; }
00049 
00051     void RegisterInputHandlerTypes() {
00052         HIORegisterInputType("stl",this);
00053     };
00054 
00056     void RegisterOutputHandlerTypes() {
00057         HIORegisterOutputType("stl",this);
00058     };
00059 
00061     const char * GetInputTypesString() {return "stl";};
00062 
00064     const char * GetOutputTypesString() {return "stl";};
00065 
00067     HInputHandlerStyle GetInputStyle() {return HInputHandlerStyleModel;};
00068 
00070     HOutputHandlerStyle GetOutputStyle() {return HOutputHandlerStyleModel;};
00071 
00082     HFileInputResult FileInputByKey(const __wchar_t * FileName, HC_KEY key, HInputHandlerOptions * options);
00083 
00084     HFileInputResult FileInputByKey(const char * FileName, HC_KEY key, HInputHandlerOptions * options){
00085         return FileInputByKey(H_WCS(FileName).encodedText(), key, options);
00086     };
00087 
00088     HFileInputResult FileInputByKey(const unsigned short * FileName, HC_KEY key, HInputHandlerOptions * options){
00089         H_UTF16 utf16;
00090         utf16.encodedText((utf16_char const*) FileName);
00091         return FileInputByKey(H_WCS(utf16).encodedText(), key, options);
00092     };
00093 
00094 
00103     HFileOutputResult FileOutputByKey(const __wchar_t * filename, HC_KEY key, HOutputHandlerOptions * options);
00104 
00105     HFileOutputResult FileOutputByKey(const unsigned short * filename, HC_KEY key, HOutputHandlerOptions * options){
00106         H_UTF16 utf16;
00107         utf16.encodedText((utf16_char const*) filename);
00108         return FileOutputByKey(H_WCS(utf16).encodedText(), key, options);
00109     }
00110 
00111     HFileOutputResult FileOutputByKey(const char * filename, HC_KEY key, HOutputHandlerOptions * options){
00112         return FileOutputByKey(H_WCS(filename).encodedText(), key, options);
00113     }
00114 
00115 private:
00116 
00117     static struct stl_info
00118     {
00119         FILE *f;
00120         bool is_ascii;
00121         HC_KEY start_segment;
00122         HC_KEY copy_segment;
00123         int triangle_count;
00124     } stl_info_s;
00125 
00126     static struct include_list
00127     {
00128         HC_KEY include;
00129         include_list *next;
00130     } include_list_s;
00131 
00132     static HFileInputResult ReadStlFile(const __wchar_t *FileName);
00133     static HFileInputResult ReadStlFileAscii(const __wchar_t *FileName);
00134     static HFileInputResult ReadStlFileBinary(const __wchar_t *FileName);
00135     static HFileOutputResult WriteStlFile(const __wchar_t *FileName, const float *vertices, const float *normals, unsigned int triangle_count, bool is_ascii, char *partname);
00136     static HFileOutputResult WriteStlFileAscii(const __wchar_t *FileName, const float *vertices, const float *normals, unsigned int triangle_count, char *partname);
00137     static HFileOutputResult WriteStlFileBinary(const __wchar_t *FileName, const float *vertices, const float *normals, unsigned int triangle_count);
00138     static HFileOutputResult ComputeStlTriangles(HC_KEY the_key, stl_info *info, HOutputHandlerOptions *options, bool no_recurse=false, float *matrix_for_segment_reference=0 );
00139 };
00140 
00141 
00142 #ifdef H_PACK_8
00143 #pragma pack(pop)
00144 #endif
00145 
00146 #endif