internal static void AddFastenersInformation(designGraph assemblyGraph, Dictionary <string, List <TessellatedSolid> > solidsNoFastener, Dictionary <TessellatedSolid, List <PrimitiveSurface> > solidPrimitive) { var counter = 0; foreach (var fastener in FastenerDetector.Fasteners) { counter++; var lockedByTheFastener = PartsLockedByTheFastenerFinder(fastener.Solid, solidsNoFastener, solidPrimitive); AddFastenerToArc(assemblyGraph, lockedByTheFastener, fastener); } // So, by this point, if there is a fastener between two or more parts, a new local variable // is added to their arc which shows the direction of freedom of the fastener. // So if I want to seperate two parts or two subassemblies, now I know that there is a // fastener holding them to each other. And I also know the removal direction of the fastener // There is still a possibility here: if any of the potential fasteners are holding 2 or more parts // The point is that they can be either a washer, nut or fastener. But if it is a fastener, I need // to find the parts that it's holding and add it to their arc counter = 0; foreach (var possible in FastenerDetector.PotentialFastener.Keys) { counter++; var locked = PartsLockedByTheFastenerFinder(possible, solidsNoFastener, solidPrimitive); if (locked.Count < 2) { if (locked.Count == 1) { var comp = (Component)assemblyGraph[locked[0]]; var pin = new Fastener() { RemovalDirection = FastenerDetector.RemovalDirectionFinderUsingObb(possible, BoundingGeometry.OrientedBoundingBoxDic[possible]), Solid = possible, Diameter = BoundingGeometry.BoundingCylinderDic[possible].Radius, OverallLength = BoundingGeometry.BoundingCylinderDic[possible].Length }; if (comp.Pins == null) { comp.Pins = new List <Fastener>(); } comp.Pins.Add(pin); } } PolygonalFace topPlane = null; var fastener = new Fastener() { RemovalDirection = FastenerDetector.RemovalDirectionFinderUsingObbWithTopPlane(possible, BoundingGeometry.OrientedBoundingBoxDic[possible], out topPlane), Solid = possible, Diameter = BoundingGeometry.BoundingCylinderDic[possible].Radius, OverallLength = BoundingGeometry.BoundingCylinderDic[possible].Length }; AddFastenerToArc(assemblyGraph, locked, fastener); /*(if (fastener.PartsLockedByFastener.Count > 2) * // if there are more than 2 parts locked by the fastener, sort them based on their distance to the top plane of the fastener * { * * }*/ } }