1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkPolygonBuilder.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 // .NAME vtkPolygonBuilder -builds a polygon from a set of abstract triangles (represented by index triplets) 16 // 17 // .SECTION Description 18 // The polygon output is the boundary of the union of the triangles. 19 // It is assumed that the input triangles form a simple polygon without 20 // internal vertices. 21 // The algorithm is quadratic to the input size, but 22 // can be sped up easily by improving the FindEdge() function. It is 23 // currently used to compute polygon for slicing. 24 // 25 26 #ifndef vtkPolygonBuilder_h 27 #define vtkPolygonBuilder_h 28 29 #include "vtkCommonMiscModule.h" // For export macro 30 #include <vector> //for private data members 31 #include "vtkType.h" //for basic types 32 #include <cstddef> //for size_t 33 #include "vtkObject.h" 34 class vtkIdList; 35 36 class VTKCOMMONMISC_EXPORT vtkPolygonBuilder 37 { 38 public: 39 vtkPolygonBuilder(); 40 void Reset(); 41 bool InsertTriangle(vtkIdType* abc); 42 void GetPolygon(vtkIdList* poly) const; 43 44 private: 45 typedef size_t VertexRef; 46 struct Vertex 47 { 48 VertexRef Next; 49 vtkIdType Vert; VertexVertex50 Vertex(VertexRef next, vtkIdType vert):Next(next), Vert(vert){} 51 }; 52 53 bool FindEdge(vtkIdType a, vtkIdType b, VertexRef& v) const; 54 VertexRef Insert(VertexRef i, vtkIdType vertexId); GetVertexId(VertexRef i)55 vtkIdType GetVertexId(VertexRef i) const { return this->Poly[i].Vert;} GetNextVertex(VertexRef i)56 VertexRef GetNextVertex(VertexRef i) const { return this->Poly[i].Next;} 57 58 std::vector<Vertex> Poly; 59 }; 60 61 #endif 62 // VTK-HeaderTest-Exclude: vtkPolygonBuilder.h 63