mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
bimtester: features, move geometric detail tests from examples to implemented steps
This commit is contained in:
@@ -5,7 +5,7 @@ use_step_matcher("parse")
|
|||||||
from bimtester.features.steps.application import en
|
from bimtester.features.steps.application import en
|
||||||
|
|
||||||
use_step_matcher("parse")
|
use_step_matcher("parse")
|
||||||
from bimtester.features.steps.attributes_eleclasses import en, de
|
from bimtester.features.steps.attributes_eleclasses import de, en
|
||||||
|
|
||||||
use_step_matcher("parse")
|
use_step_matcher("parse")
|
||||||
from bimtester.features.steps.attributes_psets import en, de
|
from bimtester.features.steps.attributes_psets import en, de
|
||||||
@@ -26,7 +26,7 @@ use_step_matcher("parse")
|
|||||||
from bimtester.features.steps.geolocation import en
|
from bimtester.features.steps.geolocation import en
|
||||||
|
|
||||||
use_step_matcher("parse")
|
use_step_matcher("parse")
|
||||||
from bimtester.features.steps.geometric_detail import en
|
from bimtester.features.steps.geometric_detail import de, en
|
||||||
|
|
||||||
use_step_matcher("parse")
|
use_step_matcher("parse")
|
||||||
from bimtester.features.steps.model_federation import en
|
from bimtester.features.steps.model_federation import en
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from behave import step
|
||||||
|
|
||||||
|
|
||||||
|
@step("Alle {ifc_class} Bauteile müssen eine geometrische Repräsentation der Klasse {representation_class} verwenden")
|
||||||
|
def step_impl(context, ifc_class, representation_class):
|
||||||
|
context.execute_steps(f'* All {ifc_class} elements have an "{representation_class}" representation')
|
||||||
@@ -28,3 +28,69 @@ def step_impl(context, number):
|
|||||||
for error in errors:
|
for error in errors:
|
||||||
message += "Polygons: {} - {}\n".format(error[0], error[1])
|
message += "Polygons: {} - {}\n".format(error[0], error[1])
|
||||||
assert False, message
|
assert False, message
|
||||||
|
|
||||||
|
|
||||||
|
@step('All "{ifc_class}" elements have an "{representation_class}" representation')
|
||||||
|
def step_impl(context, ifc_class, representation_class):
|
||||||
|
eleclass_has_geometric_representation_of_specific_class(
|
||||||
|
context,
|
||||||
|
ifc_class,
|
||||||
|
representation_class
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ************************************************************************************************
|
||||||
|
# helper
|
||||||
|
def eleclass_has_geometric_representation_of_specific_class(
|
||||||
|
context,
|
||||||
|
ifc_class,
|
||||||
|
representation_class
|
||||||
|
):
|
||||||
|
|
||||||
|
def is_item_a_representation(item, representation):
|
||||||
|
if "/" in representation:
|
||||||
|
for cls in representation.split("/"):
|
||||||
|
if item.is_a(cls):
|
||||||
|
return True
|
||||||
|
elif item.is_a(representation):
|
||||||
|
return True
|
||||||
|
|
||||||
|
context.falseelems = []
|
||||||
|
context.falseguids = []
|
||||||
|
context.falseprops = {}
|
||||||
|
rep = None
|
||||||
|
|
||||||
|
elements = IfcStore.file.by_type(ifc_class)
|
||||||
|
for elem in elements:
|
||||||
|
if not elem.Representation:
|
||||||
|
continue
|
||||||
|
has_representation = False
|
||||||
|
for representation in elem.Representation.Representations:
|
||||||
|
for item in representation.Items:
|
||||||
|
if item.is_a("IfcMappedItem"):
|
||||||
|
# We only check one more level deep.
|
||||||
|
for item2 in item.MappingSource.MappedRepresentation.Items:
|
||||||
|
if is_item_a_representation(item2, representation_class):
|
||||||
|
has_representation = True
|
||||||
|
rep = item2
|
||||||
|
else:
|
||||||
|
if is_item_a_representation(item, representation_class):
|
||||||
|
has_representation = True
|
||||||
|
rep = item
|
||||||
|
if not has_representation:
|
||||||
|
context.falseelems.append(str(elem))
|
||||||
|
context.falseguids.append(elem.GlobalId)
|
||||||
|
context.falseprops[elem.id()] = str(rep)
|
||||||
|
|
||||||
|
context.elemcount = len(elements)
|
||||||
|
context.falsecount = len(context.falseelems)
|
||||||
|
util.assert_elements(
|
||||||
|
ifc_class,
|
||||||
|
context.elemcount,
|
||||||
|
context.falsecount,
|
||||||
|
context.falseelems,
|
||||||
|
message_all_falseelems=_("All {elemcount} {ifc_class} elements are not a {parameter} representation."),
|
||||||
|
message_some_falseelems=_("The following {falsecount} of {elemcount} {ifc_class} elements are not a {parameter} representation: {falseelems}"),
|
||||||
|
message_no_elems=_("There are no {ifc_class} elements in the IFC file."),
|
||||||
|
parameter=representation_class
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
from behave import step
|
|
||||||
|
|
||||||
import geometric_detail_methods as gdm
|
|
||||||
from utils import assert_elements
|
|
||||||
from utils import IfcFile
|
|
||||||
from utils import switch_locale
|
|
||||||
|
|
||||||
|
|
||||||
the_lang = "en"
|
|
||||||
|
|
||||||
|
|
||||||
@step("all {ifc_class} elements have an {representation_class} representation")
|
|
||||||
def step_impl(context, ifc_class, representation_class):
|
|
||||||
switch_locale(context.localedir, the_lang)
|
|
||||||
gdm.eleclass_has_geometric_representation_of_specific_class(
|
|
||||||
context,
|
|
||||||
ifc_class,
|
|
||||||
representation_class
|
|
||||||
)
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
from behave import step
|
|
||||||
|
|
||||||
import geometric_detail_methods as gdm
|
|
||||||
from utils import switch_locale
|
|
||||||
|
|
||||||
|
|
||||||
the_lang = "de"
|
|
||||||
|
|
||||||
|
|
||||||
@step("Alle {ifc_class} Bauteile müssen eine geometrische Repräsentation der Klasse {representation_class} verwenden")
|
|
||||||
def step_impl(context, ifc_class, representation_class):
|
|
||||||
switch_locale(context.localedir, the_lang)
|
|
||||||
gdm.eleclass_has_geometric_representation_of_specific_class(
|
|
||||||
context,
|
|
||||||
ifc_class,
|
|
||||||
representation_class
|
|
||||||
)
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import gettext # noqa
|
|
||||||
from utils import assert_elements
|
|
||||||
from utils import IfcFile
|
|
||||||
|
|
||||||
|
|
||||||
def eleclass_has_geometric_representation_of_specific_class(
|
|
||||||
context,
|
|
||||||
ifc_class,
|
|
||||||
representation_class
|
|
||||||
):
|
|
||||||
|
|
||||||
def is_item_a_representation(item, representation):
|
|
||||||
if "/" in representation:
|
|
||||||
for cls in representation.split("/"):
|
|
||||||
if item.is_a(cls):
|
|
||||||
return True
|
|
||||||
elif item.is_a(representation):
|
|
||||||
return True
|
|
||||||
|
|
||||||
context.falseelems = []
|
|
||||||
context.falseguids = []
|
|
||||||
context.falseprops = {}
|
|
||||||
rep = None
|
|
||||||
|
|
||||||
elements = IfcFile.get().by_type(ifc_class)
|
|
||||||
for elem in elements:
|
|
||||||
if not elem.Representation:
|
|
||||||
continue
|
|
||||||
has_representation = False
|
|
||||||
for representation in elem.Representation.Representations:
|
|
||||||
for item in representation.Items:
|
|
||||||
if item.is_a("IfcMappedItem"):
|
|
||||||
# We only check one more level deep.
|
|
||||||
for item2 in item.MappingSource.MappedRepresentation.Items:
|
|
||||||
if is_item_a_representation(item2, representation_class):
|
|
||||||
has_representation = True
|
|
||||||
rep = item2
|
|
||||||
else:
|
|
||||||
if is_item_a_representation(item, representation_class):
|
|
||||||
has_representation = True
|
|
||||||
rep = item
|
|
||||||
if not has_representation:
|
|
||||||
context.falseelems.append(str(elem))
|
|
||||||
context.falseguids.append(elem.GlobalId)
|
|
||||||
context.falseprops[elem.id()] = str(rep)
|
|
||||||
|
|
||||||
context.elemcount = len(elements)
|
|
||||||
context.falsecount = len(context.falseelems)
|
|
||||||
assert_elements(
|
|
||||||
ifc_class,
|
|
||||||
context.elemcount,
|
|
||||||
context.falsecount,
|
|
||||||
context.falseelems,
|
|
||||||
message_all_falseelems=_("All {elemcount} {ifc_class} elements are not a {parameter} representation."),
|
|
||||||
message_some_falseelems=_("The following {falsecount} of {elemcount} {ifc_class} elements are not a {parameter} representation: {falseelems}"),
|
|
||||||
message_no_elems=_("There are no {ifc_class} elements in the IFC file."),
|
|
||||||
parameter=representation_class
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user