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 The 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 <kicad_gl/kiglad.h> // Must be included first
29
34#include <vector>
35#include <mutex>
36
37
38typedef std::vector< SFVEC3F > SFVEC3F_VECTOR;
39
40
45{
46public:
47
52 TRIANGLE_LIST( unsigned int aNrReservedTriangles, bool aReserveNormals );
53
57 void Reserve_More( unsigned int aNrReservedTriangles, bool aReserveNormals );
58
59 void AddTriangle( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 );
60
61 void AddQuad( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3, const SFVEC3F& aV4 );
62
63 void AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 );
64
65 void AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3,
66 const SFVEC3F& aN4 );
67
73 const float* GetVertexPointer() const { return (const float *)&m_vertexs[0].x; }
74
80 const float* GetNormalsPointer() const { return (const float*) &m_normals[0].x; }
81
82 unsigned int GetVertexSize() const { return (unsigned int) m_vertexs.size(); }
83
84 unsigned int GetNormalsSize() const { return (unsigned int) m_normals.size(); }
85
86private:
89};
90
91
96{
97public:
103 explicit TRIANGLE_DISPLAY_LIST( unsigned int aNrReservedTriangles );
104
106
113
114
115 void AddToMiddleContours( const SHAPE_LINE_CHAIN& outlinePath, float zBot, float zTop,
116 double aBiuTo3Du, bool aInvertFaceDirection,
117 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
118
119 void AddToMiddleContours( const SHAPE_POLY_SET& aPolySet, float zBot, float zTop,
120 double aBiuTo3Du, bool aInvertFaceDirection,
121 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
122
123 void AddToMiddleContours( const std::vector< SFVEC2F >& aContourPoints, float zBot,
124 float zTop, bool aInvertFaceDirection,
125 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
126
128
134};
135
136
141{
142public:
152 OPENGL_RENDER_LIST( const TRIANGLE_DISPLAY_LIST& aLayerTriangles,
153 GLuint aTextureIndexForSegEnds, float aZBot, float aZTop );
154
159
163 void DrawTopAndMiddle() const;
164
168 void DrawBotAndMiddle() const;
169
173 void DrawTop() const;
174
178 void DrawBot() const;
179
183 void DrawMiddle() const;
184
188 void DrawAll( bool aDrawMiddle = true ) const;
189
198 void DrawCulled( bool aDrawMiddle,
199 const OPENGL_RENDER_LIST* aSubtractList = nullptr,
200 const OPENGL_RENDER_LIST* bSubtractList = nullptr,
201 const OPENGL_RENDER_LIST* cSubtractList = nullptr,
202 const OPENGL_RENDER_LIST* dSubtractList = nullptr ) const;
203
204 void ApplyScalePosition( float aZposition, float aZscale );
205 void ApplyScalePosition( OPENGL_RENDER_LIST* aOtherList );
206
208
209 void SetItIsTransparent( bool aSetTransparent );
210
211 float GetZBot() const { return m_zBot; }
212 float GetZTop() const { return m_zTop; }
213
214private:
215 GLuint generate_top_or_bot_seg_ends( const TRIANGLE_LIST* aTriangleContainer,
216 bool aIsNormalUp, GLuint aTextureId ) const;
217
218 GLuint generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
219 bool aIsNormalUp ) const;
220
221 GLuint generate_middle_triangles( const TRIANGLE_LIST* aTriangleContainer ) const;
222
223 void beginTransformation() const;
224 void endTransformation() const;
225
226 void setBlendfunction() const;
227
228private:
229 float m_zBot;
230 float m_zTop;
236
240
242};
243
244#endif // TRIANGLE_DISPLAY_LIST_H
GLuint generate_middle_triangles(const TRIANGLE_LIST *aTriangleContainer) const
float GetZBot() const
float GetZTop() const
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.
GLuint m_layer_middle_contours_quads
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.
OPENGL_RENDER_LIST(const TRIANGLE_DISPLAY_LIST &aLayerTriangles, GLuint aTextureIndexForSegEnds, float aZBot, float aZTop)
Create the display lists for a layer.
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
void AddToMiddleContours(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
TRIANGLE_LIST * m_layer_middle_contours_quads
TRIANGLE_LIST * m_layer_top_segment_ends
TRIANGLE_LIST * m_layer_bot_triangles
TRIANGLE_DISPLAY_LIST(unsigned int aNrReservedTriangles)
Initialize arrays with reserved triangles.
TRIANGLE_LIST * m_layer_top_triangles
bool IsLayersSizeValid()
Check if the vertex arrays of the layers are as expected.
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.
TRIANGLE_LIST(unsigned int aNrReservedTriangles, bool aReserveNormals)
void Reserve_More(unsigned int aNrReservedTriangles, bool aReserveNormals)
Reserve more triangles.
std::vector< SFVEC3F > SFVEC3F_VECTOR
glm::vec3 SFVEC3F
Definition xv3d_types.h:44