------------------------------------------------------------------------------
| 64 | |
| 65 | //------------------------------------------------------------------------------ |
| 66 | int vtkAttributesErrorMetric::RequiresEdgeSubdivision( |
| 67 | double* leftPoint, double* midPoint, double* rightPoint, double alpha) |
| 68 | { |
| 69 | assert("pre: leftPoint_exists" && leftPoint != nullptr); |
| 70 | assert("pre: midPoint_exists" && midPoint != nullptr); |
| 71 | assert("pre: rightPoint_exists" && rightPoint != nullptr); |
| 72 | assert("pre: clamped_alpha" && alpha > 0 && alpha < 1); |
| 73 | |
| 74 | int result; |
| 75 | double ae; |
| 76 | vtkGenericAttributeCollection* ac; |
| 77 | |
| 78 | this->ComputeSquareAbsoluteAttributeTolerance(); |
| 79 | |
| 80 | constexpr int ATTRIBUTE_OFFSET = 6; |
| 81 | |
| 82 | ac = this->DataSet->GetAttributes(); |
| 83 | vtkGenericAttribute* a = ac->GetAttribute(ac->GetActiveAttribute()); |
| 84 | |
| 85 | if (this->GenericCell->IsAttributeLinear(a)) |
| 86 | { |
| 87 | // don't need to do anything: |
| 88 | ae = 0; |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | if (ac->GetActiveComponent() >= 0) |
| 93 | { |
| 94 | int i = ac->GetAttributeIndex(ac->GetActiveAttribute()) + ac->GetActiveComponent() + |
| 95 | ATTRIBUTE_OFFSET; |
| 96 | double tmp = leftPoint[i] + alpha * (rightPoint[i] - leftPoint[i]) - midPoint[i]; |
| 97 | ae = tmp * tmp; |
| 98 | } |
| 99 | else // module of the vector |
| 100 | { |
| 101 | int i = ac->GetAttributeIndex(ac->GetActiveAttribute()) + ATTRIBUTE_OFFSET; |
| 102 | int j = 0; |
| 103 | int c = ac->GetNumberOfComponents(); |
| 104 | double tmp; |
| 105 | #if 0 |
| 106 | // If x and y are two vectors, we compute: ||x|-|y|| |
| 107 | double interpolatedValueMod=0; |
| 108 | double midValueMod=0; |
| 109 | while(j<c) |
| 110 | { |
| 111 | tmp=leftPoint[i+j]+alpha*(rightPoint[i+j]-leftPoint[i+j]); |
| 112 | interpolatedValueMod+=tmp*tmp; |
| 113 | tmp=midPoint[i+j]; |
| 114 | midValueMod+=tmp*tmp; |
| 115 | ++j; |
| 116 | } |
| 117 | tmp=sqrt(midValueMod)-sqrt(interpolatedValueMod); |
| 118 | ae=tmp*tmp; |
| 119 | #else |
| 120 | // If x and y are two vectors, we compute: |x-y| |
| 121 | // We should compute ||x|-|y|| but |x-y| is usually enough |
| 122 | // and tends to produce less degenerated edges. |
| 123 | // Remind that: ||x|-|y||<=|x-y| |
nothing calls this directly
no test coverage detected