/* ========================================================================= * * * * OpenMesh * * Copyright (c) 2001-2020, RWTH-Aachen University * * Department of Computer Graphics and Multimedia * * All rights reserved. * * www.openmesh.org * * * *---------------------------------------------------------------------------* * This file is part of OpenMesh. * *---------------------------------------------------------------------------* * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted provided that the following conditions * * are met: * * * * 1. Redistributions of source code must retain the above copyright notice, * * this list of conditions and the following disclaimer. * * * * 2. Redistributions in binary form must reproduce the above copyright * * notice, this list of conditions and the following disclaimer in the * * documentation and/or other materials provided with the distribution. * * * * 3. Neither the name of the copyright holder nor the names of its * * contributors may be used to endorse or promote products derived from * * this software without specific prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * * ========================================================================= */ #pragma once #include #include #include #include #include #include #include //== NAMESPACES =============================================================== namespace OpenMesh { namespace Predicates { //== FORWARD DECLARATION ====================================================== //== CLASS DEFINITION ========================================================= template struct PredicateBase { }; template struct Predicate : public PredicateBase> { Predicate(PredicateT _p) : p_(_p) {} template bool operator()(const T& _t) const { return p_(_t); } PredicateT p_; }; template Predicate make_predicate(PredicateT& _p) { return { _p }; } template Predicate make_predicate(PredicateT&& _p) { return { _p }; } template struct Disjunction : public PredicateBase> { Disjunction(Predicate1T _p1, Predicate2T _p2) : p1_(_p1), p2_(_p2) {} template bool operator()(const T& _t) const { return p1_( _t) || p2_( _t); } Predicate1T p1_; Predicate2T p2_; }; template struct Conjunction : public PredicateBase> { Conjunction(Predicate1T _p1, Predicate2T _p2) : p1_(_p1), p2_(_p2) {} template bool operator()(const T& _t) const { return p1_( _t) && p2_( _t); } Predicate1T p1_; Predicate2T p2_; }; template struct Negation : public PredicateBase> { Negation(const PredicateT& _p1) : p1_(_p1) {} template bool operator()(const T& _t) const { return !p1_( _t); } PredicateT p1_; }; template Disjunction operator||(PredicateBase& p1, PredicateBase& p2) { return Disjunction(static_cast(p1), static_cast(p2)); } template Disjunction operator||(PredicateBase& p1, PredicateBase&& p2) { return Disjunction(static_cast(p1), static_cast(p2)); } template Disjunction operator||(PredicateBase&& p1, PredicateBase& p2) { return Disjunction(static_cast(p1), static_cast(p2)); } template Disjunction operator||(PredicateBase&& p1, PredicateBase&& p2) { return Disjunction(static_cast(p1), static_cast(p2)); } template Conjunction operator&&(PredicateBase& p1, PredicateBase& p2) { return Conjunction(static_cast(p1), static_cast(p2)); } template Conjunction operator&&(PredicateBase& p1, PredicateBase&& p2) { return Conjunction(static_cast(p1), static_cast(p2)); } template Conjunction operator&&(PredicateBase&& p1, PredicateBase& p2) { return Conjunction(static_cast(p1), static_cast(p2)); } template Conjunction operator&&(PredicateBase&& p1, PredicateBase&& p2) { return Conjunction(static_cast(p1), static_cast(p2)); } template Negation operator!(PredicateBase

& p) { return Negation(static_cast(p)); } template Negation

operator!(PredicateBase

&& p) { return Negation

(static_cast(p)); } struct Feature : public PredicateBase { template bool operator()(const SmartHandleStatusPredicates& _h) const { return _h.feature(); } }; struct Selected : public PredicateBase { template bool operator()(const SmartHandleStatusPredicates& _h) const { return _h.selected(); } }; struct Tagged : public PredicateBase { template bool operator()(const SmartHandleStatusPredicates& _h) const { return _h.tagged(); } }; struct Tagged2 : public PredicateBase { template bool operator()(const SmartHandleStatusPredicates& _h) const { return _h.tagged2(); } }; struct Locked : public PredicateBase { template bool operator()(const SmartHandleStatusPredicates& _h) const { return _h.locked(); } }; struct Hidden : public PredicateBase { template bool operator()(const SmartHandleStatusPredicates& _h) const { return _h.hidden(); } }; struct Deleted : public PredicateBase { template bool operator()(const SmartHandleStatusPredicates& _h) const { return _h.deleted(); } }; struct Boundary : public PredicateBase { template bool operator()(const SmartHandleBoundaryPredicate& _h) const { return _h.is_boundary(); } }; template struct Regular: public PredicateBase> { bool operator()(const SmartVertexHandle& _vh) const { return _vh.valence() == (_vh.is_boundary() ? boundary_reg : inner_reg); } }; using RegularQuad = Regular<4,3>; using RegularTri = Regular<6,4>; /// Wrapper object to hold an object and a member function pointer, /// and provides operator() to call that member function for that object with one argument template struct MemberFunctionWrapper { T t_; // Objects whose member function we want to call MF mf_; // pointer to member function MemberFunctionWrapper(T _t, MF _mf) : t_(_t), mf_(_mf) {} template auto operator()(const O& _o) -> decltype ((t_.*mf_)(_o)) { return (t_.*mf_)(_o); } }; /// Helper to create a MemberFunctionWrapper without explicitely naming the types template MemberFunctionWrapper make_member_function_wrapper(T&& _t, MF _mf) { return MemberFunctionWrapper(std::forward(_t), _mf); } /// Convenience macro to create a MemberFunctionWrapper for *this object #define OM_MFW(member_function) OpenMesh::Predicates::make_member_function_wrapper(*this, &std::decay::type::member_function) //============================================================================= } // namespace Predicates } // namespace OpenMesh //============================================================================= //=============================================================================