diff --git a/opennurbs_3dm_attributes.cpp b/opennurbs_3dm_attributes.cpp index 74957a46..3fb2942c 100644 --- a/opennurbs_3dm_attributes.cpp +++ b/opennurbs_3dm_attributes.cpp @@ -33,11 +33,6 @@ public: bool operator==(const ON_3dmObjectAttributesPrivate&) const; bool operator!=(const ON_3dmObjectAttributesPrivate&) const; - ON::ClipParticipationSource m_clip_participation_source = ON::ClipParticipationSource::FromLayer; - ON_UuidList m_clipplane_list; - bool m_clipping_proof = false; - bool m_clipplane_list_is_participation = true; - ON::SectionAttributesSource m_section_attributes_source = ON::SectionAttributesSource::FromLayer; double m_linetype_scale = 1.0; ON_Color m_hatch_background_fill; @@ -60,18 +55,6 @@ ON_3dmObjectAttributesPrivate::ON_3dmObjectAttributesPrivate(const ON_3dmObjectA bool ON_3dmObjectAttributesPrivate::operator==(const ON_3dmObjectAttributesPrivate& other) const { - if (m_clip_participation_source != other.m_clip_participation_source) - return false; - - if (m_clipplane_list != other.m_clipplane_list) - return false; - - if (m_clipplane_list_is_participation != other.m_clipplane_list_is_participation) - return false; - - if (m_clipping_proof != other.m_clipping_proof) - return false; - if (m_section_attributes_source != other.m_section_attributes_source) return false; @@ -413,7 +396,7 @@ enum ON_3dmObjectAttributesTypeCodes : unsigned char ObsoleteLineCapStyle = 24, ObsoleteLineJoinStyleSource = 25, ObsoleteLineJoinStyle = 26, - ClipParticipationSource = 27, + ObsoleteClipParticipationSource = 27, SelectiveClippingData = 28, // 18 Oct 2021 S. Baer // file version 2.4: add section hatch attributes @@ -446,7 +429,7 @@ enum ON_3dmObjectAttributesTypeCodes : unsigned char ClippingPlaneLabelStyle = 40, // 11 May 2023 S. Baer // file version 2.13: how the participation list for clipping planes is interpreted - SelectiveClippingListType = 41, + ObsoleteSelectiveClippingListType = 41, // add items here LastAttributeTypeCode = 41 @@ -697,12 +680,12 @@ bool ON_3dmObjectAttributes::Internal_ReadV5( ON_BinaryArchive& file ) if (minor_version <= 2) break; - if (ON_3dmObjectAttributesTypeCodes::ClipParticipationSource == itemid) //27 + if (ON_3dmObjectAttributesTypeCodes::ObsoleteClipParticipationSource == itemid) //27 { unsigned char clip_participation_source = 0; rc = file.ReadChar(&clip_participation_source); if (!rc) break; - SetClipParticipationSource(ON::ClipParticipationSourceFromUnsigned(clip_participation_source)); + //SetClipParticipationSource(ON::ClipParticipationSourceFromUnsigned(clip_participation_source)); rc = file.ReadChar(&itemid); if (!rc || 0 == itemid) break; } @@ -715,15 +698,15 @@ bool ON_3dmObjectAttributes::Internal_ReadV5( ON_BinaryArchive& file ) ON_UuidList selectiveClipping; rc = selectiveClipping.Read(file); if (!rc) break; - if (clipping_proof) - SetClipParticipationForNone(); - else - { - if (selectiveClipping.Count() > 0) - { - SetClipParticipationList(selectiveClipping.Array(), selectiveClipping.Count(), true); - } - } + //if (clipping_proof) + // SetClipParticipationForNone(); + //else + //{ + // if (selectiveClipping.Count() > 0) + // { + // SetClipParticipationList(selectiveClipping.Array(), selectiveClipping.Count(), true); + // } + //} rc = file.ReadChar(&itemid); if (!rc || 0 == itemid) break; } @@ -896,14 +879,14 @@ bool ON_3dmObjectAttributes::Internal_ReadV5( ON_BinaryArchive& file ) if (minor_version <= 12) break; - if (ON_3dmObjectAttributesTypeCodes::SelectiveClippingListType == itemid) // 41 + if (ON_3dmObjectAttributesTypeCodes::ObsoleteSelectiveClippingListType == itemid) // 41 { bool b = true; rc = file.ReadBool(&b); if (!rc) break; - if (nullptr == m_private) - m_private = new ON_3dmObjectAttributesPrivate(this); - m_private->m_clipplane_list_is_participation = b; + //if (nullptr == m_private) + // m_private = new ON_3dmObjectAttributesPrivate(this); + //m_private->m_clipplane_list_is_participation = b; rc = file.ReadChar(&itemid); if (!rc || 0 == itemid) break; @@ -1325,32 +1308,32 @@ bool ON_3dmObjectAttributes::Internal_WriteV5( ON_BinaryArchive& file ) const // be default which means there is no need to check their state if (m_private) { - if (ClipParticipationSource() != ON::ClipParticipationSource::FromLayer) - { - c = ON_3dmObjectAttributesTypeCodes::ClipParticipationSource; // 27 - rc = file.WriteChar(c); - if (!rc) break; - rc = file.WriteChar((unsigned char)ClipParticipationSource()); - if (!rc) break; - } + //if (ClipParticipationSource() != ON::ClipParticipationSource::FromLayer) + //{ + // c = ON_3dmObjectAttributesTypeCodes::ClipParticipationSource; // 27 + // rc = file.WriteChar(c); + // if (!rc) break; + // rc = file.WriteChar((unsigned char)ClipParticipationSource()); + // if (!rc) break; + //} - { - bool forAllClippingPlanes = true; - bool forNoClippingPlanes = false; - ON_UuidList selectiveClipping; - bool isParticipationList = true; - GetClipParticipation(forAllClippingPlanes, forNoClippingPlanes, selectiveClipping, isParticipationList); - if (!forAllClippingPlanes) - { - c = ON_3dmObjectAttributesTypeCodes::SelectiveClippingData; // 28 - rc = file.WriteChar(c); - if (!rc) break; - rc = file.WriteBool(forNoClippingPlanes); - if (!rc) break; - rc = selectiveClipping.Write(file); - if (!rc) break; - } - } + //{ + // bool forAllClippingPlanes = true; + // bool forNoClippingPlanes = false; + // ON_UuidList selectiveClipping; + // bool isParticipationList = true; + // GetClipParticipation(forAllClippingPlanes, forNoClippingPlanes, selectiveClipping, isParticipationList); + // if (!forAllClippingPlanes) + // { + // c = ON_3dmObjectAttributesTypeCodes::SelectiveClippingData; // 28 + // rc = file.WriteChar(c); + // if (!rc) break; + // rc = file.WriteBool(forNoClippingPlanes); + // if (!rc) break; + // rc = selectiveClipping.Write(file); + // if (!rc) break; + // } + //} if (SectionAttributesSource() != ON::SectionAttributesSource::FromLayer) { @@ -1491,14 +1474,14 @@ bool ON_3dmObjectAttributes::Internal_WriteV5( ON_BinaryArchive& file ) const if (!rc) break; } - if (m_private && false == m_private->m_clipplane_list_is_participation) - { - c = ON_3dmObjectAttributesTypeCodes::SelectiveClippingListType; //41 - rc = file.WriteChar(c); - if (!rc) break; - rc = file.WriteBool(m_private->m_clipplane_list_is_participation); - if (!rc) break; - } + //if (m_private && false == m_private->m_clipplane_list_is_participation) + //{ + // c = ON_3dmObjectAttributesTypeCodes::SelectiveClippingListType; //41 + // rc = file.WriteChar(c); + // if (!rc) break; + // rc = file.WriteBool(m_private->m_clipplane_list_is_participation); + // if (!rc) break; + //} // 0 indicates end of attributes - this should be the last item written c = 0; @@ -1960,43 +1943,43 @@ unsigned int ON_3dmObjectAttributes::ApplyParentalControl( m_display_order = parents_attributes.m_display_order; } - if (ON::ClipParticipationSource::FromParent == ClipParticipationSource()) - { - if (0 != (0x80 & control_limits)) - { - rc |= 0x80; - SetClipParticipationSource(parents_attributes.ClipParticipationSource()); - if (ON::ClipParticipationSource::FromLayer == ClipParticipationSource() && parent_layer.Index() >= 0) - { - SetClipParticipationSource(ON::ClipParticipationSource::FromObject); - bool forAll = false; - bool forNone = false; - ON_UuidList list; - bool isParticipationList = true; - parent_layer.GetClipParticipation(forAll, forNone, list, isParticipationList); - if (forAll) - SetClipParticipationForAll(); - else if (forNone) - SetClipParticipationForNone(); - else if (list.Count() > 0) - SetClipParticipationList(list.Array(), list.Count(), isParticipationList); - } - if (ON::ClipParticipationSource::FromObject == ClipParticipationSource()) - { - bool forAll = false; - bool forNone = false; - ON_UuidList list; - bool isParticipationList = true; - parents_attributes.GetClipParticipation(forAll, forNone, list, isParticipationList); - if (forAll) - SetClipParticipationForAll(); - else if (forNone) - SetClipParticipationForNone(); - else if (list.Count() > 0) - SetClipParticipationList(list.Array(), list.Count(), isParticipationList); - } - } - } + //if (ON::ClipParticipationSource::FromParent == ClipParticipationSource()) + //{ + // if (0 != (0x80 & control_limits)) + // { + // rc |= 0x80; + // SetClipParticipationSource(parents_attributes.ClipParticipationSource()); + // if (ON::ClipParticipationSource::FromLayer == ClipParticipationSource() && parent_layer.Index() >= 0) + // { + // SetClipParticipationSource(ON::ClipParticipationSource::FromObject); + // bool forAll = false; + // bool forNone = false; + // ON_UuidList list; + // bool isParticipationList = true; + // parent_layer.GetClipParticipation(forAll, forNone, list, isParticipationList); + // if (forAll) + // SetClipParticipationForAll(); + // else if (forNone) + // SetClipParticipationForNone(); + // else if (list.Count() > 0) + // SetClipParticipationList(list.Array(), list.Count(), isParticipationList); + // } + // if (ON::ClipParticipationSource::FromObject == ClipParticipationSource()) + // { + // bool forAll = false; + // bool forNone = false; + // ON_UuidList list; + // bool isParticipationList = true; + // parents_attributes.GetClipParticipation(forAll, forNone, list, isParticipationList); + // if (forAll) + // SetClipParticipationForAll(); + // else if (forNone) + // SetClipParticipationForNone(); + // else if (list.Count() > 0) + // SetClipParticipationList(list.Array(), list.Count(), isParticipationList); + // } + // } + //} if (ON::SectionAttributesSource::FromParent == SectionAttributesSource()) { @@ -2379,85 +2362,6 @@ int ON_3dmObjectAttributes::DisplayMaterialRefCount() const } -ON::ClipParticipationSource ON_3dmObjectAttributes::ClipParticipationSource() const -{ - return m_private ? m_private->m_clip_participation_source : DefaultAttributesPrivate.m_clip_participation_source; -} -void ON_3dmObjectAttributes::SetClipParticipationSource(ON::ClipParticipationSource source) -{ - if (ClipParticipationSource() == source) - return; - - if (nullptr == m_private) - m_private = new ON_3dmObjectAttributesPrivate(this); - m_private->m_clip_participation_source = source; -} - -void ON_3dmObjectAttributes::SetClipParticipationForAll() -{ - // default is true for all clipping planes. If our private pointer hasn't - // been created, there is no need to do anything - if (nullptr == m_private) - return; - - m_private->m_clipplane_list.Empty(); - m_private->m_clipplane_list_is_participation = true; - m_private->m_clipping_proof = false; -} -void ON_3dmObjectAttributes::SetClipParticipationForNone() -{ - if (nullptr == m_private) - m_private = new ON_3dmObjectAttributesPrivate(this); - m_private->m_clipplane_list.Empty(); - m_private->m_clipplane_list_is_participation = true; - m_private->m_clipping_proof = true; -} -void ON_3dmObjectAttributes::SetClipParticipationList(const ON_UUID* clippingPlaneIds, int count, bool isParticipationList) -{ - if (nullptr == clippingPlaneIds || count < 1) - { - SetClipParticipationForAll(); - return; - } - - if (nullptr == m_private) - m_private = new ON_3dmObjectAttributesPrivate(this); - m_private->m_clipplane_list.Empty(); - for (int i = 0; i < count; i++) - m_private->m_clipplane_list.AddUuid(clippingPlaneIds[i], true); - - m_private->m_clipplane_list_is_participation = isParticipationList; - m_private->m_clipping_proof = false; -} -void ON_3dmObjectAttributes::GetClipParticipation( - bool& forAllClippingPlanes, - bool& forNoClippingPlanes, - ON_UuidList& specificClipplaneList, - bool& listIsParticipation) const -{ - listIsParticipation = true; - if (nullptr == m_private) - { - forAllClippingPlanes = true; - forNoClippingPlanes = false; - specificClipplaneList.Empty(); - return; - } - - specificClipplaneList = m_private->m_clipplane_list; - listIsParticipation = m_private->m_clipplane_list_is_participation; - if (specificClipplaneList.Count() > 0) - { - forAllClippingPlanes = false; - forNoClippingPlanes = false; - } - else - { - forNoClippingPlanes = m_private->m_clipping_proof; - forAllClippingPlanes = !forNoClippingPlanes; - } -} - ON::SectionAttributesSource ON_3dmObjectAttributes::SectionAttributesSource() const { diff --git a/opennurbs_3dm_attributes.h b/opennurbs_3dm_attributes.h index d5b3fd29..c86be876 100644 --- a/opennurbs_3dm_attributes.h +++ b/opennurbs_3dm_attributes.h @@ -365,43 +365,6 @@ public: // is on. ON::active_space m_space = ON::model_space; - // Set the object to participate in clipping for all clipping plane objects. - // This is the default behavior. - void SetClipParticipationForAll(); - - // Set the object to be immune from the clipping for all clipping planes. - void SetClipParticipationForNone(); - - // Set the object to only be clipped by a specific set of clipping planes. - // Paramters: - // clippingPlaneIds [in] - array of ON_UUIDs for clipping planes - // count [in] - number of elements in clippingPlaneIds - // listIsParticipation [in] - is the list clipping planes that the object - // participates with or an exclusion list of clipping planes to not - // participate with - void SetClipParticipationList(const ON_UUID* clippingPlaneIds, int count, bool listIsParticipation); - - // Get details on how the object will interact with clipping planes - // Parameters: - // forAllClippingPlanes [out] - if true, this object interacts with all - // clipping planes - // forNoClippingPlanes [out] - if true, this object is immune from all - // clipping planes - // specificClipplaneList [out] - if the object interacts with only a - // specific set of clipping planes, this list will have the uuids of - // those clipping plane objects - // listIsParticipation [out] - is specificClipplaneList a participation - // list or an exclusion list - void GetClipParticipation( - bool& forAllClippingPlanes, - bool& forNoClippingPlanes, - ON_UuidList& specificClipplaneList, - bool& listIsParticipation) const; - - // Source for clip participation details - ON::ClipParticipationSource ClipParticipationSource() const; - void SetClipParticipationSource(ON::ClipParticipationSource source); - #pragma region Section Attributes // Sections are the product of intersecting a plane with an object. // For surface type geometry (ON_Brep, ON_Extrusion, ON_SubD, ON_Mesh) diff --git a/opennurbs_3dm_settings.cpp b/opennurbs_3dm_settings.cpp index 0169c3f2..0c09821f 100644 --- a/opennurbs_3dm_settings.cpp +++ b/opennurbs_3dm_settings.cpp @@ -1849,6 +1849,8 @@ const ON_PostEffects& ON_3dmRenderSettings::PostEffects(void) const return const_cast(this)->PostEffects(); } +#ifdef RDK_RENDER_PRESETS + extern ON_UUID uuidRenderPreset_Studio; extern ON_UUID uuidRenderPreset_Custom; extern ON_UUID uuidRenderPreset_Exterior; @@ -1890,6 +1892,7 @@ void ON_3dmRenderSettings::GetRenderPresetList(ON_SimpleArray& presets) presets.Append(uuidRenderPreset_Interior); presets.Append(uuidRenderPreset_Custom); } +#endif ////////////////////////////////////////////////////////////////////////////////////////// // diff --git a/opennurbs_3dm_settings.h b/opennurbs_3dm_settings.h index 3fe1608e..cf0931c8 100644 --- a/opennurbs_3dm_settings.h +++ b/opennurbs_3dm_settings.h @@ -874,11 +874,6 @@ public: // Sets the id of the rendering environment for a particular usage. void SetRenderEnvironmentId(EnvironmentUsage usage, const ON_UUID& id); - // Access to render presets. - ON_UUID CurrentRenderPreset(void) const; - void SetCurrentRenderPreset(const ON_UUID& uuid); - void GetRenderPresetList(ON_SimpleArray& presets) const; - private: unsigned short m_reserved1 = 0; diff --git a/opennurbs_arc.cpp b/opennurbs_arc.cpp index c3c57714..554a0262 100644 --- a/opennurbs_arc.cpp +++ b/opennurbs_arc.cpp @@ -296,6 +296,14 @@ bool ON_Arc::IsCircle() const ? true : false; } +bool ON_Arc::IsLinear(double tol) const +{ + static const double Theta_max = 2*ON_PI - 4.0 * atan(.5); // about 250 degrees + return AngleRadians() < Theta_max && // Angle must be less than max + radius * (1.0 - cos(AngleRadians() / 2.0)) < tol && // Segment height less than tol + radius * 2.0 * sin(AngleRadians() / 2.0) > tol; // Chord length greater than tol +} + double ON_Arc::AngleRadians() const { return m_angle[1]-m_angle[0]; diff --git a/opennurbs_arc.h b/opennurbs_arc.h index 00a44bff..fbfc7f60 100644 --- a/opennurbs_arc.h +++ b/opennurbs_arc.h @@ -354,6 +354,11 @@ public: // angle is 360 degrees. bool IsCircle() const; + + // Returns: + // True if the arc is within tol of the chord and chord is longer than tol + bool IsLinear(double tol) const; + // Returns: // The arc's subtended angle in radians. double AngleRadians() const; diff --git a/opennurbs_arccurve.cpp b/opennurbs_arccurve.cpp index ce10663d..b05e5ded 100644 --- a/opennurbs_arccurve.cpp +++ b/opennurbs_arccurve.cpp @@ -357,7 +357,10 @@ ON_ArcCurve::IsLinear( // true if curve locus is a line segment double // tolerance - formal parameter intentionally ignored in this virtual function ) const { - return false; + return false; // GBA 23 May 23. This just seems wrong. Maybe we should change this very early in WIP and see if anyone notices. + // I think this is the correct implementation + // return m_arc.IsLinear(tolerance); + } bool diff --git a/opennurbs_defines.cpp b/opennurbs_defines.cpp index e79ea1c3..cbe946c8 100644 --- a/opennurbs_defines.cpp +++ b/opennurbs_defines.cpp @@ -2821,20 +2821,6 @@ ON::LineJoinStyle ON::LineJoinStyleFromUnsigned( } -ON::ClipParticipationSource ON::ClipParticipationSourceFromUnsigned( - unsigned int clip_participation_source_as_unsigned -) -{ - switch (clip_participation_source_as_unsigned) - { - ON_ENUM_FROM_UNSIGNED_CASE(ON::ClipParticipationSource::FromLayer); - ON_ENUM_FROM_UNSIGNED_CASE(ON::ClipParticipationSource::FromObject); - ON_ENUM_FROM_UNSIGNED_CASE(ON::ClipParticipationSource::FromParent); - } - ON_ERROR("invalid clip_participation_source_as_unsigned parameter."); - return ON::ClipParticipationSource::FromLayer; -} - ON::SectionFillRule ON::SectionFillRuleFromUnsigned( unsigned int section_fill_rule_as_unsigned ) diff --git a/opennurbs_defines.h b/opennurbs_defines.h index 14c46509..99fd7f6f 100644 --- a/opennurbs_defines.h +++ b/opennurbs_defines.h @@ -2476,26 +2476,6 @@ public: unsigned int join_as_unsigned ); -#pragma region RH_C_SHARED_ENUM [ON::ClipParticipationSource] [Rhino.DocObjects.ObjectClipParticipationSource] - /// - /// The source of clipping plane effects on an object. - /// - /// 8.0 - enum class ClipParticipationSource : unsigned char - { - /// Clip participation is defined by object's layer - FromLayer = 0, - /// Clip participation is specific to the object - FromObject = 1, - /// Clip participation is defined by object's parent - FromParent = 3 - }; -#pragma endregion - - static ClipParticipationSource ClipParticipationSourceFromUnsigned( - unsigned int clip_participation_source_as_unsigned - ); - #pragma region RH_C_SHARED_ENUM [ON::SectionFillRule] [Rhino.DocObjects.ObjectSectionFillRule] /// /// For sectioning an object; the decision of when to generate hatches and fills. diff --git a/opennurbs_layer.cpp b/opennurbs_layer.cpp index fb972dc3..7c540631 100644 --- a/opennurbs_layer.cpp +++ b/opennurbs_layer.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved. +// Copyright (c) 1993-2023 Robert McNeel & Associates. All rights reserved. // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert // McNeel & Associates. // @@ -30,10 +30,6 @@ public: bool operator==(const ON_LayerPrivate&) const; bool operator!=(const ON_LayerPrivate&) const; - ON_UuidList m_clipplane_list; - bool m_clipplane_list_is_participation = true; - bool m_clipping_proof = false; - std::shared_ptr m_custom_section_style; bool m_visible_in_new_details = true; @@ -47,15 +43,6 @@ bool ON_LayerPrivate::operator==(const ON_LayerPrivate& other) const if (this == &other) return true; - if (m_clipplane_list != other.m_clipplane_list) - return false; - - if (m_clipplane_list_is_participation != other.m_clipplane_list_is_participation) - return false; - - if (m_clipping_proof != other.m_clipping_proof) - return false; - { const ON_SectionStyle* customThis = m_custom_section_style.get(); const ON_SectionStyle* customOther = other.m_custom_section_style.get(); @@ -273,25 +260,25 @@ void ON_Layer::Dump( ON_TextLog& dump ) const dump.Print("plot color rgb = "); dump.PrintRGB(m_plot_color); dump.Print("\n"); dump.Print("default material index = %d\n",m_material_index); - { - bool clipAll = true; - bool clipNone = false; - ON_UuidList cliplist; - bool isSelectiveList = true; - GetClipParticipation(clipAll, clipNone, cliplist, isSelectiveList); - if (clipAll) - { - dump.Print("participates with all clipping planes\n"); - } - else if (clipNone) - { - dump.Print("participates with no clipping planes\n"); - } - else - { - dump.Print("participates with specific clipping planes\n"); - } - } + //{ + // bool clipAll = true; + // bool clipNone = false; + // ON_UuidList cliplist; + // bool isSelectiveList = true; + // GetClipParticipation(clipAll, clipNone, cliplist, isSelectiveList); + // if (clipAll) + // { + // dump.Print("participates with all clipping planes\n"); + // } + // else if (clipNone) + // { + // dump.Print("participates with no clipping planes\n"); + // } + // else + // { + // dump.Print("participates with specific clipping planes\n"); + // } + //} const ON_SectionStyle* section_style = CustomSectionStyle(); if (nullptr == section_style) @@ -312,7 +299,7 @@ void ON_Layer::Dump( ON_TextLog& dump ) const // inferred when the data matches default values. enum ON_LayerTypeCodes : unsigned char { - SelectiveClippingData = 28, + ObsoleteSelectiveClippingData = 28, // 18 Oct 2021 S. Baer // chunk version 1.11: add section hatch attributes SectionHatchIndex = 29, @@ -332,7 +319,7 @@ enum ON_LayerTypeCodes : unsigned char CustomSectionStyle = 35, // 11 May 2023 S. Baer // New selective clipping data with bool for list type - SelectiveClippingListType = 36, + ObsoleteSelectiveClippingListType = 36, LastLayerTypeCode = 36 }; @@ -495,24 +482,24 @@ bool ON_Layer::Write( unsigned char c = 0; // selective clipping (1.10) - { - bool forAllClippingPlanes = true; - bool forNoClippingPlanes = false; - ON_UuidList selectiveList; - bool isParticipationList = true; - GetClipParticipation(forAllClippingPlanes, forNoClippingPlanes, selectiveList, isParticipationList); - // only write selective clipping data if it is not default - if (false == forAllClippingPlanes || true == forNoClippingPlanes || selectiveList.Count() > 0) - { - c = ON_LayerTypeCodes::SelectiveClippingData; - rc = file.WriteChar(c); - if (!rc) break; - rc = file.WriteBool(forNoClippingPlanes); - if (!rc) break; - rc = selectiveList.Write(file); - if (!rc) break; - } - } + //{ + // bool forAllClippingPlanes = true; + // bool forNoClippingPlanes = false; + // ON_UuidList selectiveList; + // bool isParticipationList = true; + // GetClipParticipation(forAllClippingPlanes, forNoClippingPlanes, selectiveList, isParticipationList); + // // only write selective clipping data if it is not default + // if (false == forAllClippingPlanes || true == forNoClippingPlanes || selectiveList.Count() > 0) + // { + // c = ON_LayerTypeCodes::SelectiveClippingData; + // rc = file.WriteChar(c); + // if (!rc) break; + // rc = file.WriteBool(forNoClippingPlanes); + // if (!rc) break; + // rc = selectiveList.Write(file); + // if (!rc) break; + // } + //} // 23 April 2023 S. Baer // Stop writing individual section attributes. All section attribute IO has been @@ -592,14 +579,14 @@ bool ON_Layer::Write( if (!rc) break; } - if (m_private && false == m_private->m_clipplane_list_is_participation) - { - c = ON_LayerTypeCodes::SelectiveClippingListType; //36 - rc = file.WriteChar(c); - if (!rc) break; - rc = file.WriteBool(m_private->m_clipplane_list_is_participation); - if (!rc) break; - } + //if (m_private && false == m_private->m_clipplane_list_is_participation) + //{ + // c = ON_LayerTypeCodes::SelectiveClippingListType; //36 + // rc = file.WriteChar(c); + // if (!rc) break; + // rc = file.WriteBool(m_private->m_clipplane_list_is_participation); + // if (!rc) break; + //} // 0 indicates end of new non-default attributes c = 0; @@ -786,7 +773,7 @@ bool ON_Layer::Read( if (0 == itemid) break; - if (ON_LayerTypeCodes::SelectiveClippingData == itemid) //28 + if (ON_LayerTypeCodes::ObsoleteSelectiveClippingData == itemid) //28 { bool noClippingPlanes = false; ON_UuidList selectiveList; @@ -794,12 +781,12 @@ bool ON_Layer::Read( if (!rc) break; rc = selectiveList.Read(file); if (!rc) break; - if (noClippingPlanes) - SetClipParticipationForNone(); - else if (selectiveList.Count() > 0) - SetClipParticipationList(selectiveList.Array(), selectiveList.Count(), true); - else - SetClipParticipationForAll(); + //if (noClippingPlanes) + // SetClipParticipationForNone(); + //else if (selectiveList.Count() > 0) + // SetClipParticipationList(selectiveList.Array(), selectiveList.Count(), true); + //else + // SetClipParticipationForAll(); rc = file.ReadChar(&itemid); if (!rc || 0 == itemid) break; @@ -907,14 +894,14 @@ bool ON_Layer::Read( if (!rc || 0 == itemid) break; } - if (ON_LayerTypeCodes::SelectiveClippingListType == itemid) + if (ON_LayerTypeCodes::ObsoleteSelectiveClippingListType == itemid) { bool b = true; file.ReadBool(&b); if (!rc) break; - if (nullptr == m_private) - m_private = new ON_LayerPrivate(); - m_private->m_clipplane_list_is_participation = b; + //if (nullptr == m_private) + // m_private = new ON_LayerPrivate(); + //m_private->m_clipplane_list_is_participation = b; rc = file.ReadChar(&itemid); if (!rc || 0 == itemid) break; @@ -2497,71 +2484,6 @@ void ON_Layer::UnsetPersistentLocking() m_extension_bits &= and_mask; } -void ON_Layer::SetClipParticipationForAll() -{ - // default is true for all clipping planes. If our private pointer hasn't - // been created, there is no need to do anything - if (nullptr == m_private) - return; - - m_private->m_clipplane_list.Empty(); - m_private->m_clipplane_list_is_participation = true; - m_private->m_clipping_proof = false; -} -void ON_Layer::SetClipParticipationForNone() -{ - if (nullptr == m_private) - m_private = new ON_LayerPrivate(); - m_private->m_clipplane_list.Empty(); - m_private->m_clipplane_list_is_participation = true; - m_private->m_clipping_proof = true; -} -void ON_Layer::SetClipParticipationList(const ON_UUID* clippingPlaneIds, int count, bool listIsParticipation) -{ - if (nullptr == clippingPlaneIds || count < 1) - { - SetClipParticipationForAll(); - return; - } - - if (nullptr == m_private) - m_private = new ON_LayerPrivate(); - m_private->m_clipplane_list.Empty(); - for (int i = 0; i < count; i++) - m_private->m_clipplane_list.AddUuid(clippingPlaneIds[i], true); - - m_private->m_clipplane_list_is_participation = listIsParticipation; - m_private->m_clipping_proof = false; -} -void ON_Layer::GetClipParticipation( - bool& forAllClippingPlanes, - bool& forNoClippingPlanes, - ON_UuidList& specificClipplaneList, - bool& listIsParticipation) const -{ - listIsParticipation = true; - if (nullptr == m_private) - { - forAllClippingPlanes = true; - forNoClippingPlanes = false; - specificClipplaneList.Empty(); - return; - } - - specificClipplaneList = m_private->m_clipplane_list; - listIsParticipation = m_private->m_clipplane_list_is_participation; - if (specificClipplaneList.Count() > 0) - { - forAllClippingPlanes = false; - forNoClippingPlanes = false; - } - else - { - forNoClippingPlanes = m_private->m_clipping_proof; - forAllClippingPlanes = !forNoClippingPlanes; - } -} - void ON_Layer::SetCustomSectionStyle(const ON_SectionStyle& sectionStyle) { if (nullptr == m_private) diff --git a/opennurbs_layer.h b/opennurbs_layer.h index 0f95f766..ac0357c7 100644 --- a/opennurbs_layer.h +++ b/opennurbs_layer.h @@ -788,39 +788,6 @@ public: // a tree control then the list of child layers is // shown in the control. - // Set objects on layer to participate in clipping for all clipping plane objects. - // This is the default behavior. - void SetClipParticipationForAll(); - - // Set objects on layer to be immune from the clipping for all clipping planes. - void SetClipParticipationForNone(); - - // Set objects on layer to only be clipped by a specific set of clipping planes. - // Paramters: - // clippingPlaneIds [in] - array of ON_UUIDs for clipping planes - // count [in] - number of elements in clippingPlaneIds - // listIsParticipation [in] - is the list clipping planes that the layer - // participates with or an exclusion list of clipping planes to not - // participate with - void SetClipParticipationList(const ON_UUID* clippingPlaneIds, int count, bool listIsParticipation); - - // Get details on how the objects on layer will interact with clipping planes - // Parameters: - // forAllClippingPlanes [out] - if true, the objects interact with all - // clipping planes - // forNoClippingPlanes [out] - if true, the objects are immune from all - // clipping planes - // specificClipplaneList [out] - if the objects interact with only a - // specific set of clipping planes, this list will have the uuids of - // those clipping plane objects - // listIsParticipation [out] - is specificClipplaneList a participation - // list or an exclusion list - void GetClipParticipation( - bool& forAllClippingPlanes, - bool& forNoClippingPlanes, - ON_UuidList& specificClipplaneList, - bool& listIsParticipation) const; - #pragma region Section Attributes // Sections are the product of intersecting a plane with an object. // For surface type geometry (ON_Brep, ON_Extrusion, ON_SubD, ON_Mesh) diff --git a/opennurbs_plane.h b/opennurbs_plane.h index 1b54210e..480ad73c 100644 --- a/opennurbs_plane.h +++ b/opennurbs_plane.h @@ -611,6 +611,21 @@ private: float m_depth = 0; }; +// The only reason this class exists is to maintain extra information on ON_ClippingPlane +// without changing the size of the ON_ClippingPlane class (to not break the SDK). This +// class helps maintain a list of additional information associated with an ON_ClippingPlane. +// Pretend it does not exist +class ON_CLASS ON_ClippingPlaneDataStore +{ +public: + ON_ClippingPlaneDataStore(); + ON_ClippingPlaneDataStore(const ON_ClippingPlaneDataStore& src); + ~ON_ClippingPlaneDataStore(); + ON_ClippingPlaneDataStore& operator=(const ON_ClippingPlaneDataStore& src); + + unsigned int m_sn=0; +}; + class ON_CLASS ON_ClippingPlane { public: @@ -641,16 +656,28 @@ public: bool DepthEnabled() const; void SetDepthEnabled(bool on); + // Default is true + bool ParticipationListsEnabled() const; + void SetParticipationListsEnabled(bool on); + + void SetParticipationLists( + const ON_SimpleArray* objectIds, + const ON_SimpleArray* layerIndices, + bool isExclusionList); + + const ON_UuidList* ObjectClipParticipationList() const; + const ON_SimpleArray* LayerClipParticipationList() const; + bool ClipParticipationListsAreExclusionLists() const; + bool Read( class ON_BinaryArchive& ); bool Write( class ON_BinaryArchive& ) const; private: bool m_depth_enabled = false; - char m_reserved[2]; - - // This should be a double, but is a float in order to not change - // the class size. When the Rhino SDK can break, this data type should change. - float m_depth = 0; + bool m_participation_lists_enabled = true; + char m_reserved; + + ON_ClippingPlaneDataStore m_data_store; }; diff --git a/opennurbs_planesurface.cpp b/opennurbs_planesurface.cpp index 3113df04..4ceb0ab5 100644 --- a/opennurbs_planesurface.cpp +++ b/opennurbs_planesurface.cpp @@ -959,6 +959,172 @@ bool ON_ClippingPlaneInfo::Read( ON_BinaryArchive& file ) return rc; } +class ON_ClippingPlaneData +{ +public: + ON_ClippingPlaneData():m_object_id_list(0){} + bool HasDefaultContent() const; + + unsigned int m_sn=0; + double m_depth = 0; + + ON_UuidList m_object_id_list; + ON_SimpleArray m_layer_list; + bool m_layer_list_is_sorted = true; + bool m_is_exclusion_list = true; +}; + +bool ON_ClippingPlaneData::HasDefaultContent() const +{ + if (m_depth != 0.0) + return false; + + if (m_object_id_list.Count()>0) + return false; + + if (m_layer_list.Count() > 0) + return false; + + if (!m_is_exclusion_list) + return false; + + return true; +} + +static ON_ClassArray g_data_list; +static ON_SleepLock g_data_list_lock; + +static int CompareClippingPlaneData(const ON_ClippingPlaneData* a, const ON_ClippingPlaneData* b) +{ + if (a && b) + { + if (a->m_snm_sn) + return -1; + if (a->m_sn>b->m_sn) + return 1; + return 0; + } + if (a) + return -1; + if (b) + return 1; + return 0; +} + +static int ClippingPlaneDataIndex(unsigned int serialNumber) +{ + if (0==serialNumber) + return -1; + ON_ClippingPlaneData data; + data.m_sn = serialNumber; + int index = g_data_list.BinarySearch(&data, CompareClippingPlaneData); + return index; +} + +static void DeleteClippingPlaneData(ON_ClippingPlaneDataStore& dataStore) +{ + if (dataStore.m_sn>0) + { + bool bReturnLock = g_data_list_lock.GetLock(); + int index = ClippingPlaneDataIndex(dataStore.m_sn); + dataStore.m_sn = 0; + g_data_list.Remove(index); + if(bReturnLock) + g_data_list_lock.ReturnLock(); + } +} + +static ON_ClippingPlaneData* GetClippingPlaneData(unsigned int sn) +{ + if (0==sn) + return nullptr; + + bool bReturnLock = g_data_list_lock.GetLock(); + int index = ClippingPlaneDataIndex(sn); + ON_ClippingPlaneData* rc = g_data_list.At(index); + if(bReturnLock) + g_data_list_lock.ReturnLock(); + return rc; +} + +static ON_ClippingPlaneData* GetClippingPlaneData(ON_ClippingPlaneDataStore& dataStore, bool createIfMissing) +{ + bool bReturnLock = g_data_list_lock.GetLock(); + int index = ClippingPlaneDataIndex(dataStore.m_sn); + ON_ClippingPlaneData* rc = g_data_list.At(index); + if (nullptr==rc && createIfMissing) + { + unsigned int serial_number = 1; + const ON_ClippingPlaneData* last = g_data_list.Last(); + if (last) + serial_number = last->m_sn + 1; + + ON_ClippingPlaneData& data = g_data_list.AppendNew(); + data.m_sn = serial_number; + dataStore.m_sn = data.m_sn; + rc = g_data_list.Last(); + } + if(bReturnLock) + g_data_list_lock.ReturnLock(); + return rc; +} + +ON_ClippingPlaneDataStore::ON_ClippingPlaneDataStore() +{ +} + +ON_ClippingPlaneDataStore::ON_ClippingPlaneDataStore(const ON_ClippingPlaneDataStore& src) +{ + ON_ClippingPlaneData* srcData = GetClippingPlaneData(src.m_sn); + if (srcData) + { + ON_ClippingPlaneData* thisData = GetClippingPlaneData(*this, true); + if (thisData) + { + thisData->m_depth = srcData->m_depth; + thisData->m_object_id_list = srcData->m_object_id_list; + thisData->m_is_exclusion_list = srcData->m_is_exclusion_list; + thisData->m_layer_list = srcData->m_layer_list; + thisData->m_layer_list_is_sorted = srcData->m_layer_list_is_sorted; + } + } + +} + +ON_ClippingPlaneDataStore::~ON_ClippingPlaneDataStore() +{ + DeleteClippingPlaneData(*this); +} + +ON_ClippingPlaneDataStore& ON_ClippingPlaneDataStore::operator=(const ON_ClippingPlaneDataStore& src) +{ + if (0==src.m_sn) + { + DeleteClippingPlaneData(*this); + } + else + { + ON_ClippingPlaneData* srcData = GetClippingPlaneData(src.m_sn); + if (nullptr==srcData) + { + DeleteClippingPlaneData(*this); + } + else + { + ON_ClippingPlaneData* thisData = GetClippingPlaneData(*this, true); + if (thisData) + { + thisData->m_depth = srcData->m_depth; + thisData->m_object_id_list = srcData->m_object_id_list; + thisData->m_is_exclusion_list = srcData->m_is_exclusion_list; + thisData->m_layer_list = srcData->m_layer_list; + thisData->m_layer_list_is_sorted = srcData->m_layer_list_is_sorted; + } + } + } + return *this; +} + void ON_ClippingPlane::Default() { @@ -966,8 +1132,9 @@ void ON_ClippingPlane::Default() m_viewport_ids.Empty(); m_plane_id = ON_nil_uuid; m_bEnabled = true; - m_depth = 0; m_depth_enabled = false; + m_participation_lists_enabled = true; + DeleteClippingPlaneData(m_data_store); } ON_ClippingPlane::ON_ClippingPlane() @@ -977,6 +1144,7 @@ ON_ClippingPlane::ON_ClippingPlane() ON_ClippingPlane::~ON_ClippingPlane() { + DeleteClippingPlaneData(m_data_store); } ON_ClippingPlaneInfo ON_ClippingPlane::ClippingPlaneInfo() const @@ -985,22 +1153,128 @@ ON_ClippingPlaneInfo ON_ClippingPlane::ClippingPlaneInfo() const info.m_plane_equation = m_plane.plane_equation; info.m_plane_id = m_plane_id; info.m_bEnabled = m_bEnabled; - info.SetDepth(m_depth); + info.SetDepth(Depth()); info.SetDepthEnabled(m_depth_enabled); return info; } double ON_ClippingPlane::Depth() const { - return m_depth; + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store.m_sn); + if (data) + return data->m_depth; + return 0; } void ON_ClippingPlane::SetDepth(double depth) { if (depth < 0.0) return; - m_depth = (float)depth; + + if (0.0 == depth) + { + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store.m_sn); + if (data) + { + data->m_depth = depth; + if (data->HasDefaultContent()) + { + DeleteClippingPlaneData(m_data_store); + } + } + return; + } + + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store, true); + if (data) + data->m_depth = depth; } +bool ON_ClippingPlane::ParticipationListsEnabled() const +{ + return m_participation_lists_enabled; +} +void ON_ClippingPlane::SetParticipationListsEnabled(bool on) +{ + m_participation_lists_enabled = on; +} + +void ON_ClippingPlane::SetParticipationLists(const ON_SimpleArray* objectIds, const ON_SimpleArray* layerIndices, bool isExclusionList) +{ + if ((nullptr == objectIds || objectIds->Count() < 1) && + (nullptr==layerIndices || layerIndices->Count()<1) && + isExclusionList) + { + // clear any existing list + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store.m_sn); + if (data) + { + data->m_object_id_list.Empty(); + data->m_layer_list.Empty(); + data->m_layer_list_is_sorted = true; + data->m_is_exclusion_list = isExclusionList; + if (data->HasDefaultContent()) + { + DeleteClippingPlaneData(m_data_store); + } + } + return; + } + + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store, true); + if (data) + { + data->m_object_id_list.Empty(); + data->m_layer_list.Empty(); + data->m_layer_list_is_sorted = true; + if (objectIds) + { + for (int i = 0; i < objectIds->Count(); i++) + { + data->m_object_id_list.AddUuid((*objectIds)[i]); + } + } + if (layerIndices && layerIndices->Count() > 0) + { + data->m_layer_list_is_sorted = false; + data->m_layer_list = (*layerIndices); + } + data->m_is_exclusion_list = isExclusionList; + } +} + + +const ON_UuidList* ON_ClippingPlane::ObjectClipParticipationList() const +{ + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store.m_sn); + if (data) + return &(data->m_object_id_list); + return nullptr; +} + +const ON_SimpleArray* ON_ClippingPlane::LayerClipParticipationList() const +{ + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store.m_sn); + if (data) + { + if (!data->m_layer_list_is_sorted) + { + data->m_layer_list.QuickSort(ON_CompareIncreasing); + data->m_layer_list_is_sorted = true; + } + return &(data->m_layer_list); + } + return nullptr; +} + +bool ON_ClippingPlane::ClipParticipationListsAreExclusionLists() const +{ + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store.m_sn); + if (data) + return data->m_is_exclusion_list; + return true; +} + + bool ON_ClippingPlane::DepthEnabled() const { return m_depth_enabled; @@ -1010,6 +1284,17 @@ void ON_ClippingPlane::SetDepthEnabled(bool on) m_depth_enabled = on; } +enum ON_ClippingPlaneTypeCodes : unsigned char +{ + ClipParticipationObjectList = 10, + ClipParticipationLayerList = 11, + ClipParticipationIsExclusion = 12, + ClipParticipationEnabled = 13, + + // add items here + NextTypeCode +}; + bool ON_ClippingPlane::Read( ON_BinaryArchive& file ) { Default(); @@ -1076,6 +1361,87 @@ bool ON_ClippingPlane::Read( ON_BinaryArchive& file ) if (!rc) break; } + if (minor_version >= 5) + { + unsigned char itemid = 0xFF; + rc = file.ReadChar(&itemid); + if (!rc) break; + if (0 == itemid) + break; + + if (ON_ClippingPlaneTypeCodes::ClipParticipationObjectList == itemid) // 10 + { + int count = 0; + rc = file.ReadInt(&count); + if (!rc) break; + + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store, true); + ON_UUID object_id = ON_nil_uuid; + for (int i = 0; i < count; i++) + { + rc = file.Read3dmReferencedComponentId(ON_ModelComponent::Type::ModelGeometry, &object_id); + if (!rc) break; + if (data) + data->m_object_id_list.AddUuid(object_id); + } + if (!rc) break; + + rc = file.ReadChar(&itemid); + if (!rc || 0 == itemid) break; + } + if (ON_ClippingPlaneTypeCodes::ClipParticipationLayerList == itemid) // 11 + { + int count = 0; + rc = file.ReadInt(&count); + if (!rc) break; + + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store, true); + for (int i = 0; i < count; i++) + { + int layer_index = 0; + rc = file.Read3dmReferencedComponentIndex(ON_ModelComponent::Type::Layer, &layer_index); + if (!rc) break; + + if (data) + { + data->m_layer_list.Append(layer_index); + data->m_layer_list_is_sorted = false; + } + } + if (!rc) break; + + rc = file.ReadChar(&itemid); + if (!rc || 0 == itemid) break; + } + if (ON_ClippingPlaneTypeCodes::ClipParticipationIsExclusion == itemid) // 12 + { + bool exclusion = true; + rc = file.ReadBool(&exclusion); + if (!rc) break; + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store, true); + if (data) + data->m_is_exclusion_list = exclusion; + rc = file.ReadChar(&itemid); + if (!rc || 0 == itemid) break; + } + if (ON_ClippingPlaneTypeCodes::ClipParticipationEnabled == itemid) // 13 + { + rc = file.ReadBool(&m_participation_lists_enabled); + if (!rc) break; + rc = file.ReadChar(&itemid); + if (!rc || 0 == itemid) break; + } + + if (itemid >= ON_ClippingPlaneTypeCodes::NextTypeCode) + { + // we are reading file written with code newer + // than this code (minor_version > 5) + itemid = 0; + } + + break; + } + break; } @@ -1087,7 +1453,9 @@ bool ON_ClippingPlane::Read( ON_BinaryArchive& file ) bool ON_ClippingPlane::Write( ON_BinaryArchive& file ) const { - bool rc = file.BeginWrite3dmChunk(TCODE_ANONYMOUS_CHUNK,1,4); + // 20 May 2023 S. Baer (RH-74763) + // version 1.5 - write clip participation + bool rc = file.BeginWrite3dmChunk(TCODE_ANONYMOUS_CHUNK,1,5); if (!rc) return false; @@ -1116,13 +1484,74 @@ bool ON_ClippingPlane::Write( ON_BinaryArchive& file ) const //version 1.2 - write distance as double //version 1.3 - continue to write distance, but the reader now knows to // interpret the distance value in a different way - rc = file.WriteDouble(m_depth); + double depth = Depth(); + rc = file.WriteDouble(depth); if (!rc) break; //version 1.4 - write enabled flag for depth rc = file.WriteBool(m_depth_enabled); if (!rc) break; + //version 1.5 + ON_ClippingPlaneData* data = GetClippingPlaneData(m_data_store.m_sn); + + if (data && data->m_object_id_list.Count() > 0) + { + const ON_UUID* ids = data->m_object_id_list.Array(); + if (ids) + { + unsigned char c = ON_ClippingPlaneTypeCodes::ClipParticipationObjectList; // 10 + rc = file.WriteChar(c); + if (!rc) break; + + int count = data->m_object_id_list.Count(); + rc = file.WriteInt(count); + if (!rc) break; + + for (int i = 0; i < count; i++) + { + rc = file.Write3dmReferencedComponentId(ON_ModelComponent::Type::ModelGeometry, ids[i]); + if (!rc) break; + } + if (!rc) break; + } + } + if (data && data->m_layer_list.Count() > 0) + { + unsigned char c = ON_ClippingPlaneTypeCodes::ClipParticipationLayerList; // 11 + rc = file.WriteChar(c); + if (!rc) break; + + int count = data->m_layer_list.Count(); + rc = file.WriteInt(count); + if (!rc) break; + for (int i = 0; i < count; i++) + { + int layer_index = data->m_layer_list[i]; + rc = file.Write3dmReferencedComponentIndex(ON_ModelComponent::Type::Layer, layer_index); + if (!rc) break; + } + if (!rc) break; + } + if (data && data->m_is_exclusion_list == false) + { + unsigned char c = ON_ClippingPlaneTypeCodes::ClipParticipationIsExclusion; // 12 + rc = file.WriteChar(c); + if (!rc) break; + rc = file.WriteBool(data->m_is_exclusion_list); + if (!rc) break; + } + if (!m_participation_lists_enabled) + { + unsigned char c = ON_ClippingPlaneTypeCodes::ClipParticipationEnabled; // 13 + rc = file.WriteChar(c); + if (!rc) break; + rc = file.WriteBool(m_participation_lists_enabled); + if (!rc) break; + } + + unsigned char lastTypeCode = 0; + rc = file.WriteChar(lastTypeCode); break; } @@ -1298,4 +1727,3 @@ bool ON_ClippingPlaneSurface::Read( ON_BinaryArchive& file ) return rc; } - diff --git a/opennurbs_public_version.h b/opennurbs_public_version.h index a47c167a..8a7f5109 100644 --- a/opennurbs_public_version.h +++ b/opennurbs_public_version.h @@ -15,9 +15,9 @@ // #define RMA_VERSION_YEAR 2023 #define RMA_VERSION_MONTH 5 -#define RMA_VERSION_DATE 19 -#define RMA_VERSION_HOUR 16 -#define RMA_VERSION_MINUTE 2 +#define RMA_VERSION_DATE 26 +#define RMA_VERSION_HOUR 13 +#define RMA_VERSION_MINUTE 4 //////////////////////////////////////////////////////////////// // @@ -35,8 +35,8 @@ // 3 = build system release build #define RMA_VERSION_BRANCH 0 -#define VERSION_WITH_COMMAS 8,0,23139,16020 -#define VERSION_WITH_PERIODS 8.0.23139.16020 +#define VERSION_WITH_COMMAS 8,0,23146,13040 +#define VERSION_WITH_PERIODS 8.0.23146.13040 #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.23139.16020" -#define RMA_VERSION_WITH_PERIODS_WSTRING L"8.0.23139.16020" +#define RMA_VERSION_WITH_PERIODS_STRING "8.0.23146.13040" +#define RMA_VERSION_WITH_PERIODS_WSTRING L"8.0.23146.13040" diff --git a/opennurbs_subd.cpp b/opennurbs_subd.cpp index b3c7d406..fafba475 100644 --- a/opennurbs_subd.cpp +++ b/opennurbs_subd.cpp @@ -4270,8 +4270,8 @@ bool ON_SubDEdgeSharpness::IsValidValue( { if (candidate_value >= 0.0 && candidate_value <= ON_SubDEdgeSharpness::MaximumValue) return true; - if (bCreaseResult && ON_SubDEdgeSharpness::MaximumValue == candidate_value) - return true; + if ( ON_SubDEdgeSharpness::CreaseValue == candidate_value) + return bCreaseResult; return false; } @@ -5691,6 +5691,46 @@ unsigned int ON_SubDEdge::FaceCount() const return m_face_count; } +ON_SubDEdgeType ON_SubDEdge::EdgeType() const +{ + if (0 == m_face_count) + { + if (ON_SubDEdgeTag::Crease == m_edge_tag) + return ON_SubDEdgeType::Wire; + } + else if (1 == m_face_count) + { + if (ON_SubDEdgeTag::Crease == m_edge_tag) + return ON_SubDEdgeType::Boundary; + } + else if (2 == m_face_count) + { + if (ON_SubDEdgeTag::Crease == m_edge_tag) + return ON_SubDEdgeType::InteriorCrease; + + if (ON_SubDEdgeTag::Smooth == m_edge_tag || ON_SubDEdgeTag::SmoothX == m_edge_tag) + { + if (this->m_sharpness.IsZero()) + return ON_SubDEdgeType::InteriorSmooth; + if (this->m_sharpness.IsSharp()) + return ON_SubDEdgeType::InteriorSharp; + } + } + else if (m_face_count <= ON_SubDEdge::MaximumFaceCount) + { + if (ON_SubDEdgeTag::Crease == m_edge_tag) + return ON_SubDEdgeType::Nonmanifold; + } + + return ON_SubDEdgeType::Invalid; +}; + +ON_SubDEdgeType ON_SubDEdgePtr::EdgeType() const +{ + const ON_SubDEdge* e = ON_SUBD_EDGE_POINTER(m_ptr); + return (nullptr != e) ? e->EdgeType() : ON_SubDEdgeType::Unset; +} + bool ON_SubDEdge::HasBoundaryEdgeTopology() const { for (;;) @@ -22334,10 +22374,12 @@ const ON_SubDEdgePtr ON_SubDEdgeChain::EdgeChainNeighbor( // Look for a single neighbor with same crease/smooth property and same face count // This lets chains turn the right way when there are both creases and smooth // edges. + const double end_sharpness = edge->Sharpness(true)[bReverse ? 0 : 1]; const ON_SubDEdge* nxt = nullptr; for (unsigned short vei = 0; vei < v->m_edge_count; vei++) { - const ON_SubDEdge* e = ON_SUBD_EDGE_POINTER(v->m_edges[vei].m_ptr); + const ON_SubDEdgePtr eptr = v->m_edges[vei]; + const ON_SubDEdge* e = ON_SUBD_EDGE_POINTER(eptr.m_ptr); if (edge == e) continue; if (bIsSmooth != e->IsSmooth()) @@ -22346,6 +22388,12 @@ const ON_SubDEdgePtr ON_SubDEdgeChain::EdgeChainNeighbor( continue; if (e->m_face_count != edge->m_face_count) continue; + + // Dale Lear - 2023 May 23 - added continuous sharpness test + const double nxt_sharpness = e->Sharpness(true)[ON_SUBD_EDGE_DIRECTION(eptr.m_ptr)]; + if (false == (end_sharpness == nxt_sharpness)) + continue; + if (e->m_vertex[0] != v && e->m_vertex[1] != v) continue; // bogus edge if (nullptr == nxt) diff --git a/opennurbs_subd.h b/opennurbs_subd.h index 9385750e..1ad09d3f 100644 --- a/opennurbs_subd.h +++ b/opennurbs_subd.h @@ -199,6 +199,74 @@ enum class ON_SubDEdgeTag : unsigned char }; #pragma endregion +#pragma region RH_C_SHARED_ENUM [ON_SubDEdgeType] [Rhino.Geometry.SubDEdgeType] [byte] +/// +/// ON_SubDEdgeType describes a subdivision edge. +/// ON_SubDEdgeType is typically used when generating text descriptions +/// or filtering edges during selection processes. +/// Do not confuse ON_SubDEdgeType and ON_SubDEdgeTag. +/// The unique types are single bits and suitable for use in bitwise logic. +/// +enum class ON_SubDEdgeType : unsigned char +{ + /// + /// Type is unset or the edge is not valid. + /// + Unset = 0, + + /// + /// The edge has zero faces and the tag is ON_SubDEdgeTag::Crease. + /// + Wire = 1, + + /// + /// The edge has one face and the tag is ON_SubDEdgeTag::Crease. + /// + Boundary = 2, + + /// + /// The edge has two faces, + /// the tag is ON_SubDEdgeTag::Smooth or ON_SubDEdgeTag::SmoothX, + /// and the edge sharpness is zero. + /// Note that ON_SubEdge::IsSmoothNotSharp() returns true if and only if ON_SubEdge::EdgeType() is InteriorSmooth. + /// + InteriorSmooth = 4, + + /// + /// The edge has two faces, + /// the tag is ON_SubDEdgeTag::Smooth or ON_SubDEdgeTag::SmoothX, + /// and the edge sharpness is nonzero. + /// Note that ON_SubEdge::IsSharp() returns true if and only if ON_SubEdge::EdgeType() is InteriorSharp. + /// + InteriorSharp = 8, + + /// + /// The edge has two faces and the tag is ON_SubDEdgeTag::Crease. + /// + InteriorCrease = 16, + + /// + /// The edge has three or more faces and the tag is ON_SubDEdgeTag::Crease. + /// + Nonmanifold = 32, + + /// + /// The edge has an invalid combination of face count, tag, and sharpness properties. + /// + Invalid = 64, + + /// + /// A mask for all interior edge types. Interior edges have 2 faces. + /// + InteriorMask = 28, + + /// + /// A mask for all valid edge types. + /// + ValidTypesMask = 63 +}; +#pragma endregion + #pragma region RH_C_SHARED_ENUM [ON_SubDHashType] [Rhino.Geometry.SubDHashType] [byte] /// /// ON_SubDHashType used used to specify what type of SubD information is hashed (topology or geometry). @@ -1319,6 +1387,17 @@ public: Otherwise, ON_SubDEdgeTag::Unset is returned. */ ON_SubDEdgeTag EdgeTag() const; + + /// + /// EdgeType() is typically used to generate text descriptions and + /// in selection filtering. + /// Do not confuse EdgeType() and EdgeTag(). + /// + /// + /// If Edge() is not nullptr, then Edge()->EdgeType() is returned. + /// Otherwise, ON_SubDEdgeType::Unset is returned. + /// + ON_SubDEdgeType EdgeType() const; /* Returns: @@ -11261,6 +11340,44 @@ public: */ void SetCurvatures() const; + /* + Description: + Computes normal curvature values for this fragment. Evaluation + points are uniformly spaced over the fragment to fill the N, Ku, Kv + arrays. + Parameters: + sample_count - [in] + How many samples to get in both directions. + comb_count_params - [in] + How many combs to get in both directions (+1 if get_first_comb is false). + get_first_comb - [in] + Wheter to skip combs at u = 0 and v = 0. The parameters at which to + get the combs are the same when: + - get_first_comb is true and comb_count is n + - get_first_comb is false and comb_count is n + getKu, getKv - [in] + Should the curvature be computed along u-isos, v-isos, or both. + P, Kuv - [out] + Arrays of size (getKu + getKv) * sample_count * comb_count_arrays where + Points and Curvatures along u-isos or along v-isos are stored. + Sample (i, j) in u direction, on u-dir comb j at sample i is stored + at index i + (j - get_first_comb ? 0 : 1) * sample_count. + Sample (i, j) in v direction, on v-dir comb i at sample j is stored + at index (getKu * sample_count * comb_count_arrays) + j + (i - get_first_comb ? 0 : 1) * sample_count. + Direction u (indexed with i) refers to the Fragment's grid 1st index + (from face->Vertex(0) to face->Vertex(1)). + Direction v (indexed with j) refers to the Fragment's grid 2nd index + (from face->Vertex(0) to face->Vertex(3)). + comb_count_arrays = comb_count_params - get_first_comb ? 1 : 0 + Returns: + Number of points sampled + */ + unsigned GetNormalCurvatures(const unsigned sample_count, + const unsigned comb_count_params, + const bool get_first_comb, const bool getKu, + const bool getKv, ON_SimpleArray* P, + ON_SimpleArray* Kuv) const; + public: // Normalized grid parameters useful for appling a texture to the grid are available @@ -11289,8 +11406,8 @@ public: bool bCurvatureArray ); - public: - void Dump(ON_TextLog& text_log) const; +public: + void Dump(ON_TextLog& text_log) const; }; class ON_CLASS ON_SubDManagedMeshFragment : public ON_SubDMeshFragment @@ -13531,6 +13648,18 @@ public: unsigned int FaceCount() const; + /// + /// EdgeType() is typically used to generate text descriptions and + /// in selection filtering. + /// Do not confuse EdgeType() and EdgeTag(). + /// + /// + /// If the edge has a valid combination of face count, tag, and sharpness properties, + /// then the corresponding type is returned. + /// Otherwise, ON_SubDEdgeType::Invalid is returned. + /// + ON_SubDEdgeType EdgeType() const; + /* Parameters: bRequireSameFaceOrientation - [in] diff --git a/opennurbs_sun.cpp b/opennurbs_sun.cpp index bf4869d1..b82ea0d6 100644 --- a/opennurbs_sun.cpp +++ b/opennurbs_sun.cpp @@ -1447,6 +1447,11 @@ void ON_Sun::UseEarthAnchorPoint(ON_EarthAnchorPoint& eap) _impl->_earth_anchor_point = &eap; } +ON_SunEngine::Accuracy ON_Sun::Accuracy(void) const +{ + return _impl->_accuracy; +} + void ON_Sun::SetAccuracy(ON_SunEngine::Accuracy acc) { _impl->_accuracy = acc; diff --git a/opennurbs_sun.h b/opennurbs_sun.h index 7deab256..411af2d6 100644 --- a/opennurbs_sun.h +++ b/opennurbs_sun.h @@ -257,6 +257,9 @@ public: // For internal use only. virtual void OnInternalXmlChanged(const ON_Sun*); + // Get the accuracy of the sun calculations. The default is minimum accuracy (for more speed). + virtual ON_SunEngine::Accuracy Accuracy(void) const; + // Set the accuracy of the sun calculations. The default is minimum accuracy (for more speed). virtual void SetAccuracy(ON_SunEngine::Accuracy acc); @@ -309,38 +312,4 @@ private: CImpl* _impl; }; -// Class ON_SunExCombine is the same as ON_Sun except that it overrides Azimuth() and Altitude() to calculate -// the sun's azimuth / altitude. -class ON_CLASS ON_SunExCombine : public ON_Sun -{ -public: - ON_SunExCombine(); - ON_SunExCombine(ON_XMLNode& model_node); - ON_SunExCombine(const ON_SunExCombine& sun); - virtual ~ON_SunExCombine(); - - virtual const ON_Sun& operator = (const ON_Sun& sun) override; - virtual const ON_SunExCombine& operator = (const ON_SunExCombine& sun); - - // Returns the azimuth of the sun in the sky (in degrees) as viewed by an observer on Earth. The value - // increases Eastwards with North as zero. This value is not affected by the sun's 'north' setting. - // If manual control is in effect, the stored value is returned. Otherwise the value is computed from the - // values stored in the local date and time, latitude, longitude, time zone and daylight saving settings. - // The stored value is not modified by this method (i.e., it is truly const). - virtual double Azimuth(void) const override; - - // Returns the altitude of the sun in the sky (in degrees) as viewed by an observer on Earth. - // If manual control is in effect, the stored value is returned. Otherwise the value is computed from the - // values stored in the local date and time, latitude, longitude, time zone and daylight saving settings. - // The stored value is not modified by this method (i.e., it is truly const). - virtual double Altitude(void) const override; - -private: // For internal use only. - friend class ON_3dmRenderSettingsPrivate; - -private: - class CImpl; - CImpl* _impl; -}; - #endif diff --git a/opennurbs_xml.cpp b/opennurbs_xml.cpp index 451a758f..634f24a2 100644 --- a/opennurbs_xml.cpp +++ b/opennurbs_xml.cpp @@ -5102,10 +5102,12 @@ ON_UUID uuidPostEffect_ToneMapper_Clamp = { 0xacb8d258, 0xc1d6, 0x499d, { 0xaa, ON_UUID uuidPostEffect_Gamma = { 0x84c0798d, 0xc43a, 0x4402, { 0x88, 0x91, 0xe0, 0xc8, 0x08, 0x8e, 0x67, 0xca } }; ON_UUID chanRGBA = { 0x453a9a1c, 0x9307, 0x4976, { 0xb2, 0x82, 0x4e, 0xad, 0x4d, 0x53, 0x98, 0x79 } }; ON_UUID chanDistanceFromCamera = { 0xb752ce0b, 0xc219, 0x4bdd, { 0xb1, 0x34, 0x26, 0x42, 0x5e, 0x1c, 0x43, 0x31 } }; +#ifdef RDK_RENDER_PRESETS ON_UUID uuidRenderPreset_Studio = { 0x5898cc05, 0x4202, 0x4dfb, { 0x83, 0xfe, 0x8f, 0xa8, 0x8f, 0x91, 0xc7, 0xd6 } }; ON_UUID uuidRenderPreset_Custom = { 0xc89a74fb, 0x1451, 0x4a9b, { 0xb8, 0x7d, 0xe3, 0x0f, 0xf3, 0x51, 0x0f, 0x96 } }; ON_UUID uuidRenderPreset_Exterior = { 0x1346FE79, 0xBF49, 0x4BB6, { 0x86, 0xF4, 0xF2, 0xC2, 0x81, 0xD1, 0xD5, 0x5A } }; ON_UUID uuidRenderPreset_Interior = { 0x14A1D7E9, 0xC75D, 0x464D, { 0xBB, 0x81, 0x38, 0x1C, 0xA2, 0xF1, 0xC9, 0x58 } }; +#endif //------------------------------------------------------------------------------------------------------------------- @@ -5217,8 +5219,10 @@ void ON_RdkDocumentDefaults::CreateXML(void) 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); +#ifdef RDK_RENDER_PRESETS p.SetParam(ON_RDK_CURRENT_RENDER_PRESET, (_major_version < 8) ? uuidRenderPreset_Custom : uuidRenderPreset_Studio); +#endif p.SetParam(ON_RDK_POST_PROCESS_GAMMA_ON, true); p.SetParam(ON_RDK_POST_PROCESS_GAMMA, (_major_version < 6) ? 1.0f : 2.2f); p.SetParam(ON_RDK_PRE_PROCESS_GAMMA_ON, (_major_version < 6) ? false : true); @@ -5232,10 +5236,12 @@ void ON_RdkDocumentDefaults::CreateXML(void) p.SetParam(ON_RDK_CUSTOM_REFLECTIVE_ENVIRONMENT_ON, false); } +#ifdef RDK_RENDER_PRESETS if (_major_version < 8) { p.SetParam(ON_RDK_CURRENT_RENDER_PRESET, uuidRenderPreset_Custom); } +#endif } }