Exemple #1
0
        /// <summary>
        /// Removes a node from the Scene Graph that is classed as invalid
        /// </summary>
        private static void pruneBadRelationship(SceneGraphNode invalidNode, bool referToParent = false)
        {
            //if (invalidNode.isValid.HasValue && invalidNode.isValid.Value == false)
            {
                if (referToParent)
                {
                    if (invalidNode.Parent != null)
                    {
                        invalidNode.Parent.Children.Remove(invalidNode);
                    }
                }
                else
                {
                    invalidNode.Children.Remove(invalidNode);
                }
            }

            if (debug)
            {
                Console.Write("pruned bad relationship ");
            }
            if (debug)
            {
                Console.WriteLine(invalidNode.ErrorStringWithLineNumbers());
            }
        }
Exemple #2
0
        // TODO: come up with a better way to define constraints between nodes, and act on them

        //TODO: Validate more X3D components

        private static void appearanceValidationConstraints(SceneGraphNode parent, out bool passed, out bool warned)
        {
            List <SceneGraphNode> invalid;

            passed = true;
            warned = false;

            if (typeof(X3DAppearanceNode).IsInstanceOfType(parent))
            {
                if (!parent.Children.Any(n => (typeof(X3DAppearanceChildNode).IsInstanceOfType(n)) ||
                                         (typeof(X3DPrototypeInstance).IsInstanceOfType(n))))
                {
                    warned = true;

                    if (!parent.alreadyWarned && debug)
                    {
                        Console.Write("[Warning] {0} doesnt contain any X3DAppearanceChildNode children ", parent.ToString());
                    }

                    if (!parent.alreadyWarned && debug)
                    {
                        Console.WriteLine(parent.ErrorStringWithLineNumbers());
                    }
                }

                invalid = parent.Children.Where(n => !((typeof(X3DAppearanceChildNode).IsInstanceOfType(n)) ||
                                                       (typeof(X3DPrototypeInstance).IsInstanceOfType(n)))).ToList();

                processInvalidNodes(parent, invalid, parent.ToString(), out passed);
            }
        }
Exemple #3
0
        /// <summary>
        /// Removes nodes classed as invalid from the Scene Graph
        /// </summary>
        private static void pruneBadRelationships(SceneGraphNode parent, List <SceneGraphNode> invalidNodes)
        {
            for (int i = 0; i < invalidNodes.Count(); i++)
            {
                SceneGraphNode invalidNode = invalidNodes[i];

                //if(invalidNode.isValid.HasValue && invalidNode.isValid.Value == false)
                {
                    parent.Children.Remove(invalidNode);
                }
            }

            if (debug)
            {
                Console.Write("pruned bad relationships ");
            }
            if (debug)
            {
                Console.WriteLine(parent.ErrorStringWithLineNumbers());
            }
        }