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

Method initFilamentColors_

source/MRIOExtras/MR3mf.cpp:1183–1215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1181}
1182
1183void ThreeMFLoader::initFilamentColors_()
1184{
1185 if ( filamentInited_ )
1186 return;
1187 filamentInited_ = true;
1188 const Json::Value* foundProjSettings{ nullptr };
1189 for ( const auto& [path, json] : jsonDocuments_ )
1190 {
1191 if ( pathFromUtf8( path ).stem() == "project_settings" )
1192 {
1193 foundProjSettings = &json;
1194 break;
1195 }
1196 }
1197 if ( !foundProjSettings )
1198 return;
1199 const auto& projSettings = *foundProjSettings;
1200 if ( !projSettings["filament_colour"].isArray() )
1201 return;
1202 const auto& fColors = projSettings["filament_colour"];
1203 filamentColors_.reserve( fColors.size() );
1204 for ( int i = 0; i < int( fColors.size() ); ++i )
1205 {
1206 if ( !fColors[i].isString() )
1207 continue;
1208 auto colorRes = parseColor( fColors[i].asString() );
1209 if ( !colorRes.has_value() )
1210 continue;
1211 filamentColors_.emplace_back( std::move( *colorRes ) );
1212 }
1213 if ( filamentColors_.size() != fColors.size() )
1214 filamentColors_.clear();
1215}
1216
1217void Node::initDefaultFillament_( ThreeMFLoader& loader )
1218{

Callers

nothing calls this directly

Calls 5

pathFromUtf8Function · 0.85
parseColorFunction · 0.70
reserveMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected