Blender  V2.93
WSFillGrid.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 #include "WSFillGrid.h"
23 #include "WEdge.h"
24 
25 namespace Freestyle {
26 
28 {
29  if (!_winged_edge || !_grid) {
30  return;
31  }
32 
33  vector<WShape *> wshapes = _winged_edge->getWShapes();
34  vector<WVertex *> fvertices;
35  vector<Vec3r> vectors;
36  vector<WFace *> faces;
37 
38  for (vector<WShape *>::const_iterator it = wshapes.begin(); it != wshapes.end(); ++it) {
39  faces = (*it)->GetFaceList();
40 
41  for (vector<WFace *>::const_iterator f = faces.begin(); f != faces.end(); ++f) {
42  (*f)->RetrieveVertexList(fvertices);
43 
44  for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv) {
45  vectors.emplace_back((*wv)->GetVertex());
46  }
47 
48  // occluder will be deleted by the grid
49  Polygon3r *occluder = new Polygon3r(vectors, (*f)->GetNormal());
50  occluder->setId(_polygon_id++);
51  occluder->userdata = (void *)(*f);
52  _grid->insertOccluder(occluder);
53  vectors.clear();
54  fvertices.clear();
55  }
56  faces.clear();
57  }
58 }
59 
60 } /* namespace Freestyle */
Classes to define a Winged Edge data structure.
Class to fill in a grid from a SceneGraph (uses only the WingedEdge structures)
void setId(unsigned id)
Definition: Polygon.h:130
void insertOccluder(Polygon3r *occluder)
Definition: Grid.cpp:154
vector< WShape * > & getWShapes()
Definition: WEdge.h:1369
static char faces[256]
inherits from class Rep
Definition: AppCanvas.cpp:32