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

Method loadFromFile_

source/MRViewer/MRToolsLibrary.cpp:333–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333bool GcodeToolsLibrary::loadFromFile_( const std::string& filename )
334{
335 const auto folderPath = getFolder_();
336 if ( folderPath.empty() )
337 return false;
338
339 std::error_code ec;
340
341 const auto meshPath = folderPath / ( filename + ".mrmesh" );
342 if ( std::filesystem::exists( meshPath, ec ) )
343 {
344 auto loadRes = MeshLoad::fromMrmesh( meshPath );
345 if ( !loadRes )
346 return false;
347
348 toolMesh_ = std::make_shared<ObjectMesh>();
349 toolMesh_->setName( filename );
350 toolMesh_->setMesh( std::make_shared<Mesh>( *loadRes ) );
351
352 endMillTool_.reset();
353
354 selectedFileName_ = filename;
355 return true;
356 }
357
358 const auto jsonPath = folderPath / ( filename + ".json" );
359 if ( std::filesystem::exists( jsonPath, ec ) )
360 {
361 auto loadRes = deserializeJsonValue( jsonPath );
362 if ( !loadRes )
363 return false;
364
365 EndMillTool tool;
366 if ( auto res = deserializeFromJson( *loadRes, tool ); !res )
367 return false;
368
369 toolMesh_ = std::make_shared<ObjectMesh>();
370 toolMesh_->setName( filename );
371 toolMesh_->setMesh( std::make_shared<Mesh>( tool.toMesh() ) );
372
373 endMillTool_ = std::make_shared<EndMillTool>( tool );
374
375 selectedFileName_ = filename;
376 return true;
377 }
378
379 return false;
380}
381
382}

Callers

nothing calls this directly

Calls 7

fromMrmeshFunction · 0.85
deserializeJsonValueFunction · 0.85
setMeshMethod · 0.80
toMeshMethod · 0.80
deserializeFromJsonFunction · 0.70
emptyMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected