Example #1
0
        public void SameXCoordinateMatch()
        {
            var document = TestUtils.DefaultsSetup();
            var solver   = new Solver(document);

            document.Transact();
            var sketchCreator = new SketchCreator(document, false);
            var sketchNode    = sketchCreator.BuildSketchNode();

            document.Commit("Added sketch");
            document.Transact();

            var point = new SolverGeometricObject(sketchNode);

            point.AddPoint(new SolverDataPoint(new Point3D(10, 2, 0)));
            solver.Geometry.Add(point);
            solver.LastGeometry.Add(point);
            var coordinateMatch = new SameCoordinatePoints(solver, 2);

            var pointN       = new Point3D(10 + 0.1, 20 - 0.1, 0.1);
            var plnOfTheView = new gpPln(new gpPnt(0, 0, 0), new gpDir(0, 0, 1));
            var solutions    = coordinateMatch.InterestingShapeAroundPoint(plnOfTheView, pointN);

            Assert.AreEqual(solutions.Count, 1);
            var solution = solutions.First();

            Assert.IsTrue(solution != null, "A solution should be found");
            Assert.IsTrue(solution is SolverEdgeTwoPointsResult, "Invalid solution type");
            Assert.IsTrue(solution.Point.IsEqual(new Point3D(10, 19.9, 0)), "Invalid magic point found");
        }
Example #2
0
        public void XYCoordinatesMatch()
        {
            var document = TestUtils.DefaultsSetup();
            var solver   = new Solver(document);

            document.Transact();
            var sketchCreator = new SketchCreator(document, false);
            var sketchNode    = sketchCreator.BuildSketchNode();

            document.Commit("Added sketch");
            document.Transact();

            var point = new SolverGeometricObject(sketchNode);

            point.AddPoint(new SolverDataPoint(new Point3D(4, 11, 0)));
            solver.Geometry.Add(point);
            solver.LastGeometry.Add(point);
            var interestingPoints = new List <SolverPreviewObject>();
            var pointN            = new Point3D(3.9, 2.9, 0.1);
            var plnOfTheView      = new gpPln(new gpPnt(0, 0, 0), new gpDir(0, 0, 1));
            var coordinateMatch   = new SameCoordinatePoints(solver, 2);
            var solutions         = coordinateMatch.InterestingShapeAroundPoint(plnOfTheView, pointN);

            Assert.AreEqual(solutions.Count, 1);
            var solution = solutions.First();

            Assert.IsTrue(solution != null, "A solution should be found");
            Assert.IsTrue(solution is SolverEdgeTwoPointsResult, "Invalid solution type");
            interestingPoints.Add(solution);

            point = new SolverGeometricObject(sketchNode);
            point.AddPoint(new SolverDataPoint(new Point3D(10, 3, 0)));
            solver.Geometry.Clear();
            solver.LastGeometry.Clear();
            solver.Geometry.Add(point);
            solver.LastGeometry.Add(point);
            coordinateMatch = new SameCoordinatePoints(solver, 2);
            solutions       = coordinateMatch.InterestingShapeAroundPoint(plnOfTheView, pointN);
            Assert.AreEqual(solutions.Count, 1);
            solution = solutions.First();
            interestingPoints.Add(solution);
            Assert.IsTrue(solution != null, "A solution should be found");
            Assert.IsTrue(solution is SolverEdgeTwoPointsResult, "Invalid solution type");

            var results = SolverTestsUtils.GetIntersectionPoints(interestingPoints, document);

            Assert.AreEqual(results.Count, 1, "Wrong number of intersection results!");
            Assert.IsTrue(results[0].IsEqual(new Point3D(4, 3, 0)), "Invalid magic point found");
        }