<commit_before>// Adaptive.cpp
/*
 * Copyright (c) 2009, <NAME>, <NAME>
 * This program is released under the BSD license. See the file COPYING for
 * details.
 */

#include "stdafx.h"
#include "Adaptive.h"
#include "CNCConfig.h"
#include "ProgramCanvas.h"
#include "interface/HeeksObj.h"
#include "interface/PropertyDouble.h"
#include "interface/PropertyChoice.h"
#include "tinyxml/tinyxml.h"
#include "CuttingTool.h"
#include "Drilling.h"

#include <sstream>

int CAdaptive::number_for_stl_file = 1;


/**
 * If the cutting_tool_number is positive and relates to an existing
 * CuttingTool object then take the toolcornerrad and toolflatrad
 * from the CuttingTool object's values.
 *
 * If the reference_object_type/id refers to either a point object
 * or a Drilling object then use that object's location as this
 * operation's starting point.  If they're negative or zero then
 * use the existing default values.
 *
 * Also check the heights of the solids and set the retractzheight
 * parameter accordingly.
 */
void CAdaptiveParams::set_initial_values(
		const std::list<int> &solids, 
		const int cutting_tool_number /* = 0 */,
		const int reference_object_type, /* = -1 */ 
		const unsigned int reference_object_id, /* = -1 */
		const std::list<int> &sketches )
{
	CNCConfig config;
	config.Read(_T("m_leadoffdz"), &m_leadoffdz, 0.1);
	config.Read(_T("m_leadofflen"), &m_leadofflen, 1.1);
	config.Read(_T("m_leadoffrad"), &m_leadoffrad, 2.0);
	config.Read(_T("m_retractzheight"), &m_retractzheight, 20.0);
	config.Read(_T("m_leadoffsamplestep"), &m_leadoffsamplestep, 0.6);
	config.Read(_T("m_toolcornerrad"), &m_toolcornerrad, 3.0);
	config.Read(_T("m_toolflatrad"), &m_toolflatrad, 0.0);
	config.Read(_T("m_samplestep"), &m_samplestep, 0.4);
	config.Read(_T("m_stepdown"), &m_stepdown, 5.0);
	config.Read(_T("m_clearcuspheight"), &m_clearcuspheight, m_stepdown / 3.0);
	config.Read(_T("m_triangleweaveres"), &m_triangleweaveres, 0.51);
	config.Read(_T("m_flatradweaveres"), &m_flatradweaveres, 0.71);
	config.Read(_T("m_dchangright"), &m_dchangright, 0.17);
	config.Read(_T("m_dchangrightoncontour"), &m_dchangrightoncontour, 0.37);
	config.Read(_T("m_dchangleft"), &m_dchangleft, -0.41);
	config.Read(_T("m_dchangefreespace"), &m_dchangefreespace, -0.6);
	config.Read(_T("m_sidecutdisplch"), &m_sidecutdisplch, 0.0);
	config.Read(_T("m_fcut"), &m_fcut, 1000);
	config.Read(_T("m_fretract"), &m_fretract, 5000);
	config.Read(_T("m_thintol"), &m_thintol, 0.0001);
	config.Read(_T("m_startpoint_x"), &m_startpoint_x, 0);
	config.Read(_T("m_startpoint_y"), &m_startpoint_y, 0);
	config.Read(_T("m_startvel_x"), &m_startvel_x, 1);
	config.Read(_T("m_startvel_y"), &m_startvel_y, 1);
	config.Read(_T("m_minz"), &m_minz, -10000000.0);
	config.Read(_T("m_boundaryclear"), &m_boundaryclear, 21);
	config.Read(_T("m_boundary_x0"), &m_boundary_x0, -20);
	config.Read(_T("m_boundary_x1"), &m_boundary_x1, 20);<commit_msg>Having the sidecutdisplch with a default of zero is a bad idea.  Any small positive number will allow the algorithm to fill in the space rather than just draw roughly around the edges.  I've changed the default value to 0.3<commit_after>// Adaptive.cpp
/*
 * Copyright (c) 2009, <NAME>, <NAME>
 * This program is released under the BSD license. See the file COPYING for
 * details.
 */

#include "stdafx.h"
#include "Adaptive.h"
#include "CNCConfig.h"
#include "ProgramCanvas.h"
#include "interface/HeeksObj.h"
#include "interface/PropertyDouble.h"
#include "interface/PropertyChoice.h"
#include "tinyxml/tinyxml.h"
#include "CuttingTool.h"
#include "Drilling.h"

#include <sstream>

int CAdaptive::number_for_stl_file = 1;


/**
 * If the cutting_tool_number is positive and relates to an existing
 * CuttingTool object then take the toolcornerrad and toolflatrad
 * from the CuttingTool object's values.
 *
 * If the reference_object_type/id refers to either a point object
 * or a Drilling object then use that object's location as this
 * operation's starting point.  If they're negative or zero then
 * use the existing default values.
 *
 * Also check the heights of the solids and set the retractzheight
 * parameter accordingly.
 */
void CAdaptiveParams::set_initial_values(
		const std::list<int> &solids, 
		const int cutting_tool_number /* = 0 */,
		const int reference_object_type, /* = -1 */ 
		const unsigned int reference_object_id, /* = -1 */
		const std::list<int> &sketches )
{
	CNCConfig config;
	config.Read(_T("m_leadoffdz"), &m_leadoffdz, 0.1);
	config.Read(_T("m_leadofflen"), &m_leadofflen, 1.1);
	config.Read(_T("m_leadoffrad"), &m_leadoffrad, 2.0);
	config.Read(_T("m_retractzheight"), &m_retractzheight, 20.0);
	config.Read(_T("m_leadoffsamplestep"), &m_leadoffsamplestep, 0.6);
	config.Read(_T("m_toolcornerrad"), &m_toolcornerrad, 3.0);
	config.Read(_T("m_toolflatrad"), &m_toolflatrad, 0.0);
	config.Read(_T("m_samplestep"), &m_samplestep, 0.4);
	config.Read(_T("m_stepdown"), &m_stepdown, 5.0);
	config.Read(_T("m_clearcuspheight"), &m_clearcuspheight, m_stepdown / 3.0);
	config.Read(_T("m_triangleweaveres"), &m_triangleweaveres, 0.51);
	config.Read(_T("m_flatradweaveres"), &m_flatradweaveres, 0.71);
	config.Read(_T("m_dchangright"), &m_dchangright, 0.17);
	config.Read(_T("m_dchangrightoncontour"), &m_dchangrightoncontour, 0.37);
	config.Read(_T("m_dchangleft"), &m_dchangleft, -0.41);
	config.Read(_T("m_dchangefreespace"), &m_dchangefreespace, -0.6);
	config.Read(_T("m_sidecutdisplch"), &m_sidecutdisplch, 0.3);
	config.Read(_T("m_fcut"), &m_fcut, 1000);
	config.Read(_T("m_fretract"), &m_fretract, 5000);
	config.Read(_T("m_thintol"), &m_thintol, 0.0001);
	config.Read(_T("m_startpoint_x"), &m_startpoint_x, 0);
	config.Read(_T("m_startpoint_y"), &m_startpoint_y, 0);
	config.Read(_T("m_startvel_x"), &m_startvel_x, 1);
	config.Read(_T("m_startvel_y"), &m_startvel_y, 1);
	config.Read(_T("m_minz"), &m_minz, -10000000.0);
	config.Read(_T("m_boundaryclear"), &m_boundaryclear, 21);
	config.Read(_T("m_boundary_x0"), &m_boundary_x0, -20);
	config.Read(_T("m_boundary_x1"), &m_boundary_x1, 20);
{'fraction_non_alphanumeric': 0.15526924347538817, 'fraction_numerical': 0.028080607862570203, 'mean_word_length': 6.081871345029239, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 2, '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': '6389936', 'n_tokens_mistral': 2518, 'n_tokens_neox': 2326, 'n_words': 486}