MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / apply_layerset

Method apply_layerset

src/ifcgeom/kernels/opencascade/layerset.cpp:284–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector<Handle_Geom_Surface>& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles, ConversionResults& result, double tol) {
285 if (surfaces.size() < 3) {
286
287 return false;
288
289 } else if (surfaces.size() == 3) {
290
291 for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
292 TopoDS_Shape a, b;
293 if (split_solid_by_surface(std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape(), surfaces[1], a, b, tol)) {
294 result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
295 result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
296 } else {
297 continue;
298 }
299 }
300
301 return true;
302
303 } else {
304
305 /*
306 // Determine whether sequence of surfaces is consistent with surface normal, so that
307 // layer operations are applied in the correct order. This seems to be always the case.
308 Bnd_Box bb;
309 for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
310 BRepBndLib::Add(it->Shape(), bb);
311 }
312
313 double x1, y1, z1, x2, y2, z2;
314 bb.Get(x1, y1, z1, x2, y2, z2);
315 gp_Pnt p1(x1, y1, z1);
316 gp_Pnt p2(x2, y2, z2);
317 gp_Pnt avg = (p1.XYZ() + p2.XYZ()) / 2.;
318
319 ShapeAnalysis_Surface sas1(surfaces[0]);
320 ShapeAnalysis_Surface sas2(surfaces[1]);
321 const gp_Pnt2d uv = sas1.ValueOfUV(avg, 1e-3);
322
323 gp_Pnt ps1, ps2, mass;
324 gp_Vec du1, dv1, du2, dv2;
325 surfaces[0]->D1(uv.X(), uv.Y(), ps1, du1, dv1);
326 const gp_Vec n1 = dv1.XYZ() ^ du1.XYZ();
327
328 const bool reversed = gp_Dir(ps2.XYZ() - ps1.XYZ()).Dot(n1) < 0.;
329
330 surfaces[surfaces.size() - 1]->D0(uv.X(), uv.Y(), mass);
331 mass.ChangeCoord() += n1.XYZ();
332 */
333
334 for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
335
336 const TopoDS_Shape& s = std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape();
337 TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol);
338
339 TopTools_ListOfShape operands;
340 for (unsigned i = 1; i < surfaces.size() - 1; ++i) {
341 double u1, v1, u2, v2;

Callers

nothing calls this directly

Calls 7

ConversionResultFunction · 0.85
push_backMethod · 0.80
splitFunction · 0.70
projectFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected