示例#1
0
        public static Curve GetProfileCurveInWorldCoordinates(this RevolvedSurface revolvedSurface)
        {
            var profileCurve = revolvedSurface.GetProfileCurve();
            var ECStoWCS     = new Transform(Transform.Identity)
            {
                Origin = revolvedSurface.Origin,
                BasisX = revolvedSurface.XDir.Normalize(),
                BasisY = revolvedSurface.YDir.Normalize(),
                BasisZ = revolvedSurface.Axis.Normalize()
            };

            return(profileCurve.CreateTransformed(ECStoWCS));
        }
示例#2
0
        public static Surface GetSurface(this Face face)
        {
            switch (face)
            {
            case PlanarFace planarFace:
                return(Plane.CreateByOriginAndBasis(planarFace.Origin, planarFace.XVector, planarFace.YVector));

            case ConicalFace conicalFace:
            {
                var basisX = conicalFace.get_Radius(0).Normalize();
                var basisY = conicalFace.get_Radius(1).Normalize();
                var basisZ = conicalFace.Axis.Normalize();
                return(ConicalSurface.Create(new Frame(conicalFace.Origin, basisX, basisY, basisZ), conicalFace.HalfAngle));
            }

            case CylindricalFace cylindricalFace:
            {
                double radius = cylindricalFace.get_Radius(0).GetLength();
                var    basisX = cylindricalFace.get_Radius(0).Normalize();
                var    basisY = cylindricalFace.get_Radius(1).Normalize();
                var    basisZ = cylindricalFace.Axis.Normalize();
                return(CylindricalSurface.Create(new Frame(cylindricalFace.Origin, basisX, basisY, basisZ), radius));
            }

            case RevolvedFace revolvedFace:
            {
                var ECStoWCS = new Transform(Transform.Identity)
                {
                    Origin = revolvedFace.Origin,
                    BasisX = revolvedFace.get_Radius(0).Normalize(),
                    BasisY = revolvedFace.get_Radius(1).Normalize(),
                    BasisZ = revolvedFace.Axis.Normalize()
                };

                var profileInWCS = revolvedFace.Curve.CreateTransformed(ECStoWCS);

                return(RevolvedSurface.Create(new Frame(ECStoWCS.Origin, ECStoWCS.BasisX, ECStoWCS.BasisY, ECStoWCS.BasisZ), profileInWCS));
            }

            case RuledFace ruledFace:
            {
                var profileCurve0 = ruledFace.get_Curve(0);
                var profileCurve1 = ruledFace.get_Curve(1);
                return(RuledSurface.Create(profileCurve0, profileCurve1));
            }
            }

            return(null);
        }
示例#3
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));
        }