KiCad PCB EDA Suite
Loading...
Searching...
No Matches
layer_triangles.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Mario Luzeiro <[email protected]>
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef TRIANGLE_DISPLAY_LIST_H
26#define TRIANGLE_DISPLAY_LIST_H
27
28#include "../../common_ogl/openGL_includes.h"
33#include <vector>
34#include <mutex>
35
36
37typedef std::vector< SFVEC3F > SFVEC3F_VECTOR;
38
39
44{
45public:
46
51 TRIANGLE_LIST( unsigned int aNrReservedTriangles, bool aReserveNormals );
52
56 void Reserve_More( unsigned int aNrReservedTriangles, bool aReserveNormals );
57
58 void AddTriangle( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 );
59
60 void AddQuad( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3, const SFVEC3F& aV4 );
61
62 void AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 );
63
64 void AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3,
65 const SFVEC3F& aN4 );
66
72 const float* GetVertexPointer() const { return (const float *)&m_vertexs[0].x; }
73
79 const float* GetNormalsPointer() const { return (const float*) &m_normals[0].x; }
80
81 unsigned int GetVertexSize() const { return (unsigned int) m_vertexs.size(); }
82
83 unsigned int GetNormalsSize() const { return (unsigned int) m_normals.size(); }
84
85private:
88};
89
90
95{
96public:
102 explicit TRIANGLE_DISPLAY_LIST( unsigned int aNrReservedTriangles );
103
105
112
113
114 void AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlinePath, float zBot, float zTop,
115 double aBiuTo3Du, bool aInvertFaceDirection,
116 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
117
118 void AddToMiddleContourns( const SHAPE_POLY_SET& aPolySet, float zBot, float zTop,
119 double aBiuTo3Du, bool aInvertFaceDirection,
120 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
121
122 void AddToMiddleContourns( const std::vector< SFVEC2F >& aContournPoints, float zBot,
123 float zTop, bool aInvertFaceDirection,
124 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
125
127
133};
134
135
140{
141public:
151 OPENGL_RENDER_LIST( const TRIANGLE_DISPLAY_LIST& aLayerTriangles,
152 GLuint aTextureIndexForSegEnds, float aZBot, float aZTop );
153
158
162 void DrawTopAndMiddle() const;
163
167 void DrawBotAndMiddle() const;
168
172 void DrawTop() const;
173
177 void DrawBot() const;
178
182 void DrawMiddle() const;
183
187 void DrawAll( bool aDrawMiddle = true ) const;
188
197 void DrawCulled( bool aDrawMiddle,
198 const OPENGL_RENDER_LIST* aSubtractList = nullptr,
199 const OPENGL_RENDER_LIST* bSubtractList = nullptr,
200 const OPENGL_RENDER_LIST* cSubtractList = nullptr,
201 const OPENGL_RENDER_LIST* dSubtractList = nullptr ) const;
202
203 void ApplyScalePosition( float aZposition, float aZscale );
204 void ApplyScalePosition( OPENGL_RENDER_LIST* aOtherList );
205
207
208 void SetItIsTransparent( bool aSetTransparent );
209
210 float GetZBot() const { return m_zBot; }
211 float GetZTop() const { return m_zTop; }
212
213private:
214 GLuint generate_top_or_bot_seg_ends( const TRIANGLE_LIST* aTriangleContainer,
215 bool aIsNormalUp, GLuint aTextureId ) const;
216
217 GLuint generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
218 bool aIsNormalUp ) const;
219
220 GLuint generate_middle_triangles( const TRIANGLE_LIST* aTriangleContainer ) const;
221
222 void beginTransformation() const;
223 void endTransformation() const;
224
225 void setBlendfunction() const;
226
227private:
228 float m_zBot;
229 float m_zTop;
235
239
241};
242
243#endif // TRIANGLE_DISPLAY_LIST_H
Store the OpenGL display lists to related with a layer.
GLuint generate_middle_triangles(const TRIANGLE_LIST *aTriangleContainer) const
float GetZBot() const
float GetZTop() const
GLuint m_layer_middle_contourns_quads
void beginTransformation() const
void DrawMiddle() const
Call the display lists for the middle elements.
GLuint generate_top_or_bot_seg_ends(const TRIANGLE_LIST *aTriangleContainer, bool aIsNormalUp, GLuint aTextureId) const
void DrawTop() const
Call the display lists for the top elements.
void DrawBot() const
Call the display lists for the bottom elements.
void ApplyScalePosition(float aZposition, float aZscale)
GLuint generate_top_or_bot_triangles(const TRIANGLE_LIST *aTriangleContainer, bool aIsNormalUp) const
void setBlendfunction() const
void DrawBotAndMiddle() const
Call the display lists for the bottom elements and middle contours.
void SetItIsTransparent(bool aSetTransparent)
void DrawCulled(bool aDrawMiddle, const OPENGL_RENDER_LIST *aSubtractList=nullptr, const OPENGL_RENDER_LIST *bSubtractList=nullptr, const OPENGL_RENDER_LIST *cSubtractList=nullptr, const OPENGL_RENDER_LIST *dSubtractList=nullptr) const
Draw all layers if they are visible by the camera if camera position is above the layer.
void endTransformation() const
~OPENGL_RENDER_LIST()
Destroy this class while free the display lists from GPU memory.
void DrawTopAndMiddle() const
Call the display lists for the top elements and middle contours.
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
Store arrays of triangles to be used to create display lists.
TRIANGLE_LIST * m_layer_bot_segment_ends
TRIANGLE_LIST * m_layer_top_segment_ends
TRIANGLE_LIST * m_layer_bot_triangles
TRIANGLE_LIST * m_layer_top_triangles
std::mutex m_middle_layer_lock
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
bool IsLayersSizeValid()
Check if the vertex arrays of the layers are as expected.
TRIANGLE_LIST * m_layer_middle_contourns_quads
Container to manage a vector of triangles.
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
const float * GetVertexPointer() const
Get the array of vertices.
SFVEC3F_VECTOR m_normals
normals array
unsigned int GetNormalsSize() const
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
void AddNormal(const SFVEC3F &aN1, const SFVEC3F &aN2, const SFVEC3F &aN3)
unsigned int GetVertexSize() const
SFVEC3F_VECTOR m_vertexs
vertex array
const float * GetNormalsPointer() const
Get the array of normals.
void Reserve_More(unsigned int aNrReservedTriangles, bool aReserveNormals)
Reserve more triangles.
std::vector< SFVEC3F > SFVEC3F_VECTOR
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44