MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / readElements

Function readElements

src/Mod/Fem/App/FemVTKTools.cpp:1731–1800  ·  view source on GitHub ↗

fill elements and fill cell array

Source from the content-addressed store, hash-verified

1729
1730// fill elements and fill cell array
1731std::vector<int> readElements(
1732 std::ifstream& ifstr,
1733 const std::string& lines,
1734 const std::map<int, int>& mapNodes,
1735 vtkCellArray* cellArray,
1736 vtkIntArray* material,
1737 vtkIntArray* group
1738)
1739{
1740 std::string line;
1741 std::string keyCode = " 3C";
1742 std::string keyCodeType = " -1";
1743 std::string keyCodeNodes = " -2";
1744 long numElem;
1745 int indicator;
1746 int elem;
1747 long elemID = 0;
1748 // element info: {type, group, material}
1749 std::vector<int> info(3);
1750 std::map<int, int> mapElem;
1751 std::vector<int> topoElem;
1752 std::vector<int> vtkType;
1753
1754 material->SetNumberOfComponents(1);
1755 material->SetName("Material");
1756
1757 group->SetNumberOfComponents(1);
1758 group->SetName("Group");
1759
1760 std::string_view view {lines};
1761
1762 std::string_view sub = view.substr(keyCode.length() + 18);
1763 valueFromLine(sub.begin(), 12, numElem);
1764
1765 sub = sub.substr(12 + 37);
1766 valueFromLine(sub.begin(), 1, indicator);
1767 int digits = getDigits(static_cast<Indicator>(indicator));
1768 while (elemID < numElem && std::getline(ifstr, line)) {
1769 std::string_view view {line};
1770 if (view.rfind(keyCodeType, 0) == 0) {
1771 std::string_view v(line.data() + keyCodeType.length());
1772 valueFromLine(v.begin(), digits, elem);
1773 v = v.substr(digits);
1774 std::string_view::iterator it1;
1775 std::vector<int>::iterator it2;
1776 for (it1 = v.begin(), it2 = info.begin(); it1 != v.end() && it2 != info.end();
1777 it1 += 5, ++it2) {
1778 valueFromLine(it1, 5, *it2);
1779 }
1780 }
1781 if (view.rfind(keyCodeNodes, 0) == 0) {
1782 std::string_view vi = view.substr(keyCodeNodes.length());
1783 int node;
1784 for (auto it = vi.begin(); it != vi.end(); it += digits) {
1785 valueFromLine(it, digits, node);
1786 topoElem.emplace_back(mapNodes.at(node));
1787 }
1788

Callers 2

RestoreMethod · 0.85
readFRDFunction · 0.85

Calls 13

valueFromLineFunction · 0.85
getDigitsFunction · 0.85
getlineFunction · 0.85
fillCellFunction · 0.85
SetNameMethod · 0.80
substrMethod · 0.80
atMethod · 0.80
lengthMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected