Ejemplo n.º 1
0
        protected static StructureNode CreateFrom(GeometricRelationship _node_source, StructureNode _sn_parent)
        {
            if (_node_source == null)
            {
                return(null);
            }

            List <HierarchicalContainer> g_content = _node_source.GeometricContent;

            if (g_content.Count == 0)
            {
                return(null);
            }

            // a geometric relationship node cannot exist w/o parent component
            if (_sn_parent == null)
            {
                return(null);
            }
            if (!_sn_parent.ContentType_Used || _sn_parent.ContentType == null)
            {
                return(null);
            }
            if (_sn_parent.ContentType != typeof(Component.Component))
            {
                return(null);
            }

            // create the node
            StructureNode node = new StructureNode();

            // content
            node.IDAsLong         = _node_source.ID;
            node.IDAsLong_Used    = true;
            node.ContentType      = typeof(GeometricRelationship);
            node.ContentType_Used = true;

            // structure
            node.ParentNode = _sn_parent;

            foreach (Point3DContainer p3dc in g_content)
            {
                StructureNode p3dc_sn = StructureNode.CreateFrom(p3dc, node);
                if (p3dc_sn != null)
                {
                    node.children_nodes.Add(p3dc_sn);
                }
            }

            return(node);
        }
Ejemplo n.º 2
0
        public static StructureNode CreateFrom(Component.Component _node_source, StructureNode _sn_parent)
        {
            if (_node_source == null)
            {
                return(null);
            }

            // create the node
            StructureNode node = new StructureNode();

            // content
            node.IDAsLong         = _node_source.ID;
            node.IDAsLong_Used    = true;
            node.ContentType      = typeof(Component.Component);
            node.ContentType_Used = true;

            // structure
            if (_sn_parent != null)
            {
                // the parent has to be a component
                if (!_sn_parent.ContentType_Used || _sn_parent.ContentType == null)
                {
                    return(null);
                }
                if (_sn_parent.ContentType != typeof(Component.Component))
                {
                    return(null);
                }
                // no self-parenting
                if (_sn_parent.IDAsLong == _node_source.ID)
                {
                    return(null);
                }

                node.ParentNode = _sn_parent;
            }

            foreach (var entry in _node_source.ContainedParameters)
            {
                Parameter.Parameter p = entry.Value;
                if (p == null)
                {
                    continue;
                }

                StructureNode p_sn = StructureNode.CreateFrom(p, node);
                if (p_sn != null)
                {
                    node.children_nodes.Add(p_sn);
                }
            }

            foreach (GeometricRelationship gr in _node_source.R2GInstances)
            {
                StructureNode gr_sn = StructureNode.CreateFrom(gr, node);
                if (gr_sn != null)
                {
                    node.children_nodes.Add(gr_sn);
                }
            }

            // recursion
            foreach (var entry in _node_source.ContainedComponents)
            {
                Component.Component sC = entry.Value;
                if (sC == null)
                {
                    continue;
                }

                StructureNode sC_sn = StructureNode.CreateFrom(sC, node);
                if (sC_sn != null)
                {
                    node.children_nodes.Add(sC_sn);
                }
            }

            return(node);
        }