2013-03-24 10:48:39 +00: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 STEPSERIALIZER_H
|
|
|
|
|
#define STEPSERIALIZER_H
|
|
|
|
|
|
|
|
|
|
#include <STEPControl_Writer.hxx>
|
2013-12-31 14:10:38 +00:00
|
|
|
#include <Interface_Static.hxx>
|
2013-03-24 10:48:39 +00:00
|
|
|
|
2017-12-20 17:09:42 +01:00
|
|
|
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
|
2013-03-24 10:48:39 +00:00
|
|
|
|
2018-03-16 13:49:11 +01:00
|
|
|
#include "../serializers/OpenCascadeBasedSerializer.h"
|
2013-03-24 10:48:39 +00:00
|
|
|
|
|
|
|
|
class StepSerializer : public OpenCascadeBasedSerializer
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
STEPControl_Writer writer;
|
|
|
|
|
public:
|
2017-01-11 12:00:51 +02:00
|
|
|
explicit StepSerializer(const std::string& out_filename, const SerializerSettings& settings)
|
2016-03-10 11:35:32 +02:00
|
|
|
: OpenCascadeBasedSerializer(out_filename, settings)
|
2013-03-24 10:48:39 +00:00
|
|
|
{}
|
|
|
|
|
virtual ~StepSerializer() {}
|
2020-03-18 10:12:54 +01:00
|
|
|
void writeShape(const std::string& name, const TopoDS_Shape& shape) {
|
2013-12-31 14:10:38 +00:00
|
|
|
std::stringstream ss;
|
|
|
|
|
std::streambuf *sb = std::cout.rdbuf(ss.rdbuf());
|
2020-03-18 10:12:54 +01:00
|
|
|
Interface_Static::SetCVal("write.step.product.name", name.c_str());
|
2013-03-24 10:48:39 +00:00
|
|
|
writer.Transfer(shape, STEPControl_AsIs);
|
2013-12-31 14:10:38 +00:00
|
|
|
std::cout.rdbuf(sb);
|
2013-03-24 10:48:39 +00:00
|
|
|
}
|
|
|
|
|
void finalize() {
|
2013-12-31 14:10:38 +00:00
|
|
|
std::stringstream ss;
|
|
|
|
|
std::streambuf *sb = std::cout.rdbuf(ss.rdbuf());
|
2013-03-24 10:48:39 +00:00
|
|
|
writer.Write(out_filename.c_str());
|
2013-12-31 14:10:38 +00:00
|
|
|
std::cout.rdbuf(sb);
|
|
|
|
|
}
|
2015-11-23 15:52:12 +02:00
|
|
|
void setUnitNameAndMagnitude(const std::string& /*name*/, float magnitude) {
|
2013-12-31 14:10:38 +00:00
|
|
|
const char* symbol = getSymbolForUnitMagnitude(magnitude);
|
|
|
|
|
if (symbol) {
|
2015-12-01 11:14:50 +01:00
|
|
|
Interface_Static::SetCVal("xstep.cascade.unit", symbol);
|
2013-12-31 14:10:38 +00:00
|
|
|
Interface_Static::SetCVal("write.step.unit", symbol);
|
|
|
|
|
}
|
2013-03-24 10:48:39 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|