Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="pixelType"></param>
        /// <param name="label"></param>
        /// <returns></returns>
        public ImageDataContract AddImage(ImageDataContract idc)
        {
            // assert that GUID was not already assigned
            System.Diagnostics.Trace.Assert(idc.ImageId.CompareTo(Guid.Empty) == 0);

            idc.ImageId     = Guid.NewGuid();
            idc.PixelBuffer =
                BufferRepository.CreateBuffer(idc.ImageId, typeof(ushort), idc.Width * idc.Height);

            _cacheImages.TryAdd(idc.ImageId, idc);

            return(idc);
        }
        public ContourDataContract AddPolygon(ContourDataContract pdc)
        {
            System.Diagnostics.Trace.Assert(pdc.Id.CompareTo(Guid.Empty) == 0);
            pdc.Id = Guid.NewGuid();
            _cachePolygons.Add(pdc.Id, pdc);

            // assert that GUID was not already assigned
            pdc.VertexBuffer =
                BufferRepository.CreateBuffer(pdc.Id, typeof(System.Windows.Media.Media3D.Vector3D),
                                              pdc.VertexCount);

            return(pdc);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ivdc"></param>
        /// <returns></returns>
        public UniformImageVolumeDataContract AddImageVolume(UniformImageVolumeDataContract ivdc)
        {
            // assert that GUID was not already assigned
            System.Diagnostics.Trace.Assert(ivdc.Identity.Guid.CompareTo(Guid.Empty) == 0);

            ivdc.Identity.Guid = Guid.NewGuid();
            ivdc.PixelBuffer   =
                BufferRepository.CreateBuffer(ivdc.Identity.Guid, typeof(ushort),
                                              ivdc.Width * ivdc.Height * ivdc.Depth);

            try
            {
                _cacheImageVolumes.Add(ivdc.Identity.Guid, ivdc);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(ivdc);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="smdc"></param>
        /// <returns></returns>
        public SurfaceMeshDataContract AddSurfaceMesh(SurfaceMeshDataContract smdc)
        {
            // assert that GUID was not already assigned
            System.Diagnostics.Trace.Assert(smdc.Id.CompareTo(Guid.Empty) == 0);
            smdc.Id = Guid.NewGuid();
            _cacheMeshes.Add(smdc.Id, smdc);

            smdc.VertexBuffer =
                BufferRepository.CreateBuffer(Guid.NewGuid(), typeof(System.Windows.Media.Media3D.Vector3D),
                                              smdc.VertexCount);

            smdc.NormalBuffer =
                BufferRepository.CreateBuffer(Guid.NewGuid(), typeof(System.Windows.Media.Media3D.Vector3D),
                                              smdc.VertexCount);

            if (smdc.TriangleCount > 0)
            {
                smdc.TriangleIndexBuffer =
                    BufferRepository.CreateBuffer(Guid.NewGuid(), typeof(TriangleIndex),
                                                  smdc.TriangleCount);
            }

            return(smdc);
        }