示例#1
0
        private static IBody2[] RoundTrip(IBody2 cutBody)
        {
            var faces  = cutBody.GetFaces().CastArray <IFace2>();
            var sheets = faces.Select(face => BSplineFace.Create(face).ToSheetBody()).ToArray();

            //foreach (var sheet in sheets)
            //{
            //    yielder(sheet.DisplayUndoable(modelDoc));
            //}


            var error = (int)swSheetSewingError_e.swSewingOk;
            var body  = Modeler
                        .CreateBodiesFromSheets2(sheets, (int)swSheetSewingOption_e.swSewToSolid, 1e-5, ref error)
                        .CastArray <IBody2>();

            return(body);
        }
        public async Task CanRebuildASquareSheet()
        {
            await CreatePartDoc(async (modelDoc, yielder) =>
            {
                var box    = Modeler.CreateSheet(Vector3.Zero, Vector3.UnitZ, 2);
                var faces  = box.GetFaces().CastArray <IFace2>();
                var sheets = faces
                             .Select
                                 (face =>
                {
                    var faceParams = BSplineFace.Create(face)
                                     .TransformSurfaceControlPoints
                                         (ctrlPts => ctrlPts.Select(v => new Vector4(v.X + 2, v.Y, v.Z, v.W)));

                    return(faceParams.ToSheetBody());
                })
                             .AssertAllSome()
                             .ToArray();

                using (box.DisplayUndoable(modelDoc)) {
                    await PauseTestExecution();
                };

                //foreach (var sheet in sheets)
                //{
                //    yielder(sheet.DisplayUndoable(modelDoc));
                //}


                var error = (int)swSheetSewingError_e.swSewingOk;
                var body  = Modeler
                            .CreateBodiesFromSheets2(sheets, (int)swSheetSewingOption_e.swSewToSolid, 1e-5, ref error)
                            .CastArray <IBody2>();

                body.Should().NotBeEmpty();

                yielder(body.DisplayUndoable(modelDoc));

                await PauseTestExecution();
            });
        }
        public async Task CanRebuildComplexFeature()
        {
            await CreatePartDoc(async (modelDoc, yielder) =>
            {
                var m       = SwAddinBase.Active.Modeler;
                var cone    = m.CreateCone(0.8, 0.2, 5);
                var box     = m.CreateBox(1, 2, 3);
                var solid   = box.Cut(cone);
                var cutBody = solid.Bodies[0];

                var faces  = cutBody.GetFaces().CastArray <IFace2>();
                var sheets = faces
                             .Select
                                 (face =>
                {
                    var faceParams = BSplineFace.Create(face)
                                     .TransformSurfaceControlPoints
                                         (ctrlPts => ctrlPts.Select(v => new Vector4(v.X + 1, v.Y, v.Z, v.W)));

                    return(faceParams.ToSheetBody());
                })
                             .ToArray();

                //foreach (var sheet in sheets)
                //{
                //    yielder(sheet.DisplayUndoable(modelDoc));
                //}


                var error = (int)swSheetSewingError_e.swSewingOk;
                var body  = Modeler
                            .CreateBodiesFromSheets2(sheets, (int)swSheetSewingOption_e.swSewToSolid, 1e-5, ref error)
                            .CastArray <IBody2>();

                body.Should().NotBeEmpty();

                yielder(body.DisplayUndoable(modelDoc));

                await PauseTestExecution();
            });
        }