📄 qbrep.h
字号:
// ------------------------------------------------------------------// qbrep.h//// This file contains the definitions of the class Brep and its// nested classes (for Matlab scripting).// ------------------------------------------------------------------// 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.// ------------------------------------------------------------------#ifndef QBREP_H#define QBREP_H#include "qnamesp.h"#include "qpoint.h"#include "qpatchmath.h"extern "C" {#include "mex.h"}// ------------------------------------------------------------------// Class QMG::Brep// A Brep is a C++ wrapper around a Matlab struct to represent// represent geometries.class QMG::Brep {public: // ------------------------------------------------------------------ // class QMG::Brep::Face_Spec // a Brep::Face_Spec specifies a topological face (entity) of a brep. // It is two integers: the first is the dimension of the face // (i.e. 0 = top vtx, 1 = top edge, etc) and the second is the // index within the dimension. typedef int PatchIndex; typedef int ControlPointIndex; typedef int FaceIndex; class Face_Spec { protected: int fdim_; FaceIndex faceind_; public: inline int fdim() const {return fdim_;} inline FaceIndex faceind() const {return faceind_;} Face_Spec(int fdim1, FaceIndex faceind1) : fdim_(fdim1), faceind_(faceind1) { } Face_Spec() { } Face_Spec(const Face_Spec& fspec) : fdim_(fspec.fdim_), faceind_(fspec.faceind_) { } inline virtual Face_Spec& operator=(const Face_Spec& fspec) { fdim_ = fspec.fdim(); faceind_ = fspec.faceind(); return *this; } inline bool operator==(const Face_Spec& fspec) const { return fspec.fdim_ == fdim_ && fspec.faceind_ == faceind_; } inline bool operator!=(const Face_Spec& fspec) const { return fspec.fdim_ != fdim_ || fspec.faceind_ != faceind_; } inline bool operator<(const Face_Spec& fspec) const { return fdim_ < fspec.fdim_ || (fdim_ == fspec.fdim_ && faceind_ < fspec.faceind_); } inline bool operator<=(const Face_Spec& fspec) const { return (*this < fspec) || (*this == fspec); } inline bool operator>(const Face_Spec& fspec) const { return fspec < *this; } inline bool operator>=(const Face_Spec& fspec) const { return (fspec < *this) || (*this == fspec); } virtual ~Face_Spec() { } };protected: struct Face_Rec1 { FaceIndex faceind; int ori; }; typedef map<Face_Spec, vector<Face_Rec1> > ChildLookupMapType; typedef map<Face_Spec, vector<Face_Spec> > IBLookupMapType; const mxArray* geo_; // Cache items from geo_ for faster access. ChildLookupMapType* child_lookup_map_; IBLookupMapType* ib_lookup_map_; int c_gdim_; int c_embedded_dim_; int c_numpv_; const mxArray* c_pvlist_; int c_num_control_points_; const double* c_control_points_; const mxArray* c_top_faces_[MAXDIM + 1]; int c_num_top_faces_[MAXDIM + 1]; // Default constructor protected -- only Brep_Under_Construction // can use it. Brep() { } // No assignmentprivate: void operator=(const Brep&) { }public: // Copying OK; copies pointer Brep(const Brep& o); static string global_id_propname() {return string("geo_global_id");} static const char* io_header_code() {return "brep_v2.0";}public: int level_size(int dim) const; // ------------------------------------------------------------------ // class QMG::Brep::Face_Spec_Loop_Over_Faces_Of_Dim // This class is for iterating over all topological faces of a certain // dimension. It is used like this: // for (Brep::Face_Spec_Loop_Over_Faces_Of_Dim fspec(g, d); fspec.notdone(); // ++fspec()) { ... } class Face_Spec_Loop_Over_Faces_Of_Dim; friend class Face_Spec_Loop_Over_Faces_Of_Dim; class Face_Spec_Loop_Over_Faces_Of_Dim : public Face_Spec { private: int num_face_; // no copying, no assignment Face_Spec_Loop_Over_Faces_Of_Dim(const Face_Spec_Loop_Over_Faces_Of_Dim&) { } virtual Face_Spec& operator=(const Face_Spec&) {return *this;} void operator=(const Face_Spec_Loop_Over_Faces_Of_Dim&) { } public: Face_Spec_Loop_Over_Faces_Of_Dim(const Brep& g, int d) : Face_Spec(d, 0), num_face_(g.level_size(d)) { } bool notdone() const {return this -> faceind_ < num_face_;} void operator++() { ++(this -> faceind_); } }; // ------------------------------------------------------------------ // class QMG::Brep::Face_Spec_Loop_Over_Faces // This class is for iterating over all topological faces of the // whole brep. Its usage is: // for (Brep::Face_Spec_Loop_Over_Faces fspec(g); fspec.notdone(); // ++fspec()) { ... } class Face_Spec_Loop_Over_Faces; friend class Face_Spec_Loop_Over_Faces; class Face_Spec_Loop_Over_Faces : public Face_Spec { private: const Brep& g_; int num_face_this_lev_; int bump_lev_(int d) { while (d <= g_.gdim() && (num_face_this_lev_ = g_.level_size(d)) == 0) ++d; return d; } // no copying, no assignment virtual Face_Spec& operator=(const Face_Spec&) {return *this; } Face_Spec_Loop_Over_Faces(const Face_Spec_Loop_Over_Faces& o) : g_(o.g_) { } void operator=(const Face_Spec_Loop_Over_Faces&) { } public: explicit Face_Spec_Loop_Over_Faces(const Brep& g) : g_(g) { this -> fdim_ = bump_lev_(0); this -> faceind_ = 0; } void operator++() { ++(this -> faceind_); if (this -> faceind_ == num_face_this_lev_) { this -> fdim_ = bump_lev_(this -> fdim_ + 1); this -> faceind_ = 0; } } bool notdone() const {return this -> fdim_ <= g_.gdim(); } };public: // ------------------------------------------------------------------ // class QMG::Brep::Face_Spec_Loop_Over_Face_Subfaces // This class is for iterating over all topological faces that are // subfaces (either internal boundaries or bounding) of a given face. // The usage is: // for (Brep::Face_Spec_Loop_Over_Face_Subfaces subfspec(g,fspec); subfspec.notdone(); // ++subfspec()) { ... } class Face_Spec_Loop_Over_Face_Subfaces; friend class Face_Spec_Loop_Over_Face_Subfaces; class Face_Spec_Loop_Over_Face_Subfaces : public Face_Spec { const Brep& brep_; int parentfdim_; int count_; int orientation_; int num_child_; int num_ib_; Face_Spec parent_; vector<Face_Rec1>& child_list_; vector<Face_Spec>& ib_list_; void set_this_(); // no copying, no assignment Face_Spec_Loop_Over_Face_Subfaces(const Face_Spec_Loop_Over_Face_Subfaces& o) : brep_(o.brep_), child_list_(o.child_list_), ib_list_(o.ib_list_) {} void operator=(const Face_Spec_Loop_Over_Face_Subfaces&) { } virtual Face_Spec& operator=(const Face_Spec&) {return *this; } public: Face_Spec_Loop_Over_Face_Subfaces(const Brep& g, const Face_Spec& f); void operator++() {++count_; set_this_();} bool notdone() const {return this -> fdim_ >= 0;} int orientation() const { return orientation_;} bool is_internal_boundary() const {return this -> fdim_ < parentfdim_ - 1; } };private: // ------------------------------------------------------------------ // This class is for doing math with patches of a // brep. It is a wrapper around the patchmath class. class PatchMath_for_Brep; friend class PatchMath_for_Brep; class PatchMath_for_Brep : public PatchMath { private: const double* controlpoints_; const double* controlpointindices_; int di_; Real control_point_coord_(int cpnum, int d) const; public: PatchMath_for_Brep(PatchType ptype, const Brep& brep, const double* controlpointindices, int patchdim, int degree1, int degree2) : PatchMath(ptype, degree1, degree2, patchdim, brep.c_embedded_dim_, false), controlpoints_(brep.c_control_points_), controlpointindices_(controlpointindices), di_(brep.c_embedded_dim_) { } ~PatchMath_for_Brep() { } };private: struct Patchinfo_ {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -