2008-11-05 05:03:03 +01:00
|
|
|
/*
|
2023-04-25 18:27:16 +02:00
|
|
|
Segmentation - Partitioning of a timeline for organising the render graph.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-11-05 05:03:03 +01:00
|
|
|
Copyright (C) Lumiera.org
|
2023-05-03 04:42:17 +02:00
|
|
|
2023, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-11-05 05:03:03 +01:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2008-11-05 05:03:03 +01:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-11-05 05:03:03 +01:00
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-11-05 05:03:03 +01:00
|
|
|
* *****************************************************/
|
|
|
|
|
|
2016-11-03 18:20:10 +01:00
|
|
|
|
2016-11-03 18:22:31 +01:00
|
|
|
/** @file segmentation.cpp
|
2023-05-03 05:01:45 +02:00
|
|
|
** Implementation details regarding the Segmentation of the Fixture.
|
|
|
|
|
**
|
|
|
|
|
** @todo 2023 WIP-WIP-WIP »Playback Vertical Slice«
|
2016-11-03 18:20:10 +01:00
|
|
|
*/
|
|
|
|
|
|
2017-04-02 04:22:51 +02:00
|
|
|
#include "lib/error.hpp"
|
2023-04-25 18:27:16 +02:00
|
|
|
#include "steam/fixture/segmentation.hpp"
|
2023-05-02 21:24:26 +02:00
|
|
|
#include "lib/time/timevalue.hpp"
|
2023-05-03 05:01:45 +02:00
|
|
|
#include "lib/split-splice.hpp"
|
2008-11-05 05:03:03 +01:00
|
|
|
|
2023-05-05 03:46:42 +02:00
|
|
|
using lib::time::Time;
|
|
|
|
|
using lib::time::TimeSpan;
|
|
|
|
|
|
2008-11-05 05:03:03 +01:00
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
namespace steam {
|
2023-04-25 18:27:16 +02:00
|
|
|
namespace fixture {
|
2011-12-02 16:10:03 +01:00
|
|
|
|
2017-04-02 04:22:51 +02:00
|
|
|
namespace error = lumiera::error;
|
|
|
|
|
|
|
|
|
|
|
2023-04-25 13:40:20 +02:00
|
|
|
Segmentation::~Segmentation() { } // emit VTable here...
|
|
|
|
|
|
2023-05-03 04:42:17 +02:00
|
|
|
|
2023-05-03 05:01:45 +02:00
|
|
|
namespace {// Implementation details...
|
2023-05-03 04:42:17 +02:00
|
|
|
|
2023-05-02 21:24:26 +02:00
|
|
|
|
2023-05-03 05:01:45 +02:00
|
|
|
}//(End) impl
|
|
|
|
|
|
2017-04-02 04:22:51 +02:00
|
|
|
|
|
|
|
|
|
2023-05-02 04:16:39 +02:00
|
|
|
/**
|
|
|
|
|
* @param start (optional) definition of the new Segment's start point (inclusive)
|
|
|
|
|
* @param after (optional) definition of the end point (exclusive)
|
|
|
|
|
* @param jobTicket specification of provided render functionality for the new Segment
|
|
|
|
|
* @remarks missing definitions will be derived or interpolated according to context
|
|
|
|
|
* - if start point is omitted, the new Segment will start seamlessly after
|
|
|
|
|
* any preceding Segment's end, in case this preceding Segment ends earlier
|
|
|
|
|
* - otherwise the preceding Segment's start point will be used, thereby effectively
|
|
|
|
|
* replacing and expanding or trimming or inserting into the preceding Segment
|
|
|
|
|
* - similar for the end point: if the definition is omitted, the new Segment
|
|
|
|
|
* will cover the time range until the next Segmen's start
|
|
|
|
|
* - if upper/lower boundaries can not be established, the covered range will be
|
|
|
|
|
* expanded from Time::ANYTIME up to Time::ANYTIME in as fitting current context
|
|
|
|
|
* - after start and end point have been established by the above rules, the actual
|
|
|
|
|
* splicing operation will be determined; either an existing Segment is replaced
|
|
|
|
|
* altogether, or it is trimmed to fit, or the new Segment is inserted, thereby
|
|
|
|
|
* creating a second (copied) part of the encompassing old Segment.
|
|
|
|
|
* - in case the JobTicket is omitted, the new Segment will be marked as _passive_
|
|
|
|
|
* and any job created from such a Segment will then be a »NOP-job«
|
2023-06-08 03:21:43 +02:00
|
|
|
* @see SplitSplice_test
|
2023-05-02 04:16:39 +02:00
|
|
|
*/
|
|
|
|
|
Segment const&
|
2023-06-10 04:52:40 +02:00
|
|
|
Segmentation::splitSplice (OptTime start, OptTime after, engine::ExitNodes&& modelLink)
|
2023-05-02 04:16:39 +02:00
|
|
|
{
|
2023-05-05 03:46:42 +02:00
|
|
|
ASSERT (!start or !after or start != after);
|
2023-05-03 04:42:17 +02:00
|
|
|
using Iter = typename list<Segment>::iterator;
|
|
|
|
|
|
2023-05-05 03:46:42 +02:00
|
|
|
auto getStart = [](Iter elm) -> Time { return elm->start(); };
|
|
|
|
|
auto getAfter = [](Iter elm) -> Time { return elm->after(); };
|
2023-06-10 04:52:40 +02:00
|
|
|
auto createSeg= [&](Iter pos, Time start, Time after) -> Iter { return segments_.emplace (pos, TimeSpan{start, after}, move(modelLink)); };
|
2023-05-05 03:46:42 +02:00
|
|
|
auto emptySeg = [&](Iter pos, Time start, Time after) -> Iter { return segments_.emplace (pos, TimeSpan{start, after}); };
|
|
|
|
|
auto cloneSeg = [&](Iter pos, Time start, Time after, Iter src) -> Iter { return segments_.emplace (pos, *src, TimeSpan{start, after}); };
|
|
|
|
|
auto discard = [&](Iter pos, Iter after) -> Iter { return segments_.erase (pos,after); };
|
2023-05-03 04:42:17 +02:00
|
|
|
|
|
|
|
|
|
2023-05-03 05:01:45 +02:00
|
|
|
lib::splitsplice::Algo splicer{ getStart
|
|
|
|
|
, getAfter
|
|
|
|
|
, createSeg
|
|
|
|
|
, emptySeg
|
|
|
|
|
, cloneSeg
|
|
|
|
|
, discard
|
|
|
|
|
, Time::NEVER
|
|
|
|
|
, segments_.begin(),segments_.end()
|
|
|
|
|
, start,after
|
|
|
|
|
};
|
|
|
|
|
splicer.determineRelations();
|
|
|
|
|
auto [s,n,e] = splicer.performSplitSplice();
|
2023-05-03 03:32:49 +02:00
|
|
|
return *n;
|
2023-05-02 04:16:39 +02:00
|
|
|
}
|
2017-04-02 04:22:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-25 18:27:16 +02:00
|
|
|
}} // namespace steam::fixture
|