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

Function postImportObject

source/MRMesh/MRObjectLoad.cpp:83–105  ·  view source on GitHub ↗

Prepare object after it has been imported from external format (not .mru)

Source from the content-addressed store, hash-verified

81
82// Prepare object after it has been imported from external format (not .mru)
83void postImportObject( const std::shared_ptr<Object> &o, const std::filesystem::path &filename )
84{
85 const auto extension = utf8string( filename.extension() );
86
87 // TODO: get format id from the format registry
88 const auto sourceFormatId = !extension.empty() ? toLower( extension.substr( 1 ) ) : "unknown";
89 const auto sourceFormatTag = fmt::format( ".source-format:{}", sourceFormatId );
90 o->addTag( sourceFormatTag );
91
92 if ( std::shared_ptr<ObjectMesh> mesh = std::dynamic_pointer_cast< ObjectMesh >( o ) )
93 {
94 // Detect flat shading needed
95 bool flat;
96 if ( SceneSettings::getDefaultShadingMode() == SceneSettings::ShadingMode::AutoDetect )
97 flat = extension == ".step" || extension == ".stp" ||
98 ( mesh->mesh() && detectFlatShading( *mesh->mesh().get() ) );
99 else
100 flat = SceneSettings::getDefaultShadingMode() == SceneSettings::ShadingMode::Flat;
101 mesh->setVisualizeProperty( flat, MeshVisualizePropertyType::FlatShading, ViewportMask::all() );
102 }
103 for ( const std::shared_ptr<Object>& child : o->children() )
104 postImportObject( child, filename );
105}
106
107} // namespace
108

Callers 2

loadObjectFromFileFunction · 0.85

Calls 7

utf8stringFunction · 0.85
toLowerFunction · 0.85
detectFlatShadingFunction · 0.85
addTagMethod · 0.80
setVisualizePropertyMethod · 0.80
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected