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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef TRIANGLE_DISPLAY_LIST_H
22#define TRIANGLE_DISPLAY_LIST_H
23
24#include <kicad_gl/kiglad.h> // Must be included first
25
30#include <vector>
31#include <mutex>
32
33
34
39{
40public:
41
46 TRIANGLE_LIST( unsigned int aNrReservedTriangles, bool aReserveNormals );
47
51 void Reserve_More( unsigned int aNrReservedTriangles, bool aReserveNormals );
52
53 void AddTriangle( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 );
54
55 void AddQuad( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3, const SFVEC3F& aV4 );
56
57 void AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 );
58
59 void AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3,
60 const SFVEC3F& aN4 );
61
67 const float* GetVertexPointer() const { return (const float *)&m_vertexs[0].x; }
68
74 const float* GetNormalsPointer() const { return (const float*) &m_normals[0].x; }
75
76 unsigned int GetVertexSize() const { return (unsigned int) m_vertexs.size(); }
77
78 unsigned int GetNormalsSize() const { return (unsigned int) m_normals.size(); }
79
80private:
81 std::vector<SFVEC3F> m_vertexs;
82 std::vector<SFVEC3F> m_normals;
83};
84
85
90{
91public:
97 explicit TRIANGLE_DISPLAY_LIST( unsigned int aNrReservedTriangles );
98
100
107
108
109 void AddToMiddleContours( const SHAPE_LINE_CHAIN& outlinePath, float zBot, float zTop,
110 double aBiuTo3Du, bool aInvertFaceDirection,
111 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
112
113 void AddToMiddleContours( const SHAPE_POLY_SET& aPolySet, float zBot, float zTop,
114 double aBiuTo3Du, bool aInvertFaceDirection,
115 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
116
117 void AddToMiddleContours( const std::vector< SFVEC2F >& aContourPoints, float zBot,
118 float zTop, bool aInvertFaceDirection,
119 const BVH_CONTAINER_2D* aThroughHoles = nullptr );
120
122
128};
129
130
135{
136public:
146 OPENGL_RENDER_LIST( const TRIANGLE_DISPLAY_LIST& aLayerTriangles,
147 GLuint aTextureIndexForSegEnds, float aZBot, float aZTop );
148
153
157 void DrawTopAndMiddle() const;
158
162 void DrawBotAndMiddle() const;
163
167 void DrawTop() const;
168
172 void DrawBot() const;
173
177 void DrawMiddle() const;
178
182 void DrawAll( bool aDrawMiddle = true ) const;
183
192 void DrawCulled( bool aDrawMiddle,
193 const OPENGL_RENDER_LIST* aSubtractList = nullptr,
194 const OPENGL_RENDER_LIST* bSubtractList = nullptr,
195 const OPENGL_RENDER_LIST* cSubtractList = nullptr,
196 const OPENGL_RENDER_LIST* dSubtractList = nullptr ) const;
197
198 void ApplyScalePosition( float aZposition, float aZscale );
199 void ApplyScalePosition( OPENGL_RENDER_LIST* aOtherList );
200
202
203 void SetItIsTransparent( bool aSetTransparent );
204
205 float GetZBot() const { return m_zBot; }
206 float GetZTop() const { return m_zTop; }
207
208private:
209 GLuint generate_top_or_bot_seg_ends( const TRIANGLE_LIST* aTriangleContainer,
210 bool aIsNormalUp, GLuint aTextureId ) const;
211
212 GLuint generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
213 bool aIsNormalUp ) const;
214
215 GLuint generate_middle_triangles( const TRIANGLE_LIST* aTriangleContainer ) const;
216
217 void beginTransformation() const;
218 void endTransformation() const;
219
220 void setBlendfunction() const;
221
222private:
223 float m_zBot;
224 float m_zTop;
230
234
236};
237
238#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.
std::vector< SFVEC3F > m_vertexs
vertex array
unsigned int GetNormalsSize() const
std::vector< SFVEC3F > m_normals
normals array
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
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.
glm::vec3 SFVEC3F
Definition xv3d_types.h:40