26 lines
570 B
C++
26 lines
570 B
C++
|
|
#include "vde/brep/tolerance.h"
|
||
|
|
#include "vde/brep/brep.h"
|
||
|
|
|
||
|
|
namespace vde::brep {
|
||
|
|
|
||
|
|
// Global tolerance config
|
||
|
|
static ToleranceConfig g_global_tolerance;
|
||
|
|
|
||
|
|
const ToleranceConfig& ToleranceConfig::global() {
|
||
|
|
return g_global_tolerance;
|
||
|
|
}
|
||
|
|
|
||
|
|
void ToleranceConfig::set_global(const ToleranceConfig& cfg) {
|
||
|
|
g_global_tolerance = cfg;
|
||
|
|
}
|
||
|
|
|
||
|
|
double model_tolerance(const BrepModel& body) {
|
||
|
|
auto bb = body.bounds();
|
||
|
|
if (bb.min().x() > bb.max().x()) return 1e-6;
|
||
|
|
|
||
|
|
double extent = bb.extent().norm();
|
||
|
|
return adaptive_tolerance(extent);
|
||
|
|
}
|
||
|
|
|
||
|
|
} // namespace vde::brep
|