// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AlignSections::execute() { setErrorCondition(0); VoxelDataContainer* m = getVoxelDataContainer(); if (NULL == m) { setErrorCondition(-1); std::stringstream ss; ss << " DataContainer was NULL"; notifyErrorMessage(ss.str(), -1); return; } int64_t totalPoints = m->getTotalPoints(); size_t numgrains = m->getNumFieldTuples(); size_t numensembles = m->getNumEnsembleTuples(); dataCheck(false, totalPoints, numgrains, numensembles); if (getErrorCondition() < 0) { return; } size_t udims[3] = {0,0,0}; m->getDimensions(udims); #if (CMP_SIZEOF_SIZE_T == 4) typedef int32_t DimType; #else typedef int64_t DimType; #endif DimType dims[3] = { static_cast<DimType>(udims[0]), static_cast<DimType>(udims[1]), static_cast<DimType>(udims[2]), }; int slice; int xspot, yspot; DimType newPosition; DimType currentPosition; // unsigned int phase2; std::vector<int> xshifts; std::vector<int> yshifts; xshifts.resize(dims[2],0); yshifts.resize(dims[2],0); find_shifts(xshifts, yshifts); std::list<std::string> voxelArrayNames = m->getCellArrayNameList(); DimType progIncrement = dims[2]/100; DimType prog = 1; int progressInt = 0; std::stringstream ss; for (DimType i = 1; i < dims[2]; i++) { if (i > prog) { ss.str(""); progressInt = ((float)i/dims[2])*100.0; ss << "Transferring Cell Data - " << progressInt << "% Complete"; notifyStatusMessage(ss.str()); prog = prog + progIncrement; } if (getCancel() == true) { return; } slice = static_cast<int>( (dims[2] - 1) - i ); for (DimType l = 0; l < dims[1]; l++) { for (DimType n = 0; n < dims[0]; n++) { if(yshifts[i] >= 0) yspot = static_cast<int>(l); else if(yshifts[i] < 0) yspot = static_cast<int>( dims[1] - 1 - l ); if(xshifts[i] >= 0) xspot = static_cast<int>(n); else if(xshifts[i] < 0) xspot = static_cast<int>( dims[0] - 1 - n ); newPosition = (slice * dims[0] * dims[1]) + (yspot * dims[0]) + xspot; currentPosition = (slice * dims[0] * dims[1]) + ((yspot + yshifts[i]) * dims[0]) + (xspot + xshifts[i]); if((yspot + yshifts[i]) >= 0 && (yspot + yshifts[i]) <= dims[1] - 1 && (xspot + xshifts[i]) >= 0 && (xspot + xshifts[i]) <= dims[0] - 1) { for(std::list<std::string>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) { std::string name = *iter; IDataArray::Pointer p = m->getCellData(*iter); p->CopyTuple(currentPosition, newPosition); } } if((yspot + yshifts[i]) < 0 || (yspot + yshifts[i]) > dims[1] - 1 || (xspot + xshifts[i]) < 0 || (xspot + xshifts[i]) > dims[0] - 1) { for(std::list<std::string>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) { std::string name = *iter; IDataArray::Pointer p = m->getCellData(*iter); p->InitializeTuple(newPosition, 0.0); } } } } } // If there is an error set this to something negative and also set a message notifyStatusMessage("Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void OpenCloseBadData::execute() { setErrorCondition(0); // int err = 0; VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); return; } int64_t totalPoints = m->getTotalPoints(); dataCheck(false, totalPoints, m->getNumFieldTuples(), m->getNumEnsembleTuples()); if (getErrorCondition() < 0 && getErrorCondition() != -305) { return; } setErrorCondition(0); Int32ArrayType::Pointer neighborsPtr = Int32ArrayType::CreateArray(totalPoints, "Neighbors"); m_Neighbors = neighborsPtr->GetPointer(0); neighborsPtr->initializeWithValues(-1); size_t udims[3] = {0,0,0}; m->getDimensions(udims); #if (CMP_SIZEOF_SIZE_T == 4) typedef int32_t DimType; #else typedef int64_t DimType; #endif DimType dims[3] = { static_cast<DimType>(udims[0]), static_cast<DimType>(udims[1]), static_cast<DimType>(udims[2]), }; // size_t count = 1; int good = 1; // int neighbor; // int index = 0; // float x, y, z; // DimType row, plane; int neighpoint; size_t numgrains = m->getNumFieldTuples(); int neighpoints[6]; neighpoints[0] = static_cast<int>(-dims[0] * dims[1]); neighpoints[1] = static_cast<int>(-dims[0]); neighpoints[2] = static_cast<int>(-1); neighpoints[3] = static_cast<int>(1); neighpoints[4] = static_cast<int>(dims[0]); neighpoints[5] = static_cast<int>(dims[0] * dims[1]); std::vector<int> currentvlist; size_t count = 0; int kstride, jstride; int grainname, grain; int current; int most; std::vector<int > n(numgrains + 1,0); for (int iteration = 0; iteration < m_NumIterations; iteration++) { for (int k = 0; k < dims[2]; k++) { kstride = static_cast<int>( dims[0]*dims[1]*k ); for (int j = 0; j < dims[1]; j++) { jstride = static_cast<int>( dims[0]*j ); for (int i = 0; i < dims[0]; i++) { count = kstride+jstride+i; std::stringstream ss; grainname = m_GrainIds[count]; if (grainname == 0) { current = 0; most = 0; for (int l = 0; l < 6; l++) { good = 1; neighpoint = static_cast<int>( count + neighpoints[l] ); if (l == 0 && k == 0) good = 0; if (l == 5 && k == (dims[2] - 1)) good = 0; if (l == 1 && j == 0) good = 0; if (l == 4 && j == (dims[1] - 1)) good = 0; if (l == 2 && i == 0) good = 0; if (l == 3 && i == (dims[0] - 1)) good = 0; if (good == 1) { grain = m_GrainIds[neighpoint]; if (m_Direction == 0 && grain > 0) { m_Neighbors[neighpoint] = count; } if ((grain > 0 && m_Direction == 1)) { n[grain]++; current = n[grain]; if (current > most) { most = current; m_Neighbors[count] = neighpoint; } } } } if (m_Direction == 1) { for (int l = 0; l < 6; l++) { good = 1; neighpoint = static_cast<int>( count + neighpoints[l] ); if (l == 0 && k == 0) good = 0; if (l == 5 && k == (dims[2] - 1)) good = 0; if (l == 1 && j == 0) good = 0; if (l == 4 && j == (dims[1] - 1)) good = 0; if (l == 2 && i == 0) good = 0; if (l == 3 && i == (dims[0] - 1)) good = 0; if (good == 1) { grain = m_GrainIds[neighpoint]; n[grain] = 0; } } } } } } } std::list<std::string> voxelArrayNames = m->getCellArrayNameList(); for (int j = 0; j < totalPoints; j++) { int grainname = m_GrainIds[j]; int neighbor = m_Neighbors[j]; if (neighbor >= 0) { if ( (grainname == 0 && m_GrainIds[neighbor] > 0 && m_Direction == 1) || (grainname > 0 && m_GrainIds[neighbor] == 0 && m_Direction == 0)) { for(std::list<std::string>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) { std::string name = *iter; IDataArray::Pointer p = m->getCellData(*iter); p->CopyTuple(neighbor, j); } } } } } // If there is an error set this to something negative and also set a message notifyStatusMessage("Complete"); }