Remove total childen count from everywhere (#359)

This commit is contained in:
Oğuzhan Koral
2024-08-08 15:42:37 +03:00
committed by GitHub
parent a81a723ba8
commit 526e497037
53 changed files with 17 additions and 81 deletions
@@ -51,7 +51,7 @@ module SpeckleConnector3
base[:renderMaterialProxies] = unpacked_materials
base[:colorProxies] = unpacked_colors
id, total_children_count, batches, refs = converter.serialize(base, state.user_state.preferences)
id, batches, refs = converter.serialize(base, state.user_state.preferences)
new_speckle_state = new_speckle_state.with_object_references(model_card.project_id, refs)
new_speckle_state = new_speckle_state.with_empty_changed_entity_persistent_ids
new_speckle_state = new_speckle_state.with_empty_changed_entity_ids
@@ -73,7 +73,6 @@ module SpeckleConnector3
sendConversionResults: converter.conversion_results,
sendObject: {
id: id,
totalChildrenCount: total_children_count,
batches: batches
}
}
@@ -21,7 +21,7 @@ module SpeckleConnector3
state = DeactivateDiffing.update_state(state, nil, {})
converter = Converters::ToSpeckle.new(state, @stream_id, {})
new_speckle_state, base = converter.convert_selection_to_base
id, total_children_count, batches = converter.serialize(base, state.user_state.preferences)
id, batches = converter.serialize(base, state.user_state.preferences)
# TODO: Later active send operation.
# Operations.send(@stream_id, batches)
@@ -35,7 +35,7 @@ module SpeckleConnector3
new_state.with_add_queue('convertedFromSketchup', @stream_id, [
{ is_string: false, val: batches },
{ is_string: true, val: id },
{ is_string: false, val: total_children_count }
{ is_string: false, val: 0 }
])
end
end
@@ -11,7 +11,6 @@ module SpeckleConnector3
SPECKLE_ID = 'speckle_id'
SPECKLE_TYPE = 'speckle_type'
APPLICATION_ID = 'application_id'
TOTAL_CHILDREN_COUNT = 'total_children_count'
CHILDREN = 'children'
PARENT = 'parent'
VALID_STREAM_IDS = 'valid_stream_ids'
@@ -39,10 +39,6 @@ module SpeckleConnector3
id
end
def total_children_count(id)
@objects[id][:totalChildrenCount]
end
# @param base [Object] base object to populate all children and their relationship
# rubocop:disable Metrics/MethodLength
def traverse_base(base)
@@ -72,9 +68,6 @@ module SpeckleConnector3
end
end
# 6. Add total children count
traversed_base[:totalChildrenCount] = closure.keys.length
# 7. Finally create id
id = get_id(traversed_base)
@@ -82,7 +75,7 @@ module SpeckleConnector3
traversed_base[:id] = id
# 9. Update __closure table on the traversed base
unless traversed_base[:totalChildrenCount].nil?
unless closure.empty?
@closure_table[id] = closure
traversed_base[:__closure] = closure unless closure.empty?
end
@@ -33,10 +33,6 @@ module SpeckleConnector3
return id, traversed
end
def total_children_count(id)
@objects[id][:totalChildrenCount]
end
# @param base [Object] base object to populate all children and their relationship
# rubocop:disable Metrics/MethodLength
def traverse_base(base)
@@ -64,9 +60,6 @@ module SpeckleConnector3
end
end
# 6. Add total children count
traversed_base[:totalChildrenCount] = closure.keys.length
# 7. Finally create id
id = get_id(traversed_base)
@@ -74,9 +67,9 @@ module SpeckleConnector3
traversed_base[:id] = id
# 9. Update __closure table on the traversed base
unless traversed_base[:totalChildrenCount].nil?
unless closure.empty?
@closure_table[id] = closure
traversed_base[:__closure] = closure unless closure.empty?
traversed_base[:__closure] = closure
end
# 10. Save object string if detached
@@ -77,7 +77,7 @@ module SpeckleConnector3
COLLECTION = SpeckleObjects::Speckle::Core::Models::Collection
GIS_LAYER_COLLECTION = SpeckleObjects::Speckle::Core::Models::GisLayerCollection
BASE_OBJECT_PROPS = %w[applicationId id speckle_type totalChildrenCount].freeze
BASE_OBJECT_PROPS = %w[applicationId id speckle_type].freeze
CONVERTABLE_SPECKLE_TYPES = %w[
Objects.Geometry.Line
Objects.Geometry.Polyline
@@ -90,7 +90,7 @@ module SpeckleConnector3
LAYER_COLLECTION = SpeckleObjects::Speckle::Core::Models::LayerCollection
GIS_LAYER_COLLECTION = SpeckleObjects::Speckle::Core::Models::GisLayerCollection
BASE_OBJECT_PROPS = %w[applicationId id speckle_type totalChildrenCount].freeze
BASE_OBJECT_PROPS = %w[applicationId id speckle_type].freeze
CONVERTABLE_SPECKLE_TYPES = %w[
Objects.Geometry.Line
Objects.Geometry.Polyline
@@ -61,7 +61,7 @@ module SpeckleConnector3
# Serialized and traversed information to send batches.
# @param base_and_entity [SpeckleObjects::Base] base object to serialize.
# @return [String, Integer, Array<Object>] base id, total_children_count of base and batches
# @return [String, Integer, Array<Object>] base id of base and batches
def serialize(base_and_entity, preferences)
serializer = SpeckleConnector3::Converters::BaseObjectSerializer.new(preferences)
t = Time.now.to_f
@@ -69,8 +69,7 @@ module SpeckleConnector3
batches = serializer.batch_json_objects
write_to_speckle_folder(id, batches)
puts "Generating traversed object elapsed #{(Time.now.to_f - t).round(5)} s"
base_total_children_count = serializer.total_children_count(id)
return id, base_total_children_count, batches, serializer.object_references
return id, batches, serializer.object_references
end
def write_to_speckle_folder(id, batches)
@@ -61,7 +61,7 @@ module SpeckleConnector3
# Serialized and traversed information to send batches.
# @param base_and_entity [SpeckleObjects::Base] base object to serialize.
# @return [String, Integer, Array<Object>] base id, total_children_count of base and batches
# @return [String, Integer, Array<Object>] base id of base and batches
def serialize(base_and_entity, preferences)
serializer = SpeckleConnector3::Converters::BaseObjectSerializer.new(preferences)
t = Time.now.to_f
@@ -69,8 +69,7 @@ module SpeckleConnector3
batches = serializer.batch_json_objects
write_to_speckle_folder(id, batches)
puts "Generating traversed object elapsed #{(Time.now.to_f - t).round(5)} s"
base_total_children_count = serializer.total_children_count(id)
return id, base_total_children_count, batches, serializer.object_references
return id, batches, serializer.object_references
end
def write_to_speckle_folder(id, batches)
@@ -20,7 +20,6 @@ module SpeckleConnector3
SPECKLE_ID => id,
APPLICATION_ID => application_id,
SPECKLE_TYPE => speckle_type,
TOTAL_CHILDREN_COUNT => children.length,
CHILDREN => children,
VALID_STREAM_IDS => [stream_id],
INVALID_STREAM_IDS => []
@@ -22,9 +22,6 @@ module SpeckleConnector3
# @return [String] id of the Speckle Base Object
attr_reader :id
# @return [Integer] total children count of the Speckle Base Object
attr_reader :total_children_count
# @return [Hash{String=>SpeckleObjects::Base}] Speckle objects belongs to edge
attr_reader :speckle_children_objects
@@ -51,7 +48,6 @@ module SpeckleConnector3
@sketchup_entity = sketchup_entity
@application_id = application_id
@id = speckle_id
@total_children_count = children.nil? ? 0 : children.length
@speckle_type = speckle_type
@speckle_children_objects = children.nil? ? [] : children
end
@@ -9,18 +9,16 @@ module SpeckleConnector3
class Base < Hash
include Immutable::ImmutableUtils
attr_reader :speckle_type, :application_id, :total_children_count, :id
attr_reader :speckle_type, :application_id, :id
def initialize(speckle_type: 'Base', total_children_count: 0, application_id: nil, id: '')
def initialize(speckle_type: 'Base', application_id: nil, id: '')
@speckle_type = speckle_type
@total_children_count = total_children_count
@application_id = application_id
@id = id
super()
update(
{
speckle_type: speckle_type,
totalChildrenCount: total_children_count,
applicationId: application_id,
id: id
}
@@ -15,7 +15,6 @@ module SpeckleConnector3
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -15,7 +15,6 @@ module SpeckleConnector3
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -15,7 +15,6 @@ module SpeckleConnector3
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -18,7 +18,6 @@ module SpeckleConnector3
def initialize(outline:, voids:, units:, material:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -15,7 +15,6 @@ module SpeckleConnector3
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -20,7 +20,6 @@ module SpeckleConnector3
def initialize(base_line:, height:, flipped:, units:, material:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -18,7 +18,6 @@ module SpeckleConnector3
def initialize(name:, elevation:, units:, element_id:, application_id: nil, id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: id
)
@@ -24,7 +24,6 @@ module SpeckleConnector3
def initialize(name:, category:, units:, base_geometries:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -15,7 +15,6 @@ module SpeckleConnector3
def initialize(family:, type:, level:, units:, base_point:, rotation:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -13,7 +13,6 @@ module SpeckleConnector3
def initialize(name:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: id
)
@@ -17,7 +17,6 @@ module SpeckleConnector3
def initialize(family:, type:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -17,7 +17,6 @@ module SpeckleConnector3
def initialize(family:, type:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -17,7 +17,6 @@ module SpeckleConnector3
def initialize(family:, type:, height:, width:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -14,7 +14,6 @@ module SpeckleConnector3
def initialize(category:, family:, type:, element_id:, application_id: nil, id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: id
)
@@ -19,7 +19,6 @@ module SpeckleConnector3
def initialize(family:, type:, outline:, voids:, level:, units:, material:, parameters:nil, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -17,7 +17,6 @@ module SpeckleConnector3
def initialize(family:, type:, diameter:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -20,7 +20,6 @@ module SpeckleConnector3
def initialize(family:, type:, base_line:, height:, flipped:, level:, units:, material:, parameters: nil, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -29,7 +29,6 @@ module SpeckleConnector3
is_perspective, lens, units, application_id, update_properties, rendering_options)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -27,7 +27,6 @@ module SpeckleConnector3
def initialize(sketchup_color, value, object_ids, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -18,7 +18,6 @@ module SpeckleConnector3
def initialize(x_size, y_size, z_size, base_plane)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -25,7 +25,6 @@ module SpeckleConnector3
sketchup_attributes: {}, speckle_schema: {}, application_id: nil)
super(
speckle_type: 'Objects.Geometry.Line',
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -38,7 +38,6 @@ module SpeckleConnector3
sketchup_attributes:, layer:, speckle_schema: {}, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -19,7 +19,6 @@ module SpeckleConnector3
def initialize(x_dir, y_dir, normal, origin, units)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -17,7 +17,6 @@ module SpeckleConnector3
def initialize(x, y, z, units)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -23,7 +23,6 @@ module SpeckleConnector3
def initialize(value:, domain:, length:, closed:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -17,7 +17,6 @@ module SpeckleConnector3
def initialize(x, y, z, units)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -20,7 +20,7 @@ module SpeckleConnector3
def self.get_qgis_attributes(obj)
attributes = obj['attributes'].to_h
speckle_properties = %w[id speckle_type totalChildrenCount units applicationId]
speckle_properties = %w[id speckle_type units applicationId]
speckle_properties.each { |key| attributes.delete(key) }
attributes
end
@@ -23,7 +23,6 @@ module SpeckleConnector3
def initialize(definition, object_ids, max_depth, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -11,7 +11,6 @@ module SpeckleConnector3
def initialize(definition_id, transform, max_depth, units, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -26,7 +26,6 @@ module SpeckleConnector3
speckle_schema: {}, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -31,7 +31,6 @@ module SpeckleConnector3
sketchup_attributes: {}, speckle_schema: {}, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -12,7 +12,6 @@ module SpeckleConnector3
def initialize(name:, color:, line_type:)
super(
speckle_type: OBJECTS_OTHER_DISPLAYSTYLE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -11,7 +11,6 @@ module SpeckleConnector3
def initialize(category:, units:, instance:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -23,7 +23,6 @@ module SpeckleConnector3
sketchup_attributes: {}, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -16,7 +16,6 @@ module SpeckleConnector3
def initialize(units:, value:)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -16,7 +16,6 @@ module SpeckleConnector3
def initialize(units:, start_value:, end_value:)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -16,7 +16,6 @@ module SpeckleConnector3
application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -14,7 +14,6 @@ module SpeckleConnector3
def initialize(active:, layers:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: nil,
id: nil
)
@@ -24,7 +24,6 @@ module SpeckleConnector3
def initialize(sketchup_material, value, object_ids, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
@@ -17,7 +17,6 @@ module SpeckleConnector3
def initialize(name:, collection_type:, elements: [], application_id: nil)
super(
speckle_type: SPECKLE_CORE_MODELS_COLLECTION,
total_children_count: 0,
application_id: application_id,
id: nil
)
+2 -2
View File
@@ -18,7 +18,7 @@ module SpeckleConnector3
base = Base.new
json = base.to_json
base_obj = {"speckle_type":"Base","totalChildrenCount":0,"applicationId":nil,"id":nil}
base_obj = {"speckle_type":"Base","applicationId":nil,"id":nil}
serialized = JSON.generate(base_obj)
assert_equal(json, serialized)
@@ -29,7 +29,7 @@ module SpeckleConnector3
base[:sketchup_attributes] = {soften_edge: true}
base[:id] = 'idididididid'
base_obj = {"speckle_type":"Base","totalChildrenCount":0,"applicationId":nil,"id":'idididididid', "sketchup_attributes": {"soften_edge": true }}
base_obj = {"speckle_type":"Base","applicationId":nil,"id":'idididididid', "sketchup_attributes": {"soften_edge": true }}
serialized = JSON.generate(base_obj)
hash = JSON.parse(serialized, { symbolize_names: true })