mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 22:16:41 +00:00
Simplify edit_profile_usage with util.shape
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
|
import ifcopenshell.util.shape
|
||||||
from ifcopenshell.geom import ShapeType
|
from ifcopenshell.geom import ShapeType
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -168,62 +169,42 @@ class Usecase:
|
|||||||
return self.get_top_right(shape)
|
return self.get_top_right(shape)
|
||||||
|
|
||||||
def get_bottom_left(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_bottom_left(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
width = ifcopenshell.util.shape.get_x(shape)
|
||||||
x = [v[i] for i in range(0, len(v), 3)]
|
height = ifcopenshell.util.shape.get_y(shape)
|
||||||
y = [v[i + 1] for i in range(0, len(v), 3)]
|
|
||||||
width = max(x) - min(x)
|
|
||||||
height = max(y) - min(y)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((-width / 2, height / 2, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((-width / 2, height / 2, 0.0)))
|
||||||
|
|
||||||
def get_bottom_centre(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_bottom_centre(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
height = ifcopenshell.util.shape.get_y(shape)
|
||||||
y = [v[i + 1] for i in range(0, len(v), 3)]
|
|
||||||
height = max(y) - min(y)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((0.0, height / 2, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((0.0, height / 2, 0.0)))
|
||||||
|
|
||||||
def get_bottom_right(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_bottom_right(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
width = ifcopenshell.util.shape.get_x(shape)
|
||||||
x = [v[i] for i in range(0, len(v), 3)]
|
height = ifcopenshell.util.shape.get_y(shape)
|
||||||
y = [v[i + 1] for i in range(0, len(v), 3)]
|
|
||||||
width = max(x) - min(x)
|
|
||||||
height = max(y) - min(y)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((width / 2, height / 2, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((width / 2, height / 2, 0.0)))
|
||||||
|
|
||||||
def get_mid_depth_left(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_mid_depth_left(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
width = ifcopenshell.util.shape.get_x(shape)
|
||||||
x = [v[i] for i in range(0, len(v), 3)]
|
|
||||||
width = max(x) - min(x)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((-width / 2, 0.0, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((-width / 2, 0.0, 0.0)))
|
||||||
|
|
||||||
def get_mid_depth_centre(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_mid_depth_centre(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((0.0, 0.0, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((0.0, 0.0, 0.0)))
|
||||||
|
|
||||||
def get_mid_depth_right(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_mid_depth_right(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
width = ifcopenshell.util.shape.get_x(shape)
|
||||||
x = [v[i] for i in range(0, len(v), 3)]
|
|
||||||
width = max(x) - min(x)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((width / 2, 0.0, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((width / 2, 0.0, 0.0)))
|
||||||
|
|
||||||
def get_top_left(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_top_left(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
width = ifcopenshell.util.shape.get_x(shape)
|
||||||
x = [v[i] for i in range(0, len(v), 3)]
|
height = ifcopenshell.util.shape.get_y(shape)
|
||||||
y = [v[i + 1] for i in range(0, len(v), 3)]
|
|
||||||
width = max(x) - min(x)
|
|
||||||
height = max(y) - min(y)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((-width / 2, -height / 2, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((-width / 2, -height / 2, 0.0)))
|
||||||
|
|
||||||
def get_top_centre(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_top_centre(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
height = ifcopenshell.util.shape.get_y(shape)
|
||||||
y = [v[i + 1] for i in range(0, len(v), 3)]
|
|
||||||
height = max(y) - min(y)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((0.0, -height / 2, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((0.0, -height / 2, 0.0)))
|
||||||
|
|
||||||
def get_top_right(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
def get_top_right(self, shape: ShapeType) -> ifcopenshell.entity_instance:
|
||||||
v = shape.verts
|
width = ifcopenshell.util.shape.get_x(shape)
|
||||||
x = [v[i] for i in range(0, len(v), 3)]
|
height = ifcopenshell.util.shape.get_y(shape)
|
||||||
y = [v[i + 1] for i in range(0, len(v), 3)]
|
|
||||||
width = max(x) - min(x)
|
|
||||||
height = max(y) - min(y)
|
|
||||||
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((width / 2, -height / 2, 0.0)))
|
return self.file.createIfcAxis2Placement3D(self.file.createIfcCartesianPoint((width / 2, -height / 2, 0.0)))
|
||||||
|
|
||||||
def update_representation(self, element: ifcopenshell.entity_instance) -> None:
|
def update_representation(self, element: ifcopenshell.entity_instance) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user