#2321 Remove IDS from IfcOpenShell to prevent confusion as it is now refactored heavily and lives in ifctester

This commit is contained in:
Dion Moult
2022-08-05 09:28:35 +10:00
parent 0b16c07e3a
commit 5b34e08c37
4 changed files with 0 additions and 3294 deletions
File diff suppressed because it is too large Load Diff
@@ -1,289 +0,0 @@
<!-- edited with XMLSpy v2022 (x64) (http://www.altova.com) by Leon van Berlo (Overleaf Investments B.V.) -->
<!-- May 24, 2022 - DRAFT -->
<xs:schema xmlns:ids="http://standards.buildingsmart.org/IDS" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://standards.buildingsmart.org/IDS" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.6.1">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
<xs:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="https://www.w3.org/2001/XMLSchema.xsd"/>
<xs:import namespace="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.w3.org/2001/XMLSchema-instance"/>
<xs:element name="ids">
<xs:complexType>
<xs:sequence>
<xs:element name="info">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="copyright" type="xs:string" minOccurs="0"/>
<xs:element name="version" type="xs:string" minOccurs="0"/>
<xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="author" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[^@]+@[^\.]+\..+"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="date" type="xs:date" minOccurs="0"/>
<xs:element name="purpose" type="xs:string" minOccurs="0"/>
<xs:element name="milestone" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="specifications">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:specificationsType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="entityType">
<xs:sequence>
<xs:element name="name" type="ids:idsValue"/>
<xs:element name="predefinedType" type="ids:idsValue" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="idsValue">
<xs:choice minOccurs="1">
<!-- place for potential additional rules for idsValue -->
<xs:element name="simpleValue" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element ref="xs:restriction" minOccurs="1" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="classificationType">
<xs:sequence>
<xs:element name="value" type="ids:idsValue" minOccurs="0"/>
<xs:element name="system" type="ids:idsValue" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="applicabilityType">
<xs:sequence>
<xs:element name="entity" type="ids:entityType" minOccurs="0"/>
<xs:element name="classification" type="ids:classificationType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="attribute" type="ids:attributeType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="property" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:propertyType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="material" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:materialType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="propertyType">
<xs:sequence>
<xs:element name="propertySet" type="ids:idsValue"/>
<xs:element name="name" type="ids:idsValue"/>
<xs:element name="value" type="ids:idsValue" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="measure">
<xs:annotation>
<xs:documentation>See the documentation and default units of these measures on https://github.com/buildingSMART/IDS/blob/master/Documentation/Physical_Quantities_and_Units.md</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="String"/>
<xs:enumeration value="Number"/>
<xs:enumeration value="AmountOfSubstance"/>
<xs:enumeration value="AreaDensity"/>
<xs:enumeration value="Area"/>
<xs:enumeration value="DynamicViscosity"/>
<xs:enumeration value="ElectricCapacitance"/>
<xs:enumeration value="ElectricCharge"/>
<xs:enumeration value="ElectricConductance"/>
<xs:enumeration value="ElectricCurrent"/>
<xs:enumeration value="ElectricResistance"/>
<xs:enumeration value="ElectricVoltage"/>
<xs:enumeration value="Energy"/>
<xs:enumeration value="Force"/>
<xs:enumeration value="Frequency"/>
<xs:enumeration value="HeatFluxDensity"/>
<xs:enumeration value="Heating"/>
<xs:enumeration value="Illuminance"/>
<xs:enumeration value="IonConcentration"/>
<xs:enumeration value="IsoThermalMoistureCapacity"/>
<xs:enumeration value="Length"/>
<xs:enumeration value="Speed"/>
<xs:enumeration value="LuminousFlux"/>
<xs:enumeration value="LuminousIntensity"/>
<xs:enumeration value="MassDensity"/>
<xs:enumeration value="MassFlowRate"/>
<xs:enumeration value="Mass"/>
<xs:enumeration value="MassPerLength"/>
<xs:enumeration value="ModulusOfElasticity"/>
<xs:enumeration value="MoistureDiffusivity"/>
<xs:enumeration value="MolecularWeight"/>
<xs:enumeration value="MomentOfInertia"/>
<xs:enumeration value="PH"/>
<xs:enumeration value="PlanarForce"/>
<xs:enumeration value="Angle"/>
<xs:enumeration value="PlaneAngle"/>
<xs:enumeration value="Power"/>
<xs:enumeration value="Pressure"/>
<xs:enumeration value="RadioActivity"/>
<xs:enumeration value="Ratio"/>
<xs:enumeration value="RotationalFrequency"/>
<xs:enumeration value="SectionModulus"/>
<xs:enumeration value="SoundPower"/>
<xs:enumeration value="SoundPressure"/>
<xs:enumeration value="SpecificHeatCapacity"/>
<xs:enumeration value="TemperatureRateOfChange"/>
<xs:enumeration value="ThermalConductivity"/>
<xs:enumeration value="Temperature"/>
<xs:enumeration value="Time"/>
<xs:enumeration value="Torque"/>
<xs:enumeration value="VaporPermeability"/>
<xs:enumeration value="Volume"/>
<xs:enumeration value="VolumetricFlowRate"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="attributeType">
<xs:sequence>
<xs:element name="name" type="ids:idsValue"/>
<xs:element name="value" type="ids:idsValue" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="materialType">
<xs:sequence>
<xs:element name="value" type="ids:idsValue" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="requirementsType">
<xs:sequence maxOccurs="unbounded">
<xs:element name="entity" minOccurs="0">
<xs:annotation>
<xs:documentation>Make sure 'Name' value of requirements entity is the same as the 'applicability' node, or a wildcard (inclusive pattern).</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:entityType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="partOf" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="entity" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="IfcElementAssembly"/>
<xs:enumeration value="IfcGroup"/>
<xs:enumeration value="IfcSystem"/>
<xs:enumeration value="IfcBuildingSystem"/>
<xs:enumeration value="IfcBuiltSystem"/>
<xs:enumeration value="IfcDistributionSystem"/>
<xs:enumeration value="IfcZone"/>
<xs:enumeration value="IfcAsset"/>
<xs:enumeration value="IfcInventory"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="classification" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:classificationType">
<xs:attribute name="uri" type="xs:anyURI" use="optional"/>
<xs:attributeGroup ref="xs:occurs"/>
<xs:attribute name="instructions" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="attribute" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:attributeType">
<xs:attributeGroup ref="xs:occurs"/>
<xs:attribute name="instructions" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="property" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:propertyType">
<xs:attribute name="uri" type="xs:anyURI" use="optional"/>
<xs:attributeGroup ref="xs:occurs"/>
<xs:attribute name="instructions" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="material" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:materialType">
<xs:attribute name="uri" type="xs:anyURI" use="optional"/>
<xs:attributeGroup ref="xs:occurs"/>
<xs:attribute name="instructions" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="specificationType">
<xs:sequence>
<xs:element name="applicability" type="ids:applicabilityType"/>
<xs:element name="requirements" type="ids:requirementsType"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attributeGroup ref="xs:occurs"/>
<xs:attribute name="ifcVersion" use="required">
<xs:simpleType>
<xs:list>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="IFC2X3"/>
<xs:enumeration value="IFC4"/>
<xs:enumeration value="IFC4X3"/>
</xs:restriction>
</xs:simpleType>
</xs:list>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="identifier" type="xs:string">
<xs:annotation>
<xs:documentation>Author of the IDS can provide an identifier to the IDS. Beware: this cannot be enforced/assumed as (global) unique.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="description" type="xs:string" use="optional"/>
<xs:attribute name="instructions" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="specificationsType">
<xs:sequence>
<xs:element name="specification" type="ids:specificationType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
@@ -1,125 +0,0 @@
# IfcOpenShell - IFC toolkit and geometry engine
# Copyright (C) 2021 Thomas Krijnen <thomas@aecgeeks.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 os
import re
import unittest
import functools
import itertools
import ifcopenshell
import test_ids
from xml.dom.minidom import parseString
from ifcopenshell import ids, template, validate
outdir = "build"
class DocGenerator:
def __init__(self):
self.facet = None
self.testcases = {}
def __call__(self, name, *, facet, inst, expected):
if not name:
return
result = "pass" if expected is True else "fail"
f = inst.wrapped_data.file
instances = list(f)
# Validate the file created and loop over the issues, fixing them
# one by one.
l = validate.json_logger()
validate.validate(f, l)
for issue in l.statements:
if "GlobalId" in issue["message"]:
issue["instance"].GlobalId = ifcopenshell.guid.new()
elif "PredefinedType" in issue["message"]:
ty = re.findall("\\(.+?\\)", issue["message"])[0][1:-1].split(", ")[0]
issue["instance"].PredefinedType = ty
elif "IfcMaterialList" in issue["message"]:
issue["instance"].Materials = [f.createIfcMaterial("Concrete", None, "CONCRETE")]
else:
raise Exception("About to emit invalid example data:", issue)
ifc_text = "\n".join([f"{e} /* Testcase */" if e == inst else str(e) for e in f])
basename = f"{result}-" + re.sub("[^0-9a-zA-Z]", "_", name.lower())
# Write IFC to disk
f.write(os.path.join(outdir, f"{basename}.ifc"))
# Create an IDS with the applicability selecting exactly
# the entity type passed to us in `inst`.
specs = ids.ids(title=name)
spec = ids.specification(name=name)
spec.add_applicability(ids.entity.create(name=inst.is_a()))
spec.add_requirement(facet)
specs.specifications.append(spec)
# Write IDS to disk
with open(os.path.join(outdir, f"{basename}.ids"), "w", encoding="utf-8") as ids_file:
ids_file.write(specs.to_string())
xml_text = "\n".join(
l
for l in parseString(specs.to_string())
.getElementsByTagName("requirements")[0]
.childNodes[1]
.toprettyxml()
.split("\n")
if l.strip()
).replace("\t", " ")
self.testcases.setdefault(self.facet, []).append(
{"name": name, "ids": xml_text, "ifc": ifc_text, "basename": basename, "result": result, "id": inst.id()}
)
assert bool(facet(inst)) is expected
def set_facet(self, facet):
self.facet = facet
test_ids.run = DocGenerator()
test_ids.set_facet = test_ids.run.set_facet
suite = unittest.TestLoader().discover(".", pattern="test_ids.py")
result = unittest.TextTestRunner(verbosity=2).run(suite)
for facet, testcases in test_ids.run.testcases.items():
with open(os.path.join(outdir, f"testcases-{facet}.md"), "w") as f:
write = functools.partial(print, file=f)
write(f"# {facet.capitalize()} testcases")
write()
write("These testcases are designed to help describe behaviour in edge cases and ambiguities. All valid IDS implementations must demonstrate identical behaviour to these test cases.")
write()
for testcase in testcases:
write(f"## [{testcase['result'].upper()}] {testcase['name']}")
write()
write("~~~xml")
write(testcase["ids"])
write("~~~")
write()
write("~~~lua")
write(testcase["ifc"])
write("~~~")
write()
write(f"[Sample IDS]({testcase['basename']}.ids) - [Sample IFC: {testcase['id']}]({testcase['basename']}.ifc)")
write()
File diff suppressed because it is too large Load Diff