[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Geometry.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20     /// <summary>
21     /// Geometry is handle to an object that can be used to define a geometric elements.
22     /// </summary>
23     /// <since_tizen> 3 </since_tizen>
24     public class Geometry : BaseHandle
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27
28         /// <summary>
29         /// Create an instance of Geometry.
30         /// </summary>
31         /// <since_tizen> 3 </since_tizen>
32         public Geometry() : this(Interop.Geometry.Geometry_New(), true)
33         {
34             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
35
36         }
37
38         internal Geometry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Geometry.Geometry_SWIGUpcast(cPtr), cMemoryOwn)
39         {
40             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41         }
42
43         /// <summary>
44         /// Enumeration for the description of the type of geometry,
45         /// used to determine how the coordinates will be used.
46         /// </summary>
47         /// <returns>Type of primitives this geometry contains.</returns>
48         /// <since_tizen> 3 </since_tizen>
49         public enum Type
50         {
51             /// <summary>
52             /// Individual points.
53             /// </summary>
54             POINTS,
55
56             /// <summary>
57             /// Individual lines (made of 2 points each).
58             /// </summary>
59             LINES,
60
61             /// <summary>
62             /// A strip of lines (made of 1 point each) which also joins the first and last point.
63             /// </summary>
64             LINE_LOOP,
65
66             /// <summary>
67             /// A strip of lines (made of 1 point each).
68             /// </summary>
69             LINE_STRIP,
70
71             /// <summary>
72             /// Individual triangles (made of 3 points each).
73             /// </summary>
74             TRIANGLES,
75
76             /// <summary>
77             /// A fan of triangles around a centre point (after the first triangle, following triangles need only 1 point).
78             /// </summary>
79             TRIANGLE_FAN,
80
81             /// <summary>
82             /// A strip of triangles (after the first triangle, following triangles need only 1 point).
83             /// </summary>
84             TRIANGLE_STRIP
85         }
86
87         /// <summary>
88         /// Adds a PropertyBuffer to be used as source of geometry vertices.
89         /// </summary>
90         /// <param name="vertexBuffer">PropertyBuffer to be used as source of geometry vertices.</param>
91         /// <returns>Index of the newly added buffer.</returns>
92         /// <since_tizen> 3 </since_tizen>
93         public uint AddVertexBuffer(PropertyBuffer vertexBuffer)
94         {
95             uint ret = Interop.Geometry.Geometry_AddVertexBuffer(swigCPtr, PropertyBuffer.getCPtr(vertexBuffer));
96             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97             return ret;
98         }
99
100         /// <summary>
101         /// Retrieves the number of vertex buffers that have been added to this geometry.
102         /// </summary>
103         /// <returns>Number of vertex buffers that have been added to this geometry.</returns>
104         /// <since_tizen> 3 </since_tizen>
105         public uint GetNumberOfVertexBuffers()
106         {
107             uint ret = Interop.Geometry.Geometry_GetNumberOfVertexBuffers(swigCPtr);
108             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109             return ret;
110         }
111
112         /// <summary>
113         /// Removes a vertex buffer.
114         /// </summary>
115         /// <param name="index">Index to the vertex buffer to remove.</param>
116         /// <since_tizen> 3 </since_tizen>
117         public void RemoveVertexBuffer(uint index)
118         {
119             Interop.Geometry.Geometry_RemoveVertexBuffer(swigCPtr, index);
120             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121         }
122
123         /// <summary>
124         /// Sets a the index data to be used as a source of indices for the geometry
125         /// Setting this buffer will cause the geometry to be rendered using indices.
126         /// </summary>
127         /// <param name="indices">Array of indices.</param>
128         /// <param name="count">Number of indices in the array.</param>
129         /// <since_tizen> 3 </since_tizen>
130         public void SetIndexBuffer(ushort[] indices, uint count)
131         {
132             Interop.Geometry.Geometry_SetIndexBuffer(swigCPtr, indices, count);
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134         }
135
136         /// <summary>
137         /// Sets the type of primitives this geometry contains.
138         /// </summary>
139         /// <param name="geometryType">Array of indices.</param>
140         /// <since_tizen> 3 </since_tizen>
141         public void SetType(Geometry.Type geometryType)
142         {
143             Interop.Geometry.Geometry_SetType(swigCPtr, (int)geometryType);
144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145         }
146
147         /// <summary>
148         /// Gets the type of primitives this geometry contains.
149         /// </summary>
150         /// <returns>Type of primitives this geometry contains.</returns>
151         /// <since_tizen> 3 </since_tizen>
152         public new Geometry.Type GetType()
153         {
154             Geometry.Type ret = (Geometry.Type)Interop.Geometry.Geometry_GetType(swigCPtr);
155             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156             return ret;
157         }
158
159         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Geometry obj)
160         {
161             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
162         }
163
164         /// <summary>
165         /// Dispose.
166         /// </summary>
167         /// <since_tizen> 3 </since_tizen>
168         protected override void Dispose(DisposeTypes type)
169         {
170             if (disposed)
171             {
172                 return;
173             }
174
175             //Release your own unmanaged resources here.
176             //You should not access any managed member here except static instance.
177             //because the execution order of Finalizes is non-deterministic.
178
179             if (swigCPtr.Handle != global::System.IntPtr.Zero)
180             {
181                 if (swigCMemOwn)
182                 {
183                     swigCMemOwn = false;
184                     Interop.Geometry.delete_Geometry(swigCPtr);
185                 }
186                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
187             }
188
189             base.Dispose(type);
190         }
191     }
192 }