CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 21, 2017, 07:32:30 am


Login with username, password and session length


Pages: [1] 2 3 4
  Print  
Author Topic: Voronoi Generator  (Read 11041 times)
billt
Droid
**
Offline Offline

Posts: 90


View Profile
« 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:
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


* Voronoi Star.JPG (37.14 KB, 569x505 - viewed 263 times.)
* Voronoi.zip (44.17 KB - downloaded 203 times.)
Logged
macbob
Storm Trooper
***
Offline Offline

Posts: 178



View Profile WWW
« Reply #1 on: October 30, 2015, 22:16:38 pm »

Whoosh!  Amazing stuff.  I am looking forward to giving this a try!

Bob
Logged
speedjf37
CNC Ewok
*
Offline Offline

Posts: 4


View Profile
« Reply #2 on: November 15, 2015, 07:43:25 am »

Hi,

Just insert pattern  hexa to make  honeycomb

Do you create plug-in ?



JF

* voronoi_generator _jf.zip (2.61 KB - downloaded 103 times.)
Logged
GeoffreyGRoy
Storm Trooper
***
Offline Offline

Posts: 120


View Profile
« 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)

* Veronoi Builder Plugin Examples.pdf (507.3 KB - downloaded 143 times.)
* VoronoiBuilder-V1.0.6.zip (868.82 KB - downloaded 95 times.)
« Last Edit: January 06, 2016, 07:06:56 am by GeoffreyGRoy » Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4565



View Profile WWW
« 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
Logged
GeoffreyGRoy
Storm Trooper
***
Offline Offline

Posts: 120


View Profile
« 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
Logged
speedjf37
CNC Ewok
*
Offline Offline

Posts: 4


View Profile
« 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

* Voronoi.zip (16.65 KB - downloaded 63 times.)
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4565



View Profile WWW
« 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
Logged
GeoffreyGRoy
Storm Trooper
***
Offline Offline

Posts: 120


View Profile
« 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

* VoronoiBuilder-V1.0.3.zip (870.11 KB - downloaded 71 times.)
Logged
speedjf37
CNC Ewok
*
Offline Offline

Posts: 4


View Profile
« 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 » Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4565



View Profile WWW
« 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 » Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4565



View Profile WWW
« Reply #11 on: December 20, 2015, 19:00:48 pm »

Re

added to the Web page

http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/VoronoiGenerator.html

++
David
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3037



View Profile
« 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
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4565



View Profile WWW
« Reply #13 on: December 20, 2015, 21:24:21 pm »

Hello

Just tested on Linux, it work for the file path

++
David
Logged
GeoffreyGRoy
Storm Trooper
***
Offline Offline

Posts: 120


View Profile
« 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
Logged
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.169 seconds with 18 queries.

Copyright © 2008 HexRay Ltd. | Sitemap