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.
NucMeshSrv.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_NUCMESHSRV_H_
30 #define NEMOSYS_NUCMESHSRV_H_
31 
32 #include "nemosys_export.h"
33 #include "Services/srvBase.H"
34 
35 #include <memory>
36 #include <type_traits>
37 #include <utility>
38 #include <vector>
39 
40 #include <SMESH_Gen.hxx>
41 
42 #include "NucMesh/ShapeBase.H"
43 
44 namespace NEM {
45 namespace SRV {
46 
47 struct NEMOSYS_EXPORT NucMeshConf {
48  /**
49  * @brief Geometry and mesh. Shapes in the list are successively overlaid on
50  * previous shapes.
51  * @details Using shared_ptr instead of unique_ptr because SWIG does not
52  * deal well with move-only types
53  */
54  std::vector<std::shared_ptr<NEM::NUCMESH::ShapeBase>> geometryAndMesh;
55  /**
56  * @brief Extrude the final 2d mesh along the z-axis
57  * @details Each entry in @c extrudeSteps denotes a layer with that height.
58  * Empty array means that final mesh will be 2d (lying in xy plane)
59  */
60  std::vector<double> extrudeSteps;
61 
62  /**
63  * Helper to insert shapes into @c geometryAndMesh
64  * @tparam Shape type derived from NEM::NUCMESH::ShapeBase
65  * @param shape object to copy or move
66  * @return reference to inserted shape (note not the same object passed in)
67  */
68  template <typename Shape>
69  typename std::add_lvalue_reference<Shape>::type insertShape(Shape &&shape) {
70  geometryAndMesh.emplace_back(std::shared_ptr<NEM::NUCMESH::ShapeBase>{
71  new typename std::decay<Shape>::type(std::forward<Shape>(shape))});
72  return dynamic_cast<Shape &>(*geometryAndMesh.back());
73  }
74 
75  /**
76  * Helper to construct and insert shapes into @c geometryAndMesh
77  * @tparam Shape type derived from NEM::NUCMESH::ShapeBase
78  * @tparam Args types of a constructor of @p Shape
79  * @param args arguments to pass to constructor of @p Shape
80  * @return reference to inserted shape
81  */
82  template <typename Shape, typename... Args>
83  Shape &makeShape(Args &&...args) {
84  geometryAndMesh.emplace_back(std::shared_ptr<NEM::NUCMESH::ShapeBase>{
85  new Shape(std::forward<Args>(args)...)});
86  return dynamic_cast<Shape &>(*geometryAndMesh.back());
87  }
88 
89  std::shared_ptr<SMESH_Gen> generator{new SMESH_Gen{}};
90 };
91 
92 class NEMOSYS_EXPORT NucMeshSrv : public srvBase {
93  public:
94  static NucMeshSrv *New();
95  void SetConfiguration(const NucMeshConf &configuration);
96  const NucMeshConf &GetConfiguration() const;
97  vtkTypeMacro(NucMeshSrv, srvBase)
98 
99  protected:
100  int RequestData(vtkInformation *request, vtkInformationVector **inputVector,
101  vtkInformationVector *outputVector) override;
102  int FillOutputPortInformation(int port, vtkInformation *info) override;
103  NucMeshSrv();
105 };
106 
107 } // namespace SRV
108 } // namespace NEM
109 
110 #endif // NEMOSYS_NUCMESHSRV_H_
std::vector< std::shared_ptr< NEM::NUCMESH::ShapeBase > > geometryAndMesh
Geometry and mesh.
Definition: NucMeshSrv.H:54
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
Shape & makeShape(Args &&...args)
Helper to construct and insert shapes into geometryAndMesh.
Definition: NucMeshSrv.H:83
std::vector< double > extrudeSteps
Extrude the final 2d mesh along the z-axis.
Definition: NucMeshSrv.H:60
std::add_lvalue_reference< Shape >::type insertShape(Shape &&shape)
Helper to insert shapes into geometryAndMesh.
Definition: NucMeshSrv.H:69
abstract class for services acting on geoMeshBase
Definition: srvBase.H:53
NucMeshConf conf_
Definition: NucMeshSrv.H:104