Skip to content

Commit a58082d

Browse files
committed
WIP
1 parent 7443de1 commit a58082d

File tree

6 files changed

+346
-0
lines changed

6 files changed

+346
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from django.db import models
2+
3+
4+
class Building(models.Model):
5+
"""
6+
"""
7+
name = models.CharField(max_length=100)
8+
address = models.TextField()
9+
10+
def __str__(self):
11+
return self.name
12+
13+
class Building(models.Model):
14+
project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='buildings')
15+
name = models.CharField(max_length=255)
16+
location_description = models.CharField(max_length=255, blank=True, null=True)
17+
18+
def __str__(self):
19+
return self.name
20+
21+
22+
class IfcBuilding(models.Model):
23+
# Core Attributes
24+
name = models.CharField(max_length=255, blank=True, null=True)
25+
description = models.TextField(blank=True, null=True)
26+
27+
# Relational Attributes
28+
object_placement = models.JSONField(blank=True, null=True, help_text="Spatial structure of the building.")
29+
representation = models.JSONField(blank=True, null=True, help_text="Representation of the building in terms of geometry or other parameters.")
30+
31+
# Specific Attributes
32+
elevation_of_ref_height = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Elevation at reference height above sea level.")
33+
elevation_of_terrain = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Elevation of the natural terrain around the building's perimeter at reference height.")
34+
building_address = models.JSONField(blank=True, null=True, help_text="Address of the building.")
35+
36+
# Relationships (For simplicity, assuming relationships are managed as JSON. Adjust according to your application's needs.)
37+
building_elements = models.JSONField(blank=True, null=True, help_text="Elements that form part of the building.")
38+
project = models.ForeignKey('IfcProject', on_delete=models.CASCADE, related_name='buildings', blank=True, null=True)
39+
40+
def __str__(self):
41+
return self.name or "Unnamed Building"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcproduct.htm
2+
3+
from django.db import models
4+
5+
class IfcProduct(models.Model):
6+
# Attributes
7+
name = models.CharField(max_length=255, blank=True, null=True)
8+
description = models.TextField(blank=True, null=True)
9+
object_placement = models.JSONField(blank=True, null=True, help_text="Spatial structure defining the object's placement in the project.")
10+
representation = models.JSONField(blank=True, null=True, help_text="Physical or geometric representation of the product.")
11+
12+
# Relationships
13+
project = models.ForeignKey('IfcProject', on_delete=models.CASCADE, related_name='products', blank=True, null=True)
14+
owner_history = models.ForeignKey('IfcOwnerHistory', on_delete=models.SET_NULL, null=True, blank=True, help_text="Information about the creation or modification of the product.")
15+
16+
def __str__(self):
17+
return self.name or "Unnamed Product"
18+
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# -*- coding: utf-8 -*-
2+
3+
4+
# =============================================================================
5+
# Docstring
6+
# =============================================================================
7+
8+
"""
9+
Provides IFC Project Model Class
10+
================================
11+
12+
13+
For detailed specifications, see:
14+
https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcproject.htm
15+
16+
""" # noqa E501
17+
18+
19+
# =============================================================================
20+
# Import
21+
# =============================================================================
22+
23+
# Import | Standard Library
24+
# from uuid import uuid4
25+
# from typing import Any, Dict, List
26+
27+
# Import | Libraries
28+
from django.urls import reverse
29+
from django.utils.translation import gettext_lazy as _
30+
31+
# Import | Local Modules
32+
from .model_ifc_object_definition import IfcObjectDefinitionModel
33+
from ..fields.model import (
34+
IfcLabelField,
35+
)
36+
from .ifc_unit_assignment import IfcUnitAssignment # Assume this handles the units used throughout the project
37+
from .ifc_geometric_representation_context import IfcGeometricRepresentationContext # Assume this handles the geometric context
38+
39+
40+
# =============================================================================
41+
# Variables
42+
# =============================================================================
43+
44+
__all__ = ["IfcProjectModel", ]
45+
46+
47+
# =============================================================================
48+
# Classes
49+
# =============================================================================
50+
51+
class IfcProjectModel(IfcObjectDefinitionModel):
52+
"""
53+
IFC Project Model Class
54+
=======================
55+
56+
Model representing an IfcProject as defined in the IFC 2x3 standard.
57+
58+
This model encapsulates the top-level project information in an IFC file,
59+
providing a context for all project-related data, including project name, geographic
60+
and geometric context, and units of measurement.
61+
62+
Attributes:
63+
long_name (models.CharField): A long and more descriptive name for the project.
64+
phase (models.CharField): The current phase of the project (e.g., design, construction).
65+
units_in_context (ForeignKey): The units used in this project.
66+
representation_contexts (ManyToManyField): Contexts that define the geometric representation.
67+
"""
68+
69+
long_name = IfcLabelField(
70+
blank=True,
71+
null=True,
72+
verbose_name=_("Long Name"),
73+
help_text=_("A longer and more descriptive name for the project.")
74+
)
75+
76+
phase = IfcLabelField(
77+
blank=True,
78+
null=True,
79+
verbose_name=_("Phase"),
80+
help_text=_("The current phase of the project such as planning, construction, or operation.") # noqa E501
81+
)
82+
83+
units_in_context = models.ForeignKey(
84+
IfcUnitAssignment,
85+
on_delete=models.RESTRICT,
86+
verbose_name=_("Units In Context"),
87+
help_text=_("The units used within this project.")
88+
)
89+
90+
representation_contexts = models.ManyToManyField(
91+
IfcGeometricRepresentationContext,
92+
verbose_name=_("Geometric Representation Contexts"),
93+
help_text=_("Geometric contexts that define how the geometries are represented in the project.")
94+
)
95+
96+
class Meta:
97+
verbose_name = _("IfcProject")
98+
verbose_name_plural = _("IfcProjects")
99+
100+
def __str__(self):
101+
return f"{self.long_name} - Phase: {self.phase}"
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# -*- coding: utf-8 -*-
2+
3+
4+
# =============================================================================
5+
# Docstring
6+
# =============================================================================
7+
8+
"""
9+
Provides IFC Representation Model Class
10+
=======================================
11+
12+
13+
For detailed specifications, see:
14+
https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcrepresentationresource/lexical/ifcrepresentation.htm
15+
16+
""" # noqa E501
17+
18+
19+
# =============================================================================
20+
# Import
21+
# =============================================================================
22+
23+
# Import | Standard Library
24+
# from uuid import uuid4
25+
# from typing import Any, Dict, List
26+
27+
# Import | Libraries
28+
from django.urls import reverse
29+
from django.utils.translation import gettext_lazy as _
30+
31+
# Import | Local Modules
32+
from .model_ifc_object_definition import IfcObjectDefinitionModel
33+
from ..fields.model import (
34+
IfcLabelField,
35+
)
36+
37+
38+
# =============================================================================
39+
# Variables
40+
# =============================================================================
41+
42+
__all__ = ["IfcRepresentation", ]
43+
44+
45+
# =============================================================================
46+
# Classes
47+
# =============================================================================
48+
49+
class IfcRepresentation(models.Model):
50+
"""
51+
"""
52+
53+
class IfcRepresentation(models.Model):
54+
"""
55+
Model representing an IfcRepresentation as defined in the IFC 2x3 standard.
56+
57+
This model defines the representation of a product in a specific representation context,
58+
such as the geometry or spatial structure.
59+
60+
Attributes:
61+
context_of_items (ForeignKey): The context in which the items are represented.
62+
representation_identifier (CharField): Identifier of the representation, e.g., 'Body', 'Axis'.
63+
representation_type (CharField): The type of the representation, e.g., 'Mesh', 'Solid'.
64+
items (ManyToManyField): Items that are part of this representation.
65+
"""
66+
67+
context_of_items = models.ForeignKey(
68+
IfcRepresentationContext,
69+
on_delete=models.CASCADE,
70+
verbose_name=_("Context of Items"),
71+
help_text=_("The context that defines how the representation items are interpreted.")
72+
)
73+
74+
representation_identifier = models.CharField(
75+
max_length=255,
76+
blank=True,
77+
null=True,
78+
verbose_name=_("Representation Identifier"),
79+
help_text=_("Identifier of the representation, such as 'Body' for geometric representation or 'Axis' for symbolic representation.")
80+
)
81+
representation_type = models.CharField(
82+
max_length=255,
83+
blank=True,
84+
null=True,
85+
verbose_name=_("Representation Type"),
86+
help_text=_("The type of the representation, such as 'Mesh', 'Solid', or 'Curve'.")
87+
)
88+
items = models.ManyToManyField(
89+
IfcRepresentationItem,
90+
verbose_name=_("Items"),
91+
help_text=_("Geometric or spatial items included in this representation.")
92+
)
93+
94+
class Meta:
95+
verbose_name = _("IfcRepresentation")
96+
verbose_name_plural = _("IfcRepresentations")
97+
98+
def __str__(self):
99+
return f"{self.representation_identifier} - {self.representation_type}"
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# -*- coding: utf-8 -*-
2+
3+
4+
# =============================================================================
5+
# Docstring
6+
# =============================================================================
7+
8+
"""
9+
Provides IFC Representation Context Model Class
10+
===============================
11+
12+
13+
For detailed specifications, see:
14+
https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcrepresentationresource/lexical/ifcrepresentationcontext.htm
15+
""" # noqa E501
16+
17+
18+
# =============================================================================
19+
# Import
20+
# =============================================================================
21+
22+
# Import | Standard Library
23+
# from uuid import uuid4
24+
# from typing import Any, Dict, List
25+
26+
# Import | Libraries
27+
from django.urls import reverse
28+
from django.utils.translation import gettext_lazy as _
29+
30+
# Import | Local Modules
31+
from .model_ifc_object_definition import IfcObjectDefinitionModel
32+
from ..fields.model import (
33+
IfcLabelField,
34+
)
35+
36+
37+
# =============================================================================
38+
# Variables
39+
# =============================================================================
40+
41+
__all__ = ["IfcRepresentationContext", ]
42+
43+
44+
# =============================================================================
45+
# Classes
46+
# =============================================================================
47+
48+
class IfcRepresentationContext(models.Model):
49+
"""
50+
Model representing an IfcRepresentationContext as defined in the IFC 2x3 standard.
51+
52+
This model provides a context for all representations, detailing the coordinate system and dimensionality,
53+
ensuring that the geometric or spatial representations are correctly interpreted according to the project's standards.
54+
55+
Attributes:
56+
context_identifier (models.CharField): Identifies the context type (e.g., Plan, Elevation).
57+
context_type (models.CharField): Describes the context further (e.g., 2D, 3D).
58+
coordinate_space_dimension (models.IntegerField): The dimensionality of the coordinate system (typically 2 or 3).
59+
"""
60+
61+
context_identifier = IfcLabelField(
62+
blank=True,
63+
null=True,
64+
verbose_name=_("Context Identifier"),
65+
help_text=_("Identifies the context type, which could be used to differentiate between different graphical or spatial contexts.") # noqa E501
66+
)
67+
68+
context_type = IfcLabelField(
69+
blank=True,
70+
null=True,
71+
verbose_name=_("Context Type"),
72+
help_text=_("Further describes the type of representation context, such as 'Model' or 'Plan'.") # noqa E501
73+
)
74+
75+
coordinate_space_dimension = models.IntegerField(
76+
default=3,
77+
verbose_name=_("Coordinate Space Dimension"),
78+
help_text=_("The dimensionality of the coordinate system used in this context, typically 2 or 3.")
79+
)
80+
81+
class Meta:
82+
verbose_name = _("IfcRepresentationContext")
83+
verbose_name_plural = _("IfcRepresentationContexts")
84+
85+
def __str__(self):
86+
return f"{self.context_identifier} ({self.context_type})"
87+

src/django-ifc/models/model_ifc_representation_item.py

Whitespace-only changes.

0 commit comments

Comments
 (0)