Files Classes Functions Hierarchy
#include <pathlineseg.h>
Public Types | |
| typedef point2< double > | pt2 |
| typedef point2< double > const | pt2c |
Public Member Functions | |
| pathlineseg () | |
| Empty. | |
| operator stringc const () | |
| Serialize. | |
| void | serializeInverse (stringc &str) |
| Read and create this class. | |
| doublec | dist01 () |
| sum d(segment k,control[i])^2 | |
| doublec | dist02 () |
| sum ((segment length[k])^2) + dist01. | |
Public Attributes | |
| vector< pt2 > | pts |
| Points, pts[0] is not used as 0 is no point. | |
| vector< uint > | control |
| Indexes to control points. | |
| vector< uint > | segments |
| Pairs of indexes to line segments. | |
Definition at line 14 of file pathlineseg.h.
| typedef point2<double> pathlineseg::pt2 |
Definition at line 18 of file pathlineseg.h.
| typedef point2<double> const pathlineseg::pt2c |
Definition at line 19 of file pathlineseg.h.
| pathlineseg::pathlineseg | ( | ) |
| doublec pathlineseg::dist01 | ( | ) |
sum d(segment k,control[i])^2
Definition at line 73 of file pathlineseg.cpp.
References control, line< PT, PD >::isnormalzero(), line< PT, PD >::nearestpointcapped(), line< PT, PD >::pos, pts, and segments.
Referenced by dist02().
00074 { 00075 double dist=0.0; 00076 00077 uint kmax=segments.size(); 00078 uint imax=control.size(); 00079 double tpos; 00080 for (uint k=0; k<kmax; ++k, ++k) 00081 { 00082 //cout << "p" << segments[k] << " p" << segments[k+1] << " "; 00083 pt2 p0(pts[ segments[k]]); 00084 pt2 p1(pts[ segments[k+1]]); 00085 line< pt2, double > Lk(p0,p1,true); 00086 //line< pt2, double > Lk( pts[ segments[k]], pts[segments[k+1]], true ); 00087 00088 //cout << SHOW(p0) << " " << SHOW(p1) << endl; 00089 //cout << "ln" << (stringc)Lk << endl; 00090 00091 for (uint i=0; i<imax; ++i) 00092 { 00093 pt2 const & q(pts[control[i]]); 00094 //cout << SHOW(k) << " " << control[i] << " " << q << " "; 00095 if (Lk.isnormalzero()) 00096 { 00097 //cout << "nm is zero" << endl; 00098 dist += (Lk.pos-q).dot(); 00099 } 00100 else 00101 { 00102 Lk.nearestpointcapped(tpos,q); 00103 //cout << "nearest point t=" << tpos << endl; 00104 dist += (Lk(tpos)-q).dot(); 00105 } 00106 //cout << SHOW(dist) << endl; 00107 } 00108 00109 } 00110 00111 return dist; 00112 }
| doublec pathlineseg::dist02 | ( | ) |
sum ((segment length[k])^2) + dist01.
Definition at line 59 of file pathlineseg.cpp.
References dist01(), pts, and segments.
00060 { 00061 double dist=dist01(); 00062 uint kmax=segments.size()/2; 00063 for (uint k=0; k<kmax; ++k) 00064 { 00065 pt2c & p0(pts[ segments[k*2] ]); 00066 pt2c & p1(pts[ segments[k*2+1] ]); 00067 dist += (p0-p1).dot(); 00068 } 00069 00070 return dist; 00071 }
| pathlineseg::operator stringc const | ( | ) |
Serialize.
Definition at line 16 of file pathlineseg.cpp.
References control, printvecfunc(), pts, and segments.
00017 { 00018 string str; 00019 00020 str << "<path>\n"; 00021 // TODO optionally write if variable empty 00022 str << "<info>Path line segements</info>\n"; 00023 00024 str << "<points2D>\n"; 00025 assert(pts.empty()==false); 00026 if (pts.empty()==false) 00027 { str << printvecfunc(pts.begin(),pts.size()) << "\n"; } 00028 str << "</points2D>\n"; 00029 str << "<control>\n"; 00030 if (control.empty()==false) 00031 { str << printvecfunc(control.begin(),control.size()) << "\n"; } 00032 str << "</control>\n"; 00033 str << "<segments>\n"; 00034 if (segments.empty()==false) 00035 { str << printvecfunc(segments.begin(),segments.size()) << "\n"; } 00036 str << "</segments>\n"; 00037 str << "</path>"; 00038 00039 return str; 00040 }
| void pathlineseg::serializeInverse | ( | stringc & | str | ) |
Read and create this class.
Definition at line 42 of file pathlineseg.cpp.
References control, stringtagparser::data(), pts, and segments.
Referenced by pathlinesegtest::test01(), pathlinesegtest::test02(), and pathlinesegtest::test03().
00043 { 00044 //assert(false); 00045 pts.clear(); 00046 control.clear(); 00047 segments.clear(); 00048 00049 stringtagparser pars(str); 00050 00051 string s1 = pars.data("info"); 00052 //cout << "*info=" << s1 << "*" << endl; 00053 string s2=pars.data("points2D"); 00054 vectorstring::serializeInverse(pts,s2); 00055 vectorstring::serializeInverse(control,pars.data("control")); 00056 vectorstring::serializeInverse(segments,pars.data("segments")); 00057 }
| vector<uint> pathlineseg::control |
Indexes to control points.
Definition at line 25 of file pathlineseg.h.
Referenced by dist01(), operator stringc const(), serializeInverse(), and pathlinesegdraw::update().
| vector< pt2 > pathlineseg::pts |
Points, pts[0] is not used as 0 is no point.
Definition at line 22 of file pathlineseg.h.
Referenced by dist01(), dist02(), operator stringc const(), pathlineseg(), serializeInverse(), and pathlinesegdraw::update().
| vector<uint> pathlineseg::segments |
Pairs of indexes to line segments.
eg 2 4 5 6 .. is (2,4), (5,6), ..
Definition at line 27 of file pathlineseg.h.
Referenced by dist01(), dist02(), operator stringc const(), serializeInverse(), pathlinesegtest::test02(), and pathlinesegdraw::update().
1.5.8