IModule * ModuleManager::FindModule(const char * moduleName) { std::string mName(moduleName); if (g_ModuleMap.find(moduleName) != g_ModuleMap.end()) { return g_ModuleMap[mName]; } else { if(LoadModule(moduleName)) return g_ModuleMap[mName]; } return nullptr; }
vtkDataSet * avtMM5FileFormat::GetMesh(int timestate, const char *meshname) { vtkDataSet *retval = 0; Initialize(); std::string mName(meshname); MeshNameMap::const_iterator pos = meshNames.find(mName); if(pos != meshNames.end()) { int i, j; vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New(); // // Populate the coordinates. Put in 3D points with z=0 if // the mesh is 2D. // int dims[3]; vtkFloatArray *coords[3]; for (i = 0 ; i < 3 ; i++) { // Default number of components for an array is 1. coords[i] = vtkFloatArray::New(); if ((size_t)i < pos->second.size()) { dims[i] = pos->second[i] + 1; coords[i]->SetNumberOfTuples(dims[i]); for (j = 0 ; j < dims[i] ; j++) { coords[i]->SetComponent(j, 0, j); } } else { dims[i] = 1; coords[i]->SetNumberOfTuples(1); coords[i]->SetComponent(0, 0, 0.); } } rgrid->SetDimensions(dims); rgrid->SetXCoordinates(coords[0]); coords[0]->Delete(); rgrid->SetYCoordinates(coords[1]); coords[1]->Delete(); rgrid->SetZCoordinates(coords[2]); coords[2]->Delete(); retval = rgrid; } else { mm5_fieldinfo_t *field = mm5_file_find_field(mm5file, meshname, timestate); if(field == 0) { EXCEPTION1(InvalidVariableException, meshname); } // We found a curve. int nPts = field->header.end_index[0] * field->header.end_index[1] * field->header.end_index[2] * field->header.end_index[3]; float *yValues = new float[nPts]; if(mm5_file_read_field(mm5file, meshname, timestate, yValues) == 0) { delete [] yValues; EXCEPTION1(InvalidVariableException, meshname); } // Make a new curve. vtkRectilinearGrid *rg =vtkVisItUtility::Create1DRGrid(nPts, VTK_FLOAT); vtkFloatArray *xc = vtkFloatArray::SafeDownCast(rg->GetXCoordinates()); vtkFloatArray *yv = vtkFloatArray::New(); yv->SetNumberOfComponents(1); yv->SetNumberOfTuples(nPts); yv->SetName(meshname); for (int j = 0 ; j < nPts ; j++) { xc->SetValue(j, float(j)); yv->SetValue(j, yValues[j]); } rg->GetPointData()->SetScalars(yv); yv->Delete(); retval = rg; delete [] yValues; } return retval; }