Skip to content

Commit

Permalink
Adaptive smooth
Browse files Browse the repository at this point in the history
  • Loading branch information
talaj committed Feb 9, 2019
1 parent 23492d6 commit 2dde0eb
Show file tree
Hide file tree
Showing 16 changed files with 440 additions and 270 deletions.
23 changes: 23 additions & 0 deletions deps/agg/include/agg_array.h
Expand Up @@ -124,6 +124,15 @@ namespace agg
memcpy(m_array, v.m_array, sizeof(T) * m_size);
}

pod_array(self_type && rhs)
{
pod_allocator<T>::deallocate(m_array, m_size);
m_array = rhs.m_array;
m_size = rhs.m_size;
rhs.m_array = nullptr;
rhs.m_size = 0;
}

void resize(unsigned _size)
{
if(_size != m_size)
Expand Down Expand Up @@ -172,6 +181,8 @@ namespace agg
pod_vector(const pod_vector<T>&);
const pod_vector<T>& operator = (const pod_vector<T>&);

pod_vector(pod_vector<T> && rhs);

// Set new capacity. All data is lost, size is set to zero.
void capacity(unsigned cap, unsigned extra_tail=0);
unsigned capacity() const { return m_capacity; }
Expand Down Expand Up @@ -272,6 +283,18 @@ namespace agg
memcpy(m_array, v.m_array, sizeof(T) * v.m_size);
}

//------------------------------------------------------------------------
template<class T> pod_vector<T>::pod_vector(pod_vector<T> && rhs)
{
pod_allocator<T>::deallocate(m_array, m_capacity);
m_size = rhs.m_size;
m_capacity = rhs.m_capacity;
m_array = rhs.m_array;
rhs.m_size = 0;
rhs.m_capacity = 0;
rhs.m_array = nullptr;
}

//------------------------------------------------------------------------
template<class T> const pod_vector<T>&
pod_vector<T>::operator = (const pod_vector<T>&v)
Expand Down
3 changes: 3 additions & 0 deletions deps/agg/include/agg_conv_adaptor_vcgen.h
Expand Up @@ -50,6 +50,9 @@ namespace agg
m_source(&source),
m_status(initial)
{}

conv_adaptor_vcgen(conv_adaptor_vcgen<VertexSource, Generator, Markers> &&) = default;

void attach(VertexSource& source) { m_source = &source; }

Generator& generator() { return m_generator; }
Expand Down
3 changes: 3 additions & 0 deletions deps/agg/include/agg_conv_curve.h
Expand Up @@ -62,6 +62,9 @@ namespace agg

explicit conv_curve(VertexSource& source) :
m_source(&source), m_last_x(0.0), m_last_y(0.0) {}

conv_curve(self_type &&) = default;

void attach(VertexSource& source) { m_source = &source; }

void approximation_method(curve_approximation_method_e v)
Expand Down
59 changes: 35 additions & 24 deletions deps/agg/include/agg_conv_smooth_poly1.h
Expand Up @@ -28,53 +28,64 @@
namespace agg
{

//-------------------------------------------------------conv_smooth_poly1
template<class VertexSource>
struct conv_smooth_poly1 :
public conv_adaptor_vcgen<VertexSource, vcgen_smooth_poly1>
//-------------------------------------------------------conv_smooth
template<class VertexSource, class VertexGenerator>
struct conv_smooth :
public conv_adaptor_vcgen<VertexSource, VertexGenerator>
{
typedef conv_adaptor_vcgen<VertexSource, vcgen_smooth_poly1> base_type;
typedef conv_adaptor_vcgen<VertexSource, VertexGenerator> base_type;

conv_smooth_poly1(VertexSource& vs) :
conv_adaptor_vcgen<VertexSource, vcgen_smooth_poly1>(vs)
conv_smooth(VertexSource& vs) :
conv_adaptor_vcgen<VertexSource, VertexGenerator>(vs)
{
}

conv_smooth(conv_smooth<VertexSource, VertexGenerator> &&) = default;

conv_smooth(const conv_smooth<VertexSource, VertexGenerator>&) = delete;
const conv_smooth<VertexSource, VertexGenerator>&
operator = (const conv_smooth<VertexSource, VertexGenerator>&) = delete;

void smooth_value(double v) { base_type::generator().smooth_value(v); }
double smooth_value() const { return base_type::generator().smooth_value(); }
unsigned type() const { return base_type::type(); }

private:
conv_smooth_poly1(const conv_smooth_poly1<VertexSource>&);
const conv_smooth_poly1<VertexSource>&
operator = (const conv_smooth_poly1<VertexSource>&);
};

template<class VertexSource>
using conv_smooth_poly1 = conv_smooth<VertexSource, vcgen_smooth_poly1>;


//-------------------------------------------------conv_smooth_poly1_curve
template<class VertexSource>
struct conv_smooth_poly1_curve :
public conv_curve<conv_smooth_poly1<VertexSource> >
//-------------------------------------------------conv_smooth_curve
template<class VertexSource, class VertexGenerator>
struct conv_smooth_curve :
public conv_curve<conv_smooth<VertexSource, VertexGenerator>>
{
conv_smooth_poly1_curve(VertexSource& vs) :
conv_curve<conv_smooth_poly1<VertexSource> >(m_smooth),
conv_smooth_curve(VertexSource& vs) :
conv_curve<conv_smooth<VertexSource, VertexGenerator>>(m_smooth),
m_smooth(vs)
{
}

conv_smooth_curve(conv_smooth_curve<VertexSource, VertexGenerator> && rhs) :
conv_curve<conv_smooth<VertexSource, VertexGenerator>>(std::move(rhs)),
m_smooth(std::move(rhs.m_smooth))
{
this->attach(m_smooth);
}

conv_smooth_curve(const conv_smooth_curve<VertexSource, VertexGenerator>&) = delete;
const conv_smooth_curve<VertexSource, VertexGenerator>&
operator = (const conv_smooth_curve<VertexSource, VertexGenerator>&) = delete;

void smooth_value(double v) { m_smooth.generator().smooth_value(v); }
double smooth_value() const { return m_smooth.generator().smooth_value(); }
unsigned type() const { return m_smooth.type(); }

private:
conv_smooth_poly1_curve(const conv_smooth_poly1_curve<VertexSource>&);
const conv_smooth_poly1_curve<VertexSource>&
operator = (const conv_smooth_poly1_curve<VertexSource>&);

conv_smooth_poly1<VertexSource> m_smooth;
conv_smooth<VertexSource, VertexGenerator> m_smooth;
};

template<class VertexSource>
using conv_smooth_poly1_curve = conv_smooth_curve<VertexSource, vcgen_smooth_poly1>;
}


Expand Down

0 comments on commit 2dde0eb

Please sign in to comment.