mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Proceed with merge
This commit is contained in:
@@ -17,69 +17,32 @@
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include "../ifcgeom/IfcGeom.h"
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include "mapping.h"
|
||||
|
||||
#define Kernel MAKE_TYPE_NAME(Kernel)
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
|
||||
|
||||
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, TopoDS_Shape& face) {
|
||||
boost::shared_ptr< aggregate_of_aggregate_of<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
|
||||
std::vector<double> uknots = l->UKnots();
|
||||
std::vector<double> vknots = l->VKnots();
|
||||
std::vector<int> umults = l->UMultiplicities();
|
||||
std::vector<int> vmults = l->VMultiplicities();
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBSplineSurfaceWithKnots* inst) {
|
||||
auto bs = new taxonomy::bspline_surface;
|
||||
|
||||
TColgp_Array2OfPnt Poles (0, (int)cps->size() - 1, 0, (int)(*cps->begin()).size() - 1);
|
||||
TColStd_Array1OfReal UKnots(0, (int)uknots.size() - 1);
|
||||
TColStd_Array1OfReal VKnots(0, (int)vknots.size() - 1);
|
||||
TColStd_Array1OfInteger UMults(0, (int)umults.size() - 1);
|
||||
TColStd_Array1OfInteger VMults(0, (int)vmults.size() - 1);
|
||||
Standard_Integer UDegree = l->UDegree();
|
||||
Standard_Integer VDegree = l->VDegree();
|
||||
auto cps = inst->ControlPointsList();
|
||||
std::transform(cps->begin(), cps->end(), std::back_inserter(bs->control_points), [this](const std::vector<IfcSchema::IfcCartesianPoint*>& inner) {
|
||||
std::vector<taxonomy::point3> ps;
|
||||
std::transform(inner.begin(), inner.end(), std::back_inserter(ps), [this](IfcSchema::IfcCartesianPoint* cp) { return as<taxonomy::point3>(map(cp)); });
|
||||
return ps;
|
||||
});
|
||||
|
||||
int i = 0, j;
|
||||
for (aggregate_of_aggregate_of<IfcSchema::IfcCartesianPoint>::outer_it it = cps->begin(); it != cps->end(); ++it, ++i) {
|
||||
j = 0;
|
||||
for (aggregate_of_aggregate_of<IfcSchema::IfcCartesianPoint>::inner_it jt = (*it).begin(); jt != (*it).end(); ++jt, ++j) {
|
||||
IfcSchema::IfcCartesianPoint* p = *jt;
|
||||
gp_Pnt pnt;
|
||||
if (!convert(p, pnt)) return false;
|
||||
Poles(i, j) = pnt;
|
||||
}
|
||||
bs->multiplicities = { inst->UMultiplicities(), inst->VMultiplicities() };
|
||||
bs->knots = { inst->UKnots(), inst->VKnots() };
|
||||
if (inst->as<IfcSchema::IfcRationalBSplineSurfaceWithKnots>()) {
|
||||
bs->weights = inst->as<IfcSchema::IfcRationalBSplineSurfaceWithKnots>()->WeightsData();
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<double>::const_iterator it = uknots.begin(); it != uknots.end(); ++it, ++i) {
|
||||
UKnots(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<double>::const_iterator it = vknots.begin(); it != vknots.end(); ++it, ++i) {
|
||||
VKnots(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<int>::const_iterator it = umults.begin(); it != umults.end(); ++it, ++i) {
|
||||
UMults(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<int>::const_iterator it = vmults.begin(); it != vmults.end(); ++it, ++i) {
|
||||
VMults(i) = *it;
|
||||
}
|
||||
Handle_Geom_Surface surf = new Geom_BSplineSurface(Poles, UKnots, VKnots, UMults, VMults, UDegree, VDegree);
|
||||
bs->degree = { inst->UDegree(), inst->VDegree() };
|
||||
|
||||
#if OCC_VERSION_HEX < 0x60502
|
||||
face = BRepBuilderAPI_MakeFace(surf);
|
||||
#else
|
||||
face = BRepBuilderAPI_MakeFace(surf, getValue(GV_PRECISION));
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return bs;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user