HIGHER ORDER CONSTRUCTION ALGORITHM METHOD FOR RAPID PROTOTYPING

Abstract: A rapid prototype modeling system (20) operates to first electronically decompose a discrete part represented by an STL file into electronic layers, using a paradigm characterized by a higher than zero order of fit with respect to the surface of the part. Physical layers are generated from the electronic layers by mechanical devices constructed and arranged to operate in accordance with the paradigm. The physical layers are then stacked appropriately to create a physical model of the discrete part.

Description: fflGHER ORDER CONSTRUCTION ALGORITHM METHOD FOR RAPID PROTOTYPING TECHNICAL FIELD This invention relates to rapid prototype modeling techniques. It is particularly directed to the use of higher order algorithms for the construction of solid prototype parts derived from 3D CAD software-generated models. BACKGROUND ART To remain competitive in a global market, manufacturers are called upon to bring a variety of products to market with continually decreasing lead times and development costs. These commercial realities are a driving force demanding the development of improved rapid prototyping techniques. A rapid prototyping technique (RP) is considered for puφoses of this disclosure to include any automatic technique for producing a solid three dimensional object from a computer assisted drawing (CAD) representation of the object. RP systems typically require minimal skill and interaction on the part of the operator. Most RP systems are quite flexible, allowing the creation of practically any shape the designer can imagine. RP thus inherently allows the creation of models that are difficult or impossible to construct by other techniques. While there exist significant differences between RP systems, RP generally produces parts that fit within a build volume of less than about a cubic meter (typically a third of a cubic meter), builds these parts at a rate of approximately 2.54 vertical centimeters (one vertical inch) per hour, and normally provides an accuracy within the range of about 0.2% - 0.5% of model dimensions, with a lower limit of 0.0127 centimeter (cm) (0.005 inches). The cost for a part from an RP service bureau ranges up to several thousand dollars for a part that fills the build volume. RP techniques are useful for producing small parts, such as disk drive cases, telephone hand sets, piston rods and the like. However, if the part to be prototyped is large; e.g., a car, the wing of an aircraft, or the support housing for a commercial power generator, the part must be generated in pieces, and the pieces then assembled. The resulting part typically requires days to construct, and its cost of construction is proportionately very high. The paradigm currently used by most RP techniques has a limited range of applicability. Parts larger than one cubic centimeter and smaller than one cubic meter are efficiently produced. Outside this range, prototypes either lose accuracy, or become expensive and time consuming to construct. Most RP techniques that are currently in use operate under a common construction paradigm. Working from a stereolithography format, faceted approximation of the solid model, the model is first decomposed into a series of parallel cross sections spaced at a distance equal to the eventual thickness of the construction layers. The part is then constructed by generating these layers from some solid material, and bonding the layers together. The cross sections are physically realized by means of a construction technique characteristic of the specific RP system utilized. There are several commercially available rapid prototyping processes, each using a unique production process for creating prototype models. A few of the more popular rapid prototyping techniques are Stereolithography (SLA), photo exposure layering (PEL), laminatedObject manufacturing (LOM), selective laser sintering (SLS), and fused deposition modeling (FDM). SLA-based systems solidify each layer from liquid photopolymer. LOM-based systems cut each layer from a sheet material. SLS-based systems fuse layers of powder into each cross section shape. These techniques construct each layer with essentially vertical edges, creating a generalized cylinder. For purposes of this disclosure, they are considered to rely upon the "vertical cylinder paradigm" (VCP). These vertical cylinders result in a stepped profile in a prototype representing a part that does not in fact have vertical edges. VCP produces a good representation of objects that have only vertical surfaces in at least one axis. The accuracy of the representation decreases as the surface shape becomes more general and the layer thickness employed increases. An example of an alternative paradigm currently in use for RP applications is in the "Protoform" software produced by Pentari. The operating paradigm used by Protoform is referred to in this disclosure as the "flat pattern paradigm" (FPP). By this RP system, a solid model is tessellated into flat polygon surfaces and then unfolded into a flat pattern. Tabs are generated at the cut edges, and the resulting pattern is plotted. The pattern is cut, folded, and tabs are joined, creating a three dimensional object. RP using FPP produces only the surface of an object, thereby requiring very little construction material. Accurate representations of curved or domed surfaces require very small tessellations, which are difficult to create. Thus, a relatively crude approximation is produced by this approach applied to non-planar surfaces. While each of the current RP systems is useful, each has at least one significant limitation. Some general examples of these limitations include: large procurement cost, expensive prototype production costs, and the use of resins and polymers that produce harmful gasses. Most importantly, all of them are limited to build volumes of less than about a cubic meter, and in some cases less than 0.02832 cubic meter (a cubic foot (ft 3 )). As presently understood, merely modifying existing RP machines would not enable effective operation significantly outside the currently available manufacturing envelope. Making vertical cylinders faster could presumably expand the envelope, but an RP machine that is efficient for producing 10 cm prototypes cannot be expected efficiently to produce 10 meter prototypes. There remains a need for an RP system capable of expanding the build volume of current systems. Moreover, in the construction of large objects, it would be preferable to operate within construction paradigms capable of realizing a closer fit between the prototype and the design part. DISCLOSURE OF INVENTION This invention provides an RP system which avoids many of the limitations of existing systems. It expands the build volume of prototype parts through the use of higher order paradigms. It also provides a system, including machine components, capable of implementing software such as that set forth at pages 14 through 117. Viewed broadly, a rapid prototype system of this invention comprises the steps of electronically decomposing an electronic model of an object into a first series of electronic layers in accordance with a paradigm characterized by a higher than zero order fit with respect to the surface of said object; generating a second series of physical layers from a construction material by mechanical means constructed and arranged to operate in accordance with that paradigm, the second series corresponding layer by layer to the first series; and constructing a physical prototype of the object by assembling the physical layers. The mechanical means for practicing the invention is structured and arranged to provide four degrees of freedom in positioning a cutting device with respect to sheets of construction material. The mechanical means is generally constructed and arranged to accept and manipulate sheets of construction material 1.22 meters (four feet) wide, or more, and is operated by control means responsive to software equivalent to that set forth at pages 14 through 117. The mechanical means generally includes support structure, operable to move a sheet of construction material forwards and backwards along a travel path in a plane; an electronically heated wire with a first end held by a first linear positioning device and a second end held by a second linear positioning device, the first and second positioning devices being supported to position the wire transverse the plane to intersect and cut a sheet of construction material traveling on the support structure; first structure, mounting the first positioning device such that it may travel back and forth transverse the travel path; second structure, mounting the second positioning device such that it may travel independently of the first positioning device back and forth transverse the travel path; and electronic control means, responsive to operating software, for controlling the relative movements of a sheet of construction material on the support structure, the first positioning means and the second positioning means. The mechanical means may also include heat control means, responsive to the operating software, constructed and arranged to adjust the temperature of the wire. The operating software is ideally equivalent to that set forth at pages 14 through 117. According to this invention, a rapid prototype modeling system operates to first electronically decompose a discrete part represented by an STL file into electronic layers, using a paradigm characterized by a higher than zero order of fit with respect to the surface of the part. Physical layers are generated from the electronic layers by mechanical devices constructed and arranged to operate in accordance with the paradigm. The physical layers are then stacked appropriately to create a physical model of the discrete part. In practice, an electronic model of an object is electronically decomposed into a first series of electronic layers in accordance with a paradigm characterized by a higher than zero order fit with respect to the surface of the object. A second series of physical layers is generated from a construction material, the second series corresponding layer-by-layer to the first series. This second series of physical layers is generated by mechanical means constructed and arranged to operate in accordance with the paradigm relied upon for decomposing the electronic model. A physical prototype of the object is then constructed by assembling the physical layers. The paradigm has a higher order of fit than that of the vertical cylinder paradigm (VCP) common to RP. It may be selected from either the trapezoidal cylinder paradigm (TCP) or the arc cylinder paradigm (ACP), although other higher order construction algorithms (HOCA) are operable. In mathematical terms, VCP is considered to produce a zero order curve fit to the model surface at the edge of each layer. By increasing the order of this fit, this invention produces a more accurate representation at the same layer thickness, and/or increased speed of construction at no less accuracy by increasing the thickness of the construction layers. A principle similar to that of the trapezoidal rule, often used in numerical integration, is applied by this invention to the construction of layered parts, thereby producing a first order curve fit at the layer edge. To apply this trapezoidal cylinder paradigm (TCP), an electronic model is first decomposed into a series of cross sections in conventional RP fashion. Rather than reconstructing each layer based on information from a single cross section, however, the layer is constructed as a linear blend between two consecutive cross sections. A slice taken vertically through this reconstructed layer would produce a trapezoid. Thus, these layers can be considered generalized trapezoidal cylinders. While VCP allows reconstruction of vertical-edged parts with very little error, the trapezoidal cylinder paradigm (TCP) additionally allows reconstruction of parts from models generated with ruled surfaces with very little error. Modeling of double curved surfaces by TCP will still produce error, but much less error than by VCP. This invention alternatively applies an arc cylinder paradigm (ACP), whereby a variable radius arc is fit to the edge of a layer. This curve fit is essentially of second order at the layer edge. Layers produced using ACP can be considered generalized cylinders with concave or convex curved edges. The radius of curvature will generally vary with position along the edge, possibly transitioning from convex to concave on a single layer. An algorithm is required to select the radius that will minimize the error between the model and the reconstructed layer. It is within contemplation to utilize paradigms using even higher order curve fits for layer edges. For example, by requiring the surface gradient at the edge of adjoining layers to be equal, a reconstructed part will be characterized by a smooth transition from layer to layer. A higher order version of the FPP would further enhance the reconstruction of curved surfaces. This invention contemplates the design and implementation of rapid prototyping devices using higher order construction algorithms (HOCA) for use in rapid prototyping of large scale master models. Examples of practical applications include full scale models of automobiles, boat hulls, wind turbine air foils, or molds for use with room temperature layup of composites. Lost foam casting and other conventional casting techniques may be used to convert large polystyrene foam models into metal castings. A specific embodiment of this invention utilizes TCP to build prototypes from "trapezoidal disks. " TCP creates linear interpolation between the upper and lower cross sections which define one layer or slice of a CAD model being constructed. The height of each trapezoid is equal to the thickness of material used to construct the prototype model. By using thick layers, construction time for the overall model is significantly reduced. It is practical, for example, to cut layers from 1.22 meters by 2.44 meters by 2.54 cm (4 ft by 8 ft by 1 inch) thick polystyrene foam insulation boards. Stacking and bonding of the layers may be done manually or by automated systems. BRIEF DESCRIPTION OF DRAWINGS In the drawings, which illustrate what is currently regarded as the best mode for carrying out the invention: FIG. 1 is a pictorial view of a machine embodying the invention, with an end plate removed to permit better visibility of components; FIG. 2 is a fragmentary view of the machine of FIG. 1, illustrating components which manipulate the positions of a sheet of construction material and a cutter; FIG. 3 is a fragmentary view of components of a cutting assembly of the machine of FIG. 1, illustrating alternative orientations of a cutter wire; FIG. 4 is a flow diagram of the method of this invention; FIG. 5 is an illustration of an electronic model of a vase; FIG. 6 is a fragmentary illustration of the model of FIG. 5 decomposed into electronic layers; FIGS. 7, 8 and 9 are diagrammatic illustrations of the respective fits with respect to a layer surface offered by VCP, TCP and ACP paradigms in accordance with the invention; FIG. 10 is a plot of the percent error of surface fit the paradigms of FIGs 7, 8 and 9 as a function of layer thickness; FIG. 11 is an illustration of an electronic model of an air foil; FIG. 12 is an illustration of the model of FIG. 11 decomposed into electronic layers; and FIG. 13 is a pictorial view of an assembled machine incoφorating the components illustrated by FIGS. 1, 2 and 3 for operation in accordance with the software set forth at pages 14 through 117. BEST MODE FOR CARRYING OUT THE INVENTION As illustrated by HG. 1 , a machine of this invention, designated generally 20, may utilize an electronically heated wire 22 (FIGS. 2 and 3) to cut rigid sheets 24. The sheets 24 are manipulated in a forward or reversed direction along a selected travel axis, A-A, atop horizontal drive rollers 26, 28. Above each drive roller is a free floating nip/idler roller 30, 32 to ensure contact between the drive rollers 26, 28 and the foam sheet 24. The heated wire 22 is shown by FIG. 2 positioned transverse the sheet 24 approximately vertically. The attitude of the wire 22 with respect to vertical transverse the travel axis A-A may be adjusted as illustrated by FIG. 3, through the relative positioning of a first linear positioning device 36, mounted to travel along a first, lower rail 37 and a second linear positioning device 38, mounted to travel along a second, upper rail 39 approximately parallel the first rail 37. As best shown by FIG. 2, the attitude of the wire 22 with respect to vertical parallel the travel axis A-A is adjustable by means of a third linear motion device 40, mounted to travel approximately normal the second rail 39. In operation, the linear motion devices 36, 38, 40 are driven in coordination with the manipulations of the sheet 24 along the axis A--A. Motion control for each linear positioning device 36, 38, 40, as well as for the drive rollers 26, 28 is supplied by stepper motors (not shown), which receive input signals from a software control program set forth at pages 14 through 117. The combination of these three motion devices 36, 38, 40 provide the illustrated mechanism 20 three degrees of freedom. The powered drive rollers 26, 28 feed the construction sheet 24 into the cutting wire 22, thereby contributing a fourth degree of freedom. Operation of the illustrated device is similar to the operation of a roll plotter, but with an additional two degrees of freedom in an x-y coordinate system. The drive rollers 26, 28 and lower linear motion device 36 act in the fashion of a roll plotter to position the base 42 of the cutting wire anywhere on the bottom surface 44 (FIG. 3) of the foam sheet 24. The upper two linear motion devices 38, 40 add two more degrees of freedom, allowing the upper end 46 (FIG. 2) of the cutter wire 22 to be positioned independently of the lower end 42. The respective ends 42, 46 of the electrically heated cutting wire 22 are directly attached to two of the three independent linear motion devices 36, 38. A coil spring 48 connects the upper end 46 of the cutting wire 22 to the device 38. The coil spring 48 accommodates length adjustments required of the wire 22 as it is positioned for making linearly interpolated cuts at an angle from the vertical plane. Temperature of the wire 22 is adjusted by varying the electric current applied to it. The cutting speed is adjusted to minimize cutter deflections caused by the construction material, in the illustrated instance, foam plastic board 24. The main tasks of the machine control software set forth at pages 14 through 17 are to recognize coordinates representing a CAD 3D solid object, and to find a sequence of cutter motions to produce the required cross sectional slices. Once an object is created in a CAD system, it can be easily saved in STL format, the file format currently utilized for many RP techniques. In selecting an STL file format, it should be recognized that the accuracy of an approximated object saved in the STL file is the maximum accuracy that the prototype machine will be able to produce. The machine uses geometry information saved in the STL file, not the CAD drawing file. The invention applied to files of greater accuracy will produce more accurate prototypes. Algorithms that generate cross sections directly from the CAD model are within contemplation. After reading an STL file, the control software regenerates the object on a computer screen. A user may then determine the most efficient slice direction by rotating, transforming, and scaling the object on screen. The software then slices the object into layers equal to a selected material thickness, and defines straight line segments which represent the edges of the object on the cut plane. The end result of this slicing algorithm is a series of independent cross sections. For the actual part layers to be cut, it is necessary to define synchronized positionings of the cutter wire 22. The cutter wire 22 must be repositioned over time, in coordination with movements of a layer 24 of construction material, to produce somewhat different cross-sectional configurations at the upper 50 and lower 44 surfaces of the layer 24 in a simultaneous coordinated motion. Defining the cutter path involves optimally matching points on the perimeters of the top and bottom surface cross sections of a slice. Cutter paths are generally determined by matching each top cross section point with the closest bottom cross section point. This distance minimization approach is generally suitable because it can accommodate virtually any shape. This technique can thus generate thick slices with small error, and is suitable for prototyping large objects rapidly. The defined cutter path corresponds to respective cutting paths on the upper and lower surfaces of a construction sheet 24. The actual hot wire 22 extends beyond the upper 50 and lower 44 surfaces and pivots about points associated with anchor rods 52, 54 displaced significantly above and below those surfaces. Accordingly, after finding cutter paths, the software calculates the appropriate positions of the respective cutter pivot points to trace the proper cutter path on the material. Finally, the software converts position coordinates into a string of pulses to drive the stepper motors. A flow chart for the complete algorithm is presented by FIG. 4. Ideally, the cutting machine should be constructed and arranged to have a pen up function. The machine is then capable of moving the cutter device from point to point without cutting material, thereby avoiding the need for the layout of access paths to loops and return paths to a home position. When a large object is built, registration of slices is an important concern. Adding paths and holes for registration can be done by the software following rules defined by the user. Two main parameters controlling the quality of the cut surface are cutter speed and temperature. Speed is defined by the pulse rate sent to the stepper motors which is related to the torque of the motors. The cutter temperature is a function of electric current going through the cutter wire 22. Undesirable combinations of speed and temperature can result in local areas where the cutter melt radius becomes excessive. Cutting too fast or too cool results in excessive deflection of the hot wire which also reduces accuracy. Optimal combination of these parameters depends on material properties and the characteristics of the object geometry, and will generally be determined through careful experiments. It has been observed that mamtaining a constant speed and temperature over the working period is beneficial. EXAMPLE 1. A simple vase 55 (FIG. 5) was designed to test construction accuracy as a function of layer thickness for the construction paradigms: VCP, TCP, and ACP. Under the assumption that the speed of construction of a layer is independent of layer thickness, it follows that parts built with thicker layers will require less time to construct. The vase shape may be represented mathematically, using a series of two dimensional (x,y) arcs and lines that are revolved about the y axis: Outer Surface: Vertical Dimension (v Equation 0 - 28 (x-3) +(v-15 2 100 225 28 - 30 3x + 5y = 164 31 - 35 x = 3 35 - 36 (x-4) 2 + (y-35) 2 = 1 36 - 38 (x-6) 2 + (y-37) 2 = 1 Inner Surface ; Vertical Dimension (v) Equation 0 - 3 x = 0 3 - 28 x 2 + (v-15) 2 100 225 28 - 30 2x + 3y = 94 30 - 35 x = 2 35 - 37 (x-4) 2 + (y-35) 2 = 4 37 - 38 (x-4) 2 + (y-38) 2 = 1 For this simple shape, as can be seen from FIG. 7, all cross sections are either solid circular cylinders 56 or solid circular annuli 58, and a specific cross section is completely defined by one or two coordinates on the x axis. To apply VCP, an algorithm is needed to select the x coordinates for each layer (one or two numbers). For TCP, each layer requires x coordinates for the upper surface and the lower surface (two or four numbers). ACP requires x coordinates for upper and lower surfaces along with one or two radii (three or six numbers). The algorithms used in this example for each paradigm were: VCP The radius of each layer is forced to match the model at the top of each layer. TCP The algorithm for TCP utilizes the cross sections generated for VCP. The top cross section for a given layer is identical to the bottom layer of the closest layer above it. ACP Arc cylinders are generated from the cross sections generated for VCP. The arc radius is generated by passing an arc through the upper surface point, the lower surface point, and a third point that lies on the model surface at the midpoint of the layer. Implementation was as follows: 1) identify the x coordinate for a new cross section in the center of the layer. 2) define a line segment from the upper surface to the center and a second from the lower surface to the center. 3) The bisecting normals of these line segments intersect at the center of curvature, identifying the radius. The fits of these construction algorithms are shown schematically in FIGS. 7, 8 and 9, respectively. The accuracy of each algorithm was measured by calculating the eπor between the volume of material required by the exact model, represented by the solid line 60, and that required by the reconstructed model, represented by the broken lines 62, 64 and 66, respectively. First, the exact volume of the mathematical model for the vase was calculated. Next, the model was decomposed into layers (FIG. 6), and the volume of the combined layers was calculated. This procedure was performed for each algorithm, varying layer thickness from 0.1 mm to 2 mm. The percent error associated with a given algorithm and layer thickness was calculated by: % Error = 100 where V 0 is the volume of the mathematical model and V rc is the volume of the reconstructed model. The data from these calculations are plotted in FIG. 10. As expected, the error is small for any of the paradigms if the layer thickness is very small. As layer thickness increases, the accuracy decreases for each method. The error for VCP increases dramatically faster than the higher order algorithms, exceeding 15 percent error as the layer thickness approaches 1 cm. At 1 cm thickness, both higher order techniques perform at under three percent error. EXAMPLE 2. A computer generated model of a NASA LS(l)-417MOD wind turbine air foil 70 is shown in FIGS. 11 and 12. Construction of this air foil was attempted with good success using the equipment described in connection with FIGS. 1-4 assembled as illustrated by FIG. 13. The foil shape is described by a series of complex spline curves 71 , which have a spline taper through the height (h) and width (w). The model is further complicated by a 42° angle of twist along the foil length (1). The total length of the model is 4.57 meters (15 feet). The initial width (at the base 75) of the air foil is 116.8 centimeters (46 inches), reducing to 25.4 centimeters (10 inches) at the tip 77. The height of the air foil starts at 19.84 centimeters (7.81 inches) at the base 75, reducing to 2.84 centimeters (1.12 inches) at the tip 77. The computer model of the air foil was created using Parametric Technology's Pro/Engineer software. Spline points at various cross sections the air foil were generated from normalized data developed at NASA. These spline points were subsequently read into Pro/Engineer and series of spline curves were fit to the points as shown in Fig 12. Smooth spline surfaces 80 were then generated between the spline curves 71. A computer solid model (Fig. 11) was created from the hollow spline shell. This computer solid model was stored as a standard stereolithography format file. The equipment illustrated by Fig. 13 was used to cut out the 180 layers required to construct the air foil prototype, requiring approximately 17 sheets of 1.22 meters by 2.44 meters by 2.54 centimeters (4 feet by 8 feet by 1 inch) thick sheets of bead board foam. Each layer of foam was then manually registered and bonded. The accuracy of this air foil prototype was in the range of 0.08 to 0.6 % error, when compared to chord lengths in the computer model. This level of accuracy is considered acceptable, given the size of the prototype and the facet mesh size of the STL file. The surface finish of the model was fairly rough, because of the STL file approximation of the computer model. Further facet refinement of the STL file would correspondingly improve the surface finish. The air foil computer model was created in approximately 2 hours using Pro/Engineer. Cut out and assembly time for the air foil prototype was estimated at 9 hours. Reference in this disclosure to details of specific embodiments is not intended to limit the scope of the appended claims which themselves recite those details regarded as significant to the invention. It is intended for the appended claims to embrace equivalents. ! Wπtten by Cheol H. Lee ! University of Utah ! File : 72readme.tru ! Date : 12/96 ! Object : General instruction for SM2 control program 1. General Process - In CAD, a stl file (*.stl) is made. - All text in stl are removed and all coords are saved m numeric form in a vertex file (*.vtx) - An object is sliced and lines that represent outlines of each cross section are save in line file (*.ln) - All lines in line file are sorted to make closed loops in counter clockwise direction and saved in a loop file (*.lρ) - All lines in loop file are discretized into po ts which are saved in a point file (*.pt) - All loops of top and bottom cross sections of a slice are matched and cutter movements are determined and saved in a cut file (*.ct) - Cutter movements are converted into number of steps to move machine which are saved in a step file (*.st) - A C program reads step file and generates commands to drive moters 2. Directory Structure - \ : all True Basic program files, *.tru - \bc31\bin\ : rp-mt4.c - \object\ : *.stl, *.vtx, setup.rp - : *.ln, *.lp, *.lpx, *.pt, *.ptx, *.ct, * ctx *.st, ctreport.txt - \object\temp\ : *.st, ctreport.txt 3. File Structures - A CAD s/w makes *.stl file - A True Basic program makes all other files from *.vtx to *.st - A C program drives machine and is called by a True Basic program - *.stl : stl file, made by CAD s/w. text or binary file - *.vtx : vertex file or object file, record file. 9 records for each triangle (xl,yl,zl,x2,y2,z2,x3,y3,z3) - *.ln : hne file, record file. 4 records for each line (xl,yl,x2,y2) - *.lp : loop file, record file. 4 records for each In (xl,yl,x2,y2) - *.lpx : loop index file, record file, each loop has 10 records (start line num, end line num, xd.yd, xu,yu, xl,yl, xr,yr) xd,yd=ymin pt. xu,yu=ymax pt. xl,yl=xmin pt, xr,yr=xmax pt - *.pt : point file, record file. 2 records for each pt (xl.yl) - *.ptx : point index file, record file, each loop has 10 records (start pt num, end pt num, xd,yd,xu,yu,xl,yl ) xr,yr) - *.ct : cut file, record file. 4 records for each cutter movement (xb,yb,xt,yt) - *.ctx : cut index file, record file. 13 records for each matching loop, and 5 rec at the end (start num of cut,end num of cut,xbstart,ybstart, xtstart, ) ^t_ l,xιrun,xrnax,ymin,ymax,uιdex_b,ιndex_t,max_angle) ... (xmιn,xmax,ymin,ymax,max_angle for all match loops) - *.st : step file, text file. 4 numbers for each cutter movement (xl,x2,yl,y2) - setup.rp : setup file, record file. 15 jop setup parameters (ob ect name,nurn_tπ,dh,angle,sρace_t,space_b,d loop,d_poιnt xmax,ymax,zmax,xh,yh,decιmal,skιp) - ctreport txt cut report, text file 16 global parameters and 4 parameters for each slice (object$,num_trι,dh,angle,space_t > space_b,d_loop,d__pomt, xmax,ymax,zmax,xh,yh,decιmal,skιp,shce,sιze of each slice, max angle of each slice, num of loops of each slice) Program Files - 72readme.tru : general instruction for SM2 control program - 72-maιn.tru . main program - 72-menu.tru : prepare menus - 72-1-vtx.tru * stl -> * vtx - 72-2-lnl.tru • *.vtx -> Mn 72-2-ln2 tru - 72-3-lpl tru . * In -> * lp 72-3-lp2 tru - 72-4-pt tru * lp -> *.pt - 72-5-ctl.tru - * pt -> * ct 72-5-ct2.tru - 72-6-st.tru *.ct -> * st - rp-mt4 c : *.st -> step pulse - 72-gvt.tru : graphics for *.vtx - 72-gln.tru graphics for *.ln, *.lp, and *.pt - 72-gct.tru . graphics for *.ct and *.st - 72-ut.tru utilities to read index file and cut report file End of File ****************************************************************** Written by Cheol Lee File: 72-ut.tru Date: 10/95 Object : display contents of index file and cut report file Input : *.lpx, *.ptx, *.ctx, ctreport.txt Output : display info on screen ****************************************************************** MENU - Cut report is in objecf\[object_name]\ctreporttxt text file (object$,num_tri,dh,angle,space_t,space_b,d_loop,d_poiJit, xmax,ymax,zmax,xh,yh,decιrnal,skip,shce,sιze of each slice, max angle of each slice, num of loops of each slice) ****************************************************************** library "utillib.tru" name$="sink" start,end= 1 call auto_read_ct_ιndex(name$,start,end) [call read cut report stop num$="19" call record_to_text_file("temp\"«&num$&".st","temρ\"&num$&".txt") end EXTERNAL ********* Summary (72-ut) ********* SUB read_ιndex_file(ιn_file$) SUB auto read_lp_index(name$, start,end) SUB auto_read_pt_index(name$,start,end) SUB read_cut_ιndex_file(file_ctx$) SUB auto_read_ct_ιndex(name$,start,end) SUB cut_report(object$,num_tri,dh,angle,space_t,space_b,d_loop,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp,shce,start,end) SUB read cut_report(name$) ****************************** Subroutine: read index file ****************************** SUB read_index_file(file_in$) ! i ! Read *.lpx,*.ptx index file and display contents ! file inS : *.lpx, or *.ptx index record file CALL open_fιle(#l,file_in$,error) IF error=l THEN exit sub ASK #1 :Filesιze num_record IF num_record=0 THEN PRINT "No record!! blank record file 1 " EXIT SUB END IF RESET #1 Begin PRINT "File name ",file_ιn$ PRINT "start/end","low(x/y)", , 'hιgh(x/y)","left(x/y)" ) "πght(x/y)" PRINT " " FOR ι=l TO num record/10 READ #1 rl,r2,r3,r4,r5,r6,r7,r8,r9,rl0 PRINT I,")",rl,r3,r5,r7,r9 PRINT l ") M .r2,r4,r6,r8,rlO PRINT " - NEXT i CLOSE #1 END SUB I *************** **************** 1 Subroutine auto_read_lp_ιndex ******************************* SUB auto_read_lρ_ιndex(name$,start,end) ' ι(3) ' display * lpx file from start lpx to end lpx 1 nameS object name 1 start.end start and end file number for * lpx FOR ι=start TO end file_ιn$="object\" & nameS & "\" & str$(ι) & " lpx" CLEAR CALL read_ιndex_file(file_ιn$) GET KEY getkey NEXT i END SUB ***************** ************** 1 Subroutine auto_read_pt_ιndex I******************************* SUB auto_read_pt_ιndex(name$,start,end) ' ι(3) 1 display * ptx file from start ptx to end ptx 1 nameS object name 1 start,end start and end file number for * ptx FOR ι=start TO end file_ιn$="object\" & nameS & "\" & str$(ι) & " ptx" CLEAR CALL read ιndex_file(file_m$) GET KEY getkey NEXT i END SUB I****************************** ' Subroutine read cut index file I ****************************** SUB read_cut_ιndex_file(fιle_ctx$) ' I 1 Read * ctx index file and display contents 1 file ctxS * ctx index record file CALL open_file(#l,file_ctx$,error) IF error=l THEN exit sub ASK #l.Fιlesιze num record IF num_record=0 THEN PRINT "No record' » blank record file' " EXIT SUB END IF RESET #1 Begin PRINT "File name ",file_ctx$ PRINT "start end","start( b/yb)","start(xt/yt)"; , mln xmax , ',")'mln/yma ' , PRINT "ιndex(b/t)","angle","xsιze","ysιze" PRINT " " FOR ι=l TO (num_record-5)/13 READ #l .rl,r2,r3,r4,r5,r6,r7,r8,r9,rl0,rl l,rl2,rl3 PRINT I,")";rl,r3,r5,r7,r9 PRINT PRINT PRINT ι,")",rl I,rl3,r8-r7,rl0-r9 PRINT ι;")",rl2 PRINT " - — " NEXT i CLOSE #1 END SUB I ******************************* ! Subroutine, auto read ct index I ******************************* SUB auto_read_ct_rndex(name$,start,end) ! ι(3) ' display *.ctx file from start.ctx to end.ctx ! nameS object name 1 start.end start and end file number for * ctx FOR ι=start TO end file_ιn$="object\" & nameS & "\" & str$(ι) & " ctx" CLEAR CALL read_cut_ιndex_file(fιle_ιn$) GET KEY getkey NEXT i END SUB I*********** ' cut report I*********** SUB cut_report(object$,num_tπ,dh,angle,space_t,space b,d_loop,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp,slιce,start,end ) ! all mput ! make cut report (ctreporttxt) in object directory ! objects, num tπ • object name number of triangles ' dh, angle • foam thickness, maximum cut angle ! space_t, space_b • space bw control point and top or bot surface ! d loop, d_poιnt . mm distance bw loops discrete point distance ' x,y,zmax : object size ! xh,yh . home position in x and y direction 1 decimal, skip • round decimal, number of skip points ! slice, start,end : num of slices start, end num of slice to report cutreport$="object\" & objects & "Vctreport txt" OPEN #5. name cutreport$,access outin, create newold,org text ERASE #5 PRINT #5: "object ";object$ PRINT #5:"trιangles ";num_tπ PRINT #5:"shces : ";shce PRINT #5."foam, angle : ";dh,angle PRINT #5:"space (t/b) : ";space_t,space_b PRINT #5:"loop dis. pt res : ";d_loop,d_poιnt PRINT #5:"skιp decimal • ";skιp,decιmal PRINT #5 -"home (xh yh) • ";xh,yh PRINT #5:"size : ";"x =";xmax;" y =";ymax;" z =";zmax PRINT #5:" " PRINT #5: "slice #"," dx"," dy"," angle"," loops" PRINT #5:" " count=0 FOR i=start TO end file_ctx$="object\" & objects & "\" & Str$(i) & ".ctx" OPEN #l :name file ctxS, access input ASK #l :filesιze fsιze loops=(fsιze-5)/13 RESET #l:record fsιze-4 READ #l :xmιn,xmax,yrrun,ymax,max_angle PRINT #5:"#";ι,xmax-xmιn,ymax-ymιn,max_angle,loops CLOSE #1 count=count+ 1 IF count>=4 THEN PRINT #5 : " count=0 END IF NEXT i PRINT #5 : " PRINT #5: "end of record" PRINT "cutreport.txt for ";objectS;" is made. " CLOSE #5 END SUB I***************************** ! Subroutine: read cut report |***************************** SUB read_cut_report(name$) ! o ! display contents of cut report file ! nameS : object name CLEAR cutreport$="object\" & nameS & "\ctreport.txt" CALL open_file(#l,cutreport$,error) IF error=l THEN exit sub count=0 DO WHILE MORE #1 INPUT #l :text$ PRINT textS count=count+l IF mod(count,24)=0 THEN get key key CLEAR END IF LOOP CLOSE #1 END SUB * ************* ! End of File * ************* I*********************************** -20- ! Written by Cheol H.Lee ! File: 71-main.tru ! Date: 6/96 ! RP Shape Maker 2 control program I **** ************************* ******* ! MEMO ! - run ixtsr m: 10000 for small memory, default is 52K ! - *.stl, *.vtx files are in "objectV directory ! - *.ln, *.lp, *.pt, *.lpx, *.ptx files are in "temp\" directory ! - setup.rp is in program directory ! - index file (*.ptx, *.lpx): num_start,num_end,xd,yd,xu,yu,xl,yl,xr,yr,.. ! 10 record for each loop ! - cut file (*.ct) : xmin,xmax,ymin,ymax,max_angle ! 5 records at the end of file ! PROS ! - maintain status file, and loaded and updated ! - menu driven, ststus list ! - window size and object size are different option. ! when change object, window and object size are updated I ************************************************* LIBRARY "72- 1-vtx.tru" LIBRARY "72-2-lnl . tru" LIBRARY "72-2-Ln2.tru" LIBRARY "72-3-lp2.tru" LIBRARY "72-3-lpl. tru" LIBRARY "72-4-pt.tru" LIBRARY "72-5-ct2.tru" LIBRARY "72-5-ctl . tru" LIBRARY "72-6-st.tru" LIBRARY "72-ut.tru" LIBRARY "72-gvt.tru" LIBRARY "72-gln.tru" LIBRARY "72-gct.tru" LIBRARY "0-menu.tru" ! LIBRARY "72-menu.trc" LIBRARY "3dlib.trc" LIBRARY "utillib2.tru" LIBRARY "utillibl. tru" LIBRARY "shell.tru" !LIBRARY "72-l-vtx.trc" !LIBRARY "72-2-lnl.trc" [LIBRARY "72-2-ln2.trc" !LIBRARY "72-3-lp2.trc" '.LIBRARY "72-3-lpl.trc" !LIBRARY "72-4-pt.trc" [LIBRARY "72-5-ct2.trc" [LIBRARY "72-5-ctl . trc" [LIBRARY "72-6-st.trc" [LIBRARY "72-ut.trc" [LIBRARY "72-gvt.trc" [LIBRARY "72-gln.trc" [LIBRARY "72-gct.trc" [LIBRARY "72-menu.tru" [LIBRARY "3dlib.trc" [LIBRARY "utillib2.trc" [LIBRARY "utillibl. trc" [LIBRARY "shell.tru" DIM a(0,0),b(0,0),ιndex(10,10) xls,x2s,y2s=800 yls= 120.63 !num_var=26 I ************** ! Main Program I************** SET MODE "vga" CALL read_setup (name$,num_tri,dh,angle,space_t,space_b,d_loop,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) i ! enu job loop DO MAT REDIM a(0,0),b(0,0) ! save memory ! menu rwm=.8 IF xmax*rwin>ymax THEN ! window size xwιn=xmax ywιn=xmax*rwιn zwιn=zmax ELSE xwιn=ymax/rwιn ywm=ymax zwm=zmax END IF CALL status (name$,num_tri τ dh,angle,space_t,space_b,d_loop,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) CLEAR SET COLOR "white" i ! main job description SELECT CASE job CASE 1 ! DO •exit do ! remove dos shell for memory CLEAR PRINT "Press (0) to return to mam menu " INPUT PROMPT "DOS command' ".com$ IF com$="0" THEN EXIT DO ELSE CALL shell(comS) END IF GET KEY getkey LOOP I. ! job setup CASE 2 change job setup DO i 1 setup menu CALL status (name$,num_trι,dh,angle,space_t,space_b,d_loop,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) CALL setup menuijob setup) CLEAR SET COLOR "white" SELECT CASE job_setup CASE 0 ' return to mam menu EXIT DO CASE 1 ' foam thickness PRINT "current foam thickness. ";dh INPUT PROMPT "Foam thickness (cm) " dh CASE 2 ! max cutter angle PRINT "current cutter angle ";angle INPUT PROMPT "Maximum cutter angle (degree) 7 " angle CASE 3 ' bot space PRINT "current bottom space ",space_b INPUT PROMPT "Bottom space from the foam (cm) 9 " space b CASE 4 ' top space PRINT "current top space. ";space t INPUT PROMPT "Top space from the foam (cm) 9 ".space t CASE 11 ! loop distance PRINT "current loop distance. ";d_loop INPUT PROMPT "Minimum distance between loops (cm) 9 " d oop CASE 12 ' point distance PRINT "current point distance. ",d_poιnt INPUT PROMPT "Maximum distance between points (cm) 9 " d_poιnt PRINT "current skip points- ",skιp INPUT PROMPT "Skip points 9 " skip CASE 14 ' decimal PRINT "current rount decimal ".decimal INPUT PROMPT "Round decimal 9 ":decιmal CASE 21 ' home position PRINT "current home position ",xh,yh INPUT PROMPT "Home position x,y (cm) 9 " xh.yh CASE 31 ' save setup CALL save_setup(name$,num_tn,dh,angle,space_t,space_b,dJoop,d_pomt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) EXIT DO CASE ELSE PRINT "Job is not available Select again " GET KEY key EXIT SELECT END SELECT LOOP i ' object CASE 3 ' combine STL files CALL shell("dιr/w/o n object\* stl") PRINT "Press (0,0,0) to cancel " INPUT PROMPT "stl_ιnl, stl_ιn2,Ostl_ιn3 9 " ιnl$,ιn2$,out$ IF ιnl$="0" and ιn2$="0" and out$="0" THEN EXIT select PRINT "Wait " CALL combιne_stl(ιnl$,ιn2$,out$) CASE 4 ' append STL files CALL shell("dιr/w/o n ob ect\* stl") PRINT "Press (0,0) to cancel " INPUT PROMPT "stI_mout, stl_ιn " moutS.inS IF ιnout$="0" and ιn$="0" THEN EXIT select PRINT "Wait " CALL append_stl(ιnout$,ιn$) CASE 5 ' stl to object CALL shell("dιr/w/o n object\* stl") PRINT "Press (0) to cancel " INPUT PROMPT "Object name 9 " nameS IF name$="0" THEN exit select com$="md object\" & nameS CALL shell(comS) CLEAR CALL stl_to_vtx(name$,num_tπ,xmax,ymax,zmax) CLEAR CALL draw vtx 3d(name$,xmax,ymax,zmax) GET KEY key CASE 6 ' select object CALL shell("dιr/w/o n object\* vtx") temp$=name$ PRINT "Press (0) to cancel " INPUT PROMPT "Object name 9 " nameS IF name$="0" THEN name$=temp$ exit select END IF CALL object sιze(name$,xmιn,xmax,ym]n,ymax,zmιn,zmax,num_trι) CASE 7 ! rotate object PRINT "Press (0,0,0) to cancel." PRINT "Current object is ";name$ PRINT INPUT PROMPT "Rotated object name, axes, angle? ":name_out$,rot_axes$,rot_angle IF rot_angle=0 THEN exit select CALL rotate_vtx(name$,rot_axes$,rot_angle,xmax,ymax,zmax,narne_out$) name$=name_ out$ CLEAR CALL draw_vtx_3d(name$,xmax,ymax,zmax) GET KEY key CASE 8 ! resize object PRINT "Press (0,0,0,0) to cancel " PRINT "To convert INCH into CM, scale=2.54 " PRINT "Current object is ";name$ PRINT INPUT PROMPT "Scaled object name, ratιo(x,y.z) 9 ":name_out$.xr,yr,zr IF xr= l and yr=l and zr=l THEN exit select IF xr=0 and yr=0 and zr=0 THEN exit select CALL scale_vtx_file(name$,xr,yr,zr,xmax,yτnax,zmax,name_out$) nameS =name_out$ CASE 9 ! registration INPUT PROMPT "Start, end file number?- ":start,end CLEAR CALL regιstratιon(name$,start,end,xwιn,ywιn) ι ' a slice CASE 1 1 ! object to one line PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foam thιckness:";dh;", number of line file ";ιnt(zmax dh)+ l INPUT PROMPT "Line file number, cut height? ":file n,shce_h IF file ln=0 and slιce_h=0 THEN exit select CALL vtx_to_line_h(name$,slιce_h,decιmal,file_ln) CLEAR CALL draw_line(name$,file_ln,0,xmax,ymax) GET KEY getkey CASE 12 ! object to hnes PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foam thιckness:";dh;", number of line file:";mt(zmax/dh)+ l INPUT PROMPT "start, end line files 9 ":start,end IF start=0 THEN Exit select CALL vtx_to_lιne(name$,start,end,dh,decιrnal) GET KEY getkey CASE 13 ! hnes to loops PRINT "Press (0,0) to cancel." PRINT "ob j ect heιght:";zmax,", foam thickness. ":dh,", number of loop fUe:":ιnt(zmax/dh)+l -25- INPUT PROMPT "start, end loop files? ":start,end IF end=0 THEN exit select CALL hne_tojoop(name$,start,end,d_loop) GET KEY getkey CASE 14 .' loop to point PRINT "Press (0,0) to cancel." PRINT "ob j ect height: ";zmax;", foam thickness: ";dh;", number of pomt file:";int(zmax/dh)+l INPUT PROMPT "start, end point files? ":start,end IF end=0 THEN exit select CALL loop_to_point(name$,start,end,d_point,decimal, 1 ) GET KEY key CASE 15 ! point to cut PRINT "Press (0,0) to cancel." PRINT "object height: ";zmax,", foam thickness. ";dh;", number of cut file:";ιnt(zmax/dh) INPUT PROMPT "start, end cut files? ":start,end IF start=0 and end=0 THEN exit select reverse=0 INPUT PROMPT "reverse(0/l)? ":reverse CALL auto_cut(name$,start,end,reverse,dh,angle,decimal,skιp) GET KEY getkey CASE 16 ! cuts to steps PRINT "Press (0,0) to cancel." PRINT "object height: ";zmax;", foam thιckness:";dh;", number of cut file:";ιnt(zmax/dh) INPUT PROMPT "start, end step files? ":start,end IF start=0 and end=0 THEN exit select INPUT PROMPT "number of holes(O-n)? ":numJιole CALL auto_step(name$,start,end,num_hole,dh,space_b,space_t,& & d_poιnt,skip,xh,yh,x 1 s,x2s,y 1 s,y2s) GET KEY getkey CASE 21 ! remove loop PRINT "Press (0) to cancel." PRINT "object heιght:";zmax;", foam thιckness:";dh;", number of loop file ",ιnt(zmax/dh)+l INPUT PROMPT "loop file number 9 ":filejp IF filejp=0 THEN exit select CLEAR CALL draw_auto_loop_2d(name$,fιle_lp,file_lp,0,xwin,ywin) SET COLOR "yellow" PRINT PRINT " Press (0) to cancel." INPUT PROMPT " loop number to be removed? ":lp_num IF lpjnum=0 THEN exit select CALL remove_loop(name$,file_lp,lp_num) CLEAR CALL draw_auto_loop_2d(name$,file_lp,file_lp,0,xwm,ywin) CASE 22 ! reverse loop PRINT "Press (0) to cancel." PRINT "object heιght:";zmax;", foam thιckness:";dh;", number of loop file.";ιnt(zmax/dh)+l INPUT PROMPT "loop file number 9 ":file_lp IF file_lp=0 THEN exit select CLEAR CALL draw_auto_loop_2d(name$,file_lp,file p,0,xwιn,ywιn) SET COLOR "yellow" PRINT "Press (0) to cancel " INPUT PROMPT "loop number to be reversed? " lp num IF lp_num=0 THEN exit select CALL reverse_loop(name$,file_lp,lp_num) CLEAR CALL draw_auto_loop_2d(name$,file_lp,file_lp,0,xwm,ywm) CASE 23 i pomt to cut (SMI) PRINT "Press (0,0) to cancel " PRINT "object heιght:";zmax;", foam thickness. ";dh;", number of cut file ",mt(zmax/dh) INPUT PROMPT "start, end cut files 9 ":start,end IF start=0 and end=0 THEN exit select CALL auto_cut_sml (name$,start,end,decιmal) GET KEY getkey Read CASE 41 ' read loop index file PRINT "Press (0,0) to cancel " PRINT "object height. ";zmax,", foam thιckness:",dh,", number of loop file ";ιnt(zmax/dh)-t 1 INPUT PROMPT "start, end number 9 ":start,end IF start=0 and end=0 THEN exit select CALL auto_read_lp_ιndex(name$,start,end) CASE 42 ' read pomt index file PRINT "Press (0,0) to cancel." PRINT "object height. ";zmax,", foam thιckness:",dh;", number of pomt file ";mt(zmax dh)+l INPUT PROMPT "start, end number 9 " start.end IF start=0 and end=0 THEN exit select CALL auto_read_pt_ιndex(name$,start,end) CASE 43 ' read ct index file PRINT "Press (0,0) to cancel " PRINT "object height ",zmax,", foam thickness ",dh,", number of point file ",ιnt(zmax/dh)+ 1 INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select CALL auto_read_ct_ιndex(name$,start,end) CASE 44 ! read coord file PRINT "Press (0) to cancel " PRINT "object heιght:";zmax;", foam thickness ",dh,", number of line file:";ιnt(zmax/dh)+l INPUT PROMPT "Coordinate file name 9 ":file_name$ IF file_name$="0" THEN exit select file_nameS="objec " & nameS & "V & file_nameS CALL read_record_file(file_name$,4) GET KEY getkey CASE 45 ! cut report PRINT "Press (0,0) to cancel " PRINT "object height. ",zmax,", foam thickness ".dh,", number of cut file ";mt(zmax/dh) rNPUT PROMPT "File number start, end 9 ":start,end shce=ιnt(zmax/dh) CALL cut_report(name$,num_trι,dh,angle,space_t,space_b,d_looρ,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp,slιce,start,end) CASE 46 ! read report CALL read_cut_report(name$) PRINT INPUT PROMPT "print? (1/0)? ":temp PRINT IF temp=l THEN com$="print objectV & nameS & "\ctreport.txt" CALL shell(comS) END IF automatic view CASE 51 ! view object - wire CLEAR CALL draw_vtx_3d(name$,xmax,ymax,zmax) GET KEY getkey CASE 52 ! view lines 3D PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foam thιckness:";dh;", number of line file:";ιnt(zmax/dh)+l INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select h_bot=(start-l)*dh h_top=(end-l)*dh CLEAR CALL draw_auto_line_3d(name$,h_bot,h_top,dh,xmax,ymax,zmax) GET KEY getkey CASE 53 ! view lines 2D PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foarm thιckness:";dh;", number of line file:";ιnt(zmax/dh)+l INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select CLEAR CALL draw_auto_lιne_2d(name$,start,end,0,xwιn,ywιn) CASE 54 ! view loops PRINT "Press (0,0) to cancel." PRINT "object height: ";zmax;", foam thickness:";dh;", number of loop file:";ιnt(zmax/dh)+l INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select CLEAR CALL draw_auto_loop_2d(name$,start,end,0,xwin,ywιn) CASE 55 ! view points PRINT "Press (0,0) to cancel." PRINT "object height: ";zmax;", foam thickness:";dh;", number of point file.";int(zmax/dh)+l INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select CLEAR CALL draw_auto_poιnt_2d(name$,start,end,0,xwιn,ywιn) CASE 56 ! view cuts -28- PRINT "Press (0,0) to cancel." PRINT "object heιght-";zmax,", foam thickness ",dh,". number of cut file ",ιnt(zmax/dh) INPUT PROMPT "start, end number? ".start.end IF start=0 and end=0 THEN exit select CALL draw_auto_cut_2d(name$,start,end,dh,xwιn,ywιn) CASE 57 ! view steps PRINT "Press (0,0) to cancel." PRINT "object height: ";zmax;", foam thιckness:";dh,", number of step file:";ιnt(zmax/dh) INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select FOR ι=start TO end CLEAR CALL draw_st_3d(name$,ι,dh,space_b,space_t,xwιn,ywιn,xls,x2s,yls,y2s,xh,yh) GET KEY getkey NEXT i CASE 91 ' prepare com$="copy objects" & nameS & "\* st object\temp" CALL shell(comS) CALL shell(comS) CASE 92 ! read report CALL read cut_report("temp") GET KEY getkey CASE 100 ' prototype CALL shell("c.\-clee\bc31\bm\rp-mt4") CASE ELSE PRINT "Job is not available. Select again " GET KEY key EXIT SELECT END SELECT LOOP END I************* ! End of file I************* ( ***************************************** **** * **** ! Written by Cheol H. Lee !! File: 71-menu.tru ! Date: 6/96 ! Library file for menu set mode "vga" clear a=l if a=l then call main menu (job) else call setup menuQob) end if end EXTERNAL I********* ! Summary (71 -menu) ! SUB status (name$,num_tπ,dh,angle,space_t,space_b,d_loop,d_poιnt,& ! & xmax,ymax,zmax,xh,yh,decιmal,skιp) ! SUB maιn_menu(job) ! SUB setup_menu(job) ! SUB read_setup(name$,num_trι,dh,angle,space_t,space_b,d_looρ,d pomt,& ' & xmax,ymax,zmax,xh,yh,decιmal,skιp) ! SUB save setup( name$,num_tri,dh,angle,space_t,space_b,d_ loop,d_poιnt,& 1 & xmax,ymax,zmax,xh,yh,decunal,skιρ) ! Subroutine: status I************************* SUB status (name$,num_tri,dh,angle,sρace_t,space_b,d loop,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) ASK free memory mem memory=round(mem/l 000, 1 ) IF dh<>0 THEN num_shce=ιnt(zmax/dh) OPEN #9:SCREEN 0.66, 1,0, 1 WINDOW #9 CLEAR SET COLOR "white" ! SET COLOR "red" PRINT "JOB SETUP " PRINT "*********************************" PRINT " Object ";name$;",";num_tri;"tri" PRINT " " PRINT " Slices :";num_shce;"slιces" PRINT " Free memory :";memory;"Kb" PRINT PRINT " Loop gab .";dJoop;"cm" PRINT " Pomt res :";d_point;"cm" PRINT " Point skip :";skιp;"pts" PRINT " Decimal :";decimal;"place" PRINT PRINT " Cut angle :";angle;"degree" PRINT " Foam :";dh;"cm" PRINT " Bottom space. ";space_b;"cm" PRINT " Top space :";space_t;"cm" PRINT PRINT " home x,y :";xh;yh PRINT PRINT " object x:";xmax;"cm" PRINT " y:";ymax;"cm" PRINT " z:";zmax;"cm" END SUB t *********************** ! Subroutine: main menu I*********************** ! main menu for job selection SET BACK "black" SET COLOR "white" OPEN #1 :SCREEN 0,0.33,0.1,1 OPEN #2:SCREEN 0.33,0.66,0.1,1 OPEN #3:SCREEN 0, 1,0,0.1 ! - 1 st column 1111111111 1 1111111111111 1111111 1 1111111 1 111 1 1 1 1 WINDOW #1 CLEAR SETCOLOR"white" ! SETCOLOR"yellow" PRINT"RPCONTROLSOFTWARER72" PRINT "by Cheol Lee " PRINT ! SET COLOR "red" PRINT "JOB LIST" PRINT "******************************" ! SET COLOR "white" PRINT " 0) Quit" PRINT " l ) DOS" PRINT " 2) Job setup" PRINT " 3) Combine STL" PRINT " 4) Append STL" PRINT " 5) STL to object" PRINT " 6) Select object" PRINT " 7) Rotate object" PRINT " 8) Resize object" PPJNT " 9) Registration" ! SET COLOR "green" PRINT "SLICE " ! SET COLOR "white" PRINT " 1 1 ) Object to a ne " PRINT " 12) Object to lines " PRINT " 13) Lines to loops " PRINT " 14) Loops to pomts " PRINT " 15) Points to cuts" PRINT " 16) Cuts to steps" PRINT PRINT " 21) Remove loop " PRINT " 22) Reverse loop " PRINT " 23) Pomts to cuts(SMl) " !- 2nd column 2222222222222222222222222222222222222222222222222 WINDOW #2 CLEAR SETCOLOR"white" ! SETCOLOR "magenta" PRINT " Manufacturing Lab " PRINT " Univ. of Utah " PRINT " " BOX LINES 0,0.8,0.93,1 PRINT PRINT ! SET COLOR "green" PRINT "READ " ! SET COLOR "white" PRINT " 41 ) Loop index" PRINT " 42) Pomt index" PRINT " 43) Cut index" PRINT " 44) Coord file" PRINT " 45) Create cut report" PRINT " 46) Read cut report" ! SET COLOR "green" PRINT "AUTOMATIC VIEW" ! SET COLOR "white" PRINT " 51 ) Object" PRINT " 52) Lmes-3D" PRINT " 53) Lmes-2D" PRINT " 54) Loops" PRINT " 55) Points" PRINT " 56) Cuts" PRINT " 57) Steps" ' SET COLOR "green" PRINT "SHAPE " MAKER r ! SET COLOR "white" PRINT " 91) prepare " PRINT " 92) check report" PRINT " 100) prototype" !— question window WINDOW #3 CLEAR SET COLOR "white" ! SET COLOR "white" INPUT PROMPT "Select a job. ":job CLEAR END SUB *************** ********** ! Subroutine: setup menu SUB setup_menu(job) SET BACK "black" OPEN#l:SCREEN 0,0.33,0.1,1 OPEN #2:SCREEN 0.33,0.66,0.1,1 OPEN #3:SCREEN 0,1,0,0.1 !- 1st column 111111111111111111111111111111111111111111111 WINDOW #1 CLEAR 1 SET COLOR "yellow" PRINT "RP CONTROL SOFTWARE R67" PRINT "by Cheol Lee " PRINT ! SET COLOR "red" PRINT "JOB LIST" PRINT "******************************" ! SET COLOR "white" PRINT " 0) Return to main menu" PRINT PRINT" 1) Foam thickness" PRINT " 2) Max Cut angle " PRINT " 3) Bottom space " PRINT " 4) Top space " PRINT PRINT" 11) Min loop gab" PRINT " 12) Point resolution" PRINT" 13) Skip points" PRINT " 14) Decimal point " PRINT PRINT "21) Home" PRINT PRINT "31) Save setup" !- 2nd column 2222222222222222222222222222222222222222222222222 WINDOW #2 CLEAR .' SET COLOR "magenta" -33- PRINT " Manufacturing Lab " PRINT " Univ. of Utah " PRINT " " BOX LINES 0,0.8,0.93,1 ! SET COLOR "white" '— question window WINDOW #3 CLEAR ' SET COLOR "white" INPUT PROMPT "Select a job. ":job CLEAR END SUB I************************ ! Subroutine: read setup I************************ SUB read setup (nameS,num_trι,dh,angle,space_t,space_b,d loop,d_pomt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) OPEN #l :name "objecfvsetup.rp", create newold.access outm, org record RESET #l :Begιn WHEN error IN READ #1 :name$,num_tπ,dh,angle,space_t,space_b,d_loop,d_poιnt READ #l -χmax,ymax,zmax READ #1 xh,yh,decιmal,skιp USE END WHEN CLOSE #1 END SUB I************************ .' Subroutine: save setup SUB save_setup(name$,num_tri,dh > angle,space_t,space_b,d_loop,d_pomt,& & xmax,ymax,zmax,xh,yh,decιmal.skιρ) OPEN #l :name "object\setup.rp", create newold.access outin, org record ERASE #1 SET #1 :RECSIZE 10 RESET #l :Begm WRITE #1 ameS.num tπ,dh,angle,space_t,space_b,d oop,d_poιnt WRITE #l :xmax,ymax,zmax WRITE #l :xh,yh.decιmal,skιp END SUB I************* ! End of File ************************************************** ********* Written by Cheol H. Lee University of Utah Date : 6/96 Object : make object vertex file by reading a stl file Input : *.stl file Output : *.vtx file *********************************************************** MEMO - *.stl and *.vtx are in "objectV directory - All other files are in "object\[name]\" directory - *.stl is a text or a binary file made by a CAD s/w - *.vtx is a record file having coord of triangles. Each triangle has 9 coord (xl,yl,zl ,x2,y2,z2,x3,y3,z3) The mm x,y,z in *.vtx are always 0 by shifting coord *********************************************************** library "71-gvt.tru" library "3dlib.trc" library"71-ut.tru" library "util b.tru" name$="temp" !name$="head" [call get_vtx(name$,num_tri) ! SUB object_sιze(name$,xmιn,xmax,ymm,ymax,zmιn,zma> ,num_trι) ! SUB shift_vtx_file(name$,xrnιn,ymιn,zmιn) [call stl_to_vtx(name$,num_tπ,xmax,ymax,zmax) !call scale_vtx_file("sl ,, .2,83,76,50,"temp") ! call combme_stl("dl ".0,3) call rotate_vtx(name$,"x", 90, xmax,ymax,zmax, "temp") [call object_sιze("temp",xmm,xmax,ymin,ymax,zmιn,zmax,num_trι) !call rotate_vtx(name$."z",90,xrnax,ymax,zmax) [call draw_vtx_3d(nameS,xmax,ymax,zmax) end EXTERNAL ********* Summary (72-1-vtx) ********* SUB combιne_stl(name_ιnl$,name_in2$,name_out$) SUB append_stl(name_ιnout$,name_ιn$) SUB vtx_to_coord(vtx$,#2) SUB text_to_coord(textS,rec_num,#2) SUB get vtx(nameS.num trι) SUB ob j ect_sιze(name$,xπun,xmax,ymin,ymax.zmιn,zmax,num tri) SUB shift vtx filei name$,xmιn,ymm,zmιn) SUB stl_to_vtx(nameS,numJri,xmax,ymax,zmax) ! SUB scale_vtx_fιle(name_in$,xr,yr,zr,xmax,ymax,zmax,name_out$) ! SUB rotate_vtx(name_ιn$,axes$,angle,xmax,ymax,zmax,name_out$) I ************************ ! Subroutine: combine stl I************************ SUB comb e_stl(name_inl$,name_in2$,name_out$) ! i,ι,o ! Merge two STL files. Useful for SilverScreen stl files ! name_ιnl$+name_in2$=name_out$ ιnl$="object\" & name_ιnl$ & ".stl" ! mput file name ιn2$="object\" & name_uι2$ & ".stl" out$="object\" & name_out$ & ".stl" ! output file name OPEN #l .Name inlS.Access mρut,Create old,Org byte OPEN #2:Name ιn2$, Access ιnput,Create old.Org byte OPEN #5 Name out$,Access outm, Create newold,Org byte ERASE #5 DO WHILE More #1 ! copy contents of first STL file READ #1 , bytes lOOO recS WRITE #5:rec$ LOOP DO WHILE More #2 ! append contents of second STL file READ #2,bytes 1000:rec$ WRITE #5:rec$ LOOP CLOSE #1 CLOSE #2 CLOSE #5 END SUB !*******••***********•*** ! Subroutine: append_stl I************************ SUB apρend_stl(name_ιnout$,name_ιn$) ! 1/0,1 ' Append STL files useful for SilverScreen stl files ! ιnout$+ιn$=ιnout$ ιnout$="ob ect\" & name_ιnout$ & ".stl" ! file names ιn$="object\" & name_in$ & ".stl" OPEN #l:Name ιnout$,Access outm,Create newold,Org byte OPEN #2:Name in$,Access mput,Create old.Org byte RESET #l :End DO WHILE More #2 ! append second file to first file READ #2,bytes 1000:rec$ WRITE #l :rec$ LOOP CLOSE #1 CLOSE #2 END SUB I ************************** ' Subroutine vtx_to_coord I ************************** SUB vtx_to_coord(vtx$,#2) ' 1,0 ' Get x, y, z coordinates out of "vertex x y z " text in stl file 1 vtx$ "vertex x y z" text in stl file ' #2 * vtx file channel vahd$="1234567890-+ e" ' valid char for coord length=Len(vtx$) xl=CPos(vtx$ > vahd$, l) ' start and end positions of x, y, z x2=NCPos( vtx$,vahd$,x 1 + 1 )- 1 y 1 =CPos(vtx$, vahd$,x2+ 1 ) y2=NCPos(vtx$,vaIιd$,y 1 + 1 )- 1 z 1 =CPos(vtx$, vahd$,y2+ 1 ) z2=NCPos( vtxS, valιd$,z 1 + 1 )- 1 x$=vtx$[xl x2] ' x,y,z string y$=vtx$[yl y2] z$=vtx$[zl z2] x=Val(x$) ' x,y,z coord y=Val(y$) z=Val(z$) WRITE #2 x,y,z ' save three vertex coords END SUB t * ** * * * *** * * * * * * * * ** ** * **** * ' Subroutine text to coord I *************************** SUB text_to_coord(text$,rec_num,#2) ' 1,0,0 ' Get x, y, z coordmates from textS of stl • textS one reading text of stl ' rec num last record number in textS ' #2 * vtx, output record file channel rec num=l ' initialize DO outer=Pos( textS, "outer",rec_num) ' pos of start of a triangli" endloop=Pos( textS, 'endloop",outer) ' pos of end of a triangle IF outer=0 OR endloop=0 THEN Exit Sub tπangle$=text$[outer endloop+6] string for one triangle rec_num=endloop+6 length=Len(tπangle$ ) v 1 =Pos( triangleS, "vertex", 1 ) ' 1 st vertex v2=Pos( triangleS, "vertex",v 1 +6) i 2nd vertex v3=Pos( triangleS, "vertex" ,v2+6) ' 3rd vertex vl$=tπangle$fvl+6 v2-l] v2$=tπangle$[v2+6 v3-l] v3$=tπangle$fv3+6 length] CALL vtx_to_coord(vl$,#2) get x,y,z CALL vtx_to_coord(v2$,#2) CALL vtx_to_coord(\ 3$,#2) LOOP END SUB I **** ********** * **** ***** 1 Subroutine get vtx I************************ SUB get_vtx(name$,num_trι) ' ι/o,o ' Make * vtx file from * stl file ' nameS STL and vertex file name without extension ' num rri number of triangles file_stl$="object\" & nameS & " stl" ' file names file_vtx$="object\" & nameS & " vtx" OPEN #1 name file stlS.org byte ASK #1 filesize fsize ' get number of chars in STL file OPEN #2 name file vtxS, access outin.create newold, org record ERASE #2 SET #2 recsιze 10 rec_pos=l ' start from beginning of STL file count=0 ' number of iteration m DO LOOP DO WHILE more #1 count=count+ 1 ' update number of iteration SET #1 record rec_pos ' read from next record READ ft 1 ,bytes 30000 textS ' read 30000 chars at a time text$=Lcase$(text$) ' make all string lower case CALL text_to_coord(text$,rec_num,#2) ' find vertex coords rec_pos=rec_pos+rec_num ' update position of record LOOP ASK #2 filesize num rec num_tπ=num_rec/9 ' calculate number of triangles CLOSE #1 CLOSE #2 END SUB I************************* ' Subroutine object size t************************* SUB ob ect_sιze(nameS.xmιn,xmax,ymιn,ymax,zmιn,zmax,nurn_trι) ' ι,o, ' Find object size reading vertex coord record file 1 nameS vertex file name ' x,y,zmιn,max nun and max of x, y, and z object size ' num tri number of triangles file_vtx$="object\" & nameS & " vtx" ' file name CALL open_fιle(#l,file_vtx$,error) ' open record file ASK #1 filesize num_rec num_trι=num_rec/9 ' number of triangles and vertexes num_vtx=num_rec/3 RESET #1 Begin xmιn,ymιn,zmm=1000 ' itiahze mm,max of x,y,z xmax,ymax,zmax=- 1000 FOR ι=l TO num vtx ' compare all x,y,z to find mm and max READ #1 x,y,z IF x<xmιn THEN xmιn=x ' update m ,max value IF x>xmax THEN xmax=x IF y<ymm THEN vmm=y IF y>ymax THEN ymax=y IF z<zmιn THEN zmιn=z IF z>zmax THEN zmax=z NEXT i CLOSE #1 END SUB t *************** ** * ********* ! Subroutme: shift vtx file I *************************** SUB shift_vtx_file(name$,xm ,ymin,zmin) ! i o,i,ι,ι ! Shift coords of vtx file to make x ,ymin,zmin=0 ! nameS: object name, nameS.vtx ' xmin, ymin, zmin : mm and max of z, y, z. original object size file_vtx$="object\" & nameS & ".vtx" ! file name OPEN #l :Name file_vtx$,Access Outιn,Create Newold,Org Record ASK #1 :filesιze num rec num_vtx=num_rec/3 ! number of vertexes RESET #l :Begιn FOR ι=l TO num vtx ! shift all coords RESET #1. Record (ι- l )*3+l READ #l :x,y,z RESET #l :Record (ι-l)*3+l WRITE #l :x-xrmn,y-ymin,z-zπun NEXT i CLOSE #1 END SUB ! Subroutine: stl to vtx I*************************** SUB sfl_to_vtx(nameS.num_tπ,xmax,ymax,zmax) ! 1/0,0,0,0,0 ! Make *.vtx coord file reading and shifting *.stl file ! nameS : *.stl, *.vtx. object name ! num_tπ,x,y,zmax : num of triangle in vertex file, and object size ! make vertex record file CALL get_vtx(nameS,num tri) ! find object size CALL object_sιze(nameS.xmιn,xmax,ymιn,ymax,zmιn,zmax,rιurn tri) ! if mιn=0, then skip shifting IF xmιn=0 and ymιn=0 and zmιn=0 THEN EXIT SUB ELSE ! if minoO, then shift CALL shift_vtx_file(name$,xmm,ymin,zmιn) xmax=xmax-xmin ymax=ymax-ymιn zmax=zmax-zmin END IF END SUB I*************************** ! Subroutme: scale vtx file I*************************** SUB scale_vtx_file(name_in$,xr,yr,zr,xmax,yrnax.zmax,name_outS) ! 1.1.1,1,1/0,1/0,1/0,0 ! Enlarge object by scaling vertex coords ' name_m$,_out$ original vertex coord file and scaled vertex file ! xr,yr,zr conversion ratio old coord*ratιo=new_coord ' x,y,zmax . new object size after scaling file_old$="object\" & name_ιn$ & " vtx" ' file names fϊle_new$="object\" & name outS &" vtx" OPEN #l:Name file oldS .Access Outm,Create Newold,Org Record IF file_old$ofile_newS THEN OPEN #2:Name fιle_new$,Access Outm,Create Newold,Org Record ERASE #2 SET #2 Recsιze 10 END IF RESET #1. Begin ASK #l:filesιze num_rec num_vtx=num_rec/3 ! get number of vertex FOR ι=l TO num vtx ' scale all vertex RESET #1 Record (l-l )*3+l READ #1 x,y,z x=x*xr ' scale x,y,z y=y*yr z=z*zr IF file_old$ofile_new$ THEN WRITE #2.x,y,z ELSE RESET #1 Record (ι-l)*3+l WRITE #1 x,y,z END IF NEXT i xmax=xmax*xr ! update object size ymax=ymax*yr zmax=zmax*zr CLOSE #1 IF fιle_old$ofile_new$ THEN CLOSE #2 END IF END SUB \ ************************ ' Subroutine rotate vtx I ************************ SUB rotate vtx(name_ιn$,axes$,angle,xmax,ymax,zmax,name_out$) ' 1/0,1,1,0,0,0,0 ' Rotate vertex file about x, y, or z axes. ! name inS, outS * vtx. object name .' axesS : rotation axes, "x", "y" or "z" ! angle • rotation angle in degree. ! xmax,ymax, zmax new object size after rotation IF axes$o"x" and axes$o"y" and axes$o"z" THEN Exit Sub IF angle=0 THEN Exit Sub file_old$="object\" & name inS & ".vtx" ! file names file_new$="object\" & name outS &".vtx" OPEN #l:Name file oldS, Access Outin. Create Newold,Org Record IF file oldSofile newS THEN OPEN #2:Name file_new$,Access Outin.Create Newold, Org Record ERASE #2 SET #2:Recsιze 10 END IF ASK #1.filesize num_rec num_vtx=num_rec/3 angle=angle*pι 180 ! convert degree into radian FOR ι=l TO num vtx ! rotate vtx RESET #l :Record i*3-2 READ #l :x,y,z IF axes$="x" THEN ' rotate about x xnew=x ynew=y*cos(angle)-z*sιn( angle) znew=y*sm(angle)+z*cos(angle) ELSE IF axes$="y" THEN ! rotate about y xnew=x*cos(angle)+z*sιn( angle) ynew=y znew=-x*sιn(angle)+z*cos( angle) ELSE ! rotate about z xnew=x*cos(angle)-y*sιn( angle) ynew=x*sιn(angle)+y*cos(angle) znew=z END IF IF file_old$ofile_new$ THEN WRITE #2:xnew,ynew,znew ELSE RESET #l :Record (ι-l)*3+l WRITE #1 :xnew,ynew,znew END IF NEXT i CLOSE #1 IF file oldSofile newS THEN CLOSE #2 END IF ! new object size CALL ob j ecι_sιze(name_out$,xmιn,xmax,ymιn,ymax,zmιn,zmax,num_trι) CALL shιft_vtx_file(name_out$,xmιn,ymm,zmιn) ! shift to make min 0 xmax=xmax-xmιn ! find new object size ymax=ymax-ymιn zmax=zmax-zmιn END SUB I************* ! End of File I************* I***************************************************************** ! Written by Cheol H. Lee ' University of Utah I ! Date : 6/96 I ! Object : slice an object (*.vtx), and make slice files (*.ln) ! Input : *.vtx file ! Output . *. In file I ***************************************************************** [ MEMO ' - *.ln files are in "object\[name]\" directory ! In *.ln are Ime coords. Each line has 4 coords (xl,yl,x2,y2) I***************************************************************** library "69-ut" library "69-gln" name$="sl " start=l end=2 dh,decιmal=2 !call vtx_to_hne(name$,start,end,dh,decιmaI) call draw_lιne(name$.2,0,100,100) end EXTERNAL ********* Summary (72-2-lnl) ********* SUB get_lme(nameS,#l,array,a(,),num_trι,slιce_h,decιmal,file_ln,num_ln) SUB vtx_to_hne_h(name$,slice_h,decιmal,file_ln) SUB vtx_to_line(name$,start,end,dh,decιmal) |********************** ! Subroutine: get line I********************** SUB get_lιne(name$,# 1 ,array,a(,),num_trι,slιce_h,decιmal,file_ln,num_ln) Make line segment coord record file (*.ln) of a slice i,..,o,o of the object at a certain height nameS . object name. *.vtx #1 : *.vtx file channel array . array option. l=use array to load vtx file, 0=do not use array If memory allows, use array a(,) : load vtx file to array. array sιze=a(num_trι,9). (xl,yl,zl,x2,y2,z2,x3,y3,z3) num tri : number of triangle in vertex file s ce i . height of a slice decimal : round decimal of hne coord file ln : Ime coord record file name, make file ln.ln in *.ln file (xl,yl ,x2,y2)(x2,y2,x3,y3).. ! num ln : number of lines in *.ln file & nameS & "\" & str$(file_ln) & ".In" ! file name OPEN #2:Name file lnS.Access Outιn,Create Newold,Org Record ERASE #2 SET #2:RECSIZE 10 RESET #1 Begin ' read * vtx file and find Ime segment on a slice FOR ι=l TO num π IF array =1 THEN ' use array if there is enough memory x 1 =a(ι, 1 ) ' read triangle coord from array yl=a(ι,2) zl=a(ι,3) x2=a(ι,4) y2=a(ι,5) z2=a(ι,6) x3=a(ι,7) y3=a(ι,8) z3=a(ι,9) ELSE ' if we don't use array, read file directly READ #1 xl ,yl ,zl x2,y2,z2,x3,y3,z3 END IF z 1 =z 1 -shce_h ' shift slice height to z=0 z2=z2-shce_h z3=z3-shce h found=0 ' found=l if side of triangle intersects ' slice plane, check=l ' check intersection of triangle and slice plane IF zl>0 AND z2>0 AND z3>0 THEN check=0 ' three z pomts are above cut IF zKO AND z2<0 AND z3<0 THEN check=0 • three z pomts are below cut IF z 1=0 AND z2=0 AND z3=0 THEN check=0 ' three z pomts are on the cut i ' when intersect IF check=l THEN i ' l) zl=0 case IF z 1=0 THEN ' at least one point is on the slice IF z2=0 AND z3o0 THEN ' zl=0 z2=0 z3<>0 xlw=xl ylw=yl x2w=x2 y2w=y2 found=l ELSE IF z2>0 THEN IF z3<=0 THEN ' zl =0 z2>0 z3<=0 xlw=xl ylw=yl n2=Abs(z2) ' n2 n3 ratio n3=Abs(z3) x2w=(n2*x3+n3*x2)/(n2+n3) y2w=(n2*y3+n3*y2)/(n2+n3) found=l END IF ' z 1 =0 z2>0 z3>0 not the case ELSE IF z2<0 THEN IF z3>=0 THEN ' zl =0 z2<0 z3>=0 xlw=xl ylw=yl n2=Abs(z2) ! n2:n3 ratio n3=Abs(z3) X2w=(n2*x3+n3*x2)/(n2+n3) y 2w=(n2*y3+n3*y2)/(n2+n3) found= 1 END IF ! z 1 =0 z2<0 z3 <0 not the case END IF END IF ! 2) zl>0 case IF zl>0 THEN ! at least one point is above slice plane IF z2=0 THEN IF z3<=0 THEN ! zl >0 z2=0 z3<=0 xlw=x2 ylw=y2 n 1 =Abs(z 1 ) ! n 1 :n3 ratio n3=Abs(z3) x2w=(nl*x3+n3*xl)/(nl+n3) y2w=(nl*y3+n3*yl)/(nl+n3) found=l END IF ' z 1 >0 z2=0 z3>0 not the case ELSE IF z2>0 THEN IF z3<0 THEN ! zl>0 z2>0 z3<0 n2=Abs(z2) ! n2:n3 ratio n3=Abs(z3) x 1 w=(n2*x3+n3 *x2)/(n2+n3) y 1 W=(n2*y3+n3*y2)/(n2+n3) n 1 =Abs(z 1 ) ! n 1 :n3 ratio n3=Abs(z3) x2w=(nl *x3+n3*xl )/(nl+n3) y2w=(nl*y3+n3*yl)/(nl+n3) found=l END IF ! else not the case ELSE IF z2<0 THEN IF z3=0 TΗEN ! zl>0 z2<0 z3=0 xlw=x3 yl =y3 n 1 =Abs(z 1 ) ! n 1 :n2 ratio n2=Abs(z2) x2w=(n 1 *x2+n2*x 1 )/(nl +n2) y2w=(n 1 * y2+n2*y2)/(n 1 +n2) found=l ELSE IF z3>0 THEN ! zl>0 z2<0 z3>0 n 1 = Abs(z 1 ) ! n 1 : n2 ratio n2=Abs(z2) Xlw=(nl*x2+n2*xl)/(nl+n2) ylw=(nl*y2+n2*yl)/(nl+n2) n2=Abs(z2) ! n2:n3 ratio n3=Abs(z3) x2w=(n2 *x3+n3 *x2)/(n2+n3) y2w=(n2*y3+n3*y2)/(n2+n3) found=l ELSE IF z3<0 THEN ! zl>0 z2<0 z3<0 nl=Abs(zl) .' nl:n2 ratio n2=Abs(z2) xlw=(nl*x2+n2*xl)/(nl+n2) ylw=(nl*y2+n2*yl)/(nl+n2) nl=Abs(zl) !nl:n3 ratio n3=Abs(z3) x2w=(nl*x3+n3*xl)/(nl+n3) y2w=(nl*y3+n3"yl)/(nl+n3) found= 1 END IF END IF END IF I ! 3)zl<0case IF zl<0 THEN ! at least one point is below slice plane IF z2=0 THEN IF z3>=0 THEN ! zKO z2=0 z3>=0 xlw=x2 ylw=y2 nl=Abs(zl) !nl:n3 ratio n3=Abs(z3) x2w=(nl*x3+n3*xl)/(nl+n3) y2w=(nl*y3+n3*yl)/(nl+n3) found= 1 END IF ELSE IF z2>0 THEN IFz3-0THEN !zl<0z2>0z3=0 xlw=x3 ylw=y3 nl=Abs(zl) !nl:n2 ratio n2=Abs(z2) x2w=(nl*x2+n2*xl)/(nl+n2) y2w=(nl*y2+n2*yl)/(nl+n2) found=l ELSE IF z3>0 THEN ! z 1 <0 z2>0 z3>0 nl=Abs(zl) !nl:n2 ratio n2=Abs(z2) xlw=(nl*x2+n2*xl)/(nl+n2) ylw=(nl*y2+n2*yl)/(nl+n2) nl=Abs(zl) !nl:n3 ratio n3=Abs(z3) x2 w=(n 1 *x3+n3 *x 1 )/(n 1 +n3 ) y2w=(nl*y3+n3*yl)/(nl+n3) found=l ELSE !zl<0z2>0z3<0 n 1 =Abs(z 1 ) ! n 1 :n2 ratio n2=Abs(z2) xlw=(nl*x2+n2*xl)/(nl+n2) ylw=(nl*y2+n2*yl)/(nl+n2) n2=Abs(z2) ! n2:n3 ratio n3=Abs(z3) x2w=(n2*x3+n3*x2)/(n2+n3) y2w=(n2*y3+n3*y2)/(n2+n3) found=l END IF ELSE IF z2<0 THEN IF z3>0 THEN ! zKO z2<0 z3>0 n 1 =Abs(z 1 ) ! n 1 : n3 ratio n3=Abs(z3) xlw=(nl*x3+n3*xl)/(nl+n3) ylw=(nl*y3+n3*yl)/(nl+n3) n2=Abs(z2) ! n2:n3 ratio n3=Abs(z3) X2w=(n2*x3+n3*x2)/(n2+n3) y2w=(n2*y3+n3*y2)/(n2+n3) found=l END IF END IF END IF END IF IF found=l THEN x 1 r=Round(x 1 w,decιmal) ! round intersecting Ime coord y 1 r=Round(y 1 w,decιmal) x2r=Round(x2w,decimal) y2r=Round(y2w,decιmal) WRITE #2:xlr,ylr,x2r,y2r ! save rounded Ime coord END IF NEXT i ASK #2:Filesιze num rec num_ln=num_rec/4 ! number of lines m *.ln file CLOSE #2 END SUB I*************************** ! Subroutine vtx to line h I*************************** SUB vtx_to_lιne_h(name$,slιce_h,decιmal,file_ln) ! 1,1,1,0 ! Cut an object at a certain height and make line files ! nameS : object name, *.vtx ! s ce h : cut height ! decimal : round Ime coords ! fϊle ln : Ime record file name. *.ln DIM a(0,0) ! initialize com$="md objectV & nameS ! if no object directory, create it CALL dos(com$) CLEAR file_vtx$="object\" & nameS & ".vtx" ! file name CALL open_file(#l,file_vtx$,error) ! open vertex coord file IF error=l THEN Exit sub ASK #l :filesize num rec num_tπ=num rec/9 PRINT " Making file ":str$(file n),".ln. Wait.. " ! make a line file CALL get me(nameS. a l,0,a(,),num_tri,slιce_h,decιmal,fιle_ln,num_lιne) CLOSE #1 END SUB ι************************* ! Subroutine: vtx to line I************************* SUB vtx_to_line(narneS,start,end,dh,decirnal) ! ι,i,i,i,ι ! Automatically cut an object with dh thickness, and make line files ! nameS : object name. *.vtx ! star end : start and end number of Ime files to make ! 1.In [h=0], staπ.ln [h=(start- 1 )*dh] ! dh.decimal: layer thickness, round line coord. DIM a(0,0) ! mitialize com$="md object\" & nameS ! if no object directory, create it CALL dos(comS) CLEAR file_vtx$="object\" & nameS & ".vtx" ! file_name CALL open_file(#l,file_vtx$,error) ! open vertex file IF error=l THEN Exit sub ASK #1 :filesize num rec num_tri=num_rec/9 array=l ! check memory for array usuage WHEN error m MAT REDIM a(num_tri,9) CALL file_to_array(file_vtx$,a(,),num_tri,9) USE array=0 END WHEN * ! making Ime files for cuts no_lιne_file=0 ! number of empty line files num_file=end-start+l ! number of line file FOR i=start TO end ! create Ime files shce_h=(i-l)*dh ! slice height PRINT PRINT "Making file ";str$(i);".ln";" (";i;7";end;"). Wait.." ! get one Ime file at certain height CALL get_lιne(name$,#l,array,a(,),num_trι,slιce_h,decιmal,ι,num_lιπe) ! if Ime file is empty, update counter. IF num_lme<3 THEN no_lιne_file=no_lιne_fιle+ 1 NEXT i PRINT " *** OUTPUT ***" PRINT PRINT num file;"files are made. " PRINT no_lιne_file;"files have less than 3 lines." CLOSE #1 END SUB I************* ! End of File I************* ι*********************************************************** ! Written by Cheol H. Lee ! University of Utah ! File: 72-2-ln2.tru ! Date: 2/96 ! Object : scale and shift line coord in line file, and find ! nun and max x,y of Ime coord ! Input : *.ln file, old Ime file ! Output : *.ln file, new Ime file |************************************************************ library "69-gln.tru" library "3dlib.trc" library "69-ut.tru" name_ιn=105 name_our=105 scale=l xshift=10 yshift=5 call lme_sιze(name_ ,xmιn,xnιax,ymin,ymax,num_line) pπnt name_ιn,xmιn,xmax,ymιn,ymax call scale_shift_hne(name_m,scale,xshιft,yshift,x m,xmax,ymm,ymax,name_out) call lme_sιze(name_out,xmιn,xmax,ymm,ymax,num_line) prmt name_out,xmιn,xmax,ymιn,ymax end EXTERNAL |********* ! Summary (72-2-ln2) I********* ! SUB lιne_sιze(name$,name,xmιn,xmax,ymιn,ymax,num_line) ! SUB scale_shιft_hne(name_ ιn,scale,xshιft,yshιft,xmm,xmax,ym ,ymax,name_out) I ************************* ! Subroutme: line size I************************* SUB line_size(name$,name,xmin,xmax,ymin,ymax,num_lme) ! ι,o,i,i,ι,ι,ι ! Fine min and max x,y m a line file ! nameS : object name. *.vtx ! name : Ime file num. name.ln ! x,ymιn,max : min and max of x, y ! num hne : number of lines in *.ln file_ln$="object\" & nameS & "\" & StrS(name) & ".In" ! file_name CALL open_file(#l,fιle_ln$,error) ! open Ime file IF error=I THEN exit sub ASK #l:filesize num rec num_hπe=num_rec/4 ! number of lines RESET #1 :Begιn xmm,yπun=1000 ! initialize mm,max of x,y,z xmax,ymax=- 1000 FOR i=l TO num hne ! find m and max x,y of all lines READ#l:xl,yl,x2,y2 CALLπιin3(xl,x2,xπ_in,xmin) CALLrn 3(yl,y2,ym ,ymin) CALLmax3(xl,x2,xmax,xmax) CALLmax3(yl,y2,ymax,ymax) NEXTi CLOSE#1 ENDSUB I ************** *************** ! Subroutme: scale_shιft_lιne |***************************** SUB scale_shιft_lme(name$,name_m,scale,xshιft,yshιft,xmm,xmax,ymm,ymax,name_out) ! ι(5),o(5) ! Enlarge and shift Ime coord by scaling x,y coords ! nameS : object name. *.vtx ' name_ιn,_out: oπg al and scaled Ime files. *.ln ! scale . conversion ratio. old_coord*scale=new_coord ' x.yshift : shift distance. x_new=x_old+xshift, y_new=y_old+yshιft ' x,ymιn,max new nun and max x,y of line file after scalmg file_ιn$="object\" & nameS & "\" & str$(name_m) & ".In" ' input file file_out$="object\" & nameS & "\" & strS(name out) & " In" ' output file OPEN #1 Name file inS, Access Outm, Create Newold.Org Record IF file_ιn$ofile_out$ THEN OPEN #2. Name file_out$, Access Outin.Create Newold.Org Record ERASE #2 SET #2:Recsιze 10 END IF ASK #l :filesιze num rec num_lιne=num_rec/4 ! number of lmes m *.ln RESET #l :Begm FOR ι=l TO num line ! scale and shift all lmes RESET #1 Record (l-l )*4+l READ #1 xl,yl ,x2,y2 xl=xl*scale+xshιft ! scale and shift x2=x2*scale+xshιft yl=yl*scale+y shift y2=y2*scale+yshιft IF file_m$<>file_out$ THEN WRITE #2:xl,yl,x2,y2 ELSE RESET #l:Record (ι-l)*4+l WRITE #l :xl,yl,x2,y2 END IF NEXT i CALL lme_sιze(name_m,xmm,xmax,ymm,ymax,num_lme) ! find mm max x,y CLOSE #1 IF file mSofile outS THEN CLOSE #2 END IF END SUB I************* I************* ********************************************************** Written by Cheol H Lee University of Utah File 72-3-lpl tru Date 1/96 Object make complete loops, and save coord mfo array Input a(num of lιnes,4) Output b(num of hnes,4), ιndex(num of loops,2) ********************************************************** MEMO - coord m * In file are checked, verified, and sorted to make complete loops - eliminate lmes which are points or duplicated lmes, and fill gaps or add missing lmes, if any - a(num of lιnes,4) from * In (xl,yl,x2,y2)(x3,y3,x4,y4), - b(sorted num of lines 4) (xl ,yl,x2,y2)(x2,y2,x3,y3), - ιndex(num of loops,2) (start dιm_b,end dιm_b)(start dιm_b, end dim b), ********************************************************** EXTERNAL I********* ' Summary (72-3-lpl) I ********* ' SUB refine ιne(a(,),dιm_al,b(,),dιrn_bl) ' SUB fιnd_connected_lιne(a(,),dιm_al,xl,yl,x2,y2,& ' & xlc,ylc,x2c,y2c,found,count_hne) ' SUB find_closest_lιne(a(,),dιm_al ,x_ref,y_ref, & 1 & xld,yld,x2d,y2d,d_mιn,count_ltne) ' SUB make_loop(a(,),dun_al,d_loop,b(,),dιm_bl,ιndex(,),drm_mdexl ) I ************************* ' Subroutine refine line |************************* SUB refιne_hne(a(,),dιm_al ,b(,),dιm_bl ) ' 1,1,0,0 ' Eliminate lmes which are not lines but points in Ime file ' a(,) line coord record array a(dιm_al,4) ' dim al number of lmes ' b(,) updated Ime coord array b(dιm_bl,4) ' duri bl updated array size new number of lmes MAT REDIM b(dιm_al ,4) ' declare array size dιm_bl=0 FOR ι=l TO dim al ' check all lines for points IF a(ι,l)<>a(ι,3) Or a(ι,2)<>a(ι,4) THEN ' if a Ime is not a point dιm_bl=dιm_bl + l b(dιm_b 1 , 1 )=a(ι, 1 ) ' save line in new array b(dιm_bl,2)=a(ι,2) b(dιm_bl,3)=a(ι,3) b(dιm >l,4)=a(ι,4) END IF NEXT i IF dιm_bl=0 THEN ! if new Ime file is empty, PRINT "Problem, no line Press any key" ! print error message GET KEY getkey EXIT SUB ELSE PRINT dιm_bl ;"lιnes revised. ";dιm_al-dιm_bl, "pomts removed " END IF END SUB I ********************************* 1 Subroutme: find connected line ι ********************************* SUB fmd_connected_lme(a(,),dιm_al,xl,yl,x2,y2,& ! ι,ι,o, ,ι/o & x 1 c.y 1 c,x2c,y2c,found,count_lιne) ' Find a Ime startmg at x2,y2, and remove duplicated lines ! a(,), dim al • line array and size a(dιm_al,4) ! xl,yl,x2,y2 . a line coord ending at x2,y2 ! xlc,ylc,x2c,y2c- a line coord startmg at x2,y2 ! found 0=ιf not found, 1 =ιf found connected hne at > 2,y2 ' count lme • number of lines checked found=0 ' initialize FOR ι=l TO dim al ! find a line startmg x2,y2 by searchmg all lmes 1 — check lmes which are not checked yet IF a(ι,l)>=0 THEN xl l=a(i,l ) yl l=a(i,2) x22=a(ι,3) y22=a(ι,4) !— check connection at starting pomt to x2,y2 IF xl l=x2 And yl l= 2 THEN a(ι, 1 )=- 10 ! mark when checked count hne=count lιne+1 ' update count lme IF x22<>xl Or y22<>yl THEN ' if not duplicated line, keep it xlc=xl l ylc=yl l x2c=x22 y2c=y22 found=l END IF '-- check connection at end pomt to x2,y2 ELSE IF x22=x2 And y22=y2 THEN a(ι, 1 )=- 10 ! mark when checked count_hne=count lιne+ 1 IF xl 1 <>xl Or y 11 <>y 1 THEN ! if not duplicated line, keep it xlc=x22 ylc=y22 x2c=xl l y2c=yl l found=l END IF END IF END IF NEXT ! END SUB I********************************* ' Subroutine find closest line I********************************* SUB fιnd_closest_lιne(a(,),dιm_al,x_ref,y_ref, & ' ι(4),o(5),ι/o & xld,yld,x2d,y2d,d_mιn,count_lme) ' If a connected Ime was not found, find closest Ime from x ref.y ref ' a(,), dιm_al Ime coord array and its size a(dιm_al,4) ' x_ref,y_ref reference point to find closest Ime from ' xld,yld,x2d,y2d closest Ime from reference pomt (x_ref,y_ref) ' d_mιn gab between ref pomt and closest Ime 1 count lme number of lines checked d_mm= 100000 ' initialize lme_pos=0 '-- check all lmes FOR ι=l TO dim a 1 '— check Ime which are not checked yet xl=a(ι,l) yl=a(ι,2) x2=a(ι,3) y2=a(ι,4) d=((x_ref-xl ) Λ 2+(y_ref-y 1 ) Λ 2) Λ 0 5 ' distance between xl .yl and reference point IF d<d_mιn THEN ' update distance xld=xl yld=yl x2d=x2 y2d=y2 d_mιn=d hne_pos=ι END IF d=((x_ref-x2) Λ 2-r(y_ref-y2) Λ 2) Λ 0 5 ' distance between x2,y2 and reference pomt IF d<d_mιn THEN ' update distance xld=x2 yld=y2 x2d=xl y2d=yl d_mιn=d lme_ρos=ι END IF END IF NEXT i IF lme_pos=0 THEN ' if the closest Ime is not found, error PRINT "Problem"' Can not find closest line " ELSE a(hne_pos, l )=-10 ' mark if checked count_hne=count_lιne+l ! update counter END IF END SUB ! Subroutme: make loop *********************** SUB make_loop(a(,),dιm_al,d_loop,b(,),dιm_bl,ιndex(,),dιm ιndexl )h(3),o(4) Make closed loops by connectmg all lines and adding missmg lmes Call find closest line, find connected lme a(,), dim al : line coord array and its size. a(dιm_al,4) (Xl 1 yl,x2,y2)(x3,y3,x4,y4)(x5,y5,x6,y6),. d loop : max gab allowed for missmg Ime if gab>d_loop, new loop exists b(,),dιm_bl loop line coord array and its size. b(dιm_bl,4) (Xl,yl,x2.y2)(x2,y2,x3,y3)(x3,y3,x4,y4),. mdex(,) loop line file index and its size. ιndex(dιm_ιndexl ,2) (start dim b.end dιm_b)(start dim b.end dim b), dim index 1 . number of loops MAT REDIM b(2*dιm_al,4) ! declare array size count_lιne=0 ! initialize count lmes considered dιm_bl=0 ' initialize number of connected line count closest_lιne=0 '— first Ime of first loop dιm_mdexl=l ! number of loops ιndex(dιm_ιndex 1 , 1 )= 1 ! first loop start mdex xl=a(l,l ) ! start line yl=a(l,2) x2=a(l,3) y2=a(l,4) dιm_b 1 =dιm_b 1 + 1 ! keep the first line b(dιm_bl,l )=xl b(dιm_bl,2)=yl b(dιm_bl ,3)=x2 b(dιm_bl ,4)=y2 a(l,l)=-10 ! mark if considered count hne=count lme+1 x_start=xl ! start a loop from xl .yl y_start=yl !-- make closed loops DO found=0 ! find connected line from xl.yl CALL fιnd_connected_lιne(a(,),dιm_a 1 ,x 1 ,y 1 ,x2,y2,& & xlc,ylc.x2c,y2c,found,count_lιne) '-- if found connected Ime, keep the line IF found=l THEN b(dιm_bl,3)=x2c b(dιm_bl ,4)=y2c END IF '-- if not found connected line, find closest Ime IF found=0 THEN CALL find_closest_lιne(a(,),dιm_al ,x2,y2, & & xlc,ylc,x2c,y2c,d_mm,count_lιne) count closest lιne=count closest lιne+1 '- add missmg Ime by filling gab IF d_mιn<d_loop THEN IF x2=x_start And y2=y_start THEN ! check d_looρ PRINT "Problem" ' Mmimum loop distance is too small " GET KEY key END IF dim b 1 =dιm_b 1 -1 ' add missing Ime b(dιm_bl,l )=x2 b(dιm_bl,2)=y2 b(dιm_bl,3)=xl c b(dιm_bl,4)=ylc dιm_bl=dιm_bl-l b(dιm_bl,l)=xlc b(dιm_bl,2)=ylc b(dιm_bl,3)=x2c b(dιm_bl,4)=y2c '— new loop ELSE '-- close loop IF x_start<>x2 OR y_start<>y2 THEN dιm_bl=dιm_bl+l b(dιm_bl,l)=x2 b(dιm_bl,2)=y2 b(dim_bl,3)=x_start b(dιm_b 1 ,4)=y start END IF ιndex(dιm_mdexl,2)=dιm_bl ' end loop mdex dιm_b 1 =dιm_b 1-1 [ new start Ime b(dιm_bl,l)=xlc b(dιm_bl,2)=ylc b(dιm_bl,3)=x2c b(dιm_bl,4)=y2c dim index 1 =dun_mdex 1 + 1 ιndex(dιm_ιndex 1 , 1 )=dιm_b 1 ' start loop mdex x_start=xlc y_start=y 1 c END IF END IF xl=xlc ! new line to be connected yl=ylc x2=x2c y2=y2c LOOP UNTIL count_lιne>=dιm_al '— close last loop IF x_start<>x2 OR y_startoy2 THEN dιm_bl=dιm_bl + l b(dιm_bl,l)=x2 b(dun_bl,2)=y2 b(dim_b 1 , 3 )=x_start b(dιm_b 1 ,4)=y_start END IF mdex(dιm_ιndexl,2)=dιm_bl ! end loop mdex PRINT dιm_ιndexl ;"loops, ";dιm_bl , "lines, ";count_closest_ line, "gabs exist " END SUB I************* 1 *** ********** ^ ******************************* ************************************** ! Written by Cheol H.Lee ! ! File. 72-4-pt.tru ! Date: 1/96 I ! Object • Read loop file (* lp, *.lpx), and make pomt file (*.pt, *.ptx) ! Input • loop record file (*.lp, *.lpx) ! Output point record file (*.pt, *.ptx) I ************ * ************ ************ *** ************** * ************* * ! MEMO ! - *.lp : ccw loop record file. (xl,yl,x2,y2)(x2,y2,x3,y3),. ' - *.lpx: loop mdex record file, each loop has 10 records ' (start Ime num, end Ime num, xd,yd, xu,yu, xl,yl, xr.yr) ! where xd,yd=ymm pt. xu,yu=ymax pt. xl,yl=xmm pt, xr,yr=xmax pt ! - *.pt : pomt coord record file (xl,yl)(x2,y2)(x3,y3),.. ! - *.ptx : pomt mdex record file, each loop has 10 records ! (num of start pt, num of end pt, xd,yd,xu,yu,xl,yl,xr,yr) ! - two methods are available in making pomt file ! 0=ιnclude all start and end points of lmes ! l=even distance pomts, ignore start and end points of lmes |******* ************************************************************** library "71-3-lpl" library "71 -gin" library "71-ut" library "utillibl " name$="fordcar" start=l end=2 step=.2 decιmal=2 method=l call read_record_file("object\fordcar\6.1p",4) ! call loop_to_po t(name$,start,end,step,decιmal,method) [ call draw_poιnt(name$ , 1 ,0, 100, 100) end EXTERNAL ********* Summary (72-4-pt) ********* SUB find_point_by_vtx(xl ,yl,x2,y2,step,decιmal,#l, count) SUB find 30int_by_dιs(x_end,y_end,x2,y2,step,decιmal,#l, count) SUB one_loop_to_pomt(name$,file_name$,step.decιmal,num_poιnt,method) SUB loop_to_poιnt(name$,start,end,step,decιmal,method) SUB scale_po t(name$,m_num,x_scale,y_scale,decιmal,out_num) ******************************* Subroutme: find_poιnt_by_vtx ******************************* SUB fιnd_pomt_by_vtx(xl,yl,x2,y2,step,decιmal ( #l, count) ! ι(6),ι o,ι/o ! Find discrete pomt coords including start and end pomts of a Ime ! xl,yl,x2,y2 : Ime coord to discretize ! step, decimal : distance bw points, round decimal pomt ! #1 : point file channel (*.pt) ! count : number of total pomts saved point file dx=x2-xl dy=y2-yl d=(dx Λ 2+dy Λ 2) Λ 0.5 ! length of a hne num_pt=ιnt(d/step) ! number of pomts on a Ime IF num_pt<l THEN ! if length of a line is shorter then one step, ! save end point WRITE #l:x2,y2 count=count+ 1 ELSE ! if length of a line is longer then one step, ! discretize FOR ι=l TO num_pt ratιo=i*step/d x=xl+ratιo*dx y=yl+ratio*dy x=round(x,decιmal) y=round(y,decιmal) WRITE #l :x,y count=count+l NEXT i IF x<>x2 or y<>y2 THEN ! check if end point is included WRITE #l :x2,y2 count=count+l END IF END IF END SUB I******************************* ! Subroutme: find_poιnt_by_dis ******************************* SUB find_poιnt_by_dιs(x_end,y_end,x2,y2,step,decιmal,# 1.count) ! i/o,ι/o,ι(4),ι o,ι/o ! Fmd point coords with even distance on a line and make point file ! x_end,y end : last point in a pt file, previous point ! x2,y2 : end point of a line ! step, decimal : distance bw pomts. round decimal point ! #1 : point file channel (*.pt) ! count : number of total points saved in point file dx=x2-x_end dy=y2-y_end d=(dx Λ 2+dy Λ 2) Λ 0.5 num_pt=int(d/steρ) ! number of point m a file IF num_pt<l THEN ! if length of a line is shorter then one step, skip Exit sub ELSE ! if length of a line is longer then one step, ! discretize a line with even step size FOR ι=l TO num_pt ratio=i*step/d x=x_end+ratio*dx y=y_end+ratio*dy x=round(x,decimal) y=round(y,decιmal) WRITE #l :x,y count=count+ 1 NEXT i x_end=x ! keep end point coordinates y_end=y END IF END SUB i **** * ** * * * * * * ** * * * * *** * * * * * ** **** * ! Subroutine: one_loop_to_point I ********************************** SUB one_loop_to_pomt(name$,file_num,step,decιmal,num_pomt,method) Read a loop file, and make a pomt file nameS : object name file num : file number for *.lp, *.lpx, *.pt, *.ptx files *.pt : point coord record file (xl ,yl)(x2,y2)(x3,y3),.. *.ptx : point index record file, each loop has 10 records (num of start pt, num of end pt, xd,yd,xu,yu,xl,yl,xr,yr) step, decimal : distance bw points, round decimal point num_poιnt . num of points in *.pt method : 0=ιnclude all start and end points of lines 1 =even distance points, ignore start and end points of lines file_loop$="object\" & nameS & "\" & strS(file num) & ".lp" ! file names file_poιnt$="object\" & nameS & "\" & str$(file_num) & ".pt" file_ιndex_lp$="object\" & nameS & "\" & str$(fϊle_num) & ".lpx" & strS(file num) & ".ptx" CALL open_file(#l,fιIe_loop$,error) IF error=l THEN Exit sub CALL open_file(#2,file_index_lp$,error) IF error=l THEN Exit sub OPEN #3:name file_pomtS, access outιn,create newold,organιzatιon record OPEN #4:name file_ιndex_pt$, access outin.create newold,organιzatιon record ERASE #3 ERASE #4 SET #3 :RECSIZE 10 ! record size of pomt file SET #4:RECSIZE 10 ! record size of loop index file RESET #l :Begιn RESET #2:Begm ASK #2:FILESIZE num record ! get number of records of loop mdex file IF num_record=0 THEN ! if loop index file is blank, exit EXIT SUB END IF LET num_loop=num_record/l 0 ! number of loops in loop file count_pt=0 ! get point coord for all loops FOR loop=l TO num loop READ #2:ln_start,ln_end,xd,yd,xu,yu,xl,yl,xr,yr ! get loop index RESET #1 :Record (ln_start- 1 )*4+ 1 READ #l :xstart,ystart,x2,y2 ! start line WRITE #3:xstart,ystart ! start point count_pt=count_pt- 1 WRITE #4:count_pt ! start point number of a loop ' discretize first Ime IF method=0 THEN ' passing all vertex method CALL find_poιnt_by_vtx(xstaιt,ystaιt,x2,y2,step,decιmal #3,count_pt) ELSE ' even pomt distance method x_end=xstart y_end=ystart CALL find_poιnt_by_dιs(x_end,y_end,x2,y2,step,decιmal,#3,count_pt) END IF i ' compute pomts for all lmes of a loop FOR ι=ln_start+l TO ln_end READ #1 xl ,yl,x2,y2 ' get line coordmate IF method=0 THEN ' passmg all vertex method CALL find_poιnt_by_vtx(xl ,yl,x2,y2,step,decιmal,#3,count_pt) ELSE ' even point distance method CALL fιnd_pomt_by_dιs(x_end,y_end,x2,y2,step,decιπιal,#3,count_pt) END IF NEXT i WRITE #3 xstart,ystart ' return start pomt count_pt=count_ρt+ 1 WRITE #4 count_pt,xd,yd,xu,yu,xl,yl,xr,yr ' save in pt mdex file NEXT loop PRINT count_pt,"poιnts m ",str$(file_num)," pt",", ",num_loop, "loops in ",str$(file_num)," ptx" num_poιnt=count_pt CLOSE#1 CLOSE#2 CLOSE#3 CLOSE#4 ENDSUB |*************************** ' Subroutme loop to_poιnt |*************************** SUB loop_to_pomt(name$,start,end,step,decimal,method) ' I,LΌ,I/O,I(3) ' Read loop file, and make pomt file 1 start, end start and end number of file for loop, point, mdex file ' step, decimal distance bw pomts round decimal point ' method 0=ιnclude all start and end points of lmes ' l=even distance points, ignore start and end points ol lines FOR ι=start TO end ' create all point files PRINT PRINT "Making file ",str$(ι)," pt"," (",ι,"/",end,") Wait " CALL one_loop_to_poιnt(nameS,ι,step,decιmal,numjιoιnt,method) NEXT i PRINT end-start+1 ; "files are made. " END SUB I************************* ! Subroutme: scale_poιnt ι ************************* SUB scale_pomt(name$,ιn_num,x_scale,y_scale,decιmal,out_num) ! ι(5),o ! Scale coords m pomt files ! in num : mput point file num to scale *.ρt ! x_scale,y_scale: scale factor. new_x=old_x*x_scale,new_y=old_y*y_scale ! decimal : round decimal ! out_num : output point file number *.pt & nameS & "\" & str$(ιn_num) & ".pt" file_out$="object\" & nameS & "\" & strS(out num) & ".pt" CALL open_fιle(#l,file_ιn$,error) IF error=l THEN Exit sub OPEN #5:name file_out$,access outin.create newold,organιzatιon record ERASE #5 SET #5 :RECSIZE 10 ! record size of output file ASK #1 :FILESIZE num rec ! number of records of loop mdex file num_pt=num_rec/2 FOR ι=l TO num_pt ! scale all pomt READ #l:x,y xnew=round(x*x_scale,decιmal) ynew=round(y*y_scale.decιmal) WRITE #5:xnew,ynew NEXT i END SUB I************* ! End of File ι ************* Wntten by Cheol Lee File. 72-5-ctl .tru Date. 6/96 Object match bot and top loops reading point file Input : * pt, * ptx Output . match loop array match(,) ***************************************************************** MEMO deal with arbiturary num of loops ignore second layer of children loops a(,) : a(num_lp,12) start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld mdex : 100< 110120130.. , 200<210220230.. , 000 mother children mother children empty match(,) : (num_lp*2,12) 0 mdex for blank file ex) match( 1 ,0) for top blank match bot loop (al) and top loop (a2) and store match info match bot mdex and top index m ascending order match 1st lp(bot)-2nd lp(top), 3rd lo(bot)-4th lp(top), etc (start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld) ***************************************************************** library "utillib.tru" name$="sιnk" file_num=17 clear dim match(0,0) call ptx_to_match(name$,file_num,match(,)) ' ,o mat pπnt match end EXTERNAL ********* Summary (72-5-ctl) ********* SUB find_mother_loop(a(,),ιndex,done,ι_rnom) ! 1/0,1,0,0 SUB find_chιld_loop(a(,),ιndex,ι_mom) ' 1/0,1,0 SUB relate_loop(name$,file_num,a(,),num mother) ' 1,1,0 SUB make_b(a(,),ιndex,b(,)) ! 1,1,0 SUB sort_b(b(,)) ' 1/0 SUB screen_b(b(,).num_2nd) ! 1/0,0,0 SUB update_a(b(,).num_2nd,ιndex,a(,)) ! 1,1,1,0 SUB sort_a(a(,),num_mom) ! 1/0,1 SUB screen_child(a(,),num_mother) ! 1/0,1 SUB match_2_loop(al(,),a2(,),num_moml,num_mom2,match(,)) ! 1,1,1,1,0 SUB ptx_to_match(name$,fιle_num,match(,)) ! ,0 I ****** ************************ ! Subroutme: find rnother loop I****************************** SUB find_mother_loop(a(,),index,done,ι_mom) ' 1/0,1,0,0 ! Find mam mother loops and give index number ! mother loop has the smallest y among loops ! a(.) : pt mdex loop array. a(num_lp,12) ' (start pt,end pt,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld) 1 index mother mdex number, ex) 100, 200, 300 ' done l=no more loop not considered, finish relate loop process ' 0=more loops to be considered ' ι_mom index number of mother loop in array a(,) πum_loop=ubound(a, 1 ) mιn_yd=1000 ' lnit min yd ι_mom=0 ' mit mdex number l FOR ι=l TO num loop ' find lowest (smallest yd) loop not considered IF a(ι, 11 )=0 THEN ' if not considered IF a(ι,4)<mrn_yd THEN ' if found lower loop, check yd mιn_yd=a(ι,4) ' update mιn_yd and min i ι_mom=ι END IF END IF NEXT i IF ι_mom=0 THEN ' if not found, done=l done=l ELSE a(ι_mom, 1 1 )=ιndex ' if found, mark index END IF END SUB I ****************************** ' Subroutme find child loop I ****************************** SUB find_chιld_loop(a(,),ιndex,ι_mom) ' 1/0,1,1 find child loop and give mdex number child loops have larger yd,xl and smaller yu,xr than mother a(,) pt mdex loop info array a(num_lp,12) (start pt.end pt,xd,yd,xu,yu,xl,yl,xr,yl,mdex,num child) index mother mdex number, ex) 100, 200, 300 child index num will be 1 10,120,130, 100 < 1 10 120 130 , 200 < 210 220 230 , 000 mother children mother children empty l mom index number of mother in array a(,) num loop=ubound(a, 1 ) xdm=a(ι_mom,3) ' mother boundary ydm=a(ι_mom,4) xum=a(ι_mom,5) yum=a(ι mom,6) xlm=a(ι_mom,7) ylm=a(ι_mom,8) xrm=a(ι_mom,9) yτm=a(ι_mom,10) count=0 ' child count FOR ι=l TO num loop ' find lowest (smallest yd) loop not considered IF a(ι, 11 )=0 THEN » if not considered IF a(ι,4)>ydm and a(ι,6)<yum and a(ι,7)>xlm and a(ι,9)<xrm THEN ιndex=ιndex+10 ' update child mdex count=count+l a(ι, 11 )=ιndex END IF END IF NEXT i a(ι mom, 12)=count ' save num of child at mom END SUB |************************** ' Subroutme. relate loop I************************** SUB relate_loop(name$,file_num,a(,),num_mother) ! 1,1,0,0 ' Find loop relationship readmg mdex file, if blank file a(0,12) mother loop has smallest yd children loops have larger yd,xl and smaller yu,xr than mother nameS : object name file num : pomt file and mdex file number. *.pt, *.ptx a(,) : a(num_lp,12) start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,rιum_chιld index : 100 < 110 120 130 .. , 200 < 210220 230.. , 000 mother children mother children empty num mother : num of mother loops file_ptx$="objecf\" & nameS & "\" & str$(file_num)&".ptx" ' index file name CALL open_file(#l,file_ptx$,error) ! save loop mdex in array IF error=l THEN exit sub ASK #l :filesιze num rec num_loop=num_rec/10 ' num of loop MAT REDIM a(num_loop,12) ! prepare array IF num_loop=0 THEN exit sub ' if blank file a(0, 12) FOR ι=l TO num loop ! store loop info FOR =l TO 10 READ #l x a(y)=x NEXTj a(ι,l l)=0 ' mit a(ι,12)=0 ! mit NEXT i mdex=0 ! mit mother mdex count=0 DO ' check all loops, find mother and childien mdex=mdex+100 ' update mother mdex CALL find_mother_looρ(a(,),ιndex,done,ι_mom) IF done=l THEN exit do ' if no more mom then exit count=count+ 1 ιndex_chιld=ιndex CALL fιnd_chιld_loop(a(,),ιndex_chιld,ι_mom) LOOP num_mother=count [pπnt num mother [mat print a CLOSE #1 END SUB I******************* ! Subroutine: make b I ******************* SUB make_b(a(,),ιndex,b(,)) ' 1,1,0 get children loop aπay b(,) of a mother loop a(,) a(num_lp,12) start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld index 100 < 1 10 120 130 , 200 < 210 220 230 , 000 mother children mother children empty b(,) children loop array b( num of children, 10) (xd,yd,xu,yu,xl,yl,xr,yr,mdex of a(,),flag) flag sorted order of a child loop num_loop=ubound(a, 1 ) FOR j=l TO num loop ! find num child IF a(j, 11 )=rndex THEN num_chιld=a(j, 12) NEXTj MAT REDIM b(num_chιld, 10) ! b(ιndex of a(),yd,sort num) FOR =l TO num_chιld ! make b() ιndex_chιld=ιndex+10*j FOR k=l TO num loop IF a(k,l l)=ιndex_chιld THEN b0,l)=a(k,3) b ,2)=a(k,4) b(j,3)=a(k,5) b ,4)=a(k,6) b0,5)=a(k,7) b0,6)=a(k,8) b0,7)=a(k,9) b(j,8)=a(k,10) b0,9)=k b ,10)=0 ! mit END IF NEXT k NEXTj END SUB t******************* * ' Subroutme sort b |********** ********** SUB sort_b(b(,)) ' I/O ! sort children loops in b(,) from smallest yd to largest ! b(,) . children loop array b(num of children.10) ' (xd,yd,xu,yu,xl,yl,xr,yr,ιndex of a(,),flag) • flag : sorted order of a child loop num lp=ubound(b, 1 ) FOR ι=l TO numjp ' sort all loop ymιn=10000 ' mit ιndex=0 FOR j=ι TO nu lp ' find mm yd IF b(j,2)<=ymιn THEN NEXTj FOR j=l TO 10 ! switch to sort temp=b(ιj) order NEXTj NEXT I END SUB I********************** ' Subroutme screen b I ********************** SUB screen_b(b(,),num_2nd) ' 1/0,0 ' remove 2nd child loop ' b(,) children loop array b(num of children, 10) ' (xd,yd,xu,yu,xl,yl,xr,yr,ιndex of a(,),flag) ' flag sorted order of a child loop -1 if 2nd child loop ' num_2nd num of 2nd children loops num_lp=ubound(b, 1 ) num_2nd=0 FOR ι=2 TO num_lp ' compare loops and find 2nd child xd=b(ι,l) yd=b(ι,2) xu=b(ι,3) yu=b(ι,4) xl=b(ι,5) yl=b(ι,6) xr=b(ι,7) yr=b(ι,8) FOR j=l TO l- l ' compare loops with smaller yd IF b(j,10)<>- l and b(j,2)<yd and b(j,4)>yu and b ,5)<xl and b(j,7)>xr THEN b(ι,10)=- l num_2nd=num_2nd+ 1 EXIT FOR END IF NEXTj NEXT i END SUB J ********************** ' Subroutme update a |********************** SUB update_a(b(,),num_2nd,ιndex,a(,)) ' 1,1,1,0 sort mdex of child in ascendmd order of yd, and update a(,) make index of 2nd children 0 update num_chιld=num_c .ιld-num_2nd a(,) a(num_lp,12) start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld mdex 100 < 110 120 130 , 200 < 210 220 230 , 000 mother children mother children empty b(,) children loop array b(num of children, 10) (xd,yd,xu,yu,xl,yl,xr,yr,mdex of a(,),flag) flag sorted order of a child loop - 1 if 2nd child num a=ubound(a, 1 ) num_b=ubound(b, 1 ) ιndex_chιld=ιndex ' mit FOR ι=l TO num_b ! update a(,) with b(,) flag=b(ι,10) ιndex_a=b(ι,9) IF flag=-l THEN a(index_a,l l)=0 ELSE ιndex_chιld=ιndex+ 10 a( index a, 11 )=ιndex_chιld END IF NEXT i IF num_2nd>0 THEN • update num child FOR ι=l TOnum_a IFa(ι,ll)=mdexTΗEN num_chιld=a(ι,12) a(ι, 12)=num_chιld-num_2nd END IF NEXTi END IF END SUB |******************* ' Subroutine sort a I******************* SUB sort_a(a(,),num_rnorn) ' 1/0,1 ' sort a(,) mom first and child second m ascendmg order of yd » ex) 100,200,300,110,120,210,220,310 ' a(,) a(num_lp,12) start.end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld ' num mo num of mother loops in a(,) DIM c(0,0) num_lp=ubound(a, 1 ) MAT REDIM c(num_lp,12) MAT c=a ' temp work space count=num_mom ' mit, num of mom and 1st child FOR ι=l TO num mom ' find num of mom and 1st loop dex=ι*100 FORj=l TO num lp ' find num child NEXTj NEXTi MAT REDIM a(count,12) FOR ι=l TO num mom ' save mom info first ιndex=ι*100 FORj=I TO num lp ' find num child IFc(j,ll)=ιndexTHEN FORk=l TO 12 a(ι,k)=c0,k) NEXTk END IF NEXTj NEXTi count_a=num mom FOR ι=l TO num mom ' save child info next ιndex=ι*100 num_chιld=a(ι,12) FOR =l TOnum_chιld ιndex_chιld=ιndex+j* 10 FOR k=l TO num_lp IF c(k.l l)=mdex_chιld THEN count_a=count_a+ 1 FOR n=l TO 12 a(count_a,n)=c(k,n) NEXTn ENDIF NEXTk NEXTj NEXT i END SUB I************************** ' Subroutme screen child ι********* ***************** SUB screen_chιld(a(,),num_mother) ' 1/0,1 ' sort children index with from smallest yd to largest yd ' remove 2nd child making mdex 0 and update num child ' a(,) a(num_lp,12) start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,tuιm_chιld ' num mom num of mother loops m a(,) DIM b(0,0) num_loop=ubound(a, 1 ) FOR ι=l TO num mother ' check all children of all mothers ιndex=num_mother* 100 FORj=l TO num loop ' find num child IF a(j,l l)=mdex THEN num_chιld=a(j,12) NEXTj MAT REDIM b(num_chιld,10) ' b(mdex of a(),yd,sort num) CALL make_b(a(,),ιndex,b(,)) • ι,ι,o CALL sort >(b(,)) ' l/o CALL screen_b(b(,),num_2nd) ' ι/o,o CALL update a(b(,),num_2nd,ιndex,a(,)) ' 1,1,1,0 NEXT i 'print num mother 'mat prmt a CALL sort_a(a(,),num_mother) END SUB |************************* ' Subroutme match_2_loop I ************************* SUB match_2_loop(al(,),a2(,),num_moml,num_mom2,match(,)) ' 1,1,1,1,0 match bot and top loops a 1 (,),a2(,) bot and top loop array a 1 (num lp, 12) (start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld) num_moml,num_mom2 num of mother loops in al(,),a2(,) match(,) (num_lp*2,12) 0 mdex for blank file ex) match( 1 ,0) for top blank match bot loop (al) and top loop (a2) and store match info match bot index and top mdex in ascending order match 1st lp(bot)-2nd lp(top), 3rd lo(bot)-4th lρ(top), cc (start,end,xd,yd,xu,yu,xl,yl,xr,yl,ιndex,num_chιld) DIM temp(0,0) num a 1 =ubound(a 1,1) num_a2=ubound(a2 , 1 ) ' one of top and bot is blank IF num_al =0 OR num_a2=0 THEN ' blank file exists PRINT "Problem blank file exist " GET KEY key ! one of top and bot has 1 loop ELSE IF num_al=l OR num_a2=l THEN ! 1 loop in top or bot MAT REDIM match( 1,2) match(l ,l)=l match(l,2)=l ! both have at least 2 loops ELSE IF num_moml=l AND num_mom2=l THEN ! 1 mom 1 child MAT REDIM match(2,2) match(l,l)=l match(l,2)=l match(2,l)=2 match(2,2)=2 ELSE IF num_moml=l AND num_mom2=2 THEN ! b=l mom 1 child, t=2 mom MAT REDIM match( 1,2) match(l,l)=l match(l,2)=l ELSE IF num_moml=2 AND num_mom2=l THEN ! b=2 mom, t=l mom 1 child MAT REDIM match( 1,2) match(l,l )=l match(l,2)=l ELSE IF num_moml=2 AND num_mom2=2 THEN ! b=2 mom, t=2 mom MAT REDIM match(2,2) match(l ,l)=l match( l,2)=l match(2,l)=2 match(2,2)=2 END IF n=ubound(match, 1 ) MAT REDIM temp(n,2) MAT temp=match MAT REDIM match(2*n,12) count=0 FOR ι=n TO 1 STEP -1 ! make match(2*n,12) bot=temp(ι,l) top=temp(i,2) count=count+l FORj=l T0 12 match(count,j)=a 1 (botj) NEXTj count=count+l FORj=l TO 12 match(countj)=a2(top,j) NEXTj NEXT i END SUB I ************************* ! Subroutme: ptx to match I************************* SUB ptx_to_match(name$,file_num,match(,)) ! i,i,o ! match bot and top loop reading ptx file ! nameS : object name ! file num : pomt file num. (file num).pt for bot (file_num+l).pt for top ! match(,) • (num_lp*2,12) ' 0 index for blank file ex) match( 1 ,0) for top blank ' match bot loop (al) and top loop (a2) and store match info ' match bot mdex and top mdex in ascendmg order ' match 1st lp(bot)-2nd lp(top), 3rd lo(bot)-4th lp(top), etc ' (star^end.xd.yd^u.y^x^yl.xr.yl.mdex.num child) DIM bot(0,0),top(0,0) CALL relate_looρ(name$,file_num,bot(,),num_moml ) ' 1,1,0 CALL relate_loop(name$,file_num+l ,top(,),num_mom2) ' 1,1,0 CALL screen_chιld(bot(,),num_moml) ! 1/0,1 CALL screen_chιld(top(,),num_mom2) ! 1/0,1 CALL match_2_loop(bot(,),top(,),num_moml,num_mom2,match(,)) ! 1,1,1,1,0 END SUB I********************* ' End of File I *************** ****** I ***************************************************** *************** ' Written by Cheol Lee 1 Date 6/96 ' Object Make cut file reading pomt file ' Input * pt, * ptx ' Output * ct, * ctx I ********************** ********************************************** • MENO ' - * ctx 13 rec for each match loop, and 5 rec at the end ' (start num of cut.end num of cut,xbstart,ybstart,xtstart,ytstart, ' xmm,xmax,ymιn,ymax,ιndex_b,mdex_t,max_angle) ' (xmιn,xmax,ymm,ymax,max_angle for all match loops) ' - can keep top cross section by reverse_cut_file for better looking slice |******************************************************************** library "71 -get tru" library "71-ut tru" library "71-5-ctl tru" library "utillibl tru" library "3dhb trc" d _poιnt= 4 cut_angle=40 decιmal=4 dh=l 3 name$="fordcarl " skιp=0 reverse=0 start,end=7 clear 'call cut_report(name$,19,l,40,2,2,2,2,12,12, 12,1, 1,2,19) 'call read_cut_reρort(name$) call auto_cut(πame$,start,end,reverse,dh,cut_angle,decιrnal, skip) end EXTERNAL ********* Summary (72-5-ct2) ********* SUB poιnt_to_array(#l,start,end,a(,)) ' ,o SUB find_closest_pt(a(,),xι,yι,ιndex,xo,yo) ' ,o,o,o SUB resort_array(a(,),mdex) ' 1/0,1 SUB cutter_posιtιon(d_allowed,decunal,xl,yl,x2,y2,x2_cut,y2_cut) ' ,0,0 SUB cut_a_loop(#l ,#2,skιp,start_b,end_b,start_t,end_t,& & xls,yls,x2s,y2s,dh,cut_angle,decιmal,#5,#6) ' ,o SUB reverse_cut_file(#l,#2) ' ι,ι SUB pomt_to_cut(name$,file_num,reverse,dh,cut_angle,decιmal,skιρ,& & xsιze,ysιze,max_angle) ' ι/o,ι ,o,o,o SUB auto_cut(name$.start,end,reverse,dh,cut_angle,decιmal,skιp) SUB cut_a_loop_sml(#l ,start_b,end_b,ιndex_b,decιmal,#5,#6) SUB ρoιnt_to_cut_sml (name$,file_num,decιmal) SUB auto cut sml (name$,start,end,decιmal) I*************************** ' Subroutme. pomt to array I*************************** SUB poιnt_to_array(#l,start,end,a(,)) ' 1,1,1,0 ' copy a loop pt coord in array ' start,end start and end pt num for a loop ' first pt and last pt are same be it is a loop 1 a(,) pomt array for a loop, a(num_pt,2 {x,y } ) num_pt=end-start+ 1 MAT REDIM a(num_pt,2) rec_start=start*2- 1 RESET #1 record rec start FOR ι=l TO num_pt READ #1 x,y a(ι,l)=x ' shift a(ι,2)=y NEXT i END SUB I***************************** ' Subroutme find_closest_pt I ********************* ******** SUB find_closest_pt(a(,),xι,yι,ιndex,xo,yo) ' ι(3),o(3) 1 find closest pt in a(,) from (xι,yι) 1 a(,) point array for a loop, a(num_pt,2 {x,y } ) ' xι,yι a point to calculate distance from ' xo.yo closest pomt m a(,) from xi.yi ' mdex mdex m a(,) for (xo.yo) num_pt=ubound(a, 1 ) mdex=0 FOR ι=l TO num_pt x=a(ι,l) y=a(ι,2) d=(xι-x) Λ 2+(yι-y) Λ 2 IF d<=d_mm THEN dex=ι xo=x yo=y d_mm=d END IF NEXT i END SUB I*************************** ' Subroutme resort array I******** ******************* SUB resort_array(a(,),ιndex) ' 1/0, 1 sort a(,) to have mdex pt comes first copy 1st pt at last ' this is cut order from 1 to end 1 a(,) pomt array for a loop, a(num_pt,2 {x,y } ) ' mdex : start point mdex in a(,) IF ιndex=l THEN Exit sub ! if mdex=l, oπgmal array DIM temp(0,0) num_pt=ubound(a, 1 ) MAT REDIM temp(num_pt,2) count=0 FOR ι=ιndex TO num_pt-l ! remove last pt. last pt= first pt count=count+l temp(count, 1 )=a(ι, 1 ) temp(count,2 )=a(ι,2) NEXT i FOR ι=l TO mdex count=count+ 1 temρ(count, 1 )=a(ι, 1 ) temp(count,2)=a(ι,2) NEXT i MAT a=temp END SUB t ***************************** ! Subroutme. cutter_posιtιon I* **************************** SUB cutter_posιtιon(d_allowed,decιmal,xl,yl,x2,y2,x2_cut,y2_cut) !ι(6),o(2) ! Fmd actual cutter position satisfying cutter length allowed .' If distance is over max, keep bot pomt and move top at max distance ! d allowed : distance allowed bw top and bot in top view ! decimal : round decimal for cut pomt (ι,..,o,o) ! xl,yl,x2,y2 : bot, top matching pomt, start pomts from pomt file ! x2_cut,y2_cuf top pomt satisfying distance requirement d=((xl-x2) A 2+( l-y2) Λ 2) Λ 0 5 ' distance of calculated point ! find actual cutter position IF d>d_allowed THEN m=d_allowed n=d-d_allowed x2_cut=(m*x2+n*xl)/d ! m:n ratio lntesection of xl and x2 y2_cut=(m*y2+n*y 1 )/d x2_cut=round(x2_cut,decιmal+ 1 ) y2_cut=round(y2_cut,decιmal+ 1 ) ELSE x2_cut=round(x2,decιmal+ 1 ) y2_cut=τound(y2,decιmal+ 1 ) END IF END SUB t ************************* ! Subroutme: cut a loop I *************** ********** SUB cut_a_loop(#l ,#2,skιp,start_b,end_b,start_t,end ,ιndex_b,ιndex_t,& & xls,yls,x2s,y2s,dh,cut_angle,decιmal,#5,#6) ! ι,..,o,o find cut path for a match loop. #l,start_b,end_b : bot pt file channel, rec num of a loop #2,start_t,end_t,: top pt file channel, rec num of a loop #5,#6 : output cut file, *.ct, *.ctx ιndex_b,ιndex_t : mdex for bot and top match loop xls,yls,x2s,y2s : bot and top first point of a match loop dh,cut_angle,decimal : foam thickness, max cut angle, round decimal *.crx . 13 rec for each match loop, and 5 rec at the end (start num of cut,end num of cut,xbstart,ybstart,xtstart,ytstart, xmm,xmax,ymm,ymax,index_b,index_t,max_angle) , ... (xmin,xrnax,ymιn,ymax,rnax_angle for all match loops) DIM b(0,0),t(0,0) CALL poιnt_to_array(#l,start_b,end_b,b(,)) ! .,o CALL poιnt_to_array(#2,start_t,end_t,t(,)) ! .,o xb=b( l,l) ! bot start pt yb=b(l,2) CALL fϊnd_cιθsest_pt(t(,),xb,yb,ιndex,xt,yt) ! .,o,o,o CALL resort_array(t(,),mdex) ! 1/0,1 cut path is from 1 to end d_allowed=dh*tan(cut_angle*pi/180) ! distance allowed bw top and bot m top view num_b=ubound(b, 1 ) ! num of pt num_t=ubound(t, 1 ) xls=b(l,l) ! first pt yls-b(l,2) x2=t(l,l) y2=t(l,2) CALL cutter_posιtιon(d_allowed,decιmal,x 1 s,y 1 S,x2,y2,x2s,y2s) RESET #5:end ASK #5:record rec start WRITE #6:rec_start WRITE #5:xls,yls,x2s,y2s ! save start cut pos bn=l ! current counter tn=l DO ! cut all pt on a loop FOR ι=l TO skip ! skip n points IF bn<num_b THEN ! read bot xl=b(bn+l,l) yl=b(bn+l,2) bn=bn+l END IF IF tn<num_t THEN ! read bot x2=t(tn+l,l) y2=t(tn+l,2) tn=tn+l END IF NEXT i IF bn>=num_b THEN ! read bot xln=b(num_b,l) yln=b(num_b,2) ELSE xln=b(bn+l ,l) yln=b(bn+l,2) END IF IF m>=num_t THEN ' read top x2n=t(num_t, 1 ) y2n=t(num_t,2) ELSE x2n=t(tn+l,l) y2n=t(tn+l,2) END IF '— compare distance d_bot=(xln-x2) A 2+(yln-y2) Λ 2 ! if move bot pomt d_top=(x2n-x 1 ) Λ 2+(y2n-y I ) A 2 ' if move top pomt d_both=(xln-x2n) A 2+(yln-y2n) Λ 2 ' if move both pomt CALL πun3(d_bot,d_top,d_both,d_mm) IF m>=num_t and bn>=num_b THEN d_mιn=d_both ELSE IF tn>=num J THEN d_mm=d_bot ELSE IF bn>=num_b THEN d_rmn=d_top END IF IF d_mιn=d_both THEN ' move both xl=xln yl=yln x2=x2n y2=y2n bn=bn+l tn=tn+l ELSE IF d_mrπ=d_top THEN ' move top " x2=x2n y2=y2n to=tn+l ELSE ' move bot xl=xln [ update yl=yln bn=bn+l END IF CALL cutter_posιtιon(d_allowed,decιmal,x 1 ,y 1 ,x2,y2,x2_cut,y2_cut) WRITE #5 l,yl,x2_cut,y2_cut LOOP UNTIL bn>=num_b AND tn>=num_t WRITE #5.x 1 s,y 1 s,x2s,y2 s ! copy start pos at last RESET #5:end ' end rec num of a lp ASK #5:record rec_new_start rec_end=rec_new_start- 1 WRITE #6:rec_end num_ct=(rec_end-rec_start+ 1 )/4 FOR ι=l TO num_ct READ #5.xl,yl,x2,y2 if xl>1000 or yl>1000 or x2>1000 or y2>1000 then pπnt xl,yl,x2,y2 pπnt num_ct,ι end if IF x 1 <xrnιn THEN xrmn=x 1 IF yKym THEN ymm=yl IF x2<xmιn THEN xmm=x2 IF y2<ymιn THEN yπun=y2 IF xl>xmax THEN xmax= l IF yl>ymax THEN ymax=yl IF x2>xmax THEN xmax=x2 IF y2>ymax THEN ymax=y2 d=((xl-x2) Λ 2+(yl-y2) Λ 2) Λ 0.5 IF d>dmax THEN dmax=d NEXT i [print xm ,xmax,yτrun,ymax max_angle=atn(dmax/dh)* 180/pι WRITE #6:xls,yls,x2s,y2s WRITE #6:xmm,xmax,ymm,ymax WRITE #6:ιndex_b,ιndex_t,max_angle END SUB I ****************** ! reverse cut file I****************** SUB reverse_cut_file(#l,#2) ! i/o,ι/o ! change top and bot record *.ct, and *.ctx ! keep top shape and cut bot at max cut angle ' #1, #2 • *.ct, *.ctx channel ASK #1 filesize num rec ct ASK #2: filesize num rec ctx num_ct=num_rec_ct/4 num_match=(num_rec_ctx-5)/l 3 FOR ι=l TO num ct rec=(ι- l)*4+l RESET #l :record rec READ #l .xl,yl,x2,y2 RESET #l :record rec WRITE #l :x2,y2,xl,yl NEXT i FOR ι=l TO num match rec=(ι-l)*13+l RESET #2:record rec READ #2:start,end,x 1 s.y Is,x2s,y2s,x 1 ,x2,y 1 ,y2,mdex 1 ,ιndex2,angle RESET #2:record rec WRITE #2 :start,end.x2s,y2s,x 1 s.y 1 s.x 1 ,x2,y 1 ,y2,ιndex2, dex 1.angle NEXT i END SUB I************************** ! Subroutine: point to cut I************************** SUB point_to_cut(name$,file_num,reverse,dh,cut_angle,decιmal,skιp,& & xsιze,ysιze,max_angle) ! ι,..,o(3) ! Fmd multi loop cut path by moving pomt to pomt ! nameS : object name ! reverse : 0=no reverse, defaule, keep bot cross section ! l=reverse, keep top cross section ! dh,cut_angle,decimal : foam thickness, max cut angle, round decimal ! skip : num of pt to skip to go to next pt to cut ! x,ysize,max_angle : max x and y and angle for a layer(all loops) DIM match(O.O) file_ct$="object\" & nameS & "\" & str$(file_num) & ".ct" file_ctx$="object\" & nameS & "\" & strS(file num) & ".ctx" IF reverse=0 THEN file_pt_b$="object\" & nameS & "V & str$(file num) & ".pt" file_pt_t$="object\" & nameS & "\" & str$(file_num+ 1 ) & ".pt" ELSE file_pt_b$="object\" & nameS & "\" & str$(file_num+l) & ".pt" filejpt_t$="object\" & nameS & "\" & str$(file_num) & ".pt" END IF CALL open_file(#l ,file_ρt_b$,error) IF error=l THEN exit sub CALL oρen_file(#2,file 3t_t$,error) IF error=l THEN exit sub OPEN #5:name file_ct$,access Outin.create Newold.org record ERASE #5 SET #5:Recsιze 10 OPEN #6:name file ctxS.access Outin,create Newold.org record ERASE #6 SET #6:Recsιze 10 CALL ptx to matchfnameS.file num.matchf,)) ! ,o num_match=ubound(match, 1 )/2 FOR ι=l TO num match IF reverse=0 THEN start_b=match(i*2-l,l) end_b=match(i*2-l,2) start_t=match(i*2, l) end_t=match(i*2,2) mdex_b=match(i*2-l,l 1) index_t=match(i*2, 11 ) ELSE start_t=match(i*2-l,l) end_t=match(i*2-l,2) start_b=match(i*2,l) end_b=match(i*2,2) mdex_t=match(i*2- 1,11) ιndex_b=match(i*2, 11 ) END IF CALL cut_a_loop(#l ,#2,skιp,start_b,end_b,start_t,end_t,ιndex_b,ιndex_t,& & xls,yl s,x2s,y2s,dh,cut_angle,decιmal,#5,#6) ! .0,0 NEXT i ASK #6: filesize fsize num_match=fsιze/ 13 xmm,ymιn=1000 xmax,ymax,max_angle=- 1000 RESET #6:begιn FOR i=l TO num match ! find slice size and max angle READ #6:start,end,x 1 s,y 1 s,x2s,y2s,x 1 ,x2,y 1 ,y2,mdex 1 ,mdex2,angle IF xKxmin THEN xmm=xl IF yl<ymιn THEN yrmn=yl IF x2<xmm THEN xmιn=x2 IF y2<yπun THEN ymm=y2 IF xl>xmax THEN xmax= l IF yl>ymax THEN ymax=yl IF x2>xmax THEN xmax=x2 IF y2>ymax THEN ymax=y2 IF angle>max_angle THEN max_angle=angle NEXT i ASK #5: filesize fsize num_cut=fsιze/4 max_angle=round(max_angle, 1 ) WRITE #6:xrmn,xmax,ymm,ymax,max_angle IF reverseoO THEN CALL reverse_cut_file(#5,#6) ! 1,1 xsιze=xmax-xmm ysιze=vmax-ymm PRINT num_cut;"cuts m ";str$(file_num);".ct" PRINT "Slice size x/y- ";xsιze;'7";ysιze PRINT "Max angle is";max_angle;"degree." CLOSE #1 CLOSE #2 CLOSE #5 CLOSE #6 END SUB I********** ! auto cut I********** SUB auto_cut(name$,start,end,reverse,dh,cut_angle,decιmal,skιp) ! 1,.. ! cut from start tod end cut file num ! nameS : object name ! start,end : start and end file num *.ct ! reverse : 0=no reverse, defaule, keep bot cross section ! l=reverse, keep top cross section ! dh,cut_angle,decιmal : foam thickness, max cut angle, round decunal ! skip : num of pt to skip to go to next pt to cut FOR ι=start TO end ' create all loop files PRINT PRINT "Making file ";str$(ι);" ct";" (";ι;"/";end;"). Wait." CALL poιnt_to_cut(name$,ι,reverse,dh,cut_angle,decιmal,skιp,& & xstze.ysize.max angle) ' 1/0,1 ,0,0,0 NEXT i PRINT end-start+1 ;"files are made " END SUB t *************** ************* ' Subroutine, cut a loop sml I******** ******************** SUB cut_a_loop_sml(#l,start_b,end_b,ιndex_b,decιmal,#5,#6) ! ι,..,o(2) • find cut path for a loop for sml, vertical cylmdrical shape ' #l,start_b,end_b : bot channel, rec num of a loop ! index b.decimal : mdex of bot round decimal ! #5,#6 : *.ct, *.ctx ' *.ctx : 13 rec for each match loop, and 5 rec at the end ' (start num of cut,end num of cut,xbstart,ybstart,xtstart,ytstart, ! xrrun,xmax,yιrun,ymax,mdex_b,mdex_t,max_angle) • ... (xrnm,xmax,ymm,ymax,max_angle for all match loops) DIM b(0,0) CALL poιnt_to_array(#l,start_b,end_b,b(,)) ! .,o num_b=ubound(b, 1 ) • num of pt RESET #5 -end ASK #5 record rec staπ WRITE #6 ec_start FOR ι=l TO num_b xl=b(ι,l) yl=b(ι,2) WRITE #5:xl,yl,xl,yl ! save start cut pos NEXT i xls=b(l,l) yls=b(l,2) WRITE #5 :x 1 s.y 1 s,x 1 s,y 1 s ! save start cut pos RESET #5:end ' end rec num of a lp ASK #5:record rec_new_start rec_end=rec_new_start- 1 WRITE #6.rec end num_ct=(rec_end-rec_start+ 1 )/4 xmax,ymax,dmax=- 1000 RESET #5:record rec start FOR ι=l TO num_ct READ #5:xl,yl,x2,y2 IF xKxπun THEN xmm=xl IF y 1 <ymm THEN ymm=y 1 IF x2<xmm THEN xmm=x2 IF y2<ymm THEN ymιn=y2 IF xl>xmax THEN xmax=xl IF yl>ymax THEN ymax= l IF x2>xmax THEN xmax=x2 IF y2>ymax THEN ymax=y2 d=((xl-x2) Λ 2+(yl-y2) Λ 2) A 0.5 IF d>dmax THEN dmax=d NEXT i WRITE #6 xls,yls,xls,yls WRITE #6:xmm,xmax,ymm > yπιax WRITE #6:mdex_b,mdex_b,max_angle END SUB t****************************** ' Subroutme: point to cut sml I****************************** SUB poιnt_to_cut_sml(name$,file_num,decιmal) ! 1,1,1 ! make cut file for sml ! nameS . object name ! file num : cut file num ! decunal . round decimal for *.ct DIM match(O.O) file_ct$="object\" & nameS & "\" & str$(file_num) & "xt" file_ctx$="object\" & nameS & "\" & str$(file_num) & ".ctx" file_pt$="object\" & nameS & "\" & str$(file_num) & ".pt" CALL open_file(#l ,file_pt$, error) IF error=l THEN exit sub OPEN #5:name file ctS, access Outm.create Newold, org record ERASE #5 SET #5:Recsιze 10 OPEN #6:name file ctxS.access Outm.create Newold.org record ERASE #6 SET #6:Recsιze 10 CALL ptx_to_match(name$,file_num,match(,)) ! ,0 num match=ubound(match, 1 )/2 FOR ι=l TO num match start_b=match(ι*2-l,l) end_b=match(ι*2-l,2) start_t=match(ι*2,l) end_t=match(ι*2,2) ιudex_b=match(ι*2-l,l 1) ιndex_t=match(ι*2, 11 ) CALL cut_a_loop_sml (# 1 ,start_b,end_b,ιndex_b,decιmal,#5,#6) NEXT i ASK #6:filesιze fsize mιm_match=fsιze/ 13 xrnin, yιmn= 1000 xmax,ymax,max_angle=- 1000 RESET #6:begιn FOR ι=l TO num match ! find slice size and max angle READ #6:start,end,x 1 s.y 1 s,x2s,y2s,x 1 ,x2,y 1 ,y2,ιndex 1 ,ιndex2,angle IF xKxmm THEN xmιn=xl IF yl<yιmn THEN yπun=yl IF x2<xmιn THEN xmιn=x2 IF y2<ymm THEN ymm=y2 IF xl>xmax THEN xmax=xl IF y 1 >ymax THEN ymax=y 1 IF x2>xmax THEN xmax=x2 IF y2>ymax THEN ymax=y2 IF angle>max_angle THEN max_angle=angle NEXT i ASK #5:filesιze fsize num_cut=fsιze/4 max_angle=round(max_angle, 1 ) WRITE #6:xmm,xmax,yrnin,ymax,max_angle xsιze=xmax-xrnin ysιze=ymax-ymιn PRINT num_cut;"cuts ";str$(file_num);".ct" PRINT "Slice size x/y: ";xsιze;"/";ystze PRINT "Max angle ιs";max_angle;"degree." CLOSE #1 CLOSE #5 CLOSE #6 END SUB t * * *** * ** * *** * * ! auto cut sml I************** SUB auto_cut_sml(name$,start,end,decimal) ! i(4) ! make cut file from start to end ! nameS : object name ! start.end : start and end cut file num ! decimal : round decunal FOR ι=start TO end ! create all loop files PRINT PRINT "Mak g file ";str$(i),".ct";" (";ι;7";end,") Wait. " CALL pomt to cut sm 1 (name$,ι,decιmal) NEXT i PRINT end-start+1 ;"files are made. " END SUB I************* ! End of File I************* I************************ ******************************************* ! Wπtten by Cheol H. Lee ! File: 72-6-sttru ! Date: 6/96 ! Object : make step file readmg cut file ! Input : *.ct, *.ctx ! Output : *.st text file I************************************************ ******************* ! MEMO ! - *.st file is text file to be read by C program ! - *.st file mcludes registration holes, and access and return path ! to reg holes. I ******************************************************************* library "71-ut.tru" library "71 -get. tru" library "utillib.tru" library "3dhb.trc" name$="carbody" start,end=6 num_hole=2 dh=2.5 space_b=1.3 space_t=1.2 d_poιnt=0.1 xh=0 yh=2 xls,x2s,y2s=800 yls=120.63 skιp=2 x2w,y2w=130 [clear call auto_step(name$,start,end,num_hole,dh,space_b,space_t,& & d_poιn skιp,xh,yh,xls,x2s,yls,y2s) call draw_auto_st_3d(name$,start,end,dh,space_b,space_t,x2w,y2w,xls,x2s,yls,y2s,xIι,yh) end EXTERNAL ********* Summary (72-6-st) ********* SUB slide_pos(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,xl,x2,yl,y2,#5) ' ..o SUB access_path(r_bot,r_top,d_pomt,skιp,xls,x2s,yls,y2s, & & xlf,x2f > ylf,y2f,xlt,x2t,ylt,y2t,#5) ! ..o SUB find_closest_cut_num(# 1 ,x,y,choιce,cut_num,x 1 c.y 1 c,x2c,y2c) SUB find hole start(# 1 ,num_hole,hole(,)) SUB hole_cιrcle(hole(,),hole_num,r_bot,r_top,d_pomt,xls,x2s,yls,y2s,& & xlf,x2f,ylf,y2f,xs,ys,#5) SUB cut_to_step(name$,file_num,num_hole,hole(,),dh,space_b,space_t,& & d_point,skip,xh,yh,xls,x2s,yls,y2s) SUB auto_step(name$,start,end,num_hole,dh,space_b,space_ t,& & d_poιnt,skιp,xh,yh,xls,x2s,yls,y2s) ( *********** ************ ! Subroutine: slide_pos I *********************** SUB slide_pos(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,xl,x2,yl,y2,#5) !ι,..,o ! convert pos of cut file to abs step pos of slide with shift ' r_bot=space_b/dh, r_top=space_t/dh ! xs.ys : shift xnew=xold+xs. ! xl,x2,yl,y2 : coord ct file ! xls.yls ■ num steps for bot / cm ! x2s,y2s : num steps for top / cm ' #5 . *.st channel, abs step pos xla=xl-(x2-xl)*r_bot ! slide pos w/o shift x2a=x2+(x2-x 1 )*r_top y 1 a=y 1 -(y2-y 1 ) *r_bot y2a=y2+(y2-y 1 )*r_toρ xla=xla+xs ! shift x2a=x2a+xs yla=yla+ys y2a=y2a+ys x 1 sa=mt(x 1 a*x 1 s) ! slide abs coord m step x2sa=ιnt(x2a*x2s) ylsa=ιnt(yla*yls) y2sa=mt((y2a-yla)*y2s) PRINT #5:xlsa PRINT #5 ylsa PRINT #5:x2sa PRINT #5:y2sa END SUB I***************************** ! Subroutme slιde_pos_poιnt ^ ********************* ******** SUB slιde_pos_poιnt(r_bot,r_top,d_poιnt,skιp,xls,x2s,yls,y2s, & & Xlf,x2f,ylf,y2f,xlt,x2t,ylt,y2t,xs,ys,#5) ! ι,..,o ! divide a Ime with d_poιnt and skip n pomt ! r_bot=space_b/dh, r_top=space_t/dh ! d_pomtskιp : distance bw pomts, num of pomts to skip ! xls,yls,x2s,y2s : bot and top ratio for motors steps/cm ! xlf,x2f,ylf,y2f : abs coord of start pomt of a Ime m cm ! xlt,x2t,ylt,y2t : abs coord of end pomt of a line in cm ! xs.ys : shift xnew=xold+xs ! #5 : step file. *.st dx 1 =x 1 t-x 1 f ! dis bw each coord dx2=x2t-x2f dyl=ylt-ylf dy2=y2t-y2f d_bot=(dx 1 Λ 2+dy 1 Λ 2) Λ 0.5 d_top=(dx2 A 2+dy2 A 2) Λ 0.5 d=max(d_bot,d_top) ! find max dis bw top and bot IF num_pt oθ THEN ! dis increment in cm ddx 1 =dx 1 /num_pt ddx2=dx2/num_pt ddy 1 =dy 1 /num_pt ddy2=dy2/num_pt FOR i=l TO num ot ! cal step size and save xl=xlf+ddxl *ι ! coord to go cm x2=x2f+ddx2*ι yl=yl f+ddyl*ι y2=y2f+ddy2*ι CALLshde_pos(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,xl,x2,yl,y2,#5) ! ..o NEXTi ENDIF CALLslide_pos(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,xlt,x2t,ylt,y2t,#5) ! ..o END SUB I************************ ! Subroutme: access_path I************************ SUB access_path(r_bot,r_top,d_pomt,skιp,xls,x2s,yls,y2s, & & Xlf,x2f,ylf,y2f,xlt,x2t,ylt,y2t,#5) ! ι,..,o ! access path from xf to xt ! r_bot=space_b/dh, r_top=space_t/dh ' d_poιnt,skιρ : distance bw pomts, num of pomts to skip ! xls,yls,x2s,y2s : bot and top ratio for motors steps/cm ! xlf,x2f,ylf,y2f : abs coord of start pomt of a line m em ! xlt,x2t,ylt,y2t : abs coord of end point of a Ime m cm ! #5 : step file. *.st xs,ys=0 CALL shdej3osjDomt(r_bot,r_top,d_poιnt,skιp,xls,x2s,yls,y2s, & & xlf,x2f,ylf,y2f,xlf,xlf,0,0,xs,ys,#5) ! ..o CALL shde_pos_pomt(r_bot,r_top,d_pomt,skιp,xls,x2s,yls,y2s, & & xlf,xlf,0,0,xlt,xlt,0,0,xs,ys,#5) ! ..o CALL slide_pos_pomt(r_bot,r_top,d_point,skip,xls,x2s,yls,y2s, & & xlt,xlt,0,0,xlt,x2t,ylt,y2t,xs,ys,#5) ! ..o END SUB 1 ************************** ******* ! Subroutine: find closest cut num ι********************************* SUB find_closest_cut_num(#l,x,y,choιce,cut_num,xlc,ylc,λ2c,y2c) ! ι(4),o(5) find closest cut num from a point (x.y) #1: cut file. *.ct x.y: point to find crosest pomt from choice : access direction 1=0 deg, 2=90 deg, 3=180 deg,4=270 deg, 0=mm dis cut_nunr cut num cut file xlc,ylc,x2c,y2c : cut record ASK #1 :filesιze num rec num_cut=(num_rec-5)/4 cut_num=0 dmm= 10000 RESET #l:Begm READ #l:xlold,ylold,x2old,y2old FOR i=2 TO num_cut READ #l:xl,yl,x2.y2 xsιgn=(x-x 1 )*(x-x 1 old) ysιgn=(y-yl)*(y-ylold) d=(x-xl) Λ 2+(y-yl) Λ 2 dy=abs(yl-y) dx=abs(xl-x) IF choιce=0 THEN IF d<dmιn THEN dmιn=d cut_num=ι END IF ELSE IF choιce=l THEN IF ysιgn<=0 and x<=xl and dx<dπun THEN dmιn=d cut_num=ι END IF ELSE IF choιce=2 THEN IF xsιgn<=0 and y<= l and dy<drmn THEN dmm=d cut_num=ι END IF ELSE IF choιce=3 THEN IF ysιgn<=0 and x>=xl and dx<drmn THEN dπun=d cut_num=ι END IF ELSE IF choιce=4 THEN IF xsιgn<=0 and y>=y 1 and dy<dmιn THEN dmm=d cut_num=ι END IF END IF IF cut_num=i THEN xlc=xl x2c=x2 ylc=yl y2c=y2 END IF xlold=xl x2old=x2 ylold=yl y2old=y2 NEXT i END SUB I************************************ ' Subroutine, find hole start ι ************************************ SUB fmd_hole_start(#l,num_hole,hole(,)) ! ι,ι,ι/o ! find cut num, rad start for all holes ! #1: cut file, *.ct. ! num_hole : num of registration holes ! hole(.) : reg hole mfo array hole(num of hole,7) ' (choice,xc,yc.radi,cut_num,rad_start,resolution) ! choice : access direction • 1=0 deg, 2=90 deg, 3=180 deg,4=270 deg, 0=mm das 1 xc,yc center of reg hole ' radi radius of reg hole ' cut num cut num of access pos m cut file 1 rad start access radian to start to cut a hole ' resolution num of pomts for a reg hole ASK #1 filesize num rec num_cut=(num_rec-5 )/4 FOR ι=l TO num_hole choιce=hole(ι,l) xc=hole(ι,2) yc=hole(ι,3) radι=hole(ι,4) IF choιce=l THEN ' start 0 deg rad_start=0 x=xc+radι y=y C CALL find_closest_cut_num(#l,x,y,choιce,cut_num,xlc,ylc,x2c,y2c) ELSE IF choιce=2 THEN ' start 90 deg rad_start=pι/2 x=xc y=yc+radι CALL find_closest_cut_num(# 1.x.y.choice.cut num.x 1 c, 1 c,x2c,y2c) ELSE IF choιce=3 THEN ' start 180 deg rad_start=pι x=xc-radι y=y C CALL ftnd_closest_cut_num(# 1 ,x,y,choιce,cut_num,x 1 c, 1 c,x2c,y2c) ELSE IF choιce=4 THEN ' start 270 deg rad_start=pι* 1 5 x=xc y=yc-radι CALL find_closest_cut_num(# 1 ,x,y,choιce,cut_num,x 1 c,y 1 c,x2c,y2c) ELSE IF choιce=0 THEN ' closest from xc.yc x=xc y=yc CALL find_closest_cut_num(#l ,x,y,choιce,cut_num,xlc,y Ic,x2c,y2c) dx=xlc-xl dy=ylc-x2 IF dx=0 THEN PRINT "Hole is outbound " Exit sub ELSE rads=atn(abs(dy/dx)) END IF IF dx>=0 and dy>=0 THEN rad_start=rads ELSE IF dx<=0 and dy>=0 THEN rad_start=pι-rads ELSE IF dx<=0 and dy<=0 THEN rad_start=pι+rads ELSE IF dx>=0 and dy<=0 THEN rad_start=2 *pι-rads END IF END IF hole(ι,5)=cut_num ! save mfo hole(ι,6)=rad_start NEXT i END SUB I************************ ! Subroutme' hole circle I************************ SUB hole_cιrcle(hole(,),hole_num,r_bot,r op,d_poιnt,x 1 s,x2s,y 1 s,y2s,& & xl f,x2f,ylf,y2f,xs,ys,#5) ' ι,. ,o ! calculate all pt and step for a hole and save in * st file ' hole(.) : reg hole mfo array. hole(num of hole,7) ! (choιce,xc,yc,radι,cut_num,rad_start,resoluhon) ! hole num • hole num in hole(,) ' r_bot=space_b/dh, r_top=space_t dh 1 d_pomt . distance bw pomts ' xls,yls,x2s,y2s : bot and top ratio for motors steps/cm ! xlf,x2f,ylf,y2f : abs coord of start pomt of a Ime m cm ' xs.ys . shift m x.y direction ' #5 step file *.st choιce=hole(hole_num, 1 ) xc=hole(hole_num,2) yc=hole(hole_num,3 ) radι=hole(hole_num,4) cut_nurn=hole(hole_num,5) rad_start=hole(hole_num,6) resolutιoπ=hole(hole_num,7) i ! access hole x_start=xc+cos(rad_start)*radι ! start pt on a hole y_start=yc+sm(rad_start)*radι CALL slιde_pos_poιnt(r_bot,r_top,d_poιnt,skrρ,xls,x2s,yls,y2s, & & xl f,x2f,y 1 f,y2f,x_start,x_start,y_start,y_start,xs,ys,#5) i .' cut hole drad=2 *pι resolutιon nl=_nt((2*pι-rad_start)/drad) ! num of pt on a arc from rad start to 2pι n2=ιnt(rad_start drad) ! num of pt on a arc from 0 to rad start FOR ι=l TO nl ! cut angle from rad start to 2*pι rad=rad_start+ι * drad xout=xc+cos(rad)*radι yout=yc+sm(rad) *radι CALL shde_pos(r_bot,r_top,xs,ys,x 1 s,x2s,y 1 s,y2s,& & xout,xout,yout,yout,#5) NEXT i xout=xc+radι ! path 0 deg pt CALL slide -os(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,xout,xout,yc,yc,#5) FOR ι=l TO ή2 ! cut angle from 0 to rad_start rad=ι*drad xout=xc+cos(rad)*radι yout=yc+sιn(rad)*radι CALL slide_pos(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,xout,xout,yout,yout,#5) NEXT i ! pass start pomt CALL slide j 30s(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,x_start,x_start,y_start,y_start,#5) I ! return to loop CALL shde_pos_pomt(r_bot,r_top,d_pomt,skιp,xls,x2s,yls,y2s, & & x_start,x_start,y_start,y_start,xlf,x2f,ylf,y2f,xs,ys,#5) END SUB I************************ ! Subroutme. cut to step SUB cut_to_step(name$,file_num,num hole,hole(,),dh,space b,space_t,& & d_po t,skιp,xh,yh,xls,x2s,yls,y2s) ! all mput ! read cut file and make step file mcludmg access path, return path, ! and registration holes ! nameS : object name ! filejnum : file num for *.ct, *.st ! num_hole : num of reg hole ! hole(,) : reg hole mfo aπay. hole(num of hole,7) ' (choιce,xc,yc,radι,cut_num,rad_start,resoluhon) ! dh,d_poιnt : foam thickness, distance bw pomts ! space b.space t • distance bw top and bot control pomt and the foam ! skip : num of point to skip ! xh.yh x and y home position ! xls,yl s,x2s,y2s : bot and top ratio for motors steps/cm file_ct$="object\" & nameS & "\" & str$(file_num) & ".ct" file_ctx$="object\" & nameS & "\" & str$(file_num) & ".ctx" file_st$="object\" & nameS & "\" & str$(file_num) & ".st" CALL open_fιle(#l,file_ct$,error) IF error=l THEN exit sub CALL open_file(#2,file_ctx$,error) IF error=l THEN exit sub OPEN #5:name file_st$,access outm, create newold, org text ERASE #5 ASK #2: filesize num rec RESET #2:record num_rec-4 READ #2:xmιn,xmax,ymιn,ymax,angie RESET #2:begιn num_match=(num rec-5 )/ 13 r_bot=space_b/dh r_top=space_t/dh xs=xh-xmιn ' calc shift ys=yh-ymm FOR ι=l TO num match ! find step for all loops IF ι=l THEN ! start pomt x 1 f,x2f=0 ! first start pos=0 ylf,y2f=0 ELSE xlf=xlt x2f=x2t ylf=ylt y2f=y2t END IF R£AD #2:start,end,xbs,ybs,xts,yts,xrmιι,xmax,ymin,ymax,index_b,index_t,angle ! a slice info xlt=xbs+xs x2t=xts+xs ylt=ybs+ys y2t=yts+ys CALL access j ,ath(r_bot,r_top,d_point,skip,xls,x2s,yls,y2s, & & xlf,x2f,ylf,y2f,xlt,x2t,ylt,y2t,#5) ! ..o CALL find_hole_start(# 1 ,num_hole,hole(,)) num_ct=(end-start+l )/4 RESET #l :record start FORj=l TO num_ct READ #l :xl,yl,x2,y2 CALL slide_pos(r_bot,r_top,xs,ys,xls,x2s,yls,y2s,xl,x2,yl,y2,#5) ! ..o FOR k=l TO num_hole cut_num=hole(k,5) IF cut_num=j THEN CALL hole_circle(hole(,),k,r_bot,r_top,d_ρoint,xl s,x2s,& & yls,y2s,xl,x2,yl,y2,xs,ys,#5) END IF NEXT k NEXTj NEXT i CALLaccess_path(r_bot,r_top,d_point,skip,xls,x2s,yls,y2s,& & xlt,x2t,ylt,y2t,0,0,0,0,#5) ! ..o CLOSE#1 CLOSE#2 CLOSE#5 ENDSUB |************************ ! Subroutine: auto step |************** ********** SUB auto_step(name$,start,end,num_hole,dh,space_b,space_t,& & d_point,skip,xh,yh,x 1 s,x2s,y 1 s,y2s) ! make step file from start to end including access path, return path, ! and registration holes ! nameS : object name ! start,end : start and end file num for *.ct, *.st ! num hole : num of reg hole ! dh,d_point : foam thickness, distance bw points ! space_b,space_t : distance bw top and bot control point and the foam ! skip : num of point to skip ! xh,yh : x and y home position ! xls,yls,x2s,y2s : bot and top ratio for motors steps/cm DIM hole(0,0) IF num_hole<>0 THEN ! make hole(,) MAT REDIM hole(num_hole,7) INPUT PROMPT "radius(cm), resolution(n), altemative(l/0)? " & & :radi,resolution,alt PRINT PRINT "choice : 0=min dis, 1=0 deg, 2=90 deg, 3=180 deg, 4=270 deg" PRINT FOR i=l TO mim iole INPUT PROMPT "Hole "&stτ$(i)&": choice(0-4),xc,yc? ":choice,xc,yc hole(i, 1 )=choice hole(ι,2)=xc hole(ι,3)=yc hole(ι,4)=radι hole(ι,7)=resolutιon NEXT i END IF FOR ι=start TO end ! make step files PRINT PRINT "Makmg file ";str$(ι);" st";" (",ι;"/";end,") Wait. " CALL cut_to_step(name$,ι,num_hole,hole(,),dh,space_b,space_t,& & d_pomt,skιp,xh,yh,x 1 s,x2s,y 1 s,y2s) IF alt=l THEN ! alt reg hole FOR j=l TO num_hole IF holeO,l)=l THEN hole0,l)=3 ELSE IF hole(j, l)=2 THEN hole0,l)=4 ELSE IF hole(j, l)=3 THEN hole ,l)=l ELSE IF hole(j,l)=4 THEN hole0,l)=2 END IF NEXTj END IF NEXT i PRINT end-start+1."files are made " END SUB |************* ! End of file |************* |*************************************************** ************** ! Wπtten by Cheol Lee ! File: 72-gct.tru ! Date: 10/95 ! Object : plot *.ct, *.st and *.ln for registration holes ! Input : *.ct, *.st, *.lp ! Output : 2D or 3D drawing for *.ct and *.st, and drawmg for reg holes I ***************************************************************** library "71 -ut tru" library "71-gln tru" library "71-5-ctl. tru" library "utillibl . tru" library "3dlιb.trc" name$="fordcar" start,end=6 num_hole=0 dh=2.54/2 space_b,space t=l d_pomt=0.2 xh=l yh=l xls,x2s,y2s=800 yls=150 x2w,y2w=50 !call draw auto_st_3d(name$,start,end,dh,space_b,space_t,x2w,y2w,x 1 s,x2s,y 1 s,y2s,xh,yh) !call registration 1,5,50,50) [stop !call draw_top_bot_2d(name$,file_num,x2w,y2w) [stop call draw_auto_cut_2d(name$, 1 , 1 ,2.74/2,x2 w,y2w) ! call registration 1 , 10, 100, 100 ) end EXTERNAL ********* Summary (72-gct) ********* SUB draw_top_bot_2d(file_num,x2w,y2w) SUB draw cut 3d(name$,file_num,dh,x2w,y2w) SUB draw_auto_cut_2d(name$,start,end,dh,x2w,y2w) SUB draw_st_3d(file_num,dh,space_b,sρace_t,x2 w,y2w,x 1 s,x2s,y 1 s,y2s,xh,yh) SUB draw auto_st_3d(name$,start,end,dh,space_b,space_t,x2w,y2w,x 1 s,x2s,y 1 s,y2s,xh,yh) ! SUB registration start,end,xmax,yrnax) 1***************** *********** ! Subroutme: draw_top_bot_2d I**************************** SUB draw_top_bot_2d(name$,file_num,x2w,y2w) ! ι(4) ! Read *.ct and plot it m 2D ! nameS : object name ! fιle_num : cut coordinate file number, *.ct ! 0,x2w,0,y2w . window size CALL draw_loop(name$,file_num,0,x2w,y2w) CALL draw_loop(name$,file_num+ 1 ,0,x2w,y2 w) END SUB I ************************* ! Subroutme: draw_cut_3d I************************* SUB draw_cut_3d(nameS,file_num,dh,x2w,y2w) ! ι(5) ! Read *.ct and plot the edges and cutter motion m 3D ! nameS . object name ! file_num . cut coordinate file number, *.ct ! dh : slice thickness ' 0,x2w,0,y2w : window size file_bot$="object\" & nameS & "\" & StrS(file num) & ".pt" file_top$="object\" & nameS & "\" & Str$(file_num+1) & ".pt" file_cut$="ob ect\" & nameS & "\" & StrS(fιle num) & ".ct" fιle_ctx$="object\" & nameS & "\" & StrS(file num) & ".ctx" CALL open_file(# 1 ,file_bot$,error) IF error=l THEN exit sub CALL open_file(#2,fιle_top$,error) IF error=l THEN exit sub CALL open_file(#3,file_cut$,error) IF error=l THEN exit sub CALL open_file(#4,file_ctx$,error) IF error=l THEN exit sub ASK #1 FILESIZE num_rec_b ASK #2:FILESIZE num_rec_t ASK #3 FILESIZE num_rec_cut ASK #4:FILESIZE num_rec_ctx LET num_poιnt_b=num rec_b/2 LET num_poιnt_t=num_rec_t/2 LET num_cut=num_rec_cut/4 LET num_match=(num_rec_ctx-5)/13 CLEAR CALL PersWιndow(0,x2w,0,y2w,0,dh) ! define window size in 3d SET BACK "red" SET COLOR "white" [CALL AskScale3(hor,ver) ! IF hor<1.2 THEN CALL SetScale3(1.2,1.2) CALL Axes3 CALL PlotText3(x2w,0,0,"X") CALL PlotText3(0,y2w,0,"Y") CALL PlotText3(0,0,dh,"Z") CALL PlotText3(0,0,0,O") SET COLOR "yellow" PRINT num_poιnt_b; "points ";str$(file num);".pt" PRINT num_pomt_t; "pomts ";str$(file_num+l);".pt" PRINT num_cut;"cut steps m ";str$(file_num),".ct" RESET #4:record num_rec_ctx-4 READ #4:xrn ,xmax,yrrnn,yrnax,rnax_angle xsιze=xmax-xπun ysιze=ymax-ymm PRINT PRINT "" PRINT " Slice size x y : ";xsιze;'7";ysιze PRINT " Max angle:";max_angle ! ! draw top and bot pomt file SET COLOR "blue" FOR ι=l TO num_poιnt_b ! plot bot edge READ #l :xl,yl CALL PlotOfO(xl,yl,0) NEXT i 'CALL PlotOff3(xl,yl,0) SET COLOR "white" FOR ι=l TO num_poιnt_t ! plot top edge READ #2:x2,y2 CALL PlotOfO(x2,y2,dh) NEXT i 'CALL PlotOff3(x2,y2,dh) ' plot cutter path SET COLOR "yellow" FOR ι=l TO num_match RESET # -record (ι-l)*13+l READ #4:rec_start,rec_end RESET #3 record rec start FOR j=l TO n cut ' plot cutter motion READ #3:xl,yl,x2,y2 CALL PlotOff3(xl,yl,0) ! draw top bot cutter pomts CALL PlotOff3(x2,y2,dh) NEXTj NEXT i CLOSE #1 CLOSE #2 CLOSE #3 CLOSE #4 END SUB I ******************************* ! Subroutme: draw_auto_cut_2d I ****** ************************* SUB draw_auto_cut_2d(name$,start,end,dh,x2w,y2w) ! ι(6) ! Read from startct to endxt, and plot cutter motion in 3D ! nameS : object name ! start,end • start and end num of cut file, *.ct ! dh : slice thickness ! 0,x2w,0,y2w : window size FOR ι=start TO end CLEAR CALL draw_cut_3d(name$,ι,dh,x2w,y2w) GET KEY getkey NEXT i END SUB ( ************************* ' Subroutine: draw_st_3d I************************* SUB draw_st_3d(name$,file_num,dh,space_b,space_t,x2w,y2w,xls,x2s,yls,y2s,xh,yh) ! all mput ! Read *.st and plot cutter motion m 3D ! nameS : object name ! file num : file num of *.st ! dh : slice thickness ! space b.space t : space bw top and bottom pivot pomt and form ! 0,x2w,0,y2w : window size ! xls,x2s,y ls,y2s : step/cm conversion for x,y direction of top and bot ! xh.yh • home position from the orgm of a coord system & nameS & "\" & StrS(file num) & ".pt" & nameS & "\" & Str$(file_num+1) & ".pt" file_ct$="object\" & nameS & "\" & Str$(file_num) & ".ct" file_ctx$="object\" & name$ & "\" & StrS(file num) & ".ctx" file_st$="object\" & nameS & "\" & StrS(file num) & ".st" CALL open_file(#l ,file_bot$, error) CALL open file(#2,file_top$, error) IF error=l THEN exit sub CALL open fιle(#3,file_ct$,error) IF error=l THEN exit sub CALL open_file(#4,fιle_ctx$,error) IF error=l THEN exit sub OPEN #5:name file_st$,access mput, org text ASK #1 :FILESIZE num_rec_b ASK #2:FILESIZE num_rec_t ASK #3:FILESIZE num_rec_ct ASK #4:FILESIZE num_rec_ctx LET num_poιnt_b=num_rec_b/2 LET num_poιnt_t=num_rec_t/2 LET num_ct=(num_rec_ct-5)/4 RESET #4:record num_rec_ctx-4 READ #4:xrmn,xmax,ymm,ymax,max_angle CALL PersWmdow(0,x2w,0,y2w,0,dh) ! define wmdow size in 3d SET BACK "red" SET COLOR "white" [CALL AskScale3(hor,ver) ! IF hor<1.2 THEN CALL SetScale3(1.2,1.2) CALL Axes3 CALL PlotText3(x2w,0,0,"X") CALL PlotText3(0,y2w,0,"Y") CALL PlotText3(0,0,dh,"Z") CALL PlotText3(0,0,0,"O") SET COLOR "yellow" PRINT num_potnt_b;"poιnts m ";str$(file_num);".pt" PRINT num_pomt_t; "pomts m ";str$(file_num+l);".pt" PRINT num_ct;"cuts ";str$(file_num);".ct" PRINT PRINT "" PRINT " Slice size x y . ";xmιn;xmax;'7";ymm;ymax PRINT " dx/dy. "jxmax-xmmi'V'symax-ymin PRINT " Max angle :";max_angle i ! draw cut file xs=xh-xmin s=yh-ymιn SET COLOR "blue" RESET #3:begin FOR i=l TO num ct ! plot bot edge READ #3:xl,yl,x2,y2 xl=xl+xs x2=x2+xs yl=yl+ys y2=y2+ys CALL PlotOff3(xl,y 1,0) CALL PlotOfO(x2,y2,dh) NEXT i ! plot cutter path SET COLOR "yellow" h=sρace_b+space_t+dh ratιo_b=(space_b)/h ratio_t=(space_b+dh)/h xlo,x2o,ylo,y2o=0 RESET #5:Begin DO WHILE MORE #5 ! plot cutter motion INPUT #5 xl$ INPUT #5 yl$ INPUT #5 x2$ INPUT #5 y2$ xl=Val(xl$) x2=Val(x2$) yl =Val(ylS) y2=Val(y2$) xl=xl/xls ' abs coord of slide m cm x2=x2/x2s yl=yl/yls y2=yl+y2/y2s xb=xl+(x2-xl)*ratio_b ! abs coord on the foam in cm xt=xl+(x2-xl)*ratio_t yb=y l+(y2-yl )*ratιo_b yt=yl+(y2-yl)*ratio set color "yellow" CALL lineOff3(xlo,ylo,0,xb,yb,0) ! draw top bot cutter points CALL lineOfD(x2o,y2o,dh,xt,yt,dh) set color "blue" CALL hneOff3(x 1 o,y 1 o,0,xb,yb,0) ! draw top bot cutter points CALL lmeOfβ(x2o,y2o,dh,xt,yt,dh) xlo=xb x2o=xt ylo=yb y2o=yt LOOP CLOSE #1 CLOSE #2 CLOSE #3 CLOSE #4 CLOSE #5 END SUB I******************************* ! Subroutine: draw_auto_st_3d I******************************* SUB draw_auto_st_3d(name$,start,end,dh,space_b,space_t,x2w,y2w,xls,x2s,yls,y2s,xh,yh) ! all mput ! Read from start.st to end.st, and plot cutter motion in 3D ! nameS : object name ! start,end: start and end file num, *.st ! dh : slice thickness ! space b.space t : space bw top and bottom pivot point and form ! 0,x2w,0,y2w wmdow size ! xls,x2s,yls,y2s : step/cm conversion for x,y direction of top and bot ! xh.yh : home position from the orgin of a coord system FOR ι=start TO end CLEAR CALL draw_st_3d(name$,ι,dh,space_b,space_t,x2w,y2w,λls,x2s,yls,y2s,xh,yh) GET KEY getkey NEXT i END SUB I************************** ! Subroutme: Registration I ***** * * * **** * ** ***** * * ** ** SUB regιstratιon(object$,start,end,xmax,ymax) ! ι(5) ! Read *.ln, and plot it m 2D for registration hole. ! start,end : start and end *.ln file num to decide reg holes ! 0,xmax,0,ymax : wmdow size OPEN #5:SCREEN 0,1,0,0.8 SET WINDOW 0,xmax,0,ymax ! define window coordinate SET COLOR "yellow/red" OPEN #6:SCREEN 0,.5,0.8,1 SET COLOR "yellow/red" OPEN #7:SCREEN 0.5,1,0.8, 1 SET COLOR "yellow/red" WINDOW #5 FOR ι=start TO end file_ln$="object\" & objects & "\" & str$(ι) & ".In" CALL oρen_fιle(#l,file_ln$,error) IF error=l THEN exit sub ASK #1 :FILESIZE record_mιm lme_num=record_num/4 ! compute number of pomts FORj=l TO ne_num READ #l:xl,yl,x2,y2 PLOT l,yl ;x2,y2 NEXTj CLOSE#1 NEXTi DO WINDOW#6 CLEAR PRINT " Select choice" PRINT " (0) exit." PRINT " (1) mouse." PRINT " (2) draw hole." PRINT " (3) redraw " INPUT PROMPT "choice ":n IF n=0 THEN exit sub ELSE IF n=l THEN WINDOW #6 CLEAR PRINT " x / y"," dx / dy" PRINT PRINT "File:";start;"to";end PRINT "Press SHIFT-CLICK to quit." xold,yold=0 DO WINDOW #5 GET MOUSE x,y,ch IF ch=2 THEN ! click x=round(x, 1 ) y=τound(y,l) dx=abs(x-xold) dy=abs(y-yold) WINDOW #7 PRINT x;y,dx;dy xold=x yold=y END IF LOOP UNTIL ch=4 ELSE IF n=2 THEN WINDOW #6 CLEAR INPUT PROMPT "number of holes? "mum hole FOR l =1 TO num hole WINDOW #6 INPUT PROMPT "radιus,xc,yc? ":radι,xc,yc WINDOW #5 SET COLOR "blue" BOX circle xc-radι,xc+radi,yc-radι,yc+radi SET COLOR "yellow" NEXT i ELSE IF n=3 THEN WINDOW #5 CLEAR FOR ι=start TO end fιle_ln$="object\" & objects & "\" & str$(i) & ".In" CALL open_file(#l,file_ln$,error) IF error=l THEN exit sub ASK #1:FILESIZE record_num line_num=record_num/4 ! compute number of points FORj=l T01ine_num READ #l :xl,yl,x2,y2 PLOT xl,yl;x2,y2 NEXTj CLOSE #1 NEXT i END IF LOOP END SUB |************* ! End of File |************* I****************************************************************** ' Written by Cheol Lee ' File. 72-gln.tru ! Date: 10/95 ! Object . draw *.ln, *.lp, *.ρt file ! Input : * In, *.lp, *.pt ! Output : 2D or 3D drawmg of files I************************************************* ***************** dim a(0,0),b(0,0) library "69-1-vtx.tru" library "69-ut.tru" library "3dhb.trc" xmιn,ymιx=0 xmax,ymax=100 [call draw_lme(l,0,"yellow",xnun,xmax,yirun,ymax) ' call regιstratιon(l,50,100,100) 1 call draw_auto_loop_2d(3,3,0,10,10) end EXTERNAL I********* ' Summary (72-gln) |********* ' SUBdraw_line(name$,file_ln,sec,x2w,y2w) ! SUBdraw_loop(name$,file_lp,sec,x2w,y2w) ' SUB draw_lιne_array(a(,),dιm_al,sec,x2w,y2w) ! SUBdraw_pomt(name$,file_pt,sec,x2w,y2w) 1 SUB draw_bounds(file_lpx,x2w,y2w) ! SUB draw_auto_lme_2d(start,end,sec,x2w,y2w) ' SUBdraw_auto_looρ_2d(start,end,sec,x2w,y2w) ! SUBdraw_auto_poιnt_2d(start,end,sec,x2w,y2w) ! SUBdraw_auto_lιne_3d(h_bot,h_top,dh,x2w,y2w,z2w) t*********************** ! Subroutine- draw Ime I*********************** SUB draw_lιne(name$,file_ln,sec,x2w,y2w) ! ι(5) ! Read * In and plot it in 2D ! nameS - object name ! file ln : Ime coordmate file number, *.ln ! sec : pause time between drawmg lmes ! 0,x2w,0,y2w : wmdow size file_ln$="object\" & nameS & "\" & stτ$(file_ln) & ".In" CALL oρen_fιle(#l,file_ln$,error) IF error=l THEN exit sub SET WINDOW 0,x2w,0,y2w ! defme wmdow coordmate SET COLOR "yellow" SET BACK "red" ASK #1:FILESIZE record_num LET lme_num=record_num/4 ! compute number of lmes FOR ι=l T0 1ιne_num READ #l:xl ,yl,x2,y2 PLOT xl,yl;x2,y2 PAUSE sec NEXT i CLOSE #1 PRINT lιne_num; "lines m ";str$(file n);".ln" END SUB I*********************** ! Subroutine: draw loop ******** *************** SUB draw_loop(name$,file_lp,sec,x2w,y2w) ! i(5) ! Read *.lp and plot it 2D ! nameS : object name ! file lp : loop coordmate file number, *.lp ! sec : pause time between drawmg lmes ! 0,x2w,0,y2w : wmdow size file_lp$="object\" & nameS & "\" & str$(file_lp) & ".lp" & nameS & "\" & str$(file_lp) & ".lpx" CALL open_file(#l,file_lp$,error) IF error=l THEN exit sub CALL open_fϊle(#2,fιle_lpx$,eπor) IF error= 1 THEN exit sub ASK # 1 :filesιze num lp rec ASK #2: filesize num idx rec num_lme=num_lp_rec/4 num_loop=num_ιdx_rec/ 10 SET WINDOW 0,x2w,0,y2w ' define wmdow coordmate SET COLOR "yellow" SET BACK "red" FOR ι=l TO num ine READ #l :xl ,yl,x2,y2 PLOT xl,yl;x2,y2 PAUSE sec NEXT i CLOSE #1 PRINT numjine," lmes in ",str$(file_lp),".lp" FOR ι=l TO num loop READ #2:start,end,xd,yd,xu,yu,xl,yl,xr,yr PRINT "#";i;": loop size = xl/x2,yl/y2 :";xl;'7";xr;", ";yd;7";yu NEXT i CLOSE #1 CLOSE #2 END SUB I***************************** ! Subroutme: draw line array I***************************** SUB draw_hne_array(a(,),dim_al,sec,x2w,y2w) ! ι(5) ! Read Ime coordinate array and plot it in 2D ! a(,),dιm_al : a(dιm_al,4). num of lmes ! sec : pause time between drawmg lmes ! 0,x2w,0,y2w : wmdow size SET WINDOW 0,x2w,0,y2w ! define window coordinate SET COLOR "yellow" SET BACK "red" IF dιm_a 1=0 THEN PRINT "No Ime." END IF FOR ι=l TO dιm_al PLOT a(ι,l),a(ι,2);a(ι,3),a(ι,4) PAUSE sec NEXT i END SUB ************************ ! Subroutine: draw_pomt I************************ SUB draw_pomt(name$,file_pt,sec,x2w,y2w) ! ι(5) ! Read *.pt and plot it m 2D ! nameS object name ! file_pt point coordmate file, *.pt ! sec : pause tune between drawmg lmes ! 0,x2w,0,y2w : wmdow size file_pt$="object\" & nameS & "\" & str$(file_pt) & " pt" CALL open_file(#l,file_pt$,error) IF error=l THEN exit sub SET WINDOW 0,x2w,0,y2w ! define wmdow coordmate SET COLOR "yellow" SET BACK "red" ASK #1 :FILESIZE record_num LET poιnt_num=record_num/2 ! compute number of pomts FOR ι=l TO pomt num PAUSE sec READ #l :x,y PLOT x,y NEXT i PRINT pomt num; "pomts m ";str$(file_pt);".pt" CLOSE #1 END SUB ! Subroutine: draw bounds I************************ SUB draw_bounds(name$,file_lpx,x2w,y2w) ! ι(4) ! Read loop mdex file, and draw all loop bounds with color ! nameS : object name ! file lpxS : loop index file, *.lpx ! 0,x2w,0,y2w : window size & nameS & "\" & str$(file_lpx) & ".lpx" CALL open_file(#l,file_lpx$,error) IF error=l THEN exit sub ASK #l:fιLESIZE n LET num loop=n/10 SET COLOR "blue" scale=0.05 dx=x2w*scale dy=y2w*scale FOR ι=l TO num loop READ # 1 :start,end,xd,yd,xu,yυ,xl,yl,xr,yr PLOT xl+dx,yl;xl,yl PLOTxr-dx,yr;xr,yr PLOTxd,yd+dy;xd,yd PLOTxu,yu-dy;xu,yu NEXTi ENDSUB ι ******************************* ' Subroutine draw auto hne_2d I ******* ************************ SUB draw_auto_lιne_2d(name$,start,end,sec,x2w,y2w) ! 1(6) ! Read from start. In to end. In, and plot it in 2D ! nameS ■ object name ! start,end: start and end num of Ime file, *.ln ! sec : pause time between drawmg lmes ! 0,x2w,0,y2w wmdow size FOR ι=start TO end CLEAR CALL draw_lιne(name$,ι,sec,x2w,y2w) GET KEY getkey NEXT i END SUB I******************************* ! Subroutme: draw auto_loop_2d \ ******** *********************** SUB draw_auto_loop_2d(name$,start,end,sec,x2w,y2w) ! 1(6) ! Read from start.lp to end.lp, and plot it in 2D ! nameS . object name ! start,end: start and end num of loop file, *.lp ! sec : pause time between drawmg lmes ! 0,x2w,0,y2w : wmdow size FOR ι=start TO end CLEAR CALL draw_loop(name$,ι,sec,x2w,y2w) CALL draw_bounds(name$,ι,x2w,y2w) GET KEY getkey NEXT i END SUB I******************************* ! Subroutine: draw_auto_poιnt_2d I******************************* SUB draw_auto_pomt_2d(name$,start,end,sec,x2w,y2w) ! 1(6) ' Read from start.pt to end.pt, and plot it in 2D ! nameS • object name ! start,end: start and end num of pomt file, *.pt ! sec : pause time between drawmg lmes ! 0,x2w,0,y2w : wmdow size FOR ι=start TO end CLEAR CALL draw_poιnt(name$,ι,sec,x2w,y2w) GET KEY getkey NEXT i END SUB I ******************** *********** ! Subroutme: draw_auto_lιne_3d I******************************* SUB draw_auto_lιne_3d(name$,h_bot,h_top,dh,x2w,y2w,z2w) ! Read all Ime files (*.ln) and draw them 3D ! h bot.h top: height of bottom and top of object ' dh . slice thickness ' 0,x2w,0,y2w,0,z2w. 3D wmdow size CALL Para Wmdow (0,x2w,0,y2w,0,z2w) ! define wmdow coordinate SET BACK "red" SET COLOR "white" [CALL SetScale3( 1.1, 1.1) CALL Axes3 CALL PlotText3(x2w,0,0,"X") CALL PlotText3(0,y2w,0,"Y") CALL PlotText3(0,0,z2w,"Z") CALL PlotText3(0,0,0,"O") SET COLOR "yellow" LET num_slice=Int((h_top-h_bof)/dh) LET num_file=num slιce+1 ! number of Ime files FOR ι=l TO num file ! read a Ime file and draw Ime LET ! slice height LET file ιne$="object\" & nameS & "\" & Str$(ι) & " In" ! Ime file name to read OPEN #l :name file lineS, access mput ! hne file ASK #1. FILESIZE record_num LET lιne_num=record_num/4 ! compute number of lmes FORj=l TO line num ! plot lmes one at a time READ #l :xl,yl,x2,y2 CALL LιneOfβ(xl,yl,h,x2,y2,h) NEXTj PAUSE pause sec CLOSE #1 NEXT i END SUB I ************* |************* I************************************************************ ! Written by Cheol Lee I ! File. 72-gvt.tru ! Date: 10/95 ! ' Object : draw *.vtx file ! Input • vertex record file. *.vtx ' Output • wireframe 3D drawmg of an object I************************************************************ library"67-1-vtx.tru" library"67-ut.tru" library "3dlιb.trc" end EXTERNAL I********* ' Summary (72-gvt) |********* ' SUB draw_vtx_3d(name$,x2w,y2w,z2w) I************************* ! Subroutme: draw vtx 3d ************************* SUB draw_vtx_3d(name$,x2w,y2w,z2w) ! ι(4) ! Read vertex file and draw wireframe 3D plot .' nameS : object name *.vtx .' 0,x2w,0,y2w,0,z2w 3d wmdow size file vtx$="object\" & nameS & " vtx" CALL open_file(#l,file_vtx$,error) IF error=l THEN exit sub ASK #1:FILESIZE num_rec LET num_tπ=num_rec/9 CALL ParaWindow(0,x2w,0,y2w,0,z2w) SETBACK "red" SET COLOR "white" CALL Axes3 CALLPlotText3(x2w,0,0,"X") CALLPlofText3(0,y2w,0,"Y") CALLPlotText3(0,0,z2w,"Z") CALLPlotText3(0,0,0,"O") SET COLOR "yellow" FOR ι= 1 to num tπ READ #l:xl,yl,zl,x2,y2,z2,x3,y3,z3 CALL ploton3(x 1 ,y 1 ,z 1 ) CALL ploton3(x2,y2,z2) CALL ploton3(x3,y3,z3) CALL plotoff3(xl ,yl,zl) NEXT i PRINT num_tri;"triangles in ";name$;".vtx" PRINT " object size x:";x2w;" y:";y2w;" z:";z2w END SUB I************* ! End of File |************* ********************************************************************* Wπtten by Cheol H.Lee File: 72-main.tru Date: 6/96 Object : mam program to control SM2 Input : *.stl, job selection Output : driving machine ********************************************************************* MEMO - *.stl, *.vtx files are in "objectV directory - *.ln,*.lp,*.lpx,*.pt,*.ptx,*.ct,*.ctx,*.st,ctreport.txt files are m "object\[object_name]\" directory - setup.rp is in "objectV directory - rp-mt4.c is in "bc31\bin\" directory - rρ-mt4.c will read *.st and ctreport.txt in "\object\temp\" directory •a******************************************************************* LIBRARY "72- 1-vtx.tru" LIBRARY "72-2-lnl. tru" LIBRARY "72-2-ln2.tru" LIBRARY "72-3-lp2.tru" LIBRARY "72-3-lpl. tru" LIBRARY "72-4-pt.tru" LIBRARY "72-5-ct2.tru" LIBRARY "72-5-ctl. tru" LIBRARY "72-6-st.tru" LIBRARY "72-ut.tru" LIBRARY "72-gvt.tru" LIBRARY "72-gln.tru" LIBRARY "72-gct.tru" LIBRARY "72-menu.tru" LIBRARY "3dlib.trc" LIBRARY "utillib2.tru" LIBRARY "utillibl. tru" LIBRARY "shell.tru" [LIBRARY "72-1-vtx.trc" [LIBRARY "72-2-lnl.trc" [LIBRARY "72-2-ln2.trc" [LIBRARY "72-3-lp2.trc" [LIBRARY "72-3-lpl.tτc" [LIBRARY "72-4-pt.trc" [LIBRARY "72-5-ct2.trc" [LIBRARY "72-5-ctl. trc" [LIBRARY "72-6-st.trc" [LIBRARY "72-ut.trc" [LIBRARY "72-gvt.trc" .'LIBRARY "72-gln.trc" [LIBRARY "72-gct.tτc" .'LIBRARY "72-menu.tru" [LIBRARY "3dlib.trc" [LIBRARY "utillιb2.trc" [LIBRARY "utillibl. trc" [LIBRARY "shell.tru" DIM a(0,0),b(0,0),index( 10, 10) xls,x2s,y2s=800 yls= 120.63 !num var=26 I ************** ! Main Program I************** SET MODE "vga" CALL read_se p (name$,num_tri,dh,angle,space_tspace_b,d_loop,d_pomt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) i ! menu job loop DO MAT REDIM a(0,0),b(0,0) ! save memory ! ! menu rwιn=.8 IF xmax*rwm>ymax THEN ' wmdow size xwm=xmax ywm=xmax*rwm zwm=zmax ELSE xwm=ymax rwm ywm=ymax zwm=zmax END IF CALL status (name$,num_tri,dh,angle,space_t,space b,d looρ,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skip) CLEAR SET COLOR "white" ! ! main job description SELECT CASE job CASE 0 ! quit STOP CASE 1 ! DO [exit do ! remove dos shell for memory CLEAR PRINT "Press (0) to return to mam menu." INPUT PROMPT "DOS command: "xomS IF com$="0" THEN EXIT DO ELSE CALL shell(comS) END IF GET KEY getkey LOOP i ! job setup CASE 2 ! change job setup DO ! setup menu CALL status (name$,num_tn,dh,angle,space_t,space_b,d_loop,d_poιnt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp) CALL setup_menu(job_setup) CLEAR SET COLOR "white" SELECT CASE job_setup CASE 0 ! return to main menu EXIT DO CASE 1 ! foam thickness PRINT "current foam thickness: ";dh INPUT PROMPT "Foam thickness (cm)? ":dh CASE 2 ! max cutter angle PRINT "current cutter angle: ";angle INPUT PROMPT "Maximum cutter angle (degree)? ":angle CASE 3 ! bot space PRINT "current bottom space: ";space_b INPUT PROMPT "Bottom space from the foam (cm)? ":space_b CASE 4 ! top space PRINT "current top space: ";space t INPUT PROMPT "Top space from the foam (cm)? ":space CASE 11 ! loop distance PRINT "current loop distance: ";d loop INPUT PROMPT "Minimum distance between loops (cm)? ":d_loop CASE 12 ! point distance PRINT "current point distance: ";d_poιnt INPUT PROMPT "Maximum distance between pomts (cm)? ":d_pomt PRINT "cuπent skip pomts: ";skιp INPUT PROMPT "Skip pomts? ":skιp CASE 14 ! decimal PRINT "current rount decimal: ";decιmal INPUT PROMPT "Round decimal? ":decimal CASE 21 ! home position PRINT "current home position : ";xh;yh INPUT PROMPT "Home position x,y (cm)? ":xh,yh CASE 31 ! save setup CALL save_setuρ(name$,num_tπ,dh,angle,space_t,space_b,d_loop,d_pomt,& & xmax,ymax,zmax,xh,yh,decιmal,skιρ) EXIT DO CASE ELSE PRINT "Job is not available. Select again " GET KEY key EXIT SELECT END SELECT LOOP i ! object CASE 3 ! combine STL files CALL shell("dir/w/o:n object\*.stl") PRINT "Press (0,0,0) to cancel." INPUT PROMPT "stl_ιnl, stl_ιn2,Ostl_ιn3'> ":ml$,in2$,out$ IF ιnl$="0" and in2$="0" and out$="0" THEN EXIT select PRINT "Wait.. " CALL combιne_stl(ιnl$,ιn2$,out$) CASE 4 ! append STL files CALL shell("dιr/w/o:n object\*.stl") PRINT "Press (0,0) to cancel " INPUT PROMPT "stl_ιnout, stl in " mout$,ιn$ IF mout$="0" and ιn$="0" THEN EXIT select PRINT "Wait . " CALL append_sfl(ιnout$,ιn$) CASE 5 ! stl to object CALL shell("dιr/w/o n object\*.stl") PRINT "Press (0) to cancel." INPUT PROMPT "Object name? ":name$ IF name$="0" THEN exit select com$="md ob ect\" & nameS CALL shell(comS) CLEAR CALL stl_to_vtx(name$,num_tπ,xmax,ymax,zmax) CLEAR CALL draw_vtx_3d(narne$,xmax,ymax,zmax) GET KEY key CASE 6 ' select object CALL shell("dιr/w/o.n objectV* vtx") temp$=name$ PRINT "Press (0) to cancel " INPUT PROMPT "Object name ".nameS IF name$="0" THEN name$=temp$ exit select END IF CALL object_sιze(name$,xπun,xmax,ymm,ymax,zmm,zrrιax,num_tπ) CASE 7 ! rotate object PRINT "Press (0,0,0) to cancel." PRINT "Current object is ";name$ PRINT INPUT PROMPT "Rotated object name, axes, angle? ":name_out$,rot_axes$,rot_angle IF rot_angle=0 THEN exit select CALL rotate_vtx(rιame$,rot_axes$,rot_angle,xmax,ymax,zmax,name_out$) name$=name_out$ CLEAR CALL draw_vtx_3d(name$,xmax,ymax,zmax) GET KEY key CASE 8 ! resize object PRINT "Press (0,0,0,0) to cancel " PRINT "To convert INCH mto CM, scale=2.54 " PRINT "Current object is ";name$ PRINT INPUT PROMPT "Scaled object name, ratιo(x,y,z) 9 ".name_out$,xr,yr,zr IF xr=l and yr=l and zr=l THEN exit select IF xr=0 and yr=0 and zr=0 THEN exit select CALL scale_vtx_file(name$,xr,yr,zr,xmax,ymax,zmax,name_out$) name$=name_out$ CASE 9 ! registration INPUT PROMPT "Start, end file number 9 " start,end CLEAR CALL regιstratιon(name$ > start,end,xwιn,ywιn) ι_ ' a slice CASE 11 ' object to one Ime PRINT "Press (0,0) to cancel " PRINT "object heιght";zmax,", foam thickness ";dh,", number of Ime file ",mt(zmax dh)+l INPUT PROMPT "Line file number, cut height 9 " file_ln,shce_h IF fιle_ln=0 and shce_h=0 THEN exit select CALL vtx_to_lιne_h(name$,slιce_h,decιmal,file_ln) CLEAR CALL draw_line(name$,file_ln,0,xmax,ymax) GET KEY getkey CASE 12 ! object to lmes PRINT "Press (0,0) to cancel." PRINT "object heιght";zmax;", foam thickness ";dh,", number of Ime file ",mt(zmax/dh)+l INPUT PROMPT "start, end Ime files 9 " start,end IF start=0 THEN Exit select CALL vtx_to_lιne(name$,start,end,dh,decιmal) GET KEY getkey CASE 13 ' lmes to loops PRINT "Press (0,0) to cancel " PRINT "object heιght:";zmax,", foam thickness ",dh,", number of loop file ",ιnt(zmax/dh)+l INPUT PROMPT "start, end loop files 9 " start,end IF end=0 THEN exit select CALL lιne_to_loop(name$,start,end,d loop) GET KEY getkey CASE 14 ! loop to pomt PRINT "Press (0,0) to cancel " PRINT "object heιght:";zmax,", foam thιckness.";dh,", number of pomt file ",mt(zmax/dh)+l INPUT PROMPT "start, end pomt files? ":start,end IF end=0 THEN exit select CALL loop_to_pomt(name$,start,end,d_pomt,decιmal, 1 ) GET KEY key CASE 15 ' pomt to cut PRINT "Press (0,0) to cancel " PRINT "object height: ";zmax,", foam thickness ",dh,", number of cut file-",ιnt(zmax/dh) INPUT PROMPT "start, end cut files 9 ":start,end IF start=0 and end=0 THEN exit select reverse=0 INPUT PROMPT "reverse(0/l) 9 " reverse CALL auto_cut(name$,start,end,reverse,dh,angle,decιrnal,skιp) GET KEY getkey CASE 16 ! cuts to steps PRINT "Press (0,0) to cancel." PRINT "object height: ";zmax;", foam thickness:";dh;", number of cut file:";int(zmax dh) INPUT PROMPT "start, end step files? ":start,end IF start=0 and end=0 THEN exit select INPUT PROMPT "number of holes(O-n)? ":num_hole CALL auto_step(name$,start,end,num_hole,dh,space_b,sρace t,& & d_point,skip,xh,yh,x 1 s,x2s,y 1 s,y2s) GET KEY getkey CASE 21 ! remove loop PRINT "Press (0) to cancel." PRINT "object height: ";zmax;", foam thickness:";dh;", number of loop file:";int(zmax/dh)+l INPUT PROMPT "loop file number? ":file_lp IF file_lp=0 THEN exit select CLEAR CALL draw_auto_loop_2d(name$,file_lp,file_lp,0,xwin,ywin) SET COLOR "yellow" PRINT PRINT " Press (0) to cancel." INPUT PROMPT " loop number to be removed? ":lp_nurn IF lp_num=0 THEN exit select CALL remove_loop(name$,file_lp,lp_num) CLEAR CALL draw_auto oop_2d(name$,file_lp,file_lp,0,xwin,ywin) CASE 22 ! reverse loop PRINT "Press (0) to cancel." PRINT "object height:";zmax;", foam thickness:";dh;", number of loop fιle:";int(zmax/dh)+l INPUT PROMPT "loop file number? ":file_lp IF file_lp=0 THEN exit select CLEAR CALL draw_auto_loop_2d(name$,file_lp,fιle_lp,0,xwin,ywin) SET COLOR "yellow" PRINT "Press (0) to cancel." INPUT PROMPT "loop number to be reversed? ":lρ_num IF lp_num=0 THEN exit select CALL reverse_loop(name$,file_lp,lp_num) CLEAR CALL draw_auto_loop_2d(name$,file_lp,file_lp,0,xwin,ywin) CASE 23 ! point to cut (SM 1 ) PRINT "Press (0,0) to cancel." PRINT "object height:";zmax;", foam thickness:";dh;", number of cut file:";int(zmax/dh) INPUT PROMPT "start, end cut files? ":start,end IF start=0 and end=0 THEN exit select CALL auto_cut_sml(name$,start,end,decimal) GET KEY getkey [ Read CASE 41 ! read loop index file PRINT "Press (0,0) to cancel." PRINT "object height:";zmax;", foam thickness: ";dh;", number of loop file:";ιnt(zmax/dh)+l INPUT PROMPT "start, end number 9 " start,end IF start=0 and end=0 THEN exit select CALL auto_read_lp_ιndex(name$,start,end) CASE 42 ' read pomt mdex file PRINT "Press (0,0) to cancel " PRINT "object height ",zmax,", foam thickness ",dh,", number of pomt file ",ιnt(zmax/dh)+l INPUT PROMPT "start, end number 9 " start,end IF start=0 and end=0 THEN exit select CALL auto_read_pt_ιndex(name$,start,end) CASE 43 ' read ct mdex file PRINT "Press (0,0) to cancel " PRINT "object height ",zmax,", foam thickness ",dh,", number of point file ",ιnt(zmax dh)+l INPUT PROMPT "start, end number 9 " start,end IF start=0 and end=0 THEN exit select CALL auto_read_ct_ιndex(name$,start,end) CASE 44 ' read coord file PRINT "Press (0) to cancel " PRINT "object height ",zmax,", foam thickness ",dh,", number of Ime file ",ιnt(zmax/dh)+l INPUT PROMPT "Coordmate file name 9 " file_name$ IF file_name$="0" THEN exit select file_name$="object\" & nameS & "\" & file names CALL read_record_file(fiIe_name$,4) GET KEY getkey CASE 45 ' cut report PRINT "Press (0,0) to cancel " PRINT "object height ",zmax,", foam thickness ",dh,", number of cut file ",ιnt(zmax/dh) INPUT PROMPT "File number start, end 9 " start,end shce=mt(zmax/dh) CALL cut_report(name$,num_tπ,dh,angle,space_t,space_b,d_ioop,d_pomt,& & xmax,ymax,zmax,xh,yh,decιmal,skιp,shce,start,end) CASE 46 ' read report CALL read_cut_report(name$) PRINT INPUT PROMPT "pπnt 9 (I/O) 9 " temp PRINT IF temp=1 1ΗEN com$="pπnt objectV & nameS & "\ctreport txt" CALL shell(comS) END IF i ' automatic view CASE 51 ' view object - wire CLEAR CALL draw_vtx_3d(name$,xmax,ymax,zmax) GET KEY getkey PRINT "Press (0,0) to cancel " PRINT "object height ",zmax,", foam thickness ",dh,", number of line file ",ιnt(zmax/dh)+l INPUT PROMPT "start, end number 9 " start,end IF start=0 and end=0 THEN exit select h_bot=(start-l)*dh h_top=(end-l)*dh CLEAR CALL draw_auto_lme_3d(name$,h_bot,h_top,dh,xmax,ymax,zmax) GET KEY getkey CASE 53 ! view lmes 2D PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foarm thιckness:";dh;", number of Ime file.";ιnt(zmax/dh)+l INPUT PROMPT "start, end number 9 ":start,end IF start=0 and end=0 THEN exit select CLEAR CALL draw_auto_lιne_2d(name$,start,end,0,xwιn,ywιn) CASE 54 ! view loops PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foam thιckness:";dh;", number of loop file:";mt(zmax/dh)+l INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select CLEAR CALL draw_auto_loop_2d(name$,start,end,0,xwιn,ywιn) CASE 55 ! view pomts PRINT "Press (0,0) to cancel." PRINT "object height: ";zmax;", foam thιckness ";dh;", number of pomt file:";ιnt(zmax/dh)+l INPUT PROMPT "start, end number 9 ":start,end IF start=0 and end=0 THEN exit select CLEAR CALL draw auto_po int 2d(name$,start,end,0,xwιn,ywιn) PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foam thιckness:";dh,", number of cut file ";ιnt(zmax dh) INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select CALL draw_auto_cut_2d(name$,start,end,dh,xwιn,ywιn) CASE 57 ! view steps PRINT "Press (0,0) to cancel." PRINT "object heιght:";zmax;", foam thickness:";dh;", number of step file:";ιnt(zmax/dh) INPUT PROMPT "start, end number? ":start,end IF start=0 and end=0 THEN exit select FOR ι=start TO end CLEAR CALL draw_st_3d(name$,ι,dh,space_b,space_t,xwm,ywm,xls,x2s,yls,y2s,xh,yh) GET KEY getkey NEXT i CASE 91 ! prepare com$="copy objectV & nameS & "\* st objectVtemp" CALL shell(comS) com$="copy ob ect\" & nameS & "\* .txt object\temp" CALL shell(comS) CASE 92 ! read report CALL read_cut_report("temp") GET KEY getkey CASE 100 .' prototype CALL shell("c:\bc31\bin\rp-mt4") CASE ELSE PRINT "Job is not available. Select again " GET KEY key EXIT SELECT END SELECT LOOP END I************* ! End of file |************* I ******************************************************************** Wπtten by Cheol H. Lee File. 72-menu.tru Date. 6/96 Object display menu, and read and save setup file Input setup.rp Output ■ dispaly menu, setup.rp ******************************************************************** MENU - 15 jop setup parameters are save m ob ectVsetup.rp record file (name$,num_tπ,dh,angle,space_t,space_b,d_loop,d_pomt xmax,ymax,zmax,xh,yh,decimal,skip) - Job setup parameters can be changed in setup menu. ******************************************************************** set mode "vga" clear a=l if a=l then else call setup_menu(job) end EXTERNAL t ********* ! Summary (72-menu) i **** ***** ! SUB status (name$,num tπ,dh,angle,space_t,space_b,d_loop,d_poιnt,& ' & xmax,ymax,zmax,xh,yh,decιmal,skιp) ! SUB setup_menu(job) • SUB read_setup(name$,num_tn,dh,angle,space_t,space_b,d loop,d_poιnt,& ! & xmax,ymax,zmax,xh,yh,decιmal,skιp) ! SUB save_setup(name$,num_-π,dh,angle,space_t,space b,d loop,d_pomt,& ' & xmax,ymax,zmax,xh,yh,decιmal,skιp) ************************* ! Subroutine: status I************************* SUB status (name$,num_tri,dh,angle,space_t,space_b,d_loop,d_point& & xmax,yrnax,zmax,xh,yh,decu -- al,skιp) ! all mput ! display status wmdow m mam menu wmdow ! nameS, num tri : object name, number of tnangles ! dh, angle : foam thickness, maximum cut angle ! space_t, space b: space bw control pomt and top or bot surface ! djoop, d_ρoιnt : m distance bw loops, discrete pomt distance ' x,y,zmax : object size ! xh,yh • home position in x and y direction ! decimal, skip ■ round decimal, number of skip pomts ASK free memory mem memory=round(mem/l 000, 1 ) IF dh<>0 THEN num_shce=ιnt(zmax/dh) OPEN #9 SCREEN 0.66,1,0,1 WINDOW #9 CLEAR SET COLOR "red" PRINT "JOB SETUP " PRINT "*********************************" PRINT " Object ";name$;",";num_tπ;"tπ" PRINT " " PRINT " Slices :";num_slice;"shces" PRINT " Free memory :";memory;"Kb" PRINT PRINT " Loop gab :";d_loop;"cm" PRINT " Pomt res .";d_pomt;"cm" PRINT " Pomt skip :";skιp;"pts" PRINT " Decimal ";decunal;"place" PRINT PRINT " Cut angle :";angle;"degree" PRINT " Foam ";dh,"cm" PRINT " Bottom space:";space_b;"cm" PRINT " Top space :";space_t;"cm" PRINT PRINT " home x,y : " ;xh;yh PRINT PRINT " object x:";xmax;"cm" PRINT " y:";vmax;"cm" PRINT " z:";zmax;"cm" END SUB I *********************** ! Subroutme: main menu I*********************** SUB mam menu (job) ' l ! display mam menu for ob selection ! job : job selection SET BACK "black" OPEN #1:SCREEN 0,0.33,0.1,1 OPEN #2:SCREEN 0.33,0.66,0.1,1 OPEN #3:SCREEN 0,1,0,0.1 !- 1st column l l l l l 111111111111111111 I I 1111111111 l l l l l 1111111 WINDOW #1 CLEAR SET COLOR "yellow" PRINT "RP CONTROL SOFTWARE R72" PRINT "by Cheol Lee " PRINT SET COLOR "red" PRINT "JOB LIST" PRINT "******************************" SET COLOR "white" PRINT " 0) Quit" PRINT " l) DOS" PRINT " 2) Job setup" PRINT " 3) Combine STL" PRINT " 4) Append STL" PRINT " 5) STL to object" PRINT " 6) Select object" PRINT " 7) Rotate object" PRINT " 8) Resize object" PRINT " 9) Registration" SET COLOR "green" PRINT "SLICE " SET COLOR "white" PRINT " 1 1) Object to a ne " PRINT " 12) Object to lmes " PRINT " 13) Lmes to loops " PRINT " 14) Loops to pomts " PRINT " 15) Pomts to cuts" PRINT " 16) Cuts to steps" PRINT PRINT " 21) Remove loop " PRINT " 22) Reverse loop " PRINT " 23) Points to cuts(SMl) " !— 2nd column WINDOW #2 CLEAR SET COLOR "magenta" PRINT " Manufacturing Lab " PRINT " Univ. of Utah " PRINT " " BOX LINES 0,0.8,0.93,1 PRINT PRINT SET COLOR "green" PRINT "READ " SET COLOR "white" PRINT " 41) Loop index" PRINT " 42) Point index" PRINT " 43) Cut index" PRINT " 44) Coord file" PRINT " 45) Create cut report" PRINT " 46) Read cut report" SET COLOR "green" PRINT "AUTOMAΗC VIEW" SET COLOR "white" PRINT " 51) Object" PRINT " 52) Lmes-3D" PRINT " 53) Lιnes-2D" PR NT " 54) Loops" PRINT " 55) Pomts" PRINT " 56) Cuts" PRINT " 57) Steps" SET COLOR "green" PRINT "SHAPE MAKER 2" SET COLOR "white" PRINT " 91) prepare " PRINT " 92) check report" PRINT " 100) prototype" '— question wmdow WINDOW #3 CLEAR SET COLOR "white" INPUT PROMPT "Select a job " job CLEAR END SUB I************************* ' Subroutme. setup menu |************************* SUB setuρ_menu(job) ' I ' display setup sub menu ' job job selection m setup sub menu SET BACK "black" OPEN #l SCREEN 0,0.33,0.1,1 OPEN #2.SCREEN 0 33,0.66,0.1,1 OPEN #3:SCREEN 0,1,0,0 1 '-- 1st column 111111111111111111111111111111111111111111111 WINDOW #1 CLEAR SET COLOR "yellow" PRINT "RP CONTROL SOFTWARE R67" PRINT "by Cheol Lee " PRINT SET COLOR "red" PRINT "JOB LIST" PRINT "******************************" SET COLOR "white" PRINT " 0) Return to mam menu" PRINT PRINT " 1) Foam thickness" PRINT " 2) Max Cut angle " PRINT " 3) Bottom space " PRINT " 4) Top space " PRINT PRINT " 11) Mm loop gab " PRINT " 12) Pomt resolution" PRINT " 13) Skip pomts " PRINT " 14) Decimal pomt " PRINT PRINT " 21) Home" PRINT PRINT " 31) Save setup" '-- 2nd column WINDOW #2 CLEAR SET COLOR "magenta" PRINT " Manufacturing Lab " PRINT " Univ of Utah " PRINT " " BOX LINES 0,0.8,0.93,1 SET COLOR "white" !— question wmdow WINDOW #3 CLEAR SET COLOR "white" INPUT PROMPT "Select a job: ":job CLEAR END SUB t ************************ 1 Subroutine- read setup I************************ SUB read setup (name$,num_tn,dh,angle,space_t,space_b,d_loop,d_poιnt,& & xmax,yrnax,zmax,xh,yh,decιmal,skιp) ' all mput ! read setup parameters m setup. rp file ! nameS, num tπ object name number of triangles ! dh, angle : foam thickness, maximum cut angle ! space t, space b: space bw control pomt and top or bot surface ! d loop, d_poιnt : nun distance bw loops, discrete pomt distance ! x,y,zmax : object size ! xh,yh • home position m x and y direction ! decimal, skip : round decimal, number of skip pomts. OPEN #l .name "objecf\setup.rp",create newold,access outm, org record RESET #l :Begm WHEN error IN READ #1 :name$,nι_m_tπ,dh,angle,space_t,space_b,d_loop,d_poιnt READ #1 :xmax,ymax,zmax READ #l:xh,yh,decιmal,skιp USE END WHEN CLOSE #1 END SUB |************************ ! Subroutine: save setup I************************ SUB save_setup(name$,num_tri,dh,angle,space_t,space_b,d_loop,d_point,& & xmax,ymax,zmax,xh,yh,decimal,skip) ! all input ! save current setup parameters in setup.rp file ! name$, num tri : object name, number of triangles ! dh, angle : foam thickness, maximum cut angle • space t, space b: space bw control point and top or bot surface ! d loop, d_point : min distance bw loops, discrete point distance ! x,y,zmax : object size ! xh.yh : home position in x and y direction ! decimal, skip : round decimal, number of skip points. OPEN #l:name "object\setup.rp",create newold,access outm, org record ERASE #1 SET #1:RECSIZE 10 RESET #l:Begin WRITE #1 :name$,num_tn,dh,angle,space_t,space_b,d_loop,d_poιnt WRITE #l:xmax,ymax,zmax WRITE #1 :xh,yh,decimal,skip END SUB I************* ! End of File |*************

Claims: CLAHvIS What is claimed is: 1. In a rapid prototype system wherein an electronic model of an object is electronically decomposed into a first series of electronic layers, a second series of physical layers is generated from a construction material, said second series corresponding layer by layer to said first series, and a physical prototype of that object is then constructed by assembling said physical layers, the improvement which comprises: a. electronically decomposing said object into said first series of electronic layers in accordance with a paradigm characterized by a higher than zero order fit with respect to the surface of said object; and b. generating said second series of physical layers from said construction material by mechanical means constructed and arranged to operate in accordance with said paradigm. 2. An improvement according to Claim 1 wherein said paradigm has a higher order of fit than that of the vertical cylinder paradigm (VCP). 3. An improvement according to Claim 2, wherein said paradigm is selected from either the trapezoidal cylinder paradigm (TCP) or the arc cylinder paradigm (ACP). 4. An improvement according to Claim 1 , wherein said steps a and b are conducted by means controlled by software equivalent to that set forth on pages 14 through 117. 5. A rapid prototype system, comprising: electronically decomposing an electronic model of an object into a first series of electronic layers in accordance with a paradigm characterized by a higher than zero order fit with respect to the surface of said object; generating a second series of physical layers from a construction material by mechanical means constructed and arranged to operate in accordance with said paradigm, said second series corresponding layer by layer to said first series; and constructing a physical prototype of said object by assembling said physical layers. 6. A rapid prototype system according to Claim 5, wherein said mechanical means is structured and arranged to provide four degrees of freedom in positioning a cutting device with respect to sheets of said construction material. 7. A rapid prototype system according to Claim 6, wherein said mechanical means is constructed and arranged to accept and manipulate sheets of construction material 1.22 meters (four feet) wide. 8. A rapid prototype system according to Claim 6, wherein said mechanical means is operated by control means responsive to software equivalent to that set forth at pages 14 through 117. 9. A rapid prototype system according to Claim 6, wherein said mechanical means includes: a support structure, operable to move a sheet of construction material forwards and backwards along a travel path in a plane; an electronically heated wire with a first end held by a first linear positioning device and a second end held by a second linear positioning device, said first and second positioning devices being supported to position said wire transverse said plane to intersect and cut a sheet of construction material traveling on said support structure; first structure, mounting said first positioning device such that it may travel back and forth transverse said travel path; second structure, mounting said second positioning device such that it may travel independently of said first positioning device back and forth transverse said travel path; and electronic control means, responsive to operating software, for controlling the relative movements of a sheet of construction material on said support structure, said first positioning means and said second positioning means. 10. A rapid prototype system according to Claim 9, including heat control means, responsive to said operating software, constructed and arranged to adjust the temperature of said wire. 11. A rapid prototype system according to Claim 9, wherein said operating software is equivalent to that set forth at pages 14 through 117.

Inventors: GAFFNEY THOMAS M, KAZA SRINIVAS, LEE CHEOL H, THOMAS CHARLES L, GAFFNEY, THOMAS, M., KAZA, SRINIVAS, LEE, CHEOL, H., THOMAS, CHARLES, L.
Applicants: UNIV UTAH RES FOUND, UNIVERSITY OF UTAH RESEARCH FOUNDATION
Application year: 1997
Main classification: G06F19
IPC codes: B29C67, G05B19