WNewVertex.h 4.2 KB
Newer Older
1 2 3 4
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
5
// Copyright 2013 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

#ifndef WNEWVERTEX_H
#define WNEWVERTEX_H

#include <cstring>

#include <osg/Vec3>


namespace butterfly
{
/**
 * Depicts a point that is subdivided on a line between two vertices. It's stored in a vertex property. The second
 * relationship is depicted by the toID field.
 */
class WNewVertex
{
public:
    /**
     * Initializes properties of a new vertex with all its necessary parameters.
     * \param toID The other point which the new vertex is interpolated between. The first point stores the new
     *             vertex object. toID is always bigger.
     */
    explicit WNewVertex( size_t toID );

    /**
     * Destroys the new vertex property.
     */
    virtual ~WNewVertex();

    /**
     * Returns the proposed ID of that new vertex. The ID should be equal to the one of the
     * final Triangle Mesh.
     * \author schwarzkopf
     * \return ID of the new vertex.
     */
    size_t getNewVertexID();

    /**
     * Sets the proposed ID for that new vertex. The ID should be equal to the one of the
     * final Triangle Mesh.
     * \author schwarzkopf
     * \param newVertexID Vertex ID to set.
     */
    void setNewVertexID( size_t newVertexID );

    /**
     * Returns the second vertex ID where the new vertex lies between these two points.
     * It's still not necessary to store the first connected one. The second ID is always
     * bigger than the first one.
     * \author schwarzkopf
     * \return The second connected Vertex ID.
     */
    size_t getToID();

    /**
     * Sets the new vertex property whether it's valid for butterfly subdivision or not.
     * Invalid lines are not subdivided.
     * \author schwarzkopf
     * \param isValid Whether the new vertex is marked to be valid for butterfly subdivision or not.
     */
    void setValid( bool isValid );

    /**
     * Returns whether the new vertex is marked to be valid for the butterfly subdivison of a
     * line between two vertices. Invalid lines are not subdivided.
     * \author schwarzkopf
     * \return Whether the new vertex is marked to be valid for butterfly subdivision or not.
     */
    bool isValid();

    /**
     * Returns coordinates of the new vertex.
     * \author schwarzkopf
     * \return Coordinate of the new vertex ID.
     */
    osg::Vec3 getCoordinate();

    /**
     * Sets coordinates of the new vertex.
     * \author schwarzkopf
     * \param coordinate coordinate of the new vertex ID.
     */
    void setCoordinate( osg::Vec3 coordinate );

private:
    /**
     * The id of the second vertex the new vertex is connected to. The first point is defined by the
     * number of the stored vertex property where this object lies in. The toID is always bigger than
     * the first ID due to data organization issue.
     */
    size_t m_toID;

    /**
     * ID the new vertex is proposed to have in the final triangle mesh.
     */
    size_t m_newVertexID;

    /**
     * Coordinate of the new vertex.
     */
    osg::Vec3 m_coordinate;

    /**
     * Property whether the new vertex is valid for subdivision. Not validly marked lines are not
     * subdivided. Therefore an alternative triangulation is taken.
     */
    bool m_isValid;
};

} //namespace butterfly
#endif  // WNEWVERTEX_H