25 #ifndef HBRVERTEXEDIT_H
26 #define HBRVERTEXEDIT_H
29 #include "../hbr/hierarchicalEdit.h"
31 #include "../version.h"
33 namespace OpenSubdiv {
34 namespace OPENSUBDIV_VERSION {
39 std::ostream& operator<<(std::ostream& out, const HbrVertexEdit<T>& path) {
40 out <<
"vertex path = (" << path.
faceid <<
' ';
41 for (
int i = 0; i < path.nsubfaces; ++i) {
42 out << static_cast<int>(path.subfaces[i]) <<
' ';
44 return out << static_cast<int>(path.vertexid) <<
"), edit = (" << path.edit[0] <<
',' << path.edit[1] <<
',' << path.edit[2] <<
')';
53 :
HbrHierarchicalEdit<T>(_faceid, _nsubfaces, _subfaces), vertexid(_vertexid), index(_index), width(_width), isP(_isP), op(_op) {
54 edit =
new float[width];
55 memcpy(edit, _edit, width *
sizeof(
float));
59 :
HbrHierarchicalEdit<T>(_faceid, _nsubfaces, _subfaces), vertexid(static_cast<unsigned char>(_vertexid)), index(_index), width(_width), isP(_isP), op(_op) {
60 edit =
new float[width];
61 memcpy(edit, _edit, width *
sizeof(
float));
71 friend std::ostream& operator<< <T> (std::ostream& out,
const HbrVertexEdit<T>& path);
80 const float*
GetEdit()
const {
return edit; }
89 face->
GetVertex(vertexid)->SetVertexEdit();
104 virtual void ApplyToBound(
struct bbox& bbox, RtMatrix *mx)
const {
106 struct xyz p = *(
struct xyz*)edit;
108 MxTransformByMatrix(&p, &p, *mx, 1);
110 bbox.min.x = std::min(bbox.min.x, p.x);
111 bbox.min.y = std::min(bbox.min.y, p.y);
112 bbox.min.z = std::min(bbox.min.z, p.z);
113 bbox.max.x = std::max(bbox.max.x, p.x);
114 bbox.max.y = std::max(bbox.max.y, p.y);
115 bbox.max.z = std::max(bbox.max.z, p.z);
118 bbox.min.x -= fabsf(p.x);
119 bbox.min.y -= fabsf(p.y);
120 bbox.min.z -= fabsf(p.z);
121 bbox.max.x += fabsf(p.x);
122 bbox.max.y += fabsf(p.y);
123 bbox.max.z += fabsf(p.z);
130 const unsigned char vertexid;
134 typename HbrHierarchicalEdit<T>::Operation op;
144 :
HbrHierarchicalEdit<T>(_faceid, _nsubfaces, _subfaces), vertexid(_vertexid), index(_index), width(_width), isP(_isP), op(_op) {
145 edit =
new float[width * 2];
146 memcpy(edit, _edit, 2 * width *
sizeof(
float));
150 :
HbrHierarchicalEdit<T>(_faceid, _nsubfaces, _subfaces), vertexid(_vertexid), index(_index), width(_width), isP(_isP), op(_op) {
151 edit =
new float[width * 2];
152 memcpy(edit, _edit, 2 * width *
sizeof(
float));
162 friend std::ostream& operator<< <T> (std::ostream& out,
const HbrVertexEdit<T>& path);
180 face->
GetVertex(vertexid)->SetVertexEdit();
195 virtual void ApplyToBound(
struct bbox& bbox, RtMatrix *mx)
const {
197 struct xyz p1 = *(
struct xyz*)edit;
198 struct xyz p2 = *(
struct xyz*)&edit[3];
200 MxTransformByMatrix(&p1, &p1, *mx, 1);
201 MxTransformByMatrix(&p2, &p2, *mx, 1);
204 bbox.min.x = std::min(std::min(bbox.min.x, p1.x), p2.x);
205 bbox.min.y = std::min(std::min(bbox.min.y, p1.y), p2.y);
206 bbox.min.z = std::min(std::min(bbox.min.z, p1.z), p2.z);
207 bbox.max.x = std::max(std::max(bbox.max.x, p1.x), p2.x);
208 bbox.max.y = std::max(std::max(bbox.max.y, p1.y), p2.y);
209 bbox.max.z = std::max(std::max(bbox.max.z, p1.z), p2.z);
210 }
else if (op == HbrVertexEdit<T>::Add ||
211 op == HbrVertexEdit<T>::Subtract) {
212 float maxx = std::max(fabsf(p1.x), fabsf(p2.x));
213 float maxy = std::max(fabsf(p1.y), fabsf(p2.y));
214 float maxz = std::max(fabsf(p1.z), fabsf(p2.z));
227 const unsigned char vertexid;
231 typename HbrHierarchicalEdit<T>::Operation op;
237 using namespace OPENSUBDIV_VERSION;
unsigned char GetVertexID() const
HbrHierarchicalEdit< T >::Operation GetOperation() const
virtual ~HbrMovingVertexEdit()
virtual void ApplyEditToVertex(HbrFace< T > *face, HbrVertex< T > *vertex)
const float * GetEdit() const
HbrVertexEdit(int _faceid, int _nsubfaces, unsigned char *_subfaces, unsigned char _vertexid, int _index, int _width, bool _isP, typename HbrHierarchicalEdit< T >::Operation _op, float *_edit)
virtual void ApplyEditToFace(HbrFace< T > *face)
unsigned char GetVertexID() const
HbrMovingVertexEdit(int _faceid, int _nsubfaces, int *_subfaces, int _vertexid, int _index, int _width, bool _isP, typename HbrHierarchicalEdit< T >::Operation _op, float *_edit)
HbrVertex< T > * GetVertex(int index) const
virtual void ApplyEditToVertex(HbrFace< T > *face, HbrVertex< T > *vertex)
HbrHierarchicalEdit< T >::Operation GetOperation() const
HbrMovingVertexEdit(int _faceid, int _nsubfaces, unsigned char *_subfaces, unsigned char _vertexid, int _index, int _width, bool _isP, typename HbrHierarchicalEdit< T >::Operation _op, float *_edit)
virtual void ApplyEditToFace(HbrFace< T > *face)
HbrVertexEdit(int _faceid, int _nsubfaces, int *_subfaces, int _vertexid, int _index, int _width, bool _isP, typename HbrHierarchicalEdit< T >::Operation _op, float *_edit)
const float * GetEdit() const