<commit_before>/*
	This file is part of the E_MinSG library.
	Copyright (C) 2007-2012 <NAME> <<EMAIL>>
	Copyright (C) 2007-2012 <NAME> <<EMAIL>>
	Copyright (C) 2007-2012 <NAME> <<EMAIL>>
	
	This library is subject to the terms of the Mozilla Public License, v. 2.0.
	You should have received a copy of the MPL along with this library; see the 
	file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "E_TreeBuilder.h"

#include "../../Core/Nodes/E_ListNode.h"
#include "../../Core/Nodes/E_GroupNode.h"



#include <E_Util/E_Utils.h>

#include <MinSG/Ext/TreeBuilder/TreeBuilder.h>

#include <Util/Macros.h>
#include <Util/GenericAttribute.h>

using namespace EScript;

namespace E_MinSG {

void E_TreeBuilder::init(EScript::Namespace & globals) {

	Namespace * lib=new Namespace();
	/** Provides functions for reorganizing the data structure of scene graphs.
	* Example:
	* ```js
	* MinSG.TreeBuilder.rebuildAsOcTree(scene, {
	* 	MinSG.TreeBuilder.MAX_TREE_DEPTH: 10,
	* 	MinSG.TreeBuilder.MAX_CHILD_COUNT: 8,
	* 	MinSG.TreeBuilder.LOOSE_FACTOR: 2,
	* 	MinSG.TreeBuilder.PREFERE_CUBES: true,
	* 	MinSG.TreeBuilder.USE_GEOMETRY_BB: false,
	* 	MinSG.TreeBuilder.EXACT_CUBES: true,
	* });
	* ```
	*/
	declareConstant(&globals,"TreeBuilder",lib);

	//! Boolean. If set, the bounding box is expanded to a cube/square before splitting (quadtree, octree). Don't forget to disable `use geometry bounding boxes´.
	declareConstant(lib, "EXACT_CUBES", String::create(MinSG::TreeBuilder::EXACT_CUBES));
	//! Number. The scale factor for boxes when inserting nodes. If you don't want a loose tree, set this value to one.
	declareConstant(lib, "LOOSE_FACTOR", String::create(MinSG::TreeBuilder::LOOSE_FACTOR));
	//! Number. The maximum number of nodes stored in leaves. Leaves with more nodes will be split up as long as the maximum depth is not reached.
	declareConstant(lib, "MAX_CHILD_COUNT", String::create(MinSG::TreeBuilder::MAX_CHILD_COUNT));
	//! Number. The maximum depth of the created tree. Leaves in depth >= maximum will not be split.
	declareConstant(lib, "MAX_TREE_DEPTH", String::create(MinSG::TreeBuilder::MAX_TREE_DEPTH));
	//! Boolean. If set, bounding boxes will not always split in all dimensions (quadtree, octree, kd-tree).
	//! If the ratio between maximum and minimum extent of the bounding box gets greater than squareroot of two, only the large dimensions are split.
	declareConstant(lib, "PREFERE_CUBES", String::create(MinSG::TreeBuilder::PREFERE_CUBES));
	//! Boolean. If set, bounding boxes of the geometry instead of those of the previous step are used for splitting (quadtree, octree, binary tree, kd-tree).
	declareConstant(lib, "USE_GEOMETRY_BB", String::create(MinSG::TreeBuilder::USE_GEOMETRY_BB));
	
	//! [ESF] void MinSG.rebuildAsBinaryTree(MinSG.GroupNode node, Map options)
	//! Builds a binary tree by splitting allways the largest dimension.
	ES_FUNCTION(lib, "rebuildAsBinaryTree", 2, 2, {
			MinSG::GroupNode * root = parameter[0].to<MinSG::GroupNode*>(rt);
			EScript::Map * emap = parameter[1].to<EScript::Map*>(rt);
			Util::GenericAttributeMap * map = dynamic_cast<Util::GenericAttributeMap *>(E_Util::E_Utils::convertEScriptObjectToGenericAttribute(emap));
			if(!map){
				WARN("rebuildAsBinaryTree: second parameter has to be a map");<commit_msg>use @code tags in comment<commit_after>/*
	This file is part of the E_MinSG library.
	Copyright (C) 2007-2012 <NAME> <<EMAIL>>
	Copyright (C) 2007-2012 <NAME> <<EMAIL>>
	Copyright (C) 2007-2012 <NAME> <<EMAIL>>
	
	This library is subject to the terms of the Mozilla Public License, v. 2.0.
	You should have received a copy of the MPL along with this library; see the 
	file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "E_TreeBuilder.h"

#include "../../Core/Nodes/E_ListNode.h"
#include "../../Core/Nodes/E_GroupNode.h"



#include <E_Util/E_Utils.h>

#include <MinSG/Ext/TreeBuilder/TreeBuilder.h>

#include <Util/Macros.h>
#include <Util/GenericAttribute.h>

using namespace EScript;

namespace E_MinSG {

void E_TreeBuilder::init(EScript::Namespace & globals) {

	Namespace * lib=new Namespace();
	/** Provides functions for reorganizing the data structure of scene graphs.
	* Example:
	* @code{.escript}
	* MinSG.TreeBuilder.rebuildAsOcTree(scene, {
	* 	MinSG.TreeBuilder.MAX_TREE_DEPTH: 10,
	* 	MinSG.TreeBuilder.MAX_CHILD_COUNT: 8,
	* 	MinSG.TreeBuilder.LOOSE_FACTOR: 2,
	* 	MinSG.TreeBuilder.PREFERE_CUBES: true,
	* 	MinSG.TreeBuilder.USE_GEOMETRY_BB: false,
	* 	MinSG.TreeBuilder.EXACT_CUBES: true,
	* });
	* @endcode
	*/
	declareConstant(&globals,"TreeBuilder",lib);

	//! Boolean. If set, the bounding box is expanded to a cube/square before splitting (quadtree, octree). Don't forget to disable `use geometry bounding boxes´.
	declareConstant(lib, "EXACT_CUBES", String::create(MinSG::TreeBuilder::EXACT_CUBES));
	//! Number. The scale factor for boxes when inserting nodes. If you don't want a loose tree, set this value to one.
	declareConstant(lib, "LOOSE_FACTOR", String::create(MinSG::TreeBuilder::LOOSE_FACTOR));
	//! Number. The maximum number of nodes stored in leaves. Leaves with more nodes will be split up as long as the maximum depth is not reached.
	declareConstant(lib, "MAX_CHILD_COUNT", String::create(MinSG::TreeBuilder::MAX_CHILD_COUNT));
	//! Number. The maximum depth of the created tree. Leaves in depth >= maximum will not be split.
	declareConstant(lib, "MAX_TREE_DEPTH", String::create(MinSG::TreeBuilder::MAX_TREE_DEPTH));
	//! Boolean. If set, bounding boxes will not always split in all dimensions (quadtree, octree, kd-tree).
	//! If the ratio between maximum and minimum extent of the bounding box gets greater than squareroot of two, only the large dimensions are split.
	declareConstant(lib, "PREFERE_CUBES", String::create(MinSG::TreeBuilder::PREFERE_CUBES));
	//! Boolean. If set, bounding boxes of the geometry instead of those of the previous step are used for splitting (quadtree, octree, binary tree, kd-tree).
	declareConstant(lib, "USE_GEOMETRY_BB", String::create(MinSG::TreeBuilder::USE_GEOMETRY_BB));
	
	//! [ESF] void MinSG.rebuildAsBinaryTree(MinSG.GroupNode node, Map options)
	//! Builds a binary tree by splitting allways the largest dimension.
	ES_FUNCTION(lib, "rebuildAsBinaryTree", 2, 2, {
			MinSG::GroupNode * root = parameter[0].to<MinSG::GroupNode*>(rt);
			EScript::Map * emap = parameter[1].to<EScript::Map*>(rt);
			Util::GenericAttributeMap * map = dynamic_cast<Util::GenericAttributeMap *>(E_Util::E_Utils::convertEScriptObjectToGenericAttribute(emap));
			if(!map){
				WARN("rebuildAsBinaryTree: second parameter has to be a map");
{'fraction_non_alphanumeric': 0.12438035150968905, 'fraction_numerical': 0.010815682739972961, 'mean_word_length': 5.119485294117647, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, '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': '5504248', 'n_tokens_mistral': 2313, 'n_tokens_neox': 2161, 'n_words': 644}