// Copyright 2021 The Manifold Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include <functional> #include <memory> #include "manifold/common.h" #include "manifold/vec_view.h" namespace manifold { /** * @ingroup Debug * * Allows modification of the assertions checked in MANIFOLD_DEBUG mode. * * @return ExecutionParams& */ ExecutionParams& ManifoldParams(); class CsgNode; class CsgLeafNode; /** @addtogroup Core * @brief The central classes of the library * @{ */ /** * @brief Mesh input/output suitable for pushing directly into graphics * libraries. * * This may not be manifold since the verts are duplicated along property * boundaries that do not match. The additional merge vectors store this missing * information, allowing the manifold to be reconstructed. MeshGL is an alias * for the standard single-precision version. Use MeshGL64 to output the full * double precision that Manifold uses internally. */ template <typename Precision, typename I = uint32_t> struct MeshGLP { … }; /** * @brief Single-precision - ideal for most uses, especially graphics. */ MeshGL; /** * @brief Double-precision, 64-bit indices - best for huge meshes. */ MeshGL64; /** * @brief This library's internal representation of an oriented, 2-manifold, * triangle mesh - a simple boundary-representation of a solid object. Use this * class to store and operate on solids, and use MeshGL for input and output. * * In addition to storing geometric data, a Manifold can also store an arbitrary * number of vertex properties. These could be anything, e.g. normals, UV * coordinates, colors, etc, but this library is completely agnostic. All * properties are merely float values indexed by channel number. It is up to the * user to associate channel numbers with meaning. * * Manifold allows vertex properties to be shared for efficient storage, or to * have multiple property verts associated with a single geometric vertex, * allowing sudden property changes, e.g. at Boolean intersections, without * sacrificing manifoldness. * * Manifolds also keep track of their relationships to their inputs, via * OriginalIDs and the faceIDs and transforms accessible through MeshGL. This * allows object-level properties to be re-associated with the output after many * operations, particularly useful for materials. Since separate object's * properties are not mixed, there is no requirement that channels have * consistent meaning between different inputs. */ class Manifold { … }; /** @} */ /** @addtogroup Debug * @ingroup Optional * @brief Debugging features * * The features require compiler flags to be enabled. Assertions are enabled * with the MANIFOLD_DEBUG flag and then controlled with ExecutionParams. * @{ */ #ifdef MANIFOLD_DEBUG inline std::string ToString(const Manifold::Error& error) { switch (error) { case Manifold::Error::NoError: return "No Error"; case Manifold::Error::NonFiniteVertex: return "Non Finite Vertex"; case Manifold::Error::NotManifold: return "Not Manifold"; case Manifold::Error::VertexOutOfBounds: return "Vertex Out Of Bounds"; case Manifold::Error::PropertiesWrongLength: return "Properties Wrong Length"; case Manifold::Error::MissingPositionProperties: return "Missing Position Properties"; case Manifold::Error::MergeVectorsDifferentLengths: return "Merge Vectors Different Lengths"; case Manifold::Error::MergeIndexOutOfBounds: return "Merge Index Out Of Bounds"; case Manifold::Error::TransformWrongLength: return "Transform Wrong Length"; case Manifold::Error::RunIndexWrongLength: return "Run Index Wrong Length"; case Manifold::Error::FaceIDWrongLength: return "Face ID Wrong Length"; case Manifold::Error::InvalidConstruction: return "Invalid Construction"; default: return "Unknown Error"; }; } inline std::ostream& operator<<(std::ostream& stream, const Manifold::Error& error) { return stream << ToString(error); } #endif /** @} */ } // namespace manifold