<commit_before>// This file is part of the AliceVision project.
// This Source Code Form is subject to the terms of the Mozilla Public License,
// v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#include "viewIO.hpp"

#include <aliceVision/sfm/utils/uid.hpp>
#include <aliceVision/camera/camera.hpp>
#include <aliceVision/image/io.hpp>

#include <stdexcept>

namespace aliceVision {
namespace sfm {

void updateIncompleteView(View& view)
{
  int width, height;
  std::map<std::string, std::string> metadata;

  image::readImageMetadata(view.getImagePath(), width, height, metadata);

  view.setWidth(width);
  view.setHeight(height);

  // reset metadata
  if(view.getMetadata().empty())
    view.setMetadata(metadata);

  // reset viewId
  view.setViewId(computeUID(view));

  if(view.getPoseId() == UndefinedIndexT)
  {
    // check if the rig poseId id is defined
    if(view.isPartOfRig())
    {
      ALICEVISION_LOG_ERROR("Error: Can't find poseId for'" << stlplus::filename_part(view.getImagePath()) << "' marked as part of a rig." << std::endl);
      throw std::invalid_argument("Error: Can't find poseId for'" + stlplus::filename_part(view.getImagePath()) + "' marked as part of a rig.");<commit_msg>[sfm] fix : Don't try to update a complete View<commit_after>// This file is part of the AliceVision project.
// This Source Code Form is subject to the terms of the Mozilla Public License,
// v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#include "viewIO.hpp"

#include <aliceVision/sfm/utils/uid.hpp>
#include <aliceVision/camera/camera.hpp>
#include <aliceVision/image/io.hpp>

#include <stdexcept>

namespace aliceVision {
namespace sfm {

void updateIncompleteView(View& view)
{
  // check if the view is complete
  if(view.getViewId() != UndefinedIndexT &&
     view.getIntrinsicId() != UndefinedIndexT &&
     view.getPoseId() == view.getViewId() &&
     view.getHeight() > 0 &&
     view.getWidth() >  0)
    return;

  int width, height;
  std::map<std::string, std::string> metadata;

  image::readImageMetadata(view.getImagePath(), width, height, metadata);

  view.setWidth(width);
  view.setHeight(height);

  // reset metadata
  if(view.getMetadata().empty())
    view.setMetadata(metadata);

  // reset viewId
  view.setViewId(computeUID(view));

  if(view.getPoseId() == UndefinedIndexT)
  {
    // check if the rig poseId id is defined
    if(view.isPartOfRig())
    {
      ALICEVISION_LOG_ERROR("Error: Can't find poseId for'" << stlplus::filename_part(view.getImagePath()) << "' marked as part of a rig." << std::endl);
      throw std::invalid_argument("Error: Can't find poseId for'" + stlplus::filename_part(view.getImagePath()) + "' marked as part of a rig.");
{'fraction_non_alphanumeric': 0.13969035890218157, 'fraction_numerical': 0.003518648838845883, 'mean_word_length': 4.049733570159858, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5300416', 'n_tokens_mistral': 954, 'n_tokens_neox': 926, 'n_words': 256}