------------------------------------------------------------------------------
| 1035 | |
| 1036 | //------------------------------------------------------------------------------ |
| 1037 | int vtkTriangleTile::Refine(vtkSimpleCellTessellator* tess, vtkTriangleTile* res) |
| 1038 | { |
| 1039 | // The output will contain a maximum of 4 vtkTriangleTiles |
| 1040 | int i, index; |
| 1041 | int numTriangleCreated = 0; |
| 1042 | |
| 1043 | double edgeSplitList[3]; |
| 1044 | vtkIdType ptId = 0; |
| 1045 | int l, r; |
| 1046 | |
| 1047 | if (this->SubdivisionLevel < tess->GetMaxSubdivisionLevel()) |
| 1048 | { |
| 1049 | // loop over edges |
| 1050 | for (i = 0, index = 0; i < 3; i++) |
| 1051 | { |
| 1052 | // we have to calculate mid point between edge TRIANGLE_EDGES_TABLE[i][0] |
| 1053 | // and TRIANGLE_EDGES_TABLE[i][1] |
| 1054 | l = TRIANGLE_EDGES_TABLE[i][0]; |
| 1055 | r = TRIANGLE_EDGES_TABLE[i][1]; |
| 1056 | |
| 1057 | edgeSplitList[i] = tess->EdgeTable->CheckEdge(this->PointId[l], this->PointId[r], ptId); |
| 1058 | |
| 1059 | // On previous step we made sure to prepare the hash table |
| 1060 | assert("check: edge table prepared" && edgeSplitList[i] != -1); |
| 1061 | |
| 1062 | // Build the case table |
| 1063 | if (edgeSplitList[i]) |
| 1064 | { |
| 1065 | index |= 1 << i; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | if (index) |
| 1070 | { |
| 1071 | // That mean at least one edge was split and thus index != 0 |
| 1072 | signed char* cases = **(vtkTessellatorTriangleCases + index); |
| 1073 | |
| 1074 | for (; cases[0] > -1; cases += 3) |
| 1075 | { |
| 1076 | for (int j = 0; j < 3; j++) |
| 1077 | { |
| 1078 | res[numTriangleCreated].CopyPoint(j, this, cases[j]); |
| 1079 | // res[numTriangleCreated].SetPointId( j, this->PointId[cases[j]] ); |
| 1080 | // res[numTriangleCreated].SetVertex( j, this->Vertex[cases[j]] ); |
| 1081 | } |
| 1082 | // update number of triangles |
| 1083 | numTriangleCreated++; |
| 1084 | } |
| 1085 | // Insert edges from new triangle into hash table: |
| 1086 | for (int k = 0; k < numTriangleCreated; k++) |
| 1087 | { |
| 1088 | res[k].SubdivisionLevel = this->SubdivisionLevel + 1; |
| 1089 | tess->InsertEdgesIntoEdgeTable(res[k]); |
| 1090 | } |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | if (numTriangleCreated == 0) |
no test coverage detected