| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #ifndef MESH_IO_H
|
| | #define MESH_IO_H
|
| |
|
| | #include <App/Material.h>
|
| | #include <Base/Matrix.h>
|
| |
|
| | #include "MeshKernel.h"
|
| |
|
| |
|
| | namespace Base
|
| | {
|
| | class XMLReader;
|
| | class Writer;
|
| | }
|
| |
|
| | namespace MeshCore
|
| | {
|
| |
|
| | class MeshKernel;
|
| |
|
| | namespace MeshIO
|
| | {
|
| | enum Format
|
| | {
|
| | Undefined,
|
| | BMS,
|
| | ASTL,
|
| | BSTL,
|
| | STL,
|
| | OBJ,
|
| | OFF,
|
| | IDTF,
|
| | MGL,
|
| | IV,
|
| | X3D,
|
| | X3DZ,
|
| | X3DOM,
|
| | VRML,
|
| | WRZ,
|
| | NAS,
|
| | PLY,
|
| | APLY,
|
| | PY,
|
| | AMF,
|
| | SMF,
|
| | ASY,
|
| | ThreeMF
|
| | };
|
| | enum Binding
|
| | {
|
| | OVERALL,
|
| | PER_VERTEX,
|
| | PER_FACE
|
| | };
|
| | }
|
| |
|
| | struct MeshExport Material
|
| | {
|
| | Material() = default;
|
| | MeshIO::Binding binding {MeshIO::OVERALL};
|
| | mutable std::string library;
|
| |
|
| | std::vector<Base::Color> ambientColor;
|
| | std::vector<Base::Color> diffuseColor;
|
| | std::vector<Base::Color> specularColor;
|
| | std::vector<Base::Color> emissiveColor;
|
| | std::vector<float> shininess;
|
| | std::vector<float> transparency;
|
| |
|
| | bool operator==(const Material& mat) const;
|
| | bool operator!=(const Material& mat) const;
|
| | };
|
| |
|
| | struct MeshExport Group
|
| | {
|
| | std::vector<FacetIndex> indices;
|
| | std::string name;
|
| | };
|
| |
|
| | |
| | |
| | |
| |
|
| | class MeshExport MeshInput
|
| | {
|
| | public:
|
| | explicit MeshInput(MeshKernel& rclM)
|
| | : _rclMesh(rclM)
|
| | , _material(nullptr)
|
| | {}
|
| | MeshInput(MeshKernel& rclM, Material* m)
|
| | : _rclMesh(rclM)
|
| | , _material(m)
|
| | {}
|
| | const std::vector<std::string>& GetGroupNames() const
|
| | {
|
| | return _groupNames;
|
| | }
|
| |
|
| |
|
| | bool LoadAny(const char* FileName);
|
| |
|
| | bool LoadFormat(std::istream& input, MeshIO::Format fmt);
|
| | |
| | |
| |
|
| | bool LoadSTL(std::istream& input);
|
| |
|
| | bool LoadAsciiSTL(std::istream& input);
|
| |
|
| | bool LoadBinarySTL(std::istream& input);
|
| |
|
| | bool LoadOBJ(std::istream& input);
|
| |
|
| | bool LoadOBJ(std::istream& input, const char* filename);
|
| |
|
| | bool LoadSMF(std::istream& input);
|
| |
|
| | bool LoadOFF(std::istream& input);
|
| |
|
| | bool LoadPLY(std::istream& input);
|
| |
|
| | void LoadXML(Base::XMLReader& reader);
|
| |
|
| | bool Load3MF(std::istream& input);
|
| |
|
| | bool LoadMeshNode(std::istream& input);
|
| |
|
| | bool LoadInventor(std::istream& input);
|
| |
|
| | bool LoadNastran(std::istream& input);
|
| |
|
| | bool LoadCadmouldFE(std::ifstream& input);
|
| |
|
| | static std::vector<std::string> supportedMeshFormats();
|
| | static MeshIO::Format getFormat(const char* FileName);
|
| |
|
| | private:
|
| | MeshKernel& _rclMesh;
|
| | Material* _material;
|
| | std::vector<std::string> _groupNames;
|
| | };
|
| |
|
| | |
| | |
| | |
| |
|
| | class MeshExport MeshOutput
|
| | {
|
| | public:
|
| | explicit MeshOutput(const MeshKernel& rclM)
|
| | : _rclMesh(rclM)
|
| | , _material(nullptr)
|
| | , apply_transform(false)
|
| | {}
|
| | MeshOutput(const MeshKernel& rclM, const Material* m)
|
| | : _rclMesh(rclM)
|
| | , _material(m)
|
| | , apply_transform(false)
|
| | {}
|
| | void SetObjectName(const std::string& n)
|
| | {
|
| | objectName = n;
|
| | }
|
| | void SetGroups(const std::vector<Group>& g)
|
| | {
|
| | _groups = g;
|
| | }
|
| |
|
| | void Transform(const Base::Matrix4D&);
|
| | |
| | |
| | |
| | |
| |
|
| | static void SetSTLHeaderData(const std::string&);
|
| | |
| | |
| |
|
| | static void SetAsymptoteSize(const std::string&, const std::string&);
|
| |
|
| | static MeshIO::Format GetFormat(const char* FileName);
|
| |
|
| | bool SaveAny(const char* FileName, MeshIO::Format f = MeshIO::Undefined) const;
|
| |
|
| | bool SaveFormat(std::ostream& str, MeshIO::Format fmt) const;
|
| |
|
| |
|
| | bool SaveAsciiSTL(std::ostream& output) const;
|
| |
|
| | bool SaveBinarySTL(std::ostream& output) const;
|
| |
|
| | bool SaveOBJ(std::ostream& output) const;
|
| |
|
| | bool SaveOBJ(std::ostream& output, const char* filename) const;
|
| |
|
| | bool SaveSMF(std::ostream& output) const;
|
| |
|
| | bool SaveOFF(std::ostream& output) const;
|
| |
|
| | bool SaveBinaryPLY(std::ostream& output) const;
|
| |
|
| | bool SaveAsciiPLY(std::ostream& output) const;
|
| |
|
| | bool SaveAsymptote(std::ostream& output) const;
|
| |
|
| | void SaveXML(Base::Writer& writer) const;
|
| |
|
| | bool Save3MF(std::ostream& output) const;
|
| |
|
| | bool SaveMeshNode(std::ostream& output);
|
| |
|
| | bool SaveIDTF(std::ostream& str) const;
|
| |
|
| | bool SaveMGL(std::ostream& str) const;
|
| |
|
| | bool SaveInventor(std::ostream& output) const;
|
| |
|
| | bool SaveX3D(std::ostream& output) const;
|
| |
|
| | bool SaveX3DOM(std::ostream& output) const;
|
| |
|
| | bool SaveVRML(std::ostream& output) const;
|
| |
|
| | bool SaveNastran(std::ostream& output) const;
|
| |
|
| | bool SaveCadmouldFE(std::ostream& output) const;
|
| |
|
| | bool SavePython(std::ostream& str) const;
|
| |
|
| | static std::vector<std::string> supportedMeshFormats();
|
| |
|
| | protected:
|
| |
|
| | bool SaveX3DContent(std::ostream& out, bool exportViewpoints) const;
|
| |
|
| | private:
|
| | const MeshKernel& _rclMesh;
|
| | const Material* _material;
|
| | Base::Matrix4D _transform;
|
| | bool apply_transform;
|
| | std::string objectName;
|
| | std::vector<Group> _groups;
|
| | static std::string stl_header;
|
| | static std::string asyWidth;
|
| | static std::string asyHeight;
|
| | };
|
| |
|
| | |
| | |
| | |
| |
|
| | class MeshCleanup
|
| | {
|
| | public:
|
| | |
| | |
| | |
| | |
| |
|
| | MeshCleanup(MeshPointArray& p, MeshFacetArray& f);
|
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | void SetMaterial(Material* mat);
|
| |
|
| | |
| | |
| |
|
| | void RemoveInvalids();
|
| |
|
| | private:
|
| | |
| | |
| |
|
| | void RemoveInvalidFacets();
|
| | |
| | |
| |
|
| | void RemoveInvalidPoints();
|
| |
|
| | private:
|
| | MeshPointArray& pointArray;
|
| | MeshFacetArray& facetArray;
|
| | Material* materialArray {nullptr};
|
| | };
|
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | class MeshPointFacetAdjacency
|
| | {
|
| | public:
|
| | |
| | |
| | |
| | |
| |
|
| | MeshPointFacetAdjacency(std::size_t p, MeshFacetArray& f);
|
| |
|
| | |
| | |
| |
|
| | void SetFacetNeighbourhood();
|
| |
|
| | private:
|
| | |
| | |
| |
|
| | void Build();
|
| |
|
| | private:
|
| | std::size_t numPoints;
|
| | MeshFacetArray& facets;
|
| | std::vector<std::vector<std::size_t>> pointFacetAdjacency;
|
| | };
|
| |
|
| |
|
| | }
|
| |
|
| | #endif
|
| |
|