当前位置: 首页>>代码示例>>C#>>正文


C# Curve.GetEndParameter方法代码示例

本文整理汇总了C#中Curve.GetEndParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Curve.GetEndParameter方法的具体用法?C# Curve.GetEndParameter怎么用?C# Curve.GetEndParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Curve的用法示例。


在下文中一共展示了Curve.GetEndParameter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSweptDiskSolid

        private static IFCAnyHandle CreateSweptDiskSolid(ExporterIFC exporterIFC, IFCFile file, Curve centerCurve, double radius)
        {
            IList<Curve> curves = new List<Curve>();
            double endParam = 0.0;
            if (centerCurve is Arc || centerCurve is Ellipse)
            {
                if (centerCurve.IsBound)
                    endParam = UnitUtil.ScaleAngle(centerCurve.GetEndParameter(1) - centerCurve.GetEndParameter(0));
                else
                    endParam = UnitUtil.ScaleAngle(2 * Math.PI);
            }
            else
                endParam = 1.0;
            curves.Add(centerCurve);

            IFCAnyHandle compositeCurve = GeometryUtil.CreateCompositeCurve(exporterIFC, curves);
            return IFCInstanceExporter.CreateSweptDiskSolid(file, compositeCurve, radius, null, 0, endParam);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:18,代码来源:FabricSheetExporter.cs

示例2: CreateProfileCurveLoopsForDirectrix

        private IList<CurveLoop> CreateProfileCurveLoopsForDirectrix(Curve directrix, out double startParam)
        {
           startParam = 0.0;

           if (directrix == null)
              return null;

           if (directrix.IsBound)
              startParam = directrix.GetEndParameter(0);

           Transform originTrf = directrix.ComputeDerivatives(startParam, false);

           if (originTrf == null)
              return null;

           // The X-dir of the transform of the start of the directrix will form the normal of the disk.
           Plane diskPlane = new Plane(originTrf.BasisX, originTrf.Origin);

           IList<CurveLoop> profileCurveLoops = new List<CurveLoop>();

           CurveLoop diskOuterCurveLoop = new CurveLoop();
           diskOuterCurveLoop.Append(Arc.Create(diskPlane, Radius, 0, Math.PI));
           diskOuterCurveLoop.Append(Arc.Create(diskPlane, Radius, Math.PI, 2.0 * Math.PI));
           profileCurveLoops.Add(diskOuterCurveLoop);

           if (InnerRadius.HasValue)
           {
              CurveLoop diskInnerCurveLoop = new CurveLoop();
              diskInnerCurveLoop.Append(Arc.Create(diskPlane, InnerRadius.Value, 0, Math.PI));
              diskInnerCurveLoop.Append(Arc.Create(diskPlane, InnerRadius.Value, Math.PI, 2.0 * Math.PI));
              profileCurveLoops.Add(diskInnerCurveLoop);
           }

           return profileCurveLoops;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:35,代码来源:IFCSweptDiskSolid.cs

示例3: UnscaleSweptSolidCurveParam

 private static double UnscaleSweptSolidCurveParam(Curve curve, double param)
 {
     if (curve.IsCyclic)
         return param * (Math.PI / 180);
     return param * (curve.GetEndParameter(1) - curve.GetEndParameter(0));
 }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:6,代码来源:IFCGeometryUtil.cs

示例4: Stream

        private void Stream(ArrayList data, Curve crv)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(Curve)));

            try
            {
                data.Add(new Snoop.Data.Double("Approximate length", crv.ApproximateLength));
            }
            catch (System.Exception ex)
            {
                data.Add(new Snoop.Data.Exception("Approximate length", ex));
            }

            try
            {
                data.Add(new Snoop.Data.Double("Length", crv.Length));
            }
            catch (System.Exception ex)
            {
                data.Add(new Snoop.Data.Exception("Length", ex));
            }

            try
            {
                data.Add(new Snoop.Data.Double("Period", crv.Period));
            }
            catch (System.Exception ex)
            {
                data.Add(new Snoop.Data.Exception("Period", ex));
            }

            try
            {
                data.Add(new Snoop.Data.Bool("Is bound", crv.IsBound));
            }
            catch (System.Exception ex)
            {
                data.Add(new Snoop.Data.Exception("Is bound", ex));
            }

            try
            {
                data.Add(new Snoop.Data.Bool("Is cyclic", crv.IsCyclic));
            }
            catch (System.Exception ex)
            {
                data.Add(new Snoop.Data.Exception("Is cyclic", ex));
            }

            try
            {
                data.Add(new Snoop.Data.Xyz("Start point", crv.GetEndPoint(0)));
                data.Add(new Snoop.Data.Xyz("End point", crv.GetEndPoint(1)));
            }
            catch (System.Exception)
            {
                // if the curve is unbound, those don't mean anything
                data.Add(new Snoop.Data.String("Start point", "N/A"));
                data.Add(new Snoop.Data.String("End point", "N/A"));
            }

            try
            {
                data.Add(new Snoop.Data.Double("Start parameter", crv.GetEndParameter(0)));
                data.Add(new Snoop.Data.Double("End parameter", crv.GetEndParameter(1)));
            }
            catch (System.Exception)
            {
                // if the curve is unbound, those don't mean anything
                data.Add(new Snoop.Data.String("Start parameter", "N/A"));
                data.Add(new Snoop.Data.String("End parameter", "N/A"));
            }

            try
            {
                data.Add(new Snoop.Data.Object("Start point reference", crv.GetEndPointReference(0)));
                data.Add(new Snoop.Data.Object("End point reference", crv.GetEndPointReference(1)));
            }
            catch (System.Exception)
            {
                // if the curve is unbound, those don't mean anything
                data.Add(new Snoop.Data.String("Start point reference", "N/A"));
                data.Add(new Snoop.Data.String("End point reference", "N/A"));
            }

             try
             {
            data.Add(new Snoop.Data.Object("Reference", crv.Reference));
             }
             catch (System.Exception ex)
             {
            data.Add(new Snoop.Data.Exception("Reference", ex));
             }

             try
             {
            data.Add(new Snoop.Data.Object("Derivative at Start", crv.ComputeDerivatives(0.0, normalized: true)));
             }
             catch (System.Exception ex)
             {
//.........这里部分代码省略.........
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:101,代码来源:CollectorExtGeom.cs

示例5: MaybeStretchBaseCurve

        private static Curve MaybeStretchBaseCurve(Curve baseCurve, Curve trimmedCurve)
        {
            // Only works for bound curves.
            if (!baseCurve.IsBound || !trimmedCurve.IsBound)
                return null;

            // The original end parameters.
            double baseCurveParam0 = baseCurve.GetEndParameter(0);
            double baseCurveParam1 = baseCurve.GetEndParameter(1);

            // The trimmed curve may actually extend beyond the base curve at one end - make sure we extend the base curve.
            XYZ trimmedEndPt0 = trimmedCurve.GetEndPoint(0);
            XYZ trimmedEndPt1 = trimmedCurve.GetEndPoint(1);

            Curve axisCurve = baseCurve.Clone();
            if (axisCurve == null)
                return null;

            // We need to make the curve unbound before we find the trimmed end parameters, because Project finds the closest point
            // on the bounded curve, whereas we want to find the closest point on the unbounded curve.
            axisCurve.MakeUnbound();

            IntersectionResult result0 = axisCurve.Project(trimmedEndPt0);
            IntersectionResult result1 = axisCurve.Project(trimmedEndPt1);

            // One of the intersection points is not on the unbound curve - abort.
            if (!MathUtil.IsAlmostZero(result0.Distance) || !MathUtil.IsAlmostZero(result1.Distance))
                return null;

            double projectedEndParam0 = result0.Parameter;
            double projectedEndParam1 = result1.Parameter;

            double minParam = baseCurveParam0;
            double maxParam = baseCurveParam1;

            // Check that the orientation is correct.
            if (axisCurve.IsCyclic)
            {
                XYZ midTrimmedPtXYZ = (trimmedCurve.Evaluate(0.5, true));
                IntersectionResult result2 = axisCurve.Project(midTrimmedPtXYZ);
                if (!MathUtil.IsAlmostZero(result2.Distance))
                    return null;

                double projectedEndParamMid = (projectedEndParam0 + projectedEndParam1) / 2.0;
                bool parametersAreNotFlipped = MathUtil.IsAlmostEqual(projectedEndParamMid, result2.Parameter);
                bool trimmedCurveIsCCW = ((projectedEndParam0 < projectedEndParam1) == parametersAreNotFlipped);

                if (!trimmedCurveIsCCW)
                {
                    double tmp = projectedEndParam0; projectedEndParam0 = projectedEndParam1; projectedEndParam1 = tmp;
                }

                // While this looks inefficient, in practice we expect to do each while loop 0 or 1 times.
                double period = axisCurve.Period;
                while (projectedEndParam0 > baseCurveParam1) projectedEndParam0 -= period;
                while (projectedEndParam1 < baseCurveParam0) projectedEndParam1 += period;

                minParam = Math.Min(minParam, projectedEndParam0);
                maxParam = Math.Max(maxParam, projectedEndParam1);
            }
            else
            {
                minParam = Math.Min(minParam, Math.Min(projectedEndParam0, projectedEndParam1));
                maxParam = Math.Max(maxParam, Math.Max(projectedEndParam0, projectedEndParam1));
            }

            axisCurve.MakeBound(minParam, maxParam);
            return axisCurve;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:69,代码来源:WallExporter.cs

示例6: CreateSimpleSweptSolidAsBRep

        /// <summary>
        /// Creates a facetation of a simple swept solid from a list of curve loops.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="profileName">The profile name.</param>
        /// <param name="profileCurveLoops">The profile curve loops.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <param name="directrix">The path curve.</param>
        /// <returns>The list of facet handles.</returns>
        public static HashSet<IFCAnyHandle> CreateSimpleSweptSolidAsBRep(ExporterIFC exporterIFC, string profileName, IList<CurveLoop> profileCurveLoops,
            XYZ normal, Curve directrix)
        {
            // see definition of IfcSurfaceCurveSweptAreaSolid from
            // http://www.buildingsmart-tech.org/ifc/IFC2x4/rc4/html/schema/ifcgeometricmodelresource/lexical/ifcsurfacecurvesweptareasolid.htm

            HashSet<IFCAnyHandle> facetHnds = null;

            if (!CanCreateSimpleSweptSolid(profileCurveLoops, normal, directrix))
                return facetHnds;

            // An extra requirement, as we can't tessellate an unbound curve.
            if (!directrix.IsBound)
                return facetHnds;
            double originalStartParam = directrix.GetEndParameter(0);

            Plane axisPlane, profilePlane;
            CreateAxisAndProfileCurvePlanes(directrix, originalStartParam, out axisPlane, out profilePlane);

            IList<CurveLoop> curveLoops = null;
            try
            {
                // Check that curve loops are valid.
                curveLoops = ExporterIFCUtils.ValidateCurveLoops(profileCurveLoops, profilePlane.Normal);
            }
            catch (Exception)
            {
                return null;
            }

            if (curveLoops == null || curveLoops.Count == 0)
                return facetHnds;

            // Tessellate the curve loops.  We don't add the last point, as these should all be closed curves.
            IList<IList<XYZ>> tessellatedOutline = new List<IList<XYZ>>();
            foreach (CurveLoop curveLoop in curveLoops)
            {
                List<XYZ> tessellatedCurve = new List<XYZ>();
                foreach (Curve curve in curveLoop)
                {
                    if (curve is Line)
                    {
                        AddScaledPointToList(exporterIFC, tessellatedCurve, curve.GetEndPoint(0));
                    }
                    else
                    {
                        IList<XYZ> curveTessellation = CreateRoughTessellation(exporterIFC, curve);
                        tessellatedCurve.AddRange(curveTessellation);
                    }
                }

                if (tessellatedCurve.Count != 0)
                    tessellatedOutline.Add(tessellatedCurve);
            }

            IFCFile file = exporterIFC.GetFile();

            IList<IList<IList<IFCAnyHandle>>> facetVertexHandles = new List<IList<IList<IFCAnyHandle>>>();

            IList<IList<IFCAnyHandle>> tessellatedOutlineHandles = new List<IList<IFCAnyHandle>>();
            foreach (IList<XYZ> tessellatedOutlinePolygon in tessellatedOutline)
            {
                IList<IFCAnyHandle> tessellatedOutlinePolygonHandles = new List<IFCAnyHandle>();
                foreach (XYZ tessellatedOutlineXYZ in tessellatedOutlinePolygon)
                {
                    tessellatedOutlinePolygonHandles.Add(ExporterUtil.CreateCartesianPoint(file, tessellatedOutlineXYZ));
                }
                tessellatedOutlineHandles.Add(tessellatedOutlinePolygonHandles);
            }
            facetVertexHandles.Add(tessellatedOutlineHandles);

            // Tessellate the Directrix.  This only works for bound Directrix curves. Unfortunately, we get XYZ values, which we will have to convert
            // back to parameter values to get the local transform.
            IList<double> tessellatedDirectrixParameters = CreateRoughParametricTessellation(directrix);

            // Create all of the other outlines by transformng the first tessellated outline to the current transform.
            Transform profilePlaneTrf = Transform.CreateTranslation(ExporterIFCUtils.TransformAndScalePoint(exporterIFC, profilePlane.Origin));
            profilePlaneTrf.BasisX = ExporterIFCUtils.TransformAndScaleVector(exporterIFC, profilePlane.XVec);
            profilePlaneTrf.BasisY = ExporterIFCUtils.TransformAndScaleVector(exporterIFC, profilePlane.YVec);
            profilePlaneTrf.BasisZ = ExporterIFCUtils.TransformAndScaleVector(exporterIFC, profilePlane.Normal);

            // The inverse transform will be applied to generate the delta transform for the profile curves from the start of the directrix
            // to the current location.  This could be optimized in the case of a Line, but current usage is really only for a single arc.
            // If that changes, we should revisit optimization possibilities.
            Transform profilePlaneTrfInverse = profilePlaneTrf.Inverse;

            // Create the delta transforms and the offset tessellated profiles.
            foreach (double parameter in tessellatedDirectrixParameters)
            {
                Transform directrixDirs = CreateProfileCurveTransform(exporterIFC, directrix, parameter);
                Transform deltaTransform = directrixDirs.Multiply(profilePlaneTrfInverse);
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:SweptSolidExporter.cs

示例7: CreateSimpleSweptSolid

        /// <summary>
        /// Creates a simple swept solid from a list of curve loops.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="profileName">The profile name.</param>
        /// <param name="profileCurveLoops">The profile curve loops.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <param name="directrix">The path curve.</param>
        /// <returns>The swept solid handle.</returns>
        public static IFCAnyHandle CreateSimpleSweptSolid(ExporterIFC exporterIFC, string profileName, IList<CurveLoop> profileCurveLoops,
            XYZ normal, Curve directrix)
        {
            // see definition of IfcSurfaceCurveSweptAreaSolid from
            // http://www.buildingsmart-tech.org/ifc/IFC2x4/rc4/html/schema/ifcgeometricmodelresource/lexical/ifcsurfacecurvesweptareasolid.htm

            IFCAnyHandle simpleSweptSolidHnd = null;

            if (!CanCreateSimpleSweptSolid(profileCurveLoops, normal, directrix))
                return simpleSweptSolidHnd;

            bool isBound = directrix.IsBound;
            double originalStartParam = isBound ? directrix.GetEndParameter(0) : 0.0;

            Plane axisPlane, profilePlane;
            CreateAxisAndProfileCurvePlanes(directrix, originalStartParam, out axisPlane, out profilePlane);

            IList<CurveLoop> curveLoops = null;
            try
            {
                // Check that curve loops are valid.
                curveLoops = ExporterIFCUtils.ValidateCurveLoops(profileCurveLoops, profilePlane.Normal);
            }
            catch (Exception)
            {
                return null;
            }

            if (curveLoops == null || curveLoops.Count == 0)
                return simpleSweptSolidHnd;

            double startParam = 0.0, endParam = 1.0;
            if (directrix is Arc)
            {
                // This effectively resets the start parameter to 0.0, and end parameter = length of curve.
                if (isBound)
                    endParam = UnitUtil.ScaleAngle(MathUtil.PutInRange(directrix.GetEndParameter(1), Math.PI, 2 * Math.PI) -
                        MathUtil.PutInRange(originalStartParam, Math.PI, 2 * Math.PI));
                else
                    endParam = 2.0 * Math.PI;
            }

            // Start creating IFC entities.

            IFCAnyHandle sweptArea = ExtrusionExporter.CreateSweptArea(exporterIFC, profileName, curveLoops, profilePlane, profilePlane.Normal);
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(sweptArea))
                return simpleSweptSolidHnd;

            IFCAnyHandle curveHandle = null;
            IFCAnyHandle referenceSurfaceHandle = ExtrusionExporter.CreateSurfaceOfLinearExtrusionFromCurve(exporterIFC, directrix, axisPlane, 1.0, 1.0,
                out curveHandle);

            // Should this be moved up?  Check.
            Plane scaledAxisPlane = GeometryUtil.GetScaledPlane(exporterIFC, axisPlane);

            IFCFile file = exporterIFC.GetFile();

            IFCAnyHandle solidAxis = ExporterUtil.CreateAxis(file, scaledAxisPlane.Origin, scaledAxisPlane.Normal, scaledAxisPlane.XVec);

            simpleSweptSolidHnd = IFCInstanceExporter.CreateSurfaceCurveSweptAreaSolid(file, sweptArea, solidAxis, curveHandle, startParam,
                endParam, referenceSurfaceHandle);
            return simpleSweptSolidHnd;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:72,代码来源:SweptSolidExporter.cs

示例8: CreateCurveLoopFromUnboundedCyclicCurve

        // In certain cases, Revit can't handle unbounded circles and ellipses.  Create a CurveLoop with the curve split into two segments.
        private CurveLoop CreateCurveLoopFromUnboundedCyclicCurve(Curve innerCurve)
        {
            if (innerCurve == null)
                return null;

            if (!innerCurve.IsCyclic)
                return null;

            // We don't know how to handle anything other than circles or ellipses with a period of 2PI.
            double period = innerCurve.Period;
            if (!MathUtil.IsAlmostEqual(period, Math.PI * 2.0))
                return null;

            double startParam = innerCurve.IsBound ? innerCurve.GetEndParameter(0) : 0.0;
            double endParam = innerCurve.IsBound ? innerCurve.GetEndParameter(1) : period;

            // Not a closed curve.
            if (!MathUtil.IsAlmostEqual(endParam - startParam, period))
                return null;

            Curve firstCurve = innerCurve.Clone();
            if (firstCurve == null)
                return null;

            Curve secondCurve = innerCurve.Clone();
            if (secondCurve == null)
                return null;

            firstCurve.MakeBound(0, period / 2.0);
            secondCurve.MakeBound(period / 2.0, period);

            CurveLoop innerCurveLoop = new CurveLoop();
            innerCurveLoop.Append(firstCurve);
            innerCurveLoop.Append(secondCurve);
            return innerCurveLoop;
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:37,代码来源:IFCProfileDef.cs


注:本文中的Curve.GetEndParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。