Exemplo n.º 1
0
 public void LengthsAreEqual()
 {
     DwgTest.ExecuteActionsInDwg(KnownValues.Notches1.DrawingPath, (db, trans) =>
     {
         var(sourceCurve, sourceNotches, targetCurve) = KnownValues.Notches1.ToObjects(db, trans);
         var sourceLength     = (sourceCurve as Polyline).Length;
         var distSourceLength = AcadHelpers.GetCurveLength(sourceCurve);
         sourceLength.ShouldBe(distSourceLength);
     });
 }
Exemplo n.º 2
0
        public (Curve sourceCurve, IEnumerable <Point3d> sourceNotches, Curve targetCurve) ToObjects(Database db, Transaction trans)
        {
            var sourceCurve = AcadHelpers.GetObject <Polyline>(SourceCurveHandle, db, trans);
            var targetCurve = AcadHelpers.GetObject <Polyline>(TargetCurveHandle, db, trans);

            var notches = SourceNotchLines.Select(lineHandle =>
            {
                var line = AcadHelpers.GetObject <Line>(lineHandle, db, trans);
                return(AcadHelpers.GetSingleIntersection(sourceCurve, line));
            });

            return(sourceCurve, notches.ToList(), targetCurve);
        }
Exemplo n.º 3
0
        public Projector ToProjector(Database db, Transaction trans)
        {
            var sourceCurve = AcadHelpers.GetObject <Polyline>(SourceCurveHandle, db, trans);
            var targetCurve = AcadHelpers.GetObject <Polyline>(TargetCurveHandle, db, trans);

            var notches = SourceNotchLines.Select(lineHandle =>
            {
                var line = AcadHelpers.GetObject <Line>(lineHandle, db, trans);
                return(AcadHelpers.GetSingleIntersection(sourceCurve, line));
            });

            return(new Projector(sourceCurve, notches.ToList(), targetCurve, TargetFacetPercentages));
        }
Exemplo n.º 4
0
        public void ShouldProject()
        {
            DwgTest.ExecuteActionsInDwg(KnownValues.Notches1.DrawingPath, (db, tx) =>
            {
                var projector     = KnownValues.Notches1.ToProjector(db, tx);
                var targetNotches = projector.Project();

                AcadHelpers.GeneratePoints(db, tx, targetNotches);
                AcadHelpers.ConfigurePointsToBeVisible(db);

                return(KnownValues.Notches1.GenerateSnapshotDrawingPath());
            });
        }
Exemplo n.º 5
0
        public void ShouldFindNotchPointsByLinesOnCurve()
        {
            DwgTest.ExecuteActionsInDwg(KnownValues.Notches1.DrawingPath, (db, trans) =>
            {
                var sourceCurve = AcadHelpers.GetObject <Polyline>(KnownValues.Notches1.SourceCurveHandle, db, trans);

                foreach (var lineHandle in KnownValues.Notches1.SourceNotchLines)
                {
                    var line = AcadHelpers.GetObject <Line>(lineHandle, db, trans);
                    AcadHelpers.GetSingleIntersection(sourceCurve, line);
                }
            });
        }
Exemplo n.º 6
0
        public void UpdateDestinationNotches()
        {
            UpdateProjectorFromParams();

            var document = Application.DocumentManager.MdiActiveDocument;

            using (document.LockDocument())
            {
                using (var tx = document.TransactionManager.StartTransaction())
                {
                    var db            = document.Database;
                    var targetNotches = projector.Project();
                    AcadHelpers.GeneratePoints(db, tx, targetNotches);
                    AcadHelpers.ConfigurePointsToBeVisible(db);

                    tx.Commit();
                }
            }
        }
Exemplo n.º 7
0
        public void Props()
        {
            DwgTest.ExecuteActionsInDwg(KnownValues.Notches1.DrawingPath, (db, trans) =>
            {
                var(sourceCurve, sourceNotches, targetCurve) = KnownValues.Notches1.ToObjects(db, trans);

                var notchCollection = new Point3dCollection(sourceNotches.ToArray());
                var notchSegments   = sourceCurve.GetSplitCurves(notchCollection);

                var sourceLength = AcadHelpers.GetCurveLength(sourceCurve);

                var facet1 = notchSegments[0] as Curve;

                var facet1Length         = AcadHelpers.GetCurveLength(facet1);
                var facet1RatioByLengths = facet1Length / sourceLength;

                //var facet1RatioByParams = sourceCurve.GetParameterAtPoint(notchCollection[0]) / (sourceCurve.EndParam - sourceCurve.StartParam);
                //facet1RatioByLengths.ShouldBe(facet1RatioByParams);
            });
        }