void SelectFaceEdge (brush_t* b, face_t *f, int p1, int p2) { winding_t *w; int i, j, k; int pnum[128]; w = Brush_MakeFaceWinding (b, f); if (!w) return; for (i=0 ; i<w->numpoints ; i++) pnum[i] = FindPoint (w->points[i]); for (i=0 ; i<w->numpoints ; i++) if (pnum[i] == p1 && pnum[(i+1)%w->numpoints] == p2) { VectorCopy (g_qeglobals.d_points[pnum[i]], f->planepts[0]); VectorCopy (g_qeglobals.d_points[pnum[(i+1)%w->numpoints]], f->planepts[1]); VectorCopy (g_qeglobals.d_points[pnum[(i+2)%w->numpoints]], f->planepts[2]); for (j=0 ; j<3 ; j++) { for (k=0 ; k<3 ; k++) { f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize; } } AddPlanept (f->planepts[0]); AddPlanept (f->planepts[1]); break; } if (i == w->numpoints) Sys_Printf ("SelectFaceEdge: failed\n"); free (w); }
bool QuadtreeValidator<T,D>::ValidateQuadtree(const Quadtree<T,D>* root, std::vector<vec<T,D>>& pointSet) const { bool valid = true; printf("\nChecking quadtree validity:\n"); // Check if all points can be found for(std::vector<vec<T,D>>::iterator it = pointSet.begin(); it != pointSet.end(); ++it) { if(!FindPoint(root, &(*it))) { printf("Could not find point: %s\n", it->ToString().c_str()); valid = false; } } // Print results if(valid) { printf("All points were found in the quadtree.\n"); } else { printf("ERROR: Not all points were found in the quadtree.\n"); } // Check pointers if( ValidatePointers(root) ) { printf("All pointers in the quadtree are correct.\n"); } else { printf("ERROR: There was a problem with the pointers between nodes in the quadtree.\n"); valid = false; } // Check if nodes are contained in their parent. if( ValidateNodeContainment(root) ) { printf("All quadtree boxes are contained in their parent.\n"); } else { printf("ERROR: Not all quadtree boxes are contained in their parent.\n"); valid = false; } // Print overall results if(valid) { printf("Quadtree is correct!\n\n"); } else { printf("ERROR: Quadtree is not correct.\n\n"); } return valid; }
/*! \brief 获取遥脉量 RemotePulse \fn CProtocolCDT::ProcessRPInfoWord \param frameInfoWord 信息字 */ void CProtocolCDT::ProcessRPInfoWord(CBaseFrame &frameInfoWord, int n_SrcStationAddress_) { FRAME_RP_TYPE *pValue; pValue = (FRAME_RP_TYPE *)frameInfoWord.GetBuffer(1); BYTE nFunctionCode=frameInfoWord[0];//功能码 int nPoint = nFunctionCode-0XA0; CPointCDT *pPoint = FindPoint(n_SrcStationAddress_, 0xA0, nPoint); // qDebug()<<"遥脉量nPoint:"<<nPoint<<"value:"<<frameInfoWord.GetUIntValue(1,4)<<pPoint; if (pPoint == NULL) return; // IPoint * pTag = FindPoint(0XA0,nPoint); // if(pTag == NULL) // return; if(pValue->INVALID == 1)//无效 return; if(pValue->BCD == 1)//bcd码 { QVariant VarProject_(BCD2Int(pValue,3)/100.0); QVariant VarOriginal_(BCD2Int(pValue,3)/100.0); pPoint->SetValue(pPoint,VarProject_,VarOriginal_); // pTag->SetIntValue(BCD2Int(pValue,3)/100.0); } else//二进制码 { QVariant VarProject_(pValue->VALUE); QVariant VarOriginal_(pValue->VALUE); pPoint->SetValue(pPoint,VarProject_,VarOriginal_); // pTag->SetIntValue(pValue->VALUE); } }
void __fastcall TMdiMap::MapDblClick(TObject *Sender) { if (BeginPoint==NULL && !PointIsMove) { KANSPOINT::iterator selected; selected=FindPoint(Xa,Ya); if (selected!=NULL) { BeginPoint=selected; PointIsMove=true; Map->Refresh(); } } else if (BeginPoint!=NULL && PointIsMove) { KANSPOINT::iterator selected; MapPoint->PlaceInp = PP_PICTURE; MapPoint->PlaceOut = PP_PLANE; MapPoint->X=Xa+Map->MapLeft; MapPoint->Y=Ya+Map->MapTop; (*BeginPoint).X=MapPoint->X; (*BeginPoint).Y=MapPoint->Y; (*BeginPoint).h=mapGetHeightValue(Map->MapHandle,MapPoint->X,MapPoint->Y); PointIsMove=false; BeginPoint=NULL; Map->Refresh(); } }
BPoint AttributeMessage::GetAttribute(const char *name, BPoint defaultValue) const { BPoint value; if (FindPoint(name, &value) != B_OK) return defaultValue; return value; }
myinline const BPoint ArpMessage::GetPoint(const char *name, const BPoint& def, int32 index) const { if( this ) { BPoint res; if( FindPoint(name, index, &res) != B_NO_ERROR ) return def; return res; } return def; }
void PathFinder::_AddIfPassable(const IE::point& point, const point_node& current, std::list<point_node*>& openList, std::list<point_node*>& closedList) { if (point.x < 0 || point.y < 0 || !_IsPassable(point)) return; // Check if point is in closed list std::list<point_node*>::const_iterator i = std::find_if(closedList.begin(), closedList.end(), FindPoint(point)); if (i != closedList.end()) { point_node* node = *i; const int newCost = CalculateCost(current.point, node->point) + current.cost; if (newCost < node->cost) { node->parent = ¤t; node->cost = newCost; } return; } i = std::find_if(openList.begin(), openList.end(), FindPoint(point)); if (i != openList.end()) { point_node* node = *i; // Point is already on the open list. // Check if getting through the point from this point // is cheaper. If so, set this as parent. const int newCost = CalculateCost(current.point, node->point) + current.cost; if (newCost < node->cost) { node->parent = ¤t; node->cost = newCost; } } else { const int cost = CalculateCost(point, current.point) + current.cost; point_node* newNode = new point_node(point, ¤t, cost); openList.push_back(newNode); } }
void __fastcall TMdiMap::popupBeginPointClick(TObject *Sender) { KANSPOINT::iterator selected; selected=FindPoint(Xa,Ya); if (selected!=NULL) { BeginPoint=selected; Map->Refresh(); } }
void __fastcall TMdiMap::N6Click(TObject *Sender) { KANSPOINT::iterator deleted; deleted=FindPoint(Xa,Ya); if (deleted!=NULL) { KANSPoints.erase(deleted); Map->Refresh(); } }
int PrioritySearchTree<T_Point>:: FindPoint(KeyType pointKey, int curVertexIndex, int &pointVertexIndex) { if ((*treePtr)[curVertexIndex].isALeaf) { pointVertexIndex = curVertexIndex; return (*treePtr)[curVertexIndex].medianKey == pointKey; } else { if (pointKey <= (*treePtr)[curVertexIndex].medianKey) { return FindPoint(pointKey, (*treePtr)[curVertexIndex].leftChildIndex, pointVertexIndex); } else { return FindPoint(pointKey, (*treePtr)[curVertexIndex].rightChildIndex, pointVertexIndex); } } }
void Preferences::LoadWindowPosition(BWindow* window, const char* name) { Lock(); BPoint p; if (FindPoint(name, &p) == B_OK) { window->MoveTo(p); make_window_visible(window); } Unlock(); }
void MakeFace (brush_t* b, face_t *f) { winding_t *w; int i; int pnum[128]; w = Brush_MakeFaceWinding (b, f); if (!w) return; for (i=0 ; i<w->numpoints ; i++) pnum[i] = FindPoint (w->points[i]); for (i=0 ; i<w->numpoints ; i++) FindEdge (pnum[i], pnum[(i+1)%w->numpoints], f); free (w); }
void __fastcall TMdiMap::popupPaintSegmentClick(TObject *Sender) { if (BeginPoint!=NULL && !PointIsMove) { KANSPOINT::iterator selected; selected=FindPoint(Xa,Ya); if (selected!=NULL && selected!=BeginPoint) { KANSTruba a; a.BegPoint = BeginPoint; a.EndPoint = selected; KANSTruby.push_back(a); BeginPoint=NULL; Map->Refresh();//PaintObj(); } } }
/*! \brief 获取总加遥测量 TotalMeasure \fn CProtocolCDT::ProcessTMInfoWord \param frameInfoWord 信息字 */ void CProtocolCDT::ProcessTMInfoWord(CBaseFrame &frameInfoWord, int n_SrcStationAddress_) { BYTE nFunctionCode = frameInfoWord[0];//功能码 for(int i=0; i<2; i++) { int nPoint = (nFunctionCode-0x86)*2+i; CPointCDT *pPoint = FindPoint(n_SrcStationAddress_, 0x86, nPoint); // qDebug()<<"总加遥测量nPoint:"<<nPoint<<"value:"<<frameInfoWord.GetUIntValue(1+i*2,2)<<pPoint; if (pPoint == NULL) continue; float fValue = (frameInfoWord.GetUIntValue(1+i*2,2)+pPoint->m_fBaseValue)*pPoint->m_fKValue; // qDebug()<<fValue<<frameInfoWord.GetUIntValue(1+i*2,2)<<pPoint->m_strPointName<<pPoint->m_fBaseValue<<pPoint->m_fKValue; QVariant VarProject_(fValue); QVariant VarOriginal_(frameInfoWord.GetUIntValue(1+i*2,2)); pPoint->SetValue(pPoint,VarProject_,VarOriginal_); } }
/*! \brief 获取遥信量 RemoteSignal \fn CProtocolCDT::ProcessRSInfoWord \param frameInfoWord 信息字 */ void CProtocolCDT::ProcessRSInfoWord(CBaseFrame &frameInfoWord, int n_SrcStationAddress_) { BYTE nFunctionCode=frameInfoWord[0];//功能码 for(int i=1; i<5; i++) { for(int j=0; j<8; j++) { BYTE nOffset = (i-1)*8+j; int nPoint = (nFunctionCode-0XF0)*32+nOffset; CPointCDT *pPoint = FindPoint(n_SrcStationAddress_, 0xF0, nPoint); // qDebug()<<"遥信量nPoint:"<<nPoint<<"value:"<<frameInfoWord.GetBit(1,nOffset)<<pPoint; if (pPoint == NULL) continue; // qDebug()<<frameInfoWord.GetBit(1,nOffset)<<pPoint->m_strPointName; QVariant VarProject_(frameInfoWord.GetBit(1,nOffset)); QVariant VarOriginal_(frameInfoWord.GetBit(1,nOffset)); pPoint->SetValue(pPoint,VarProject_,VarOriginal_); } } }
void MakeFace (face_t *f) #endif { winding_t *w; int i; int pnum[128]; #ifdef NEWEDGESEL w = Brush_MakeFaceWinding (b, f); #else w = Brush_MakeFaceWinding (selected_brushes.next, f); #endif if (!w) return; for (i=0 ; i<w->numpoints ; i++) pnum[i] = FindPoint (w->points[i]); for (i=0 ; i<w->numpoints ; i++) FindEdge (pnum[i], pnum[(i+1)%w->numpoints], f); free (w); }
void SelectFaceEdge (face_t * f, int p1, int p2) #endif { idWinding *w; int i, j, k; int pnum[128]; #ifdef NEWEDGESEL w = Brush_MakeFaceWinding(b, f); #else w = Brush_MakeFaceWinding(selected_brushes.next, f); #endif if (!w) { return; } for (i = 0; i < w->GetNumPoints(); i++) { pnum[i] = FindPoint( (*w)[i].ToVec3() ); } for (i = 0; i < w->GetNumPoints(); i++) { if (pnum[i] == p1 && pnum[(i + 1) % w->GetNumPoints()] == p2) { VectorCopy(g_qeglobals.d_points[pnum[i]], f->planepts[0]); VectorCopy(g_qeglobals.d_points[pnum[(i + 1) % w->GetNumPoints()]], f->planepts[1]); VectorCopy(g_qeglobals.d_points[pnum[(i + 2) % w->GetNumPoints()]], f->planepts[2]); for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) { f->planepts[j][k] = floor(f->planepts[j][k] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize; } } AddPlanept(&f->planepts[0]); AddPlanept(&f->planepts[1]); break; } } if ( i == w->GetNumPoints() ) { Sys_Status("SelectFaceEdge: failed\n"); } delete w; }
void SelectVertex (int p1) { brush_t *b; winding_t *w; int i, j, k; face_t *f; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { w = Brush_MakeFaceWinding (b, f); if (!w) continue; for (i=0 ; i<w->numpoints ; i++) { if (FindPoint (w->points[i]) == p1) { VectorCopy (w->points[(i+w->numpoints-1)%w->numpoints], f->planepts[0]); VectorCopy (w->points[i], f->planepts[1]); VectorCopy (w->points[(i+1)%w->numpoints], f->planepts[2]); for (j=0 ; j<3 ; j++) { for (k=0 ; k<3 ; k++) { ;//f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize; } } AddPlanept (f->planepts[1]); //MessageBeep(-1); break; } } free (w); } } }
void MakeFace (face_t * f) #endif { idWinding *w; int i; int pnum[128]; #ifdef NEWEDGESEL w = Brush_MakeFaceWinding(b, f); #else w = Brush_MakeFaceWinding(selected_brushes.next, f); #endif if (!w) { return; } for (i = 0; i < w->GetNumPoints(); i++) { pnum[i] = FindPoint( (*w)[i].ToVec3() ); } for (i = 0; i < w->GetNumPoints(); i++) { FindEdge(pnum[i], pnum[(i + 1) % w->GetNumPoints()], f); } delete w; }
/*! \brief 处理遥测信息字,获取遥测量 RemoteMeasure \fn CProtocolCDT::ProcessRMInfoWord \param frameInfoWord 信息字 */ void CProtocolCDT::ProcessRMInfoWord(CBaseFrame &frameInfoWord, int n_SrcStationAddress_) { FRAME_RM_TYPE *pValue; BYTE nFunctionCode=frameInfoWord[0];//功能码 for(int i=0; i<2;i++) { int nPoint = nFunctionCode*2+i; pValue=(FRAME_RM_TYPE *)frameInfoWord.GetBuffer(1+i*2); CPointCDT *pPoint = FindPoint(n_SrcStationAddress_,0,nPoint); // qDebug()<<"遥测信息nPoint:"<<nPoint<<"value:"<<pValue->VALUE<<pPoint; if (pPoint == NULL) continue; if(!pValue->OVERFALL && !pValue->INVALID) { float fValue = (pValue->VALUE+pPoint->m_fBaseValue)*pPoint->m_fKValue; // qDebug()<<fValue<<pValue->VALUE<<pPoint->m_strPointName<<pPoint->m_fBaseValue<<pPoint->m_fKValue; QVariant VarProject_(fValue); QVariant VarOriginal_(pValue->VALUE); pPoint->SetValue(pPoint,VarProject_,VarOriginal_); } } }
bool CJavaScript_Protocol::OnCreateChannel(CJavaScript_ProtocolI::JAVASCRIPT_CONTROL_TYPE nType_, const QDomElement elemControl_, CRTDBI *pRealDatabase) { m_pRTDB = pRealDatabase; m_nType = nType_; qDebug()<<__func__<<__LINE__<<"CJavaScript_Protocol"<<nType_; // QString elemControlTagName = elemControl_.tagName(); switch (m_nType) { case CJavaScript_ProtocolI::Control_Undefined: return false; break; case CJavaScript_ProtocolI::Control_Start: break; case CJavaScript_ProtocolI::Control_Cycle: break; case CJavaScript_ProtocolI::Control_Timing: break; case CJavaScript_ProtocolI::Control_DateChange: {///< 数据改变 qDebug()<<__func__<<__LINE__<<"CJavaScript_Protocol 2"<<nType_<<elemControl_.tagName(); QDomNodeList JavaScriptList = elemControl_.elementsByTagName("JavaScript"); /// 添加点 for (int nJavaScriptCount = 0; nJavaScriptCount < JavaScriptList.count(); ++nJavaScriptCount) { QDomElement Elem_JavaScript = JavaScriptList.at(nJavaScriptCount).toElement(); qDebug()<<__func__<<__LINE__<<"CJavaScript_Protocol 3"<<Elem_JavaScript.attribute("Script"); QDomNodeList PointNodeList = Elem_JavaScript.elementsByTagName("Point"); // QString strScript = Elem_JavaScript.attribute("Script"); // QString strDesc = Elem_JavaScript.attribute("Desc"); for (int nPointCount = 0; nPointCount < PointNodeList.count(); ++nPointCount) { QDomElement elemPoint = PointNodeList.at(nPointCount).toElement(); qDebug()<<__func__<<__LINE__<<"CJavaScript_Protocol 4"<<elemPoint.attribute("Link"); Point *pPoint = new Point; pPoint->m_strLink = elemPoint.attribute("Link"); CTagI *pTag = m_pRTDB->FindTag(pPoint->m_strLink); if (pTag) { pPoint->m_pTag = pTag; // pPoint->m_pTag->SetNotify(pPoint);///设置转发点 这里不设置转发点 AddPoint(pPoint); } } }/// 添加点结束 /// 初始化JS脚本 for (int nJavaScriptCount = 0; nJavaScriptCount < JavaScriptList.count(); ++nJavaScriptCount) { QDomElement Elem_JavaScript = JavaScriptList.at(nJavaScriptCount).toElement(); QDomNodeList PointNodeList = Elem_JavaScript.elementsByTagName("Point"); QString strScript = Elem_JavaScript.attribute("Script"); QString strDesc = Elem_JavaScript.attribute("Desc"); qDebug()<<__func__<<__LINE__<<strScript<<strDesc; JavaScript *pJavaScript = NULL; for (int nPointCount = 0; nPointCount < PointNodeList.count(); ++nPointCount) { QDomElement elemPoint = PointNodeList.at(nPointCount).toElement(); QString strLink = elemPoint.attribute("Link"); CTagI *pTag = m_pRTDB->FindTag(strLink); if (pTag == NULL) { break; } if (FindPoint(strLink) == NULL) { break; } if (pJavaScript == NULL) { pJavaScript = new JavaScript; pJavaScript->m_strScript = strScript; } CJavaScript_DataChange_Point *pPoint = new CJavaScript_DataChange_Point; pPoint->m_strLink = strLink; pPoint->m_pProtocol = this; pPoint->m_pTag = pTag; pPoint->m_pTag->SetNotify(pPoint);///设置转发点 pPoint->AddJavaScript(pJavaScript); PointStruct *pPointStruct = new PointStruct; pPointStruct->m_strLink = strLink; pPointStruct->m_strName = elemPoint.attribute("Name"); // pPointStruct->m_pPoint = FindPoint(strLink); pPointStruct->m_pPoint = pPoint; pJavaScript->m_PointStructMap.insert(strLink,pPointStruct); qDebug()<<"111111111"<<__func__<<__LINE__<<strScript<<strDesc<<strLink; } qDebug()<<"SCRIPT="<<Elem_JavaScript.attribute("Script"); }/// 初始化JS脚本 结束 } break; default: break; } // if (elemControlTagName == "ControlCycle") // {///< 循环 // }else if (elemControlTagName == "ControlTiming") // {///< 定时 // }else if (elemControlTagName == "ControlDateChange") // {///< 数据改变 // QDomNodeList JavaScriptList = elemControl_.elementsByTagName("JavaScript"); // /// 添加点 // for (int nJavaScriptCount = 0; nJavaScriptCount < JavaScriptList.count(); ++nJavaScriptCount) // { // QDomElement Elem_JavaScript = JavaScriptList.at(nJavaScriptCount).toElement(); // QDomNodeList PointNodeList = Elem_JavaScript.elementsByTagName("Point"); //// QString strScript = Elem_JavaScript.attribute("Script"); //// QString strDesc = Elem_JavaScript.attribute("Desc"); // for (int nPointCount = 0; nPointCount < PointNodeList.count(); ++nPointCount) // { // QDomElement elemPoint = PointNodeList.at(nPointCount).toElement(); // Point *pPoint = new Point; // pPoint->m_strLink = elemPoint.attribute("Link"); // CTagI *pTag = m_pRTDB->FindTag(pPoint->m_strLink); // if (pTag) // { // pPoint->m_pTag = pTag; //// pPoint->m_pTag->SetNotify(pPoint);///设置转发点 这里不设置转发点 // AddPoint(pPoint); // } // } // }/// 添加点结束 // /// 初始化JS脚本 // for (int nJavaScriptCount = 0; nJavaScriptCount < JavaScriptList.count(); ++nJavaScriptCount) // { // QDomElement Elem_JavaScript = JavaScriptList.at(nJavaScriptCount).toElement(); // QDomNodeList PointNodeList = Elem_JavaScript.elementsByTagName("Point"); // QString strScript = Elem_JavaScript.attribute("Script"); // QString strDesc = Elem_JavaScript.attribute("Desc"); // qDebug()<<__func__<<__LINE__<<strScript<<strDesc; // JavaScript *pJavaScript = NULL; // for (int nPointCount = 0; nPointCount < PointNodeList.count(); ++nPointCount) // { // QDomElement elemPoint = PointNodeList.at(nPointCount).toElement(); // QString strLink = elemPoint.attribute("Link"); // CTagI *pTag = m_pRTDB->FindTag(strLink); // if (pTag == NULL) // { // break; // } // if (FindPoint(strLink) == NULL) // { // break; // } // if (pJavaScript == NULL) // { // pJavaScript = new JavaScript; // pJavaScript->m_strScript = strScript; // } // CJavaScript_DataChange_Point *pPoint = new CJavaScript_DataChange_Point; // pPoint->m_strLink = strLink; // pPoint->m_pProtocol = this; // pPoint->m_pTag = pTag; // pPoint->m_pTag->SetNotify(pPoint);///设置转发点 // pPoint->AddJavaScript(pJavaScript); // PointStruct *pPointStruct = new PointStruct; // pPointStruct->m_strLink = strLink; // pPointStruct->m_strName = elemPoint.attribute("Name"); // pPointStruct->m_pPoint = FindPoint(strLink); // pJavaScript->m_PointStructMap.insert(strLink,pPointStruct); // } // qDebug()<<"SCRIPT="<<Elem_JavaScript.attribute("Script"); // }/// 初始化JS脚本 结束 // }else // { // return false; // } return true; }
/* ======================================================================================================================= ======================================================================================================================= */ void SelectVertex(int p1) { brush_t *b; idWinding *w; int i, j, k; face_t *f; #ifdef NEWEDGESEL for (b = selected_brushes.next; b != &selected_brushes; b = b->next) { for (f = b->brush_faces; f; f = f->next) { w = Brush_MakeFaceWinding(b, f); if (!w) { continue; } for (i = 0; i < w->GetNumPoints(); i++) { if ( FindPoint( (*w)[i].ToVec3() ) == p1 ) { VectorCopy((*w)[(i + w->GetNumPoints() - 1) % w->GetNumPoints()], f->planepts[0]); VectorCopy((*w)[i], f->planepts[1]); VectorCopy((*w)[(i + 1) % w->GetNumPoints()], f->planepts[2]); for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) { // f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize; } } AddPlanept(&f->planepts[1]); // MessageBeep(-1); break; } } delete w; } } #else b = selected_brushes.next; for (f = b->brush_faces; f; f = f->next) { w = Brush_MakeFaceWinding(b, f); if (!w) { continue; } for (i = 0; i < w->GetNumPoints(); i++) { if (FindPoint(w[i]) == p1) { VectorCopy(w[(i + w->GetNumPoints() - 1) % w->GetNumPoints()], f->planepts[0]); VectorCopy(w[i], f->planepts[1]); VectorCopy(w[(i + 1) % w->GetNumPoints()], f->planepts[2]); for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) { // f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize; } } AddPlanept(&f->planepts[1]); // MessageBeep(-1); break; } } delete w; } #endif }