from dilap.geometry.vec3 import vec3
from dilap.geometry.pointset import pointset

#import dilap.topology.meshes.trimesh as tmsh
import dilap.topology.trimesh as tmsh

#import dilap.mesh.tools as dtl
import dilap.core.plotting as dtl
import matplotlib.pyplot as plt

import unittest,numpy,math

import pdb

#python3 -m unittest discover -v ./ "*tests.py"

class test_trimesh(unittest.TestCase):

    def plotmesh(self):
        mesh = self.mesh
        ax = dtl.plot_axes()
        for f in mesh.faces:
            pxs = (mesh.verts[vx][0] for vx in f)
            ps = self.pset.gps(pxs)
            ax = dtl.plot_polygon(ps,ax)
        plt.show()

    def avert(self,p):
        px = self.pset.ap(p)
        nx = self.nset.ap(vec3(0,0,1))
        ux = self.uset.ap(vec3(0,0,0))
        return self.mesh.avert(px,nx,ux)

    def assert_counts(self,vcnt,ecnt,fcnt):
        self.assertEqual(self.mesh.vcnt(),vcnt)
        self.assertEqual(self.mesh.ecnt(),ecnt)
        self.assertEqual(self.mesh.fcnt(),fcnt)

    def quad(self):
        self.v1 = self.avert(vec3(-1,-1,-1))
        self.v2 = self.avert(vec3( 1,-1,-1))