Author Topic: Voronoi Generator  (Read 41963 times)

Offline billt

  • Droid
  • **
  • Posts: 90
    • View Profile
Voronoi Generator
« on: October 30, 2015, 20:43:46 pm »
This script generates a random Voronoi (or Delaunay) pattern and automatically trims it to the selected polylines or regions.
It was originally inspired by MacBob's Voronoi Table Lamp:
http://www.cambam.co.uk/forum/index.php?topic=3954.msg26519#msg26519

Several user variables are available to change the appearance of the output:
Code: [Select]
VType = "V"  #Options are V="Voronoi Diagram" or D="Delaunay Triangulation"
RandomType = "Grid"  #Options are "Random" or "Grid"
DiagramType = "Thick"  #Options are "Line" or "Thick"

##For RandomType = "Random"
PointDensity = .1  #number of points per unit area

##For RandomType = "Grid"
GridSpacing = 4  #distance between grid seed points
Wildness = .7   #Measure of variation from grid seed points, 1.0 = Grid Spacing

##For DiagramType = "Thick"
VoronoiOffset = 0.2  #offset amount from voronoi lines, thickness is then 2X VoronoiOffset
SourceOffset = 0.5  #offset from border which contains the voronoi patterns

MacBob's concepts incorporated into this script:
 * Rectangular grid of seed points with a certain amount of "wildness".
 * Thickness value for the lines to create a stained glass window effect.

Select your bounding pattern before running the script.
Also make sure to combine polylines into Regions if you want to exclude interior islands.

The attached zip includes the script (voronoi_generator 4-5-15.py) and all of the necessary imports.  The imported function is Steven Fortune's Sweepline Algorithm converted to Python by Bill Simons.  Stay tuned, I am working on converting this to a plugin and will post here when it is complete.

Cheers - BillT

Offline macbob

  • Storm Trooper
  • ***
  • Posts: 189
    • View Profile
    • Bob Mackay
Re: Voronoi Generator
« Reply #1 on: October 30, 2015, 22:16:38 pm »
Whoosh!  Amazing stuff.  I am looking forward to giving this a try!

Bob

Offline speedjf37

  • Ewok
  • *
  • Posts: 4
    • View Profile
Re: Voronoi Generator
« Reply #2 on: November 15, 2015, 07:43:25 am »
Hi,

Just insert pattern  hexa to make  honeycomb

Do you create plug-in ?



JF

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 270
    • View Profile
Re: Voronoi Generator
« Reply #3 on: December 18, 2015, 08:06:55 am »
Dear BillT and Others

Here is the first release of my Voronoi Builder plugin for CamBam.  I have been inspired by your efforts and others (especially MacBob) who have shown an interest in this form of modelling and the creation of interesting objects using Voronoi shapes.

The plugin will create Voronio shapes in variously shaped bounding shapes, and with some options for defining seed points for various  effects.  I have used a number of the features in BillTs script as well as two third party C# libraries for some of the background work.

This first version (v1.0.2) also includes options to create 2.5D surface models/textures using the Voronoi cells as a starting point.

I would welcome comments and feedback, and, of course, notification of any bugs etc.

Geoff

PS I have attached here the latest version (1.0.6)
« Last Edit: January 06, 2016, 07:06:56 am by GeoffreyGRoy »

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Voronoi Generator
« Reply #4 on: December 18, 2015, 20:46:44 pm »
Hello,

Very nice !! some hours to explore it !!  thanks.

A suggestion ; if you can add something to cancel calculation (both for voronoi and picture calculation).

Also it could be fine to have the honeycomb pattern as in JF addendum (or maybe it is already here and I don't know how to set it ?)

++
David

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 270
    • View Profile
Re: Voronoi Generator
« Reply #5 on: December 19, 2015, 08:38:08 am »
Dear David

The facility to cancel the computation will appear in the next release.

Could you please explain what you mean by "the honeycomb pattern as in JF addendum", I do not understand what you mean.

thanks for the feedback

Geoff

Offline speedjf37

  • Ewok
  • *
  • Posts: 4
    • View Profile
Re: Voronoi Generator
« Reply #6 on: December 19, 2015, 08:58:32 am »
Hi ,

Your plug-in is better mine !

My plug-in is so bugged .

Can you give a link from the lib in use ?


JF

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Voronoi Generator
« Reply #7 on: December 19, 2015, 15:28:34 pm »

Could you please explain what you mean by "the honeycomb pattern as in JF addendum", I do not understand what you mean.


Hello,

Like on this picture.
http://www.usinages.com/threads/voronoi-generator.81154/#post-916649


Ah ! another thing ; in your code, don't translate the the menu item ; if you translate it, it appears 2 times in the translation list (this plugin, the squircle plugin and texture builder)

http://www.atelier-des-fougeres.fr/Cambam/Aide/API%20Doc/Cambam_cad_dll/Cambam_Utils/textTranslation.html

++
David

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 270
    • View Profile
Re: Voronoi Generator
« Reply #8 on: December 20, 2015, 06:39:57 am »
Dear David & JF

Thanks for the feed back and corrections, I am attaching v1.0.3:
(1) Hexagonal shapes added, the previously named "Hexagonal" shapes is now correctly named "Triangular" shapes)
(2) Can now cancel execution
(3) Corrected (no) translation of menu item (David: thanks for pointing this out I had not realised this before)
(4) a number of minor bug fixes and UI changes.
(5) Updated User Guide

I know that I have not yet added translations to the combo items, if this is necessary I will try to figure out how to best do it.

thanks again

Geoff

Offline speedjf37

  • Ewok
  • *
  • Posts: 4
    • View Profile
Re: Voronoi Generator
« Reply #9 on: December 20, 2015, 09:15:26 am »
hello,

new version is better but you don't  refresh design after compute veronoi


try this:

      CamBamUI.MainUI.ActiveView.ZoomToFit();

     this.GeometryView.RefreshView();


Can you share your source ?

thanks JF
« Last Edit: December 20, 2015, 09:47:30 am by speedjf37 »

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Voronoi Generator
« Reply #10 on: December 20, 2015, 16:44:34 pm »
Hello,

Quote
I know that I have not yet added translations to the combo items, if this is necessary I will try to figure out how to best do it.

Currently, I don't know how to do ... and I don't know if we can translate the "string collection" if it was created in the form designer ... maybe each item must be translated and added to the string collection by the program .. ? .. not sure.

Can you add the Undo management ?


edit: some inconsistence with the save file format for the image.

If I choose png, file name is xxx.jpg and the file format seems to be JPEG

If I choose jpg file name is xxx.bmp and the file format seems to be PNG

If I choose tiff file name is xxx (without extension) and the file format seems to be PNG

++
David
« Last Edit: December 20, 2015, 17:06:11 pm by dh42 »

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Voronoi Generator
« Reply #11 on: December 20, 2015, 19:00:48 pm »

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Voronoi Generator
« Reply #12 on: December 20, 2015, 21:12:43 pm »
Does the file path work with Linux ? I had to change the Wrapper code to make it work, if you look at the source code for Wrapper, it's in there.

http://www.cambam.co.uk/forum/index.php?topic=4388.msg41778#msg41778
Filmed in Supermarionation

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Voronoi Generator
« Reply #13 on: December 20, 2015, 21:24:21 pm »
Hello

Just tested on Linux, it work for the file path

++
David

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 270
    • View Profile
Re: Voronoi Generator
« Reply #14 on: December 21, 2015, 00:11:50 am »
Thanks for feedback:

David: I will fix the image format issue.  On the undo issue, I should be able to undo the entities created in the new layer, but I have not been able to do this successfully, do you have any suggestions?

JF: I will refresh the view as suggested.

As soon as the basic bugs are sorted I will publish the source.

Geoff