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


C# Curve.ComputeDerivatives方法代码示例

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


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

示例1: 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

示例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: 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 (profileCurveLoops.Count == 0)
                return simpleSweptSolidHnd;

            IFCFile file = exporterIFC.GetFile();

            XYZ startPoint = directrix.get_EndPoint(0);
            XYZ profilePlaneNormal = null;
            XYZ profilePlaneXDir = null;
            XYZ profilePlaneYDir = null;

            IFCAnyHandle curveHandle = null;

            double startParam = 0, endParam = 1;
            Plane scaledReferencePlane = null;
            if (directrix is Line)
            {
                Line line = directrix as Line;
                startParam = line.get_EndParameter(0);
                endParam = line.get_EndParameter(1);
                profilePlaneNormal = line.Direction;
                profilePlaneYDir = normal;
                profilePlaneXDir = profilePlaneNormal.CrossProduct(profilePlaneYDir);

                XYZ linePlaneNormal = profilePlaneYDir;
                XYZ linePlaneXDir = profilePlaneXDir;
                XYZ linePlaneYDir = linePlaneNormal.CrossProduct(linePlaneXDir);
                XYZ linePlaneOrig = startPoint;

                scaledReferencePlane = GeometryUtil.CreateScaledPlane(exporterIFC, linePlaneXDir, linePlaneYDir, linePlaneOrig);
                curveHandle = GeometryUtil.CreateLine(exporterIFC, line, scaledReferencePlane);
            }
            else if (directrix is Arc)
            {
                Arc arc = directrix as Arc;

                startParam = MathUtil.PutInRange(arc.get_EndParameter(0), Math.PI, 2 * Math.PI) * (180 / Math.PI);
                endParam = MathUtil.PutInRange(arc.get_EndParameter(1), Math.PI, 2 * Math.PI) * (180 / Math.PI);

                profilePlaneNormal = directrix.ComputeDerivatives(0, true).BasisX;
                profilePlaneXDir = (arc.Center - startPoint).Normalize();
                profilePlaneYDir = profilePlaneNormal.CrossProduct(profilePlaneXDir).Normalize();

                XYZ arcPlaneNormal = arc.Normal;
                XYZ arcPlaneXDir = profilePlaneXDir;
                XYZ arcPlaneYDir = arcPlaneNormal.CrossProduct(arcPlaneXDir);
                XYZ arcPlaneOrig = startPoint;

                scaledReferencePlane = GeometryUtil.CreateScaledPlane(exporterIFC, arcPlaneXDir, arcPlaneYDir, arcPlaneOrig);
                curveHandle = GeometryUtil.CreateArc(exporterIFC, arc, scaledReferencePlane);
            }
            else
                return simpleSweptSolidHnd;

            IFCAnyHandle referencePlaneAxisHandle = ExporterUtil.CreateAxis(file, scaledReferencePlane.Origin, scaledReferencePlane.Normal, scaledReferencePlane.XVec);
            IFCAnyHandle referencePlaneHandle = IFCInstanceExporter.CreatePlane(file, referencePlaneAxisHandle);

            Plane profilePlane = new Plane(profilePlaneXDir, profilePlaneYDir, startPoint);

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

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

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

            profilePlane = GeometryUtil.GetScaledPlane(exporterIFC, profilePlane);
            IFCAnyHandle solidAxis = ExporterUtil.CreateAxis(file, profilePlane.Origin, profilePlane.Normal, profilePlane.XVec);

            simpleSweptSolidHnd = IFCInstanceExporter.CreateSurfaceCurveSweptAreaSolid(file, sweptArea, solidAxis, curveHandle, startParam,
                endParam, referencePlaneHandle);
            return simpleSweptSolidHnd;
        }
开发者ID:stiter,项目名称:ifcexporter,代码行数:100,代码来源:SweptSolidExporter.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: CreateAxisAndProfileCurvePlanes

        private static void CreateAxisAndProfileCurvePlanes(Curve directrix, double param, out Plane axisPlane, out Plane profileCurvePlane)
        {
            Transform directrixDirs = directrix.ComputeDerivatives(param, false);
            XYZ startPoint = directrixDirs.Origin;

            // The X and Y are reversed for the axisPlane; the X is the direction orthogonal to the curve in the plane of the curve, and Y is the tangent.
            XYZ curveXDir = -directrixDirs.BasisY.Normalize();
            XYZ curveYDir = directrixDirs.BasisX.Normalize();
            XYZ curveZDir = directrixDirs.BasisZ.Normalize();

            // We are constructing the profile plane so that the normal matches the curve tangent, and the X matches the curve normal.
            XYZ profilePlaneXDir = curveZDir;
            XYZ profilePlaneYDir = curveXDir;
            XYZ profilePlaneZDir = curveYDir;

            axisPlane = new Plane(curveXDir, curveYDir, startPoint);

            profileCurvePlane = new Plane(profilePlaneXDir, profilePlaneYDir, startPoint);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:19,代码来源:SweptSolidExporter.cs

示例6: CreateProfileCurveTransform

        private static Transform CreateProfileCurveTransform(ExporterIFC exporterIFC, Curve directrix, double param)
        {
            Transform directrixDirs = directrix.ComputeDerivatives(param, false);
            XYZ origin = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, directrixDirs.Origin);

            // We are constructing the profile plane so that the normal matches the curve tangent, and the X matches the curve normal.
            XYZ profilePlaneXDir = ExporterIFCUtils.TransformAndScaleVector(exporterIFC, directrixDirs.BasisZ.Normalize());
            XYZ profilePlaneYDir = ExporterIFCUtils.TransformAndScaleVector(exporterIFC, -directrixDirs.BasisY.Normalize());
            XYZ profilePlaneZDir = ExporterIFCUtils.TransformAndScaleVector(exporterIFC, directrixDirs.BasisX.Normalize());

            Transform profileCurveTransform = Transform.CreateTranslation(origin);
            profileCurveTransform.BasisX = profilePlaneXDir;
            profileCurveTransform.BasisY = profilePlaneYDir;
            profileCurveTransform.BasisZ = profilePlaneZDir;

            return profileCurveTransform;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:17,代码来源:SweptSolidExporter.cs

示例7: GetOrientedCurveList

      /// <summary>
      /// Returns a list of curves that represent the profile of an extrusion to be split into material layers, for simple cases.
      /// </summary>
      /// <param name="loops">The original CurveLoops representing the extrusion profile.</param>
      /// <param name="axisCurve">The axis curve used by IfcMaterialLayerUsage to place the IfcMaterialLayers.</param>
      /// <param name="offsetNorm">The normal used for calculating curve offsets.</param>
      /// <param name="offset">The offset distance from the axis curve to the material layers, as defined in the IfcMaterialLayerSetUsage "OffsetFromReferenceLine" parameter.</param>
      /// <param name="totalThickness">The total thickness of all of the generated material layers.</param>
      /// <returns>A list of curves oriented according to the axis curve.</returns>
      /// <remarks>The list will contain 4 curves in this order:
      /// 1. The curve (a bounded Line or an Arc) at the boundary of the first material layer, oriented in the same direction as the Axis curve.
      /// 2. The line, possibly slanted, representing an end cap and connecting the 1st curve to the 3rd curve.
      /// 3. The curve (of the same type as the first) at the boundary of the last material layer, oriented in the opposite direction as the Axis curve.
      /// 4. The line, possibly slanted, representing an end cap and connecting the 3rd curve to the 1st curve.
      /// Over time, we may increase the number of cases suported.</remarks>
      private IList<Curve> GetOrientedCurveList(IList<CurveLoop> loops, Curve axisCurve, XYZ offsetNorm, double offset, double totalThickness)
      {
         // We are going to limit our attempts to a fairly simple but common case:
         // 1. 2 bounded curves parallel to the axis curve, of the same type, and either Lines or Arcs.
         // 2. 2 other edges connecting the two other curves, which are Lines.
         // This covers most cases and gets rid of issues with highly irregular edges.
         if (loops.Count() != 1 || loops[0].Count() != 4)
            return null;

         // The CreateOffset routine works opposite what IFC expects.  For a line, the Revit API offset direction
         // is the (line tangent) X (the normal of the plane containing the line).  In IFC, the (local) line tangent is +X,
         // the local normal of the plane is +Z, and the positive direction of the offset is +Y.  As such, we need to
         // reverse the normal of the plane to offset in the right direction.
         Curve offsetAxisCurve = axisCurve.CreateOffset(offset, -offsetNorm);

         Curve unboundOffsetAxisCurve = offsetAxisCurve.Clone();
         unboundOffsetAxisCurve.MakeUnbound();

         IList<Curve> originalCurveList = new List<Curve>();
         IList<Curve> unboundCurveList = new List<Curve>();
         foreach (Curve loopCurve in loops[0])
         {
            originalCurveList.Add(loopCurve);
            Curve unboundCurve = loopCurve.Clone();
            unboundCurve.MakeUnbound();
            unboundCurveList.Add(unboundCurve);
         }

         int startIndex = -1;
         bool flipped = false;
         for (int ii = 0; ii < 4; ii++)
         {
            // The offset axis curve should match one of the curves of the extrusion profile.  
            // We check that here by seeing if a point on the offset axis curve is on the current unbounded curve.
            if (unboundCurveList[ii].Intersect(unboundOffsetAxisCurve) != SetComparisonResult.Overlap &&
                MathUtil.IsAlmostZero(unboundCurveList[ii].Distance(offsetAxisCurve.GetEndPoint(0))))
            {
               startIndex = ii;

               Transform originalCurveLCS = originalCurveList[ii].ComputeDerivatives(0.0, true);
               Transform axisCurveLCS = axisCurve.ComputeDerivatives(0.0, true);

               // We want the first curve to have the same orientation as the axis curve. We will flip the resulting
               // "curve loop" if not.
               bool? maybeFlipped = CurvesHaveOppositeOrientation(originalCurveList[ii], axisCurve);
               if (!maybeFlipped.HasValue)
                  return null;

               flipped = maybeFlipped.Value;

               // Now check that startIndex and startIndex+2 are parallel, and totalThickness apart.
               if ((unboundCurveList[ii].Intersect(unboundCurveList[(ii + 2) % 4]) == SetComparisonResult.Overlap) ||
                   !MathUtil.IsAlmostEqual(unboundCurveList[ii].Distance(originalCurveList[(ii + 2) % 4].GetEndPoint(0)), totalThickness))
                  return null;

               break;
            }
         }

         // We may want to consider loosening the IsAlmostEqual check above if this fails a lot for seemingly good cases.
         if (startIndex == -1)
            return null;

         IList<Curve> orientedCurveList = new List<Curve>();
         for (int ii = 0, currentIndex = startIndex; ii < 4; ii++)
         {
            Curve currentCurve = originalCurveList[currentIndex];
            if (flipped)
               currentCurve = currentCurve.CreateReversed();
            orientedCurveList.Add(currentCurve);
            currentIndex = flipped ? (currentIndex + 3) % 4 : (currentIndex + 1) % 4;
         }
         return orientedCurveList;
      }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:89,代码来源:IFCExtrudedAreaSolid.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: GetTangentAt

 /// <summary>
 /// Obtains the tangent of the given curve at the given parameter.
 /// </summary>
 /// <param name="curve">The curve.</param>
 /// <param name="parameter">The normalized parameter.</param>
 /// <returns>The normalized tangent vector.</returns>
 private XYZ GetTangentAt(Curve curve, double parameter)
 {
     Transform t = curve.ComputeDerivatives(parameter, true);
     // BasisX is the tangent vector of the curve.
     return t.BasisX.Normalize();
 }
开发者ID:AMEE,项目名称:revit,代码行数:12,代码来源:FindColumns.cs


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