// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2015 Qingnan Zhou // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. // #ifndef IGL_COPYLEFT_CGAL_BINARY_WINDING_NUMBER_OPERATIONS_H #define IGL_COPYLEFT_CGAL_BINARY_WINDING_NUMBER_OPERATIONS_H #include #include "../../igl_inline.h" #include "../../MeshBooleanType.h" #include // TODO: This is not written according to libigl style. These should be // function handles. // // Why is this templated on DerivedW namespace igl { namespace copyleft { namespace cgal { template class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( const Eigen::PlainObjectBase& /*win_nums*/) const { throw (std::runtime_error("not implemented!")); } }; template <> class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( const Eigen::PlainObjectBase& win_nums) const { return win_nums(0) > 0 || win_nums(1) > 0; } }; template <> class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( const Eigen::PlainObjectBase& win_nums) const { return win_nums(0) > 0 && win_nums(1) > 0; } }; template <> class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( const Eigen::PlainObjectBase& win_nums) const { return win_nums(0) > 0 && win_nums(1) <= 0; } }; template <> class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( const Eigen::PlainObjectBase& win_nums) const { return (win_nums(0) > 0 && win_nums(1) <= 0) || (win_nums(0) <= 0 && win_nums(1) > 0); } }; template <> class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( const Eigen::PlainObjectBase& /*win_nums*/) const { return true; } }; typedef BinaryWindingNumberOperations BinaryUnion; typedef BinaryWindingNumberOperations BinaryIntersect; typedef BinaryWindingNumberOperations BinaryMinus; typedef BinaryWindingNumberOperations BinaryXor; typedef BinaryWindingNumberOperations BinaryResolve; enum KeeperType { KEEP_INSIDE, KEEP_ALL }; template class WindingNumberFilter { public: template short operator()( const Eigen::PlainObjectBase& /*win_nums*/) const { throw std::runtime_error("Not implemented"); } }; template<> class WindingNumberFilter { public: template short operator()(T out_w, T in_w) const { if (in_w > 0 && out_w <= 0) return 1; else if (in_w <= 0 && out_w > 0) return -1; else return 0; } }; template<> class WindingNumberFilter { public: template short operator()(T /*out_w*/, T /*in_w*/) const { return 1; } }; typedef WindingNumberFilter KeepInside; typedef WindingNumberFilter KeepAll; } } } #endif