1 /*========================================================================= 2 Program: Visualization Toolkit 3 Module: vtkOBJImporter.h 4 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 5 All rights reserved. 6 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 7 8 This software is distributed WITHOUT ANY WARRANTY; without even 9 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 10 PURPOSE. See the above copyright notice for more information. 11 =========================================================================*/ 12 /** 13 * @class vtkOBJImporter 14 * @brief import from .obj wavefront files 15 * 16 * from Wavefront .obj & associated .mtl files. 17 * @par Thanks - Peter Karasev (Georgia Tech / Keysight Technologies Inc),: 18 * Allen Tannenbaum (SUNY Stonybrook), Patricio Vela (Georgia Tech) 19 * @sa 20 * vtkImporter 21 */ 22 23 #ifndef vtkOBJImporter_h 24 #define vtkOBJImporter_h 25 26 #include "vtkIOImportModule.h" // For export macro 27 #include <string> // for string 28 #include "vtkSmartPointer.h" // for ivars 29 #include "vtkImporter.h" 30 31 class vtkRenderWindow; 32 class vtkRenderer; 33 class vtkPolydata; 34 class vtkOBJPolyDataProcessor; 35 36 /** @note{updated by peter karasev, 2015 to read texture coordinates + material properties} 37 @note{An example of a supported (*).mtl file is show below. 38 Lighting values and texture images are specified, and a corresponding vtkActor 39 with properties and vtkTexture will be created upon import. } 40 41 # Wavefront material file saved from Meshlab 42 newmtl material_0 43 Ka 0.400000 0.400000 0.400000 44 Kd 0.5 0.5 0.5 45 Ks 0.85 0.9 0.9 46 illum 2 47 Ns 0.000000 48 map_Kd map1024.png 49 50 newmtl material_1 51 Ka 0.200000 0.200000 0.200000 52 Kd 0.666667 0.666667 0.666667 53 Ks 1.000000 0.9 1.000000 54 illum 2 55 Ns 0.000000 56 map_Kd flare.jpg 57 58 **/ 59 class VTKIOIMPORT_EXPORT vtkOBJImporter : public vtkImporter 60 { 61 public: 62 static vtkOBJImporter *New(); 63 64 vtkTypeMacro(vtkOBJImporter,vtkImporter); 65 void PrintSelf(ostream& os, vtkIndent indent) override; 66 67 //@{ 68 /** 69 * Specify the name of the file to read. 70 */ 71 void SetFileName(const char* arg); 72 void SetFileNameMTL(const char* arg); 73 void SetTexturePath(const char* path); 74 const char* GetFileName() const; 75 const char* GetFileNameMTL() const; 76 const char* GetTexturePath() const; 77 //@} 78 79 /** 80 * Get a string describing an output 81 */ 82 std::string GetOutputDescription(int idx); 83 84 protected: 85 vtkOBJImporter(); 86 ~vtkOBJImporter() override; 87 88 int ImportBegin() override /*override*/; 89 void ImportEnd () override /*override*/; 90 void ReadData() override /* override */; 91 92 vtkSmartPointer<vtkOBJPolyDataProcessor> Impl; 93 94 private: 95 vtkOBJImporter(const vtkOBJImporter&) = delete; 96 void operator=(const vtkOBJImporter&) = delete; 97 }; 98 99 100 101 #endif 102 // VTK-HeaderTest-Exclude: vtkOBJImporter.h 103