Пример #1
0
        //--------------------------------------------------------------------------------------------------

        protected void AddNamedSubshapes(string name, TopoDS_Shape sourceShape, BRepBuilderAPI_MakeShape makeShape)
        {
            __ProcessShapes(sourceShape.Faces());
            __ProcessShapes(sourceShape.Edges());
            __ProcessShapes(sourceShape.Vertices());

            //----

            void __ProcessShapes(IEnumerable <TopoDS_Shape> shapes)
            {
                var index = 0;

                foreach (var shape in shapes)
                {
                    var modifiedShapes = makeShape.Modified(shape).ToList();
                    if (modifiedShapes.Any())
                    {
                        foreach (var modifiedShape in modifiedShapes)
                        {
                            AddNamedSubshape(name, modifiedShape, index);
                        }
                    }
                    else if (!makeShape.IsDeleted(shape))
                    {
                        AddNamedSubshape(name, shape, index);
                    }
                    index++;
                }
            }
        }
Пример #2
0
        //--------------------------------------------------------------------------------------------------

        protected void UpdateModifiedSubshapes(TopoDS_Shape sourceShape, BRepBuilderAPI_MakeShape makeShape)
        {
            __Process(sourceShape.Faces());
            __Process(sourceShape.Edges());
            __Process(sourceShape.Vertices());

            //-----

            void __Process(IEnumerable <TopoDS_Shape> shapes)
            {
                foreach (var shape in shapes)
                {
                    var modList = makeShape.Modified(shape);
                    if (modList.Size() == 0)
                    {
                        // Delete check can result in exception
                        try
                        {
                            if (makeShape.IsDeleted(shape))
                            {
                                RemoveModifiedSubshape(shape);
                            }
                        }
                        catch (SEHException)
                        {
                            // That means that the makeShape has this shape not in list,
                            // so it is NOT deleted and NOT modified
                        }
                    }
                    else
                    {
                        AddModifiedSubshape(shape, modList.ToList());
                        AddModifiedSubshape(shape, makeShape.Generated(shape).ToList());
                    }
                }
            }
        }