ProcessDistance Class Reference

If a platonic piece of string whose length l and endpoints (p0,p1) is laid along a path [e0,e1,e2,....en], this class calculates the index of the element ei, which contains p1 and the parameter mu (0<=mu<1) which can be used to calculate the actual coordinate value of p1. More...

#include <pathproc.h>

Inheritance diagram for ProcessDistance:

ProcessPath CCObject SimpleCCObject List of all members.

Public Member Functions

 ProcessDistance (const double flat)
 Constructor for processdistance.
double PathDistance (const double dist, Path *Input, INT32 *index)
 Returns information about a point, which lies a particular distance along a path.
virtual void OpenElement (PathVerb Verb, INT32 index)
 Called from ProcessPath which is about to open a new path element.
virtual BOOL NewPoint (PathVerb Verb, DocCoord *pCoord)
 Called from ProcessPath which has generated a new point on the open element.
virtual BOOL CloseElement (BOOL ok, PathVerb Verb, INT32 index)
 This function is called after processing all new points on a path element. The path element being a curve or line segment within the path passed to ProcessDistance::PathDistance(). The function will use the element length calculated by NewPoint and decrement the total path length by this amount. If at some point the working distance goes negative, a parameter is calculated along the element.

Private Attributes

double Distance
INT32 ElementIndex
double ElementLength
double ElementParam
DocCoord PrevCoord

Detailed Description

If a platonic piece of string whose length l and endpoints (p0,p1) is laid along a path [e0,e1,e2,....en], this class calculates the index of the element ei, which contains p1 and the parameter mu (0<=mu<1) which can be used to calculate the actual coordinate value of p1.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/10/94

Definition at line 242 of file pathproc.h.


Constructor & Destructor Documentation

ProcessDistance::ProcessDistance const double  flat  ) 
 

Constructor for processdistance.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/11/94
Parameters:
flat = flattness threshold to be used when processing the path [INPUTS]

Definition at line 778 of file pathproc.cpp.

00778                                                   : ProcessPath(flat)
00779 {
00780     ElementLength = 0;
00781     ElementParam = 0;
00782     ElementIndex = 0;
00783 
00784 
00785 }


Member Function Documentation

BOOL ProcessDistance::CloseElement BOOL  done,
PathVerb  Verb,
INT32  index
[virtual]
 

This function is called after processing all new points on a path element. The path element being a curve or line segment within the path passed to ProcessDistance::PathDistance(). The function will use the element length calculated by NewPoint and decrement the total path length by this amount. If at some point the working distance goes negative, a parameter is calculated along the element.

BOOL ProcessDistance::CloseElement(BOOL done, PathVerb Verb, INT32 index)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/10/94
Parameters:
done = true if the new point function procesed all new points in the [INPUTS] open element correctly, false if it did not. Verb = verb of closing element. index = index of closing element.
[OUTPUTS] 

Reimplemented from ProcessPath.

Definition at line 899 of file pathproc.cpp.

00900 {
00901     if (done)
00902     {
00903         Distance-=ElementLength;
00904         INT32 nextindex = index;
00905         if ((Distance>0) && ProcSource->FindNextEndPoint(&nextindex))
00906             return FALSE;
00907 
00908         Distance+=ElementLength;
00909         ElementIndex = index;
00910 
00911         if (ElementLength>0)
00912             ElementParam = Distance / ElementLength;
00913         else
00914             ElementParam = 0;
00915 
00916         return TRUE;
00917 
00918     }
00919     return FALSE;
00920 }

BOOL ProcessDistance::NewPoint PathVerb  Verb,
DocCoord pCoord
[virtual]
 

Called from ProcessPath which has generated a new point on the open element.

BOOL ProcessDistance::NewPoint(PathVerb Verb, DocCoord* pCoord)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/10/94

Implements ProcessPath.

Definition at line 864 of file pathproc.cpp.

00865 {
00866     if (!ProcFirstPoint)
00867     {
00868         double p0 = PrevCoord.x - pCoord->x;
00869         double p1 = PrevCoord.y - pCoord->y;
00870         ElementLength += sqrt((p0*p0)+(p1*p1));
00871     }
00872     PrevCoord = *pCoord;
00873     return TRUE;
00874 }

void ProcessDistance::OpenElement PathVerb  Verb,
INT32  index
[virtual]
 

Called from ProcessPath which is about to open a new path element.

void ProcessDistance::OpenElement(PathVerb Verb, INT32 index)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/10/94
Parameters:
Verb = verb of opening element. [INPUTS] index = index of opening element.

Reimplemented from ProcessPath.

Definition at line 845 of file pathproc.cpp.

00846 {
00847     ElementLength = 0;
00848     ElementParam = 0;
00849     ElementIndex = 0;
00850 }

double ProcessDistance::PathDistance const double  dist,
Path pSource,
INT32 *  index
 

Returns information about a point, which lies a particular distance along a path.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/11/94
Parameters:
sqrdist = a distance along the path pSource [INPUTS] pSource = a pointer to a path
index = the index of an element in the path [OUTPUTS]
Returns:
double = an element parameter p where 0<=p<=1 such that p is the squared distance along the path pSource.
See also:
Path::ClosestPointTo(), which will return a doccoord given a parameter p and index i.

Definition at line 807 of file pathproc.cpp.

00808 {
00809     ENSURE(dist>=0, "distance along path is negative in ProcessDistance::PathDistance");
00810 
00811     if (dist>0)
00812         Distance = dist;
00813     else
00814         Distance = 0;
00815 
00816     // if we have a simple position then return the start
00817     if (Distance == 0)
00818     {
00819         *index = 0;
00820         return 0;
00821     }
00822 
00823     // set up the processpath process.
00824     ProcessFlags PFlags;
00825     BOOL ok = ProcessPath::Init(pSource);
00826     if (ok) ok = ProcessPath::Process(PFlags);
00827     if (ok) *index = ElementIndex;
00828 
00829     return ElementParam;
00830 }


Member Data Documentation

double ProcessDistance::Distance [private]
 

Definition at line 252 of file pathproc.h.

INT32 ProcessDistance::ElementIndex [private]
 

Definition at line 253 of file pathproc.h.

double ProcessDistance::ElementLength [private]
 

Definition at line 254 of file pathproc.h.

double ProcessDistance::ElementParam [private]
 

Definition at line 255 of file pathproc.h.

DocCoord ProcessDistance::PrevCoord [private]
 

Definition at line 256 of file pathproc.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:00:08 2007 for Camelot by  doxygen 1.4.4