Example #1
0
        /// <summary>
        /// Appends a new root local placement and changes the transformation graph.
        /// </summary>
        /// <param name="s">The model store</param>
        /// <returns>Added placement</returns>
        public IIfcLocalPlacement NewRootIfcLocalPlacement(IModel s)
        {
            // Compute delta alignment
            var virtualParent = SourceReferenceAxis.TransformAxisTo(TargetReferenceAxis);

            // Generate new root placement
            switch (s.SchemaVersion)
            {
            case Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3:
                return(s.NewIfc2x3ObjectPlacementTo(virtualParent));

            case Xbim.Common.Step21.XbimSchemaVersion.Ifc4:
            case Xbim.Common.Step21.XbimSchemaVersion.Ifc4x1:
                return(s.NewIfc4ObjectPlacementTo(virtualParent));

            default:
                throw new ArgumentException($"Unhandled schema version {s.SchemaVersion}");
            }
        }
Example #2
0
        /// <summary>
        /// Changes an existing local placement to be aligned to target axis.
        /// </summary>
        /// <param name="placement">A placement to be aligned</param>
        /// <param name="transform">The associated transform in model units</param>
        /// <returns>The given placement with (possible) additional axis components</returns>
        public IIfcLocalPlacement ChangeIfcLocalPlacement(IIfcLocalPlacement placement, XbimMatrix3D transform)
        {
            // Compute delta alignment
            var virtualParent = SourceReferenceAxis.TransformAxisTo(TargetReferenceAxis);
            // Multiply out with selected placement
            var unitsPerMeter  = placement.Model.ModelFactors.OneMeter;
            var finalAlignment = new IfcAlignReferenceAxis(transform * virtualParent.To3D(unitsPerMeter), unitsPerMeter);

            switch (placement.Model.SchemaVersion)
            {
            case Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3:
                return((placement as Xbim.Ifc2x3.GeometricConstraintResource.IfcLocalPlacement).ChangeIfc2x3ObjectPlacementTo(finalAlignment, true));

            case Xbim.Common.Step21.XbimSchemaVersion.Ifc4:
            case Xbim.Common.Step21.XbimSchemaVersion.Ifc4x1:
                return((placement as Xbim.Ifc4.GeometricConstraintResource.IfcLocalPlacement).ChangeIfc4ObjectPlacementTo(finalAlignment, true));

            default:
                throw new ArgumentException($"Unhandled schema version {placement.Model.SchemaVersion}");
            }
        }