diff --git a/opennurbs_3dm_attributes.cpp b/opennurbs_3dm_attributes.cpp index 5f27724e..d48f58d8 100644 --- a/opennurbs_3dm_attributes.cpp +++ b/opennurbs_3dm_attributes.cpp @@ -1840,18 +1840,18 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( { unsigned int rc = 0; - if (m_bVisible && !parents_attributes.m_bVisible) + if (0 != (0x01 & control_limits)) { - if (0 != (0x01 & control_limits)) + if (m_bVisible && !parents_attributes.m_bVisible) { rc |= 0x01; m_bVisible = false; } } - if (ON::color_from_parent == m_color_source) + if (0 != (0x02 & control_limits)) { - if (0 != (0x02 & control_limits)) + if (ON::color_from_parent == m_color_source) { rc |= 0x02; m_color_source = parents_attributes.m_color_source; @@ -1869,9 +1869,9 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( } } - if (ON::material_from_parent == m_material_source) + if (0 != (0x04 & control_limits)) { - if (0 != (0x04 & control_limits)) + if (ON::material_from_parent == m_material_source) { rc |= 0x04; m_material_source = parents_attributes.m_material_source; @@ -1889,9 +1889,9 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( } } - if (ON::plot_color_from_parent == m_plot_color_source) + if (0 != (0x08 & control_limits)) { - if (0 != (0x08 & control_limits)) + if (ON::plot_color_from_parent == m_plot_color_source) { rc |= 0x08; m_plot_color_source = parents_attributes.m_plot_color_source; @@ -1905,9 +1905,9 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( } } - if (ON::plot_weight_from_parent == m_plot_weight_source) + if (0 != (0x10 & control_limits)) { - if (0 != (0x10 & control_limits)) + if (ON::plot_weight_from_parent == m_plot_weight_source) { rc |= 0x10; m_plot_weight_source = parents_attributes.m_plot_weight_source; @@ -1921,9 +1921,9 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( } } - if (ON::linetype_from_parent == m_linetype_source) + if (0 != (0x20 & control_limits)) { - if (0 != (0x20 & control_limits)) + if (ON::linetype_from_parent == m_linetype_source) { rc |= 0x20; m_linetype_source = parents_attributes.m_linetype_source; @@ -1943,9 +1943,9 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( m_display_order = parents_attributes.m_display_order; } - //if (ON::ClipParticipationSource::FromParent == ClipParticipationSource()) + //if (0 != (0x80 & control_limits)) //{ - // if (0 != (0x80 & control_limits)) + // if (ON::ClipParticipationSource::FromParent == ClipParticipationSource()) // { // rc |= 0x80; // SetClipParticipationSource(parents_attributes.ClipParticipationSource()); @@ -1981,9 +1981,9 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( // } //} - if (ON::SectionAttributesSource::FromParent == SectionAttributesSource()) + if (0 != (0x100 & control_limits)) { - if (0 != (0x100 & control_limits)) + if (ON::SectionAttributesSource::FromParent == SectionAttributesSource()) { rc |= 0x100; SetSectionAttributesSource(parents_attributes.SectionAttributesSource()); diff --git a/opennurbs_3dm_settings.cpp b/opennurbs_3dm_settings.cpp index 2f92a642..23f16f5b 100644 --- a/opennurbs_3dm_settings.cpp +++ b/opennurbs_3dm_settings.cpp @@ -1803,7 +1803,7 @@ ON_UUID ON_3dmRenderSettings::RenderEnvironmentId(EnvironmentUsage usage, Enviro return RenderEnvironmentId(EnvironmentUsage::Background, purpose); case EnvironmentUsage::Skylighting: - if (!Skylight().On()) + if (!Skylight().Enabled()) return ON_nil_uuid; if (e.SkylightingRenderEnvironmentOverride()) @@ -2051,7 +2051,7 @@ double ON_3dmAnnotationSettings::WorldViewHatchScale() const if (this != &ON_3dmAnnotationSettings::Default) { if (m_private) - world_view_hatch_scale = m_private->m_world_view_text_scale; + world_view_hatch_scale = m_private->m_world_view_hatch_scale; } return world_view_hatch_scale; } diff --git a/opennurbs_curve.cpp b/opennurbs_curve.cpp index 9676b41f..c91054e2 100644 --- a/opennurbs_curve.cpp +++ b/opennurbs_curve.cpp @@ -1884,20 +1884,24 @@ bool ON_NurbsCurve::RepairBadKnots( double knot_tolerance, bool bRepair ) //int knot_count = KnotCount(); int i, j0, j1; - bool bIsPeriodic = IsPeriodic(); + const bool bIsPeriodic = IsPeriodic(); + const bool bIsUnclamped = this->UnclampedTagForExperts(); + const bool bUnclampedUniformCubic = Internal_IsUniformCubic(*this); - if ( !bIsPeriodic ) + const bool bClampEnds = + false == bIsPeriodic + && false == bIsUnclamped + && false == bUnclampedUniformCubic; + + if (bClampEnds) { if ( m_knot[0] != m_knot[m_order-2] || m_knot[m_cv_count-1] != m_knot[m_cv_count+m_order-3] ) { - if (false == Internal_IsUniformCubic(*this)) - { - rc = true; - if (bRepair) - ClampEnd(2); - else - return rc; - } + rc = true; + if (bRepair) + ClampEnd(2); + else + return rc; } } @@ -2015,8 +2019,11 @@ bool ON_NurbsCurve::RepairBadKnots( double knot_tolerance, bool bRepair ) if ( bRepair && bIsPeriodic && rc ) { - if ( !IsPeriodic() ) + if (!IsPeriodic()) + { + // the repairs broke being periodic. ClampEnd(2); + } } } return rc; diff --git a/opennurbs_dithering.cpp b/opennurbs_dithering.cpp index f3cdd705..1b970dff 100644 --- a/opennurbs_dithering.cpp +++ b/opennurbs_dithering.cpp @@ -60,8 +60,8 @@ const ON_Dithering& ON_Dithering::operator = (const ON_Dithering& dit) { if (this != &dit) { - SetOn (dit.On()); - SetMethod(dit.Method()); + SetEnabled(dit.Enabled()); + SetMethod (dit.Method()); } return *this; @@ -69,8 +69,8 @@ const ON_Dithering& ON_Dithering::operator = (const ON_Dithering& dit) bool ON_Dithering::operator == (const ON_Dithering& dit) const { - if (On() != dit.On()) return false; - if (Method() != dit.Method()) return false; + if (Enabled() != dit.Enabled()) return false; + if (Method() != dit.Method()) return false; return true; } @@ -80,14 +80,14 @@ bool ON_Dithering::operator != (const ON_Dithering& dit) const return !(operator == (dit)); } -bool ON_Dithering::On(void) const +bool ON_Dithering::Enabled(void) const { - return m_impl->GetParameter(XMLPathDit(), ON_RDK_DITHERING_ON, false); + return m_impl->GetParameter(XMLPathDit(), ON_RDK_DITHERING_ENABLED, false); } -void ON_Dithering::SetOn(bool b) +void ON_Dithering::SetEnabled(bool b) { - m_impl->SetParameter(XMLPathDit(), ON_RDK_DITHERING_ON, b); + m_impl->SetParameter(XMLPathDit(), ON_RDK_DITHERING_ENABLED, b); } ON_Dithering::Methods ON_Dithering::Method(void) const @@ -110,7 +110,7 @@ void ON_Dithering::SetMethod(Methods m) ON__UINT32 ON_Dithering::DataCRC(ON__UINT32 crc) const { - const bool b = On(); + const bool b = Enabled(); crc = ON_CRC32(crc, sizeof(b), &b); const auto m = Method(); diff --git a/opennurbs_dithering.h b/opennurbs_dithering.h index cf6e1a7a..74978405 100644 --- a/opennurbs_dithering.h +++ b/opennurbs_dithering.h @@ -27,11 +27,11 @@ public: virtual bool operator == (const ON_Dithering& dit) const; virtual bool operator != (const ON_Dithering& dit) const; - // Get dithering on / off state. - virtual bool On(void) const; + // Get the dithering enabled state. + virtual bool Enabled(void) const; - // Set dithering on or off. - virtual void SetOn(bool b); + // Enable or disable dithering. + virtual void SetEnabled(bool b); enum class Methods { SimpleNoise, FloydSteinberg }; diff --git a/opennurbs_extensions.cpp b/opennurbs_extensions.cpp index 82dfb1f3..4bb9b215 100644 --- a/opennurbs_extensions.cpp +++ b/opennurbs_extensions.cpp @@ -5660,13 +5660,13 @@ static bool GetRDKObjectInformation(const ON_Object& object, ON_wString& xml, in const auto sizeof_buffer = buf.Size(); - auto p = std::unique_ptr(new ON__UINT8[sizeof_buffer]); + auto p = std::unique_ptr(new ON__UINT8[size_t(sizeof_buffer)]); ON__UINT8* buffer = p.get(); buf.SeekFromStart(0); buf.Read(sizeof_buffer, buffer); const unsigned int archive_opennurbs_version_number = ON::Version(); - ON_Read3dmBufferArchive archive(sizeof_buffer, buffer, false, archive_3dm_version, archive_opennurbs_version_number); + ON_Read3dmBufferArchive archive(size_t(sizeof_buffer), buffer, false, archive_3dm_version, archive_opennurbs_version_number); int version = 0; if (!archive.ReadInt(&version)) @@ -5747,13 +5747,13 @@ static bool GetMeshModifierUserDataXML(ON_UserData& ud, ON_wString& xml, int arc const ON__UINT64 sizeof_buffer = buf.Size(); - auto p = std::unique_ptr(new ON__UINT8[sizeof_buffer]); + auto p = std::unique_ptr(new ON__UINT8[size_t(sizeof_buffer)]); ON__UINT8* buffer = p.get(); buf.SeekFromStart(0); buf.Read(sizeof_buffer, buffer); const auto archive_opennurbs_version_number = ON::Version(); - ON_Read3dmBufferArchive archive(sizeof_buffer, buffer, false, archive_3dm_version, archive_opennurbs_version_number); + ON_Read3dmBufferArchive archive(size_t(sizeof_buffer), buffer, false, archive_3dm_version, archive_opennurbs_version_number); int version = 0; if (!archive.ReadInt(&version)) diff --git a/opennurbs_file_utilities.cpp b/opennurbs_file_utilities.cpp index 7003f0bc..eb25f9d5 100644 --- a/opennurbs_file_utilities.cpp +++ b/opennurbs_file_utilities.cpp @@ -4294,12 +4294,12 @@ public: size_t ON_UnicodeTextFilePrivate::ReadData(void* buf, size_t bytes_to_read) { - return _file.Read(bytes_to_read, buf); + return size_t(_file.Read(bytes_to_read, buf)); } size_t ON_UnicodeTextFilePrivate::WriteData(const void* buf, size_t bytes_to_write) { - return _file.Write(bytes_to_write, buf); + return size_t(_file.Write(bytes_to_write, buf)); } static const wchar_t* FileStreamMode(ON_UnicodeTextFile::Modes m) @@ -4453,7 +4453,7 @@ bool ON_UnicodeTextFilePrivate::WriteString(const wchar_t* wsz) bool ON_UnicodeTextFilePrivate::ReadStringFromUTF8(ON_wString& s) { - const auto size_in_bytes = _file.GetLength() - _file.CurrentPosition(); + const auto size_in_bytes = size_t(_file.GetLength() - _file.CurrentPosition()); auto p = std::unique_ptr(new ON__UINT8[size_in_bytes + 1]); auto* pBuffer = p.get(); @@ -4476,8 +4476,8 @@ bool ON_UnicodeTextFilePrivate::ReadStringFromUTF8(ON_wString& s) bool ON_UnicodeTextFilePrivate::ReadStringFromUTF16(ON_wString& s) { const auto char_size = sizeof(ON__UINT16); - const auto size_in_bytes = _file.GetLength() - _file.CurrentPosition(); - const auto size_in_chars = size_in_bytes / char_size; + const auto size_in_bytes = size_t(_file.GetLength() - _file.CurrentPosition()); + const auto size_in_chars = size_t(size_in_bytes / char_size); #ifdef ON_RUNTIME_WIN // On Windows, wchar_t is UTF16 so we can load the file directly into the ON_wString. diff --git a/opennurbs_ground_plane.cpp b/opennurbs_ground_plane.cpp index 46de5293..3b46d943 100644 --- a/opennurbs_ground_plane.cpp +++ b/opennurbs_ground_plane.cpp @@ -34,7 +34,7 @@ public: CImpl(const CImpl& i) = delete; CImpl(ON_XMLNode& n) : ON_InternalXMLImpl(&n) { } - bool On(void) const { return GetParameter(XMLPath(), ON_RDK_GP_ON, false).AsBool(); } + bool Enabled(void) const { return GetParameter(XMLPath(), ON_RDK_GP_ENABLED, false).AsBool(); } bool ShowUnderside(void) const { return GetParameter(XMLPath(), ON_RDK_GP_SHOW_UNDERSIDE, false).AsBool(); } double Altitude(void) const { return GetParameter(XMLPath(), ON_RDK_GP_ALTITUDE, 0.0).AsDouble(); } bool AutoAltitude(void) const { return GetParameter(XMLPath(), ON_RDK_GP_AUTO_ALTITUDE, false).AsBool(); } @@ -46,7 +46,7 @@ public: ON_2dVector TextureOffset(void) const { return ON_2dVector(GetParameter(XMLPath(), ON_RDK_GP_TEXTURE_OFFSET, ON_nil_uuid).As2dPoint()); } ON_2dVector TextureSize(void) const { return ON_2dVector(GetParameter(XMLPath(), ON_RDK_GP_TEXTURE_SIZE, ON_nil_uuid).As2dPoint()); } - void SetOn(bool v) { SetParameter(XMLPath(), ON_RDK_GP_ON, v); } + void SetEnabled(bool v) { SetParameter(XMLPath(), ON_RDK_GP_ENABLED, v); } void SetShowUnderside(bool v) { SetParameter(XMLPath(), ON_RDK_GP_SHOW_UNDERSIDE, v); } void SetAltitude(double v) { SetParameter(XMLPath(), ON_RDK_GP_ALTITUDE, v); } void SetAutoAltitude(bool v) { SetParameter(XMLPath(), ON_RDK_GP_AUTO_ALTITUDE, v); } @@ -87,7 +87,7 @@ const ON_GroundPlane& ON_GroundPlane::operator = (const ON_GroundPlane& gp) { // When copying the object, we need to directly copy the underlying XML. So we can't allow // virtual overrides to execute because they might hide the real values we want to copy. - _impl->SetOn (gp._impl->On()); + _impl->SetEnabled (gp._impl->Enabled()); _impl->SetShowUnderside (gp._impl->ShowUnderside()); _impl->SetAltitude (gp._impl->Altitude()); _impl->SetAutoAltitude (gp._impl->AutoAltitude()); @@ -107,7 +107,7 @@ bool ON_GroundPlane::operator == (const ON_GroundPlane& gp) const { // When checking equality, we need to directly check the underlying storage. So we can't allow // virtual overrides to execute because they might hide the real values we want to check. - if (_impl->On() != gp._impl->On() ) return false; + if (_impl->Enabled() != gp._impl->Enabled() ) return false; if (_impl->ShowUnderside() != gp._impl->ShowUnderside() ) return false; if (_impl->AutoAltitude() != gp._impl->AutoAltitude() ) return false; if (_impl->ShadowOnly() != gp._impl->ShadowOnly() ) return false; @@ -128,9 +128,9 @@ bool ON_GroundPlane::operator != (const ON_GroundPlane& gp) const return !(operator == (gp)); } -bool ON_GroundPlane::On(void) const +bool ON_GroundPlane::Enabled(void) const { - return _impl->On(); + return _impl->Enabled(); } bool ON_GroundPlane::ShowUnderside(void) const @@ -183,9 +183,9 @@ double ON_GroundPlane::TextureRotation(void) const return _impl->TextureRotation(); } -void ON_GroundPlane::SetOn(bool v) +void ON_GroundPlane::SetEnabled(bool v) { - _impl->SetOn(v); + _impl->SetEnabled(v); } void ON_GroundPlane::SetShowUnderside(bool v) diff --git a/opennurbs_ground_plane.h b/opennurbs_ground_plane.h index 5f7ae731..a37cc2d0 100644 --- a/opennurbs_ground_plane.h +++ b/opennurbs_ground_plane.h @@ -28,7 +28,7 @@ public: virtual bool operator != (const ON_GroundPlane& gp) const; // Returns true if the ground plane is enabled, else false. - virtual bool On(void) const; + virtual bool Enabled(void) const; // Returns true if ground plane backface is enabled, else false. virtual bool ShowUnderside(void) const; @@ -62,7 +62,7 @@ public: virtual double TextureRotation(void) const; // Set the ground plane enabled state. - virtual void SetOn(bool on); + virtual void SetEnabled(bool on); // Set if the ground plane backface is enabled. virtual void SetShowUnderside(bool on); diff --git a/opennurbs_internal_defines.h b/opennurbs_internal_defines.h index 1c031d38..f31582c1 100644 --- a/opennurbs_internal_defines.h +++ b/opennurbs_internal_defines.h @@ -36,9 +36,6 @@ #define PRIVATE_CHECK(c) { } #endif -#define ON_KIND_MATERIAL L"material" -#define ON_KIND_ENVIRONMENT L"environment" -#define ON_KIND_TEXTURE L"texture" #define ON_RDK_UD_ROOT L"render-content-manager-data" inline bool IsFloatEqual (float f1, float f2) { return (fabsf(f1 - f2) < 1e-6); } diff --git a/opennurbs_knot.cpp b/opennurbs_knot.cpp index 8954b8b8..f439f10e 100644 --- a/opennurbs_knot.cpp +++ b/opennurbs_knot.cpp @@ -1419,3 +1419,5 @@ int ON_InsertKnot( return rc; } + + diff --git a/opennurbs_knot.h b/opennurbs_knot.h index 98edc052..61f4613e 100644 --- a/opennurbs_knot.h +++ b/opennurbs_knot.h @@ -338,6 +338,10 @@ bool ON_ClampKnotVector( int // end 0 = clamp start, 1 = clamp end, 2 = clamp both ends ); + + + + /* Returns: Number of knots added. diff --git a/opennurbs_nurbscurve.cpp b/opennurbs_nurbscurve.cpp index 519bb221..bd3dc3ed 100644 --- a/opennurbs_nurbscurve.cpp +++ b/opennurbs_nurbscurve.cpp @@ -4371,6 +4371,64 @@ int ON_NurbsCurve::RemoveSingularSpans() return singular_span_count; } + +static bool Internal_UnclampedKnots( + int order, + int cv_count, + const double* cv, + const double* knot + ) +{ + return + order >= 3 + && cv_count >= order + && nullptr != cv + && nullptr != knot + && knot[0] > ON_UNSET_VALUE + && knot[cv_count + order - 3] < ON_UNSET_POSITIVE_VALUE + && knot[order - 2] < knot[order - 1] - ON_ZERO_TOLERANCE + && knot[cv_count - 2] < knot[cv_count - 1] - ON_ZERO_TOLERANCE + && ((knot[0] < knot[order - 2] - ON_ZERO_TOLERANCE) || (knot[cv_count - 1] < knot[cv_count + order - 3] - ON_ZERO_TOLERANCE)) + ; +} + +bool ON_NurbsCurve::UnclampedTagForExperts() const +{ + if ( + 0 != (m_knot_capacity_and_tags & ON_NurbsCurve::masks::unclamped_knots_tag) + && Internal_UnclampedKnots(m_order,m_cv_count,m_cv,m_knot) + && false == IsPeriodic() + ) + { + return true; + } + return false; +} + +/* +Description: + Set the curve's UnclampedTag() property. +Parameters: + bUnclampedTag - [in] + If bUnclampedTag is true, the curve has unclamped knots, + and the curve is not periodic, + then the UnclampedTag() property is set to true. + Otherwise the UnclampedTag() property is set to false. +*/ +void ON_NurbsCurve::SetUnclampedTagForExperts( + bool bUnclampedTag +) +{ + if ( + bUnclampedTag + && Internal_UnclampedKnots(m_order, m_cv_count, m_cv, m_knot) + && false == this->IsPeriodic() + ) + m_knot_capacity_and_tags |= ON_NurbsCurve::masks::unclamped_knots_tag; + else + m_knot_capacity_and_tags &= ~ON_NurbsCurve::masks::unclamped_knots_tag; +} + bool ON_NurbsCurve::SubDFriendlyTag() const { if (0 != (m_knot_capacity_and_tags & ON_NurbsCurve::masks::subdfriendly_tag)) diff --git a/opennurbs_nurbscurve.h b/opennurbs_nurbscurve.h index fdefba78..bd991651 100644 --- a/opennurbs_nurbscurve.h +++ b/opennurbs_nurbscurve.h @@ -976,6 +976,7 @@ public: double* // g[cv_count] ) const; + bool ZeroCVs(); // zeros control vertices and, if rational, sets weights to 1 // Description: @@ -986,8 +987,9 @@ public: // Returns: // true if successful bool ClampEnd( - int end - ); + int end + ); + // Description: // Insert a knot and update cv locations. @@ -1236,13 +1238,34 @@ public: Parameters: bSubDFriendlyTag - [in] If bSubDFriendlyTag is true and IsSubDFriendly(true) is true, - then the SubDFriendlyTag() property is set to true. + then the SubDFriendlyTag() property is set to true. Otherwise the SubDFriendlyTag property is set to false. */ void SetSubDFriendlyTag( bool bSubDFriendlyTag ); + /* + Returns: + True if this curve was explicitly tagged as having unclampled knots + and currently has unclampled knots. + */ + bool UnclampedTagForExperts() const; + + /* + Description: + Set the curve's UnclampedTag() property. + Parameters: + bUnclampedTag - [in] + If bUnclampedTag is true, the curve has unclamped knots, + and the curve is not periodic, + then the UnclampedTag() property is set to true. + Otherwise the UnclampedTag() property is set to false. + */ + void SetUnclampedTagForExperts( + bool bUnclampedTag + ); + ///////////////////////////////////////////////////////////////// // Implementation @@ -1276,6 +1299,7 @@ private: { knot_capacity = 0x0FFFFFFFU, subdfriendly_tag = 0x80000000U, + unclamped_knots_tag = 0x40000000U, // set if Rhino should accept this curve with unclamped knots all_tags = 0xF0000000U, }; unsigned int m_knot_capacity_and_tags; diff --git a/opennurbs_public_version.h b/opennurbs_public_version.h index c01c1b22..2b45578b 100644 --- a/opennurbs_public_version.h +++ b/opennurbs_public_version.h @@ -14,10 +14,10 @@ // first step in each build. // #define RMA_VERSION_YEAR 2023 -#define RMA_VERSION_MONTH 6 -#define RMA_VERSION_DATE 27 -#define RMA_VERSION_HOUR 14 -#define RMA_VERSION_MINUTE 0 +#define RMA_VERSION_MONTH 7 +#define RMA_VERSION_DATE 11 +#define RMA_VERSION_HOUR 10 +#define RMA_VERSION_MINUTE 35 //////////////////////////////////////////////////////////////// // @@ -35,8 +35,8 @@ // 3 = build system release build #define RMA_VERSION_BRANCH 0 -#define VERSION_WITH_COMMAS 8,0,23178,14000 -#define VERSION_WITH_PERIODS 8.0.23178.14000 +#define VERSION_WITH_COMMAS 8,0,23192,10350 +#define VERSION_WITH_PERIODS 8.0.23192.10350 #define COPYRIGHT "Copyright (C) 1993-2023, Robert McNeel & Associates. All Rights Reserved." #define SPECIAL_BUILD_DESCRIPTION "Public OpenNURBS C++ 3dm file IO library." @@ -47,8 +47,8 @@ #define RMA_VERSION_NUMBER_SR_STRING "SR0" #define RMA_VERSION_NUMBER_SR_WSTRING L"SR0" -#define RMA_VERSION_WITH_PERIODS_STRING "8.0.23178.14000" -#define RMA_VERSION_WITH_PERIODS_WSTRING L"8.0.23178.14000" +#define RMA_VERSION_WITH_PERIODS_STRING "8.0.23192.10350" +#define RMA_VERSION_WITH_PERIODS_WSTRING L"8.0.23192.10350" diff --git a/opennurbs_render_content.cpp b/opennurbs_render_content.cpp index 26c692bd..481654ce 100644 --- a/opennurbs_render_content.cpp +++ b/opennurbs_render_content.cpp @@ -261,12 +261,12 @@ ON_Color ON_Environment::BackgroundColor(void) const return m_impl->m_back_col; } -void ON_Environment::SetBackgroundColor(ON_Color color) +void ON_Environment::SetBackgroundColor(const ON_Color& col) { - m_impl->m_back_col = color; + m_impl->m_back_col = col; } -ON_Texture ON_Environment::BackgroundImage(void) const +const ON_Texture& ON_Environment::BackgroundImage(void) const { return m_impl->m_back_image; } @@ -977,22 +977,22 @@ ON_RenderContent::ChildIterator ON_RenderContent::GetChildIterator(void) const return ChildIterator(this); } -const ON_RenderContent* ON_RenderContent::Parent(void) const +ON_RenderContent* ON_RenderContent::Parent(void) const { return _private->m_parent; } -const ON_RenderContent* ON_RenderContent::FirstChild(void) const +ON_RenderContent* ON_RenderContent::FirstChild(void) const { return _private->m_first_child; } -const ON_RenderContent* ON_RenderContent::NextSibling(void) const +ON_RenderContent* ON_RenderContent::NextSibling(void) const { return _private->m_next_sibling; } -const ON_RenderContent& ON_RenderContent::TopLevel(void) const +ON_RenderContent& ON_RenderContent::TopLevel(void) const { return _private->TopLevel(); } @@ -1310,6 +1310,11 @@ ON_Material ON_RenderMaterial::ToOnMaterial(void) const return mat; } +ON_RenderContent* ON_RenderMaterial::NewRenderContent(void) const +{ + return new ON_RenderMaterial; +} + // ON_RenderEnvironment ON_OBJECT_IMPLEMENT(ON_RenderEnvironment, ON_RenderContent, "A0AB8EF9-5FD4-4320-BBDA-A1200D1846E4"); @@ -1375,6 +1380,11 @@ ON_Environment ON_RenderEnvironment::ToOnEnvironment(void) const return env; } +ON_RenderContent* ON_RenderEnvironment::NewRenderContent(void) const +{ + return new ON_RenderEnvironment; +} + // ON_RenderTexture ON_OBJECT_IMPLEMENT(ON_RenderTexture, ON_RenderContent, "677D9905-CC8C-41E6-A7AD-2409DDE68ED0"); @@ -1511,6 +1521,17 @@ ON_wString ON_RenderTexture::Filename(void) const return v.AsString(); } +bool ON_RenderTexture::SetFilename(const wchar_t* f) +{ + return SetParameter(ON_RENDER_TEXTURE_FILENAME, f); +} + +ON_RenderContent* ON_RenderTexture::NewRenderContent(void) const +{ + return new ON_RenderTexture; +} + + int ONX_Model::AddRenderMaterial(const wchar_t* mat_name) { static ON_UUID uuidPB = { 0x5a8d7b9b, 0xcdc9, 0x49de, { 0x8c, 0x16, 0x2e, 0xf6, 0x4f, 0xb0, 0x97, 0xab } }; diff --git a/opennurbs_render_content.h b/opennurbs_render_content.h index 4f60ee25..d1843527 100644 --- a/opennurbs_render_content.h +++ b/opennurbs_render_content.h @@ -45,9 +45,9 @@ public: }; virtual ON_Color BackgroundColor(void) const; - virtual void SetBackgroundColor(ON_Color color); + virtual void SetBackgroundColor(const ON_Color& col); - virtual ON_Texture BackgroundImage(void) const; + virtual const ON_Texture& BackgroundImage(void) const; virtual void SetBackgroundImage(const ON_Texture& tex); virtual BackgroundProjections BackgroundProjection(void) const; @@ -164,16 +164,16 @@ public: virtual ChildIterator GetChildIterator(void) const; // Returns: The parent content or null if this is the top level object. - virtual const ON_RenderContent* Parent(void) const; + virtual ON_RenderContent* Parent(void) const; // Returns: The first child of this content or null if none. - virtual const ON_RenderContent* FirstChild(void) const; + virtual ON_RenderContent* FirstChild(void) const; // Returns: The first sibling of this content or null if none. - virtual const ON_RenderContent* NextSibling(void) const; + virtual ON_RenderContent* NextSibling(void) const; // Returns: The top level parent of this content. - virtual const ON_RenderContent& TopLevel(void) const; + virtual ON_RenderContent& TopLevel(void) const; // Returns: True if this is a top-level content (i.e., has no parent; is not a child). virtual bool IsTopLevel(void) const; @@ -224,6 +224,8 @@ public: // Returns the kind of render content as a string. virtual ON_wString Kind(void) const; + virtual ON_RenderContent* NewRenderContent(void) const = 0; + // If ON_RenderContent::Cast(ref.ModelComponent()) is not null, // that pointer is returned. Otherwise, none_return_value is returned. static const ON_RenderContent* FromModelComponentRef(const ON_ModelComponentReference& ref, @@ -251,10 +253,11 @@ public: ON_RenderMaterial(const ON_RenderMaterial& m); virtual ~ON_RenderMaterial(); - virtual const ON_RenderContent& operator = (const ON_RenderContent&) override; + virtual const ON_RenderContent& operator = (const ON_RenderContent&) override; virtual const ON_RenderMaterial& operator = (const ON_RenderMaterial&); virtual ON_Material ToOnMaterial(void) const; + virtual ON_RenderContent* NewRenderContent(void) const override; }; class ON_CLASS ON_RenderEnvironment : public ON_RenderContent @@ -270,6 +273,7 @@ public: virtual const ON_RenderEnvironment& operator = (const ON_RenderEnvironment&); virtual ON_Environment ToOnEnvironment(void) const; + virtual ON_RenderContent* NewRenderContent(void) const override; }; class ON_CLASS ON_RenderTexture : public ON_RenderContent @@ -289,6 +293,12 @@ public: // If the texture has a file name, returns that file name. Otherwise returns an empty string. virtual ON_wString Filename(void) const; + + // Set the texture's file name (if possible). If the texture does not have a file name (e.g., a + // procedural texture), the method returns false. + virtual bool SetFilename(const wchar_t*); + + virtual ON_RenderContent* NewRenderContent(void) const override; }; #endif diff --git a/opennurbs_safe_frame.cpp b/opennurbs_safe_frame.cpp index 271e3dd7..678a9f72 100644 --- a/opennurbs_safe_frame.cpp +++ b/opennurbs_safe_frame.cpp @@ -96,7 +96,7 @@ const ON_SafeFrame& ON_SafeFrame::operator = (const ON_SafeFrame& sf) { if (this != &sf) { - SetOn (sf.On()); + SetEnabled (sf.Enabled()); SetPerspectiveOnly (sf.PerspectiveOnly()); SetFieldGridOn (sf.FieldGridOn()); SetLiveFrameOn (sf.LiveFrameOn()); @@ -115,7 +115,7 @@ const ON_SafeFrame& ON_SafeFrame::operator = (const ON_SafeFrame& sf) bool ON_SafeFrame::operator == (const ON_SafeFrame& sf) const { - if (On() != sf.On()) return false; + if (Enabled() != sf.Enabled()) return false; if (PerspectiveOnly() != sf.PerspectiveOnly()) return false; if (FieldGridOn() != sf.FieldGridOn()) return false; if (LiveFrameOn() != sf.LiveFrameOn()) return false; @@ -137,14 +137,14 @@ bool ON_SafeFrame::operator != (const ON_SafeFrame& sf) const return !(operator == (sf)); } -bool ON_SafeFrame::On(void) const +bool ON_SafeFrame::Enabled(void) const { - return m_impl->GetBaseParameter(ON_RDK_SF_ON, false).AsBool(); + return m_impl->GetBaseParameter(ON_RDK_SF_ENABLED, false).AsBool(); } -void ON_SafeFrame::SetOn(bool b) +void ON_SafeFrame::SetEnabled(bool b) { - m_impl->SetBaseParameter(ON_RDK_SF_ON, b); + m_impl->SetBaseParameter(ON_RDK_SF_ENABLED, b); } bool ON_SafeFrame::PerspectiveOnly(void) const diff --git a/opennurbs_safe_frame.h b/opennurbs_safe_frame.h index 7bdcac41..5b597d21 100644 --- a/opennurbs_safe_frame.h +++ b/opennurbs_safe_frame.h @@ -27,11 +27,11 @@ public: virtual bool operator == (const ON_SafeFrame& sf) const; virtual bool operator != (const ON_SafeFrame& sf) const; - // Returns true if the safe frame is on. - virtual bool On(void) const; + // Returns true if the safe frame is enabled. + virtual bool Enabled(void) const; // Sets the safe frame on or off. - virtual void SetOn(bool b); + virtual void SetEnabled(bool b); // Returns true if the safe frame is only displayed in perspective views. virtual bool PerspectiveOnly(void) const; diff --git a/opennurbs_skylight.cpp b/opennurbs_skylight.cpp index 5a2ef97d..1ae43acc 100644 --- a/opennurbs_skylight.cpp +++ b/opennurbs_skylight.cpp @@ -60,7 +60,7 @@ const ON_Skylight& ON_Skylight::operator = (const ON_Skylight& sl) { if (this != &sl) { - SetOn(sl.On()); + SetEnabled(sl.Enabled()); SetShadowIntensity(sl.ShadowIntensity()); } @@ -69,7 +69,7 @@ const ON_Skylight& ON_Skylight::operator = (const ON_Skylight& sl) bool ON_Skylight::operator == (const ON_Skylight& sl) const { - if (On() != sl.On()) return false; + if (Enabled() != sl.Enabled()) return false; if (ShadowIntensity() != sl.ShadowIntensity()) return false; return true; @@ -80,14 +80,14 @@ bool ON_Skylight::operator != (const ON_Skylight& sl) const return !(operator == (sl)); } -bool ON_Skylight::On(void) const +bool ON_Skylight::Enabled(void) const { - return m_impl->GetParameter(XMLPath(), ON_RDK_SUN_SKYLIGHT_ON, false).AsBool(); + return m_impl->GetParameter(XMLPath(), ON_RDK_SUN_SKYLIGHT_ENABLED, false).AsBool(); } -void ON_Skylight::SetOn(bool b) +void ON_Skylight::SetEnabled(bool b) { - m_impl->SetParameter(XMLPath(), ON_RDK_SUN_SKYLIGHT_ON, b); + m_impl->SetParameter(XMLPath(), ON_RDK_SUN_SKYLIGHT_ENABLED, b); } double ON_Skylight::ShadowIntensity(void) const diff --git a/opennurbs_skylight.h b/opennurbs_skylight.h index d94ff667..11a3f027 100644 --- a/opennurbs_skylight.h +++ b/opennurbs_skylight.h @@ -28,10 +28,10 @@ public: virtual bool operator != (const ON_Skylight& sl) const; // Returns true if the skylight is enabled, else false. - virtual bool On(void) const; + virtual bool Enabled(void) const; // Set the skylight enabled state. - virtual void SetOn(bool b); + virtual void SetEnabled(bool b); // Returns the skylight shadow intensity. This is unused at present. virtual double ShadowIntensity(void) const; diff --git a/opennurbs_string_scan.cpp b/opennurbs_string_scan.cpp index 53a64192..7137b92b 100644 --- a/opennurbs_string_scan.cpp +++ b/opennurbs_string_scan.cpp @@ -736,7 +736,7 @@ const ON_wString ON_wString::ToMemorySize(size_t size_in_bytes) { const double x = ((double)sz)/((double)kb); if (0 == n) - return ON_wString::FormatToString(L"0.03f %ls", x, units); + return ON_wString::FormatToString(L"%0.03f %ls", x, units); if (n >= 10) return ON_wString::FormatToString(L"%0.1f %ls", x, units); diff --git a/opennurbs_subd_fragment.cpp b/opennurbs_subd_fragment.cpp index 6585ceed..7745b563 100644 --- a/opennurbs_subd_fragment.cpp +++ b/opennurbs_subd_fragment.cpp @@ -1004,7 +1004,7 @@ void ON_SubDManagedMeshFragment::CopyHelper(const ON_SubDMeshFragment& src) if (0 != K_count && vertex_capacity != K_count) { ON_SUBD_ERROR("invalid src.CurvatureCount()"); - K_count; + K_count = 0; } unsigned C_count = src.ColorCount(); diff --git a/opennurbs_xml.cpp b/opennurbs_xml.cpp index 0a901797..5478ceb4 100644 --- a/opennurbs_xml.cpp +++ b/opennurbs_xml.cpp @@ -1074,7 +1074,7 @@ ON_Buffer ON_XMLVariant::AsBuffer(void) const void* ON_XMLVariant::AsBuffer(size_t& size_out) const { auto buf = AsBuffer(); - size_out = buf.Size(); + size_out = size_t(buf.Size()); if (nullptr != _private->_raw_buffer) delete[] _private->_raw_buffer; @@ -1131,9 +1131,9 @@ ON_wString ON_XMLVariant::AsString(void) const _private->_string_val = wszBase64Prefix; auto& buffer = GetBuffer(); const auto buf_size = buffer.Size(); - auto* buf = new char[buf_size]; + auto* buf = new char[size_t(buf_size)]; buffer.Read(buf_size, buf); - ON_Base64::Encode(buf, buf_size, _private->_string_val, true); + ON_Base64::Encode(buf, size_t(buf_size), _private->_string_val, true); delete[] buf; return _private->_string_val; } @@ -3602,7 +3602,7 @@ public: ON_ASSERT(m_paSortedProperties != nullptr); - if (m_iIndex >= m_paSortedProperties->size()) + if (m_iIndex >= int(m_paSortedProperties->size())) return nullptr; return &(*m_paSortedProperties)[m_iIndex++]; @@ -5235,7 +5235,7 @@ void ON_RdkDocumentDefaults::CreateXML(void) // Misc rendering settings. ON_XMLParameters p(rendering); p.SetParam(ON_RDK_EMBED_SUPPORT_FILES_ON, true); - p.SetParam(ON_RDK_DITHERING_ON, false); + p.SetParam(ON_RDK_DITHERING_ENABLED, false); p.SetParam(ON_RDK_DITHERING_METHOD, ON_RDK_DITHERING_METHOD_FLOYD_STEINBERG); p.SetParam(ON_RDK_CUSTOM_REFLECTIVE_ENVIRONMENT, ON_nil_uuid); p.SetParam(ON_RDK_CUSTOM_REFLECTIVE_ENVIRONMENT_ON, (_major_version < 6) ? false : true); @@ -5292,7 +5292,7 @@ void ON_RdkDocumentDefaults::CreateXML(void) p.SetParam(ON_RDK_SUN_ALTITUDE, engine.Altitude()); p.SetParam(ON_RDK_SUN_OBSERVER_TIMEZONE, engine.TimeZoneHours()); - p.SetParam(ON_RDK_SUN_SKYLIGHT_ON, (_major_version < 6) ? false : true); + p.SetParam(ON_RDK_SUN_SKYLIGHT_ENABLED, (_major_version < 6) ? false : true); p.SetParam(ON_RDK_SUN_SKYLIGHT_SHADOW_INTENSITY, 1.0); p.SetParam(ON_RDK_SUN_SKYLIGHT_ENVIRONMENT_OVERRIDE, (_major_version < 6) ? false : true); p.SetParam(ON_RDK_SUN_SKYLIGHT_ENVIRONMENT_ID, ON_nil_uuid); @@ -5304,7 +5304,7 @@ void ON_RdkDocumentDefaults::CreateXML(void) auto& safe_frame = Create(settings, ON_RDK_SAFE_FRAME); { ON_XMLParameters p(safe_frame); - p.SetParam(ON_RDK_SF_ON, false); + p.SetParam(ON_RDK_SF_ENABLED, false); p.SetParam(ON_RDK_SF_PERSPECTIVE_ONLY, true); p.SetParam(ON_RDK_SF_4x3_FIELD_GRID_ON, false); @@ -5340,7 +5340,7 @@ void ON_RdkDocumentDefaults::CreateXML(void) auto& ground_plane = Create(settings, ON_RDK_GROUND_PLANE); { ON_XMLParameters p(ground_plane); - p.SetParam(ON_RDK_GP_ON, (_major_version < 6) ? false : true); + p.SetParam(ON_RDK_GP_ENABLED, (_major_version < 6) ? false : true); p.SetParam(ON_RDK_GP_SHOW_UNDERSIDE, false); p.SetParam(ON_RDK_GP_ALTITUDE, 0.0); p.SetParam(ON_RDK_GP_AUTO_ALTITUDE, true); diff --git a/opennurbs_xml.h b/opennurbs_xml.h index 65d63edd..c500d325 100644 --- a/opennurbs_xml.h +++ b/opennurbs_xml.h @@ -76,7 +76,7 @@ typedef bool (*ON_XMLRecurseChildrenCallback)(class ON_XMLNode*, void*); #define ON_RDK_CURRENT_RENDER_PRESET L"current-preset" #define ON_RDK_EMBED_SUPPORT_FILES_ON L"embed-support-files-on" - #define ON_RDK_DITHERING_ON L"use-dithering" + #define ON_RDK_DITHERING_ENABLED L"use-dithering" #define ON_RDK_DITHERING_METHOD L"dithering" #define ON_RDK_DITHERING_METHOD_FLOYD_STEINBERG L"floyd-steinberg" #define ON_RDK_DITHERING_METHOD_SIMPLE_NOISE L"simple-noise" @@ -105,7 +105,7 @@ typedef bool (*ON_XMLRecurseChildrenCallback)(class ON_XMLNode*, void*); #define ON_RDK_SUN_OBSERVER_LATITUDE L"observer-latitude" #define ON_RDK_SUN_OBSERVER_LONGITUDE L"observer-longitude" #define ON_RDK_SUN_OBSERVER_TIMEZONE L"observer-timezone" - #define ON_RDK_SUN_SKYLIGHT_ON L"skylight-on" + #define ON_RDK_SUN_SKYLIGHT_ENABLED L"skylight-on" #define ON_RDK_SUN_SKYLIGHT_SHADOW_INTENSITY L"skylight-shadow-intensity" #define ON_RDK_SUN_SKYLIGHT_ENVIRONMENT_OVERRIDE L"skylight-custom-environment-on" #define ON_RDK_SUN_SKYLIGHT_ENVIRONMENT_ID L"skylight-custom-environment" @@ -113,7 +113,7 @@ typedef bool (*ON_XMLRecurseChildrenCallback)(class ON_XMLNode*, void*); #define ON_RDK_SUN_INTENSITY L"intensity" #define ON_RDK_SAFE_FRAME L"safe-frame" - #define ON_RDK_SF_ON L"on" + #define ON_RDK_SF_ENABLED L"on" #define ON_RDK_SF_PERSPECTIVE_ONLY L"perspective-only" #define ON_RDK_SF_4x3_FIELD_GRID_ON L"field-display-on" #define ON_RDK_SF_LIVE_FRAME L"live-frame" @@ -125,7 +125,7 @@ typedef bool (*ON_XMLRecurseChildrenCallback)(class ON_XMLNode*, void*); #define ON_RDK_SFF_LINK L"link" #define ON_RDK_GROUND_PLANE L"ground-plane" - #define ON_RDK_GP_ON L"on" + #define ON_RDK_GP_ENABLED L"on" #define ON_RDK_GP_ALTITUDE L"altitude" #define ON_RDK_GP_AUTO_ALTITUDE L"auto-altitude" #define ON_RDK_GP_SHOW_UNDERSIDE L"show-underside" @@ -291,6 +291,11 @@ typedef bool (*ON_XMLRecurseChildrenCallback)(class ON_XMLNode*, void*); #define ON_TEXTURE_SIMULATION_TRANSPARENT_COLOR L"trans-color" #define ON_TEXTURE_SIMULATION_TRANSPARENT_COLOR_SENSITIVITY L"trans-color-sensitivity" +// Strings returned by ON_RenderContent::Kind(). +#define ON_KIND_MATERIAL L"material" +#define ON_KIND_ENVIRONMENT L"environment" +#define ON_KIND_TEXTURE L"texture" + #define ON_RDK_POSTFIX_SECTION L"-section" class ON_CLASS ON_XMLVariant