public void It_Returns_The_Intersections_Between_A_3D_Curves() { // Arrange int degree = 3; List <Point3> crvPts0 = new List <Point3> { new Point3(0, 0, 0), new Point3(5, 2.5, 5), new Point3(5, 5, 0), new Point3(7.5, 10, 5), new Point3(10, 10, 0) }; List <Point3> crvPts1 = new List <Point3> { new Point3(2.225594, 1.226218, 2.01283), new Point3(8.681402, 4.789645, 5.010206), new Point3(6.181402, 4.789645, 0.010206), new Point3(1.181402, 7.289645, 5.010206), new Point3(8.496731, 9.656647, 2.348212) }; NurbsCurve crv0 = new NurbsCurve(crvPts0, degree); NurbsCurve crv1 = new NurbsCurve(crvPts1, degree); // Act List <CurvesIntersectionResult> intersections = Intersect.CurveCurve(crv0, crv1); // Assert intersections.Count.Should().Be(3); foreach (CurvesIntersectionResult intersection in intersections) { _testOutput.WriteLine(intersection.ToString()); intersection.PointA.DistanceTo(intersection.PointB).Should().BeLessThan(GSharkMath.MaxTolerance); } }
public void It_Returns_The_Intersections_Between_A_Planar_Curves() { // Arrange int degree = 3; List <Point3> crvPts0 = new List <Point3> { new Point3(-5, 0, 0), new Point3(10, 0, 0), new Point3(10, 10, 0), new Point3(0, 10, 0), new Point3(5, 5, 0) }; List <Point3> crvPts1 = new List <Point3> { new Point3(-5, 0, 0), new Point3(5, -1, 0), new Point3(10, 5, 0), new Point3(3, 10, 0), new Point3(5, 12, 0) }; NurbsCurve crv0 = new NurbsCurve(crvPts0, degree); NurbsCurve crv1 = new NurbsCurve(crvPts1, degree); // Act List <CurvesIntersectionResult> intersections = Intersect.CurveCurve(crv0, crv1); // Assert intersections.Count.Should().Be(3); foreach (CurvesIntersectionResult intersection in intersections) { _testOutput.WriteLine(intersection.ToString()); intersection.PointA.DistanceTo(intersection.PointB).Should().BeLessThan(GSharkMath.MaxTolerance); } }
public static bool TryJoin(Brep b1, Brep b2, out Brep result) { List <Curve> c1 = CurveUtils.Join(b1.GetExternalEdges()); List <Curve> c2 = CurveUtils.Join(b2.GetExternalEdges()); List <Curve> nakedEdges = new List <Curve>(); List <Curve> overlappedEdges = new List <Curve>(); List <Point> pts = new List <Point>(); List <Curve> updatedN = new List <Curve>(); List <Curve> updatedI = new List <Curve>(); for (int i = 0; i < c1.Count; i++) { for (int j = 0; j < c2.Count; j++) { if (Intersect.CurveCurve(c1[i], c2[j], 0.001, out pts, out overlappedEdges, out nakedEdges)) { updatedN.AddRange(nakedEdges); updatedN.AddRange(overlappedEdges); } } } if (updatedN.Count > 0) { Group <Brep> polySurface = new Group <Brep>(); if (b1 is PolySurface) { polySurface.AddRange((b1 as PolySurface).Surfaces); } else { polySurface.Add(b1); } if (b2 is PolySurface) { polySurface.AddRange((b2 as PolySurface).Surfaces); } else { polySurface.Add(b2); } result = new PolySurface(polySurface); result.GetExternalEdges().AddRange(updatedN); result.GetInternalEdges().AddRange(updatedI); return(true); } else { result = null; return(false); } }
public void It_Returns_The_Intersection_Between_A_Planar_Curves() { // Arrange int crvDegree0 = 2; var crvPts0 = new List <Point3> { new Point3(0, 0, 0), new Point3(0.5, 0.1, 0), new Point3(2, 0, 0) }; int crvDegree1 = 2; var crvPts1 = new List <Point3> { new Point3(0.5, 0.5, 0), new Point3(0.7, 0, 0), new Point3(0.5, -1.5, 0) }; NurbsCurve crv0 = new NurbsCurve(crvPts0, crvDegree0); NurbsCurve crv1 = new NurbsCurve(crvPts1, crvDegree1); // Act List <CurvesIntersectionResult> intersection = Intersect.CurveCurve(crv0, crv1); // Assert _testOutput.WriteLine(intersection[0].ToString()); intersection.Count.Should().Be(1); intersection[0].PointA.DistanceTo(intersection[0].PointB).Should().BeLessThan(GSharkMath.MaxTolerance); }
public void It_Returns_The_Intersection_Between_Two_Planar_Lines() { // Arrange int crvDegree0 = 1; var crvPts0 = new List <Point3> { new Point3(0, 0, 0), new Point3(2, 0, 0) }; int crvDegree1 = 1; var crvPts1 = new List <Point3> { new Point3(0.5, 0.5, 0), new Point3(0.5, -1.5, 0) }; NurbsCurve crv0 = new NurbsCurve(crvPts0, crvDegree0); NurbsCurve crv1 = new NurbsCurve(crvPts1, crvDegree1); // Act List <CurvesIntersectionResult> intersection = Intersect.CurveCurve(crv0, crv1, GSharkMath.MaxTolerance); // Assert intersection.Count.Should().Be(1); intersection[0].ParameterA.Should().BeApproximately(0.25, GSharkMath.MaxTolerance); intersection[0].ParameterB.Should().BeApproximately(0.25, GSharkMath.MaxTolerance); }