public void Start() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent<SocketIOComponent>(); Player = GameObject.FindGameObjectWithTag("Player"); Player_rg = Player.GetComponent<Rigidbody>(); modify = Player.GetComponent<Modify>(); world = GameObject.Find("WorldStartHere").GetComponent<World>(); socket.On("open", TestOpen); socket.On("boop", TestBoop); socket.On("error", TestError); socket.On("close", TestClose); // socket.On("user_added", AddUserToWorld); socket.On ("user_update_position", UpdateOtherPos); // socket.On ("user list", AddUserToWorld); socket.On("map_modify", ModifyMap); socket.On ("set_specblock", SetSpecBlock); socket.On ("shotting", OtherShotting); StartCoroutine("BeepBoop"); // StartCoroutine("SendPosition"); }
public static Color ModifyLight( Color c, Modify modify ) { double h; double s; double l; c.GetHSL( out h, out s, out l ); l = modify( l ); l = Math.Min( Math.Max( 0, l ), 1 ); return FromHSL( h, s, l ); }
public static Color ModifySaturation( Color c, Modify modify ) { double h; double s; double l; c.GetHSL( out h, out s, out l ); s = modify( s ); s = Math.Min( Math.Max( 0, s ), 1 ); return FromHSL( h, s, l ); }
public static Color ModifyHSL( Color c, Modify modifyH, Modify modifyS, Modify modifyL ) { double h; double s; double l; c.GetHSL( out h, out s, out l ); h = modifyH( h ); s = modifyS( s ); l = modifyL( l ); s = Math.Min( Math.Max( 0, s ), 1 ); l = Math.Min( Math.Max( 0, l ), 1 ); return FromHSL( h, s, l ); }
public static Color ModifyHue( Color c, Modify modify ) { double h; double s; double l; c.GetHSL( out h, out s, out l ); h = modify( h ); return FromHSL( h, s, l ); }
public void TestText() { Modify.TextStyle("Tahoma", 100, 5 * Math.PI / 180, 0.8); Draw.Text("FontAbc", 100, Point3d.Origin, 0, true); }
public void exportleo() { DocumentCollection docCol = Application.DocumentManager; Database db = docCol.MdiActiveDocument.Database; Editor editor = docCol.MdiActiveDocument.Editor; Document doc = docCol.MdiActiveDocument; using (Transaction tx = db.TransactionManager.StartTransaction()) { var plines = QuickSelection.SelectAll("LWPOLYLINE").QWhere(x => x.Layer == "RØR INSTRUMENT SIGNAL").ToList(); editor.WriteMessage($"\nPlines collected {plines.Count}"); plines.QOpenForWrite <Polyline>(listToExplode => { foreach (var poly in listToExplode) { Modify.Explode(poly.ObjectId); } }); var rumPolyIds = QuickSelection.SelectAll("LWPOLYLINE").QWhere(x => x.Layer == "RUM DELER").ToList(); editor.WriteMessage($"\nCollected {rumPolyIds.Count} rum polylines."); rumPolyIds.QOpenForWrite <Polyline>(listToClean => { foreach (var poly in listToClean) { Algorithms.PolyClean_RemoveDuplicatedVertex(poly); } }); List <(string Tag, string RoomNr)> tagRoomlist = new List <(string Tag, string RoomNr)>(); int i = 0; List <BlockReference> AllBlocks = new List <BlockReference>(); var rumPolys = rumPolyIds.QOpenForRead <Polyline>(); foreach (Polyline pline in rumPolys) { i++; editor.WriteMessage($"\nProcessing polyline number {i}."); List <BlockReference> blocks = new List <BlockReference>(); PromptSelectionResult selection = editor.SelectByPolyline(pline, ExtensionMethods.PolygonSelectionMode.Window, new TypedValue(0, "INSERT")); if (selection.Status == PromptStatus.OK) { SelectionSet set = selection.Value; foreach (SelectedObject selObj in set) { if (selObj != null) { BlockReference block = tx.GetObject(selObj.ObjectId, OpenMode.ForRead) as BlockReference; blocks.Add(block); AllBlocks.Add(block); } } } else { editor.WriteMessage($"\nPolyline number {i} failed the selection!"); } BlockReference roomNumberBlock = blocks.Where(x => x.Name == "rumnummer").FirstOrDefault(); if (roomNumberBlock == null) { continue; } string roomNumber = roomNumberBlock.GetBlockAttribute("ROOMNO"); editor.WriteMessage($"\nRoom nr.: {roomNumber}"); foreach (BlockReference br in blocks) { string tagValue = string.Empty; var attrs = br.GetBlockAttributes(); if (attrs.ContainsKey("TEXT1")) { tagValue = attrs["TEXT1"]; } else if (attrs.ContainsKey("TAG")) { tagValue = attrs["TAG"]; } else { continue; } if (!string.IsNullOrEmpty(roomNumber)) { tagRoomlist.Add((tagValue, roomNumber)); } } } //Sort the pairs list tagRoomlist = tagRoomlist.OrderBy(x => x.Tag).ToList(); //Export to excel xel.Application excel = new xel.Application(); if (null == excel) { throw new System.Exception("Failed to start EXCEL!"); } excel.Visible = true; xel.Workbook workbook = excel.Workbooks.Add(Missing.Value); xel.Worksheet worksheet; worksheet = excel.ActiveSheet as xel.Worksheet; worksheet.Name = "LeoExport"; worksheet.Columns.ColumnWidth = 15; int row = 1; int col = 1; foreach (var pair in tagRoomlist) { worksheet.Rows[row].Cells[col] = pair.Tag; worksheet.Rows[row].Cells[col + 1] = pair.RoomNr; //worksheet.Cells[row, col] = pair.Item1; //worksheet.Cells[row, col+1] = pair.Item2; row++; } } }
private void Execute(Piece piece, Modify modifyPiece, ICommand pieceCommand) { modifyPiece.SetCommand(pieceCommand); modifyPiece.Invoke(); }
public static void Test01(bool propertyLevelDiffing = true) { Console.WriteLine("Running Diffing_Engine Test01"); // 1. Suppose Alessio is creating 3 bars in Grasshopper, representing a Portal frame structure. // These will be Alessio's "Current" objects. List <IBHoMObject> currentObjs_Alessio = new List <IBHoMObject>(); for (int i = 0; i < 3; i++) { Bar obj = BH.Engine.Base.Create.RandomObject(typeof(Bar)) as Bar; obj.Fragments = obj.Fragments.Where(fragm => fragm != null).ToList(); // (RandomObject bug workaround: it generates a random number of null fragments) obj.Name = "bar_" + i.ToString(); currentObjs_Alessio.Add(obj as dynamic); } // 2. Alessio wants these bars to be part of a "Portal frame Stream" that will be tracking the objects for future changes. // Alessio creates a stream string comment = "Portal Frame Stream"; Stream stream_Alessio = Create.Stream(currentObjs_Alessio, comment); // this will add the hash fragments to the objects // Alessio can now push the Stream. // 3. Eduardo is now asked to do some changes to the "Portal frame Project" created by Alessio. // On his machine, Eduardo now PULLS the Stream from the external platform to read the existing objects. IEnumerable <IBHoMObject> readObjs_Eduardo = stream_Alessio.Objects.Select(obj => BH.Engine.Base.Query.DeepClone(obj) as IBHoMObject).ToList(); // Eduardo will now work on these objects. List <IBHoMObject> currentObjs_Eduardo = readObjs_Eduardo.ToList(); // 5. Eduardo now modifies one of the bars, deletes another one, and creates a new one. // modifies bar_0 currentObjs_Eduardo[0].Name = "modifiedBar_0"; // deletes bar_1 currentObjs_Eduardo.RemoveAt(1); // adds a new bar Bar newBar = BH.Engine.Base.Create.RandomObject(typeof(Bar)) as Bar; newBar.Name = "newBar_1"; currentObjs_Eduardo.Insert(1, newBar as dynamic); // 6. Eduardo updates the Stream Revision. Stream stream_Eduardo = Modify.StreamRevision(stream_Alessio, currentObjs_Eduardo); // Eduardo can now push this Stream. // -------------------------------------------------------- // // Eduardo can also manually check the differences. Delta delta = Compute.Diffing(stream_Alessio, stream_Eduardo, propertyLevelDiffing, null, true); // 7. Now Eduardo can push his new delta object (like step 3). // `delta.ToCreate` will have 1 object; `delta2.ToUpdate` 1 object; `delta2.ToDelete` 1 object; `delta2.Unchanged` 2 objects. // You can also see which properties have changed for what objects: check `delta2.ModifiedPropsPerObject`. Debug.Assert(delta.NewObjects.Count == 1, "Incorrect number of object identified as new/ToBeCreated."); Debug.Assert(delta.ModifiedObjects.Count == 1, "Incorrect number of object identified as modified/ToBeUpdated."); Debug.Assert(delta.OldObjects.Count == 1, "Incorrect number of object identified as old/ToBeDeleted."); var modifiedPropsPerObj = delta.ModifiedPropsPerObject.First().Value; Debug.Assert(modifiedPropsPerObj.Count == 1, "Incorrect number of changed properties identified by the property-level diffing."); Debug.Assert(modifiedPropsPerObj.First().Key == "Name", "Error in property-level diffing"); Debug.Assert(modifiedPropsPerObj.First().Value.Item1 as string == "modifiedBar_0", "Error in property-level diffing"); Console.WriteLine("Test01 concluded."); }
public override void BuildProcessing(MillingCommandGenerator generator) { const int CornerIndentIncrease = 5; var curve = ProcessingArea.GetCurve(); var thickness = TechProcess.Thickness.Value + 2; // запил на 2мм ниже нижнего края var toolDiameter = TechProcess.Tool.Diameter; var engineSide = Side.None; double offsetArc = 0; double angleA = 0; if (TechProcess.MachineType == MachineType.ScemaLogic) { AngleA = 0; } switch (curve) { case Arc arc: CalcArc(arc); break; case Line line: CalcLine(line); break; case Polyline polyline: CalcPolyline(polyline); break; default: throw new InvalidOperationException($"Кривая типа {curve.GetType()} не может быть обработана."); } var outerSideSign = OuterSide == Side.Left ^ curve is Line ? -1 : 1; var offsetCoeff = Math.Tan(angleA) * outerSideSign; var depthCoeff = 1 / Math.Cos(angleA); var toolThickness = TechProcess.Tool.Thickness.Value * depthCoeff; var compensation = (offsetArc + (engineSide == OuterSide ^ TechProcess.MachineType == MachineType.Donatoni ? toolThickness : 0)) * outerSideSign; var shift = angleA > 0 ? -thickness * offsetCoeff : 0; var sumIndent = CalcIndent(thickness) * (Convert.ToInt32(IsExactlyBegin) + Convert.ToInt32(IsExactlyEnd)); if (sumIndent >= curve.Length()) { if (AngleA != 0) { throw new InvalidOperationException("Расчет намечания выполняется только при нулевом вертикальном угле."); } var point = Scheduling(); var angle = BuilderUtils.CalcToolAngle((curve.EndPoint - curve.StartPoint).ToVector2d().Angle, engineSide); generator.Move(point.X, point.Y, angleC: angle); generator.Cutting(point.X, point.Y, point.Z, TechProcess.PenetrationFeed); return; } var modes = SawingModes.ConvertAll(p => new CuttingMode { Depth = p.Depth, DepthStep = p.DepthStep, Feed = p.Feed }); var passList = BuilderUtils.GetPassList(modes, thickness, !ProcessingArea.ObjectId.IsLine()).ToList(); Curve toolpathCurve = null; foreach (var item in passList) { CreateToolpath(item.Key, compensation + shift + item.Key * offsetCoeff); if (generator.IsUpperTool) { var point = engineSide == Side.Right ^ (passList.Count() % 2 == 1) ? toolpathCurve.EndPoint : toolpathCurve.StartPoint; var vector = Vector3d.ZAxis * (item.Key + generator.ZSafety); if (angleA != 0) { vector = vector.RotateBy(outerSideSign * angleA, ((Line)toolpathCurve).Delta) * depthCoeff; } var p0 = point + vector; var angleC = BuilderUtils.CalcToolAngle(toolpathCurve, point, engineSide); generator.Move(p0.X, p0.Y, angleC: angleC, angleA: Math.Abs(AngleA)); if (TechProcess.MachineType == MachineType.ScemaLogic) { generator.Command("28;;XYCZ;;;;;;", "Цикл"); } } generator.Cutting(toolpathCurve, item.Value, TechProcess.PenetrationFeed, engineSide); } generator.Uplifting(Vector3d.ZAxis.RotateBy(outerSideSign * angleA, toolpathCurve.EndPoint - toolpathCurve.StartPoint) * (thickness + generator.ZSafety) * depthCoeff); if ((!IsExactlyBegin || !IsExactlyEnd) && Departure == 0) { var gashCurve = curve.GetOffsetCurves(shift)[0] as Curve; var gashList = new List <ObjectId>(); if (!IsExactlyBegin) { gashList.Add(Acad.CreateGash(gashCurve, gashCurve.StartPoint, OuterSide, thickness * depthCoeff, toolDiameter, toolThickness)); } if (!IsExactlyEnd) { gashList.Add(Acad.CreateGash(gashCurve, gashCurve.EndPoint, OuterSide, thickness * depthCoeff, toolDiameter, toolThickness)); } if (gashList.Count > 0) { Modify.AppendToGroup(base.TechProcess.ExtraObjectsGroup.Value, gashList.ToArray()); } gashCurve.Dispose(); } // Local func ------------------------ void CalcArc(Arc arc) { AngleA = 0; var startSide = Math.Sign(Math.Cos(arc.StartAngle.Round(3))); var endSide = Math.Sign(Math.Cos(arc.EndAngle.Round(3))); var cornersOneSide = Math.Sign(startSide * endSide); if (arc.TotalAngle.Round(3) > Math.PI && cornersOneSide > 0) { throw new InvalidOperationException("Обработка дуги невозможна - дуга пересекает углы 90 и 270 градусов."); } if (cornersOneSide < 0) // дуга пересекает углы 90 или 270 градусов { if (TechProcess.MachineType == MachineType.ScemaLogic) { throw new InvalidOperationException("Обработка дуги невозможна - дуга пересекает угол 90 или 270 градусов."); } engineSide = startSide > 0 ? Side.Left : Side.Right; } if (OuterSide == Side.Left) // внутренний рез дуги { if (TechProcess.MachineType == MachineType.Donatoni && engineSide != Side.Left) // подворот диска при вн. резе дуги { engineSide = Side.Right; //var comp = arc.Radius - Math.Sqrt(arc.Radius * arc.Radius - thickness * (toolDiameter - thickness)); //AngleA = Math.Atan2(comp, thickness).ToDeg(); var R = arc.Radius; var t = thickness; var d = toolDiameter; var comp = (2 * R * t * t - Math.Sqrt(-d * d * d * d * t * t + 4 * d * d * R * R * t * t + d * d * t * t * t * t)) / (d * d - 4 * R * R); AngleA = -Math.Atan2(comp, thickness).ToDeg(); } else { offsetArc = arc.Radius - Math.Sqrt(arc.Radius * arc.Radius - thickness * (toolDiameter - thickness)); } } if (engineSide == Side.None) { engineSide = (startSide + endSide) > 0 ? Side.Right : Side.Left; } } void CalcLine(Line line) { angleA = AngleA.ToRad(); engineSide = AngleA == 0 ? BuilderUtils.CalcEngineSide(line.Angle) : AngleA > 0 ? OuterSide : OuterSide.Opposite(); } void CalcPolyline(Polyline polyline) { int sign = 0; for (int i = 0; i < polyline.NumberOfVertices; i++) { var point = polyline.GetPoint3dAt(i); var s = Math.Sign(Math.Sin(polyline.GetTangent(point).Angle.Round(6))); if (s == 0) { continue; } if (sign == 0) { sign = s; continue; } var bulge = polyline.GetBulgeAt(i - 1); if (bulge == 0) { bulge = polyline.GetBulgeAt(i); } if (s != sign) { if (TechProcess.MachineType == MachineType.ScemaLogic) { throw new InvalidOperationException("Обработка полилинии невозможна - кривая пересекает углы 90 или 270 градусов."); } var side = sign > 0 ^ bulge < 0 ? Side.Left : Side.Right; if (engineSide != Side.None) { if (engineSide != side) { throw new InvalidOperationException("Обработка полилинии невозможна."); } } else { engineSide = side; } sign = s; } else if (Math.Abs(bulge) > 1) { throw new InvalidOperationException("Обработка невозможна - дуга полилинии пересекает углы 90 и 270 градусов."); } } if (engineSide == Side.None) { engineSide = BuilderUtils.CalcEngineSide(polyline.GetTangent(polyline.StartPoint).Angle); } } void CreateToolpath(double depth, double offset) { toolpathCurve = curve.GetOffsetCurves(offset)[0] as Curve; toolpathCurve.TransformBy(Matrix3d.Displacement(-Vector3d.ZAxis * depth)); if (Departure > 0 && toolpathCurve is Line line) { if (!IsExactlyBegin) { toolpathCurve.StartPoint = line.ExpandStart(Departure); } if (!IsExactlyEnd) { toolpathCurve.EndPoint = line.ExpandEnd(Departure); } } if (!IsExactlyBegin && !IsExactlyEnd) { return; } var indent = CalcIndent(depth * depthCoeff); switch (toolpathCurve) { case Line l: if (IsExactlyBegin) { l.StartPoint = l.GetPointAtDist(indent); } if (IsExactlyEnd) { l.EndPoint = l.GetPointAtDist(l.Length - indent); } break; case Arc a: var indentAngle = indent / ((Arc)curve).Radius; if (IsExactlyBegin) { a.StartAngle = a.StartAngle + indentAngle; } if (IsExactlyEnd) { a.EndAngle = a.EndAngle - indentAngle; } break; case Polyline p: if (IsExactlyBegin) { p.SetPointAt(0, p.GetPointAtDist(indent).ToPoint2d()); } //p.StartPoint = p.GetPointAtDist(indent); if (IsExactlyEnd) { //p.EndPoint = p.GetPointAtDist(p.Length - indent); p.SetPointAt(p.NumberOfVertices - 1, p.GetPointAtDist(p.Length - indent).ToPoint2d()); } break; } ; } double CalcIndent(double depth) => Math.Sqrt(depth * (toolDiameter - depth)) + CornerIndentIncrease; /// <summary> /// Расчет точки намечания /// </summary> Point3d Scheduling() { var vector = curve.EndPoint - curve.StartPoint; var depth = thickness; var point = Point3d.Origin; if (IsExactlyBegin && IsExactlyEnd) { var l = vector.Length - 2 * CornerIndentIncrease; depth = (toolDiameter - Math.Sqrt(toolDiameter * toolDiameter - l * l)) / 2; point = curve.StartPoint + vector / 2; } else { var indentVector = vector.GetNormal() * (Math.Sqrt(depth * (toolDiameter - depth)) + CornerIndentIncrease); point = IsExactlyBegin ? curve.StartPoint + indentVector : curve.EndPoint - indentVector; Acad.CreateGash(curve, IsExactlyBegin ? curve.EndPoint : curve.StartPoint, OuterSide, depth, toolDiameter, toolThickness, point); } return(point + vector.GetPerpendicularVector().GetNormal() * compensation - Vector3d.ZAxis * depth); } }
private void Execute(GamePlayControll gamePlayControll, Modify modifyGamePlay, ICommand GamePlayCommand) { modifyGamePlay.SetCommand(GamePlayCommand); modifyGamePlay.Invoke(); }
private void RemoveShapeVertex(IVertex v, Shape shape) { this.VisitedGraph.RemoveVertex(v); this.ShapeVertices.Remove(shape); this.VertexShapes.Remove(v); Modify m = new Modify(); m.AddDeleteShape(shape); this.Panel.AbstractShape.History.Do(m); }
private void RemoveConnectionEdge(IEdge e, Connection conn) { this.VisitedGraph.RemoveEdge(e); this.EdgeConnections.Remove(e); this.ConnectionEdges.Remove(conn); Modify m = new Modify(); m.AddDeleteConnection(conn); this.Panel.AbstractShape.History.Do(m); }
public void RemoveEdge(IEdge e) { if (e==null) throw new ArgumentNullException("e"); if (!this.VisitedGraph.ContainsEdge(e)) throw new ArgumentException("e is not part of the graph"); Connection conn = this.EdgeConnections[e]; this.VisitedGraph.RemoveEdge(e); this.EdgeConnections.Remove(e); this.ConnectionEdges.Remove(conn); Modify m = new Modify(); m.AddDeleteConnection(conn); this.Panel.AbstractShape.History.Do(m); }
public Shape AttachShape(IVertex v) { if (v==null) throw new ArgumentNullException("v"); if (!this.VisitedGraph.ContainsVertex(v)) throw new ArgumentException("vertex is not part of the graph"); if (this.vertexShapes.Contains(v)) throw new ArgumentException("shape already associtated with this vertex"); Shape shape = this.ShapeProvider.ProvideShape(v); this.Panel.Insert(shape); Modify m = new Modify(); m.AddInsertShape(shape,this.Panel.AbstractShape); this.Panel.AbstractShape.History.Do(m); Connect(v,shape); return shape; }
public Connection AttachConnection(NetronGraphvizLayouter layout,IEdge e) { if (e==null) throw new ArgumentNullException("e"); if (!this.VisitedGraph.ContainsEdge(e)) throw new ArgumentException("edge already in graph"); if (this.EdgeConnections.Contains(e)) throw new ArgumentException("connection already associtated with this edge"); // create edge Connection conn = this.ConnectionProvider.ProvideConnection(e); // set points layout.PositionConnection(e,conn); Connect(e,conn); // connect to target Modify m = new Modify(); m.AddInsertConnection(conn, conn.From, conn.To,this.Panel.AbstractShape); this.Panel.AbstractShape.History.Do(m); return conn; }