STLLoader.hh
00001 /*
00002  * Copyright 2011 Nate Koenig & Andrew Howard
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  *
00016 */
00017 #ifndef STLLOADER_HH
00018 #define STLLOADER_HH
00019 
00020 #include <stdint.h>
00021 
00022 #include "common/MeshLoader.hh"
00023 
00024 #define LINE_MAX_LEN 256
00025 #define COR3_MAX 200000
00026 #define ORDER_MAX 10
00027 #define FACE_MAX 200000
00028 
00029 
00030 namespace gazebo
00031 {
00032     namespace common
00033   {
00036 
00038     class STLLoader : public MeshLoader
00039     {
00041       public: STLLoader();
00042   
00044       public: virtual ~STLLoader();
00045   
00047       public: virtual Mesh *Load( const std::string &filename );
00048   
00050       private: void ReadAscii( FILE *filein, Mesh *mesh );
00051   
00053       private: void ReadBinary ( FILE *filein, Mesh *mesh );
00054   
00056       private: bool Leqi ( char* string1, char* string2 );
00057   
00059       private: int RcolFind ( float a[][COR3_MAX], int m, int n, float r[] );
00060   
00062       private: uint32_t LongIntRead ( FILE *filein );
00063   
00065       private: uint16_t ShortIntRead ( FILE *filein );
00066   
00068       private: float FloatRead ( FILE *filein );
00069   
00070     };
00072   }
00073 }
00074 #endif