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


C# Curve.Evaluate方法代码示例

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


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

示例1: CreateReversedCurve

    /// <summary>
    /// Create a new curve with the same 
    /// geometry in the reverse direction.
    /// </summary>
    /// <param name="orig">The original curve.</param>
    /// <returns>The reversed curve.</returns>
    /// <throws cref="NotImplementedException">If the 
    /// curve type is not supported by this utility.</throws>
    static Curve CreateReversedCurve(
      Autodesk.Revit.Creation.Application creapp,
      Curve orig )
    {
      if( !IsSupported( orig ) )
      {
        throw new NotImplementedException(
          "CreateReversedCurve for type "
          + orig.GetType().Name );
      }

      if( orig is Line )
      {
        return Line.CreateBound( 
          orig.GetEndPoint( 1 ),
          orig.GetEndPoint( 0 ) );
      }
      else if( orig is Arc )
      {
        return Arc.Create( orig.GetEndPoint( 1 ), 
          orig.GetEndPoint( 0 ), 
          orig.Evaluate( 0.5, true ) );
      }
      else
      {
        throw new Exception(
          "CreateReversedCurve - Unreachable" );
      }
    }
开发者ID:mtumminello,项目名称:RoomEditorApp,代码行数:37,代码来源:ContiguousCurveSorter.cs

示例2: GetPlaneFromCurve

        public static Plane GetPlaneFromCurve(Curve c, bool planarOnly)
        {
            //find the plane of the curve and generate a sketch plane
            double period = c.IsBound ? 0.0 : (c.IsCyclic ? c.Period : 1.0);

            var p0 = c.IsBound ? c.Evaluate(0.0, true) : c.Evaluate(0.0, false);
            var p1 = c.IsBound ? c.Evaluate(0.5, true) : c.Evaluate(0.25 * period, false);
            var p2 = c.IsBound ? c.Evaluate(1.0, true) : c.Evaluate(0.5 * period, false);

            if (IsLineLike(c))
            {
                XYZ norm = null;

                //keep old plane computations
                if (System.Math.Abs(p0.Z - p2.Z) < Tolerance)
                {
                    norm = XYZ.BasisZ;
                }
                else
                {
                    var v1 = p1 - p0;
                    var v2 = p2 - p0;

                    var p3 = new XYZ(p2.X, p2.Y, p0.Z);
                    var v3 = p3 - p0;
                    norm = v1.CrossProduct(v3);
                    if (norm.IsZeroLength())
                    {
                        norm = v2.CrossProduct(XYZ.BasisY);
                    }
                    norm = norm.Normalize();
                }

                return new Plane(norm, p0);

            }

            var cLoop = new CurveLoop();
            cLoop.Append(c.Clone());
            if (cLoop.HasPlane())
            {
                return cLoop.GetPlane();
            }
            if (planarOnly)
                return null;

            // Get best fit plane using tesselation
            var points = c.Tessellate().Select(x => x.ToPoint(false));

            var bestFitPlane =
                Autodesk.DesignScript.Geometry.Plane.ByBestFitThroughPoints(points);

            return bestFitPlane.ToPlane(false);
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:54,代码来源:CurveUtils.cs

示例3: GetAxisAndRangeFromCurve

 /// <summary>
 /// Gets origin, X direction and curve bound from a curve.
 /// </summary>
 /// <param name="curve">
 /// The curve.
 /// </param>
 /// <param name="curveBounds">
 /// The output curve bounds.
 /// </param>
 /// <param name="xDirection">
 /// The output X direction.
 /// </param>
 /// <param name="origin">
 /// The output origin.
 /// </param>
 public static void GetAxisAndRangeFromCurve(Curve curve,
    out IFCRange curveBounds, out XYZ xDirection, out XYZ origin)
 {
     curveBounds = new IFCRange(curve.get_EndParameter(0), curve.get_EndParameter(1));
     origin = curve.Evaluate(curveBounds.Start, false);
     if (curve is Arc)
     {
         Arc arc = curve as Arc;
         xDirection = arc.XDirection;
     }
     else
     {
         Transform trf = curve.ComputeDerivatives(curveBounds.Start, false);
         xDirection = trf.get_Basis(0);
     }
 }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:31,代码来源:GeometryUtil.cs

示例4: Rescale

        public float Rescale(float value, Curve analogEvaluationCurve)
        {
            if (value < m_Left)
            {
                m_Left = value;
            }
            else if (value > m_Right)
            {
                m_Right = value;
            }

            float eps = 1e-4f;

            if (value + eps > m_Identity && value - eps < m_Identity)
            {
                value = 0.0f;
            }
            else if (value < m_Identity)
            {
                value = (value - m_Identity) / (m_Identity - m_Left);
            }
            else if (value > m_Identity)
            {
                value = (value - m_Identity) / (m_Right - m_Identity);
            }

            if (Math.Abs(value) < 1e-4)
            {
                value = 0.0f;
            }

            if (value > 0.0f)
            {
                if (value < m_PositiveDeadZone)
                {
                    m_PositiveDeadZone = value;
                }

                float deadZone = m_PositiveDeadZone;
                float t = (1.0f - deadZone);
                if (t != 0.0f)
                {
                    value = (value - deadZone) / t;
                }
            }
            else if (value < 0.0f)
            {
                if (Math.Abs(value) < m_NegativeDeadZone)
                {
                    m_NegativeDeadZone = Math.Abs(value);
                }

                float deadZone = m_NegativeDeadZone;
                float t = (1.0f - deadZone);
                if (t != 0.0f)
                {
                    value = -1.0f * (Math.Abs(value) - deadZone) / t;
                }
            }

            return (m_Invert ? -1.0f : 1.0f) * Math.Sign(value) * analogEvaluationCurve.Evaluate(Math.Abs(value));
        }
开发者ID:ChristopherFunk,项目名称:ksp-advanced-flybywire,代码行数:62,代码来源:AxisConfiguration.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: CreateReversedCurve

 static Curve CreateReversedCurve(Autodesk.Revit.Creation.Application creapp, Curve orig)
 {
     if (orig is Autodesk.Revit.DB.Line)
     {
         return Autodesk.Revit.DB.Line.CreateBound(
           orig.GetEndPoint(1),
           orig.GetEndPoint(0));
     }
     else if (orig is Autodesk.Revit.DB.Arc)
     {
         return Autodesk.Revit.DB.Arc.Create(orig.GetEndPoint(1),
           orig.GetEndPoint(0),
           orig.Evaluate(0.5, true));
     }
     else
     {
         throw new Exception(
           "CreateReversedCurve - Unreachable");
     }
 }
开发者ID:bbrangeo,项目名称:Grevit,代码行数:20,代码来源:Utilities.cs

示例7: CreateCurveByPoints

        private Autodesk.Revit.DB.CurveByPoints CreateCurveByPoints(Autodesk.Revit.DB.CurveByPoints c, Curve gc, XYZ start, XYZ end)
        {
            //Add the geometry curves start and end points to a ReferencePointArray.
            ReferencePointArray refPtArr = new ReferencePointArray();
            if (gc.GetType() == typeof(Line))
            {
                ReferencePoint refPointStart = this.UIDocument.Document.FamilyCreate.NewReferencePoint(start);
                ReferencePoint refPointEnd = this.UIDocument.Document.FamilyCreate.NewReferencePoint(end);
                refPtArr.Append(refPointStart);
                refPtArr.Append(refPointEnd);
                //c = dynRevitSettings.Doc.Document.FamilyCreate.NewCurveByPoints(refPtArr);
            }
            else if (gc.GetType() == typeof(Arc) && foundCreateArcThroughPoints)
            {
                Type CurveByPointsUtilsType = typeof(Autodesk.Revit.DB.CurveByPointsUtils);
                MethodInfo[] curveElementMethods = CurveByPointsUtilsType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
                System.String nameOfMethodSetCurve = "CreateArcThroughPoints";

                foreach (MethodInfo m in curveElementMethods)
                {
                    if (m.Name == nameOfMethodSetCurve)
                    {
                        object[] argsM = new object[4];

                        ReferencePoint refPointStart = this.UIDocument.Document.FamilyCreate.NewReferencePoint(start);
                        ReferencePoint refPointEnd = this.UIDocument.Document.FamilyCreate.NewReferencePoint(end);
                        XYZ midPoint = gc.Evaluate(0.5, true);
                        ReferencePoint refMidPoint = this.UIDocument.Document.FamilyCreate.NewReferencePoint(midPoint);

                        argsM[0] = this.UIDocument.Document;
                        argsM[1] = refPointStart;
                        argsM[2] = refPointEnd;
                        argsM[3] = refMidPoint;

                        c = (Autodesk.Revit.DB.CurveByPoints)m.Invoke(null, argsM);
                        if (c != null && c.GeometryCurve.GetType() == typeof(Arc))
                           return c;
                        if (c != null)
                            this.DeleteElement(c.Id);
                        break;
                    }
                }
                foundCreateArcThroughPoints = false;
            }
            if (gc.GetType() != typeof(Line))
            {
                IList <XYZ> xyzList = gc.Tessellate();
                int numPoints = xyzList.Count;
                for (int ii = 0; ii < numPoints; ii++)
                {
                    ReferencePoint refPoint = this.UIDocument.Document.FamilyCreate.NewReferencePoint(xyzList[ii]);
                    refPtArr.Append(refPoint);
                }
            }
            c = dynRevitSettings.Doc.Document.FamilyCreate.NewCurveByPoints(refPtArr);
            return c;
        }
开发者ID:parchjs,项目名称:Dynamo,代码行数:57,代码来源:Curve.cs

示例8: GetAxisAndRangeFromCurve

 /// <summary>
 /// Gets origin, X direction and curve bound from a curve.
 /// </summary>
 /// <param name="curve">
 /// The curve.
 /// </param>
 /// <param name="curveBounds">
 /// The output curve bounds.
 /// </param>
 /// <param name="xDirection">
 /// The output X direction.
 /// </param>
 /// <param name="origin">
 /// The output origin.
 /// </param>
 public static void GetAxisAndRangeFromCurve(Curve curve,
    out UV curveBounds, out XYZ xDir, out XYZ orig)
 {
     curveBounds = new UV(curve.get_EndParameter(0), curve.get_EndParameter(1));
     orig = curve.Evaluate(curveBounds.U, false);
     Transform trf = curve.ComputeDerivatives(curveBounds.U, false);
     xDir = trf.get_Basis(0);
 }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:23,代码来源:GeometryUtil.cs

示例9: GetPlaneFromCurve

        public static Plane GetPlaneFromCurve(Curve c, bool planarOnly)
        {
            //cases to handle
            //straight line - normal will be inconclusive

            //find the plane of the curve and generate a sketch plane
            double period = c.IsBound ? 0.0 : (c.IsCyclic ? c.Period : 1.0);

            var p0 = c.IsBound ? c.Evaluate(0.0, true) : c.Evaluate(0.0, false);
            var p1 = c.IsBound ? c.Evaluate(0.5, true) : c.Evaluate(0.25 * period, false);
            var p2 = c.IsBound ? c.Evaluate(1.0, true) : c.Evaluate(0.5 * period, false);

            if (c is Line)
            {
                var v1 = p1 - p0;
                var v2 = p2 - p0;
                XYZ norm = null;

                //keep old plane computations
                if (Math.Abs(p0.Z - p2.Z) < 0.0001)
                {
                    norm = XYZ.BasisZ;
                }
                else
                {
                    var p3 = new XYZ(p2.X, p2.Y, p0.Z);
                    var v3 = p3 - p0;
                    norm = v1.CrossProduct(v3);
                    if (norm.IsZeroLength())
                    {
                        norm = v2.CrossProduct(XYZ.BasisY);
                    }
                    norm = norm.Normalize();
                }

                return new Plane(norm, p0);

            }

            Autodesk.Revit.DB.CurveLoop cLoop = new Autodesk.Revit.DB.CurveLoop();
            cLoop.Append(c.Clone());
            if (cLoop.HasPlane())
            {
                return cLoop.GetPlane();
            }
            if (planarOnly)
                return null;

            IList<XYZ> points = c.Tessellate();
            List<XYZ> xyzs = new List<XYZ>();
            for (int iPoint = 0; iPoint < points.Count; iPoint++)
                xyzs.Add(points[iPoint]);

            //var v1 = p1 - p0;
            //var v2 = p2 - p0;
            //var norm = v1.CrossProduct(v2).Normalize();

            ////Normal can be zero length in the case of a straight line
            ////or a curve whose three parameter points as measured above
            ////happen to lie along the same line. In this case, project
            ////the last point down to a plane and use the projected vector
            ////and one of the vectors from above to calculate a normal.
            //if (norm.IsZeroLength())
            //{
            //    if (p0.Z == p2.Z)
            //    {
            //        norm = XYZ.BasisZ;
            //    }
            //    else
            //    {
            //        var p3 = new XYZ(p2.X, p2.Y, p0.Z);
            //        var v3 = p3 - p0;
            //        norm = v1.CrossProduct(v3);
            //    }
            //}

            //var curvePlane = new Plane(norm, p0);

            XYZ meanPt;
            List<XYZ> orderedEigenvectors;
            BestFitLine.PrincipalComponentsAnalysis(xyzs, out meanPt, out orderedEigenvectors);
            var normal = orderedEigenvectors[0].CrossProduct(orderedEigenvectors[1]);
            var plane = dynRevitSettings.Doc.Application.Application.Create.NewPlane(normal, meanPt);
            return plane;
        }
开发者ID:kscalvin,项目名称:Dynamo,代码行数:85,代码来源:RevitUtils.cs

示例10: FindColumnsOnEitherSideOfWall

        /// <summary>
        /// Finds columns on either side of the given wall.
        /// </summary>
        /// <param name="wall">The wall.</param>
        /// <param name="locationCurve">The location curve of the wall.</param>
        /// <param name="wallCurve">The profile of the wall.</param>
        /// <param name="parameter">The normalized parameter along the wall profile which is being evaluated.</param>
        /// <param name="elevation">The elevation at which the rays are cast.</param>
        /// <param name="within">The maximum distance away that columns may be found.</param>
        private void FindColumnsOnEitherSideOfWall(Wall wall, LocationCurve locationCurve, Curve wallCurve, double parameter, double elevation, double within)
        {
            XYZ rayDirection = GetTangentAt(wallCurve, parameter);
            XYZ wallLocation = wallCurve.Evaluate(parameter, true);

            XYZ wallDelta = GetWallDeltaAt(wall, locationCurve, parameter);

            XYZ rayStart = new XYZ(wallLocation.X + wallDelta.X, wallLocation.Y + wallDelta.Y, elevation);
            FindColumnsByDirection(rayStart, rayDirection, within, wall);

            rayStart = new XYZ(wallLocation.X - wallDelta.X, wallLocation.Y - wallDelta.Y, elevation);
            FindColumnsByDirection(rayStart, rayDirection, within, wall);
        }
开发者ID:AMEE,项目名称:revit,代码行数:22,代码来源:FindColumns.cs

示例11: Rescale

        public float Rescale(float value, Curve analogEvaluationCurve, bool manualDeadZones)
        {
            if (value < m_Left)
            {
                m_Left = value;
            }
            else if (value > m_Right)
            {
                m_Right = value;
            }

            float eps = 1e-4f;

            if (value + eps > m_Identity && value - eps < m_Identity)
            {
                value = 0.0f;
            }
            else if (value < m_Identity)
            {
                value = (value - m_Identity) / (m_Identity - m_Left);
            }
            else if (value > m_Identity)
            {
                value = (value - m_Identity) / (m_Right - m_Identity);
            }

            if (Math.Abs(value) < 1e-4)
            {
                value = 0.0f;
            }

            if (value > 0.0f)
            {
                if (value < m_PositiveDeadZone && !manualDeadZones)
                {
                    m_PositiveDeadZone = value;
                }

                float deadZone = m_PositiveDeadZone;
                float t = (1.0f - deadZone);
                if (t != 0.0f)
                {
                    value = (value - deadZone) / t;
                }

                value = Mathf.Clamp(value, 0.0f, 1.0f);
            }
            else if (value < 0.0f)
            {
                if (Math.Abs(value) < m_NegativeDeadZone && !manualDeadZones)
                {
                    m_NegativeDeadZone = Math.Abs(value);
                }

                float deadZone = m_NegativeDeadZone;
                float t = (1.0f - deadZone);
                if (t != 0.0f)
                {
                    value = -1.0f * (Math.Abs(value) - deadZone) / t;
                }

                value = Mathf.Clamp(value, -1.0f, 0.0f);
            }

            return 1.0f * Math.Sign(value) * analogEvaluationCurve.Evaluate(Math.Abs(value));
        }
开发者ID:ChristopherFunk,项目名称:ksp-advanced-flybywire,代码行数:66,代码来源:AxisConfiguration.cs

示例12: drawInsulation

        /// <summary>
        /// DrawInsulation
        /// </summary>
        public double drawInsulation(List<ElementId> grp, Document doc, Curve lower, double distance, Curve upper, ref bool leftwing, List<Interruption> Breaks, bool zigzag)
        {
            double dist = distance / lower.Length;
            if (dist > 1) return 100;

            XYZ P1 = lower.Evaluate(dist, true);
            IntersectionResultArray result = new IntersectionResultArray();
            XYZ normal = lower.GetCurveTangentToEndPoint(P1);

            SetComparisonResult scr = Line.CreateUnbound(P1, normal).Intersect(upper, out result);
            if (result == null || result.Size == 0)
            {
                if (dist > 0.5) return 100;
                else
                {
                    upper = upper.Clone();
                    upper.MakeUnbound();
                    scr = Line.CreateUnbound(P1, normal).Intersect(upper, out result);
                }

            }

            XYZ P3 = result.get_Item(0).XYZPoint;
            double height = P1.DistanceTo(P3);
            double r = height / 4;
            double distr = (distance + r) / lower.Length;
            if (distr > 1) return 100;

            foreach (Interruption interrupt in Breaks)
            {
                if (distr > lower.ComputeNormalizedParameter(interrupt.from) && distr < lower.ComputeNormalizedParameter(interrupt.to)) return r;
            }

            XYZ P2 = (distr < 1) ? lower.Evaluate(distr, true) : P1;

            double disth = (distance + height) / lower.Length;

            SetComparisonResult scr2 = Line.CreateUnbound(P2, lower.GetCurveTangentToEndPoint(P2)).Intersect(upper, out result);
            if (result == null || result.Size == 0) return 100;
            XYZ P4 = (P1 != P2) ? result.get_Item(0).XYZPoint : upper.GetEndPoint(1);

            if (zigzag)
                drawZigZag(grp, doc, P1, P2, P3, P4, leftwing);
            else
                drawSoftLoop(grp, doc, P1, P2, P3, P4, leftwing);

            if (leftwing) leftwing = false; else leftwing = true;

            return r;
        }
开发者ID:moethu,项目名称:Insulator,代码行数:53,代码来源:Insulator.cs


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