📄 sizectl_fe.cpp
字号:
// ------------------------------------------------------------------// sizectl_fe.cpp//// This file contains member functions for the size_control class that// invoke the front end interpreter. This is the Matlab version.// ------------------------------------------------------------------// Author: Stephen A. Vavasis// Copyright (c) 1999 by Cornell University. All rights reserved.// // See the accompanying file 'Copyright' for authorship information,// the terms of the license governing this software, and disclaimers// concerning this software.// ------------------------------------------------------------------// This file is part of the QMG software. // Version 2.0 of QMG, release date September 3, 1999.// ------------------------------------------------------------------#include "qsizectl.h"#include "qfrontend.h"namespace { void pause(const char* str) { mexPrintf("%s\nPress return", str); mxArray* plhs[1]; mxArray* prhs[1]; mexCallMATLAB(0, plhs, 0, prhs, "pause"); mexPrintf("continuing\n"); }}void QMG::MG::SizeControl::fe_initialize() {}void QMG::MG::SizeControl::fe_terminate() { }QMG::Real QMG::MG::SizeControl::fe_invoke_sizefunc(const Point& realpoint, const Point& parampoint, const Brep::Face_Spec& sourcespec, Brep::PatchIndex patchind, const string& sizefunc) const { mxArray* rpt = mxCreateDoubleMatrix(di_, 1, mxREAL); double* rptd = mxGetPr(rpt); for (int j = 0; j < di_; ++j) rptd[j] = realpoint[j]; int pdim = sourcespec.fdim(); if (pdim == di_) pdim = 0; mxArray* ppt = mxCreateDoubleMatrix(pdim, 1, mxREAL); double* pptd = mxGetPr(ppt); for (int k = 0; k < pdim; ++k) pptd[k] = parampoint[k]; mxArray* fsp = mxCreateDoubleMatrix(2, 1, mxREAL); double* fspd = mxGetPr(fsp); fspd[0] = static_cast<double>(sourcespec.fdim()); fspd[1] = static_cast<double>(sourcespec.faceind()); mxArray* ptc = mxCreateDoubleMatrix(1, 1, mxREAL); *mxGetPr(ptc) = static_cast<double>(patchind); mxArray* szf = mxCreateString(sizefunc.c_str()); mxArray* userdata = mxCreateString(user_data_.c_str()); mxArray* prhs[6]; prhs[0] = rpt; prhs[1] = ppt; prhs[2] = fsp; prhs[3] = ptc; prhs[4] = szf; prhs[5] = userdata; mxArray* plhs[1]; mexCallMATLAB(1, plhs, 6, prhs, extern_funcname_.c_str()); double sz; if (plhs[0] == 0 || !mxIsDouble(plhs[0]) || mxIsSparse(plhs[0]) || mxGetPi(plhs[0]) || mxGetM(plhs[0]) * mxGetN(plhs[0]) != 1) throw_error("Matlab external size control function did not return a scalar"); sz = *mxGetPr(plhs[0]); if (sz <= 0) { ostringstream os; os << "Size control function returned " << sz << " but positive number required."; throw_error(os.str()); } for (int l = 0; l < 6; ++l) mxDestroyArray(prhs[l]); mxDestroyArray(plhs[0]); return sz;}QMG::Real QMG::MG::SizeControl::fe_invoke_sizefunc_interior(const Point& realpoint, const Brep::Face_Spec& sourcespec, const string& sizefunc) const { mxArray* rpt = mxCreateDoubleMatrix(di_, 1, mxREAL); double* rptd = mxGetPr(rpt); for (int j = 0; j < di_; ++j) rptd[j] = realpoint[j]; mxArray* fsp = mxCreateDoubleMatrix(2, 1, mxREAL); double* fspd = mxGetPr(fsp); fspd[0] = static_cast<double>(sourcespec.fdim()); fspd[1] = static_cast<double>(sourcespec.faceind()); mxArray* szf = mxCreateString(sizefunc.c_str()); mxArray* prhs[3]; prhs[0] = rpt; prhs[1] = fsp; prhs[2] = szf; mxArray* plhs[1]; string tmp1 = extern_funcname_ + "_interior"; mexCallMATLAB(1, plhs, 3, prhs, tmp1.c_str()); double sz; if (plhs[0] == 0 || !mxIsDouble(plhs[0]) || mxIsSparse(plhs[0]) || mxGetPi(plhs[0]) || mxGetM(plhs[0]) * mxGetN(plhs[0]) != 1) throw_error("Matlab external size control function did not return a scalar"); sz = *mxGetPr(plhs[0]); if (sz <= 0) { ostringstream os; os << "Size control function returned " << sz << " but positive number required."; throw_error(os.str()); } for (int l = 0; l < 3; ++l) mxDestroyArray(prhs[l]); mxDestroyArray(plhs[0]); return sz;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -