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


C# Autodesk.Triangulate方法代码示例

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


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

示例1: TriangulateFace

        public void TriangulateFace(Autodesk.Revit.DB.Face vFace, Transform instTransform)
        {
            try
            {
                //setup utility class
                LuxExporter.UnitConverter Converter = new UnitConverter();

                //process face
                Mesh vMesh = vFace.Triangulate();

                //check if we have a quad mesh (4 edges to a face)
                if (vMesh.Vertices.Count == 4)
                {
                    //increase face counter
                    iNumberOfFaces++;

                    //found quad
                    Data.NumberOfVerticesinFace = 4;
                    //loop through all vertices and add
                    foreach (XYZ ii in vMesh.Vertices)
                    {
                        XYZ point = ii;
                        XYZ transformedPoint;

                        //transform geometry (only required in nested families / or elements like baluster
                        if (instTransform == null)
                        {
                            transformedPoint = point;
                        }
                        else
                        {
                            transformedPoint = instTransform.OfPoint(point);
                        }

                        //get the normal
                        XYZ NormalAtPoint;

                        IntersectionResult IntResult= vFace.Project(ii);

                        if (IntResult != null)
                        {
                            UV UVatPoint = IntResult.UVPoint;
                            NormalAtPoint = new XYZ(vFace.ComputeNormal(UVatPoint).X, vFace.ComputeNormal(UVatPoint).Y, vFace.ComputeNormal(UVatPoint).Z);
                        }
                        else
                        {
                            //this needs fixing!!!
                            NormalAtPoint = new XYZ(0, 0, 0);
                        }

                        //convert to meter
                        transformedPoint = Converter.ConvertPointCoordToMeter(transformedPoint);
                        //NormalAtPoint = Converter.ConvertPointCoordToMeter(NormalAtPoint);

                        //add to ply class
                        Data.AddVertice(transformedPoint,NormalAtPoint);

                    }

                }
                else
                {
                    // set pointer
                    Data.NumberOfVerticesinFace = 3;

                    //export all triangles in face
                    for (int i = 0; i < vMesh.NumTriangles; i++)
                    {
                        //increase face counter
                        iNumberOfFaces++;

                        MeshTriangle objTriangular = vMesh.get_Triangle(i);

                        for (int iPointsCounter = 0; iPointsCounter < 3; iPointsCounter++)
                        {
                            XYZ point = objTriangular.get_Vertex(iPointsCounter);
                            XYZ transformedPoint;
                            //transform geometry (only required in nested families / or elements like baluster
                            if (instTransform == null)
                            {
                                transformedPoint = point;
                            }
                            else
                            {
                                transformedPoint = instTransform.OfPoint(point);
                            }

                            XYZ NormalAtPoint;

                            //get the normal
                            IntersectionResult IntResult = vFace.Project(point);
                            if (IntResult!=null)
                            {
                                UV UVatPoint = IntResult.UVPoint;
                                NormalAtPoint = new XYZ(vFace.ComputeNormal(UVatPoint).X,vFace.ComputeNormal(UVatPoint).Y,vFace.ComputeNormal(UVatPoint).Z);
                            }
                            else
                            {
                                //this needs fixing
                                NormalAtPoint = new XYZ(0, 0, 0);
//.........这里部分代码省略.........
开发者ID:jchristel,项目名称:LuxExporter,代码行数:101,代码来源:PLY_By_Material.cs


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