MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / getToIntConverter

Function getToIntConverter

source/MRMesh/MRPrecisePredicates3.cpp:367–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367ConvertToIntVector getToIntConverter( const Box3d& box )
368{
369 Vector3d center{ box.center() };
370 auto bbSize = box.size();
371 double maxDim = std::max( { bbSize[0],bbSize[1],bbSize[2] } );
372
373 // range is selected so that after centering each integer point is within [-max/2; +max/2] range,
374 // so the difference of any two points will be within [-max; +max] range
375 double invRange = cRangeIntMax / maxDim;
376
377 return [invRange, center] ( const Vector3f& v )
378 {
379 // perform intermediate operations in double for better precision
380 const auto d = ( Vector3d{ v } - center ) * invRange;
381 // and round to the nearest integer instead of truncating to zero
382 return Vector3i( (int)std::round( d.x ), (int)std::round( d.y ), (int)std::round( d.z ) );
383 };
384}
385
386ConvertToFloatVector getToFloatConverter( const Box3d& box )
387{

Callers 8

TESTFunction · 0.85
selfBooleanFunction · 0.85
rayMeshIntersectAll_Function · 0.85
getVectorConvertersFunction · 0.85
precisePredicatesFunction · 0.85
meshSpacePredicatesFunction · 0.85
terrainTriangulationFunction · 0.85
uniteManyMeshesFunction · 0.85

Calls 4

maxFunction · 0.85
roundFunction · 0.85
centerMethod · 0.45
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68