1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
|
//
// Copyright (C) : Please refer to the COPYRIGHT file distributed
// with this source distribution.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
///////////////////////////////////////////////////////////////////////////////
#include "Curve.h"
#include "CurveIterators.h"
#include "CurveAdvancedIterators.h"
/**********************************/
/* */
/* */
/* CurvePoint */
/* */
/* */
/**********************************/
CurvePoint::CurvePoint()
{
__A=0;
__B=0;
_t2d=0;
}
CurvePoint::CurvePoint(SVertex *iA, SVertex *iB, float t)
{
__A=iA;
__B=iB;
_t2d=t;
if((iA == 0) && (t == 1.f))
{
_Point2d=__B->point2d();
_Point3d=__B->point3d();
}
else if((iB == 0) && (t == 0.f))
{
_Point2d=__A->point2d();
_Point3d=__A->point3d();
}
else
{
_Point2d=__A->point2d()+_t2d*(__B->point2d()-__A->point2d());
_Point3d=__A->point3d()+_t2d*(__B->point3d()-__A->point3d());
}
}
CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)
{
__A = 0;
__B = 0;
float t1=iA->t2d();
float t2=iB->t2d();
if((iA->A() == iB->A()) && (iA->B() == iB->B()) && (iA->A() != 0) && (iA->B() != 0) && (iB->A() != 0) && (iB->B() != 0))
{
__A=iA->A();
__B=iB->B();
_t2d=t1+t2*t3-t1*t3;
}
else if((iA->B() == 0) && (iB->B() == 0))
{
__A = iA->A();
__B = iB->A();
_t2d = t3;
}
else if((iA->t2d() == 0) && (iB->t2d() == 0))
{
__A = iA->A();
__B = iB->A();
_t2d = t3;
}
else if(iA->A() == iB->A())
{
iA_A_eq_iB_A:
if(iA->t2d() == 0){
__A = iB->A();
__B = iB->B();
_t2d = t3;
}else if(iB->t2d() == 0){
__A = iA->A();
__B = iA->B();
_t2d = t3;
}
}
else if(iA->B() == iB->B())
{
iA_B_eq_iB_B:
if(iA->t2d() == 1){
__A = iB->A();
__B = iB->B();
_t2d = t3;
}else if(iB->t2d() == 1){
__A = iA->A();
__B = iA->B();
_t2d = t3;
}
}
else if(iA->B() == iB->A())
{
iA_B_eq_iB_A:
if((iA->t2d() != 1.f) && (iB->t2d() == 0.f))
{
__A = iA->A();
__B = iA->B();
_t2d=t1+t3-t1*t3;
//_t2d = t3;
}
else if((iA->t2d() == 1.f) && (iB->t2d() != 0.f))
{
__A = iB->A();
__B = iB->B();
//_t2d = t3;
_t2d=t2*t3;
}
else if((iA->getPoint2D() - iA->getPoint2D()).norm() < 1e-6) {
__A = iB->A();
__B = iB->B();
//_t2d = t3;
_t2d=t2*t3;
}
}
else if(iA->A() != 0 && iB->A() != 0 && (iA->A()->point3d() - iB->A()->point3d()).norm() < 1e-6)
{
goto iA_A_eq_iB_A;
}
else if(iA->B() != 0 && iB->B() != 0 && (iA->B()->point3d() - iB->B()->point3d()).norm() < 1e-6)
{
goto iA_B_eq_iB_B;
}
else if(iA->B() != 0 && iB->A() != 0 && (iA->B()->point3d() - iB->A()->point3d()).norm() < 1e-6)
{
goto iA_B_eq_iB_A;
}
if (!__A || !__B) {
printf("iA A 0x%p p (%f, %f)\n", iA->A(), iA->A()->getPoint2D().x(), iA->A()->getPoint2D().y());
printf("iA B 0x%p p (%f, %f)\n", iA->B(), iA->B()->getPoint2D().x(), iA->B()->getPoint2D().y());
printf("iB A 0x%p p (%f, %f)\n", iB->A(), iB->A()->getPoint2D().x(), iB->A()->getPoint2D().y());
printf("iB B 0x%p p (%f, %f)\n", iB->B(), iB->B()->getPoint2D().x(), iB->B()->getPoint2D().y());
printf("iA t2d %f p (%f, %f)\n", iA->t2d(), iA->getPoint2D().x(), iA->getPoint2D().y());
printf("iB t2d %f p (%f, %f)\n", iB->t2d(), iB->getPoint2D().x(), iB->getPoint2D().y());
cerr << "Fatal error in CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)" << endl;
}
assert(__A != 0 && __B != 0);
//_Point2d=__A->point2d()+_t2d*(__B->point2d()-__A->point2d());
//_Point3d=__A->point3d()+_t2d*(__B->point3d()-__A->point3d());
_Point2d= iA->point2d()+t3*(iB->point2d()-iA->point2d());
_Point3d=__A->point3d()+_t2d*(__B->point3d()-__A->point3d());
}
CurvePoint::CurvePoint(const CurvePoint& iBrother)
{
__A=iBrother.__A;
__B=iBrother.__B;
_t2d=iBrother._t2d;
_Point2d=iBrother._Point2d;
_Point3d=iBrother._Point3d;
}
CurvePoint& CurvePoint::operator=(const CurvePoint& iBrother)
{
__A=iBrother.__A;
__B=iBrother.__B;
_t2d=iBrother._t2d;
_Point2d=iBrother._Point2d;
_Point3d=iBrother._Point3d;
return *this;
}
FEdge *CurvePoint::fedge()
{
if(getNature() & Nature::T_VERTEX)
return 0;
return __A->fedge();
}
FEdge* CurvePoint::getFEdge(Interface0D& inter)
{
CurvePoint* iVertexB = dynamic_cast<CurvePoint*>(&inter);
if (!iVertexB) {
cerr << "Warning: CurvePoint::getFEdge() failed to cast the given 0D element to CurvePoint." << endl;
return 0;
}
if(((__A == iVertexB->__A) && (__B == iVertexB->__B))
||
((__A == iVertexB->__B) && (__B == iVertexB->__A)))
return __A->getFEdge(*__B);
else if(__B == 0)
{
if(iVertexB->__B == 0)
return __A->getFEdge(*(iVertexB->__A));
else if(iVertexB->__A == __A)
return __A->getFEdge(*(iVertexB->__B));
else if(iVertexB->__B == __A)
return __A->getFEdge(*(iVertexB->__A));
}
else if(iVertexB->__B == 0)
{
if(iVertexB->__A == __A)
return __B->getFEdge(*(iVertexB->__A));
else if(iVertexB->__A == __B)
return __A->getFEdge(*(iVertexB->__A));
}
else if(__B == iVertexB->__A)
{
if((_t2d != 1) && (iVertexB->_t2d == 0))
return __A->getFEdge(*__B);
if((_t2d == 1) && (iVertexB->_t2d != 0))
return iVertexB->__A->getFEdge(*(iVertexB->__B));
}
else if(__B == iVertexB->__B)
{
if((_t2d != 1) && (iVertexB->_t2d == 1))
return __A->getFEdge(*__B);
if((_t2d == 1) && (iVertexB->_t2d != 1))
return iVertexB->__A->getFEdge(*(iVertexB->__B));
}
else if(__A == iVertexB->__A)
{
if((_t2d == 0) && (iVertexB->_t2d != 0))
return iVertexB->__A->getFEdge(*(iVertexB->__B));
if((_t2d != 0) && (iVertexB->_t2d == 0))
return __A->getFEdge(*__B);
}
else if(__A == iVertexB->__B)
{
if((_t2d == 0) && (iVertexB->_t2d != 1))
return iVertexB->__A->getFEdge(*(iVertexB->__B));
if((_t2d != 0) && (iVertexB->_t2d == 1))
return __A->getFEdge(*__B);
}
#if 0
printf("__A 0x%p p (%f, %f)\n", __A, __A->getPoint2D().x(), __A->getPoint2D().y());
printf("__B 0x%p p (%f, %f)\n", __B, __B->getPoint2D().x(), __B->getPoint2D().y());
printf("iVertexB->A() 0x%p p (%f, %f)\n", iVertexB->A(), iVertexB->A()->getPoint2D().x(), iVertexB->A()->getPoint2D().y());
printf("iVertexB->B() 0x%p p (%f, %f)\n", iVertexB->B(), iVertexB->B()->getPoint2D().x(), iVertexB->B()->getPoint2D().y());
printf("_t2d %f p (%f, %f)\n", _t2d, getPoint2D().x(), getPoint2D().y());
printf("iVertexB->t2d() %f p (%f, %f)\n", iVertexB->t2d(), iVertexB->getPoint2D().x(), iVertexB->getPoint2D().y());
#endif
cerr << "Warning: CurvePoint::getFEdge() failed." << endl;
return 0;
}
Vec3r CurvePoint::normal() const
{
if(__B == 0)
return __A->normal();
if(__A == 0)
return __B->normal();
Vec3r Na = __A->normal();
if(Exception::getException())
Na = Vec3r(0,0,0);
Vec3r Nb = __B->normal();
if(Exception::getException())
Nb = Vec3r(0,0,0);
// compute t3d:
real t3d = SilhouetteGeomEngine::ImageToWorldParameter(__A->getFEdge(*__B),_t2d);
return ((1-t3d)*Na+t3d*Nb);
}
// Material CurvePoint::material() const
//{
// if(__A == 0)
// return __B->material();
// return __A->material();
//}
// Id CurvePoint::shape_id() const
// {
// if(__A == 0)
// return __B->shape_id();
// return __A->shape_id();
// }
const SShape * CurvePoint::shape() const
{
if(__A == 0)
return __B->shape();
return __A->shape();
}
// float CurvePoint::shape_importance() const
// {
// if(__A == 0)
// return __B->shape_importance();
// return __A->shape_importance();
// }
// const unsigned CurvePoint::qi() const
//{
// if(__A == 0)
// return __B->qi();
// if(__B == 0)
// return __A->qi();
// return __A->getFEdge(*__B)->qi();
//}
occluder_container::const_iterator CurvePoint::occluders_begin() const
{
if(__A == 0)
return __B->occluders_begin();
if(__B == 0)
return __A->occluders_begin();
return __A->getFEdge(*__B)->occluders_begin();
}
occluder_container::const_iterator CurvePoint::occluders_end() const
{
if(__A == 0)
return __B->occluders_end();
if(__B == 0)
return __A->occluders_end();
return __A->getFEdge(*__B)->occluders_end();
}
bool CurvePoint::occluders_empty() const
{
if(__A == 0)
return __B->occluders_empty();
if(__B == 0)
return __A->occluders_empty();
return __A->getFEdge(*__B)->occluders_empty();
}
int CurvePoint::occluders_size() const
{
if(__A == 0)
return __B->occluders_size();
if(__B == 0)
return __A->occluders_size();
return __A->getFEdge(*__B)->occluders_size();
}
const SShape * CurvePoint::occluded_shape() const
{
if(__A == 0)
return __B->occluded_shape();
if(__B == 0)
return __A->occluded_shape();
return __A->getFEdge(*__B)->occluded_shape();
}
const Polygon3r& CurvePoint::occludee() const
{
if(__A == 0)
return __B->occludee();
if(__B == 0)
return __A->occludee();
return __A->getFEdge(*__B)->occludee();
}
const bool CurvePoint::occludee_empty() const
{
if(__A == 0)
return __B->occludee_empty();
if(__B == 0)
return __A->occludee_empty();
return __A->getFEdge(*__B)->occludee_empty();
}
real CurvePoint::z_discontinuity() const
{
if(__A == 0)
return __B->z_discontinuity();
if(__B == 0)
return __A->z_discontinuity();
if(__A->getFEdge(*__B) == 0)
return 0.0;
return __A->getFEdge(*__B)->z_discontinuity();
}
//
// float CurvePoint::local_average_depth() const
//{
// return local_average_depth_function<CurvePoint >(this);
//}
//
// float CurvePoint::local_depth_variance() const
//{
// return local_depth_variance_function<CurvePoint >(this);
//}
//
// real CurvePoint::local_average_density(float sigma) const
//{
// //return local_average_density<CurvePoint >(this);
//
// return density_function<CurvePoint >(this);
//}
// Vec3r shaded_color() const ;
//
// Vec3r CurvePoint::orientation2d() const
// {
// if(__A == 0)
// return __B->orientation2d();
// if(__B == 0)
// return __A->orientation2d();
// return __B->point2d()-__A->point2d();
// }
//
// Vec3r CurvePoint::orientation3d() const
// {
// if(__A == 0)
// return __B->orientation3d();
// if(__B == 0)
// return __A->orientation3d();
// return __B->point3d()-__A->point3d();
// }
// real curvature2d() const {return viewedge()->curvature2d((_VertexA->point2d()+_VertexB->point2d())/2.0);}
//
// Vec3r CurvePoint::curvature2d_as_vector() const
//{
// // Vec3r edgeA = (_FEdges[0])->orientation2d().normalize();
// // Vec3r edgeB = (_FEdges[1])->orientation2d().normalize();
// // return edgeA+edgeB;
// //
// if(__A == 0)
// return __B->curvature2d_as_vector();
// if(__B == 0)
// return __A->curvature2d_as_vector();
// return ((1-_t2d)*__A->curvature2d_as_vector()+_t2d*__B->curvature2d_as_vector());
//}
//
// real CurvePoint::curvature2d_as_angle() const
//{
// // Vec3r edgeA = (_FEdges[0])->orientation2d();
// // Vec3r edgeB = (_FEdges[1])->orientation2d();
// // Vec2d N1(-edgeA.y(), edgeA.x());N1.normalize();
// // Vec2d N2(-edgeB.y(), edgeB.x());N2.normalize();
// // return acos((N1*N2));
//
// if(__A == 0)
// return __B->curvature2d_as_angle();
// if(__B == 0)
// return __A->curvature2d_as_angle();
// return ((1-_t2d)*__A->curvature2d_as_angle()+_t2d*__B->curvature2d_as_angle());
//}
real CurvePoint::curvatureFredo() const
{
if(__A == 0)
return __B->curvatureFredo();
if(__B == 0)
return __A->curvatureFredo();
return ((1-_t2d)*__A->curvatureFredo()+_t2d*__B->curvatureFredo());
}
Vec2d CurvePoint::directionFredo () const
{
if(__A == 0)
return __B->directionFredo();
if(__B == 0)
return __A->directionFredo();
return ((1-_t2d)*__A->directionFredo()+_t2d*__B->directionFredo());
}
/**********************************/
/* */
/* */
/* Curve */
/* */
/* */
/**********************************/
/* for functions */
Curve::~Curve()
{
if(!_Vertices.empty())
{
for(vertex_container::iterator it=_Vertices.begin(), itend =_Vertices.end();
it!=itend;
++it)
{
delete (*it);
}
_Vertices.clear();
}
}
/*! iterators access */
Curve::point_iterator Curve::points_begin(float step)
{
vertex_container::iterator second = _Vertices.begin();++second;
return point_iterator(_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), _nSegments, step, 0.f, 0.f);
//return point_iterator(_Vertices.begin(), second, _nSegments, step, 0.f, 0.f);
}
Curve::const_point_iterator Curve::points_begin(float step) const
{
vertex_container::const_iterator second = _Vertices.begin();++second;
return const_point_iterator(_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), _nSegments, step, 0.f, 0.f);
//return const_point_iterator(_Vertices.begin(), second, _nSegments, step, 0.f, 0.f);
}
Curve::point_iterator Curve::points_end(float step)
{
return point_iterator(_Vertices.end(), _Vertices.end(), _Vertices.begin(), _Vertices.end(), _nSegments, step, 1.f, _Length);
//return point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.f, _Length);
}
Curve::const_point_iterator Curve::points_end(float step) const
{
return const_point_iterator(_Vertices.end(), _Vertices.end(), _Vertices.begin(), _Vertices.end(), _nSegments, step, 1.f, _Length);
//return const_point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.f, _Length);
}
// Adavnced Iterators access
Curve::point_iterator Curve::vertices_begin(){return points_begin(0);}
Curve::const_point_iterator Curve::vertices_begin() const {return points_begin(0);}
Curve::point_iterator Curve::vertices_end(){return points_end(0);}
Curve::const_point_iterator Curve::vertices_end() const {return points_end(0);}
// specialized iterators access
CurveInternal::CurvePointIterator Curve::curvePointsBegin(float t){
vertex_container::iterator second = _Vertices.begin();++second;
return CurveInternal::CurvePointIterator(_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), 0, _nSegments, _Length, t, 0.f, 0.f);
}
CurveInternal::CurvePointIterator Curve::curvePointsEnd(float t){
vertex_container::iterator last = _Vertices.end();--last;
return CurveInternal::CurvePointIterator(last, _Vertices.end(), _Vertices.begin(), _Vertices.end(), _nSegments, _nSegments, _Length, t, 0.f, _Length);
}
CurveInternal::CurvePointIterator Curve::curveVerticesBegin(){
return curvePointsBegin(0);
}
CurveInternal::CurvePointIterator Curve::curveVerticesEnd(){
return curvePointsEnd(0);
}
Interface0DIterator Curve::pointsBegin(float t){
vertex_container::iterator second = _Vertices.begin();++second;
Interface0DIterator ret(new CurveInternal::CurvePointIterator(_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), 0, _nSegments, _Length, t, 0.f, 0.f));
return ret;
}
Interface0DIterator Curve::pointsEnd(float t){
vertex_container::iterator last = _Vertices.end();--last;
Interface0DIterator ret(new CurveInternal::CurvePointIterator(last, _Vertices.end(), _Vertices.begin(), _Vertices.end(), _nSegments, _nSegments, _Length, t, 0.f, _Length));
return ret;
}
Interface0DIterator Curve::verticesBegin(){
return pointsBegin(0);
}
Interface0DIterator Curve::verticesEnd(){
return pointsEnd(0);
}
// Vec3r shaded_color(int iCombination = 0) const ;
//
// Vec3r Curve::orientation2d(point_iterator it) const
//{
// return (*it)->orientation2d();
//}
/* template <class BaseVertex> */
/* Vec3r Curve::orientation2d(int iCombination) const */
/* { */
/* return edge_orientation2d_function<Curve >(this, iCombination); */
/* } */
//
// Vec3r Curve::orientation3d(point_iterator it) const
//{
// return (*it)->orientation3d();
//}
/* */
/* Vec3r Curve::orientation3d(int iCombination) const */
/* { */
/* return edge_orientation3d_function<Curve >(this, iCombination); */
/* } */
// real curvature2d(point_iterator it) const {return (*it)->curvature2d();}
// real curvature2d(int iCombination = 0) const ;
// Material Curve::material() const
//{
// const_vertex_iterator v=vertices_begin(), vend=vertices_end();
// const Material& mat = (*v)->material();
// for(;v!=vend;++v)
// {
// if((*v)->material() != mat)
// Exception::raiseException();
// }
// return mat;
//}
// int Curve::qi() const
//{
// const_vertex_iterator v=vertices_begin(), vend=vertices_end();
// int qi_= (*v)->qi();
// for(;v!=vend;++v)
// {
// if((*v)->qi() != qi_)
// Exception::raiseException();
// }
// return qi_;
//}
// occluder_container::const_iterator occluders_begin() const {return _FEdgeA->occluders().begin();}
// occluder_container::const_iterator occluders_end() const {return _FEdgeA->occluders().end();}
//int Curve::occluders_size() const
//{
// return qi();
//}
// bool Curve::occluders_empty() const
//{
// const_vertex_iterator v=vertices_begin(), vend=vertices_end();
// bool empty = (*v)->occluders_empty();
// for(;v!=vend;++v)
// {
// if((*v)->occluders_empty() != empty)
// Exception::raiseException();
// }
// return empty;
//}
// const Polygon3r& occludee() const {return *(_FEdgeA->aFace());}
// const SShape * Curve::occluded_shape() const
//{
// const_vertex_iterator v=vertices_begin(), vend=vertices_end();
// const SShape *sshape = (*v)->occluded_shape();
// for(;v!=vend;++v)
// {
// if((*v)->occluded_shape() != sshape)
// Exception::raiseException();
// }
// return sshape;
//}
// const bool Curve::occludee_empty() const
//{
// const_vertex_iterator v=vertices_begin(), vend=vertices_end();
// bool empty = (*v)->occludee_empty();
// for(;v!=vend;++v)
// {
// if((*v)->occludee_empty() != empty)
// Exception::raiseException();
// }
// return empty;
//}
/* */
/* real Curve::z_discontinuity(int iCombination) const */
/* { */
/* return z_discontinuity_edge_function<Curve >(this, iCombination); */
/* } */
// int Curve::shape_id() const
// {
// const_vertex_iterator v=vertices_begin(), vend=vertices_end();
// Id id = (*v)->shape_id();
// for(;v!=vend;++v)
// {
// if((*v)->shape_id() != id)
// Exception::raiseException();
// }
// return id.first;
// }
// const SShape * Curve::shape() const
//{
// const_vertex_iterator v=vertices_begin(), vend=vertices_end();
// const SShape *sshape = (*v)->shape();
// for(;v!=vend;++v)
// {
// if((*v)->shape() != sshape)
// Exception::raiseException();
// }
// return sshape;
//}
// occluder_container::const_iterator Curve::occluders_begin() const
//{
// const_vertex_iterator v=vertices_begin();
// return (*v)->occluders_begin();
//}
//
//
// occluder_container::const_iterator Curve::occluders_end() const
//{
// const_vertex_iterator v=vertices_end();
// return (*v)->occluders_end();
//}
/* */
/* Vec3r Curve::curvature2d_as_vector(int iCombination) const */
/* { */
/* return curvature2d_as_vector_edge_function<Curve >(this, iCombination); */
/* } */
/* */
/* real Curve::curvature2d_as_angle(int iCombination) const */
/* { */
/* return curvature2d_as_angle_edge_function<Curve >(this, iCombination); */
/* } */
/* */
/* float Curve::shape_importance(int iCombination) const */
/* { */
/* return shape_importance_edge_function<Curve >(this, iCombination); */
/* } */
/* */
/* float Curve::local_average_depth(int iCombination) const */
/* { */
/* return local_average_depth_edge_function<Curve >(this, iCombination); */
/* } */
/* */
/* float Curve::local_depth_variance(int iCombination ) const */
/* { */
/* return local_depth_variance_edge_function<Curve >(this, iCombination); */
/* // local_depth_variance_functor<Point> functor; */
/* // float result; */
/* // Evaluate<float, local_depth_variance_functor<Point> >(&functor, iCombination, result); */
/* // return result; */
/* } */
/* */
/* real Curve::local_average_density(float sigma, int iCombination ) const */
/* { */
/* return density_edge_function<Curve >(this, iCombination); */
/* // density_functor<Point> functor; */
/* // real result; */
/* // Evaluate<real, density_functor<Point> >(&functor, iCombination, result); */
/* // return result; */
/* } */
#define EPS_CURVA_DIR 0.01
void Curve::computeCurvatureAndOrientation ()
{
// const_vertex_iterator v=vertices_begin(), vend=vertices_end(), v2, prevV, v0;
// Vec2d p0, p1, p2;
// Vec3r p;
// p=(*v)->point2d();
// p0=Vec2d(p[0], p[1]);
// prevV=v; ++v;
// p=(*v)->point2d();
// p1=Vec2d(p[0], p[1]);
// Vec2d prevDir(p1-p0);
// for(;v!=vend;++v)
// {
// v2=v; ++v2;
// if (v2==vend) break;
// Vec3r p2=(*v2)->point2d();
// Vec2d BA=p0-p1;
// Vec2d BC=p2-p1;
// real lba=BA.norm(), lbc=BC.norm();
// BA.normalizeSafe();
// BC.normalizeSafe();
// Vec2d normalCurvature=BA+BC;
// Vec2d dir=Vec2d(BC-BA);
// Vec2d normal=Vec2d(-dir[1], dir[0]);
// normal.normalizeSafe();
// real curvature=normalCurvature*normal;
// if (lba+lbc > MY_EPSILON)
// curvature/=(0.5*lba+lbc);
// if (dir.norm() < MY_EPSILON)
// dir=0.1*prevDir;
// (*v)->setCurvatureFredo(curvature);
// (*v)->setDirectionFredo(dir);
// prevV=v; p0=p1; p1=p2; prevDir=dir; prevDir.normalize();
// }
// (*v)->setCurvatureFredo((*prevV)->curvatureFredo());
// (*v)->setDirectionFredo((*v)->point2d()-(*prevV)->point2d());
// v0=vertices_begin(); v2=v0; ++v2;
// (*v0)->setCurvatureFredo((*v2)->curvatureFredo());
// (*v0)->setDirectionFredo((*v2)->point2d()-(*v0)->point2d());
// //closed curve case one day...
// //
// return;
// //numerical degeneracy verification.. we'll see later
// const_vertex_iterator vLastReliable=vertices_begin();
// v=vertices_begin();
// p=(*v)->point2d();
// p0=Vec2d(p[0], p[1]);
// prevV=v; ++v;
// p=(*v)->point2d();
// p1=Vec2d(p[0], p[1]);
// bool isReliable=false;
// if ((p1-p0).norm>EPS_CURVA)
// {
// vLastReliable=v;
// isReliable=true;
// }
// for(;v!=vend;++v)
// {
// v2=v; ++v2;
// if (v2==vend) break;
// Vec3r p2=(*v2)->point2d();
// Vec2d BA=p0-p1;
// Vec2d BC=p2-p1;
// real lba=BA.norm(), lbc=BC.norm();
// if ((lba+lbc)<EPS_CURVA)
// {
// isReliable=false;
// cerr<<"/";
// }
// else
// {
// if (!isReliable)//previous points were not reliable
// {
// const_vertex_iterator vfix=vLastReliable;
// vfix++;
// for (; vfix!=v; ++vfix)
// {
// (*vfix)->setCurvatureFredo((*v)->curvatureFredo());
// (*vfix)->setDirectionFredo((*v)->directionFredo());
// }
// }
// isReliable=true;
// vLastReliable=v;
// }
// prevV=v; p0=p1; p1=p2;
// }
}
|