XbimGeometry icon indicating copy to clipboard operation
XbimGeometry copied to clipboard

IfcGrid with Relative Placement

Open Dakki97 opened this issue 4 years ago • 0 comments

When having an IfcGrid with IfcGridAxes and the IFCGrid has Transformations applied to it, such as Direction, Rotation and RelativePlacement, how can the correctly transformed vertices be retrieved without it being a mesh.

I extract Axes like so:

            var factor = getSIUnitFactor(lengthUnit);
            if (gauss == null)
            {
                gauss = new GaussCoordinates(0, 0);
            }
            var axes = new List<Axis>();
            var grids = model.Instances.OfType<IIfcGrid>();
            if (grids.Count() > 1) Logger.Warn("You have more than one grid, axes might be wrong");
            if (grids.Any())
            {
                foreach (var grid in grids)
                {
                    if (grid.UAxes.Count() == 0 && grid.VAxes.Count() == 0)
                    {
                        Logger.Warn("This model does not contain any axes");
                    }
                    else
                    {
                        if (
                            (grid.UAxes.Count() != 0 && grid.VAxes.Count() == 0) ||
                            (grid.UAxes.Count() == 0 && grid.VAxes.Count() != 0))
                        {
                            Logger.Warn("IfcGrid not used correctly, axes might be wrong");
                        }
                        var uaxes = grid.UAxes;
                        var vaxes = grid.VAxes;
                        var gridaxes = uaxes.Concat(vaxes);
                        axes.AddRange(ExtractAxes(gridaxes, gauss, factor));
                    }
                }
            }
            else
            {
                var gridaxes = model.Instances.OfType<IIfcGridAxis>().DistinctBy(axis => axis.AxisTag);
                if (gridaxes.Any())
                {
                    axes = ExtractAxes(gridaxes, gauss, factor);
                }
                else
                {
                    Logger.Warn("This model does not contain any axes");
                }
            }
            return axes;

The problem is that this approach only works when the vertices of the IfcGrid are perfectly transformed to begin with. When working with meshes its pretty easy to get the correctly transformed vertices. As IfcProduct is a parent of IfcGrid, there is a way to get the correclty transformed axes, but then i have mesh geometry for what is actually just a line.

Is there a simpler solution for this?

Dakki97 avatar Mar 17 '20 14:03 Dakki97