------------------------------------------------------------------------------ Description : Set the geometric accuracy with a value relative to the bounding box of the dataset. Internally compute the absolute tolerance. For instance 0.01 will give better result than 0.1. \pre valid_range_value: value>0 && value<1 \pre ds_exists: ds!=0
| 52 | // \pre valid_range_value: value>0 && value<1 |
| 53 | // \pre ds_exists: ds!=0 |
| 54 | void vtkGeometricErrorMetric::SetRelativeGeometricTolerance(double value, vtkGenericDataSet* ds) |
| 55 | { |
| 56 | assert("pre: valid_range_value" && value > 0 && value < 1); |
| 57 | assert("pre: ds_exists" && ds != nullptr); |
| 58 | |
| 59 | double bounds[6]; |
| 60 | ds->GetBounds(bounds); |
| 61 | double smallest; |
| 62 | double length; |
| 63 | smallest = bounds[1] - bounds[0]; |
| 64 | length = bounds[3] - bounds[2]; |
| 65 | if (length < smallest || smallest == 0.0) |
| 66 | { |
| 67 | smallest = length; |
| 68 | } |
| 69 | length = bounds[5] - bounds[4]; |
| 70 | if (length < smallest || smallest == 0.0) |
| 71 | { |
| 72 | smallest = length; |
| 73 | } |
| 74 | length = ds->GetLength(); |
| 75 | if (length < smallest || smallest == 0.0) |
| 76 | { |
| 77 | smallest = length; |
| 78 | } |
| 79 | if (smallest == 0) |
| 80 | { |
| 81 | smallest = 1; |
| 82 | } |
| 83 | double tmp = value * smallest; |
| 84 | this->SmallestSize = smallest; |
| 85 | std::cout << "this->SmallestSize=" << this->SmallestSize << endl; |
| 86 | this->Relative = 1; |
| 87 | tmp = tmp * tmp; |
| 88 | |
| 89 | if (this->AbsoluteGeometricTolerance != tmp) |
| 90 | { |
| 91 | this->AbsoluteGeometricTolerance = tmp; |
| 92 | this->Modified(); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | #define VTK_DISTANCE_LINE_POINT |
| 97 |