mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #4052. Bug where invalid plane was generated due to missing X axis.
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
from __future__ import annotations
|
||||
import numpy as np
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.shape_builder
|
||||
from mathutils import Vector
|
||||
from typing import Any, Union
|
||||
from dataclasses import dataclass
|
||||
|
||||
@@ -131,15 +133,8 @@ class ClippingInfo:
|
||||
def apply(
|
||||
self, file: ifcopenshell.file, first_operand: ifcopenshell.entity_instance, unit_scale: float
|
||||
) -> ifcopenshell.entity_instance:
|
||||
# TODO: move to a separate method like `shape_builder.add_plane`
|
||||
def create_ifc_half_space_solid():
|
||||
location = file.createIfcCartesianPoint([i / unit_scale for i in self.location])
|
||||
direction = file.createIfcDirection(self.normal)
|
||||
axis_placement = file.createIfcAxis2Placement3D(location, direction, None)
|
||||
plane = file.createIfcPlane(axis_placement)
|
||||
halfspace_solid = file.createIfcHalfSpaceSolid(plane, False)
|
||||
return halfspace_solid
|
||||
|
||||
second_operand = create_ifc_half_space_solid()
|
||||
builder = ifcopenshell.util.shape_builder.ShapeBuilder(file)
|
||||
plane = builder.plane(location=Vector([i / unit_scale for i in self.location]), normal=Vector(self.normal))
|
||||
second_operand = file.createIfcHalfSpaceSolid(plane, False)
|
||||
first_operand = file.createIfcBooleanClippingResult("DIFFERENCE", first_operand, second_operand)
|
||||
return first_operand
|
||||
|
||||
@@ -171,6 +171,19 @@ class ShapeBuilder:
|
||||
# self.file_file.createIfcAxis2Placement2D(tool.Ifc.get().createIfcCartesianPoint(center[0:2]))
|
||||
return ifc_curve
|
||||
|
||||
def plane(
|
||||
self, location: Vector = Vector((0.0, 0.0, 0.0)).freeze(), normal: Vector = Vector((0.0, 0.0, 1.0)).freeze()
|
||||
):
|
||||
location = self.file.createIfcCartesianPoint(location)
|
||||
direction = self.file.createIfcDirection(normal)
|
||||
if normal.to_tuple(2) == Vector((0.0, 0.0, 1.0)):
|
||||
arbitrary_vector = Vector((0.0, 1.0, 0.0))
|
||||
else:
|
||||
arbitrary_vector = Vector((0.0, 0.0, 1.0))
|
||||
x_axis = self.file.createIfcDirection(normal.cross(arbitrary_vector).normalized())
|
||||
axis_placement = self.file.createIfcAxis2Placement3D(location, direction, x_axis)
|
||||
return self.file.createIfcPlane(axis_placement)
|
||||
|
||||
# TODO: explain points order for the curve_between_two_points
|
||||
# because the order is important and defines the center of the curve
|
||||
# currently it seems like the first point shifted by x-axis defines the center
|
||||
@@ -846,9 +859,9 @@ class ShapeBuilder:
|
||||
# )
|
||||
|
||||
points, segments, ifc_curve = self.get_simple_2dcurve_data(
|
||||
coords,
|
||||
fillets = (0, 1, 4, 5, 6, 7, 10, 11),
|
||||
fillet_radius=(r+t, r+t, r, r, r+t, r+t, r, r),
|
||||
coords,
|
||||
fillets = (0, 1, 4, 5, 6, 7, 10, 11),
|
||||
fillet_radius=(r+t, r+t, r, r, r+t, r+t, r, r),
|
||||
closed=True, create_ifc_curve=True)
|
||||
# fmt: on
|
||||
|
||||
|
||||
Reference in New Issue
Block a user