2024-09-10 12:15:43 +05:00
|
|
|
# IfcOpenShell - IFC toolkit and geometry engine
|
|
|
|
|
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
|
|
|
|
#
|
|
|
|
|
# This file is part of IfcOpenShell.
|
|
|
|
|
#
|
|
|
|
|
# IfcOpenShell is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# IfcOpenShell is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
import ifcopenshell
|
|
|
|
|
import ifcopenshell.geom
|
|
|
|
|
import test.bootstrap
|
|
|
|
|
from ifcopenshell.util.shape_builder import ShapeBuilder, V
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCreatingShapes(test.bootstrap.IFC4):
|
|
|
|
|
def test_create_IfcCirle(self):
|
|
|
|
|
builder = ShapeBuilder(self.file)
|
|
|
|
|
item = builder.circle(radius=1.0)
|
|
|
|
|
settings = ifcopenshell.geom.settings()
|
|
|
|
|
shape = ifcopenshell.geom.create_shape(settings, item)
|
|
|
|
|
assert shape.verts
|
|
|
|
|
|
|
|
|
|
def test_create_IfcEllipse(self):
|
2024-09-11 15:05:18 +05:00
|
|
|
builder = ShapeBuilder(self.file)
|
|
|
|
|
item = self.file.create_entity(
|
|
|
|
|
"IfcEllipse", Position=builder.create_axis2_placement_2d(), SemiAxis1=1.0, SemiAxis2=0.5
|
2024-09-10 12:15:43 +05:00
|
|
|
)
|
|
|
|
|
settings = ifcopenshell.geom.settings()
|
|
|
|
|
shape = ifcopenshell.geom.create_shape(settings, item)
|
|
|
|
|
assert shape.verts
|
2024-09-11 15:08:18 +05:00
|
|
|
|
|
|
|
|
def test_create_IfcLine(self):
|
|
|
|
|
item = self.file.create_entity(
|
|
|
|
|
"IfcLine",
|
|
|
|
|
Pnt=self.file.create_entity("IfcCartesianPoint", (0.0, 0.0)),
|
|
|
|
|
Dir=self.file.create_entity(
|
|
|
|
|
"IfcVector", Orientation=self.file.create_entity("IfcDirection", (1.0, 0.0)), Magnitude=1.0
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
settings = ifcopenshell.geom.settings()
|
|
|
|
|
shape = ifcopenshell.geom.create_shape(settings, item)
|
|
|
|
|
assert shape.verts
|
|
|
|
|
|
|
|
|
|
def test_create_IfcBSplineCurve(self):
|
|
|
|
|
item = item = self.file.create_entity(
|
|
|
|
|
"IfcBSplineCurveWithKnots",
|
|
|
|
|
Degree=3,
|
|
|
|
|
ControlPointsList=[self.file.create_entity("IfcCartesianPoint", p) for p in points],
|
|
|
|
|
KnotMultiplicities=(4, 1, 1, 4),
|
|
|
|
|
Knots=(0.0, 1 / 3, 2 / 3, 1.0),
|
|
|
|
|
)
|
|
|
|
|
settings = ifcopenshell.geom.settings()
|
|
|
|
|
shape = ifcopenshell.geom.create_shape(settings, item)
|
|
|
|
|
assert shape.verts
|