/**************************************************************************************/ /* */ /* Visualization Library */ /* http://visualizationlibrary.org */ /* */ /* Copyright (c) 2005-2020, Michele Bosi */ /* All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or without modification, */ /* are permitted provided that the following conditions are met: */ /* */ /* - Redistributions of source code must retain the above copyright notice, this */ /* list of conditions and the following disclaimer. */ /* */ /* - 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. */ /* */ /* 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. */ /* */ /**************************************************************************************/ #ifndef EdgeExtractor_INCLUDE_ONCE #define EdgeExtractor_INCLUDE_ONCE #include #include #include #include #include namespace vl { class SceneManager; class Rendering; class Actor; class ActorCollection; class Geometry; /** The EdgeExtractor class extracts the edges from one or more Geometry objects. The edges are always extracted from the triangles or quads that are part of a vl::Geometry and can be of three types: \a silhouette edges, \a crease edges and \a boundary edges. - \a Silhouette edges are those edges that are shared by a backfacing and front facing quad or triangle. - \a Crease edges are those edges that are shared by two triangles or quads and that form an angle >= creaseAngle(), ie: 0 means that the two triangles or quads are coplanar; the edges of a cube define 90 degrees angles; the lateral edges of a 10 faces cylinder define 36 (360/10) degrees angles and so on. - \a Boundary edges are those edges that belong to a single triangle or quad. \par Usage - Extract the edges from one or more Geometry objects using one of the extractEdges() methods. - Assign the Geometry returned by generateEdgeGeometry() to a new Actor. This geometry will contain the edges previously extracted ready to be rendered. - Assign a new EdgeUpdateCallback to the previously created Actor, using the Actor::renderEventCallbacks() method. - Initialize the previously created EdgeUpdateCallback edges with the edges extracted by the EdgeExtractor, that is, assign EdgeExtractor::edges() to EdgeUpdateCallback::edges(). \sa - \ref pagGuideEdgeRendering "Edge Enhancement and Wireframe Rendering Tutorial" - vl::EdgeRenderer */ class VLGRAPHICS_EXPORT EdgeExtractor: public Object { VL_INSTRUMENT_CLASS(vl::EdgeExtractor, Object) public: //! A single edge as extracted from the EdgeExtractor class. class Edge { public: Edge(): mIsCrease(false) {} Edge(const fvec3& v1, const fvec3& v2) { mIsCrease = false; if (v1 generateEdgeGeometry() const; const std::vector& edges() const { return mEdges; } std::vector& edges() { return mEdges; } void reset() { mEdges.clear(); } //! The minimum angle (in degrees) considered to generate crease-edges float creaseAngle() const { return mCreaseAngle; } //! The minimum angle (in degrees) considered to generate crease-edges void setCreaseAngle(float a) { mCreaseAngle = a; } bool warnNonManifold() const { return mWarnNonManifold; } void setWarnNonManifold(bool warn_on) { mWarnNonManifold = warn_on; } protected: void addEdge(std::set& edges, const EdgeExtractor::Edge& e, const fvec3& n); protected: std::vector mEdges; float mCreaseAngle; bool mWarnNonManifold; }; } #endif