Example #1
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);
        }
Example #2
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));
        }
Example #3
0
 public static bool HasSecondProfilePoint(this RuledSurface ruledSurface)
 {
     return(ruledSurface.GetSecondProfilePoint() is object);
 }
Example #4
0
 public static bool HasFirstProfilePoint(this RuledSurface ruledSurface)
 {
     return(ruledSurface.GetFirstProfilePoint() is object);
 }