IFEM  90A354
TextureProperties.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef TEXTURE_PROPERTIES_H_
15 #define TEXTURE_PROPERTIES_H_
16 
17 #include "Function.h"
18 #include "MatVec.h"
19 #include <map>
20 
21 namespace tinyxml2 { class XMLElement; }
22 class Vec3;
23 
24 
27 public:
30  void parse (const tinyxml2::XMLElement* elem);
31 
33  void printLog() const;
34 
39  bool getProperty(const std::string& name, const Vec3& X, double& val) const;
40 
43  bool hasProperty(const std::string& name) const;
44 
45 protected:
47  struct Property {
48  double min;
49  double max;
51  bool prescaled = false;
52  };
53 
54  std::map<std::string, Property> properties;
55 };
56 
57 
59 class PropertyFunc : public RealFunc {
60 public:
64  PropertyFunc(const std::string& prop, const TextureProperties& props)
65  : m_prop(prop), m_props(props)
66  {}
67 
69  virtual ~PropertyFunc() {}
70 
73  double evaluate(const Vec3& X) const override
74  {
75  double val;
76  m_props.getProperty(m_prop, X, val);
77  return val;
78  }
79 
80 protected:
81  std::string m_prop;
83 };
84 
85 #endif
General functions with arbitrary argument and value type.
Global algebraic operations on index 1-based matrices and vectors.
Class to use a property as a function.
Definition: TextureProperties.h:59
std::string m_prop
Name of property.
Definition: TextureProperties.h:81
double evaluate(const Vec3 &X) const override
Evaluate function in a point.
Definition: TextureProperties.h:73
virtual ~PropertyFunc()
Empty destructor.
Definition: TextureProperties.h:69
PropertyFunc(const std::string &prop, const TextureProperties &props)
Constructor initializes the members.
Definition: TextureProperties.h:64
const TextureProperties & m_props
Texture properties container.
Definition: TextureProperties.h:82
Scalar-valued unary function of a spatial point.
Definition: Function.h:193
Class containing a set of properties defined through a texture map.
Definition: TextureProperties.h:26
bool hasProperty(const std::string &name) const
Check if a property is available.
Definition: TextureProperties.C:125
bool getProperty(const std::string &name, const Vec3 &X, double &val) const
Get value for a property.
Definition: TextureProperties.C:99
void printLog() const
Print property information to log.
Definition: TextureProperties.C:90
std::map< std::string, Property > properties
Map of available properties.
Definition: TextureProperties.h:54
void parse(const tinyxml2::XMLElement *elem)
Parse an XML definition. param elem XML element to parse.
Definition: TextureProperties.C:25
Simple class for representing a point in 3D space.
Definition: Vec3.h:27
Struct holding information about a property.
Definition: TextureProperties.h:47
bool prescaled
True if data is already scaled.
Definition: TextureProperties.h:51
Matrix3D textureData
Texture data.
Definition: TextureProperties.h:50
double max
Maximum value.
Definition: TextureProperties.h:49
double min
Minimum value.
Definition: TextureProperties.h:48