MeshIO.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MESH_IO_H
00025 #define MESH_IO_H
00026
00027 #include "MeshKernel.h"
00028 #include <Base/Vector3D.h>
00029 #include <Base/Matrix.h>
00030 #include <App/Material.h>
00031
00032 namespace Base {
00033 class XMLReader;
00034 class Writer;
00035 }
00036
00037 namespace MeshCore {
00038
00039 class MeshKernel;
00040
00041 namespace MeshIO {
00042 enum Format {
00043 Undefined,
00044 BMS,
00045 ASTL,
00046 BSTL,
00047 OBJ,
00048 OFF,
00049 IV,
00050 VRML,
00051 WRZ,
00052 NAS,
00053 PLY,
00054 PY
00055 };
00056 enum Binding {
00057 OVERALL,
00058 PER_VERTEX,
00059 PER_FACE
00060 };
00061 }
00062
00063 struct MeshExport Material
00064 {
00065 Material() : binding(MeshIO::OVERALL) {}
00066 MeshIO::Binding binding;
00067 std::vector<App::Color> diffuseColor;
00068 };
00069
00074 class MeshExport MeshInput
00075 {
00076 public:
00077 MeshInput (MeshKernel &rclM): _rclMesh(rclM){};
00078 virtual ~MeshInput (void) { }
00079
00081 bool LoadAny(const char* FileName);
00085 bool LoadSTL (std::istream &rstrIn);
00087 bool LoadAsciiSTL (std::istream &rstrIn);
00089 bool LoadBinarySTL (std::istream &rstrIn);
00091 bool LoadOBJ (std::istream &rstrIn);
00093 bool LoadPLY (std::istream &rstrIn);
00095 void LoadXML (Base::XMLReader &reader);
00097 bool LoadMeshNode (std::istream &rstrIn);
00099 bool LoadInventor (std::istream &rstrIn);
00101 bool LoadNastran (std::istream &rstrIn);
00103 bool LoadCadmouldFE (std::ifstream &rstrIn);
00104
00105 protected:
00106 MeshKernel &_rclMesh;
00107 };
00108
00113 class MeshExport MeshOutput
00114 {
00115 public:
00116 MeshOutput (const MeshKernel &rclM)
00117 : _rclMesh(rclM), _material(0), apply_transform(false){}
00118 MeshOutput (const MeshKernel &rclM, const Material* m)
00119 : _rclMesh(rclM), _material(m), apply_transform(false){}
00120 virtual ~MeshOutput (void) { }
00121 void Transform(const Base::Matrix4D&);
00127 static void SetSTLHeaderData(const std::string&);
00129 bool SaveAny(const char* FileName, MeshIO::Format f=MeshIO::Undefined) const;
00130
00132 bool SaveAsciiSTL (std::ostream &rstrOut) const;
00134 bool SaveBinarySTL (std::ostream &rstrOut) const;
00136 bool SaveOBJ (std::ostream &rstrOut) const;
00138 bool SaveOFF (std::ostream &rstrOut) const;
00140 bool SavePLY (std::ostream &rstrOut) const;
00142 void SaveXML (Base::Writer &writer) const;
00144 bool SaveMeshNode (std::ostream &rstrIn);
00146 bool SaveInventor (std::ostream &rstrOut) const;
00148 bool SaveVRML (std::ostream &rstrOut, const App::Material &rclMat) const;
00150 bool SaveNastran (std::ostream &rstrOut) const;
00152 bool SaveCadmouldFE (std::ostream &rstrOut) const;
00154 bool SavePython (std::ostream &rstrOut) const;
00155
00156 protected:
00157 const MeshKernel &_rclMesh;
00158 const Material* _material;
00159 Base::Matrix4D _transform;
00160 bool apply_transform;
00161 static std::string stl_header;
00162 };
00163
00164 struct MeshExport VRMLViewpointData
00165 {
00166 Base::Vector3f clVRefPln;
00167 Base::Vector3f clVRefUp;
00168 Base::Vector3f clVRefPt;
00169 Base::Vector3f clPRefPt;
00170 double dVPlnDist;
00171 double dUmin;
00172 double dUmax;
00173 double dVmin;
00174 double dVmax;
00175 std::string clName;
00176 };
00177
00178 struct MeshExport VRMLInfo
00179 {
00180 std::string _clFileName;
00181 std::string _clAuthor;
00182 std::string _clDate;
00183 std::string _clCompany;
00184 std::string _clAnnotation;
00185 std::string _clPicFileName;
00186 App::Color _clColor;
00187 bool _bSaveViewPoints;
00188 bool _bSavePicture;
00189 std::vector<std::string> _clComments;
00190 std::vector<VRMLViewpointData> _clViewpoints;
00191 };
00192
00193
00194 }
00195
00196 #endif // MESH_IO_H