libs/yocto/yocto_scene.cpp
// Checks for validity of the scene->
Checks for validity of the scene->
Checks for validity of the scene - >
vector<string> scene_validation(const scene_model* scene, bool notextures) {
  auto errs        = vector<string>();
  auto check_names = [&errs](const auto& vals, const string& base) {
    auto used = unordered_map<string, int>();
    used.reserve(vals.size());
    for (auto& value : vals) used[value->name] += 1;
    for (auto& [name, used] : used) {
      if (name == "") {
        errs.push_back("empty " + base + " name");
      } else if (used > 1) {
        errs.push_back("duplicated " + base + " name " + name);
      }
    }
  };
  auto check_empty_textures = [&errs](const vector<scene_texture*>& vals) {
    for (auto value : vals) {
      if (value->hdr.empty() && value->ldr.empty()) {
        errs.push_back("empty texture " + value->name);
      }
    }
  };
  check_names(scene->cameras, "camera");
  check_names(scene->shapes, "shape");
  check_names(scene->instances, "instance");
  check_names(scene->textures, "texture");
  check_names(scene->environments, "environment");
  if (!notextures) check_empty_textures(scene->textures);
  return errs;
}
vector < string > scene_validation ( const scene_model * scene , bool notextures ) { auto errs = vector < string > ( ) ; auto check_names = [ & errs ] ( const auto & vals , const string & base ) { auto used = unordered_map < string , int > ( ) ; used . reserve ( vals . size ( ) ) ; for ( auto & value : vals ) used [ value -> name ] += 1 ; for ( auto & [ name , used ] : used ) { if ( name == " " ) { errs . push_back ( " " + base + " " ) ; } else if ( used > 1 ) { errs . push_back ( " " + base + " " + name ) ; } } } ; auto check_empty_textures = [ & errs ] ( const vector < scene_texture * > & vals ) { for ( auto value : vals ) { if ( value -> hdr . empty ( ) && value -> ldr . empty ( ) ) { errs . push_back ( " " + value -> name ) ; } } } ; check_names ( scene -> cameras , " " ) ; check_names ( scene -> shapes , " " ) ; check_names ( scene -> instances , " " ) ; check_names ( scene -> textures , " " ) ; check_names ( scene -> environments , " " ) ; if ( ! notextures ) check_empty_textures ( scene -> textures ) ; return errs ; }
Checks for validity of the scene->
Checks for validity of the scene - >