/// <summary>
        /// Проверка на пересечения с другими закладными элементами.
        /// TRUE - если проверка пройдена
        /// </summary>
        private bool checkForIntersects(OpeningTask task /*, PenetrInfo penInfo*/)
        {
            //task.scanInfo();

            //BCOM.Element penElement =
            //    PenetrHelper.getPenElementWithoutFlanges(task, penInfo);

            //IEnumerable<BCOM.Element> intersects =
            //    ElementHelper.scanIntersectsInElementRange(penElement,
            //        App.ActiveModelReference);

            //foreach (BCOM.Element intersection in intersects)
            //{
            //    if (intersection.IsPenetrationCell())
            //    {
            //        var body = getBodyWithOutFlanges(intersection.AsCellElement());

            //        var contrIntersects =
            //            ElementHelper.scanIntersectsInElementRange( body,
            //                App.ActiveModelReference);

            //        BCOM.Range3d res = App.Range3dInit();
            //        if (App.Range3dIntersect2(ref res, body.Range, penElement.Range))
            //        {
            //            return false;
            //        }
            //    }
            //    else if (intersection.IsCompundCell())
            //    {
            //        return false;
            //    }
            //}
            return(true);
        }
        public void preview()
        {
            previewTranCon_.Reset();

            try
            {
                foreach (DataRow row in TaskTable.Rows)
                {
                    OpeningTask task = rowsToTasks_[row];

                    var opening = new Opening(task);
                    opening.AddProjection();

                    previewTranCon_.AppendCopyOfElement(opening.GetElement());

                    foreach (BCOM.Element projElement in opening.GetProjections())
                    {
                        previewTranCon_.AppendCopyOfElement(projElement);
                    }
                }
            }
            catch (Exception ex) // TODO
            {
                ex.AddToMessageCenter();
            }
        }
        public void addToModel()
        {
            previewTranCon_?.Reset();

            Session.Instance.StartUndoGroup();

            ElementHelper.RunByRecovertingSettings(() => {
                foreach (DataRow row in TaskTable.Rows)
                {
                    Session.Instance.SetUndoMark();

                    OpeningTask task = rowsToTasks_[row];
                    try
                    {
                        Opening opening = new Opening(task);
                        opening.AddPerforation();
                        opening.AddProjection();
                        opening.AddToModel(false);

                        row.SetField(FieldName.STATUS, "DONE");
                        // TODO статус о выполнении
                    }
                    catch (Exception ex)
                    {
                        // TODO статус о выполнении
                        row.SetField(FieldName.STATUS, "ERROR");
                        Session.Instance.Keyin("undo");
                        var last = App.ActiveModelReference.GetLastValidGraphicalElement();
                        last?.Rewrite();
                    }
                }
            });

            Session.Instance.EndUndoGroup();
        }
        private void TaskTable_RowChanged(object sender, DataRowChangeEventArgs e)
        {
            if (!rowsToTasks_.ContainsKey(e.Row))
            {
                return;
            }

            OpeningTask task = rowsToTasks_[e.Row];

            task.Height = e.Row.Field <double>(FieldName.HEIGHT);
            task.Width  = e.Row.Field <double>(FieldName.WIDTH);
            task.Depth  = e.Row.Field <double>(FieldName.DEPTH);

            foreach (Sp3dToDataGroupMapProperty dgProp in task.DataGroupPropsValues.Keys.ToList())
            {
                foreach (string key in new string[] { dgProp.Key, dgProp.TargetName })
                {
                    if (e.Row.Table.Columns.Contains(key))
                    {
                        task.DataGroupPropsValues[dgProp] = e.Row.Field <string>(key);
                    }
                }
            }
        }