📄 qsimpcomp.h
字号:
// ------------------------------------------------------------------// qsimpcomp.h//// This file contains the definitions of the class SimpComp and SimpComp_// Under_Construction, which are for simplicial complexes (meshes).// This version of qsimpcomp.h is for the Matlab front end.// ------------------------------------------------------------------// 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 QSIMPCOMP_H#define QSIMPCOMP_H#include "qnamesp.h"#include "qbrep.h"// ------------------------------------------------------------------// Class QMG::SimpComplex// Holds a mesh. Is actually a wrapper around the C data structure// Cptc_MshDesc.class QMG::SimpComplex {public: typedef int VertexOrdinalIndex; typedef int VertexGlobalIndex; typedef map<VertexGlobalIndex, VertexOrdinalIndex> GlobalToOrdinalMapType;protected: // The mesh is here. const mxArray* mesh_; // Cache some data for faster access. int c_embedded_dim_; int c_gdim_; const mxArray* c_entries_; Real* c_nodearray_; // An aux data structure to map global to ordinal vertex indices. mutable GlobalToOrdinalMapType* global_to_ordinal_; // Derived classes make simpcomplex from pieces. SimpComplex() { }private: // no assignment. void operator=(const SimpComplex&) { } virtual void verify_global_to_ordinal_() const { if (global_to_ordinal_) return; throw_error("Missing global_to_ordinal"); }public: static const char* io_header_code() {return "mesh_v2.01";} // Copying just copies pointer SimpComplex(const SimpComplex& other); // Member functions to return information about the mesh: // intrinsic dimension, embedded dimension, number of nodes, // number of elements, and the Global ID of the brep from // which this mesh was created. int gdim() const {return c_gdim_; } int embedded_dim() const { return c_embedded_dim_;} int num_nodes() const; int num_elements() const; int brep_levelsize(int level) const; string lookup_prop_val(const string& prop) const; int num_prop_val() const; string prop(int i) const; string val(int i) const;private: VertexOrdinalIndex process_ordinal_vnum_(VertexOrdinalIndex vnumo) const;public: VertexOrdinalIndex global_to_ordinal(VertexGlobalIndex vnum) const { verify_global_to_ordinal_(); GlobalToOrdinalMapType::const_iterator it = global_to_ordinal_ -> find(vnum); if (it == global_to_ordinal_ -> end()) throw_error("Global vertex index not in mesh"); return it -> second; } VertexOrdinalIndex global_to_ordinal_nothrow(VertexGlobalIndex vnum) const { verify_global_to_ordinal_(); GlobalToOrdinalMapType::const_iterator it = global_to_ordinal_ -> find(vnum); if (it == global_to_ordinal_ -> end()) return -1; return it -> second; } VertexGlobalIndex ordinal_to_global(VertexOrdinalIndex vnumo) const; // Member functions to return info about the nodes: real coordinates, // owning topological face, patch index, parametric coordinates. Real real_coord_o(VertexOrdinalIndex vnumo, int jj) const; Real real_coord(VertexGlobalIndex vnum, int jj) const { return real_coord_o(global_to_ordinal(vnum), jj); }public: // Member functions to look up nodes adjacent to a top. entity. int num_node_on_face(const Brep::Face_Spec& fspec) const; VertexGlobalIndex node_on_face(const Brep::Face_Spec& fspec, int seqno) const; Brep::PatchIndex patchind_on_face(const Brep::Face_Spec& fspec, int seqno) const; Real param_coord_on_face(const Brep::Face_Spec& fspec, int seqno, int jj) const; // Member functions to return info about the elements: the vertices making // up the element, and the topological faces owning the element's faces. int num_meshface_on_face(const Brep::Face_Spec& fspec) const; VertexGlobalIndex node_of_meshface_on_face(const Brep::Face_Spec& fspec, int seqno, int jj) const; virtual ~SimpComplex() { }};// ------------------------------------------------------------------// A derived class that takes a pointer to the C-data structure// for a mesh and constructs the auxiliary data item. // class QMG::SimpComplex_From_FrontEnd : public QMG::SimpComplex {private: void make_global_to_ordinal_() const; virtual void verify_global_to_ordinal_() const { if (!global_to_ordinal_) make_global_to_ordinal_(); } public: explicit SimpComplex_From_FrontEnd(const mxArray* mesh); ~SimpComplex_From_FrontEnd(); // Destructive copy & destructive copy using standard // helper class.private: class SimpComplex_From_FrontEnd_Returnval { private: friend class SimpComplex_From_FrontEnd; SimpComplex_From_FrontEnd& sref_; SimpComplex_From_FrontEnd_Returnval(SimpComplex_From_FrontEnd& s, int) : sref_(s) { } };public: // destructive copy semantics (like auto_ptr) SimpComplex_From_FrontEnd(SimpComplex_From_FrontEnd& other); SimpComplex_From_FrontEnd(const SimpComplex_From_FrontEnd_Returnval& sucr); operator SimpComplex_From_FrontEnd_Returnval() { return SimpComplex_From_FrontEnd_Returnval(*this, 0); }};// ------------------------------------------------------------------// Class QMG::SimpComplex_Under_Construction// Holds a mesh. Is actually a wrapper around the C data structure// Cptc_MshDesc. This routine allows the user to build a simplicial// complex node by node and element by element using member functions.// It maintains data about the present size of all the arrays so// that it can tell when a new malloc is needed.class QMG::SimpComplex_Under_Construction : public QMG::SimpComplex {private: // These are the max sizes of the allocated arrays in the Cptc_MshDesc // data structure. map<Brep::Face_Spec, int>* max_nodes_per_face_; map<Brep::Face_Spec, int>* max_elems_per_face_; vector<int> max_lev_size_; int max_nodes_; int max_prop_val_; VertexGlobalIndex next_vnum_; struct Vertex_Bdry_Inc_ { VertexGlobalIndex vnum; Brep::Face_Spec fspec; bool operator<(const Vertex_Bdry_Inc_& other) const; }; struct Vertex_Pos_ { Brep::PatchIndex patchind; double param[2]; }; typedef map<Vertex_Bdry_Inc_, Vertex_Pos_> Vert_Bdry_Lookup_; Vert_Bdry_Lookup_* vertinclookup_; struct Face_Bdry_Inc_ { VertexGlobalIndex meshv[3]; bool operator<(const Face_Bdry_Inc_& other) const; }; // A data structure to hold mesh entities (higher dim. than vertices) // lying on a brep boundary. typedef map<Face_Bdry_Inc_, Brep::Face_Spec> Face_Bdry_Lookup_; Face_Bdry_Lookup_* faceinclookup_; // Kills the data structure. Used when transferring ownership. void clobber_(); // no assignment void operator=(const SimpComplex_Under_Construction&) { } virtual void verify_global_to_ordinal_() const {}public: // Routine to add a new vertex to the complex. Need its real coordinates. // Return its global index. pair<VertexOrdinalIndex, VertexGlobalIndex> add_vertex(const vector<Real>& realcoord); VertexOrdinalIndex add_vertex(const vector<Real>& realcoord, VertexGlobalIndex vnum); // For adding records of vertices upon brep faces. void add_vertex_bdryinc(VertexGlobalIndex vnum, const Brep::Face_Spec& fspec, Brep::PatchIndex patchind, const vector<Real>& param); Brep::PatchIndex retrieve_vertex_bdryinc_patchind(VertexGlobalIndex vnum, const Brep::Face_Spec& fspec) const; Point retrieve_vertex_bdryinc_param(VertexGlobalIndex vnum, const Brep::Face_Spec& fspec) const; // For adding faces of dim 1 or higher void add_simplex_face(const vector<VertexGlobalIndex>& verts, const Brep::Face_Spec& fspec); // Constructor starts with an empty simplicial complex. SimpComplex_Under_Construction(int intrinsic_dim, int embedded_dim, const vector<int>& level_size); void add_fspec(const Brep::Face_Spec& fspec); void add_prop_val(const string& prop, const string& val); void remove_unused_vertices(); // Release returns the pointer to the implementation. This works // kind of like auto_ptr. mxArray* release(); ~SimpComplex_Under_Construction(); // See brepstream.cpp for the next one. This one reads a mesh from an istream // in ascii format. static SimpComplex_Under_Construction read_from_istream(istream& istr, bool code_already_read, int& line_count); // Destructive copy & destructive copy using standard // helper class.private: class SimpComplex_Under_Construction_Returnval { private: friend class SimpComplex_Under_Construction; SimpComplex_Under_Construction& sref_; SimpComplex_Under_Construction_Returnval(SimpComplex_Under_Construction& s, int) : sref_(s) { } };public: // destructive copy semantics (like auto_ptr) SimpComplex_Under_Construction(SimpComplex_Under_Construction& other); SimpComplex_Under_Construction(const SimpComplex_Under_Construction_Returnval& sucr); operator SimpComplex_Under_Construction_Returnval() { return SimpComplex_Under_Construction_Returnval(*this, 0); }};extern QMG::ostream& operator<<(QMG::ostream& os, const QMG::SimpComplex& sc);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -