Skip to content
Snippets Groups Projects
Select Git revision
  • 9014ea2d5694cb64068d73ce17866489c362b934
  • 5.4 default protected
  • 5.5
  • dev/5.5
  • dev/5.4
  • dev/5.3_downgrade
  • feature/experimenttime_hack
  • 5.3 protected
  • _IntenSelect5.3
  • IntenSelect5.3
  • 4.27 protected
  • 4.26 protected
  • 5.0 protected
  • 4.22 protected
  • 4.21 protected
  • UE5.4-2024.1
  • UE5.4-2024.1-rc1
  • UE5.3-2023.1-rc3
  • UE5.3-2023.1-rc2
  • UE5.3-2023.1-rc
20 results

BP_ButtonWidget.uasset

Blame
  • transfer_function.hpp 2.07 KiB
    #ifndef TRANSFER_FUNCTION_HPP
    #define TRANSFER_FUNCTION_HPP
    
    #include <cstdint>
    #include <fstream>
    #include <string>
    
    #include <vtk_jsoncpp.h>
    #include <vtkColorTransferFunction.h>
    #include <vtkPiecewiseFunction.h>
    #include <vtkSmartPointer.h>
    
    namespace rt
    {
    class transfer_function
    {
    public:
      explicit transfer_function  (const std::string& filepath)
      {
        std::ifstream   file_stream(filepath);
        vtkJson::Reader reader;
        vtkJson::Value  root;
        reader.parse(file_stream, root);
    
        auto opacity = root[0]["Points"   ];
        auto color   = root[0]["RGBPoints"];
        auto space   = root[0]["ColorSpace"].asString();
    
        for (auto i = 0; i < opacity.size(); i += 4)
          opacity_function->AddPoint(
            opacity[i    ].asFloat(), 
            opacity[i + 1].asFloat());
        for (auto i = 0; i < color.size(); i += 4)
          color_function->AddRGBPoint(
            color  [i    ].asFloat(), 
            color  [i + 1].asFloat(), 
            color  [i + 2].asFloat(), 
            color  [i + 3].asFloat());
    
        if      (space == "RGB")
          color_function->SetColorSpace(VTK_CTF_RGB);
        else if (space == "HSV")
          color_function->SetColorSpace(VTK_CTF_HSV);
        else if (space == "LAB")
          color_function->SetColorSpace(VTK_CTF_LAB);
        else if (space == "CIEDE2000")
          color_function->SetColorSpace(VTK_CTF_LAB_CIEDE2000);
        else if (space == "Diverging")
          color_function->SetColorSpace(VTK_CTF_DIVERGING);
        else if (space == "Step")
          color_function->SetColorSpace(VTK_CTF_STEP);
      }
      transfer_function           (const transfer_function&  that) = default;
      transfer_function           (      transfer_function&& temp) = default;
     ~transfer_function           ()                               = default;
      transfer_function& operator=(const transfer_function&  that) = default;
      transfer_function& operator=(      transfer_function&& temp) = default; 
    
      vtkSmartPointer<vtkPiecewiseFunction>     opacity_function = vtkSmartPointer<vtkPiecewiseFunction>    ::New();
      vtkSmartPointer<vtkColorTransferFunction> color_function   = vtkSmartPointer<vtkColorTransferFunction>::New();
    };
    }
    
    #endif