forked from mcneel/opennurbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopennurbs_dithering.cpp
129 lines (105 loc) · 3.1 KB
/
opennurbs_dithering.cpp
1
2
3
4
5
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
//
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
#include "opennurbs.h"
#include "opennurbs_internal_defines.h"
#if !defined(ON_COMPILING_OPENNURBS)
// This check is included in all opennurbs source .c and .cpp files to insure
// ON_COMPILING_OPENNURBS is defined when opennurbs source is compiled.
// When opennurbs source is being compiled, ON_COMPILING_OPENNURBS is defined
// and the opennurbs .h files alter what is declared and how it is declared.
#error ON_COMPILING_OPENNURBS must be defined when compiling opennurbs
#endif
class ON_Dithering::CImpl : public ON_InternalXMLImpl
{
public:
CImpl() { }
CImpl(ON_XMLNode& n) : ON_InternalXMLImpl(&n) { }
};
static const wchar_t* XMLPathDit(void)
{
return ON_RDK_DOCUMENT ON_XML_SLASH ON_RDK_SETTINGS ON_XML_SLASH ON_RDK_RENDERING;
}
ON_Dithering::ON_Dithering()
{
m_impl = new CImpl;
}
ON_Dithering::ON_Dithering(ON_XMLNode& model_node)
{
m_impl = new CImpl(model_node);
}
ON_Dithering::ON_Dithering(const ON_Dithering& dit)
{
m_impl = new CImpl;
operator = (dit);
}
ON_Dithering::~ON_Dithering()
{
delete m_impl;
m_impl = nullptr;
}
const ON_Dithering& ON_Dithering::operator = (const ON_Dithering& dit)
{
if (this != &dit)
{
SetEnabled(dit.Enabled());
SetMethod (dit.Method());
}
return *this;
}
bool ON_Dithering::operator == (const ON_Dithering& dit) const
{
if (Enabled() != dit.Enabled()) return false;
if (Method() != dit.Method()) return false;
return true;
}
bool ON_Dithering::operator != (const ON_Dithering& dit) const
{
return !(operator == (dit));
}
bool ON_Dithering::Enabled(void) const
{
return m_impl->GetParameter(XMLPathDit(), ON_RDK_DITHERING_ENABLED, false);
}
void ON_Dithering::SetEnabled(bool b)
{
m_impl->SetParameter(XMLPathDit(), ON_RDK_DITHERING_ENABLED, b);
}
ON_Dithering::Methods ON_Dithering::Method(void) const
{
const ON_wString s = m_impl->GetParameter(XMLPathDit(), ON_RDK_DITHERING_METHOD, L"").AsString();
if (ON_RDK_DITHERING_METHOD_FLOYD_STEINBERG == s)
return Methods::FloydSteinberg;
return Methods::SimpleNoise;
}
void ON_Dithering::SetMethod(Methods m)
{
const wchar_t* wsz = ON_RDK_DITHERING_METHOD_SIMPLE_NOISE;
if (Methods::FloydSteinberg == m)
wsz = ON_RDK_DITHERING_METHOD_FLOYD_STEINBERG;
m_impl->SetParameter(XMLPathDit(), ON_RDK_DITHERING_METHOD, wsz);
}
ON__UINT32 ON_Dithering::DataCRC(ON__UINT32 crc) const
{
const bool b = Enabled();
crc = ON_CRC32(crc, sizeof(b), &b);
const auto m = Method();
crc = ON_CRC32(crc, sizeof(m), &m);
return crc;
}
void* ON_Dithering::EVF(const wchar_t* func, void* data)
{
return nullptr;
}
void ON_Dithering::OnInternalXmlChanged(const ON_Dithering*)
{
}