/*
Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*---------------------- Pro/Toolkit Includes ------------------------*/
#include <ProToolkit.h>
#include <ProSelection.h>
#include <ProGeomitem.h>
#include <ProUtil.h>
#include <UtilMath.h>
#include <ProSurface.h>
/*---------------------- Application Includes ------------------------*/
#include <TestError.h>
/*---------------------- Function Prototypes -------------------------*/
ProError UserConeAngDisp();
/*============================================================================*\
Function: UserConeAngDisp()
Purpose: Display Angle of Selected Cone
\*============================================================================*/
ProError UserConeAngDisp()
{
int sel_count;
double angle;
ProError status;
ProModelitem p_mdl_item;
ProFileName msgfile;
ProGeomitemdata *geom_data=NULL;
ProSurface surface;
ProSrftype surface_type;
ProSelection *psels=NULL;
/*----------------------------------------------------------------------------*\
Prompt user for selection of cone
\*----------------------------------------------------------------------------*/
ProStringToWstring(msgfile,"msg_uggeom.txt");
status = ProMessageDisplay(msgfile,"USER Select Cone to Evaluate:");
ERROR_CHECK( "UserConeAngDisp", "ProMessageDisplay(Select Cone)", status );
if((ProSelect("surface",1,NULL,NULL,NULL,NULL,&psels, &sel_count) !=
PRO_TK_NO_ERROR) || (sel_count < 1))
return((int)PRO_TK_GENERAL_ERROR);
status = ProSelectionModelitemGet(psels[0],&p_mdl_item);
ERROR_CHECK( "UserConeAngDisp", "ProSelectionModelitemGet", status );
status = ProGeomitemToSurface(&p_mdl_item,&surface);
ERROR_CHECK( "UserConeAngDisp","ProGeomitemToSurface",status);
status = ProSurfaceTypeGet(surface,&surface_type);
ERROR_CHECK( "UserConeAngDisp","ProSurfaceTypeGet",status);
if(surface_type != PRO_SRF_CONE)
{
ProMessageDisplay(msgfile,"USER Surface selected is not a Cone");
ERROR_CHECK( "UserConeAngDisp","ProMessageDisplay(Surface selected is not)",status);
return((int)PRO_TK_GENERAL_ERROR);
}
status = ProGeomitemdataGet(&p_mdl_item,&geom_data);
ERROR_CHECK( "UserConeAngDisp","ProGeomitemdataGet",status);
angle = fabs(geom_data->data.p_surface_data->srf_shape.cone.alpha*180.0/PI);
status = ProMessageDisplay(msgfile,"USER Cone angle is %0f",&angle);
ERROR_CHECK( "UserConeAngDisp","ProMessageDisplay(Cone angle is)",status);
status = ProGeomitemdataFree(&geom_data);
ERROR_CHECK( "UserConeAngDisp","ProGeomitemdataFree",status);
return(status);
}