Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

HIOUtilityHTML.h
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 #pragma once
11 
12 #include <vector>
13 #include <array>
14 #include <assert.h>
15 #include "HIOManager.h"
16 
17 #ifdef HIO_HTML
18 # ifdef _MSC_VER
19 # define HIO_API __declspec (dllexport)
20 # else
21 # define HIO_API __attribute__ ((visibility ("default")))
22 # endif
23 #else
24 # define HIO_API
25 #endif
26 
27 namespace hio_html_internal
28 {
29  using Matrix = std::array<float, 16>;
30  using RGBAColor = std::array<float, 4>;
31  using RGBColor = std::array<float, 3>;
32  using Point = std::array<float, 3>;
33 
34  using StringArray = std::vector<std::string>;
35  using MatrixArray = std::vector<Matrix>;
36  using KeyArray = std::vector<HC_KEY>;
37  using FloatArray = std::vector<float>;
38  using IntArray = std::vector<int>;
39  using PointArray = std::vector<Point>;
40  using RGBColorArray = std::vector<RGBColor>;
41  using RGBAColorArray = std::vector<RGBAColor>;
42 
43  static inline uint32_t extract_uint32_t(float const & a)
44  {
45  uint32_t i;
46  memcpy(&i, &a, sizeof(float));
47  return i;
48  }
49 
50  static inline bool float_match(float const & a, float const & b) {
51  uint32_t va = extract_uint32_t(a);
52  uint32_t vb = extract_uint32_t(b);
53 
54  if (((va | vb) & 0x7FFFFFFF) == 0)
55  return true;
56 
57  return va == vb;
58  }
59 
60  struct Vector
61  {
62  float x;
63  float y;
64  float z;
65 
66  Vector() {}
67  Vector(float x, float y, float z) : x(x), y(y), z(z) {}
68  Vector(Point const & p) : x(p[0]), y(p[1]), z(p[2]) {}
69  Vector(Vector const & that) : x(that.x), y(that.y), z(that.z) {}
70 
71  bool operator== (Vector const & v) const {
72  return float_match(x, v.x) && float_match(y, v.y) && float_match(z, v.z);
73  }
74  bool operator!= (Vector const & v) const { return !(*this == v); }
75 
76  Vector const operator+(Vector const & v) const { return Vector(x + v.x, y + v.y, z + v.z); }
77  Vector const operator-(Vector const & v) const { return Vector(x - v.x, y - v.y, z - v.z); }
78  Vector & operator+=(Vector const & v) { x += v.x; y += v.y; z += v.z; return *this; }
79  Vector & operator-=(Vector const & v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
80 
81  Vector const operator*(float s) const { return Vector(s * x, s * y, s * z); }
82  Vector const operator/(float s) const { return operator*(1.0f / s); }
83  Vector & operator*=(float s) { x *= s; y *= s; z *= s; return *this; }
84  Vector & operator/=(float s) { return operator*=(1.0f / s); }
85 
86  inline float Dot(Vector const & v) const { return x * v.x + y * v.y + z * v.z; }
87  inline float Length() const { return sqrt(Dot(*this)); }
88  inline Vector & Normalize()
89  {
90  float length = Length();
91  if (length > 1e-30f)
92  operator/=(length);
93  else
94  *this = Zero();
95  return *this;
96  }
97  inline Vector const Normalized() const
98  {
99  Vector copy = *this;
100  return copy.Normalize();
101  }
102  inline Vector const Cross(Vector const & v) const
103  {
104  Vector cross;
105  HC_Compute_Cross_Product(this, &v, &cross);
106  return cross;
107  }
108 
109  static inline Vector Zero() { return Vector(0, 0, 0); }
110  };
111 
112  inline Vector operator*(float s, Vector const & v) { return v * s; }
113 
114  using VectorArray = std::vector<Vector>;
115 }
120 class HIO_API HIOUtilityHTML : public HOutputHandler
121 {
122 public:
125  virtual ~HIOUtilityHTML() {}
126 
129 
131  const char * GetOutputName() { return "HIOUtilityHTML"; }
132 
134  const char * GetOutputTypesString() { return "html"; }
135 
137  HOutputHandlerStyle GetOutputStyle() { return HOutputHandlerStyleModel; }
138 
146  HFileOutputResult FileOutputByKey(const __wchar_t * filename, HC_KEY key, HOutputHandlerOptions * options);
147 
155  HFileOutputResult FileOutputByKey(const unsigned short * filename, HC_KEY key, HOutputHandlerOptions * options);
156 
164  HFileOutputResult FileOutputByKey(const char * filename, HC_KEY key, HOutputHandlerOptions * options);
165 };
166 
167 #ifdef HIO_HTML
168 extern "C" {
169  HIO_API void * CreateOutput(HIOManager *manager);
170  HIO_API void Free(HIOUtilityHTML *);
171 }
172 
173 
174 #endif
Definition: HIOUtilityHTML.h:120
Definition: HIOManager.h:1421
virtual HFileOutputResult FileOutputByKey(const char *filename, HC_KEY key, HOutputHandlerOptions *options)
Definition: HIOUtilityHTML.h:60
const char * GetOutputTypesString()
Definition: HIOUtilityHTML.h:134
const char * GetOutputName()
Definition: HIOUtilityHTML.h:131
HOutputHandlerStyle GetOutputStyle()
Definition: HIOUtilityHTML.h:137
#define HOutputOpFileOutputByKey
This HOutputHandler supports output from a segment key.
Definition: HIOManager.h:73
Definition: HDWFMisc.h:22
HOutputHandlerStyle
Definition: HIOManager.h:833
HOutputHandler an abstract base class for model and image output.
Definition: HIOManager.h:1234
virtual void RegisterOutputHandlerTypes()=0
Definition: HIOManager.h:879
HIOUtilityHTML()
Definition: HIOUtilityHTML.h:124
void SetOutputOps(unsigned long ops)
This sets the HOutputOp.
Definition: HIOManager.h:1399
A header file containing the HIO classes for passing to HBaseView::FileInput and HBaseView::FileOutpu...