mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
Proceed with merge
This commit is contained in:
@@ -17,47 +17,14 @@
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <BRepPrimAPI_MakePrism.hxx>
|
||||
#include <BRepAlgoAPI_Common.hxx>
|
||||
#include "../ifcgeom/IfcGeom.h"
|
||||
#include "../ifcgeom_schema_agnostic/wire_utils.h"
|
||||
#include "mapping.h"
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
#define Kernel MAKE_TYPE_NAME(Kernel)
|
||||
|
||||
bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace* l, TopoDS_Shape& shape) {
|
||||
TopoDS_Shape halfspace;
|
||||
if ( ! IfcGeom::Kernel::convert((IfcSchema::IfcHalfSpaceSolid*)l,halfspace) ) return false;
|
||||
|
||||
TopoDS_Wire wire;
|
||||
if ( ! convert_wire(l->PolygonalBoundary(),wire) || ! wire.Closed() ) return false;
|
||||
|
||||
gp_Trsf trsf;
|
||||
if ( ! convert(l->Position(),trsf) ) return false;
|
||||
|
||||
TColgp_SequenceOfPnt points;
|
||||
if (util::wire_to_sequence_of_point(wire, points)) {
|
||||
// Boolean subtractions not very robust for narrow operands,
|
||||
// increase minimal point spacing to eliminate such shapes.
|
||||
const double t = getValue(GV_PRECISION) * 10.;
|
||||
util::remove_duplicate_points_from_loop(points, wire.Closed() != 0, t); // Note: wire always closed, as per if statement above
|
||||
util::remove_collinear_points_from_loop(points, wire.Closed() != 0, t);
|
||||
if (points.Length() < 3) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Not enough points retained from:", l->PolygonalBoundary());
|
||||
return false;
|
||||
}
|
||||
util::sequence_of_point_to_wire(points, wire, wire.Closed() != 0);
|
||||
}
|
||||
|
||||
TopoDS_Shape prism = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(wire),gp_Vec(0,0,200));
|
||||
gp_Trsf down; down.SetTranslation(gp_Vec(0,0,-100.0));
|
||||
|
||||
// `trsf` and `down` both have a unit scale factor
|
||||
prism.Move(trsf*down);
|
||||
|
||||
shape = BRepAlgoAPI_Common(halfspace,prism);
|
||||
return true;
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolygonalBoundedHalfSpace* inst) {
|
||||
auto s = (taxonomy::solid*)map_impl((IfcSchema::IfcHalfSpaceSolid*) inst);
|
||||
auto f = (taxonomy::face*)s->children[0];
|
||||
f->children = { map(inst->PolygonalBoundary()) };
|
||||
f->matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user