[Plugin] Voronoi - Convex Hull

[Plugin] Voronoi - Convex Hull

Postby a4chitect » Sun Mar 16, 2008 10:24 am

see attached jpg for instructions

original topic with more images

thanks:
to the creators of the Qhull program (calculates voronoi, convex hull,...) http://www.qhull.org/
to this community and all people involved in sketchup/ruby/forums
licence: your only duty is to share any improvements and/or upgrades of this code under this same condition

notes:

All file locations are inside your Sketchup\Plugins\Qhull directory
All plugins can be found in sketchup under toolbar menu Plugins\Qhull

Points were created with the qhull\pointify plugin
-it converts all vertices of the selection into construction points

to construct Voronoi (or convex Hull) select the points (you don't have to worry about
different geometry in the selection set, the plugin filters out points only)
-all points are selected, you have to write them to a file for the qhull engine to process them
this can be done by pressing qhull\export cpoints

once exported, you can start the Voronoi buildup by running
qhull\voronoi
-please note that this always takes your your most recently exported cpoints
-nothing has to be selected for the construction to start

debugging:
-one error can occur while exporting points, to check this process just delete points.txt file in the qhull directory and run the qhull\export cpoints plugin
then open the newly created points.txt file and if it is not blank, all went ok
-second possible problem is that the qhull engine is unable to process your geometry (out of mathematical reasons) just check if a results file gets generated in the
qhull directory: qvoronoi.txt (of course delete any previous qvoronoi.txt before)
-the third possibility is that the constructing script cannot process the results into geometry, this is the place to let me know

when you keep getting a previous result instead of the current one, try to delete the qhull\qvoronoi.txt file manually

PLUGIN SPECIFIC
Voronoi: -sometimes result is easier for qhull to compute when you export the bounding box along with the cpoints
-i couldn't get the engine to export lines reaching infinity, so you will not get these right now
Convex hull: -when you don't want to get a simple 'box', don't export the bounding box along with cpoints

windows only
but is very easily portable for a mac - feel free to do so, you can find the mac version of qhull here: http://qhull.darwinports.com/
1
Last edited by Rich O Brien on Fri Mar 29, 2013 4:10 pm, edited 3 times in total.
Reason: Just cleaning up and organizing the Plugin forum. Adding [Plugin] tag

a4chitect 
PluginStore Author
PluginStore Author
 

Re: reRELEASE: Voronoi, Convex Hull

Postby tolieolson » Tue May 06, 2008 6:24 pm

Hi. I love the concept of the plugin. Problem is that it won't work even after I've tried deleting the old point file and creating a new one.

The details of what I'm doing:
I create a box.
Draw lines connecting sides in a random fashion, about 9 lines.
Pointify.
Export cpoints.
Click on voronoi, and all that happens is a flash of a dialog box in the corner of my screen that looks like DOS. No shape emerges.

Perhaps there is a bug that I ran into. Any tips?
0

tolieolson 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby AcesHigh » Thu May 08, 2008 3:43 am

I must be sincere about my dumbness. I dont understand what exactly this plugin does and what uses could it have.

Any example of what type of modelling is made easier by the plugin?
0

AcesHigh 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby kwistenbiebel » Thu May 08, 2008 8:49 am

I have the same issue as AcesHigh.

It seems to be a very useful thing for a lot of people but I never understood what it does and how to get the preliminary geometry (curved 3Dlines ?) in place before using the plugin.

The lingo used (Voronoi?) sounds like chinese to me. :D
0

kwistenbiebel 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby pav_3j » Thu May 08, 2008 10:03 am

ditto

pav
0
Just won the 'Who is Least Competitive Championships' where trying to win will make you lose. Trying to lose makes you win which makes you lose. Not trying at all makes you lose which makes you win which makes you lose.

pav_3j 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby remus » Thu May 08, 2008 8:19 pm

Well i'll add my bit here. My understanding of vornoir (or convex hull) is that its the sort of shape youd get if you draped a cloth over a shape. Apparently its useful for physics simulations, i tihnk sketchyphysics uses them for some shapes.

Im sure if you do a google search on it youll get lots of info.
0

remus 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby a4chitect » Thu May 08, 2008 8:51 pm

I can't help further at the moment, but please check the link mentioned in the first post (directing to the original thread) for pictures and explanations

voronoi is a system of subdividing space - in a special way, so that each element gets enclosed in a cell while each wall is equally far from both points

convex hull is like remus said a little like wrapping your points in a stiff cloth (because it covers all concave inserts) hence the name: convex hull

script is not a normal ruby script because the whole calculation is done outside of sketchup (the already mentioned dos command prompt) in a program called qhull. I managed to tweak the script to run almost always at my pc, it is far from clean and reliable. I have posted all the possible steps to make it run, and can only wish you luck at the moment. :thumb:
0

a4chitect 
PluginStore Author
PluginStore Author
 

Re: reRELEASE: Voronoi, Convex Hull

Postby a4chitect » Fri May 09, 2008 8:46 pm

this is a little modified version, it has probably the same bugs and unreliable performance, but maybe it will work for you
0

a4chitect 
PluginStore Author
PluginStore Author
 

Re: reRELEASE: Voronoi, Convex Hull

Postby halroach » Mon Jun 23, 2008 12:27 pm

tolieolson wrote:Hi. I love the concept of the plugin. Problem is that it won't work even after I've tried deleting the old point file and creating a new one.

The details of what I'm doing:
I create a box.
Draw lines connecting sides in a random fashion, about 9 lines.
Pointify.
Export cpoints.
Click on voronoi, and all that happens is a flash of a dialog box in the corner of my screen that looks like DOS. No shape emerges.

Perhaps there is a bug that I ran into. Any tips?


Hi, I'm running into the same problem. Have you found a solution?
0
User avatar
halroach 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby halroach » Mon Jun 23, 2008 12:50 pm

I'm getting the same problem as tolieolson's

"I create a box.
Draw lines connecting sides in a random fashion, about 9 lines.
Pointify.
Export cpoints.
Click on voronoi, and all that happens is a flash of a dialog box in the corner of my screen that looks like DOS. No shape emerges."

In the Ruby Console I get the folloing error:

Code: Select all
Error: #<Errno::ENOENT: No such file or directory - C:/Program Files/Google/Google SketchUp 6/Plugins\qhull\qvoronoi.txt>
C:/Program Files/Google/Google SketchUp 6/Plugins/voronoi.rb:14:in `initialize'
C:/Program Files/Google/Google SketchUp 6/Plugins/voronoi.rb:14:in `new'
C:/Program Files/Google/Google SketchUp 6/Plugins/voronoi.rb:14:in `mesh'
C:/Program Files/Google/Google SketchUp 6/Plugins/tooling/voronoi.rb:138
C:/Program Files/Google/Google SketchUp 6/Plugins/tooling/voronoi.rb:138:in `call'


suggestions?
Thanks!
0
User avatar
halroach 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby sawamura » Wed Jul 30, 2008 11:38 pm

I have the same problem of Halroach.

this plugin works on sketchup 6?

i can make the points.txt file by using the extract Cpoints tool, but when i click in voronoi, nothing happends.
0

sawamura 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby zhuangsuph » Tue Aug 05, 2008 7:46 am

this is a little modified version, it has probably the same bugs and unreliable performance, but maybe it will work for you
0

zhuangsuph 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby Z_stern » Sat Sep 13, 2008 11:34 am

I have exactly same problem with this plugin. Points are exported correctly, but "voronoi" command brings no result (and I see same errors in ruby console as user harloch had).
Sketchup Pro 6.4.112, Win XP HE.
0

Z_stern 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby cyin6 » Sun Sep 14, 2008 3:01 pm

I have some problems with export_points.rb
Error: #<NoMethodError: undefined method `triangulate' for Qexport:Class>
where is the triangulate def called on line 89?
0

cyin6 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby mcdermottadrian » Mon Nov 24, 2008 4:30 am

Hi,

I'm having the same issues with this plugin; can generate a points file, but neither the convex hull nor voronoi does anything (just a flash of the command prompt window).

Amazing potential... if it worked. Has anyone figured this one out?
0

mcdermottadrian 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby Color_Man » Fri Mar 20, 2009 3:57 pm

There are a large number of significant errors in the command structures in these scripts. the cpoints script hangs most of the time and never gets past writing the first line, unless you respond YES to adding the bounding box.
0

Color_Man 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby andrew1184 » Wed Apr 08, 2009 11:01 pm

Anyone figured out what the deal is with these scripts? I've been trying to figure out how to write a voronoi script for Sketchup for quite a while now and every time I start looking for information the only information I find is this thread with a link to a script that doesn't work at all.
0

andrew1184 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby craigbic » Wed Apr 29, 2009 6:16 pm

I can get Convex Hull to work using this procedure:

    1) Create points based on whatever geometry using Plugins>Qhull>Pointify
    2) Export points (to points.txt file) using Plugins>Qhull>Export CPoints
    3) Use a Windows Command Prompt to run the command "qhull.exe TI points.txt o TO qhull.txt" inside the Plugins\Qhull directory which generates the required qhull.txt file.
    4) Back in SU, run Plugins>Qhull>Convex Hull, which does generate the convex hull - at least for me at work using SU6

However, even when I create the required qvoronoi.txt file from exported points (have tried with and without bounding box included) via the command prompt command "qhull.exe TI points.txt v Qbb o TO qvoronoi.txt" and I go back into SU and run Plugins>Qhull>Voronoi - nothing happens except a quick flash of the command prompt window. This is really frustrating :twisted: since I really have a need to create voronoi-based architecture for a project and i don't want to have to go to Rhino.

Has ANYONE had any luck with this at all?
0
Checkout the Sketchup Graphics Blog at http://sketchupgraphics.com

craigbic 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby harnstein » Sun May 03, 2009 1:19 pm

following craig's footprints i came to the same result. no a very usable way to create qhull, but works.

how did you get to the information, that you can write "qhull.exe TI points.txt v Qbb o TO qvoronoi.txt" ?


this is real research...like going around in the woods eating everything just to find something tasty...
0
still sketchin'

harnstein 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby craigbic » Mon May 04, 2009 1:01 pm

harnstein wrote:how did you get to the information, that you can write "qhull.exe TI points.txt v Qbb o TO qvoronoi.txt" ?


I got that from the qhull.exe documentation from qhull.org. If you open up a command window to the qhull directory in the plugins folder of SU and type "qhull" it will bring up a list of all the little options you can add such as "Qbb" etc... Qhull is working and that's nice but what I really wanted was voronoi to work. I really hope someone takes up the mantle and get this working. I tried for hours, modifying the script and couldn't get it to function (not that I know much about Ruby mind you).

Perhaps what we'll need to do is to export the c-points and then run voronoi.exe to qvoronoi.txt and then run THATfile through MatLab or Mathematica to spit out a model.
0
Checkout the Sketchup Graphics Blog at http://sketchupgraphics.com

craigbic 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby craigbic » Tue May 05, 2009 7:29 pm

I managed to figure out a way of generating 3D voronoi objects from SU geometry but it is FAR from automatic and doesn't involve SU as much as you would think/like. First you will need to download and install Python. Second download an unzip somewhere this collection of Python scripts specifically for creating 3D meshes from voronoi diagrams - voronoi3d.zip (The following has worked for me in SU6:

    1)First create a cloud of points - you can either use the Qhull program rbox.exe (i.e. command prompt & type "rbox.exe 1000" for a cloud of a 1000 points) or you can use the Plugins>Qhull>Pointify and then Export C-Points to generate a point cloud from your selected SU geometry.

    2)Next use a text editor like Notepad to edit the points.txt file. The first line will be something like "3 129" The first number is always 3 (I believe this is how many dimensions the file has 2 for 2d, 3 for 3d but don't quote me) and the second number is the amount of points in the cloud.

    3)Change this line to "3 rbox 129" (i.e. insert "rbox" in between these two numbers.)

    4)Hit the enter button to create a new line below this one and then type the number of points again (i.e. 129).

    5)Save the file.

    6)Next open a command prompt to the SU>Plugins>Qhull directory and type or paste the following completely including the word "type" - "type points.txt|qvoronoi p Fv >out.txt", which will generate a voronoi diagram to a file called "out.txt".

    7)Next copy both the points.txt and out.txt files to the directory where you unzipped the voronoi3d.zip file containing the handy Python scripts.

    8)Double-click on the manifold3d.py Python script (from voronoi3d.zip), which will open a command window.

    9)Wait for this to complete ( this can take a minute or two) and you should have a Wavefront obj file called obj.obj.

    10)Use MeshLab to convert to 3ds or use the obj import plugin for SU from Jim Foltz to bring the 3D voronoi mesh into SU.

So that was what I had to do to generate a 3D Voronoi model from a point cloud in SU. Whewwww! :knockout: I have attached a couple of pics showing the results from generating a random point cloud from rbox.exe (the one with the greenish/greyish Google Earth-like background) and the other pic showing a 3D Voronoi model generated from a point cloud made from the Pointify plugin run on lines generated from running the lsystem plugin on a straight line (i.e. create a tree, select tree, click Plugins>Qhull>Pointify). Both 3D Voronoi meshes were given a quick treatment with transparent faces and Didier's lines2Tubes plugin just to make them interesting.

Perhaps based on this - maybe a Ruby-Master could create new or modify the existing scripts to work properly.
0
Checkout the Sketchup Graphics Blog at http://sketchupgraphics.com

craigbic 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby harnstein » Fri May 08, 2009 7:37 pm

thanks for the good reply!

my internet-service has been down for ONE WEEK- imagine that!!! still rrrrrr...!

just getting bits of my connection, i have to wait again till monday- i try to use your guide then and join this thread again!

greetings, harnstein

..and a nice weekend ;)
0
still sketchin'

harnstein 
 

Re: reRELEASE: Voronoi, Convex Hull

Postby craigbic » Sat May 09, 2009 6:24 am

harnstein wrote:thanks for the good reply!

my internet-service has been down for ONE WEEK- imagine that!!! still rrrrrr...!

just getting bits of my connection, i have to wait again till monday- i try to use your guide then and join this thread again!

greetings, harnstein

..and a nice weekend ;)


Hey, no problem. Glad I had something offer. I hope you can at least get to the point I have been able to but I'm REALLY hoping someone will come along and integrate the qhull.exe and voronoi.exe programs better in SU and make the whole process self-contained. We'll see.

Let me know how things go.
0
Checkout the Sketchup Graphics Blog at http://sketchupgraphics.com

craigbic 
 

Re: [Plugin] reRELEASE: Voronoi, Convex Hull

Postby btxscg » Sat Oct 29, 2011 7:19 am

verygood ineed it thanks
0

btxscg 
 

Re: [Plugin] Voronoi - Convex Hull

Postby Sl!m » Mon Feb 10, 2014 12:29 pm

Hi there,

when I launch qhull/voronoi, the DOS box that appears for half a second says (thanks to my exceptional reflexes into pressing the printscreen button):

qhull error: could not open file "qhull\points.txt".
while executing : | qhull TI qhull\points.txt v Qbb Qj o Fv TO qhull\qvoronoi.txt
Options selected for Qhull 2003.1 2033/12/30:


my points.txt was properly generated before. Any idea ?

Thanks
0

Sl!m 
Premium Member
Premium Member
 

Re: [Plugin] Voronoi - Convex Hull

Postby mitcorb » Mon Feb 10, 2014 1:44 pm

Are you not able to see anything if you have the Ruby Console open?
0
I take the slow, deliberate approach in my aimless wandering.
User avatar
mitcorb 
Top SketchUcator
 

Re: [Plugin] Voronoi - Convex Hull

Postby DareDevil » Mon Feb 10, 2014 5:54 pm

It's a security problem.
The plugin must write the points.txt in the qhull directory, but it's in programfile directory and the plug have'nt the autorization to write there... So Qhull can't read the file because don't exist !

2 solutions :
- give full autorization to the Qhull directory (bad thing but works)
- change the place to the qhull directory and modify the .rb to point it (I don't try...)
0
User avatar
DareDevil 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: Jick, nlipovac and 15 guests

Visit our sponsors: