45 if (_current_set->empty()) {
52 I1DContainer::iterator it = _current_set->begin();
53 I1DContainer::iterator itbegin = it;
54 while (it != _current_set->end()) {
63 new_set.push_back(i1d);
67 rejected.push_back(i1d);
71 if ((*itbegin)->getExactTypeName() !=
"ViewEdge") {
72 for (it = rejected.begin(); it != rejected.end(); ++it) {
77 _current_set->clear();
78 *_current_set = new_set;
86 if (_current_view_edges_set.empty()) {
94 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
95 it_edge != _current_view_edges_set.end();
97 if (pred(**it_edge) < 0) {
104 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
112 if (modifier(**it) < 0) {
120 if (pred(**it) < 0) {
128 new_chains_set.push_back(new_chain);
131 if (!new_chains_set.empty()) {
132 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
133 _current_chains_set.push_back(*it);
135 new_chains_set.clear();
136 _current_set = &_current_chains_set;
141 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
144 new_chains_set.clear();
150 if (_current_view_edges_set.empty()) {
160 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
161 it_edge != _current_view_edges_set.end();
163 if (pred(**it_edge) < 0) {
169 if (pred_ts(**it_edge) < 0) {
176 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
189 if (pred(**it) < 0) {
196 if (pred_ts(**it) < 0) {
204 new_chains_set.push_back(new_chain);
207 if (!new_chains_set.empty()) {
208 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
209 _current_chains_set.push_back(*it);
211 new_chains_set.clear();
212 _current_set = &_current_chains_set;
217 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
220 new_chains_set.clear();
229 if (_current_view_edges_set.empty()) {
237 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
238 it_edge != _current_view_edges_set.end();
240 if (pred(**it_edge)) {
244 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
246 it.setCurrentEdge(edge);
248 Chain *new_chain =
new Chain(
id);
251 ViewEdgeIterator it_back(it);
255 new_chain->push_viewedge_back(*it, it.getOrientation());
258 }
while (!it.isEnd() && !pred(**it));
260 it.setCurrentEdge(edge);
262 while (!it.isEnd() && !pred(**it)) {
263 new_chain->push_viewedge_front(*it, it.getOrientation());
268 _current_chains_set.push_back(new_chain);
271 if (!_current_chains_set.empty()) {
272 _current_set = &_current_chains_set;
278 if (_current_view_edges_set.empty()) {
283 Functions1D::IncrementChainingTimeStampF1D ts;
284 Predicates1D::EqualToChainingTimeStampUP1D pred_ts(
TimeStamp::instance()->getTimeStamp() + 1);
289 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
290 it_edge != _current_view_edges_set.end();
292 if (pred(**it_edge) || pred_ts(**it_edge)) {
296 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
298 it.setCurrentEdge(edge);
300 Chain *new_chain =
new Chain(
id);
303 ViewEdgeIterator it_back(it);
307 new_chain->push_viewedge_back(*it, it.getOrientation());
310 }
while (!it.isEnd() && !pred(**it) && !pred_ts(**it));
312 it.setCurrentEdge(edge);
314 while (!it.isEnd() && !pred(**it) && !pred_ts(**it)) {
315 new_chain->push_viewedge_front(*it, it.getOrientation());
320 _current_chains_set.push_back(new_chain);
323 if (!_current_chains_set.empty()) {
324 _current_set = &_current_chains_set;
331 if (_current_view_edges_set.empty()) {
341 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
342 it_edge != _current_view_edges_set.end();
344 if (pred(**it_edge) < 0) {
350 if (pred_ts(**it_edge) < 0) {
357 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
369 ViewEdgeIterator it_back(it);
382 if (pred(**it) < 0) {
397 while (!it.
isEnd()) {
398 if (pred(**it) < 0) {
412 new_chains_set.push_back(new_chain);
415 if (!new_chains_set.empty()) {
416 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
417 _current_chains_set.push_back(*it);
419 new_chains_set.clear();
420 _current_set = &_current_chains_set;
425 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
428 new_chains_set.clear();
434 if (_current_view_edges_set.empty()) {
444 for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
445 it_edge != _current_view_edges_set.end();
447 if (pred_ts(**it_edge) < 0) {
454 edge =
dynamic_cast<ViewEdge *
>(*it_edge);
466 ViewEdgeIterator it_back(it);
476 }
while (!it.
isEnd());
484 while (!it.
isEnd()) {
492 new_chains_set.push_back(new_chain);
495 if (!new_chains_set.empty()) {
496 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
497 _current_chains_set.push_back(*it);
499 new_chains_set.clear();
500 _current_set = &_current_chains_set;
505 for (I1DContainer::iterator it = new_chains_set.begin(); it != new_chains_set.end(); ++it) {
508 new_chains_set.clear();
514 if (_current_chains_set.empty()) {
515 cerr <<
"Warning: current set empty" << endl;
525 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
526 for (; cit != citend; ++cit) {
527 Id currentId = (*cit)->getId();
528 new_curve =
new Chain(currentId);
529 first = (*cit)->pointsBegin(sampling);
530 end = (*cit)->pointsEnd(sampling);
538 for (; it != end; ++it) {
545 if (pred.
result && (it != last)) {
546 splitted_chains.push_back(new_curve);
548 new_curve =
new Chain(currentId);
557 splitted_chains.push_back(new_curve);
561 cit = _current_chains_set.begin();
562 for (; cit != citend; ++cit) {
565 _current_chains_set.clear();
567 _current_chains_set = splitted_chains;
569 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
574 _current_chains_set.push_back(*cit);
577 splitted_chains.clear();
579 if (!_current_chains_set.empty()) {
580 _current_set = &_current_chains_set;
585 cit = splitted_chains.begin();
586 citend = splitted_chains.end();
587 for (; cit != citend; ++cit) {
590 splitted_chains.clear();
598 if (_current_chains_set.empty()) {
599 cerr <<
"Warning: current set empty" << endl;
610 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
611 for (; cit != citend; ++cit) {
612 Id currentId = (*cit)->getId();
613 first = (*cit)->pointsBegin(sampling);
614 end = (*cit)->pointsEnd(sampling);
622 new_curve =
new Chain(currentId);
625 point =
dynamic_cast<CurvePoint *
>(&(*itStart));
628 point =
dynamic_cast<CurvePoint *
>(&(*itStop));
634 if (stoppingPred(itStop) < 0) {
638 }
while (!stoppingPred.
result);
640 point =
dynamic_cast<CurvePoint *
>(&(*itStop));
647 splitted_chains.push_back(new_curve);
652 if (itStart == end) {
655 if (startingPred(itStart) < 0) {
658 }
while (!startingPred.
result);
659 }
while (!
ELEM(itStart, end, last));
663 cit = _current_chains_set.begin();
664 for (; cit != citend; ++cit) {
667 _current_chains_set.clear();
669 _current_chains_set = splitted_chains;
671 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
676 _current_chains_set.push_back(*cit);
679 splitted_chains.clear();
681 if (!_current_chains_set.empty()) {
682 _current_set = &_current_chains_set;
687 cit = splitted_chains.begin();
688 citend = splitted_chains.end();
689 for (; cit != citend; ++cit) {
692 splitted_chains.clear();
705 newChains.push_back(_curve);
722 for (; ((it != end) && (
next != end)); ++it, ++
next) {
724 if (func(it0d) < 0) {
735 newChains.push_back(_curve);
741 if (newId ==
nullptr) {
742 newId =
new Id(_curve->
getId());
758 for (; (vit != vitend) && (vnext != vitend) &&
763 if ((vit == vitend) || (vnext == vitend)) {
765 cout <<
"The split takes place in bad location" << endl;
767 newChains.push_back(_curve);
778 for (vit = vnext; vit != vitend; ++vit) {
784 if (pred(*new_curve_a) < 0 || (!pred.
result && pred(*new_curve_b) < 0)) {
791 newChains.push_back(_curve);
797 splitted_chains.push_back(_curve);
799 __recursiveSplit(new_curve_a, func, pred, sampling, newChains, splitted_chains);
800 __recursiveSplit(new_curve_b, func, pred, sampling, newChains, splitted_chains);
808 if (_current_chains_set.empty()) {
809 cerr <<
"Warning: current set empty" << endl;
813 Chain *currentChain =
nullptr;
816 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
817 for (; cit != citend; ++cit) {
818 currentChain =
dynamic_cast<Chain *
>(*cit);
823 if (pred(*currentChain) < 0) {
827 __recursiveSplit(currentChain, func, pred, sampling, newChains, splitted_chains);
830 newChains.push_back(currentChain);
834 if (!splitted_chains.empty()) {
835 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
838 splitted_chains.clear();
841 _current_chains_set.clear();
843 _current_chains_set = newChains;
845 for (cit = newChains.begin(), citend = newChains.end(); cit != citend; ++cit) {
850 _current_chains_set.push_back(*cit);
855 if (!_current_chains_set.empty()) {
856 _current_set = &_current_chains_set;
871 newChains.push_back(_curve);
883 real _min = func(it0d);
895 for (; ((it != end) && (
next != end)); ++it, ++
next) {
898 if (pred0d(it0d) < 0) {
904 if (func(it0d) < 0) {
918 newChains.push_back(_curve);
924 if (newId ==
nullptr) {
925 newId =
new Id(_curve->
getId());
941 for (; (vit != vitend) && (vnext != vitend) &&
946 if ((vit == vitend) || (vnext == vitend)) {
948 cout <<
"The split takes place in bad location" << endl;
950 newChains.push_back(_curve);
961 for (vit = vnext; vit != vitend; ++vit) {
967 if (pred(*new_curve_a) < 0 || (!pred.
result && pred(*new_curve_b) < 0)) {
974 newChains.push_back(_curve);
980 splitted_chains.push_back(_curve);
982 __recursiveSplit(new_curve_a, func, pred0d, pred, sampling, newChains, splitted_chains);
983 __recursiveSplit(new_curve_b, func, pred0d, pred, sampling, newChains, splitted_chains);
992 if (_current_chains_set.empty()) {
993 cerr <<
"Warning: current set empty" << endl;
997 Chain *currentChain =
nullptr;
1000 I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
1001 for (; cit != citend; ++cit) {
1002 currentChain =
dynamic_cast<Chain *
>(*cit);
1003 if (!currentChain) {
1007 if (pred(*currentChain) < 0) {
1011 __recursiveSplit(currentChain, func, pred0d, pred, sampling, newChains, splitted_chains);
1014 newChains.push_back(currentChain);
1018 if (!splitted_chains.empty()) {
1019 for (cit = splitted_chains.begin(), citend = splitted_chains.end(); cit != citend; ++cit) {
1022 splitted_chains.clear();
1025 _current_chains_set.clear();
1027 _current_chains_set = newChains;
1029 for (cit = newChains.begin(), citend = newChains.end(); cit != citend; ++cit) {
1030 if ((*cit)->getLength2D() <
M_EPSILON) {
1034 _current_chains_set.push_back(*cit);
1039 if (!_current_chains_set.empty()) {
1040 _current_set = &_current_chains_set;
1058 if ((*_pred)(*
i1, *i2) < 0) {
1059 throw std::runtime_error(
"comparison failed");
1070 if (!_current_set) {
1075 std::sort(_current_set->begin(), _current_set->end(), wrapper);
1077 catch (std::runtime_error &
e) {
1078 cerr <<
"Warning: Operator.sort(): " <<
e.what() << endl;
1089 float currentCurvilignAbscissa = 0.0f;
1095 Vec2r previous = current;
1099 bool hasSingularity =
false;
1104 sv =
dynamic_cast<SVertex *
>(&(*it));
1106 cerr <<
"Warning: unexpected Vertex type" << endl;
1115 Vec2r vec_tmp(current - previous);
1117 if (dist < 1.0e-6) {
1118 hasSingularity =
true;
1120 currentCurvilignAbscissa += dist;
1125 }
while (!
ELEM(it, itend, itfirst));
1127 if (it == itfirst) {
1131 sv =
dynamic_cast<SVertex *
>(&(*it));
1133 cerr <<
"Warning: unexpected Vertex type" << endl;
1143 Vec2r vec_tmp(current - previous);
1145 if (dist < 1.0e-6) {
1146 hasSingularity =
true;
1148 currentCurvilignAbscissa += dist;
1157 stroke->
setLength(currentCurvilignAbscissa);
1158 if (hasSingularity) {
1165 while (!vnext.
isEnd()) {
1167 next = (*vnext).getPoint();
1168 if ((
next - current).
norm() < 1.0e-6) {
1175 std::vector<StrokeVertex *> overlapping_vertices;
1176 overlapping_vertices.push_back(&(*
v));
1178 overlapping_vertices.push_back(&(*vnext));
1182 if (vnext.
isEnd()) {
1185 next = (*vnext).getPoint();
1186 }
while ((
next - current).
norm() < 1.0e-6);
1190 if (!vnext.
isEnd()) {
1191 target = (*vnext).getPoint();
1194 else if (!vprevious.
isBegin()) {
1195 target = (*vprevious).getPoint();
1203 current = overlapping_vertices.front()->getPoint();
1204 Vec2r dir(target - current);
1207 int nvert = overlapping_vertices.size();
1208 if (dist <
len * nvert) {
1215 std::vector<StrokeVertex *>::iterator it = overlapping_vertices.begin();
1217 for (
int n = 0; n < nvert; n++) {
1224 for (
int n = 0; n < nvert; n++) {
1231 if (vnext.
isEnd()) {
1245 bool warning =
false;
1246 while (!vnext.
isEnd()) {
1248 next = (*vnext).getPoint2D();
1249 if ((
next - current).
norm() < 1.0e-6) {
1257 printf(
"Warning: stroke contains singular points.\n");
1265 for (vector<StrokeShader *>::iterator it =
shaders.begin(); it !=
shaders.end(); ++it) {
1266 if ((*it)->shade(stroke) < 0) {
1276 if (!_current_set) {
1277 cerr <<
"Warning: current set empty" << endl;
1281 for (Operators::I1DContainer::iterator it = _current_set->begin(); it != _current_set->end();
1283 if (pred(**it) < 0) {
1297 new_strokes_set.push_back(stroke);
1301 for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end();
1303 _current_strokes_set.push_back(*it);
1305 new_strokes_set.clear();
1309 for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end();
1313 new_strokes_set.clear();
1321 cerr <<
"Error: no ViewMap computed yet" << endl;
1324 _current_view_edges_set.clear();
1325 for (I1DContainer::iterator it = _current_chains_set.begin(); it != _current_chains_set.end();
1329 _current_chains_set.clear();
1332 ViewMap::viewedges_container::iterator ve = vedges.begin(), veend = vedges.end();
1333 for (; ve != veend; ++ve) {
1337 _current_view_edges_set.push_back(*ve);
1339 _current_set = &_current_view_edges_set;
1340 if (removeStrokes) {
1341 _current_strokes_set.clear();
typedef float(TangentPoint)[2]
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
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()
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)