From 777690902663f3dc820f183329e404a6388485f4 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Wed, 1 Jul 2020 12:42:04 -0400 Subject: Change boolean blenlib interface to be purely C++. --- source/blender/blenlib/BLI_boolean.hh | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 source/blender/blenlib/BLI_boolean.hh (limited to 'source/blender/blenlib/BLI_boolean.hh') 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 vert_orig; + Array> face_orig; + Array>> edge_orig; +}; + +struct PolyMesh { + Array vert; + Array> face; + /* triangulation can have zero length: then boolean will do it. */ + Array> 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 shape_fn); + +TriMesh boolean_trimesh(const TriMesh &tm, bool_optype op, int nshapes, std::function shape_fn); + +void write_obj_polymesh(const Array &vert, + const Array> &face, + const std::string &objname); + +} // namespace meshintersect +} // namespace blender + +#endif /* __BLI_BOOLEAN_HH__ */ -- cgit v1.2.3