Example #1
0
def commandStellate():
	figures=objFigure.fromGfFigure(gf.figureGet())
	if figureInfo:
		name,desc=figureInfo.getNameDesc()
	figures=[stellateFigure(f) for f in figures]
	if name:
		name="Stellated " + name
	desc=None
	gf.figureOpen(objFigure.toGfFigure(figures), True)
	if figureInfo:
		figureInfo.setNameDescPath(name, desc)
Example #2
0
def commandCreateDual():
	figures=objFigure.fromGfFigure(gf.figureGet())
	for f in figures:
		if not check.isFigureConvex(f):
			raise RuntimeError("The figure is not convex")
	if figureInfo:
		name, desc = figureInfo.getNameDesc()
	figures=[createDual(f) for f in figures]
	gf.figureOpen(objFigure.toGfFigure(figures), True)
	if figureInfo:
		figureInfo.setNameDescPath("Dual of " + name, None)
def commandCreateDual():
	figures=objFigure.fromGfFigure(gf.figureGet())
	for f in figures:
		if not check.isFigureConvex(f):
			raise RuntimeError("The figure is not convex")
	if figureInfo:
		name, desc = figureInfo.getNameDesc()
	figures=[createDual(f) for f in figures]
	gf.figureOpen(objFigure.toGfFigure(figures), True)
	if figureInfo:
		figureInfo.setNameDescPath("Dual of " + name, None)
Example #4
0
def commandCutOff(lastCoordinate=0):
	gfFigure=gf.figureGet()
	if gfFigure:
		gfFigure[0]=[gf.posRotate(p) for p in gfFigure[0]]
	figures=objFigure.fromGfFigure(gfFigure)
	if not figures:
		raise RuntimeError("Nothing opened")
	dim=figures[0].spaceDim
	hyperplane=algebra.Hyperplane((0,)*(dim-1)+(1,), lastCoordinate)
	newFigures=[]
	for f in figures:
		newFigures.extend(cutFigure(f, hyperplane)[0])
	gfFigure=objFigure.toGfFigure(newFigures)
	if gfFigure:
		gfFigure[0]=[gf.posRotateBack(p) for p in gfFigure[0]]
	if figureInfo:
		name, desc=figureInfo.getNameDesc()
	gf.figureOpen(gfFigure, True)
	if figureInfo:
		figureInfo.setNameDescPath("Truncated "+name, None)
Example #5
0
def commandCutFigure(lastCoordinate=0):
	gfFigure=gf.figureGet()
	gfFigure[0]=[gf.posRotate(p) for p in gfFigure[0]]
	figures=objFigure.fromGfFigure(gfFigure)
	if not figures:
		raise RuntimeError("Nothing opened")
	dim=figures[0].spaceDim
	if dim<=0:
		raise RuntimeError("The figure cannot be cut")
	hyperplane=algebra.Hyperplane((0,)*(dim-1)+(1,), lastCoordinate)
	newFigures=[]
	for f in figures:
		newFigures.extend(cutFigure(f, hyperplane)[1])
	gfFigure=objFigure.toGfFigure(newFigures)
	if gfFigure:
		gfFigure[0]=[p[:-1] for p in gfFigure[0]]
		del gfFigure[dim]
	if figureInfo:
		name, desc=figureInfo.getNameDesc()
	gf.figureOpen(gfFigure)
	if figureInfo:
		figureInfo.setNameDescPath("Cross-section of "+name, None)
Example #6
0
def commandCutFaces(dim=2, ratio=0.1):
	if ratio>=1 or ratio<=0:
		raise RuntimeError("Wrong ratio")
	figures=objFigure.fromGfFigure(gf.figureGet())
	for f in figures:
		if not check.isFigureConvex(f):
			raise RuntimeError("The figure is not convex")
	if figureInfo:
		name, desc = figureInfo.getNameDesc()
	figures2=[]
	for f in figures:
		figures2.extend(cutOffFacesDim(f, ratio, dim))
	gf.figureOpen(objFigure.toGfFigure(figures2), True)
	gf.clear()
	if dim==0:
		name = name + " with vertices cut off"
	elif dim==1:
		name = name + " with edges cut off"
	else:
		name = name + " with " + str(dim) + "-faces cut off"

	if figureInfo:
		figureInfo.setNameDescPath(name, None)