/** * \author Darryn Campbell (DCC, JRQ768) * \date May 2011 (Initial Creation) */ void CNetworkDetectionBase::run() { CheckConnectivity(); while( !isStopping() ) { wait(m_iNetworkPollInterval / 1000); if (!isStopping()) { CheckConnectivity(); } } LOG(INFO) + "Stopping Network Detection Thread"; }
eConnectionBoxMode CHostTracker::OnTimeoutEvent(int& nPollInterval, int& nBadLinkTimer) { eConnectionBoxMode mode = eNone; nBadLinkTimer = nBadLinkTimer + nPollInterval; nPollInterval = m_iNetworkPollInterval; if( CheckConnectivity()) { LOG(INFO) + "ConnectionChecking: CheckConnectivity passed"; mode = eHideConnectionBox; nBadLinkTimer =0; } else { LOG(INFO) + "ConnectionChecking: CheckConnectivity failed"; mode = eShowConnectionBox; nBadLinkTimer = nBadLinkTimer + m_iPingTimeOut; if(nBadLinkTimer >= m_iConnectionDlgTimeout) { //navigate to badlink rho::String navUrl = rho::common::convertToStringA(m_szBadLinkUrl); RHODESAPP().navigateToUrl(navUrl.c_str()); //set badlink counter to zero nBadLinkTimer =0; mode = eHideConnectionBox; nPollInterval = INFINITE;//once dlg time out happens we have to infinite until we get a navcomplete or any other event } } return mode; }
void HClusterDlg::SpatialConstraintClustering() { int transpose = 0; // row wise fastcluster::cluster_result Z2(rows-1); if (chk_contiguity->GetValue()) { vector<boost::uuids::uuid> weights_ids; WeightsManInterface* w_man_int = project->GetWManInt(); w_man_int->GetIds(weights_ids); int sel = combo_weights->GetSelection(); if (sel < 0) sel = 0; if (sel >= weights_ids.size()) sel = weights_ids.size()-1; boost::uuids::uuid w_id = weights_ids[sel]; GalWeight* gw = w_man_int->GetGal(w_id); if (gw == NULL) { wxMessageDialog dlg (this, _("Invalid Weights Information:\n\n The selected weights file is not valid.\n Please choose another weights file, or use Tools > Weights > Weights Manager\n to define a valid weights file."), _("Warning"), wxOK | wxICON_WARNING); dlg.ShowModal(); return; } //GeoDaWeight* weights = w_man_int->GetGal(w_id); // Check connectivity if (!CheckConnectivity(gw)) { wxString msg = _("The connectivity of selected spatial weights is incomplete, please adjust the spatial weights."); wxMessageDialog dlg(this, msg, _("Warning"), wxOK | wxICON_WARNING ); dlg.ShowModal(); return; } double** ragged_distances = distancematrix(rows, columns, input_data, mask, weight, dist, transpose); double** distances = DataUtils::fullRaggedMatrix(ragged_distances, rows, rows); for (int i = 1; i < rows; i++) free(ragged_distances[i]); free(ragged_distances); std::vector<bool> undefs(rows, false); SpanningTreeClustering::AbstractClusterFactory* redcap = new SpanningTreeClustering::FirstOrderSLKRedCap(rows, columns, distances, input_data, undefs, gw->gal, NULL, 0); for (int i=0; i<redcap->ordered_edges.size(); i++) { Z2[i]->node1 = redcap->ordered_edges[i]->orig->id; Z2[i]->node2 = redcap->ordered_edges[i]->dest->id; Z2[i]->dist = redcap->ordered_edges[i]->length; } delete redcap; } }
void avtDatasetVerifier::VerifyDataset(vtkDataSet *ds, int dom) { int i, j; int nPts = ds->GetNumberOfPoints(); int nCells = ds->GetNumberOfCells(); int nPtVars = ds->GetPointData()->GetNumberOfArrays(); for (i = 0 ; i < nPtVars ; i++) { vtkDataArray *pt_var = ds->GetPointData()->GetArray(i); int nscalars = pt_var->GetNumberOfTuples(); if (nscalars != nPts) { CorrectVarMismatch(pt_var, ds->GetPointData(), nPts); // CorrectVarMismatch invalidates pt_var pointer. Grab it again. pt_var = ds->GetPointData()->GetArray(i); IssueVarMismatchWarning(nscalars, nPts,true,dom,pt_var->GetName()); } } int nCellVars = ds->GetCellData()->GetNumberOfArrays(); for (i = 0 ; i < nCellVars ; i++) { vtkDataArray *cell_var = ds->GetCellData()->GetArray(i); int nscalars = cell_var->GetNumberOfTuples(); if (nscalars != nCells) { CorrectVarMismatch(cell_var, ds->GetCellData(), nCells); // CorrectVarMismatch invalidates cell_var pointer. Grab it again. cell_var = ds->GetCellData()->GetArray(i); bool issueWarning = true; vtkUnsignedCharArray *gz = (vtkUnsignedCharArray *) ds->GetCellData()->GetArray("avtGhostZones"); if (gz != NULL) { int ntuples = gz->GetNumberOfTuples(); int num_real = 0; for (j = 0 ; j < ntuples ; j++) { if (gz->GetValue(j) == '\0') num_real++; } if (num_real == nscalars) { issueWarning = false; debug1 << "The input file has an invalid number of " << "entries in a zonal variable. Since the number" << " of entries corresponds to the number of real " << "zones, no warning is being issued." << endl; } } if (issueWarning) IssueVarMismatchWarning(nscalars, nCells, false, dom, cell_var->GetName()); } } int dims[3]; bool didDims = false; if (ds->GetDataObjectType() == VTK_RECTILINEAR_GRID) { vtkRectilinearGrid *rg = (vtkRectilinearGrid *) ds; rg->GetDimensions(dims); didDims = true; } if (ds->GetDataObjectType() == VTK_STRUCTURED_GRID) { vtkStructuredGrid *sg = (vtkStructuredGrid *) ds; sg->GetDimensions(dims); didDims = true; } if (didDims) { int dimsnpts = (dims[0]*dims[1]*dims[2]); int dimsncells = 1; if (dims[0] > 1) dimsncells *= dims[0]-1; if (dims[1] > 1) dimsncells *= dims[1]-1; if (dims[2] > 1) dimsncells *= dims[2]-1; if (dimsnpts != nPts) { if (! issuedWarningForVarMismatch) { char msg[1024]; sprintf(msg, "Your dimensions were declared to be %d x %d x %d, " "which should mean %d points. But your point " "variables have %d points. This is an unrecoverable " "error.", dims[0], dims[1], dims[2], dimsnpts, nPts); avtCallback::IssueWarning(msg); issuedWarningForVarMismatch = true; } } if (dimsncells != nCells) { if (! issuedWarningForVarMismatch) { char msg[1024]; sprintf(msg, "Your dimensions were declared to be %d x %d x %d, " "which should mean %d cells. But your cell " "variables have %d cells. This is an unrecoverable " "error.", dims[0], dims[1], dims[2], dimsncells, nCells); avtCallback::IssueWarning(msg); issuedWarningForVarMismatch = true; } } } if (avtCallback::GetSafeMode()) { issuedSafeModeWarning = false; if (ds->GetDataObjectType() == VTK_RECTILINEAR_GRID) { vtkRectilinearGrid *rg = (vtkRectilinearGrid *) ds; CheckArray(dom, rg->GetXCoordinates(), "X-coordinates"); CheckArray(dom, rg->GetYCoordinates(), "Y-coordinates"); CheckArray(dom, rg->GetZCoordinates(), "Z-coordinates"); } else if (ds->GetDataObjectType() == VTK_STRUCTURED_GRID) { vtkStructuredGrid *sg = (vtkStructuredGrid *) ds; CheckArray(dom, sg->GetPoints()->GetData(), "Coordinates"); } else if (ds->GetDataObjectType() == VTK_UNSTRUCTURED_GRID) { vtkUnstructuredGrid *ug = (vtkUnstructuredGrid *) ds; CheckArray(dom, ug->GetPoints()->GetData(), "Coordinates"); CheckConnectivity(dom, ug->GetNumberOfPoints(), ug->GetCells(), "Cells"); } else if (ds->GetDataObjectType() == VTK_POLY_DATA) { vtkPolyData *pd = (vtkPolyData *) ds; CheckArray(dom, pd->GetPoints()->GetData(), "Coordinates"); CheckConnectivity(dom, pd->GetNumberOfPoints(), pd->GetVerts(), "Vertex Cells"); CheckConnectivity(dom, pd->GetNumberOfPoints(), pd->GetLines(), "Line Cells"); CheckConnectivity(dom, pd->GetNumberOfPoints(), pd->GetPolys(), "Polygon Cells"); CheckConnectivity(dom, pd->GetNumberOfPoints(), pd->GetStrips(), "Triangle Strip Cells"); } for (int i = 0 ; i < 2 ; i++) { vtkDataSetAttributes *atts = NULL; if (i == 0) atts = ds->GetCellData(); else atts = ds->GetPointData(); int narr = atts->GetNumberOfArrays(); for (int j = 0 ; j < narr ; j++) { vtkDataArray *arr = atts->GetArray(j); const char *name = arr->GetName(); if (name == NULL) { if (i == 0) name = "Unnamed Cell Var"; else name = "Unnamed Point Var"; } CheckArray(dom, arr, name); } } } }