qlifter.cpp

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

CPP
182
字号
// ------------------------------------------------------------------// qlifter.cpp//// This file contains functions of a class for lifting parameter values // from low-dimensional subfaces.// ------------------------------------------------------------------// 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 "qlifter.h"boolQMG::Brep_Parameter_Lifter::Bdry_CtlPoint_Key::operator<(const Bdry_CtlPoint_Key& o) const {  if (bdry_dim < o.bdry_dim) return true;  if (bdry_dim > o.bdry_dim) return false;  if (bdry_pts[0] < o.bdry_pts[0]) return true;  if (bdry_pts[0] > o.bdry_pts[0]) return false;  if (bdry_dim == 0) return false;  return bdry_pts[1] < o.bdry_pts[1];}voidQMG::Brep_Parameter_Lifter::insert_(int dim,                                    Brep::ControlPointIndex cp1,                                    Brep::ControlPointIndex cp2,                                    int lift1,                                     int lift2,                                    const Brep::Face_Spec& fspec,                                    Brep::PatchIndex& patchind) {  Bdry_CtlPoint_Key key;  Patch_Address rec;  key.bdry_dim = dim;  key.bdry_pts[0] = cp1;  key.bdry_pts[1] = cp2;  rec.fspec = fspec;  rec.patchind = patchind;  rec.lift_coord[0] = lift1;  rec.lift_coord[1] = lift2;  lookup_map_.insert(pair<Bdry_CtlPoint_Key, Patch_Address>(key,rec));  if (dim == 1) {    key.bdry_pts[0] = cp2;    key.bdry_pts[1] = cp1;    if (lift1 == 2 || lift1 == 3)      rec.lift_coord[0] = 5 - lift1;    if (lift2 == 2 || lift2 == 3)      rec.lift_coord[1] = 5 - lift2;    lookup_map_.insert(pair<Bdry_CtlPoint_Key, Patch_Address>(key,rec));  }}QMG::Brep_Parameter_Lifter::Brep_Parameter_Lifter(const Brep& b) :b_(b){  for (Brep::Face_Spec_Loop_Over_Faces fspec(b);       fspec.notdone();       ++fspec) {    int fdim = fspec.fdim();        for (Brep::Loop_over_patches_of_face ptloop(b, fspec);         ptloop.notdone();         ++ptloop) {      // Put all the boundaries of this face in      // the hash table.            Brep::PatchIndex patchind = ptloop.index();      if (fdim == 1) {        int deg = ptloop.degree1();        Brep::ControlPointIndex cp1 = ptloop.control_point(0);        Brep::ControlPointIndex cp2 = ptloop.control_point(deg);        // Insert the endpoints.        insert_(0, cp1, 0, 0, 0, fspec, patchind);        insert_(0, cp2, 0, 1, 0, fspec, patchind);      }      else if (fdim == 2) {        if (ptloop.ptype() == BEZIER_TRIANGLE) {          int deg = ptloop.degree1();          Brep::ControlPointIndex cp1 = ptloop.control_point(0);          Brep::ControlPointIndex cp2 =             ptloop.control_point(deg * (deg + 1) / 2);          Brep::ControlPointIndex cp3 =             ptloop.control_point((deg + 1) * (deg + 2) / 2 - 1);                    // Insert the three vertices.          insert_(0, cp1, 0, 0, 1, fspec, patchind);          insert_(0, cp2, 0, 0, 0, fspec, patchind);          insert_(0, cp3, 0, 1, 0, fspec, patchind);          // Insert the three edges.  (Each one twice)          insert_(1, cp1, cp2, 0, 3, fspec, patchind);          insert_(1, cp1, cp3, 2, 3, fspec, patchind);          insert_(1, cp2, cp3, 2, 0, fspec, patchind);        }        else { // patchtype = quad.          int deg1 = ptloop.degree1();          int deg2 = ptloop.degree2();          Brep::ControlPointIndex cp1 = ptloop.control_point(0);          Brep::ControlPointIndex cp2 = ptloop.control_point(deg1);          Brep::ControlPointIndex cp3 =             ptloop.control_point(deg2 * (deg1 + 1));          Brep::ControlPointIndex cp4 =             ptloop.control_point((deg2 + 1) * (deg1 + 1) - 1);          // Insert the four boundary points.          insert_(0, cp1, 0, 0, 0, fspec, patchind);          insert_(0, cp2, 0, 1, 0, fspec, patchind);          insert_(0, cp3, 0, 0, 1, fspec, patchind);          insert_(0, cp4, 0, 1, 1, fspec, patchind);          // Insert the four edges, each one twice.          insert_(1, cp1, cp2, 2, 0, fspec, patchind);          insert_(1, cp1, cp3, 0, 2, fspec, patchind);          insert_(1, cp2, cp4, 1, 2, fspec, patchind);          insert_(1, cp3, cp4, 2, 1, fspec, patchind);        }      }    }  }}          #ifndef BUG_IN_USINGusing QMG::pair;#endifpair<QMG::Point, QMG::Brep::PatchIndex>QMG::Brep_Parameter_Lifter::lift_parameters(const Brep::Face_Spec& orig_fspec,                                            Brep::PatchIndex orig_patchind,                                            const Point& orig_paramcoord,                                            const Brep::Face_Spec& target_fspec) const {  if (orig_fspec == target_fspec)     return pair<Point,Brep::PatchIndex>(orig_paramcoord, orig_patchind);  Bdry_CtlPoint_Key key;  int ofdim = orig_fspec.fdim();  key.bdry_dim = ofdim;  key.bdry_pts[0] = b_.patch_control_point(orig_fspec, orig_patchind, 0);  if (ofdim == 1) {    int deg = b_.patch_degree1(orig_fspec, orig_patchind);    key.bdry_pts[1] = b_.patch_control_point(orig_fspec, orig_patchind, deg);  }  typedef multimap<Bdry_CtlPoint_Key, Patch_Address> MBPA;  typedef MBPA::const_iterator MapIt;  Real tmpc[5];  tmpc[0] = 0.0;  tmpc[1] = 1.0;  tmpc[2] = orig_paramcoord[0];  tmpc[3] = 1.0 - orig_paramcoord[0];  pair<MapIt,MapIt> rval = lookup_map_.equal_range(key);  Point returnpoint;  for (MapIt it1 = rval.first; it1 != rval.second; ++it1) {    if (it1 -> second.fspec == target_fspec) {      returnpoint[0] = tmpc[it1 -> second.lift_coord[0]];      if (target_fspec.fdim() == 2) {        returnpoint[1] = tmpc[it1 -> second.lift_coord[1]];      }      return pair<Point, Brep::PatchIndex>(returnpoint, it1 -> second.patchind);    }  }  throw_error("Parent patch not found in lift_parameters");  // This statement never reached, but VC++5.0 won't compile without it.  return pair<Point, Brep::PatchIndex>(orig_paramcoord, orig_patchind);}      

⌨️ 快捷键说明

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