qbrep.cpp
来自「算断裂的」· C++ 代码 · 共 580 行 · 第 1/2 页
CPP
580 行
// ------------------------------------------------------------------// qbrep.cpp//// This file contains member functions for qbrep.h// ------------------------------------------------------------------// 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.h"QMG::RealQMG::Brep::PatchMath_for_Brep::control_point_coord_(int cprel, int d) const { if (patchdim_ == 0) { ControlPointIndex cpind = geo_ -> top_vertices[faceind_].control_pnt_indx; return geo_ -> control_points[cpind].coord[d]; } else if (patchdim_ == 1) { ControlPointIndex cpind = geo_ -> top_edges[faceind_].curves[patchind_].control_pnt_indx[cprel]; return geo_ -> control_points[cpind].coord[d]; } else { ControlPointIndex cpind = geo_ -> top_surfaces[faceind_].patches[patchind_].control_pnt_indx[cprel]; return geo_ -> control_points[cpind].coord[d]; }}int QMG::Brep::face_number_of_patches(const Face_Spec& fspec) const { int fdim = fspec.fdim(); int faceind = fspec.faceind();#ifdef RANGECHECK if (fdim < 0 || fdim > geo_ -> intrinsic_dimension || fdim > 2 || fdim >= geo_ -> embedded_dimension) throw_error("Range error in fdim in face_number_of_patches"); if (faceind < 0 || faceind >= level_size(fdim)) throw_error("Range error in faceind in face_number_of_patches");#endif if (fdim == 0) return 1; else if (fdim == 1) return geo_ -> top_edges[faceind].num_curves; else return geo_ -> top_surfaces[faceind].num_patches;} int QMG::Brep::patch_degree1(const Face_Spec& fspec, PatchIndex patchind) const { int fdim = fspec.fdim(); FaceIndex faceind = fspec.faceind();#ifdef RANGECHECK if (fdim < 0 || fdim > 2 || fdim >= geo_ -> embedded_dimension || faceind < 0 || faceind >= level_size(fdim)) throw_error("Fspec out of range"); int numpatches = (fdim == 0)? 1 : ((fdim == 1)? geo_ -> top_edges[faceind].num_curves : geo_ -> top_surfaces[faceind].num_patches); if (patchind < 0 || patchind >= numpatches) throw_error("Patchind out of range");#endif if (fdim == 0) return 1; else if (fdim == 1) return geo_ -> top_edges[faceind].curves[patchind].order; else return geo_ -> top_surfaces[faceind].patches[patchind].order_u;}int QMG::Brep::patch_degree2(const Face_Spec& fspec, PatchIndex patchind) const { int fdim = fspec.fdim(); FaceIndex faceind = fspec.faceind();#ifdef RANGECHECK if (fdim < 2 || fdim > 2 || fdim >= geo_ -> embedded_dimension || faceind < 0 || faceind >= level_size(fdim)) throw_error("Fspec out of range"); int numpatches = geo_ -> top_surfaces[faceind].num_patches; if (patchind < 0 || patchind >= numpatches) throw_error("Patchind out of range");#endif if (fdim != 2 || geo_ -> top_surfaces[faceind].patches[patchind].type != CPTC_PATCHTYPE_QUAD) return 1; return geo_ -> top_surfaces[faceind].patches[patchind].order_v;}QMG::PatchTypeQMG::Brep::patch_type(const Face_Spec& fspec, PatchIndex patchind) const { int fdim = fspec.fdim(); FaceIndex faceind = fspec.faceind();#ifdef RANGECHECK if (fdim < 0 || fdim > 2 || fdim >= geo_ -> embedded_dimension || faceind < 0 || faceind >= level_size(fdim)) throw_error("Fspec out of range"); int numpatches = (fdim == 0)? 1 : ((fdim == 1)? geo_ -> top_edges[faceind].num_curves : geo_ -> top_surfaces[faceind].num_patches); if (patchind < 0 || patchind >= numpatches) throw_error("Patchind out of range");#endif if (fdim < 2) return BEZIER_TRIANGLE; else if (geo_ -> top_surfaces[faceind].patches[patchind].type == CPTC_PATCHTYPE_TRIANGLE) return BEZIER_TRIANGLE; return BEZIER_QUAD;}QMG::Brep::ControlPointIndexQMG::Brep::patch_control_point(const Face_Spec& fspec, PatchIndex patchind, int cpindex) const { int fdim = fspec.fdim(); FaceIndex faceind = fspec.faceind();#ifdef RANGECHECK if (fdim < 0 || fdim > 2 || fdim >= geo_ -> embedded_dimension || faceind < 0 || faceind >= level_size(fdim)) throw_error("Fspec out of range"); int numpatches = (fdim == 0)? 1 : ((fdim == 1)? geo_ -> top_edges[faceind].num_curves : geo_ -> top_surfaces[faceind].num_patches); if (patchind < 0 || patchind >= numpatches) throw_error("Patchind out of range"); if (cpindex < 0) throw_error("cpindex negative"); if (fdim == 0) { if (cpindex > 0) throw_error("cpindex range err 1"); } else if (fdim == 1) { if (cpindex > geo_ -> top_edges[faceind].curves[patchind].order) throw_error("cpindex range err 2"); } else if (geo_ -> top_surfaces[faceind].patches[patchind].type == CPTC_PATCHTYPE_TRIANGLE) { int ord = geo_ -> top_surfaces[faceind].patches[patchind].order_u; if (cpindex >= (ord + 1) * (ord + 2) / 2) throw_error("cpindex range err 3"); } else { int ord1 = geo_ -> top_surfaces[faceind].patches[patchind].order_u; int ord2 = geo_ -> top_surfaces[faceind].patches[patchind].order_v; if (cpindex >= (ord1 + 1) * (ord2 + 1)) throw_error("cpindex range err 4"); }#endif if (fdim == 0) return geo_ -> top_vertices[faceind].control_pnt_indx; else if (fdim == 1) return geo_ -> top_edges[faceind].curves[patchind].control_pnt_indx[cpindex]; else return geo_ -> top_surfaces[faceind].patches[patchind].control_pnt_indx[cpindex];}QMG::Brep::PatchMath_for_Brep QMG::Brep::patchmath(const Face_Spec& fspec, PatchIndex patchind) const { int fdim = fspec.fdim(); FaceIndex faceind = fspec.faceind();#ifdef RANGECHECK if (fdim < 0 || fdim > 2 || fdim >= geo_ -> embedded_dimension || faceind < 0 || faceind >= level_size(fdim)) throw_error("Fspec out of range"); int numpatches = (fdim == 0)? 1 : ((fdim == 1)? geo_ -> top_edges[faceind].num_curves : geo_ -> top_surfaces[faceind].num_patches); if (patchind < 0 || patchind >= numpatches) throw_error("Patchind out of range");#endif if (fdim == 0) { return PatchMath_for_Brep(BEZIER_TRIANGLE, 1, 0, geo_, 0, faceind, patchind); } else if (fdim == 1) { return PatchMath_for_Brep(BEZIER_TRIANGLE, geo_ -> top_edges[faceind].curves[patchind].order, 0, geo_, 1, faceind, patchind); } else { //fdim == 2 return PatchMath_for_Brep( (geo_ -> top_surfaces[faceind].patches[patchind].type == CPTC_PATCHTYPE_TRIANGLE)? BEZIER_TRIANGLE : BEZIER_QUAD, geo_ -> top_surfaces[faceind].patches[patchind].order_u, geo_ -> top_surfaces[faceind].patches[patchind].order_v, geo_, 2, faceind, patchind); }}// level_size (number of topological faces of a given dim) of a brep// see qbrep.h for additional comments about these classes.int QMG::Brep::level_size(int dim) const {#ifdef RANGECHECK if (dim < 0 || dim > geo_ -> intrinsic_dimension) { throw_error("Dimension out of range in loop _over faces of dim"); }#endif switch(dim) { case 0: return geo_ -> num_top_vertices; case 1: return geo_ -> num_top_edges; case 2: return geo_ -> num_top_surfaces; } // case 3: return geo_ -> num_top_regions;}QMG::Brep::Face_Spec_Loop_Over_Face_Subfaces::Face_Spec_Loop_Over_Face_Subfaces(const Brep& g, const Face_Spec& f) { count_ = 0; parentfdim_ = f.fdim(); FaceIndex parentfaceind = f.faceind();#ifdef RANGECHECK if (parentfdim_ < 0 || parentfdim_ > g.gdim()) throw_error("Fdim out of range in loop_over_face_subfaces"); if (parentfaceind < 0) throw_error("Faceind out of range (0) in loop_over_face_subfaces");#endif if (parentfdim_ == 1) {#ifdef RANGECHECK if (parentfaceind >= g.geo_ -> num_top_edges) throw_error("Faceind out range (1) in loop_over_face_subfaces");#endif this_edge_ = & (g.geo_ -> top_edges[parentfaceind]); } else if (parentfdim_ == 2) {#ifdef RANGECHECK if (parentfaceind >= g.geo_ -> num_top_surfaces) throw_error("Faceind out of range (2) in loop_over_face_subfaces");#endif this_surf_ = & (g.geo_ -> top_surfaces[parentfaceind]); } else if (parentfdim_ == 3) {#ifdef RANGECHECK if (parentfaceind >= g.geo_ -> num_top_surfaces) throw_error("Faceind out of range (3) in loop_over_face_subfaces");#endif this_region_ = &(g.geo_ -> top_regions[parentfaceind]); } set_this_();}void QMG::Brep::Face_Spec_Loop_Over_Face_Subfaces::set_this_() { orientation_ = 2; if (parentfdim_ == 1 && count_ < this_edge_ -> num_bound_vertices) { this -> fdim_ = 0; this -> faceind_ = this_edge_ -> bound_vertices[count_]; return; } if (parentfdim_ == 2) { if (count_ < this_surf_ -> num_bound_vertices) { this -> fdim_ = 0; this -> faceind_ = this_surf_ -> bound_vertices[count_]; return; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?