Isolate (most of the) geometry processing code into separate opencascade kernel

This commit is contained in:
Thomas Krijnen
2019-01-18 11:23:19 +01:00
parent 0072e1f247
commit ad24b6be0f
38 changed files with 678 additions and 491 deletions
+1 -1
View File
@@ -230,7 +230,7 @@ public:
bool ready();
void writeHeader();
void write(const IfcGeom::TriangulationElement<real_t>* o);
void write(const IfcGeom::BRepElement<real_t>* /*o*/) {}
void write(const IfcGeom::NativeElement<real_t>* /*o*/) {}
void finalize();
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {
+2 -2
View File
@@ -28,7 +28,7 @@ typedef float real_t;
#include "../serializers/Serializer.h"
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
#include "../ifcgeom/IfcGeomElement.h"
#include "../ifcgeom_schema_agnostic/IfcGeomElement.h"
class SerializerSettings : public IfcGeom::IteratorSettings
{
@@ -77,7 +77,7 @@ public:
virtual bool isTesselated() const = 0;
virtual void write(const IfcGeom::TriangulationElement<real_t>* o) = 0;
virtual void write(const IfcGeom::BRepElement<real_t>* o) = 0;
virtual void write(const IfcGeom::NativeElement<real_t>* o) = 0;
virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) = 0;
const SerializerSettings& settings() const { return settings_; }
+2 -2
View File
@@ -42,8 +42,8 @@ public:
: OpenCascadeBasedSerializer(out_filename, settings)
{}
virtual ~IgesSerializer() {}
void writeShape(const TopoDS_Shape& shape) {
writer.AddShape(shape);
void writeShape(const IfcGeom::ConversionResultShape* shape) {
writer.AddShape(*(IfcGeom::OpenCascadeShape*)shape);
}
void finalize() {
writer.Write(out_filename.c_str());
@@ -34,7 +34,7 @@ bool OpenCascadeBasedSerializer::ready() {
return succeeded;
}
void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement<real_t>* o) {
void OpenCascadeBasedSerializer::write(const IfcGeom::NativeElement<real_t>* o) {
TopoDS_Shape compound = o->geometry().as_compound();
if (o->geometry().settings().get(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS)) {
@@ -44,7 +44,8 @@ void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement<real_t>* o) {
compound = BRepBuilderAPI_Transform(compound, scale, true).Shape();
}
writeShape(compound);
IfcGeom::OpenCascadeShape s(compound);
writeShape(&s);
}
#define RATHER_SMALL (1e-3)
+3 -3
View File
@@ -21,7 +21,7 @@
#define OPENCASCADEBASEDSERIALIZER_H
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
#include "../ifcgeom/OpenCascadeConversionResult.h"
#include "../serializers/GeometrySerializer.h"
class OpenCascadeBasedSerializer : public GeometrySerializer {
@@ -38,9 +38,9 @@ public:
virtual ~OpenCascadeBasedSerializer() {}
void writeHeader() {}
bool ready();
virtual void writeShape(const TopoDS_Shape& shape) = 0;
virtual void writeShape(const IfcGeom::ConversionResultShape* shape) = 0;
void write(const IfcGeom::TriangulationElement<real_t>* /*o*/) {}
void write(const IfcGeom::BRepElement<real_t>* o);
void write(const IfcGeom::NativeElement<real_t>* o);
bool isTesselated() const { return false; }
void setFile(IfcParse::IfcFile*) {}
};
+2 -2
View File
@@ -36,10 +36,10 @@ public:
: OpenCascadeBasedSerializer(out_filename, settings)
{}
virtual ~StepSerializer() {}
void writeShape(const TopoDS_Shape& shape) {
void writeShape(const IfcGeom::ConversionResultShape* shape) {
std::stringstream ss;
std::streambuf *sb = std::cout.rdbuf(ss.rdbuf());
writer.Transfer(shape, STEPControl_AsIs);
writer.Transfer(((IfcGeom::OpenCascadeShape*)shape)->shape(), STEPControl_AsIs);
std::cout.rdbuf(sb);
}
void finalize() {
+2 -2
View File
@@ -283,14 +283,14 @@ SvgSerializer::path_object& SvgSerializer::start_path(IfcUtil::IfcBaseEntity* st
return p;
}
void SvgSerializer::write(const IfcGeom::BRepElement<real_t>* o)
void SvgSerializer::write(const IfcGeom::NativeElement<real_t>* o)
{
IfcUtil::IfcBaseEntity* storey = storey_;
boost::optional<double> storey_elevation = boost::none;
/*
TODO: based on BRepElement::parent()
TODO: based on NativeElement::parent()
IfcSchema::IfcObjectDefinition* obdef = static_cast<IfcSchema::IfcObjectDefinition*>(file->entityById(o->id()));
+1 -1
View File
@@ -62,7 +62,7 @@ public:
void writeHeader();
bool ready();
void write(const IfcGeom::TriangulationElement<real_t>* /*o*/) {}
void write(const IfcGeom::BRepElement<real_t>* o);
void write(const IfcGeom::NativeElement<real_t>* o);
void write(path_object& p, const TopoDS_Wire& wire);
path_object& start_path(IfcUtil::IfcBaseEntity* storey, const std::string& id);
bool isTesselated() const { return false; }
+1 -1
View File
@@ -51,7 +51,7 @@ public:
void writeHeader();
void writeMaterial(const IfcGeom::Material& style);
void write(const IfcGeom::TriangulationElement<real_t>* o);
void write(const IfcGeom::BRepElement<real_t>* /*o*/) {}
void write(const IfcGeom::NativeElement<real_t>* /*o*/) {}
void finalize() {}
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}