Esempio n. 1
0
        public void TestFindConnectors()
        {
            //Arrange
            NodeMigrationData migrationDataTest = null;
            string documentDynPath = Path.Combine(TestDirectory, @"core\Angle.dyn");
            XmlDocument xmlDoc = new XmlDocument();
            string endGuid = "67f40bd6-cdee-470a-9aa5-2c9d6f6c87bc";

            //Act
            xmlDoc.Load(documentDynPath);
            migrationDataTest = new NodeMigrationData(xmlDoc);
            PortId portId = new PortId(endGuid, 0, PortType.Input);

            //This call will find several connectors in the Angle.dyn file
            var connectorsFound = migrationDataTest.FindConnectors(portId);

            //Assert
            Assert.IsNotNull(connectorsFound); //It means that at least one connector was found

            //For the file Angle.dyn will find just one connector then it will validate that the end property is valid
            foreach (var connector in connectorsFound)
            {
                Assert.AreEqual(connector.GetAttribute("end"), "67f40bd6-cdee-470a-9aa5-2c9d6f6c87bc");
            }
            
        }
Esempio n. 2
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var    migratedData = new NodeMigrationData(data.Document);
            var    oldNode      = data.MigratedNodes.ElementAt(0);
            string oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            var codeBlockNode = MigrationManager.CreateCodeBlockNodeFrom(oldNode);

            codeBlockNode.SetAttribute("CodeText",
                                       "p=Plane.ByOriginNormal(origin,axis.AsVector());\n" +
                                       "cs=CoordinateSystem.ByPlane(p);\n" +
                                       "Cylinder.ByRadiusHeight(cs,r,h);");
            migratedData.AppendNode(codeBlockNode);

            //create and reconnect the connecters
            var        oldInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);

            var        oldInPort1 = new PortId(oldNodeId, 1, PortType.INPUT);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);

            var        oldInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            var        oldInPort3 = new PortId(oldNodeId, 3, PortType.INPUT);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);

            var oldOutPort0      = new PortId(oldNodeId, 0, PortType.OUTPUT);
            var oldOutConnectors = data.FindConnectors(oldOutPort0);

            var newInPort0  = new PortId(oldNodeId, 0, PortType.INPUT);
            var newInPort1  = new PortId(oldNodeId, 1, PortType.INPUT);
            var newInPort2  = new PortId(oldNodeId, 2, PortType.INPUT);
            var newInPort3  = new PortId(oldNodeId, 3, PortType.INPUT);
            var newOutPort2 = new PortId(oldNodeId, 2, PortType.OUTPUT);

            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector1, newInPort0);
            data.ReconnectToPort(connector2, newInPort2);
            data.ReconnectToPort(connector3, newInPort3);

            if (oldOutConnectors.Any())
            {
                foreach (var connector in oldOutConnectors)
                {
                    //connect anything that previously was connected to output port 0
                    //to output port 2
                    data.ReconnectToPort(connector, newOutPort2);
                }
            }

            return(migratedData);
        }
Esempio n. 3
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Geometry.Intersect", "Geometry.Intersect@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            var connector0 = data.FindFirstConnector(oldInPort0);
            var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
            var connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector0, oldInPort0);
            data.ReconnectToPort(connector1, oldInPort1);

            // reconnect output port at 1 to 0
            var oldXYZOut = new PortId(newNodeId, 1, PortType.Output);
            var newXyzOut = new PortId(newNodeId, 0, PortType.Output);
            var xyzConnects = data.FindConnectors(oldXYZOut);

            if (xyzConnects != null)
            {
                xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
            }

            // get u parm
            if (connector0 != null)
            {
                var crvInputNodeId = connector0.Attributes["start"].Value;
                var crvInputIndex = int.Parse(connector0.Attributes["start_index"].Value);

                // make parm at point node 
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 2, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);

                oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            // get v parm
            if (connector1 != null)
            {
                var crvInputNodeId = connector1.Attributes["start"].Value;
                var crvInputIndex = int.Parse(connector1.Attributes["start_index"].Value);

                // make parm at point node 
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 3, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);

                oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return migrationData;
        }
Esempio n. 4
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);

            #region Create DSFunction node

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Geometry.Intersect", "Geometry.Intersect@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            var faceInConnector = data.FindFirstConnector(oldInPort0);
            var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
            var crvInConnector = data.FindFirstConnector(oldInPort1);

            // probably unnecessary
            data.ReconnectToPort(faceInConnector, oldInPort0);
            data.ReconnectToPort(crvInConnector, oldInPort1);

            #endregion

            // in ports of curve-face intersection

                // 1) crv   -> stays the same
                // 2) face  -> stays the same

            // out ports of curve-face intersection

                // 1) result    -> this will be killed off by the migration
                // 2) xyz       -> this is out port 1 of oldNode
                // 3) uv        -> use Surface.ParameterAtPoint
                // 4) t         -> use Curve.ParameterAtPoint
                // 5) edge      -> killed
                // 6) edge t    -> killed


            // reconnect output port at 1 to 0
            var oldXYZOut = new PortId(newNodeId, 1, PortType.Output);
            var newXyzOut = new PortId(newNodeId, 0, PortType.Output);
            var xyzConnects = data.FindConnectors(oldXYZOut);

            if (xyzConnects != null)
            {
                xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
            }

            // get uv parm
            if (faceInConnector != null)
            {
                var faceInputNodeId = faceInConnector.Attributes["start"].Value;
                var faceInputIndex = int.Parse(faceInConnector.Attributes["start_index"].Value);

                // get the parameter as a vector
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Surface.UVParameterAtPoint",
                    "Surface.UVParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(faceInputNodeId, faceInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newUVOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldUVOut = new PortId(newNodeId, 2, PortType.Output);

                var oldUVConnectors = data.FindConnectors(oldUVOut);
                if (oldUVConnectors != null)
                    oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newUVOut));
            }

            // get v parm
            if (crvInConnector != null)
            {
                var crvInputNodeId = crvInConnector.Attributes["start"].Value;
                var crvInputIndex = int.Parse(crvInConnector.Attributes["start_index"].Value);

                // make parm at point node 
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 3, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);
                if (oldTConnectors != null)
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return migrationData;
        }
Esempio n. 5
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            string oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            XmlElement newNode = MigrationManager.CloneAndChangeName(oldNode, "DSCore.Filter", "Filter");
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            PortId oldOutputPort = new PortId(oldNodeId, 0, PortType.Output);
            PortId newOutputPort = new PortId(newNodeId, 1, PortType.Output);

            if (data.FindConnectors(oldOutputPort) != null)
                foreach (XmlElement connector in data.FindConnectors(oldOutputPort))
                    data.ReconnectToPort(connector, newOutputPort);

            PortId oldInPort0 = new PortId(oldNodeId, 0, PortType.Input);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);

            PortId oldInPort1 = new PortId(oldNodeId, 1, PortType.Input);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);

            PortId newInPort0 = new PortId(newNodeId, 0, PortType.Input);
            PortId newInPort1 = new PortId(newNodeId, 1, PortType.Input);

            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector1, newInPort0);

            migrationData.AppendNode(newNode);
            return migrationData;
        }
Esempio n. 6
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.Intersect", "Geometry.Intersect@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            var connector0 = data.FindFirstConnector(oldInPort0);
            var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
            var connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector0, oldInPort0);
            data.ReconnectToPort(connector1, oldInPort1);

            // reconnect output port at 1 to 0
            var oldXYZOut   = new PortId(newNodeId, 1, PortType.Output);
            var newXyzOut   = new PortId(newNodeId, 0, PortType.Output);
            var xyzConnects = data.FindConnectors(oldXYZOut);

            if (xyzConnects != null)
            {
                xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
            }

            // get u parm
            if (connector0 != null)
            {
                var crvInputNodeId = connector0.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(connector0.Attributes["start_index"].Value);

                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 2, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);

                oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            // get v parm
            if (connector1 != null)
            {
                var crvInputNodeId = connector1.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(connector1.Attributes["start_index"].Value);

                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 3, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);

                oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return(migrationData);
        }
Esempio n. 7
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);

            #region Create DSFunction node

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.Intersect", "Geometry.Intersect@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0      = new PortId(newNodeId, 0, PortType.Input);
            var faceInConnector = data.FindFirstConnector(oldInPort0);
            var oldInPort1      = new PortId(newNodeId, 1, PortType.Input);
            var crvInConnector  = data.FindFirstConnector(oldInPort1);

            // probably unnecessary
            data.ReconnectToPort(faceInConnector, oldInPort0);
            data.ReconnectToPort(crvInConnector, oldInPort1);

            #endregion

            // in ports of curve-face intersection

            // 1) crv   -> stays the same
            // 2) face  -> stays the same

            // out ports of curve-face intersection

            // 1) result    -> this will be killed off by the migration
            // 2) xyz       -> this is out port 1 of oldNode
            // 3) uv        -> use Surface.ParameterAtPoint
            // 4) t         -> use Curve.ParameterAtPoint
            // 5) edge      -> killed
            // 6) edge t    -> killed


            // reconnect output port at 1 to 0
            var oldXYZOut   = new PortId(newNodeId, 1, PortType.Output);
            var newXyzOut   = new PortId(newNodeId, 0, PortType.Output);
            var xyzConnects = data.FindConnectors(oldXYZOut);

            if (xyzConnects != null)
            {
                xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
            }

            // get uv parm
            if (faceInConnector != null)
            {
                var faceInputNodeId = faceInConnector.Attributes["start"].Value;
                var faceInputIndex  = int.Parse(faceInConnector.Attributes["start_index"].Value);

                // get the parameter as a vector
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Surface.UVParameterAtPoint",
                    "Surface.UVParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(faceInputNodeId, faceInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newUVOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldUVOut = new PortId(newNodeId, 2, PortType.Output);

                var oldUVConnectors = data.FindConnectors(oldUVOut);
                if (oldUVConnectors != null)
                {
                    oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newUVOut));
                }
            }

            // get v parm
            if (crvInConnector != null)
            {
                var crvInputNodeId = crvInConnector.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(crvInConnector.Attributes["start_index"].Value);

                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 3, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);
                if (oldTConnectors != null)
                {
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
                }
            }

            return(migrationData);
        }
Esempio n. 8
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            #region Create new DSFunction node - Geometry.GetClosestPoint@Geometry

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.GetClosestPoint", "Geometry.GetClosestPoint@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0      = new PortId(newNodeId, 0, PortType.INPUT);
            var ptInConnector   = data.FindFirstConnector(oldInPort0);
            var oldInPort1      = new PortId(newNodeId, 1, PortType.INPUT);
            var faceInConnector = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(ptInConnector, oldInPort1);
            data.ReconnectToPort(faceInConnector, oldInPort0);

            #endregion

            #region Reconnect the old UV out port

            // if necessary, get the face UV
            var oldUVOut        = new PortId(newNodeId, 1, PortType.OUTPUT);
            var oldUVConnectors = data.FindConnectors(oldUVOut);

            if (oldUVConnectors != null && oldUVConnectors.Any())
            {
                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Surface.UVParameterAtPoint",
                    "Surface.UVParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                var crvInputNodeId = faceInConnector.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(faceInConnector.Attributes["start_index"].Value);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.OUTPUT);
                oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }
            #endregion

            #region Reconnect the old distance out port

            var oldDOut        = new PortId(newNodeId, 2, PortType.OUTPUT);
            var oldDConnectors = data.FindConnectors(oldDOut);

            // If necessary, get the distance to the projected point
            if (oldDConnectors != null && oldDConnectors.Any())
            {
                // Get the original output ports connected to input
                var ptInputNodeId = ptInConnector.Attributes["start"].Value;
                var ptInputIndex  = int.Parse(ptInConnector.Attributes["start_index"].Value);

                // make distance to node
                var distTo = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Geometry.DistanceTo",
                    "Geometry.DistanceTo@Geometry");
                migrationData.AppendNode(distTo);
                var distToId = MigrationManager.GetGuidFromXmlElement(distTo);

                data.CreateConnector(newNode, 0, distTo, 0);
                data.CreateConnectorFromId(ptInputNodeId, ptInputIndex, distToId, 1);

                var newDOut = new PortId(distToId, 0, PortType.OUTPUT);
                oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
            }

            #endregion

            return(migrationData);
        }
Esempio n. 9
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migratedData = new NodeMigrationData(data.Document);
            var oldNode = data.MigratedNodes.ElementAt(0);
            string oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            var codeBlockNode = MigrationManager.CreateCodeBlockNodeFrom(oldNode);
            codeBlockNode.SetAttribute("CodeText",
                "p=Plane.ByOriginNormal(origin,axis.AsVector());\n"+
                "cs=CoordinateSystem.ByPlane(p);\n"+
                "Cylinder.ByRadiusHeight(cs,r,h);");
            migratedData.AppendNode(codeBlockNode);

            //create and reconnect the connecters
            var oldInPort0 = new PortId(oldNodeId, 0, PortType.Input);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);

            var oldInPort1 = new PortId(oldNodeId, 1, PortType.Input);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);

            var oldInPort2 = new PortId(oldNodeId, 2, PortType.Input);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            var oldInPort3 = new PortId(oldNodeId, 3, PortType.Input);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);

            var oldOutPort0 = new PortId(oldNodeId, 0, PortType.Output);
            var oldOutConnectors = data.FindConnectors(oldOutPort0);

            var newInPort0 = new PortId(oldNodeId, 0, PortType.Input);
            var newInPort1 = new PortId(oldNodeId, 1, PortType.Input);
            var newInPort2 = new PortId(oldNodeId, 2, PortType.Input);
            var newInPort3 = new PortId(oldNodeId, 3, PortType.Input);
            var newOutPort2 = new PortId(oldNodeId, 2, PortType.Output);

            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector1, newInPort0);
            data.ReconnectToPort(connector2, newInPort2);
            data.ReconnectToPort(connector3, newInPort3);

            if (oldOutConnectors != null && oldOutConnectors.Any())
            {
                foreach (var connector in oldOutConnectors)
                {
                    //connect anything that previously was connected to output port 0
                    //to output port 2
                    data.ReconnectToPort(connector, newOutPort2);
                }
            }

            return migratedData;
        }
Esempio n. 10
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            #region Create new DSFunction node - Geometry.ClosestPointTo@Geometry

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Geometry.ClosestPointTo", "Geometry.ClosestPointTo@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            var ptInConnector = data.FindFirstConnector(oldInPort0);
            var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
            var faceInConnector = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(ptInConnector, oldInPort1);
            data.ReconnectToPort(faceInConnector, oldInPort0);

            #endregion

            #region Reconnect the old UV out port

            // if necessary, get the face UV
            var oldUVOut = new PortId(newNodeId, 1, PortType.Output);
            var oldUVConnectors = data.FindConnectors(oldUVOut);

            if (oldUVConnectors != null && oldUVConnectors.Any())
            {
                // make parm at point node 
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Surface.UVParameterAtPoint",
                    "Surface.UVParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                var crvInputNodeId = faceInConnector.Attributes["start"].Value;
                var crvInputIndex = int.Parse(faceInConnector.Attributes["start_index"].Value);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }
            #endregion

            #region Reconnect the old distance out port

            var oldDOut = new PortId(newNodeId, 2, PortType.Output);
            var oldDConnectors = data.FindConnectors(oldDOut);

            // If necessary, get the distance to the projected point
            if (oldDConnectors != null && oldDConnectors.Any())
            {
                // Get the original output ports connected to input
                var ptInputNodeId = ptInConnector.Attributes["start"].Value;
                var ptInputIndex = int.Parse(ptInConnector.Attributes["start_index"].Value);

                // make distance to node
                var distTo = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Geometry.DistanceTo",
                    "Geometry.DistanceTo@Geometry");
                migrationData.AppendNode(distTo);
                var distToId = MigrationManager.GetGuidFromXmlElement(distTo);

                data.CreateConnector(newNode, 0, distTo, 0);
                data.CreateConnectorFromId(ptInputNodeId, ptInputIndex, distToId, 1);

                var newDOut = new PortId(distToId, 0, PortType.Output);
                oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
            }

            #endregion

            return migrationData;
        }
Esempio n. 11
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Geometry.ClosestPointTo", "Geometry.ClosestPointTo@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            var connector0 = data.FindFirstConnector(oldInPort0);
            var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
            var connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector0, oldInPort0);
            data.ReconnectToPort(connector1, oldInPort1);

            var oldDOut = new PortId(newNodeId, 2, PortType.Output);
            var oldTOut = new PortId(newNodeId, 1, PortType.Output);

            if ((connector0 != null) && (data.FindConnectors(oldDOut) != null))
            {
                // Get the original output ports connected to input
                var ptInputNodeId = connector0.Attributes["start"].Value;
                var ptInputIndex = int.Parse(connector0.Attributes["start_index"].Value);

                // make distance to node
                var distTo = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 1, "ProtoGeometry.dll",
                    "Geometry.DistanceTo",
                    "Geometry.DistanceTo@Geometry");
                migrationData.AppendNode(distTo);
                var distToId = MigrationManager.GetGuidFromXmlElement(distTo);

                data.CreateConnector(newNode, 0, distTo, 0);
                data.CreateConnectorFromId(ptInputNodeId, ptInputIndex, distToId, 1);

                var newDOut = new PortId(distToId, 0, PortType.Output);
                var oldDConnectors = data.FindConnectors(oldDOut);

                if (oldDConnectors != null)
                    oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
            }

            if ((connector1 != null) && (data.FindConnectors(oldTOut) != null))
            {
                var crvInputNodeId = connector1.Attributes["start"].Value;
                var crvInputIndex = int.Parse(connector1.Attributes["start_index"].Value);

                // make parm at point node 
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTConnectors = data.FindConnectors(oldTOut);

                if (oldTConnectors != null)
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return migrationData;
        }