ContourGroup: Difference between revisions

From SDK
Jump to navigation Jump to search
No edit summary
 
Line 86: Line 86:


[[  -------------- MarkContourParameterSteps ---------------------------------  |   
[[  -------------- MarkContourParameterSteps ---------------------------------  |   
|  Insert a marker at each parameter step around the contour and display the   
|  Insert a marker at each parameter step around the contour and display the   
|  distance from the start point   
|  distance from the start point   
| ]]   
| ]]   


Line 123: Line 120:


[[File:Back.jpg|right|50px|link=Creating Vectors From Script]]
[[File:Back.jpg|right|50px|link=Creating Vectors From Script]]
==References==
==References==
'''Please Note:''' The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information]
'''Please Note:''' The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information]

Latest revision as of 12:04, 30 August 2024

Back.jpg

This object is used to move along a contour a fixed distance at a time irrespective of the number of spans in the contour or the type of spans.

Constructor

ContourCarriage( Contour ctr, Point2D pt)

Creates a ‘carriage’ for the passed contour and positions it at the nearest point on the contour to the passed point.

ctr-Contour -The contour that the carriage travels along

pt-Point2D -The carriage is positioned on the contour at the closest position to this point



ContourCarriage( integer span_index, double parameter)

Creates a ‘carriage’ for a contour and set its positions for the span with the passed index at the passed parameter position (in range 0-1.0) on the span. These values are normaly specified as 0,0.0 to position the carriage at the start of the first span in the contour.

span_index-integer -Index of span, carriage will be positioned at parameter-double -Parameter along span carriage will be positioned at



e.g local cursor = ContourCarriage(0, 0.0)


Properties

.IsInvalid

R/O - bool - Returns true if current position is invalid


.SpanIndex

R/O - integer - Return span index for current position of carriage


.SpanParameter

R/O - double - Return span parameter (in range 0-1.0) for current position of carriage


Methods

:Move( Contour ctr, double distance)

Moves the carriage the requested distance along the contour. Returns true if manage to move requested distance successfully. If the contour is closed we will wrap around at the end, if it is open and you attempt to move past the end this method will return false.

ctr-Contour -The contour this carriage rides along

distance - double –The distance to move along the contour, negative values will move back towards the start


:Position( Contour ctr)

Returns a Point2D representing the current position on the carriage on the passed contour

ctr-Contour -The contour this carriage rides along


:UpdatePosition( Contour ctr, Point2D pt)

Update the position of the carriage to the nearest position on the contour to the passed point.

ctr-Contour -The contour that the carriage travels along

pt-Point2D -The carriage is positioned on the contour at the closest position to this point


Example Code

 

[[  -------------- MarkContourParameterSteps ---------------------------------   |  
|  Insert a marker at each parameter step around the contour and display the  
|  distance from the start point  
| ]]  

function MarkContourParameterSteps(num_steps, contour, layer)  
   local cursor = ContourCarriage(0, 0.0)  
   local contour_length = contour.Length    
   local step_dist = contour_length / num_steps  
   local end_index = num_steps    
   if contour.IsOpen then
     end_index = end_index + 1      
   end -- if end
   for i = 1, end_index do  
     local ctr_pos = cursor:Position(contour)  
     local marker = CadMarker("D:" .. (step_dist * (i - 1)), ctr_pos, 3)           
     layer:AddObject(marker, true)      
     cursor:Move(contour, step_dist)  
   end  -- for end
  end -- function end







Back.jpg

References

Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information