------------------------------------------------------------------------------
| 410 | |
| 411 | //------------------------------------------------------------------------------ |
| 412 | void vtkRandomAttributeGenerator::GeneratePointData(vtkPointData* outputPD, vtkIdType numPts) |
| 413 | { |
| 414 | if (this->GeneratePointScalars) |
| 415 | { |
| 416 | vtkDataArray* ptScalars = this->GenerateData(this->DataType, numPts, this->NumberOfComponents, |
| 417 | 0, this->NumberOfComponents - 1, this->MinimumComponentValue, this->MaximumComponentValue); |
| 418 | const char* scalarsName = "RandomPointScalars"; |
| 419 | ptScalars->SetName(scalarsName); |
| 420 | outputPD->AddArray(ptScalars); |
| 421 | outputPD->SetActiveScalars(scalarsName); |
| 422 | ptScalars->Delete(); |
| 423 | } |
| 424 | if (this->GeneratePointVectors) |
| 425 | { |
| 426 | vtkDataArray* ptVectors = this->GenerateData( |
| 427 | this->DataType, numPts, 3, 0, 2, this->MinimumComponentValue, this->MaximumComponentValue); |
| 428 | const char* vectorsName = "RandomPointVectors"; |
| 429 | ptVectors->SetName(vectorsName); |
| 430 | outputPD->AddArray(ptVectors); |
| 431 | outputPD->SetActiveVectors(vectorsName); |
| 432 | ptVectors->Delete(); |
| 433 | } |
| 434 | if (this->GeneratePointNormals) |
| 435 | { |
| 436 | vtkDataArray* ptNormals = this->GenerateData( |
| 437 | this->DataType, numPts, 3, 0, 2, this->MinimumComponentValue, this->MaximumComponentValue); |
| 438 | double v[3]; |
| 439 | for (vtkIdType id = 0; id < numPts; id++) |
| 440 | { |
| 441 | ptNormals->GetTuple(id, v); |
| 442 | vtkMath::Normalize(v); |
| 443 | ptNormals->SetTuple(id, v); |
| 444 | } |
| 445 | const char* normalsName = "RandomPointNormals"; |
| 446 | ptNormals->SetName(normalsName); |
| 447 | outputPD->AddArray(ptNormals); |
| 448 | outputPD->SetActiveNormals(normalsName); |
| 449 | ptNormals->Delete(); |
| 450 | } |
| 451 | if (this->GeneratePointTensors) |
| 452 | { |
| 453 | // fill in 6 components, and then shift them around to make them symmetric |
| 454 | vtkDataArray* ptTensors = this->GenerateData( |
| 455 | this->DataType, numPts, 9, 0, 5, this->MinimumComponentValue, this->MaximumComponentValue); |
| 456 | double t[9]; |
| 457 | for (vtkIdType id = 0; id < numPts; id++) |
| 458 | { |
| 459 | ptTensors->GetTuple(id, t); |
| 460 | t[8] = t[3]; // make sure the tensor is symmetric |
| 461 | t[3] = t[1]; |
| 462 | t[6] = t[2]; |
| 463 | t[7] = t[5]; |
| 464 | ptTensors->SetTuple(id, t); |
| 465 | } |
| 466 | const char* tensorsName = "RandomPointTensors"; |
| 467 | ptTensors->SetName(tensorsName); |
| 468 | outputPD->AddArray(ptTensors); |
| 469 | outputPD->SetActiveTensors(tensorsName); |
no test coverage detected