private static void PrintHeader(string name, ProfileSet set, int measurementsCount, TimeSpan total) { Console.Clear(); Console.WriteLine(); Console.WriteLine( $"------ {name} {(set)} iteration #{measurementsCount} in {(int) total.TotalMilliseconds} ms ------"); Console.WriteLine($" | % | VAL ips | AVG ips | MIN ips | MAX ips | RMS |"); }
//creates a cutout private void Create_Cutout(double PointOnGraphic_X, double PointOnGraphic_Y, double PointOnGraphic_Z, SolidEdgeGeometry.Face selected_face, int[] face_norm, string selected_face_normal) { PartDocument _doc = _application.ActiveDocument as PartDocument; RefPlanes refPlanes = null; RefPlane refPlane = null; refPlanes = _doc.RefPlanes; //Adding parallel refplane to the selected face refPlane = refPlanes.AddParallelByDistance(selected_face, 0.0, ReferenceElementConstants.igNormalSide, false, false, true, false); Relations2d relations2D = null; ProfileSets profileSets = null; ProfileSet profileSet = null; Profiles profiles = null; Profile profile = null; Lines2d lines2D = null; Models models = null; Model model = null; Sketchs sketchs = null; Sketch sketch = null; ExtrudedCutouts extrudedCutouts = null; sketchs = _doc.Sketches; sketch = sketchs.Add(); profileSets = _doc.ProfileSets; profileSet = profileSets.Add(); profiles = sketch.Profiles; profile = profiles.Add(refPlane); lines2D = profile.Lines2d; relations2D = (Relations2d)profile.Relations2d; //adding a 2D profile for the cutout lines2D.AddBy2Points(0.03, -0.055, 0.045, -0.055); lines2D.AddBy2Points(0.045, -0.055, 0.045, -0.04); lines2D.AddBy2Points(0.045, -0.04, 0.03, -0.04); lines2D.AddBy2Points(0.03, -0.04, 0.03, -0.055); profile.End(ProfileValidationType.igProfileClosed); models = _doc.Models; model = models.Item(1); extrudedCutouts = model.ExtrudedCutouts; //adding a new extruded cutout extrudedCutouts.AddThroughNext(Profile: profile, ProfileSide: FeaturePropertyConstants.igLeft, ProfilePlaneSide: FeaturePropertyConstants.igLeft ); }
public static void RunCalc(ProfileSet set) { var runner = ProfileTools.GetSet(set); var reportTime = set switch { ProfileSet.Primitives => 1_000_000, ProfileSet.Middle => 80000, ProfileSet.Complex => 10000, ProfileSet.All => 2000, _ => throw new ArgumentOutOfRangeException(nameof(set), set, null) }; var calculateBench = new ProfileCalculateSet(); for (int i = 0; i < 3; i++) { runner(calculateBench); } int measurementsCount = 0; int historyCount = 10; var calcStopWatch = new Stopwatch(); var calcHistory = new LinkedList <double>(); for (int iterations = 1; !Console.KeyAvailable || Console.ReadKey().Key != ConsoleKey.Escape; iterations++) { calcStopWatch.Start(); runner(calculateBench); calcStopWatch.Stop(); if (iterations >= reportTime) { measurementsCount++; calcHistory.AddAndTruncate(calcStopWatch.Elapsed.TotalMilliseconds, historyCount); var total = calcStopWatch.Elapsed; var buildAndRunTime = calcStopWatch.Elapsed; calcStopWatch.Reset(); PrintHeader("CALC", set, measurementsCount, total); PrintResults("calculate", buildAndRunTime, calcHistory, iterations); PrintFooter(); iterations = 1; } } }
public static void RunParse(ProfileSet set) { var runner = ProfileTools.GetSet(set); var reportTime = set switch { ProfileSet.Primitives => 10000, ProfileSet.Middle => 5000, ProfileSet.Complex => 1000, ProfileSet.All => 2000, _ => throw new ArgumentOutOfRangeException(nameof(set), set, null) }; var parseBench = new ProfileParserSet(); for (int i = 0; i < 3; i++) { runner(parseBench); } int measurementsCount = 0; int historyCount = 10; var parseStopWatch = new Stopwatch(); var parseHistory = new LinkedList <double>(); for (int iterations = 1; !Console.KeyAvailable || Console.ReadKey().Key != ConsoleKey.Escape; iterations++) { parseStopWatch.Start(); runner(parseBench); parseStopWatch.Stop(); if (iterations >= reportTime) { measurementsCount++; parseHistory.AddAndTruncate(parseStopWatch.Elapsed.TotalMilliseconds, historyCount); PrintHeader("PARSE", set, measurementsCount, parseStopWatch.Elapsed); PrintResults("parse ", parseStopWatch.Elapsed, parseHistory, iterations); PrintFooter(); parseStopWatch.Reset(); iterations = 1; } } }
/// <summary> /// Sync this profile with the server. /// </summary> public void Sync() { if (CIX.Online && Username == CIX.Username) { string[] splitName = FullName.Split(new[] { ' ' }, 2); LogFile.WriteLine("Uploading profile for {0} to server", CIX.Username); ProfileSet newProfileSmall = new ProfileSet { Fname = splitName[0], Sname = (splitName.Length > 1) ? splitName[1] : string.Empty, Location = Location, Email = EMailAddress, Flags = (int)Flags, Sex = Sex }; try { HttpWebRequest request = APIRequest.Post("user/setprofile", APIRequest.APIFormat.XML, newProfileSmall); string responseString = APIRequest.ReadResponseString(request); if (responseString == "Success") { Pending = false; LogFile.WriteLine("Profile successfully uploaded"); } request = APIRequest.Post("user/setresume", APIRequest.APIFormat.XML, About); responseString = APIRequest.ReadResponseString(request); if (responseString == "True") { Pending = false; LogFile.WriteLine("Resume successfully uploaded"); } } catch (Exception e) { CIX.ReportServerExceptions("Profile.Sync", e); } } }
public static Action <IProfileSet> GetSet(ProfileSet set) { switch (set) { case ProfileSet.Primitives: return(RunPrimitiveExamples); case ProfileSet.Middle: return(RunMiddleExamples); case ProfileSet.Complex: return(RunComplexExamples); case ProfileSet.All: return(RunAllExamples); default: throw new ArgumentOutOfRangeException(nameof(set), set, null); } }
//creates a slot private void Create_Slot(double PointOnGraphic_X, double PointOnGraphic_Y, double PointOnGraphic_Z, SolidEdgeGeometry.Face selected_face, int[] face_norm, string selected_face_normal) { PartDocument _doc = _application.ActiveDocument as PartDocument; RefPlanes refPlanes = null; RefPlane refPlane = null; refPlanes = _doc.RefPlanes; //Adding a parallel refplane to the selected face refPlane = refPlanes.AddParallelByDistance(selected_face, 0.0, ReferenceElementConstants.igNormalSide, false, false, true, false); ProfileSets profileSets = null; ProfileSet profileSet = null; Profiles profiles = null; Profile profile = null; Lines2d lines2D = null; Models models = null; Model model = null; Sketchs sketchs = null; Sketch sketch = null; Slots slots = null; Slot slot = null; sketchs = _doc.Sketches; sketch = sketchs.Add(); profileSets = _doc.ProfileSets; profileSet = profileSets.Add(); profiles = sketch.Profiles; //Adding the refplane to the profile profile = profiles.Add(refPlane); lines2D = profile.Lines2d; lines2D.AddBy2Points(0.02, 0, 0.02, 0.02); profile.End(ProfileValidationType.igProfileClosed); models = _doc.Models; model = models.Item(1); slots = model.Slots; //Adding a new slot slots.Add(Profile: profile, SlotType: FeaturePropertyConstants.igRegularSlot, SlotEndCondition: FeaturePropertyConstants.igFormedEnd, SlotWidth: 0.005, SlotOffsetWidth: 0, SlotOffsetDepth: 0, ExtentType: FeaturePropertyConstants.igThroughAll, ExtentSide: FeaturePropertyConstants.igLeft, FiniteDistance: 0, KeyPointFlags: KeyPointExtentConstants.igTangentNormal, KeyPointOrTangentFace: null, ExtentType2: FeaturePropertyConstants.igNone, ExtentSide2: FeaturePropertyConstants.igNone, FiniteDistance2: 0, KeyPointFlags2: KeyPointExtentConstants.igTangentNormal, KeyPointOrTangentFace2: null, FromFaceOrPlane: null, FromOffsetSide: OffsetSideConstants.seOffsetNone, FromOffsetDistance: 0, ToFaceOrPlane: null, ToOffsetSide: OffsetSideConstants.seOffsetNone, ToOffsetDistance: 0 ); }
//creates a hole private void create_hole(double PointOnGraphic_X, double PointOnGraphic_Y, double PointOnGraphic_Z, SolidEdgeGeometry.Face selected_face, int[] face_norm, string selected_face_normal) { // var selected_face = pGraphicDispatch as SolidEdgeGeometry.Face; PartDocument _doc = _application.ActiveDocument as PartDocument; RefPlanes refPlanes = null; RefPlane refPlane = null; refPlanes = _doc.RefPlanes; //Adding parallel refplane to the selected face refPlane = refPlanes.AddParallelByDistance(selected_face, 0.0, ReferenceElementConstants.igNormalSide, false, false, true, false); //Running windows form application System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.Run(new Form1()); MessageBox.Show("Cancel Hole Dimension?"); Form1 form1 = new Form1(); //Hole diameter from user input double cc = form1.Hole_dia; while (cc < 0.0) { MessageBox.Show("Enter valid dimension"); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.Run(new Form1()); Form1 form2 = new Form1(); double dd = form2.Hole_dia; MessageBox.Show("Cancel diamension?"); if (cc == dd) { MessageBox.Show("invalid argument"); dd = 0.0; } cc = dd; } ProfileSets profileSets = null; ProfileSet profileSet = null; Profiles profiles = null; Profile profile = null; Models models = null; HoleDataCollection holeDataCollection = null; HoleData holeData = null; Holes2d holes2D = null; Holes holes = null; Sketchs sketchs = null; Sketch sketch = null; Array ref_dir = new double[3] as Array; //getting the unit vector of the reference direction refPlane.GetReferenceDirection(ref ref_dir); var Ref_dirX = ref_dir as double[]; Array root_point = new double[3] as Array; refPlane.GetRootPoint(ref root_point); var Root_point = root_point as double[]; //calculating the cross-product between ref_dir and normal vector double[] Ref_dirY = new double[3] { Ref_dirX[2] * face_norm[1] - Ref_dirX[1] * face_norm[2], Ref_dirX[0] * face_norm[2] - Ref_dirX[2] * face_norm[0], Ref_dirX[1] * face_norm[0] - Ref_dirX[0] * face_norm[1] }; double Xcenter = -0.06; //local coordinates double Ycenter = -0.06; //calculating global coordinates from local coordinates double[] X_bar = new double[3] { Xcenter *Ref_dirX[0] + Ycenter * Ref_dirY[0] + Root_point[0], Xcenter *Ref_dirX[1] + Ycenter * Ref_dirY[1] + Root_point[1], Xcenter *Ref_dirX[2] + Ycenter * Ref_dirY[2] + Root_point[2] }; //Calculating the angle between vectors root_point and global double[] OX = new double[3] { PointOnGraphic_X - Root_point[0], PointOnGraphic_Y - Root_point[1], PointOnGraphic_Z - Root_point[2] }; //calculating the modulus of vector OX double OX_Mod = Math.Sqrt(Math.Pow(OX[0], 2) + Math.Pow(OX[1], 2) + Math.Pow(OX[2], 2)); //calculating the modulus of vector Ref_dirX double Ref_dirX_Mod = Math.Sqrt(Math.Pow(Ref_dirX[0], 2) + Math.Pow(Ref_dirX[1], 2) + Math.Pow(Ref_dirX[2], 2)); //calculating the modulus of the vector ReF_dirY double Ref_dirY_Mod = Math.Sqrt(Math.Pow(Ref_dirY[0], 2) + Math.Pow(Ref_dirY[1], 2) + Math.Pow(Ref_dirY[2], 2)); //calculating the dot product between vector OX and Ref_dirY double dotY = (OX[0] * Ref_dirY[0]) + (OX[1] * Ref_dirY[1]) + (OX[2] * Ref_dirY[2]); //calculating the dot product between vector OX and Ref_dirX double dotX = (OX[0] * Ref_dirX[0]) + (OX[1] * Ref_dirX[1]) + (OX[2] * Ref_dirX[2]); //calculating the angle between vector OX and Ref_dirY double angleY = Math.Acos(dotY / (OX_Mod * Ref_dirY_Mod)); //calculating the angle between vector OX and Ref_dirX double angleX = Math.Acos(dotX / (OX_Mod * Ref_dirX_Mod)); double X_dir = 0.0; double Y_dir = 0.0; if (angleY > Math.PI / 2) { X_dir = OX_Mod * Math.Cos(-angleX); Y_dir = OX_Mod * Math.Sin(-angleX); } else { X_dir = OX_Mod * Math.Cos(angleX); Y_dir = OX_Mod * Math.Sin(angleX); } if (OX_Mod == 0.0) { X_dir = 0.0; Y_dir = 0.0; } if (cc > 0.0) { sketchs = _doc.Sketches; sketch = sketchs.Add(); holeDataCollection = _doc.HoleDataCollection; //Defining hole properties holeData = holeDataCollection.Add( HoleType: SolidEdgePart.FeaturePropertyConstants.igRegularHole, HoleDiameter: cc / 1000); profileSets = _doc.ProfileSets; profileSet = profileSets.Add(); //profiles = profileSet.Profiles; profiles = sketch.Profiles; profile = profiles.Add(refPlane); holes2D = profile.Holes2d; var dd = holes2D.Add(X_dir, Y_dir); profile.End(ProfileValidationType.igProfileClosed); // dd.Move(X_dir, Y_dir, 0.0, 0.0); //_application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewLookatFace); //getting the hole collection and creating a simple hole Model model = _doc.Models.Item(1); holes = model.Holes; holes.AddThroughNext( Profile: profile, ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igBoth, Data: holeData); } }
protected void OnProfileSet(WindowProfile newProfile) { ProfileSet?.Invoke(this, new WindowProfileEventArgs(newProfile)); }
public static void RunAll(ProfileSet set) { var runner = ProfileTools.GetSet(set); var reportTime = set switch { ProfileSet.Primitives => 4000, ProfileSet.Middle => 1500, ProfileSet.Complex => 500, ProfileSet.All => 500, _ => throw new ArgumentOutOfRangeException(nameof(set), set, null) }; var buildBench = new ProfileBuildAllSet(); var parseBench = new ProfileParserSet(); var updateBench = new ProfileUpdateSet(); var calculateBench = new ProfileCalculateSet(); for (int i = 0; i < 3; i++) { runner(parseBench); runner(buildBench); runner(updateBench); runner(calculateBench); } int measurementsCount = 0; int historyCount = 10; var parseStopWatch = new Stopwatch(); var parseHistory = new LinkedList <double>(); var buildStopWatch = new Stopwatch(); var buildHistory = new LinkedList <double>(); var interpritateHistory = new LinkedList <double>(); var updateStopWatch = new Stopwatch(); var updateHistory = new LinkedList <double>(); var calcStopWatch = new Stopwatch(); var calcHistory = new LinkedList <double>(); for (int iterations = 1; !Console.KeyAvailable || Console.ReadKey().Key != ConsoleKey.Escape; iterations++) { parseStopWatch.Start(); runner(parseBench); parseStopWatch.Stop(); buildStopWatch.Start(); runner(buildBench); buildStopWatch.Stop(); updateStopWatch.Start(); runner(updateBench); updateStopWatch.Stop(); calcStopWatch.Start(); runner(calculateBench); calcStopWatch.Stop(); if (iterations >= reportTime) { measurementsCount++; parseHistory.AddAndTruncate(parseStopWatch.Elapsed.TotalMilliseconds, historyCount); buildHistory.AddAndTruncate(buildStopWatch.Elapsed.TotalMilliseconds, historyCount); interpritateHistory.AddAndTruncate(buildStopWatch.Elapsed.TotalMilliseconds - parseStopWatch.Elapsed.TotalMilliseconds, historyCount); updateHistory.AddAndTruncate(updateStopWatch.Elapsed.TotalMilliseconds, historyCount); calcHistory.AddAndTruncate(calcStopWatch.Elapsed.TotalMilliseconds, historyCount); var total = parseStopWatch.Elapsed + buildStopWatch.Elapsed + updateStopWatch.Elapsed + calcStopWatch.Elapsed; var buildAndRunTime = buildStopWatch.Elapsed + calcStopWatch.Elapsed; parseStopWatch.Reset(); buildStopWatch.Reset(); updateStopWatch.Reset(); calcStopWatch.Reset(); PrintHeader("everything", set, measurementsCount, total); PrintResults("parse ", buildAndRunTime, parseHistory, iterations); PrintResults("interprt ", buildAndRunTime, interpritateHistory, iterations); PrintResults("calculate", buildAndRunTime, calcHistory, iterations); PrintResults("update ", buildAndRunTime, updateHistory, iterations); PrintFooter(); iterations = 1; } } }