private IList <CurveLoop> GetTransformedCurveLoopsFromSimpleProfile(IFCSimpleProfile simpleSweptArea, Transform unscaledLcs, Transform scaledLcs)
        {
            IList <CurveLoop> loops = new List <CurveLoop>();

            // It is legal for simpleSweptArea.Position to be null, for example for IfcArbitraryClosedProfileDef.
            Transform unscaledSweptAreaPosition =
                (simpleSweptArea.Position == null) ? unscaledLcs : unscaledLcs.Multiply(simpleSweptArea.Position);

            Transform scaledSweptAreaPosition =
                (simpleSweptArea.Position == null) ? scaledLcs : scaledLcs.Multiply(simpleSweptArea.Position);

            CurveLoop currLoop = simpleSweptArea.OuterCurve;

            if (currLoop == null || currLoop.Count() == 0)
            {
                Importer.TheLog.LogError(simpleSweptArea.Id, "No outer curve loop for profile, ignoring.", false);
                return(null);
            }
            loops.Add(IFCGeometryUtil.CreateTransformed(currLoop, Id, unscaledSweptAreaPosition, scaledSweptAreaPosition));

            if (simpleSweptArea.InnerCurves != null)
            {
                foreach (CurveLoop innerCurveLoop in simpleSweptArea.InnerCurves)
                {
                    loops.Add(IFCGeometryUtil.CreateTransformed(innerCurveLoop, Id, unscaledSweptAreaPosition, scaledSweptAreaPosition));
                }
            }

            return(loops);
        }
        private void GetTransformedCurveLoopsFromProfile(IFCProfile profile, Transform lcs, ISet <IList <CurveLoop> > loops)
        {
            if (profile is IFCSimpleProfile)
            {
                IFCSimpleProfile simpleSweptArea = profile as IFCSimpleProfile;

                IList <CurveLoop> currLoops = GetTransformedCurveLoopsFromSimpleProfile(simpleSweptArea, lcs);
                if (currLoops != null && currLoops.Count > 0)
                {
                    loops.Add(currLoops);
                }
            }
            else if (profile is IFCCompositeProfile)
            {
                IFCCompositeProfile compositeSweptArea = profile as IFCCompositeProfile;

                foreach (IFCProfile subProfile in compositeSweptArea.Profiles)
                {
                    GetTransformedCurveLoopsFromProfile(subProfile, lcs, loops);
                }
            }
            else
            {
                // TODO: Support.
                Importer.TheLog.LogError(Id, "SweptArea Profile #" + profile.Id + " not yet supported.", false);
            }
        }
        private void GetTransformedCurveLoopsFromProfile(IFCProfileDef profile, Transform unscaledLcs, Transform scaledLcs, ISet <IList <CurveLoop> > loops)
        {
            if (profile is IFCSimpleProfile)
            {
                IFCSimpleProfile simpleSweptArea = profile as IFCSimpleProfile;

                IList <CurveLoop> currLoops = GetTransformedCurveLoopsFromSimpleProfile(simpleSweptArea, unscaledLcs, scaledLcs);
                if (currLoops != null && currLoops.Count > 0)
                {
                    loops.Add(currLoops);
                }
            }
            else if (profile is IFCCompositeProfile)
            {
                IFCCompositeProfile compositeSweptArea = profile as IFCCompositeProfile;

                foreach (IFCProfileDef subProfile in compositeSweptArea.Profiles)
                {
                    GetTransformedCurveLoopsFromProfile(subProfile, unscaledLcs, scaledLcs, loops);
                }
            }
            else if (profile is IFCDerivedProfileDef)
            {
                IFCDerivedProfileDef derivedProfileDef = profile as IFCDerivedProfileDef;

                Transform fullUnscaledLCS = unscaledLcs;
                Transform localLCS        = derivedProfileDef.Operator.Transform;
                if (fullUnscaledLCS == null)
                {
                    fullUnscaledLCS = localLCS;
                }
                else if (localLCS != null)
                {
                    fullUnscaledLCS = fullUnscaledLCS.Multiply(localLCS);
                }

                Transform fullScaledLCS = scaledLcs;
                if (fullScaledLCS == null)
                {
                    fullScaledLCS = localLCS;
                }
                else if (localLCS != null)
                {
                    fullScaledLCS = fullScaledLCS.Multiply(localLCS);
                }

                GetTransformedCurveLoopsFromProfile(derivedProfileDef.ParentProfile, fullUnscaledLCS, fullScaledLCS, loops);
            }
            else
            {
                // TODO: Support.
                Importer.TheLog.LogError(Id, "SweptArea Profile #" + profile.Id + " not yet supported.", false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Returns the surface which defines the internal shape of the face
        /// </summary>
        /// <param name="lcs">The local coordinate system for the surface.  Can be null.</param>
        /// <returns>The surface which defines the internal shape of the face</returns>
        public override Surface GetSurface(Transform lcs)
        {
            if (SweptCurve == null)
            {
                Importer.TheLog.LogError(Id, "Cannot find the profile curve of this revolved face.", true);
            }

            IFCSimpleProfile simpleProfile = SweptCurve as IFCSimpleProfile;

            if (simpleProfile == null)
            {
                Importer.TheLog.LogError(Id, "Can't handle profile curve of type " + SweptCurve.GetType() + ".", true);
            }

            CurveLoop outerCurve   = simpleProfile.OuterCurve;
            Curve     profileCurve = (outerCurve != null) ? outerCurve.First <Curve>() : null;

            if (profileCurve == null)
            {
                Importer.TheLog.LogError(Id, "Cannot create the profile curve of this revolved surface.", true);
            }

            if (outerCurve.Count() > 1)
            {
                Importer.TheLog.LogError(Id, "Revolved surface has multiple profile curves, ignoring all but first.", false);
            }

            Curve revolvedSurfaceProfileCurve = profileCurve.CreateTransformed(Position);

            if (!RevolvedSurface.IsValidProfileCurve(AxisPosition.Origin, AxisPosition.BasisZ, revolvedSurfaceProfileCurve))
            {
                Importer.TheLog.LogError(Id, "Profile curve is invalid for this revolved surface.", true);
            }

            if (lcs == null)
            {
                return(RevolvedSurface.Create(AxisPosition.Origin, AxisPosition.BasisZ, revolvedSurfaceProfileCurve));
            }

            Curve transformedRevolvedSurfaceProfileCurve = revolvedSurfaceProfileCurve.CreateTransformed(lcs);

            return(RevolvedSurface.Create(lcs.OfPoint(AxisPosition.Origin), lcs.OfVector(AxisPosition.BasisZ), transformedRevolvedSurfaceProfileCurve));
        }
Beispiel #5
0
        /// <summary>
        /// Returns the surface which defines the internal shape of the face
        /// </summary>
        /// <param name="lcs">The local coordinate system for the surface.  Can be null.</param>
        /// <returns>The surface which defines the internal shape of the face</returns>
        public override Surface GetSurface(Transform lcs)
        {
            Curve sweptCurve = null;

            // Get the RuledSurface which is used to create the geometry from the brepbuilder
            if (!(SweptCurve is IFCSimpleProfile))
            {
                return(null);
            }
            else
            {
                // Currently there is no easy way to get the curve from the IFCProfile, so for now we assume that
                // the SweptCurve is an IFCSimpleProfile and its outer curve only contains one curve, which is the
                // profile curve that we want
                IFCSimpleProfile simpleSweptCurve = SweptCurve as IFCSimpleProfile;
                CurveLoop        outerCurve       = simpleSweptCurve.OuterCurve;
                if (outerCurve == null)
                {
                    return(null);
                }
                CurveLoopIterator it = outerCurve.GetCurveLoopIterator();
                sweptCurve = it.Current;
            }
            // Position/transform the Curve first according to the lcs of the IfcSurfaceOfLinearExtrusion
            sweptCurve = sweptCurve.CreateTransformed(Position);

            // Create the second profile curve by translating the first one in the extrusion direction
            Curve profileCurve2 = sweptCurve.CreateTransformed(Transform.CreateTranslation(ExtrudedDirection.Multiply(Depth)));

            if (lcs == null)
            {
                return(RuledSurface.Create(sweptCurve, profileCurve2));
            }

            Curve transformedProfileCurve1 = sweptCurve.CreateTransformed(lcs);
            Curve transformedProfileCurve2 = profileCurve2.CreateTransformed(lcs);

            return(RuledSurface.Create(transformedProfileCurve1, transformedProfileCurve2));
        }