Ejemplo n.º 1
0
	ProError BatchPlot::ReadDirectory(wchar_t *w_directory, wchar_t *w_filter, std::vector<Model> &list)
	{
		ProError	status;
		ProPath		*w_file_names;
		ProPath		*w_directories;
		int			n_count;

		status = ProArrayAlloc(0, sizeof(ProPath), 1,(ProArray*)&w_file_names);
		status = ProArrayAlloc(0, sizeof(ProPath), 1,(ProArray*)&w_directories);
		status = ProFilesList(w_directory, w_filter, PRO_FILE_LIST_LATEST_SORTED,  &w_file_names, &w_directories);
		status = ProArraySizeGet(w_file_names, &n_count);
		for(int i=0; i<n_count; i++)
		{
			Model m(w_file_names[i]);
			list.push_back(m);
		}

		status = ProArraySizeGet(w_directories, &n_count);
		for(int i=0; i<n_count; i++)
		{
			status = BatchPlot::ReadDirectory(w_directories[i], w_filter, list);
		}

		ProArrayFree((ProArray *) &w_file_names);
		ProArrayFree((ProArray *) &w_directories);

		return PRO_TK_NO_ERROR;
	}
Ejemplo n.º 2
0
	ProError BatchPlot::GetDiskItems(wchar_t *w_directory, bool recursive, std::vector<Gui::Model> &list)
	{
		ProError	status;
		ProLine		w_filter;
		ProPath		*w_file_names;
		ProPath		*w_directories;
		int			n_count;

		if (_waccess(w_directory, 00) == -1)
		{
			Mirim::MsgBox::Show(L"PMP", L"Select valid folder");
			return PRO_TK_NO_ERROR;
		}

		status = BatchPlot::GetFileFilter(true, true, w_filter);
		if (status != PRO_TK_NO_ERROR)
		{
			Mirim::MsgBox::Show(L"PMP", L"Select file type");
			return status;
		}

		status = ProArrayAlloc(0, sizeof(ProPath), 1,(ProArray*)&w_file_names);
		status = ProArrayAlloc(0, sizeof(ProPath), 1,(ProArray*)&w_directories);
		status = ProFilesList(w_directory, w_filter, PRO_FILE_LIST_LATEST_SORTED,  &w_file_names, &w_directories);
		status = ProArraySizeGet(w_file_names, &n_count);
		for(int i=0; i<n_count; i++)
		{
			Model m(w_file_names[i]);
			list.push_back(m);
		}

		if (!recursive) return PRO_TK_NO_ERROR;

		status = ProArraySizeGet(w_directories, &n_count);
		for(int i=0; i<n_count; i++)
		{
			status = BatchPlot::ReadDirectory(w_directories[i], w_filter, list);
		}

		ProArrayFree((ProArray *) &w_file_names);
		ProArrayFree((ProArray *) &w_directories);

		return PRO_TK_NO_ERROR;
	}
Ejemplo n.º 3
0
// 得到相接的边
ProEdge CSDMdlMachLongAxisCheck::GetCloseEdge(const ProPoint3d pt, ProContourdata *pContourArr)
{
    if (NULL == m_pCurSld)
        return NULL;
    if (pContourArr == NULL)
        return NULL;

    int nCounterSize = -1;
    ProArraySizeGet(pContourArr, &nCounterSize);
    int nEdgeSize = -1;
    ProEdge pEdge = NULL, pRetEdge = NULL;
    ProEnttype entType;
    ProError status = PRO_TK_GENERAL_ERROR;
    ProGeomitemdata *pEdgeData = NULL;
    for (int i=0; i<nCounterSize; i++)
    {
        ProContourdata &contour = pContourArr[i];
        ProArraySizeGet(contour.edge_id_arr, &nEdgeSize);
        for (int j=0; j<nEdgeSize; j++)
        {
            status = ProEdgeInit(m_pCurSld, contour.edge_id_arr[j], &pEdge);
            if (status != PRO_TK_NO_ERROR || pEdge == NULL)
                continue;

            ProEdgeTypeGet(pEdge, &entType);
            if (entType != PRO_ENT_ARC)
                continue;
            ProEdgeDataGet(pEdge, &pEdgeData);
            if (IsPntCoincide(pEdgeData->data.p_curve_data->arc.origin, pt))
                pRetEdge = pEdge;
            ProGeomitemdataFree(&pEdgeData);
            if (pRetEdge != NULL)
                break;
        }
        if (pRetEdge != NULL)
            break;
    }

    return pRetEdge;
}
Ejemplo n.º 4
0
/*============================================================================*\
 Function:	ProUtilMenuStringsFree
 Purpose:       Free memory allocated by ..Alloc, ..StrAdd, ..WstrAdd
\*============================================================================*/
ProError ProUtilMenuStringsFree(
    wchar_t ***w_ptr)
{
    ProError err;
    int i, n_str;
    wchar_t **w_p = *w_ptr;

    err = ProArraySizeGet((ProArray)w_p, &n_str);
    for (i=n_str-2; i>0; i--)
	free(w_p[i]);
    err = ProArrayFree((ProArray*)w_ptr);
    return (err);
}
Ejemplo n.º 5
0
	ProError BatchPlot::GetWorkspaceItems(std::vector<Gui::Model> &list)
	{
		ProError		status;
		ProFileListOpt	option = PRO_FILE_LIST_LATEST_SORTED;
		wchar_t			*w_server_alias;
		wchar_t			*w_workspace_name;
		ProPath			*w_file_names;
		ProPath			*w_folder_names;
		ProPath			w_path;
		ProPath			w_filter;

		status = BatchPlot::GetFileFilter(true, true, w_filter);

		status = ProServerActiveGet(&w_server_alias);
		if (status != PRO_TK_NO_ERROR)
		{
			Mirim::MsgBox::Show(L"Server Alias", L"Could not find Active PDMLink Server");
			return PRO_TK_E_NOT_FOUND;
		}

		status = ProServerWorkspaceGet(w_server_alias, &w_workspace_name);
		if (status != PRO_TK_NO_ERROR)
		{
			Mirim::MsgBox::Show(L"Workspace", L"Could not find Active Workspace.");
			return PRO_TK_E_NOT_FOUND;
		}

		wsprintf(w_path, L"wtws://%s/%s", w_server_alias, w_workspace_name);

		status = ProArrayAlloc(0, sizeof(ProPath), 1,(ProArray*)&w_file_names);
		status = ProArrayAlloc(0, sizeof(ProPath), 1,(ProArray*)&w_folder_names);
		status = ProFilesList(w_path, w_filter, option, &w_file_names, &w_folder_names); 
		int n_count = -1;
		status = ProArraySizeGet(w_file_names, &n_count);

		for(int i=0; i<n_count; i++)
		{
			Model m(w_file_names[i]);
			list.push_back(m);
		}

		status = ProWstringFree(w_server_alias);
		status = ProWstringFree(w_workspace_name);

		status = ProArrayFree((ProArray *) &w_file_names);
		status = ProArrayFree((ProArray *) &w_folder_names);

		return PRO_TK_NO_ERROR;
	}
Ejemplo n.º 6
0
/*====================================================================*\
    FUNCTION :	ProUtilFeatureElementsDump()
    PURPOSE  :	To write a decription of a feature elements to a text file
\*====================================================================*/
void ProUtilFeatureElementsDump(
    ProModelitem *feature,
    FILE *fp)
{
    ProError		status;
    ProElement		elem_tree;
    FeatureElemPrintData print_data;
    ElemtreeElement *elements;
    int elements_num, i;

/*----------------------------------------------*\
    Create a copy of the feature element tree 
\*----------------------------------------------*/
    status = ProFeatureElemtreeExtract( feature, NULL, PRO_FEAT_EXTRACT_NO_OPTS, &elem_tree );
    TEST_CALL_REPORT("ProFeatureElemtreeExtract()", 
	"ProUtilFeatureElementsDump()", status, 
              (status != PRO_TK_NO_ERROR) && (status != PRO_TK_INVALID_TYPE));

/*-----------------------------------------------------------*\
    For non-supported features, don't dump the element info
\*-----------------------------------------------------------*/
    if (status == PRO_TK_INVALID_TYPE)
      {
        ProTKFprintf(fp, "Element tree is not supported for this feature\n");
      }
    else
       if (status == PRO_TK_NO_ERROR)
          {
            print_data.fp = fp;
            print_data.p_feature = feature;
			          
            status = ProUtilCollectElemtreeElements (elem_tree, NULL, &elements);
            if (status == PRO_TK_NO_ERROR)
            { 
                status = ProArraySizeGet ((ProArray)elements, &elements_num);
                TEST_CALL_REPORT( "ProArraySizeGet()",
		    "ProUtilFeatureElementsDump()",
		    status, status != PRO_TK_NO_ERROR );
                for (i = 0; i < elements_num; i++)
                {
                    status = ProUtilElemPrint (elem_tree, elements[i].p_element,
                        elements[i].p_elempath, &print_data);
                }
                status = ProUtilElemtreeElementArrayFree (&elements);
            }
          }

}
Ejemplo n.º 7
0
/*============================================================================*\
 Function:	ProUtilMenuStringsWstrAdd
 Purpose:       Alloc memory and add string to MenuStrings array
\*============================================================================*/
ProError ProUtilMenuStringsWstrAdd(
    wchar_t ***w_ptr,
    wchar_t *w_str)
{
    ProError err;
    wchar_t *w_p;
    int len, n_str;

    len = ProUtilWstrLen(w_str);
    w_p = (wchar_t*)calloc(len + 1, sizeof(wchar_t));
    if (w_p == NULL)
	return (PRO_TK_GENERAL_ERROR);
    ProUtilWstrcpy(w_p, w_str); 

    err = ProArraySizeGet((ProArray)*w_ptr, &n_str);
    err = ProArrayObjectAdd((ProArray*)w_ptr, n_str-1, 1, &w_p);
    return (err);
}
Ejemplo n.º 8
0
/*============================================================================*\
 Function:	ProUtilMenuStringsStrAdd
 Purpose:       Alloc memory and add string to MenuStrings array
\*============================================================================*/
ProError ProUtilMenuStringsStrAdd(
    wchar_t ***w_ptr,
    char *str)
{
    ProError err;
    wchar_t *w_p;
    int n_str;

    int len = static_cast<int>(strlen(str));
    w_p = (wchar_t*)calloc(len + 1, sizeof(wchar_t));
    if (w_p == NULL)
	return (PRO_TK_GENERAL_ERROR);
    ProStringToWstring(w_p, str); 

    err = ProArraySizeGet((ProArray)*w_ptr, &n_str);
    err = ProArrayObjectAdd((ProArray*)w_ptr, n_str-1, 1, &w_p);
    return (err);
}
Ejemplo n.º 9
0
ProError CSDMdlSpecAsmRefCheck::AsmMdlVisitAction(ProFeature *pFea, ProError status, ProAppData pData)
{
	UNUSED_ALWAYS(status);
	AsmRefVisitData &visitData = *((AsmRefVisitData *)pData);
	
	ProAsmcompconstraint* pArrCons = NULL;
	if (ProAsmcompConstraintsGet(pFea, &pArrCons) == PRO_TK_NO_ERROR)
	{
		int nCount;
		ProArraySizeGet(pArrCons, &nCount);
		for (int i=0; i<nCount; i++)
		{
			ProAsmcompConstrType type;
			ProAsmcompconstraintTypeGet(pArrCons[i], &type);
			if (type != PRO_ASM_CSYS)
			{
				ProMdl pMdl = NULL;
				ProAsmcompMdlGet(pFea, &pMdl);
				ProName name;
				ProMdlNameGet(pMdl, name);
				visitData.nResultType = CHECK_RESULT_INVALID_VALUE;
				visitData.arrMdlNames.Add(CString(name));
				visitData.arrErrorIDs.Add(pFea->id);
				break;
			}
		}
		ProArrayFree((ProArray*)&pArrCons);
	}
	else
	{
		ProMdl pMdl = NULL;
		ProAsmcompMdlGet(pFea, &pMdl);
		ProName name;
		ProMdlNameGet(pMdl, name);
		visitData.nResultType = CHECK_RESULT_INVALID_VALUE;
		visitData.arrMdlNames.Add(CString(name));
		visitData.arrErrorIDs.Add(pFea->id);
	}

	return PRO_TK_NO_ERROR;
}
Ejemplo n.º 10
0
/*====================================================================*\
    FUNCTION :	ProUtilElemPrint()
    PURPOSE  :	Visit function.
\*====================================================================*/
ProError ProUtilElemPrint( 
    ProElement elem_tree, 
    ProElement  elem,
    ProElempath elem_path, 
    FeatureElemPrintData* p_data )
{
    ProError		status;
    ProElemId		elem_id;
    int			dimension_id = -1;
    ProBoolean		is_visible;
    ProBoolean		is_incomplete;
    ProBoolean		is_compound;
    ProBoolean          is_array;
    ProBoolean          is_multival;
    ProValue*		p_values;
    ProValue            value;
    int			array_size;
    ProValueData	value_data;
    char		value_data_str[ 48 ];
    int			i;
    ProBoolean          flag = PRO_B_TRUE;             

    status = ProElementIdGet( elem, &elem_id );
    TEST_CALL_REPORT("ProElementIdGet()", 
	"ProUtilElemPrint()",
	PRO_TK_NO_ERROR, status != PRO_TK_NO_ERROR);
    ProTKFprintf( p_data->fp, "Element ID: %d\n", elem_id );

    status = ProFeatureElemIsVisible( p_data->p_feature, elem_path, 
	&is_visible );
#if 0
    TEST_CALL_REPORT("ProFeatureElemIsVisible()",
	"ProUtilElemPrint()", status,
	status != PRO_TK_NO_ERROR );
#else
/* This function return PRO_TK_E_NOT_FOUND for Element FEATURE_TYPE,
from feature PRO_FEAT_DATUM_QUILT (it's a bug)*/
    TEST_CALL_REPORT("ProFeatureElemIsVisible()",
	"ProUtilElemPrint()", status,
        0);
#endif

    status = ProFeatureElemIsIncomplete( p_data->p_feature, elem_path, 
	&is_incomplete );
#if 0
    /* spr 751801 */
    TEST_CALL_REPORT( "ProFeatureElemIsIncomplete()", "ProUtilElemPrint()", 		status, status != PRO_TK_NO_ERROR);
#else
    TEST_CALL_REPORT( "ProFeatureElemIsIncomplete()", "ProUtilElemPrint()",     	status, 0 );
#endif

    status = ProElementIsCompound( elem, NULL, &is_compound );
    TEST_CALL_REPORT("ProElementIsCompound()", "ProUtilElemPrint()",
	status, status != PRO_TK_NO_ERROR);

    status = ProElementIsArray(elem, NULL, &is_array );
    TEST_CALL_REPORT("ProElementIsArray()", "ProUtilElemPrint()",
        status, status != PRO_TK_NO_ERROR);

    ProTKFprintf( p_data->fp, is_visible == PRO_B_TRUE ? "\tVisible\n" : "\tInvisible\n" );
    ProTKFprintf( p_data->fp, is_incomplete == PRO_B_TRUE ? "\tIncomplete\n" : 
	"\tComplete\n" );

    ProTKFprintf( p_data->fp, is_compound == PRO_B_TRUE ? "\tCompound\n" : 
	                            (is_array == PRO_B_TRUE ? "\tArray\n" :
                                           "\tNeither compound nor array\n"));

    if( is_compound == PRO_B_TRUE || is_array == PRO_B_TRUE)
	return PRO_TK_NO_ERROR;

    status = ProFeatureElemDimensionIdGet( p_data->p_feature, elem_path, 
	&dimension_id );
    TEST_CALL_REPORT("ProFeatureElemDimensionIdGet()", 
	"ProUtilElemPrint()",
	status, (status != PRO_TK_NO_ERROR)&&
                (status != PRO_TK_E_NOT_FOUND));

     if (status != PRO_TK_E_NOT_FOUND)
         ProTKFprintf( p_data->fp, "\tDimension ID: %d\n", dimension_id );
     else
         ProTKFprintf( p_data->fp, "\tThis element does not contain dimension\n");

    status = ProArrayAlloc( 0, sizeof(ProValue), 1, (ProArray*)&p_values );
    TEST_CALL_REPORT( "ProArrayAlloc()", "ProUtilElemPrint()",
			status, status != PRO_TK_NO_ERROR );

    status = ProElementIsMultival(elem, NULL, &is_multival);
    TEST_CALL_REPORT( "ProElementIsMultival", 
                       "ProUtilElemPrint", status, status != PRO_TK_NO_ERROR);

    if (is_multival == PRO_B_TRUE)
    {
       status = ProFeatureElemValuesGet( p_data->p_feature,
                                          elem_path, &p_values );
#if 0
	TEST_CALL_REPORT( "ProFeatureElemValuesGet()", "ProUtilElemPrint()",
	    status,
	    status != PRO_TK_NO_ERROR );
#else
/* ProFeatureElemValuesGet() - returns PRO_TK_E_NOT_FOUND in the PIPE mode
for Element PRO_E_STD_EDGE_CHAMF_EDGES.(bugminsk1347)*/
	TEST_CALL_REPORT( "ProFeatureElemValuesGet()", "ProUtilElemPrint()",
	    status,
	    0 );
#endif
    }
    else
    {
       status = ProElementValueGet(elem, &value);
       TEST_CALL_REPORT( "ProElementValueGet", "ProUtilElemPrint",
                                status, status != PRO_TK_NO_ERROR);
  
       status = ProArrayObjectAdd((ProArray*)&p_values, PRO_VALUE_UNUSED,
                                                                1, &value);
       TEST_CALL_REPORT( "ProArrayObjectAdd", "ProUtilElemPrint",
                                status, status != PRO_TK_NO_ERROR);
    }
    if (p_values!=NULL){
        array_size = 0;
        status = ProArraySizeGet( (ProArray)p_values, &array_size );
        TEST_CALL_REPORT( "ProArraySizeGet()", "ProUtilElemPrint()",
			status, status != PRO_TK_NO_ERROR );

        ProTKFprintf( p_data->fp, "\t%s\n",(i=1)?"Value:":"Values:" );
        for( i=0; i<array_size; i++ )
	  {
	   /*To avoid PRO_E_SKETCHER and PRO_E_PATTERN, following condition is set*/
	    if(( elem_id == 458) || (elem_id == 27))
	      flag = PRO_B_FALSE; 
	    
	    if(flag == PRO_B_TRUE)
	      {
		status = ProValueDataGet( p_values[i], &value_data );
        	TEST_CALL_REPORT( "ProValueDataGet()", "ProUtilElemPrint()",
				  status, status != PRO_TK_NO_ERROR );
		switch( value_data.type )
		  {
		  case PRO_VALUE_TYPE_INT:
	            ProTKSprintf( value_data_str, "%d", value_data.v.i );
	            break;
		    
		  case PRO_VALUE_TYPE_DOUBLE:
	            ProTKSprintf( value_data_str, "%f", value_data.v.d );
                    break;
		    
		  case PRO_VALUE_TYPE_POINTER:
	            ProTKSprintf( value_data_str, "Pointer=*", value_data.v.p );
	            break;
		    
		  case PRO_VALUE_TYPE_STRING:
		    
                    if ( value_data.v.s !=NULL)
		      ProTKSprintf( value_data_str, "%s", value_data.v.s );
		    else 
		      ProTKSprintf( value_data_str,"<NULL>" );
		    break;
		    
		  case PRO_VALUE_TYPE_WSTRING:
		    
		    /* NOTE - NULL is possible in some element trees 
		       (for example, for the element PRO_E_STD_FEATURE_NAME
		       where NULL means that feature has the default name) */
		    
                    if ( value_data.v.w !=NULL)
		      ProWstringToString( value_data_str, value_data.v.w );
                    else 
		      ProTKSprintf( value_data_str,"<NULL>" );
	            break;
		    
		  case PRO_VALUE_TYPE_SELECTION:
	            ProTKSprintf( value_data_str, "Selection" );
	            break;
		    
		  case PRO_VALUE_TYPE_TRANSFORM:
                    ProTKSprintf( value_data_str, "Transformation" );
                    break;
		    
		  default:
	            ProTKSprintf( value_data_str, "**UNKNOWN**\n" );
		  }
		
		ProTKFprintf( p_data->fp, "\t%s\n", value_data_str );
	      }
	  }
	
        status = ProArrayFree( (ProArray*)&p_values );
        TEST_CALL_REPORT( "ProArrayFree()", "ProUtilFeatureElementsDump()",
			  status, status != PRO_TK_NO_ERROR );
    }
    
    
    return PRO_TK_NO_ERROR;
}
bool make_solid_templated( ProSolid& in_original, ProSolid& out_template )
{
	ProError rc;
	char pro_str[128];
	log4cpp::Category& log_cf = log4cpp::Category::getInstance(LOGCAT_CONSOLEANDLOGFILE);
	
	ProUnitsystem original_system;
	switch( rc = ProMdlPrincipalunitsystemGet(in_original, &original_system) ) {
	case PRO_TK_NO_ERROR: break;
	case PRO_TK_BAD_INPUTS:
		log_cf.errorStream() 
			<< "failed getting the principal unit-system.";
		break;
	default:
		log_cf.errorStream() 
			<< "could not aquire the unit system = " << rc;
		return false;
	}
	/*
	ProUnititem* original_mass_unit;
	switch( rc = ProMdlUnitsCollect( in_original, 
		PRO_UNITTYPE_MASS, &original_mass_unit) ) {
	case PRO_TK_NO_ERROR: break;
	default:
		log_cf.errorStream() << "could not collect unit systems = " << rc;
		return false;
	}
	*/

	ProUnitsystem* template_systems;
	//ProUnititem template_units;
	switch( rc = ProMdlUnitsystemsCollect( out_template, &template_systems) ) {
	case PRO_TK_NO_ERROR: break;
	default:
		log_cf.errorStream() << "could not collect unit systems = " << rc;
		return false;
	}
	ProUnitsystem template_system;
	int size_template_systems;
	ProArraySizeGet( template_systems, &size_template_systems );
	for( int ix=0; ix < size_template_systems; ++ix ) {
		int names_matched;
		ProWstringCompare(template_systems[ix].name,
			original_system.name, PRO_VALUE_UNUSED, &names_matched);
		if (names_matched != 0) continue;
		template_system = template_systems[ix];
		break;
	}

	switch( rc = ProMdlPrincipalunitsystemSet(out_template, 
		&template_system, PRO_UNITCONVERT_SAME_SIZE, PRO_B_TRUE,
		PRO_VALUE_UNUSED) ) {
	case PRO_TK_NO_ERROR: break;
	case PRO_TK_BAD_INPUTS:
		log_cf.errorStream() 
			<< "could not set the units in the shrinkwrap : "
			<< ProWstringToString(pro_str, template_system.name);
		break;
	default:
		log_cf.errorStream() 
			<< "could not set units in shinkwrap = "
			<< rc;
		return false;
	}
	return true;
}