Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
293 commits
Select commit Hold shift + click to select a range
0e136ea
Update
johltn Mar 3, 2021
92555ae
Update
johltn Mar 3, 2021
fdc0b26
Temporarily install xlsxwriter
johltn Mar 3, 2021
9c05e08
Update
johltn Mar 3, 2021
221e27b
Update bsdd
johltn Mar 3, 2021
b49a1bd
Report consistency
johltn Mar 9, 2021
7a485c3
Get checkboxes values
johltn Mar 9, 2021
ac30ae4
nginx http -> https redirect
aothms Mar 9, 2021
9b88264
Add checkboxes
johltn Mar 9, 2021
e7b9c04
Merge branch 'master' of https://github.com/AECgeeks/ifc-pipeline
johltn Mar 9, 2021
2c022a0
Merge branch 'master' into validation
johltn Mar 9, 2021
583416a
Temporarily remove checkboxes
johltn Mar 9, 2021
e496560
Filename in report
johltn Mar 9, 2021
99081d7
Update
johltn Mar 10, 2021
360ce3d
Use own MVD to extract data and rename variable names
johltn Mar 10, 2021
6deb11c
Update checkboxes
johltn Mar 11, 2021
eeea6d1
Improve CSS and change logo
johltn Mar 12, 2021
25e92a0
Delete console log
johltn Mar 12, 2021
147aabb
Choose what to validate from index page
johltn Mar 12, 2021
46bac51
More logical order user interface
johltn Mar 12, 2021
3103cd2
Update
johltn Mar 17, 2021
036b25a
Mutliclassification
johltn Mar 17, 2021
06edc54
Set tolerance for string matching and fix typos
johltn Mar 17, 2021
8150a7b
Start test infrastructure and add step parser as submodule
johltn Mar 18, 2021
984198a
Minor renaming
johltn Mar 18, 2021
8e91d2f
Minor renaming
johltn Mar 18, 2021
d7c6ffb
Update
johltn Mar 18, 2021
8464bfa
Update
johltn Mar 18, 2021
07eaf1d
Update worker according to new submodule
johltn Mar 18, 2021
173aaf3
Add parsing test
johltn Mar 18, 2021
c7f03bf
Commit before CSS
johltn Mar 31, 2021
72af517
Before cleaning
johltn Mar 31, 2021
0b43b8b
Change CSS
johltn Apr 1, 2021
6b10852
sqlalchemy version
johltn Apr 1, 2021
4317a89
Update
johltn Apr 1, 2021
1f72015
CSS
johltn Apr 1, 2021
bc25987
ids
johltn Apr 6, 2021
724c995
CSS update and creation of second tab for IDS upload and other things
johltn Apr 19, 2021
e5916dd
Fix
johltn Apr 19, 2021
e19b1e1
Progress bar and info
johltn Apr 19, 2021
bb06689
Clean
johltn Apr 19, 2021
43581d3
Update
johltn Apr 21, 2021
324076e
Rename check_bSDD.py to check_bsdd.py
johltn Apr 21, 2021
9b95c0b
Add application name
johltn May 3, 2021
a78f19e
Upload IDS and get IFC upload link from it, new report structure
johltn May 4, 2021
34862e9
Improve report
johltn May 15, 2021
db12627
Test changes
May 15, 2021
8b0b135
Improve report
johltn May 15, 2021
d745e5d
Improve report
johltn May 16, 2021
f46757e
Start to add tabulation
johltn May 16, 2021
928929c
Improve report
johltn May 16, 2021
c9d324e
Start folding rows
johltn May 17, 2021
2fc00e4
Fold at the entity level
johltn May 17, 2021
d7073b4
Folded at start
johltn May 17, 2021
cedd8a2
Advance on report
johltn May 17, 2021
444df25
Improve folding
johltn May 17, 2021
8235b2e
Improve report
johltn May 17, 2021
4b2e18e
Possibility to fold by validation type
johltn May 17, 2021
d6c3488
Improve report
johltn May 18, 2021
bf2e94b
Copy ids files to file storage
johltn May 18, 2021
f1b6978
Process ids in worker and get the file back from the server
johltn May 18, 2021
2e59989
Update
johltn May 18, 2021
85b83ba
Add not checked icon and condition for ids_spec
johltn May 18, 2021
4b8f99b
Unconcatenate function
johltn May 18, 2021
1c9e2a9
Fix typo
johltn May 18, 2021
48683d4
Reverse change
johltn May 18, 2021
01cd93e
Config control
johltn May 19, 2021
dbf348a
Pass ids results, but JSON decoding has to be handled
johltn May 19, 2021
5d59ccb
Handle no IDS case
johltn May 21, 2021
a4e7859
Several updates
johltn Jun 5, 2021
4e014f2
Intermediate commit
johltn Jun 7, 2021
d08f214
Intermediate commit
johltn Jun 7, 2021
df8da2f
Improve configuration handling
johltn Jun 7, 2021
955c528
Before adding IDS to table
johltn Jun 7, 2021
b5f1d46
Update
johltn Jun 7, 2021
3e9b35d
Update
johltn Jun 7, 2021
3010ffe
Improve bSDD validation
johltn Jun 8, 2021
7f1fbd5
Remove pdb; pdb.set-trace()
johltn Jun 8, 2021
1e2caa1
Fix CSS
johltn Jun 15, 2021
26cac28
Update
johltn Jun 15, 2021
bb9f1c5
Update
johltn Jun 23, 2021
e94db57
Add possibility to input license, hours, and details from UI and pass…
johltn Jun 23, 2021
03587e9
buildingSmart OAuth2 and OpenId authentification flow (no flask imple…
johltn Sep 8, 2021
8f4d563
Test environment variables passed to container
johltn Sep 13, 2021
ecaec29
Read value of env variable
johltn Sep 13, 2021
beef1e9
Test Oauth2
johltn Sep 13, 2021
6d664f5
Update Dockerfile
johltn Sep 13, 2021
efd0157
Update Dockerfile
johltn Sep 13, 2021
b80ab27
Update Dockerfile
johltn Sep 13, 2021
5ead567
Update Dockerfile and docker-compose.yml
johltn Sep 13, 2021
52b3afb
Update Dockerfile
johltn Sep 13, 2021
cd0a58e
Update login code
johltn Sep 13, 2021
6156ec3
Update login code
johltn Sep 13, 2021
9a96320
Update login code
johltn Sep 13, 2021
11e06bf
Update login code
johltn Sep 13, 2021
adc3d51
Update login code
johltn Sep 13, 2021
53c5c3d
Update login code
johltn Sep 13, 2021
4eb2193
Update login code
johltn Sep 13, 2021
269f9f3
Callback route
johltn Sep 14, 2021
71ab909
Callback route
johltn Sep 14, 2021
ce6072a
Callback route
johltn Sep 14, 2021
9bf53ea
Callback route
johltn Sep 14, 2021
16832ff
Forgot the return statement!
johltn Sep 14, 2021
87d989b
Check authorization in callback
johltn Sep 14, 2021
2b423a2
Error handling
johltn Sep 14, 2021
2aca075
Add error template
johltn Sep 14, 2021
52ccade
Get email
johltn Sep 15, 2021
18ecf1c
Get email
johltn Sep 15, 2021
9d43816
Update README.md
johltn Sep 15, 2021
3bc468e
First tentative to get decoded token_id
johltn Sep 15, 2021
b5a468d
JSON deserialization
johltn Sep 15, 2021
1f46cfc
Render index template instead of test
johltn Sep 15, 2021
0907fd8
Print decoded
johltn Sep 15, 2021
9afbb32
Try with state parameter
johltn Sep 15, 2021
e288561
Store state in session
johltn Sep 18, 2021
f8273f4
Tentative to solve secret key not set
johltn Sep 18, 2021
7660bd8
No state parameter in fetch_token
johltn Sep 18, 2021
cae40bb
Update
johltn Sep 18, 2021
a033908
Change anchor ref
johltn Sep 20, 2021
586950a
Start to implement the new database
johltn Sep 20, 2021
71b2549
Fix session variables names
johltn Sep 20, 2021
b067d81
Pass user id back to server
johltn Oct 2, 2021
2fab6ab
Save user input to database
johltn Oct 4, 2021
ce3e6cc
Save to DB from checking file locally
johltn Oct 6, 2021
c729801
Add __init__.py files
johltn Oct 6, 2021
6a2139b
Save changes
johltn Oct 6, 2021
2618649
DB change
johltn Oct 6, 2021
8d6d35e
Update num of geoms and props
johltn Oct 6, 2021
964962a
Package fixes
aothms Oct 6, 2021
7549513
Merge pull request #1 from aothms/validation
johltn Oct 6, 2021
601f6e9
Merge branch 'validation' of https://github.com/johltn/ifc-pipeline i…
johltn Oct 6, 2021
c21b982
Create new relationships between tables
johltn Oct 6, 2021
368fb8c
Use new bSDD API version
johltn Oct 6, 2021
f0776f0
Only process IFC files
johltn Oct 6, 2021
ccf7957
Save IFC instance into DB and link it to bSDD result
johltn Oct 7, 2021
75e4825
Get IFC file values and sotre them in DB
johltn Oct 7, 2021
0529db5
Fix types validation task bsdd result
johltn Oct 7, 2021
066c710
Use file id instead of file code
johltn Oct 7, 2021
9e884f4
Update
johltn Oct 7, 2021
32b9020
Fix typo
johltn Oct 7, 2021
d70203c
Update
johltn Oct 7, 2021
a7eb586
Start cleaning
johltn Oct 9, 2021
fef9ca2
Start new validation process
johltn Oct 17, 2021
04a445f
Update
johltn Oct 24, 2021
cf8402e
Retrieve files of the user
johltn Oct 25, 2021
3af4021
Keep changes after refresh
johltn Oct 25, 2021
7e773dd
Add number of geoms and props to saved files
johltn Oct 25, 2021
8806db5
Update:
johltn Oct 25, 2021
9df0e17
Add geoms and props while validating
johltn Oct 25, 2021
c87d217
Improve dashboard interface, data retrieval, and save result to DB fr…
johltn Oct 26, 2021
58fd2c6
Update bsdd checking
johltn Oct 26, 2021
5ff2f05
Update new checking
johltn Oct 26, 2021
be7535d
Handle pset or property not found
johltn Oct 26, 2021
ee46c5f
Fixing DB update
johltn Oct 26, 2021
2dbc292
Ok to change license from saved files'
johltn Oct 26, 2021
fab88ba
Update DB successfully for saved files
johltn Oct 26, 2021
8bb6332
Before modif
johltn Oct 28, 2021
8875330
Update classification
johltn Oct 28, 2021
182d83a
Ready to be saved in DB
johltn Oct 28, 2021
c9fd982
Add View report to saved files
johltn Oct 28, 2021
40a43c6
Start using buttons on index page and change check_bsdd2
johltn Nov 2, 2021
3955496
Add to DB and change DB schema for bsdd result
johltn Nov 2, 2021
2aea1d4
Many changes in the checking process, the database processes, and the…
johltn Nov 6, 2021
12f6086
Fix link from validation
johltn Nov 6, 2021
e84a6a6
Before using only dashboard template
johltn Nov 9, 2021
0d59b6b
Dashboard merging in progress
johltn Nov 14, 2021
91da1e3
Start merging validation and dashboard
johltn Nov 20, 2021
5f35032
Seems ok for the progress
johltn Nov 20, 2021
7b0b6b8
Almost ok (fix refresh while validation not done)
johltn Nov 20, 2021
a8233aa
Start creating the table with JS only
johltn Nov 23, 2021
0613360
Before implementing poll function
johltn Nov 23, 2021
a56cfc4
Before changing poll function
johltn Nov 24, 2021
abecc33
Update
johltn Nov 25, 2021
768b047
Progress in handling the fetching of progress. Todo next: modify the …
johltn Dec 10, 2021
5502d69
Complete table ok. Next: update additional info from user input
johltn Dec 11, 2021
1dfdbe6
Start putting the JS processing into a separate file
johltn Dec 11, 2021
6e26332
Dahsboards merged
johltn Dec 15, 2021
087f95a
Add possibility to download file
johltn Dec 15, 2021
2ef3193
Temporary fix for data dumping
johltn Dec 16, 2021
108e760
mailgun
johltn Dec 16, 2021
af298d8
Integrate new checking
johltn Dec 16, 2021
353e863
Results from DB
johltn Dec 16, 2021
03a57a0
Update geoms props
johltn Dec 16, 2021
be25dcb
Date to ISO format
johltn Dec 16, 2021
6e9c145
Small fix, before dropzone changes
johltn Jan 3, 2022
b0903ef
Use Dropzone.js instead of flask-dropzone and sanitize config handling
johltn Jan 3, 2022
6bf0198
Fix small bug and delete flask_dropzone references
johltn Jan 3, 2022
56b7a3e
Start general debugging
johltn Jan 4, 2022
0bd23b9
Many modifications before deployement
johltn Jan 4, 2022
e352099
Many small fixes
johltn Jan 4, 2022
a6dfa04
Update:
johltn Jan 5, 2022
5103276
Update
johltn Jan 5, 2022
b193321
Task_id
johltn Jan 5, 2022
75e403b
Update
johltn Jan 5, 2022
a398b66
Send email for uploaded files
johltn Jan 5, 2022
63c1973
Improve sentence for email
johltn Jan 5, 2022
f7c32e5
New report page relying on DB from dashboard
johltn Jan 10, 2022
6a4ce3d
Many changes including improvement of the report and cleaning of the …
johltn Jan 11, 2022
2062289
Small fix
johltn Jan 11, 2022
bd00f8f
Modify date
johltn Jan 18, 2022
15979fc
Improve date handling
johltn Jan 18, 2022
332ea08
Bunch of files modified, cleaning needed
johltn Jan 19, 2022
a8bac19
Fix overlap in Download cell
johltn Jan 19, 2022
317b679
Small improvement of CSS
johltn Jan 19, 2022
c44424c
Right color for Download anchor
johltn Jan 19, 2022
48a8868
Cleaning
johltn Jan 22, 2022
0e71d5b
First deletion of unused files
johltn Jan 26, 2022
08a4cf5
Delete tree viz
johltn Jan 26, 2022
2863315
Use list comprehension to unconcatenate models codes
johltn Jan 26, 2022
590a590
Use context manager for DB session
johltn Jan 26, 2022
f24b485
Improve progress writing and remove numpy dependency in check_bsdd
johltn Jan 26, 2022
d929df4
Remove previous report template
johltn Jan 26, 2022
3abfaab
Use json loading only once to store bsdd response content
johltn Jan 26, 2022
560420a
Reduce string indexing
johltn Jan 26, 2022
0e714e0
Remove unnecessary module
johltn Jan 26, 2022
190ebe1
Keep cleaning
johltn Jan 26, 2022
2069c06
Use dataclass instead of dict to store bsdd validation results
johltn Jan 27, 2022
0b32f5c
Small fixes
johltn Jan 27, 2022
a594660
Different bsdd_results handling cases. May be temporary
johltn Jan 27, 2022
86718a3
Clean info module
johltn Jan 27, 2022
89f5481
Start cleaning database module
johltn Jan 27, 2022
917315e
Add number of building elements
johltn Jan 28, 2022
bce6358
Add comments on dataclass serialization
johltn Jan 28, 2022
95ec3a8
Use Enum
johltn Jan 29, 2022
c10b4ce
Change default arg
johltn Jan 29, 2022
1887e66
Further small modification for the database module
johltn Jan 29, 2022
a4c7169
Start cleaning main
johltn Feb 1, 2022
40bbc3c
Login decorator
aothms Feb 3, 2022
365bbce
Decorator and logout
johltn Feb 7, 2022
6afef04
Add argument to logout method
johltn Feb 7, 2022
8b9e667
Keep cleaning
johltn Feb 7, 2022
bf7b7cb
Start modifying URLs
johltn Feb 7, 2022
2a6a797
Use backticks for template literals
johltn Feb 7, 2022
2ff9a02
Redirect to logout endpoint
johltn Feb 9, 2022
f46b8c9
Use context manager for DB session in main
johltn Feb 9, 2022
2c7dcd0
Keep cleaning
johltn Feb 9, 2022
edbf680
Recuce ambiguous query
johltn Feb 9, 2022
92f0c50
Remove redundant method
johltn Feb 9, 2022
6212afc
Validate config form
johltn Feb 11, 2022
a5976b6
Check model's user
johltn Feb 11, 2022
4e4319e
Validate update JSON (maybe use the same YAML file for all validation?)
johltn Feb 12, 2022
69e0110
Remove close call within context manager
johltn Feb 12, 2022
3c666a7
Remove file index in update
johltn Feb 12, 2022
34c7525
Clean JS
johltn Feb 12, 2022
50d1957
Remove unsused CSS
johltn Feb 14, 2022
fc7b5f2
Remove unused CSS
johltn Feb 14, 2022
e4e0b4b
Remove ast call
johltn Feb 14, 2022
acffdce
Remove unused CSS and use helper functions for input
johltn Feb 14, 2022
9f14b93
Removing CSS from JS
johltn Feb 14, 2022
42b5144
No more CSS in JS, return error message for DB update, and helper fun…
johltn Feb 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
models/
docker-volumes/

16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
__pycache__/
*.py[cod]
*.ifc
*.json
*.cover
docker-volumes
application/static/bimsurfer
application/nix
application/win
application/ifc-pipeline.db
application/ifc-python-parser
application/ifc-parser
application/bimsurfer_temp/
application/static/test.jpg
application/checks/ifcopenshell/
application/checks/request_builder.py
application/checks/dresult_bsdd.json
application/checks/result_bsdd.json
application/checks/__pycache__
application/checks/.pytest_cache
application/checks/tests/test_files
application/decoded.json
application/test_send.py
*.txt
application/ifcopenshell
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "application/bimsurfer"]
path = application/bimsurfer
url = https://github.com/AECgeeks/BIMsurfer2
[submodule "application/checks/ifc-python-parser"]
path = application/checks/ifc-python-parser
url = https://github.com/johltn/ifc-python-parser
[submodule "application/checks/step-file-parser"]
path = application/checks/step-file-parser
url = https://github.com/IfcOpenShell/step-file-parser
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ There is a small web application in Flask that accepts file uploads. HTTPS is pr
./init.sh my.domain.name.com
docker-compose up -d
~~~

## Development notes
Remember to store credentials as environment variables in `/etc/environment`
20 changes: 18 additions & 2 deletions application/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM debian:buster-slim

WORKDIR /
RUN apt-get -y update && apt-get -y --no-install-recommends --no-install-suggests install python3 python3-pip unzip wget libpq-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev npm python3-setuptools python3-dev python3-wheel supervisor
RUN python3 -m pip install flask flask-cors numpy Pillow gunicorn rq redis sqlalchemy psycopg2 sqlalchemy-utils Flask-BasicAuth flasgger requests flask-dropzone
RUN apt-get -y update && apt-get -y --no-install-recommends --no-install-suggests install git python3 python3-pip unzip wget libpq-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev npm python3-setuptools python3-dev python3-wheel supervisor

RUN python3 -m pip install --upgrade pip

RUN python3 -m pip install flask flask-cors numpy Pillow gunicorn rq redis SQLAlchemy==1.3.24 psycopg2 sqlalchemy-utils Flask-BasicAuth flasgger requests flask-dropzone lark-parser pyparsing XlsxWriter fuzzywuzzy python-Levenshtein requests_oauthlib Authlib requests argparse --upgrade
RUN npm install -g jsdoc gltf-pipeline requirejs npx uglify-js

# IfcConvert v0.6.0
Expand All @@ -13,6 +16,7 @@ RUN wget -O /tmp/ifcopenshell_python.zip https://s3.amazonaws.com/ifcopenshell-b
RUN mkdir -p `python3 -c 'import site; print(site.getusersitepackages())'`
RUN unzip -d `python3 -c 'import site; print(site.getusersitepackages())'` /tmp/ifcopenshell_python.zip


# Temporary 'hotfix'
RUN wget -O `python3 -c 'import site; print(site.getusersitepackages())'`/ifcopenshell/validate.py https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcopenshell-python/ifcopenshell/validate.py

Expand All @@ -21,6 +25,18 @@ WORKDIR /www
COPY application/*.py /www/
COPY application/templates /www/templates

COPY application/checks /www/checks
RUN unzip -d /www/checks /tmp/ifcopenshell_python.zip


RUN mkdir -p /www/checks/ifcopenshell/mvd
RUN echo 1
RUN git clone https://github.com/opensourceBIM/python-mvdxml /www/checks/ifcopenshell/mvd

# RUN ls www/checks/ifcopenshell/
# RUN mv python-mvdxml/* www/checks/ifcopenshell/mvd
# RUN ls www/checks/ifcopenshell/

COPY .git/HEAD /tmp/.git/HEAD
COPY .git/refs/ /tmp/.git/refs/
RUN /bin/bash -c '(cat /tmp/.git/$(cat /tmp/.git/HEAD | cut -d \ -f 2)) || cat /tmp/.git/HEAD' > /version
Expand Down
58 changes: 58 additions & 0 deletions application/checks/check_MVD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import ifcopenshell
from ifcopenshell.mvd import mvd
import logging
import json
import sys
import os
import time

def validate_mvd(mvd_fn):
mvd_concept_roots = ifcopenshell.mvd.concept_root.parse(mvd_fn)
passed = 1

for concept_root in mvd_concept_roots:
try: #todo: check mvdXML file schema
entity_type = concept_root.entity
if len(ifc_file.by_type(entity_type)):
entity_instances = ifc_file.by_type(entity_type)
for concept in concept_root.concepts():
for rule in concept.template().rules:

for e in entity_instances:
extraction = mvd.extract_data(rule,e)
for ex in extraction:
print(ex)
for k, v in ex.items():
print(v)
if v == "Nonexistent value":
passed = 0

except:
pass

return passed


if __name__ == "__main__":
start_time = time.time()

ifc_fn = sys.argv[1]
ifc_file = ifcopenshell.open(ifc_fn)

mvd_fn = "./ifcopenshell/mvd/mvd_examples/officials/ReferenceView_V1-2.mvdxml"
mvd_fn= os.path.join(os.path.dirname(__file__), "ifcopenshell/mvd/mvd_examples/officials/ReferenceView_V1-2.mvdxml")
mvd_concept_roots = ifcopenshell.mvd.concept_root.parse(mvd_fn)

jsonresultout = os.path.join(os.getcwd(), "result_mvd.json")
passed = validate_mvd(mvd_fn)
print("--- %s seconds ---" % (time.time() - start_time))

if passed == 1:
mvd_result = {'mvd':'v'}
elif passed == 0:
mvd_result = {'mvd':'i'}


with open(jsonresultout, 'w', encoding='utf-8') as f:
json.dump(mvd_result, f, ensure_ascii=False, indent=4)

158 changes: 158 additions & 0 deletions application/checks/check_bsdd_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import ifcopenshell
import sys
import requests
import json
import argparse
from helper import database



def get_classification_object(uri):
url = "https://bs-dd-api-prototype.azurewebsites.net/api/Classification/v3"
return requests.get(url, {'namespaceUri':uri})

def validate_ifc_classification_reference(relating_classification):
uri = relating_classification.Location
bsdd_response = get_classification_object(uri)
if bsdd_response.status_code != 200:
return 0
elif bsdd_response.status_code == 200:
return bsdd_response

def has_specifications(bsdd_response_content):
if bsdd_response_content["classificationProperties"]:
return 1
else:
return 0

def validate_instance(constraint,ifc_file, instance):

result = {"pset_name":"pset not found","property_name":"pset not found","value":"pset not found","datatype":"pset not found" }
constraint = {
"specified_pset_name":constraint["propertySet"],
"specified_property_name" : constraint["name"],
"specified_datatype" : constraint["dataType"],
"specified_predefined_value" : constraint["predefinedValue"],
}


# Integrate these:
# "maxExclusive": 0
# "maxInclusive": 0
# "minExclusive": 0
# "minInclusive": 0
# "pattern": ""

for definition in instance.IsDefinedBy:
if definition.is_a() == "IfcRelDefinesByProperties":

pset = definition.RelatingPropertyDefinition
if pset.Name == constraint["specified_pset_name"]:
result["property_name"] = "property not found"
result["value"] = "property not found"
result["datatype"] = "property not found"

result = {"pset_name":pset.Name,"property_name":"pset not found","value":"pset not found","datatype":"pset not found" }
for property in pset.HasProperties:
if property.Name == constraint["specified_property_name"]:
result["property_name"] = property.Name

if isinstance(property.NominalValue, ifcopenshell.entity_instance):
result["value"] = property.NominalValue[0]
result["datatype"] = type(property.NominalValue[0])
else:
result["value"] = property.NominalValue
result["datatype"] = type(property.NominalValue[0])



return {"constraint":constraint,"result":result}



def check_bsdd(ifc_fn, task_id):

file_code = ifc_fn.split(".ifc")[0]
ifc_file = ifcopenshell.open(ifc_fn)

with database.Session() as session:
model = session.query(database.model).filter(database.model.code == file_code)[0]
file_id = model.id

n = len(ifc_file.by_type("IfcRelAssociatesClassification"))
if n:
percentages = [i * 100. / n for i in range(n+1)]
num_dots = [int(b) - int(a) for a, b in zip(percentages, percentages[1:])]

for idx, rel in enumerate(ifc_file.by_type("IfcRelAssociatesClassification")):

sys.stdout.write(num_dots[idx] * ".")
sys.stdout.flush()

related_objects = rel.RelatedObjects
relating_classification = rel.RelatingClassification

bsdd_response = validate_ifc_classification_reference(relating_classification)
bsdd_content = json.loads(bsdd_response.text)

for ifc_instance in related_objects:
instance = database.ifc_instance(ifc_instance.GlobalId, ifc_instance.is_a(), file_id)
session.add(instance)
session.flush()
instance_id = instance.id
session.commit()

if bsdd_response:
if has_specifications(bsdd_content):
specifications = bsdd_content["classificationProperties"]
for constraint in specifications:
bsdd_result = database.bsdd_result(task_id)
# Should create instance entry
bsdd_result.instance_id = instance_id

bsdd_result.bsdd_classification_uri = bsdd_content["namespaceUri"]
bsdd_result.bsdd_type_constraint = ";".join(bsdd_content["relatedIfcEntityNames"])
bsdd_result.bsdd_property_constraint = json.dumps(constraint)
bsdd_result.bsdd_property_uri = constraint["propertyNamespaceUri"]

results = validate_instance(constraint, ifc_file, ifc_instance)["result"]

bsdd_result.ifc_property_set = results["pset_name"]
bsdd_result.ifc_property_name = results["property_name"]

if not isinstance(results["datatype"], str):
bsdd_result.ifc_property_type = results["datatype"].__name__
bsdd_result.ifc_property_value = results["value"]

session.add(bsdd_result)
session.commit()
else:
# Record NULL in other fields
bsdd_result = database.bsdd_result(task_id)
bsdd_result.bsdd_property_constraint = "no constraint"
session.add(bsdd_result)
session.commit()
else:
# Record NULL everywhere in bsdd_result
bsdd_result = database.bsdd_result(task_id)
bsdd_result.bsdd_classification_uri = "classification not found"
session.add(bsdd_result)
session.commit()

#todo: implement scores that actually validate or not the model
model = session.query(database.model).filter(database.model.code == file_code)[0]
model.status_bsdd = 'v'
session.commit()

if __name__=="__main__":
parser = argparse.ArgumentParser(description="Generate classified IFC file")
parser.add_argument("--input","-i", default="Duplex_A_20110505.ifc", type=str)
parser.add_argument("--task","-t", default=0, type=int)

args = parser.parse_args()
check_bsdd(args.input, args.task)





5 changes: 5 additions & 0 deletions application/checks/helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os, sys

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

import database
1 change: 1 addition & 0 deletions application/checks/ifc-python-parser
Submodule ifc-python-parser added at a71438
33 changes: 33 additions & 0 deletions application/checks/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys, os
import ifcopenshell
from helper import database

ifc_fn = sys.argv[1]
ifc_file = ifcopenshell.open(ifc_fn)

try:
detected_mvd = ifc_file.header.file_description.description[0].split(" ", 1)[1]
detected_mvd = detected_mvd[1:-1]
except:
detected_mvd = "no MVD detected"

try:
authoring_app = ifc_file.by_type("IfcApplication")[0].ApplicationFullName
except:
authoring_app = 'no authoring app detected'

with database.Session() as session:
model = session.query(database.model).filter(database.model.code == ifc_fn[:-4]).all()[0]
model.size = str(round(os.path.getsize(ifc_fn)*10**-6)) + "MB"
model.schema = ifc_file.schema
model.authoring_application = authoring_app
model.mvd = detected_mvd
model.number_of_elements = len(ifc_file.by_type("IfcBuildingElement"))
model.number_of_geometries = len(ifc_file.by_type("IfcShapeRepresentation"))
model.number_of_properties = len(ifc_file.by_type("IfcProperty"))

session.commit()
session.close()



11 changes: 11 additions & 0 deletions application/checks/tests/test_bsdd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest
import sys
import os

path = os.path.join(os.path.dirname(__file__), "..")
sys.path.insert(1, path)

from check_bSDD import get_domains

def test_domains():
assert len(get_domains()) == 18
21 changes: 21 additions & 0 deletions application/checks/tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest
import sys
import os

import ifcopenshell

path = os.path.join(os.path.dirname(__file__), "../step-file-parser")
sys.path.insert(1, path)

from parse_file import *

def test_parsing():
filepath = os.path.join(os.path.dirname(__file__), "test_files\\Duplex_A_20110505.ifc")
ifc_file = ifcopenshell.open(filepath)

f = open(filepath, "r")
text = f.read()
tree = ifc_parser.parse(text)
entities = process_tree(tree)

assert entities[375]['attributes'][0] == ifc_file.by_id(375).GlobalId
Loading