xBimTeam / XbimGeometry

XbimGeometry contains the CLR interop libraries and the c++ engine used to compute the 3D geometry of models.
https://xbimteam.github.io/
Other
260 stars 131 forks source link

Generating Solid objects for IFC product layers #409

Closed ido-cu closed 1 year ago

ido-cu commented 1 year ago

I have a model with elements that are composed of several layers. I'd like to generate a solid object for each one of those layers (as if they were separate elements). I access the Material property on the IfcProduct and try to get the representation like this:

const string STYLE_REPRESENTATION_ID = "Style";

IIfcMaterialLayerSetUsage layerSet = element.Material as IIfcMaterialLayerSetUsage;

foreach (IIfcMaterialLayer currentlayer in layerSet.ForLayerSet.MaterialLayers)

{

    foreach (IIfcMaterialDefinitionRepresentation currentLayerRep in currentlayer.Material.HasRepresentation)

    {

        IIfcRepresentation elementRep = currentLayerRep.Representations?
            .FirstOrDefault(rep => rep.RepresentationIdentifier == STYLE_REPRESENTATION_ID);
...

But I get a IfcStyledRepresentation object which does not implement IIfcGeometricRepresentationItem so I can't create a solid using XbimGeometryEngine.Create.

What am I doing wrong? Is it even possible with xbim? and if so, how can I do it?

Thanks!

martin1cerny commented 1 year ago

IIfcMaterialDefinitionRepresentation is about visual representation of the material itself, not about the material layer, as you can read in the documentation. Walls geometry is usually defined as extruded area, where you can calculate individual layers of the wall only as an inferred shape based in the geometry of the wall and its layer composition and orientation. What do you need this for? Do you actually need the shape, or do you need to get calculated properties such as volume and area?

ido-cu commented 1 year ago

I can manage without the volume and area... Are you saying that I need to get the solid of the wall, and then figure out how to split it according to the LayerThickness property of each layer?

ido-cu commented 1 year ago

Oh wait... did you mean that I can build my own IfcExtrudedAreaSolid with defined the width of the layer and a little offset (where every other property of it stays exactly the same) and build a solid object from this? :) I'm guessing that I'll need to add the offset to the transformation, right?

martin1cerny commented 1 year ago

Yes, you can do that. You can take the profile and manipulate it on the fly to get a solid per layer. You are welcome to contribute the code. Others might find it useful as well.

ido-cu commented 1 year ago

ok, thanks! (I'm currently just researching it, I'll be happy to contribute when it's ready)