Exemplo n.º 1
0
        public void Init(IW32Win w32, NoForm root)
        {
            this.w32        = w32;
            noForm          = root;
            noForm.renderer = this;
            lock (noForm)
            {
                var sz = root.Size;
                // Initialise d2d things
                backBuffer = new Texture2D(device, new Texture2DDescription()
                {
                    ArraySize         = 1,
                    MipLevels         = 1,
                    SampleDescription = new SampleDescription(1, 0),
                    OptionFlags       = ResourceOptionFlags.GdiCompatible,
                    Width             = (int)sz.width,
                    Height            = (int)sz.height,
                    Usage             = ResourceUsage.Default,
                    BindFlags         = BindFlags.RenderTarget,
                    Format            = Format.B8G8R8A8_UNorm,
                });
                renderView      = new RenderTargetView(device, backBuffer);
                surface         = backBuffer.QueryInterface <Surface1>();
                d2dRenderTarget = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));
                scbTrans        = new SolidColorBrush(d2dRenderTarget, new Color4(1f, 0f, 1f, 0f)); // set buffer area to transparent

                // Init uDraw and assign IRenderElement parts
                _backRenderer = new SharpDX_RenderElements(d2dRenderTarget);
                _uDraw        = new D2DDraw(_backRenderer);

                // Create the observer
                dobs = new DirtyObserver(noForm, RenderPass, () => noForm.DirtyAnimated, () => noForm.ReqSize, () => FPSLimit);
            }
        }
Exemplo n.º 2
0
        public DxgiTargetDeviceContext(IPreviewWindow PreviewWindow, int Width, int Height)
        {
            _editorSession        = new Direct2DEditorSession(Width, Height, PreviewWindow);
            _gdiCompatibleTexture = _editorSession.CreateGdiTexture(Width, Height);

            _dxgiSurface = _gdiCompatibleTexture.QueryInterface <Surface1>();
        }
        public void TestRenderUsingGDI()
        {
            var game = new DX11Game();

            game.InitDirectX();

            // Create the DirectX11 texture2D.  This texture will be shared with the DirectX10
            // device.  The DirectX10 device will be used to render text onto this texture.  DirectX11
            // will then draw this texture (blended) onto the screen.
            // The KeyedMutex flag is required in order to share this resource.
            SlimDX.Direct3D11.Texture2D textureD3D11 = new Texture2D(game.Device, new Texture2DDescription
            {
                Width             = 100,
                Height            = 100,
                MipLevels         = 1,
                ArraySize         = 1,
                Format            = Format.B8G8R8A8_UNorm,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = ResourceUsage.Default,
                BindFlags         = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags    = CpuAccessFlags.None,
                OptionFlags       = ResourceOptionFlags.KeyedMutex
            });

            var surface  = textureD3D11.AsSurface();
            var surface1 = Surface1.FromPointer(surface.ComPointer);



            game.GameLoopEvent += delegate
            {
            };
        }
Exemplo n.º 4
0
        void HandleCreatedStuff()
        {
            SwapChainDescription swapchainDescription = new SwapChainDescription()
            {
                BufferCount       = 1,
                Flags             = SwapChainFlags.GdiCompatible,
                IsWindowed        = true,
                ModeDescription   = new ModeDescription((int)noForm.Size.width, (int)noForm.Size.height, new Rational(60, 1), Format.B8G8R8A8_UNorm),
                OutputHandle      = winHandle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Sequential,
                Usage             = Usage.RenderTargetOutput
            };

            SharpDXLib.Direct3D10.Device1.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, swapchainDescription, out device, out swapchain);

            // Initialise d2d things
            backBuffer      = Texture2D.FromSwapChain <Texture2D>(swapchain, 0);
            renderView      = new RenderTargetView(device, backBuffer);
            surface         = backBuffer.QueryInterface <Surface1>();
            d2dRenderTarget = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));

            // Init uDraw and assign IRenderElement parts
            _backRenderer = new SharpDX_RenderElements(d2dRenderTarget);
            _uDraw        = new D2DDraw(_backRenderer);
        }
Exemplo n.º 5
0
        void Resize(Common.Size ReqSize)
        {
            var            w    = (int)d2dRenderTarget.Size.Width;
            var            h    = (int)d2dRenderTarget.Size.Height;
            var            nbb  = new Texture2D(device, backBuffer.Description);
            ResourceRegion rrgn = new ResourceRegion()
            {
                Front = 0, Back = 1, Top = 0, Left = 0, Right = w, Bottom = h
            };

            device.CopySubresourceRegion(backBuffer, 0, rrgn, nbb, 0, 0, 0, 0);

            d2dRenderTarget.Dispose();
            renderView.Dispose();
            surface.Dispose();
            backBuffer.Dispose();

            swapchain.ResizeBuffers(0, (int)ReqSize.width, (int)ReqSize.height, Format.B8G8R8A8_UNorm, SwapChainFlags.None);
            backBuffer      = Texture2D.FromSwapChain <Texture2D>(swapchain, 0);
            renderView      = new RenderTargetView(device, backBuffer);
            surface         = backBuffer.QueryInterface <Surface1>();
            d2dRenderTarget = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));

            device.CopySubresourceRegion(nbb, 0, rrgn, backBuffer, 0, 0, 0, 0);
            nbb.Dispose();
        }
Exemplo n.º 6
0
        private void SetupResources()
        {
            this.backBuffer = Texture2D.FromSwapChain <Texture2D>(swapChain, 0);
            this.targetView = new RenderTargetView(this.device, this.backBuffer);

            this.surface        = this.backBuffer.QueryInterface <Surface1>();
            this.painter        = new SharpDX.Direct2D1.DeviceContext(this.surface);
            this.bitmap         = new Bitmap1(this.painter, this.surface);
            this.painter.Target = this.bitmap;

            device.ImmediateContext.OutputMerger.SetRenderTargets(targetView);
        }
        internal override string[] GetText()
        {
            List <string> list = new List <string>();

            list.AddRange(new string[] { "Oxs_TwoSurfaceExchange:" + Name + " {", "sigma " + Sigma, "sigma2 "
                                         + Sigma2 + "surface1 {" });
            list.AddRange(Surface1.GetText());
            list.Add("}");
            list.Add("surface2 {");
            list.AddRange(Surface2.GetText());
            list.Add("}");
            list.Add("}");
            return(list.ToArray());
        }
Exemplo n.º 8
0
        void Resize()
        {
            d2dDeviceContext.Target = null;
            d2dSurface.Dispose();
            swapChain.ResizeBuffers(0, 0, 0, Format.Unknown, SwapChainFlags.None);
            Surface1 dxgiSurface = swapChain.GetBackBuffer <Surface1>(0);
            var      props       = new BitmapProperties1(new PixelFormat(Format.B8G8R8A8_UNorm, D2D.AlphaMode.Ignore),
                                                         d2dDeviceContext.DotsPerInch.Width,
                                                         d2dDeviceContext.DotsPerInch.Height,
                                                         BitmapOptions.Target | BitmapOptions.CannotDraw);

            d2dSurface = new Bitmap1(d2dDeviceContext, dxgiSurface, props);
            dxgiSurface.Dispose();
            d2dDeviceContext.Target = d2dSurface;
        }
Exemplo n.º 9
0
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // Resize the form and backbuffer to noForm.Size
            Resize(ReqSize);

            Win32Util.Size w32Size = new Win32Util.Size((int)ReqSize.width, (int)ReqSize.height);
            Win32Util.SetWindowSize(w32Size, winHandle); // FIXME blocks when closing->endrender event is locked...

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            // Do Drawing stuff
            DrawingSize rtSize = new DrawingSize((int)d2dRenderTarget.Size.Width, (int)d2dRenderTarget.Size.Height);

            using (Texture2D t2d = new Texture2D(backBuffer.Device, backBuffer.Description))
            {
                using (Surface1 srf = t2d.QueryInterface <Surface1>())
                {
                    using (RenderTarget trt = new RenderTarget(d2dFactory, srf, new RenderTargetProperties(d2dRenderTarget.PixelFormat)))
                    {
                        _backRenderer.renderTarget = trt;
                        trt.BeginDraw();
                        noForm.DrawBase(this, dc);
                        trt.EndDraw();

                        foreach (var rc in dc.AsRectangles())
                        {
                            t2d.Device.CopySubresourceRegion(t2d, 0,
                                                             new ResourceRegion()
                            {
                                Left = (int)rc.left, Right = (int)rc.right, Top = (int)rc.top, Bottom = (int)rc.bottom, Back = 1, Front = 0
                            }, backBuffer, 0,
                                                             (int)rc.left, (int)rc.top, 0);
                        }
                    }
                }
            }
            swapchain.Present(0, PresentFlags.None);

            //System.Threading.Thread.Sleep(1000);
            lastFrameRenderDuration = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }
Exemplo n.º 10
0
        void InitializeDirect2D()
        {
            d3dDevice  = new D3D.Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport);
            dxgiDevice = d3dDevice.QueryInterface <DXGI.Device1>();
            var desc = new SwapChainDescription1()
            {
                Width             = 0,
                Height            = 0,
                Format            = Format.B8G8R8A8_UNorm,
                Stereo            = false,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = Usage.RenderTargetOutput,
                BufferCount       = 3,
                Scaling           = Scaling.None,
                SwapEffect        = SwapEffect.FlipSequential,
                Flags             = SwapChainFlags.None
            };

            DXGI.Factory2 dxgiFactory = dxgiDevice.Adapter.GetParent <DXGI.Factory2>();
            swapChain = new SwapChain1(dxgiFactory, d3dDevice, Child.Handle, ref desc);
            swapChain.BackgroundColor = Color4.White;
            dxgiFactory.Dispose();

            d2dFactory       = new D2D.Factory1(FactoryType.SingleThreaded);
            d2dDevice        = new D2D.Device(d2dFactory, dxgiDevice);
            d2dDeviceContext = new D2D.DeviceContext(d2dDevice, DeviceContextOptions.None);
            d2dDeviceContext.TextAntialiasMode = TextAntialiasMode.Cleartype;
            //d2dDeviceContext.DotsPerInch = new Size2F(96, 96);
            var props = new BitmapProperties1(new PixelFormat(Format.B8G8R8A8_UNorm, D2D.AlphaMode.Ignore),
                                              d2dDeviceContext.DotsPerInch.Width,
                                              d2dDeviceContext.DotsPerInch.Height,
                                              BitmapOptions.Target | BitmapOptions.CannotDraw);
            Surface1 dxgiSurface = swapChain.GetBackBuffer <Surface1>(0);

            d2dSurface = new Bitmap1(d2dDeviceContext, dxgiSurface, props);
            dxgiSurface.Dispose();
            d2dDeviceContext.Target = d2dSurface;

            VertexFillBrush = new SolidColorBrush(d2dDeviceContext, new Color4(1, 0.5f, 0, 1));
            VertexDrawBrush = new SolidColorBrush(d2dDeviceContext, new Color4(0.2f, 0.2f, 0.2f, 1));
            EdgeDrawBrush   = new SolidColorBrush(d2dDeviceContext, Color4.Black);
            RasterDrawBrush = new SolidColorBrush(d2dDeviceContext, new Color4(0.5f, 0.5f, 0.5f, 1));
        }
Exemplo n.º 11
0
        void Resize(Size ReqSize)
        {
            // Initialise d2d things
            var nbb = new Texture2D(device, new Texture2DDescription()
            {
                ArraySize         = 1,
                MipLevels         = 1,
                SampleDescription = new SampleDescription(1, 0),
                OptionFlags       = ResourceOptionFlags.GdiCompatible,
                Width             = (int)ReqSize.width + edgeBufferSize,
                Height            = (int)ReqSize.height + edgeBufferSize,
                Usage             = ResourceUsage.Default,
                BindFlags         = BindFlags.RenderTarget,
                Format            = Format.B8G8R8A8_UNorm
            });

            ResourceRegion rrgn = new ResourceRegion()
            {
                Front  = 0,
                Back   = 1,
                Top    = 0,
                Left   = 0,
                Right  = (int)ReqSize.width,
                Bottom = (int)ReqSize.height
            };

            //int bef = HashResource(nbb);
            device.CopySubresourceRegion(backBuffer, 0, rrgn, nbb, 0, 0, 0, 0);
            //int aft = HashResource(nbb);

            backBuffer.Dispose();
            backBuffer = nbb;

            renderView.Dispose();
            surface.Dispose();
            d2dRenderTarget.Dispose();

            renderView      = new RenderTargetView(device, backBuffer);
            surface         = backBuffer.QueryInterface <Surface1>();
            d2dRenderTarget = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));
        }
Exemplo n.º 12
0
        private void copyBuffer(Surface1 surface1, Rectangle desktopBounds, Action <IntPtr, int, Rectangle> copyFrameBuffer)
        {
            if (surface1 == null)
            {
                return;
            }

            DataRectangle map    = surface1.Map(MapFlags.Read);
            IntPtr        srcPtr = map.DataPointer;

            Rectangle offsetBounds = desktopBounds;

            offsetBounds.Offset(-this._outputRect.Left, -this._outputRect.Top);

            try
            {
                copyFrameBuffer(srcPtr, map.Pitch, offsetBounds);
            }
            catch { }

            surface1.Unmap();
        }
        internal bool AcquireNextFrame(int timeout, Action <Surface1, Rectangle, Action <IntPtr, int, Rectangle> > copyAction, Action <IntPtr, int, Rectangle> copyFrameBuffer)
        {
            SharpDX.DXGI.Resource desktopResource;

            try
            {
                _outputDuplication.AcquireNextFrame(timeout, out OutputDuplicateFrameInformation fi, out desktopResource);
            }
            catch (SharpDXException e)
            {
                if (e.ResultCode == DXGIError.DXGI_ERROR_ACCESS_LOST)
                {
                    throw;
                }

                return(false);
            }

            if (desktopResource == null)
            {
                return(false);
            }

            try
            {
                using (Texture2D textureResource = desktopResource.QueryInterface <Texture2D>())
                {
                    Texture2DDescription desc = textureResource.Description;

                    Texture2DDescription textureDescription = desc;
                    textureDescription.MipLevels = 1;
                    textureDescription.ArraySize = 1;
                    textureDescription.SampleDescription.Count   = 1;
                    textureDescription.SampleDescription.Quality = 0;
                    textureDescription.Usage          = ResourceUsage.Staging;
                    textureDescription.BindFlags      = 0;
                    textureDescription.CpuAccessFlags = CpuAccessFlags.Read;
                    textureDescription.OptionFlags    = ResourceOptionFlags.None;

                    using (Texture2D d3d11Texture2D = new Texture2D(_device, textureDescription))
                    {
                        _device.ImmediateContext.CopyResource(textureResource, d3d11Texture2D);

                        using (Surface1 surface = d3d11Texture2D.QueryInterface <Surface1>())
                        {
                            copyAction(surface, this.DesktopCoordinates, copyFrameBuffer);
                            return(true);
                        }
                    }
                }
            }
            finally
            {
                if (desktopResource != null)
                {
                    desktopResource.Dispose();
                }

                _outputDuplication.ReleaseFrame();
            }
        }
Exemplo n.º 14
0
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // FIXME so much object spam and disposal in this very high frequency function (also inside Resize called belw).  My poor megabytes!

            // Resize the form and backbuffer to noForm.Size, and fire the noForms sizechanged
            Resize(ReqSize);

            // make size...
            Win32Util.Size w32Size = new Win32Util.Size((int)ReqSize.width, (int)ReqSize.height);
            Win32Util.SetWindowSize(w32Size, hWnd);

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            lock (noForm)
            {
                // Do Drawing stuff
                DrawingSize rtSize = new DrawingSize((int)d2dRenderTarget.Size.Width, (int)d2dRenderTarget.Size.Height);
                using (Texture2D t2d = new Texture2D(backBuffer.Device, backBuffer.Description))
                {
                    using (Surface1 srf = t2d.QueryInterface <Surface1>())
                    {
                        using (RenderTarget trt = new RenderTarget(d2dFactory, srf, new RenderTargetProperties(d2dRenderTarget.PixelFormat)))
                        {
                            _backRenderer.renderTarget = trt;
                            trt.BeginDraw();
                            noForm.DrawBase(this, dc);
                            // Fill with transparency the edgeBuffer!
                            trt.FillRectangle(new RectangleF(0, noForm.Size.height, noForm.Size.width + edgeBufferSize, noForm.Size.height + edgeBufferSize), scbTrans);
                            trt.FillRectangle(new RectangleF(noForm.Size.width, 0, noForm.Size.width + edgeBufferSize, noForm.Size.height + edgeBufferSize), scbTrans);
                            trt.EndDraw();

                            foreach (var rc in dc.AsRectangles())
                            {
                                t2d.Device.CopySubresourceRegion(t2d, 0,
                                                                 new ResourceRegion()
                                {
                                    Left = (int)rc.left, Right = (int)rc.right, Top = (int)rc.top, Bottom = (int)rc.bottom, Back = 1, Front = 0
                                }, backBuffer, 0,
                                                                 (int)rc.left, (int)rc.top, 0);
                            }
                        }
                    }
                }

                // Present DC to windows (ugh layered windows sad times)
                IntPtr dxHdc = surface.GetDC(false);
                System.Drawing.Graphics dxdc     = System.Drawing.Graphics.FromHdc(dxHdc);
                Win32Util.Point         dstPoint = new Win32Util.Point((int)(noForm.Location.X), (int)(noForm.Location.Y));
                Win32Util.Point         srcPoint = new Win32Util.Point(0, 0);
                Win32Util.Size          pSize    = new Win32Util.Size(rtSize.Width, rtSize.Height);
                Win32Util.BLENDFUNCTION bf       = new Win32Util.BLENDFUNCTION()
                {
                    SourceConstantAlpha = 255, AlphaFormat = Win32Util.AC_SRC_ALPHA, BlendFlags = 0, BlendOp = 0
                };

                bool suc = Win32Util.UpdateLayeredWindow(hWnd, someDC, ref dstPoint, ref pSize, dxHdc, ref srcPoint, 1, ref bf, 2);

                surface.ReleaseDC();
                dxdc.Dispose();
            }
            lastFrameRenderDuration = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }
Exemplo n.º 15
0
        private void BindingInputSchema()
        {
            switch (dataType)
            {
                case DATA_TYPE.S101:
                    dataset = new Dataset();

                    //Information Types
                    InformationTypes informationTypes = new InformationTypes();
                    for (int i = 0; i < s101.itr.Count; i++)
                    {
                        InformationTypeRecord informationType = s101.itr[i];
                        string name = s101.dsgir.dsid.ITCS[informationType.irid.nitc];

                        if(name.Equals("SpatialQuality"))
                        {
                            SpatialQuality sq = new SpatialQuality();
                            sq.id = i.ToString();
                            //qualityOfPosition
                        }
                        else if(name.Equals("ChartNote"))
                        {

                        }
                    }

                    //Points
                    Point1[] points = new Point1[s101.pr.Count];
                    for (int i = 0; i < s101.pr.Count; i++)
                    {
                        PointRecord point = s101.pr[i];
                        Point1 inputPoint = new Point1();
                        inputPoint.id = (i + 1).ToString();
                        //fix
                        Coordinate2D coor = new Coordinate2D();
                        coor.x = point.c2it[0].coor.xcoo;
                        coor.y = point.c2it[0].coor.ycoo;
                        inputPoint.Coordinate2D = coor;
                        points[i] = inputPoint;
                    }
                    dataset.Points = points;

                    //MultiPoints
                    MultiPoint1[] multiPoints = new MultiPoint1[s101.mpr.Count];
                    for (int i = 0; i < s101.mpr.Count; i++)
                    {
                        MultiPointRecord multiPoint = s101.mpr[i];
                        //fix
                        for (int z = 0; z < multiPoint.c3il.Count; z++)
                        {
                            var coorList = multiPoint.c3il[z];
                            MultiPoint1 inputMultiPoint = new MultiPoint1();
                            inputMultiPoint.id = (i + 1).ToString();
                            inputMultiPoint.Coordinate3D = new Coordinate3D[coorList.coor.Count];
                            for (int k = 0; k < coorList.coor.Count; k++)
                            {
                                Coordinate3D coor = new Coordinate3D();
                                coor.x = coorList.coor[k].xcoo;
                                coor.y = coorList.coor[k].ycoo;
                                coor.z = coorList.coor[k].zcoo;
                                inputMultiPoint.Coordinate3D[k] = coor;
                            }
                            multiPoints[z] = inputMultiPoint;

                        }

                    }
                    dataset.MultiPoints = multiPoints;

                    //Curves
                    Curve1[] curves = new Curve1[s101.cr.Count];
                    for (int i = 0; i < s101.cr.Count; i++)
                    {
                        var curve = s101.cr[i];
                        Curve1 inputCurve = new Curve1();
                        inputCurve.id = (i + 1).ToString();

                        inputCurve.Boundary = new BoundaryRelation[curve.ptas.Count];
                        for (int z = 0; z < curve.ptas.Count; z++)
                        {
                            BoundaryRelation br = new BoundaryRelation();

                            var ptas = curve.ptas[z];
                            br.@ref = ptas.rrid.ToString();

                            BoundaryType type = (BoundaryType)Enum.Parse(typeof(BoundaryType), ptas.topi.ToString());
                            br.boundaryType = type;

                            inputCurve.Boundary[z] = br;
                        }

                        Segment[] segment = new Segment[curve.segh.Count];
                        for (int z = 0; z < curve.segh.Count; z++)
                        {
                            Segment sgm = new Segment();
                            var segh = curve.segh[z];
                            InterpolationType type =(InterpolationType) Enum.Parse(typeof(InterpolationType),segh.intp.ToString());
                            sgm.interpolation = type;

                            List<Coordinate2D> coores = new List<Coordinate2D>();
                           foreach (var c2il in segh.c2il)
                           {
                               foreach (var coor in c2il.coor)
                               {
                                   Coordinate2D coor2d = new Coordinate2D();
                                   coor2d.y = coor.ycoo;
                                   coor2d.x = coor.xcoo;
                                   coores.Add(coor2d);
                               }
                            }
                            sgm.ControlPoint = coores.ToArray();
                            segment[z] = sgm;
                        }
                        inputCurve.Segment = segment;

                        curves[i] = inputCurve;
                    }
                    dataset.Curves = curves;

                    //CompositeCurves
                    CompositeCurve1[] compositeCurves = new CompositeCurve1[s101.ccr.Count];
                    for (int i = 0; i < s101.ccr.Count; i++)
                    {
                        var compositeCurve = s101.ccr[i];
                        CompositeCurve1 inputCompositeCurve = new CompositeCurve1();
                        inputCompositeCurve.id = (i + 1).ToString();
                        List<CurveRelation> cl = new List<CurveRelation>();
                        List<CurveRelation> ccl = new List<CurveRelation>();
                        foreach (var cuco in compositeCurve.cuco)
                        {
                            if (cuco.rrnm == 120) //curve
                            {
                                CurveRelation cr = new CurveRelation();
                                cr.@ref = cuco.rrid.ToString();
                                cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), cuco.ornt.ToString());
                                cl.Add(cr);
                            }
                            else if (cuco.rrnm == 125) //compositCurve
                            {
                                CurveRelation cr = new CurveRelation();
                                cr.@ref = cuco.rrid.ToString();
                                cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), cuco.ornt.ToString());
                                ccl.Add(cr);
                            }
                        }
                        inputCompositeCurve.Curve = cl.ToArray();
                        inputCompositeCurve.CompositeCurve1 = ccl.ToArray();
                        compositeCurves[i] = inputCompositeCurve;
                    }
                    dataset.CompositeCurves = compositeCurves;

                    //surfaces //fix
                    Surface1[] surfaces = new Surface1[s101.sr.Count];
                    for (int i = 0; i < s101.sr.Count; i++)
                    {
                        var surface = s101.sr[i];
                        Surface1 inputSurface = new Surface1();
                        inputSurface.id = (i + 1).ToString();
                        List<Ring> interiorRing = new List<Ring>();
                        List<Ring> ExteriorRing = new List<Ring>();
                        foreach (var rias in surface.rias)
                        {
                            Ring ring = new Ring();
                            List<CurveRelation> crl = new List<CurveRelation>();
                            List<ItemsChoiceType> ict = new List<ItemsChoiceType>();
                            if (rias.rrnm == 120) //curve
                            {
                                CurveRelation cr = new CurveRelation();
                                cr.@ref = rias.rrid.ToString();
                                cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), rias.ornt.ToString());
                                ict.Add(ItemsChoiceType.Curve);
                                crl.Add(cr);
                            }
                            else if (rias.rrnm == 125)//compositeCurve
                            {
                                CurveRelation cr = new CurveRelation();
                                cr.@ref = rias.rrid.ToString();
                                cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), rias.ornt.ToString());
                                ict.Add(ItemsChoiceType.CompositeCurve);
                                crl.Add(cr);
                            }
                            ring.Items = crl.ToArray();
                            ring.ItemsElementName = ict.ToArray();

                            if (rias.usag == 1)
                            {
                                interiorRing.Add(ring);
                            }
                            else if (rias.usag == 2)
                            {
                                ExteriorRing.Add(ring);
                            }
                        }
                        inputSurface.InnerRing = interiorRing.ToArray();
                        inputSurface.OuterRing = ExteriorRing.ToArray();
                        surfaces[i] = inputSurface;
                    }
                    dataset.Surfaces = surfaces;

                    //feature
                    Features features = new Features();
                    List<DepthArea> dal = new List<DepthArea>();
                    List<Landmark> lm = new List<Landmark>();
                    for (int i = 0; i < s101.ftr.Count; i++)
                    {
                        var feature = s101.ftr[i];

                        string featureName = s101.dsgir.dsid.FTCS[feature.frid.nftc];

                        if (featureName.Equals("DepthArea"))
                        {
                            DepthArea da = new DepthArea();
                            da.id = (i + 1).ToString();

                            foreach (var attr in feature.attr)
                            {
                                string attrName = s101.dsgir.dsid.ATCS[attr.natc];
                                if (attrName.Equals("depthRangeMinimumValue"))
                                {
                                    if (attr.atvl.Equals(""))
                                        da.depthValue1Specified = false;
                                    else
                                    {
                                        da.depthValue1Specified = true;
                                        da.depthRangeMinimumValue = Convert.ToDouble(attr.atvl);
                                    }
                                }
                                else if (attrName.Equals("depthRangeMaximumValue"))
                                {
                                    if (attr.atvl.Equals(""))
                                        da.depthValue2Specified = false;
                                    else
                                    {
                                        da.depthValue2Specified = true;
                                        da.depthRangeMaximumValue = Convert.ToDouble(attr.atvl);
                                    }
                                }

                            }

                            List<CurveRelation> cl = new List<CurveRelation>();
                            List<CurveRelation> ccl = new List<CurveRelation>();
                            List<MaskedRelation> pl = new List<MaskedRelation>();
                            List<MaskedRelation> mpl = new List<MaskedRelation>();
                            List<MaskedRelation> sl = new List<MaskedRelation>();
                            foreach (var spas in feature.spas)
                            {
                                if (spas.rrnm == S101.Point)
                                {
                                    MaskedRelation mr = new MaskedRelation();
                                    da.primitive = GeometricPrimitive.Point;
                                    mr.@ref = spas.rrid.ToString();
                                    pl.Add(mr);
                                }
                                else if (spas.rrnm == S101.MultiPoint)
                                {
                                    MaskedRelation mr = new MaskedRelation();
                                    da.primitive = GeometricPrimitive.MultiPoint;
                                    mr.@ref = spas.rrid.ToString();
                                    mpl.Add(mr);
                                }
                                else if (spas.rrnm == S101.Curve)
                                {
                                    CurveRelation cr = new CurveRelation();
                                    da.primitive = GeometricPrimitive.Curve;
                                    cr.@ref = spas.rrid.ToString();
                                    cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), spas.ornt.ToString());
                                    cl.Add(cr);
                                }
                                else if (spas.rrnm == S101.Surface)
                                {
                                    MaskedRelation mr = new MaskedRelation();
                                    da.primitive = GeometricPrimitive.Surface;
                                    mr.@ref = spas.rrid.ToString();
                                    sl.Add(mr);
                                }
                                else if (spas.rrnm == S101.CompositeCurve)
                                {
                                    CurveRelation cr = new CurveRelation();
                                    da.primitive = GeometricPrimitive.Curve;
                                    cr.@ref = spas.rrid.ToString();
                                    cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), spas.ornt.ToString());
                                    ccl.Add(cr);
                                }

                            }
                            da.Curve = cl.ToArray();
                            da.Point = pl.ToArray();
                            da.Surface = sl.ToArray();
                            da.CompositeCurve = ccl.ToArray();
                            da.PointSet = mpl.ToArray();
                            dal.Add(da);

                        }
                        else if (featureName.Equals("Landmark"))
                        {
                            Landmark landmark = new Landmark();
                            landmark.id = (i + 1).ToString();

                            foreach (var attr in feature.attr)
                            {
                                int d = 3;
                            }
                            foreach (var inas in feature.inas)
                            {
                                string informationName = s101.dsgir.dsid.IACS[inas.niac];
                                string roleName = s101.dsgir.dsid.ARCS[inas.narc];

                                int s = 5;
                                foreach (var natc in inas.natc)
                                {

                                }
                            }
                            landmark.objectName = "11";
                            List<CurveRelation> cl = new List<CurveRelation>();
                            List<CurveRelation> ccl = new List<CurveRelation>();
                            List<MaskedRelation> pl = new List<MaskedRelation>();
                            List<MaskedRelation> mpl = new List<MaskedRelation>();
                            List<MaskedRelation> sl = new List<MaskedRelation>();
                            foreach (var spas in feature.spas)
                            {
                                if (spas.rrnm == S101.Point)
                                {
                                    MaskedRelation mr = new MaskedRelation();
                                    landmark.primitive = GeometricPrimitive.Point;
                                    mr.@ref = spas.rrid.ToString();
                                    pl.Add(mr);
                                }
                                else if (spas.rrnm == S101.MultiPoint)
                                {
                                    MaskedRelation mr = new MaskedRelation();
                                    landmark.primitive = GeometricPrimitive.Point;
                                    mr.@ref = spas.rrid.ToString();
                                    mpl.Add(mr);
                                }
                                else if (spas.rrnm == S101.Curve)
                                {
                                    CurveRelation cr = new CurveRelation();
                                    landmark.primitive = GeometricPrimitive.Curve;
                                    cr.@ref = spas.rrid.ToString();
                                    cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), spas.ornt.ToString());
                                    cl.Add(cr);
                                }
                                else if (spas.rrnm == S101.Surface)
                                {
                                    MaskedRelation mr = new MaskedRelation();
                                    landmark.primitive = GeometricPrimitive.Point;
                                    mr.@ref = spas.rrid.ToString();
                                    sl.Add(mr);
                                }
                                else if (spas.rrnm == S101.CompositeCurve)
                                {
                                    CurveRelation cr = new CurveRelation();
                                    landmark.primitive = GeometricPrimitive.Curve;
                                    cr.@ref = spas.rrid.ToString();
                                    cr.orientation = (Orientation)Enum.Parse(typeof(Orientation), spas.ornt.ToString());
                                    ccl.Add(cr);
                                }

                            }
                            landmark.CompositeCurve = ccl.ToArray();
                            landmark.Curve = cl.ToArray();
                            landmark.Point = pl.ToArray();
                            landmark.PointSet = mpl.ToArray();
                            landmark.Surface = sl.ToArray();

                            lm.Add(landmark);
                        }
                        else if (featureName.Equals("LandArea"))
                        {

                        }

                    }

                    features.DepthArea = dal.ToArray();
                    features.Landmark = lm.ToArray();
                    dataset.Features = features;

                    break;
                default:
                    break;
            }
        }