<commit_before>/******************************************************************
*
*	CyberX3D for C++
*
*	Copyright (C) <NAME> 1996-2007
*
*	File:	IndexedTriangleSetNode.cpp
*
*	Revisions;
*
*	11/27/02
*		- The first revision.
*
******************************************************************/

#include <cybergarage/x3d/IndexedTriangleSetNode.h>
#include <cybergarage/x3d/Graphic3D.h>

using namespace CyberX3D;

static const char indexEventInString[] = "index";

IndexedTriangleSetNode::IndexedTriangleSetNode() 
{
	setHeaderFlag(false);
	setType(INDEXEDTRIANGLESET_NODE);

	///////////////////////////
	// Field 
	///////////////////////////

	// index  field
	indexField = new MFInt32();
	indexField->setName(indexFieldString);
	addField(indexField);

	///////////////////////////
	// EventIn
	///////////////////////////

	// index  EventIn
	set_indexField = new MFInt32();
	set_indexField->setName(indexFieldString);
	addEventIn(set_indexField);
}

IndexedTriangleSetNode::~IndexedTriangleSetNode() 
{
}

////////////////////////////////////////////////
//	List
////////////////////////////////////////////////

IndexedTriangleSetNode *IndexedTriangleSetNode::next() const
{
	return (IndexedTriangleSetNode *)Node::next(getType());
}

IndexedTriangleSetNode *IndexedTriangleSetNode::nextTraversal() const
{
	return (IndexedTriangleSetNode *)Node::nextTraversalByType(getType());
}

////////////////////////////////////////////////
// set_index
////////////////////////////////////////////////

MFInt32 *IndexedTriangleSetNode::getSetIndexField() const
{
	if (isInstanceNode() == false)
		return set_indexField;
	return (MFInt32 *)getEventIn(indexEventInString);
}

////////////////////////////////////////////////
// CoordIndex
////////////////////////////////////////////////

MFInt32 *IndexedTriangleSetNode::getIndexField() const
{
	if (isInstanceNode() == false)
		return indexField;
	return (MFInt32 *)getField(indexFieldString);
}

void IndexedTriangleSetNode::addIndex(int value) 
{
	getIndexField()->addValue(value);
}

int IndexedTriangleSetNode::getNIndexes() const
{
	return getIndexField()->getSize();
}

int IndexedTriangleSetNode::getIndex(int index) const
{
	return getIndexField()->get1Value(index);
}

void IndexedTriangleSetNode::clearIndex() 
{
	getIndexField()->clear();
}
	
////////////////////////////////////////////////
//	functions
////////////////////////////////////////////////
	
bool IndexedTriangleSetNode::isChildNodeType(Node *node) const
{
	if (node->isColorNode() || node->isCoordinateNode() || node->isNormalNode() || node->isTextureCoordinateNode())
		return true;
	else
		return false;
}

void IndexedTriangleSetNode::uninitialize() 
{
}

void IndexedTriangleSetNode::update() 
{
}

////////////////////////////////////////////////
//	Infomation
////////////////////////////////////////////////

void IndexedTriangleSetNode::outputContext(std::ostream &printStream, const char *indentString) const
{
}

////////////////////////////////////////////////
//	IndexedTriangleSetNode::initialize
////////////////////////////////////////////////

void IndexedTriangleSetNode::initialize() 
{
}

////////////////////////////////////////////////////////////
//	getNPolygons
////////////////////////////////////////////////////////////

int IndexedTriangleSetNode::getNPolygons() const
{
	CoordinateNode *coordNode = getCoordinateNodes();
	if (!coordNode)
		return 0;

	int nCoordIndexes = coordNode->getNPoints();
	int nCoordIndex = nCoordIndexes / 3;

	return nCoordIndex;
}

////////////////////////////////////////////////
//	IndexedTriangleSetNode::getVertexArray
////////////////////////////////////////////////

size_t IndexedTriangleSetNode::getNumVertexArrays()
{
	return 1;
}

void IndexedTriangleSetNode::getVertexArray(VertexArray& array, size_t id) 
{
	if (id != 0) return;

	VertexFormat format;
	format.addAttribute<float>("position", 3);
	format.addAttribute<float>("normal", 3);
	format.addAttribute<float>("texcoord", 2);
    const CoordinateNode *v_node = (CoordinateNode*)getCoordField()->getValue();
	array = VertexArray(v_node->getNPoints(), getNIndexes(), false, format);
}

////////////////////////////////////////////////
//	IndexedTriangleSetNode::getVertexData
////////////////////////////////////////////////

void IndexedTriangleSetNode::getVertexData(size_t id, void *vertex_data)
{
	if (id >= getNumVertexArrays()) {
		return;<commit_msg>Update number of polygons<commit_after>/******************************************************************
*
*	CyberX3D for C++
*
*	Copyright (C) <NAME> 1996-2007
*
*	File:	IndexedTriangleSetNode.cpp
*
*	Revisions;
*
*	11/27/02
*		- The first revision.
*
******************************************************************/

#include <cybergarage/x3d/IndexedTriangleSetNode.h>
#include <cybergarage/x3d/Graphic3D.h>

using namespace CyberX3D;

static const char indexEventInString[] = "index";

IndexedTriangleSetNode::IndexedTriangleSetNode() 
{
	setHeaderFlag(false);
	setType(INDEXEDTRIANGLESET_NODE);

	///////////////////////////
	// Field 
	///////////////////////////

	// index  field
	indexField = new MFInt32();
	indexField->setName(indexFieldString);
	addField(indexField);

	///////////////////////////
	// EventIn
	///////////////////////////

	// index  EventIn
	set_indexField = new MFInt32();
	set_indexField->setName(indexFieldString);
	addEventIn(set_indexField);
}

IndexedTriangleSetNode::~IndexedTriangleSetNode() 
{
}

////////////////////////////////////////////////
//	List
////////////////////////////////////////////////

IndexedTriangleSetNode *IndexedTriangleSetNode::next() const
{
	return (IndexedTriangleSetNode *)Node::next(getType());
}

IndexedTriangleSetNode *IndexedTriangleSetNode::nextTraversal() const
{
	return (IndexedTriangleSetNode *)Node::nextTraversalByType(getType());
}

////////////////////////////////////////////////
// set_index
////////////////////////////////////////////////

MFInt32 *IndexedTriangleSetNode::getSetIndexField() const
{
	if (isInstanceNode() == false)
		return set_indexField;
	return (MFInt32 *)getEventIn(indexEventInString);
}

////////////////////////////////////////////////
// CoordIndex
////////////////////////////////////////////////

MFInt32 *IndexedTriangleSetNode::getIndexField() const
{
	if (isInstanceNode() == false)
		return indexField;
	return (MFInt32 *)getField(indexFieldString);
}

void IndexedTriangleSetNode::addIndex(int value) 
{
	getIndexField()->addValue(value);
}

int IndexedTriangleSetNode::getNIndexes() const
{
	return getIndexField()->getSize();
}

int IndexedTriangleSetNode::getIndex(int index) const
{
	return getIndexField()->get1Value(index);
}

void IndexedTriangleSetNode::clearIndex() 
{
	getIndexField()->clear();
}
	
////////////////////////////////////////////////
//	functions
////////////////////////////////////////////////
	
bool IndexedTriangleSetNode::isChildNodeType(Node *node) const
{
	if (node->isColorNode() || node->isCoordinateNode() || node->isNormalNode() || node->isTextureCoordinateNode())
		return true;
	else
		return false;
}

void IndexedTriangleSetNode::uninitialize() 
{
}

void IndexedTriangleSetNode::update() 
{
}

////////////////////////////////////////////////
//	Infomation
////////////////////////////////////////////////

void IndexedTriangleSetNode::outputContext(std::ostream &printStream, const char *indentString) const
{
}

////////////////////////////////////////////////
//	IndexedTriangleSetNode::initialize
////////////////////////////////////////////////

void IndexedTriangleSetNode::initialize() 
{
}

////////////////////////////////////////////////////////////
//	getNPolygons
////////////////////////////////////////////////////////////

int IndexedTriangleSetNode::getNPolygons() const
{
	return getNIndexes() / 3;
}

////////////////////////////////////////////////
//	IndexedTriangleSetNode::getVertexArray
////////////////////////////////////////////////

size_t IndexedTriangleSetNode::getNumVertexArrays()
{
	return 1;
}

void IndexedTriangleSetNode::getVertexArray(VertexArray& array, size_t id) 
{
	if (id != 0) return;

	VertexFormat format;
	format.addAttribute<float>("position", 3);
	format.addAttribute<float>("normal", 3);
	format.addAttribute<float>("texcoord", 2);
    const CoordinateNode *v_node = (CoordinateNode*)getCoordField()->getValue();
	array = VertexArray(v_node->getNPoints(), getNIndexes(), false, format);
}

////////////////////////////////////////////////
//	IndexedTriangleSetNode::getVertexData
////////////////////////////////////////////////

void IndexedTriangleSetNode::getVertexData(size_t id, void *vertex_data)
{
	if (id >= getNumVertexArrays()) {
		return;
{'fraction_non_alphanumeric': 0.35691207015924303, 'fraction_numerical': 0.008885298869143781, 'mean_word_length': 1.9958520566885587, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 42, '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': '2227388', 'n_tokens_mistral': 2433, 'n_tokens_neox': 2350, 'n_words': 375}