Been looking into working around an offset bug. As the bug report describes, some offset routines just flat out assign 0.001 as a tolerance without any calculation. Upon investigation, it appears that most, if not all, the settng of tolerance values are predicated upon the new tolerance being greater/looser than the current tolerance. That makes sense as the greatest calculated tolerance should be the final tolerance. However that practice makes it hard to 'tighten' tolerances. Here is what I think is the minimum work flow to tighten tolerances.
Here is the output of that code:
Opinions? Thoughts?
C++:
int main (int /*argc*/, char** /*argv*/)
{
try
{
auto report = [](const TopoDS_Shape &s)
{
std::cout << std::setprecision(std::numeric_limits<double>::digits10 + 1) << std::fixed
<< " Max Face Tolerance: " << BRep_Tool::MaxTolerance(s, TopAbs_FACE) << std::endl
<< " Max Edge Tolerance: " << BRep_Tool::MaxTolerance(s, TopAbs_EDGE) << std::endl
<< "Max Vertex Tolerance: " << BRep_Tool::MaxTolerance(s, TopAbs_VERTEX) << std::endl
<< std::endl;
};
auto inShape = readShape("../../offsetTolerance3.brep");
assert(!inShape.IsNull());
std::cout << std::endl << "Input Shape:" << std::endl;
report(inShape);
ShapeFix_ShapeTolerance tighten;
tighten.SetTolerance(inShape, Precision::Confusion(), TopAbs_WIRE);
std::cout << std::endl << "Tighten Shape:" << std::endl;
report(inShape);
std::cout << std::endl << "Output Shape:" << std::endl;
if (!ShapeFix::SameParameter(inShape, false))
throw std::runtime_error("Shape fix failed");
report(inShape);
std::cout << std::endl << "Program finished normally" << std::endl;
}
catch (const Standard_Failure &error)
{
std::cout << "OCC Error: " << error.GetMessageString() << std::endl;
}
catch (const std::exception &error)
{
std::cout << "My Error: " << error.what() << std::endl;
}
return 0;
}
Here is the output of that code:
Code:
Input Shape:
Max Face Tolerance: 0.0000001000000000
Max Edge Tolerance: 0.0010000000000000
Max Vertex Tolerance: 0.0010000000000000
Tighten Shape:
Max Face Tolerance: 0.0000001000000000
Max Edge Tolerance: 0.0000001000000000
Max Vertex Tolerance: 0.0000001000000000
Output Shape:
Max Face Tolerance: 0.0000001000000000
Max Edge Tolerance: 0.0000001344348549
Max Vertex Tolerance: 0.0000001344348549
Opinions? Thoughts?