KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wrlfacet.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) 2016 Cirilo Bernardo <[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
25
26
27#ifndef WRLFACET_H
28#define WRLFACET_H
29
30#include <list>
31#include <vector>
32#include "wrltypes.h"
34
35
36class SGNODE;
37
38class FACET
39{
40public:
41 FACET();
42
43 void Init();
44 bool HasMinPoints();
45 bool HasColors();
46
50 void AddVertex( WRLVEC3F& aVertex, int aIndex );
51
58 void AddColor( const SGCOLOR& aColor );
59
67 float CalcFaceNormal();
68
69 void Renormalize( float aMaxValue );
70
77 void CalcVertexNormal( int aIndex, std::list< FACET* >& aFacetList, float aCreaseAngle );
78
85 bool GetWeightedNormal( int aIndex, WRLVEC3F& aNorm );
86
92 bool GetFaceNormal( WRLVEC3F& aNorm );
93
102 bool GetData( std::vector< WRLVEC3F >& aVertexList, std::vector< WRLVEC3F >& aNormalsList,
103 std::vector< SGCOLOR >& aColorsList, WRL1_ORDER aVertexOrder );
104
106 {
107 return maxIdx;
108 }
109
114 void CollectVertices( std::vector< std::list< FACET* > >& aFacetList );
115
116private:
117 std::vector< WRLVEC3F > vertices; // vertices of the facet
118 std::vector< SGCOLOR > colors; // per-vertex/per-face color (if any)
119 std::vector< int > indices; // index of each vertex
120
121 WRLVEC3F face_normal; // normal of this facet
122 std::vector< WRLVEC3F > norms; // per-vertex normals
123 std::vector< WRLVEC3F > vnweight; // angle weighted per vertex normal
124
125 int maxIdx; // maximum index used
126};
127
128
129class SHAPE
130{
131public:
133
134 FACET* NewFacet();
135 SGNODE* CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrder,
136 float aCreaseLimit = 0.74317, bool isVRML2 = false );
137
138private:
139 std::list< FACET* > facets;
140};
141
142#endif // WRLFACET_H
WRLVEC3F face_normal
Definition wrlfacet.h:121
std::vector< SGCOLOR > colors
Definition wrlfacet.h:118
std::vector< WRLVEC3F > vnweight
Definition wrlfacet.h:123
bool GetFaceNormal(WRLVEC3F &aNorm)
Retrieve the normal for this facet.
Definition wrlfacet.cpp:441
bool HasMinPoints()
Definition wrlfacet.cpp:169
void Renormalize(float aMaxValue)
Definition wrlfacet.cpp:659
std::vector< WRLVEC3F > vertices
Definition wrlfacet.h:117
int maxIdx
Definition wrlfacet.h:125
bool GetWeightedNormal(int aIndex, WRLVEC3F &aNorm)
Retrieve the angle weighted normal for the given vertex index.
Definition wrlfacet.cpp:408
float CalcFaceNormal()
Calculate the normal to the facet assuming a CCW orientation and perform the calculation of the angle...
Definition wrlfacet.cpp:208
bool HasColors()
Definition wrlfacet.cpp:178
void CollectVertices(std::vector< std::list< FACET * > > &aFacetList)
Add a pointer to this object at each position within aFacetList referenced by the internal vertex ind...
Definition wrlfacet.cpp:638
void AddVertex(WRLVEC3F &aVertex, int aIndex)
Add the vertex and its associated index to the internal list of polygon vertices.
Definition wrlfacet.cpp:187
std::vector< WRLVEC3F > norms
Definition wrlfacet.h:122
std::vector< int > indices
Definition wrlfacet.h:119
void CalcVertexNormal(int aIndex, std::list< FACET * > &aFacetList, float aCreaseAngle)
Calculate the weighted normal for the given vertex.
Definition wrlfacet.cpp:325
int GetMaxIndex()
Definition wrlfacet.h:105
void AddColor(const SGCOLOR &aColor)
Add the given RGB color to the internal list.
Definition wrlfacet.cpp:200
void Init()
Definition wrlfacet.cpp:154
bool GetData(std::vector< WRLVEC3F > &aVertexList, std::vector< WRLVEC3F > &aNormalsList, std::vector< SGCOLOR > &aColorsList, WRL1_ORDER aVertexOrder)
Package the internal data as triangles with corresponding per-vertex normals.
Definition wrlfacet.cpp:458
The base class of all Scene Graph nodes.
Definition sg_node.h:71
An abstract shape on 2D plane.
Definition shape.h:124
FACET * NewFacet()
Definition wrlfacet.cpp:691
SGNODE * CalcShape(SGNODE *aParent, SGNODE *aColor, WRL1_ORDER aVertexOrder, float aCreaseLimit=0.74317, bool isVRML2=false)
Definition wrlfacet.cpp:699
std::list< FACET * > facets
Definition wrlfacet.h:139
collects header files for all SG* wrappers and the API
declares some compound types used for VRML
WRL1_ORDER
Definition wrltypes.h:110
glm::vec3 WRLVEC3F
Definition wrltypes.h:184