void MyFrame::OnSaveNonLinearModes(wxCommandEvent& event) { wxFileDialog *dlg = new wxFileDialog(this, _T("Save nonlinear modes"), uiState.currentWorkingDirectory, _T(""), _T("Modal Matrix Files(*.U)|*.U|All files(*.*)|*.*"), wxFD_SAVE /*| wxHIDE_READONLY*/, wxDefaultPosition); if ( dlg->ShowModal() == wxID_OK ) { wxString nonLinearModesFilename( dlg->GetPath()); SaveCurrentWorkingDirectory(nonLinearModesFilename); if( !nonLinearModesFilename.empty() ) { const char * filename = nonLinearModesFilename.mb_str(); int code = WriteMatrixToDisk((char*)filename, 3 * precomputationState.nonLinearModalMatrix->Getn(), precomputationState.nonLinearModalMatrix->Getr(), precomputationState.nonLinearModalMatrix->GetMatrix()); if (code != 0) { this->errMsg( _T("Saving error"), _T("Unable to save nonlinear modes to ") + nonLinearModesFilename ); dlg->Destroy(); return; } } } dlg->Destroy(); }
void MyFrame::OnSaveFrequencies(wxCommandEvent& event) { wxFileDialog *dlg = new wxFileDialog(this, _T("Save frequencies"), uiState.currentWorkingDirectory, _T(""), _T("Frequency Files(*.freq)|*.freq|All files(*.*)|*.*"), wxFD_SAVE /*| wxHIDE_READONLY*/, wxDefaultPosition); if ( dlg->ShowModal() == wxID_OK ) { wxString frequencyFilename( dlg->GetPath()); SaveCurrentWorkingDirectory(frequencyFilename); if( !frequencyFilename.empty() ) { const char * filename = frequencyFilename.mb_str(); int code = WriteMatrixToDisk((char*)filename, precomputationState.rLin, 1, precomputationState.frequencies); if (code != 0) { this->errMsg( _T("Saving error"), _T("Unable to save frequencies to ") + frequencyFilename ); dlg->Destroy(); return; } } } dlg->Destroy(); }
int Matrix<real>::Save(const char * filename) const { if (WriteMatrixToDisk(filename, m, n, data) != 0) { printf("Error writing matrix to %s.\n", filename); return 1; } return 0; }
void MyFrame::InterpolateMatrix(wxString dataDescription, ModalMatrix * inputModalMatrix) { wxFileDialog *dlg = new wxFileDialog(this, _T("Interpolate ") + dataDescription + _T(" to triangle mesh"), uiState.currentWorkingDirectory, _T(""), _T("Modal Matrix Files(*.U)|*.U|All files(*.*)|*.*"), wxFD_SAVE /*| wxHIDE_READONLY*/, wxDefaultPosition); if ( dlg->ShowModal() == wxID_OK ) { wxString outputFilename( dlg->GetPath() ); SaveCurrentWorkingDirectory(outputFilename); if( !outputFilename.empty() ) { SetCursor(*wxHOURGLASS_CURSOR); if (!precomputationState.interpolationDataAvailable) BuildInterpolant(); // interpolate printf("Interpolating data...\n"); double * inputMatrix = inputModalMatrix->GetMatrix(); int nTarget = (int)(precomputationState.renderingMesh->getNumVertices()); double * outputMatrix = (double*) malloc (sizeof(double) * 3 * nTarget * inputModalMatrix->Getr()); for(int i=0; i<inputModalMatrix->Getr(); i++) { precomputationState.simulationMesh->interpolate( &inputMatrix[ELT(3*precomputationState.simulationMesh->getNumVertices(),0,i)], &outputMatrix[ELT(3*nTarget,0,i)], nTarget, precomputationState.simulationMesh->getNumElementVertices(), precomputationState.interpolationData_vertices, precomputationState.interpolationData_weights); } // save file to disk const char * filename = outputFilename.mb_str(); printf("Saving output to %s.\n", (char*)filename); int code = WriteMatrixToDisk((char*)filename, 3 * nTarget, inputModalMatrix->Getr(), outputMatrix); free(outputMatrix); SetCursor(*wxSTANDARD_CURSOR); if (code != 0) { this->errMsg( _T("Saving error"), _T("Unable to save interpolated data to ") + outputFilename ); dlg->Destroy(); return; } } } dlg->Destroy(); }