gmdouble.cpp

来自「算断裂的」· C++ 代码 · 共 165 行

CPP
165
字号
// ------------------------------------------------------------------// gmdouble.cpp//// This file contains the driver for gmdouble, which // is for doubling an internal boundary.// ------------------------------------------------------------------// 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 "qbrep_constr.h"#include "qsimpcomp.h"#include "qfrontend.h"#include "qancestor.h"#define GM_ROUTINE_NAME gmdouble#define GM_ROUTINE_NAME_Q "gmdouble"namespace QMG {  namespace MG {    using namespace QMG;    struct PatchInBrepAddress {      Brep::Face_Spec fspec;      Brep::PatchIndex patchind;      PatchInBrepAddress(const Brep::Face_Spec& f, Brep::PatchIndex p) : 	fspec(f), patchind(p) { }      PatchInBrepAddress(const PatchInBrepAddress& o) : fspec(o.fspec), patchind(o.patchind) { }      PatchInBrepAddress() { }      bool operator<(const PatchInBrepAddress& ip) const;      bool operator==(const PatchInBrepAddress& ip) const;    };    // Functions defined in double.cpp    extern Brep_Under_Construction      double_brep(const Brep& b,                  const vector<Brep::Face_Spec>& faces_to_double,                  double tol,                  // other return variables:                  Brep::Face_Labeling<Brep::FaceIndex>& oldfspec_to_new_map,                  Brep::Face_Labeling<int>& face_num_copies,                  map<PatchInBrepAddress, bool>& patch_is_flipped);        extern SimpComplex_Under_Construction      double_simpcomp(const Brep& b,                      const Brep& newb,                      const SimpComplex& sc,                      const Brep::Face_Labeling<Brep::FaceIndex>& oldfspec_to_new_map,                      const Brep::Face_Labeling<int>& num_copies,                      const map<PatchInBrepAddress,bool>& patch_is_flipped,                      double tol                      );  }}namespace {      using namespace QMG;  using namespace QMG::MG;  using namespace QMG::FrontEnd;    // This is a function object used for a map whose key is a string.  // We want to compare strings disregarding case.    class Nocase {  public:    bool operator() (const string& x, const string& y) const {      return compare_nocase(x,y) < 0;    }  };    void worker(const QMG::FrontEnd::ArgValType& argvalhandle,              QMG::FrontEnd::ReturnValType& returnvalhandle,              QMG::FrontEnd::Interpreter& interp) {        argvalhandle.verify_nargin(2, 3, GM_ROUTINE_NAME_Q);    if (argvalhandle.nargin() == 2) {      returnvalhandle.verify_nargout(1, 1, "gmdouble (brep-only as input)");    }    else      returnvalhandle.verify_nargout(2, 2, "gmdouble (brep and simpcomp as input)");        int nargin = argvalhandle.nargin();    int nargout = returnvalhandle.nargout();        Brep_From_FrontEnd brep = argvalhandle.get_brep(0);    vector<string> facenames = argvalhandle.get_vector_string(1);    int di = brep.embedded_dim();    if (brep.gdim() != di)      throw_error("Brep must be full dimensional for double_ib");        vector<Brep::Face_Spec> faces_to_double;    if (facenames.size() == 1 && facenames[0] == "*") {      Brep::Ancestor_Lookup anc_lookup(brep);      for (Brep::Face_Spec_Loop_Over_Faces_Of_Dim fspec(brep, di - 1);           fspec.notdone();           ++fspec) {        int dbrcount = 0;        for (Brep::Ancestor_Lookup::Loop_over_ancestors ancloop(anc_lookup, fspec);             ancloop.notdone();             ++ancloop) {          if (ancloop.ancestor_fspec().fdim() == di) {            if (ancloop.occurrence_count() == 2)              ++dbrcount;            else              dbrcount = 2;          }        }        if (dbrcount == 1)          faces_to_double.push_back(fspec);      }    }    else {      map<string,int, Nocase> facenamemap;      for (Brep::Face_Spec_Loop_Over_Faces_Of_Dim fspec(brep, di - 1);           fspec.notdone();           ++fspec)        facenamemap.insert(pair<string,int>(brep.face_name(fspec), fspec.faceind() + 1));            int numnames = facenames.size();      for (int j = 0; j < numnames; ++j) {        Brep::FaceIndex faceind1 = facenamemap[facenames[j]] - 1;        if (faceind1 < 0) {          ostringstream os;          os << "Face name '" << facenames[j] << "' listed in input but not found among faces "             << "of dimension " << di-1 << " of brep";          throw_error(os.str());        }        faces_to_double.push_back(Brep::Face_Spec(di - 1, faceind1));      }    }    Brep::Face_Labeling<Brep::FaceIndex> oldfspec_to_new_map(brep, -1);    Brep::Face_Labeling<int> face_num_copies(brep, 0);    map<PatchInBrepAddress, bool> patch_is_flipped;        double tol = default_tol(interp);    Brep_Under_Construction newbrep =       double_brep(brep, faces_to_double, tol, oldfspec_to_new_map,                  face_num_copies, patch_is_flipped);    if (nargin == 3) {      SimpComplex_From_FrontEnd sc = argvalhandle.get_simpcomp(2);      SimpComplex_Under_Construction newsc =         double_simpcomp(brep, newbrep, sc, oldfspec_to_new_map, face_num_copies,                        patch_is_flipped, tol);      returnvalhandle.put_simpcomp(1, newsc);    }    returnvalhandle.put_brep(0, newbrep);  }} #include "gm_entrypoint.cpp"

⌨️ 快捷键说明

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