CGAL wrap for rhino-python (through ctypes) Beta

Here just 2 functions (2d alpha shape and weighted voronoi diagram) wrapping from CGAL, combining rhino script functions.

cgal_wrap.zip

your script should be in the same folder

cgal_files

How to use (2d weighted voronoi diagram, It would work on Gh-Python as well.):

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import random
import cgal_wrap as cgal

rrct = rs.GetObject()

ptlist = []
for i in range(15):
    x = random.uniform(-1000,1000)
    y = random.uniform(-1000,1000)
    rs.AddPoint([x,y,0])
    weight = random.uniform(100,200)
    pt = rg.Point3d(x,y,weight)
    ptlist.append(pt)

heightat = 2000
cells = cgal.VoronoiWeighted2DDiagram(ptlist,heightat,rrct)

How to use (2d alpha shape, It would work on Gh-Python as well.)

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import random
import cgal_wrap as cgal

ptlist = []
for i in range(20):
    x = random.uniform(-1000,1000)
    y = random.uniform(-1000,1000)
    pt = rg.Point3d(x,y,0)
    ptlist.append(pt)
    rs.AddPoint(pt)

alpha = 1000000
segs = cgal.AlphaShape2D(ptlist,alpha)

 

for developer:

here source code and project file(qmake)  cgal_wrapping_cpp

requires: visual studio 2012 express, Qt 5.2 (64bit), CGAL-4.4, gmtl, mpfr, mpir, boost-1_55_0

It is still beta version and just for testing. I appreciate for your modification, adding more effective CGAL functions.

 

Comments are closed.