PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
UCDUtilities.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __UCDUtilities_H
13#define __UCDUtilities_H
14
15#include "Eigen/Eigen"
16#include <list>
17#include <string>
18
19namespace Gedim
20{
21template <typename T> struct UCDProperty final
22{
23 std::string Label;
24 std::string UnitLabel;
25
26 unsigned int Size;
27 unsigned int NumComponents;
28 const T *Data;
29};
30
32{
33 public:
34 enum struct Types
35 {
36 Unknown = -1,
37 Point = 0,
38 Line = 1,
39 Triangle = 2,
40 Quadrilateral = 3,
41 Hexahedron = 4,
42 Prism = 5,
43 Tetrahedron = 6,
44 Pyramid = 7
45 };
46
47 const Types Type;
48 const std::vector<unsigned int> PointIds;
49 const unsigned int MaterialId;
50
51 UCDCell(const Types type, const std::vector<unsigned int> pointIds, const unsigned int materialId)
53 {
54 }
55
56 const std::string CellLabel(const UCDCell::Types type) const;
57};
58
60{
61 public:
63 {
64 Ascii = 0
65 };
66
67 private:
68 std::vector<UCDCell> CreatePointCells(const Eigen::MatrixXd &points, const Eigen::VectorXi &materials) const;
69 std::vector<UCDCell> CreateLineCells(const Eigen::MatrixXi &lines, const Eigen::VectorXi &materials) const;
70 std::vector<UCDCell> CreatePolygonCells(const std::vector<std::vector<unsigned int>> &polygons_vertices,
71 const Eigen::VectorXi &materials) const;
72 std::vector<UCDCell> CreatePolyhedraCells(const std::vector<std::vector<unsigned int>> &polyhedra_vertices,
73 const Eigen::VectorXi &materials) const;
74
75 void ExportUCDAscii(const Eigen::MatrixXd &points,
76 const std::vector<UCDProperty<double>> &point_properties,
77 const std::vector<UCDCell> &cells,
78 const std::vector<UCDProperty<double>> &cell_properties,
79 const std::string &filePath) const;
80
81 public:
83 {
84 }
85 virtual ~UCDUtilities()
86 {
87 }
88
89 void ExportPoints(const std::string &filePath,
90 const Eigen::MatrixXd &points,
91 const std::vector<UCDProperty<double>> &points_properties = {},
92 const Eigen::VectorXi &materials = {}) const;
93
94 void ExportSegments(const std::string &filePath,
95 const Eigen::MatrixXd &points,
96 const Eigen::MatrixXi &segments,
97 const std::vector<UCDProperty<double>> &points_properties = {},
98 const std::vector<UCDProperty<double>> &segmnents_properties = {},
99 const Eigen::VectorXi &materials = {}) const;
100
101 void ExportPolygons(const std::string &filePath,
102 const Eigen::MatrixXd &points,
103 const std::vector<std::vector<unsigned int>> &polygons_vertices,
104 const std::vector<UCDProperty<double>> &points_properties = {},
105 const std::vector<UCDProperty<double>> &polygons_properties = {},
106 const Eigen::VectorXi &materials = {}) const;
107
108 void ExportPolyhedra(const std::string &filePath,
109 const Eigen::MatrixXd &points,
110 const std::vector<std::vector<unsigned int>> &polyhedra_vertices,
111 const std::vector<UCDProperty<double>> &points_properties = {},
112 const std::vector<UCDProperty<double>> &polyhedra_properties = {},
113 const Eigen::VectorXi &materials = {}) const;
114};
115} // namespace Gedim
116
117#endif // __UCDUtilities_H
Eigen column vector.
Definition Eigen_Array.hpp:23
Definition UCDUtilities.hpp:32
const Types Type
Definition UCDUtilities.hpp:47
const unsigned int MaterialId
Definition UCDUtilities.hpp:49
const std::string CellLabel(const UCDCell::Types type) const
Definition UCDUtilities.cpp:280
UCDCell(const Types type, const std::vector< unsigned int > pointIds, const unsigned int materialId)
Definition UCDUtilities.hpp:51
const std::vector< unsigned int > PointIds
Definition UCDUtilities.hpp:48
Types
Definition UCDUtilities.hpp:35
Definition UCDUtilities.hpp:60
void ExportPolygons(const std::string &filePath, const Eigen::MatrixXd &points, const std::vector< std::vector< unsigned int > > &polygons_vertices, const std::vector< UCDProperty< double > > &points_properties={}, const std::vector< UCDProperty< double > > &polygons_properties={}, const Eigen::VectorXi &materials={}) const
Definition UCDUtilities.cpp:56
void ExportPolyhedra(const std::string &filePath, const Eigen::MatrixXd &points, const std::vector< std::vector< unsigned int > > &polyhedra_vertices, const std::vector< UCDProperty< double > > &points_properties={}, const std::vector< UCDProperty< double > > &polyhedra_properties={}, const Eigen::VectorXi &materials={}) const
Definition UCDUtilities.cpp:75
void ExportSegments(const std::string &filePath, const Eigen::MatrixXd &points, const Eigen::MatrixXi &segments, const std::vector< UCDProperty< double > > &points_properties={}, const std::vector< UCDProperty< double > > &segmnents_properties={}, const Eigen::VectorXi &materials={}) const
Definition UCDUtilities.cpp:37
void ExportPoints(const std::string &filePath, const Eigen::MatrixXd &points, const std::vector< UCDProperty< double > > &points_properties={}, const Eigen::VectorXi &materials={}) const
Definition UCDUtilities.cpp:20
virtual ~UCDUtilities()
Definition UCDUtilities.hpp:85
ExportFormats
Definition UCDUtilities.hpp:63
@ Ascii
Definition UCDUtilities.hpp:64
UCDUtilities()
Definition UCDUtilities.hpp:82
Definition Eigen_Array.cpp:22
Definition UCDUtilities.hpp:22
std::string UnitLabel
Definition UCDUtilities.hpp:24
unsigned int Size
Definition UCDUtilities.hpp:26
unsigned int NumComponents
Definition UCDUtilities.hpp:27
std::string Label
Definition UCDUtilities.hpp:23
const T * Data
Definition UCDUtilities.hpp:28