public void CanRoundTripIgesViaStreams() { var disc0 = Modeler.CreateCirclularSheet (center: Vector3.Zero , vNormal: Vector3.UnitZ , vRef: Vector3.UnitX , radius: 2 ); var mStream = new MemoryStream(); disc0.SaveAsIges(stream => { stream.CopyTo(mStream); mStream.Position = 0; }, false); var loadedBody = BodyExtensions.LoadBodiesAsIges(mStream).First(); loadedBody.Should().NotBeNull(); var b0 = disc0.GetBodyBoxTs(); var b1 = loadedBody.GetBodyBoxTs(); b0.P0.X.Should().BeApproximately(b1.P0.X, 1e-5); b0.P0.Y.Should().BeApproximately(b1.P0.Y, 1e-5); b0.P0.Z.Should().BeApproximately(b1.P0.Z, 1e-5); b0.P1.X.Should().BeApproximately(b1.P1.X, 1e-5); b0.P1.Y.Should().BeApproximately(b1.P1.Y, 1e-5); b0.P1.Z.Should().BeApproximately(b1.P1.Z, 1e-5); }
public async Task GetTrimCurves2ForADiscShouldReturnASingleNonPeriodicClosedTrimCurve() { await CreatePartDoc(async (modelDoc, yielder) => { var disc0 = Modeler.CreateCirclularSheet (center: Vector3.Zero , vNormal: Vector3.UnitZ , vRef: Vector3.UnitX , radius: 2 ); // Display the original sheet. Visually verify it is ok. // Press "Continue Test Execution" button within solidworks // to continue the test after visual inspection of the sheet using (disc0.DisplayUndoable(modelDoc)) await PauseTestExecution(pause: false); // The sheet should only have one face. Extract it var faces = disc0.GetFaces().CastArray <IFace2>(); faces.Length.Should().Be(1); var face = faces[0]; // Convert the solidworks face to a bspline face var bsplineFace = BSplineFace.Create(face); bsplineFace.TrimLoops.Count.Should().Be(1); bsplineFace.TrimLoops[0].Count.Should().Be(1); // The curve is a clamped closed curve. It is not "Solidworks periodic" bsplineFace.TrimLoops[0][0].KnotVectorU.Take(3).ShouldBeEquivalentTo(new[] { 0, 0, 0 }); bsplineFace.TrimLoops[0][0].KnotVectorU.TakeLast(3).ShouldBeEquivalentTo(new[] { 1, 1, 1 }); var controlPoints00 = bsplineFace.TrimLoops[0][0].ControlPoints; controlPoints00.First() .Should().Be(controlPoints00.Last()); // This is not solidworks periodic so this property should be false bsplineFace.TrimLoops[0][0].IsClosed.Should().BeTrue(); }); }
public async Task CanRebuildACirclularSheet() { await CreatePartDoc(async (modelDoc, yielder) => { var disc0 = Modeler.CreateCirclularSheet (center: Vector3.Zero , vNormal: Vector3.UnitZ , vRef: Vector3.UnitX , radius: 2 ); // Display the original sheet. Visually verify it is ok. // Press "Continue Test Execution" button within solidworks // to continue the test after visual inspection of the sheet using (disc0.DisplayUndoable(modelDoc)) await PauseTestExecution(); // The sheet should only have one face. Extract it var faces = disc0.GetFaces().CastArray <IFace2>(); faces.Length.Should().Be(1); var face = faces[0]; // Convert the solidworks face to a bspline face var bsplineFace = BSplineFace.Create(face); // Convert the bspline face back to a sheet body var disc1 = bsplineFace.ToSheetBody().__Value__(); // Display the recovered sheet. Visually verify it is ok // Press "Continue Test Execution" button within solidworks // to continue the test after visual inspection of the sheet using (disc1.DisplayUndoable(modelDoc)) await PauseTestExecution(); await PauseTestExecution(); }); }