{"size": 4417, "ext": "js", "max_stars_repo_path": "src/mago3d/geometry/VtxRingsList.js", "max_stars_repo_name": "mali151298/mago3djs", "max_stars_repo_stars_event_min_datetime": "2017-01-24T06:45:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-24T02:31:09.000Z", "max_issues_repo_path": "src/mago3d/geometry/VtxRingsList.js", "max_issues_repo_name": "jyh7a/mago3djs", "max_issues_repo_issues_event_min_datetime": "2017-01-23T08:37:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-09T09:30:19.000Z", "max_forks_repo_path": "src/mago3d/geometry/VtxRingsList.js", "max_forks_repo_name": "jyh7a/mago3djs", "max_forks_repo_forks_event_min_datetime": "2017-01-23T08:14:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T01:34:12.000Z"}
{"max_stars_count": 120, "max_issues_count": 71, "max_forks_count": 52, "avg_line_length": 18.1769547325, "max_line_length": 106, "alphanum_fraction": 0.7020602219}
'use strict';
/**
 * vertex ring list.
 * @exception {Error} Messages.CONSTRUCT_ERROR
 * 
 * @class VtxRing
 * 
 */
var VtxRingsList = function() 
{
	if (!(this instanceof VtxRingsList)) 
	{
		throw new Error(Messages.CONSTRUCT_ERROR);
	}
	/**
	 * vertex list.
	 * @type {Array.<VtxRing>}
	 */
	this.vtxRingsArray;
};

/**
 * delete all vertex and element index ranges.
 */
VtxRingsList.prototype.deleteObjects = function()
{
	if (this.vtxRingsArray !== undefined)
	{
		var vtxRingsCount = this.vtxRingsArray.length;
		for (var i=0; i<vtxRingsCount; i++)
		{
			this.vtxRingsArray[i].deleteObjects();
			this.vtxRingsArray[i] = undefined;
		}
		this.vtxRingsArray = undefined;
	}
};


/**
 * get vtxRing count.
 * @returns {Number} 
 */
VtxRingsList.prototype.getVtxRingsCount = function()
{
	if (this.vtxRingsArray === undefined)
	{ return 0; }
	
	return this.vtxRingsArray.length;
};

/**
 * get vtxRing.
 * @param {Number} idx.
 * @returns {VtxRing|undefined} 
 */
VtxRingsList.prototype.getVtxRing = function(idx)
{
	if (this.vtxRingsArray === undefined)
	{ return undefined; }
	
	return this.vtxRingsArray[idx];
};

/**
 * add new vtxRing and return.
 * @returns {IndexRange}
 */
VtxRingsList.prototype.newVtxRing = function()
{
	if (this.vtxRingsArray === undefined)
	{ this.vtxRingsArray = []; }
	
	var vtxRing = new VtxRing();
	this.vtxRingsArray.push(vtxRing);
	return vtxRing;
};

/**
 * vertex ring list copy from another vertex ring list.
 * @param {VtxRingList} vtxRingList
 */
VtxRingsList.prototype.copyFrom = function(vtxRingsList)
{
	if (vtxRingsList === undefined)
	{ return; }
	
	if (this.vtxRingsArray === undefined)
	{ this.vtxRingsArray = []; }
	
	var vtxRing;
	var vtxRingsCount = vtxRingsList.getVtxRingsCount();
	for (var i=0; i<vtxRingsCount; i++)
	{
		vtxRing = this.newVtxRing();
		vtxRing.copyFrom(vtxRingsList.getVtxRing(i));
	}
};

/**
 * vertex point translate.
 * @param {Number} x
 * @param {Number} y
 * @param {Number} z
 * @see Point3D#add
 */
VtxRingsList.prototype.translate = function(x, y, z)
{
	var vtxRingsCount = this.getVtxRingsCount();
	for (var i=0; i<vtxRingsCount; i++)
	{
		this.vtxRingsArray[i].translate(x, y, z);
	}
};

/**
 * vertex point transform by matrix4
 * @param {Matrix4} tMat4
 * @see Matrix4#transformPoint3D
 */
VtxRingsList.prototype.transformPointsByMatrix4 = function(tMat4)
{
	var vtxRingsCount = this.getVtxRingsCount();
	for (var i=0; i<vtxRingsCount; i++)
	{
		this.vtxRingsArray[i].transformPointsByMatrix4(tMat4);
	}
};

/**
 * get all vertex. 
 * @param {Array} resultVerticesArray
 * @returns {Array.<Vertex>|undefined} if this.vtxRingsArray is undefined, return resultVerticesArray.
 */
VtxRingsList.prototype.getAllVertices = function(resultVerticesArray)
{
	if (this.vtxRingsArray === undefined)
	{ return resultVerticesArray; }
	
	var vtxRingsCount = this.getVtxRingsCount();
	for (var i=0; i<vtxRingsCount; i++)
	{
		this.vtxRingsArray[i].getAllVertices(resultVerticesArray);
	}
	
	return resultVerticesArray;
};

/**
 * set vertex idx in list.
 * @deprecated Must no use. and VtxRing has no setVerticesIdxInList method.
 */
VtxRingsList.prototype.setVerticesIdxInList = function()
{
	if (this.vtxRingsArray === undefined)
	{ return; }
	
	var vtxRingsCount = this.getVtxRingsCount();
	for (var i=0; i<vtxRingsCount; i++)
	{
		this.vtxRingsArray[i].setVerticesIdxInList();
	}
};

/**
 * get vertex intersected with plane. 
 * @static
 * @param {VtxRingList} vtxRingList if vtxRingList undefined, return resultVtxRingList.
 * @param {Plane} plane. 
 * @param {Point3D} projectionDirection projectionDirection must be unitary.
 * @param {VtxRingList} resultVtxRingList Optional. if undefined, set new VtxRingList instance.
 * @returns {VtxRingList} resultVtxRingList
 */
VtxRingsList.getProjectedOntoPlane = function(vtxRingList, plane, projectionDirection, resultVtxRingList)
{
	if (vtxRingList === undefined)
	{ return resultVtxRingList; }
	
	if (resultVtxRingList === undefined)
	{ resultVtxRingList = new VtxRingsList(); }
	
	var vtxRing, projectedVtxRing;;
	var vtxRingsCount = vtxRingList.getVtxRingsCount();
	for (var i=0; i<vtxRingsCount; i++)
	{
		vtxRing = vtxRingList.getVtxRing(i);
		projectedVtxRing = resultVtxRingList.newVtxRing();
		projectedVtxRing = VtxRing.getProjectedOntoPlane(vtxRing, plane, projectionDirection, projectedVtxRing);
	}
	
	return resultVtxRingList;
};


















































