├── .gitignore
├── .travis.yml
├── COPYING
├── COPYING.LESSER
├── README.md
├── cmake
└── CMakeLists.txt
├── nix
└── build-all.py
├── src
├── examples
│ ├── CMakeLists.txt
│ ├── IfcAdvancedHouse.cpp
│ ├── IfcOpenHouse.cpp
│ ├── IfcParseExamples.cpp
│ ├── arbitrary_open_profile_def.cpp
│ ├── composite_profile_def.cpp
│ ├── csg_primitive.cpp
│ ├── ellipse_pies.cpp
│ ├── faces.cpp
│ ├── ifc_curve_rebar.cpp
│ ├── profiles.cpp
│ ├── suzanne_geometry.h
│ └── triangulated_faceset.cpp
├── ifcblender
│ └── io_import_scene_ifc
│ │ └── __init__.py
├── ifcconvert
│ ├── ColladaSerializer.cpp
│ ├── ColladaSerializer.h
│ ├── GeometrySerializer.h
│ ├── IfcConvert.cpp
│ ├── IgesSerializer.h
│ ├── OpenCascadeBasedSerializer.cpp
│ ├── OpenCascadeBasedSerializer.h
│ ├── Serializer.h
│ ├── StepSerializer.h
│ ├── SvgSerializer.cpp
│ ├── SvgSerializer.h
│ ├── WavefrontObjSerializer.cpp
│ ├── WavefrontObjSerializer.h
│ ├── XmlSerializer.cpp
│ ├── XmlSerializer.h
│ ├── util.cpp
│ └── util.h
├── ifcexpressparser
│ ├── DocAttribute.csv
│ ├── DocDefined.csv
│ ├── DocEntity.csv
│ ├── DocEntityAttributes.csv
│ ├── DocEnumeration.csv
│ ├── DocSelect.csv
│ ├── README.txt
│ ├── bootstrap.py
│ ├── codegen.py
│ ├── documentation.py
│ ├── enum_header.py
│ ├── express.bnf
│ ├── header.py
│ ├── implementation.py
│ ├── latebound_header.py
│ ├── latebound_implementation.py
│ ├── mapping.py
│ ├── nodes.py
│ ├── schema.py
│ └── templates.py
├── ifcgeom
│ ├── ConversionResult.h
│ ├── IfcGeom.h
│ ├── IfcGeomAbstractKernel.cpp
│ ├── IfcGeomElement.h
│ ├── IfcGeomIterator.h
│ ├── IfcGeomIteratorSettings.h
│ ├── IfcGeomMaterial.cpp
│ ├── IfcGeomMaterial.h
│ ├── IfcGeomRenderStyles.cpp
│ ├── IfcGeomRenderStyles.h
│ ├── IfcGeomRepresentation.h
│ ├── IfcGeomShapeType.h
│ ├── ifc_geom_api.h
│ └── kernels
│ │ ├── cgal
│ │ ├── CgalConversionFunctions.cpp
│ │ ├── CgalConversionResult.cpp
│ │ ├── CgalConversionResult.h
│ │ ├── CgalEntityMapping.cpp
│ │ ├── CgalEntityMapping.h
│ │ ├── CgalEntityMappingCreateCache.h
│ │ ├── CgalEntityMappingCurve.h
│ │ ├── CgalEntityMappingDeclaration.h
│ │ ├── CgalEntityMappingDefine.h
│ │ ├── CgalEntityMappingFace.h
│ │ ├── CgalEntityMappingPurgeCache.h
│ │ ├── CgalEntityMappingShape.h
│ │ ├── CgalEntityMappingShapeType.h
│ │ ├── CgalEntityMappingShapes.h
│ │ ├── CgalEntityMappingUndefine.h
│ │ ├── CgalEntityMappingWire.h
│ │ ├── CgalIfcGeomCurves.cpp
│ │ ├── CgalIfcGeomFaces.cpp
│ │ ├── CgalIfcGeomPrimitives.cpp
│ │ ├── CgalIfcGeomShapes.cpp
│ │ ├── CgalIfcGeomShapesWithStyles.cpp
│ │ ├── CgalIfcGeomWires.cpp
│ │ ├── CgalKernel.cpp
│ │ └── CgalKernel.h
│ │ └── opencascade
│ │ ├── EntityMapping.cpp
│ │ ├── EntityMapping.h
│ │ ├── EntityMappingCreateCache.h
│ │ ├── EntityMappingCurve.h
│ │ ├── EntityMappingDeclaration.h
│ │ ├── EntityMappingDefine.h
│ │ ├── EntityMappingFace.h
│ │ ├── EntityMappingPurgeCache.h
│ │ ├── EntityMappingShape.h
│ │ ├── EntityMappingShapeType.h
│ │ ├── EntityMappingShapes.h
│ │ ├── EntityMappingUndefine.h
│ │ ├── EntityMappingWire.h
│ │ ├── IfcGeomCurves.cpp
│ │ ├── IfcGeomFaces.cpp
│ │ ├── IfcGeomFunctions.cpp
│ │ ├── IfcGeomHelpers.cpp
│ │ ├── IfcGeomOpenCascadeSerialization.cpp
│ │ ├── IfcGeomSerialisation.cpp
│ │ ├── IfcGeomShapes.cpp
│ │ ├── IfcGeomWires.cpp
│ │ ├── OpenCascadeConversionResult.h
│ │ ├── OpenCascadeKernel.h
│ │ ├── OpenCascadeSerialization.h
│ │ └── OpenCascadeShape.cpp
├── ifcgeomserver
│ ├── IfcGeomServer.cpp
│ └── README.md
├── ifcjni
│ ├── IfcJni.cpp
│ └── org_ifcopenshell_IfcOpenShellModel.h
├── ifcmax
│ ├── CMakeLists.txt
│ ├── IfcMax.cpp
│ └── IfcMax.h
├── ifcopenshell-python
│ └── ifcopenshell
│ │ ├── __init__.py
│ │ ├── entity_instance.py
│ │ ├── file.py
│ │ ├── geom
│ │ ├── __init__.py
│ │ ├── app.py
│ │ ├── code_editor_pane.py
│ │ ├── main.py
│ │ └── occ_utils.py
│ │ └── guid.py
├── ifcparse
│ ├── Ifc2x3-latebound.cpp
│ ├── Ifc2x3-latebound.h
│ ├── Ifc2x3.cpp
│ ├── Ifc2x3.h
│ ├── Ifc2x3enum.h
│ ├── Ifc4-latebound.cpp
│ ├── Ifc4-latebound.h
│ ├── Ifc4.cpp
│ ├── Ifc4.h
│ ├── Ifc4enum.h
│ ├── IfcCharacterDecoder.cpp
│ ├── IfcCharacterDecoder.h
│ ├── IfcEntityDescriptor.h
│ ├── IfcException.h
│ ├── IfcFile.h
│ ├── IfcGlobalId.cpp
│ ├── IfcGlobalId.h
│ ├── IfcHierarchyHelper.cpp
│ ├── IfcHierarchyHelper.h
│ ├── IfcLateBoundEntity.cpp
│ ├── IfcLateBoundEntity.h
│ ├── IfcLogger.cpp
│ ├── IfcLogger.h
│ ├── IfcParse.cpp
│ ├── IfcParse.h
│ ├── IfcSIPrefix.cpp
│ ├── IfcSIPrefix.h
│ ├── IfcSpfHeader.cpp
│ ├── IfcSpfHeader.h
│ ├── IfcSpfStream.h
│ ├── IfcUtil.cpp
│ ├── IfcUtil.h
│ ├── IfcWritableEntity.h
│ ├── IfcWrite.cpp
│ ├── IfcWrite.h
│ └── ifc_parse_api.h
├── ifcwrap
│ ├── CMakeLists.txt
│ ├── IfcGeomWrapper.i
│ ├── IfcParseWrapper.i
│ ├── IfcPython.i
│ └── utils
│ │ ├── type_conversion.i
│ │ ├── typemaps_in.i
│ │ └── typemaps_out.i
└── qtviewer
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── mainwindow.cpp
│ └── mainwindow.h
├── test
├── bpy.py
├── input
│ ├── IfcArbitraryOpenProfileDef.ifc
│ ├── IfcCShapeProfileDef.ifc
│ ├── IfcCircleProfileDef.ifc
│ ├── IfcCompositeProfileDef.ifc
│ ├── IfcCsgPrimitive.ifc
│ ├── IfcEllipseProfileDef.ifc
│ ├── IfcIShapeProfileDef.ifc
│ ├── IfcLShapeProfileDef.ifc
│ ├── IfcRectangleProfileDef.ifc
│ ├── IfcReinforcingBar.ifc
│ ├── IfcTShapeProfileDef.ifc
│ ├── IfcTrapeziumProfileDef.ifc
│ ├── IfcUShapeProfileDef.ifc
│ ├── IfcZShapeProfileDef.ifc
│ ├── acad2010_objects.ifc
│ ├── acad2010_walls.ifc
│ ├── advanced_brep.ifc
│ ├── basic_shape_Brep.ifc
│ ├── basic_shape_CSG.ifc
│ ├── basic_shape_SurfaceModel.ifc
│ ├── basic_shape_SweptSolid.ifc
│ ├── basic_shape_Tessellation.ifc
│ ├── building_element_configuration_wall.ifc
│ ├── building_service_element_air-terminal-type.ifc
│ ├── building_service_element_air-terminal.ifc
│ ├── construction_scheduling_task.ifc
│ ├── ellipse_pies.ifc
│ ├── faces.ifc
│ ├── faceted_brep.ifc
│ ├── faceted_brep_csg.ifc
│ ├── geometrygym_great_court_roof.ifc
│ ├── ifcopenshell_halfspaces.ifc
│ ├── large_offset.ifc
│ ├── mapped_circle.ifc
│ ├── mapped_item_style.ifc
│ ├── mapped_shape_multiple.ifc
│ ├── mapped_shape_representation.ifc
│ ├── mapped_shape_transformation.ifc
│ ├── nested_mapped_item.ifc
│ ├── revit2011_wall1.ifc
│ ├── revit2011_wall2.ifc
│ ├── revit2012_janesville_restaurant.zip
│ ├── revit2014_multiple_bounded_halfspaces.ifc
│ ├── standard_case_element_beam.ifc
│ ├── structural_analysis_curve.ifc
│ └── tesselated_faceset.ifc
└── run.py
└── win
├── build-all.cmd
├── build-deps.cmd
├── build-deps.sh
├── build-ifcopenshell.bat
├── build-ifcopenshell.sh
├── build-type-cfg.cmd
├── install-ifcopenshell.bat
├── install-ifcopenshell.sh
├── patches
├── OpenCOLLADA_CMakeLists.txt.patch
├── occt-V7_0_0-9059ca1_CMakeLists.txt
├── occt-V7_0_0-9059ca1_OpenGl_PrimitiveArray.cxx
├── occt-V7_0_0-9059ca1_XCAFDoc_Dimension.cxx
├── occt-V7_0_0-9059ca1_XCAFDoc_GeomTolerance.cxx
├── occt-V7_0_0-9059ca1_occt_defs_flags.cmake
└── occt-V7_0_0-9059ca1_occt_toolkit.cmake
├── readme.md
├── run-cmake.bat
├── run-cmake.sh
├── set-python-to-path.bat
├── utils
├── 7za.exe
├── cecho.cmd
└── license.txt
└── vs-cfg.cmd
/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependency and build folders created by the build scripts
2 | /deps*/
3 | /build*/
4 | /install*/
5 | /win/BuildDepsCache*.txt
6 | # IfcExpressParser residue
7 | /src/ifcexpressparser/express_parser.py
8 | # General Python residue
9 | __pycache__
10 | # Visual Studio Code files
11 | .vscode
12 | # Mac metadata
13 | .DS_Store
14 | # Conversion results
15 | /test/input/*.obj
16 | /test/input/*.mtl
17 | /test/input/*.tmp
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 | compiler: gcc
3 | os: linux
4 | dist: xenial
5 | sudo: required
6 |
7 |
8 | before_install:
9 | - sudo apt-get update -qq
10 |
11 |
12 | install:
13 | - sudo apt-get install -qq gcc-4.8 g++-4.8
14 |
15 | - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90
16 | - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
17 |
18 | - sudo apt-get install -y libboost-dev
19 | - sudo apt-get install -y libboost-regex-dev
20 | - sudo apt-get install -y libboost-system-dev
21 | - sudo apt-get install -y libboost-thread-dev
22 | - sudo apt-get install -y libboost-program-options-dev
23 | - sudo apt-get install -y cmake
24 | - sudo apt-get install -y libicu-dev
25 | - sudo apt-get install -y python-all-dev
26 | - sudo apt-get install -y swig
27 | - sudo apt-get install -y liboce-foundation-dev
28 | - sudo apt-get install -y liboce-modeling-dev
29 | - sudo apt-get install -y liboce-ocaf-dev
30 | - sudo apt-get install -y liboce-visualization-dev
31 | - sudo apt-get install -y liboce-ocaf-lite-dev
32 |
33 | - sudo apt-get install -y libpcre3-dev
34 |
35 | - sudo apt-get install -y libcgal-dev libmpfr-dev libgmp-dev
36 |
37 | script:
38 | - pwd
39 | - cd ..
40 | - git clone https://github.com/KhronosGroup/OpenCOLLADA.git
41 | - cd OpenCOLLADA
42 | - git checkout 064a60b65c2c31b94f013820856bc84fb1937cc6
43 | - mkdir build
44 | - cd build
45 | - cmake ..
46 | - make
47 | - sudo make install
48 | - cd ..
49 | - cd ..
50 | - pwd
51 | - cd IfcOpenShell_CGAL
52 | - pwd
53 | - cd cmake
54 | - mkdir build-ifc2x3 build-ifc4
55 | - cd build-ifc2x3
56 | - cmake -DCOLLADA_SUPPORT=True -DOPENCOLLADA_INCLUDE_DIR=/usr/local/include/opencollada -DOPENCOLLADA_LIBRARY_DIR=/usr/local/lib/opencollada -DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DUSE_IFC4=False -DBUILD_IFCPYTHON=True -DUNICODE_SUPPORT=True -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DGMP_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ -DMPFR_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ ..
57 | - make -j IfcConvert
58 | - cd ../build-ifc4
59 | - cmake -DCOLLADA_SUPPORT=True -DOPENCOLLADA_INCLUDE_DIR=/usr/local/include/opencollada -DOPENCOLLADA_LIBRARY_DIR=/usr/local/lib/opencollada -DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DUSE_IFC4=True -DBUILD_IFCPYTHON=True -DUNICODE_SUPPORT=True -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DGMP_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ -DMPFR_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ ..
60 | - make -j IfcConvert
61 |
--------------------------------------------------------------------------------
/src/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ################################################################################
19 |
20 | ADD_EXECUTABLE(IfcParseExamples IfcParseExamples.cpp)
21 | TARGET_LINK_LIBRARIES(IfcParseExamples IfcParse)
22 | set_target_properties(IfcParseExamples PROPERTIES FOLDER Examples)
23 |
24 | ADD_EXECUTABLE(IfcOpenHouse IfcOpenHouse.cpp)
25 | TARGET_LINK_LIBRARIES(IfcOpenHouse ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES})
26 | set_target_properties(IfcOpenHouse PROPERTIES FOLDER Examples)
27 |
28 | ADD_EXECUTABLE(IfcAdvancedHouse IfcAdvancedHouse.cpp)
29 | TARGET_LINK_LIBRARIES(IfcAdvancedHouse ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES})
30 | set_target_properties(IfcAdvancedHouse PROPERTIES FOLDER Examples)
31 |
--------------------------------------------------------------------------------
/src/examples/IfcParseExamples.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #include "../ifcparse/IfcFile.h"
21 |
22 | #if USE_VLD
23 | #include
24 | #endif
25 |
26 | using namespace IfcSchema;
27 |
28 | int main(int argc, char** argv) {
29 |
30 | if ( argc != 2 ) {
31 | std::cout << "usage: IfcParseExamples " << std::endl;
32 | return 1;
33 | }
34 |
35 | // Redirect the output (both progress and log) to stdout
36 | Logger::SetOutput(&std::cout,&std::cout);
37 |
38 | // Parse the IFC file provided in argv[1]
39 | IfcParse::IfcFile file;
40 | if ( ! file.Init(argv[1]) ) {
41 | std::cout << "Unable to parse .ifc file" << std::endl;
42 | return 1;
43 | }
44 |
45 | // Lets get a list of IfcBuildingElements, this is the parent
46 | // type of things like walls, windows and doors.
47 | // entitiesByType is a templated function and returns a
48 | // templated class that behaves like a std::vector.
49 | // Note that the return types are all typedef'ed as members of
50 | // the generated classes, ::list for the templated vector class,
51 | // ::ptr for a shared pointer and ::it for an iterator.
52 | // We will simply iterate over the vector and print a string
53 | // representation of the entity to stdout.
54 | //
55 | // Secondly, lets find out which of them are IfcWindows.
56 | // In order to access the additional properties that windows
57 | // have on top af the properties of building elements,
58 | // we need to cast them to IfcWindows. Since these properties
59 | // are optional we need to make sure the properties are
60 | // defined for the window in question before accessing them.
61 | IfcBuildingElement::list::ptr elements = file.entitiesByType();
62 |
63 | std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << std::endl;
64 |
65 | for ( IfcBuildingElement::list::it it = elements->begin(); it != elements->end(); ++ it ) {
66 |
67 | const IfcBuildingElement* element = *it;
68 | std::cout << element->entity->toString() << std::endl;
69 |
70 | if ( element->is(IfcWindow::Class()) ) {
71 | const IfcWindow* window = (IfcWindow*)element;
72 |
73 | if ( window->hasOverallWidth() && window->hasOverallHeight() ) {
74 | const double area = window->OverallWidth()*window->OverallHeight();
75 | std::cout << "The area of this window is " << area << std::endl;
76 | }
77 | }
78 |
79 | }
80 |
81 | }
--------------------------------------------------------------------------------
/src/examples/triangulated_faceset.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | /********************************************************************************
21 | * *
22 | * Example that generates an IfcTriangulatedFaceSet *
23 | * *
24 | ********************************************************************************/
25 |
26 | #include "../ifcparse/Ifc4.h"
27 | #include "../ifcparse/IfcUtil.h"
28 | #include "../ifcparse/IfcHierarchyHelper.h"
29 |
30 | #include "suzanne_geometry.h"
31 |
32 | typedef std::string S;
33 | typedef IfcParse::IfcGlobalId guid;
34 | boost::none_t const null = (static_cast(0));
35 |
36 | template
37 | std::vector< std::vector > create_vector_from_array(const T* arr, unsigned size) {
38 | std::vector< std::vector > result;
39 | result.reserve(size);
40 |
41 | for (unsigned i = 0; i < size; ) {
42 | std::vector ts; ts.reserve(3);
43 | for (unsigned j = 0; j < 3; ++i, ++j) {
44 | ts.push_back(arr[i]);
45 | }
46 | result.push_back(ts);
47 | }
48 |
49 | return result;
50 | }
51 |
52 | int main(int argc, char** argv) {
53 | IfcHierarchyHelper file;
54 |
55 | IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy(
56 | guid(), 0, S("Blender's Suzanne"), null, null, 0, 0, null, null);
57 | file.addBuildingProduct(product);
58 | product->setOwnerHistory(file.getSingle());
59 |
60 | product->setObjectPlacement(file.addLocalPlacement());
61 |
62 | IfcSchema::IfcRepresentation::list::ptr reps (new IfcSchema::IfcRepresentation::list);
63 | IfcSchema::IfcRepresentationItem::list::ptr items (new IfcSchema::IfcRepresentationItem::list);
64 |
65 | std::vector< std::vector< double > > vertices_vector = create_vector_from_array(vertices, sizeof(vertices) / sizeof(vertices[0]));
66 | std::vector< std::vector< int > > indices_vector = create_vector_from_array(indices, sizeof(indices) / sizeof(indices[0]));
67 |
68 | IfcSchema::IfcCartesianPointList3D* coordinates = new IfcSchema::IfcCartesianPointList3D(vertices_vector);
69 | IfcSchema::IfcTriangulatedFaceSet* faceset = new IfcSchema::IfcTriangulatedFaceSet(coordinates, null, null, indices_vector, null);
70 |
71 | items->push(faceset);
72 | IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(
73 | file.getRepresentationContext("Model"), S("Body"), S("SurfaceModel"), items);
74 | reps->push(rep);
75 |
76 | IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps);
77 | file.addEntity(shape);
78 |
79 | product->setRepresentation(shape);
80 |
81 | const std::string filename = "tesselated_faceset.ifc";
82 | file.header().file_name().name(filename);
83 | std::ofstream f(filename.c_str());
84 | f << file;
85 | }
86 |
--------------------------------------------------------------------------------
/src/ifcconvert/GeometrySerializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef GEOMETRYSERIALIZER_H
21 | #define GEOMETRYSERIALIZER_H
22 |
23 | #ifdef IFCCONVERT_DOUBLE_PRECISION
24 | typedef double real_t;
25 | #else
26 | typedef float real_t;
27 | #endif
28 |
29 | #include "../ifcconvert/Serializer.h"
30 | #include "../ifcgeom/IfcGeomIterator.h"
31 |
32 | class GeometrySerializer : public Serializer {
33 | public:
34 | GeometrySerializer(const IfcGeom::IteratorSettings &settings) : settings_(settings) {}
35 | virtual ~GeometrySerializer() {}
36 |
37 | virtual bool isTesselated() const = 0;
38 | virtual void write(const IfcGeom::TriangulationElement* o) = 0;
39 | virtual void write(const IfcGeom::NativeElement* o) = 0;
40 | virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) = 0;
41 |
42 | const IfcGeom::IteratorSettings& settings() const { return settings_; }
43 | IfcGeom::IteratorSettings& settings() { return settings_; }
44 |
45 | protected:
46 | IfcGeom::IteratorSettings settings_;
47 | };
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/src/ifcconvert/IgesSerializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IGESSERIALIZER_H
21 | #define IGESSERIALIZER_H
22 |
23 | #include "OpenCascadeBasedSerializer.h"
24 |
25 | #include
26 | #include
27 |
28 | #include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
29 |
30 | class IgesSerializer : public OpenCascadeBasedSerializer
31 | {
32 | private:
33 | IGESControl_Writer writer;
34 | public:
35 | /// @note IGESControl_Controller::Init() must be called prior to instantiating IgesSerializer.
36 | /// See http://tracker.dev.opencascade.org/view.php?id=23679 for more information.
37 | IgesSerializer(const std::string& out_filename, const IfcGeom::IteratorSettings &settings)
38 | : OpenCascadeBasedSerializer(out_filename, settings)
39 | {}
40 | virtual ~IgesSerializer() {}
41 | void writeShape(const IfcGeom::ConversionResultShape* shape) {
42 | writer.AddShape(*(IfcGeom::OpenCascadeShape*)shape);
43 | }
44 | void finalize() {
45 | writer.Write(out_filename.c_str());
46 | }
47 | void setUnitNameAndMagnitude(const std::string& /*name*/, float magnitude) {
48 | const char* symbol = getSymbolForUnitMagnitude(magnitude);
49 | if (symbol) {
50 | Interface_Static::SetCVal("xstep.cascade.unit", symbol);
51 | Interface_Static::SetCVal("write.iges.unit", symbol);
52 | }
53 | }
54 | };
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/src/ifcconvert/OpenCascadeBasedSerializer.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 | #include
26 |
27 | #include "OpenCascadeBasedSerializer.h"
28 | #include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
29 | #include "../ifcgeom/kernels/opencascade/OpenCascadeKernel.h"
30 |
31 | bool OpenCascadeBasedSerializer::ready() {
32 | std::ofstream test_file(out_filename.c_str(), std::ios_base::binary);
33 | bool succeeded = test_file.is_open();
34 | test_file.close();
35 | remove(out_filename.c_str());
36 | return succeeded;
37 | }
38 |
39 | void OpenCascadeBasedSerializer::write(const IfcGeom::NativeElement* o) {
40 | for (IfcGeom::ConversionResults::const_iterator it = o->geometry().begin(); it != o->geometry().end(); ++ it) {
41 | gp_GTrsf gtrsf = *(IfcGeom::OpenCascadePlacement*) it->Placement();
42 |
43 | const gp_GTrsf& o_trsf = *(IfcGeom::OpenCascadePlacement*) o->transformation().data();
44 | gtrsf.PreMultiply(o_trsf);
45 |
46 | if (o->geometry().settings().get(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS)) {
47 | gp_Trsf scale;
48 | scale.SetScaleFactor(1.0 / o->geometry().settings().unit_magnitude());
49 | gtrsf.PreMultiply(scale);
50 | }
51 |
52 | const TopoDS_Shape& s = *(IfcGeom::OpenCascadeShape*) it->Shape();
53 | const TopoDS_Shape moved_shape = IfcGeom::OpenCascadeKernel::apply_transformation(s, gtrsf);
54 |
55 | IfcGeom::OpenCascadeShape shp(moved_shape);
56 | writeShape(&shp);
57 | }
58 | }
59 |
60 | #define RATHER_SMALL (1e-3)
61 | #define APPROXIMATELY_THE_SAME(a,b) (fabs(a-b) < RATHER_SMALL)
62 |
63 | const char* OpenCascadeBasedSerializer::getSymbolForUnitMagnitude(float mag) {
64 | if (APPROXIMATELY_THE_SAME(mag, 0.001f)) {
65 | return "MM";
66 | } else if (APPROXIMATELY_THE_SAME(mag, 0.01f)) {
67 | return "CM";
68 | } else if (APPROXIMATELY_THE_SAME(mag, 1.0f)) {
69 | return "M";
70 | } else if (APPROXIMATELY_THE_SAME(mag, 0.3048f)) {
71 | return "FT";
72 | } else if (APPROXIMATELY_THE_SAME(mag, 0.0254f)) {
73 | return "INCH";
74 | } else {
75 | return 0;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/ifcconvert/OpenCascadeBasedSerializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef OPENCASCADEBASEDSERIALIZER_H
21 | #define OPENCASCADEBASEDSERIALIZER_H
22 |
23 | #include "../ifcgeom/IfcGeomIterator.h"
24 |
25 | #include "../ifcconvert/GeometrySerializer.h"
26 |
27 | class OpenCascadeBasedSerializer : public GeometrySerializer {
28 | OpenCascadeBasedSerializer(const OpenCascadeBasedSerializer&); //N/A
29 | OpenCascadeBasedSerializer& operator =(const OpenCascadeBasedSerializer&); //N/A
30 | protected:
31 | const std::string out_filename;
32 | const char* getSymbolForUnitMagnitude(float mag);
33 | public:
34 | explicit OpenCascadeBasedSerializer(const std::string& out_filename, const IfcGeom::IteratorSettings &settings)
35 | : GeometrySerializer(settings)
36 | , out_filename(out_filename)
37 | {}
38 | virtual ~OpenCascadeBasedSerializer() {}
39 | void writeHeader() {}
40 | bool ready();
41 | virtual void writeShape(const IfcGeom::ConversionResultShape* shape) = 0;
42 | void write(const IfcGeom::TriangulationElement* /*o*/) {}
43 | void write(const IfcGeom::NativeElement* o);
44 | bool isTesselated() const { return false; }
45 | void setFile(IfcParse::IfcFile*) {}
46 | };
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/ifcconvert/Serializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef SERIALIZER_H
21 | #define SERIALIZER_H
22 |
23 | #include "../ifcparse/IfcFile.h"
24 |
25 | class Serializer {
26 | public:
27 | virtual ~Serializer() {}
28 |
29 | virtual bool ready() = 0;
30 | virtual void writeHeader() = 0;
31 | virtual void finalize() = 0;
32 | virtual void setFile(IfcParse::IfcFile*) = 0;
33 | };
34 |
35 | #endif
--------------------------------------------------------------------------------
/src/ifcconvert/StepSerializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef STEPSERIALIZER_H
21 | #define STEPSERIALIZER_H
22 |
23 | #include
24 | #include
25 |
26 | #include "../ifcgeom/IfcGeomIterator.h"
27 |
28 | #include "../ifcconvert/OpenCascadeBasedSerializer.h"
29 | #include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
30 |
31 | class StepSerializer : public OpenCascadeBasedSerializer
32 | {
33 | private:
34 | STEPControl_Writer writer;
35 | public:
36 | explicit StepSerializer(const std::string& out_filename, const IfcGeom::IteratorSettings &settings)
37 | : OpenCascadeBasedSerializer(out_filename, settings)
38 | {}
39 | virtual ~StepSerializer() {}
40 | void writeShape(const IfcGeom::ConversionResultShape* shape) {
41 | std::stringstream ss;
42 | std::streambuf *sb = std::cout.rdbuf(ss.rdbuf());
43 | writer.Transfer(*(IfcGeom::OpenCascadeShape*)shape, STEPControl_AsIs);
44 | std::cout.rdbuf(sb);
45 | }
46 | void finalize() {
47 | std::stringstream ss;
48 | std::streambuf *sb = std::cout.rdbuf(ss.rdbuf());
49 | writer.Write(out_filename.c_str());
50 | std::cout.rdbuf(sb);
51 | }
52 | void setUnitNameAndMagnitude(const std::string& /*name*/, float magnitude) {
53 | const char* symbol = getSymbolForUnitMagnitude(magnitude);
54 | if (symbol) {
55 | Interface_Static::SetCVal("xstep.cascade.unit", symbol);
56 | Interface_Static::SetCVal("write.step.unit", symbol);
57 | }
58 | }
59 | };
60 |
61 | #endif
--------------------------------------------------------------------------------
/src/ifcconvert/SvgSerializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * Copyright 2015 IfcOpenShell and ROOT B.V. *
4 | * *
5 | * This file is part of IfcOpenShell. *
6 | * *
7 | * IfcOpenShell is free software: you can redistribute it and/or modify *
8 | * it under the terms of the Lesser GNU General Public License as published by *
9 | * the Free Software Foundation, either version 3.0 of the License, or *
10 | * (at your option) any later version. *
11 | * *
12 | * IfcOpenShell is distributed in the hope that it will be useful, *
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 | * Lesser GNU General Public License for more details. *
16 | * *
17 | * You should have received a copy of the Lesser GNU General Public License *
18 | * along with this program. If not, see . *
19 | * *
20 | ********************************************************************************/
21 |
22 | #ifndef SVGSERIALIZER_H
23 | #define SVGSERIALIZER_H
24 |
25 | #include "../ifcconvert/GeometrySerializer.h"
26 | #include "../ifcconvert/util.h"
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | class SvgSerializer : public GeometrySerializer {
33 | public:
34 | typedef std::pair > path_object;
35 | protected:
36 | std::ofstream svg_file;
37 | double xmin, ymin, xmax, ymax, width, height;
38 | boost::optional section_height;
39 | bool rescale;
40 | std::multimap paths;
41 | std::vector< boost::shared_ptr > xcoords;
42 | std::vector< boost::shared_ptr > ycoords;
43 | std::vector< boost::shared_ptr > radii;
44 | IfcParse::IfcFile* file;
45 | public:
46 | SvgSerializer(const std::string& out_filename, const IfcGeom::IteratorSettings &settings)
47 | : GeometrySerializer(settings)
48 | , svg_file(out_filename.c_str())
49 | , xmin(+std::numeric_limits::infinity())
50 | , ymin(+std::numeric_limits::infinity())
51 | , xmax(-std::numeric_limits::infinity())
52 | , ymax(-std::numeric_limits::infinity())
53 | , rescale(false)
54 | , file(0)
55 | {}
56 | void addXCoordinate(const boost::shared_ptr& fi) { xcoords.push_back(fi); }
57 | void addYCoordinate(const boost::shared_ptr& fi) { ycoords.push_back(fi); }
58 | void addSizeComponent(const boost::shared_ptr& fi) { radii.push_back(fi); }
59 | void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; }
60 | void writeHeader();
61 | bool ready();
62 | void write(const IfcGeom::TriangulationElement* /*o*/) {}
63 | void write(const IfcGeom::NativeElement* o);
64 | void write(path_object& p, const TopoDS_Wire& wire);
65 | path_object& start_path(IfcSchema::IfcBuildingStorey* storey, const std::string& id);
66 | bool isTesselated() const { return false; }
67 | void finalize();
68 | void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
69 | void setFile(IfcParse::IfcFile* f) { file = f; }
70 | void setBoundingRectangle(double width, double height);
71 | void setSectionHeight(double h) { section_height = h; }
72 | std::string nameElement(const IfcGeom::Element* elem);
73 | std::string nameElement(const IfcSchema::IfcProduct* elem);
74 | };
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/src/ifcconvert/WavefrontObjSerializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef WAVEFRONTOBJSERIALIZER_H
21 | #define WAVEFRONTOBJSERIALIZER_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include "../ifcconvert/GeometrySerializer.h"
28 |
29 | // http://people.sc.fsu.edu/~jburkardt/txt/obj_format.txt
30 | class WaveFrontOBJSerializer : public GeometrySerializer {
31 | private:
32 | const std::string mtl_filename;
33 | std::ofstream obj_stream;
34 | std::ofstream mtl_stream;
35 | unsigned int vcount_total;
36 | std::set materials;
37 | public:
38 | WaveFrontOBJSerializer(const std::string& obj_filename, const std::string& mtl_filename, const IfcGeom::IteratorSettings &settings)
39 | : GeometrySerializer(settings)
40 | , mtl_filename(mtl_filename)
41 | , obj_stream(obj_filename.c_str())
42 | , mtl_stream(mtl_filename.c_str())
43 | , vcount_total(1)
44 | {}
45 | virtual ~WaveFrontOBJSerializer() {}
46 | bool ready();
47 | void writeHeader();
48 | void writeMaterial(const IfcGeom::Material& style);
49 | void write(const IfcGeom::TriangulationElement* o);
50 | void write(const IfcGeom::NativeElement* /*o*/) {}
51 | void finalize() {}
52 | bool isTesselated() const { return true; }
53 | void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
54 | void setFile(IfcParse::IfcFile*) {}
55 | };
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/src/ifcconvert/XmlSerializer.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef XMLSERIALIZER_H
21 | #define XMLSERIALIZER_H
22 |
23 | #include "../ifcconvert/Serializer.h"
24 |
25 | class XmlSerializer : public Serializer {
26 | private:
27 | IfcParse::IfcFile* file;
28 | std::string xml_filename;
29 | public:
30 | XmlSerializer(const std::string& xml_filename)
31 | : Serializer()
32 | , xml_filename(xml_filename)
33 | {}
34 |
35 | bool ready() { return true; }
36 | void writeHeader() {}
37 | void finalize();
38 | void setFile(IfcParse::IfcFile* f) { file = f; }
39 | };
40 |
41 | #endif
--------------------------------------------------------------------------------
/src/ifcconvert/util.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #include
21 | #include
22 |
23 | #include "../ifcconvert/util.h"
24 |
25 | using namespace util;
26 |
27 | boost::shared_ptr string_buffer::add(const std::string& s) {
28 | boost::shared_ptr i = boost::shared_ptr(new string_item(s));
29 | items.push_back(i);
30 | return i;
31 | }
32 | boost::shared_ptr string_buffer::add(const double& d) {
33 | boost::shared_ptr i = boost::shared_ptr(new float_item(d));
34 | items.push_back(i);
35 | return i;
36 | }
37 | std::string string_buffer::str() const {
38 | std::stringstream ss;
39 | for (std::vector< boost::shared_ptr- >::const_iterator it = items.begin(); it != items.end(); ++it) {
40 | ss << (**it).str();
41 | }
42 | return ss.str();
43 | }
44 |
--------------------------------------------------------------------------------
/src/ifcconvert/util.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCCONVERT_UTIL_H
21 | #define IFCCONVERT_UTIL_H
22 |
23 | #include
24 | #include
25 |
26 | #include
27 |
28 | namespace util {
29 | class string_buffer {
30 | public:
31 | class item {
32 | public:
33 | virtual std::string str() const = 0;
34 | virtual ~item() {};
35 | };
36 | class string_item : public item {
37 | std::string s;
38 | public:
39 | string_item(const std::string& s) : s(s) {}
40 | void assign(const std::string& s) { this->s = s; }
41 | const std::string& value() const { return s; }
42 | std::string& value() { return s; }
43 | std::string str() const { return s; }
44 | virtual ~string_item() {};
45 | };
46 | class float_item : public item {
47 | double d;
48 | public:
49 | float_item(const double& d) : d(d) {}
50 | void assign(const double& d) { this->d = d; }
51 | const double& value() const { return d; }
52 | double& value() { return d; }
53 | std::string str() const { std::stringstream ss; ss << d; return ss.str(); }
54 | virtual ~float_item() {};
55 | };
56 | private:
57 | std::vector< boost::shared_ptr
- > items;
58 | void clear();
59 | void assign(const std::vector< boost::shared_ptr
- >& other);
60 | public:
61 | boost::shared_ptr add(const std::string& s);
62 | boost::shared_ptr add(const double& d);
63 | std::string str() const;
64 | };
65 | }
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/src/ifcexpressparser/DocDefined.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aothms/IfcOpenShell_CGAL/9ae55ab303ec366a255be214434282cfe5b5140a/src/ifcexpressparser/DocDefined.csv
--------------------------------------------------------------------------------
/src/ifcexpressparser/DocEntity.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aothms/IfcOpenShell_CGAL/9ae55ab303ec366a255be214434282cfe5b5140a/src/ifcexpressparser/DocEntity.csv
--------------------------------------------------------------------------------
/src/ifcexpressparser/DocEnumeration.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aothms/IfcOpenShell_CGAL/9ae55ab303ec366a255be214434282cfe5b5140a/src/ifcexpressparser/DocEnumeration.csv
--------------------------------------------------------------------------------
/src/ifcexpressparser/DocSelect.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aothms/IfcOpenShell_CGAL/9ae55ab303ec366a255be214434282cfe5b5140a/src/ifcexpressparser/DocSelect.csv
--------------------------------------------------------------------------------
/src/ifcexpressparser/README.txt:
--------------------------------------------------------------------------------
1 | This folder contains Python code to generate C++ type information based on an
2 | Express schema. In particular is has only been tested using recent version of
3 | the IFC schema and will most likely fail on any other Express schema.
4 |
5 | The code can be invoked in the following way and results in two header files
6 | and a single implementation file named according to the schema name in the
7 | Express file. A python 3 interpreter with the pyparsing [1] library is required.
8 |
9 | $ python bootstrap.py express.bnf > express_parser.py && python express_parser.py IFC2X3_TC1.exp
10 |
11 | [1] http://pyparsing.wikispaces.com/Download+and+Installation
12 |
--------------------------------------------------------------------------------
/src/ifcexpressparser/codegen.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | class Base(object):
21 | """
22 | A base class for all code generation classes. Currently only working around
23 | some python 2/3 incompatibilities in terms of unicode file handling.
24 | """
25 | def emit(self):
26 | import platform
27 | if tuple(map(int, platform.python_version_tuple())) < (2, 8):
28 | from io import open as unicode_open
29 | unicode_type = unicode
30 | else:
31 | unicode_open = open
32 | unicode_type = lambda x, *args, **kwargs: x
33 | f = unicode_open(self.file_name, 'w', encoding='utf-8')
34 | f.write(unicode_type(repr(self), encoding='utf-8', errors='ignore'))
35 | f.close()
36 |
--------------------------------------------------------------------------------
/src/ifcexpressparser/documentation.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | ###############################################################################
21 | # #
22 | # This files uses the documentation files from buildingSMART to generate #
23 | # descriptions from EXPRESS names that are suitable for comments in the C++ #
24 | # code. The .csv files used by this file are generated from the MS Office #
25 | # Access database, which in turn has been generated from the IFC baseline #
26 | # documentation by the IFCDOC utility provided by buildingSMART. #
27 | # #
28 | ###############################################################################
29 |
30 | import re
31 | import os
32 | import csv
33 |
34 | from schema import OrderedCaseInsensitiveDict
35 |
36 | try: from html.entities import entitydefs
37 | except: from htmlentitydefs import entitydefs
38 |
39 | make_absolute = lambda fn: os.path.join(os.path.dirname(os.path.realpath(__file__)), fn)
40 |
41 | name_to_oid = OrderedCaseInsensitiveDict()
42 | oid_to_desc = {}
43 | oid_to_name = {}
44 | oid_to_pid = {}
45 | regices = list(zip([re.compile(s,re.M) for s in [r'<[\w\n=" \-/\.;_\t:%#,\?\(\)]+>',r'(\n[\t ]*){2,}',r'^[\t ]+']],['','\n\n',' ']))
46 |
47 | definition_files = ['DocEntity.csv', 'DocEnumeration.csv', 'DocDefined.csv', 'DocSelect.csv']
48 | definition_files = map(make_absolute, definition_files)
49 | for fn in definition_files:
50 | with open(fn) as f:
51 | for oid, name, desc in csv.reader(f, delimiter=';', quotechar='"'):
52 | name_to_oid[name] = oid
53 | oid_to_name[oid] = name
54 | oid_to_desc[oid] = desc
55 |
56 | with open(make_absolute('DocEntityAttributes.csv')) as f:
57 | for pid, x, oid in csv.reader(f, delimiter=';', quotechar='"'):
58 | oid_to_pid[oid] = pid
59 |
60 | with open(make_absolute('DocAttribute.csv')) as f:
61 | for oid, name, desc in csv.reader(f, delimiter=';', quotechar='"'):
62 | pid = oid_to_pid[oid]
63 | pname = oid_to_name[pid]
64 | name_to_oid[".".join((pname, name))] = oid
65 | oid_to_desc[oid] = desc
66 |
67 | def description(item):
68 | global name_to_oid, oid_to_desc, oid_to_name, oid_to_pid
69 | oid = name_to_oid.get(item,0)
70 | desc = oid_to_desc.get(oid, None)
71 | if desc:
72 | for a,b in entitydefs.items(): desc = desc.replace("&%s;"%a,b)
73 | desc = desc.replace("\r","")
74 | for r,s in regices: desc = r.sub(s,desc)
75 | desc = desc.strip()
76 | return desc.split("\n")
77 | else: return []
--------------------------------------------------------------------------------
/src/ifcexpressparser/enum_header.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | import templates
21 | import codegen
22 |
23 | class EnumHeader(codegen.Base):
24 | def __init__(self, mapping):
25 | enumerable_types = sorted(set([name for name, type in mapping.schema.types.items()] + [name for name, type in mapping.schema.entities.items()]))
26 |
27 | self.str = templates.enum_header % {
28 | 'schema_name_upper' : mapping.schema.name.upper(),
29 | 'schema_name' : mapping.schema.name.capitalize(),
30 | 'types' : ', '.join(enumerable_types)
31 | }
32 |
33 | self.schema_name = mapping.schema.name.capitalize()
34 |
35 | self.file_name = '%senum.h'%self.schema_name
36 |
37 |
38 | def __repr__(self):
39 | return self.str
40 |
--------------------------------------------------------------------------------
/src/ifcexpressparser/latebound_header.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | import codegen
21 | import templates
22 |
23 | class LateBoundHeader(codegen.Base):
24 | def __init__(self, mapping):
25 | self.str = templates.lb_header % {
26 | 'schema_name_upper' : mapping.schema.name.upper(),
27 | 'schema_name' : mapping.schema.name.capitalize()
28 | }
29 |
30 | self.schema_name = mapping.schema.name.capitalize()
31 |
32 | self.file_name = '%s-latebound.h'%self.schema_name
33 |
34 |
35 | def __repr__(self):
36 | return self.str
37 |
--------------------------------------------------------------------------------
/src/ifcexpressparser/schema.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | import nodes
21 | import platform
22 | import collections
23 |
24 | if tuple(map(int, platform.python_version_tuple())) < (2, 7):
25 | import ordereddict
26 | collections.OrderedDict = ordereddict.OrderedDict
27 |
28 | # According to ISO 10303-11 7.1.2: Letters: "... The case of
29 | # letters is significant only within explicit string literals."
30 | class OrderedCaseInsensitiveDict(collections.OrderedDict):
31 | class KeyObject(str):
32 | def __eq__(self, other):
33 | return self.lower() == other.lower()
34 | def __hash__(self):
35 | return hash(self.lower())
36 |
37 | def __init__(self, *args, **kwargs):
38 | collections.OrderedDict.__init__(self)
39 | for key, value in collections.OrderedDict(*args, **kwargs).items():
40 | self[OrderedCaseInsensitiveDict.KeyObject(key)] = value
41 | def __setitem__(self, key, value):
42 | return collections.OrderedDict.__setitem__(self, OrderedCaseInsensitiveDict.KeyObject(key), value)
43 | def __getitem__(self, key):
44 | return collections.OrderedDict.__getitem__(self, OrderedCaseInsensitiveDict.KeyObject(key))
45 | def get(self, key, *args, **kwargs):
46 | return collections.OrderedDict.get(self, OrderedCaseInsensitiveDict.KeyObject(key), *args, **kwargs)
47 | def __contains__(self, key):
48 | return collections.OrderedDict.__contains__(self, OrderedCaseInsensitiveDict.KeyObject(key))
49 |
50 | class Schema:
51 | def is_enumeration(self, v):
52 | return str(v) in self.enumerations
53 | def is_select(self, v):
54 | return str(v) in self.selects
55 | def is_simpletype(self, v):
56 | return str(v) in self.simpletypes
57 | def is_type(self, v):
58 | return str(v) in self.types
59 | def is_entity(self, v):
60 | return str(v) in self.entities
61 | def __init__(self, parsetree):
62 | self.name = parsetree[1]
63 |
64 | sort = lambda d: OrderedCaseInsensitiveDict(sorted(d))
65 |
66 | self.types = sort([(t.name,t) for t in parsetree if isinstance(t, nodes.TypeDeclaration)])
67 | self.entities = sort([(t.name,t) for t in parsetree if isinstance(t, nodes.EntityDeclaration)])
68 |
69 | of_type = lambda *types: sort([(a, b.type.type) for a,b in self.types.items() if any(isinstance(b.type.type, ty) for ty in types)])
70 |
71 | self.enumerations = of_type(nodes.EnumerationType)
72 | self.selects = of_type(nodes.SelectType)
73 | self.simpletypes = of_type(str, nodes.AggregationType, nodes.BinaryType, nodes.StringType)
74 |
--------------------------------------------------------------------------------
/src/ifcgeom/ConversionResult.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCSHAPELIST_H
21 | #define IFCSHAPELIST_H
22 |
23 | #include "../ifcgeom/IfcGeomRenderStyles.h"
24 | #include "../ifcgeom/IfcGeomIteratorSettings.h"
25 |
26 | namespace IfcGeom {
27 |
28 | namespace Representation {
29 | template
30 | class IFC_GEOM_API Triangulation;
31 | }
32 |
33 | class IFC_GEOM_API ConversionResultPlacement {
34 | public:
35 | virtual void Multiply(const ConversionResultPlacement*) = 0;
36 | virtual void PreMultiply(const ConversionResultPlacement*) = 0;
37 | virtual double Value(int i, int j) const = 0;
38 | virtual ConversionResultPlacement* clone() const = 0;
39 | virtual ~ConversionResultPlacement() {}
40 | };
41 |
42 | class IFC_GEOM_API ConversionResultShape {
43 | public:
44 | virtual void Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement* place, IfcGeom::Representation::Triangulation* t, int surface_style_id) const = 0;
45 | virtual void Serialize(std::string&) const = 0;
46 | virtual ConversionResultShape* clone() const = 0;
47 | virtual ~ConversionResultShape() {}
48 | };
49 |
50 | class IFC_GEOM_API ConversionResult {
51 | private:
52 | ConversionResultPlacement* placement;
53 | ConversionResultShape* shape;
54 | const SurfaceStyle* style;
55 | public:
56 | ConversionResult(const ConversionResultPlacement* placement, const ConversionResultShape* shape, const SurfaceStyle* style)
57 | : placement(placement->clone()), shape(shape->clone()), style(style) {}
58 | ConversionResult(const ConversionResultPlacement* placement, const ConversionResultShape* shape)
59 | : placement(placement->clone()), shape(shape->clone()), style(0) {}
60 | ConversionResult(const ConversionResultShape* shape, const SurfaceStyle* style)
61 | : placement(0), shape(shape->clone()), style(style) {}
62 | ConversionResult(const ConversionResultShape* shape)
63 | : placement(0), shape(shape->clone()), style(0) {}
64 | void append(const ConversionResultPlacement* trsf) {
65 | if (placement == 0) {
66 | placement = trsf->clone();
67 | } else {
68 | placement->Multiply(trsf);
69 | }
70 | }
71 | void prepend(const ConversionResultPlacement* trsf) {
72 | if (placement == 0) {
73 | placement = trsf->clone();
74 | } else {
75 | placement->PreMultiply(trsf);
76 | }
77 | }
78 | const ConversionResultShape* Shape() const { return shape; }
79 | const ConversionResultPlacement* Placement() const { return placement; }
80 | bool hasStyle() const { return style != 0; }
81 | const SurfaceStyle& Style() const { return *style; }
82 | void setStyle(const SurfaceStyle* style) { this->style = style; }
83 | };
84 |
85 | typedef std::vector ConversionResults;
86 | }
87 | #endif
88 |
--------------------------------------------------------------------------------
/src/ifcgeom/IfcGeomMaterial.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #include "IfcGeomMaterial.h"
21 |
22 | static double black[3] = {0.,0.,0.};
23 |
24 | IfcGeom::Material::Material(const IfcGeom::SurfaceStyle* style) : style(style) {}
25 | bool IfcGeom::Material::hasDiffuse() const { return style->Diffuse() ? true : false; }
26 | bool IfcGeom::Material::hasSpecular() const { return style->Specular() ? true : false; }
27 | bool IfcGeom::Material::hasTransparency() const { return style->Transparency() ? true : false; }
28 | bool IfcGeom::Material::hasSpecularity() const { return style->Specularity() ? true : false; }
29 | const double* IfcGeom::Material::diffuse() const { if (hasDiffuse()) return &((*style->Diffuse()).R()); else return black; }
30 | const double* IfcGeom::Material::specular() const { if (hasSpecular()) return &((*style->Specular()).R()); else return black; }
31 | double IfcGeom::Material::transparency() const { if (hasTransparency()) return *style->Transparency(); else return 0; }
32 | double IfcGeom::Material::specularity() const { if (hasSpecularity()) return *style->Specularity(); else return 0; }
33 | const std::string &IfcGeom::Material::name() const { return style->Name(); }
34 | const std::string &IfcGeom::Material::original_name() const { return style->original_name(); }
35 | bool IfcGeom::Material::operator==(const IfcGeom::Material& other) const { return style == other.style; }
36 |
--------------------------------------------------------------------------------
/src/ifcgeom/IfcGeomMaterial.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCGEOMMATERIAL_H
21 | #define IFCGEOMMATERIAL_H
22 |
23 | #include
24 |
25 | #include "../ifcgeom/IfcGeomRenderStyles.h"
26 |
27 | namespace IfcGeom {
28 |
29 | class IFC_GEOM_API Material {
30 | private:
31 | const IfcGeom::SurfaceStyle* style;
32 | public:
33 | explicit Material(const IfcGeom::SurfaceStyle* style = 0); // TODO default constructor for vector?
34 | // Material(const Material& other);
35 | // Material& operator=(const Material& other);
36 | bool hasDiffuse() const;
37 | bool hasSpecular() const;
38 | bool hasTransparency() const;
39 | bool hasSpecularity() const;
40 | const double* diffuse() const;
41 | const double* specular() const;
42 | double transparency() const;
43 | double specularity() const;
44 | const std::string &name() const;
45 | const std::string &original_name() const;
46 | bool operator==(const Material& other) const;
47 | };
48 |
49 | }
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/ifcgeom/IfcGeomShapeType.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCGEOMSHAPETYPE_H
21 | #define IFCGEOMSHAPETYPE_H
22 |
23 | namespace IfcGeom {
24 |
25 | enum ShapeType {
26 | ST_SHAPELIST,
27 | ST_SHAPE,
28 | ST_FACE,
29 | ST_WIRE,
30 | ST_CURVE,
31 | ST_EDGE,
32 | ST_VERTEX,
33 | ST_OTHER
34 | };
35 |
36 | }
37 |
38 | #endif
--------------------------------------------------------------------------------
/src/ifcgeom/ifc_geom_api.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFC_GEOM_API_H
21 | #define IFC_GEOM_API_H
22 |
23 | #ifdef IFC_SHARED_BUILD
24 | #ifdef _WIN32
25 | #ifdef IFC_GEOM_EXPORTS
26 | #define IFC_GEOM_API __declspec(dllexport)
27 | #else
28 | #define IFC_GEOM_API __declspec(dllimport)
29 | #endif
30 | #else // simply assume *nix + GCC-like compiler
31 | #define IFC_GEOM_API __attribute__((visibility("default")))
32 | #endif
33 | #else
34 | #define IFC_GEOM_API
35 | #endif
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp:
--------------------------------------------------------------------------------
1 | #include "CgalKernel.h"
2 | #include "CgalConversionResult.h"
3 |
4 | void IfcGeom::CgalShape::Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation* t, int surface_style_id) const {
5 | cgal_shape_t s = shape_;
6 | const cgal_placement_t& trsf = dynamic_cast(place)->trsf();
7 |
8 | // Apply transformation
9 | if (place != NULL) for (auto &vertex: vertices(s)) {
10 | vertex->point() = vertex->point().transform(trsf);
11 | }
12 |
13 | std::string error_file_path;
14 | for (unsigned int error_number = 1; error_number < 1000; ++error_number) {
15 | error_file_path = std::string("/Users/ken/Desktop/error/error");
16 | error_file_path += std::to_string(error_number);
17 | error_file_path += ".off";
18 | std::ifstream file_path_test(error_file_path);
19 | if (!file_path_test.good()) break;
20 | }
21 |
22 | if (!s.is_valid()) {
23 | Logger::Message(Logger::LOG_ERROR, "Invalid Polyhedron_3 in object (before triangulation)");
24 | std::ofstream ferror;
25 | ferror.open(error_file_path);
26 | ferror << s << std::endl;
27 | ferror.close();
28 | return;
29 | }
30 |
31 | // std::ofstream fbefore;
32 | // fbefore.open("/Users/ken/Desktop/before.off");
33 | // fbefore << s << std::endl;
34 | // fbefore.close();
35 |
36 | // Triangulate the shape and compute the normals
37 | // std::map vertex_normals;
38 | // boost::associative_property_map> vertex_normals_map(vertex_normals);
39 | std::map face_normals;
40 | boost::associative_property_map> face_normals_map(face_normals);
41 | cgal_shape_t s_copy(s);
42 | bool success = false;
43 | try {
44 | success = CGAL::Polygon_mesh_processing::triangulate_faces(s);
45 | } catch (...) {
46 | Logger::Message(Logger::LOG_ERROR, "Triangulation crashed");
47 | std::ofstream ferror;
48 | ferror.open(error_file_path);
49 | ferror << s << std::endl;
50 | ferror.close();
51 | return;
52 | } if (!success) {
53 | Logger::Message(Logger::LOG_ERROR, "Triangulation failed");
54 | std::ofstream ferror;
55 | ferror.open(error_file_path);
56 | ferror << s << std::endl;
57 | ferror.close();
58 | return;
59 | }
60 | // std::cout << "Triangulated model: " << s.size_of_facets() << " facets and " << s.size_of_vertices() << " vertices" << std::endl;
61 |
62 | // std::ofstream fafter;
63 | // fafter.open("/Users/ken/Desktop/after.off");
64 | // fafter << s << std::endl;
65 | // fafter.close();
66 |
67 | if (!s.is_valid()) {
68 | Logger::Message(Logger::LOG_ERROR, "Invalid Polyhedron_3 in object (after triangulation)");
69 | std::ofstream ferror;
70 | ferror.open(error_file_path);
71 | ferror << s_copy << std::endl;
72 | ferror.close();
73 | return;
74 | }
75 |
76 | // CGAL::Polygon_mesh_processing::compute_normals(s, vertex_normals_map, face_normals_map);
77 | CGAL::Polygon_mesh_processing::compute_face_normals(s, face_normals_map);
78 |
79 | for (auto &face: faces(s)) {
80 | if (!face->is_triangle()) {
81 | std::cout << "Warning: non-triangular face!" << std::endl;
82 | continue;
83 | }
84 | CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = face->facet_begin();
85 | do {
86 | t->faces().push_back((int)t->verts().size()/3);
87 | t->addVertex(surface_style_id,
88 | CGAL::to_double(current_halfedge->vertex()->point().cartesian(0)),
89 | CGAL::to_double(current_halfedge->vertex()->point().cartesian(1)),
90 | CGAL::to_double(current_halfedge->vertex()->point().cartesian(2)));
91 | for (int i = 0; i < 3; ++i) t->normals().push_back(CGAL::to_double(face_normals_map[face].cartesian(i)));
92 | ++current_halfedge;
93 | } while (current_halfedge != face->facet_begin());
94 | t->material_ids().push_back(surface_style_id);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalConversionResult.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef CGALCONVERSIONRESULT_H
21 | #define CGALCONVERSIONRESULT_H
22 |
23 | #include "../../../ifcgeom/ConversionResult.h"
24 |
25 | namespace IfcGeom {
26 |
27 | class CgalPlacement : public ConversionResultPlacement {
28 | public:
29 | CgalPlacement(const cgal_placement_t& trsf)
30 | : trsf_(trsf)
31 | {}
32 |
33 | const cgal_placement_t& trsf() const { return trsf_; }
34 | operator const cgal_placement_t& () { return trsf_; }
35 |
36 | virtual double Value(int i, int j) const {
37 | return CGAL::to_double(trsf_.cartesian(i-1, j-1));
38 | }
39 | virtual void Multiply(const ConversionResultPlacement* other) {
40 | trsf_ = trsf_ * ((CgalPlacement *)other)->trsf_;
41 | }
42 | virtual void PreMultiply(const ConversionResultPlacement* other) {
43 | trsf_ = ((CgalPlacement *)other)->trsf_ * trsf_;
44 | }
45 | virtual ConversionResultPlacement* clone() const {
46 | return new CgalPlacement(trsf_);
47 | }
48 | private:
49 | cgal_placement_t trsf_;
50 | };
51 |
52 | class CgalShape : public ConversionResultShape {
53 | public:
54 | CgalShape(const cgal_shape_t& shape)
55 | : shape_(shape)
56 | {}
57 |
58 | const cgal_shape_t& shape() const { return shape_; }
59 | operator const cgal_shape_t& () { return shape_; }
60 |
61 | virtual void Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation* t, int surface_style_id) const;
62 | virtual void Serialize(std::string&) const {
63 | throw std::runtime_error("Not implemented");
64 | }
65 | virtual ConversionResultShape* clone() const {
66 | return new CgalShape(shape_);
67 | }
68 | private:
69 | cgal_shape_t shape_;
70 | };
71 |
72 | }
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingCreateCache.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define CLASS(T,V) \
3 | std::map T;
4 | #include "CgalEntityMappingDefine.h"
5 |
6 | #include "CgalEntityMapping.h"
7 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingCurve.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define CURVE(T) \
3 | if ( l->is(T::Class()) ) return convert((T*)l,r);
4 | #include "CgalEntityMappingDefine.h"
5 |
6 | #include "CgalEntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingDeclaration.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define CLASS(T,V) bool convert(const IfcSchema::T* L, V& r);
3 | #define SHAPES(T) CLASS(T,ConversionResults)
4 | #define SHAPE(T) CLASS(T,cgal_shape_t)
5 | #define WIRE(T) CLASS(T,cgal_wire_t)
6 | #define FACE(T) CLASS(T,cgal_face_t)
7 | #define CURVE(T) CLASS(T,cgal_curve_t)
8 | #include "CgalEntityMappingDefine.h"
9 |
10 | #include "CgalEntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingDefine.h:
--------------------------------------------------------------------------------
1 | #ifndef SHAPES
2 | #define SHAPES(T)
3 | #endif
4 | #ifndef SHAPE
5 | #define SHAPE(T)
6 | #endif
7 | #ifndef WIRE
8 | #define WIRE(T)
9 | #endif
10 | #ifndef FACE
11 | #define FACE(T)
12 | #endif
13 | #ifndef CURVE
14 | #define CURVE(T)
15 | #endif
16 | #ifndef CLASS
17 | #define CLASS(T,V)
18 | #endif
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingFace.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define FACE(T) \
3 | if ( l->is(T::Class()) ) return convert((T*)l,r);
4 | #include "CgalEntityMappingDefine.h"
5 |
6 | #include "CgalEntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingPurgeCache.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define CLASS(T,V) \
3 | T.clear();
4 | #include "CgalEntityMappingDefine.h"
5 |
6 | #include "CgalEntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingShape.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define SHAPE(T) \
3 | if ( !processed && l->is(T::Class()) ) { \
4 | processed = true; \
5 | try { \
6 | if ( convert((T*)l,r) ) { \
7 | success = true; \
8 | } \
9 | } catch (const std::exception& e) { \
10 | Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
11 | return false; \
12 | } \
13 | if (!success) { \
14 | Logger::Message(Logger::LOG_ERROR,"Failed to convert:",l->entity); \
15 | return false; \
16 | } \
17 | }
18 | #include "CgalEntityMappingDefine.h"
19 |
20 | #include "CgalEntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingShapeType.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define SHAPES(T) \
3 | if ( l->is(T::Class()) ) return ST_SHAPELIST;
4 | #define SHAPE(T) \
5 | if ( l->is(T::Class()) ) return ST_SHAPE;
6 | #define WIRE(T) \
7 | if ( l->is(T::Class()) ) return ST_WIRE;
8 | #define FACE(T) \
9 | if ( l->is(T::Class()) ) return ST_FACE;
10 | #define CURVE(T) \
11 | if ( l->is(T::Class()) ) return ST_CURVE;
12 | #include "CgalEntityMappingDefine.h"
13 |
14 | #include "CgalEntityMapping.h"
15 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingShapes.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define SHAPES(T) \
3 | if ( l->is(T::Class()) ) { \
4 | try { \
5 | return convert((T*)l,r); \
6 | } catch (const std::exception& e) { \
7 | Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
8 | } \
9 | return false; \
10 | }
11 | #include "CgalEntityMappingDefine.h"
12 |
13 | #include "CgalEntityMapping.h"
14 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingUndefine.h:
--------------------------------------------------------------------------------
1 | #ifdef SHAPES
2 | #undef SHAPES
3 | #endif
4 | #ifdef SHAPE
5 | #undef SHAPE
6 | #endif
7 | #ifdef WIRE
8 | #undef WIRE
9 | #endif
10 | #ifdef FACE
11 | #undef FACE
12 | #endif
13 | #ifdef CURVE
14 | #undef CURVE
15 | #endif
16 | #ifdef CLASS
17 | #undef CLASS
18 | #endif
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalEntityMappingWire.h:
--------------------------------------------------------------------------------
1 | #include "CgalEntityMappingUndefine.h"
2 | #define WIRE(T) \
3 | if ( l->is(T::Class()) ) return convert((T*)l,r);
4 | #include "CgalEntityMappingDefine.h"
5 |
6 | #include "CgalEntityMapping.h"
7 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/cgal/CgalIfcGeomCurves.cpp:
--------------------------------------------------------------------------------
1 | #include "CgalKernel.h"
2 |
3 | bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcCircle* l, cgal_curve_t& curve) {
4 | const double r = l->Radius() * getValue(GV_LENGTH_UNIT);
5 | if ( r < ALMOST_ZERO ) {
6 | Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", l->entity);
7 | return false;
8 | }
9 | cgal_placement_t trsf;
10 | IfcSchema::IfcAxis2Placement* placement = l->Position();
11 | if (placement->is(IfcSchema::Type::IfcAxis2Placement3D)) {
12 | IfcGeom::CgalKernel::convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
13 | } else {
14 | cgal_placement_t trsf2d;
15 | IfcGeom::CgalKernel::convert((IfcSchema::IfcAxis2Placement2D*)placement,trsf2d);
16 | trsf = trsf2d;
17 | }
18 |
19 | const int segments = 12;
20 |
21 | curve = cgal_curve_t();
22 | for (int current_segment = 0; current_segment < segments; ++current_segment) {
23 | double current_angle = current_segment*2.0*3.141592653589793/((double)segments);
24 | curve.push_back(Kernel::Point_3(r*cos(current_angle), r*sin(current_angle), 0));
25 | }
26 |
27 | for (auto &vertex: curve) {
28 | vertex = vertex.transform(trsf);
29 | }
30 |
31 | return true;
32 | }
33 |
34 | bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcEllipse* l, cgal_curve_t& curve) {
35 | double x = l->SemiAxis1() * getValue(GV_LENGTH_UNIT);
36 | double y = l->SemiAxis2() * getValue(GV_LENGTH_UNIT);
37 | if (x < ALMOST_ZERO || y < ALMOST_ZERO) {
38 | Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", l->entity);
39 | return false;
40 | }
41 | cgal_placement_t trsf;
42 | IfcSchema::IfcAxis2Placement* placement = l->Position();
43 | if (placement->is(IfcSchema::Type::IfcAxis2Placement3D)) {
44 | convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
45 | } else {
46 | cgal_placement_t trsf2d;
47 | convert((IfcSchema::IfcAxis2Placement2D*)placement,trsf2d);
48 | trsf = trsf2d;
49 | }
50 |
51 | const int segments = 12;
52 |
53 | curve = cgal_curve_t();
54 | for (int current_segment = 0; current_segment < segments; ++current_segment) {
55 | double current_angle = current_segment*2.0*3.141592653589793/((double)segments);
56 | curve.push_back(Kernel::Point_3(x*cos(current_angle), y*sin(current_angle), 0));
57 | }
58 |
59 | for (auto &vertex: curve) {
60 | vertex = vertex.transform(trsf);
61 | }
62 |
63 | return true;
64 | }
65 |
66 | bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcLine* l, cgal_curve_t& curve) {
67 | cgal_point_t pnt;
68 | cgal_direction_t vec;
69 | convert(l->Pnt(),pnt);
70 | convert(l->Dir(),vec);
71 | curve = cgal_curve_t();
72 | curve.push_back(pnt);
73 | curve.push_back(pnt+vec);
74 | return true;
75 | }
76 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingCreateCache.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define CLASS(T,V) \
3 | std::map T;
4 | #include "EntityMappingDefine.h"
5 |
6 | #include "EntityMapping.h"
7 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingCurve.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define CURVE(T) \
3 | if ( l->is(T::Class()) ) return convert((T*)l,r);
4 | #include "EntityMappingDefine.h"
5 |
6 | #include "EntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingDeclaration.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define CLASS(T,V) bool convert(const IfcSchema::T* L, V& r);
3 | #define SHAPES(T) CLASS(T,ConversionResults)
4 | #define SHAPE(T) CLASS(T,TopoDS_Shape)
5 | #define WIRE(T) CLASS(T,TopoDS_Wire)
6 | #define FACE(T) CLASS(T,TopoDS_Shape)
7 | #define CURVE(T) CLASS(T,Handle(Geom_Curve))
8 | #include "EntityMappingDefine.h"
9 |
10 | #include "EntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingDefine.h:
--------------------------------------------------------------------------------
1 | #ifndef SHAPES
2 | #define SHAPES(T)
3 | #endif
4 | #ifndef SHAPE
5 | #define SHAPE(T)
6 | #endif
7 | #ifndef WIRE
8 | #define WIRE(T)
9 | #endif
10 | #ifndef FACE
11 | #define FACE(T)
12 | #endif
13 | #ifndef CURVE
14 | #define CURVE(T)
15 | #endif
16 | #ifndef CLASS
17 | #define CLASS(T,V)
18 | #endif
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingFace.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define FACE(T) \
3 | if ( l->is(T::Class()) ) return convert((T*)l,r);
4 | #include "EntityMappingDefine.h"
5 |
6 | #include "EntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingPurgeCache.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define CLASS(T,V) \
3 | T.clear();
4 | #include "EntityMappingDefine.h"
5 |
6 | #include "EntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingShape.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define SHAPE(T) \
3 | if ( !processed && l->is(T::Class()) ) { \
4 | processed = true; \
5 | try { \
6 | if ( convert((T*)l,r) ) { \
7 | success = true; \
8 | } \
9 | } catch (const std::exception& e) { \
10 | Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
11 | return false; \
12 | } catch (const Standard_Failure& f) { \
13 | if (f.GetMessageString() && strlen(f.GetMessageString())) \
14 | Logger::Message(Logger::LOG_ERROR, std::string("Error in: ") + f.GetMessageString() + "\nFailed to convert:", l->entity); \
15 | else \
16 | Logger::Message(Logger::LOG_ERROR, "Failed to convert:", l->entity); \
17 | return false; \
18 | } \
19 | if (!success) { \
20 | Logger::Message(Logger::LOG_ERROR,"Failed to convert:",l->entity); \
21 | return false; \
22 | } \
23 | }
24 | #include "EntityMappingDefine.h"
25 |
26 | #include "EntityMapping.h"
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingShapeType.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define SHAPES(T) \
3 | if ( l->is(T::Class()) ) return ST_SHAPELIST;
4 | #define SHAPE(T) \
5 | if ( l->is(T::Class()) ) return ST_SHAPE;
6 | #define WIRE(T) \
7 | if ( l->is(T::Class()) ) return ST_WIRE;
8 | #define FACE(T) \
9 | if ( l->is(T::Class()) ) return ST_FACE;
10 | #define CURVE(T) \
11 | if ( l->is(T::Class()) ) return ST_CURVE;
12 | #include "EntityMappingDefine.h"
13 |
14 | #include "EntityMapping.h"
15 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingShapes.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define SHAPES(T) \
3 | if ( l->is(T::Class()) ) { \
4 | try { \
5 | return convert((T*)l,r); \
6 | } catch (const std::exception& e) { \
7 | Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
8 | } catch (const Standard_Failure& f) { \
9 | if (f.GetMessageString()) \
10 | Logger::Message(Logger::LOG_ERROR, std::string("Error in: ") + f.GetMessageString() + "\nFailed to convert:", l->entity); \
11 | else \
12 | Logger::Message(Logger::LOG_ERROR, "Failed to convert:", l->entity); \
13 | } \
14 | return false; \
15 | }
16 | #include "EntityMappingDefine.h"
17 |
18 | #include "EntityMapping.h"
19 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingUndefine.h:
--------------------------------------------------------------------------------
1 | #ifdef SHAPES
2 | #undef SHAPES
3 | #endif
4 | #ifdef SHAPE
5 | #undef SHAPE
6 | #endif
7 | #ifdef WIRE
8 | #undef WIRE
9 | #endif
10 | #ifdef FACE
11 | #undef FACE
12 | #endif
13 | #ifdef CURVE
14 | #undef CURVE
15 | #endif
16 | #ifdef CLASS
17 | #undef CLASS
18 | #endif
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/EntityMappingWire.h:
--------------------------------------------------------------------------------
1 | #include "EntityMappingUndefine.h"
2 | #define WIRE(T) \
3 | if ( l->is(T::Class()) ) return convert((T*)l,r);
4 | #include "EntityMappingDefine.h"
5 |
6 | #include "EntityMapping.h"
7 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/IfcGeomOpenCascadeSerialization.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 |
26 | #include "../../../ifcgeom/IfcGeom.h"
27 | #include "../../../ifcgeom/IfcGeomRepresentation.h"
28 |
29 | #include "../opencascade/OpenCascadeKernel.h"
30 | #include "../opencascade/OpenCascadeConversionResult.h"
31 |
32 | IfcGeom::Representation::Serialization::Serialization(const Native& brep)
33 | : Representation(brep.settings())
34 | , _id(brep.getId())
35 | {
36 | TopoDS_Compound compound;
37 | BRep_Builder builder;
38 | builder.MakeCompound(compound);
39 | for (IfcGeom::ConversionResults::const_iterator it = brep.begin(); it != brep.end(); ++ it) {
40 | const TopoDS_Shape& s = ((OpenCascadeShape*) it->Shape())->shape();
41 | gp_GTrsf trsf = ((OpenCascadePlacement*)it->Placement())->trsf();
42 |
43 | if (it->hasStyle() && it->Style().Diffuse()) {
44 | const IfcGeom::SurfaceStyle::ColorComponent& clr = *it->Style().Diffuse();
45 | _surface_styles.push_back(clr.R());
46 | _surface_styles.push_back(clr.G());
47 | _surface_styles.push_back(clr.B());
48 | } else {
49 | _surface_styles.push_back(-1.);
50 | _surface_styles.push_back(-1.);
51 | _surface_styles.push_back(-1.);
52 | }
53 | if (it->hasStyle() && it->Style().Transparency()) {
54 | _surface_styles.push_back(1. - *it->Style().Transparency());
55 | } else {
56 | _surface_styles.push_back(1.);
57 | }
58 |
59 | if (settings().get(IteratorSettings::CONVERT_BACK_UNITS)) {
60 | gp_Trsf scale;
61 | scale.SetScaleFactor(1.0 / settings().unit_magnitude());
62 | trsf.PreMultiply(scale);
63 | }
64 |
65 | const TopoDS_Shape moved_shape = IfcGeom::OpenCascadeKernel::apply_transformation(s, trsf);
66 |
67 | builder.Add(compound, moved_shape);
68 | }
69 | std::stringstream sstream;
70 | BRepTools::Write(compound,sstream);
71 | _brep_data = sstream.str();
72 | }
73 |
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCGEOMOPENCASCADEREPRESENTATION_H
21 | #define IFCGEOMOPENCASCADEREPRESENTATION_H
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #include
31 | #include
32 |
33 | #include
34 | #include
35 | #include
36 |
37 | namespace IfcGeom {
38 |
39 | class OpenCascadePlacement : public ConversionResultPlacement {
40 | public:
41 | OpenCascadePlacement(const gp_GTrsf& trsf)
42 | : trsf_(trsf)
43 | {}
44 |
45 | const gp_GTrsf& trsf() const { return trsf_; }
46 | operator const gp_GTrsf& () { return trsf_; }
47 |
48 | virtual double Value(int i, int j) const {
49 | return trsf_.Value(i, j);
50 | }
51 | virtual void Multiply(const ConversionResultPlacement* other) {
52 | trsf_.Multiply(((OpenCascadePlacement*)other)->trsf_);
53 | }
54 | virtual void PreMultiply(const ConversionResultPlacement* other) {
55 | trsf_.PreMultiply(((OpenCascadePlacement*)other)->trsf_);
56 | }
57 | virtual ConversionResultPlacement* clone() const {
58 | return new OpenCascadePlacement(trsf_);
59 | }
60 | private:
61 | gp_GTrsf trsf_;
62 | };
63 |
64 | class OpenCascadeShape : public ConversionResultShape {
65 | public:
66 | OpenCascadeShape(const TopoDS_Shape& shape)
67 | : shape_(shape)
68 | {}
69 |
70 | const TopoDS_Shape& shape() const { return shape_; }
71 | operator const TopoDS_Shape& () { return shape_; }
72 |
73 | virtual void Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation* t, int surface_style_id) const;
74 | virtual void Serialize(std::string&) const {
75 | throw std::runtime_error("Not implemented");
76 | }
77 | virtual ConversionResultShape* clone() const {
78 | return new OpenCascadeShape(shape_);
79 | }
80 | private:
81 | TopoDS_Shape shape_;
82 | };
83 |
84 | }
85 |
86 | #endif
--------------------------------------------------------------------------------
/src/ifcgeom/kernels/opencascade/OpenCascadeSerialization.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef OPENCASCADESERIALIZATION_H
21 | #define OPENCASCADESERIALIZATION_H
22 |
23 | #include "../../../ifcparse/IfcParse.h"
24 |
25 | #include
26 |
27 | namespace IfcGeom {
28 |
29 | IfcSchema::IfcProductDefinitionShape* tesselate(const TopoDS_Shape& shape, double deflection);
30 | IfcSchema::IfcProductDefinitionShape* serialise(const TopoDS_Shape& shape, bool advanced);
31 |
32 | }
33 |
34 | #endif
--------------------------------------------------------------------------------
/src/ifcgeomserver/README.md:
--------------------------------------------------------------------------------
1 | IfcGeomServer
2 | -------------
3 |
4 | A command-line executable intented to be ran as a child process that receives an IFC model from stdin and will send binary geometry information of products found in the IFC file in separate messages on stdout. The advantage over conventional static or dynamic linking is that, in case the IfcOpenShell process would crash (either due to invalid input, heap overflow, bugs, ...), this does not affect the main process. Currently, the only implementation of a consumer for this process is the Java module over at: https://github.com/opensourceBIM/IfcOpenShell-BIMserver-plugin/blob/master/src/org/ifcopenshell/IfcGeomServerClient.java
5 |
--------------------------------------------------------------------------------
/src/ifcjni/org_ifcopenshell_IfcOpenShellModel.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class org_ifcopenshell_IfcOpenShellModel */
4 |
5 | #ifndef _Included_org_ifcopenshell_IfcOpenShellModel
6 | #define _Included_org_ifcopenshell_IfcOpenShellModel
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: org_ifcopenshell_IfcOpenShellModel
12 | * Method: getGeometry
13 | * Signature: ()Lorg/ifcopenshell/IfcGeomObject;
14 | */
15 | JNIEXPORT jobject JNICALL Java_org_ifcopenshell_IfcOpenShellModel_getGeometry
16 | (JNIEnv *, jobject);
17 |
18 | /*
19 | * Class: org_ifcopenshell_IfcOpenShellModel
20 | * Method: setIfcData
21 | * Signature: ([B)Z
22 | */
23 | JNIEXPORT jboolean JNICALL Java_org_ifcopenshell_IfcOpenShellModel_setIfcData
24 | (JNIEnv *, jobject, jbyteArray);
25 |
26 | /*
27 | * Class: org_ifcopenshell_IfcOpenShellModel
28 | * Method: getPluginVersion
29 | * Signature: ()Ljava/lang/String;
30 | */
31 | JNIEXPORT jstring JNICALL Java_org_ifcopenshell_IfcOpenShellModel_getPluginVersion
32 | (JNIEnv *, jobject);
33 |
34 | #ifdef __cplusplus
35 | }
36 | #endif
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/ifcmax/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ################################################################################
19 |
20 | INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} ${ICU_INCLUDE_DIR}
21 | ${Boost_INCLUDE_DIRS} ${THREEDS_MAX_SDK_HOME}/include
22 | )
23 |
24 | # All recent versions of 3ds Max (2014 and newer) are 64-bit only so assume lib/x64 directory
25 | LINK_DIRECTORIES(${LINK_DIRECTORIES} ${IfcOpenShell_BINARY_DIR} ${OCC_LIBRARY_DIR} ${OPENCOLLADA_LIBRARY_DIR}
26 | ${ICU_LIBRARY_DIR} ${Boost_LIBRARY_DIRS} ${THREEDS_MAX_SDK_HOME}/lib/x64/Release
27 | )
28 |
29 | ADD_LIBRARY(IfcMax SHARED IfcMax.h IfcMax.cpp)
30 |
31 | # TODO: find the minimal subset of 3dsmax libraries to reference
32 | TARGET_LINK_LIBRARIES(IfcMax ${IFCOPENSHELL_LIBRARIES} Comctl32.lib zlibdll.lib bmm.lib core.lib CustDlg.lib edmodel.lib expr.lib
33 | flt.lib geom.lib gfx.lib gup.lib imageViewers.lib ManipSys.lib maxnet.lib Maxscrpt.lib
34 | maxutil.lib MenuMan.lib menus.lib mesh.lib MNMath.lib Paramblk2.lib particle.lib Poly.lib RenderUtil.lib
35 | tessint.lib viewfile.lib ${OPENCASCADE_LIBRARIES}
36 | )
37 |
38 | SET_TARGET_PROPERTIES(IfcMax PROPERTIES SUFFIX ".dli")
39 |
40 | INSTALL(TARGETS IfcMax RUNTIME DESTINATION ${BINDIR})
41 |
--------------------------------------------------------------------------------
/src/ifcmax/IfcMax.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCMAX_H
21 | #define IFCMAX_H
22 |
23 | #include "Max.h"
24 |
25 | extern ClassDesc* GetIFCImpDesc();
26 |
27 | class IFCImp : public SceneImport
28 | {
29 | public:
30 | int ExtCount(); // = 1
31 | const TCHAR * Ext(int n); // = "IFC"
32 | const TCHAR * LongDesc(); // = "IfcOpenShell IFC Importer for 3ds Max"
33 | const TCHAR * ShortDesc(); // = "Industry Foundation Classes"
34 | const TCHAR * AuthorName(); // = "Thomas Krijnen"
35 | const TCHAR * CopyrightMessage(); // = "Copyright (c) 2011-2016 IfcOpenShell"
36 | const TCHAR * OtherMessage1(); // = ""
37 | const TCHAR * OtherMessage2(); // = ""
38 | unsigned int Version(); // = 12
39 | void ShowAbout(HWND hWnd);
40 | int DoImport(const TCHAR *name,ImpInterface *ei,Interface *i, BOOL suppressPrompts);
41 | };
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/ifcopenshell-python/ifcopenshell/__init__.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | from __future__ import print_function
21 |
22 | import os
23 | import sys
24 | import platform
25 |
26 | python_distribution = os.path.join(platform.system().lower(),
27 | platform.architecture()[0],
28 | 'python%s.%s' % platform.python_version_tuple()[:2])
29 | sys.path.append(os.path.abspath(os.path.join(
30 | os.path.dirname(__file__),
31 | 'lib', python_distribution)))
32 |
33 | try:
34 | from . import ifcopenshell_wrapper
35 | except Exception as e:
36 | if int(platform.python_version_tuple()[0]) == 2:
37 | import traceback
38 | traceback.print_exc()
39 | print('-' * 64)
40 | raise ImportError("IfcOpenShell not built for '%s'" % python_distribution)
41 |
42 | from . import guid
43 | from .file import file
44 | from .entity_instance import entity_instance
45 |
46 | def open(fn=None):
47 | return file(ifcopenshell_wrapper.open(os.path.abspath(fn))) if fn else file()
48 |
49 |
50 | def create_entity(type,*args,**kwargs):
51 | e = entity_instance(ifcopenshell_wrapper.entity_instance(type))
52 | attrs = list(enumerate(args)) + \
53 | [(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
54 | for idx, arg in attrs: e[idx] = arg
55 | return e
56 |
57 |
58 | version = ifcopenshell_wrapper.version()
59 | schema_identifier = ifcopenshell_wrapper.schema_identifier()
60 | get_supertype = ifcopenshell_wrapper.get_supertype
61 |
--------------------------------------------------------------------------------
/src/ifcopenshell-python/ifcopenshell/file.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | import numbers
21 | import functools
22 |
23 | from . import ifcopenshell_wrapper
24 | from .entity_instance import entity_instance
25 |
26 | class file(object):
27 | def __init__(self, f=None):
28 | self.wrapped_data = f or ifcopenshell_wrapper.file(True)
29 | def create_entity(self,type,*args,**kwargs):
30 | e = entity_instance(ifcopenshell_wrapper.entity_instance(type))
31 | attrs = list(enumerate(args)) + \
32 | [(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
33 | for idx, arg in attrs: e[idx] = arg
34 | self.wrapped_data.add(e.wrapped_data)
35 | e.wrapped_data.this.disown()
36 | return e
37 | def __getattr__(self, attr):
38 | if attr[0:6] == 'create': return functools.partial(self.create_entity,attr[6:])
39 | else: return getattr(self.wrapped_data, attr)
40 | def __getitem__(self, key):
41 | if isinstance(key, numbers.Integral):
42 | return entity_instance(self.wrapped_data.by_id(key))
43 | elif isinstance(key, str):
44 | return entity_instance(self.wrapped_data.by_guid(key))
45 | def by_id(self, id): return self[id]
46 | def by_guid(self, guid): return self[guid]
47 | def add(self, inst):
48 | inst.wrapped_data.this.disown()
49 | return entity_instance(self.wrapped_data.add(inst.wrapped_data))
50 | def by_type(self, type):
51 | return [entity_instance(e) for e in self.wrapped_data.by_type(type)]
52 | def traverse(self, inst, max_levels=None):
53 | if max_levels is None:
54 | max_levels = -1
55 | return [entity_instance(e) for e in self.wrapped_data.traverse(inst.wrapped_data, max_levels)]
56 | def get_inverse(self, inst):
57 | return [entity_instance(e) for e in self.wrapped_data.get_inverse(inst.wrapped_data)]
58 | def remove(self, inst):
59 | return self.wrapped_data.remove(inst.wrapped_data)
60 | def __iter__(self):
61 | return iter(self[id] for id in self.wrapped_data.entity_names())
62 |
--------------------------------------------------------------------------------
/src/ifcopenshell-python/ifcopenshell/geom/__init__.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | from . import occ_utils as utils
21 | from .main import *
22 |
--------------------------------------------------------------------------------
/src/ifcopenshell-python/ifcopenshell/guid.py:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | import string
21 |
22 | from functools import reduce
23 |
24 | chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + '_$'
25 |
26 | def compress(g):
27 | bs = [int(g[i:i+2], 16) for i in range(0, len(g), 2)]
28 | def b64(v, l=4):
29 | return ''.join([chars[(v // (64**i))%64] for i in range(l)][::-1])
30 | return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i+1] << 8) + bs[i+2]) for i in range(1,16,3)])
31 |
32 | def expand(g):
33 | def b64(v):
34 | return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))
35 | bs = [b64(g[0:2])]
36 | for i in range(5):
37 | d = b64(g[2+4*i:6+4*i])
38 | bs += [(d >> (8*(2-j)))%256 for j in range(3)]
39 | return ''.join(['%02x'%b for b in bs])
40 |
41 | def split(g):
42 | return '{%s-%s-%s-%s-%s}'%(g[:8], g[8:12], g[12:16], g[16:20], g[20:])
43 |
44 |
--------------------------------------------------------------------------------
/src/ifcparse/Ifc2x3-latebound.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | /********************************************************************************************
21 | * *
22 | * This file has been generated from *
23 | * http://www.buildingsmart-tech.org/downloads/ifc/ifc2x3tc/IFC2X3_TC1_EXPRESS_longform.zip *
24 | * Do not make modifications but instead modify the Python script that has been *
25 | * used to generate this. *
26 | * *
27 | ********************************************************************************************/
28 |
29 | #ifndef IFC2X3RT_H
30 | #define IFC2X3RT_H
31 |
32 | #define IfcSchema Ifc2x3
33 |
34 | #include "../ifcparse/ifc_parse_api.h"
35 | #include "../ifcparse/IfcUtil.h"
36 | #include "../ifcparse/IfcEntityDescriptor.h"
37 | #include "../ifcparse/IfcWritableEntity.h"
38 |
39 | namespace Ifc2x3 {
40 | namespace Type {
41 | IFC_PARSE_API int GetAttributeCount(Enum t);
42 | IFC_PARSE_API int GetAttributeIndex(Enum t, const std::string& a);
43 | IFC_PARSE_API IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
44 | IFC_PARSE_API Enum GetAttributeEntity(Enum t, unsigned char a);
45 | IFC_PARSE_API const std::string& GetAttributeName(Enum t, unsigned char a);
46 | IFC_PARSE_API bool GetAttributeOptional(Enum t, unsigned char a);
47 | IFC_PARSE_API bool GetAttributeDerived(Enum t, unsigned char a);
48 | IFC_PARSE_API std::pair GetEnumerationIndex(Enum t, const std::string& a);
49 | IFC_PARSE_API std::pair GetInverseAttribute(Enum t, const std::string& a);
50 | IFC_PARSE_API std::set GetInverseAttributeNames(Enum t);
51 | IFC_PARSE_API void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
52 | }}
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/ifcparse/Ifc4-latebound.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | /********************************************************************************
21 | * *
22 | * This file has been generated from *
23 | * http://www.buildingsmart-tech.org/ifc/IFC4/Add1/IFC4_ADD1.exp *
24 | * Do not make modifications but instead modify the Python script that has been *
25 | * used to generate this. *
26 | * *
27 | ********************************************************************************/
28 |
29 | #ifndef IFC4RT_H
30 | #define IFC4RT_H
31 |
32 | #define IfcSchema Ifc4
33 |
34 | #include "../ifcparse/ifc_parse_api.h"
35 | #include "../ifcparse/IfcUtil.h"
36 | #include "../ifcparse/IfcEntityDescriptor.h"
37 | #include "../ifcparse/IfcWritableEntity.h"
38 |
39 | namespace Ifc4 {
40 | namespace Type {
41 | IFC_PARSE_API int GetAttributeCount(Enum t);
42 | IFC_PARSE_API int GetAttributeIndex(Enum t, const std::string& a);
43 | IFC_PARSE_API IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
44 | IFC_PARSE_API Enum GetAttributeEntity(Enum t, unsigned char a);
45 | IFC_PARSE_API const std::string& GetAttributeName(Enum t, unsigned char a);
46 | IFC_PARSE_API bool GetAttributeOptional(Enum t, unsigned char a);
47 | IFC_PARSE_API bool GetAttributeDerived(Enum t, unsigned char a);
48 | IFC_PARSE_API std::pair GetEnumerationIndex(Enum t, const std::string& a);
49 | IFC_PARSE_API std::pair GetInverseAttribute(Enum t, const std::string& a);
50 | IFC_PARSE_API std::set GetInverseAttributeNames(Enum t);
51 | IFC_PARSE_API void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
52 | }}
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/ifcparse/IfcCharacterDecoder.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | /********************************************************************************
21 | * *
22 | * Implementation of character decoding as described in ISO 10303-21 table 2 and *
23 | * table 4 *
24 | * *
25 | ********************************************************************************/
26 |
27 | #ifndef IFCCHARACTERDECODER_H
28 | #define IFCCHARACTERDECODER_H
29 |
30 | #include
31 | #include
32 |
33 | #ifdef HAVE_ICU
34 | #include "unicode/ucnv.h"
35 | #else
36 | typedef unsigned int UChar32;
37 | #endif
38 |
39 | #include "../ifcparse/IfcSpfStream.h"
40 |
41 | namespace IfcParse {
42 |
43 | class IFC_PARSE_API IfcCharacterDecoder {
44 | private:
45 | IfcParse::IfcSpfStream* file;
46 | #ifdef HAVE_ICU
47 | static UConverter* destination;
48 | static UConverter* converter;
49 | static UConverter* compatibility_converter;
50 | static int previous_codepage;
51 | static UErrorCode status;
52 | #endif
53 | void addChar(std::stringstream& s,const UChar32& ch);
54 | public:
55 | #ifdef HAVE_ICU
56 | enum ConversionMode {DEFAULT,UTF8,LATIN,JSON,PYTHON};
57 | static ConversionMode mode;
58 |
59 | // Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior to encode characters.
60 | // It just translate to extended string in system default code page, not unicode.
61 | // If you want to process these strings, set true.
62 | static bool compatibility_mode;
63 | static std::string compatibility_charset;
64 |
65 | #else
66 | static char substitution_character;
67 | #endif
68 | IfcCharacterDecoder(IfcParse::IfcSpfStream* file);
69 | ~IfcCharacterDecoder();
70 | void dryRun();
71 | operator std::string();
72 | };
73 |
74 | }
75 |
76 | namespace IfcWrite {
77 |
78 | class IFC_PARSE_API IfcCharacterEncoder {
79 | private:
80 | std::string str;
81 | #ifdef HAVE_ICU
82 | static UErrorCode status;
83 | static UConverter* converter;
84 | #endif
85 | public:
86 | IfcCharacterEncoder(const std::string& input);
87 | ~IfcCharacterEncoder();
88 | operator std::string();
89 | };
90 |
91 | }
92 |
93 | #endif
94 |
--------------------------------------------------------------------------------
/src/ifcparse/IfcException.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCEXCEPTION_H
21 | #define IFCEXCEPTION_H
22 |
23 | #include "ifc_parse_api.h"
24 |
25 | #include
26 |
27 | #include
28 | #include
29 |
30 | #ifdef _MSC_VER
31 | // "C4275 can be ignored in Visual C++ if you are deriving from a type in the Standard C++ Library",
32 | // https://msdn.microsoft.com/en-us/library/3tdb471s.aspx
33 | #pragma warning(push)
34 | #pragma warning(disable : 4275)
35 | #endif
36 |
37 | namespace IfcParse {
38 | class IFC_PARSE_API IfcException : public std::exception {
39 | private:
40 | std::string message;
41 | public:
42 | IfcException(const std::string& m)
43 | : message(m) {}
44 | virtual ~IfcException () throw () {}
45 | virtual const char* what() const throw() {
46 | return message.c_str();
47 | }
48 | };
49 |
50 | class IFC_PARSE_API IfcAttributeOutOfRangeException : public IfcException {
51 | public:
52 | IfcAttributeOutOfRangeException(const std::string& e)
53 | : IfcException(e) {}
54 | ~IfcAttributeOutOfRangeException () throw () {}
55 | };
56 |
57 | class IFC_PARSE_API IfcInvalidTokenException : public IfcException {
58 | public:
59 | IfcInvalidTokenException(
60 | int token_start,
61 | const std::string& token_string,
62 | const std::string& expected_type
63 | )
64 | : IfcException(
65 | std::string("Token ") + token_string + " at " +
66 | boost::lexical_cast(token_start) +
67 | " invalid " + expected_type
68 | )
69 | {}
70 | IfcInvalidTokenException(
71 | int token_start,
72 | char c
73 | )
74 | : IfcException(
75 | std::string("Unexpected '") + std::string(1, c) + "' at " +
76 | boost::lexical_cast(token_start)
77 | )
78 | {}
79 | ~IfcInvalidTokenException() throw () {}
80 | };
81 |
82 | }
83 |
84 | #ifdef _MSC_VER
85 | #pragma warning(pop)
86 | #endif
87 |
88 | #endif
89 |
--------------------------------------------------------------------------------
/src/ifcparse/IfcGlobalId.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCGLOBALID_H
21 | #define IFCGLOBALID_H
22 |
23 | #include
24 | #include
25 |
26 | #include "ifc_parse_api.h"
27 |
28 | namespace IfcParse {
29 |
30 | /// A helper class for the creation of IFC GlobalIds.
31 | class IFC_PARSE_API IfcGlobalId {
32 | private:
33 | std::string string_data, formatted_string;
34 | boost::uuids::uuid uuid_data;
35 | public:
36 | static const unsigned int length = 22;
37 | IfcGlobalId();
38 | IfcGlobalId(const std::string&);
39 | operator const std::string&() const;
40 | operator const boost::uuids::uuid&() const;
41 | const std::string& formatted() const;
42 | };
43 |
44 | }
45 |
46 | #endif
--------------------------------------------------------------------------------
/src/ifcparse/IfcLateBoundEntity.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCLATEBOUNDENTITY_H
21 | #define IFCLATEBOUNDENTITY_H
22 |
23 | #include
24 |
25 | #include "ifc_parse_api.h"
26 |
27 | #include "../ifcparse/IfcUtil.h"
28 | #include "../ifcparse/IfcWrite.h"
29 | #include "../ifcparse/IfcWritableEntity.h"
30 |
31 | namespace IfcParse {
32 |
33 | // TODO: Somehow these methods should become part of IfcBaseEntity directly so
34 | // that in the IfcFile class the distinction what entity type to be created is
35 | // no longer necessary and weird diagonal casts when creating geometry from
36 | // IfcLateBoundEntities are eliminated.
37 | class IFC_PARSE_API IfcLateBoundEntity : public IfcUtil::IfcBaseEntity {
38 | private:
39 | IfcWrite::IfcWritableEntity* writable_entity();
40 | void invalid_argument(unsigned int i, const std::string& t);
41 | public:
42 | IfcLateBoundEntity(const std::string& s);
43 | IfcLateBoundEntity(IfcAbstractEntity* e);
44 |
45 | bool is(IfcSchema::Type::Enum v) const;
46 | IfcSchema::Type::Enum type() const;
47 | bool is_a(const std::string& s) const;
48 | std::string is_a() const;
49 |
50 | unsigned int id() const;
51 | unsigned int getArgumentCount() const;
52 | IfcUtil::ArgumentType getArgumentType(unsigned int i) const;
53 | IfcSchema::Type::Enum getArgumentEntity(unsigned int i) const;
54 | Argument* getArgument(unsigned int i) const;
55 | const char* getArgumentName(unsigned int i) const;
56 | unsigned getArgumentIndex(const std::string& a) const;
57 | bool getArgumentOptionality(unsigned int i) const;
58 |
59 | IfcEntityList::ptr get_inverse(const std::string& a);
60 |
61 | std::vector getAttributeNames() const;
62 | std::vector getInverseAttributeNames() const;
63 |
64 | void setArgumentAsNull(unsigned int i);
65 | void setArgumentAsInt(unsigned int i, int v);
66 | void setArgumentAsBool(unsigned int i, bool v);
67 | void setArgumentAsDouble(unsigned int i, double v);
68 | void setArgumentAsString(unsigned int i, const std::string& v);
69 | void setArgumentAsEntityInstance(unsigned int i, IfcLateBoundEntity* v);
70 |
71 | void setArgumentAsAggregateOfInt(unsigned int i, const std::vector& v);
72 | void setArgumentAsAggregateOfDouble(unsigned int i, const std::vector& v);
73 | void setArgumentAsAggregateOfString(unsigned int i, const std::vector& v);
74 | void setArgumentAsAggregateOfEntityInstance(unsigned int i, IfcEntityList::ptr v);
75 |
76 | void setArgumentAsAggregateOfAggregateOfInt(unsigned int i, const std::vector< std::vector >& v);
77 | void setArgumentAsAggregateOfAggregateOfDouble(unsigned int i, const std::vector< std::vector >& v);
78 | void setArgumentAsAggregateOfAggregateOfEntityInstance(unsigned int i, IfcEntityListList::ptr v);
79 |
80 | std::string toString();
81 |
82 | bool is_valid();
83 | };
84 |
85 | }
86 |
87 | #endif
--------------------------------------------------------------------------------
/src/ifcparse/IfcLogger.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #include "IfcLogger.h"
21 | #include "../ifcparse/IfcException.h"
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 |
29 |
30 | void Logger::SetProduct(boost::optional product) {
31 | current_product = product;
32 | }
33 | void Logger::SetOutput(std::ostream* l1, std::ostream* l2) {
34 | log1 = l1;
35 | log2 = l2;
36 | if ( ! log2 ) {
37 | log2 = &log_stream;
38 | }
39 | }
40 | void Logger::Message(Logger::Severity type, const std::string& message, IfcAbstractEntity* entity) {
41 | if ( log2 && type >= verbosity ) {
42 | (*log2) << "[" << severity_strings[type] << "] ";
43 | if ( current_product ) {
44 | (*log2) << "{" << (*current_product)->GlobalId() << "} ";
45 | }
46 | (*log2) << message << std::endl;
47 | if ( entity ) (*log2) << entity->toString() << std::endl;
48 | }
49 | }
50 | void Logger::Status(const std::string& message, bool new_line) {
51 | if ( log1 ) {
52 | (*log1) << message;
53 | if ( new_line ) (*log1) << std::endl;
54 | else (*log1) << std::flush;
55 | }
56 | }
57 | void Logger::ProgressBar(int progress) {
58 | if ( log1 ) {
59 | Status("\r[" + std::string(progress,'#') + std::string(50 - progress,' ') + "]", false);
60 | }
61 | }
62 | std::string Logger::GetLog() {
63 | return log_stream.str();
64 | }
65 | void Logger::Verbosity(Logger::Severity v) { verbosity = v; }
66 | Logger::Severity Logger::Verbosity() { return verbosity; }
67 |
68 | std::ostream* Logger::log1 = 0;
69 | std::ostream* Logger::log2 = 0;
70 | std::stringstream Logger::log_stream;
71 | Logger::Severity Logger::verbosity = Logger::LOG_NOTICE;
72 | const char* Logger::severity_strings[] = { "Notice","Warning","Error" };
73 | boost::optional Logger::current_product;
--------------------------------------------------------------------------------
/src/ifcparse/IfcLogger.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCLOGGER_H
21 | #define IFCLOGGER_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #ifdef USE_IFC4
30 | #include "../ifcparse/Ifc4.h"
31 | #else
32 | #include "../ifcparse/Ifc2x3.h"
33 | #endif
34 |
35 | #include
36 |
37 | #include "ifc_parse_api.h"
38 |
39 | class IFC_PARSE_API Logger {
40 | public:
41 | typedef enum { LOG_NOTICE, LOG_WARNING, LOG_ERROR } Severity;
42 | private:
43 | static std::ostream* log1;
44 | static std::ostream* log2;
45 | static std::stringstream log_stream;
46 | static Severity verbosity;
47 | static const char* severity_strings[];
48 | static boost::optional current_product;
49 | public:
50 | static void SetProduct(boost::optional product);
51 | /// Determines to what stream respectively progress and errors are logged
52 | static void SetOutput(std::ostream* l1, std::ostream* l2);
53 | /// Determines the types of log messages to get logged
54 | static void Verbosity(Severity v);
55 | static Severity Verbosity();
56 | /// Log a message to the output stream
57 | static void Message(Severity type, const std::string& message, IfcAbstractEntity* entity=0);
58 | static void Status(const std::string& message, bool new_line=true);
59 | static void ProgressBar(int progress);
60 | static std::string GetLog();
61 | };
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/src/ifcparse/IfcSIPrefix.cpp:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 | #include "IfcSIPrefix.h"
20 |
21 | double IfcParse::IfcSIPrefixToValue(IfcSchema::IfcSIPrefix::IfcSIPrefix v) {
22 | if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_EXA ) return 1.e18;
23 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_PETA ) return 1.e15;
24 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_TERA ) return 1.e12;
25 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_GIGA ) return 1.e9;
26 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_MEGA ) return 1.e6;
27 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_KILO ) return 1.e3;
28 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_HECTO ) return 1.e2;
29 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_DECA ) return 1.;
30 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_DECI ) return 1.e-1;
31 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_CENTI ) return 1.e-2;
32 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_MILLI ) return 1.e-3;
33 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_MICRO ) return 1.e-6;
34 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_NANO ) return 1.e-9;
35 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_PICO ) return 1.e-12;
36 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_FEMTO ) return 1.e-15;
37 | else if ( v == IfcSchema::IfcSIPrefix::IfcSIPrefix_ATTO ) return 1.e-18;
38 | else return 1.;
39 | }
40 |
41 | double IfcParse::get_SI_equivalent(IfcSchema::IfcNamedUnit* named_unit) {
42 | double scale = 1.;
43 | IfcSchema::IfcSIUnit* si_unit = 0;
44 |
45 | if (named_unit->is(IfcSchema::Type::IfcConversionBasedUnit)) {
46 | IfcSchema::IfcConversionBasedUnit* conv_unit = named_unit->as();
47 | IfcSchema::IfcMeasureWithUnit* factor = conv_unit->ConversionFactor();
48 | IfcSchema::IfcUnit* component = factor->UnitComponent();
49 | if (component->is(IfcSchema::Type::IfcSIUnit)) {
50 | si_unit = component->as();
51 | IfcSchema::IfcValue* v = factor->ValueComponent();
52 | scale = *v->entity->getArgument(0);
53 | }
54 | } else if (named_unit->is(IfcSchema::Type::IfcSIUnit)) {
55 | si_unit = named_unit->as();
56 | }
57 | if (si_unit) {
58 | if (si_unit->hasPrefix()) {
59 | scale *= IfcSIPrefixToValue(si_unit->Prefix());
60 | }
61 | } else {
62 | scale = 0.;
63 | }
64 |
65 | return scale;
66 | }
--------------------------------------------------------------------------------
/src/ifcparse/IfcSIPrefix.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFCSIPREFIX
21 | #define IFCSIPREFIX
22 |
23 | #include "../ifcparse/IfcParse.h"
24 | #include "ifc_parse_api.h"
25 |
26 | namespace IfcParse {
27 | IFC_PARSE_API double IfcSIPrefixToValue(IfcSchema::IfcSIPrefix::IfcSIPrefix);
28 | IFC_PARSE_API double get_SI_equivalent(IfcSchema::IfcNamedUnit*);
29 | }
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/ifcparse/IfcSpfStream.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | /*********************************************************************************
21 | * *
22 | * Reads a file in chunks of BUF_SIZE and provides functions to access its *
23 | * contents randomly and character by character *
24 | * *
25 | ********************************************************************************/
26 |
27 | #ifndef IFCSPFSTREAM_H
28 | #define IFCSPFSTREAM_H
29 |
30 | #include
31 | #include
32 |
33 | #include "ifc_parse_api.h"
34 |
35 | // As of IfcOpenShell version 0.3.0 the paging functionality, which
36 | // loads a file on disk into multiple chunks, has been disabled.
37 | // It proved to be an inefficient way of working with large files,
38 | // as often these did not facilitate to be parsed in a sequential
39 | // manner efficiently. To enable the paging functionality uncomment
40 | // the following statement.
41 | // #define BUF_SIZE (8 * 1024 * 1024)
42 |
43 | namespace IfcParse {
44 | /// The IfcSpfStream class represents a ISO 10303-21 IFC-SPF file in memory.
45 | /// The file is interpreted as a sequence of tokens which are lazily
46 | /// interpreted only when requested. If the size of the file is
47 | /// larger than BUF_SIZE, the file is split into seperate pages, of
48 | /// which only one is simultaneously kept in memory, for files
49 | /// that define their entities not in a sequential nature, this is
50 | /// detrimental for the performance of the parser.
51 | class IFC_PARSE_API IfcSpfStream {
52 | private:
53 | FILE* stream;
54 | char* buffer;
55 | unsigned int ptr;
56 | unsigned int len;
57 | void ReadBuffer(bool inc=true);
58 | #ifdef BUF_SIZE
59 | unsigned int offset;
60 | bool paging;
61 | #endif
62 | public:
63 | bool valid;
64 | bool eof;
65 | unsigned int size;
66 | IfcSpfStream(const std::string& fn);
67 | IfcSpfStream(std::istream& f, int len);
68 | IfcSpfStream(void* data, int len);
69 | ~IfcSpfStream();
70 | /// Returns the character at the cursor
71 | char Peek();
72 | /// Returns the character at specified offset
73 | char Read(unsigned int offset);
74 | /// Increment the file cursor and reads new page if necessary
75 | void Inc();
76 | void Close();
77 | /// Moves the file cursor to an arbitrary offset in the file
78 | void Seek(unsigned int offset);
79 | /// Returns the cursor position
80 | unsigned int Tell();
81 | };
82 | }
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/src/ifcparse/ifc_parse_api.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | #ifndef IFC_PARSE_API_H
21 | #define IFC_PARSE_API_H
22 |
23 | #ifdef IFC_SHARED_BUILD
24 | #ifdef _WIN32
25 | #ifdef IFC_PARSE_EXPORTS
26 | #define IFC_PARSE_API __declspec(dllexport)
27 | #else
28 | #define IFC_PARSE_API __declspec(dllimport)
29 | #endif
30 | #else // simply assume *nix + GCC-like compiler
31 | #define IFC_PARSE_API __attribute__((visibility("default")))
32 | #endif
33 | #else
34 | #define IFC_PARSE_API
35 | #endif
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/ifcwrap/IfcPython.i:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | * *
3 | * This file is part of IfcOpenShell. *
4 | * *
5 | * IfcOpenShell is free software: you can redistribute it and/or modify *
6 | * it under the terms of the Lesser GNU General Public License as published by *
7 | * the Free Software Foundation, either version 3.0 of the License, or *
8 | * (at your option) any later version. *
9 | * *
10 | * IfcOpenShell is distributed in the hope that it will be useful, *
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 | * Lesser GNU General Public License for more details. *
14 | * *
15 | * You should have received a copy of the Lesser GNU General Public License *
16 | * along with this program. If not, see . *
17 | * *
18 | ********************************************************************************/
19 |
20 | %begin %{
21 | #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
22 | /* https://github.com/swig/swig/issues/325 */
23 | # include
24 | # include
25 | # include
26 | # include
27 | # include
28 | # include
29 | # include
30 | # include
31 | # include
32 | # include
33 | # include
34 | # include
35 | # include
36 | # include
37 | # include
38 | #endif
39 |
40 | #ifdef _MSC_VER
41 | # pragma warning(push)
42 | # pragma warning(disable : 4127 4244 4702 4510 4512 4610)
43 | # if _MSC_VER > 1800
44 | # pragma warning(disable : 4456 4459)
45 | # endif
46 | #endif
47 | // TODO add '# pragma warning(pop)' to the very end of the file
48 | %}
49 |
50 | %include "std_string.i"
51 | %include "exception.i"
52 |
53 | %exception {
54 | try {
55 | $action
56 | } catch(const IfcParse::IfcAttributeOutOfRangeException& e) {
57 | SWIG_exception(SWIG_IndexError, e.what());
58 | } catch(const IfcParse::IfcException& e) {
59 | SWIG_exception(SWIG_RuntimeError, e.what());
60 | } catch(const std::runtime_error& e) {
61 | SWIG_exception(SWIG_RuntimeError, e.what());
62 | } catch(...) {
63 | SWIG_exception(SWIG_RuntimeError, "An unknown error occurred");
64 | }
65 | }
66 |
67 | %module ifcopenshell_wrapper %{
68 | #include "../ifcgeom/IfcGeom.h"
69 | #include "../ifcgeom/IfcGeomIterator.h"
70 |
71 | #include "../ifcparse/IfcFile.h"
72 | #include "../ifcparse/IfcLateBoundEntity.h"
73 |
74 | #ifdef USE_IFC4
75 | #include "../ifcparse/Ifc4-latebound.h"
76 | #else
77 | #include "../ifcparse/Ifc2x3-latebound.h"
78 | #endif
79 |
80 | #include
81 | %}
82 |
83 | %include "utils/type_conversion.i"
84 |
85 | %include "utils/typemaps_in.i"
86 |
87 | %include "utils/typemaps_out.i"
88 |
89 | %include "IfcGeomWrapper.i"
90 | %include "IfcParseWrapper.i"
91 |
--------------------------------------------------------------------------------
/src/ifcwrap/utils/typemaps_out.i:
--------------------------------------------------------------------------------
1 | %typemap(out) IfcEntityList::ptr {
2 | const unsigned size = $1 ? $1->size() : 0;
3 | $result = PyTuple_New(size);
4 | for (unsigned i = 0; i < size; ++i) {
5 | PyTuple_SetItem($result, i, pythonize((*$1)[i]));
6 | }
7 | }
8 |
9 | %typemap(out) IfcUtil::ArgumentType {
10 | $result = SWIG_Python_str_FromChar(IfcUtil::ArgumentTypeToString($1));
11 | }
12 |
13 | %typemap(out) std::pair {
14 | // The SWIG %exception directive does not take care
15 | // of our typemap. So the attribute conversion block
16 | // is wrapped in a try-catch block manually.
17 | try {
18 | const Argument& arg = *($1.second);
19 | const IfcUtil::ArgumentType type = $1.first;
20 | if (arg.isNull() || type == IfcUtil::Argument_DERIVED) {
21 | Py_INCREF(Py_None);
22 | $result = Py_None;
23 | } else {
24 | switch(type) {
25 | case IfcUtil::Argument_INT: {
26 | int v = arg;
27 | $result = pythonize(v);
28 | break; }
29 | case IfcUtil::Argument_BOOL: {
30 | bool v = arg;
31 | $result = pythonize(v);
32 | break; }
33 | case IfcUtil::Argument_DOUBLE: {
34 | double v = arg;
35 | $result = pythonize(v);
36 | break; }
37 | case IfcUtil::Argument_ENUMERATION:
38 | case IfcUtil::Argument_STRING: {
39 | std::string v = arg;
40 | $result = pythonize(v);
41 | break; }
42 | case IfcUtil::Argument_BINARY: {
43 | boost::dynamic_bitset<> v = arg;
44 | $result = pythonize(v);
45 | break; }
46 | case IfcUtil::Argument_AGGREGATE_OF_INT: {
47 | std::vector v = arg;
48 | $result = pythonize_vector(v);
49 | break; }
50 | case IfcUtil::Argument_AGGREGATE_OF_DOUBLE: {
51 | std::vector v = arg;
52 | $result = pythonize_vector(v);
53 | break; }
54 | case IfcUtil::Argument_AGGREGATE_OF_STRING: {
55 | std::vector v = arg;
56 | $result = pythonize_vector(v);
57 | break; }
58 | case IfcUtil::Argument_ENTITY_INSTANCE: {
59 | IfcUtil::IfcBaseClass* v = arg;
60 | $result = pythonize(v);
61 | break; }
62 | case IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
63 | IfcEntityList::ptr v = arg;
64 | $result = pythonize(v);
65 | break; }
66 | case IfcUtil::Argument_AGGREGATE_OF_BINARY: {
67 | std::vector< boost::dynamic_bitset<> > v = arg;
68 | $result = pythonize_vector(v);
69 | break; }
70 | case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT: {
71 | std::vector< std::vector > v = arg;
72 | $result = pythonize_vector2(v);
73 | break; }
74 | case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: {
75 | std::vector< std::vector > v = arg;
76 | $result = pythonize_vector2(v);
77 | break; }
78 | case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
79 | IfcEntityListList::ptr v = arg;
80 | $result = pythonize(v);
81 | break; }
82 | case IfcUtil::Argument_UNKNOWN:
83 | default:
84 | SWIG_exception(SWIG_RuntimeError,"Unknown attribute type");
85 | break;
86 | }
87 | }
88 | } catch(IfcParse::IfcException& e) {
89 | SWIG_exception(SWIG_RuntimeError, e.what());
90 | } catch(...) {
91 | SWIG_exception(SWIG_RuntimeError, "An unknown error occurred");
92 | }
93 | }
94 |
95 | %define CREATE_VECTOR_TYPEMAP_OUT(template_type)
96 | %typemap(out) std::vector {
97 | $result = pythonize_vector($1);
98 | }
99 | %typemap(out) const std::vector& {
100 | $result = pythonize_vector(*$1);
101 | }
102 | %enddef
103 |
104 | CREATE_VECTOR_TYPEMAP_OUT(int)
105 | CREATE_VECTOR_TYPEMAP_OUT(unsigned int)
106 | CREATE_VECTOR_TYPEMAP_OUT(double)
107 | CREATE_VECTOR_TYPEMAP_OUT(std::string)
108 | CREATE_VECTOR_TYPEMAP_OUT(IfcGeom::Material)
109 |
--------------------------------------------------------------------------------
/src/qtviewer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ################################################################################
19 |
20 | # Find QT header files
21 | SET(QT_MIN_VERSION "4.5.0")
22 | FIND_PACKAGE(Qt4 REQUIRED)
23 | FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
24 |
25 | INCLUDE(${QT_USE_FILE})
26 | SET(CMAKE_PACKAGE_QTGUI TRUE)
27 |
28 | # Find QT header files
29 | IF("$ENV{QT_INCLUDE_DIR}" STREQUAL "")
30 | SET(QT_INCLUDE_DIR "/usr/include/QT4/" CACHE FILEPATH "QT4 header files")
31 | MESSAGE(STATUS "Looking for QT4 include files in: ${QT_INCLUDE_DIR}")
32 | MESSAGE(STATUS "Use QT_INCLUDE_DIR to specify another directory")
33 | ELSE()
34 | SET(QT_INCLUDE_DIR $ENV{QT_INCLUDE_DIR} CACHE FILEPATH "QT4 header files")
35 | MESSAGE(STATUS "Looking for QT4 include files in: ${QT_INCLUDE_DIR}")
36 | ENDIF()
37 |
38 |
39 | INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
40 |
41 | SET(QTviewer_SRCS
42 | ../../src/qtviewer/mainwindow.h
43 | ../../src/qtviewer/mainwindow.cpp
44 | ../../src/qtviewer/main.cpp
45 | )
46 | SET(QTviewer_MOC_SRCS
47 | ../../src/qtviewer/mainwindow.h
48 | )
49 |
50 | QT_WRAP_CPP(QTviewer QTviewer_SRCS ${QTviewer_MOC_SRCS})
51 |
52 | ADD_EXECUTABLE( QTviewer ${QTviewer_SRCS} ${QTviewer_MOC_SRCS})
53 | #http://www.qtcentre.org/wiki/index.php?title=Compiling_Qt4_apps_with_CMake
54 |
55 | TARGET_LINK_LIBRARIES (QTviewer ${IFCLIBS} ${QT_LIBRARIES} ${OPENCASCADE_LIBRARIES})
56 |
--------------------------------------------------------------------------------
/src/qtviewer/main.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #ifndef QT_NO_OPENGL
5 | #include
6 | #endif
7 |
8 | #include "mainwindow.h"
9 |
10 | int main(int argc, char **argv)
11 | {
12 | QApplication app(argc, argv);
13 |
14 | //QGLViewer viewer;
15 |
16 | // Restore the previous viewer state.
17 | //viewer.restoreStateFromFile();
18 |
19 | MainWindow window;
20 | //window.openFile(" ");
21 |
22 | window.show();
23 |
24 | return app.exec();
25 | }
26 |
--------------------------------------------------------------------------------
/src/qtviewer/mainwindow.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "mainwindow.h"
4 | #include
5 |
6 | #include
7 |
8 | MainWindow::MainWindow()
9 | : QMainWindow()
10 | {
11 |
12 |
13 | IfcGeomObjects::Settings(IfcGeomObjects::USE_WORLD_COORDS,true);
14 | IfcGeomObjects::Settings(IfcGeomObjects::WELD_VERTICES,false);
15 | IfcGeomObjects::Settings(IfcGeomObjects::SEW_SHELLS,true);
16 |
17 |
18 |
19 | QMenu *fileMenu = new QMenu(tr("&File"), this);
20 | QAction *openAction = fileMenu->addAction(tr("&Open..."));
21 | openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
22 | QAction *quitAction = fileMenu->addAction(tr("E&xit"));
23 | quitAction->setShortcuts(QKeySequence::Quit);
24 |
25 | menuBar()->addMenu(fileMenu);
26 |
27 | QMenu *viewMenu = new QMenu(tr("&View"), this);
28 | m_backgroundAction = viewMenu->addAction(tr("&Background"));
29 | m_backgroundAction->setEnabled(false);
30 | m_backgroundAction->setCheckable(true);
31 | m_backgroundAction->setChecked(false);
32 | //connect(m_backgroundAction, SIGNAL(toggled(bool)), (QWidget*)m_v, SLOT(setViewBackground(bool)));
33 |
34 | m_outlineAction = viewMenu->addAction(tr("&Outline"));
35 | m_outlineAction->setEnabled(false);
36 | m_outlineAction->setCheckable(true);
37 | m_outlineAction->setChecked(true);
38 | // connect(m_outlineAction, SIGNAL(toggled(bool)), (QWidget*)m_v, SLOT(setViewOutline(bool)));
39 |
40 | menuBar()->addMenu(viewMenu);
41 |
42 | connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
43 | connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
44 |
45 | //setCentralWidget((QWidget*)m_v);
46 | setWindowTitle(tr("IfcOpenShell QT Viewer"));
47 | }
48 |
49 | void MainWindow::openFile(const QString &path)
50 | {
51 | QString fileName;
52 | if (path.isNull())
53 | fileName = QFileDialog::getOpenFileName(this, tr("Open IFC"),
54 | m_currentPath, "IFC files (*.ifc)");
55 | else
56 | fileName = path;
57 |
58 | if (!fileName.isEmpty()) {
59 | QFile file(fileName);
60 | if (!file.exists()) {
61 | QMessageBox::critical(this, tr("Open IFC"),
62 | QString("Could not open file '%1'.").arg(fileName));
63 |
64 | m_outlineAction->setEnabled(false);
65 | m_backgroundAction->setEnabled(false);
66 | return;
67 | }
68 | std::stringstream ss;
69 | if ( ! IfcGeomObjects::Init(fileName.toStdString(),&std::cout,&ss) ) {
70 | QMessageBox::critical(this, tr("Open IFC"),
71 | QString("[Error] unable to parse file '%1'. Or no geometrical entities found" ).arg(fileName));
72 | return;
73 | }
74 |
75 | //connect((QWidget*)m_view, SIGNAL(drawNeeded()), this, SLOT(drawIfcObject()));
76 |
77 | if (!fileName.startsWith(":/")) {
78 | m_currentPath = fileName;
79 | setWindowTitle(tr("%1 - IFCViewer").arg(m_currentPath));
80 | }
81 |
82 | m_outlineAction->setEnabled(true);
83 | m_backgroundAction->setEnabled(true);
84 |
85 | // resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
86 | }
87 | }
88 |
89 |
90 | void MainWindow::draw()
91 | {
92 |
93 |
94 |
95 | }
96 |
97 |
98 |
--------------------------------------------------------------------------------
/src/qtviewer/mainwindow.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef MAINWINDOW_H
4 | #define MAINWINDOW_H
5 |
6 | #include
7 | #include
8 | #include
9 | #include "../ifcgeom/IfcGeomObjects.h"
10 |
11 | class ObjectsView;
12 |
13 | class QGLViewer;
14 |
15 | QT_BEGIN_NAMESPACE
16 | class QAction;
17 | class QGraphicsView;
18 | class QGraphicsScene;
19 | class QGraphicsRectItem;
20 | QT_END_NAMESPACE
21 |
22 | class MainWindow : public QMainWindow
23 | {
24 | Q_OBJECT
25 |
26 | public:
27 | MainWindow();
28 |
29 |
30 | public Q_SLOTS:
31 | void draw();
32 |
33 | public slots:
34 | void openFile(const QString &path = QString());
35 |
36 | private:
37 | QAction *m_nativeAction;
38 | QAction *m_glAction;
39 | QAction *m_imageAction;
40 | QAction *m_highQualityAntialiasingAction;
41 | QAction *m_backgroundAction;
42 | QAction *m_outlineAction;
43 |
44 | QString m_currentPath;
45 | };
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/test/input/IfcCShapeProfileDef.ifc:
--------------------------------------------------------------------------------
1 | ISO-10303-21;
2 | HEADER;
3 | FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
4 | FILE_NAME('IfcCShapeProfileDef.ifc','2014-02-23T12:17:27',(''),('',''),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev','');
5 | FILE_SCHEMA(('IFC2X3'));
6 | ENDSEC;
7 | DATA;
8 | #1=IFCPERSON($,$,'',$,$,$,$,$);
9 | #2=IFCORGANIZATION($,'IfcOpenShell',$,$,$);
10 | #3=IFCPERSONANDORGANIZATION(#1,#2,$);
11 | #4=IFCAPPLICATION(#2,'0.5.0-dev','IfcOpenShell','IfcOpenShell');
12 | #5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1393154247);
13 | #6=IFCDIRECTION((0.,1.,0.));
14 | #7=IFCDIRECTION((1.,0.,0.));
15 | #8=IFCDIRECTION((0.,0.,1.));
16 | #9=IFCCARTESIANPOINT((0.,0.,0.));
17 | #10=IFCAXIS2PLACEMENT3D(#9,#8,#7);
18 | #11=IFCGEOMETRICREPRESENTATIONCONTEXT('Plan','Model',3,1.E-005,#10,#6);
19 | #12=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
20 | #13=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
21 | #14=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
22 | #15=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.0174533),#14);
23 | #16=IFCCONVERSIONBASEDUNIT(#12,.PLANEANGLEUNIT.,'Degrees',#15);
24 | #17=IFCUNITASSIGNMENT((#13,#16));
25 | #18=IFCPROJECT('0dWVy0Y8vE$B13m7$YY1VX',#5,'IfcCShapeProfileDef',$,$,$,$,(#11),#17);
26 | #19=IFCDIRECTION((1.,0.,0.));
27 | #20=IFCDIRECTION((0.,0.,1.));
28 | #21=IFCCARTESIANPOINT((0.,0.,0.));
29 | #22=IFCAXIS2PLACEMENT3D(#21,#20,#19);
30 | #23=IFCLOCALPLACEMENT($,#22);
31 | #24=IFCSITE('18EIqdfBHCG8dtQdgrEE7G',#5,$,$,$,#23,$,$,.ELEMENT.,$,$,$,$,$);
32 | #25=IFCRELAGGREGATES('1PZDvu6jTBnOWX25s7CRQR',#5,$,$,#18,(#24));
33 | #26=IFCDIRECTION((1.,0.,0.));
34 | #27=IFCDIRECTION((0.,0.,1.));
35 | #28=IFCCARTESIANPOINT((0.,0.,0.));
36 | #29=IFCAXIS2PLACEMENT3D(#28,#27,#26);
37 | #30=IFCLOCALPLACEMENT(#23,#29);
38 | #31=IFCBUILDING('2nNmzjoEPEPA0eDThSZlum',#5,$,$,$,#30,$,$,.ELEMENT.,$,$,$);
39 | #32=IFCRELAGGREGATES('2ByfxPqAz5iRLvgscS_Zcz',#5,$,$,#24,(#31));
40 | #33=IFCDIRECTION((1.,0.,0.));
41 | #34=IFCDIRECTION((0.,0.,1.));
42 | #35=IFCCARTESIANPOINT((0.,0.,0.));
43 | #36=IFCAXIS2PLACEMENT3D(#35,#34,#33);
44 | #37=IFCLOCALPLACEMENT(#30,#36);
45 | #38=IFCBUILDINGSTOREY('2Q8wqY1S164A1vNUz3LEIE',#5,$,$,$,#37,$,$,.ELEMENT.,$);
46 | #39=IFCRELAGGREGATES('3rgDF6pw56Ov5SW7WfqsMe',#5,$,$,#31,(#38));
47 | #40=IFCBUILDINGELEMENTPROXY('2Wz6WQMgr51xgotG$Q9XmJ',#5,'profile',$,$,#46,#58,$,$);
48 | #41=IFCRELCONTAINEDINSPATIALSTRUCTURE('37T52A1uzFS867214SlMqu',#5,$,$,(#40),#38);
49 | #42=IFCDIRECTION((1.,0.,0.));
50 | #43=IFCDIRECTION((0.,0.,1.));
51 | #44=IFCCARTESIANPOINT((0.,0.,0.));
52 | #45=IFCAXIS2PLACEMENT3D(#44,#43,#42);
53 | #46=IFCLOCALPLACEMENT($,#45);
54 | #47=IFCDIRECTION((1.,0.));
55 | #48=IFCCARTESIANPOINT((0.,0.));
56 | #49=IFCAXIS2PLACEMENT2D(#48,#47);
57 | #50=IFCDIRECTION((0.,0.,1.));
58 | #51=IFCDIRECTION((1.,0.,0.));
59 | #52=IFCDIRECTION((0.,0.,1.));
60 | #53=IFCCARTESIANPOINT((0.,0.,0.));
61 | #54=IFCAXIS2PLACEMENT3D(#53,#52,#51);
62 | #55=IFCCSHAPEPROFILEDEF(.AREA.,$,#49,50.,25.,5.,10.,$,$);
63 | #56=IFCEXTRUDEDAREASOLID(#55,#54,#50,20.);
64 | #57=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#56));
65 | #58=IFCPRODUCTDEFINITIONSHAPE($,$,(#57));
66 | #59=IFCBUILDINGELEMENTPROXY('0qB16KHWrEAu_H_Yi9_gN5',#5,'profile',$,$,#65,#77,$,$);
67 | #60=IFCRELCONTAINEDINSPATIALSTRUCTURE('2WW5G3oZz9uwEaQn2MHxaa',#5,$,$,(#59),#38);
68 | #61=IFCDIRECTION((1.,0.,0.));
69 | #62=IFCDIRECTION((0.,0.,1.));
70 | #63=IFCCARTESIANPOINT((100.,0.,0.));
71 | #64=IFCAXIS2PLACEMENT3D(#63,#62,#61);
72 | #65=IFCLOCALPLACEMENT($,#64);
73 | #66=IFCDIRECTION((1.,0.));
74 | #67=IFCCARTESIANPOINT((0.,0.));
75 | #68=IFCAXIS2PLACEMENT2D(#67,#66);
76 | #69=IFCDIRECTION((0.,0.,1.));
77 | #70=IFCDIRECTION((1.,0.,0.));
78 | #71=IFCDIRECTION((0.,0.,1.));
79 | #72=IFCCARTESIANPOINT((0.,0.,0.));
80 | #73=IFCAXIS2PLACEMENT3D(#72,#71,#70);
81 | #74=IFCCSHAPEPROFILEDEF(.AREA.,$,#68,50.,25.,5.,10.,2.,$);
82 | #75=IFCEXTRUDEDAREASOLID(#74,#73,#69,20.);
83 | #76=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#75));
84 | #77=IFCPRODUCTDEFINITIONSHAPE($,$,(#76));
85 | ENDSEC;
86 | END-ISO-10303-21;
87 |
--------------------------------------------------------------------------------
/test/input/IfcCircleProfileDef.ifc:
--------------------------------------------------------------------------------
1 | ISO-10303-21;
2 | HEADER;
3 | FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
4 | FILE_NAME('IfcCircleProfileDef.ifc','2014-02-23T12:17:27',(''),('',''),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev','');
5 | FILE_SCHEMA(('IFC2X3'));
6 | ENDSEC;
7 | DATA;
8 | #1=IFCPERSON($,$,'',$,$,$,$,$);
9 | #2=IFCORGANIZATION($,'IfcOpenShell',$,$,$);
10 | #3=IFCPERSONANDORGANIZATION(#1,#2,$);
11 | #4=IFCAPPLICATION(#2,'0.5.0-dev','IfcOpenShell','IfcOpenShell');
12 | #5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1393154247);
13 | #6=IFCDIRECTION((0.,1.,0.));
14 | #7=IFCDIRECTION((1.,0.,0.));
15 | #8=IFCDIRECTION((0.,0.,1.));
16 | #9=IFCCARTESIANPOINT((0.,0.,0.));
17 | #10=IFCAXIS2PLACEMENT3D(#9,#8,#7);
18 | #11=IFCGEOMETRICREPRESENTATIONCONTEXT('Plan','Model',3,1.E-005,#10,#6);
19 | #12=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
20 | #13=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
21 | #14=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
22 | #15=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.0174533),#14);
23 | #16=IFCCONVERSIONBASEDUNIT(#12,.PLANEANGLEUNIT.,'Degrees',#15);
24 | #17=IFCUNITASSIGNMENT((#13,#16));
25 | #18=IFCPROJECT('2QehVu89r7sBGVc65BnqIx',#5,'IfcCircleProfileDef',$,$,$,$,(#11),#17);
26 | #19=IFCDIRECTION((1.,0.,0.));
27 | #20=IFCDIRECTION((0.,0.,1.));
28 | #21=IFCCARTESIANPOINT((0.,0.,0.));
29 | #22=IFCAXIS2PLACEMENT3D(#21,#20,#19);
30 | #23=IFCLOCALPLACEMENT($,#22);
31 | #24=IFCSITE('1OlSQImpTDewLEbzb$U3_x',#5,$,$,$,#23,$,$,.ELEMENT.,$,$,$,$,$);
32 | #25=IFCRELAGGREGATES('3DL40LKfrDkQku7IV8swA6',#5,$,$,#18,(#24));
33 | #26=IFCDIRECTION((1.,0.,0.));
34 | #27=IFCDIRECTION((0.,0.,1.));
35 | #28=IFCCARTESIANPOINT((0.,0.,0.));
36 | #29=IFCAXIS2PLACEMENT3D(#28,#27,#26);
37 | #30=IFCLOCALPLACEMENT(#23,#29);
38 | #31=IFCBUILDING('1q6K1nCsr5TQ8XggyI937I',#5,$,$,$,#30,$,$,.ELEMENT.,$,$,$);
39 | #32=IFCRELAGGREGATES('1s3B1qUeH0uACbj7HVUEWS',#5,$,$,#24,(#31));
40 | #33=IFCDIRECTION((1.,0.,0.));
41 | #34=IFCDIRECTION((0.,0.,1.));
42 | #35=IFCCARTESIANPOINT((0.,0.,0.));
43 | #36=IFCAXIS2PLACEMENT3D(#35,#34,#33);
44 | #37=IFCLOCALPLACEMENT(#30,#36);
45 | #38=IFCBUILDINGSTOREY('2NXm3KklDB8P0_ghcPjrHX',#5,$,$,$,#37,$,$,.ELEMENT.,$);
46 | #39=IFCRELAGGREGATES('0RWVfnFD1FYxLKs80Elmfb',#5,$,$,#31,(#38));
47 | #40=IFCBUILDINGELEMENTPROXY('0VvlqPNMHFXvNiinWkSe6x',#5,'profile',$,$,#46,#58,$,$);
48 | #41=IFCRELCONTAINEDINSPATIALSTRUCTURE('3vv32q5cT27AbLbpFs79$6',#5,$,$,(#40),#38);
49 | #42=IFCDIRECTION((1.,0.,0.));
50 | #43=IFCDIRECTION((0.,0.,1.));
51 | #44=IFCCARTESIANPOINT((0.,0.,0.));
52 | #45=IFCAXIS2PLACEMENT3D(#44,#43,#42);
53 | #46=IFCLOCALPLACEMENT($,#45);
54 | #47=IFCDIRECTION((1.,0.));
55 | #48=IFCCARTESIANPOINT((0.,0.));
56 | #49=IFCAXIS2PLACEMENT2D(#48,#47);
57 | #50=IFCDIRECTION((0.,0.,1.));
58 | #51=IFCDIRECTION((1.,0.,0.));
59 | #52=IFCDIRECTION((0.,0.,1.));
60 | #53=IFCCARTESIANPOINT((0.,0.,0.));
61 | #54=IFCAXIS2PLACEMENT3D(#53,#52,#51);
62 | #55=IFCCIRCLEPROFILEDEF(.AREA.,$,#49,25.);
63 | #56=IFCEXTRUDEDAREASOLID(#55,#54,#50,20.);
64 | #57=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#56));
65 | #58=IFCPRODUCTDEFINITIONSHAPE($,$,(#57));
66 | #59=IFCBUILDINGELEMENTPROXY('3kvG86uhj1YuaKDAy6ngZO',#5,'profile',$,$,#65,#77,$,$);
67 | #60=IFCRELCONTAINEDINSPATIALSTRUCTURE('3pqeZ0fbP1k9FNyVEg$Ie2',#5,$,$,(#59),#38);
68 | #61=IFCDIRECTION((1.,0.,0.));
69 | #62=IFCDIRECTION((0.,0.,1.));
70 | #63=IFCCARTESIANPOINT((100.,0.,0.));
71 | #64=IFCAXIS2PLACEMENT3D(#63,#62,#61);
72 | #65=IFCLOCALPLACEMENT($,#64);
73 | #66=IFCDIRECTION((1.,0.));
74 | #67=IFCCARTESIANPOINT((0.,0.));
75 | #68=IFCAXIS2PLACEMENT2D(#67,#66);
76 | #69=IFCDIRECTION((0.,0.,1.));
77 | #70=IFCDIRECTION((1.,0.,0.));
78 | #71=IFCDIRECTION((0.,0.,1.));
79 | #72=IFCCARTESIANPOINT((0.,0.,0.));
80 | #73=IFCAXIS2PLACEMENT3D(#72,#71,#70);
81 | #74=IFCCIRCLEHOLLOWPROFILEDEF(.AREA.,$,#68,25.,5.);
82 | #75=IFCEXTRUDEDAREASOLID(#74,#73,#69,20.);
83 | #76=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#75));
84 | #77=IFCPRODUCTDEFINITIONSHAPE($,$,(#76));
85 | ENDSEC;
86 | END-ISO-10303-21;
87 |
--------------------------------------------------------------------------------
/test/input/IfcCompositeProfileDef.ifc:
--------------------------------------------------------------------------------
1 | ISO-10303-21;
2 | HEADER;
3 | FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
4 | FILE_NAME('IfcCompositeProfileDef.ifc','2014-03-16T10:22:14',(''),('',''),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev','');
5 | FILE_SCHEMA(('IFC2X3'));
6 | ENDSEC;
7 | DATA;
8 | #1=IFCCARTESIANPOINT((40.,0.));
9 | #2=IFCDIRECTION((0.,-1.));
10 | #3=IFCDIRECTION((1.,0.));
11 | #4=IFCCARTESIANPOINT((40.,0.));
12 | #5=IFCDIRECTION((1.,0.));
13 | #6=IFCDIRECTION((0.,-1.));
14 | #7=IFCDIRECTION((1.,0.));
15 | #8=IFCCARTESIANPOINT((0.,0.));
16 | #9=IFCAXIS2PLACEMENT2D(#8,#7);
17 | #10=IFCDIRECTION((1.,0.));
18 | #11=IFCCARTESIANPOINT((0.,0.));
19 | #12=IFCAXIS2PLACEMENT2D(#11,#10);
20 | #13=IFCDIRECTION((1.,0.));
21 | #14=IFCCARTESIANPOINT((0.,0.));
22 | #15=IFCAXIS2PLACEMENT2D(#14,#13);
23 | #16=IFCDIRECTION((1.,0.));
24 | #17=IFCCARTESIANPOINT((80.,0.));
25 | #18=IFCAXIS2PLACEMENT2D(#17,#16);
26 | #19=IFCLSHAPEPROFILEDEF(.AREA.,$,#12,50.,25.,5.,1.,2.,2.,$,$);
27 | #20=IFCTSHAPEPROFILEDEF(.AREA.,$,#15,50.,40.,10.,10.,3.,2.,1.,2.,2.,$);
28 | #21=IFCCARTESIANTRANSFORMATIONOPERATOR2D(#3,#2,#1,$);
29 | #22=IFCCARTESIANTRANSFORMATIONOPERATOR2D(#6,#5,#4,0.3);
30 | #23=IFCISHAPEPROFILEDEF(.AREA.,$,#9,25.,50.,5.,5.,2.);
31 | #24=IFCDERIVEDPROFILEDEF(.AREA.,$,#19,#21,$);
32 | #25=IFCDERIVEDPROFILEDEF(.AREA.,$,#20,#22,$);
33 | #26=IFCCSHAPEPROFILEDEF(.AREA.,$,#18,50.,25.,5.,10.,2.,$);
34 | #27=IFCPERSON($,$,'',$,$,$,$,$);
35 | #28=IFCORGANIZATION($,'IfcOpenShell',$,$,$);
36 | #29=IFCPERSONANDORGANIZATION(#27,#28,$);
37 | #30=IFCAPPLICATION(#28,'0.5.0-dev','IfcOpenShell','IfcOpenShell');
38 | #31=IFCOWNERHISTORY(#29,#30,$,.ADDED.,$,#29,#30,1394961734);
39 | #32=IFCDIRECTION((0.,1.,0.));
40 | #33=IFCDIRECTION((1.,0.,0.));
41 | #34=IFCDIRECTION((0.,0.,1.));
42 | #35=IFCCARTESIANPOINT((0.,0.,0.));
43 | #36=IFCAXIS2PLACEMENT3D(#35,#34,#33);
44 | #37=IFCGEOMETRICREPRESENTATIONCONTEXT('Plan','Model',3,1.E-005,#36,#32);
45 | #38=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
46 | #39=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
47 | #40=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
48 | #41=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.0174533),#40);
49 | #42=IFCCONVERSIONBASEDUNIT(#38,.PLANEANGLEUNIT.,'Degrees',#41);
50 | #43=IFCUNITASSIGNMENT((#39,#42));
51 | #44=IFCPROJECT('2ksZObKFD9HusrYk4uMUU9',#31,'IfcCompositeProfileDef',$,$,$,$,(#37),#43);
52 | #45=IFCDIRECTION((1.,0.,0.));
53 | #46=IFCDIRECTION((0.,0.,1.));
54 | #47=IFCCARTESIANPOINT((0.,0.,0.));
55 | #48=IFCAXIS2PLACEMENT3D(#47,#46,#45);
56 | #49=IFCLOCALPLACEMENT($,#48);
57 | #50=IFCSITE('3UH8_fRJ14bO11RLWcfDaG',#31,$,$,$,#49,$,$,.ELEMENT.,$,$,$,$,$);
58 | #51=IFCRELAGGREGATES('0d_e2pRBz5EwbcE2Jlxmor',#31,$,$,#44,(#50));
59 | #52=IFCDIRECTION((1.,0.,0.));
60 | #53=IFCDIRECTION((0.,0.,1.));
61 | #54=IFCCARTESIANPOINT((0.,0.,0.));
62 | #55=IFCAXIS2PLACEMENT3D(#54,#53,#52);
63 | #56=IFCLOCALPLACEMENT(#49,#55);
64 | #57=IFCBUILDING('0_d_HoUTX9CRwB2hQNCKfF',#31,$,$,$,#56,$,$,.ELEMENT.,$,$,$);
65 | #58=IFCRELAGGREGATES('3YNTjz3UTAreL7rtMwgZja',#31,$,$,#50,(#57));
66 | #59=IFCDIRECTION((1.,0.,0.));
67 | #60=IFCDIRECTION((0.,0.,1.));
68 | #61=IFCCARTESIANPOINT((0.,0.,0.));
69 | #62=IFCAXIS2PLACEMENT3D(#61,#60,#59);
70 | #63=IFCLOCALPLACEMENT(#56,#62);
71 | #64=IFCBUILDINGSTOREY('2r7DzLsTvBOvBpy8KFQofF',#31,$,$,$,#63,$,$,.ELEMENT.,$);
72 | #65=IFCRELAGGREGATES('1NiveFQ1n2N9_KPmICXHc8',#31,$,$,#57,(#64));
73 | #66=IFCBUILDINGELEMENTPROXY('0Xroij9BHE2BHPOGPuqa$d',#31,'profile',$,$,#72,#81,$,$);
74 | #67=IFCRELCONTAINEDINSPATIALSTRUCTURE('0duzsVh356ivGmTWCOFWGF',#31,$,$,(#66),#64);
75 | #68=IFCDIRECTION((1.,0.,0.));
76 | #69=IFCDIRECTION((0.,0.,1.));
77 | #70=IFCCARTESIANPOINT((0.,0.,0.));
78 | #71=IFCAXIS2PLACEMENT3D(#70,#69,#68);
79 | #72=IFCLOCALPLACEMENT($,#71);
80 | #73=IFCDIRECTION((0.,0.,1.));
81 | #74=IFCDIRECTION((1.,0.,0.));
82 | #75=IFCDIRECTION((0.,0.,1.));
83 | #76=IFCCARTESIANPOINT((0.,0.,0.));
84 | #77=IFCAXIS2PLACEMENT3D(#76,#75,#74);
85 | #78=IFCCOMPOSITEPROFILEDEF(.AREA.,'IFC',(#23,#24,#25,#26),$);
86 | #79=IFCEXTRUDEDAREASOLID(#78,#77,#73,20.);
87 | #80=IFCSHAPEREPRESENTATION(#37,'Body','SweptSolid',(#79));
88 | #81=IFCPRODUCTDEFINITIONSHAPE($,$,(#80));
89 | ENDSEC;
90 | END-ISO-10303-21;
91 |
--------------------------------------------------------------------------------
/test/input/IfcEllipseProfileDef.ifc:
--------------------------------------------------------------------------------
1 | ISO-10303-21;
2 | HEADER;
3 | FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
4 | FILE_NAME('IfcEllipseProfileDef.ifc','2014-03-08T17:03:55',(''),('',''),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev','');
5 | FILE_SCHEMA(('IFC2X3'));
6 | ENDSEC;
7 | DATA;
8 | #1=IFCPERSON($,$,'',$,$,$,$,$);
9 | #2=IFCORGANIZATION($,'IfcOpenShell',$,$,$);
10 | #3=IFCPERSONANDORGANIZATION(#1,#2,$);
11 | #4=IFCAPPLICATION(#2,'0.5.0-dev','IfcOpenShell','IfcOpenShell');
12 | #5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1394294635);
13 | #6=IFCDIRECTION((0.,1.,0.));
14 | #7=IFCDIRECTION((1.,0.,0.));
15 | #8=IFCDIRECTION((0.,0.,1.));
16 | #9=IFCCARTESIANPOINT((0.,0.,0.));
17 | #10=IFCAXIS2PLACEMENT3D(#9,#8,#7);
18 | #11=IFCGEOMETRICREPRESENTATIONCONTEXT('Plan','Model',3,1.E-005,#10,#6);
19 | #12=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
20 | #13=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
21 | #14=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
22 | #15=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.0174533),#14);
23 | #16=IFCCONVERSIONBASEDUNIT(#12,.PLANEANGLEUNIT.,'Degrees',#15);
24 | #17=IFCUNITASSIGNMENT((#13,#16));
25 | #18=IFCPROJECT('3zPj9qt6b9uuqkZQigbIUL',#5,'IfcEllipseProfileDef',$,$,$,$,(#11),#17);
26 | #19=IFCDIRECTION((1.,0.,0.));
27 | #20=IFCDIRECTION((0.,0.,1.));
28 | #21=IFCCARTESIANPOINT((0.,0.,0.));
29 | #22=IFCAXIS2PLACEMENT3D(#21,#20,#19);
30 | #23=IFCLOCALPLACEMENT($,#22);
31 | #24=IFCSITE('0fzyNsjdH8vOcUjt8$PuFb',#5,$,$,$,#23,$,$,.ELEMENT.,$,$,$,$,$);
32 | #25=IFCRELAGGREGATES('3b6NTLFl90y9B9mkk3Apl7',#5,$,$,#18,(#24));
33 | #26=IFCDIRECTION((1.,0.,0.));
34 | #27=IFCDIRECTION((0.,0.,1.));
35 | #28=IFCCARTESIANPOINT((0.,0.,0.));
36 | #29=IFCAXIS2PLACEMENT3D(#28,#27,#26);
37 | #30=IFCLOCALPLACEMENT(#23,#29);
38 | #31=IFCBUILDING('2sB5jIogHAcufB_vBdB8z$',#5,$,$,$,#30,$,$,.ELEMENT.,$,$,$);
39 | #32=IFCRELAGGREGATES('3r5mQcTMjAWPCUBO3584B8',#5,$,$,#24,(#31));
40 | #33=IFCDIRECTION((1.,0.,0.));
41 | #34=IFCDIRECTION((0.,0.,1.));
42 | #35=IFCCARTESIANPOINT((0.,0.,0.));
43 | #36=IFCAXIS2PLACEMENT3D(#35,#34,#33);
44 | #37=IFCLOCALPLACEMENT(#30,#36);
45 | #38=IFCBUILDINGSTOREY('21OPnmQjPC7fB2hCmAGxl2',#5,$,$,$,#37,$,$,.ELEMENT.,$);
46 | #39=IFCRELAGGREGATES('0FyTJUr$b0Vx0H9qUG_MEf',#5,$,$,#31,(#38));
47 | #40=IFCBUILDINGELEMENTPROXY('2Obawd97P7S8UAzLkXlrkZ',#5,'profile',$,$,#46,#58,$,$);
48 | #41=IFCRELCONTAINEDINSPATIALSTRUCTURE('0TJZk7Mo95f8zg0_jQmfrn',#5,$,$,(#40),#38);
49 | #42=IFCDIRECTION((1.,0.,0.));
50 | #43=IFCDIRECTION((0.,0.,1.));
51 | #44=IFCCARTESIANPOINT((0.,0.,0.));
52 | #45=IFCAXIS2PLACEMENT3D(#44,#43,#42);
53 | #46=IFCLOCALPLACEMENT($,#45);
54 | #47=IFCDIRECTION((1.,0.));
55 | #48=IFCCARTESIANPOINT((0.,0.));
56 | #49=IFCAXIS2PLACEMENT2D(#48,#47);
57 | #50=IFCDIRECTION((0.,0.,1.));
58 | #51=IFCDIRECTION((1.,0.,0.));
59 | #52=IFCDIRECTION((0.,0.,1.));
60 | #53=IFCCARTESIANPOINT((0.,0.,0.));
61 | #54=IFCAXIS2PLACEMENT3D(#53,#52,#51);
62 | #55=IFCELLIPSEPROFILEDEF(.AREA.,$,#49,25.,15.);
63 | #56=IFCEXTRUDEDAREASOLID(#55,#54,#50,20.);
64 | #57=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#56));
65 | #58=IFCPRODUCTDEFINITIONSHAPE($,$,(#57));
66 | #59=IFCBUILDINGELEMENTPROXY('0NBhbTBuH8WhOr_fE1ET$R',#5,'profile',$,$,#65,#77,$,$);
67 | #60=IFCRELCONTAINEDINSPATIALSTRUCTURE('0_wTPh_ELEcAwL3MN1Xjzj',#5,$,$,(#59),#38);
68 | #61=IFCDIRECTION((1.,0.,0.));
69 | #62=IFCDIRECTION((0.,0.,1.));
70 | #63=IFCCARTESIANPOINT((100.,0.,0.));
71 | #64=IFCAXIS2PLACEMENT3D(#63,#62,#61);
72 | #65=IFCLOCALPLACEMENT($,#64);
73 | #66=IFCDIRECTION((1.,0.));
74 | #67=IFCCARTESIANPOINT((0.,0.));
75 | #68=IFCAXIS2PLACEMENT2D(#67,#66);
76 | #69=IFCDIRECTION((0.,0.,1.));
77 | #70=IFCDIRECTION((1.,0.,0.));
78 | #71=IFCDIRECTION((0.,0.,1.));
79 | #72=IFCCARTESIANPOINT((0.,0.,0.));
80 | #73=IFCAXIS2PLACEMENT3D(#72,#71,#70);
81 | #74=IFCELLIPSEPROFILEDEF(.AREA.,$,#68,15.,25.);
82 | #75=IFCEXTRUDEDAREASOLID(#74,#73,#69,20.);
83 | #76=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#75));
84 | #77=IFCPRODUCTDEFINITIONSHAPE($,$,(#76));
85 | ENDSEC;
86 | END-ISO-10303-21;
87 |
--------------------------------------------------------------------------------
/test/input/IfcZShapeProfileDef.ifc:
--------------------------------------------------------------------------------
1 | ISO-10303-21;
2 | HEADER;
3 | FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
4 | FILE_NAME('IfcZShapeProfileDef.ifc','2014-02-23T12:17:26',(''),('',''),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev','');
5 | FILE_SCHEMA(('IFC2X3'));
6 | ENDSEC;
7 | DATA;
8 | #1=IFCPERSON($,$,'',$,$,$,$,$);
9 | #2=IFCORGANIZATION($,'IfcOpenShell',$,$,$);
10 | #3=IFCPERSONANDORGANIZATION(#1,#2,$);
11 | #4=IFCAPPLICATION(#2,'0.5.0-dev','IfcOpenShell','IfcOpenShell');
12 | #5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1393154246);
13 | #6=IFCDIRECTION((0.,1.,0.));
14 | #7=IFCDIRECTION((1.,0.,0.));
15 | #8=IFCDIRECTION((0.,0.,1.));
16 | #9=IFCCARTESIANPOINT((0.,0.,0.));
17 | #10=IFCAXIS2PLACEMENT3D(#9,#8,#7);
18 | #11=IFCGEOMETRICREPRESENTATIONCONTEXT('Plan','Model',3,1.E-005,#10,#6);
19 | #12=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
20 | #13=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
21 | #14=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
22 | #15=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.0174533),#14);
23 | #16=IFCCONVERSIONBASEDUNIT(#12,.PLANEANGLEUNIT.,'Degrees',#15);
24 | #17=IFCUNITASSIGNMENT((#13,#16));
25 | #18=IFCPROJECT('2xysnmCqT26vNI$aSsYXTO',#5,'IfcZShapeProfileDef',$,$,$,$,(#11),#17);
26 | #19=IFCDIRECTION((1.,0.,0.));
27 | #20=IFCDIRECTION((0.,0.,1.));
28 | #21=IFCCARTESIANPOINT((0.,0.,0.));
29 | #22=IFCAXIS2PLACEMENT3D(#21,#20,#19);
30 | #23=IFCLOCALPLACEMENT($,#22);
31 | #24=IFCSITE('1ul3e381DAqxxPikhkB6Qz',#5,$,$,$,#23,$,$,.ELEMENT.,$,$,$,$,$);
32 | #25=IFCRELAGGREGATES('1o7wk83jrAA9WN5dUaVi7j',#5,$,$,#18,(#24));
33 | #26=IFCDIRECTION((1.,0.,0.));
34 | #27=IFCDIRECTION((0.,0.,1.));
35 | #28=IFCCARTESIANPOINT((0.,0.,0.));
36 | #29=IFCAXIS2PLACEMENT3D(#28,#27,#26);
37 | #30=IFCLOCALPLACEMENT(#23,#29);
38 | #31=IFCBUILDING('25mGHsRtT1G9ye5DF_yWRK',#5,$,$,$,#30,$,$,.ELEMENT.,$,$,$);
39 | #32=IFCRELAGGREGATES('3ig$czHyn44e9z_09tJlEW',#5,$,$,#24,(#31));
40 | #33=IFCDIRECTION((1.,0.,0.));
41 | #34=IFCDIRECTION((0.,0.,1.));
42 | #35=IFCCARTESIANPOINT((0.,0.,0.));
43 | #36=IFCAXIS2PLACEMENT3D(#35,#34,#33);
44 | #37=IFCLOCALPLACEMENT(#30,#36);
45 | #38=IFCBUILDINGSTOREY('0gquwm1oXFiR48aW6D6xfh',#5,$,$,$,#37,$,$,.ELEMENT.,$);
46 | #39=IFCRELAGGREGATES('1OS_upnnL8BfYZodhCacHJ',#5,$,$,#31,(#38));
47 | #40=IFCBUILDINGELEMENTPROXY('1KGlDKo2z4shOSM583z1$Y',#5,'profile',$,$,#46,#58,$,$);
48 | #41=IFCRELCONTAINEDINSPATIALSTRUCTURE('02TaRhRoX6RetW2Ux$vbeE',#5,$,$,(#40),#38);
49 | #42=IFCDIRECTION((1.,0.,0.));
50 | #43=IFCDIRECTION((0.,0.,1.));
51 | #44=IFCCARTESIANPOINT((0.,0.,0.));
52 | #45=IFCAXIS2PLACEMENT3D(#44,#43,#42);
53 | #46=IFCLOCALPLACEMENT($,#45);
54 | #47=IFCDIRECTION((1.,0.));
55 | #48=IFCCARTESIANPOINT((0.,0.));
56 | #49=IFCAXIS2PLACEMENT2D(#48,#47);
57 | #50=IFCDIRECTION((0.,0.,1.));
58 | #51=IFCDIRECTION((1.,0.,0.));
59 | #52=IFCDIRECTION((0.,0.,1.));
60 | #53=IFCCARTESIANPOINT((0.,0.,0.));
61 | #54=IFCAXIS2PLACEMENT3D(#53,#52,#51);
62 | #55=IFCZSHAPEPROFILEDEF(.AREA.,$,#49,50.,25.,5.,5.,$,$);
63 | #56=IFCEXTRUDEDAREASOLID(#55,#54,#50,20.);
64 | #57=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#56));
65 | #58=IFCPRODUCTDEFINITIONSHAPE($,$,(#57));
66 | #59=IFCBUILDINGELEMENTPROXY('2ZFfuhwN5F_vBMKpzuJtV9',#5,'profile',$,$,#65,#77,$,$);
67 | #60=IFCRELCONTAINEDINSPATIALSTRUCTURE('2nT1ZSn$nFMuoqiPGvLLWx',#5,$,$,(#59),#38);
68 | #61=IFCDIRECTION((1.,0.,0.));
69 | #62=IFCDIRECTION((0.,0.,1.));
70 | #63=IFCCARTESIANPOINT((100.,0.,0.));
71 | #64=IFCAXIS2PLACEMENT3D(#63,#62,#61);
72 | #65=IFCLOCALPLACEMENT($,#64);
73 | #66=IFCDIRECTION((1.,0.));
74 | #67=IFCCARTESIANPOINT((0.,0.));
75 | #68=IFCAXIS2PLACEMENT2D(#67,#66);
76 | #69=IFCDIRECTION((0.,0.,1.));
77 | #70=IFCDIRECTION((1.,0.,0.));
78 | #71=IFCDIRECTION((0.,0.,1.));
79 | #72=IFCCARTESIANPOINT((0.,0.,0.));
80 | #73=IFCAXIS2PLACEMENT3D(#72,#71,#70);
81 | #74=IFCZSHAPEPROFILEDEF(.AREA.,$,#68,50.,25.,5.,5.,2.,2.);
82 | #75=IFCEXTRUDEDAREASOLID(#74,#73,#69,20.);
83 | #76=IFCSHAPEREPRESENTATION(#11,'Body','SweptSolid',(#75));
84 | #77=IFCPRODUCTDEFINITIONSHAPE($,$,(#76));
85 | ENDSEC;
86 | END-ISO-10303-21;
87 |
--------------------------------------------------------------------------------
/test/input/revit2012_janesville_restaurant.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aothms/IfcOpenShell_CGAL/9ae55ab303ec366a255be214434282cfe5b5140a/test/input/revit2012_janesville_restaurant.zip
--------------------------------------------------------------------------------
/win/build-all.cmd:
--------------------------------------------------------------------------------
1 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 | :: ::
3 | :: This file is part of IfcOpenShell. ::
4 | :: ::
5 | :: IfcOpenShell is free software: you can redistribute it and/or modify ::
6 | :: it under the terms of the Lesser GNU General Public License as published by ::
7 | :: the Free Software Foundation, either version 3.0 of the License, or ::
8 | :: (at your option) any later version. ::
9 | :: ::
10 | :: IfcOpenShell is distributed in the hope that it will be useful, ::
11 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
12 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
13 | :: Lesser GNU General Public License for more details. ::
14 | :: ::
15 | :: You should have received a copy of the Lesser GNU General Public License ::
16 | :: along with this program. If not, see . ::
17 | :: ::
18 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
19 |
20 | :: The first argument is assumed to be a CMake generator and it is passed for build-deps, run-cmake, build-ifcopenshell,
21 | :: and install-ifcopenshell. The second argument is assumed to be a build configuration type and it is passed for build-deps,
22 | :: build-ifcopenshell and install-ifcopenshell. The rest of the arguments are passed for run-cmake.
23 | :: Usage example for doing an optimized vs2015-x64 build with debug information and using IFC 4:
24 | :: > build-all.cmd vs2015-x64 RelWithDebInfo -DUSE_IFC4=1 -DENABLE_BUILD_OPTIMIZATIONS=1
25 |
26 | @echo off
27 |
28 | setlocal EnableDelayedExpansion
29 |
30 | call vs-cfg.cmd %1
31 | if not %ERRORLEVEL%==0 GOTO :Error
32 | :: Use "yes" trick to break the pause in build-deps.cmd
33 | echo y | call .\build-deps %1 %2
34 | if not %ERRORLEVEL%==0 goto :EOF
35 | :: Same trick as in run-cmake.bat
36 | set ARGUMENTS=%*
37 | if not (%1)==() call set ARGUMENTS=%%ARGUMENTS:%1=%%
38 | if not (%2)==() call set ARGUMENTS=%%ARGUMENTS:%2=%%
39 | call .\run-cmake %1 %ARGUMENTS%
40 | if not %ERRORLEVEL%==0 goto :EOF
41 | call .\build-ifcopenshell %1 %2
42 | ECHO %ERRORLEVEL%
43 | if not %ERRORLEVEL%==0 goto :EOF
44 | call .\install-ifcopenshell %1 %2
45 |
--------------------------------------------------------------------------------
/win/build-deps.sh:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | ###############################################################################
21 | # #
22 | # This script installs and builds IfcOpenShell's dependencies using MSYS2 #
23 | # #
24 | # Note that this script is currently a very bare-bones implementation #
25 | # #
26 | ###############################################################################
27 |
28 | set -e
29 |
30 | # Set defaults for missing empty environment variables
31 |
32 | if [ -z "$IFCOS_NUM_BUILD_PROCS" ]; then
33 | IFCOS_NUM_BUILD_PROCS=$(expr $(sysctl -n hw.ncpu 2> /dev/null || cat /proc/cpuinfo | grep processor | wc -l) + 1)
34 | fi
35 |
36 | BUILD_DIR=build-msys
37 | SCRIPT_DIR=`pwd "$0"`
38 |
39 | DEPS_DIR="$SCRIPT_DIR/../deps"
40 | [ -d $DEPS_DIR ] || mkdir -p $DEPS_DIR
41 |
42 | INSTALL_DIR="$SCRIPT_DIR/../deps-msys-installed"
43 |
44 | pacman --noconfirm -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost make swig
45 |
46 | export PATH=/mingw64/bin/:$PATH
47 |
48 | function git_clone_or_pull {
49 | [ -d $2 ] || git clone $1 $2
50 | pushd $2
51 | git pull
52 | popd
53 | }
54 |
55 | function git_clone_and_checkout_revision {
56 | [ -d $2 ] || git clone $1 $2
57 | pushd $2
58 | git checkout $3
59 | popd
60 | }
61 |
62 | # Use a fixed revision in order to prevent introducing breaking changes
63 | git_clone_and_checkout_revision https://github.com/KhronosGroup/OpenCOLLADA.git "$DEPS_DIR/OpenCOLLADA" \
64 | 064a60b65c2c31b94f013820856bc84fb1937cc6
65 | pushd "$DEPS_DIR/OpenCOLLADA"
66 | [ -d $BUILD_DIR ] || mkdir -p $BUILD_DIR
67 | pushd $BUILD_DIR
68 | cmake .. -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR/OpenCOLLADA"
69 | make -j$IFCOS_NUM_BUILD_PROCS
70 | make install
71 | popd
72 |
73 | git_clone_or_pull https://github.com/tpaviot/oce.git "$DEPS_DIR/oce"
74 | git_clone_or_pull https://github.com/QbProg/oce-win-bundle.git "$DEPS_DIR/oce/oce-win-bundle"
75 | pushd "$DEPS_DIR/oce"
76 | [ -d $BUILD_DIR ] || mkdir -p $BUILD_DIR
77 | pushd $BUILD_DIR
78 | # -DOCE_BUILD_SHARED_LIB=0
79 | cmake .. -G "MSYS Makefiles" -DOCE_INSTALL_PREFIX="$INSTALL_DIR/oce" -DOCE_TESTING=0
80 | make -j$IFCOS_NUM_BUILD_PROCS
81 | make install
82 | popd
83 |
84 | popd
85 |
86 | echo IfcOpenShell dependencies installed and built
87 |
--------------------------------------------------------------------------------
/win/build-ifcopenshell.bat:
--------------------------------------------------------------------------------
1 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 | :: ::
3 | :: This file is part of IfcOpenShell. ::
4 | :: ::
5 | :: IfcOpenShell is free software: you can redistribute it and/or modify ::
6 | :: it under the terms of the Lesser GNU General Public License as published by ::
7 | :: the Free Software Foundation, either version 3.0 of the License, or ::
8 | :: (at your option) any later version. ::
9 | :: ::
10 | :: IfcOpenShell is distributed in the hope that it will be useful, ::
11 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
12 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
13 | :: Lesser GNU General Public License for more details. ::
14 | :: ::
15 | :: You should have received a copy of the Lesser GNU General Public License ::
16 | :: along with this program. If not, see . ::
17 | :: ::
18 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
19 |
20 | :: This batch file expects CMake generator as %1 and build configuration type as %2. If not provided,
21 | :: a deduced generator will be used for %1 and BUILD_CFG_DEFAULT for %2 (both set in vs-cfg.cmd)
22 | :: Possible extra parameters are passed for the MSBuild call.
23 |
24 | @echo off
25 | set PROJECT_NAME=IfcOpenShell
26 | echo.
27 |
28 | :: Enable the delayed environment variable expansion needed in VSConfig.cmd.
29 | setlocal EnableDelayedExpansion
30 | set IFCOS_PAUSE_ON_ERROR=
31 |
32 | :: Read cached variables from the most recently modified BuildDepsCache.txt.
33 | for /f "tokens=*" %%f in ('dir BuildDepsCache-*.txt /o:-n /t:a /b') do (
34 | for /f "delims== tokens=1,2" %%G in (%%f) do set %%G=%%H
35 | )
36 |
37 | set GENERATOR=%1
38 | if (%1)==() (
39 | if not defined GEN_SHORTHAND (
40 | echo BuildDepsCache file does and/or GEN_SHORTHAND missing from it. Run build-deps.cmd to create it.
41 | set IFCOS_PAUSE_ON_ERROR=pause
42 | goto :Error
43 | )
44 | set GENERATOR=%GEN_SHORTHAND%
45 | echo Generator not passed, but GEN_SHORTHAND=!GENERATOR! read from BuildDepsCache
46 | echo.
47 | )
48 | call vs-cfg.cmd %GENERATOR%
49 | IF NOT %ERRORLEVEL%==0 GOTO :Error
50 | call build-type-cfg.cmd %2
51 | IF NOT %ERRORLEVEL%==0 GOTO :Error
52 |
53 | echo.
54 | if not defined IFCOS_NUM_BUILD_PROCS set IFCOS_NUM_BUILD_PROCS=%NUMBER_OF_PROCESSORS%
55 | call cecho.cmd 0 13 "* IFCOS_NUM_BUILD_PROCS`t= %IFCOS_NUM_BUILD_PROCS%"
56 | echo.
57 |
58 | call cecho.cmd 0 13 "Building %VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME%"
59 | cmake --build ..\%BUILD_DIR% -- /nologo /m:%IFCOS_NUM_BUILD_PROCS% /p:Platform=%VS_PLATFORM% /p:Configuration=%BUILD_CFG% ^
60 | %3 %4 %5 %6 %7 %8 %9
61 | IF NOT %ERRORLEVEL%==0 GOTO :Error
62 |
63 | echo.
64 | call cecho.cmd 0 10 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% build finished."
65 | set IFCOS_SCRIPT_RET=0
66 | goto :End
67 |
68 | :Error
69 | echo.
70 | call "%~dp0\utils\cecho.cmd" 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% build failed!"
71 | %IFCOS_PAUSE_ON_ERROR%
72 | set IFCOS_SCRIPT_RET=1
73 |
74 | :End
75 | exit /b %IFCOS_SCRIPT_RET%
76 |
--------------------------------------------------------------------------------
/win/build-ifcopenshell.sh:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | set -e
21 |
22 | export PATH=/mingw64/bin/:$PATH
23 |
24 | if [ -z "$IFCOS_NUM_BUILD_PROCS" ]; then
25 | IFCOS_NUM_BUILD_PROCS=$(expr $(sysctl -n hw.ncpu 2> /dev/null || cat /proc/cpuinfo | grep processor | wc -l) + 1)
26 | fi
27 |
28 | pushd ../build-msys
29 | /mingw64/bin/mingw32-make.exe -j$IFCOS_NUM_BUILD_PROCS
30 | popd
31 |
--------------------------------------------------------------------------------
/win/build-type-cfg.cmd:
--------------------------------------------------------------------------------
1 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 | :: ::
3 | :: This file is part of IfcOpenShell. ::
4 | :: ::
5 | :: IfcOpenShell is free software: you can redistribute it and/or modify ::
6 | :: it under the terms of the Lesser GNU General Public License as published by ::
7 | :: the Free Software Foundation, either version 3.0 of the License, or ::
8 | :: (at your option) any later version. ::
9 | :: ::
10 | :: IfcOpenShell is distributed in the hope that it will be useful, ::
11 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
12 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
13 | :: Lesser GNU General Public License for more details. ::
14 | :: ::
15 | :: You should have received a copy of the Lesser GNU General Public License ::
16 | :: along with this program. If not, see . ::
17 | :: ::
18 | ::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::
19 |
20 | :: This script initializes various CMake build configuration type related variables.
21 | :: This batch file expects CMake build configuration type as %1.
22 |
23 | @echo off
24 |
25 | :: Set up variables depending on the used build configuration type.
26 | set BUILD_CFG=%1
27 |
28 | :: The default build types provided by CMake
29 | set BUILD_CFG_MINSIZEREL=MinSizeRel
30 | set BUILD_CFG_RELEASE=Release
31 | set BUILD_CFG_RELWITHDEBINFO=RelWithDebInfo
32 | set BUILD_CFG_DEBUG=Debug
33 | set BUILD_CFG_DEFAULT=%BUILD_CFG_RELWITHDEBINFO%
34 |
35 | IF "!BUILD_CFG!"=="" (
36 | set BUILD_CFG=%BUILD_CFG_DEFAULT%
37 | call utils\cecho.cmd 0 14 "%~nx0: Warning: BUILD_CFG not specified - using the default %BUILD_CFG_DEFAULT%"
38 | )
39 | IF NOT !BUILD_CFG!==%BUILD_CFG_MINSIZEREL% IF NOT !BUILD_CFG!==%BUILD_CFG_RELEASE% (
40 | IF NOT !BUILD_CFG!==%BUILD_CFG_RELWITHDEBINFO% IF NOT !BUILD_CFG!==%BUILD_CFG_DEBUG% (
41 | call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake build configuration type passed: !BUILD_CFG!. Cannot proceed."
42 | exit /b 1
43 | ))
44 |
45 | :: DEBUG_OR_RELEASE and DEBUG_OR_RELEASE_LOWERCASE are "Debug" and "debug" for Debug build and "Release" and
46 | :: "release" for all of the Release variants.
47 | :: POSTFIX_D, POSTFIX_UNDERSCORE_D and POSTFIX_UNDERSCORE_DEBUG are helpers for performing file copies and
48 | :: checking for existence of files. In release build these variables are empty.
49 | set DEBUG_OR_RELEASE=Release
50 | set DEBUG_OR_RELEASE_LOWERCASE=release
51 | set POSTFIX_D=
52 | set POSTFIX_UNDERSCORE_D=
53 | set POSTFIX_UNDERSCORE_DEBUG=
54 | IF %BUILD_CFG%==Debug (
55 | set DEBUG_OR_RELEASE=Debug
56 | set DEBUG_OR_RELEASE_LOWERCASE=debug
57 | set POSTFIX_D=d
58 | set POSTFIX_UNDERSCORE_D=_d
59 | set POSTFIX_UNDERSCORE_DEBUG=_debug
60 | )
61 |
--------------------------------------------------------------------------------
/win/install-ifcopenshell.bat:
--------------------------------------------------------------------------------
1 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 | :: ::
3 | :: This file is part of IfcOpenShell. ::
4 | :: ::
5 | :: IfcOpenShell is free software: you can redistribute it and/or modify ::
6 | :: it under the terms of the Lesser GNU General Public License as published by ::
7 | :: the Free Software Foundation, either version 3.0 of the License, or ::
8 | :: (at your option) any later version. ::
9 | :: ::
10 | :: IfcOpenShell is distributed in the hope that it will be useful, ::
11 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
12 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
13 | :: Lesser GNU General Public License for more details. ::
14 | :: ::
15 | :: You should have received a copy of the Lesser GNU General Public License ::
16 | :: along with this program. If not, see . ::
17 | :: ::
18 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
19 |
20 | :: This batch file expects CMake generator as %1 and build configuration type as %2. If not provided,
21 | :: a deduced generator will be used for %1 and BUILD_CFG_DEFAULT for %2 (both set in vs-cfg.cmd)
22 | :: Possible extra parameters are passed for the MSBuild call.
23 |
24 | @echo off
25 | set PROJECT_NAME=IfcOpenShell
26 | echo.
27 |
28 | :: Enable the delayed environment variable expansion needed in VSConfig.cmd.
29 | setlocal EnableDelayedExpansion
30 | set IFCOS_PAUSE_ON_ERROR=
31 |
32 | :: Read cached variables from the most recently modified BuildDepsCache.txt.
33 | for /f "tokens=*" %%f in ('dir BuildDepsCache-*.txt /o:-n /t:a /b') do (
34 | for /f "delims== tokens=1,2" %%G in (%%f) do set %%G=%%H
35 | )
36 | set GENERATOR=%1
37 | if (%1)==() (
38 | if not defined GEN_SHORTHAND (
39 | echo BuildDepsCache file does and/or GEN_SHORTHAND missing from it. Run build-deps.cmd to create it.
40 | set IFCOS_PAUSE_ON_ERROR=pause
41 | goto :Error
42 | )
43 | set GENERATOR=%GEN_SHORTHAND%
44 | echo Generator not passed, but GEN_SHORTHAND=!GENERATOR! read from BuildDepsCache
45 | echo.
46 | )
47 | call vs-cfg.cmd %GENERATOR%
48 | IF NOT %ERRORLEVEL%==0 GOTO :Error
49 | call build-type-cfg.cmd %2
50 | IF NOT %ERRORLEVEL%==0 GOTO :Error
51 |
52 | echo.
53 | IF "%IFCOS_NUM_BUILD_PROCS%"=="" set IFCOS_NUM_BUILD_PROCS=%NUMBER_OF_PROCESSORS%
54 | call cecho.cmd 0 13 "* IFCOS_NUM_BUILD_PROCS`t= %IFCOS_NUM_BUILD_PROCS%"
55 | echo.
56 |
57 | call cecho.cmd 0 13 "Installing %VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME%"
58 | cmake --build ..\%BUILD_DIR% --target INSTALL -- /nologo /m:%IFCOS_NUM_BUILD_PROCS% /p:Platform=%VS_PLATFORM% ^
59 | /p:Configuration=%BUILD_CFG% %3 %4 %5 %6 %7 %8 %9
60 | IF NOT %ERRORLEVEL%==0 GOTO :Error
61 |
62 | echo.
63 | call cecho.cmd 0 10 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% installation finished."
64 | set IFCOS_SCRIPT_RET=0
65 | goto :End
66 |
67 | :Error
68 | echo.
69 | call "%~dp0\utils\cecho.cmd" 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% installation failed!"
70 | %IFCOS_PAUSE_ON_ERROR%
71 | set IFCOS_SCRIPT_RET=1
72 |
73 | :End
74 | exit /b %IFCOS_SCRIPT_RET%
75 |
--------------------------------------------------------------------------------
/win/install-ifcopenshell.sh:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | set -e
21 |
22 | export PATH=/mingw64/bin/:$PATH
23 |
24 | if [ -z "$IFCOS_NUM_BUILD_PROCS" ]; then
25 | IFCOS_NUM_BUILD_PROCS=$(expr $(sysctl -n hw.ncpu 2> /dev/null || cat /proc/cpuinfo | grep processor | wc -l) + 1)
26 | fi
27 |
28 | pushd ../build-msys
29 | make install -j$IFCOS_NUM_BUILD_PROCS
30 | popd
31 |
--------------------------------------------------------------------------------
/win/patches/OpenCOLLADA_CMakeLists.txt.patch:
--------------------------------------------------------------------------------
1 | diff --git a/CMakeLists.txt b/CMakeLists.txt
2 | index 9e28557..7549c16 100644
3 | --- a/CMakeLists.txt
4 | +++ b/CMakeLists.txt
5 | @@ -271,7 +271,7 @@ add_subdirectory(COLLADASaxFrameworkLoader)
6 | add_subdirectory(COLLADAStreamWriter)
7 |
8 | # building COLLADAValidator app
9 | -add_subdirectory(COLLADAValidator)
10 | +#add_subdirectory(COLLADAValidator)
11 |
12 |
13 | # Library export
14 |
--------------------------------------------------------------------------------
/win/run-cmake.sh:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # #
3 | # This file is part of IfcOpenShell. #
4 | # #
5 | # IfcOpenShell is free software: you can redistribute it and/or modify #
6 | # it under the terms of the Lesser GNU General Public License as published by #
7 | # the Free Software Foundation, either version 3.0 of the License, or #
8 | # (at your option) any later version. #
9 | # #
10 | # IfcOpenShell is distributed in the hope that it will be useful, #
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 | # Lesser GNU General Public License for more details. #
14 | # #
15 | # You should have received a copy of the Lesser GNU General Public License #
16 | # along with this program. If not, see . #
17 | # #
18 | ###############################################################################
19 |
20 | set -e
21 |
22 | export PATH=/mingw64/bin/:$PATH
23 |
24 | BUILD_DIR=../build-msys
25 | [ -d $BUILD_DIR ] || mkdir -p $BUILD_DIR
26 |
27 | CMAKE_INSTALL_PREFIX=../installed-msys
28 |
29 | pushd $BUILD_DIR
30 |
31 | # PYTHON_INCLUDE_DIR=/mingw64/include/python2.7 \
32 | # PYTHON_LIBRARY=/mingw64/lib/python2.7/config/libpython2.7.a \
33 | OCC_INCLUDE_DIR=`pwd`/../deps-msys-installed/oce/include/oce/ \
34 | OCC_LIBRARY_DIR=`pwd`/../deps-msys-installed/oce/Win64/lib/ \
35 | OPENCOLLADA_INCLUDE_DIR=`pwd`/../deps-msys-installed/OpenCOLLADA/include/opencollada/ \
36 | OPENCOLLADA_LIBRARY_DIR=`pwd`/../deps-msys-installed/OpenCOLLADA/lib/opencollada/ \
37 | cmake -G "MSYS Makefiles" ../cmake -DSWIG_DIR=/usr/bin -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX \
38 | -DCMAKE_MAKE_PROGRAM=/mingw64/bin/mingw32-make.exe $@
39 |
40 | popd
41 |
--------------------------------------------------------------------------------
/win/set-python-to-path.bat:
--------------------------------------------------------------------------------
1 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 | :: ::
3 | :: This file is part of IfcOpenShell. ::
4 | :: ::
5 | :: IfcOpenShell is free software: you can redistribute it and/or modify ::
6 | :: it under the terms of the Lesser GNU General Public License as published by ::
7 | :: the Free Software Foundation, either version 3.0 of the License, or ::
8 | :: (at your option) any later version. ::
9 | :: ::
10 | :: IfcOpenShell is distributed in the hope that it will be useful, ::
11 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
12 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
13 | :: Lesser GNU General Public License for more details. ::
14 | :: ::
15 | :: You should have received a copy of the Lesser GNU General Public License ::
16 | :: along with this program. If not, see . ::
17 | :: ::
18 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
19 |
20 | :: Pass x86 or x64 as %1, if not specified x64 assumed.
21 |
22 | @echo off
23 | set TARGET_ARCH=%1
24 | if "%TARGET_ARCH%"=="" set TARGET_ARCH=x64
25 | if not exist "%~dp0BuildDepsCache-%TARGET_ARCH%.txt". (
26 | echo %~dp0BuildDepsCache-%TARGET_ARCH%.txt does not exist
27 | goto :EOF
28 | )
29 | for /f "delims== tokens=1,2" %%G in ("%~dp0BuildDepsCache-%TARGET_ARCH%.txt") do set %%G=%%H
30 | if not defined PYTHONHOME (
31 | echo PYTHONHOME not defined
32 | goto :EOF
33 | )
34 |
35 | echo %PYTHONHOME% set to PATH
36 | set PATH=%PYTHONHOME%;%PATH%
37 |
--------------------------------------------------------------------------------
/win/utils/7za.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aothms/IfcOpenShell_CGAL/9ae55ab303ec366a255be214434282cfe5b5140a/win/utils/7za.exe
--------------------------------------------------------------------------------
/win/utils/cecho.cmd:
--------------------------------------------------------------------------------
1 | :: Usage: call cecho.cmd background foreground "message here"
2 | :: NOTES/TODOS 1) This is super slow 2) leading spaces are omitted 3) printing string with quotes doesn't work (quotes must be escaped awkwardly)
3 | @powershell -command write-host -background %~1 -foreground "%~2" "%3"
4 | @exit /b
5 |
--------------------------------------------------------------------------------
/win/utils/license.txt:
--------------------------------------------------------------------------------
1 | 7-Zip Command line version
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | License for use and distribution
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 |
6 | 7-Zip Copyright (C) 1999-2010 Igor Pavlov.
7 |
8 | 7za.exe is distributed under the GNU LGPL license
9 |
10 | Notes:
11 | You can use 7-Zip on any computer, including a computer in a commercial
12 | organization. You don't need to register or pay for 7-Zip.
13 |
14 |
15 | GNU LGPL information
16 | --------------------
17 |
18 | This library is free software; you can redistribute it and/or
19 | modify it under the terms of the GNU Lesser General Public
20 | License as published by the Free Software Foundation; either
21 | version 2.1 of the License, or (at your option) any later version.
22 |
23 | This library is distributed in the hope that it will be useful,
24 | but WITHOUT ANY WARRANTY; without even the implied warranty of
25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 | Lesser General Public License for more details.
27 |
28 | You can receive a copy of the GNU Lesser General Public License from
29 | http://www.gnu.org/
30 |
--------------------------------------------------------------------------------