|
| 1 | +// This file is part of libigl, a simple c++ geometry processing library. |
| 2 | +// |
| 3 | +// Copyright (C) 2023 Alec Jacobson |
| 4 | +// |
| 5 | +// This Source Code Form is subject to the terms of the Mozilla Public License |
| 6 | +// v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 7 | +// obtain one at http://mozilla.org/MPL/2.0/. |
| 8 | +#include <common.h> |
| 9 | +#include <npe.h> |
| 10 | +#include <typedefs.h> |
| 11 | +#include <igl/writeMSH.h> |
| 12 | + |
| 13 | +const char* ds_writeMSH = R"igl_Qu8mg5v7( |
| 14 | + /// write triangle surface mesh and tetrahedral volume mesh to .msh file |
| 15 | + /// |
| 16 | + /// @param[in] msh - file name |
| 17 | + /// @param[in] X eigen double matrix of vertex positions #X by 3 |
| 18 | + /// @param[in] Tri #Tri eigen integer matrix of triangular faces indices into vertex positions |
| 19 | + /// @param[in] Tet #Tet eigen integer matrix of tetrahedral indices into vertex positions |
| 20 | + /// @param[in] TriTag #Tri eigen integer vector of tags associated with surface faces |
| 21 | + /// @param[in] TetTag #Tet eigen integer vector of tags associated with volume elements |
| 22 | + /// @param[in] XFields #XFields list of strings with field names associated with nodes |
| 23 | + /// @param[in] XF #XFields list of eigen double matrices, fields associated with nodes |
| 24 | + /// @param[in] EFields #EFields list of strings with field names associated with elements |
| 25 | + /// @param[in] TriF #EFields list of eigen double matrices, fields associated with surface elements |
| 26 | + /// @param[in] TetF #EFields list of eigen double matrices, fields associated with volume elements |
| 27 | + /// |
| 28 | + /// \bug files are always stored in binary format |
| 29 | + /// \bug file format is 2.2 |
| 30 | + /// \bug only triangle surface elements and tetrahedral volumetric elements are supported |
| 31 | + /// \bug only 3D information is supported |
| 32 | + /// \bug the tag id is duplicated for physical (0) and elementary (1) |
| 33 | + /// \bug same element fields are expected to be associated with surface elements and volumetric elements |
| 34 | +)igl_Qu8mg5v7"; |
| 35 | + |
| 36 | +npe_function(writeMSH) |
| 37 | +npe_doc(ds_writeMSH) |
| 38 | +npe_arg(filename, std::string) |
| 39 | +// float not allowed because writeMSH is not templated |
| 40 | +npe_arg(X, dense_double) |
| 41 | +npe_arg(Tri, dense_int32, dense_int64) |
| 42 | +npe_default_arg(Tet, npe_matches(Tri), pybind11::array()) |
| 43 | +npe_default_arg(TriTag, npe_matches(Tri), pybind11::array()) |
| 44 | +npe_default_arg(TetTag, npe_matches(Tri), pybind11::array()) |
| 45 | + |
| 46 | +npe_begin_code() |
| 47 | + |
| 48 | +std::vector<std::string> XFields, EFields; |
| 49 | +std::vector<Eigen::MatrixXd> XF, TriF, TetF; |
| 50 | +Eigen::MatrixXd X_copy = X.template cast<double>(); |
| 51 | +Eigen::MatrixXi Tri_copy = Tri.template cast<int>(); |
| 52 | +Eigen::MatrixXi Tet_copy = Tet.template cast<int>(); |
| 53 | +Eigen::MatrixXi TriTag_copy = TriTag.template cast<int>(); |
| 54 | +Eigen::MatrixXi TetTag_copy = TetTag.template cast<int>(); |
| 55 | + |
| 56 | +return igl::writeMSH( |
| 57 | + filename, |
| 58 | + X_copy, |
| 59 | + Tri_copy, |
| 60 | + Tet_copy, |
| 61 | + TriTag_copy, |
| 62 | + TetTag_copy, |
| 63 | + XFields, |
| 64 | + XF, |
| 65 | + EFields, |
| 66 | + TriF, |
| 67 | + TetF); |
| 68 | + |
| 69 | +npe_end_code() |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
0 commit comments