Close and Smooth - A pair of Xtras for Macromedia FreeHand ========================================================== From Pat Dunlavey Cartographics 8/31/98 Close.x32 ========= Close was written to address a situation that is common in cartography, where paths which are intended to be closed, come into FreeHand (usually via DXF) as unclosed paths. This is especially common with data deriving from GIS databases, where the closed attribute of a path is not explicitly defined in the geometry, but rather in a linked attribute which does not survive the translation into FreeHand. Once these paths are in FreeHand, the task of closing them can be laborious in the extreme, since FreeHand offers no method other than individually selecting each path and closing it via the object inspector, one at a time. If you happen to be working on a map of, say, Minnesota, and need to close every single lake, the job can take days, and cost much in lost sanity and repetitive stress injuries. Close was written to address this problem. With Close, you can select all the paths at once, run the Close Xtra, and they can all be closed instantly. Close was also written to deal with the problem of contours - some should be closed (hills, depressions), and some should not. By entering a close tolerance, you can apply Close only to those paths whose end points fall within that distance tolerance. Another feature in Close allows you to drop the last point on the path prior to closing it. This is useful if you intend to connect the vertices on the path with smooth bezier curves, and do not wish to have a kink at the start/end point caused by coincident points or points too close together. Usage: ===== When you launch FH, "Close" will appear in your Operations palette, and under Path Operations... in the Xtras menu. Close works on any number of selected paths which have more than 2 points. After selecting the paths, invoke Close by clicking the button on the Operations palette, or selecting the Xtras>Path Operations...>Close... menu. A small dialog will appear, offering three choices: Always close (close all paths of three points or more) Close when the start and end points touch. Close only when start and end points fall within a user-defined distance of each other. If this option is chosen, then a text field will activate, allowing you to enter a value for this distance, using the current units (e.g. points, inches). A check box allows you to control whether the last point on the path gets deleted prior to closing the path. This is especially useful if the start and end points are close together, you intend to subsequently run "Smooth", and need to have that start/end vertex appear smooth. Smooth.x32 ========== Smooth was written to address another situation that is common when working from imported GIS data that usually come into FreeHand through a process which does not support continuous curvature in paths such as contours and streams. Since artwork in FreeHand is generally intended for high quality publication, it is important that we cartographers have a way of smoothing the representation of these paths, while keeping them faithful to the true path. Paths in a GIS dataset are commonly filtered through a point-reduction algorithm that removes points regarded as redundant. Most often, this filter works by imposing an imaginary tube along the the path, and any intermediate points that fall within the tube are discarded. This can result in long path segments without any points, where the original path was mostly straight. FreeHand, through the object inspector, offers the possibility to apply automatic smoothing to at most one path at a time, and requires you to select each vertex to be smoothed. If you have ever tried it, you don't need to be told that selecting all the points on one path without accidently selecting any other paths can be practically impossible, especially when working with contours, for example. Michael Slomski has written an Xtra (for 68K Macintosh) which will select all the points on a selected path. But FreeHand's object inspector still limits automatic smoothing to one path at a time. FreeHand's automatic smoothing suffers from a couple other problems as well, when applied to cartographic situations. The first is that it will always extend the bezier handles to 0.395 times the length of the adjacent line segment. If the line segments (distances between points) are always short, this may not be a problem. However, tube-width filtering often leaves long path segments, and FreeHand will extend the bezier handles without limit, often resulting in big looping curves where the path should actually conform quite closely to the straight line segment. The second problem has to do with the way FreeHand smooths the end points on an unclosed path. FreeHand will extend the bezier handles on these points straight towards the previous/next point, usually resulting in an S-curve. Smooth addresses these limitations: by allowing points to be smoothed on any number of selected paths (if no points are selected on a path, then all the points will be smoothed); by allowing you to impose a limit beyond which the bezier handles will not be extended (as measured perpendicular to the path segment - a kind of tube-width filter in reverse); and by always retracting the bezier handles on the end points of an unclosed path so that the curve may "fall" naturally into the point, without creating the "S-curve" artifact. Smooth works on any path of two points or more, and will smooth the paths within a group or composite path (joined). If you want to restrict smoothing to a certain path or paths within a group or composite object, you must sub-select those paths. Two-point paths can be smoothed also. If the path is not closed, the result will simply be a straight line (the bezier handles on the two end points are retracted). If the path is closed, then the smoothed path will appear as an ellipse. The standard bezier handle extension is 0.395 times the length of the adjacent straight line segment. With this degree of extension, a square will smooth to an approximation of a circle. Smooth's smoothing limit is the distance measured perpendicularly to the line segment (using the current units of measure). The bezier handle may be extended up to 0.395 times the length of the line segment as long as it falls inside this perpendicular distance from the line, otherwise it will be truncated. In my experience, the resulting smooth curve does not extend beyond about 2/3 of this smoothing limit from the straight line section. Therefore, if you want to have the curves stay within, say 0.1 inch of the straight line path, then you could set the smoothing limit to 0.15 inches. You will probably have to experiment with different smoothing limits to determine what works best for your data. Smooth operations are undoable! A word about this Smooth Xtra versus FreeHand's Simplify command: Smooth does not modify the points on path, it merely changes the way that the dots are connected (my working title for this Xtra was "Connect the Dots"). Simplify works by creating a new path that more or less closely approximates the original path. I find that Simplify's behavior is often not helpful. Simplify generalizes paths, turning subtly curving sections into broad simple curves, and tightly curving sections into sharp corners. Smooth does not generalize. It simply connects the points with appropriately smooth continuous curves. Each has it's own application, and they may be used in combination as well. You might run Simplify on a path, and then run Smooth to eliminate corner points. Usage: ===== When you launch FH, Smooth will appear in your Operations palette, and under Path Operations... in the Xtras menu. Smooth works on any number of selected points and selected paths. If points are selected on a path, only those points will be smoothed on that path. After making your selection, invoke Smooth by clicking the button on the Operations palette, or selecting the Xtras>Path Operations...>Smooth... menu. A small dialog will appear, offering the choice to smooth with no handle limit, or to impose a limit on the bezier handles. Choosing no-limit, will allow the bezier handles to extend to any length (0.395 * the length of the straight line segment). If you choose to limit the handles, the text entry field will activate, allowing you to enter the distance, using the current units (e.g. points, inches). The distance is measured at a right angle from the straight line segment, not simple distance from the vertex. This allows Smooth to behave more or less as you would want when the path data has been filtered with a tube-width type point filter. If you know the tube-width that was used to filter the points, then setting the handle limit to approximately 1.5 times that distance will constrain the smoothed line within that tube. Supported environments: ====================== These two Xtras have been written for Macromedia FreeHand 8, and versions are available for both 32-bit Windows (Win95/98 and WinNT4) and Macintosh with PowerMac processor. Unfortunately, they are not available for 68K Macintosh at this time. Installation: ============ Extract the Xtras on the platform for which is is intended (do not unstuff the Mac version on a Windows system since the resource fork will be lost), and put the Xtras into your FreeHand/English/Xtras folder. The Xtras will not be available until FreeHand is (re)launched. Registration: ============ I have chosen to distribute Close and Smooth under the "shareware" concept. You may use them for 30 days for evaluation purposes, after which you should either register the software or discontinue its use. Feel free to pass this software along to others. The only thing I require is that you include a copy of this readme file. As much as I would love to give this software away as freeware, I have two quite selfish reasons for not doing so. The first is that I spent about a thousand dollars paying a very fine programmer to develop them for me (a bargain, I might add), and I would like to get some of that back. The second is that you folks who are going to use these Xtras are my competition, and I'd like to get a little something in return for helping you all out! What do you get when you register? Not much actually. I'll notify you if I release updates or upgrades. But mostly, you'll just get that nice feeling of knowing that you're being a good citizen. I'm asking for $40 as the shareware fee (per installation), but that's only a suggestion. If it's not worth that much to you, I won't be one bit offended if you choose to send less. I won't even be offended if you send me no money at all. Hey, everyone's got to start somewhere, right? But please do register either way. I'd like to know who is using these. To register, send me your name, company name, address, phone number, and email address to: Pat Dunlavey Cartographics 40 Oblong Road Williamstown, MA 01267 Make any checks payable to Pat Dunlavey Cartographics. Feedback: ======== I've used these Xtras in FreeHand 8, running in Windows NT4 for a while without problems. Others have tested them on Power Macintoshes running FreeHand 8, and Win95 running FreeHand 8, likewise without problems. I tested them very briefly with FreeHand 7 under Windows NT4 - Smooth appeared to operate correctly, but Close does not close paths. To my knowledge, at the time of this writing, no other combinations have been tested (e.g. FH7 on Power Macintosh). Please send reports of any problems to me . If there is enough interest in a 68K Macintosh version, I will bring one out (it requires some rewriting of code). Also, I will try to address the known FH7 problem with Close (and any that I don't yet know about) only if enough interest is expressed. Thanks, Pat Dunlavey Pat Dunlavey Cartographics 40 Oblong Road Williamstown, MA 01267 phone: 413-458-9273 fax: 413-458-9812 pat@pdcarto.com www.berkshire.net/~pdcarto