Skip to content

Instantly share code, notes, and snippets.

@Rogach
Rogach / Declutter.scala
Created August 5, 2013 16:33
Phase for Slick, that unboxes wrapped tables
package scala.slick.compiler
import scala.slick.ast._
import scala.collection.mutable.HashMap
class Declutter extends Phase {
val name = "declutter"
def apply(tree: Node, state: CompilationState): Node = {
val replaced = new HashMap[Symbol, Symbol]

Example table definitions & query:

case class House(id: Long, address: String)
case class Metro(id: Long, houseId: Long, name: String)
case class Room(id: Long, houseId: Long, area: Int)

object Houses extends Table[House]("Houses") {
  def id = column[Long]("id", O.AutoInc, O.PrimaryKey)
  def address = column[String]("address")
@Rogach
Rogach / Declutter.scala
Created August 5, 2013 17:04
Phase for Slick, that unboxes wrapped tables
package scala.slick.compiler
import scala.slick.ast._
import scala.collection.mutable.HashMap
class Declutter extends Phase {
val name = "declutter"
def apply(tree: Node, state: CompilationState): Node = {
val replaced = new HashMap[Symbol, Symbol]
@Rogach
Rogach / ShowTree.scala
Created September 10, 2013 04:30
Macro to display case class hierarchy as Swing JTree.
package dxf.macros
import scala.language.experimental.macros
import scala.reflect.macros.Context
import scala.swing._
import scala.swing.Swing._
import javax.swing._
import javax.swing.tree.DefaultMutableTreeNode
object ShowTree {
@Rogach
Rogach / ShowTree.scala
Created September 12, 2013 06:41
Macro to display case class hierarchy as Swing JTree. (now uses quasiquotes)
package dxf.macros
import scala.language.experimental.macros
import scala.reflect.macros.Context
import scala.swing._
import scala.swing.Swing._
import javax.swing._
import javax.swing.tree.DefaultMutableTreeNode
object ShowTree {
ovd::VoronoiDiagram* vd = new ovd::VoronoiDiagram(1,100);
ovd::Point p0(-0.2567719874411157,-0.4983049800651602);
ovd::Point p1(0.12205285479992212,-0.640371712930281);
ovd::Point p2(-0.25972854724944455,-0.5143879072702902);
ovd::Point p3(-0.34168692840153536,-0.6418861147966213);
ovd::Point p4(-0.5288215108461576,0.18480346369654843);
ovd::Point p5(-0.35263585687204546,-0.50735692278175);
ovd::Point p6(-0.4821854389417177,0.46463421861462373);
ovd::VoronoiDiagram* vd = new ovd::VoronoiDiagram(1,100);
ovd::Point p0(-0.2567719874411157,-0.4983049800651602);
ovd::Point p1(0.12205285479992212,-0.640371712930281);
ovd::Point p2(-0.25972854724944455,-0.5143879072702902);
ovd::Point p3(-0.34168692840153536,-0.6418861147966213);
ovd::Point p4(-0.5288215108461576,0.18480346369654843);
ovd::Point p5(-0.35263585687204546,-0.50735692278175);
ovd::Point p6(-0.4821854389417177,0.46463421861462373);
package org.rogach.jopenvoronoi;
import java.io.*;
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.Color;
// random polygon generator
// uses space partitioning algorithm, described here: http://www.geometrylab.de/applet-29-en#space
public class RandomPolygon {
12.02-335-gaa6b701
find_seed_vertex on f=0
Face 0: 0(2)-f0-7(2)-f0-1(0)-f0-2(0)-f0-8(2)-f0-
0 h= -2.72236 dist=3apex=(0.159074, -0.227556)
7 queued (h=-1.31573 )
8 queued (h=-1.09637 )
9 queued (h=-0.842597 )
7 marked IN (in_circle) ( -1.31573 )
8 marked IN (in_circle) ( -1.09637 )
9 marked IN (in_circle) ( -0.842597 )
#include <string>
#include <iostream>
#include <openvoronoi/medial_axis_filter.hpp>
#include <openvoronoi/medial_axis_walk.hpp>
#include <openvoronoi/voronoidiagram.hpp>
#include <openvoronoi/polygon_interior_filter.hpp>
#include <openvoronoi/utility/vd2svg.hpp>
#include <openvoronoi/version.hpp>