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

Method writeTri

source/MRMesh/MRMeshSave.cpp:306–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306bool BinaryStlSaver::writeTri( const Triangle3f& tri )
307{
308 // perform normal computation in double-precision to get exactly the same single-precision result on all platforms
309 const Vector3d ad = applyDouble( settings_.xf, tri[0] );
310 const Vector3d bd = applyDouble( settings_.xf, tri[1] );
311 const Vector3d cd = applyDouble( settings_.xf, tri[2] );
312 const Vector3f normal( cross( bd - ad, cd - ad ).normalized() );
313 const Vector3f ap( ad );
314 const Vector3f bp( bd );
315 const Vector3f cp( cd );
316
317 out_.write( (const char*)&normal, 12 );
318 out_.write( (const char*)&ap, 12 );
319 out_.write( (const char*)&bp, 12 );
320 out_.write( (const char*)&cp, 12 );
321 std::uint16_t attr{ 0 };
322 out_.write( ( const char* )&attr, 2 );
323 ++savedNumTris_;
324 return (bool)out_;
325}
326
327bool BinaryStlSaver::updateHeadCounter()
328{

Callers 1

toBinaryStlFunction · 0.80

Calls 4

applyDoubleFunction · 0.85
crossFunction · 0.70
normalizedMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected