176 if (rings.empty()) {
return output; }
178 TopoDS_Vertex centerVert{BRepBuilderAPI_MakeVertex{coords2Point(center)}};
180 std::vector<std::vector<TopoDS_Vertex>> vertices{};
181 vertices.reserve(rings.size());
182 std::vector<std::vector<TopoDS_Edge>> circumferentialEdges{};
183 circumferentialEdges.reserve(rings.size());
184 for (
const auto &ring : rings) {
185 auto vertsAndEdges = funcVertsCircEdges(ring);
186 vertices.emplace_back(std::move(vertsAndEdges.first));
187 circumferentialEdges.emplace_back(std::move(vertsAndEdges.second));
190 std::vector<std::vector<TopoDS_Edge>> radialEdges{};
191 radialEdges.reserve(rings.size());
192 std::vector<std::vector<TopoDS_Face>> faces{};
193 faces.reserve(rings.size());
195 auto prevVerts = vertices.begin();
196 auto iterVerts = rings.size() >= 2 ? prevVerts + 1 : vertices.end();
197 auto prevCircEdges = circumferentialEdges.begin();
199 rings.size() >= 2 ? prevCircEdges + 1 : circumferentialEdges.end();
201 radialEdges.emplace_back();
202 faces.emplace_back();
203 auto &innerEdges = circumferentialEdges[0];
204 BRepBuilderAPI_MakeWire wireBuilder{};
205 for (
const auto &edge : innerEdges) { wireBuilder.Add(edge); }
206 faces.back().emplace_back(BRepBuilderAPI_MakeFace{wireBuilder});
208 for (; iterVerts != vertices.end();
209 ++prevVerts, ++iterVerts, ++prevCircEdges, ++iterCircEdges) {
210 radialEdges.emplace_back(getRadialEdges(*prevVerts, *iterVerts));
212 getFaces(*prevCircEdges, *iterCircEdges, radialEdges.back()));
218 switch (rings[0].meshType.meshingType) {
219 case RingMeshOption::MeshingType::STRUCT:
221 output.insertConstruct<QuadMeshSurface>(faces[0][0],
224 case RingMeshOption::MeshingType::TRI:
226 output.insertConstruct<TriMeshSurface>(faces[0][0],
230 if (!rings[0].sideset.empty()) {
231 auto &ssetName = rings[0].sideset;
232 for (
int i = 0; i < numSides; ++i) {
233 output.insertConstruct<SideSetEdge>(circumferentialEdges[0][i],
238 auto prevCircEdges = circumferentialEdges.begin();
240 rings.size() >= 2 ? prevCircEdges + 1 : circumferentialEdges.end();
241 auto iterRadialEdges = radialEdges.begin() + 1;
242 auto iterFaces = faces.begin() + 1;
243 auto prevRing = rings.begin();
244 auto iterRing = rings.size() >= 2 ? prevRing + 1 : rings.end();
245 for (; iterRing != rings.end(); prevCircEdges = iterCircEdges,
246 ++iterCircEdges, ++iterRadialEdges,
247 ++iterFaces, ++iterRing, ++prevRing) {
250 auto &prevMeshingParams = prevRing->meshType;
251 for (
int i = 0; i < numSides; ++i) {
252 switch (meshingType) {
253 case RingMeshOption::MeshingType::STRUCT:
255 output.insertConstruct<QuadMeshSurface>(iterFaces->at(i),
258 case RingMeshOption::MeshingType::TRI:
260 output.insertConstruct<TriMeshSurface>(iterFaces->at(i),
264 if (meshingType == RingMeshOption::MeshingType::STRUCT) {
265 if (prevMeshingParams.meshingType ==
266 RingMeshOption::MeshingType::STRUCT &&
267 prevMeshingParams.numSegments[1] !=
meshingParams.numSegments[1]) {
268 std::cerr <<
"Different number of nodes in circumferential direction " 269 "in adjacent rings may cause mesh errors.\n";
271 for (
int i = 0; i < numSides; ++i) {
273 if (prevMeshingParams.meshingType !=
274 RingMeshOption::MeshingType::STRUCT) {
276 output.getMap()[prevCircEdges->at(i)].reset(
new EdgeSegments{
279 output.insertConstruct<EdgeSegments>(iterCircEdges->at(i),
282 output.insertConstruct<EdgeSegments>(iterRadialEdges->at(i),
"",
286 if (!iterRing->sideset.empty()) {
287 auto &ssetName = iterRing->sideset;
288 for (
int i = 0; i < numSides; ++i) {
289 output.insertConstruct<SideSetEdge>(iterCircEdges->at(i), ssetName);
Class to manage TopoDS_Shapes along with metadata.