from viennagrid.wrapper import TriangularCartesian2D_Domain as Domain
from viennagrid.wrapper import TriangularCartesian2D_Segmentation as Segmentation
from viennagrid.wrapper import PointCartesian2D as Point

from viennagrid.wrapper import TriangularCartesian2D_Cell_Accessor as CellAccessor
from viennagrid.wrapper import surface

from viennagrid.wrapper import read_vtk, write_vtk

# Create an empty domain
domain = Domain()

# Add vertices to the domain. These vertices will then be used to define
# cells.
domain.make_vertex(Point(0, 0)) # Vertex with ID #0
domain.make_vertex(Point(1, 0)) # Vertex with ID #1
domain.make_vertex(Point(2, 0)) # Vertex with ID #2
domain.make_vertex(Point(2, 1)) # Vertex with ID #3
domain.make_vertex(Point(1, 1)) # Vertex with ID #4
domain.make_vertex(Point(0, 1)) # Vertex with ID #5

# Create a segmentation of the domain
segmentation = Segmentation(domain)

# Create 2 segments in the segmentation of the domain
seg0 = segmentation.make_segment()
seg1 = segmentation.make_segment()

# Create 2 cells in the first segment. Since the domain is a triangular domain,
# cells are triangles and three vertices must be specified to create a cell.
from viennagrid.wrapper import volume

####################################
# Domain setup
####################################

domain = Domain()

p0 = Point(0, 0)
p1 = Point(1, 0)
p2 = Point(2, 0)
p3 = Point(2, 1)
p4 = Point(1, 1)
p5 = Point(0, 1)

domain.make_vertex(p0) # Vertex with ID #0
domain.make_vertex(p1) # Vertex with ID #1
domain.make_vertex(p2) # Vertex with ID #2
domain.make_vertex(p3) # Vertex with ID #3
domain.make_vertex(p4) # Vertex with ID #4
domain.make_vertex(p5) # Vertex with ID #5

segmentation = Segmentation(domain)

seg0 = segmentation.make_segment()
seg1 = segmentation.make_segment()

cell_00 = seg0.make_cell(domain.get_vertex(0), domain.get_vertex(1), domain.get_vertex(5))
cell_01 = seg0.make_cell(domain.get_vertex(1), domain.get_vertex(4), domain.get_vertex(5))

cell_10 = seg1.make_cell(domain.get_vertex(1), domain.get_vertex(2), domain.get_vertex(4))