mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
fix leaking as_compound() calls
This commit is contained in:
committed by
Thomas Krijnen
parent
c9eb345491
commit
15a31074e8
@@ -254,7 +254,7 @@ IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool
|
||||
builder.Add(compound, moved_shape);
|
||||
}
|
||||
|
||||
return new ifcopenshell::geometry::OpenCascadeShape(compound);
|
||||
return new ifcopenshell::geometry::OpenCascadeShape(std::move(compound));
|
||||
#else
|
||||
throw std::runtime_error("Not available without Open Cascade");
|
||||
#endif
|
||||
|
||||
@@ -1365,8 +1365,10 @@ namespace IfcGeom {
|
||||
}
|
||||
|
||||
std::vector<T> select(const IfcGeom::BRepElement* elem, bool completely_within = false, double extend = -1.e-5) const {
|
||||
auto shp = elem->geometry().as_compound();
|
||||
auto compound = ((ifcopenshell::geometry::OpenCascadeShape*)shp)->shape();
|
||||
auto shp = (ifcopenshell::geometry::OpenCascadeShape*)elem->geometry().as_compound();
|
||||
TopoDS_Shape compound(std::move((ifcopenshell::geometry::OpenCascadeShape*)shp)->shape()));
|
||||
delete shp;
|
||||
|
||||
const auto& m = elem->transformation().data()->ccomponents();
|
||||
gp_Trsf tr;
|
||||
tr.SetValues(
|
||||
@@ -1956,8 +1958,9 @@ namespace IfcGeom {
|
||||
return;
|
||||
}
|
||||
|
||||
auto compound_generic = elem->geometry().as_compound();
|
||||
auto compound = ((ifcopenshell::geometry::OpenCascadeShape*)compound_generic)->shape();
|
||||
auto compound_generic = (ifcopenshell::geometry::OpenCascadeShape*)elem->geometry().as_compound();
|
||||
TopoDS_Shape compound(std::move(compound_generic->shape()));
|
||||
delete compound_generic;
|
||||
|
||||
const auto& m = elem->transformation().data()->ccomponents();
|
||||
gp_Trsf tr;
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace ifcopenshell {
|
||||
public:
|
||||
OpenCascadeShape(const TopoDS_Shape& shape)
|
||||
: shape_(shape) {}
|
||||
OpenCascadeShape(TopoDS_Shape&& shape)
|
||||
: shape_(std::move(shape)) {}
|
||||
|
||||
const TopoDS_Shape& shape() const { return shape_; }
|
||||
operator const TopoDS_Shape& () { return shape_; }
|
||||
|
||||
Reference in New Issue
Block a user