0022734: Memory allocation error in OpenGl
[occt.git] / src / OpenGl / OpenGl_Mesh.hxx
1 // Created on: 2011-07-13
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 #ifndef OpenGl_Mesh_Header
22 #define OpenGl_Mesh_Header
23
24 #include <InterfaceGraphic_telem.hxx>
25 #include <Graphic3d_Array1OfVertex.hxx>
26 #include <Graphic3d_Array1OfVertexN.hxx>
27 #include <Graphic3d_Array1OfVertexC.hxx>
28 #include <Graphic3d_Array1OfVertexNC.hxx>
29 #include <Graphic3d_Array1OfVertexNT.hxx>
30 #include <Aspect_Array1OfEdge.hxx>
31 #include <Aspect_InteriorStyle.hxx>
32
33 #include <OpenGl_Element.hxx>
34 #include <OpenGl_AspectFace.hxx>
35
36 struct TEL_INDEXPOLY_DATA
37 {
38   Tint       num_vertices;   /* Number of vertices */
39   Tint       num_facets;     /* Number of facets (triangles, quadrangles or polygons) */
40   Tint       num_bounds;     /* Number of bounds in a facet (3, 4 or more) */
41   Tint       facet_flag;     /* TEL_FA_NONE or TEL_FA_NORMAL */
42   Tint       vertex_flag;    /* TEL_VT_NONE or TEL_VT_NORMAL */
43   Tint       *edge_vis;      /* Edge visibility indicators for each edge */
44   Tint       *indices;       /* Connectivity array */
45   tel_point  fnormals;       /* Facet normals */
46   tel_colour fcolours;       /* Facet colour values */
47   tel_point  vertices;       /* Vertices */
48   tel_colour vcolours;       /* Vertex colour values */
49   tel_point  vnormals;       /* Vertex normals */
50   tel_texture_coord vtexturecoord; /* Texture Coordinates */
51   DEFINE_STANDARD_ALLOC
52 };
53
54 class OpenGl_Mesh : public OpenGl_Element
55 {
56  public:
57
58   OpenGl_Mesh (const Graphic3d_Array1OfVertex& AListVertex, const Aspect_Array1OfEdge& AListEdge);
59   OpenGl_Mesh (const Graphic3d_Array1OfVertexN& AListVertex, const Aspect_Array1OfEdge& AListEdge);
60   OpenGl_Mesh (const Graphic3d_Array1OfVertexC& AListVertex, const Aspect_Array1OfEdge& AListEdge);
61   OpenGl_Mesh (const Graphic3d_Array1OfVertexNC& AListVertex, const Aspect_Array1OfEdge& AListEdge);
62   OpenGl_Mesh (const Graphic3d_Array1OfVertexNT& AListVertex, const Aspect_Array1OfEdge& AListEdge);
63
64   virtual ~OpenGl_Mesh ();
65
66   virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
67
68  protected:
69
70   void Init (const Tint ANbVertices, tel_point AVertices,
71              tel_point AVNormals, tel_colour AVColors, tel_texture_coord ATCoords,
72              const Aspect_Array1OfEdge& AListEdge, const Tint ANbBounds);
73
74   void draw_indexpoly (const Tint,          /* front_lighting_model,  */
75                        const Aspect_InteriorStyle, /* interior_style, */
76                        const TEL_COLOUR *, /* edge_colour, */
77                        const OPENGL_SURF_PROP *,
78                        const Handle(OpenGl_Workspace) &) const;
79
80   void draw_degenerates_as_points (const float) const;
81
82   void draw_degenerates_as_bboxs () const;
83
84   void draw_edges (const TEL_COLOUR *, const Aspect_InteriorStyle, Tint, const Handle(OpenGl_Workspace) &) const;
85
86   TEL_INDEXPOLY_DATA myData;
87   DS_INTERNAL *myDS;
88
89  public:
90   DEFINE_STANDARD_ALLOC
91 };
92
93 #endif //OpenGl_Mesh_Header