Beispiel #1
0
        /// <summary>
        /// 输出Polymesh多边形网格,同时它也是属于face的
        /// </summary>
        /// <param name="node"></param>
        public void OnPolymesh(PolymeshTopology node)
        {
            //这里非常重要空间几何信息全都在这里
            int nPts    = node.NumberOfPoints;
            int nFacets = node.NumberOfFacets;

            VertexBuilder <VertexPosition, VertexTexture1, VertexEmpty>[] vertexs = new VertexBuilder <VertexPosition, VertexTexture1, VertexEmpty> [nPts];
            XYZ       p;
            UV        uv;
            Transform t = CurrentTransform;

            for (int i = 0; i < nPts; i++)
            {
                p          = t.OfPoint(node.GetPoint(i));
                uv         = node.GetUV(i);
                vertexs[i] = new VertexBuilder <VertexPosition, VertexTexture1, VertexEmpty>(new VERTEX((float)(p.Y), (float)(p.Z), (float)(p.X)),
                                                                                             new VertexTexture1(new Vector2((float)uv.U, (float)uv.V)));
            }


            var mesh = new MeshBuilder <VertexPosition, VertexTexture1>();
            var prim = mesh.UsePrimitive(_currentMaterial);


            PolymeshFacet f;

            for (int i = 0; i < nFacets; i++)
            {
                f = node.GetFacet(i);
                prim.AddTriangle(vertexs[f.V1], vertexs[f.V2], vertexs[f.V3]);
            }
            _currentMesh.AddMesh(mesh, Matrix4x4.Identity);
        }
Beispiel #2
0
        /// <summary>
        /// 从polymesh中获取三角面片信息
        /// </summary>
        /// <param name="polyMesh"></param>
        /// <returns></returns>
        private List <TriangleData> GetTriangleDataFromPolymesh(PolymeshTopology polyMesh, bool bIsOrignPosition = false)
        {
            List <TriangleData> listTri = new List <TriangleData>();

            XYZ point;

            for (int i = 0; i < polyMesh.NumberOfFacets; i++)
            {
                point = polyMesh.GetPoint(polyMesh.GetFacet(i).V1);
                if (!bIsOrignPosition)
                {
                    point = CurrentTransform.OfPoint(point);
                }
                PointData pt1 = new PointData(point.X, point.Y, point.Z);

                point = polyMesh.GetPoint(polyMesh.GetFacet(i).V2);
                if (!bIsOrignPosition)
                {
                    point = CurrentTransform.OfPoint(point);
                }
                PointData pt2 = new PointData(point.X, point.Y, point.Z);

                point = polyMesh.GetPoint(polyMesh.GetFacet(i).V3);
                if (!bIsOrignPosition)
                {
                    point = CurrentTransform.OfPoint(point);
                }
                PointData pt3 = new PointData(point.X, point.Y, point.Z);

                listTri.Add(new TriangleData(pt1, pt2, pt3));
            }

            return(listTri);
        }
Beispiel #3
0
        public void OnPolymesh(PolymeshTopology node)
        {
            int nPts    = node.NumberOfPoints;
            int nFacets = node.NumberOfFacets;

            Debug.Print($"Polymesh : {nPts} vertices {nFacets} facets");

            IList <XYZ> vertices = node.GetPoints();
            IList <XYZ> normals  = node.GetNormals();

            DistributionOfNormals distrib = node.DistributionOfNormals;

            VERTEX[]  vertexs = new VERTEX[nPts];
            XYZ       p;
            Transform t = CurrentTransform;

            for (int i = 0; i < nPts; i++)
            {
                p = t.OfPoint(node.GetPoint(i));
                //vertexs[i] = new VERTEX((float)(p.Y*_foot_to_m), (float)(p.Z*_foot_to_m), (float)(p.X*_foot_to_m));
                vertexs[i] = new VERTEX((float)(p.Y), (float)(p.Z), (float)(p.X));
            }

            var prim = _mesh.UsePrimitive(_material);

            PolymeshFacet f;

            for (int i = 0; i < nFacets; i++)
            {
                f = node.GetFacet(i);
                prim.AddTriangle(vertexs[f.V1], vertexs[f.V2], vertexs[f.V3]);
            }
        }
        public void OnPolymesh(PolymeshTopology polymesh)
        {
            CurrentPolymeshIndex++;

            WriteXmlGeometryBegin();
            WriteXmlGeometrySourcePositions(polymesh);
            WriteXmlGeometrySourceNormals(polymesh);
            if (polymesh.NumberOfUVs > 0)
            {
                WriteXmlGeometrySourceMap(polymesh);
            }

            WriteXmlGeometryVertices();

            if (polymesh.NumberOfUVs > 0)
            {
                WriteXmlGeometryTrianglesWithMap(polymesh);
            }
            else
            {
                WriteXmlGeometryTrianglesWithoutMap(polymesh);
            }

            WriteXmlGeometryEnd();

            polymeshToMaterialId.Add(CurrentPolymeshIndex, currentMaterialId);
        }
        private void WriteXmlGeometrySourcePositions(PolymeshTopology polymesh)
        {
            streamWriter.Write("<source id=\"geom-" + CurrentPolymeshIndex + "-positions" + "\">\n");
            streamWriter.Write("<float_array id=\"geom-" + CurrentPolymeshIndex + "-positions" + "-array" + "\" count=\"" + (polymesh.NumberOfPoints * 3) + "\">\n");

            XYZ       point;
            Transform currentTransform = transformationStack.Peek();

            for (int iPoint = 0; iPoint < polymesh.NumberOfPoints; ++iPoint)
            {
                point = polymesh.GetPoint(iPoint);
                point = currentTransform.OfPoint(point);
                streamWriter.Write("{0:0.0000} {1:0.0000} {2:0.0000}\n", point.X, point.Y, point.Z);
            }

            streamWriter.Write("</float_array>\n");
            streamWriter.Write("<technique_common>\n");
            streamWriter.Write("<accessor source=\"#geom-" + CurrentPolymeshIndex + "-positions" + "-array\"" + " count=\"" + polymesh.NumberOfPoints + "\" stride=\"3\">\n");
            streamWriter.Write("<param name=\"X\" type=\"float\"/>\n");
            streamWriter.Write("<param name=\"Y\" type=\"float\"/>\n");
            streamWriter.Write("<param name=\"Z\" type=\"float\"/>\n");
            streamWriter.Write("</accessor>\n");
            streamWriter.Write("</technique_common>\n");
            streamWriter.Write("</source>\n");
        }
        /// <summary>
        ///     This method is called when a tessellated polymesh of a 3d face is being output.
        /// </summary>
        /// <param name="node">The polymesh node.</param>
        public void OnPolymesh(PolymeshTopology node)
        {
            try
            {
                var points = node
                             .GetPoints()
                             .Select(p => transformations.Peek().OfPoint(p))
                             .ToArray();

                foreach (var facet in node.GetFacets())
                {
                    current.GeometryPerMaterial.AddFace(new[]
                    {
                        0,
                        current.VerticesPerMaterial.AddVertex(points[facet.V1].ToVector3()),
                        current.VerticesPerMaterial.AddVertex(points[facet.V2].ToVector3()),
                        current.VerticesPerMaterial.AddVertex(points[facet.V3].ToVector3()),
                    });
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
Beispiel #7
0
        public void OnPolymesh(PolymeshTopology node)
        {
            num++;
            MessageBuffer mb = new MessageBuffer();

            mb.add(node.NumberOfPoints);
            mb.add(node.NumberOfFacets);
            mb.add(node.NumberOfNormals);
            mb.add(node.NumberOfUVs);


            foreach (Autodesk.Revit.DB.XYZ point in node.GetPoints())
            {
                mb.add(point);
            }
            foreach (Autodesk.Revit.DB.XYZ normal in node.GetNormals())
            {
                mb.add(normal);
            }
            foreach (Autodesk.Revit.DB.UV uv in node.GetUVs())
            {
                mb.add((float)uv.U);
                mb.add((float)uv.V);
            }
            foreach (Autodesk.Revit.DB.PolymeshFacet facet in node.GetFacets())
            {
                mb.add(facet.V1);
                mb.add(facet.V2);
                mb.add(facet.V3);
            }

            OpenCOVERPlugin.COVER.Instance.sendMessage(mb.buf, OpenCOVERPlugin.COVER.MessageTypes.NewPolyMesh);
            return;
        }
Beispiel #8
0
        public void OnPolymesh(PolymeshTopology polymesh)
        {
            IList <XYZ> pts = polymesh.GetPoints();
            Transform   t   = CurrentTransform;

            pts = pts.Select(p => t.OfPoint(p)).ToList();

            var normals = polymesh.GetNormals();
            var uvs     = polymesh.GetUVs();

            int v1, v2, v3;
            int v4, v5, v6;
            int v7, v8, v9;
            int faceindex = 0;

            foreach (PolymeshFacet facet in polymesh.GetFacets())
            {
                v1 = _vertices.AddVertex(new PointInt(pts[facet.V1], _switch_coordinates));
                v2 = _vertices.AddVertex(new PointInt(pts[facet.V2], _switch_coordinates));
                v3 = _vertices.AddVertex(new PointInt(pts[facet.V3], _switch_coordinates));

                face.Add(v1);
                face.Add(v2);
                face.Add(v3);

                v4 = _uvs.AddVertex(new PointDouble(uvs[facet.V1]));
                v5 = _uvs.AddVertex(new PointDouble(uvs[facet.V2]));
                v6 = _uvs.AddVertex(new PointDouble(uvs[facet.V3]));
                face.Add(v4);
                face.Add(v5);
                face.Add(v6);

                if (polymesh.DistributionOfNormals == DistributionOfNormals.AtEachPoint)
                {
                    v7 = _normals.AddVertex(new PointDouble(normals[facet.V1], _switch_coordinates));
                    v8 = _normals.AddVertex(new PointDouble(normals[facet.V2], _switch_coordinates));
                    v9 = _normals.AddVertex(new PointDouble(normals[facet.V3], _switch_coordinates));
                }
                else if (polymesh.DistributionOfNormals == DistributionOfNormals.OnEachFacet)
                {
                    v7 = _normals.AddVertex(new PointDouble(normals[faceindex], _switch_coordinates));
                    v8 = v7;
                    v9 = v7;
                }
                else
                {
                    v7 = _normals.AddVertex(new PointDouble(normals[0], _switch_coordinates));
                    v8 = v7;
                    v9 = v7;
                }
                face.Add(v7);
                face.Add(v8);
                face.Add(v9);

                faceindex++;
            }
        }
Beispiel #9
0
        /// <summary>
        /// 从polymesh中获取顶点列表
        /// </summary>
        /// <param name="polymesh"></param>
        /// <returns></returns>
        private List <PointData> GetVertexesFromPolymesh(PolymeshTopology polymesh)
        {
            List <PointData> listPoint = new List <PointData>();

            for (int i = 0; i < polymesh.NumberOfPoints; i++)
            {
                listPoint.Add(new PointData(polymesh.GetPoint(i).X, polymesh.GetPoint(i).Y, polymesh.GetPoint(i).Z));
            }

            return(listPoint);
        }
Beispiel #10
0
        /// <summary>
        /// 从polymesh中获取三角形顶点索引数据
        /// </summary>
        /// <param name="polymesh"></param>
        /// <returns></returns>
        private List <TriangleIndexData> GetTriangleIndexFromPolymesh(PolymeshTopology polymesh)
        {
            List <TriangleIndexData> listIndex = new List <TriangleIndexData>();

            for (int i = 0; i < polymesh.NumberOfFacets; i++)
            {
                listIndex.Add(new TriangleIndexData(polymesh.GetFacet(i).V1, polymesh.GetFacet(i).V2, polymesh.GetFacet(i).V3));
            }

            return(listIndex);
        }
Beispiel #11
0
        public void OnPolymesh(PolymeshTopology polymesh)
        {
            IList <XYZ> pts = polymesh.GetPoints();
            Transform   t   = CurrentTransform;

            pts = pts.Select(p => t.OfPoint(p)).ToList();

            var normals = polymesh.GetNormals();
            var uvs     = polymesh.GetUVs();

            GetFaceIndex(polymesh, pts, normals, uvs);
        }
Beispiel #12
0
        /// <summary>
        /// Runs for every polymesh being processed. Typically this is a single face
        /// of an element's mesh. Here we populate the data into our "_current" variables
        /// (geometry and vertices) keyed on the element/material combination (this is important
        /// because within a single element, materials can be changed and repeated in unknown order).
        /// </summary>
        /// <param name="polymesh"></param>
        public void OnPolymesh(PolymeshTopology polymesh)
        {
            string vertex_key = Nodes.CurrentKey + "_" + Materials.CurrentKey;

            Debug.WriteLine("    OnPolymesh: " + vertex_key);

            // Add new "_current" entries if vertex_key is unique
            _currentGeometry.AddOrUpdateCurrent(vertex_key, new GeometryData());
            _currentVertices.AddOrUpdateCurrent(vertex_key, new VertexLookupInt());

            // Populate current geometry normals data
            //if (polymesh.DistributionOfNormals == DistributionOfNormals.AtEachPoint)
            //{
            //    IList<XYZ> norms = polymesh.GetNormals();
            //    foreach (XYZ norm in norms)
            //    {
            //        _currentGeometry.CurrentItem.normals.Add(norm.X);
            //        _currentGeometry.CurrentItem.normals.Add(norm.Y);
            //        _currentGeometry.CurrentItem.normals.Add(norm.Z);
            //    }
            //}

            // populate current vertices vertex data and current geometry faces data
            Transform   t   = CurrentTransform;
            IList <XYZ> pts = polymesh.GetPoints();

            pts = pts.Select(p => t.OfPoint(p)).ToList();
            IList <PolymeshFacet> facets = polymesh.GetFacets();

            foreach (PolymeshFacet facet in facets)
            {
                int v1 = _currentVertices.CurrentItem.AddVertex(new PointInt(pts[facet.V1], _flipCoords));
                int v2 = _currentVertices.CurrentItem.AddVertex(new PointInt(pts[facet.V2], _flipCoords));
                int v3 = _currentVertices.CurrentItem.AddVertex(new PointInt(pts[facet.V3], _flipCoords));

                _currentGeometry.CurrentItem.faces.Add(v1);
                _currentGeometry.CurrentItem.faces.Add(v2);
                _currentGeometry.CurrentItem.faces.Add(v3);

                //if (polymesh.DistributionOfNormals == DistributionOfNormals.OnePerFace)
                //{
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).X);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).Y);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).Z);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).X);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).Y);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).Z);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).X);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).Y);
                //    _currentGeometry.CurrentItem.normals.Add(polymesh.GetNormal(0).Z);
                //}
            }
        }
Beispiel #13
0
        /// <summary>
        /// 获取几何信息中每个三角面对应点的顶点坐标/法向坐标/UV坐标的索引
        /// 并存入face列表中
        /// </summary>
        /// <param name="polymesh"></param>
        /// <param name="pts"></param>
        /// <param name="normals"></param>
        /// <param name="uvs"></param>
        private void GetFaceIndex(PolymeshTopology polymesh, IList <XYZ> pts, IList <XYZ> normals, IList <UV> uvs)
        {
            int v1, v2, v3;
            int v4, v5, v6;
            int v7, v8, v9;
            int faceindex = 0;

            foreach (PolymeshFacet facet in polymesh.GetFacets())
            {
                v1 = _vertices.AddVertex(new PointInt(pts[facet.V1], _switch_coordinates));
                v2 = _vertices.AddVertex(new PointInt(pts[facet.V2], _switch_coordinates));
                v3 = _vertices.AddVertex(new PointInt(pts[facet.V3], _switch_coordinates));

                face.Add(v1);
                face.Add(v2);
                face.Add(v3);

                v4 = _uvs.AddVertex(new PointDouble(uvs[facet.V1]));
                v5 = _uvs.AddVertex(new PointDouble(uvs[facet.V2]));
                v6 = _uvs.AddVertex(new PointDouble(uvs[facet.V3]));
                face.Add(v4);
                face.Add(v5);
                face.Add(v6);

                if (polymesh.DistributionOfNormals == DistributionOfNormals.AtEachPoint)
                {
                    v7 = _normals.AddVertex(new PointDouble(normals[facet.V1], _switch_coordinates));
                    v8 = _normals.AddVertex(new PointDouble(normals[facet.V2], _switch_coordinates));
                    v9 = _normals.AddVertex(new PointDouble(normals[facet.V3], _switch_coordinates));
                }
                else if (polymesh.DistributionOfNormals == DistributionOfNormals.OnEachFacet)
                {
                    v7 = _normals.AddVertex(new PointDouble(normals[faceindex], _switch_coordinates));
                    v8 = v7;
                    v9 = v7;
                }
                else
                {
                    v7 = _normals.AddVertex(new PointDouble(normals[0], _switch_coordinates));
                    v8 = v7;
                    v9 = v7;
                }
                face.Add(v7);
                face.Add(v8);
                face.Add(v9);

                faceindex++;
            }
        }
Beispiel #14
0
        public void OnPolymesh(PolymeshTopology polymesh)
        {
            //Debug.WriteLine( string.Format(
            //  "    OnPolymesh: {0} points, {1} facets, {2} normals {3}",
            //  polymesh.NumberOfPoints,
            //  polymesh.NumberOfFacets,
            //  polymesh.NumberOfNormals,
            //  polymesh.DistributionOfNormals ) );

            IList <XYZ> pts = polymesh.GetPoints();

            Transform t = CurrentTransform;



            pts = pts.Select(p => t.OfPoint(p)).ToList();

            if (isOld)
            {
            }
            else if (isNew)
            {
                _insDict[oldInd1][oldInd2] = pts;

                int v1, v2, v3;

                foreach (PolymeshFacet facet
                         in polymesh.GetFacets())
                {
                    //Debug.WriteLine( string.Format(
                    //  "      {0}: {1} {2} {3}", i++,
                    //  facet.V1, facet.V2, facet.V3 ) );

                    v1 = CurrentVerticesPerMaterial.AddVertex(new PointInt(
                                                                  pts[facet.V1], _switch_coordinates));

                    v2 = CurrentVerticesPerMaterial.AddVertex(new PointInt(
                                                                  pts[facet.V2], _switch_coordinates));

                    v3 = CurrentVerticesPerMaterial.AddVertex(new PointInt(
                                                                  pts[facet.V3], _switch_coordinates));

                    CurrentGeometryPerMaterial.data.faces.Add(0);
                    CurrentGeometryPerMaterial.data.faces.Add(v1);
                    CurrentGeometryPerMaterial.data.faces.Add(v2);
                    CurrentGeometryPerMaterial.data.faces.Add(v3);
                }
            }
        }
Beispiel #15
0
        public void OnPolymesh(PolymeshTopology node)
        {
            int nPts    = node.NumberOfPoints;
            int nFacets = node.NumberOfFacets;

            DistributionOfNormals distrib
                = node.DistributionOfNormals;

            Debug.Print(string.Format(
                            "Polymesh {0} vertices {1} facets",
                            nPts, nFacets));

            int iFacet = 0;
            int iPoint = 0;

            IList <XYZ> vertices = node.GetPoints();
            IList <XYZ> normals  = node.GetNormals();
            XYZ         normal;

            foreach (PolymeshFacet triangle in node.GetFacets())
            {
                // Just grab one normal per facet; ignore the
                // three normals per point if they differ.

                if (DistributionOfNormals.OnePerFace == distrib)
                {
                    normal = node.GetNormal(0);
                }
                else if (DistributionOfNormals.OnEachFacet
                         == distrib)
                {
                    normal = node.GetNormal(iFacet++);
                }
                else
                {
                    Debug.Assert(DistributionOfNormals
                                 .AtEachPoint == distrib, "what else?");

                    normal = node.GetNormal(triangle.V1)
                             + node.GetNormal(triangle.V2)
                             + node.GetNormal(triangle.V3);
                    normal /= 3.0;
                }

                StoreTriangle(vertices, triangle, normal);
            }
        }
Beispiel #16
0
        public void OnPolymesh(PolymeshTopology inMesh)
        {
            switch (inMesh.DistributionOfNormals)
            {
            case DistributionOfNormals.AtEachPoint:
                break;

            case DistributionOfNormals.OnEachFacet:
                break;

            case DistributionOfNormals.OnePerFace:
                break;

            default:
                break;
            }
            m_Exporter.AddGeometry(inMesh.GetPoints(), inMesh.GetFacets(), inMesh.GetNormals(), m_stackTransform.Peek());
        }
        private void WriteXmlGeometryTrianglesWithMap(PolymeshTopology polymesh)
        {
            streamWriter.Write("<triangles count=\"" + polymesh.NumberOfFacets + "\"");
            if (IsMaterialValid(currentMaterialId))
            {
                streamWriter.Write(" material=\"material-" + currentMaterialId.ToString() + "\"");
            }
            streamWriter.Write(">\n");
            streamWriter.Write("<input offset=\"0\" semantic=\"VERTEX\" source=\"#geom-" + CurrentPolymeshIndex + "-vertices" + "\"/>\n");
            streamWriter.Write("<input offset=\"1\" semantic=\"NORMAL\" source=\"#geom-" + CurrentPolymeshIndex + "-normals" + "\"/>\n");
            streamWriter.Write("<input offset=\"2\" semantic=\"TEXCOORD\" source=\"#geom-" + CurrentPolymeshIndex + "-map" + "\" set=\"0\"/>\n");
            streamWriter.Write("<p>\n");
            PolymeshFacet facet;

            switch (polymesh.DistributionOfNormals)
            {
            case DistributionOfNormals.AtEachPoint:
                for (int i = 0; i < polymesh.NumberOfFacets; ++i)
                {
                    facet = polymesh.GetFacet(i);
                    streamWriter.Write(facet.V1 + " " + facet.V1 + " " + facet.V1 + " " +
                                       facet.V2 + " " + facet.V2 + " " + facet.V2 + " " +
                                       facet.V3 + " " + facet.V3 + " " + facet.V3 + " " +
                                       "\n");
                }
                break;

            case DistributionOfNormals.OnEachFacet:
            //TODO : DistributionOfNormals.OnEachFacet
            case DistributionOfNormals.OnePerFace:
                for (int i = 0; i < polymesh.NumberOfFacets; ++i)
                {
                    facet = polymesh.GetFacet(i);
                    streamWriter.Write(facet.V1 + " 0 " + facet.V1 + " " +
                                       facet.V2 + " 0 " + facet.V2 + " " +
                                       facet.V3 + " 0 " + facet.V3 + " " +
                                       "\n");
                }
                break;
            }

            streamWriter.Write("</p>\n");
            streamWriter.Write("</triangles>\n");
        }
        private void WriteXmlGeometrySourceNormals(PolymeshTopology polymesh)
        {
            int nNormals = 0;

            switch (polymesh.DistributionOfNormals)
            {
            case DistributionOfNormals.AtEachPoint:
                nNormals = polymesh.NumberOfPoints;
                break;

            case DistributionOfNormals.OnePerFace:
                nNormals = 1;
                break;

            case DistributionOfNormals.OnEachFacet:
                //TODO : DistributionOfNormals.OnEachFacet
                nNormals = 1;
                break;
            }

            streamWriter.Write("<source id=\"geom-" + CurrentPolymeshIndex + "-normals" + "\">\n");
            streamWriter.Write("<float_array id=\"geom-" + CurrentPolymeshIndex + "-normals" + "-array" + "\" count=\"" + (nNormals * 3) + "\">\n");

            XYZ       point;
            Transform currentTransform = transformationStack.Peek();

            for (int iNormal = 0; iNormal < nNormals; ++iNormal)
            {
                point = polymesh.GetNormal(iNormal);
                point = currentTransform.OfVector(point);
                streamWriter.Write("{0:0.0000} {1:0.0000} {2:0.0000}\n", point.X, point.Y, point.Z);
            }

            streamWriter.Write("</float_array>\n");
            streamWriter.Write("<technique_common>\n");
            streamWriter.Write("<accessor source=\"#geom-" + CurrentPolymeshIndex + "-normals" + "-array\"" + " count=\"" + nNormals + "\" stride=\"3\">\n");
            streamWriter.Write("<param name=\"X\" type=\"float\"/>\n");
            streamWriter.Write("<param name=\"Y\" type=\"float\"/>\n");
            streamWriter.Write("<param name=\"Z\" type=\"float\"/>\n");
            streamWriter.Write("</accessor>\n");
            streamWriter.Write("</technique_common>\n");
            streamWriter.Write("</source>\n");
        }
Beispiel #19
0
        private MeshData GetMeshDataFromPolymesh(PolymeshTopology polymesh)
        {
            var mesh = new MeshData
            {
                TriangleIndexes = new List <TriangleIndexData>(),
                Vertexes        = new List <PointData>(),
                Normals         = new List <PointData>(),
                TextureUVs      = new List <TextureUV>()
            };

            for (int i = 0; i < polymesh.NumberOfFacets; i++)
            {
                var facet = polymesh.GetFacet(i);
                mesh.TriangleIndexes.Add(new TriangleIndexData(facet.V1, facet.V2, facet.V3));
            }

            var oneNormalPerpoint = polymesh.DistributionOfNormals == DistributionOfNormals.AtEachPoint;

            for (int i = 0; i < polymesh.NumberOfPoints; i++)
            {
                mesh.Vertexes.Add(new PointData(polymesh.GetPoint(i).X, polymesh.GetPoint(i).Y, polymesh.GetPoint(i).Z));
                if (oneNormalPerpoint)
                {
                    var normal = polymesh.GetNormal(i);
                    //mesh.Normals.Add(new PointData(normal.X, normal.Y, normal.Z));
                }
            }

            if (polymesh.DistributionOfNormals == DistributionOfNormals.OnePerFace)
            {
                var normal = polymesh.GetNormal(0);
                //mesh.Normals.Add(new PointData(normal.X, normal.Y, normal.Z));
            }

            for (int i = 0; i < polymesh.NumberOfUVs; i++)
            {
                var tmpuv = polymesh.GetUV(i);
                mesh.TextureUVs.Add(new TextureUV(tmpuv.U, tmpuv.V));
            }

            return(mesh);
        }
        private void WriteXmlGeometrySourceMap(PolymeshTopology polymesh)
        {
            streamWriter.Write("<source id=\"geom-" + CurrentPolymeshIndex + "-map" + "\">\n");
            streamWriter.Write("<float_array id=\"geom-" + CurrentPolymeshIndex + "-map" + "-array" + "\" count=\"" + (polymesh.NumberOfUVs * 2) + "\">\n");

            UV uv;

            for (int iUv = 0; iUv < polymesh.NumberOfUVs; ++iUv)
            {
                uv = polymesh.GetUV(iUv);
                streamWriter.Write("{0:0.0000} {1:0.0000}\n", uv.U, uv.V);
            }

            streamWriter.Write("</float_array>\n");
            streamWriter.Write("<technique_common>\n");
            streamWriter.Write("<accessor source=\"#geom-" + CurrentPolymeshIndex + "-map" + "-array\"" + " count=\"" + polymesh.NumberOfPoints + "\" stride=\"2\">\n");
            streamWriter.Write("<param name=\"S\" type=\"float\"/>\n");
            streamWriter.Write("<param name=\"T\" type=\"float\"/>\n");
            streamWriter.Write("</accessor>\n");
            streamWriter.Write("</technique_common>\n");
            streamWriter.Write("</source>\n");
        }
Beispiel #21
0
        /// <summary>
        /// 当输出3d面的镶嵌多边形时,将调用此方法。
        /// </summary>
        /// <param name="polymesh">表示多边形网格拓扑的节点</param>
        void IExportContext.OnPolymesh(PolymeshTopology polymesh)
        {
            ModelGeometry exportedGeometry = new ModelGeometry
            {
                Points                = polymesh.GetPoints(),
                Normals               = polymesh.GetNormals(),
                Uvs                   = polymesh.GetUVs(),
                Transform             = transformationStack.Peek(),
                DistributionOfNormals = polymesh.DistributionOfNormals,
                Indices               = new List <int>(polymesh.GetFacets().Count * 3)
            };

            if (exportedGeometry.Transform.IsConformal && exportedGeometry.Transform.HasReflection)
            {
                using (IEnumerator <PolymeshFacet> enumerator = polymesh.GetFacets().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        PolymeshFacet current = enumerator.Current;
                        exportedGeometry.Indices.Add(current.V1);
                        exportedGeometry.Indices.Add(current.V3);
                        exportedGeometry.Indices.Add(current.V2);
                    }
                    goto Fine;
                }
            }
            foreach (PolymeshFacet current2 in polymesh.GetFacets())
            {
                exportedGeometry.Indices.Add(current2.V1);
                exportedGeometry.Indices.Add(current2.V2);
                exportedGeometry.Indices.Add(current2.V3);
            }
Fine:
            if (isElementDoubleSided)
            {
                exportedGeometry.MakeDoubleSided();
            }
            documentAndMaterialIdToGeometries[currentDocumentAndMaterialId].Add(exportedGeometry);
        }
Beispiel #22
0
        public void OnPolymesh(PolymeshTopology node)
        {
            XMesh m = new XMesh();

            m.Name = "Mesh" + XData.Objects.Last().Meshs.Count;
            Transform t = Transforms.Peek();

            for (int i = 0; i < node.NumberOfFacets; i++)
            {
                PolymeshFacet f = node.GetFacet(i);
                m.Triangles.Add(f.V1);
                m.Triangles.Add(f.V2);
                m.Triangles.Add(f.V3);
            }
            for (int i = 0; i < node.NumberOfPoints; i++)
            {
                XYZ p = t.OfPoint(node.GetPoint(i));
                m.Vertexs.Add(new XVec3(p.X, p.Y, p.Z));
            }
            for (int i = 0; i < node.NumberOfNormals; i++)
            {
                XYZ n = t.OfVector(node.GetNormal(i));
                m.Normals.Add(new XVec3(n.X, n.Y, n.Z));
            }
            for (int i = 0; i < node.NumberOfUVs; i++)
            {
                UV u = node.GetUV(i);
                m.UVs.Add(new XVec2(u.U, u.V));
            }
            m.MaterialID = matLink[matid];
            XData.Objects.Last().Meshs.Add(m);
            string log = null;

            if (EnableLog)
            {
                log = "Mesh\n,Name:" + m.Name + "\nVertex:" + m.Vertexs.Count;
            }
            meshLog.Add(log);
        }
Beispiel #23
0
        public void OnGeometry(PolymeshTopology polymesh)
        {
            if (currentNodeId == null)
            {
                throw new Exception();
            }

            string vertex_key = currentNodeId + "_" + materialDict.CurrentKey;

            if (currentGeom.ContainsKey(vertex_key) == false)
            {
                currentGeom.Add(vertex_key, new GeometryData());
            }

            // Populate normals from this polymesh
            IList <XYZ> norms = polymesh.GetNormals();

            foreach (XYZ norm in norms)
            {
                currentGeom[vertex_key].normals.Add(norm.X);
                currentGeom[vertex_key].normals.Add(norm.Y);
                currentGeom[vertex_key].normals.Add(norm.Z);
            }

            // Populate vertex and faces data
            IList <XYZ> pts = polymesh.GetPoints();

            foreach (PolymeshFacet facet in polymesh.GetFacets())
            {
                int v1 = currentGeom[vertex_key].vertDictionary.AddVertex(new PointInt(pts[facet.V1], _flipCoords));
                int v2 = currentGeom[vertex_key].vertDictionary.AddVertex(new PointInt(pts[facet.V2], _flipCoords));
                int v3 = currentGeom[vertex_key].vertDictionary.AddVertex(new PointInt(pts[facet.V3], _flipCoords));

                currentGeom[vertex_key].faces.Add(v1);
                currentGeom[vertex_key].faces.Add(v2);
                currentGeom[vertex_key].faces.Add(v3);
            }
        }
        /// <summary>
        /// 输出Polymesh多边形网格,同时它也是属于face的
        /// </summary>
        /// <param name="node"></param>
        public void OnPolymesh(PolymeshTopology node)
        {
            //把当前ElementId作为对象名写入文件
            swObj.Write("o " + currentId.IntegerValue.ToString() + "\n");
            swObj.Write("usemtl " + currentMaterialId.IntegerValue.ToString() + "\n");

            //取得顶点坐标并进行位置转换
            Transform   currentTransform = m_TransformationStack.Peek();
            IList <XYZ> points           = node.GetPoints();

            points = points.Select(p => currentTransform.OfPoint(p)).ToList();

            //把顶点数据写入文件
            foreach (XYZ point in points)
            {
                swObj.Write("v " + point.X.ToString() + " " + point.Y.ToString() + " " + point.Z.ToString() + "\n");
            }

            //取得UV坐标
            IList <UV> uvs = node.GetUVs();

            //把UV数据写入文件
            foreach (UV uv in uvs)
            {
                swObj.Write("vt " + uv.U.ToString() + " " + uv.V.ToString() + " 0.0000\n");
            }
            //取得面
            IList <PolymeshFacet> facets = node.GetFacets();

            //把面数据写入文件
            foreach (PolymeshFacet facet in facets)
            {
                swObj.Write("f " + (facet.V1 + 1 + index).ToString() + "/" + (facet.V1 + 1 + index).ToString() + " " + (facet.V2 + 1 + index).ToString() + "/" + (facet.V2 + 1 + index).ToString() + " " + (facet.V3 + 1 + index).ToString() + "/" + (facet.V3 + 1 + index).ToString() + "\n");
            }
            index += node.NumberOfPoints;
        }
        public void OnPolymesh(PolymeshTopology inMesh)
        {
            switch (inMesh.DistributionOfNormals)
            {
                case DistributionOfNormals.AtEachPoint:
                    break;

                case DistributionOfNormals.OnEachFacet:
                    break;

                case DistributionOfNormals.OnePerFace:
                    break;

                default:
                    break;
            }
            m_Exporter.AddGeometry(inMesh.GetPoints(), inMesh.GetFacets(), inMesh.GetNormals(), m_stackTransform.Peek());
        }
Beispiel #26
0
 public void OnPolymesh(PolymeshTopology node)
 {
     throw new NotImplementedException();
 }
Beispiel #27
0
        public void OnPolymesh(PolymeshTopology node)
        {
            num++;
            MessageBuffer mb = new MessageBuffer();
            mb.add(node.NumberOfPoints);
            mb.add(node.NumberOfFacets);
            mb.add(node.NumberOfNormals);
            mb.add(node.NumberOfUVs);

            foreach (Autodesk.Revit.DB.XYZ point in node.GetPoints())
            {
                mb.add(point);
            }
            foreach (Autodesk.Revit.DB.XYZ normal in node.GetNormals())
            {
                mb.add(normal);
            }
            foreach (Autodesk.Revit.DB.UV uv in node.GetUVs())
            {
                mb.add((float)uv.U);
                mb.add((float)uv.V);
            }
            foreach (Autodesk.Revit.DB.PolymeshFacet facet in node.GetFacets())
            {
                mb.add(facet.V1);
                mb.add(facet.V2);
                mb.add(facet.V3);
            }

            OpenCOVERPlugin.COVER.Instance.sendMessage(mb.buf, OpenCOVERPlugin.COVER.MessageTypes.NewPolyMesh);
            return;
        }
 public void OnPolymesh(PolymeshTopology node)
 {
 }
Beispiel #29
0
        public void OnPolymesh(PolymeshTopology node)
        {
            var pts = node.GetPoints();
            var t   = tfStack.Peek();

            pts = pts.Select(p => t.OfPoint(p)).ToList();

            List <XYZ> xyzlist;
            List <int> indexlist;

            if (currentobject != null)
            {
                var elem_per_material_uid = $"{currentobject.uuid}-{currentmaterialuid}";
                if (XYZs.ContainsKey(elem_per_material_uid))
                {
                    xyzlist   = XYZs[elem_per_material_uid];
                    indexlist = Indexs[elem_per_material_uid];
                }
                else
                {
                    xyzlist = new List <XYZ>();
                    XYZs.Add(elem_per_material_uid, xyzlist);
                    indexlist = new List <int>();
                    Indexs.Add(elem_per_material_uid, indexlist);
                }
                foreach (PolymeshFacet facet in node.GetFacets())
                {
                    var v1          = facet.V1;
                    var pv1         = pts[v1];
                    var matcheditem = xyzlist.FirstOrDefault(x => x.IsAlmostEqualTo(pv1));
                    if (matcheditem != null)
                    {
                        indexlist.Add(xyzlist.IndexOf(matcheditem));
                    }
                    else
                    {
                        xyzlist.Add(pv1);
                        indexlist.Add(xyzlist.Count - 1);
                    }


                    var v2  = facet.V2;
                    var pv2 = pts[v2];
                    matcheditem = xyzlist.FirstOrDefault(x => x.IsAlmostEqualTo(pv2));
                    if (matcheditem != null)
                    {
                        indexlist.Add(xyzlist.IndexOf(matcheditem));
                    }
                    else
                    {
                        xyzlist.Add(pv2);
                        indexlist.Add(xyzlist.Count - 1);
                    }


                    var v3  = facet.V3;
                    var pv3 = pts[v3];
                    matcheditem = xyzlist.FirstOrDefault(x => x.IsAlmostEqualTo(pv3));
                    if (matcheditem != null)
                    {
                        indexlist.Add(xyzlist.IndexOf(matcheditem));
                    }
                    else
                    {
                        xyzlist.Add(pv3);
                        indexlist.Add(xyzlist.Count - 1);
                    }
                }
                XYZs[elem_per_material_uid]   = xyzlist;
                Indexs[elem_per_material_uid] = indexlist;
            }
        }
Beispiel #30
0
        public void OnPolymesh(PolymeshTopology node)
        {
            Transform transform       = this.m_TransformationStack.Peek();
            int       numberOfFacets  = node.NumberOfFacets;
            int       numberOfPoints  = node.NumberOfPoints;
            int       numberOfUVs     = node.NumberOfUVs;
            int       numberOfNormals = node.NumberOfNormals;

            this.TotalNBofPoints += numberOfPoints;
            this.TotalNBofFacets += numberOfFacets;
            int  num = this.m_AllViews.VerticeNb / 4;
            bool exportProperties = this.m_AllViews.ExportProperties;

            if (exportProperties)
            {
                bool flag = !this.ListElementID01.Contains(this.CurrentElementId.IntegerValue.ToString());
                if (flag)
                {
                    this.ListElementID01.Add(this.CurrentElementId.IntegerValue.ToString());
                }
            }
            bool findPatterns = this.m_AllViews.FindPatterns;

            if (findPatterns)
            {
                List <int> list  = new List <int>();
                bool       flag2 = !list.Contains(this.MaterialFaceID);
                if (flag2)
                {
                    list.Add(this.MaterialFaceID);
                }
                bool flag3 = this.key_ElementIDListMatID == null;
                if (flag3)
                {
                    bool flag4 = !this.h_ElementIDListMatID.ContainsKey(this.CurrentElementId.IntegerValue);
                    if (flag4)
                    {
                        this.h_ElementIDListMatID.Add(this.CurrentElementId.IntegerValue, list);
                        this.key_ElementIDListMatID = this.h_ElementIDListMatID.Keys;
                    }
                }
                bool flag5 = false;
                bool flag6 = this.key_ElementIDListMatID != null;
                if (flag6)
                {
                    bool flag7 = this.key_ElementIDListMatID.Count > 0;
                    if (flag7)
                    {
                        foreach (object obj in this.key_ElementIDListMatID)
                        {
                            int  num2  = (int)obj;
                            bool flag8 = num2 == this.CurrentElementId.IntegerValue;
                            if (flag8)
                            {
                                flag5 = true;
                            }
                        }
                        bool flag9 = flag5;
                        if (flag9)
                        {
                            foreach (object obj2 in this.key_ElementIDListMatID)
                            {
                                int  num3   = (int)obj2;
                                bool flag10 = num3 == this.CurrentElementId.IntegerValue;
                                if (flag10)
                                {
                                    List <int> list2  = (List <int>) this.h_ElementIDListMatID[num3];
                                    bool       flag11 = !list2.Contains(this.MaterialFaceID);
                                    if (flag11)
                                    {
                                        list2.Add(this.MaterialFaceID);
                                    }
                                    this.h_ElementIDListMatID[num3] = list2;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            bool flag12 = !flag5;
                            if (flag12)
                            {
                                bool flag13 = !this.h_ElementIDListMatID.ContainsKey(this.CurrentElementId.IntegerValue);
                                if (flag13)
                                {
                                    this.h_ElementIDListMatID.Add(this.CurrentElementId.IntegerValue, list);
                                    this.key_ElementIDListMatID = this.h_ElementIDListMatID.Keys;
                                }
                            }
                        }
                    }
                }
            }
            bool maxVerticesPerObj = this.m_AllViews.MaxVerticesPerObj;

            if (maxVerticesPerObj)
            {
                bool flag14 = this.TotalNBofPoints <= num * 4;
                if (flag14)
                {
                    bool flag15 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID01.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag15)
                    {
                        this.ListElementID01.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag16 = this.TotalNBofPoints > num * 4 & this.TotalNBofPoints <= num * 8;
                if (flag16)
                {
                    bool flag17 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID02.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag17)
                    {
                        this.ListElementID02.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag18 = this.TotalNBofPoints > num * 8 & this.TotalNBofPoints <= num * 12;
                if (flag18)
                {
                    bool flag19 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID03.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag19)
                    {
                        this.ListElementID03.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag20 = this.TotalNBofPoints > num * 12 & this.TotalNBofPoints <= num * 16;
                if (flag20)
                {
                    bool flag21 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID04.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag21)
                    {
                        this.ListElementID04.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag22 = this.TotalNBofPoints > num * 16 & this.TotalNBofPoints <= num * 20;
                if (flag22)
                {
                    bool flag23 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID05.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag23)
                    {
                        this.ListElementID05.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag24 = this.TotalNBofPoints > num * 20 & this.TotalNBofPoints <= num * 24;
                if (flag24)
                {
                    bool flag25 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID06.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag25)
                    {
                        this.ListElementID06.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag26 = this.TotalNBofPoints > num * 24 & this.TotalNBofPoints <= num * 28;
                if (flag26)
                {
                    bool flag27 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID07.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag27)
                    {
                        this.ListElementID07.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag28 = this.TotalNBofPoints > num * 28 & this.TotalNBofPoints <= num * 32;
                if (flag28)
                {
                    bool flag29 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID08.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag29)
                    {
                        this.ListElementID08.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag30 = this.TotalNBofPoints > num * 32 & this.TotalNBofPoints <= num * 36;
                if (flag30)
                {
                    bool flag31 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID09.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag31)
                    {
                        this.ListElementID09.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
                bool flag32 = this.TotalNBofPoints > num * 36 & this.TotalNBofPoints <= num * 40;
                if (flag32)
                {
                    bool flag33 = !this.ListElementID_ALL.Contains(this.CurrentElementId.IntegerValue.ToString()) & !this.ListElementID10.Contains(this.CurrentElementId.IntegerValue.ToString());
                    if (flag33)
                    {
                        this.ListElementID10.Add(this.CurrentElementId.IntegerValue.ToString());
                        this.ListElementID_ALL.Add(this.CurrentElementId.IntegerValue.ToString());
                    }
                }
            }
        }
Beispiel #31
0
 void IExportContext.OnPolymesh(PolymeshTopology node)
 {
     throw new NotImplementedException();
 }
Beispiel #32
0
        public void OnPolymesh(PolymeshTopology polymesh)
        {
            Debug.WriteLine(string.Format(
                                "    OnPolymesh: {0} points, {1} facets, {2} normals {3}",
                                polymesh.NumberOfPoints,
                                polymesh.NumberOfFacets,
                                polymesh.NumberOfNormals,
                                polymesh.DistributionOfNormals));

            IList <XYZ> pts     = polymesh.GetPoints();
            IList <XYZ> normals = polymesh.GetNormals();

            Transform t = CurrentTransform;

            int nVertices = pts.Count;

            List <int> vertexCoordsMm = new List <int>(
                3 * nVertices);

            foreach (XYZ p in pts)
            {
                // Translate the entire element geometry
                // to the bounding box midpoint and scale
                // to metric millimetres.

                XYZ q = t.OfPoint(p) - _pmid;

                vertexCoordsMm.Add(Util.FootToMm(p.X));
                vertexCoordsMm.Add(Util.FootToMm(p.Y));
                vertexCoordsMm.Add(Util.FootToMm(p.Z));
            }

            int i = 0;

            int[] triangleIndices = new int[3];
            XYZ[] triangleCorners = new XYZ[3];

            foreach (PolymeshFacet facet
                     in polymesh.GetFacets())
            {
                Debug.WriteLine(string.Format(
                                    "      {0}: {1} {2} {3}", i++,
                                    facet.V1, facet.V2, facet.V3));

                IList <int> vertices = facet.GetVertices();

                for (int j = 0; j < 3; ++j)
                {
                    int k = vertices[j];
                    triangleIndices[j] = k;
                    triangleCorners[j] = pts[k];
                }

                // Calculate constant triangle facet normal.

                XYZ v = triangleCorners[1]
                        - triangleCorners[0];
                XYZ w = triangleCorners[2]
                        - triangleCorners[0];
                XYZ triangleNormal = v
                                     .CrossProduct(w)
                                     .Normalize();

                for (int j = 0; j < 3; ++j)
                {
                    int nFaceVertices = _faceVertices.Count;

                    Debug.Assert(nFaceVertices.Equals(_faceNormals.Count),
                                 "expected equal number of face vertex and normal coordinates");

                    _faceIndices.Add(nFaceVertices / 3);

                    int i3 = triangleIndices[j] * 3;

                    // Rotate the X, Y and Z directions,
                    // since the Z direction points upward
                    // in Revit as opposed to sideways or
                    // outwards or forwards in WebGL.

                    _faceVertices.Add(vertexCoordsMm[i3 + 1]);
                    _faceVertices.Add(vertexCoordsMm[i3 + 2]);
                    _faceVertices.Add(vertexCoordsMm[i3]);

                    if (CmdElemGeom.RetainCurvedSurfaceFacets)
                    {
                        _faceNormals.Add(triangleNormal.Y);
                        _faceNormals.Add(triangleNormal.Z);
                        _faceNormals.Add(triangleNormal.X);
                    }
                    else
                    {
                        XYZ normal = normals[triangleIndices[j]];
                        _faceNormals.Add(normal.Y);
                        _faceNormals.Add(normal.Z);
                        _faceNormals.Add(normal.X);
                    }
                }
            }
        }