/*
	Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/

#include <ProToolkit.h>
#include <ProSolid.h>

/*====================================================================*\
FUNCTION: UserSolidFullRegenerate()
PURPOSE:  Fully regenerates the indicated model - 
					prompt for fix model on failure
\*====================================================================*/
ProError UserSolidFullRegenerate (ProSolid solid, ProBoolean allow_fix)
{
	ProError status;

	int regeneration_flags = PRO_REGEN_FORCE_REGEN;

/*--------------------------------------------------------------------*\
	Add the "Can fix" flag to the regeneration options
\*--------------------------------------------------------------------*/
	if (allow_fix)
		regeneration_flags |= PRO_REGEN_ALLOW_CONFIRM;

	status = ProSolidRegenerate (solid, regeneration_flags);

	return PRO_TK_NO_ERROR;
}

/*====================================================================*\
FUNCTION: UserFullRegenerate()
PURPOSE:  Fully regenerates the current model - allow fix model on failure
\*====================================================================*/
ProError UserFullRegenerate ()
{
	ProError status;
	ProMdl model;
	ProMdlType type;

	status = ProMdlCurrentGet (&model);
	if (status != PRO_TK_NO_ERROR)
		return PRO_TK_GENERAL_ERROR;

	status = ProMdlTypeGet (model, &type);

	if (type != PRO_MDL_PART && type != PRO_MDL_ASSEMBLY)
		return PRO_TK_GENERAL_ERROR;

	UserSolidFullRegenerate (model, PRO_B_TRUE);

	return PRO_TK_NO_ERROR;
}