NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
mergeCells.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_MERGECELLS_H_
30 #define NEMOSYS_MERGECELLS_H_
31 
32 #include "nemosys_export.h"
33 
34 #include <map>
35 
36 #include <vtkObject.h>
37 #include <vtkDataSetAttributes.h>
38 #include <vtkUnstructuredGrid.h>
39 
40 class vtkDataSet;
41 class vtkPointData;
42 class vtkCellData;
43 
44 namespace NEM {
45 namespace MSH {
46 
47 class mergeCellsSTLCloak;
48 
49 /*
50  * Adopted from vtkMergeCells, VTK, with very minor
51  * modifications to return a map between old and new cells. Note duplicating
52  * the entire class becomes unnecessary as of VTK version 9, where most private
53  * members of this class are protected.
54  */
55 class NEMOSYS_NO_EXPORT mergeCells : public vtkObject {
56  public:
57  vtkTypeMacro(mergeCells, vtkObject)
58  void PrintSelf(ostream &os, vtkIndent indent) override;
59 
60  static mergeCells *New();
61 
62  vtkSetObjectMacro(UnstructuredGrid, vtkUnstructuredGrid);
63  vtkGetObjectMacro(UnstructuredGrid, vtkUnstructuredGrid);
64 
65  vtkSetMacro(TotalNumberOfCells, vtkIdType);
66  vtkGetMacro(TotalNumberOfCells, vtkIdType);
67 
68  vtkSetMacro(TotalNumberOfPoints, vtkIdType);
69  vtkGetMacro(TotalNumberOfPoints, vtkIdType);
70 
71  vtkSetMacro(UseGlobalIds, int);
72  vtkGetMacro(UseGlobalIds, int);
73 
74  vtkSetClampMacro(PointMergeTolerance, float, 0.0f, VTK_FLOAT_MAX);
75  vtkGetMacro(PointMergeTolerance, float);
76 
77  vtkSetMacro(UseGlobalCellIds, int);
78  vtkGetMacro(UseGlobalCellIds, int);
79 
80  vtkSetMacro(MergeDuplicatePoints, int);
81  vtkGetMacro(MergeDuplicatePoints, int);
82  vtkBooleanMacro(MergeDuplicatePoints, int);
83 
84  vtkSetMacro(TotalNumberOfDataSets, int);
85  vtkGetMacro(TotalNumberOfDataSets, int);
86 
87  /**
88  * Provide a DataSet to be merged in to the final UnstructuredGrid.
89  * This call returns after the merge has completed. Be sure to call
90  * SetTotalNumberOfCells, SetTotalNumberOfPoints, and SetTotalNumberOfDataSets
91  * before making this call. Return the idMap from old and new points.
92  */
93 
94  vtkSmartPointer<vtkIdTypeArray> MergeDataSet(vtkDataSet *set);
95 
96  void Finish();
97 
98  protected:
99  mergeCells();
100  ~mergeCells() VTK_OVERRIDE;
101 
102  void FreeLists();
103  void StartUGrid(vtkDataSet *set);
104  vtkIdTypeArray *MapPointsToIdsUsingGlobalIds(vtkDataSet *set);
105  vtkIdTypeArray *MapPointsToIdsUsingLocator(vtkDataSet *set);
106  vtkIdType AddNewCellsUnstructuredGrid(vtkDataSet *set, vtkIdTypeArray *idMap);
107  vtkIdType AddNewCellsDataSet(vtkDataSet *set, vtkIdTypeArray *idMap);
108 
109  vtkIdType GlobalCellIdAccessGetId(vtkIdType idx);
110  int GlobalCellIdAccessStart(vtkDataSet *set);
111  vtkIdType GlobalNodeIdAccessGetId(vtkIdType idx);
112  int GlobalNodeIdAccessStart(vtkDataSet *set);
113 
114  int TotalNumberOfDataSets;
115 
116  vtkIdType TotalNumberOfCells;
117  vtkIdType TotalNumberOfPoints;
118 
119  vtkIdType NumberOfCells; // so far
120  vtkIdType NumberOfPoints;
121 
122  int UseGlobalIds; // point, or node, IDs
123  int GlobalIdArrayType;
124  void *GlobalIdArray;
125 
126  int UseGlobalCellIds; // cell IDs
127  int GlobalCellIdArrayType;
128  void *GlobalCellIdArray;
129 
130  float PointMergeTolerance;
131  int MergeDuplicatePoints;
132 
133  char InputIsUGrid;
134  char InputIsPointSet;
135 
136  mergeCellsSTLCloak *GlobalIdMap;
137  mergeCellsSTLCloak *GlobalCellIdMap;
138 
139  vtkDataSetAttributes::FieldList *ptList;
140  vtkDataSetAttributes::FieldList *cellList;
141 
142  vtkUnstructuredGrid *UnstructuredGrid;
143 
144  int nextGrid;
145 
146  mergeCells(const mergeCells &) = delete;
147  void operator=(const mergeCells &) = delete;
148 };
149 
150 } // namespace MSH
151 } // namespace NEM
152 
153 #endif // NEMOSYS_MERGECELLS_H_
geoMeshBase * New(MeshType meshType)
Create a new mesh object.