Uses clipping approach to build the polygon edges
| 805 | |
| 806 | // Uses clipping approach to build the polygon edges |
| 807 | int vtkImageToPolyDataFilter::BuildEdges(vtkUnsignedCharArray* vtkNotUsed(pixels), int dims[3], |
| 808 | double origin[3], double spacing[3], vtkUnsignedCharArray* pointDescr, vtkPolyData* edges) |
| 809 | { |
| 810 | double x[3]; |
| 811 | int i, j, edgeCount; |
| 812 | vtkIdType ptId, p0, p1, p2, p3, startId, attrId, id[8], pts[4]; |
| 813 | vtkCellArray* edgeConn = edges->GetLines(); |
| 814 | vtkPoints* points = edges->GetPoints(); |
| 815 | |
| 816 | // Build edges around perimeter of image. Note that the point ids |
| 817 | // The first four points are the image corners and are inserted and |
| 818 | // marked so that they can't be moved during smoothing. |
| 819 | points->InsertPoint(0, origin); |
| 820 | pointDescr->InsertValue(0, 1); |
| 821 | |
| 822 | // Keep track of the polygons that use each edge as well as associated |
| 823 | // intersection points on edge (if any) |
| 824 | this->EdgeTable = vtkEdgeTable::New(); |
| 825 | this->EdgeTable->InitEdgeInsertion(dims[0] * dims[1], 1); |
| 826 | |
| 827 | this->EdgeUseTable = vtkEdgeTable::New(); |
| 828 | this->EdgeUseTable->InitEdgeInsertion(dims[0] * dims[1], 1); |
| 829 | |
| 830 | this->EdgeUses = vtkIntArray::New(); |
| 831 | this->EdgeUses->SetNumberOfComponents(2); |
| 832 | this->EdgeUses->Allocate(4 * dims[0] * dims[1], dims[0] * dims[1]); |
| 833 | |
| 834 | // Generate corner points of image |
| 835 | x[0] = origin[0] + (dims[0] - 1) * spacing[0]; |
| 836 | x[1] = origin[1]; |
| 837 | x[2] = 0.0; |
| 838 | points->InsertPoint(1, x); |
| 839 | pointDescr->InsertValue(1, 1); |
| 840 | |
| 841 | x[0] = origin[0] + (dims[0] - 1) * spacing[0]; |
| 842 | x[1] = origin[1] + (dims[1] - 1) * spacing[1]; |
| 843 | x[2] = 0.0; |
| 844 | points->InsertPoint(2, x); |
| 845 | pointDescr->InsertValue(2, 1); |
| 846 | |
| 847 | x[0] = origin[0]; |
| 848 | x[1] = origin[1] + (dims[1] - 1) * spacing[1]; |
| 849 | x[2] = 0.0; |
| 850 | points->InsertPoint(3, x); |
| 851 | pointDescr->InsertValue(3, 1); |
| 852 | |
| 853 | // Let's create perimeter edges - bottom x edge |
| 854 | startId = 0; |
| 855 | x[1] = origin[1]; |
| 856 | for (i = 0; i < (dims[0] - 1); i++) |
| 857 | { |
| 858 | p0 = i; |
| 859 | p1 = i + 1; |
| 860 | if (this->Visited[p0] != this->Visited[p1]) |
| 861 | { |
| 862 | x[0] = origin[0] + i * spacing[0] + 0.5 * spacing[0]; |
| 863 | ptId = points->InsertNextPoint(x); |
| 864 | this->EdgeTable->InsertEdge(p0, p1, ptId); |
no test coverage detected