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


C# CurveLoop类代码示例

本文整理汇总了C#中CurveLoop的典型用法代码示例。如果您正苦于以下问题:C# CurveLoop类的具体用法?C# CurveLoop怎么用?C# CurveLoop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetValidXVectorFromLoop

        private XYZ GetValidXVectorFromLoop(CurveLoop curveLoop, XYZ zVec, XYZ origin)
        {
            foreach (Curve curve in curveLoop)
            {
                IList<XYZ> pointsToCheck = new List<XYZ>();

                // If unbound, must be cyclic.
                if (!curve.IsBound)
                {
                    pointsToCheck.Add(curve.Evaluate(0, false));
                    pointsToCheck.Add(curve.Evaluate(Math.PI / 2.0, false));
                    pointsToCheck.Add(curve.Evaluate(Math.PI, false));
                }
                else
                {
                    pointsToCheck.Add(curve.Evaluate(0, true));
                    pointsToCheck.Add(curve.Evaluate(1.0, true));
                    if (curve.IsCyclic)
                        pointsToCheck.Add(curve.Evaluate(0.5, true));
                }

                foreach (XYZ pointToCheck in pointsToCheck)
                {
                    XYZ possibleVec = (pointToCheck - origin);
                    XYZ yVec = zVec.CrossProduct(possibleVec).Normalize();
                    if (yVec.IsZeroLength())
                        continue;
                    return yVec.CrossProduct(zVec);
                }
            }

            return null;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:33,代码来源:IFCRevolvedAreaSolid.cs

示例2: IsIFCLoopCCW

        /// <summary>
        /// Determines if curve loop is counterclockwise.
        /// </summary>
        /// <param name="curveLoop">
        /// The curveLoop.
        /// </param>
        /// <param name="normal">
        /// The normal.
        /// </param>
        /// <returns>
        /// Returns true only if the loop is counterclockwise, false otherwise.
        /// </returns>
        public static bool IsIFCLoopCCW(CurveLoop curveLoop, XYZ normal)
        {
            if (curveLoop == null)
                throw new Exception("CurveLoop is null.");

            // If loop is not suitable for ccw evaluation an exception is thrown
            return curveLoop.IsCounterclockwise(normal);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:20,代码来源:GeometryUtil.cs

示例3: GenerateLoop

 protected override CurveLoop GenerateLoop()
 {
     CurveLoop curveLoop = new CurveLoop();
     foreach (IFCOrientedEdge edge in EdgeList) 
     {
         if (edge != null)
             curveLoop.Append(edge.GetGeometry());
     }
     return curveLoop;
 }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:10,代码来源:IFCEdgeLoop.cs

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

示例5: CreateTransformed

        /// <summary>
        /// Create a copy of a curve loop with a given transformation applied.
        /// </summary>
        /// <param name="origLoop">The original curve loop.</param>
        /// <param name="trf">The transform.</param>
        /// <returns>The transformed loop.</returns>
        public static CurveLoop CreateTransformed(CurveLoop origLoop, Transform trf)
        {
            if (origLoop == null)
                return null;

            CurveLoop newLoop = new CurveLoop();
            foreach (Curve curve in origLoop)
            {
                newLoop.Append(curve.CreateTransformed(trf));
            }
            return newLoop;
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:18,代码来源:IFCGeometryUtil.cs

示例6: CurveLoopIsARectangle

        private static bool CurveLoopIsARectangle(CurveLoop curveLoop, out IList<int> cornerIndices)
        {
            cornerIndices = new List<int>(4);

            // looking for four orthogonal lines in one curve loop.
            int sz = curveLoop.Count();
            if (sz < 4)
                return false;

            IList<Line> lines = new List<Line>();
            foreach (Curve curve in curveLoop)
            {
                if (!(curve is Line))
                    return false;

                lines.Add(curve as Line);
            }

            sz = lines.Count;
            int numAngles = 0;

            // Must have 4 right angles found, and all other lines collinear -- if not, not a rectangle.
            for (int ii = 0; ii < sz; ii++)
            {
                double dot = lines[ii].Direction.DotProduct(lines[(ii + 1) % sz].Direction);
                if (MathUtil.IsAlmostZero(dot))
                {
                    if (numAngles > 3)
                        return false;
                    cornerIndices.Add(ii);
                    numAngles++;
                }
                else if (MathUtil.IsAlmostEqual(dot, 1.0))
                {
                    XYZ line0End1 = lines[ii].GetEndPoint(1);
                    XYZ line1End0 = lines[(ii + 1) % sz].GetEndPoint(0);
                    if (!line0End1.IsAlmostEqualTo(line1End0))
                        return false;
                }
                else
                    return false;
            }

            return (numAngles == 4);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:45,代码来源:ExtrusionExporter.cs

示例7: ToRevitType

        /// <summary>
        /// A PolyCurve is not a curve, this is a special extension method to convert to a Revit CurveLoop
        /// </summary>
        /// <param name="pcrv"></param>
        /// <returns></returns>
        public static Autodesk.Revit.DB.CurveLoop ToRevitType(this Autodesk.DesignScript.Geometry.PolyCurve pcrv)
        {
            if (!pcrv.IsClosed)
            {
                throw new Exception("The input PolyCurve must be closed");
            }

            var cl = new CurveLoop();

            var crvs = pcrv.Curves();

            foreach (Autodesk.DesignScript.Geometry.Curve curve in crvs)
            {
                Autodesk.Revit.DB.Curve converted = curve.ToNurbsCurve().ToRevitType();
                cl.Append(converted);
            }

            return cl;

        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:25,代码来源:ProtoToRevitCurve.cs

示例8: ToRevitType

        public static Autodesk.Revit.DB.CurveLoop ToRevitType(this Autodesk.DesignScript.Geometry.PolyCurve pcrv,
            bool performHostUnitConversion = true)
        {
            if (!pcrv.IsClosed)
            {
                throw new Exception("The input PolyCurve must be closed");
            }

            pcrv = performHostUnitConversion ? pcrv.InHostUnits() : pcrv;

            var cl = new CurveLoop();
            var crvs = pcrv.Curves();

            foreach (Autodesk.DesignScript.Geometry.Curve curve in crvs)
            {
                Autodesk.Revit.DB.Curve converted = curve.ToNurbsCurve().ToRevitType(false);
                cl.Append(converted);
            }

            return cl;
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:21,代码来源:ProtoToRevitCurve.cs

示例9: GetFaceBoundary

        private static CurveLoop GetFaceBoundary(Face face, EdgeArray faceBoundary, XYZ baseLoopOffset,
            bool polygonalOnly, out FaceBoundaryType faceBoundaryType)
        {
            faceBoundaryType = FaceBoundaryType.Polygonal;
            CurveLoop currLoop = new CurveLoop();
            foreach (Edge faceBoundaryEdge in faceBoundary)
            {
                Curve edgeCurve = faceBoundaryEdge.AsCurveFollowingFace(face);
                Curve offsetCurve = (baseLoopOffset != null) ? MoveCurve(edgeCurve, baseLoopOffset) : edgeCurve;
                if (!(offsetCurve is Line))
                {
                    if (polygonalOnly)
                    {
                        IList<XYZ> tessPts = offsetCurve.Tessellate();
                        int numTessPts = tessPts.Count;
                        for (int ii = 0; ii < numTessPts - 1; ii++)
                        {
                            Line line = Line.get_Bound(tessPts[ii], tessPts[ii + 1]);
                            currLoop.Append(line);
                        }
                    }
                    else
                    {
                        currLoop.Append(offsetCurve);
                    }

                    if (offsetCurve is Arc)
                        faceBoundaryType = FaceBoundaryType.LinesAndArcs;
                    else
                        faceBoundaryType = FaceBoundaryType.Complex;
                }
                else
                    currLoop.Append(offsetCurve);
            }
            return currLoop;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:36,代码来源:GeometryUtil.cs

示例10: ReverseOrientation

 /// <summary>
 /// Reverses curve loop.
 /// </summary>
 /// <param name="curveloop">
 /// The curveloop.
 /// </param>
 /// <returns>
 /// The reversed curve loop.
 /// </returns>
 public static CurveLoop ReverseOrientation(CurveLoop curveloop)
 {
     CurveLoop copyOfCurveLoop = CurveLoop.CreateViaCopy(curveloop);
     copyOfCurveLoop.Flip();
     return copyOfCurveLoop;
 }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:15,代码来源:GeometryUtil.cs

示例11: GetCurveLoop

        /// <summary>
        /// Get the curve or CurveLoop representation of IFCCurve, as a CurveLoop.  This will have a value, as long as Curve or CurveLoop do.
        /// </summary>
        public CurveLoop GetCurveLoop()
        {
            if (CurveLoop != null)
                return CurveLoop;
            if (Curve == null)
                return null;

            CurveLoop curveAsCurveLoop = new CurveLoop();
            curveAsCurveLoop.Append(Curve);
            return curveAsCurveLoop;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:14,代码来源:IFCCurve.cs

示例12: FindParentHandle

        /// <summary>
        /// Finds parent handle from opening CurveLoop and parent CurveLoops.
        /// </summary>
        /// <param name="elementHandles">The parent handles.</param>
        /// <param name="curveLoops">The parent CurveLoops.</param>
        /// <param name="openingLoop">The opening CurveLoop.</param>
        /// <returns>The parent handle.</returns>
        private static IFCAnyHandle FindParentHandle(IList<IFCAnyHandle> elementHandles, IList<CurveLoop> curveLoops, CurveLoop openingLoop)
        {
            // first one is roof handle, others are slabs
            if (elementHandles.Count != curveLoops.Count + 1)
                return null;

            for (int ii = 0; ii < curveLoops.Count; ii++)
            {
                if (GeometryUtil.CurveLoopsInside(openingLoop, curveLoops[ii]) || GeometryUtil.CurveLoopsIntersect(openingLoop, curveLoops[ii]))
                {
                    return elementHandles[ii + 1];
                }
            }
            return elementHandles[0];
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:22,代码来源:OpeningUtil.cs

示例13: SplitSweptDiskIntoValidPieces

        private IList<GeometryObject> SplitSweptDiskIntoValidPieces(CurveLoop trimmedDirectrixInWCS, IList<CurveLoop> profileCurveLoops, SolidOptions solidOptions)
        {
           // If we have 0 or 1 curves, there is nothing we can do here.
           int numCurves = trimmedDirectrixInWCS.Count();
           if (numCurves < 2)
              return null;

           // We will attempt to represent the original description in as few pieces as possible.  
           IList<Curve> directrixCurves = new List<Curve>();
           foreach (Curve directrixCurve in trimmedDirectrixInWCS)
           {
              if (directrixCurve == null)
              {
                 numCurves--;
                 if (numCurves < 2)
                    return null;
                 continue;
              }
              directrixCurves.Add(directrixCurve);
           }

           IList<GeometryObject> sweptDiskPieces = new List<GeometryObject>();

           // We will march along the directrix one curve at a time, trying to build a bigger piece of the sweep.  At the point that we throw an exception,
           // we will take the last biggest piece and start over.
           CurveLoop currentCurveLoop = new CurveLoop();
           Solid bestSolidSoFar = null;
           double pathAttachmentParam = directrixCurves[0].GetEndParameter(0);

           for (int ii = 0; ii < numCurves; ii++)
           {
              currentCurveLoop.Append(directrixCurves[ii]);
              try
              {
                 Solid currentSolid = GeometryCreationUtilities.CreateSweptGeometry(currentCurveLoop, 0, pathAttachmentParam, profileCurveLoops,
                    solidOptions);
                 bestSolidSoFar = currentSolid;
              }
              catch
              {
                 if (bestSolidSoFar != null)
                 {
                    sweptDiskPieces.Add(bestSolidSoFar);
                    bestSolidSoFar = null;
                 }
              }

              // This should only happen as a result of the catch loop above.  We want to protect against the case where one or more pieces of the sweep 
              // are completely invalid.
              while (bestSolidSoFar == null && (ii < numCurves))
              {
                 try
                 {
                    currentCurveLoop = new CurveLoop();
                    currentCurveLoop.Append(directrixCurves[ii]);
                    profileCurveLoops = CreateProfileCurveLoopsForDirectrix(directrixCurves[ii], out pathAttachmentParam);

                    Solid currentSolid = GeometryCreationUtilities.CreateSweptGeometry(currentCurveLoop, 0, pathAttachmentParam, profileCurveLoops,
                       solidOptions);
                    bestSolidSoFar = currentSolid;
                    break;
                 }
                 catch
                 {
                    ii++;
                 }
              }
           }

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

示例14: CreatePolyCurveLoop

        /// <summary>
        /// Creates an open or closed CurveLoop from a list of vertices.
        /// </summary>
        /// <param name="pointXYZs">The list of vertices.</param>
        /// <param name="points">The optional list of IFCAnyHandles that generated the vertices, used solely for error reporting.</param>
        /// <param name="id">The id of the IFCAnyHandle associated with the CurveLoop.</param>
        /// <param name="isClosedLoop">True if the vertices represent a closed loop, false if not.</param>
        /// <returns>The new curve loop.</returns>
        /// <remarks>If isClosedLoop is true, there will be pointsXyz.Count line segments.  Otherwise, there will be pointsXyz.Count-1.</remarks>
        public static CurveLoop CreatePolyCurveLoop(IList<XYZ> pointXYZs, IList<IFCAnyHandle> points, int id, bool isClosedLoop)
        {
            int numPoints = pointXYZs.Count;
            if (numPoints < 2)
                return null;

            IList<int> badIds = new List<int>();

            int numMinPoints = isClosedLoop ? 3 : 2;
            
            // Check distance between points; remove too-close points, and warn if result is non-collinear.
            // Always include first point.
            IList<XYZ> finalPoints = new List<XYZ>();
            finalPoints.Add(pointXYZs[0]);
            int numNewPoints = 1;
            for (int ii = 1; ii < numPoints; ii++)
            {
                if (IFCGeometryUtil.LineSegmentIsTooShort(finalPoints[numNewPoints - 1], pointXYZs[ii]))
                {
                    if (points != null)
                        badIds.Add(points[ii].StepId);
                    else
                        badIds.Add(ii+1);
                }
                else
                {
                    finalPoints.Add(pointXYZs[ii]);
                    numNewPoints++;
                }
            }

            // Check final segment; if too short, delete 2nd to last point.
            if (isClosedLoop)
            {
                if (IFCGeometryUtil.LineSegmentIsTooShort(finalPoints[numNewPoints - 1], pointXYZs[0]))
                {
                    finalPoints.RemoveAt(numNewPoints - 1);
                    numNewPoints--;
                }
            }

            // This can be a very common warning, so we will restrict to verbose logging.
            if (Importer.TheOptions.VerboseLogging)
            {
                if (badIds.Count > 0)
                {
                    int count = badIds.Count;
                    string msg = null;
                    if (count == 1)
                    {
                        msg = "Polyline had 1 point that was too close to one of its neighbors, removing point: #" + badIds[0] + ".";
                    }
                    else
                    {
                        msg = "Polyline had " + count + " points that were too close to one of their neighbors, removing points:";
                        foreach (int badId in badIds)
                            msg += " #" + badId;
                        msg += ".";
                    }
                    IFCImportFile.TheLog.LogWarning(id, msg, false);
                }
            }

            if (numNewPoints < numMinPoints)
            {
                if (Importer.TheOptions.VerboseLogging)
                {
                    string msg = "PolyCurve had " + numNewPoints + " point(s) after removing points that were too close, expected at least " + numMinPoints + ", ignoring.";
                    IFCImportFile.TheLog.LogWarning(id, msg, false);
                }
                return null;
            }

            CurveLoop curveLoop = new CurveLoop();
            for (int ii = 0; ii < numNewPoints - 1; ii++)
                curveLoop.Append(Line.CreateBound(finalPoints[ii], finalPoints[ii + 1]));
            if (isClosedLoop)
                curveLoop.Append(Line.CreateBound(finalPoints[numNewPoints - 1], finalPoints[0]));

            return curveLoop;
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:90,代码来源:IFCGeometryUtil.cs

示例15: TransformAndProjectCurveLoopToPlane

        private static IList<UV> TransformAndProjectCurveLoopToPlane(ExporterIFC exporterIFC, CurveLoop loop, Plane projScaledPlane)
        {
            IList<UV> uvs = new List<UV>();

            XYZ projDir = projScaledPlane.Normal;
            foreach (Curve curve in loop)
            {
                XYZ point = curve.get_EndPoint(0);
                XYZ scaledPoint = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, point);

                UV scaledUV = ProjectPointToPlane(projScaledPlane, projDir, scaledPoint);
                uvs.Add(scaledUV);
            }
            return uvs;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:15,代码来源:GeometryUtil.cs


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