// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int AvizoUniformCoordinateWriter::writeData(MXAFileWriter64 &writer) { std::string start("@1\n"); writer.writeString(start); if(true == m_WriteBinaryFile) { writer.writeArray(m_GrainIds, getVoxelDataContainer()->getTotalPoints()); } else { // The "20 Items" is purely arbitrary and is put in to try and save some space in the ASCII file int64_t totalPoints = getVoxelDataContainer()->getTotalPoints(); int count = 0; std::stringstream ss; for (int64_t i = 0; i < totalPoints; ++i) { ss << m_GrainIds[i]; if(count < 20) { ss << " "; count++; } else { ss << "\n"; writer.writeString(ss.str()); ss.str(""); count = 0; } } // Pick up any remaining data that was not written because we did not have 20 items on a line. writer.writeString(ss.str()); } return 1; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void GenerateSurfaceMeshConnectivity::execute() { int err = 0; std::stringstream ss; setErrorCondition(err); VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The Voxel DataContainer Object was NULL", -999); return; } setErrorCondition(0); dataCheck(false, 1, 1, 1); if (getErrorCondition() < 0) { return; } // We need the vertex->Triangle Lists to build the Triangle Neighbor lists so if either // of those are true then build the vertex->triangle lists if (m_GenerateVertexTriangleLists == true || m_GenerateTriangleNeighbors == true) { notifyStatusMessage("Generating Vertex Triangle List"); getSurfaceMeshDataContainer()->buildMeshVertLinks(); } if (m_GenerateTriangleNeighbors == true) { notifyStatusMessage("Generating Face Neighbors List"); getSurfaceMeshDataContainer()->buildMeshFaceNeighborLists(); } if (m_GenerateEdgeIdList == true) { // There was no Edge connectivity before this filter so delete it when we are done with it GenerateUniqueEdges::Pointer conn = GenerateUniqueEdges::New(); ss.str(""); ss << getMessagePrefix() << " |->Generating Unique Edge Ids |->"; conn->setMessagePrefix(ss.str()); conn->setObservers(getObservers()); conn->setVoxelDataContainer(getVoxelDataContainer()); conn->setSurfaceMeshDataContainer(getSurfaceMeshDataContainer()); conn->setSolidMeshDataContainer(getSolidMeshDataContainer()); conn->execute(); if(conn->getErrorCondition() < 0) { setErrorCondition(conn->getErrorCondition()); return; } } /* Let the GUI know we are done with this filter */ notifyStatusMessage("Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- std::string AvizoUniformCoordinateWriter::generateHeader() { std::stringstream ss; if(m_WriteBinaryFile == true) { #ifdef CMP_WORDS_BIGENDIAN ss << "# AmiraMesh BINARY 2.1\n"; #else ss << "# AmiraMesh BINARY-LITTLE-ENDIAN 2.1\n"; #endif } else { ss << "# AmiraMesh 3D ASCII 2.0\n"; } ss << "\n"; ss << "# Dimensions in x-, y-, and z-direction\n"; size_t x = 0, y = 0, z = 0; getVoxelDataContainer()->getDimensions(x, y, z); ss << "define Lattice " << x << " " << y << " " << z << "\n\n"; ss << "Parameters {\n"; ss << " DREAM3DParams {\n"; ss << " Author \"DREAM3D\",\n"; ss << " DateTime \"" << tifDateTime() << "\"\n"; ss << " }\n"; ss << " Units {\n"; ss << " Coordinates \"microns\"\n"; ss << " }\n"; ss << " Content \"" << x << "x" << y << "x" << z << " int, uniform coordinates\",\n"; float origin[3]; getVoxelDataContainer()->getOrigin(origin); float res[3]; getVoxelDataContainer()->getResolution(res); ss << " # Bounding Box is xmin xmax ymin ymax zmin zmax\n"; ss << " BoundingBox " << origin[0] << " " << origin[0] + (res[0] * x); ss << " " << origin[1] << " " << origin[1] + (res[1] * x); ss << " " << origin[2] << " " << origin[2] + (res[2] * x); ss << ",\n"; ss << " CoordType \"uniform\"\n"; ss << "}\n\n"; ss << "Lattice { int GrainIds } = @1\n\n"; ss << "# Data section follows\n"; return ss.str(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void OpenCloseBadData::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); GET_PREREQ_DATA(m, DREAM3D, CellData, GrainIds, ss, -301, int32_t, Int32ArrayType, voxels, 1) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void PerPhaseMinSize::preflight() { dataCheck(true, 1, 1, 1); VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); return; } RenumberGrains::Pointer renumber_grains = RenumberGrains::New(); renumber_grains->setObservers(this->getObservers()); renumber_grains->setVoxelDataContainer(m); renumber_grains->setMessagePrefix(getMessagePrefix()); renumber_grains->preflight(); int err = renumber_grains->getErrorCondition(); if (err < 0) { setErrorCondition(renumber_grains->getErrorCondition()); addErrorMessages(renumber_grains->getPipelineMessages()); return; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AddOrientationNoise::add_orientation_noise() { notifyStatusMessage("Adding Orientation Noise"); DREAM3D_RANDOMNG_NEW() VoxelDataContainer* m = getVoxelDataContainer(); //float ea1, ea2, ea3; float g[3][3]; float newg[3][3]; float rot[3][3]; float w, n1, n2, n3; int64_t totalPoints = m->getTotalPoints(); for (size_t i = 0; i < static_cast<size_t>(totalPoints); ++i) { float ea1 = m_CellEulerAngles[3*i+0]; float ea2 = m_CellEulerAngles[3*i+1]; float ea3 = m_CellEulerAngles[3*i+2]; OrientationMath::EulertoMat(ea1, ea2, ea3, g); n1 = static_cast<float>( rg.genrand_res53() ); n2 = static_cast<float>( rg.genrand_res53() ); n3 = static_cast<float>( rg.genrand_res53() ); w = static_cast<float>( rg.genrand_res53() ); w = 2.0*(w-0.5); w = (m_Magnitude*w); OrientationMath::AxisAngletoMat(w, n1, n2, n3, rot); MatrixMath::Multiply3x3with3x3(g, rot, newg); OrientationMath::MattoEuler(newg, ea1, ea2, ea3); m_CellEulerAngles[3*i+0] = ea1; m_CellEulerAngles[3*i+1] = ea2; m_CellEulerAngles[3*i+2] = ea3; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AlignSectionsList::find_shifts(std::vector<int> &xshifts, std::vector<int> &yshifts) { VoxelDataContainer* m = getVoxelDataContainer(); //int64_t totalPoints = m->totalPoints(); std::ifstream inFile; inFile.open(m_InputFile.c_str()); 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 newxshift, newyshift; for (DimType iter = 1; iter < dims[2]; iter++) { inFile >> slice >> newxshift >> newyshift; xshifts[iter] = xshifts[iter-1] + newxshift; yshifts[iter] = yshifts[iter-1] + newyshift; } inFile.close(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AlignSectionsFeature::execute() { setErrorCondition(0); VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); 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; } AlignSections::execute(); // If there is an error set this to something negative and also set a message notifyStatusMessage("Aligning Sections Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AdjustVolumeOrigin::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; if (m_ApplyToVoxelVolume == true) { VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-383); addErrorMessage(getHumanLabel(), "VoxelDataContainer is missing", getErrorCondition()); } } if (m_ApplyToSurfaceMesh == true) { SurfaceMeshDataContainer* sm = getSurfaceMeshDataContainer(); if(NULL == sm) { setErrorCondition(-383); addErrorMessage(getHumanLabel(), "SurfaceMeshDataContainer is missing", getErrorCondition()); } else { // We MUST have Nodes if(sm->getVertices().get() == NULL) { setErrorCondition(-384); addErrorMessage(getHumanLabel(), "SurfaceMesh DataContainer missing Nodes", getErrorCondition()); } } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AdjustVolumeOrigin::execute() { VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); return; } setErrorCondition(0); std::stringstream ss; // Set the Voxel Volume First, since this is easy if (m_ApplyToVoxelVolume ==true) { m->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z); } if (m_ApplyToSurfaceMesh == true) { updateSurfaceMesh(); } if (m_ApplyToSolidMesh == true) { updatesSolidMesh(); } notifyStatusMessage("Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FlattenImage::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); //int err = 0; int numImageComp = 1; IDataArray::Pointer iDataArray = m->getCellData(m_ImageDataArrayName); if(NULL != iDataArray.get()) { UInt8ArrayType* imageDataPtr = UInt8ArrayType::SafePointerDownCast(iDataArray.get()); if (NULL != imageDataPtr) { numImageComp = imageDataPtr->GetNumberOfComponents(); } } GET_PREREQ_DATA(m, DREAM3D, CellData, ImageData, ss, -301, unsigned char, UCharArrayType, voxels, numImageComp) // if(err == -301) // { // setErrorCondition(0); // err = 0; // GET_PREREQ_DATA(m, DREAM3D, CellData, ImageData, ss, -302, unsigned char, UCharArrayType, voxels, 3) // } CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, FlatImageData, ss, int32_t, Int32ArrayType, 0, voxels, 1) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AddOrientationNoise::execute() { int err = 0; setErrorCondition(err); DREAM3D_RANDOMNG_NEW() VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); return; } int64_t totalPoints = m->getTotalPoints(); size_t totalFields = m->getNumFieldTuples(); dataCheck(false, totalPoints, totalFields, m->getNumEnsembleTuples()); if (getErrorCondition() < 0) { return; } m_Magnitude = m_Magnitude*m_pi/180.0; add_orientation_noise(); // If there is an error set this to something negative and also set a message notifyStatusMessage("AddOrientationNoises Completed"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void Threshold::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); if(m_SelectedCellArrayName.empty() == true) { setErrorCondition(-11000); ss << "An array from the Voxel Data Container must be selected."; addErrorMessage(getHumanLabel(),ss.str(),getErrorCondition()); } else { m_RawImageDataArrayName=m_SelectedCellArrayName; GET_PREREQ_DATA(m, DREAM3D, CellData, RawImageData, ss, -300, ImageProcessing::DefaultPixelType, ImageProcessing::DefaultArrayType, voxels, 1) if(m_OverwriteArray) { } else { CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, ProcessedImageData, ss, ImageProcessing::DefaultPixelType, ImageProcessing::DefaultArrayType, 0, voxels, 1) m->renameCellData(m_ProcessedImageDataArrayName, m_NewCellArrayName); } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FlattenImage::execute() { VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); return; } setErrorCondition(0); int64_t totalPoints = m->getTotalPoints(); size_t numgrains = m->getNumFieldTuples(); size_t numensembles = m->getNumEnsembleTuples(); dataCheck(false, totalPoints, numgrains, numensembles); if (getErrorCondition() < 0) { return; } float Rfactor = 1.0; float Gfactor = 1.0; float Bfactor = 1.0; if (m_FlattenMethod == DREAM3D::FlattenImageMethod::Average) { Rfactor = 1.0/3.0; Gfactor = 1.0/3.0; Bfactor = 1.0/3.0; } else if (m_FlattenMethod == DREAM3D::FlattenImageMethod::Luminosity) { Rfactor = 0.21; Gfactor = 0.72; Bfactor = 0.07; } #ifdef DREAM3D_USE_PARALLEL_ALGORITHMS tbb::task_scheduler_init init; bool doParallel = true; #endif size_t comp = m->getCellData(m_ImageDataArrayName)->GetNumberOfComponents(); // std::cout << "FlattenImage: " << m_ConversionFactor << std::endl; #ifdef DREAM3D_USE_PARALLEL_ALGORITHMS if (doParallel == true) { tbb::parallel_for(tbb::blocked_range<size_t>(0, totalPoints), FlattenImageImpl(m_ImageData, m_FlatImageData, Rfactor, Gfactor, Bfactor, comp), tbb::auto_partitioner()); } else #endif { FlattenImageImpl serial(m_ImageData, m_FlatImageData, Rfactor, Gfactor, Bfactor, comp); serial.convert(0, totalPoints); } notifyStatusMessage("Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- std::string AvizoRectilinearCoordinateWriter::generateHeader() { std::stringstream ss; if(m_WriteBinaryFile == true) { #ifdef CMP_WORDS_BIGENDIAN ss << "# AmiraMesh BINARY 2.1\n"; #else ss << "# AmiraMesh BINARY-LITTLE-ENDIAN 2.1\n"; #endif } else { ss << "# AmiraMesh 3D ASCII 2.0\n"; } ss << "\n"; ss << "# Dimensions in x-, y-, and z-direction\n"; size_t x = 0, y = 0, z = 0; getVoxelDataContainer()->getDimensions(x, y, z); ss << "define Lattice " << x << " " << y << " " << z << "\n"; ss << "define Coordinates " << (x + y + z) << "\n\n"; ss << "Parameters {\n"; ss << " DREAM3DParams {\n"; ss << " Author \"DREAM3D\",\n"; ss << " DateTime \"" << tifDateTime() << "\"\n"; ss << " }\n"; ss << " Units {\n"; ss << " Coordinates \"microns\"\n"; ss << " }\n"; float origin[3]; getVoxelDataContainer()->getOrigin(origin); float res[3]; getVoxelDataContainer()->getResolution(res); ss << " CoordType \"rectilinear\"\n"; ss << "}\n\n"; ss << "Lattice { int GrainIds } = @1\n"; ss << "Coordinates { float xyz } = @2\n\n"; ss << "# Data section follows\n"; return ss.str(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void IdentifySample::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); GET_PREREQ_DATA(m, DREAM3D, CellData, GoodVoxels, ss, -301, bool, BoolArrayType, voxels, 1) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RotateEulerRefFrame::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); GET_PREREQ_DATA(m, DREAM3D, CellData, CellEulerAngles, ss, -301, float, FloatArrayType, voxels, 3) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindAxisODF::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); int err = 0; GET_PREREQ_DATA(m, DREAM3D, FieldData, AxisEulerAngles, ss, -301, float, FloatArrayType, fields, 3) TEST_PREREQ_DATA(m, DREAM3D, FieldData, SurfaceFields, err, -302, bool, BoolArrayType, fields, 1) if(err == -302) { setErrorCondition(0); FindSurfaceGrains::Pointer find_surfacefields = FindSurfaceGrains::New(); find_surfacefields->setObservers(this->getObservers()); find_surfacefields->setVoxelDataContainer(getVoxelDataContainer()); if(preflight == true) find_surfacefields->preflight(); if(preflight == false) find_surfacefields->execute(); } GET_PREREQ_DATA(m, DREAM3D, FieldData, SurfaceFields, ss, -302, bool, BoolArrayType, fields, 1) err = 0; TEST_PREREQ_DATA(m, DREAM3D, FieldData, FieldPhases, err, -303, int32_t, Int32ArrayType, fields, 1) if(err == -303) { setErrorCondition(0); FindGrainPhases::Pointer find_grainphases = FindGrainPhases::New(); find_grainphases->setObservers(this->getObservers()); find_grainphases->setVoxelDataContainer(getVoxelDataContainer()); if(preflight == true) find_grainphases->preflight(); if(preflight == false) find_grainphases->execute(); } GET_PREREQ_DATA(m, DREAM3D, FieldData, FieldPhases, ss, -303, int32_t, Int32ArrayType, fields, 1) typedef DataArray<unsigned int> PhaseTypeArrayType; GET_PREREQ_DATA(m, DREAM3D, EnsembleData, PhaseTypes, ss, -307, unsigned int, PhaseTypeArrayType, ensembles, 1) m_StatsDataArray = StatsDataArray::SafeObjectDownCast<IDataArray*, StatsDataArray*>(m->getEnsembleData(DREAM3D::EnsembleData::Statistics).get()); if(m_StatsDataArray == NULL) { StatsDataArray::Pointer p = StatsDataArray::New(); m_StatsDataArray = p.get(); m_StatsDataArray->fillArrayWithNewStatsData(ensembles, m_PhaseTypes); m->addEnsembleData(DREAM3D::EnsembleData::Statistics, p); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void VoxelDataContainerWriter::writeXdmfGridFooter(const std::string &label) { if (false == m_WriteXdmfFile || NULL == m_XdmfPtr || NULL == getVoxelDataContainer()) { return; } std::ostream& out = *m_XdmfPtr; out << " </Grid>" << std::endl; out << " <!-- *************** END OF " << label << " *************** -->" << std::endl; out << std::endl; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void UpdateCellQuats::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); GET_PREREQ_DATA(m, DREAM3D, CellData, Quats, ss, -301, float, FloatArrayType, voxels, 5) CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, Quats, ss, float, FloatArrayType, 0, voxels, 4) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void PerPhaseMinSize::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); GET_PREREQ_DATA(m, DREAM3D, CellData, GrainIds, ss, -301, int32_t, Int32ArrayType, voxels, 1); GET_PREREQ_DATA(m, DREAM3D, CellData, CellPhases, ss, -301, int32_t, Int32ArrayType, voxels, 1); GET_PREREQ_DATA(m, DREAM3D, FieldData, FieldPhases, ss, -301, int32_t, Int32ArrayType, fields, 1); CREATE_NON_PREREQ_DATA(m, DREAM3D, FieldData, Active, ss, bool, BoolArrayType, true, fields, 1); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ClearData::execute() { int err = 0; setErrorCondition(err); VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); return; } setErrorCondition(0); dataCheck(false, m->getTotalPoints(), m->getNumFieldTuples(), m->getNumEnsembleTuples()); 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 index; std::list<std::string> voxelArrayNames = m->getCellArrayNameList(); for (int k = m_ZMin; k < m_ZMax+1; k++) { for (int j = m_YMin; j < m_YMax+1; j++) { for (int i = m_XMin; i < m_XMax+1; i++) { index = (k * dims[0] * dims[1]) + (j * dims[0]) + i; 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(index,0); } } } } notifyStatusMessage("Completed"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DxReader::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); if (getInputFile().empty() == true) { ss << ClassName() << " needs the Input File Set and it was not."; setErrorCondition(-387); addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition()); } else if (MXAFileInfo::exists(getInputFile()) == false) { ss << "The input file does not exist."; setErrorCondition(-388); addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition()); } CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, GrainIds, ss, int32_t, Int32ArrayType, 0, voxels, 1) m->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z); m->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z); if (m_InStream.is_open() == true) { m_InStream.close(); } // We need to read the header of the input file to get the dimensions m_InStream.open(getInputFile().c_str(), std::ios_base::binary); if(!m_InStream) { ss.clear(); ss << " Runtime Error. The input file '" << getInputFile() << "' could not be" << " opened for reading. Do you have access to this file?"; setErrorCondition(-49800); addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition()); return; } int error = readHeader(); m_InStream.close(); if (error < 0) { setErrorCondition(error); ss.clear(); ss << "Error occurred trying to parse the dimensions from the input file. Is the input file a Dx file?"; addErrorMessage(getHumanLabel(), ss.str(), -11000); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int VoxelDataContainerWriter::writeEnsembleData(hid_t dcGid) { std::stringstream ss; int err = 0; VoxelDataContainer* m = getVoxelDataContainer(); // Write the Ensemble data err = H5Utilities::createGroupsFromPath(H5_ENSEMBLE_DATA_GROUP_NAME, dcGid); if(err < 0) { ss.str(""); ss << "Error creating HDF Group " << H5_ENSEMBLE_DATA_GROUP_NAME << std::endl; setErrorCondition(-66); notifyErrorMessage( ss.str(), err); H5Gclose(dcGid); // Close the Data Container Group return err; } err = H5Lite::writeStringAttribute(dcGid, H5_ENSEMBLE_DATA_GROUP_NAME, H5_NAME, H5_ENSEMBLE_DATA_DEFAULT); hid_t ensembleGid = H5Gopen(dcGid, H5_ENSEMBLE_DATA_GROUP_NAME, H5P_DEFAULT); if(err < 0) { ss.str(""); ss << "Error opening ensemble Group " << H5_ENSEMBLE_DATA_GROUP_NAME << std::endl; setErrorCondition(-67); notifyErrorMessage( ss.str(), err); H5Gclose(dcGid); // Close the Data Container Group return err; } NameListType names = m->getEnsembleArrayNameList(); for (NameListType::iterator iter = names.begin(); iter != names.end(); ++iter) { IDataArray::Pointer array = m->getEnsembleData(*iter); err = array->writeH5Data(ensembleGid); if(err < 0) { ss.str(""); ss << "Error writing Ensemble array '" << *iter << "' to the HDF5 File"; notifyErrorMessage( ss.str(), err); setErrorCondition(err); H5Gclose(ensembleGid); // Close the Cell Group H5Gclose(dcGid); // Close the Data Container Group return err; } } H5Gclose(ensembleGid); return err; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindFieldNeighborCAxisMisalignments::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); // Field Data GET_PREREQ_DATA(m, DREAM3D, FieldData, AvgQuats, ss, -301, float, FloatArrayType, fields, 4) GET_PREREQ_DATA(m, DREAM3D, FieldData, FieldPhases, ss, -303, int32_t, Int32ArrayType, fields, 1) if(m_FindAvgMisals == true) { CREATE_NON_PREREQ_DATA(m, DREAM3D, FieldData, AvgCAxisMisalignments, ss, float, FloatArrayType, 0, fields, 1) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ReadH5Ebsd::copyHEDMArrays(H5EbsdVolumeReader* ebsdReader) { float* f1 = NULL; float* f2 = NULL; float* f3 = NULL; int* phasePtr = NULL; FloatArrayType::Pointer fArray = FloatArrayType::NullPointer(); Int32ArrayType::Pointer iArray = Int32ArrayType::NullPointer(); VoxelDataContainer* m = getVoxelDataContainer(); int64_t totalPoints = m->getTotalPoints(); if (m_SelectedVoxelCellArrays.find(m_CellEulerAnglesArrayName) != m_SelectedVoxelCellArrays.end() ) { // radianconversion = M_PI / 180.0; f1 = reinterpret_cast<float*>(ebsdReader->getPointerByName(Ebsd::Mic::Euler1)); f2 = reinterpret_cast<float*>(ebsdReader->getPointerByName(Ebsd::Mic::Euler2)); f3 = reinterpret_cast<float*>(ebsdReader->getPointerByName(Ebsd::Mic::Euler3)); fArray = FloatArrayType::CreateArray(totalPoints * 3, DREAM3D::CellData::EulerAngles); fArray->SetNumberOfComponents(3); float* cellEulerAngles = fArray->GetPointer(0); for (int64_t i = 0; i < totalPoints; i++) { cellEulerAngles[3 * i] = f1[i]; cellEulerAngles[3 * i + 1] = f2[i]; cellEulerAngles[3 * i + 2] = f3[i]; } m->addCellData(DREAM3D::CellData::EulerAngles, fArray); } if (m_SelectedVoxelCellArrays.find(m_CellPhasesArrayName) != m_SelectedVoxelCellArrays.end() ) { phasePtr = reinterpret_cast<int*>(ebsdReader->getPointerByName(Ebsd::Mic::Phase)); iArray = Int32ArrayType::CreateArray(totalPoints, DREAM3D::CellData::Phases); iArray->SetNumberOfComponents(1); ::memcpy(iArray->GetPointer(0), phasePtr, sizeof(int32_t) * totalPoints); m->addCellData(DREAM3D::CellData::Phases, iArray); } if (m_SelectedVoxelCellArrays.find(Ebsd::Mic::Confidence) != m_SelectedVoxelCellArrays.end() ) { f1 = reinterpret_cast<float*>(ebsdReader->getPointerByName(Ebsd::Mic::Confidence)); fArray = FloatArrayType::CreateArray(totalPoints, Ebsd::Mic::Confidence); fArray->SetNumberOfComponents(1); ::memcpy(fArray->GetPointer(0), f1, sizeof(float) * totalPoints); m->addCellData(Ebsd::Mic::Confidence, fArray); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int VoxelDataContainerWriter::writeFaceData(hid_t dcGid) { std::stringstream ss; int err = 0; VoxelDataContainer* m = getVoxelDataContainer(); // Write the Voxel Data err = H5Utilities::createGroupsFromPath(H5_FACE_DATA_GROUP_NAME, dcGid); if(err < 0) { ss.str(""); ss << "Error creating HDF Group " << H5_FACE_DATA_GROUP_NAME << std::endl; setErrorCondition(-63); notifyErrorMessage( ss.str(), err); H5Gclose(dcGid); // Close the Data Container Group return err; } hid_t FaceGroupId = H5Gopen(dcGid, H5_FACE_DATA_GROUP_NAME, H5P_DEFAULT); if(err < 0) { ss.str(""); ss << "Error writing string attribute to HDF Group " << H5_FACE_DATA_GROUP_NAME << std::endl; setErrorCondition(-64); notifyErrorMessage( ss.str(), err); H5Gclose(dcGid); // Close the Data Container Group return err; } NameListType names = m->getFaceArrayNameList(); for (NameListType::iterator iter = names.begin(); iter != names.end(); ++iter) { ss.str(""); ss << "Writing Face Data '" << *iter << "' to HDF5 File" << std::endl; notifyStatusMessage(ss.str()); IDataArray::Pointer array = m->getFaceData(*iter); err = array->writeH5Data(FaceGroupId); if(err < 0) { ss.str(""); ss << "Error writing array '" << *iter << "' to the HDF5 File"; notifyErrorMessage( ss.str(), err); setErrorCondition(err); H5Gclose(FaceGroupId); // Close the Face Group H5Gclose(dcGid); // Close the Data Container Group return err; } } H5Gclose(FaceGroupId); // Close the Face Group return err; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AvizoRectilinearCoordinateWriter::execute() { int err = 0; setErrorCondition(err); VoxelDataContainer* m = getVoxelDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The DataContainer Object was NULL", -999); return; } setErrorCondition(0); // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path std::string parentPath = MXAFileInfo::parentPath(m_OutputFile); if(!MXADir::mkdir(parentPath, true)) { std::stringstream ss; ss << "Error creating parent path '" << parentPath << "'"; notifyErrorMessage(ss.str(), -1); setErrorCondition(-1); return; } int64_t totalPoints = m->getTotalPoints(); size_t totalFields = m->getNumFieldTuples(); size_t totalEnsembleTuples = m->getNumEnsembleTuples(); dataCheck(false, totalPoints, totalFields, totalEnsembleTuples); MXAFileWriter64 writer(m_OutputFile); if(false == writer.initWriter()) { std::stringstream ss; ss << "Error opening file '" << parentPath << "'"; notifyErrorMessage(ss.str(), -1); setErrorCondition(-1); return; } std::string header = generateHeader(); writer.writeString(header); err = writeData(writer); /* Let the GUI know we are done with this filter */ notifyStatusMessage("Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void GenerateEnsembleStatistics::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); GET_PREREQ_DATA(m, DREAM3D, FieldData, FieldPhases, ss, -303, int32_t, Int32ArrayType, fields, 1) if(m_SizeDistribution == true || m_Omega3Distribution == true || m_AspectRatioDistribution == true || m_NeighborhoodDistribution == true || m_CalculateAxisODF == true) { GET_PREREQ_DATA(m, DREAM3D, FieldData, BiasedFields, ss, -302, bool, BoolArrayType, fields, 1) GET_PREREQ_DATA(m, DREAM3D, FieldData, EquivalentDiameters, ss, -302, float, FloatArrayType, fields, 1) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AlignSectionsFeature::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); if(true == getWriteAlignmentShifts() && getAlignmentShiftFileName().empty() == true) { ss << "The Alignment Shift file name must be set before executing this filter."; setErrorCondition(-1); addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition()); } GET_PREREQ_DATA(m, DREAM3D, CellData, GoodVoxels, ss, -303, bool, BoolArrayType, voxels, 1) }