2008/10/03

graphviz , python-yapgvb

没有评论:

Graphviz是画各种流程图,网络图的软件,主页是http://www.graphviz.org/,他是AT&T Labs-Research开发的图形绘制工具, 可以很方便的用来绘制结构化的图形网络,支持多种格式输出, 生成图片的质量和速度都不错。

python-yapgvb is a python binding for Graphviz, using Boost.python.



2008/10/02

VPython

没有评论:
Vpython 是一个显示3D几何图形动画的python GTK程序。 目前py.CGAL.visual想继续把CGAL -python支持的包
bind进来(已binding的有polygon, kd-tree等)。

VPython homepage http://vpython.org/

py.CGAL.visual project
http://cgi.di.uoa.gr/~compgeom/pycgalvisual/

Installation under Ubuntu
sudo apt-get install python-visual # need gtk, boost,numpy

Example : 一个小球撞击地板的动画
(from http://vpython.org/vpythonprog.htm )

#!/usr/bin/python

from visual import *
floor = box (pos=(0,0,0), length=4, height=0.5, width=4, color=color.blue)
ball = sphere (pos=(0,4,0), radius=1, color=color.red)
ball.velocity = vector(0,-1,0)
dt = 0.01
while 1:
rate (100)
ball.pos = ball.pos + ball.velocity*dt
if ball.y < ball.radius:ball.velocity.y = -ball.velocity.y
else:ball.velocity.y = ball.velocity.y - 9.8*dt

2008/10/01

Install CGAL and CGAL-python

没有评论:
0. Prerequisites
Boost http://www.boost.org
sudo apt-get install libboost-python1.34.1
GMP http://gmplib.org/
sudo apt-get install python-gmpy # will also install libgmp3c2
MPFR http://www.mpfr.org/
(search in synaptic )
1. Install CGAL 3.3.1
sudo apt-get install libcgal2 libcgal-dev libcgal-demo
or
Goto http://www.cgal.org/cgi-bin/cgal_download.pl
./install_cgal -i

2. Install CGAL-python 0.9.3
https://gforge.inria.fr/frs/?group_id=320
follow "readme" instruction.
Homepage: http://cgal-python.gforge.inria.fr/

图简单,可以安装 0.9.1版本。http://amcg.ese.ic.ac.uk/~pfarrell/python-cgal/ 有一个python-cgal 0.9.1的deb安装包,可用


安装 python-cgal 0.9.3 (with Ubuntu 8.10, python2.5)

按readme安装后,输入
$python
>>> from CGAL.Triangulations_2 import *
出现如下错误:
Traceback (most recent call last):
File "", line 1, in
File "CGAL/__init__.py", line 3, in
from Kernel import *
ImportError: CGAL/Kernel.so: undefined symbol: _ZN4CGAL8ROTATIONE

代替make, 用Patrick Farrell写的一个安装程序 http://lists.gforge.inria.fr/pipermail/cgal-python-users/attachments/20080910/8d96239f/setup.py

Put it in your CGAL-python source directory and type:

python setup.py build
sudo python setup.py install
and it works.


---------------------------------------------------
#setup.py
from distutils.core import setup
from distutils.extension import Extension
import os
import os.path
import glob

# Author: Patrick Farrell
# patrick.farrell06@imperial.ac.uk

def MakeExtension(directory):
try:
os.stat(os.path.join("bindings", directory, "All_files_at_once.cpp"))
files = [os.path.join("bindings", directory, "All_files_at_once.cpp")]
except OSError:
files = glob.glob(os.path.join("bindings", directory, "*.cpp"))

ext = Extension(
"CGAL/%s" % directory,
files,
include_dirs=["../.."],
libraries=["CGAL", "boost_python", "gmp", "mpfr"],
define_macros=[('CGAL_DONT_USE_LAZY_KERNEL', None)]
)
return ext

directories = [directory for directory in os.listdir("bindings") if os.path.isdir(
os.path.join("bindings", directory))]
extensions = [MakeExtension(directory) for directory in directories]

setup(
name='CGAL-Python',
version='0.9',
description="Python bindings for the Computational Geometry Algorithms Libra
ry",
author = "CGAL team",
url = "http://cgal-python.gforge.inria.fr/",
packages=["CGAL"],
package_dir={"CGAL": "cgal_package/CGAL"},
ext_modules=extensions,
)

---------------------------------------------------


CGAL-Python is a collection of python modules corresponding to CGAL.
Currently CGAL-Python contains the following modules:
  • CGAL.Kernel: Point_2 , Point_3 ....
  • CGAL.Triangulations_2: Triangulation_2, Delaunay_triangulation_2, Constrained_triangulation_2 ...
  • CGAL. Triangulations_3: Triangulation_3, Delaunay_triangulation_3
  • CGAL.Mesh_2
  • CGAL. Geometric_Optimisation: Min_annulus_2, Min_annulus_3, Min_circle_2, Min_ellipse_2 , Min_sphere_2, Min_sphere_3
  • CGAL.Alpha_shapes_2(3)
  • CGAL.Polyhedron
  • CGAL.Convex_hull_2
To use CGAL as Python package you have to import the module you expect to use by typing :
from CGAL import * # this will import the whole CGAL.
from CGAL.Kernel import * # you have to import this module.

Example:
----------------------------------------------------------------------
from CGAL.Kernel import *
from CGAL.Triangulations_2 import *
from random import *
dt = Delaunay_triangulation_2()
vert = {}
for i in range(20):
vert[i] = dt.insert(Point_2(random(),random()))
# the finite vertices:
for v in dt.vertices:
print v.point()
# the finite edges
for e in dt.edges:
print e.vertex()
# the finite faces
for f in dt.faces:
for i in range(3): print f.vertex(i).point()
# compute the finite faces incident to Vertex = vert[0]
finites_faces = []
f1 = cir_faces.next()
if dt.is_infinite(f1) == False:
finites_faces.append(f1)
for f in cir_faces:
if f == f1:break

finites_faces.append(f)
---------------------------------------------------------------

Other useful packages under Ubuntu:
pyste是boost.python自带的代码生成器,利用pyste可以很方便的为c++ 的 lib加一层python的shell。pyste依赖gccxml. dependent on boost
mapnik 地图渲染引擎,其渲染的地图效果堪和googlemaps媲美. 里面的底层绘制是使用Agg库,Agg是一个高效的2D图形引擎库. python-mapnik, dependent on boost

geomview http://www.geomview.org 画二维图最好用GnuPlot,而画三维图的时候最好用geomview


----