31 if (_current_set->empty()) {
38 I1DContainer::iterator it = _current_set->begin();
39 I1DContainer::iterator itbegin = it;
40 while (it != _current_set->end()) {
49 new_set.push_back(i1d);
53 rejected.push_back(i1d);
57 if ((*itbegin)->getExactTypeName() !=
"ViewEdge") {
58 for (it = rejected.begin(); it != rejected.end(); ++it) {
63 _current_set->clear();
64 *_current_set = new_set;
72 if (_current_view_edges_set.empty()) {
80 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
81 it_edge != _current_view_edges_set.end();
83 if (pred(**it_edge) < 0) {
90 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
98 if (modifier(**it) < 0) {
106 if (pred(**it) < 0) {
114 new_chains_set.push_back(new_chain);
117 if (!new_chains_set.empty()) {
118 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
119 _current_chains_set.push_back(*it);
121 new_chains_set.clear();
122 _current_set = &_current_chains_set;
127 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
130 new_chains_set.clear();
136 if (_current_view_edges_set.empty()) {
146 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
147 it_edge != _current_view_edges_set.end();
149 if (pred(**it_edge) < 0) {
155 if (pred_ts(**it_edge) < 0) {
162 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
175 if (pred(**it) < 0) {
182 if (pred_ts(**it) < 0) {
190 new_chains_set.push_back(new_chain);
193 if (!new_chains_set.empty()) {
194 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
195 _current_chains_set.push_back(*it);
197 new_chains_set.clear();
198 _current_set = &_current_chains_set;
203 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
206 new_chains_set.clear();
215 if (_current_view_edges_set.empty()) {
223 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
224 it_edge != _current_view_edges_set.end();
226 if (pred(**it_edge)) {
230 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
232 it.setCurrentEdge(edge);
234 Chain *new_chain =
new Chain(
id);
237 ViewEdgeIterator it_back(it);
241 new_chain->push_viewedge_back(*it, it.getOrientation());
244 }
while (!it.isEnd() && !pred(**it));
246 it.setCurrentEdge(edge);
248 while (!it.isEnd() && !pred(**it)) {
249 new_chain->push_viewedge_front(*it, it.getOrientation());
254 _current_chains_set.push_back(new_chain);
257 if (!_current_chains_set.empty()) {
258 _current_set = &_current_chains_set;
264 if (_current_view_edges_set.empty()) {
269 Functions1D::IncrementChainingTimeStampF1D ts;
270 Predicates1D::EqualToChainingTimeStampUP1D pred_ts(
TimeStamp::instance()->getTimeStamp() + 1);
275 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
276 it_edge != _current_view_edges_set.end();
278 if (pred(**it_edge) || pred_ts(**it_edge)) {
282 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
284 it.setCurrentEdge(edge);
286 Chain *new_chain =
new Chain(
id);
289 ViewEdgeIterator it_back(it);
293 new_chain->push_viewedge_back(*it, it.getOrientation());
296 }
while (!it.isEnd() && !pred(**it) && !pred_ts(**it));
298 it.setCurrentEdge(edge);
300 while (!it.isEnd() && !pred(**it) && !pred_ts(**it)) {
301 new_chain->push_viewedge_front(*it, it.getOrientation());
306 _current_chains_set.push_back(new_chain);
309 if (!_current_chains_set.empty()) {
310 _current_set = &_current_chains_set;
317 if (_current_view_edges_set.empty()) {
327 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
328 it_edge != _current_view_edges_set.end();
330 if (pred(**it_edge) < 0) {
336 if (pred_ts(**it_edge) < 0) {
343 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
355 ViewEdgeIterator it_back(it);
368 if (pred(**it) < 0) {
383 while (!it.
isEnd()) {
384 if (pred(**it) < 0) {
398 new_chains_set.push_back(new_chain);
401 if (!new_chains_set.empty()) {
402 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
403 _current_chains_set.push_back(*it);
405 new_chains_set.clear();
406 _current_set = &_current_chains_set;
411 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
414 new_chains_set.clear();
420 if (_current_view_edges_set.empty()) {
430 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
431 it_edge != _current_view_edges_set.end();
433 if (pred_ts(**it_edge) < 0) {
440 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
452 ViewEdgeIterator it_back(it);
462 }
while (!it.
isEnd());
470 while (!it.
isEnd()) {
478 new_chains_set.push_back(new_chain);
481 if (!new_chains_set.empty()) {
482 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
483 _current_chains_set.push_back(*it);
485 new_chains_set.clear();
486 _current_set = &_current_chains_set;
491 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
494 new_chains_set.clear();
500 if (_current_chains_set.empty()) {
501 cerr <<
"Warning: current set empty" << endl;
511 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
512 for (; cit != citend; ++cit) {
513 Id currentId = (*cit)->getId();
514 new_curve =
new Chain(currentId);
515 first = (*cit)->pointsBegin(sampling);
516 end = (*cit)->pointsEnd(sampling);
524 for (; it != end; ++it) {
531 if (pred.
result && (it != last)) {
532 splitted_chains.push_back(new_curve);
534 new_curve =
new Chain(currentId);
543 splitted_chains.push_back(new_curve);
547 cit = _current_chains_set.begin();
548 for (; cit != citend; ++cit) {
551 _current_chains_set.clear();
553 _current_chains_set = splitted_chains;
555 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
560 _current_chains_set.push_back(*cit);
563 splitted_chains.clear();
565 if (!_current_chains_set.empty()) {
566 _current_set = &_current_chains_set;
571 cit = splitted_chains.begin();
572 citend = splitted_chains.end();
573 for (; cit != citend; ++cit) {
576 splitted_chains.clear();
584 if (_current_chains_set.empty()) {
585 cerr <<
"Warning: current set empty" << endl;
596 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
597 for (; cit != citend; ++cit) {
598 Id currentId = (*cit)->getId();
599 first = (*cit)->pointsBegin(sampling);
600 end = (*cit)->pointsEnd(sampling);
608 new_curve =
new Chain(currentId);
620 if (stoppingPred(itStop) < 0) {
624 }
while (!stoppingPred.
result);
633 splitted_chains.push_back(new_curve);
638 if (itStart == end) {
641 if (startingPred(itStart) < 0) {
644 }
while (!startingPred.
result);
645 }
while (!
ELEM(itStart, end, last));
649 cit = _current_chains_set.begin();
650 for (; cit != citend; ++cit) {
653 _current_chains_set.clear();
655 _current_chains_set = splitted_chains;
657 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
662 _current_chains_set.push_back(*cit);
665 splitted_chains.clear();
667 if (!_current_chains_set.empty()) {
668 _current_set = &_current_chains_set;
673 cit = splitted_chains.begin();
674 citend = splitted_chains.end();
675 for (; cit != citend; ++cit) {
678 splitted_chains.clear();
691 newChains.push_back(_curve);
708 for (; ((it != end) && (
next != end)); ++it, ++
next) {
710 if (func(it0d) < 0) {
721 newChains.push_back(_curve);
727 if (newId ==
nullptr) {
728 newId =
new Id(_curve->
getId());
744 for (; (vit != vitend) && (vnext != vitend) &&
749 if ((vit == vitend) || (vnext == vitend)) {
751 cout <<
"The split takes place in bad location" << endl;
753 newChains.push_back(_curve);
764 for (vit = vnext; vit != vitend; ++vit) {
770 if (pred(*new_curve_a) < 0 || (!pred.
result && pred(*new_curve_b) < 0)) {
777 newChains.push_back(_curve);
783 splitted_chains.push_back(_curve);
785 __recursiveSplit(new_curve_a, func, pred, sampling, newChains, splitted_chains);
786 __recursiveSplit(new_curve_b, func, pred, sampling, newChains, splitted_chains);
794 if (_current_chains_set.empty()) {
795 cerr <<
"Warning: current set empty" << endl;
799 Chain *currentChain =
nullptr;
802 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
803 for (; cit != citend; ++cit) {
804 currentChain =
dynamic_cast<Chain *
>(*cit);
809 if (pred(*currentChain) < 0) {
813 __recursiveSplit(currentChain, func, pred, sampling, newChains, splitted_chains);
816 newChains.push_back(currentChain);
820 if (!splitted_chains.empty()) {
821 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
824 splitted_chains.clear();
827 _current_chains_set.clear();
829 _current_chains_set = newChains;
831 for (cit = newChains.begin(), citend = newChains.end(); cit != citend; ++cit) {
836 _current_chains_set.push_back(*cit);
841 if (!_current_chains_set.empty()) {
842 _current_set = &_current_chains_set;
857 newChains.push_back(_curve);
869 real _min = func(it0d);
881 for (; ((it != end) && (
next != end)); ++it, ++
next) {
884 if (pred0d(it0d) < 0) {
890 if (func(it0d) < 0) {
904 newChains.push_back(_curve);
910 if (newId ==
nullptr) {
911 newId =
new Id(_curve->
getId());
927 for (; (vit != vitend) && (vnext != vitend) &&
932 if ((vit == vitend) || (vnext == vitend)) {
934 cout <<
"The split takes place in bad location" << endl;
936 newChains.push_back(_curve);
947 for (vit = vnext; vit != vitend; ++vit) {
953 if (pred(*new_curve_a) < 0 || (!pred.
result && pred(*new_curve_b) < 0)) {
960 newChains.push_back(_curve);
966 splitted_chains.push_back(_curve);
968 __recursiveSplit(new_curve_a, func, pred0d, pred, sampling, newChains, splitted_chains);
969 __recursiveSplit(new_curve_b, func, pred0d, pred, sampling, newChains, splitted_chains);
978 if (_current_chains_set.empty()) {
979 cerr <<
"Warning: current set empty" << endl;
983 Chain *currentChain =
nullptr;
986 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
987 for (; cit != citend; ++cit) {
988 currentChain =
dynamic_cast<Chain *
>(*cit);
993 if (pred(*currentChain) < 0) {
997 __recursiveSplit(currentChain, func, pred0d, pred, sampling, newChains, splitted_chains);
1000 newChains.push_back(currentChain);
1004 if (!splitted_chains.empty()) {
1005 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
1008 splitted_chains.clear();
1011 _current_chains_set.clear();
1013 _current_chains_set = newChains;
1015 for (cit = newChains.begin(), citend = newChains.end(); cit != citend; ++cit) {
1016 if ((*cit)->getLength2D() <
M_EPSILON) {
1020 _current_chains_set.push_back(*cit);
1025 if (!_current_chains_set.empty()) {
1026 _current_set = &_current_chains_set;
1044 if ((*_pred)(*
i1, *i2) < 0) {
1045 throw std::runtime_error(
"comparison failed");
1056 if (!_current_set) {
1061 std::sort(_current_set->begin(), _current_set->end(), wrapper);
1063 catch (std::runtime_error &
e) {
1064 cerr <<
"Warning: Operator.sort(): " <<
e.what() << endl;
1075 float currentCurvilignAbscissa = 0.0f;
1081 Vec2r previous = current;
1085 bool hasSingularity =
false;
1090 sv =
dynamic_cast<SVertex *
>(&(*it));
1092 cerr <<
"Warning: unexpected Vertex type" << endl;
1101 Vec2r vec_tmp(current - previous);
1103 if (dist < 1.0e-6) {
1104 hasSingularity =
true;
1106 currentCurvilignAbscissa += dist;
1111 }
while (!
ELEM(it, itend, itfirst));
1113 if (it == itfirst) {
1117 sv =
dynamic_cast<SVertex *
>(&(*it));
1119 cerr <<
"Warning: unexpected Vertex type" << endl;
1129 Vec2r vec_tmp(current - previous);
1131 if (dist < 1.0e-6) {
1132 hasSingularity =
true;
1134 currentCurvilignAbscissa += dist;
1143 stroke->
setLength(currentCurvilignAbscissa);
1144 if (hasSingularity) {
1151 while (!vnext.
isEnd()) {
1153 next = (*vnext).getPoint();
1154 if ((
next - current).
norm() < 1.0e-6) {
1161 std::vector<StrokeVertex *> overlapping_vertices;
1162 overlapping_vertices.push_back(&(*
v));
1164 overlapping_vertices.push_back(&(*vnext));
1168 if (vnext.
isEnd()) {
1171 next = (*vnext).getPoint();
1172 }
while ((
next - current).
norm() < 1.0e-6);
1176 if (!vnext.
isEnd()) {
1177 target = (*vnext).getPoint();
1180 else if (!vprevious.
isBegin()) {
1181 target = (*vprevious).getPoint();
1189 current = overlapping_vertices.front()->getPoint();
1190 Vec2r dir(target - current);
1193 int nvert = overlapping_vertices.size();
1194 if (dist <
len * nvert) {
1201 std::vector<StrokeVertex *>::iterator it = overlapping_vertices.begin();
1203 for (
int n = 0; n < nvert; n++) {
1210 for (
int n = 0; n < nvert; n++) {
1217 if (vnext.
isEnd()) {
1231 bool warning =
false;
1232 while (!vnext.
isEnd()) {
1234 next = (*vnext).getPoint2D();
1235 if ((
next - current).
norm() < 1.0e-6) {
1243 printf(
"Warning: stroke contains singular points.\n");
1251 for (vector<StrokeShader *>::iterator it =
shaders.begin(); it !=
shaders.end(); ++it) {
1252 if ((*it)->shade(stroke) < 0) {
1262 if (!_current_set) {
1263 cerr <<
"Warning: current set empty" << endl;
1267 for (Operators::I1DContainer::iterator it = _current_set->begin(); it != _current_set->end();
1269 if (pred(**it) < 0) {
1283 new_strokes_set.push_back(stroke);
1287 for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end();
1289 _current_strokes_set.push_back(*it);
1291 new_strokes_set.clear();
1295 for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end();
1299 new_strokes_set.clear();
1307 cerr <<
"Error: no ViewMap computed yet" << endl;
1310 _current_view_edges_set.clear();
1311 for (I1DContainer::iterator it = _current_chains_set.begin(); it != _current_chains_set.end();
1315 _current_chains_set.clear();
1318 ViewMap::viewedges_container::iterator ve = vedges.begin(), veend = vedges.end();
1319 for (; ve != veend; ++ve) {
1323 _current_view_edges_set.push_back(*ve);
1325 _current_set = &_current_view_edges_set;
1326 if (removeStrokes) {
1327 _current_strokes_set.clear();
Class to define a canvas designed to draw style modules.
Iterators used to iterate over the elements of the Curve.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
Class gathering stroke creation algorithms.
Iterators used to iterate over the elements of the Stroke.
Classes to define a stroke.
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
void sort(btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
Helper function of 3X3 SVD for sorting singular values.
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
void push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
void push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
void setSplittingId(Id *sid)
Interface0DIterator castToInterface0DIterator() const
virtual Vec2r getPoint2D() const
unsigned int nSegments() const
void push_vertex_back(Vertex *iVertex)
CurveInternal::CurvePointIterator curvePointsBegin(float t=0.0f)
CurveInternal::CurvePointIterator curveVerticesBegin()
CurveInternal::CurvePointIterator curveVerticesEnd()
CurveInternal::CurvePointIterator curvePointsEnd(float t=0.0f)
id_type getSecond() const
void setSecond(id_type second)
virtual bool isEnd() const
virtual Geometry::Vec2r getPoint2D() const
virtual Interface0DIterator verticesEnd()
virtual Interface0DIterator verticesBegin()
static int sort(BinaryPredicate1D &pred)
static int select(UnaryPredicate1D &pred)
static int chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred, UnaryFunction1D_void &modifier)
static void reset(bool removeStrokes=true)
vector< Interface1D * > I1DContainer
static int sequentialSplit(UnaryPredicate0D &startingPred, UnaryPredicate0D &stoppingPred, float sampling=0.0f)
static int recursiveSplit(UnaryFunction0D< double > &func, UnaryPredicate1D &pred, float sampling=0)
static int bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred)
static int create(UnaryPredicate1D &pred, vector< StrokeShader * > shaders)
vector< Stroke * > StrokesContainer
bool operator()(Interface1D *i1, Interface1D *i2)
PredicateWrapper(BinaryPredicate1D &pred)
void setCurvilinearAbscissa(float iAbscissa)
void setPoint(real x, real y)
void push_back(StrokeVertex *iVertex)
virtual Interface0DIterator verticesBegin()
void setLength(float iLength)
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t=0.0f)
unsigned int strokeVerticesSize() const
static TimeStamp * instance()
Vec< T, N > & normalize()
bool getOrientation() const
void setOrientation(bool orientation)
void setBegin(ViewEdge *begin)
virtual bool isEnd() const
void setCurrentEdge(ViewEdge *edge)
vector< ViewEdge * > viewedges_container
static ViewMap * getInstance()
viewedges_container & ViewEdges()
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static void error(const char *str)
static const real M_EPSILON
static int __recursiveSplit(Chain *_curve, UnaryFunction0D< double > &func, UnaryPredicate1D &pred, float sampling, Operators::I1DContainer &newChains, Operators::I1DContainer &splitted_chains)
static Stroke * createStroke(Interface1D &inter)
int applyShading(Stroke &stroke, vector< StrokeShader * > &shaders)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)