Class TLcdIFCModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
,ILcdStatusSource
This model decoder decodes IFC files into an ILcdModel
.
For more information on how this model decoder handles IFC files,
please consult The IFC data format article.
Input
File | Required | Entry point | Description |
---|---|---|---|
*.ifc | x | x | A supported ifc file. |
File | Required | Entry point | Description |
---|---|---|---|
*.ifc.index | x | x | A text file containing a list of supported ifc files (one file per line) that belong to the same project and that have the same reference. Refer to the Combining multiple IFC files article for more details. |
Supported file transfer protocols
This model decoder supports all transfer protocols that are supported by the InputStreamFactory
of this decoder when working with an .ifc
file. When using a .ifc.index
file as entry point, the model
decoder needs to find the root files which is done by finding files on the file system directly.
Model reference
IFC data can contain geo-referencing information itself, but that is not supported by this decoder. This section describes what strategies this decoder uses to find a suitable reference for the data.
-
The model reference is obtained from an
ILcdModelReferenceDecoder
. The default reference decoder set on this model decoder is based on all model reference decoders annotated with theLcdService
annotation. For example, you use a.prj
file with WKT information, or a.epgs
file with an EPSG code next to the input data. -
Alternatively, you can use a
.llh
file next to the input data with a single text line containing a longitude, latitude and height coordinate (defined in the default EPSG 4326 reference). This will then be used as a topocentric reference to position your model in the world. -
You can set a fallback model reference to be used when no reference information can be found
next to the input data: see
setDefaultModelReference(com.luciad.model.ILcdModelReference)
.decoder.setDefaultModelReference(fallbackModelReference);
If no geo-reference information can be found with any of these strategies, then the data will be loaded in its
original, non-georeferenced coordinate system.
Note: Data that is decoded in its original coordinate system, can not be visualized on a
geographical map. The dataset must be geo-located with an external tool, after conversion has been done.
This is equivalent to setting a TLcdCartesianReference
as fallback reference:
decoder.setDefaultModelReference(new TLcdCartesianReference(TLcdDistanceUnit.METRE_UNIT,
TLcdDistanceUnit.METRE_UNIT,
TLcdDistanceUnit.METRE_UNIT));
Model structure
This decoder can create 2 different kind of models:
- The geometry model: this model contains the IFC geometry. The display name has the suffix "[GEOMETRY]"
- The features model: this model contains the
properties of the IFC structural elements (like doors, walls, etc.), together with their bounding box.
This model is a
TLcd2DBoundsIndexedModel
, its display name has the suffix "[FEATURES]"
With the TLcdBIMDataSource
data source, it's possible to specify the model type for the
decodeSource(ILcdDataSource)
and decodeModelMetadata(ILcdDataSource)
methods.
The geometry type is assumed for the decode(String)
and decodeModelMetadata(String)
methods.
The possibility to decode 2 different models is also reflected through the discoverDataSources(java.lang.String)
method:
it provides 2 ILcdDataSource
instances, one for the geometry model and one for the features model, that
can both be decoded using the decodeSource(ILcdDataSource)
} method.
Model descriptor
The type name of model descriptor is "IFC".Model elements
The objects in the model depend on the type of the model.
- The geometry model: this model contains elements that do not implement any public LuciadLightspeed
API. However, this model can be used as input for the
TLcdOGC3DTilesModelEncoder
- The features model: this model contains elements implementing the
ILcdDataObject
interface. They are also annotated withTLcdHasGeometryAnnotation
andTLcdPrimaryKeyAnnotation
annotations so this model can for instance be used as input for theTLcdGeoJsonModelEncoder
or other encoders supportingILcdDataObject
s
Sample code
Obtain the default model containing the geometry: ILcdModelDecoder decoder = new TLcdIFCModelDecoder();
ILcdModel model = decoder.decode(sourceName);
TLcdIFCModelDecoder decoder = new TLcdIFCModelDecoder();
ILcdModel model = decoder.decodeSource(new TLcdBIMDataSource(sourceName, TLcdBIMDataSource.Type.FEATURES));
Thread safety
- The decoding of models is thread-safe.
- The decoded models are thread-safe for read access.
Supported versions and specifications
This decoder supports the following IFC specification versions:
- IFC 2.3.0.1: IFC2 Edition 3 - Technical Corrigendum 1
- IFC 4.0.2.1: IFC4 - Addendum 2 - Technical Corrigendum 1
Known limitations
See What are the supported versions and limitations for more information on the limitations of this decoder.
- Since:
- 2022.0
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aListener) Registers the given listener so it will receive status events from this source.boolean
canDecodeSource
(ILcdDataSource aDataSource) Checks whether this model decoder can decode the data source(s), identified by the passedILcdDataSource
.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.decodeFeatures
(String aSourceName) Creates a new model from the given data source.decodeModelMetadata
(ILcdDataSource aDataSource) Decodes metadata for the specified data source.decodeModelMetadata
(String aSourceName) Decodes metadata for the specified data source.decodeSource
(ILcdDataSource aDataSource) Creates a new model from the given data source.List
<? extends ILcdDataSource> discoverDataSources
(String aPath) Retrieves twoILcdDataSource
instances: one for the geometry model and one for the features model.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns the input stream factory that is used.Returns the decoder used to produce model references.void
removeStatusListener
(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.void
setDefaultModelReference
(ILcdModelReference aModelReference) void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to be used.void
setModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the decoder to use to produce model references for models created with this decoder.
-
Field Details
-
TYPE_NAME
Thetype name
for the decoded IFC geometry models.- See Also:
-
-
Constructor Details
-
TLcdIFCModelDecoder
public TLcdIFCModelDecoder()
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
throws an exception for that same source name.For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be verified; typically a file name or a URL.- Returns:
true
if this decoder can likely decode the data specified by the source name,false
otherwise.- See Also:
-
discoverDataSources
Retrieves two
ILcdDataSource
instances: one for the geometry model and one for the features model.- Specified by:
discoverDataSources
in interfaceILcdModelDecoder
- Parameters:
aPath
- A path to the data source to be decoded; typically a file path or a URL.- Returns:
- If this model decoder returns
true
forcanDecodeSource(String)
, it will return a list containing the twoILcdDataSource
instances. - Throws:
IOException
- If this model decoder returnsfalse
forcanDecodeSource(String)
or if any exceptions caused by IO problems or invalid data occur.
-
decodeSource
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
- Throws a
NullPointerException
when anull
data source is passed. - Delegates to the
ILcdModelDecoder.decode(String)
method when aTLcdDataSource
is passed. - Throws an IOException in other case.
- Specified by:
decodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdDataSource
to be decoded.- Returns:
- a model containing the decoded data. While
null
is allowed, implementors are advised to throw an error instead. - Throws:
IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException { try { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }
- See Also:
- Throws a
-
decode
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
null
is allowed, implementors are advised to throw an error instead. - Throws:
IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.public ILcdModel decode( String aSourceName ) throws IOException { try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }
- See Also:
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the data source(s), identified by the passed
ILcdDataSource
.For performance reasons, we strongly recommend that this will only be a simple test. For example: check the instance class of
aDataSource
, or check the file extension if it is aTLcdDataSource
.The default implementation of this method will check if the given
ILcdDataSource
is aTLcdDataSource
. If not, this method returns false. Otherwise, it delegates the source to theILcdModelDecoder.canDecodeSource(String)
method.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdModelSource
to be verified.- Returns:
true
if this decoder can likely decode the data specified byaDataSource
,false
otherwise.- See Also:
-
decodeModelMetadata
Description copied from interface:ILcdModelDecoder
Decodes metadata for the specified data source. By default, this decodes the model and returns the model metadata found on that model. Implementations can override this method to speed up the retrieval.- Specified by:
decodeModelMetadata
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be decoded; typically a file name or a URL.- Returns:
- the model metadata for the data source, never null.
- Throws:
IOException
- if the metadata cannot be decoded for some reason.- See Also:
-
decodeModelMetadata
Description copied from interface:ILcdModelDecoder
Decodes metadata for the specified data source. By default, this decodes the model and returns the model metadata found on that model. Implementations can override this method to speed up the retrieval.- Specified by:
decodeModelMetadata
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- the data source to be decoded.- Returns:
- the model metadata for the data source, never null.
- Throws:
IOException
- if the metadata cannot be decoded for some reason.- See Also:
-
decodeFeatures
Creates a new model from the given data source. This model contains the metadata of the 'structural elements' of the given IFC data source. The elements of this model implement theILcdDataObject
interface.- Parameters:
aSourceName
- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the feature data.
- Throws:
NullPointerException
- ifaSourceName
is null.IOException
- for any exceptions caused by IO problems or invalid dataInterruptedIOException
- when the thread on which this method is called is interrupted
-
setDefaultModelReference
-
getDefaultModelReference
-
addStatusListener
Description copied from interface:ILcdStatusSource
Registers the given listener so it will receive status events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a
ALcdWeakStatusListener
instance as status listener.- Specified by:
addStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSource
Removes the specified listener so it is no longer notified.- Specified by:
removeStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to remove.
-
setInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapable
Sets the input stream factory to be used.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.
-
getInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapable
Returns the input stream factory that is used.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory that is used.
-
getModelReferenceDecoder
Returns the decoder used to produce model references.- Returns:
- the decoder to produce model references.
- See Also:
-
setModelReferenceDecoder
Sets the decoder to use to produce model references for models created with this decoder.- Parameters:
aModelReferenceDecoder
- the decoder to use to produce model references for models created with this decoder.- See Also:
-