Giter VIP home page Giter VIP logo

ifc.java's Introduction

IFC.JAVA

What?

This repository contains all IFC entities in the form of a Java class library. It contains all the classes provided in the IFC EXPRESS schema, but in a JAVA syntax. Hence, these IFC classes can be used directly for working with IFC data in JAVA.

Class Tree

The code allows serialising and deserialising IFC objects to XML and JSON using out of the box annotations (Jackson package). IFC-SPF (STEP) is not supported. We suggest exporting building data in the right syntax directly from any BIM tool using scripts, native APIs, Dynamo scripts or other. Resulting JSON and XML can be loaded directly into this Java code library; and then the data can be used.

Annotations

Why?

IFC is a common data model in the AEC industry. Many starting developers and PhD students consider using IFC to obtain data. Yet, parsing IFC STEP files (.ifc) is cumbersome and difficult. With this library, XML and JSON versions of IFC data can be randomly read, used, and generated, thus easing the work for developers looking at IFC. These XML and JSON files are ideally equally interoperable with class libraries in C# and Python, which is work that is underway.

How?

The project is developed using maven, and the resulting artefact is meant to be published in the open maven repository (https://mvnrepository.com/) to allow re-use this library in other code.

This work is in progress. Code is likely unstable and not entirely user-friendely. Please report issues when you encounter them. Additional sample files are highly welcome as well; they are collected in the Examples folder.

The code currently only contains the classes specified in IFC4 Addendum 2 (https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/).

Serialisation and deserialisation is done using the Jackson package; and it is therefore out of the box. This code can be seen in the IfcParser.java code.

XmlMapper m = new XmlMapper();
m.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
m.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
m.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true);
proj = m.readValue(inputStream, IfcProject.class);

After deserialising the XML, one can directly work with the IFC data.

Iterator<IfcRelAggregates> iter = proj.getIsDecomposedBy().iterator();
while(iter.hasNext()){
		IfcRelAggregates ira = iter.next();
		if(ira.getRelatedObjects().size() == 0){
			System.out.println("did not find IfcSite");
			ira.getRelatedObjects().add(new IfcSite());
			IfcSite s = new IfcSite();
			s.setName("My New Site");
		}				
}

And deserialize again into JSON and/or XML.

ObjectMapper m = new ObjectMapper();
m.configure(SerializationFeature.INDENT_OUTPUT, true);
m.setSerializationInclusion(JsonInclude.Include.NON_NULL);
m.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

String jsonString;
jsonString = m.writeValueAsString(proj);

File jsonOutput = new File(fp);
FileWriter fileWriter = new FileWriter(jsonOutput);
fileWriter.write(jsonString);
fileWriter.close();

Results

Sample data files (XML, JSON) can be found in the Examples folder. This includes:

<IfcProject Class="IfcProject" GlobalId="3oUsrKbqD0wh41n0gL1Hqn" Name="0001" LongName="Project Name" Phase="Project Status">
  <OwnerHistory LastModifiedDate="0" CreationDate="1570561985">
    <OwningUser>
      <ThePerson GivenName="pipauwel">
        <MiddleNames>
          <MiddleName>Test</MiddleName>
          <MiddleName>Me</MiddleName>
        </MiddleNames>
      </ThePerson>
      <TheOrganization Name="This is the organisation"/>
    </OwningUser>
    <OwningApplication Version="2019" ApplicationFullName="Autodesk Revit 2019 (ENU)" ApplicationIdentifier="Revit">
      <ApplicationDeveloper Name="Autodesk Revit 2019 (ENU)"/>
    </OwningApplication>
  </OwnerHistory>
</IfcProject>
{
  "Class" : "IfcProject",
  "globalId" : "3oUsrKbqD0wh41n0gL1Hqn",
  "ownerHistory" : {
    "owningUser" : {
      "thePerson" : {
        "givenName" : "pipauwel",
        "middleNames" : [ "Test", "Me" ]
      },
      "theOrganization" : {
        "name" : "This is the organisation"
      }
    },
    "owningApplication" : {
      "applicationDeveloper" : {
        "name" : "Autodesk Revit 2019 (ENU)"
      },
      "version" : "2019",
      "applicationFullName" : "Autodesk Revit 2019 (ENU)",
      "applicationIdentifier" : "Revit"
    },
    "lastModifiedDate" : 0,
    "creationDate" : 1570561985
  }
}

Contact

Please contact Pieter Pauwels (TU Eindhoven - [email protected]) for further information, suggestions, questions, or anything related to this project.

Feel free to make Git Issues with particular features you would like to have included.

Feel free to extend the IFC schema by making additional subclasses where relevant. If you do so, please do this in a separate branch, so that your suggestions can be tracked.

ifc.java's People

Contributors

pipauwel avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.