Пример #1
0
 public void Add(string mesh, short productTypeId, int productLabel, int geometryLabel, XbimMatrix3D?transform, short modelId)
 {
     lock (meshLock)
     {
         var frag = new XbimMeshFragment(PositionCount, TriangleIndexCount, productTypeId, productLabel, geometryLabel, modelId);
         Read(mesh, transform);
         frag.EndPosition      = PositionCount - 1;
         frag.EndTriangleIndex = TriangleIndexCount - 1;
         _meshes.Add(frag);
     }
 }
Пример #2
0
        public IXbimMeshGeometry3D GetMeshGeometry3D(XbimMeshFragment frag)
        {
            var m3D = new XbimMeshGeometry3D();

            for (var i = frag.StartPosition; i <= frag.EndPosition; i++)
            {
                m3D.Positions.Add(Positions[i]);
                m3D.Normals.Add(Normals[i]);
            }
            for (var i = frag.StartTriangleIndex; i <= frag.EndTriangleIndex; i++)
            {
                m3D.TriangleIndices.Add(TriangleIndices[i] - frag.StartPosition);
            }
            return(m3D);
        }
Пример #3
0
        //adds the content of the toAdd to this, it is added as a single mesh fragment, any meshes in toAdd are lost
        public void Add(IXbimMeshGeometry3D toAdd, int entityLabel, Type ifcType, short modelId)
        {
            var startPosition = Positions.Count;
            var fragment      = new XbimMeshFragment(startPosition, TriangleIndexCount, modelId);

            Positions.AddRange(toAdd.Positions);
            Normals.AddRange(toAdd.Normals);
            foreach (var idx in toAdd.TriangleIndices)
            {
                TriangleIndices.Add(idx + startPosition);
            }
            fragment.EndPosition      = PositionCount - 1;
            fragment.EndTriangleIndex = TriangleIndexCount - 1;
            fragment.EntityLabel      = entityLabel;
            fragment.EntityTypeId     = IfcMetaData.IfcTypeId(ifcType);
            _meshes.Add(fragment);
        }
Пример #4
0
        /// <summary>
        /// Builds a triangulated mesh with normals, appends points etc t the end of the existing mesh
        /// </summary>
        /// <typeparam name="TGeomType"></typeparam>
        /// <param name="builder"></param>
        /// <param name="transform"></param>
        /// <param name="modelId"></param>
        /// <returns>The fragment defining the piece of the mesh built with this operation
        /// If there is no data an empty fragment is returned, if the mesh is goinng to excees the size of a an unsigned short
        /// then the data is not added and a fragement with zero number of points is returned and
        /// a start position that is equal to the length of the mesh. The Entity Label is also sent to int.MinValue</returns>
        public XbimMeshFragment BuildWithNormals <TGeomType>(TGeomType builder, XbimMatrix3D transform, short modelId = 0) where TGeomType : IXbimTriangulatesToPositionsNormalsIndices
        {
            _dataStream.Seek(0, SeekOrigin.Begin);
            BinaryReader br = new BinaryReader(_dataStream);

            if (!IsEmpty) // has data
            {
                builder.BeginBuild();
                XbimMeshFragment fragment = new XbimMeshFragment(builder.PositionCount, builder.TriangleIndexCount, modelId);
                if (!BuildWithNormals(builder, br, transform))
                {
                    fragment.EntityLabel = -1; //set the entity label to indicate failure
                }
                fragment.EndPosition      = builder.PositionCount - 1;
                fragment.EndTriangleIndex = builder.TriangleIndexCount - 1;
                builder.EndBuild();
                return(fragment);
            }
            else
            {
                return(default(XbimMeshFragment));
            }
        }
Пример #5
0
 public MeshInfo(XbimMeshFragment mf, XbimMeshLayer <TMesh, TMaterial> xbimMeshLayer)
 {
     _mf            = mf;
     _xbimMeshLayer = xbimMeshLayer;
 }