Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified strategy for GUID, Hash, and Copy/DeepCopy #9

Closed
5 tasks done
alelom opened this issue Aug 11, 2020 · 29 comments
Closed
5 tasks done

Unified strategy for GUID, Hash, and Copy/DeepCopy #9

alelom opened this issue Aug 11, 2020 · 29 comments
Assignees
Labels
type:feature New capability or enhancement type:question Ask for further details or start conversation

Comments

@alelom
Copy link
Member

alelom commented Aug 11, 2020

We need a unified strategy as title. In light of the meeting tomorrow morning, we should go through the following points:

  • Go through the definitions in Diffing_Engine: review the structure/organisation of the identifiers #8. Make sure we're all on the same page. --> good conclusions and revision of some definitions
  • hash to be considered a more "base" property of BHoMObjects ? --> not needed, calculate upon necessity
  • Make sure the Modify Engine methods do not alter the BHoM_Guid. The object must not be re-instantiated, but always cloned.
    • Have a CI check on it?
    • Actually forcing this at a framework level, avoiding to rely on the implementer of the method? We could always force a clone when passing inputs to Modify Engine methods.
      --> Responsibility moved at the level of the UI in @adecler 's latest PR; @adecler to raise an issue to review where deepclone is used everywhere
  • BH.Engine.Base.Query.ShallowClone() vs BH.Engine.Base.Query.DeepClone() vs BH.oM.Base.GetShallowClone(). Agree whether it's best to keep all three of them or not.
    --> attribute on the Modify method to decide whether to do deepclone or shallowclone. By default, deepclone @adecler
    --> pull 200/500/1000 panels from revit --> check deepclone efficiency @IsakNaslundBh , @pawelbaran
    --> exclude the fragments/customdata from the deepclone in the UI level
    --> we can remove the BH.oM.Base.GetShallowClone() as the Query.ShallowClone() now relies on the Deepcloner extension
  • Move the Hash generation as up as possible - Base Engine would probably be problematic, but consider the Serialisation Engine, or another Engine called something more specific like "Hashing Engine". Diffing is too specific to the diffing. @al-fisher @alelom
  • @pawelbaran note: SetProperty - hash would be preferred way

Instructions for the changes on Clone methods can be found on this comment below: #9 (comment)

@alelom alelom added type:feature New capability or enhancement type:question Ask for further details or start conversation labels Aug 11, 2020
@adecler
Copy link
Member

adecler commented Oct 6, 2020

I'll create the list of methods calling DeepClone and ShallowClone soon.

@adecler
Copy link
Member

adecler commented Oct 7, 2020

First, here's the list of methods that contain Clone in their name and are called by at least on non-clone method:

BH.oM.Base.BHoMObject.GetShallowClone
BH.Engine.Base.Query.DeepClone
BH.oM.Base.IBHoMObject.GetShallowClone
BH.Engine.Geometry.Query.Clone
BH.Engine.Geometry.Query.IClone
BH.Engine.Base.Query.ShallowClone

The ShallowClone methods could probably do with a bit of clearing.

@adecler
Copy link
Member

adecler commented Oct 7, 2020

Here's the list of Modify methods that are calling one of the Clone methods above:

Full list

BH.Engine.Adapters.ETABS.Modify.SetDiaphragm(Panel panel, Diaphragm diaphragm)
BH.Engine.Adapters.ETABS.Modify.SetPier(Panel panel, Pier pier)
BH.Engine.Adapters.ETABS.Modify.SetShellType(ISurfaceProperty property, ShellType shellType)
BH.Engine.Adapters.ETABS.Modify.SetSpandrel(Panel panel, Spandrel spandrel)
BH.Engine.Adapters.Filing.Modify.AddContent(FSFile file, List<Object> content)
BH.Engine.Adapters.Filing.Modify.ChangeDirectory(IFSContainer fileOrDir, FSDirectory to)
BH.Engine.Adapters.Filing.Modify.RemoveContent(FSFile file)
BH.Engine.Adapters.Filing.Modify.Rename(IFSContainer fileOrDir, String name)
BH.Engine.Adapters.GSA.Modify.SetAnalysisType(LoadCombination loadcombination, AnalysisType analysisType, Int32 stage)
BH.Engine.Adapters.IES.Modify.RepairOpening(Opening opening, Panel host, List<Panel> panelsAsSpace)
BH.Engine.Adapters.IES.Modify.RepairOpening(Opening opening, Panel hostPanel, PanelType hostType)
BH.Engine.Adapters.Plaxis.Modify.ApplyPlaxisStiffnessModifier(ConstantThickness thicknessProperty, Double e1Factor, Double e2Factor, and 4 more inputs)
BH.Engine.Adapters.Plaxis.Modify.ApplyPlaxisStiffnessModifier(Panel panel, Double e1Factor, Double e2Factor, and 4 more inputs)
BH.Engine.Adapters.Revit.Modify.AddParameterLinks(ParameterMap parameterMap, and 2 more inputs)
BH.Engine.Adapters.Revit.Modify.AddParameterLinks(ParameterSettings parameterSettings, Type type, and 2 more inputs)
BH.Engine.Adapters.Revit.Modify.AddParameterMaps(ParameterSettings parameterSettings, IEnumerable<ParameterMap> parameterMaps, Boolean merge)
BH.Engine.Adapters.Revit.Modify.Append(FamilyLibrary familyLibrary, String directory, Boolean topDirectoryOnly)
BH.Engine.Adapters.Revit.Modify.Append(FamilyLibrary familyLibrary, String path)
BH.Engine.Adapters.Revit.Modify.Move(ModelInstance modelInstance, Vector vector)
BH.Engine.Adapters.Revit.Modify.RemoveIdentifiers(IBHoMObject bHoMObject)
BH.Engine.Adapters.Revit.Modify.RemoveParameterLinks(ParameterMap parameterMap, IEnumerable<String> propertyNames)
BH.Engine.Adapters.Revit.Modify.RemoveParameterLinks(ParameterSettings parameterSettings, Type type, IEnumerable<String> propertyNames)
BH.Engine.Adapters.Revit.Modify.RemoveParameterMaps(ParameterSettings parameterSettings, IEnumerable<Type> types)
BH.Engine.Adapters.Revit.Modify.SetFamilyLibrary(FamilyLoadSettings familyLoadSettings, FamilyLibrary familyLibrary)
BH.Engine.Adapters.Revit.Modify.SetFamilyLibrary(RevitSettings revitSettings, FamilyLibrary familyLibrary)
BH.Engine.Adapters.Revit.Modify.SetMapSettings(RevitSettings revitSettings, ParameterSettings mapSettings)
BH.Engine.Adapters.Revit.Modify.SetRevitParameter(IBHoMObject bHoMObject, String paramName, Object value)
BH.Engine.Adapters.Revit.Modify.SetRevitParameters(IBHoMObject bHoMObject, List<String> paramNames, List<Object> values)
BH.Engine.Adapters.Revit.Modify.SetTag(IBHoMObject bHoMObject, String tag)
BH.Engine.Adapters.Revit.Modify.UpdateCustomDataValue(IBHoMObject bHoMObject, String name, Object value)
BH.Engine.Adapters.TAS.Modify.SetTag(IBHoMObject bHoMObject, String tag)
BH.Engine.Adapters.TAS.Modify.UpdateCustomDataValue(IBHoMObject bHoMObject, String name, Object value)
BH.Engine.Analytical.Modify.SetElements0D(ILink<TNode> link, List<IElement0D> newElements0D)
BH.Engine.Analytical.Modify.SetGeometry(IEdge edge, ICurve curve)
BH.Engine.Analytical.Modify.SetGeometry(ILink<TNode> link, ICurve curve)
BH.Engine.Analytical.Modify.SetGeometry(INode node, Point point)
BH.Engine.Analytical.Modify.SetInternalElements2D(IPanel<TEdge, TOpening> panel, List<IElement2D> openings)
BH.Engine.Analytical.Modify.SetOutlineElements1D(IOpening<TEdge> opening, IEnumerable<IElement1D> edges)
BH.Engine.Analytical.Modify.SetOutlineElements1D(IPanel<TEdge, TOpening> panel, IEnumerable<IElement1D> edges)
BH.Engine.Analytical.Modify.SetOutlineElements1D(IRegion region, IEnumerable<IElement1D> outlineElements)
BH.Engine.Architecture.Modify.CleanRoom(Room room, Double angleTolerance, Double minimumSegmentLength)
BH.Engine.Architecture.Modify.SetGeometry(Grid grid, ICurve curve)
BH.Engine.Architecture.Modify.SetGeometry(Room room, Point locationPoint, ICurve perimeterCurve)
BH.Engine.Architecture.Modify.SetOutlineElements1D(Room room, List<IElement1D> outlineElements1D)
BH.Engine.Audience.Modify.Cut(SeatingBay seatingBay, List<ICurve> cutters, Boolean keepOutside, and 1 more inputs)
BH.Engine.Audience.Modify.Cut(Stand stand, List<ICurve> cutters, Boolean keepOutside, and 1 more inputs)
BH.Engine.Audience.Modify.MapProfile(TierProfile originalSection, Vector scale, Point source, and 2 more inputs)
BH.Engine.Audience.Modify.ReorderBays(SeatFrontPlan seatFrontPlan, Int32 shift)
BH.Engine.Audience.Modify.ReorderBays(VenueSeating venueSeating, Int32 shift)
BH.Engine.Audience.Modify.SeatingBayRows(SeatingBay seatingBay)
BH.Engine.Base.Modify.AddFragment(IBHoMObject iBHoMObject, IFragment fragment, Boolean replace)
BH.Engine.Base.Modify.RemoveFragment(IBHoMObject iBHoMObject, Type fragmentType)
BH.Engine.CableNetDesign.Modify.SetNbCables(GravityCableNet cableNet, Int32 nbTensionRingCables, Int32 nbRadialCables)
BH.Engine.CableNetDesign.Modify.SetPrestress(Bar bar, Double prestress, Boolean keepExactForce)
BH.Engine.CableNetDesign.Modify.SetSlackLength(Bar bar, Double slackLength, Boolean keepExactForce)
BH.Engine.CableNetDesign.Modify.SetSlackLengthScale(Bar bar, Double slackLengthScale, Boolean keepExactForce)
BH.Engine.CableNetDesign.Modify.SizeCable(Bar bar, BarForce force, Double factorOfSaftey, and 2 more inputs)
BH.Engine.CableNetDesign.Modify.SizeCables(GravityCableNet cableNet, Double factorOfSafety, Double contingency, and 1 more inputs)
BH.Engine.CableNetDesign.Modify.SizeCableSection(CableSection section, BarForce force, Double factorOfSafety, and 2 more inputs)
BH.Engine.Diffing.Modify.SetHashFragment(T obj, DiffConfig diffConfig)
BH.Engine.Diffing.Modify.SetHashFragment(T obj, String hash)
BH.Engine.Environment.Modify.AddAdjacentSpace(Panel panel, String spaceName)
BH.Engine.Environment.Modify.AddOpening(Panel panel, Opening opening)
BH.Engine.Environment.Modify.AssignGenericConstructions(Opening opening)
BH.Engine.Environment.Modify.AssignGenericConstructions(Panel panel, Boolean assignOpenings)
BH.Engine.Environment.Modify.ChangeAdjacentSpace(Panel panel, String spaceNameToChange, String replacementSpaceName)
BH.Engine.Environment.Modify.Copy(Panel panel)
BH.Engine.Environment.Modify.FixNormal(List<List<Panel>> panelsAsSpaces)
BH.Engine.Environment.Modify.RemoveOpening(List<Panel> panels)
BH.Engine.Environment.Modify.RemoveOpeningsByName(List<Panel> panels, String openingName)
BH.Engine.Environment.Modify.SetAdjancentSpaces(Panel panel, List<String> spaceNames)
BH.Engine.Environment.Modify.SetGeometry(Edge edge, ICurve curve)
BH.Engine.Environment.Modify.SetGeometry(Node node, Point point)
BH.Engine.Environment.Modify.SetGeometry(Opening opening, ICurve curve)
BH.Engine.Environment.Modify.SetGeometry(Panel panel, ICurve curve)
BH.Engine.Environment.Modify.SetGeometry(Space space, Point locationPoint)
BH.Engine.Environment.Modify.SetInternalElements2D(Panel panel, List<IElement2D> internalElements2D)
BH.Engine.Environment.Modify.SetOpeningType(List<Opening> openings, OpeningType openingType)
BH.Engine.Environment.Modify.SetOutlineElements1D(Opening opening, List<IElement1D> outlineElements1D)
BH.Engine.Environment.Modify.SetOutlineElements1D(Panel panel, List<IElement1D> outlineElements1D)
BH.Engine.Environment.Modify.SetOutlineElements1D(Space space, List<IElement1D> outlineElements1D)
BH.Engine.Environment.Modify.Split(List<Panel> panels)
BH.Engine.Environment.Modify.Split(Panel panel, List<Line> cuttingLines)
BH.Engine.Environment.Modify.Split(Panel panel, Panel cuttingPanel)
BH.Engine.Environment.Modify.SplitOpeningByGeometry(Opening opening, List<Polyline> polylines)
BH.Engine.Environment.Modify.SplitPanelByGeometry(Panel panel, List<Polyline> polylines)
BH.Engine.FormFinding.Modify.AddBoundaryCondition(RelaxSystem system, IBoundaryCondition bc, Double tolerance)
BH.Engine.FormFinding.Modify.AddForceObject(RelaxSystem system, IForceObject forceObject, Double tolerance)
BH.Engine.FormFinding.Modify.MergeUnaryForces(RelaxSystem system)
BH.Engine.Geometry.Modify.CollapseToPolyline(Polyline curve, Double angleTolerance, Int32 maxSegmentCount)
BH.Engine.Geometry.Modify.Flip(NurbsCurve curve)
BH.Engine.Geometry.Modify.Normalise(Vector vector)
BH.Engine.Geometry.Modify.Offset(Arc curve, Double offset, Vector normal, and 2 more inputs)
BH.Engine.Geometry.Modify.Offset(Circle curve, Double offset, Vector normal, and 2 more inputs)
BH.Engine.Geometry.Modify.Project(Circle circle, Plane p)
BH.Engine.Geometry.Modify.ProjectAlong(Circle circle, Plane plane, Vector vector)
BH.Engine.Geometry.Modify.SetGeometry(Arc curve, ICurve newCurve)
BH.Engine.Geometry.Modify.SetGeometry(Circle curve, ICurve newCurve)
BH.Engine.Geometry.Modify.SetGeometry(Ellipse curve, ICurve newCurve)
BH.Engine.Geometry.Modify.SetGeometry(Grid grid, ICurve curve)
BH.Engine.Geometry.Modify.SetGeometry(Line curve, ICurve newCurve)
BH.Engine.Geometry.Modify.SetGeometry(NurbsCurve curve, ICurve newCurve)
BH.Engine.Geometry.Modify.SetGeometry(Point point, Point newPoint)
BH.Engine.Geometry.Modify.SetGeometry(PolyCurve curve, ICurve newCurve)
BH.Engine.Geometry.Modify.SetGeometry(Polyline curve, ICurve newCurve)
BH.Engine.Geometry.Modify.SortCurves(PolyCurve curve, Double tolerance)
BH.Engine.Geometry.Modify.SplitAtPoints(Arc arc, List<Point> points, Double tolerance)
BH.Engine.Geometry.Modify.SplitAtPoints(Circle circle, List<Point> points, Double tolerance)
BH.Engine.Geometry.Modify.SplitAtPoints(Line line, List<Point> points, Double tolerance)
BH.Engine.Geometry.Modify.SplitAtPoints(PolyCurve curve, List<Point> points, Double tolerance)
BH.Engine.Geometry.Modify.SplitAtPoints(Polyline curve, List<Point> points, Double tolerance)
BH.Engine.Geometry.Modify.Translate(Circle curve, Vector transform)
BH.Engine.Geometry.Modify.Translate(Extrusion surface, Vector transform)
BH.Engine.Geometry.Modify.Translate(Plane plane, Vector transform)
BH.Engine.MEP.Modify.SetGeometry(IFlow obj, ICurve curve)
BH.Engine.MEP.Modify.SetGeometry(Node node, Point point)
BH.Engine.ModelLaundry.Modify.SnapToElements(IElement0D element0D, IEnumerable<IElement> refElements, Double maxDistance, and 1 more inputs)
BH.Engine.Physical.Modify.SetGeometry(IFramingElement framingElement, ICurve curve)
BH.Engine.Physical.Modify.SetInternalElements2D(ISurface surface, List<IElement2D> internalElements2D)
BH.Engine.Physical.Modify.SetOutlineElements1D(IOpening opening, List<IElement1D> outlineElements1D)
BH.Engine.Physical.Modify.SetOutlineElements1D(ISurface surface, List<IElement1D> outlineElements1D)
BH.Engine.Reflection.Modify.PropertyValue(BHoMObject obj, String propName, Object value)
BH.Engine.Representation.Modify.SetRendermesh(IBHoMObject bHoMObject, IGeometry representation, String customDataKey)
BH.Engine.Spatial.Modify.SetInternalElements2D(IElement2D element2D, List<IElement2D> newElements2D)
BH.Engine.Structure.Bridges.Modify.SetProperties(Ladder ladder, ISectionProperty primaryMember, ISectionProperty crossMember, and 3 more inputs)
BH.Engine.Structure.Bridges.Modify.SetProperties(Truss truss, ISectionProperty topChord, ISectionProperty bottomChord, and 4 more inputs)
BH.Engine.Structure.Elements.Modify.SetCutback(IFramingElement framingElement, Double start, Double end)
BH.Engine.Structure.Elements.Modify.SetEndNormals(IFramingElement framingElement, Vector start, Vector end)
BH.Engine.Structure.Modify.AddReinforcement(ConcreteSection section, and 1 more inputs)
BH.Engine.Structure.Modify.ApplyModifiers(ISectionProperty prop, Double area, Double iy, and 4 more inputs)
BH.Engine.Structure.Modify.ApplyModifiers(ISurfaceProperty prop, Double fxx, Double fxy, and 8 more inputs)
BH.Engine.Structure.Modify.Flip(Bar bar)
BH.Engine.Structure.Modify.Flip(Edge edge)
BH.Engine.Structure.Modify.OrientTowards(FEMesh mesh, Point orientationPoint)
BH.Engine.Structure.Modify.SetElements0D(Bar bar, List<IElement0D> newElements0D)
BH.Engine.Structure.Modify.SetGeometry(Bar bar, ICurve curve)
BH.Engine.Structure.Modify.SetGeometry(Edge edge, ICurve curve)
BH.Engine.Structure.Modify.SetGeometry(Node node, Point point)
BH.Engine.Structure.Modify.SetGeometry(Surface strSurface, ISurface geoSurface)
BH.Engine.Structure.Modify.SetInternalElements2D(Panel panel, List<IElement2D> openings)
BH.Engine.Structure.Modify.SetLocalOrientation(FEMeshFace face, FEMesh mesh, Vector localX)
BH.Engine.Structure.Modify.SetLocalOrientation(Panel panel, Vector localX)
BH.Engine.Structure.Modify.SetLocalOrientations(FEMesh mesh, Vector localX)
BH.Engine.Structure.Modify.SetMaterial(Bar bar, IMaterialFragment material)
BH.Engine.Structure.Modify.SetNormal(Bar bar, Vector normal)
BH.Engine.Structure.Modify.SetOutlineElements1D(Opening opening, List<IElement1D> edges)
BH.Engine.Structure.Modify.SetOutlineElements1D(Panel panel, List<IElement1D> edges)
BH.Engine.Structure.Modify.SetReinforcement(ConcreteSection section, and 1 more inputs)
BH.Engine.Structure.Modify.SetStructuralFragment(Material material, IMaterialFragment structuralFragment)

@adecler
Copy link
Member

adecler commented Oct 7, 2020

Here's the list of non-Modify methods calling one of the clone methods:

Full list

BH.Engine.Adapters.Revit.Query.Duplicate(IBHoMObject bHoMObject)
BH.Engine.Adapters.SAP2000.Query.JoinRigidLink(List<RigidLink> linkList)
BH.Engine.Adapters.SAP2000.Query.SplitRigidLink(RigidLink link)
BH.Engine.Architecture.Query.NewElement1D(Room room, ICurve curve)
BH.Engine.Audience.Query.PlaceSeats(Row row, Double unitWidth, Cartesian world, and 1 more inputs)
BH.Engine.CableNetDesign.Compute.Equilibrate(GravityCableNet cableNet, EquilibrateMethod method)
BH.Engine.CableNetDesign.Compute.FixPlanRelaxationByMinHeight(GravityCableNet cableNet, EquilibrateMethod settings)
BH.Engine.CableNetDesign.Compute.RelaxCables(GravityCableNet cableNet, EquilibrateMethod settings)
BH.Engine.Diffing.Compute.DiffGenericObjects(IEnumerable<Object> pastObjects, IEnumerable<Object> currentObjects, DiffConfig diffConfig, and 1 more inputs)
BH.Engine.Diffing.Compute.Diffing(IEnumerable<Object> pastObjs, IEnumerable<Object> followingObjs, DiffConfig diffConfig, and 1 more inputs)
BH.Engine.Diffing.Compute.DiffingHash(Object obj, DiffConfig diffConfig)
BH.Engine.Diffing.Compute.DiffOneByOne(IEnumerable<Object> pastObjects, IEnumerable<Object> currentObjects, DiffConfig diffConfig, and 1 more inputs)
BH.Engine.Diffing.Compute.DiffWithCustomId(IEnumerable<IBHoMObject> pastObjects, IEnumerable<IBHoMObject> currentObjects, String customdataIdKey, and 1 more inputs)
BH.Engine.Diffing.Compute.DiffWithFragmentId(IEnumerable<IBHoMObject> pastObjects, IEnumerable<IBHoMObject> currentObjects, Type fragmentType, and 2 more inputs)
BH.Engine.Diffing.Query.DifferentProperties(Object obj1, Object obj2, DiffConfig diffConfig)
BH.Engine.Environment.Query.NewElement1D(Opening opening, ICurve curve)
BH.Engine.Environment.Query.NewElement1D(Panel panel, ICurve curve)
BH.Engine.Environment.Query.NewElement1D(Space space, ICurve curve)
BH.Engine.Geometry.Compute.BooleanDifference(Line line, Line refLine, Double tolerance)
BH.Engine.Geometry.Compute.BooleanDifference(List<Line> lines, List<Line> refLines, Double tolerance)
BH.Engine.Geometry.Compute.BooleanIntersection(Line line, Line refLine, Double tolerance)
BH.Engine.Geometry.Compute.BooleanIntersection(List<Line> lines, Double tolerance)
BH.Engine.Geometry.Compute.BooleanUnion(Line line, Line refLine, Double tolerance)
BH.Engine.Geometry.Compute.ClusterCollinear(List<Line> lines, Double tolerance)
BH.Engine.Geometry.Compute.RowEchelonForm(Double[,] imatrix, Boolean reduced, Double tolerance)
BH.Engine.Geometry.Convert.ToNurbsCurve(NurbsCurve curve)
BH.Engine.Geometry.Query.Area(PolyCurve curve)
BH.Engine.Geometry.Query.Bounds(BoundingBox boundingBox)
BH.Engine.Geometry.Query.ExternalEdges(Extrusion surface)
BH.Engine.Geometry.Query.InternalEdges(Extrusion surface)
BH.Engine.Geometry.Query.IsClockwise(Polyline polyline, Vector normal, Double tolerance)
BH.Engine.Geometry.Query.IsCoplanar(Polyline curve1, Polyline curve2, Double tolerance)
BH.Engine.Geometry.Query.LineIntersection(Line line1, Line line2, Boolean useInfiniteLines, and 2 more inputs)
BH.Engine.Geometry.Query.LineIntersections(Arc arc, Line line, Boolean useInfiniteLine, and 1 more inputs)
BH.Engine.Geometry.Query.LineIntersections(Circle circle, Line line, Boolean useInfiniteLine, and 1 more inputs)
BH.Engine.Geometry.Query.LineIntersections(PolyCurve curve, Line line, Boolean useInfiniteLine, and 1 more inputs)
BH.Engine.Geometry.Query.LineIntersections(Polyline curve, Line line, Boolean useInfiniteLine, and 1 more inputs)
BH.Engine.Graphics.Query.AutoRange(GradientOptions gradientOptions, IEnumerable<Double> allValues)
BH.Engine.Graphics.Query.CenterGradientAsymmetric(Gradient gradient, Double from, Double to)
BH.Engine.Graphics.Query.CenteringOptions(GradientOptions gradientOptions)
BH.Engine.Graphics.Query.DefaultGradient(GradientOptions gradientOptions, String defaultGradient)
BH.Engine.ModelLaundry.Query.LineIntersections(IElement1D element1D, Line line, Boolean useInfiniteLine, and 1 more inputs)
BH.Engine.ModelLaundry.Query.LineIntersections(IElement2D element2D, Line line, Boolean useInfiniteLine, and 1 more inputs)
BH.Engine.Structure.Compute.ShearAreaPolyline(Polyline pLine, Double momentOfInertia, Double tol)
BH.Engine.Structure.Query.ControlPoints(Bar bar)
BH.Engine.Structure.Trusses.Compute.InternalPoints(List<Point> points, Polyline polyline, Int32 internalDivsions)
BH.Engine.Structure.Trusses.Compute.IterateBracing(List<Point> bracingList, List<Point> intersectionPoints, BracingOrientation bracingOrientation, and 6 more inputs)
BH.oM.Architecture.Theatron.ProfileOrigin.ProfileOrigin(Point origin, Vector direction)
BH.oM.Architecture.Theatron.TheatronFullProfile.TheatronFullProfile(List<ProfileParameters> parameters)
BH.oM.Architecture.Theatron.TheatronFullProfile.TheatronFullProfile(List<ProfileParameters> parameters, Point focalPoint, ProfileOrigin sectionOrigin)
BH.oM.Architecture.Theatron.TheatronFullProfile.TheatronFullProfile(List<ProfileParameters> parameters, TheatronPlan planGeometry)
BH.oM.Architecture.Theatron.TierProfile.TransformProfile(TierProfile originalSection, Vector scale, Point source, and 2 more inputs)
BH.oM.Dimensional.IElement1D.NewElement1D(IOpening surface, ICurve curve)
BH.oM.Dimensional.IElement1D.NewElement1D(ISurface surface, ICurve curve)
BH.oM.Dimensional.IElement1D.NewElement1D(Opening opening, ICurve curve)
BH.oM.Dimensional.IElement1D.NewElement1D(Panel panel, ICurve curve)
BH.oM.Dimensional.IElement2D.MultiStoreyWalls(List<Level> levels, List<ICurve> centrelines, List<ICurve> openingsAllLevels, and 2 more inputs)
BH.oM.Geometry.Plane.Plane(Point p1, Point p2, Point p3)
BH.oM.Humans.ViewQuality.Audience.Audience(Audience audienceToCopy)
BH.oM.Structure.Buildings.MultiStorey.MultiStorey(List<Double> levelElevations, List<ICurve> floorOutlines, List<ICurve> wallCurves, and 5 more inputs)

@adecler
Copy link
Member

adecler commented Oct 7, 2020

I have summarised the two lists above per namespace so we can tick them as they get fixed:

@adecler
Copy link
Member

adecler commented Oct 7, 2020

Just to confirm: the DeepClone and ShallowClone methods are returning an object with the same Guid already:

image

Agreed we should get rid of the other clone methods (including the geometry ones)

@adecler
Copy link
Member

adecler commented Oct 15, 2020

GetShallowClone from the oM and GeometryClone methods will be removed completely. So the onyl two remaining Clone methods are Engine.Base.Query.DeepClone() and Engine.Base.Query.ShallowClone()

Instructions:

  • Replace calls to Geometry.Clone and Geometry.IClone to calls to Engine.Base.DeepClone(). Feel free to use Engine.Base.ShallowClone() where you feel appropriate.
  • Replace calls to GetShallowClone with calls to Engine.Base.ShallowClone()
  • Remove the as X conversion after the cloning since casting is not necessary anymore

See the PR on the Geometry engine for an example: BHoM/BHoM_Engine#2070

To be actioned as soon as convenient. Can be done separately but need to be done by the end of sprint 4.

Once all the calls to Clone methods have been cleaned, I will delete the four clone methods mentioned above.

@al-fisher , @adecler , @alelom , @IsakNaslundBh , @FraserGreenroyd , @pawelbaran , @LMarkowski , @peterjamesnugent , @rolyhudson , FYI

@IsakNaslundBh
Copy link

Remove any reference to any clone method in the Modify namespace. If there is a good reason to keep it, please mention it here

Would be a bit careful with this, especially for any modify methods that are related to the IElement workflows. A lot of the methods that target IElement currently relies on the objects being cloned at modify. For example splitting something assumes that you can just call SetGeometry() twice with different geometries and get two of objects back that have different geometries but all other properties maintained exactly the same.

Can definitely get behind getting rid of GetShallowClone() by the end of sprint 4, but getting rid of cloning in every single modify method I would be a bit more careful with for the reasons stated above. For each method we basically need to check the implications it has on methods calling it, which can be non-trivial as the methods calling it might be in another toolkit, and even more so, called via some interface via RunExtensionMethod.

@al-fisher
Copy link
Member

Understood - we need to understand the scale of the work. Perhaps worth a session specifically on this again next week after individuals have looked a specific cases? Can we link to some specific methods and how they might need to be tackled?
I know @adecler was going to look at some of the reflection and geometry cases over the next few days to look a concrete issues for other also to watch out for.

As you say - priority, as I see it, is to remove all use of BH.oM.Base.BHoMObject.GetShallowClone. If that means replacing with BH.Engine.Base.Query.ShallowClone that is fine.
Removal of BHoMObject.GetShallowClone is of course important in the needed reliance of GUID and use of Hash.

@adecler
Copy link
Member

adecler commented Oct 16, 2020

I think it is important to stress the fact that Modify methods are now ment to always modify the input object. This will be reinforced by later making the return type of ALL Modify method void (see #11).

The idea behind this is simple:

  • Objects in C# are always mutable (this is how C# wants to work by default)
  • Objects in UI scripts are always immutable (this is how UIs like Grasshopper want to work by default)

The BHoM_UI is already taking care of handling the discrepancy between the two realms by handling the cloning when appropriate.

This means that

  • Modify methods should remove the step of first cloning the input object
  • Modify methods that were creating a new object should modify the input object instead
  • Modify methods that were returning a new type of object are not compliant and should move to either Query or Compute as they are already breaking the compliance rules.

This is why I really like @alelom 's idea of having the Modify methods returning null because it leaves you no choice but to be compliant on top of being far more intuitive when deciding how to use those methods 😄 . We will, however, enforce the output to be void on a second phase to avoid too much mess.

I hope that makes the intent a bit more clear and helps you when you take on the tasks above. I will try to share my experience of fixing the Modify methods for the Geometry engine as much as possible but happy to have other meeting for those that still find this change confusing.

@IsakNaslundBh
Copy link

I think it is important to stress the fact that Modify methods are now ment to always modify the input object. This will be reinforced by later making the return type of ALL Modify method void (see #11).

Yeah, understand this ofc. All I am saying is that we can not simply look at the methods in isolation. You need to find all calls in the code, in all toolkits that can reach that method and evaluate if the implicit cloning mechanism that we have up until this point enforce was used by any of the methods.

I do not know how widespread this is, but as stated in the previous comment, I know it happens in quite a few cases for the IElements

@adecler
Copy link
Member

adecler commented Oct 16, 2020

Yeah, understand this ofc. All I am saying is that we can not simply look at the methods in isolation. You need to find all calls in the code, in all toolkits that can reach that method and evaluate if the implicit cloning mechanism that we have up until this point enforce was used by any of the methods.

Exactly, that what I meant by

Check all methods calling a method with a deleted call to Clone to make sure they don't rely on the object being cloned.

Fun, isn't it ? 😉

What I recommend is to first fix all Modify methods in isolation and then check all calling methods. Not only will you naturally solve the problem for Modify methods calling other Modify methods but it will also help you stay focus on the first part of the task without running around in the code too much.

@adecler
Copy link
Member

adecler commented Oct 16, 2020

FYI, I have started a discussion around the Modify methods with an output type different than their first input type here: BHoM/BHoM#1031

@alelom
Copy link
Member Author

alelom commented Jul 26, 2021

All remaining calls to the oM's GetShallowClone() method have been now targeted by PRs to remove them. I've also removed calls to IClone where present (Analytical_Engine, Structure_Engine):

Implementations of GetShallowClone to be removed after it is removed from the IBHoMObject interface:

@adecler
Copy link
Member

adecler commented Jul 27, 2021

@alelom , you can find all the methods calling GetShallowClone using something like this:

image

@FraserGreenroyd
Copy link
Contributor

@alelom to capture PR comments - MEP Engine and Facade Engine PRs do not match the files they claim to change, MEP Engine PR was dealing with Physical Engine files, and Facade Engine PR was dealing with Structure Engine.

Those two engines might need reinvestigating?

@FraserGreenroyd
Copy link
Contributor

Ok all sorted now by the looks of it, thanks @alelom

@FraserGreenroyd
Copy link
Contributor

@alelom I've merged all your PRs for you. The one on XML needs to be done in coordination with the one on BHoM, same branch, etc. - lemme know when you want to do that.

@alelom
Copy link
Member Author

alelom commented Jul 29, 2021

Wonderful! Thanks @FraserGreenroyd

@alelom
Copy link
Member Author

alelom commented Jul 30, 2021

The method GetShallowClone has now been removed from the base BHoMObject: BHoM/BHoM#1265.

@alelom
Copy link
Member Author

alelom commented Jul 30, 2021

Final action on the unified strategy for the Cloning is to get rid of the last remaining Clone method: BH.Engine.Geometry.Query.Clone and BH.Engine.Geometry.Query.IClone.

All calls those two methods will be replaced with calls to Engine.Base.DeepClone().
This is actioned here: BHoM/BHoM_Engine#2585

@FraserGreenroyd
Copy link
Contributor

Ok we've merged that today as well now @alelom - does that conclude this issue?

@alelom
Copy link
Member Author

alelom commented Jul 30, 2021

With BHoM/BHoM#1265 and BHoM/BHoM_Engine#2585 merged we now are left with a unified strategy for cloning. In other words, now BHoM only defines two cloning methods: BH.Engine.Base.DeepClone() and BH.Engine.Base.ShallowClone() – both relying on the open source library DeepCloner.

This removes any ambiguity on how to clone objects in BHoM. Monitoring for performance should continue as well as logging for features we may need from the DeepCloner library.

@alelom alelom closed this as completed Jul 30, 2021
@al-fisher
Copy link
Member

Fantastic! This is great @alelom @FraserGreenroyd 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New capability or enhancement type:question Ask for further details or start conversation
Projects
None yet
Development

No branches or pull requests

6 participants