1 // File: LineConn2d_Path.h
2 // Created: 11.08.05 15:08:00
3 // Author: Alexander GRIGORIEV
4 // Copyright: Open Cascade 2005
7 #ifndef LineConn2d_Path_HeaderFile
8 #define LineConn2d_Path_HeaderFile
10 #include <LineConn2d_Segment.h>
11 #include <LineConn2d.h>
12 #include <NCollection_List.hxx>
14 class LineConn2d_Model;
17 * Single path as temporary object created during the calculation of
18 * connections. It can be treated as:
19 * @li Segment having a definite orientation, origin and length. or
20 * @li 2D box along that segment, with a width equal to the model tolerance, or
21 * @li Node of the tree of Paths created during the calculations.
24 class LineConn2d_Path : public LineConn2d_Segment
27 // ---------- PUBLIC METHODS ----------
29 /// Empty Constructor.
30 Standard_EXPORT LineConn2d_Path ();
33 Standard_EXPORT LineConn2d_Path (const gp_XY& theStart,
35 const LineConn2d_Model& theModel,
36 const LineConn2d::Orient theOri =
37 LineConn2d::Indefinite);
41 Standard_EXPORT Standard_Real Width () const;
46 inline const LineConn2d_Path& Parent () const
47 { return * myParent; }
50 * Query the orientation, according to the given Side
52 * Defines the side on which the orientation is calculated.
57 Standard_EXPORT LineConn2d::Orient Orientation (const Standard_Integer theSide
61 * Query the limitation of the Path.
63 * @li -1: limited on the left;
64 * @li 0: limited on the front or unlimited;
65 * @li 1: limited on the right.
67 inline Standard_Integer Limitation () const
68 { return myLimitation; }
71 * Query the direction according to the given Side.
73 * Defines the side on which the direction is calculated.
78 * Unit vector of the corresponding direction.
80 Standard_EXPORT gp_XY Direction (const Standard_Integer theSide
84 * Query the price associated with the end of the current Path.
85 * The price is calculated by the method Evaluate().
87 * - the distance is calculated as sum of absolute distances along X and Y.
88 * - the distance contribution to the price is percent of the half-perimeter
90 * - each change of orientation gives the contribution of PriceOfBreak points.
92 inline Standard_Integer Price () const
93 { return myPriceLen + myPriceDist; }
96 * Create a Path in the given direction. The Path stops at an Object or
97 * at the boundary of the Model.
101 * Used to provide the set of Objects, to properly stop the Path.
103 * Beginning of the Path.
105 * Orientation of the Path.
107 * True indicates the the root path is built.
111 static Standard_EXPORT Standard_Boolean
112 createPath (LineConn2d_Path& outPath,
113 const LineConn2d_Model& theModel,
114 const gp_XY& theStart,
115 const LineConn2d::Orient theOrient,
116 const Standard_Boolean isRoot);
119 * Evaluate the price of the trajectory where the current Path is the last
120 * one. This is done by incrementing the price of the Parent by the addition
121 * due to this Path element.
122 * <p>This method also checks if the path ends on theTarget, if yes then it
123 * sets the flag myIsComplete.
125 * Target point of the path sequence (the end of the calculated connection)
127 Standard_EXPORT Standard_Integer
128 Evaluate (const gp_XY& theTarget);
131 * Add the branch path. This method sets the Parent field in theBranch
133 * Path added as branch to the current one.
135 * Target point for price evaluation (method Evaluate is called with it).
137 Standard_EXPORT void AddBranch (LineConn2d_Path& theBranch,
138 const gp_XY& theTarget);
141 * Query if the Path is completed.
143 inline Standard_Boolean
145 { return myIsComplete; }
148 * Project orthogonally the given point on the Path segment.
150 * Output parameter, the projection point belonging to the inside of
151 * the Path segment (only updated if the method returns True).
153 * The given point to be projected.
155 * True if the projection is found inside the Path segment
157 Standard_EXPORT Standard_Boolean ProjectPoint
159 const gp_XY& thePoint) const;
162 * Price contributon of one path break (change of orientation)
164 static inline Standard_Integer
169 // ---------- PROTECTED METHODS ----------
173 // ---------- PRIVATE FIELDS ----------
174 const LineConn2d_Model * myModel;
175 const LineConn2d_Path * myParent;
176 NCollection_List <LineConn2d_Path> myBranches;
177 Standard_Integer myPriceLen;
178 Standard_Integer myPriceDist;
179 Standard_Integer myLimitation; ///< -1, 0(def) or 1
180 LineConn2d::Orient myOrient;
181 Standard_Boolean myIsComplete;
183 friend class LineConn2d_PathIterator;