2012-12-28 20:21:05 +00:00
|
|
|
/*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief Class to define a chain of viewedges.
|
2012-12-28 20:21:05 +00:00
|
|
|
*/
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
#include "Curve.h"
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
#include "../view_map/ViewMap.h"
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
/*! Class to represent a 1D elements issued from the chaining process.
|
|
|
|
|
* A Chain is the last step before the Stroke and is used in the Splitting and Creation processes.
|
2008-04-30 15:41:54 +00:00
|
|
|
*/
|
|
|
|
|
class Chain : public Curve {
|
|
|
|
|
protected:
|
2012-12-28 20:21:05 +00:00
|
|
|
// tmp
|
2013-03-11 06:56:51 +00:00
|
|
|
Id *_splittingId;
|
2012-12-28 20:21:05 +00:00
|
|
|
FEdge *
|
|
|
|
|
_fedgeB; // the last FEdge of the ViewEdge passed to the last call for push_viewedge_back().
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-04-30 15:41:54 +00:00
|
|
|
public:
|
2019-07-31 14:25:09 +02:00
|
|
|
/*! Default constructor. */
|
2012-12-28 20:21:05 +00:00
|
|
|
Chain() : Curve()
|
|
|
|
|
{
|
|
|
|
|
_splittingId = 0;
|
|
|
|
|
_fedgeB = 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
/*! Builds a chain from its Id. */
|
|
|
|
|
Chain(const Id &id) : Curve(id)
|
|
|
|
|
{
|
|
|
|
|
_splittingId = 0;
|
|
|
|
|
_fedgeB = 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
/*! Copy Constructor */
|
|
|
|
|
Chain(const Chain &iBrother) : Curve(iBrother)
|
|
|
|
|
{
|
|
|
|
|
_splittingId = iBrother._splittingId;
|
|
|
|
|
_fedgeB = iBrother._fedgeB;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
/*! Destructor. */
|
|
|
|
|
virtual ~Chain()
|
|
|
|
|
{
|
|
|
|
|
// only the last splitted deletes this id
|
|
|
|
|
if (_splittingId) {
|
2019-05-31 22:51:19 +10:00
|
|
|
if (*_splittingId == _Id) {
|
2012-12-28 20:21:05 +00:00
|
|
|
delete _splittingId;
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2012-12-28 20:21:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
/*! Returns the string "Chain" */
|
|
|
|
|
virtual string getExactTypeName() const
|
|
|
|
|
{
|
|
|
|
|
return "Chain";
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
/*! Adds a ViewEdge at the end of the chain
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param iViewEdge:
|
2012-12-28 20:21:05 +00:00
|
|
|
* The ViewEdge that must be added.
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param orientation:
|
2012-12-28 20:21:05 +00:00
|
|
|
* The orientation with which this ViewEdge must be processed.
|
|
|
|
|
*/
|
|
|
|
|
void push_viewedge_back(ViewEdge *iViewEdge, bool orientation);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
/*! Adds a ViewEdge at the beginning of the chain
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param iViewEdge:
|
2012-12-28 20:21:05 +00:00
|
|
|
* The ViewEdge that must be added.
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param orientation:
|
2012-12-28 20:21:05 +00:00
|
|
|
* The orientation with which this ViewEdge must be processed.
|
|
|
|
|
*/
|
|
|
|
|
void push_viewedge_front(ViewEdge *iViewEdge, bool orientation);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
inline void setSplittingId(Id *sid)
|
|
|
|
|
{
|
|
|
|
|
_splittingId = sid;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-11 06:56:51 +00:00
|
|
|
inline Id *getSplittingId()
|
2012-12-28 20:21:05 +00:00
|
|
|
{
|
|
|
|
|
return _splittingId;
|
|
|
|
|
}
|
2014-10-02 15:18:10 +09:00
|
|
|
|
|
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Chain")
|
|
|
|
|
#endif
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|