Generate plane equations only once to avoid a lot of extra work
| 41 | #define VTK_DELTA 0.0001 |
| 42 | // Generate plane equations only once to avoid a lot of extra work |
| 43 | void vtkImplicitSelectionLoop::Initialize() |
| 44 | { |
| 45 | int i, numPts; |
| 46 | double x[3], xProj[3]; |
| 47 | |
| 48 | numPts = this->Loop->GetNumberOfPoints(); |
| 49 | this->Polygon->Points->SetDataTypeToDouble(); |
| 50 | this->Polygon->Points->SetNumberOfPoints(numPts); |
| 51 | |
| 52 | if (this->AutomaticNormalGeneration) |
| 53 | { |
| 54 | // Make sure points define a loop with a normal |
| 55 | vtkPolygon::ComputeNormal(this->Loop, this->Normal); |
| 56 | if (this->Normal[0] == 0.0 && this->Normal[1] == 0.0 && this->Normal[2] == 0.0) |
| 57 | { |
| 58 | vtkErrorMacro(<< "Cannot determine inside/outside of loop"); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // Determine origin point by taking average |
| 63 | this->Origin[0] = this->Origin[1] = this->Origin[2] = 0.0; |
| 64 | for (i = 0; i < numPts; i++) |
| 65 | { |
| 66 | this->Loop->GetPoint(i, x); |
| 67 | this->Origin[0] += x[0]; |
| 68 | this->Origin[1] += x[1]; |
| 69 | this->Origin[2] += x[2]; |
| 70 | } |
| 71 | this->Origin[0] /= numPts; |
| 72 | this->Origin[1] /= numPts; |
| 73 | this->Origin[2] /= numPts; |
| 74 | |
| 75 | // Project points onto plane generating new coordinates |
| 76 | for (i = 0; i < numPts; i++) |
| 77 | { |
| 78 | this->Loop->GetPoint(i, x); |
| 79 | vtkPlane::ProjectPoint(x, this->Origin, this->Normal, xProj); |
| 80 | this->Polygon->Points->SetPoint(i, xProj); |
| 81 | } |
| 82 | |
| 83 | this->Polygon->GetBounds(this->Bounds); |
| 84 | this->DeltaX = VTK_DELTA * (this->Bounds[1] - this->Bounds[0]); |
| 85 | this->DeltaY = VTK_DELTA * (this->Bounds[3] - this->Bounds[2]); |
| 86 | this->DeltaZ = VTK_DELTA * (this->Bounds[5] - this->Bounds[4]); |
| 87 | this->InitializationTime.Modified(); |
| 88 | } |
| 89 | |
| 90 | //------------------------------------------------------------------------------ |
| 91 | // Evaluate plane equations. Return smallest absolute value. |
no test coverage detected