//play game //it was hard for the part of an oscillation of two alternating patterns is reached // and I couldnt figure out the logic to put that in my code int Game(int g, int *gf, int *sp, int a[row][col], int b[row][col], int c[row][col]){ int s = 1; int curGen = 0; while (s){ //if gen is 0 stop game if (g == curGen ){ s =0; } else{ //need to figure out how to switch arrays in parameters until gen count is out //and how to switch them into TransferArray method if (curGen%3 ==1 || curGen%3 == 0){ TransferArray(a,b); *gf = two; // check a b to see if the same if (CheckArray(a,b,row,col) == 1){ *sp = 1; s= 0; } // check b c to see if the same if (CheckArray(b,c,row,col) == 1){ *sp = 1; s= 0; } } else if (curGen%3 == 2){ TransferArray(b,c); *gf = three; // check b c if (CheckArray(b,c,row,col) == 1){ *sp = 1; s= 0; } // check a c if (CheckArray(a,c,row,col) == 1){ *sp = 1; s= 0; } } else{ TransferArray(c,a); *gf = one; // check a c if (CheckArray(a,c,row,col) == 1){ *sp = 1; s= 0; } // check a b if (CheckArray(a,b,row,col) == 1){ *sp = 1; s= 0; } } curGen++; } } return curGen; }
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); } } } }