<commit_before>package collada

import (
	"errors"
)

type Vertex struct {
	X float64
	Y float64
	Z float64
}

type Mesh struct {
	// Contains vertices which you can use to draw triangles. At this point no
	// tristrips or trifans are implemented.
	// TODO Implement tristrips and trifans
	// TODO Normals
	Vertices []Vertex
	Id       string
	Name     string
}

func newMesh(m *MeshData, id, name string) (*Mesh, error) {
	if m.Triangles == nil {
		return nil, errors.New("Mesh is not triangulated")
	}

	return nil, errors.New("Not implemented")
}

func (m *MeshData) triangles() ([]Vertex, error) {
	vertices, _ := m.vertices()
	primitives, err := m.Triangles.primitives()
	if err != nil {
		return nil, err
	}

	vertOffset := m.Triangles.semantic("VERTEX")
	retval := make([]Vertex, 0)
	baseIndex := 0
	stride := len(m.Triangles.Inputs)
	for count := 0; count < m.Triangles.Count; count++ {
		// There should always be valid amount of indices, crash and burn if
		// there isn't

		// Fetch right vertex with index from primitives array.
		vertex := vertices[primitives[baseIndex+vertOffset]]
		retval = append(retval, vertex)
		baseIndex += stride
	}

	return retval, nil
}

// Apply SourceData.Accessor to SourceData.FloatArray to get vertices.
func (m *MeshData) vertices() ([]Vertex, error) {
	var err error<commit_msg>Handle missed error in MeshData.triangles()<commit_after>package collada

import (
	"errors"
)

type Vertex struct {
	X float64
	Y float64
	Z float64
}

type Mesh struct {
	// Contains vertices which you can use to draw triangles. At this point no
	// tristrips or trifans are implemented.
	// TODO Implement tristrips and trifans
	// TODO Normals
	Vertices []Vertex
	Id       string
	Name     string
}

func newMesh(m *MeshData, id, name string) (*Mesh, error) {
	if m.Triangles == nil {
		return nil, errors.New("Mesh is not triangulated")
	}

	return nil, errors.New("Not implemented")
}

func (m *MeshData) triangles() ([]Vertex, error) {
	var err error

	vertices, err := m.vertices()
	if err != nil {
		return nil, err
	}

	primitives, err := m.Triangles.primitives()
	if err != nil {
		return nil, err
	}

	vertOffset := m.Triangles.semantic("VERTEX")
	retval := make([]Vertex, 0)
	baseIndex := 0
	stride := len(m.Triangles.Inputs)
	for count := 0; count < m.Triangles.Count; count++ {
		// There should always be valid amount of indices, crash and burn if
		// there isn't

		// Fetch right vertex with index from primitives array.
		vertex := vertices[primitives[baseIndex+vertOffset]]
		retval = append(retval, vertex)
		baseIndex += stride
	}

	return retval, nil
}

// Apply SourceData.Accessor to SourceData.FloatArray to get vertices.
func (m *MeshData) vertices() ([]Vertex, error) {
	var err error
{'fraction_non_alphanumeric': 0.1153705732018985, 'fraction_numerical': 0.0065717415115005475, 'mean_word_length': 3.6519524617996604, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2909105', 'n_tokens_mistral': 945, 'n_tokens_neox': 895, 'n_words': 309}