@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdIFCModelDecoder extends Object implements ILcdModelDecoder, ILcdStatusSource, ILcdInputStreamFactoryCapable
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.
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. |
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.
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.
ILcdModelReferenceDecoder
. The default reference decoder set on
this model decoder is based on all model reference decoders annotated with the LcdService
annotation.
For example, you use a .prj
file with WKT information, or a .epgs
file with an EPSG code
next to the input data.
.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.
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));
This decoder can create 2 different kind of models:
decode(String)
method: this model contains the IFC geometry.
The display name has the suffix "[GEOMETRY]"decodeFeatures(String)
method: 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]"
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.
The object in the model depend on the type of the model.
TLcdOGC3DTilesModelEncoder
ILcdDataObject
interface.
They are also annotated with TLcdHasGeometryAnnotation
and TLcdPrimaryKeyAnnotation
annotations
so this model can for instance be used for instance as input for the TLcdGeoJsonModelEncoder
or other
encoders supporting ILcdDataObject
s ILcdModelDecoder decoder = new TLcdIFCModelDecoder();
ILcdModel model = decoder.decode(sourceName);
Obtain the features model:
TLcdIFCModelDecoder decoder = new TLcdIFCModelDecoder();
ILcdModel model = decoder.decodeFeatures(sourceName);
This decoder supports the following IFC specification versions:
See What are the supported versions and limitations for more information on the limitations of this decoder.
Modifier and Type | Field and Description |
---|---|
static String |
TYPE_NAME
The
type name for the decoded IFC geometry models. |
Constructor and Description |
---|
TLcdIFCModelDecoder() |
Modifier and Type | Method and Description |
---|---|
void |
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 passed
ILcdDataSource . |
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ILcdModel |
decodeFeatures(String aSourceName)
Creates a new model from the given data source.
|
TLcdModelMetadata |
decodeModelMetadata(String aSourceName)
Decodes metadata for the specified data source.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Creates a new model from the given data source.
|
List<? extends ILcdDataSource> |
discoverDataSources(String aPath)
Retrieves two
ILcdDataSource instances: one for the geometry model and one for the features model. |
ILcdModelReference |
getDefaultModelReference() |
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decodeModelMetadata
public static final String TYPE_NAME
type name
for the decoded IFC geometry models.public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
true
for a source name while decode
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.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public List<? extends ILcdDataSource> discoverDataSources(String aPath) throws IOException
Retrieves two ILcdDataSource
instances: one for the geometry model and one for the features model.
discoverDataSources
in interface ILcdModelDecoder
aPath
- A path to the data source to be decoded; typically a file path or a URL.true
for canDecodeSource(String)
, it will
return a list containing the two ILcdDataSource
instances.IOException
- If this model decoder returns false
for canDecodeSource(String)
or if any exceptions caused by IO problems or invalid data occur.public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
NullPointerException
when a null
data source is passed.ILcdModelDecoder.decode(String)
method when a TLcdDataSource
is passed.decodeSource
in interface ILcdModelDecoder
aDataSource
- the ILcdDataSource
to be decoded.null
is allowed, implementors are advised to throw an error instead.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);
}
}
ILcdModelDecoder.canDecodeSource(ILcdDataSource)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.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);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)
public boolean canDecodeSource(ILcdDataSource aDataSource)
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 a TLcdDataSource
.
The default implementation of this method will check if the given ILcdDataSource
is a
TLcdDataSource
. If not, this method returns false. Otherwise, it delegates
the source to the ILcdModelDecoder.canDecodeSource(String)
method.
canDecodeSource
in interface ILcdModelDecoder
aDataSource
- the ILcdModelSource
to be verified.true
if this decoder can likely decode the data specified by aDataSource
, false
otherwise.ILcdModelDecoder.decodeSource(ILcdDataSource)
,
ILcdModelDecoder.decodeModelMetadata(ILcdDataSource)
public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
ILcdModelDecoder
decodeModelMetadata
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.IOException
- if the metadata cannot be decoded for some reason.ILcdModelDecoder.canDecodeSource(String)
public ILcdModel decodeFeatures(String aSourceName) throws IOException
ILcdDataObject
interface.aSourceName
- the data source to be decoded; typically a file name or a URL.NullPointerException
- if aSourceName
is null.IOException
- for any exceptions caused by IO problems or invalid dataInterruptedIOException
- when the thread on which this method is called is interruptedpublic void setDefaultModelReference(ILcdModelReference aModelReference)
public ILcdModelReference getDefaultModelReference()
public void addStatusListener(ILcdStatusListener aListener)
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.
addStatusListener
in interface ILcdStatusSource
aListener
- The listener to be notified when the status has changed.public void removeStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
removeStatusListener
in interface ILcdStatusSource
aListener
- The listener to remove.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
ILcdInputStreamFactoryCapable
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
,
setDefaultModelReference(com.luciad.model.ILcdModelReference)
public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
aModelReferenceDecoder
- the decoder to use to produce model references for models created with this decoder.getModelReferenceDecoder()
,
setDefaultModelReference(com.luciad.model.ILcdModelReference)