------------------------------------------------------------------------------
| 493 | |
| 494 | //------------------------------------------------------------------------------ |
| 495 | void vtkRandomAttributeGenerator::GenerateCellData(vtkCellData* outputCD, vtkIdType numCells) |
| 496 | { |
| 497 | if (this->GenerateCellScalars) |
| 498 | { |
| 499 | vtkDataArray* cellScalars = |
| 500 | this->GenerateData(this->DataType, numCells, this->NumberOfComponents, 0, |
| 501 | this->NumberOfComponents - 1, this->MinimumComponentValue, this->MaximumComponentValue); |
| 502 | const char* scalarsName = "RandomCellScalars"; |
| 503 | cellScalars->SetName(scalarsName); |
| 504 | outputCD->AddArray(cellScalars); |
| 505 | outputCD->SetActiveScalars(scalarsName); |
| 506 | cellScalars->Delete(); |
| 507 | } |
| 508 | if (this->GenerateCellVectors) |
| 509 | { |
| 510 | vtkDataArray* cellVectors = this->GenerateData( |
| 511 | this->DataType, numCells, 3, 0, 2, this->MinimumComponentValue, this->MaximumComponentValue); |
| 512 | const char* vectorsName = "RandomCellVectors"; |
| 513 | cellVectors->SetName(vectorsName); |
| 514 | outputCD->AddArray(cellVectors); |
| 515 | outputCD->SetActiveVectors(vectorsName); |
| 516 | cellVectors->Delete(); |
| 517 | } |
| 518 | if (this->GenerateCellNormals) |
| 519 | { |
| 520 | vtkDataArray* cellNormals = this->GenerateData( |
| 521 | this->DataType, numCells, 3, 0, 2, this->MinimumComponentValue, this->MaximumComponentValue); |
| 522 | double v[3]; |
| 523 | for (vtkIdType id = 0; id < numCells; id++) |
| 524 | { |
| 525 | cellNormals->GetTuple(id, v); |
| 526 | vtkMath::Normalize(v); |
| 527 | cellNormals->SetTuple(id, v); |
| 528 | } |
| 529 | const char* normalsName = "RandomCellNormals"; |
| 530 | cellNormals->SetName(normalsName); |
| 531 | outputCD->AddArray(cellNormals); |
| 532 | outputCD->SetActiveNormals(normalsName); |
| 533 | cellNormals->Delete(); |
| 534 | } |
| 535 | if (this->GenerateCellTensors) |
| 536 | { |
| 537 | vtkDataArray* cellTensors = this->GenerateData( |
| 538 | this->DataType, numCells, 9, 0, 5, this->MinimumComponentValue, this->MaximumComponentValue); |
| 539 | double t[9]; |
| 540 | for (vtkIdType id = 0; id < numCells; id++) |
| 541 | { |
| 542 | cellTensors->GetTuple(id, t); |
| 543 | t[6] = t[1]; // make sure the tensor is symmetric |
| 544 | t[7] = t[2]; |
| 545 | t[8] = t[4]; |
| 546 | cellTensors->SetTuple(id, t); |
| 547 | } |
| 548 | const char* tensorsName = "RandomCellTensors"; |
| 549 | cellTensors->SetName(tensorsName); |
| 550 | outputCD->AddArray(cellTensors); |
| 551 | outputCD->SetActiveTensors(tensorsName); |
| 552 | cellTensors->Delete(); |
no test coverage detected