<commit_before>package surface

import (
	"fmt"

	"github.com/vladimir-ch/dcel"
)

// Point is a point in 3D Euclidean space.
type Point [3]float64

// Vertex is a DCEL node with a position in 3D space.
type Vertex struct {
	dcel.BaseNode
	Point Point
}

// Mesh is a triangle mesh in 3D space.
type Mesh struct {
	dcel.Graph
}

// NewMesh returns a new Mesh.
func NewMesh() *Mesh {
	return &Mesh{
		Graph: *dcel.New(items{}),
	}
}

// AddVertex adds a new vertex with the given id located at p to the mesh.
func (m *Mesh) AddVertex(id int, p Point) {
	u := m.AddNode(id).(*Vertex)
	u.Point = p
}

// Vertex returns a vertex with the given id or nil if such vertex does not
// exist in the mesh.
func (m *Mesh) Vertex(id int) *Vertex {
	u := m.Node(id)
	if u == nil {
		return nil
	}
	return u.(*Vertex)
}

// AddFace adds a new triangle face with the given id and vertices to the mesh.
// If such face cannot be added, it returns a non-nil error.
// It panics if a face with the same id already exists in the mesh.
func (m *Mesh) AddFace(id int, n1, n2, n3 *Vertex) error {
	if m.Graph.HasFace(id) {
		panic(fmt.Sprintf("surface: face ID collision: %d", id))
	}
	return m.Graph.AddFace(id, n1, n2, n3)
}

type items struct {<commit_msg>AddVertex() and AddFace() do not take an ID<commit_after>package surface

import "github.com/vladimir-ch/dcel"

// Point is a point in 3D Euclidean space.
type Point [3]float64

// Vertex is a DCEL node with a position in 3D space.
type Vertex struct {
	dcel.BaseNode
	Point Point
}

// Mesh is a triangle mesh in 3D space.
type Mesh struct {
	dcel.Graph
}

// NewMesh returns a new Mesh.
func NewMesh() *Mesh {
	return &Mesh{
		Graph: *dcel.New(items{}),
	}
}

// AddVertex adds a new vertex located at p to the mesh.
func (m *Mesh) AddVertex(p Point) *Vertex {
	u := m.AddNode(m.NewNodeID()).(*Vertex)
	u.Point = p
	return u
}

// Vertex returns a vertex with the given id or nil if such vertex does not
// exist in the mesh.
func (m *Mesh) Vertex(id int) *Vertex {
	u := m.Node(id)
	if u == nil {
		return nil
	}
	return u.(*Vertex)
}

// AddFace adds a new triangle face with the given vertices to the mesh.
// If such face cannot be added, it returns a non-nil error.
func (m *Mesh) AddFace(n1, n2, n3 *Vertex) error {
	return m.Graph.AddFace(m.NewFaceID(), n1, n2, n3)
}

type items struct {
{'fraction_non_alphanumeric': 0.11696658097686376, 'fraction_numerical': 0.010282776349614395, 'mean_word_length': 3.2224231464737794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2661332', 'n_tokens_mistral': 867, 'n_tokens_neox': 844, 'n_words': 345}