| 181 | } |
| 182 | |
| 183 | void vtkWebGLPolyData::SetLine(float* _points, int _numberOfPoints, int* _index, int _numberOfIndex, |
| 184 | unsigned char* _colors, int maxSize) |
| 185 | { |
| 186 | this->webGlType = wLINES; |
| 187 | |
| 188 | vtkWebGLDataSet* obj; |
| 189 | while (!this->Internal->Parts.empty()) |
| 190 | { |
| 191 | obj = this->Internal->Parts.back(); |
| 192 | this->Internal->Parts.pop_back(); |
| 193 | obj->Delete(); |
| 194 | } |
| 195 | |
| 196 | short* index; |
| 197 | int div = maxSize * 2; |
| 198 | if (_numberOfPoints < div) |
| 199 | { |
| 200 | index = new short[_numberOfIndex]; |
| 201 | for (int i = 0; i < _numberOfIndex; i++) |
| 202 | index[i] = (short)((unsigned int)_index[i]); |
| 203 | obj = vtkWebGLDataSet::New(); |
| 204 | obj->SetPoints(_points, _numberOfPoints); |
| 205 | obj->SetIndexes(index, _numberOfIndex); |
| 206 | obj->SetColors(_colors); |
| 207 | obj->SetMatrix(this->Matrix); |
| 208 | this->Internal->Parts.push_back(obj); |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | int total = _numberOfIndex; |
| 213 | int curr = 0; |
| 214 | int size = 0; |
| 215 | |
| 216 | while (curr < total) |
| 217 | { |
| 218 | if (div + curr > total) |
| 219 | size = total - curr; |
| 220 | else |
| 221 | size = div; |
| 222 | |
| 223 | float* points = new float[size * 3]; |
| 224 | unsigned char* colors = new unsigned char[size * 4]; |
| 225 | short* indexes = new short[size]; |
| 226 | |
| 227 | for (int j = 0; j < size; j++) |
| 228 | { |
| 229 | indexes[j] = j; |
| 230 | |
| 231 | points[j * 3 + 0] = _points[_index[curr + j] * 3 + 0]; |
| 232 | points[j * 3 + 1] = _points[_index[curr + j] * 3 + 1]; |
| 233 | points[j * 3 + 2] = _points[_index[curr + j] * 3 + 2]; |
| 234 | |
| 235 | colors[j * 4 + 0] = _colors[_index[curr + j] * 4 + 0]; |
| 236 | colors[j * 4 + 1] = _colors[_index[curr + j] * 4 + 1]; |
| 237 | colors[j * 4 + 2] = _colors[_index[curr + j] * 4 + 2]; |
| 238 | colors[j * 4 + 3] = _colors[_index[curr + j] * 4 + 3]; |
| 239 | } |
| 240 | curr += size; |