public XbimFaceTriangulation Transform(XbimQuaternion q)
        {
            var result = new XbimFaceTriangulation(_indices.Count, _normals.Count);

            foreach (var normal in _normals)
            {
                result.AddNormal(normal.Transform(q));
            }
            foreach (var index in _indices)
            {
                result.AddIndex(index);
            }
            return(result);
        }
        public static XbimShapeTriangulation ReadShapeTriangulation(this BinaryReader br)
        {
            var version = br.ReadByte(); //stream format version
			var numVertices = br.ReadInt32();
            var numTriangles = br.ReadInt32();
            var vertices = new List<XbimPoint3D>(numVertices);

            for (var i = 0; i < numVertices; i++)
            {
                vertices.Add(br.ReadPointFloat3D());
            }
            var numFaces = br.ReadInt32();
            var faces = new List<XbimFaceTriangulation>(numFaces);
            for (var i = 0; i < numFaces; i++)
            {
                
                var numTrianglesInFace = br.ReadInt32();
                if (numTrianglesInFace == 0) continue;
                var isPlanar = numTrianglesInFace > 0;
                numTrianglesInFace = Math.Abs(numTrianglesInFace);
                if (isPlanar)
                {
                     var faceTriangulation = new XbimFaceTriangulation(numTrianglesInFace, 1);
                     faceTriangulation.AddNormal(br.ReadPackedNormal());
                     for (var j = 0; j < numTrianglesInFace; j++)
                     {
                         faceTriangulation.AddIndex(br.ReadIndex(numVertices));//a
                         faceTriangulation.AddIndex(br.ReadIndex(numVertices));//b
                         faceTriangulation.AddIndex(br.ReadIndex(numVertices));//c
                     }
                     faces.Add(faceTriangulation);
                }
                else
                {
                    var faceTriangulation = new XbimFaceTriangulation(numTrianglesInFace, numTrianglesInFace*3);
                    for (var j = 0; j < numTrianglesInFace; j++)
                    {
                        faceTriangulation.AddIndex(br.ReadIndex(numVertices));//a
                        faceTriangulation.AddNormal(br.ReadPackedNormal());
                        faceTriangulation.AddIndex(br.ReadIndex(numVertices));//b
                        faceTriangulation.AddNormal(br.ReadPackedNormal());
                        faceTriangulation.AddIndex(br.ReadIndex(numVertices));//c
                        faceTriangulation.AddNormal(br.ReadPackedNormal());
                    }
                    faces.Add(faceTriangulation);
                }
            }
            return new XbimShapeTriangulation(vertices, faces, version);
        }
 public XbimFaceTriangulation Transform(XbimQuaternion q)
 {
     var result = new XbimFaceTriangulation(_indices.Count, _normals.Count);
     foreach (var normal in _normals)
          result.AddNormal(normal.Transform(q));
     foreach (var index in _indices)
         result.AddIndex(index);
     return result;
 }