------------------------------------------------------------------------------
| 2369 | |
| 2370 | //------------------------------------------------------------------------------ |
| 2371 | void vtkSimpleCellTessellator::Triangulate(vtkGenericAdaptorCell* cell, |
| 2372 | vtkGenericAttributeCollection* att, vtkDoubleArray* points, vtkCellArray* cellArray, |
| 2373 | vtkPointData* internalPd) |
| 2374 | { |
| 2375 | assert("pre: cell_exists" && cell != nullptr); |
| 2376 | assert("pre: valid_dimension" && cell->GetDimension() == 2); |
| 2377 | assert("pre: att_exists" && att != nullptr); |
| 2378 | assert("pre: points_exists" && points != nullptr); |
| 2379 | assert("pre: cellArray_exists" && cellArray != nullptr); |
| 2380 | assert("pre: internalPd_exists" && internalPd != nullptr); |
| 2381 | |
| 2382 | int j; |
| 2383 | |
| 2384 | if (cell->GetType() != VTK_HIGHER_ORDER_TRIANGLE) |
| 2385 | { |
| 2386 | // build a linear polygon, call tessellate() on it and iterate over each triangle |
| 2387 | // by sending it to the tessellator |
| 2388 | |
| 2389 | // int *faceVerts=cell->GetFaceArray(index); // implicit |
| 2390 | // int numVerts=cell->GetNumberOfVerticesOnFace(index); |
| 2391 | int numVerts = cell->GetNumberOfBoundaries(0); |
| 2392 | |
| 2393 | this->Polygon->PointIds->SetNumberOfIds(numVerts); |
| 2394 | this->Polygon->Points->SetNumberOfPoints(numVerts); |
| 2395 | |
| 2396 | this->AllocatePointIds(cell->GetNumberOfBoundaries(0)); |
| 2397 | cell->GetPointIds(this->PointIds); |
| 2398 | double* pcoords = cell->GetParametricCoords(); |
| 2399 | |
| 2400 | int i = 0; |
| 2401 | while (i < numVerts) |
| 2402 | { |
| 2403 | this->Polygon->PointIds->SetId(i, i); // this->PointIds[i] |
| 2404 | this->Polygon->Points->SetPoint(i, pcoords + 3 * i); // should be global? |
| 2405 | ++i; |
| 2406 | } |
| 2407 | |
| 2408 | this->Polygon->TriangulateLocalIds(0, this->TriangleIds); |
| 2409 | |
| 2410 | // now iterate over any sub-triangle and call triangulateface on it |
| 2411 | vtkIdType pts[3]; |
| 2412 | vtkIdType ids[3]; |
| 2413 | int c = this->TriangleIds->GetNumberOfIds(); |
| 2414 | i = 0; |
| 2415 | while (i < c) |
| 2416 | { |
| 2417 | // Build the next sub-triangle |
| 2418 | j = 0; |
| 2419 | while (j < 3) |
| 2420 | { |
| 2421 | pts[j] = this->TriangleIds->GetId(i); |
| 2422 | // Get the point Ids (global) |
| 2423 | ids[j] = this->PointIds[pts[j]]; |
| 2424 | ++j; |
| 2425 | ++i; |
| 2426 | } |
| 2427 | |
| 2428 | // |
no test coverage detected