<commit_before>// This file is part of the Shapy project.
// Licensing information can be found in the LICENSE file.
// (C) 2015 The Shapy Team. All rights reserved.
goog.provide('shapy.editor.Face');

goog.require('goog.vec.Mat4');
goog.require('goog.vec.Vec2');
goog.require('goog.vec.Vec3');
goog.require('shapy.editor.Editable');
goog.require('shapy.editor.geom');



/**
 * Face of an object.
 *
 * @constructor
 * @extends {shapy.editor.Editable}
 *
 * @param {!shapy.editor.Object} object
 * @param {number}               id
 * @param {number}               e0
 * @param {number}               e1
 * @param {number}               e2
 * @param {number}               opt_ue0
 * @param {number}               opt_ue1
 * @param {number}               opt_ue2
 */
shapy.editor.Face = function(
    object, id,
    e0, e1, e2,
    opt_ue0, opt_ue1, opt_ue2)
{
  shapy.editor.Editable.call(this, shapy.editor.Editable.Type.FACE);

  /** @public {!shapy.editor.Object} @const */
  this.object = object;
  /** @public {!number} @const */
  this.id = parseInt(id);
  /** @public {number} @const */
  this.e0 = parseInt(e0);
  /** @public {number} @const */
  this.e1 = parseInt(e1);
  /** @public {number} @const */
  this.e2 = parseInt(e2);
  /** @public {number} @const */
  this.ue0 = opt_ue0 || 0;
  /** @public {number} @const */
  this.ue1 = opt_ue1 || 0;
  /** @public {number} @const */
  this.ue2 = opt_ue2 || 0;
};
goog.inherits(shapy.editor.Face, shapy.editor.Editable);


/**
 * Retrieves the edges forming a face.
 *
 * @return {!Array<!shapy.editor.Edge>}
 */
shapy.editor.Face.prototype.getEdges = function() {
  return [
    this.object.edges[this.e0 >= 0 ? this.e0 : -this.e0],
    this.object.edges[this.e1 >= 0 ? this.e1 : -this.e1],
    this.object.edges[this.e2 >= 0 ? this.e2 : -this.e2]
  ];
};


/**
 * Retrives the vertices forming a face.
 *
 * @return {!Array<!shapy.editor.Vertex>}
 */
shapy.editor.Face.prototype.getVertices = function() {
  var e = this.getEdges();
  return [
    this.object.verts[this.e0 >= 0 ? e[0].v0 : e[0].v1],
    this.object.verts[this.e1 >= 0 ? e[1].v0 : e[1].v1],
    this.object.verts[this.e2 >= 0 ? e[2].v0 : e[2].v1],
  ];
};


/**
 * Retrives the vertices forming a face.
 *
 * @return {!Array<!shapy.editor.Vertex>}
 */
shapy.editor.Face.prototype.getUVEdges = function() {
  var e = this.getEdges();
  return [
    this.object.uvEdges[this.ue0 >= 0 ? this.ue0 : -this.ue0],
    this.object.uvEdges[this.ue1 >= 0 ? this.ue1 : -this.ue1],
    this.object.uvEdges[this.ue2 >= 0 ? this.ue2 : -this.ue2],
  ];
};



/**
 * Retrives the uv.
 *
 * @return {!Array<!shapy.editor.Vertex>}
 */
shapy.editor.Face.prototype.getUVs = function() {
  var e = this.getUVEdges();
  return [
    this.object.uvPoints[this.ue0 >= 0 ? e[0].uv0 : e[0].uv1],
    this.object.uvPoints[this.ue1 >= 0 ? e[1].uv0 : e[1].uv1],
    this.object.uvPoints[this.ue2 >= 0 ? e[2].uv0 : e[2].uv1],
  ];
};


/**
 * Retrieves the object edited.
 *
 * @return {shapy.editor.Object}
 */
shapy.editor.Face.prototype.getObject = function() {
  return this.object;
};


/**
 * Retrives the positions of vertices forming a face.
 *<commit_msg>Fixed extrude null pointer deref.<commit_after>// This file is part of the Shapy project.
// Licensing information can be found in the LICENSE file.
// (C) 2015 The Shapy Team. All rights reserved.
goog.provide('shapy.editor.Face');

goog.require('goog.vec.Mat4');
goog.require('goog.vec.Vec2');
goog.require('goog.vec.Vec3');
goog.require('shapy.editor.Editable');
goog.require('shapy.editor.geom');



/**
 * Face of an object.
 *
 * @constructor
 * @extends {shapy.editor.Editable}
 *
 * @param {!shapy.editor.Object} object
 * @param {number}               id
 * @param {number}               e0
 * @param {number}               e1
 * @param {number}               e2
 * @param {number}               opt_ue0
 * @param {number}               opt_ue1
 * @param {number}               opt_ue2
 */
shapy.editor.Face = function(
    object, id,
    e0, e1, e2,
    opt_ue0, opt_ue1, opt_ue2)
{
  shapy.editor.Editable.call(this, shapy.editor.Editable.Type.FACE);

  /** @public {!shapy.editor.Object} @const */
  this.object = object;
  /** @public {!number} @const */
  this.id = parseInt(id);
  /** @public {number} @const */
  this.e0 = parseInt(e0);
  /** @public {number} @const */
  this.e1 = parseInt(e1);
  /** @public {number} @const */
  this.e2 = parseInt(e2);
  /** @public {number} @const */
  this.ue0 = opt_ue0 || 0;
  /** @public {number} @const */
  this.ue1 = opt_ue1 || 0;
  /** @public {number} @const */
  this.ue2 = opt_ue2 || 0;
};
goog.inherits(shapy.editor.Face, shapy.editor.Editable);


/**
 * Retrieves the edges forming a face.
 *
 * @return {!Array<!shapy.editor.Edge>}
 */
shapy.editor.Face.prototype.getEdges = function() {
  return [
    this.object.edges[this.e0 >= 0 ? this.e0 : -this.e0],
    this.object.edges[this.e1 >= 0 ? this.e1 : -this.e1],
    this.object.edges[this.e2 >= 0 ? this.e2 : -this.e2]
  ];
};


/**
 * Retrives the vertices forming a face.
 *
 * @return {!Array<!shapy.editor.Vertex>}
 */
shapy.editor.Face.prototype.getVertices = function() {
  var e = this.getEdges();
  return [
    this.object.verts[this.e0 >= 0 ? e[0].v0 : e[0].v1],
    this.object.verts[this.e1 >= 0 ? e[1].v0 : e[1].v1],
    this.object.verts[this.e2 >= 0 ? e[2].v0 : e[2].v1],
  ];
};


/**
 * Retrives the vertices forming a face.
 *
 * @return {!Array<!shapy.editor.Vertex>}
 */
shapy.editor.Face.prototype.getUVEdges = function() {
  var e = this.getEdges();
  return [
    this.object.uvEdges[this.ue0 >= 0 ? this.ue0 : -this.ue0],
    this.object.uvEdges[this.ue1 >= 0 ? this.ue1 : -this.ue1],
    this.object.uvEdges[this.ue2 >= 0 ? this.ue2 : -this.ue2],
  ];
};



/**
 * Retrives the uv.
 *
 * @return {!Array<!shapy.editor.Vertex>}
 */
shapy.editor.Face.prototype.getUVs = function() {
  if (!this.ue0 || !this.ue1 || !this.ue2) {
    return [];
  }
  var e = this.getUVEdges();
  return [
    this.object.uvPoints[this.ue0 >= 0 ? e[0].uv0 : e[0].uv1],
    this.object.uvPoints[this.ue1 >= 0 ? e[1].uv0 : e[1].uv1],
    this.object.uvPoints[this.ue2 >= 0 ? e[2].uv0 : e[2].uv1],
  ];
};


/**
 * Retrieves the object edited.
 *
 * @return {shapy.editor.Object}
 */
shapy.editor.Face.prototype.getObject = function() {
  return this.object;
};


/**
 * Retrives the positions of vertices forming a face.
 *
{'fraction_non_alphanumeric': 0.19257178526841448, 'fraction_numerical': 0.02980649188514357, 'mean_word_length': 2.781120943952802, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, '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': '7534017', 'n_tokens_mistral': 2552, 'n_tokens_neox': 2507, 'n_words': 481}