iMSTK
Interactive Medical Simulation Toolkit
imstkTexture.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "imstkTexture.h"
8 
9 namespace imstk
10 {
11 Texture::Texture(std::string path, Type type) :
12  m_type(type), m_path(path)
13 {
14 }
15 
16 Texture::Texture(std::shared_ptr<ImageData> imageTex, Type type) :
17  imageTexture(imageTex), m_type(type), m_path("")
18 {
19 }
20 
23 {
24  return m_type;
25 }
26 
29 {
30  FileType textureType = FileType::Unknown;
31 
32  std::string extString = m_path.substr(m_path.find_last_of(".") + 1);
33 
34  if (extString.empty() || m_path.find(".") == std::string::npos)
35  {
36  return textureType;
37  }
38 
39  if (extString == "bmp" || extString == "BMP")
40  {
41  textureType = FileType::Bmp;
42  }
43  else if (extString == "png" || extString == "PNG")
44  {
45  textureType = FileType::Png;
46  }
47  else if (extString == "jpg" || extString == "JPG"
48  || extString == "jpeg" || extString == "JPEG")
49  {
50  textureType = FileType::Jpg;
51  }
52  else if (extString == "dds" || extString == "DDS")
53  {
54  textureType = FileType::Dds;
55  }
56 
57  return textureType;
58 }
59 } // namespace imstk
Texture(std::string path="", Type type=Type::Diffuse)
Constructor.
Type
Texture type - determines filtering.
Definition: imstkTexture.h:30
Compound Geometry.
std::string m_path
Texture file path.
Definition: imstkTexture.h:168
Type getType() const
Get type.
FileType getFileType()
Get file extension.
Type m_type
Texture type.
Definition: imstkTexture.h:167