2019-05-07 17:06:45 +02:00
|
|
|
/********************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* Lesser GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef GLTFSERIALIZER_H
|
|
|
|
|
#define GLTFSERIALIZER_H
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_GLTF
|
|
|
|
|
|
2022-05-03 11:38:12 +02:00
|
|
|
#include "../serializers/serializers_api.h"
|
2021-10-18 11:38:01 +02:00
|
|
|
#include "../ifcgeom_schema_agnostic/GeometrySerializer.h"
|
2019-05-07 17:06:45 +02:00
|
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
using json = nlohmann::json;
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
2022-05-03 11:38:12 +02:00
|
|
|
class SERIALIZERS_API GltfSerializer : public WriteOnlyGeometrySerializer {
|
2019-05-07 17:06:45 +02:00
|
|
|
private:
|
|
|
|
|
std::string filename_, tmp_filename1_, tmp_filename2_;
|
|
|
|
|
std::ofstream fstream_, tmp_fstream1_, tmp_fstream2_;
|
|
|
|
|
std::map<std::string, int> materials_, meshes_;
|
|
|
|
|
json json_, node_array_;
|
2023-10-03 21:26:00 +02:00
|
|
|
boost::optional<json> ecef_transform_, north_rotation_;
|
2023-08-28 13:54:21 +08:00
|
|
|
int bufferViewId;
|
|
|
|
|
|
2019-05-07 17:06:45 +02:00
|
|
|
int writeMaterial(const IfcGeom::Material& style);
|
|
|
|
|
public:
|
|
|
|
|
GltfSerializer(const std::string& filename, const SerializerSettings& settings);
|
2019-06-04 17:03:58 +02:00
|
|
|
virtual ~GltfSerializer();
|
2019-05-07 17:06:45 +02:00
|
|
|
bool ready();
|
|
|
|
|
void writeHeader();
|
2021-07-11 15:00:59 +02:00
|
|
|
void write(const IfcGeom::TriangulationElement* o);
|
|
|
|
|
void write(const IfcGeom::BRepElement* /*o*/) {}
|
2019-05-07 17:06:45 +02:00
|
|
|
void finalize();
|
|
|
|
|
bool isTesselated() const { return true; }
|
|
|
|
|
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
|
2023-10-03 21:26:00 +02:00
|
|
|
void setFile(IfcParse::IfcFile*);
|
2019-05-07 17:06:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|