proj home

Files   Classes   Functions   Hierarchy  

pathlinesegvec Class Reference

pathlineseg with segment points in an array. Used for minimizing. More...

#include <pathlineseg.h>

Inheritance diagram for pathlinesegvec:
Collaboration diagram for pathlinesegvec:

List of all members.

Public Member Functions

doublec dist01 ()
doublec dist02 ()
doublec operator() ()
 Evaluates distance function to xi[dim].
void read ()
 Read ps state copying segment points to xi.
void write ()
 Write to ps with new state.
 pathlinesegvec (pathlineseg &ps_)
 Constructor.

Public Attributes

uint distfn
 Select the distance function 1 for dist01, 2 for dist02.
pathlinesegps
 Original.

Protected Types

typedef point2< double > pt2


Detailed Description

pathlineseg with segment points in an array. Used for minimizing.

Definition at line 49 of file pathlineseg.h.


Member Typedef Documentation

typedef point2<double> pathlinesegvec::pt2 [protected]

Definition at line 52 of file pathlineseg.h.


Constructor & Destructor Documentation

pathlinesegvec::pathlinesegvec ( pathlineseg ps_  ) 

Constructor.

Definition at line 114 of file pathlineseg.cpp.

00117   : funcstate<double>( (ps_.segments.size()/2+1)*2),
00118   distfn(2), ps(ps_), pts(ps_.pts), control(ps_.control),
00119   segments(ps_.segments) 
00120 {
00121 }


Member Function Documentation

doublec pathlinesegvec::dist01 (  ) 

Definition at line 148 of file pathlineseg.cpp.

References funcstate< double >::dim, line< PT, PD >::isnormalzero(), line< PT, PD >::nearestpointcapped(), line< PT, PD >::pos, and funcstate< double >::xi.

Referenced by dist02(), and operator()().

00149 {
00150   double dist=0.0;
00151 
00152   uint kmax=segments.size()/2;
00153   uint imax=control.size();
00154   double tpos;
00155   for (uint k=0; k<kmax; ++k)
00156   {
00157 //cout << "p" << segments[k] << " p" << segments[k+1] << " ";
00158     pt2 p0(xi[ k*2 ],xi[k*2+1]);
00159     pt2 p1(xi[(k+1)*2],xi[(k+1)*2+1]);
00160 //cout << SHOW(p0) << "  " << SHOW(p1) << endl;
00161     line< pt2, double > Lk(p0,p1,true);
00162 // cout << "ln" << (stringc)Lk << endl;
00163 
00164     for (uint i=0; i<imax; ++i)
00165     {
00166       pt2 const & q(pts[control[i]]);
00167 //cout << SHOW(k) << " " << control[i] << " " << q << " ";
00168       if (Lk.isnormalzero())
00169       {
00170 //cout << "nm is zero" << endl;
00171         dist += (Lk.pos-q).dot();
00172       }
00173       else
00174       {
00175         Lk.nearestpointcapped(tpos,q);
00176 //cout << "nearest point t=" <<  tpos << endl;
00177         dist += (Lk(tpos)-q).dot();
00178       }     
00179 //cout << SHOW(dist) << endl;
00180     }
00181   }
00182 
00183 //cout << SHOW(dim) << endl;
00184   xi[dim]=dist;
00185   return xi[dim];
00186 }

doublec pathlinesegvec::dist02 (  ) 

Definition at line 133 of file pathlineseg.cpp.

References funcstate< double >::dim, dist01(), and funcstate< double >::xi.

Referenced by operator()().

00134 {
00135   double dist=dist01();
00136   uint kmax=segments.size()/2;
00137   for (uint k=0; k<kmax; ++k)
00138   {
00139     pt2 p0(xi[ k*2 ],xi[k*2+1]);
00140     pt2 p1(xi[(k+1)*2],xi[(k+1)*2+1]);
00141     dist += (p0-p1).dot();    
00142   }
00143 
00144   xi[dim]=dist;
00145   return xi[dim];
00146 }

doublec pathlinesegvec::operator() (  )  [virtual]

Evaluates distance function to xi[dim].

Implements funcstate< double >.

Definition at line 124 of file pathlineseg.cpp.

References dist01(), dist02(), and distfn.

00125 {
00126   if (distfn==1)
00127     return dist01();
00128 
00129   assert(distfn==2);
00130   return dist02();
00131 }

void pathlinesegvec::read (  ) 

Read ps state copying segment points to xi.

Definition at line 188 of file pathlineseg.cpp.

References assertreturn, funcstate< double >::dim, and funcstate< double >::xi.

Referenced by pathlinesegtest::test03(), and pathlinesegtest::unittest01().

00189 {
00190   assertreturn(dim>0);
00191 
00192   xi[0] = pts[segments[0]].x;
00193   xi[1] = pts[segments[0]].y;
00194 
00195   uint j=2;
00196   uint imax=segments.size();
00197   for ( uint i=0; i<imax; ++i,++i)
00198   {
00199     assert(i+1<imax);
00200     xi[j++] = pts[segments[i+1]].x;
00201     xi[j++] = pts[segments[i+1]].y;
00202   }
00203 }

void pathlinesegvec::write (  ) 

Write to ps with new state.

Definition at line 205 of file pathlineseg.cpp.

References assertreturn, funcstate< double >::dim, and funcstate< double >::xi.

Referenced by pathlinesegtest::test03(), and pathlinesegtest::unittest01().

00206 {
00207   assertreturn(dim>0);
00208   assertreturn(segments.empty()==false);
00209 
00210   pts[segments[0]].x = xi[0];
00211   pts[segments[0]].y = xi[1];
00212 
00213   uint kmax=segments.size()/2;
00214   for (uint k=0; k<kmax; ++k)
00215   {
00216     pts[segments[2*k+1]].x = xi[(k+1)*2];
00217     pts[segments[2*k+1]].y = xi[(k+1)*2+1];
00218   }
00219 }


Member Data Documentation

Select the distance function 1 for dist01, 2 for dist02.

Definition at line 56 of file pathlineseg.h.

Referenced by operator()(), pathlinesegtest::test03(), and pathlinesegtest::unittest01().

Original.

Definition at line 62 of file pathlineseg.h.


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:08 2011 for Chelton Evans Source by  doxygen 1.5.8