MeshLink
Computational geometry access
MeshModel.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2019-2020 Pointwise, Inc.
4  * All rights reserved.
5  *
6  * This sample Pointwise source code is not supported by Pointwise, Inc.
7  * It is provided freely for demonstration purposes only.
8  * SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE.
9  *
10  ***************************************************************************/
11 
12 #ifndef MESH_MODEL_CLASS
13 #define MESH_MODEL_CLASS
14 
15 #include "Types.h"
16 #include "MeshTopo.h"
17 #include "MeshString.h"
18 #include "MeshSheet.h"
19 
20 #include <algorithm>
21 #include <map>
22 #include <string>
23 #include <vector>
24 using StringArray = std::vector<std::string>;
25 
26 /****************************************************************************
27  * MeshModel class
28  ***************************************************************************/
38 class ML_STORAGE_CLASS MeshModel : public MeshTopo {
39 public:
40  friend class MeshAssociativity;
41 
43  //
49  MeshModel(
50  std::string &ref,
51  MLINT mid,
52  MLINT aref,
53  MLINT gref,
54  std::string &name);
55 
57  //
65  bool addPoint(MLINT i1,
66  MLINT mid,
67  MLINT aref,
68  MLINT gref,
69  std::string &name,
70  ParamVertex *pv1, bool mapID);
71 
73  //
81  bool addPoint(
82  std::string &ref,
83  MLINT mid,
84  MLINT aref,
85  MLINT gref,
86  std::string &name,
87  ParamVertex *pv1, bool mapID);
88 
94  MeshPoint *findLowestTopoPointByInd(MLINT i1) const;
95 
101  MeshPoint *findHighestTopoPointByInd(MLINT i1) const;
102 
108  MeshPoint * findPointByInd(MLINT i1) const;
109 
118  void deletePointByInd(MLINT i1);
122  void deletePointByRef(const std::string &ref);
126  void deletePointByRef(MLINT iref);
127 
130  MeshPoint* getMeshPointByName(const std::string &name) const;
133  MeshPoint* getMeshPointByID(MLINT id) const;
136  MeshPoint* getMeshPointByRef(const std::string &ref) const;
137 
139  StringArray getMeshPointRefs() const;
140 
155  bool addEdge(MLINT i1, MLINT i2,
156  MLINT mid,
157  MLINT aref,
158  MLINT gref,
159  std::string &name,
160  ParamVertex *pv1, ParamVertex *pv2, bool mapID);
161 
167  //
176  bool addEdge(
177  std::string &ref,
178  MLINT mid,
179  MLINT aref,
180  MLINT gref,
181  std::string &name,
182  ParamVertex *pv1, ParamVertex *pv2, bool mapID);
183 
196  void addEdgePoint(MLINT i1,
197  MLINT mid,
198  MLINT aref,
199  MLINT gref,
200  ParamVertex *pv1);
201 
214  void addFaceEdgePoint(MLINT i1,
215  MLINT mid,
216  MLINT aref,
217  MLINT gref,
218  ParamVertex *pv1);
219 
225  MeshPoint * findEdgePointByInd(MLINT i1) const;
226 
232  MeshPoint *findFaceEdgePointByInd(MLINT i1) const;
233 
246  void addFaceEdge(MLINT i1, MLINT i2,
247  MLINT mid,
248  MLINT aref,
249  MLINT gref,
250  ParamVertex *pv1, ParamVertex *pv2);
251 
255  MeshEdge * getMeshEdgeByName(const std::string &name) const;
256 
260  MeshEdge * getMeshEdgeByRef(const std::string &ref) const;
261 
267  MeshEdge *findLowestTopoEdgeByInds(MLINT i1, MLINT i2) const;
268 
274  MeshEdge *findEdgeByInds(MLINT i1, MLINT i2) const;
275 
281  MeshEdge *findFaceEdgeByInds(MLINT i1, MLINT i2) const;
282 
284  //
286  //
291  void deleteEdgeByInds(MLINT i1, MLINT i2);
292 
296  void deleteEdgeByRef(const std::string &ref);
297 
301  void deleteEdgeByRef(MLINT iref);
302 
316  bool addFace(MLINT i1, MLINT i2, MLINT i3,
317  MLINT mid,
318  MLINT aref,
319  MLINT gref,
320  std::string &name,
321  ParamVertex *pv1, ParamVertex *pv2,
322  ParamVertex *pv3, bool mapID);
323 
337  bool addFace(
338  std::string &ref,
339  MLINT mid,
340  MLINT aref,
341  MLINT gref,
342  std::string &name,
343  ParamVertex *pv1, ParamVertex *pv2,
344  ParamVertex *pv3, bool mapID);
345 
359  bool addFace(MLINT i1, MLINT i2, MLINT i3, MLINT i4,
360  MLINT mid,
361  MLINT aref,
362  MLINT gref,
363  std::string &name,
364  ParamVertex *pv1, ParamVertex *pv2,
365  ParamVertex *pv3, ParamVertex *pv4, bool mapID);
366 
380  bool addFace(
381  std::string &ref,
382  MLINT mid,
383  MLINT aref,
384  MLINT gref,
385  std::string &name,
386  ParamVertex *pv1, ParamVertex *pv2,
387  ParamVertex *pv3, ParamVertex *pv4, bool mapID);
388 
393  MeshFace *findFaceByInds(MLINT i1, MLINT i2, MLINT i3,
394  MLINT i4 = MESH_TOPO_INDEX_UNUSED);
395 
403  void deleteFaceByInds(MLINT i1, MLINT i2, MLINT i3,
404  MLINT i4 = MESH_TOPO_INDEX_UNUSED);
405 
412  void deleteFaceByRef(const std::string &ref);
413 
418  //
420  void deleteFaceByRef(MLINT iref);
421 
425  MeshFace * getMeshFaceByName(const std::string &name) const;
426 
430  MeshFace * getMeshFaceByRef(const std::string &ref) const;
431 
433  //
435  MLINT getNumEdges() const;
436 
438  //
440  MLINT getNumFaces() const;
441 
446  bool addMeshString(MeshString* meshString, bool mapID=false);
447 
451  MeshString* getMeshStringByID(MLINT id) const;
452 
456  MeshString* getMeshStringByName(const std::string &name) const;
457 
461  MeshString * getMeshStringByRef(const std::string &ref) const;
462 
467  bool addMeshSheet(MeshSheet* meshSheet, bool mapID=false);
468 
472  MeshSheet* getMeshSheetByID(MLINT id) const;
473 
477  MeshSheet* getMeshSheetByName(const std::string &name) const;
478 
480  //
482  MeshSheet * getMeshSheetByRef(const std::string &ref) const;
483 
487  void getMeshEdges(std::vector<const MeshEdge *> &edges) const;
488 
490  void getMeshFaces(std::vector<const MeshFace *> &faces) const;
491 
495  void getMeshStrings(std::vector<MeshString *> &strings) const;
496 
498  size_t getMeshStringCount() const;
499 
501  void getMeshSheets(std::vector<MeshSheet *> &sheets) const;
502 
504  size_t getMeshSheetCount() const;
505 
507  ~MeshModel();
508 
510  virtual const std::string &getBaseName() const;
512  virtual MLUINT &getNameCounter();
513 
514 private:
517 
519  MeshModel() {};
520 
522  std::map<pwiFnvHash::FNVHash, MeshPoint*> pointMap_; // not the owner
529 
531  std::map<pwiFnvHash::FNVHash, MeshEdge*> edgeMap_; // not the owner
538 
540  std::map<pwiFnvHash::FNVHash, MeshPoint*> edgePointMap_; // owner
542  std::map<pwiFnvHash::FNVHash, MeshPoint*> faceEdgePointMap_; // owner
543 
544 
546  std::map<pwiFnvHash::FNVHash, MeshEdge*> faceEdgeMap_; // owner
547 
549  std::map<pwiFnvHash::FNVHash, MeshFace*> faceMap_; // not the owner
556 
563 
570 };
571 
572 typedef std::map<std::string, MeshModel *> MeshModelNameMap;
573 
574 #endif
575 
576 /****************************************************************************
577  *
578  * DISCLAIMER:
579  * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS
580  * ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED
581  * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
582  * PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED
583  * BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY
584  * FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
585  * WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF
586  * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE
587  * USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN
588  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE
589  * FAULT OR NEGLIGENCE OF POINTWISE.
590  *
591  ***************************************************************************/
MeshSheetNameMap meshSheetNameMap_
Map MeshSheet name to unique ID.
Definition: MeshModel.h:565
MeshEdgeNameMap meshEdgeNameMap_
Map MeshEdge name to unique ID.
Definition: MeshModel.h:533
MeshTopoRefToNameMap meshSheetRefToNameMap_
Map MeshSheet application-defined reference string to name.
Definition: MeshModel.h:569
MeshTopoIDToNameMap meshSheetIDToNameMap_
Map MeshSheet unique ID to name.
Definition: MeshModel.h:567
std::map< std::string, MeshEdge * > MeshEdgeNameMap
Definition: MeshTopo.h:534
MeshTopoRefToNameMap meshEdgeRefToNameMap_
Map MeshEdge application-defined reference string to name.
Definition: MeshModel.h:537
Storage for mesh topology and geometry associativity data.
MLUINT64 MLUINT
Standard unsigned integer - value depends on IS64BIT macro.
Definition: Types.h:122
std::map< std::string, MeshFace * > MeshFaceNameMap
Definition: MeshTopo.h:696
MeshStringNameMap meshStringNameMap_
Map MeshString name to unique ID.
Definition: MeshModel.h:558
std::map< pwiFnvHash::FNVHash, MeshPoint * > faceEdgePointMap_
Map face-edge-point index hash to MeshPoint.
Definition: MeshModel.h:542
3D (volume) mesh topology
Definition: MeshModel.h:38
MeshTopoIDToNameMap meshStringIDToNameMap_
Map MeshString unique ID to name.
Definition: MeshModel.h:560
std::map< std::string, MeshSheet * > MeshSheetNameMap
Definition: MeshSheet.h:247
0-D (point) mesh entity
Definition: MeshTopo.h:323
MeshTopoRefToNameMap meshFaceRefToNameMap_
Map MeshFace application-defined reference string to name.
Definition: MeshModel.h:555
std::map< pwiFnvHash::FNVHash, MeshFace * > faceMap_
Map face index hash to MeshFace.
Definition: MeshModel.h:549
std::map< std::string, MeshModel * > MeshModelNameMap
Definition: MeshModel.h:572
2D (surface) mesh topology
Definition: MeshSheet.h:35
MeshTopoIDToNameMap meshPointIDToNameMap_
Map MeshPoint unique ID to name.
Definition: MeshModel.h:526
1D (curve) mesh topology
Definition: MeshString.h:33
std::map< std::string, std::string > MeshTopoRefToNameMap
Definition: MeshTopo.h:308
std::map< pwiFnvHash::FNVHash, MeshEdge * > edgeMap_
Map edge indices hash to edge.
Definition: MeshModel.h:531
std::map< std::string, MeshString * > MeshStringNameMap
Definition: MeshString.h:159
static MLUINT nameCounter_
unique name counter, global for all MeshTopo object names
Definition: MeshModel.h:516
MeshTopoRefToNameMap meshStringRefToNameMap_
Map MeshString application-defined reference string to name.
Definition: MeshModel.h:562
std::map< MLINT, std::string > MeshTopoIDToNameMap
Definition: MeshTopo.h:304
virtual MLUINT & getNameCounter()
Returns the current value of the counter used for generating unique mesh entity names.
1-D (edge) mesh entity
Definition: MeshTopo.h:421
virtual const std::string & getBaseName() const
Returns the base name used for generating unique mesh entity names.
2-D (face) mesh entity
Definition: MeshTopo.h:548
std::map< std::string, MeshPoint * > MeshPointNameMap
Definition: MeshTopo.h:408
std::map< pwiFnvHash::FNVHash, MeshPoint * > edgePointMap_
Map edge-point index hash to MeshPoint.
Definition: MeshModel.h:540
std::map< pwiFnvHash::FNVHash, MeshEdge * > faceEdgeMap_
Map face-edge index hash to MeshEdge.
Definition: MeshModel.h:546
MeshTopoIDToNameMap meshEdgeIDToNameMap_
Map MeshEdge name to unique ID.
Definition: MeshModel.h:535
bool getMeshStringByName(const std::string &name, MeshModel **model, MeshString **string) const
Get MeshString by name.
MeshFaceNameMap meshFaceNameMap_
Map MeshFace name to unique ID.
Definition: MeshModel.h:551
MeshPointNameMap meshPointNameMap_
Map MeshPoint name to unique ID.
Definition: MeshModel.h:524
std::vector< std::string > StringArray
Definition: MeshModel.h:24
Base class for mesh topology entities.
Definition: MeshTopo.h:132
MeshTopoRefToNameMap meshPointRefToNameMap_
Map MeshPoint application-defined reference string to name.
Definition: MeshModel.h:528
Parametric geometry data.
Definition: MeshTopo.h:69
MLINT64 MLINT
Standard integer - value depends on IS64BIT macro.
Definition: Types.h:120
MeshTopoIDToNameMap meshFaceIDToNameMap_
Map MeshFace unique ID to name.
Definition: MeshModel.h:553
bool getMeshSheetByName(const std::string &name, MeshModel **model, MeshSheet **sheet) const
Get MeshSheet by name.