diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2020-07-01 19:42:04 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2020-07-01 19:42:04 +0300 |
commit | 777690902663f3dc820f183329e404a6388485f4 (patch) | |
tree | 7429a08f1e506dcd85501dad9bca0595efb661be /source/blender/blenlib/BLI_boolean.hh | |
parent | 590ce6817d76b01d1eff0a54bf2f5240596ccefa (diff) |
Change boolean blenlib interface to be purely C++.
Diffstat (limited to 'source/blender/blenlib/BLI_boolean.hh')
-rw-r--r-- | source/blender/blenlib/BLI_boolean.hh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_boolean.hh b/source/blender/blenlib/BLI_boolean.hh new file mode 100644 index 00000000000..1ced075a907 --- /dev/null +++ b/source/blender/blenlib/BLI_boolean.hh @@ -0,0 +1,67 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __BLI_BOOLEAN_HH__ +#define __BLI_BOOLEAN_HH__ + +/** \file + * \ingroup bli + */ + +# include "BLI_array.hh" +# include "BLI_math_mpq.hh" +# include "BLI_mesh_intersect.hh" +# include "BLI_mpq3.hh" + +namespace blender { +namespace meshintersect { + +/* Enum values after BOOLEAN_NONE need to match BMESH_ISECT_BOOLEAN_... values in editmesh_intersect.c. */ +enum bool_optype { + BOOLEAN_NONE = -1, + /* Aligned with BooleanModifierOp. */ + BOOLEAN_ISECT = 0, + BOOLEAN_UNION = 1, + BOOLEAN_DIFFERENCE = 2, +}; + +struct PolyMeshOrig { + Array<int> vert_orig; + Array<Array<int>> face_orig; + Array<Array<std::pair<int, int>>> edge_orig; +}; + +struct PolyMesh { + Array<mpq3> vert; + Array<Array<int>> face; + /* triangulation can have zero length: then boolean will do it. */ + Array<Array<IndexedTriangle>> triangulation; + /* orig can be dummy for boolean input, but has useful information for its output. */ + PolyMeshOrig orig; +}; + +PolyMesh boolean(PolyMesh &pm, bool_optype op, int nshapes, std::function<int(int)> shape_fn); + +TriMesh boolean_trimesh(const TriMesh &tm, bool_optype op, int nshapes, std::function<int(int)> shape_fn); + +void write_obj_polymesh(const Array<mpq3> &vert, + const Array<Array<int>> &face, + const std::string &objname); + +} // namespace meshintersect +} // namespace blender + +#endif /* __BLI_BOOLEAN_HH__ */ |