Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/build*/
/install*/
/win/BuildDepsCache*.txt
/src/ifcexpressparser/__pycache__
/src/ifcexpressparser/express_parser.py
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Prerequisites
Dependencies
============
* [Boost](http://www.boost.org/)
* Open Cascade *optional*, but required for building IfcGeom)
* Open Cascade *optional*, but required for building IfcGeom
[Official](http://www.opencascade.org/getocc/download/loadocc/) or [community edition](https://github.com/tpaviot/oce)
For converting IFC representation items into BRep solids and tesselated meshes
* [ICU](http://site.icu-project.org/) *optional*
Expand All @@ -34,14 +34,16 @@ the cmake/ folder.

The preferred way to fetch and build this project's dependencies is to use the build scripts
in win/ folder. See [win/readme.md] for more information. Instructions in a nutshell
(assuming Visual Studio x64 environment variables set):
(**assuming Visual Studio 2015 x64 environment variables set**):

> git clone https://github.com/IfcOpenShell/IfcOpenShell.git
> cd oce\win
> build-deps.cmd (defaults to using VS 2015 x64 RelWithDebInfo build)
> run-cmake.bat (defaults to using VS 2015 x64)
> build-deps.cmd (defaults to RelWithDebInfo build)
> run-cmake.bat
> ..\build-vs2015-x64\IfcOpenShell.sln
You can now build the solution using the RelWithDebInfo configuration (freshly created solution by CMake defaults to Debug).
Build the INSTALL project to deploy the headers and binaries into a single location if wanted/needed.

You can now build the solution using the `RelWithDebInfo` configuration (freshly created solution by CMake defaults to `Debug`).
Build the `INSTALL` project to deploy the headers and binaries into a single location if wanted/needed.

Alternatively, the old Visual Studio solution and project files requiring manual work can
be found from the win/sln folder.
Expand Down
13 changes: 10 additions & 3 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ OPTION(UNICODE_SUPPORT "Build IfcOpenShell with Unicode support (requires ICU)."
OPTION(COLLADA_SUPPORT "Build IfcConvert with COLLADA support (requires OpenCOLLADA)." ON)
OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizations on RelWithDebInfo and Release builds." OFF)
#TODO OPTION(IFCCONVERT_DOUBLE_PRECISION "IfcConvert: Use double precision floating-point numbers." OFF)
OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3" OFF)
OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when switching this)" OFF)
OPTION(BUILD_IFCPYTHON "Build IfcPython." ON)
OPTION(BUILD_EXAMPLES "Build example applications." ON)
# TODO QtViewer is deprecated ATM as it uses the 0.4 API
Expand Down Expand Up @@ -217,10 +217,17 @@ if(ENABLE_BUILD_OPTIMIZATIONS)
endif()

IF(MSVC)
# Enforce Unicode for CRT and Win32 API calls
ADD_DEFINITIONS(-D_UNICODE -DUNICODE)
# Disable warnings about unsafe C functions; we could use the safe C99 & C11 versions if we have no need for supporting old compilers.
ADD_DEFINITIONS(-D_UNICODE -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-bigobj) # required for building the big ifcXXX.objs, https://msdn.microsoft.com/en-us/library/ms173499.aspx

# Bump up the warning level from the default 3 to 4.
ADD_DEFINITIONS(-W4)
IF(MSVC_VERSION GREATER 1800) # > 2013
# Disable overeager and false positives causing C4458 ("declaration of 'indentifier' hides class member"), at least for now.
ADD_DEFINITIONS(-wd4458)
ENDIF()
# Link against the static VC runtime
FOREACH(flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
Expand Down
2 changes: 1 addition & 1 deletion src/examples/IfcOpenHouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ boost::none_t const null = boost::none;
// The creation of Nurbs-surface for the IfcSite mesh, to be implemented lateron
void createGroundShape(TopoDS_Shape& shape);

int main(int argc, char** argv) {
int main() {

// The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several
// convenience functions for working with geometry in IFC files.
Expand Down
2 changes: 1 addition & 1 deletion src/ifcconvert/ColladaSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void ColladaSerializer::ColladaExporter::ColladaGeometries::write(const std::str
lines.setMaterial(materials[it->first].name());
lines.setCount((unsigned long)it->second.size());
int offset = 0;
lines.getInputList().push_back(COLLADASW::Input(COLLADASW::InputSemantic::VERTEX, "#" + mesh_id + COLLADASW::LibraryGeometries::VERTICES_ID_SUFFIX, 0));
lines.getInputList().push_back(COLLADASW::Input(COLLADASW::InputSemantic::VERTEX, "#" + mesh_id + COLLADASW::LibraryGeometries::VERTICES_ID_SUFFIX, offset++));
lines.prepareToAppendValues();
lines.appendValues(it->second);
lines.finish();
Expand Down
19 changes: 18 additions & 1 deletion src/ifcconvert/ColladaSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#ifndef COLLADASERIALIZER_H
#define COLLADASERIALIZER_H

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201 4512)
#endif
#include <COLLADASWStreamWriter.h>
#include <COLLADASWPrimitves.h>
#include <COLLADASWLibraryGeometries.h>
Expand All @@ -34,19 +38,25 @@
#include <COLLADASWLibraryMaterials.h>
#include <COLLADASWBaseInputElement.h>
#include <COLLADASWAsset.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include "../ifcgeom/IfcGeomIterator.h"

#include "../ifcconvert/GeometrySerializer.h"

class ColladaSerializer : public GeometrySerializer
{
// TODO The vast amount of implement details of ColladaSerializer could be hidden to the cpp file.
private:
class ColladaExporter
{
private:
class ColladaGeometries : public COLLADASW::LibraryGeometries
{
ColladaGeometries(const ColladaGeometries&); //N/A
ColladaGeometries& operator =(const ColladaGeometries&); //N/A
public:
explicit ColladaGeometries(COLLADASW::StreamWriter& stream)
: COLLADASW::LibraryGeometries(&stream)
Expand All @@ -58,6 +68,9 @@ class ColladaSerializer : public GeometrySerializer
class ColladaScene : public COLLADASW::LibraryVisualScenes
{
private:
ColladaScene(const ColladaScene&); //N/A
ColladaScene& operator =(const ColladaScene&); //N/A

const std::string scene_id;
bool scene_opened;
public:
Expand All @@ -71,9 +84,13 @@ class ColladaSerializer : public GeometrySerializer
};
class ColladaMaterials : public COLLADASW::LibraryMaterials
{
ColladaMaterials(const ColladaMaterials&); //N/A
ColladaMaterials& operator =(const ColladaMaterials&); //N/A
private:
class ColladaEffects : public COLLADASW::LibraryEffects
{
ColladaEffects(const ColladaEffects&); //N/A
ColladaEffects& operator =(const ColladaEffects&); //N/A
public:
explicit ColladaEffects(COLLADASW::StreamWriter& stream)
: COLLADASW::LibraryEffects(&stream)
Expand Down Expand Up @@ -148,7 +165,7 @@ class ColladaSerializer : public GeometrySerializer
bool ready();
void writeHeader();
void write(const IfcGeom::TriangulationElement<double>* o);
void write(const IfcGeom::BRepElement<double>* o) {}
void write(const IfcGeom::BRepElement<double>* /*o*/) {}
void finalize();
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {
Expand Down
10 changes: 4 additions & 6 deletions src/ifcconvert/IfcConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include "../ifcconvert/XmlSerializer.h"
#include "../ifcconvert/SvgSerializer.h"

#include <IGESControl_Controller.hxx>

static std::string DEFAULT_EXTENSION = "obj";

void printVersion() {
Expand Down Expand Up @@ -198,9 +200,7 @@ int main(int argc, char** argv) {
std::set<std::string> entities;
for (std::vector<std::string>::const_iterator it = entity_vector.begin(); it != entity_vector.end(); ++it) {
std::string lowercase_type = *it;
for (std::string::iterator c = lowercase_type.begin(); c != lowercase_type.end(); ++c) {
*c = tolower(*c);
}
std::transform(lowercase_type.begin(), lowercase_type.end(), lowercase_type.begin(), ::tolower);
entities.insert(lowercase_type);
}

Expand All @@ -217,9 +217,7 @@ int main(int argc, char** argv) {
}

std::string output_extension = output_filename.substr(output_filename.size()-4);
for (std::string::iterator c = output_extension.begin(); c != output_extension.end(); ++c) {
*c = tolower(*c);
}
std::transform(output_extension.begin(), output_extension.end(), output_extension.begin(), ::tolower);

// If no entities are specified these are the defaults to skip from output
if (entity_vector.empty()) {
Expand Down
3 changes: 1 addition & 2 deletions src/ifcconvert/IgesSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#ifndef IGESSERIALIZER_H
#define IGESSERIALIZER_H

#include <IGESControl_Controller.hxx>
#include <IGESControl_Writer.hxx>
#include <Interface_Static.hxx>

Expand All @@ -43,7 +42,7 @@ class IgesSerializer : public OpenCascadeBasedSerializer
void finalize() {
writer.Write(out_filename.c_str());
}
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {
void setUnitNameAndMagnitude(const std::string& /*name*/, float magnitude) {
const char* symbol = getSymbolForUnitMagnitude(magnitude);
if (symbol) {
Interface_Static::SetCVal("write.iges.unit", symbol);
Expand Down
7 changes: 4 additions & 3 deletions src/ifcconvert/OpenCascadeBasedSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
#include "../ifcconvert/GeometrySerializer.h"

class OpenCascadeBasedSerializer : public GeometrySerializer {
OpenCascadeBasedSerializer(const OpenCascadeBasedSerializer&); //N/A
OpenCascadeBasedSerializer& operator =(const OpenCascadeBasedSerializer&); //N/A
protected:
const std::string& out_filename;
const std::string out_filename;
const char* getSymbolForUnitMagnitude(float mag);
public:
explicit OpenCascadeBasedSerializer(const std::string& out_filename)
Expand All @@ -35,10 +37,9 @@ class OpenCascadeBasedSerializer : public GeometrySerializer {
{}
virtual ~OpenCascadeBasedSerializer() {}
void writeHeader() {}
void writeMaterial(const IfcGeom::SurfaceStyle& style) {}
bool ready();
virtual void writeShape(const TopoDS_Shape& shape) = 0;
void write(const IfcGeom::TriangulationElement<double>* o) {}
void write(const IfcGeom::TriangulationElement<double>* /*o*/) {}
void write(const IfcGeom::BRepElement<double>* o);
bool isTesselated() const { return false; }
void setFile(IfcParse::IfcFile*) {}
Expand Down
3 changes: 1 addition & 2 deletions src/ifcconvert/StepSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#ifndef STEPSERIALIZER_H
#define STEPSERIALIZER_H

#include <STEPControl_Controller.hxx>
#include <STEPControl_Writer.hxx>
#include <Interface_Static.hxx>

Expand Down Expand Up @@ -49,7 +48,7 @@ class StepSerializer : public OpenCascadeBasedSerializer
writer.Write(out_filename.c_str());
std::cout.rdbuf(sb);
}
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {
void setUnitNameAndMagnitude(const std::string& /*name*/, float magnitude) {
const char* symbol = getSymbolForUnitMagnitude(magnitude);
if (symbol) {
Interface_Static::SetCVal("write.step.unit", symbol);
Expand Down
2 changes: 1 addition & 1 deletion src/ifcconvert/SvgSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement<double>* o) {
typedef IfcSchema::IfcRelAggregates decomposition_element;
#endif

while (true) {
for (;;) {
// Iterate over the decomposing element to find the parent IfcBuildingStorey
decomposition_element::list::ptr decomposes = obdef->Decomposes();
if (!decomposes->size()) {
Expand Down
6 changes: 2 additions & 4 deletions src/ifcconvert/SvgSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class SvgSerializer : public GeometrySerializer {
public:
typedef std::pair<std::string, std::vector<util::string_buffer> > path_object;
protected:
const char* getSymbolForUnitMagnitude(float mag);
std::ofstream svg_file;
double xmin, ymin, xmax, ymax, width, height;
boost::optional<double> section_height;
Expand All @@ -62,15 +61,14 @@ class SvgSerializer : public GeometrySerializer {
virtual 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; }
virtual ~SvgSerializer() {}
virtual void writeHeader();
virtual void writeMaterial(const IfcGeom::SurfaceStyle& style) {}
virtual bool ready();
virtual void write(const IfcGeom::TriangulationElement<double>* o) {}
virtual void write(const IfcGeom::TriangulationElement<double>* /*o*/) {}
virtual void write(const IfcGeom::BRepElement<double>* o);
virtual void write(path_object& p, const TopoDS_Wire& wire);
virtual path_object& start_path(IfcSchema::IfcBuildingStorey* storey, const std::string& id);
virtual bool isTesselated() const { return false; }
virtual void finalize();
virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) {}
virtual void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
virtual void setFile(IfcParse::IfcFile* f) { file = f; }
virtual void setBoundingRectangle(double width, double height);
virtual void setSectionHeight(double h) { section_height = h; }
Expand Down
4 changes: 2 additions & 2 deletions src/ifcconvert/WavefrontObjSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class WaveFrontOBJSerializer : public GeometrySerializer {
void writeHeader();
void writeMaterial(const IfcGeom::Material& style);
void write(const IfcGeom::TriangulationElement<double>* o);
void write(const IfcGeom::BRepElement<double>* o) {}
void write(const IfcGeom::BRepElement<double>* /*o*/) {}
void finalize() {}
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {}
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
void setFile(IfcParse::IfcFile*) {}
};

Expand Down
24 changes: 23 additions & 1 deletion src/ifcconvert/XmlSerializer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/

#include <map>

#include <boost/property_tree/ptree.hpp>
Expand All @@ -7,6 +26,8 @@

#include "XmlSerializer.h"

#include <algorithm>

using boost::property_tree::ptree;
using namespace IfcSchema;

Expand Down Expand Up @@ -58,7 +79,8 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
unit_name = unit->Name();
}

for (std::string::iterator c = unit_name.begin(); c != unit_name.end(); ++c) *c = tolower(*c);
// TODO add toLower() and toUpper() string helper functions for the project
std::transform(unit_name.begin(), unit_name.end(), unit_name.begin(), ::tolower);

value = unit_name;
}
Expand Down
4 changes: 3 additions & 1 deletion src/ifcexpressparser/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ the IFC schema and will most likely fail on any other Express schema.

The code can be invoked in the following way and results in two header files
and a single implementation file named according to the schema name in the
Express file. A python 3 interpreter with the pyparsing library is required.
Express file. A python 3 interpreter with the pyparsing [1] library is required.

$ python bootstrap.py express.bnf > express_parser.py && python express_parser.py IFC2X3_TC1.exp

[1] http://pyparsing.wikispaces.com/Download+and+Installation
Loading