File: GmshModel.h

package info (click to toggle)
madlib 1.3.0-2.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 6,912 kB
  • sloc: cpp: 39,850; sh: 10,088; makefile: 476
file content (101 lines) | stat: -rw-r--r-- 2,884 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// -*- C++ -*-
// -------------------------------------------------------------------
// MAdLib - Copyright (C) 2008-2009 Universite catholique de Louvain
//
// See the Copyright.txt and License.txt files for license information. 
// You should have received a copy of these files along with MAdLib. 
// If not, see <http://www.madlib.be/license/>
//
// Please report all bugs and problems to <contrib@madlib.be>
//
// Authors: Jean-Francois Remacle, Gaetan Compere
// -------------------------------------------------------------------

#ifndef _H_GMSHMODEL
#define _H_GMSHMODEL

#ifdef _HAVE_GMSH_

#include "MAdModel.h"

#include "gmsh/GModel.h"
#include "GmshEntities.h"
#include <list>
#include <set>

namespace MAd {

  // -------------------------------------------------------------------
  class GmshModel : public MAdModel {

  private:
    GModel * model;

  public:

    GmshModel(std::string name=""): 
      MAdModel(name)
    { 
      model = new GModel(_name);
      GModel::current(GModel::list.size() - 1);
    }
    ~GmshModel();

    ModelType type() const { return GMSHMODEL; }

    // Gmsh mesh file format
    int readMSH(const std::string &filename);
  
    // Gmsh native CAD format
    int readGEO(const std::string &filename);
  
    // OCC formats
    int readSTEP(const std::string &filename);
    int readBREP(const std::string &filename);
    int readIGES(const std::string &filename);

    GModel * getModel() { return model; }

    // get the number of entities in this model
    int getNumRegions()  const { return regions.size();  }
    int getNumFaces()    const { return faces.size();    }
    int getNumEdges()    const { return edges.size();    }
    int getNumVertices() const { return vertices.size(); }

    // find the entity with the given tag and create it if not found
    GmshGEntity * getEntityByTag(int dim, int tag);
    GmshGRegion * getRegionByTag(int);
    GmshGFace   * getFaceByTag  (int);
    GmshGEdge   * getEdgeByTag  (int);
    GmshGVertex * getVertexByTag(int);

    // get an iterator initialized to the first/last entity in this model.
    riter firstRegion() { return regions.begin(); }
    fiter firstFace()   { return faces.begin(); }
    eiter firstEdge()   { return edges.begin(); }
    viter firstVertex() { return vertices.begin(); }
    riter lastRegion()  { return regions.end(); }
    fiter lastFace()    { return faces.end(); }
    eiter lastEdge()    { return edges.end(); }
    viter lastVertex()  { return vertices.end(); }

  private:

    void importFromModel();

    void clean();

    std::set<GmshGRegion *,GmshGEntityLessThan> regions;
    std::set<GmshGFace   *,GmshGEntityLessThan> faces;
    std::set<GmshGEdge   *,GmshGEntityLessThan> edges;
    std::set<GmshGVertex *,GmshGEntityLessThan> vertices;

  };

}

// -------------------------------------------------------------------

#endif

#endif