📄 qbrep_constr.cpp
字号:
iblist_((*(brep.ib_lookup_map_))[fspec]), fspec_(fspec) { int fdim = fspec.fdim(); int faceind = fspec.faceind(); if (fdim < 0 || fdim > brep_.c_gdim_ || faceind < 0 || faceind >= brep_.c_num_top_faces_[fdim]) throw_error("Range error in top face bound inserter"); childlist1_ = mxGetCell(brep_.c_top_faces_[fdim], 5 * faceind + 2); if (childlist1_ == 0) throw_error("Attempt to create ib-inserter to face that has no childlist"); maxsize1_ = mxGetN(childlist1_); iblist1_ = mxGetCell(brep_.c_top_faces_[fdim], 5 * faceind + 3); if (iblist1_ == 0 || mxGetN(iblist1_) > 0) throw_error("Attempt to create ib-inserter to face that already has ib's"); maxsize2_ = 0;}void QMG::Brep_Under_Construction::Top_face_ib_inserter::insert_ib(const Brep::Face_Spec& subfspec) { if (subfspec.fdim() == fspec_.fdim() - 1) { for (int count = 0; count < 2; ++count) { int numchild = mxGetN(childlist1_); if (numchild == maxsize1_) { int newsize = numchild * 2 + 2; mxArray** oldcells = static_cast<mxArray**>(mxGetData(childlist1_)); mxArray** newcells = static_cast<mxArray**>(mxMalloc(newsize * sizeof(mxArray*))); for (int j = 0; j < numchild; ++j) newcells[j] = oldcells[j]; mxFree(oldcells); mxSetData(childlist1_, static_cast<void*>(newcells)); maxsize1_ = newsize; } mxSetN(childlist1_, numchild + 1); mxSetCell(childlist1_, numchild, mxCreateString(brep_.face_name(subfspec).c_str())); Face_Rec1 rec; rec.faceind = subfspec.faceind(); rec.ori = 2; childlist_.push_back(rec); } } else { int numib = mxGetN(iblist1_); if (numib == maxsize2_) { int newsize = numib * 2 + 2; mxArray** oldcells = static_cast<mxArray**>(mxGetData(iblist1_)); mxArray** newcells = static_cast<mxArray**>(mxMalloc(newsize * sizeof(mxArray*))); for (int j = 0; j < numib; ++j) newcells[j] = oldcells[j]; mxFree(oldcells); mxSetData(iblist1_, static_cast<void*>(newcells)); maxsize2_ = newsize; } mxSetN(iblist1_, numib + 1); mxSetCell(iblist1_, numib, mxCreateString(brep_.face_name(subfspec).c_str())); iblist_.push_back(subfspec); }}QMG::Brep_Under_Construction::Top_face_propval_inserter::Top_face_propval_inserter(Brep_Under_Construction& brep, const Brep::Face_Spec& fspec):brep_(brep){ int fdim = fspec.fdim(); int faceind = fspec.faceind(); if (fdim < 0 || fdim > brep_.c_gdim_ || faceind < 0 || faceind >= brep_.c_num_top_faces_[fdim]) throw_error("Range error in top face patch inserter"); pvlist_ = mxGetCell(brep_.c_top_faces_[fdim], 5 * faceind + 1); if (pvlist_ == 0 || mxGetN(pvlist_) > 0) throw_error("Attempt to create patch inserter for face that already has patches"); maxsize_ = 0;}voidQMG::Brep_Under_Construction::Top_face_propval_inserter::insert_propval(const string& prop, const string& val) { int npv = mxGetN(pvlist_); if (npv == maxsize_) { int newsize = npv * 2 + 2; mxArray** oldcells = static_cast<mxArray**>(mxGetData(pvlist_)); mxArray** newcells = static_cast<mxArray**>(mxMalloc(2 * newsize * sizeof(mxArray*))); for (int j = 0; j < 2 * npv; ++j) newcells[j] = oldcells[j]; mxFree(oldcells); mxSetData(const_cast<mxArray*>(pvlist_), static_cast<void*>(newcells)); maxsize_ = newsize; } mxSetCell(const_cast<mxArray*>(pvlist_), 2 * npv, mxCreateString(prop.c_str())); mxSetCell(const_cast<mxArray*>(pvlist_), 2 * npv + 1, mxCreateString(val.c_str())); mxSetN(const_cast<mxArray*>(pvlist_), npv + 1);}QMG::Brep_Under_Construction::Top_face_propval_inserter::~Top_face_propval_inserter() {}QMG::Brep_Under_Construction::Top_face_patch_inserter::Top_face_patch_inserter(Brep_Under_Construction& brep, const Brep::Face_Spec& fspec) : brep_(brep), fspec_(fspec) { int fdim = fspec.fdim(); int faceind = fspec.faceind(); if (fdim < 0 || fdim > brep_.c_gdim_ || faceind < 0 || faceind >= brep_.c_num_top_faces_[fdim]) throw_error("Range error in top face patch inserter"); patchlist_ = mxGetCell(brep_.c_top_faces_[fdim], 5 * faceind + 4); if (patchlist_ == 0 || mxGetN(patchlist_) > 0) throw_error("Attempt to create patch inserter for face that already has patches"); maxsize_ = 0;}void QMG::Brep_Under_Construction::Top_face_patch_inserter::insert_patch(int degree1, int degree2, PatchType ptype, const vector<Brep::ControlPointIndex>& control_points) { if (fspec_.fdim() > 2 || fspec_.fdim() >= brep_.c_embedded_dim_) throw_error("Attempt to insert patch into chamber"); int numpatch = mxGetN(patchlist_); if (numpatch == maxsize_) { int newsize = numpatch * 2 + 2; mxArray** newcells = static_cast<mxArray**>(mxMalloc(sizeof(mxArray*) * newsize * 3)); mxArray** oldcells = static_cast<mxArray**>(mxGetData(patchlist_)); for (int j = 0; j < numpatch * 3; ++j) newcells[j] = oldcells[j]; mxFree(oldcells); mxSetData(patchlist_, newcells); maxsize_ = newsize; } char* patchtype = "vertex"; if (fspec_.fdim() == 1) patchtype = "bezier_curve"; else if (fspec_.fdim() == 2) { if (ptype == BEZIER_QUAD) patchtype = "bezier_quad"; else patchtype = "bezier_triangle"; } mxSetCell(patchlist_, 3 * numpatch, mxCreateString(patchtype)); mxArray* deg1; if (fspec_.fdim() == 0) { deg1 = mxCreateDoubleMatrix(0,1, mxREAL); } else if (fspec_.fdim() == 1 || (fspec_.fdim() == 2 && ptype == BEZIER_TRIANGLE)) { deg1 = mxCreateDoubleMatrix(1,1, mxREAL); *mxGetPr(deg1) = static_cast<double>(degree1); } else { deg1 = mxCreateDoubleMatrix(2,1, mxREAL); mxGetPr(deg1)[0] = static_cast<double>(degree1); mxGetPr(deg1)[1] = static_cast<double>(degree2); } mxSetCell(patchlist_, 3 * numpatch + 1, deg1); int ncp = control_points.size(); int ncp1; if (fspec_.fdim() == 0) ncp1 = 1; else if (fspec_.fdim() == 1) ncp1 = degree1 + 1; else if (ptype == BEZIER_TRIANGLE) ncp1 = (degree1 + 1) * (degree1 + 2) / 2; else ncp1 = (degree1 + 1) * (degree2 + 1); if (ncp != ncp1) throw_error("Patch has the wrong number of control points"); mxArray* cp1 = mxCreateDoubleMatrix(ncp, 1, mxREAL); for (int j = 0; j < ncp; ++j) { if (control_points[j] < 0 || control_points[j] >= brep_.c_num_control_points_) throw_error("Control point index out of range"); mxGetPr(cp1)[j] = static_cast<double>(control_points[j]); } mxSetCell(patchlist_, 3 * numpatch + 2, cp1); mxSetN(patchlist_, numpatch + 1);}QMG::Brep_Under_Construction::~Brep_Under_Construction() { if (geo_ != 0) mxDestroyArray(const_cast<mxArray*>(geo_));}mxArray*QMG::Brep_Under_Construction::release() { mxArray* gtmp = const_cast<mxArray*>(geo_); geo_ = 0; delete child_lookup_map_; delete ib_lookup_map_; child_lookup_map_ = 0; ib_lookup_map_ = 0; return gtmp;}QMG::Brep_Under_Construction::Brep_Under_Construction(Brep_Under_Construction& other) : Brep(other) { mxArray* geoentries = mxGetFieldByNumber(geo_, 0, 0); control_points_a_ = mxGetCell(geoentries, 4); child_lookup_map_ = other.child_lookup_map_; ib_lookup_map_ = other.ib_lookup_map_; other.child_lookup_map_ = 0; other.ib_lookup_map_ = 0; other.geo_ = 0;} QMG::Brep_Under_Construction:: Brep_Under_Construction(const Brep_Under_Construction_Returnval& sucr) : Brep(sucr.bref_) { mxArray* geoentries = mxGetFieldByNumber(geo_, 0, 0); control_points_a_ = mxGetCell(geoentries, 4); child_lookup_map_ = sucr.bref_.child_lookup_map_; ib_lookup_map_ = sucr.bref_.ib_lookup_map_; sucr.bref_.child_lookup_map_ = 0; sucr.bref_.ib_lookup_map_ = 0; sucr.bref_.geo_ = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -