| 36 | } |
| 37 | |
| 38 | int vtkTextureMapToPlane::RequestData(vtkInformation* vtkNotUsed(request), |
| 39 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 40 | { |
| 41 | // get the info objects |
| 42 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 43 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 44 | |
| 45 | // get the input and output |
| 46 | vtkDataSet* input = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 47 | vtkDataSet* output = vtkDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 48 | |
| 49 | double tcoords[2]; |
| 50 | vtkIdType numPts; |
| 51 | vtkFloatArray* newTCoords; |
| 52 | vtkIdType i; |
| 53 | int j; |
| 54 | double proj, minProj, axis[3], sAxis[3], tAxis[3]; |
| 55 | int dir = 0; |
| 56 | double s, t, sSf, tSf, p[3]; |
| 57 | int abort = 0; |
| 58 | vtkIdType progressInterval; |
| 59 | |
| 60 | vtkDebugMacro(<< "Generating texture coordinates!"); |
| 61 | |
| 62 | // First, copy the input to the output as a starting point |
| 63 | output->CopyStructure(input); |
| 64 | |
| 65 | if ((numPts = input->GetNumberOfPoints()) < 3 && this->AutomaticPlaneGeneration) |
| 66 | { |
| 67 | vtkErrorMacro(<< "Not enough points for automatic plane mapping\n"); |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | // Allocate texture data |
| 72 | // |
| 73 | newTCoords = vtkFloatArray::New(); |
| 74 | newTCoords->SetName("Texture Coordinates"); |
| 75 | newTCoords->SetNumberOfComponents(2); |
| 76 | newTCoords->SetNumberOfTuples(numPts); |
| 77 | progressInterval = numPts / 20 + 1; |
| 78 | |
| 79 | // Compute least squares plane if on automatic mode; otherwise use |
| 80 | // normal specified or plane specified |
| 81 | // |
| 82 | if (this->AutomaticPlaneGeneration && |
| 83 | (this->Origin[0] == 0.0 && this->Origin[1] == 0.0 && this->Origin[2] == 0.0 && |
| 84 | this->Point1[0] == 0.0 && this->Point1[1] == 0.0 && this->Point1[2] == 0.0)) |
| 85 | { |
| 86 | this->ComputeNormal(output); |
| 87 | |
| 88 | vtkMath::Normalize(this->Normal); |
| 89 | |
| 90 | // Now project each point onto plane generating s,t texture coordinates |
| 91 | // |
| 92 | // Create local s-t coordinate system. Need to find the two axes on |
| 93 | // the plane and encompassing all the points. Hence use the bounding |
| 94 | // box as a reference. |
| 95 | // |
nothing calls this directly
no test coverage detected