⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sizectl_fe.cpp

📁 算断裂的
💻 CPP
字号:
// ------------------------------------------------------------------// sizectl_fe.cpp//// This file contains member functions for the size_control class that// invoke the front end interpreter.  This is the Tcl/Tk 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 QMG {  namespace FrontEnd {    extern int set_tcl_lib(Tcl_Interp* interp);  }}   namespace {  Tcl_Interp* subinterp = 0;}void QMG::MG::SizeControl::fe_initialize() {  if (subinterp) return;  subinterp = Tcl_CreateInterp();  QMG::FrontEnd::set_tcl_lib(subinterp);  int returncode = Tcl_Eval(subinterp, "source $qmg_library/qmg_sizecontrol.tcl");  if (returncode != TCL_OK) {    Tcl_DeleteInterp(subinterp);    subinterp = 0;    throw_error("Unable to source qmg_sizecontrol.tcl");  }  Tcl_MakeSafe(subinterp);}void QMG::MG::SizeControl::fe_terminate() {   if (subinterp) {    Tcl_DeleteInterp(subinterp);    subinterp = 0;  }}namespace {    using namespace QMG;  using namespace QMG::MG;  void dump_err(Tcl_Interp* sizectl_interp, int returncode, ostream& os) {    if (returncode == TCL_OK)      return;    os << "interp -> result = " << sizectl_interp -> result << std::endl;    const char* c = Tcl_GetVar(sizectl_interp, "errorInfo", 0);    if (c)       os << "error_info = " << c << std::endl;    ostringstream errstr;    errstr << "Error has occurred during Tcl/Tk size control evaluation: "      << sizectl_interp -> result;    throw_error(errstr.str());  }}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 {  ostringstream os;  Tcl_Interp* interp = subinterp;  os << extern_funcname_ << " {" << sizefunc << "} {" << user_data_ << "} " << sourcespec     << " " << patchind << " {" << realpoint << "}  {";  for (int j = 0; j < sourcespec.fdim(); ++j)    os << parampoint[j] << " ";  os << "}";  int returncode = Tcl_Eval(interp, const_cast<char*>(os.str().c_str()));  if (returncode != TCL_OK)    dump_err(interp, returncode, logstr_.str());  double sz;  returncode = Tcl_GetDouble(interp, interp -> result, &sz);  if (returncode != TCL_OK) {    ostringstream os;    os << "Could not convert return value \""      << interp -> result << "\"from size control function to double";    throw_error(os.str());  }  if (sz <= 0) {    ostringstream os;    os << "Size control function returned " << sz << " but positive number required.";    throw_error(os.str());  }  return sz;}QMG::Real  QMG::MG::SizeControl::fe_invoke_sizefunc_interior(const Point& realpoint,                                                        const Brep::Face_Spec& sourcespec,                                                        const string& sizefunc) const {   ostringstream os;  Tcl_Interp* interp = subinterp;  os << extern_funcname_ << "_interior {"      << sizefunc << "} {" << user_data_ << "} " << sourcespec      << " {" << realpoint << "}";   int returncode = Tcl_Eval(interp, const_cast<char*>(os.str().c_str()));  if (returncode != TCL_OK)    dump_err(interp, returncode, logstr_.str());  double sz;  returncode = Tcl_GetDouble(interp, interp -> result, &sz);  if (returncode != TCL_OK) {    ostringstream os;    os << "Could not convert return value \""      << interp -> result << "\"from interior size control function to double";    throw_error(os.str());  }  if (sz <= 0) {    ostringstream os;    os << "Size control function returned " << sz << " but positive number required.";    throw_error(os.str());  }  return sz;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -