void simulateJumps::init() { //init the vector of waiting times. _waitingTimeParams.clear(); _waitingTimeParams.resize(_alphabetSize); int i, j; for (i = 0; i < _alphabetSize; ++i) { _waitingTimeParams[i] = -_sp.dPij_dt(i, i, 0.0); } //init _jumpProbs. //_jumpProbs[i][j] = Q[i][j] / -Q[i][i] _jumpProbs.clear(); _jumpProbs.resize(_alphabetSize); for (i = 0; i < _alphabetSize; ++i) { MDOUBLE sum = 0.0; _jumpProbs[i].resize(_alphabetSize); for (j = 0; j < _alphabetSize; ++j) { if (i == j) _jumpProbs[i][j] = 0.0; else { _jumpProbs[i][j] = _sp.dPij_dt(i, j, 0.0) / _waitingTimeParams[i]; } sum += _jumpProbs[i][j]; } if (! DEQUAL(sum, 1.0)){ string err = "error in simulateJumps::init(): sum probabilities is not 1 and equal to "; err+=double2string(sum); errorMsg::reportError(err); } } //init _orderNodesVec: a vector in which the branch lengths are ordered in ascending order _tree.getAllNodes(_orderNodesVec, _tree.getRoot()); sort(_orderNodesVec.begin(), _orderNodesVec.end(), simulateJumpsAbstract::compareDist); _nodes2JumpsExp.clear(); _nodes2JumpsProb.clear(); VVdouble zeroMatrix(getCombinedAlphabetSize()); for (i = 0; i < getCombinedAlphabetSize(); ++i) zeroMatrix[i].resize(getCombinedAlphabetSize(), 0.0); Vdouble zeroVector(getCombinedAlphabetSize(),0.0); for (i = 0; i < _orderNodesVec.size(); ++i) { string nodeName = _orderNodesVec[i]->name(); _nodes2JumpsExp[nodeName] = zeroMatrix; _nodes2JumpsProb[nodeName] = zeroMatrix; for (j=0; j<getCombinedAlphabetSize();++j) _totalTerminals[nodeName]=zeroVector; } }
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 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; }
// 检查倒角特征,若倒角角度值小于输入值,返回FALSE,否则返回TRUE BOOL CSDMdlMachChamferAngCheck::CheckChamferFeature(ProFeature *pFeature, CString strAngle) { ProError status; double Leg1Val; double Leg2Val; ProElempathItem pathItems[3]; pathItems[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID; pathItems[0].path_item.elem_id = PRO_E_RNDCH_SETS; pathItems[1].type = PRO_ELEM_PATH_ITEM_TYPE_INDEX; pathItems[1].path_item.elem_index = 0; pathItems[2].type = PRO_ELEM_PATH_ITEM_TYPE_ID; pathItems[2].path_item.elem_id = PRO_E_RNDCH_DIMENSIONAL_SCHEMA; CStringArray arrChamferAng; CStringToCStringArray(strAngle, arrChamferAng); ProElempath pElemPath = NULL; ProValue pValue = NULL; ProValueData value_data; for (int i = 0;; i++) { status = ProElempathAlloc (&pElemPath); pathItems[1].path_item.elem_index = i; status = ProElempathDataSet (pElemPath, pathItems, 3); status = ProFeatureElemValueGet(pFeature, pElemPath, &pValue); if (status == PRO_TK_NO_ERROR) { status = ProValueDataGet(pValue, &value_data); if ((PRO_CHM_D_X_D == value_data.v.i)||(PRO_CHM_45_X_D == value_data.v.i)) { int nTempResult = FALSE; for (int i = 0; i <arrChamferAng.GetSize(); i++ ) { if(DEQUAL(_wtof(arrChamferAng.GetAt(i)), 45.0)) { return TRUE; } } if (nTempResult == FALSE) { return FALSE; } } else if (PRO_CHM_D1_X_D2 == value_data.v.i) { Leg1Val = GetChamferLeg1Val(pFeature,i); Leg2Val = GetChamferLeg2Val(pFeature,i); double dFeaAngle; dFeaAngle = atan(Leg1Val/Leg2Val); int nTempResult = FALSE; for (int i = 0; i <arrChamferAng.GetSize(); i++ ) { if (DEQUAL(dFeaAngle/PI*180, _wtof(arrChamferAng.GetAt(i))) || DEQUAL(dFeaAngle/PI*180, 180 - _wtof(arrChamferAng.GetAt(i)))) { nTempResult = TRUE; } } if (nTempResult == FALSE) { return FALSE; } } else if (PRO_CHM_ANG_X_D == value_data.v.i) { Leg2Val = GetChamferLeg2Val(pFeature,i); int nTempResult = FALSE; for (int i = 0; i <arrChamferAng.GetSize(); i++ ) { if (DEQUAL(Leg2Val, _wtof(arrChamferAng.GetAt(i))) || DEQUAL(Leg2Val, 180 - _wtof(arrChamferAng.GetAt(i)))) { nTempResult = TRUE; } } if (nTempResult == FALSE) { return FALSE; } } } else { break; } status = ProElempathFree(&pElemPath); } return TRUE; }
ProError CSDMdlMachFlatBottomHoleCheck::HoleFeaVisitAction(ProFeature *pFeature, ProError status, ProAppData data) { data; int nSurfCheckResult = -1; status = ProFeatureGeomitemVisit(pFeature,PRO_SURFACE, SurfGeomitemVisitAction, NULL,&nSurfCheckResult); if (nSurfCheckResult == CHECK_RESULT_NO_ERROR) { return PRO_TK_NO_ERROR; } CArray<ProSurface>arrSurf; ProSurface HolePrimSurf; GetHolePrimSurf(pFeature, HolePrimSurf); arrSurf.Add(HolePrimSurf); status = ProFeatureGeomitemVisit(pFeature,PRO_SURFACE, HoleGeomitemVisitAction, NULL,&arrSurf); //获得特征的柱面和平面 int nSurfNum = (int)arrSurf.GetSize(); if (nSurfNum == 1) { return PRO_TK_NO_ERROR; } ProSrftype SurfType; ProSurface CylSurf; for (int i = 1; i < nSurfNum; i++) { status = ProSurfaceTypeGet(arrSurf.GetAt(i), &SurfType); if(SurfType == PRO_SRF_CYL) { CylSurf = arrSurf.GetAt(i); break; } } CArray<ProSurface>arrVisit; arrVisit.Add(HolePrimSurf); arrVisit.Add(CylSurf); status = ProSurfaceContourVisit(CylSurf, SurfContourVisitAction, NULL, &arrVisit); //获得孔底环非柱面的邻面arrVisit.GetAt(2) if (arrVisit.GetSize() != 3) { return PRO_TK_NO_ERROR; } status = ProSurfaceTypeGet(arrVisit.GetAt(2), &SurfType); if (SurfType != PRO_SRF_PLANE) { return PRO_TK_NO_ERROR; } double dPlanAxis[3]; GetPlaneSurfAxis(arrVisit.GetAt(2), dPlanAxis); ProSurface HoleCylSurf; ProVector dHoleAxis; Pro3dPnt origin; double dRadius; GetHoleCylSurf(pFeature, HoleCylSurf, dHoleAxis, origin, dRadius); double Values[3]; Values[0] = dPlanAxis[1]*dHoleAxis[2] - dPlanAxis[2]*dHoleAxis[1]; Values[1] = dPlanAxis[2]*dHoleAxis[0] - dPlanAxis[0]*dHoleAxis[2]; Values[2] = dPlanAxis[0]*dHoleAxis[1] - dPlanAxis[1]*dHoleAxis[0]; if (DEQUAL(Values[0], 0.0) && DEQUAL(Values[1], 0.0) && DEQUAL(Values[2], 0.0)) { m_FlatBottomHoleVisitData.nFlatBottomHoleResultType = CHECK_RESULT_INVALID_VALUE; } if (m_FlatBottomHoleVisitData.nFlatBottomHoleResultType == CHECK_RESULT_INVALID_VALUE) { int arrHoleCutDirPrepUpErrorSize = (int)m_FlatBottomHoleVisitData.arrFlatBottomHoleErrorIDs.GetSize(); if (0 != arrHoleCutDirPrepUpErrorSize) { for (int k=0; k<arrHoleCutDirPrepUpErrorSize; k++) { if (m_FlatBottomHoleVisitData.arrFlatBottomHoleErrorIDs[k] == (*pFeature).id) return PRO_TK_NO_ERROR; } } m_FlatBottomHoleVisitData.arrFlatBottomHoleErrorIDs.Add((*pFeature).id); } return PRO_TK_NO_ERROR; }
BOOL CSD3DDrawingColorCheck::DoAction(void *pData, const CheckData &checkData) { pData; CStringArray arrCheckRule; double dRed; double dGreen; double dBlue; arrCheckRule.Copy(checkData.checkRule.arrRuleContent); int nCount = (int)arrCheckRule.GetSize(); if (nCount == 3) { for (int i = 0; i < 1; i++) { if (!IsNumber(arrCheckRule.GetAt(i))) { return FALSE; } else if (!DEQUAL(_wtof(arrCheckRule.GetAt(i)), 0.0) && !IsPoistive(arrCheckRule.GetAt(i))) { return FALSE; } else if (_wtof(arrCheckRule.GetAt(i)) > 255.0) { return FALSE; } } dRed = _wtof(arrCheckRule.GetAt(0)); dGreen = _wtof(arrCheckRule.GetAt(1)); dBlue = _wtof(arrCheckRule.GetAt(2)); } else return FALSE; ProColor color; color.value.map.red = dRed/255; color.value.map.green = dGreen/255; color.value.map.blue = dBlue/255; color.method = PRO_COLOR_METHOD_RGB; ProModelitem item; BOOL bSetError = FALSE; for (int i=0, nType=-1; i <checkData.checkResult.arrErrorItems.GetCount(); i++) { ProTextStyle pTextStyle; item.id = checkData.checkResult.arrErrorItems[i].nID; item.owner = checkData.checkResult.arrErrorItems[i].pOwner; nType = checkData.checkResult.arrErrorItems[i].nType; if (PRO_NOTE == nType) // 注解 { item.type = PRO_NOTE; ProNoteTextStyleGet(&item, &pTextStyle); ProTextStyleColorSet(pTextStyle, &color); if (ProNoteTextStyleSet(&item, pTextStyle) != PRO_TK_NO_ERROR) bSetError = TRUE; } else if (PRO_DIMENSION == nType) // 尺寸 { item.type = PRO_DIMENSION; ProDimensionTextstyleGet(&item, &pTextStyle); ProTextStyleColorSet(pTextStyle, &color); if (ProDimensionTextstyleSet(&item, pTextStyle) != PRO_TK_NO_ERROR) bSetError = TRUE; ProDimensionDisplayUpdate(&item); } else if (PRO_REF_DIMENSION == nType) // 参考尺寸 { item.type = PRO_REF_DIMENSION; ProDimensionTextstyleGet(&item, &pTextStyle); ProTextStyleColorSet(pTextStyle, &color); if (ProDimensionTextstyleSet(&item, pTextStyle) != PRO_TK_NO_ERROR) bSetError = TRUE; ProDimensionDisplayUpdate(&item); } else if (PRO_GTOL == nType) // 几何公差 { item.type = PRO_GTOL; ProGtolTextstyleGet(&item, &pTextStyle); ProTextStyleColorSet(pTextStyle, &color); if (ProGtolTextstyleSet(&item, pTextStyle) != PRO_TK_NO_ERROR) bSetError = TRUE; ProAnnotationDisplay(&item, NULL, NULL, NULL); } else if (PRO_SYMBOL_INSTANCE == nType) // 符号 { item.type = PRO_SYMBOL_INSTANCE; ProDtlsyminstdata pdtldata = NULL; ProDtlsyminstDataGet(&item, PRODISPMODE_NUMERIC, &pdtldata); ProDtlsyminstdataColorSet(pdtldata, &color); if (ProDtlsyminstModify(&item, pdtldata) != PRO_TK_NO_ERROR) bSetError = TRUE; ProAnnotationDisplay(&item, NULL, NULL, NULL); } else if (PRO_SURF_FIN == nType) // 表面光洁度 { item.type = PRO_SURF_FIN; ProDtlsyminstdata pdtldata = NULL; ProSurffinishDataGet(&item, PRODISPMODE_NUMERIC, &pdtldata); ProDtlsyminstdataColorSet(pdtldata, &color); if (ProSurffinishModify(&item, pdtldata) != PRO_TK_NO_ERROR) bSetError = TRUE; ProAnnotationDisplay(&item, NULL, NULL, NULL); } else if (PRO_SET_DATUM_TAG == nType) // 基准标签 { item.type = PRO_SET_DATUM_TAG; ProSetdatumtagTextstyleGet(&item, &pTextStyle); ProTextStyleColorSet(pTextStyle, &color); if (ProSetdatumtagTextstyleSet(&item, pTextStyle) != PRO_TK_NO_ERROR) bSetError = TRUE; ProAnnotationDisplay(&item, NULL, NULL, NULL); } ProTextStyleFree(&pTextStyle); } ProWindowRepaint(PRO_VALUE_UNUSED); if (bSetError) return FALSE; return TRUE; }
int CSD3DDrawingColorCheck::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() < 3) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } for (int i = 0; i < 3; i++) { if (!IsNumber(checkRule.arrRuleContent.GetAt(i))) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return CHECK_RESULT_INVALID_INPUT; } else if (!DEQUAL(_wtof(checkRule.arrRuleContent.GetAt(i)), 0.0) && !IsPoistive(checkRule.arrRuleContent.GetAt(i))) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return CHECK_RESULT_INVALID_INPUT; } else if (_wtof(checkRule.arrRuleContent.GetAt(i)) > 255.0) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return CHECK_RESULT_INVALID_INPUT; } } Drw3DColorVisitData visitData; visitData.dRed = _wtof(checkRule.arrRuleContent.GetAt(0)); visitData.dGreen = _wtof(checkRule.arrRuleContent.GetAt(1)); visitData.dBlue = _wtof(checkRule.arrRuleContent.GetAt(2)); // 注解 ProMdlNoteVisit(pMdl, Note3DVisitAciton, NULL, &visitData); // 从动尺寸 ProSolidDimensionVisit(ProMdlToSolid(pMdl), PRO_B_FALSE, Dim3DVisitAciton, NULL, &visitData); // 参考尺寸 ProSolidDimensionVisit(ProMdlToSolid(pMdl), PRO_B_TRUE, Dim3DVisitAciton, NULL, &visitData); // 几何公差 ProMdlGtolVisit(pMdl, Gtol3DVisitAciton, NULL, &visitData); // 符号(焊接符号、基准符号) ProSolidDtlsyminstVisit(ProMdlToSolid(pMdl), Symbol3DVisitAciton, NULL, &visitData); // 表面光洁度 ProSolidSurffinishVisit(ProMdlToSolid(pMdl), SurfFin3DVisitAciton, NULL, &visitData); // 基准标签 ProSolidSetdatumtagVisit(ProMdlToSolid(pMdl), DatumTagVisitAciton, NULL, &visitData); checkResult.arrErrorItems.RemoveAll(); if (visitData.arrErrors.GetCount() > 0) { checkResult.arrErrorItems.Copy(visitData.arrErrors); checkResult.nResultType = CHECK_RESULT_ERROR_VALUE; return CHECK_RESULT_ERROR_VALUE; } else { checkResult.nResultType = CHECK_RESULT_NO_ERROR; return CHECK_RESULT_NO_ERROR; } }
ProError CSDMdlMachDeepHoleCheck::DeepHoleGeomitemVisitAction(ProGeomitem *pGeomitem, ProError status, ProAppData data) { ProGeomitemdata *pGeomitemdata; ProSurfacedata *Surdata; ProSurfaceshapedata SufShapedata; ProCylinderdata Cylindata; ProSurface surf ; ProSrftype SurfTyp; status = ProGeomitemToSurface(pGeomitem, &surf); status = ProSurfaceTypeGet(surf, &SurfTyp); if (SurfTyp != PRO_SRF_CYL) { return PRO_TK_NO_ERROR; } status = ProGeomitemdataGet(pGeomitem,&pGeomitemdata); Surdata = (*pGeomitemdata).data.p_surface_data; SufShapedata = (*Surdata).srf_shape; double DeepHole_umax = (*Surdata).uv_max[0]; double DeepHole_vmax = (*Surdata).uv_max[1]; //double DeepHole_umin = (*Surdata).uv_min[0]; double DeepHole_vmin = (*Surdata).uv_min[1]; Cylindata = SufShapedata.cylinder; double cylin_origin[3]; double DeepHole_e1[3]; double DeepHole_e2[3]; double DeepHole_e3[3]; double DeepHole_radius; for (int i = 0; i<3; i++) { cylin_origin[i] = Cylindata.origin[i]; DeepHole_e1[i] = Cylindata.e1[i]; DeepHole_e2[i] = Cylindata.e2[i]; DeepHole_e3[i] = Cylindata.e3[i]; } DeepHole_radius = Cylindata.radius; if (DEQUAL(DeepHole_radius, 0.0)) { return PRO_TK_NO_ERROR; } double DeepHole_point1[3]; double DeepHole_point2[3]; for (int j = 0; j<3; j++) { DeepHole_point1[j] = DeepHole_radius*(cos(DeepHole_umax)*DeepHole_e1[j] + sin(DeepHole_umax)*DeepHole_e2[j]) + DeepHole_vmax*DeepHole_e3[j] + cylin_origin[j]; DeepHole_point2[j] = DeepHole_radius*(cos(DeepHole_umax)*DeepHole_e1[j] + sin(DeepHole_umax)*DeepHole_e2[j]) + DeepHole_vmin*DeepHole_e3[j] + cylin_origin[j]; } double DeepHoleDepth; DeepHoleDepth = sqrt((DeepHole_point1[0] - DeepHole_point2[0])*(DeepHole_point1[0] - DeepHole_point2[0]) + (DeepHole_point1[1] - DeepHole_point2[1])*(DeepHole_point1[1] - DeepHole_point2[1]) + (DeepHole_point1[2] - DeepHole_point2[2])*(DeepHole_point1[2] - DeepHole_point2[2])); ProFeature DeepHoleErrorFeat; int arrDeepHoleErrorSize = (int)(*(DeepHoleFeaVisitData*)data).arrDeepHoleErrorIDs.GetSize(); if ((DeepHoleDepth/DeepHole_radius)>(*(DeepHoleFeaVisitData*)data).dDeepHoleRatio) { (*(DeepHoleFeaVisitData*)data).nDeepHoleResultType = CHECK_RESULT_INVALID_VALUE; status = ProGeomitemFeatureGet(pGeomitem,&DeepHoleErrorFeat); if (0 != arrDeepHoleErrorSize) { for (int k=0; k<arrDeepHoleErrorSize; k++) { if ((*(DeepHoleFeaVisitData*)data).arrDeepHoleErrorIDs[k] == DeepHoleErrorFeat.id) return PRO_TK_NO_ERROR; } } (*(DeepHoleFeaVisitData*)data).arrDeepHoleErrorIDs.Add(DeepHoleErrorFeat.id); } return PRO_TK_NO_ERROR; }
// 检查开始 int CSDMdlAttrParaSpecifiedValueCheck::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 (!IsFilterValid(checkRule.strRuleName, pMdl)) { checkResult.nResultType = CHECK_RESULT_INVALID_MODEL; return checkResult.nResultType; } // 检查输入值有效性 if (checkRule.arrRuleContent.GetCount() < 1) { checkResult.nResultType = CHECK_RESULT_INVALID_INPUT; return checkResult.nResultType; } //----------------------------------------------------------------------------------- ProModelitem mdlItem; ProMdlToModelitem(pMdl, &mdlItem); checkResult.arrErrorItems.RemoveAll(); // 解析参数 CStringArray arrItems; CStringToCStringArray(checkRule.arrRuleContent[0], arrItems, L";"); CString strParaName; int nParaType; CString strParaValue; BOOL bDesignation; for (int i = 0; i < arrItems.GetSize(); i ++) { strParaName = arrItems[i].Left(arrItems[i].Find(L"(")); int nCount = arrItems[i].Find(L")") - arrItems[i].Find(L"(")-1; CString strProperty; strProperty = arrItems[i].Mid(arrItems[i].Find(L"(") + 1, nCount); CStringArray arrPropertys; CStringToCStringArray(strProperty, arrPropertys, L","); nParaType = _wtoi(arrPropertys[0]); strParaValue = arrPropertys[1]; ParseParaValue(mdlItem, strParaValue, strParaValue); bDesignation = _wtoi(arrPropertys[2]); ProName paraname; wcsncpy_s(paraname, PRO_NAME_SIZE, (LPCTSTR)strParaName, _TRUNCATE); ProParameter para; // 判断参数是否存在 ErrorItem item; item.strItemName = strParaName; item.nID = i; if (GetSDParameter(&mdlItem, paraname, para)) { // 检查参数类型 ProParamvalue proval; ProParameterValueGet(¶, &proval); int nType = GetParaType(proval.type); if (nType != nParaType) { item.nType = PARAERROR_TYPE; checkResult.arrErrorItems.Add(item); } else { // 检查参数值 if (PARAM_STRING == nParaType) { if (strParaValue.Compare(proval.value.s_val) != 0) { item.nType = PARAERROR_VALUE; checkResult.arrErrorItems.Add(item); continue; } } else if (PARAM_REAL == nParaType) { if (!DEQUAL(proval.value.d_val, _wtof(strParaValue))) { item.nType = PARAERROR_VALUE; checkResult.arrErrorItems.Add(item); continue; } } else if (PARAM_INTEGER == nParaType) { if (proval.value.i_val != _wtoi(strParaValue)) { item.nType = PARAERROR_VALUE; checkResult.arrErrorItems.Add(item); continue; } } else if (PARAM_BOOL == nParaType) { if (proval.value.l_val != _wtoi(strParaValue)) { item.nType = PARAERROR_VALUE; checkResult.arrErrorItems.Add(item); continue; } } // 检查是否指定 ProBoolean designation; ProParameterDesignationVerify(¶, &designation); if (bDesignation != designation) { item.nType = PARAERROR_DESIGNATION; checkResult.arrErrorItems.Add(item); } } } else { item.nType = PARAERROR_NOEXIST; checkResult.arrErrorItems.Add(item); } } if (checkResult.arrErrorItems.GetCount() > 0) checkResult.nResultType = CHECK_RESULT_ERROR_VALUE; else checkResult.nResultType = CHECK_RESULT_NO_ERROR; return checkResult.nResultType; }
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; }