public void ProfileCustom() { var sketch = Sketch.Create(); var body = Body.Create(sketch); var sb = new SketchBuilder(sketch); sb.StartPath(0, 0); sb.LineTo(10, 0); sb.LineTo(15, 5); sb.LineTo(25, 10); sb.LineTo(20, 0); var profile = Sketch.Create(); sb = new SketchBuilder(profile); sb.StartPath(-0.5, -0.5); sb.LineTo(0, 0.5); sb.LineTo(0.5, -0.5); sb.LineTo(-0.5, -0.5); sb.ClosePath(); var pipe = Pipe.Create(body, profile); Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "ProfileCustom01"))); }
public void HlrPolyGeneration() { // Create simple geometry var imprint = TestGeomGenerator.CreateImprint(); Assert.IsTrue(imprint.Make(Shape.MakeFlags.None)); var ocShape = imprint.GetTransformedBRep(); // Create HLR Algo var hlrAlgo = new HlrBRepAlgoPoly(new[] { ocShape }); hlrAlgo.SetProjection(_Projection); hlrAlgo.Update(); // Get Hlr Shape var visibleSharp = hlrAlgo.GetResult(HlrEdgeType.VisibleSharp); Assert.IsNotNull(visibleSharp); Assert.IsTrue(ModelCompare.CompareShape(visibleSharp, Path.Combine(_BasePath, "Poly_VisSharp"))); var hiddenSharp = hlrAlgo.GetResult(HlrEdgeType.HiddenSharp); Assert.IsNotNull(hiddenSharp); Assert.IsTrue(ModelCompare.CompareShape(hiddenSharp, Path.Combine(_BasePath, "Poly_HidSharp"))); }
public void VaryBendRadius() { var sketch = Sketch.Create(); var body = Body.Create(sketch); var sb = new SketchBuilder(sketch); sb.StartPath(0, 0); sb.LineTo(10, 0); sb.LineTo(15, 5); sb.LineTo(25, 10); sb.LineTo(20, 0); var pipe = Pipe.Create(body); Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "VaryBendRadius01"))); pipe.Flags = pipe.Flags.Removed(Pipe.PipeFlags.AutoBendRadius); pipe.BendRadius = 0.5; Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "VaryBendRadius02"))); pipe.SizeX = 1.5; Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "VaryBendRadius03"))); pipe.Flags = pipe.Flags.Added(Pipe.PipeFlags.AutoBendRadius); Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "VaryBendRadius04"))); }
public void SpineStartOffset() { var sketch = Sketch.Create(); var body = Body.Create(sketch); var sb = new SketchBuilder(sketch); sb.StartPath(40, -165); sb.LineTo(48, -110); sb.LineTo(105, -116); sb.LineTo(160, -80); sb.LineTo(112, -30); sb.LineTo(73, -25); var pipe = Pipe.Create(body); pipe.Profile = Pipe.ProfileType.Rectangle; pipe.SizeX = 3.0; /* pipe.Profile = Pipe.ProfileType.Circle; * Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); * Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "SpineStartOffset01")));*/ pipe.Profile = Pipe.ProfileType.Rectangle; Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "SpineStartOffset02"))); }
public void FlangeNamedSubshapes() { var box = Box.Create(10.0, 10.0, 1.0); var body = Body.Create(box); var flangeSheet = FlangeSheet.Create(body, new SubshapeReference(SubshapeType.Face, box.Guid, 1), 45.0, 5.0); Assume.That(ModelCompare.CompareShape(flangeSheet, Path.Combine(_BasePath, "FlangeNamedSubshapes"))); var faces = flangeSheet.GetBRep().Faces(); _TestSubshape(9, "Flange", 0); _TestSubshape(10, "Flange", 1); _TestSubshape(11, "Flange", 2); _TestSubshape(12, "Flange", 3); _TestSubshape(13, "Flange", 5); _TestSubshape(8, "Bend", 3); _TestSubshape(7, "Bend", 2); _TestSubshape(6, "Bend", 1); _TestSubshape(5, "Bend", 0); void _TestSubshape(int faceIndex, string expectedName, int expectedIndex) { var subshapeReference = flangeSheet.GetSubshapeReference(SubshapeType.Face, faceIndex); Assert.That(subshapeReference.Name, Is.EqualTo(expectedName)); Assert.That(subshapeReference.Index, Is.EqualTo(expectedIndex)); var foundFaces = flangeSheet.FindSubshape(subshapeReference, null); Assert.That(foundFaces.Count, Is.EqualTo(1)); Assert.That(foundFaces[0].IsSame(faces[faceIndex])); } }
public void ProfileHollowRectangle() { var sketch = Sketch.Create(); var body = Body.Create(sketch); var sb = new SketchBuilder(sketch); sb.StartPath(0, 0); sb.LineTo(10, 0); sb.LineTo(15, 5); sb.LineTo(25, 10); sb.LineTo(20, 0); var pipe = Pipe.Create(body); pipe.Profile = Pipe.ProfileType.HollowRectangle; pipe.SizeX = 0.5; Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "ProfileHollowRectangle01"))); pipe.Flags = pipe.Flags.Removed(Pipe.PipeFlags.SymmetricProfile); Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "ProfileHollowRectangle02"))); pipe.SizeX = 1.5; pipe.Thickness = 0.2; Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "ProfileHollowRectangle03"))); // Too thick pipe.SizeX = 1.5; pipe.Thickness = 1.0; Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "ProfileHollowRectangle04"))); }
public void AsciiReadWrite() { var originalBytes = TestData.GetTestData(@"SourceData\Brep\ImprintRingFace.brep"); Assume.That(originalBytes, Is.Not.Null); // Read in var originalShape = BRepExchange.ReadASCII(originalBytes); Assert.IsNotNull(originalShape); Assert.AreEqual(TopAbs_ShapeEnum.TopAbs_COMPOUND, originalShape.ShapeType()); // Write out var writtenBytes = BRepExchange.WriteASCII(originalShape, false); Assert.IsNotNull(writtenBytes); Assert.AreEqual(4900, writtenBytes.Length, 50); // due to some slight differences (e.g. +/-0) // Re-read in var rereadShape = BRepExchange.ReadASCII(writtenBytes); Assert.IsNotNull(rereadShape); Assert.AreEqual(TopAbs_ShapeEnum.TopAbs_COMPOUND, rereadShape.ShapeType()); Assert.IsFalse(_HasTriangulation(rereadShape), "HasTriangulation"); Assert.IsTrue(ModelCompare.CompareShape(rereadShape, @"SourceData\Brep\ImprintRingFace")); }
public void ImprintCopiedEdgeReference() { var imprint = TestGeomGenerator.CreateImprint(); imprint.Depth = 2.5; imprint.Mode = Imprint.ImprintMode.Raise; Assert.IsTrue(imprint.Make(Shape.MakeFlags.None)); var edges = imprint.GetBRep().Edges(); var chamfer = Chamfer.Create(imprint.Body); chamfer.Mode = Chamfer.ChamferModes.Symmetric; chamfer.Edges = new[] { imprint.GetSubshapeReference(edges[9]), imprint.GetSubshapeReference(edges[14]) }; chamfer.Distance = 1; chamfer.SecondDistance = 1; Assert.IsNotNull(chamfer.Edges[0]); Assert.IsNotNull(chamfer.Edges[1]); Assert.AreNotEqual(chamfer.Edges[0], chamfer.Edges[1], "Double edge references!"); Assert.IsTrue(chamfer.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(chamfer, Path.Combine(_BasePath, "ImprintCopiedEdge"))); }
public void BinaryReadWrite() { var originalBytes = TestData.GetTestData(@"SourceData\Brep\ImprintRingFace.brep"); Assume.That(originalBytes, Is.Not.Null); // Read in as ASCII var originalShape = BRepExchange.ReadASCII(originalBytes); Assert.IsNotNull(originalShape); Assert.AreEqual(TopAbs_ShapeEnum.TopAbs_COMPOUND, originalShape.ShapeType()); // Write out var writtenBytes = BRepExchange.WriteBinary(originalShape, false); Assert.IsNotNull(writtenBytes); Assert.AreEqual(7222, writtenBytes.Length); // Re-read in var rereadShape = BRepExchange.ReadBinary(writtenBytes); Assert.IsNotNull(rereadShape); Assert.AreEqual(TopAbs_ShapeEnum.TopAbs_COMPOUND, rereadShape.ShapeType()); Assert.IsFalse(_HasTriangulation(rereadShape), "HasTriangulation"); Assert.IsTrue(ModelCompare.CompareShape(rereadShape, @"SourceData\Brep\ImprintRingFace")); }
public void FlangesOnSameFaceWithNoGaps() { /* The Flange modifier shouldn't allow this: * 1. The Unfold modifier will proberly have problems to find bend section, since faces are shared between bend sections. * 2. It cannot be produces, to have seperate flanges there must be a minimum gap between them (by cutting, edging, etc) */ var box = Box.Create(10.0, 10.0, 1.0); var body = Body.Create(box); var flangeSheet1 = FlangeSheet.Create(body, new SubshapeReference(SubshapeType.Face, box.Guid, 1), 45.0, 5.0); flangeSheet1.StartGap = 7.5; flangeSheet1.EndGap = 0.0; flangeSheet1.Relief = FlangeSheet.ReliefFlags.Rectangular; var flangeSheet2 = FlangeSheet.Create(body, flangeSheet1.GetSubshapeReference(SubshapeType.Face, 7), 45.0, 5.0); flangeSheet2.StartGap = 5.0; flangeSheet2.EndGap = 0.0; flangeSheet2.Relief = FlangeSheet.ReliefFlags.Rectangular | FlangeSheet.ReliefFlags.OppositeSide; var flangeSheet3 = FlangeSheet.Create(body, flangeSheet2.GetSubshapeReference(SubshapeType.Face, 12), 45.0, 5.0); flangeSheet3.StartGap = 0.0; flangeSheet3.EndGap = 0.0; Assume.That(flangeSheet3.Make(Shape.MakeFlags.None)); Assert.That(flangeSheet3.Make(Shape.MakeFlags.DebugOutput)); Assert.That(ModelCompare.CompareShape(flangeSheet3, Path.Combine(_BasePath, "FlangesOnSameFaceWithNoGaps"))); }
public void ReversedFace() { var baseShape = new Box { DimensionX = 20, DimensionY = 20, DimensionZ = 20, }; var body = TestGeomGenerator.CreateBody(baseShape, new Pnt(-10, -10, 0)); var imprint = Imprint.Create(body, baseShape.GetSubshapeReference(SubshapeType.Face, 0)); var sketch = imprint.Operands[1] as Sketch; Assert.IsNotNull(sketch); sketch.Points.Add(0, new Pnt2d(0, 0)); sketch.Points.Add(1, new Pnt2d(0, 11)); sketch.Segments.Add(0, new SketchSegmentCircle(0, 1)); Assert.IsNotNull(imprint); imprint.Depth = 2.5; imprint.Mode = Imprint.ImprintMode.Raise; Assert.IsTrue(imprint.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(imprint, Path.Combine(_BasePath, "ReversedFace"))); }
public void SplitEllipticalArcReversed() { var sketch = Sketch.Create(); int p1 = sketch.AddPoint(new Pnt2d(-2, 5)); int p2 = sketch.AddPoint(new Pnt2d(2, 1)); int pc = sketch.AddPoint(new Pnt2d(0, 0)); int s1 = sketch.AddSegment(new SketchSegmentEllipticalArc(p1, p2, pc)); (int p3, int[] segs) = SketchUtils.SplitSegment(sketch, sketch.Segments[s1], Maths.PI * 0.25); Assert.AreNotEqual(SketchUtils.SplitSegmentFailed, (p3, segs)); Assert.AreEqual(12, sketch.Points.Count); Assert.AreEqual(4, sketch.Segments.Count); Assert.IsInstanceOf <SketchSegmentEllipticalArc>(sketch.Segments[segs[0]]); Assert.That(sketch.Segments[segs[0]].Points.SequenceEqual(new[] { p1, p3, pc })); Assert.IsInstanceOf <SketchSegmentBezier>(sketch.Segments[segs[1]]); Assert.That(sketch.Segments[segs[1]].Points.SequenceEqual(new[] { p3, p3 + 1, p3 + 2, p3 + 3 })); Assert.IsInstanceOf <SketchSegmentBezier>(sketch.Segments[segs[2]]); Assert.That(sketch.Segments[segs[2]].Points.SequenceEqual(new[] { p3 + 3, p3 + 4, p3 + 5, p3 + 6 })); Assert.IsInstanceOf <SketchSegmentBezier>(sketch.Segments[segs[3]]); Assert.That(sketch.Segments[segs[3]].Points.SequenceEqual(new[] { p3 + 6, p3 + 7, p3 + 8, p2 })); Assert.IsTrue(sketch.Make(Shape.MakeFlags.None)); ModelCompare.CompareShape2D(sketch, Path.Combine(_BasePath, "SplitEllipticalArcReversed")); }
public void GenerateHlrMultiShape() { // Create simple geometry var imprint = TestGeomGenerator.CreateImprint(); Assert.IsTrue(imprint.Make(Shape.MakeFlags.None)); var ocShape = imprint.GetTransformedBRep(); var box = new Box() { DimensionX = 10, DimensionY = 10, DimensionZ = 10 }; Assert.IsTrue(box.Make(Shape.MakeFlags.None)); var ocBoxShape = box.GetBRep(); // Create HLR Algo var hlrAlgo = new HlrBRepAlgo(new[] { ocShape, ocBoxShape }); hlrAlgo.SetProjection(_Projection); hlrAlgo.Update(); // Get Hlr Shape var visibleSharp = hlrAlgo.GetResult(HlrEdgeType.VisibleSharp); Assert.IsNotNull(visibleSharp); Assert.IsTrue(ModelCompare.CompareShape(visibleSharp, Path.Combine(_BasePath, "MultiShape_VisSharp"))); }
public void NoBend() { var box = Box.Create(10.0, 10.0, 1.0); var body = Body.Create(box); var flangeSheet = FlangeSheet.Create(body, new SubshapeReference(SubshapeType.Face, box.Guid, 1), 0.0, 5); Assert.IsTrue(ModelCompare.CompareShape(flangeSheet, Path.Combine(_BasePath, "NoBend"))); }
public void Cut() { var shapes = TestGeomGenerator.CreateBooleanBodies(false); var boolOp = BooleanCut.Create(shapes.target, shapes.operands); Assert.IsTrue(boolOp.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(boolOp, Path.Combine(_BasePath, "Cut"))); }
public void MultiCurve() { var shape = CreateSketch(SketchType.MultiCurve); Assert.IsNotNull(shape); Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "MultiCurve"), ModelCompare.CompareFlags.CompareBytes)); }
public void CircleOfArcs() { var sketch = TestSketchGenerator.CreateCircleWithArcs(10, 4); var pipe = Pipe.Create(sketch.Body); Assert.IsNotNull(pipe); Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "CircleOfArcs"))); }
public void ReliefRectangular() { var box = Box.Create(10.0, 10.0, 1.0); var body = Body.Create(box); var flangeSheet = FlangeSheet.Create(body, new SubshapeReference(SubshapeType.Face, box.Guid, 1), 45.0, 5.0, 1.0); flangeSheet.Relief = FlangeSheet.ReliefFlags.Rectangular; Assert.IsTrue(ModelCompare.CompareShape(flangeSheet, Path.Combine(_BasePath, "ReliefRectangular"))); }
public void Rectangle() { var sketch = TestSketchGenerator.CreateRectangle(10, 5); var pipe = Pipe.Create(sketch.Body); Assert.IsNotNull(pipe); Assert.IsTrue(pipe.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(pipe, Path.Combine(_BasePath, "Rectangle"))); }
public void SecondFlangeOnFlangeSide() { var source = TestData.GetBodyFromBRep(Path.Combine(_BasePath, "SecondFlangeOnFlangeSide_Source.brep")); Assume.That(source, Is.Not.Null); var flangeSheet = FlangeSheet.Create(source, new SubshapeReference(SubshapeType.Face, source.Shape.Guid, 2), 45.0, 5.0); Assert.IsTrue(ModelCompare.CompareShape(flangeSheet, Path.Combine(_BasePath, "SecondFlangeOnFlangeSide"))); }
public void GapStart() { var box = Box.Create(10.0, 10.0, 1.0); var body = Body.Create(box); var flangeSheet = FlangeSheet.Create(body, new SubshapeReference(SubshapeType.Face, box.Guid, 1), 45.0, 5.0); flangeSheet.StartGap = 2.5; Assert.IsTrue(ModelCompare.CompareShape(flangeSheet, Path.Combine(_BasePath, "GapStart"))); }
public void CurveLocalY() { var shape = CreateRevolve(SketchType.Curve); Assert.IsNotNull(shape); shape.Axis = Revolve.RevolveAxis.LocalY; Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "CurveLocalY"))); }
public void Simple() { var shape = new Sphere() { Radius = 10 }; Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "Simple"))); }
public void Cutout() { var shape = TestGeomGenerator.CreateImprint(); Assert.IsNotNull(shape); shape.Depth = 2.5; shape.Mode = Imprint.ImprintMode.Cutout; Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "Cutout"))); }
public void Multiple() { var box = Box.Create(10.0, 10.0, 1.0); var body = Body.Create(box); var flangeSheet1 = FlangeSheet.Create(body, box.GetSubshapeReference(SubshapeType.Face, 1), 20.0, 5.0); var flangeSheet2 = FlangeSheet.Create(body, box.GetSubshapeReference(SubshapeType.Face, 3), 40.0, 5.0); var flangeSheet3 = FlangeSheet.Create(body, box.GetSubshapeReference(SubshapeType.Face, 0), 60.0, 5.0); var flangeSheet4 = FlangeSheet.Create(body, box.GetSubshapeReference(SubshapeType.Face, 2), 80.0, 5.0); var flangeSheet5 = FlangeSheet.Create(body, flangeSheet4.GetSubshapeReference(SubshapeType.Face, 7), 30.0, 5.0); Assert.IsTrue(ModelCompare.CompareShape(flangeSheet5, Path.Combine(_BasePath, "Multiple"))); }
public void MultiFace() { var shape = TestGeomGenerator.CreateImprint(TestGeomGenerator.SketchType.MultiCircle); Assert.IsNotNull(shape); shape.Depth = 2.5; shape.Mode = Imprint.ImprintMode.Raise; Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "MultiFace"))); }
public void SwappedEdgeDirection() { var box = Box.Create(10.0, 10.0, 1.0); var body = Body.Create(box); var flangeSheet = FlangeSheet.Create(body, new SubshapeReference(SubshapeType.Face, box.Guid, 2), 45.0, 5.0); flangeSheet.StartGap = 2.0; flangeSheet.EndGap = 5.0; flangeSheet.Relief = FlangeSheet.ReliefFlags.Rectangular; Assert.IsTrue(ModelCompare.CompareShape(flangeSheet, Path.Combine(_BasePath, "SwappedEdgeDirection"))); }
public void MultiCurve() { var shape = CreateRevolve(SketchType.MultiCurve); Assert.IsNotNull(shape); shape.Axis = Revolve.RevolveAxis.LocalY; shape.SegmentAngle = 120; Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "MultiCurve"))); }
public void Offset() { var shape = CreateRevolve(SketchType.Curve); Assert.IsNotNull(shape); shape.Axis = Revolve.RevolveAxis.LocalY; shape.Offset = new Vec(-10, 0, 0); Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "Offset"))); }
public void MinLatitude() { var shape = new Sphere() { Radius = 10, MinLatitude = 30 }; Assert.IsTrue(shape.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "MinLatitude"))); }