KiCad PCB EDA Suite
TRIANGLE_LIST Class Reference

Container to manage a vector of triangles. More...

#include <layer_triangles.h>

Public Member Functions

 TRIANGLE_LIST (unsigned int aNrReservedTriangles, bool aReserveNormals)
 
void Reserve_More (unsigned int aNrReservedTriangles, bool aReserveNormals)
 Reserve more triangles. More...
 
void AddTriangle (const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
 
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)
 
void AddNormal (const SFVEC3F &aN1, const SFVEC3F &aN2, const SFVEC3F &aN3, const SFVEC3F &aN4)
 
const float * GetVertexPointer () const
 Get the array of vertices. More...
 
const float * GetNormalsPointer () const
 Get the array of normals. More...
 
unsigned int GetVertexSize () const
 
unsigned int GetNormalsSize () const
 

Private Attributes

SFVEC3F_VECTOR m_vertexs
 vertex array More...
 
SFVEC3F_VECTOR m_normals
 normals array More...
 

Detailed Description

Container to manage a vector of triangles.

Definition at line 43 of file layer_triangles.h.

Constructor & Destructor Documentation

◆ TRIANGLE_LIST()

TRIANGLE_LIST::TRIANGLE_LIST ( unsigned int  aNrReservedTriangles,
bool  aReserveNormals 
)
Parameters
aNrReservedTrianglesis number of triangles expected to be used.
aReserveNormalsif you use normals, set it to bool to reserve space.

Definition at line 31 of file layer_triangles.cpp.

32 {
33  wxASSERT( aNrReservedTriangles > 0 );
34 
35  m_vertexs.clear();
36  m_normals.clear();
37 
38  m_vertexs.reserve( aNrReservedTriangles * 3 );
39 
40  if( aReserveNormals )
41  m_normals.reserve( aNrReservedTriangles * 3 );
42 }
SFVEC3F_VECTOR m_normals
normals array
SFVEC3F_VECTOR m_vertexs
vertex array

References m_normals, and m_vertexs.

Member Function Documentation

◆ AddNormal() [1/2]

void TRIANGLE_LIST::AddNormal ( const SFVEC3F aN1,
const SFVEC3F aN2,
const SFVEC3F aN3 
)

Definition at line 75 of file layer_triangles.cpp.

76 {
77  m_normals.push_back( aN1 );
78  m_normals.push_back( aN2 );
79  m_normals.push_back( aN3 );
80 }
SFVEC3F_VECTOR m_normals
normals array

References m_normals.

Referenced by TRIANGLE_DISPLAY_LIST::AddToMiddleContourns().

◆ AddNormal() [2/2]

void TRIANGLE_LIST::AddNormal ( const SFVEC3F aN1,
const SFVEC3F aN2,
const SFVEC3F aN3,
const SFVEC3F aN4 
)

Definition at line 82 of file layer_triangles.cpp.

84 {
85  m_normals.push_back( aN1 );
86  m_normals.push_back( aN2 );
87  m_normals.push_back( aN3 );
88 
89  m_normals.push_back( aN3 );
90  m_normals.push_back( aN4 );
91  m_normals.push_back( aN1 );
92 }
SFVEC3F_VECTOR m_normals
normals array

References m_normals.

◆ AddQuad()

void TRIANGLE_LIST::AddQuad ( const SFVEC3F aV1,
const SFVEC3F aV2,
const SFVEC3F aV3,
const SFVEC3F aV4 
)

Definition at line 54 of file layer_triangles.cpp.

56 {
57  m_vertexs.push_back( aV1 );
58  m_vertexs.push_back( aV2 );
59  m_vertexs.push_back( aV3 );
60 
61  m_vertexs.push_back( aV3 );
62  m_vertexs.push_back( aV4 );
63  m_vertexs.push_back( aV1 );
64 }
SFVEC3F_VECTOR m_vertexs
vertex array

References m_vertexs.

Referenced by RENDER_3D_OPENGL::addObjectTriangles(), TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), and RENDER_3D_OPENGL::generateCylinder().

◆ AddTriangle()

void TRIANGLE_LIST::AddTriangle ( const SFVEC3F aV1,
const SFVEC3F aV2,
const SFVEC3F aV3 
)

Definition at line 67 of file layer_triangles.cpp.

68 {
69  m_vertexs.push_back( aV1 );
70  m_vertexs.push_back( aV2 );
71  m_vertexs.push_back( aV3 );
72 }
SFVEC3F_VECTOR m_vertexs
vertex array

References m_vertexs.

Referenced by RENDER_3D_OPENGL::addObjectTriangles(), and RENDER_3D_OPENGL::addTopAndBottomTriangles().

◆ GetNormalsPointer()

const float* TRIANGLE_LIST::GetNormalsPointer ( ) const
inline

Get the array of normals.

Returns
a pointer to start of array of normals.

Definition at line 79 of file layer_triangles.h.

79 { return (const float*) &m_normals[0].x; }
SFVEC3F_VECTOR m_normals
normals array

References m_normals.

Referenced by OPENGL_RENDER_LIST::generate_middle_triangles().

◆ GetNormalsSize()

unsigned int TRIANGLE_LIST::GetNormalsSize ( ) const
inline

Definition at line 83 of file layer_triangles.h.

83 { return (unsigned int) m_normals.size(); }
SFVEC3F_VECTOR m_normals
normals array

References m_normals.

Referenced by OPENGL_RENDER_LIST::generate_middle_triangles(), OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(), and OPENGL_RENDER_LIST::generate_top_or_bot_triangles().

◆ GetVertexPointer()

const float* TRIANGLE_LIST::GetVertexPointer ( ) const
inline

Get the array of vertices.

Returns
a pointer to the start of array vertex.

Definition at line 72 of file layer_triangles.h.

72 { return (const float *)&m_vertexs[0].x; }
SFVEC3F_VECTOR m_vertexs
vertex array

References m_vertexs.

Referenced by OPENGL_RENDER_LIST::generate_middle_triangles(), OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(), and OPENGL_RENDER_LIST::generate_top_or_bot_triangles().

◆ GetVertexSize()

unsigned int TRIANGLE_LIST::GetVertexSize ( ) const
inline

◆ Reserve_More()

void TRIANGLE_LIST::Reserve_More ( unsigned int  aNrReservedTriangles,
bool  aReserveNormals 
)

Reserve more triangles.

Definition at line 45 of file layer_triangles.cpp.

46 {
47  m_vertexs.reserve( m_vertexs.size() + aNrReservedTriangles * 3 );
48 
49  if( aReserveNormals )
50  m_normals.reserve( m_normals.size() + aNrReservedTriangles * 3 );
51 }
SFVEC3F_VECTOR m_normals
normals array
SFVEC3F_VECTOR m_vertexs
vertex array

References m_normals, and m_vertexs.

Referenced by TRIANGLE_DISPLAY_LIST::AddToMiddleContourns().

Member Data Documentation

◆ m_normals

SFVEC3F_VECTOR TRIANGLE_LIST::m_normals
private

normals array

Definition at line 87 of file layer_triangles.h.

Referenced by AddNormal(), GetNormalsPointer(), GetNormalsSize(), Reserve_More(), and TRIANGLE_LIST().

◆ m_vertexs

SFVEC3F_VECTOR TRIANGLE_LIST::m_vertexs
private

vertex array

Definition at line 86 of file layer_triangles.h.

Referenced by AddQuad(), AddTriangle(), GetVertexPointer(), GetVertexSize(), Reserve_More(), and TRIANGLE_LIST().


The documentation for this class was generated from the following files: