ProError disassemble(ProSolid in_solid) { ProError rs; // The application data passed to the filter and visiting functions. Appdata app_data; app_data.level = 1; app_data.path.owner = in_solid; app_data.path.table_num = -1; app_data.path.comp_id_table[0] = 0; // visits all the features in the specified solid. // <B>NOTE:</B> Internal features are also visited. // Use <B>ProFeatureVisibilityGet()</B> to filter/skip them if required. ProAppData* app_data_vp = reinterpret_cast<ProAppData*>(&app_data); switch( rs = ProSolidFeatVisit(in_solid, visit_action, filter_action, app_data_vp) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "Either no features exist, " << " or they were all filtered out by the filter function."; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "Any other value is the value returned " << " by the action function (visiting stopped)." << rs; } return PRO_TK_NO_ERROR; }
int CSDMdlMachChamferAngCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } // 检查输入值有效性 if (checkRule.arrRuleContent.GetCount() < 1) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } CStringArray arrChamferAng; CStringToCStringArray(checkRule.arrRuleContent[0], arrChamferAng); for (int i = 0; i < arrChamferAng.GetSize(); i++) { if (IsNumber(arrChamferAng.GetAt(i)) == FALSE || _wtof(arrChamferAng.GetAt(i)) < 0 || DEQUAL(_wtof(arrChamferAng.GetAt(i)),0.0)) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return CHECK_RESULT_INVALID_INPUT; } } ChamferFeaVisitAngData visitData; visitData.nResultType = CHECK_RESULT_NO_ERROR; visitData.strAngle = checkRule.arrRuleContent[0]; ProError status; status = ProSolidFeatVisit((ProSolid)pMdl, ChamferFeaVisitAction, ChamferFeaFilterAction, &visitData); checkResult.arrErrorItems.RemoveAll(); ErrorItem errItem; for (int i=0; i<visitData.arrChamferAngErrorIDs.GetSize(); i++) { errItem.nID = visitData.arrChamferAngErrorIDs[i]; errItem.nType = PRO_FEATURE; errItem.pOwner = pMdl; checkResult.arrErrorItems.Add(errItem); } checkResult.nResultType = visitData.nResultType; return visitData.nResultType; }
int CSDMdlMachFeaMinSizeCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } // 检查输入值有效性 if (checkRule.arrRuleContent.GetCount() < 1 || _wtof(checkRule.arrRuleContent[0]) <= 0 || DEQUAL(_wtof(checkRule.arrRuleContent[0]),0.0)) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } FeaMinSizeVisitData VisitData; VisitData.nFeaMinSizeResultType = CHECK_RESULT_NO_ERROR; VisitData.dMinSizeRatio = _wtof(checkRule.arrRuleContent[0])/100; ProError status; status = ProSolidFeatVisit((ProSolid)pMdl, GeoFeaVisitAction, GeoFeaFilterAction, &VisitData); if (status == PRO_TK_E_NOT_FOUND) { VisitData.nFeaMinSizeResultType = CHECK_RESULT_ITEM_NOT_FOUND; return CHECK_RESULT_ITEM_NOT_FOUND; } checkResult.arrErrorItems.RemoveAll(); ErrorItem errItem; for (int i=0; i<VisitData.arrFeaMinSizeErrorIDs.GetSize(); i++) { errItem.nID = VisitData.arrFeaMinSizeErrorIDs[i]; errItem.nType = PRO_FEATURE; errItem.pOwner = pMdl; checkResult.arrErrorItems.Add(errItem); } checkResult.nResultType = VisitData.nFeaMinSizeResultType; return VisitData.nFeaMinSizeResultType; }
int CSDMdlMachDeepHoleCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } // 检查输入值有效性 if (checkRule.arrRuleContent.GetCount() < 1 || _wtof(checkRule.arrRuleContent[0]) <= 0 || DEQUAL(_wtof(checkRule.arrRuleContent[0]),0.0)) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } DeepHoleFeaVisitData DeepHoleVisitData; DeepHoleVisitData.nDeepHoleResultType = CHECK_RESULT_NO_ERROR; DeepHoleVisitData.dDeepHoleRatio = _wtof(checkRule.arrRuleContent[0]); ProError status; status = ProSolidFeatVisit((ProSolid)pMdl, DeepHoleFeaVisitAction, NULL, &DeepHoleVisitData); checkResult.arrErrorItems.RemoveAll(); ErrorItem errItem; for (int i=0; i<DeepHoleVisitData.arrDeepHoleErrorIDs.GetSize(); i++) { errItem.nID = DeepHoleVisitData.arrDeepHoleErrorIDs[i]; errItem.nType = PRO_FEATURE; errItem.pOwner = pMdl; checkResult.arrErrorItems.Add(errItem); } checkResult.nResultType = DeepHoleVisitData.nDeepHoleResultType; return DeepHoleVisitData.nDeepHoleResultType; }
// 检查开始,传出检查结果 int CSDMdlSpecAsmRefCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { checkRule; ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } AsmRefVisitData assVisitData; assVisitData.bFirstComp = FALSE; assVisitData.bFirstDatum = FALSE; assVisitData.nResultType = CHECK_RESULT_NO_ERROR; ProSolidFeatVisit((ProSolid)pMdl, AsmMdlVisitAction, AsmMdlFilterAction, &assVisitData); checkResult.arrErrorItems.RemoveAll(); ErrorItem errItem; for (int i=0; i<assVisitData.arrErrorIDs.GetSize(); i++) { errItem.nID = assVisitData.arrErrorIDs[i]; errItem.strItemName = assVisitData.arrMdlNames[i]; errItem.nType = PRO_FEATURE; errItem.pOwner = pMdl; checkResult.arrErrorItems.Add(errItem); } checkResult.nResultType = assVisitData.nResultType; return assVisitData.nResultType; }
int CSDMdlMachFlatBottomHoleCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { checkRule; ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } ProError status; m_FlatBottomHoleVisitData.nFlatBottomHoleResultType = CHECK_RESULT_NO_ERROR; m_FlatBottomHoleVisitData.arrFlatBottomHoleErrorIDs.RemoveAll(); status = ProSolidFeatVisit((ProSolid)pMdl, HoleFeaVisitAction, HoleFeaFilterAction, NULL); checkResult.arrErrorItems.RemoveAll(); ErrorItem errItem; for (int i=0; i<m_FlatBottomHoleVisitData.arrFlatBottomHoleErrorIDs.GetSize(); i++) { errItem.nID = m_FlatBottomHoleVisitData.arrFlatBottomHoleErrorIDs[i]; errItem.nType = PRO_FEATURE; errItem.pOwner = pMdl; checkResult.arrErrorItems.Add(errItem); } checkResult.nResultType = m_FlatBottomHoleVisitData.nFlatBottomHoleResultType; return checkResult.nResultType; }
//=================================================================================================== int CSDMdlSpecUnusedDatumCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { checkRule; ProError status; ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } UnusedDatumVisitData VisitData; VisitData.nResultType = CHECK_RESULT_NO_ERROR; status = ProSolidFeatVisit((ProSolid)pMdl, DatumFeaVisitAction, DatumFeaFilterAction, &VisitData); checkResult.arrErrorItems.RemoveAll(); ErrorItem errItem; for (int i=0; i<VisitData.arrUnusedSkeErrors.GetSize(); i++) { errItem.nID = VisitData.arrUnusedSkeErrors[i].nID; errItem.nType = PRO_FEATURE; errItem.pOwner = pMdl; checkResult.arrErrorItems.Add(errItem); } checkResult.nResultType = VisitData.nResultType; return checkResult.nResultType; }
// 检查函数 int CSDMdlAttrFeaSystemCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } // 检查输入值有效性 if (checkRule.arrRuleContent.GetSize() < 1) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } ProError status; checkResult.nResultType = CHECK_RESULT_NO_ERROR; checkResult.arrErrorItems.RemoveAll(); ProModelitem mdlItem; ProMdlToModelitem(pMdl, &mdlItem); CString strFeaType, strFeaName; NameFeaVisitData visitData; ErrorItem errItem; CStringArray arrFeatures; CStringToCStringArray(checkRule.arrRuleContent[0], arrFeatures); for (int i=0; i<(int)arrFeatures.GetSize(); i++) { strFeaType = arrFeatures[i].Left(arrFeatures[i].Find(L"(")); int nCount = arrFeatures[i].Find(L")") - arrFeatures[i].Find(L"(")-1; strFeaName = arrFeatures[i].Mid(arrFeatures[i].Find(L"(") + 1, nCount); ParseParaValue(mdlItem, strFeaName, strFeaName); strFeaName.MakeUpper(); int nFeaType=-1, nSubType=-1; GetFeatTypeAndSubType(strFeaType, nFeaType, nSubType); visitData.strCheckContent = strFeaName; visitData.nFeaType = nFeaType; visitData.nSubType = nSubType; status = ProSolidFeatVisit((ProSolid)pMdl, FeatureNameVisit, FeatureNameFilter, &visitData); if (status != PRO_TK_USER_ABORT) { checkResult.nResultType = CHECK_RESULT_INVALID_VALUE; errItem.nType = visitData.nFeaType; errItem.strItemName = visitData.strCheckContent; checkResult.arrErrorItems.Add(errItem); } } return checkResult.nResultType; }
ProError visit_component_action( ProFeature* in_feature, ProError in_status, Appdata in_app_data ) { ProError rs; ProMdl model; switch( rs = ProAsmcompMdlGet(in_feature, &model) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified feature is not a valid component feature."; return PRO_TK_GENERAL_ERROR; case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "Assembly component model is not a solid or is not in memory."; return PRO_TK_GENERAL_ERROR; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unexpected error: " << rs; return PRO_TK_GENERAL_ERROR; } ProSolid solid = static_cast<ProSolid>(model); ProMdlType component_type; switch( rs = ProMdlTypeGet(model, &component_type) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid."; return PRO_TK_GENERAL_ERROR; case PRO_TK_GENERAL_ERROR: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The information could not be obtained."; return PRO_TK_GENERAL_ERROR; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unexpected error: " << rs; return PRO_TK_GENERAL_ERROR; } ProAsmcomp component = static_cast<ProAsmcomp>(*in_feature); Appdata app_data; app_data.level = in_app_data.level+1; app_data.path.owner = static_cast<ProSolid>(component.owner); app_data.path.owner = in_app_data.path.owner; app_data.path.table_num = in_app_data.path.table_num + 1; for( int ix=0; ix < app_data.path.table_num; ++ix ) { app_data.path.comp_id_table[ix] = in_app_data.path.comp_id_table[ix]; } app_data.path.comp_id_table[app_data.path.table_num] = in_feature->id; switch( component_type ) { case PRO_ASSEMBLY: { ProAppData* app_data_vp = reinterpret_cast<ProAppData*>(&app_data); switch( rs = ProSolidFeatVisit(solid, visit_action, filter_action, app_data_vp) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "filter produced no component features."; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "Any other value is the value returned " << " by the action function (visiting stopped)." << rs; } } break; case PRO_PART: { ProMdl self; switch( rs = ProModelitemMdlGet(in_feature, &self) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "feature has no model. " << in_feature->id; } char assembly_name[PRO_NAME_SIZE]; { ProName wname; switch( rs = ProMdlNameGet(self, wname) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid. " << in_feature->id; throw std::runtime_error("selector feature name failed"); case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified item does not have a name. "; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "ill specified error: " << rs; throw std::runtime_error("selector feature name failed"); } ProWstringToString(assembly_name, wname); } char model_name[PRO_PATH_SIZE]; { wchar_t* wname; ProBoolean is_modifiable; switch( rs = ProMdlCommonnameGet(self, &wname, &is_modifiable) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid. " << in_feature->id; throw std::runtime_error("selector feature name failed"); case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified item does not have a name. "; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "ill specified error: " << rs; throw std::runtime_error("selector feature name failed"); } ProWstringToString(model_name, wname); ProWstringFree(wname); } char item_name[PRO_NAME_SIZE]; { ProName wname; switch( rs = ProModelitemNameGet(in_feature, wname) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid. " << in_feature->id; throw std::runtime_error("selector feature name failed"); case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified item does not have a name. "; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "ill specified error: " << rs; throw std::runtime_error("selector feature name failed"); } ProWstringToString(item_name, wname); } // If you request the transformation from the member to the // assembly, this is PRO_B_TRUE. Otherwise, this is PRO_B_FALSE. ProBoolean bottom_up = PRO_B_TRUE; ProMatrix transformation; // retrieve the transformation matrix, given the component path. switch( rs = ProAsmcomppathTrfGet(&app_data.path, bottom_up, transformation) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "transform get, the input argument is invalid: " << app_data.path.comp_id_table; return PRO_TK_GENERAL_ERROR; case PRO_TK_GENERAL_ERROR: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified component path was wrong, or contained missing members."; return PRO_TK_GENERAL_ERROR; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unexpected error: " << rs; return PRO_TK_GENERAL_ERROR; } isis_LOG(lg, isis_FILE, isis_INFO) << "transformation: " << assembly_name << " : " << model_name << " : " << item_name; isis_LOG(lg, isis_FILE, isis_INFO) << "["; for( int ix=0; ix < 4; ++ix ) { isis_LOG(lg, isis_FILE, isis_INFO) << "\n\t["; for( int jx=0; jx < 4; ++jx ) { isis_LOG(lg, isis_FILE, isis_INFO) << '\t' << transformation[ix][jx]; } isis_LOG(lg, isis_FILE, isis_INFO) << "]"; } isis_LOG(lg, isis_FILE, isis_INFO) << "]\n"; return PRO_TK_NO_ERROR; } default: { isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unknown-component-type: " << component_type; } } return PRO_TK_NO_ERROR; }
int CSDMdlMachBendRadiusCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult) { ProMdl pMdl = (ProMdl)pData; if (NULL == pMdl) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } // 检查输入值有效性 if (checkRule.arrRuleContent.GetCount() < 1 || _wtof(checkRule.arrRuleContent[0]) <= 0 || DEQUAL(_wtof(checkRule.arrRuleContent[0]),0.0)) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } ProError status; ProDimension thick; status = ProSmtPartThicknessGet(ProMdlToPart(pMdl), &thick); if (status != PRO_TK_NO_ERROR) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } double dThickness = 0.0; ProDimensionValueGet(&thick, &dThickness); if (DEQUAL(dThickness, 0.000)) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } SheetBendFeaVisitData visitData; visitData.dMinRatio = _wtof(checkRule.arrRuleContent[0]); visitData.dThick = dThickness; status = ProSolidFeatVisit((ProSolid)pMdl, (ProFeatureVisitAction)SheetFeatVisitAction, (ProFeatureFilterAction)SheetFeatVisitFilter, &visitData); checkResult.arrErrorItems.RemoveAll(); ErrorItem errItem; for (int i=0; i<visitData.arrErrorIDs.GetSize(); i++) { errItem.nID = visitData.arrErrorIDs[i]; errItem.nType = PRO_FEATURE; errItem.pOwner = pMdl; checkResult.arrErrorItems.Add(errItem); } if (checkResult.arrErrorItems.GetCount() > 0) checkResult.nResultType = CHECK_RESULT_INVALID_VALUE; else checkResult.nResultType = CHECK_RESULT_NO_ERROR; return checkResult.nResultType; }