~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Mesh/App/Core/MeshIO.h

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (c) 2005 Imetric 3D GmbH                                    *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This library is free software; you can redistribute it and/or         *
 
7
 *   modify it under the terms of the GNU Library General Public           *
 
8
 *   License as published by the Free Software Foundation; either          *
 
9
 *   version 2 of the License, or (at your option) any later version.      *
 
10
 *                                                                         *
 
11
 *   This library  is distributed in the hope that it will be useful,      *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU Library General Public License for more details.                  *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU Library General Public     *
 
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
 
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
 
 
24
#ifndef MESH_IO_H
 
25
#define MESH_IO_H
 
26
 
 
27
#include "MeshKernel.h"
 
28
#include <Base/Vector3D.h>
 
29
#include <App/Material.h>
 
30
 
 
31
namespace Base {
 
32
class XMLReader;
 
33
class Writer;
 
34
}
 
35
 
 
36
namespace MeshCore {
 
37
 
 
38
class MeshKernel;
 
39
 
 
40
/**
 
41
 * The MeshInput class is able to read a mesh object from a input stream
 
42
 * in various formats.
 
43
 */
 
44
class MeshExport MeshInput
 
45
{
 
46
public:
 
47
    MeshInput (MeshKernel &rclM): _rclMesh(rclM){};
 
48
    virtual ~MeshInput (void) { }
 
49
 
 
50
    /// Loads the file, decided by extension
 
51
    bool LoadAny(const char* FileName);
 
52
    /** Loads an STL file either in binary or ASCII format. 
 
53
     * Therefore the file header gets checked to decide if the file is binary or not.
 
54
     */
 
55
    bool LoadSTL (std::istream &rstrIn);
 
56
    /** Loads an ASCII STL file. */
 
57
    bool LoadAsciiSTL (std::istream &rstrIn);
 
58
    /** Loads a binary STL file. */
 
59
    bool LoadBinarySTL (std::istream &rstrIn);
 
60
    /** Loads an OBJ Mesh file. */
 
61
    bool LoadOBJ (std::istream &rstrIn);
 
62
    /** Loads the mesh object from an XML file. */
 
63
    void LoadXML (Base::XMLReader &reader);
 
64
    /** Loads a node from an OpenInventor file. */
 
65
    bool LoadMeshNode (std::istream &rstrIn);
 
66
    /** Loads an OpenInventor file. */
 
67
    bool LoadInventor (std::istream &rstrIn);
 
68
    /** Loads a Nastran file. */
 
69
    bool LoadNastran (std::istream &rstrIn);
 
70
    /** Loads a Cadmould FE file. */
 
71
    bool LoadCadmouldFE (std::ifstream &rstrIn);
 
72
 
 
73
protected:
 
74
    MeshKernel &_rclMesh;   /**< reference to mesh data structure */
 
75
};
 
76
 
 
77
/**
 
78
 * The MeshOutput class is able to write a mesh object to an ouput stream
 
79
 * on various formats.
 
80
 */
 
81
class MeshExport MeshOutput
 
82
{
 
83
public:
 
84
    enum Format {
 
85
        Undefined,
 
86
        BMS,
 
87
        ASTL,
 
88
        BSTL,
 
89
        OBJ,
 
90
        IV,
 
91
        VRML,
 
92
        WRZ,
 
93
        NAS,
 
94
        PY
 
95
    };
 
96
 
 
97
    MeshOutput (const MeshKernel &rclM): _rclMesh(rclM){};
 
98
    virtual ~MeshOutput (void) { }
 
99
    /// Saves the file, decided by extension if not explicitly given
 
100
    bool SaveAny(const char* FileName, Format f=Undefined) const;
 
101
 
 
102
    /** Saves the mesh object into an ASCII STL file. */
 
103
    bool SaveAsciiSTL (std::ostream &rstrOut) const;
 
104
    /** Saves the mesh object into a binary STL file. */
 
105
    bool SaveBinarySTL (std::ostream &rstrOut) const;
 
106
    /** Saves the mesh object into an OBJ file. */
 
107
    bool SaveOBJ (std::ostream &rstrOut) const;
 
108
    /** Saves the mesh object into an XML file. */
 
109
    void SaveXML (Base::Writer &writer) const;
 
110
    /** Saves a node to an OpenInventor file. */
 
111
    bool SaveMeshNode (std::ostream &rstrIn);
 
112
    /** Writes an OpenInventor file. */
 
113
    bool SaveInventor (std::ostream &rstrOut) const;
 
114
    /** Writes a VRML file. */
 
115
    bool SaveVRML (std::ostream &rstrOut, const App::Material &rclMat) const;
 
116
    /** Writes a Nastran file. */
 
117
    bool SaveNastran (std::ostream &rstrOut) const;
 
118
    /** Writes a Cadmould FE file. */
 
119
    bool SaveCadmouldFE (std::ostream &rstrOut) const;
 
120
    /** Writes a python module which creates a mesh */
 
121
    bool SavePython (std::ostream &rstrOut) const;
 
122
 
 
123
protected:
 
124
    const MeshKernel &_rclMesh;   /**< reference to mesh data structure */
 
125
};
 
126
 
 
127
struct MeshExport VRMLViewpointData
 
128
{
 
129
    Base::Vector3f clVRefPln;
 
130
    Base::Vector3f clVRefUp;
 
131
    Base::Vector3f clVRefPt;
 
132
    Base::Vector3f clPRefPt;
 
133
    double    dVPlnDist;
 
134
    double    dUmin;
 
135
    double    dUmax;
 
136
    double    dVmin;
 
137
    double    dVmax;
 
138
    std::string  clName;
 
139
};
 
140
 
 
141
struct MeshExport VRMLInfo
 
142
{
 
143
    std::string _clFileName;
 
144
    std::string _clAuthor;
 
145
    std::string _clDate;
 
146
    std::string _clCompany;
 
147
    std::string _clAnnotation;
 
148
    std::string _clPicFileName;
 
149
    App::Color  _clColor;
 
150
    bool     _bSaveViewPoints;
 
151
    bool     _bSavePicture;
 
152
    std::vector<std::string> _clComments;
 
153
    std::vector<VRMLViewpointData> _clViewpoints;
 
154
};
 
155
 
 
156
 
 
157
} // namespace MeshCore
 
158
 
 
159
#endif // MESH_IO_H