34 for (i = 0; i < 3; ++i) {
38 _userAttributesReal =
nullptr;
39 _userAttributesVec2f =
nullptr;
40 _userAttributesVec3f =
nullptr;
46 _alpha = iBrother._alpha;
47 _thickness[0] = iBrother._thickness[0];
48 _thickness[1] = iBrother._thickness[1];
49 for (
int i = 0; i < 3; ++i) {
50 _color[i] = iBrother._color[i];
52 _visible = iBrother._visible;
53 if (iBrother._userAttributesReal) {
54 _userAttributesReal =
new realMap(*iBrother._userAttributesReal);
57 _userAttributesReal =
nullptr;
59 if (iBrother._userAttributesVec2f) {
60 _userAttributesVec2f =
new Vec2fMap(*iBrother._userAttributesVec2f);
63 _userAttributesVec2f =
nullptr;
65 if (iBrother._userAttributesVec3f) {
66 _userAttributesVec3f =
new Vec3fMap(*iBrother._userAttributesVec3f);
69 _userAttributesVec3f =
nullptr;
86 _thickness[0] = iRThickness;
87 _thickness[1] = iLThickness;
91 _userAttributesReal =
nullptr;
92 _userAttributesVec2f =
nullptr;
93 _userAttributesVec3f =
nullptr;
98 _alpha = (1 - t) * a1._alpha + t * a2._alpha;
99 _thickness[0] = (1 - t) * a1._thickness[0] + t * a2._thickness[0];
100 _thickness[1] = (1 - t) * a1._thickness[1] + t * a2._thickness[1];
101 for (
int i = 0; i < 3; ++i) {
102 _color[i] = (1 - t) * a1._color[i] + t * a2._color[i];
108 if ((a1._userAttributesReal) && (a2._userAttributesReal)) {
109 if (a1._userAttributesReal->size() == a2._userAttributesReal->size()) {
110 _userAttributesReal =
new realMap;
111 realMap::iterator it1 = a1._userAttributesReal->begin(),
112 it1end = a1._userAttributesReal->end();
113 realMap::iterator it2 = a2._userAttributesReal->begin();
114 for (; it1 != it1end; ++it1, ++it2) {
115 (*_userAttributesReal)[(*it1).first] = ((1 - t) * (*it1).second + t * (*it2).second);
120 _userAttributesReal =
nullptr;
122 if ((a1._userAttributesVec2f) && (a2._userAttributesVec2f)) {
123 if (a1._userAttributesVec2f->size() == a2._userAttributesVec2f->size()) {
124 _userAttributesVec2f =
new Vec2fMap;
125 Vec2fMap::iterator it1 = a1._userAttributesVec2f->begin(),
126 it1end = a1._userAttributesVec2f->end();
127 Vec2fMap::iterator it2 = a2._userAttributesVec2f->begin();
128 for (; it1 != it1end; ++it1, ++it2) {
129 (*_userAttributesVec2f)[(*it1).first] = ((1 - t) * (*it1).second + t * (*it2).second);
134 _userAttributesVec2f =
nullptr;
136 if ((a1._userAttributesVec3f) && (a2._userAttributesVec3f)) {
137 if (a1._userAttributesVec3f->size() == a2._userAttributesVec3f->size()) {
138 _userAttributesVec3f =
new Vec3fMap;
139 Vec3fMap::iterator it1 = a1._userAttributesVec3f->begin(),
140 it1end = a1._userAttributesVec3f->end();
141 Vec3fMap::iterator it2 = a2._userAttributesVec3f->begin();
142 for (; it1 != it1end; ++it1, ++it2) {
143 (*_userAttributesVec3f)[(*it1).first] = ((1 - t) * (*it1).second + t * (*it2).second);
148 _userAttributesVec3f =
nullptr;
154 if (_userAttributesReal) {
155 _userAttributesReal->clear();
156 delete _userAttributesReal;
158 if (_userAttributesVec2f) {
159 _userAttributesVec2f->clear();
160 delete _userAttributesVec2f;
162 if (_userAttributesVec3f) {
163 _userAttributesVec3f->clear();
164 delete _userAttributesVec3f;
171 _alpha = iBrother._alpha;
172 _thickness[0] = iBrother._thickness[0];
173 _thickness[1] = iBrother._thickness[1];
174 for (i = 0; i < 3; ++i) {
175 _color[i] = iBrother._color[i];
177 _visible = iBrother._visible;
178 if (iBrother._userAttributesReal) {
179 if (!_userAttributesReal) {
180 _userAttributesReal =
new realMap;
182 _userAttributesReal =
new realMap(*(iBrother._userAttributesReal));
185 _userAttributesReal =
nullptr;
187 if (iBrother._userAttributesVec2f) {
188 if (!_userAttributesVec2f) {
189 _userAttributesVec2f =
new Vec2fMap;
191 _userAttributesVec2f =
new Vec2fMap(*(iBrother._userAttributesVec2f));
194 _userAttributesVec2f =
nullptr;
196 if (iBrother._userAttributesVec3f) {
197 if (!_userAttributesVec3f) {
198 _userAttributesVec3f =
new Vec3fMap;
200 _userAttributesVec3f =
new Vec3fMap(*(iBrother._userAttributesVec3f));
203 _userAttributesVec3f =
nullptr;
210 if (!_userAttributesReal) {
212 cout <<
"StrokeAttribute warning: no real attribute was defined" << endl;
216 realMap::iterator a = _userAttributesReal->find(iName);
217 if (a == _userAttributesReal->end()) {
219 cout <<
"StrokeAttribute warning: no real attribute was added with the name " << iName
229 if (!_userAttributesVec2f) {
231 cout <<
"StrokeAttribute warning: no Vec2f attribute was defined" << endl;
235 Vec2fMap::iterator a = _userAttributesVec2f->find(iName);
236 if (a == _userAttributesVec2f->end()) {
238 cout <<
"StrokeAttribute warning: no Vec2f attribute was added with the name " << iName
248 if (!_userAttributesVec3f) {
250 cout <<
"StrokeAttribute warning: no Vec3f attribute was defined" << endl;
254 Vec3fMap::iterator a = _userAttributesVec3f->find(iName);
255 if (a == _userAttributesVec3f->end()) {
257 cout <<
"StrokeAttribute warning: no Vec3f attribute was added with the name " << iName
267 if (!_userAttributesReal) {
270 realMap::iterator a = _userAttributesReal->find(iName);
271 if (a == _userAttributesReal->end()) {
279 if (!_userAttributesVec2f) {
282 Vec2fMap::iterator a = _userAttributesVec2f->find(iName);
283 if (a == _userAttributesVec2f->end()) {
291 if (!_userAttributesVec3f) {
294 Vec3fMap::iterator a = _userAttributesVec3f->find(iName);
295 if (a == _userAttributesVec3f->end()) {
303 if (!_userAttributesReal) {
304 _userAttributesReal =
new realMap;
306 (*_userAttributesReal)[iName] = att;
311 if (!_userAttributesVec2f) {
312 _userAttributesVec2f =
new Vec2fMap;
314 (*_userAttributesVec2f)[iName] = att;
319 if (!_userAttributesVec3f) {
320 _userAttributesVec3f =
new Vec3fMap;
322 (*_userAttributesVec3f)[iName] = att;
335 _CurvilignAbscissa = 0.0f;
336 _StrokeLength = 0.0f;
341 _Attribute = iBrother._Attribute;
342 _CurvilignAbscissa = 0.0f;
343 _StrokeLength = 0.0f;
348 _CurvilignAbscissa = 0.0f;
349 _StrokeLength = 0.0f;
354 _CurvilignAbscissa = 0.0f;
355 _StrokeLength = 0.0f;
369 _Attribute = iAttribute;
370 _CurvilignAbscissa = 0.0f;
371 _StrokeLength = 0.0f;
377 _Attribute = iBrother._Attribute;
379 _CurvilignAbscissa = 0.0f;
381 _StrokeLength = 0.0f;
402 for (
int a = 0; a <
MAX_MTEX; a++) {
412 for (vertex_container::const_iterator
v = iBrother._Vertices.begin(),
413 vend = iBrother._Vertices.end();
417 _Vertices.push_back(*
v);
421 _ViewEdges = iBrother._ViewEdges;
422 _sampling = iBrother._sampling;
423 _mediumType = iBrother._mediumType;
424 _textureId = iBrother._textureId;
425 _textureStep = iBrother._textureStep;
426 for (
int a = 0; a <
MAX_MTEX; a++) {
427 _mtex[
a] = iBrother._mtex[
a];
429 _nodeTree = iBrother._nodeTree;
430 _tips = iBrother._tips;
441 if (!_Vertices.empty()) {
442 for (vertex_container::iterator
v = _Vertices.begin(), vend = _Vertices.end();
v != vend;
v++)
458 if (!_Vertices.empty()) {
462 for (vertex_container::const_iterator
v = iBrother._Vertices.begin(),
463 vend = iBrother._Vertices.end();
467 _Vertices.push_back(*
v);
469 _Length = iBrother._Length;
471 _ViewEdges = iBrother._ViewEdges;
472 _sampling = iBrother._sampling;
486 for (vertex_container::iterator
v = _Vertices.begin(), vend = _Vertices.end();
v != vend; ++
v) {
487 (*v)->setStrokeLength(iLength);
493 if (iNVertices <=
int(_Vertices.size())) {
497 float sampling = _Length /
float(iNVertices - _Vertices.size() + 1);
528 if (NPointsToAdd <= 0) {
540 vector<StrokeSegment> strokeSegments;
542 float meanlength = 0;
544 while ((it != itend) && (
next != itend)) {
545 Vec2r a((it)->getPoint());
549 int numberOfPointsToAdd =
int(
floor(NPointsToAdd * norm_var / _Length));
550 float csampling = norm_var /
float(numberOfPointsToAdd + 1);
551 strokeSegments.emplace_back(it,
next, norm_var, numberOfPointsToAdd, csampling);
552 N += numberOfPointsToAdd;
553 meanlength += norm_var;
558 meanlength /=
float(nsegments);
561 bool checkEveryone =
false;
563 while (
N < NPointsToAdd) {
565 for (vector<StrokeSegment>::iterator s = strokeSegments.begin(), send = strokeSegments.end();
569 if (s->_sampling == 0.0f) {
573 if (s->_resampled ==
false) {
574 if ((!checkEveryone) && (s->_length < meanlength)) {
579 s->_sampling = s->_length /
float(s->_n + 1);
580 s->_resampled = resampled =
true;
582 if (
N == NPointsToAdd) {
587 if (checkEveryone && !resampled) {
590 checkEveryone =
true;
592 if (
N < NPointsToAdd) {
598 for (vector<StrokeSegment>::iterator s = strokeSegments.begin(), send = strokeSegments.end();
602 newVertices.push_back(&*(s->_begin));
603 if (s->_sampling < _sampling) {
604 _sampling = s->_sampling;
607 t = s->_sampling / s->_length;
608 for (
int i = 0; i < s->_n; ++i) {
609 newVertex =
new StrokeVertex(&*(s->_begin), &*(s->_end), t);
610 newVertices.push_back(newVertex);
611 t += s->_sampling / s->_length;
620 if ((it != itend) && (
next == itend) ) {
621 newVertices.push_back(&(*it));
624 int newsize = newVertices.size();
625 if (newsize != iNPoints) {
626 cerr <<
"Warning: incorrect points number" << endl;
630 _Vertices = newVertices;
639 if (iSampling == 0) {
642 if (iSampling >= _sampling) {
646 _sampling = iSampling;
651 const real limit = 0.99;
657 while ((it != itend) && (
next != itend)) {
658 newVertices.push_back(&(*it));
659 Vec2r a((it)->getPoint());
663 if (norm_var <= _sampling) {
671 t = _sampling / norm_var;
675 newVertices.push_back(newVertex);
676 t = t + _sampling / norm_var;
682 if ((it != itend) && (
next == itend) ) {
683 newVertices.push_back(&(*it));
687 _Vertices = newVertices;
695 vertex_container::iterator it = _Vertices.begin(), itend = _Vertices.end();
696 for (; it != itend; ++it) {
705 vertex_container::iterator it = _Vertices.begin(), itend = _Vertices.end();
706 for (; it != itend; ++it) {
707 if ((*it) == iVertex) {
709 it = _Vertices.erase(it);
718 vertex_container::iterator itnext =
next.getIt();
719 _Vertices.insert(itnext, iVertex);
726 float curvabsc = 0.0f;
727 vertex_container::iterator it = _Vertices.begin(), itend = _Vertices.end();
728 vertex_container::iterator previous = it;
729 for (; it != itend; ++it) {
730 curvabsc += ((*it)->getPoint() - (*previous)->getPoint()).
norm();
731 (*it)->setCurvilinearAbscissa(curvabsc);
735 for (it = _Vertices.begin(); it != itend; ++it) {
736 (*it)->setStrokeLength(_Length);
753 return vertex_iterator(_Vertices.end(), _Vertices.begin(), _Vertices.end());
758 if ((t != 0) && (t < _sampling)) {
762 this->_Vertices.begin(), this->_Vertices.begin(), this->_Vertices.end());
768 this->_Vertices.end(), this->_Vertices.begin(), this->_Vertices.end());
774 this->_Vertices.begin(), this->_Vertices.begin(), this->_Vertices.end()));
781 this->_Vertices.end(), this->_Vertices.begin(), this->_Vertices.end()));
797 for (vertex_container::iterator it = _Vertices.begin(), itend = _Vertices.end(); it != itend;
824 if ((sampling != 0) && (sampling < _sampling)) {
827 return vertex_iterator(_Vertices.begin(), _Vertices.begin(), _Vertices.end());
837 while (!
next.end()) {
849 while (!
next.end()) {
856Stroke::vertex_container::reverse_iterator Stroke::vertices_last(
float sampling)
859 if (sampling < _sampling) {
862 return _Vertices.rbegin();
865inline Vec3r shaded_color(
int iCombination = 0)
const;
867inline Vec<3, real> Stroke::orientation2d(const_vertex_iterator it)
const
869 return iterator_edge_orientation2d_function<Stroke, const_vertex_iterator>(
this, it);
872Vec3r Stroke::orientation2d(
int iCombination)
const
874 return edge_orientation2d_function<Stroke>(*
this, iCombination);
877inline Vec3r Stroke::orientation3d(const_vertex_iterator it)
const
879 return iterator_edge_orientation3d_function<Stroke, const_vertex_iterator>(*
this, it);
882Vec3r Stroke::orientation3d(
int iCombination)
const
884 return edge_orientation3d_function<Stroke>(*
this, iCombination);
891 for (;
v != vend; ++
v) {
892 if (mat != (*v)->material()) {
899int Stroke::qi()
const
902 int qi_ = (*v)->qi();
903 for (;
v != vend; ++
v) {
904 if ((*v)->qi() != qi_) {
911inline occluder_container::const_iterator occluders_begin()
const
913 return _FEdgeA->occluders().begin();
916inline occluder_container::const_iterator occluders_end()
const
918 return _FEdgeA->occluders().end();
921int Stroke::occluders_size()
const
926bool Stroke::occluders_empty()
const
929 bool empty = (*v)->occluders_empty();
930 for (;
v != vend; ++
v) {
931 if ((*v)->occluders_empty() != empty) {
939inline const polygon3d &occludee()
const
941 return *(_FEdgeA->aFace());
945const SShape *Stroke::occluded_shape()
const
948 const SShape *sshape = (*v)->occluded_shape();
949 for (;
v != vend; ++
v) {
950 if ((*v)->occluded_shape() != sshape) {
957const bool Stroke::occludee_empty()
const
960 bool empty = (*v)->occludee_empty();
961 for (;
v != vend; ++
v) {
962 if ((*v)->occludee_empty() != empty) {
969const SShape *Stroke::shape()
const
972 const SShape *sshape = (*v)->shape();
973 for (;
v != vend; ++
v) {
974 if ((*v)->shape() != sshape) {
981real Stroke::z_discontinuity(
int iCombination)
const
983 return z_discontinuity_edge_function<Stroke>(*
this, iCombination);
986Vec3r Stroke::curvature2d_as_vector(
int iCombination)
const
988 return curvature2d_as_vector_edge_function<Stroke>(*
this, iCombination);
991real Stroke::curvature2d_as_angle(
int iCombination)
const
993 return curvature2d_as_angle_edge_function<Stroke>(*
this, iCombination);
996float Stroke::shape_importance(
int iCombination)
const
998 return shape_importance_edge_function<Stroke>(*
this, iCombination);
1001float Stroke::local_average_depth(
int iCombination)
const
1003 return local_average_depth_edge_function<Stroke>(*
this, iCombination);
1006float Stroke::local_depth_variance(
int iCombination)
const
1008 return local_depth_variance_edge_function<Stroke>(*
this, iCombination);
1011real Stroke::local_average_density(
float sigma,
int iCombination)
const
1013 return density_edge_function<Stroke>(*
this, iCombination);
Iterators used to iterate over the elements of the Stroke. Can't be used in python.
Iterators used to iterate over the elements of the Stroke.
Classes to render a stroke with OpenGL.
Classes to define a stroke.
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
static int raiseException(exception_type exception=UNDEFINED)
virtual ~StrokeAttribute()
bool isAttributeAvailableVec3f(const char *iName) const
void setThickness(float tr, float tl)
Vec3f getAttributeVec3f(const char *iName) const
void setAttributeReal(const char *iName, float att)
const float getThicknessR() const
void setAttributeVec3f(const char *iName, const Vec3f &att)
const float getThicknessL() const
bool isAttributeAvailableVec2f(const char *iName) const
Vec2f getAttributeVec2f(const char *iName) const
void setAttributeVec2f(const char *iName, const Vec2f &att)
StrokeAttribute & operator=(const StrokeAttribute &iBrother)
bool isAttributeAvailableReal(const char *iName) const
float getAttributeReal(const char *iName) const
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const =0
StrokeInternal::StrokeVertexIterator _end
StrokeSegment(StrokeInternal::StrokeVertexIterator ibegin, StrokeInternal::StrokeVertexIterator iend, float ilength, int in, float isampling)
StrokeInternal::StrokeVertexIterator _begin
float curvilinearAbscissa() const
float strokeLength() const
const StrokeAttribute & attribute() const
StrokeVertex & operator=(const StrokeVertex &iBrother)
virtual Interface0DIterator pointsEnd(float t=0.0f)
const_vertex_iterator vertices_begin() const
embedding vertex iterator
void ScaleThickness(float iFactor)
virtual Interface0DIterator verticesBegin()
StrokeInternal::vertex_iterator_base< StrokeInternal::vertex_nonconst_traits > vertex_iterator
StrokeInternal::vertex_iterator_base< StrokeInternal::vertex_const_traits > const_vertex_iterator
void RemoveVertex(StrokeVertex *iVertex)
void InsertVertex(StrokeVertex *iVertex, StrokeInternal::StrokeVertexIterator next)
const_vertex_iterator vertices_end() const
std::deque< StrokeVertex * > vertex_container
virtual Interface0DIterator verticesEnd()
void Render(const StrokeRenderer *iRenderer)
uint strokeVerticesSize() const
virtual Interface0DIterator pointsBegin(float t=0.0f)
void RenderBasic(const StrokeRenderer *iRenderer)
Stroke & operator=(const Stroke &iBrother)
void setLength(float iLength)
float ComputeSampling(int iNVertices)
StrokeInternal::StrokeVertexIterator strokeVerticesEnd()
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t=0.0f)
int Resample(int iNPoints)
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float2 floor(const float2 a)
VecMat::Vec3< real > Vec3r