TrapsList Class Reference

Simple class containing a list of TrapEdgeLists representing a complex path Each TrapEdgeList represents a sub-path of the overall source path. More...

#include <pathtrap.h>

Inheritance diagram for TrapsList:

CCObject SimpleCCObject List of all members.

Public Member Functions

 TrapsList (INT32 Repeat=0)
 Constructor.
 ~TrapsList ()
 Destructor.
UINT32 GetNumTraps (void)
TrapEdgeListGetTrapEdgeList (UINT32 index)
TrapEdgeListGetLastTrapEdgeList (void)
TrapEdgeListAddEdgeList (void)
 Add a new TrapEdgeList object to this list.
BOOL PostProcessLists (ProcessPathToTrapezoids *pProcessor, TrapTravelType TravelType)
 Scans the recorded list of TrapEdgeLists and fills in the remaining information (normals and position values) for all trapezoids therein.
INT32 GetRepeatLength (void)

Protected Member Functions

BOOL ExpandArray (void)
 (Internal method) Expands the storage structure of the list to allow more entries to be used. Called automatically by AddEdgeList if it needs more edges.

Protected Attributes

UINT32 Used
UINT32 CurrentSize
TrapEdgeList ** pTraps
INT32 RepeatLength

Detailed Description

Simple class containing a list of TrapEdgeLists representing a complex path Each TrapEdgeList represents a sub-path of the overall source path.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Notes: Sorry, Jim, but I've had to use inlining to keep common operations efficient

Definition at line 369 of file pathtrap.h.


Constructor & Destructor Documentation

TrapsList::TrapsList INT32  Repeat = 0  ) 
 

Constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Parameters:
Repeat - 0 to generate a single stroke (TrapEdgeList) per subpath, which [INPUTS] will cause the stroke to be stretched along the entire path, or...
a millipoint repeat distance (which will cause many TrapEdgelists to be generated), such that the stroke repeats along the path.

Definition at line 683 of file pathtrap.cpp.

00684 {
00685     Used         = 0;
00686     CurrentSize  = 0;
00687     pTraps       = NULL;
00688     RepeatLength = Repeat;
00689 }

TrapsList::~TrapsList  ) 
 

Destructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96

Definition at line 704 of file pathtrap.cpp.

00705 {
00706     if (pTraps != NULL)
00707     {
00708         for (UINT32 Index = 0; Index < Used; Index++)
00709             delete pTraps[Index];
00710 
00711         CCFree(pTraps);
00712     }
00713 }


Member Function Documentation

TrapEdgeList * TrapsList::AddEdgeList void   ) 
 

Add a new TrapEdgeList object to this list.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Returns:
NULL if it failed to allocate memory, else a pointer to a new TrapEdgeList object for you to use

Definition at line 731 of file pathtrap.cpp.

00732 {
00733     if (Used >= CurrentSize)        // If we've run out of room in the array
00734     {
00735         if (!ExpandArray())         // Try to allocate more
00736             return(NULL);           // And return NULl if we failed
00737     }
00738 
00739     TrapEdgeList *pObject = new TrapEdgeList(this);
00740     if (pObject == NULL)
00741         return(NULL);
00742 
00743     pTraps[Used] = pObject;
00744     Used++;
00745 
00746     return(pObject);
00747 }

BOOL TrapsList::ExpandArray void   )  [protected]
 

(Internal method) Expands the storage structure of the list to allow more entries to be used. Called automatically by AddEdgeList if it needs more edges.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Parameters:
On succesful exit, the member array of TrapEdgeList objects will be bigger [OUTPUTS]
Returns:
FALSE if it failed to allocate memory
Notes: Internal storage is an array of TrapEdgeList _pointers_ To use an item, you must therefore

Definition at line 770 of file pathtrap.cpp.

00771 {
00772     // Work out how many entries to allocate.
00773     // Each item is small, so we allocate a reasonably large number
00774     // Note that potential implementation of dashed lines could create a lot of 
00775     // TrapEdgeLists (one per dash), so we need lots of spare capacity to cope
00776     // with this situation. I've therefore erred on the generous side.
00777     const INT32 AllocSize = CurrentSize + 64;
00778 
00779     if (pTraps == NULL)
00780     {
00781         // We have no array yet, so allocate one
00782         pTraps = (TrapEdgeList **) CCMalloc(AllocSize * sizeof(TrapEdgeList *));
00783         if (pTraps == NULL)
00784             return(FALSE);
00785     }
00786     else
00787     {
00788         // We have an array - we must make it larger
00789         TrapEdgeList **pNewBuf = (TrapEdgeList **) CCRealloc(pTraps, AllocSize * sizeof(TrapEdgeList *));
00790         if (pNewBuf == NULL)
00791             return(FALSE);
00792 
00793         pTraps = pNewBuf;
00794     }
00795 
00796     // Success. Update the current size value
00797     CurrentSize = AllocSize;
00798 
00799     // Initialise the pointers to safe values
00800     for (UINT32 Index = Used; Index < CurrentSize; Index++)
00801         pTraps[Index] = NULL;
00802 
00803     return(TRUE);
00804 }

TrapEdgeList* TrapsList::GetLastTrapEdgeList void   )  [inline]
 

Definition at line 384 of file pathtrap.h.

00385                                     { return((Used == 0) ? NULL : pTraps[Used-1]); };

UINT32 TrapsList::GetNumTraps void   )  [inline]
 

Definition at line 377 of file pathtrap.h.

00377 { return(Used); };

INT32 TrapsList::GetRepeatLength void   )  [inline]
 

Definition at line 394 of file pathtrap.h.

00394 { return(RepeatLength); };

TrapEdgeList* TrapsList::GetTrapEdgeList UINT32  index  )  [inline]
 

Definition at line 380 of file pathtrap.h.

00381                                     { ERROR3IF(index >= Used, "Out of range"); return(pTraps[index]); };

BOOL TrapsList::PostProcessLists ProcessPathToTrapezoids pProcessor,
TrapTravelType  TravelType
 

Scans the recorded list of TrapEdgeLists and fills in the remaining information (normals and position values) for all trapezoids therein.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Parameters:
pProcessor - The object which is calling us [INPUTS] TravelType - Describes how to record "positions" along the path: TrapTravel_None Don't record travel (FASTEST) TrapTravel_Parametric 0.0 to 1.0 parametric range TrapTravel_Millipoint Absolute millipoints distance
On succesful exit, the member TrapEdgeList objects will be complete [OUTPUTS]
Returns:
FALSE if it failed to complete the operation (Note: No error is set at this level)
MUST be called on the list before trying to use the edge structures!

Notes: TrapTravel_None will leave edge "Position" values TOTALLY UNINITIALISED

Definition at line 838 of file pathtrap.cpp.

00840 {
00841 // There is a problem with fixed repeating vector brushes sometimes doing a bit
00842 // more than they should, in other words, a 6 repeat brush starting on the 7th
00843 // repeat, or at least adding 1 trap to the list for it...
00844 // The commented out stuff below was the last ever bit of code written by Jason.
00845 // It was intended as a fix, but I (Richard) never got round to getting it compiling
00846 // let alone testing it. Since the stroking job is now no more, and also since this
00847 // comment is still here, I suspect the problem still remains. To see it in action
00848 // you need to draw a wibbly filled freehand shape and pop the gallery up. The
00849 // symptoms are a bizarre line to the right of the preview. It's tricky to get a
00850 // repeating case...
00851 // Jason, if you decided to come back, good on you mate... If not, may I wish
00852 // whoever is reading this all the best with the stroking system - blimmin
00853 // fabby, innit ?
00854 /*  BOOL DiscardPartialRepeats = TRUE;
00855 
00856     if (RepeatDist > 0 && DiscardPartialRepeats && Used > 1)
00857     {
00858         TrapEdge *pEdge = pTraps[Used-1]->GetLastTrapEdge();
00859         if (pEdge != NULL && pEdge->Position < RepeatDist/2)
00860         {
00861             delete pTraps[Used-1];
00862             pTraps[Used-1] = NULL;
00863             Used--;
00864         }
00865     }*/
00866 
00867     for (UINT32 Index = 0; Index < Used; Index++)
00868     {
00869         if (pTraps[Index] != NULL)
00870         {
00871             if (!pTraps[Index]->ProcessEdgeNormals(pProcessor))
00872                 return(FALSE);
00873 
00874             if (!pTraps[Index]->ProcessEdgePositions(TravelType))
00875                 return(FALSE);
00876         }
00877     }
00878 
00879     return(TRUE);
00880 }


Member Data Documentation

UINT32 TrapsList::CurrentSize [protected]
 

Definition at line 403 of file pathtrap.h.

TrapEdgeList** TrapsList::pTraps [protected]
 

Definition at line 404 of file pathtrap.h.

INT32 TrapsList::RepeatLength [protected]
 

Definition at line 406 of file pathtrap.h.

UINT32 TrapsList::Used [protected]
 

Definition at line 402 of file pathtrap.h.


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