<commit_before>/*
   For more information, please see: http://software.sci.utah.edu

   The MIT License

   Copyright (c) 2008 Scientific Computing and Imaging Institute,
   University of Utah.


   Permission is hereby granted, free of charge, to any person obtaining a
   copy of this software and associated documentation files (the "Software"),
   to deal in the Software without restriction, including without limitation
   the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included
   in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   DEALINGS IN THE SOFTWARE.
*/

/**
  \file    VolumeDataset.h
  \author  <NAME>
           SCI Institute
           University of Utah
  \version 1.0
  \date    August 2008
*/


#pragma once

#ifndef VOLUMEDATASET_H
#define VOLUMEDATASET_H

#include "../StdTuvokDefines.h"
#include <string>
#include "TransferFunction1D.h"
#include "TransferFunction2D.h"
#include "../IO/UVF/UVF.h"
#include "../Basics/Vectors.h"

typedef VECTOR2<UINT64> UINT64VECTOR2;
typedef VECTOR3<UINT64> UINT64VECTOR3;
typedef VECTOR4<UINT64> UINT64VECTOR4;

class VolumeDataset;

/// A wrapper around UVF data to provide easy access to 3D-only data.  UVF data
/// is n-dimensional, making it hard to work with directly.
class VolumeDatasetInfo {
  public:
    VolumeDatasetInfo() : m_pVolumeDataBlock(NULL) {}

    void SetRescaleFactors(const DOUBLEVECTOR3& vfRescale) {
      m_vfRescale[0] = vfRescale[0];
      m_vfRescale[1] = vfRescale[1];
      m_vfRescale[2] = vfRescale[2];
    }
    DOUBLEVECTOR3 GetRescaleFactors() const {
      return DOUBLEVECTOR3(m_vfRescale[0], m_vfRescale[1], m_vfRescale[2]);
    }

    UINT64VECTOR3 GetBrickCount(const UINT64 iLOD) const;
    UINT64VECTOR3 GetBrickSize(const UINT64 iLOD,
                               const UINT64VECTOR3& vBrick) const;
    FLOATVECTOR3 GetEffectiveBrickSize(const UINT64 iLOD,
                                       const UINT64VECTOR3& vBrick) const;
    UINT64VECTOR3 GetDomainSize(const UINT64 iLOD=0) const;
    UINT64VECTOR3 GetMaxBrickSize() const;
    UINT64VECTOR3 GetBrickOverlapSize() const;
    UINT64 GetLODLevelCount() const;
    DOUBLEVECTOR3 GetScale() const;
    bool ContainsData(const UINT64 iLOD, const UINT64VECTOR3& vBrick,
                      double fIsoval) const;
    bool ContainsData(const UINT64 iLOD, const UINT64VECTOR3& vBrick,
                      double fMin, double fMax) const;
    bool ContainsData(const UINT64 iLOD, const UINT64VECTOR3& vBrick,
                      double fMin, double fMax,
                      double fMinGrad, double fMaxGrad) const;

    void SetRescaleFactorsND(std::vector<double> vfRescale) {
      m_vfRescale = vfRescale;
    }
    const std::vector<double>& GetRescaleFactorsND() const {
      return m_vfRescale;
    }

    const std::vector<UINT64>& GetBrickCountND(const std::vector<UINT64>& vLOD) const;
    const std::vector<UINT64>& GetBrickSizeND(const std::vector<UINT64>& vLOD,
                                              const std::vector<UINT64>& vBrick) const;
    const std::vector<UINT64>& GetDomainSizeND() const;
    const std::vector<UINT64>& GetMaxBrickSizeND() const;
    const std::vector<UINT64>& GetBrickOverlapSizeND() const;
    const std::vector<UINT64>& GetLODLevelCountND() const;
    const std::vector<double> GetScaleND() const;

    /// \todo change this if we want to support color data
    UINT64 GetBitWidth() const {
      return m_pVolumeDataBlock->ulElementBitSize[0][0];
    }

    /// \todo change this if we want to support color data
    UINT64 GetComponentCount() const {return 1;}

    bool GetIsSigned() const {return m_pVolumeDataBlock->bSignedElement[0][0];}
    bool GetIsFloat() const {
      return GetBitWidth() != m_pVolumeDataBlock->ulElementBitSize[0][0];
    }
    bool IsSameEndianess() const {return m_bIsSameEndianess;}

  private:
    VolumeDatasetInfo(RasterDataBlock* pVolumeDataBlock,
                      MaxMinDataBlock* pMaxMinData, bool bIsSameEndianess);
    RasterDataBlock*         m_pVolumeDataBlock;
    MaxMinDataBlock*         m_pMaxMinData;

    // read from the dataset
    bool                        m_bIsSameEndianess;
    std::vector<UINT64VECTOR3>  m_aDomainSize;
    UINT64VECTOR3               m_aOverlap;
    UINT64VECTOR3               m_aMaxBrickSize;
    UINT64                      m_iLODLevel;
    DOUBLEVECTOR3               m_aScale;
    std::vector<UINT64VECTOR3>  m_vaBrickCount;
    std::vector< std::vector< std::vector<std::vector<UINT64VECTOR3> > > >m_vvaBrickSize;
    std::vector< std::vector< std::vector<std::vector<InternalMaxMinElemen> > > >m_vvaMaxMin;

    // set externally by the user
    std::vector<double>         m_vfRescale;

    friend class VolumeDataset;
};

class VolumeDataset {
public:
  VolumeDataset(const std::string& strFilename, bool bVerify);
  VolumeDataset();
  virtual ~VolumeDataset();<commit_msg>Virtualize methods so subclasses can override them.<commit_after>/*
   For more information, please see: http://software.sci.utah.edu

   The MIT License

   Copyright (c) 2008 Scientific Computing and Imaging Institute,
   University of Utah.


   Permission is hereby granted, free of charge, to any person obtaining a
   copy of this software and associated documentation files (the "Software"),
   to deal in the Software without restriction, including without limitation
   the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included
   in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   DEALINGS IN THE SOFTWARE.
*/

/**
  \file    VolumeDataset.h
  \author  <NAME>
           SCI Institute
           University of Utah
  \version 1.0
  \date    August 2008
*/


#pragma once

#ifndef VOLUMEDATASET_H
#define VOLUMEDATASET_H

#include "../StdTuvokDefines.h"
#include <string>
#include "TransferFunction1D.h"
#include "TransferFunction2D.h"
#include "../IO/UVF/UVF.h"
#include "../Basics/Vectors.h"

typedef VECTOR2<UINT64> UINT64VECTOR2;
typedef VECTOR3<UINT64> UINT64VECTOR3;
typedef VECTOR4<UINT64> UINT64VECTOR4;

class VolumeDataset;

/// A wrapper around UVF data to provide easy access to 3D-only data.  UVF data
/// is n-dimensional, making it hard to work with directly.
class VolumeDatasetInfo {
  public:
    VolumeDatasetInfo() : m_pVolumeDataBlock(NULL) {}

    void SetRescaleFactors(const DOUBLEVECTOR3& vfRescale) {
      m_vfRescale[0] = vfRescale[0];
      m_vfRescale[1] = vfRescale[1];
      m_vfRescale[2] = vfRescale[2];
    }
    DOUBLEVECTOR3 GetRescaleFactors() const {
      return DOUBLEVECTOR3(m_vfRescale[0], m_vfRescale[1], m_vfRescale[2]);
    }

    virtual UINT64VECTOR3 GetBrickCount(const UINT64 iLOD) const;
    virtual UINT64VECTOR3 GetBrickSize(const UINT64 iLOD,
                                       const UINT64VECTOR3& vBrick) const;
    virtual FLOATVECTOR3 GetEffectiveBrickSize(const UINT64 iLOD,
                                               const UINT64VECTOR3& vBrick) const;
    virtual UINT64VECTOR3 GetDomainSize(const UINT64 iLOD=0) const;
    UINT64VECTOR3 GetMaxBrickSize() const;
    UINT64VECTOR3 GetBrickOverlapSize() const;
    UINT64 GetLODLevelCount() const;
    DOUBLEVECTOR3 GetScale() const;
    virtual bool ContainsData(const UINT64 iLOD, const UINT64VECTOR3& vBrick,
                              double fIsoval) const;
    virtual bool ContainsData(const UINT64 iLOD, const UINT64VECTOR3& vBrick,
                              double fMin, double fMax) const;
    virtual bool ContainsData(const UINT64 iLOD, const UINT64VECTOR3& vBrick,
                              double fMin, double fMax,
                              double fMinGrad, double fMaxGrad) const;

    void SetRescaleFactorsND(std::vector<double> vfRescale) {
      m_vfRescale = vfRescale;
    }
    const std::vector<double>& GetRescaleFactorsND() const {
      return m_vfRescale;
    }

    const std::vector<UINT64>& GetBrickCountND(const std::vector<UINT64>& vLOD) const;
    const std::vector<UINT64>& GetBrickSizeND(const std::vector<UINT64>& vLOD,
                                              const std::vector<UINT64>& vBrick) const;
    const std::vector<UINT64>& GetDomainSizeND() const;
    const std::vector<UINT64>& GetMaxBrickSizeND() const;
    const std::vector<UINT64>& GetBrickOverlapSizeND() const;
    const std::vector<UINT64>& GetLODLevelCountND() const;
    const std::vector<double> GetScaleND() const;

    /// \todo change this if we want to support color data
    UINT64 GetBitWidth() const {
      return m_pVolumeDataBlock->ulElementBitSize[0][0];
    }

    /// \todo change this if we want to support color data
    UINT64 GetComponentCount() const {return 1;}

    bool GetIsSigned() const {return m_pVolumeDataBlock->bSignedElement[0][0];}
    bool GetIsFloat() const {
      return GetBitWidth() != m_pVolumeDataBlock->ulElementBitSize[0][0];
    }
    bool IsSameEndianess() const {return m_bIsSameEndianess;}

  protected:
    UINT64VECTOR3               m_aOverlap;
    // set externally by the user
    std::vector<double>         m_vfRescale;

  private:
    VolumeDatasetInfo(RasterDataBlock* pVolumeDataBlock,
                      MaxMinDataBlock* pMaxMinData, bool bIsSameEndianess);
    RasterDataBlock*         m_pVolumeDataBlock;
    MaxMinDataBlock*         m_pMaxMinData;

    // read from the dataset
    bool                        m_bIsSameEndianess;
    std::vector<UINT64VECTOR3>  m_aDomainSize;
    UINT64VECTOR3               m_aMaxBrickSize;
    UINT64                      m_iLODLevel;
    DOUBLEVECTOR3               m_aScale;
    std::vector<UINT64VECTOR3>  m_vaBrickCount;
    std::vector< std::vector< std::vector<std::vector<UINT64VECTOR3> > > >m_vvaBrickSize;
    std::vector< std::vector< std::vector<std::vector<InternalMaxMinElemen> > > >m_vvaMaxMin;

    friend class VolumeDataset;
};

class VolumeDataset {
public:
  VolumeDataset(const std::string& strFilename, bool bVerify);
  VolumeDataset();
  virtual ~VolumeDataset();
{'fraction_non_alphanumeric': 0.08096879695925042, 'fraction_numerical': 0.024573499513833644, 'mean_word_length': 3.1872686898593634, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1155790', 'n_tokens_mistral': 3638, 'n_tokens_neox': 3471, 'n_words': 1007}