Skip to content

Commit 661c8bc

Browse files
committed
Small changes to curve segment handling for purpose of wrapper
1 parent 909978c commit 661c8bc

9 files changed

Lines changed: 43 additions & 13 deletions

File tree

src/ifcgeom/AbstractKernel.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonom
7575
}
7676
return r.size() > s;
7777
}
78+
79+
bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::piecewise_function::ptr item, IfcGeom::ConversionResults& cs) {
80+
auto expl = item->evaluate();
81+
expl->instance = item->instance;
82+
return convert(expl, cs);
83+
}

src/ifcgeom/AbstractKernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace ifcopenshell { namespace geometry { namespace kernels {
5454
virtual bool convert_impl(const taxonomy::surface_curve_sweep::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
5555
virtual bool convert_impl(const taxonomy::loft::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
5656
virtual bool convert_impl(const taxonomy::collection::ptr, IfcGeom::ConversionResults&);
57-
virtual bool convert_impl(const taxonomy::piecewise_function::ptr item, IfcGeom::ConversionResults& cs) { return convert(item->evaluate(), cs); }
57+
virtual bool convert_impl(const taxonomy::piecewise_function::ptr item, IfcGeom::ConversionResults& cs);
5858

5959
/*
6060
virtual void set_offset(const std::array<double, 3> &p_offset);

src/ifcgeom/Converter.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,21 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
356356
);
357357
}
358358

359+
IfcGeom::ConversionResults ifcopenshell::geometry::Converter::convert(IfcUtil::IfcBaseClass * item)
360+
{
361+
std::clock_t map_start = std::clock();
362+
auto geom_item = mapping_->map(item);
363+
IfcGeom::ConversionResults results;
364+
if (geom_item) {
365+
std::clock_t geom_start = std::clock();
366+
kernel_->convert(geom_item, results);
367+
std::clock_t geom_end = std::clock();
368+
total_map_time += (geom_start - map_start) / (double) CLOCKS_PER_SEC;
369+
total_geom_time += (geom_end - geom_start) / (double) CLOCKS_PER_SEC;
370+
}
371+
return results;
372+
}
373+
359374
//#include "../../ifcparse/Ifc2x3.h"
360375
//#include "../../ifcparse/Ifc4.h"
361376
//

src/ifcgeom/Converter.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,7 @@ namespace ifcopenshell { namespace geometry {
4444
double total_map_time = 0.;
4545
double total_geom_time = 0.;
4646

47-
IfcGeom::ConversionResults convert(IfcUtil::IfcBaseClass* item) {
48-
std::clock_t map_start = std::clock();
49-
auto geom_item = mapping_->map(item);
50-
std::clock_t geom_start = std::clock();
51-
IfcGeom::ConversionResults results;
52-
kernel_->convert(geom_item, results);
53-
std::clock_t geom_end = std::clock();
54-
total_map_time += (geom_start - map_start) / (double) CLOCKS_PER_SEC;
55-
total_geom_time += (geom_end - geom_start) / (double) CLOCKS_PER_SEC;
56-
return results;
57-
}
47+
IfcGeom::ConversionResults convert(IfcUtil::IfcBaseClass* item);
5848

5949
IfcGeom::BRepElement* create_brep_for_representation_and_product(const IfcUtil::IfcBaseEntity* representation, const IfcUtil::IfcBaseEntity* product);
6050
// IfcGeom::BRepElement* create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* representation, const IfcUtil::IfcBaseEntity* product, IfcGeom::BRepElement* brep);

src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class IFC_GEOM_API OpenCascadeKernel : public kernels::AbstractKernel {
138138
bool convert(const taxonomy::solid::ptr, TopoDS_Shape&);
139139
bool convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf);
140140

141+
virtual bool convert_impl(const taxonomy::loop::ptr, IfcGeom::ConversionResults&);
141142
virtual bool convert_impl(const taxonomy::face::ptr, IfcGeom::ConversionResults&);
142143
virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&);
143144
virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&);

src/ifcgeom/kernels/opencascade/loop.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,18 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
240240
wire = bld.wire();
241241

242242
return true;
243-
}
243+
}
244+
245+
bool OpenCascadeKernel::convert_impl(const taxonomy::loop::ptr loop, IfcGeom::ConversionResults& results) {
246+
TopoDS_Wire shape;
247+
if (!convert(loop, shape)) {
248+
return false;
249+
}
250+
251+
results.emplace_back(ConversionResult(
252+
loop->instance->data().id(),
253+
new OpenCascadeShape(shape),
254+
loop->surface_style
255+
));
256+
return true;
257+
}

src/ifcgeom/mapping/IfcCompositeCurve.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
8888
aggregate_of_instance::ptr profile = inst->data().getInverse(&IfcSchema::IfcProfileDef::Class(), -1);
8989
const bool force_close = profile && profile->size() > 0;
9090
loop->closed = force_close;
91+
loop->instance = inst;
9192
return loop;
9293
}
9394
else {
95+
pwf->instance = inst;
9496
return pwf;
9597
}
9698
}

src/ifcgeom/mapping/IfcCurveSegment.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCurveSegment* inst) {
455455
// @todo it might be suboptimal that we no longer have the spans now
456456
auto pwf = taxonomy::make<taxonomy::piecewise_function>();
457457
pwf->spans.push_back({ length, fn_transformed });
458+
pwf->instance = inst;
458459
return pwf;
459460

460461
/*

src/ifcgeom/mapping/IfcGradientCurve.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
7070

7171
auto pwf = taxonomy::make<taxonomy::piecewise_function>();
7272
pwf->spans.emplace_back( min_length, composition );
73+
pwf->instance = inst;
7374
return pwf;
7475
}
7576

0 commit comments

Comments
 (0)