2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-12-28 20:21:05 +00:00
|
|
|
|
|
|
|
|
#pragma once
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
2023-08-18 08:51:29 +10:00
|
|
|
* \brief Class to define a chain of view-edges.
|
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 {
|
|
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Class to represent a 1D elements issued from the chaining process.
|
2012-12-28 20:21:05 +00:00
|
|
|
* 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:
|
2021-06-24 15:57:33 +10: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
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Builds a chain from its Id. */
|
2012-12-28 20:21:05 +00:00
|
|
|
Chain(const Id &id) : Curve(id)
|
|
|
|
|
{
|
|
|
|
|
_splittingId = 0;
|
|
|
|
|
_fedgeB = 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Copy Constructor */
|
2012-12-28 20:21:05 +00:00
|
|
|
Chain(const Chain &iBrother) : Curve(iBrother)
|
|
|
|
|
{
|
|
|
|
|
_splittingId = iBrother._splittingId;
|
|
|
|
|
_fedgeB = iBrother._fedgeB;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Destructor. */
|
2012-12-28 20:21:05 +00:00
|
|
|
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
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Returns the string "Chain" */
|
2012-12-28 20:21:05 +00:00
|
|
|
virtual string getExactTypeName() const
|
|
|
|
|
{
|
|
|
|
|
return "Chain";
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-24 15:57:33 +10: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
|
|
|
|
2021-06-24 15:57:33 +10: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 */
|