Beispiel #1
0
        private IGeometry BuildLinkGeometry(ISchematicInMemoryFeatureLink schLink1, ISchematicInMemoryFeatureNode schNodeToReduce, ISchematicInMemoryFeatureLink schLink2, ISchematicRulesHelper rulesHelper)
        {
            if (schLink1 == null || schLink2 == null || schNodeToReduce == null || rulesHelper == null)
            {
                return(null);
            }

            if (m_keepVertices == false)
            {
                return(null); // no geometry
            }
            Polyline  newPoly   = new Polyline();
            IPolyline polyLink1 = rulesHelper.GetLinkPoints(schLink1, (schLink1.FromNode == schNodeToReduce));
            IPolyline polyLink2 = rulesHelper.GetLinkPoints(schLink2, (schLink2.ToNode == schNodeToReduce));
            IPoint    nodePt    = rulesHelper.GetNodePoint(schNodeToReduce);
            IPoint    Pt;

            IPointCollection newPts   = (IPointCollection)newPoly;
            IPointCollection link1Pts = (IPointCollection)polyLink1;
            IPointCollection link2Pts = (IPointCollection)polyLink2;

            int Count = link1Pts.PointCount;
            int i;

            for (i = 0; i < Count - 1; i++)
            {
                Pt = link1Pts.get_Point(i);
                newPts.AddPoint(Pt);
            }

            newPts.AddPoint(nodePt);

            Count = link2Pts.PointCount;
            for (i = 1; i < Count; i++)
            {
                Pt = link2Pts.get_Point(i);
                newPts.AddPoint(Pt);
            }

            IGeometry buildGeometry = (IGeometry)newPoly;

            return(buildGeometry);
        }
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            bool abortOperation = false;

            ESRI.ArcGIS.Schematic.ISchematicOperation schematicOperation = null;

            try
            {
                if (m_dockableDigit == null)
                {
                    return;
                }

                if (arg != null)
                {
                    m_x = arg.X;
                    m_y = arg.Y;
                }

                if (m_dockableWindow == null)
                {
                    return;
                }

                if (m_dockableWindow.IsVisible() == false)
                {
                    m_dockableWindow.Show(true);
                }

                ESRI.ArcGIS.SchematicControls.ISchematicTarget target = (ESRI.ArcGIS.SchematicControls.ISchematicTarget)m_schematicExtension;

                if (target != null)
                {
                    m_schematicLayer = target.SchematicTarget;
                }

                if (m_schematicLayer == null)
                {
                    System.Windows.Forms.MessageBox.Show("No target Layer");
                    return;
                }

                ISchematicInMemoryDiagram               inMemoryDiagram;
                ISchematicInMemoryFeatureClass          schematicInMemoryFeatureClass;
                ISchematicInMemoryFeatureClassContainer schematicInMemoryFeatureClassContainer;

                //Get the point
                ESRI.ArcGIS.Geometry.Point point = new ESRI.ArcGIS.Geometry.Point();

                ESRI.ArcGIS.ArcMapUI.IMxApplication mxApp;
                ESRI.ArcGIS.Display.IAppDisplay     appDisplay;
                IScreenDisplay         screenDisplay;
                IDisplay               display;
                IDisplayTransformation transform;
                ISpatialReference      spatialReference;

                inMemoryDiagram = m_schematicLayer.SchematicInMemoryDiagram;
                schematicInMemoryFeatureClassContainer = (ISchematicInMemoryFeatureClassContainer)inMemoryDiagram;

                if (schematicInMemoryFeatureClassContainer == null)
                {
                    return;
                }

                mxApp = (ESRI.ArcGIS.ArcMapUI.IMxApplication)m_app;

                if (mxApp == null)
                {
                    return;
                }

                appDisplay = mxApp.Display;

                if (appDisplay == null)
                {
                    return;
                }

                screenDisplay = appDisplay.FocusScreen;
                display       = screenDisplay;

                if (display == null)
                {
                    return;
                }

                transform = display.DisplayTransformation;

                if (transform == null)
                {
                    return;
                }

                spatialReference = transform.SpatialReference;

                WKSPoint mapPt = new WKSPoint();
                ESRI.ArcGIS.Display.tagPOINT devPoint;
                devPoint.x = m_x;
                devPoint.y = m_y;
                transform.TransformCoords(ref mapPt, ref devPoint, 1, 1); //'esriTransformToMap

                point.SpatialReference = spatialReference;
                point.Project(spatialReference);
                point.X = mapPt.X;
                point.Y = mapPt.Y;

                schematicInMemoryFeatureClass = schematicInMemoryFeatureClassContainer.GetSchematicInMemoryFeatureClass(m_dockableDigit.FeatureClass());

                if (schematicInMemoryFeatureClass == null)
                {
                    System.Windows.Forms.MessageBox.Show("Invalid Type.");
                    return;
                }

                if (m_dockableDigit.CreateNode())
                {
                    //TestMandatoryField
                    m_dockableDigit.btnOKPanel1.Visible = false;

                    if (m_dockableDigit.ValidateFields() == false)
                    {
                        m_dockableDigit.x(m_x);
                        m_dockableDigit.y(m_y);

                        System.Windows.Forms.MessageBox.Show(m_dockableDigit.ErrorProvider1.GetError(m_dockableDigit.btnOKPanel1) + m_messageFromOK);
                        return;
                    }

                    ESRI.ArcGIS.Geometry.IGeometry geometry;

                    ISchematicInMemoryFeature schematicInMemoryFeatureNode;

                    geometry = point;

                    schematicOperation = (ESRI.ArcGIS.Schematic.ISchematicOperation) new ESRI.ArcGIS.SchematicControls.SchematicOperation();

                    //digit operation is undo(redo)able we add it in the stack
                    IMxDocument doc = (IMxDocument)m_app.Document;
                    ESRI.ArcGIS.SystemUI.IOperationStack operationStack;
                    operationStack = doc.OperationStack;
                    operationStack.Do(schematicOperation);
                    schematicOperation.StartOperation("Digit", m_app, m_schematicLayer, true);

                    //do abort operation
                    abortOperation = true;

                    schematicInMemoryFeatureNode = schematicInMemoryFeatureClass.CreateSchematicInMemoryFeatureNode(geometry, "");
                    //schematicInMemoryFeatureNode.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusNew; if we want the node deleted after update
                    schematicInMemoryFeatureNode.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusLocked;

                    abortOperation = false;
                    schematicOperation.StopOperation();

                    ISchematicFeature schematicFeature = schematicInMemoryFeatureNode;
                    m_dockableDigit.FillValue(ref schematicFeature);

                    if (m_dockableDigit.AutoClear())
                    {
                        m_dockableDigit.SelectionChanged();
                    }
                }
                else
                {
                    m_dockableDigit.btnOKPanel2.Visible = false;

                    //Get the Tolerance of ArcMap
                    Double      tolerance;
                    IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)m_app.Document;
                    ESRI.ArcGIS.esriSystem.WKSPoint point2 = new WKSPoint();
                    ESRI.ArcGIS.Display.tagPOINT    devPt;

                    tolerance = mxDocument.SearchTolerancePixels;
                    devPt.x   = (int)tolerance;
                    devPt.y   = (int)tolerance;

                    transform.TransformCoords(ref point2, ref devPt, 1, 2); //2 <-> esriTransformSize 4 <-> esriTransformToMap

                    tolerance = point2.X * 5;                               //increase the tolerance value

                    IEnumSchematicFeature schematicFeatures = m_schematicLayer.GetSchematicFeaturesAtPoint(point, tolerance, false, true);

                    ISchematicFeature schematicFeatureSelected = null;
                    double            distancetmp;
                    double            distance = 0;
                    schematicFeatures.Reset();

                    if (schematicFeatures.Count <= 0)
                    {
                        return;
                    }

                    //pSchematicFeatures may contain several features, we are choosing the closest node.
                    ISchematicFeature schematicFeature2 = schematicFeatures.Next();

                    double dX;
                    double dY;
                    ISchematicInMemoryFeatureNode schematicInMemoryFeatureNode = null;
                    if (schematicFeature2 != null)
                    {
                        if (schematicFeature2.SchematicElementClass.SchematicElementType == ESRI.ArcGIS.Schematic.esriSchematicElementType.esriSchematicNodeType)
                        {
                            schematicInMemoryFeatureNode = (ISchematicInMemoryFeatureNode)schematicFeature2;
                        }
                    }

                    ISchematicInMemoryFeatureNodeGeometry schematicInMemoryFeatureNodeGeometry = (ISchematicInMemoryFeatureNodeGeometry)schematicInMemoryFeatureNode;
                    dX = schematicInMemoryFeatureNodeGeometry.Position.X;
                    dY = schematicInMemoryFeatureNodeGeometry.Position.Y;
                    schematicFeatureSelected = schematicFeature2;
                    distance = SquareDistance(dX - point.X, dY - point.Y);

                    while (schematicFeature2 != null)
                    {
                        //find the closest featureNode...
                        if (schematicInMemoryFeatureNode != null)
                        {
                            schematicInMemoryFeatureNodeGeometry = (ISchematicInMemoryFeatureNodeGeometry)schematicInMemoryFeatureNode;

                            if (schematicInMemoryFeatureNodeGeometry == null)
                            {
                                continue;
                            }

                            dX          = schematicInMemoryFeatureNodeGeometry.Position.X;
                            dY          = schematicInMemoryFeatureNodeGeometry.Position.Y;
                            distancetmp = SquareDistance(dX - point.X, dY - point.Y);

                            if (distancetmp < distance)
                            {
                                distance = distancetmp;
                                schematicFeatureSelected = schematicFeature2;
                            }
                        }

                        schematicFeature2 = schematicFeatures.Next();

                        if (schematicFeature2 != null)
                        {
                            if (schematicFeature2.SchematicElementClass.SchematicElementType == ESRI.ArcGIS.Schematic.esriSchematicElementType.esriSchematicNodeType)
                            {
                                schematicInMemoryFeatureNode = (ISchematicInMemoryFeatureNode)schematicFeature2;
                            }
                        }
                    }

                    if (schematicFeatureSelected == null)
                    {
                        return;
                    }

                    if (schematicFeatureSelected.SchematicElementClass.SchematicElementType != esriSchematicElementType.esriSchematicNodeType)
                    {
                        return;
                    }

                    if (m_schematicFeature1 == null)
                    {
                        m_schematicFeature1 = schematicFeatureSelected;
                        m_dockableDigit.SchematicFeature1(m_schematicFeature1);

                        if (!m_dockableDigit.CheckValidFeature(true))
                        {
                            m_schematicFeature1 = null;
                            m_dockableDigit.SchematicFeature1(m_schematicFeature1);
                            throw new Exception("Invalid starting node for this link type");
                        }

                        //Begin Feedback
                        m_linkFbk         = new NewLineFeedback();
                        m_linkFbk.Display = screenDisplay;

                        //symbol
                        ISimpleLineSymbol sLnSym;
                        IRgbColor         rGB = new RgbColor();

                        sLnSym = (ESRI.ArcGIS.Display.ISimpleLineSymbol)m_linkFbk.Symbol;

                        //Make a color
                        rGB.Red   = 255;
                        rGB.Green = 0;
                        rGB.Blue  = 0;

                        // Setup the symbol with color and style
                        sLnSym.Color = rGB;

                        m_linkFbk.Start(point);
                        //End Feedback

                        //To know if we are in the same diagram.
                        m_schematicLayerForLink = m_schematicLayer;
                    }
                    else
                    {
                        if (m_schematicLayerForLink != m_schematicLayer)
                        {
                            System.Windows.Forms.MessageBox.Show("wrong Target layer");
                            m_schematicLayerForLink = null;
                            EndFeedBack();
                            return;
                        }
                        m_schematicFeature2 = schematicFeatureSelected;
                        m_dockableDigit.SchematicFeature2(m_schematicFeature2);

                        //TestMandatoryField
                        if (m_dockableDigit.ValidateFields() == false)
                        {
                            m_dockableDigit.x(m_x);
                            m_dockableDigit.y(m_y);

                            System.Windows.Forms.MessageBox.Show(m_dockableDigit.ErrorProvider1.GetError(m_dockableDigit.btnOKPanel2) + m_messageFromOK);
                            return;
                        }

                        if (!m_dockableDigit.CheckValidFeature(false))
                        {
                            m_schematicFeature2 = null;
                            m_dockableDigit.SchematicFeature2(m_schematicFeature2);
                            throw new Exception("Invalid End node for this link type");
                        }

                        //CreateLink
                        ISchematicInMemoryFeature schematicInMemoryFeatureLink;

                        schematicOperation = (ESRI.ArcGIS.Schematic.ISchematicOperation) new ESRI.ArcGIS.SchematicControls.SchematicOperation();

                        //digit operation is undo(redo)able we add it in the stack
                        IMxDocument doc = (IMxDocument)m_app.Document;
                        ESRI.ArcGIS.SystemUI.IOperationStack operationStack;
                        operationStack = doc.OperationStack;
                        operationStack.Do(schematicOperation);
                        schematicOperation.StartOperation("Digit", m_app, m_schematicLayer, true);

                        //do abort operation
                        abortOperation = true;

                        schematicInMemoryFeatureLink = schematicInMemoryFeatureClass.CreateSchematicInMemoryFeatureLink((ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode)m_schematicFeature1, (ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode)m_schematicFeature2, "");
                        //schematicInMemoryFeatureLink.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusNew; if we want the node deleted after update
                        schematicInMemoryFeatureLink.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusLocked;

                        abortOperation = false;
                        schematicOperation.StopOperation();

                        ISchematicFeature schematicFeature = schematicInMemoryFeatureLink;
                        m_dockableDigit.FillValue(ref schematicFeature);

                        //End Feedback
                        EndFeedBack();

                        m_schematicLayerForLink = null;

                        if (m_dockableDigit.AutoClear())
                        {
                            m_dockableDigit.SelectionChanged();
                        }
                    }
                }

                //Refresh the view and viewer windows
                RefreshView();
            }
            catch (System.Exception e)
            {
                if (abortOperation && (schematicOperation != null))
                {
                    schematicOperation.AbortOperation();
                }

                EndFeedBack();
                System.Windows.Forms.MessageBox.Show(e.Message);
            }

            return;
        }
Beispiel #3
0
        public void Apply(ISchematicInMemoryDiagram inMemoryDiagram, ESRI.ArcGIS.esriSystem.ITrackCancel cancelTracker)
        {
            if (m_reductionLinkName == "")
            {
                return;
            }

            IEnumSchematicInMemoryFeature enumSchematicElement;
            ISchematicInMemoryFeature     schemElement;
            ISchematicDiagramClass        diagramClass = null;
            ISchematicElementClass        elementClass;
            IEnumSchematicElementClass    enumElementClass;

            Microsoft.VisualBasic.Collection allreadyUsed = new Microsoft.VisualBasic.Collection();
            try
            {
                diagramClass = inMemoryDiagram.SchematicDiagramClass;
            }
            catch { }
            if (diagramClass == null)
            {
                return;
            }

            enumElementClass = diagramClass.AssociatedSchematicElementClasses;
            enumElementClass.Reset();
            elementClass = enumElementClass.Next();
            while (elementClass != null)
            {
                if (elementClass.Name == m_reductionLinkName)
                {
                    break;
                }
                elementClass = enumElementClass.Next();
            }
            if (elementClass == null)
            {
                return;
            }

            // Get all link from selected class
            enumSchematicElement = inMemoryDiagram.GetSchematicInMemoryFeaturesByClass(elementClass);
            enumSchematicElement.Reset();

            ISchematicInMemoryFeatureLink link     = null;
            ISchematicInMemoryFeatureNode fromNode = null;
            ISchematicInMemoryFeatureNode toNode   = null;
            int iFromPort = 0;
            int iToPort   = 0;
            ISchematicInMemoryFeature           newElem = null;
            IEnumSchematicInMemoryFeatureLink   enumIncidentLinks;
            ISchematicInMemoryFeatureLinkerEdit schemLinker = (ISchematicInMemoryFeatureLinkerEdit)(new SchematicLinkerClass());
            bool bReduction = false;

            schemElement = enumSchematicElement.Next();
            while (schemElement != null)
            {
                try
                {
                    string elemName = allreadyUsed[schemElement.Name].ToString();
                    // if found, this link is allready used
                    schemElement = enumSchematicElement.Next();
                    continue;
                }
                catch
                {
                    // Add link to collection
                    allreadyUsed.Add(schemElement.Name, schemElement.Name, null, null);
                }

                // Get from node and to node
                link     = (ISchematicInMemoryFeatureLink)schemElement;
                fromNode = link.FromNode;
                toNode   = link.ToNode;
                if (m_usePort)
                {
                    iFromPort = link.FromPort;
                    iToPort   = link.ToPort;
                }
                // Get all links from this node
                enumIncidentLinks = fromNode.GetIncidentLinks(esriSchematicEndPointType.esriSchematicOriginOrExtremityNode);
                enumIncidentLinks.Reset();
                newElem = enumIncidentLinks.Next();
                while (newElem != null)
                {
                    bReduction = false;
                    if (newElem == schemElement)
                    {
                        // the new link is the same link we works on
                        newElem = enumIncidentLinks.Next();
                        continue;
                    }
                    link = (ISchematicInMemoryFeatureLink)newElem;

                    // 1st case of comparison
                    if (fromNode == link.FromNode && toNode == link.ToNode)
                    {
                        if (m_usePort)
                        {
                            bReduction = (iFromPort == link.FromPort && iToPort == link.ToPort);
                        }
                        else
                        {
                            bReduction = true;
                        }
                    }
                    // 2nd case of comparison
                    else if (fromNode == link.ToNode && toNode == link.FromNode)
                    {
                        if (m_usePort)
                        {
                            bReduction = (iFromPort == link.ToPort && iToPort == link.FromPort);
                        }
                        else
                        {
                            bReduction = true;
                        }
                    }

                    if (bReduction)
                    {
                        try
                        {
                            schemLinker.ReportAssociations(newElem, schemElement);    // Reports asssociation to first link
                            allreadyUsed.Add(newElem.Name, newElem.Name, null, null); // Add link to collection
                            newElem.Displayed = false;                                // this link is not visible
                        }
                        catch { }
                    }
                    newElem = enumIncidentLinks.Next();
                }
                schemElement.Displayed = true;
                schemElement           = enumSchematicElement.Next();
            }
        }
Beispiel #4
0
        private void ReduceNode(ISchematicRulesHelper rulesHelper, ISchematicInMemoryFeatureClass superspanLinkClass, ISpatialReference spatialRef, ISchematicInMemoryFeature schFeatureToReduce)
        {
            if (schFeatureToReduce.Displayed == false || rulesHelper == null || spatialRef == null)
            {
                return;
            }

            // get the two connected links
            IEnumSchematicInMemoryFeature enumLink = rulesHelper.GetDisplayedIncidentLinks((ISchematicInMemoryFeatureNode)schFeatureToReduce, esriSchematicEndPointType.esriSchematicOriginOrExtremityNode);

            if (enumLink == null || enumLink.Count != 2)
            {
                return;
            }

            enumLink.Reset();
            ISchematicInMemoryFeature     schFeat1 = enumLink.Next();
            ISchematicInMemoryFeature     schFeat2 = enumLink.Next();
            ISchematicInMemoryFeatureLink schLink1 = (ISchematicInMemoryFeatureLink)schFeat1;
            ISchematicInMemoryFeatureLink schLink2 = (ISchematicInMemoryFeatureLink)schFeat2;

            if (schLink1 == null || schLink2 == null)
            {
                return;
            }


            ISchematicInMemoryFeature schFeatureSuperspan = null;
            ISchematicInMemoryFeature schFeatureTmp       = null;

            ISchematicInMemoryFeatureNode schNodeToReduce = (ISchematicInMemoryFeatureNode)schFeatureToReduce;
            ISchematicInMemoryFeatureNode schFromNode;
            ISchematicInMemoryFeatureNode schToNode;
            int iFromPort;
            int iToPort;


            IGeometry superspanGeometry;

            if (schLink2.FromNode == schNodeToReduce)
            {
                superspanGeometry = BuildLinkGeometry(schLink1, schNodeToReduce, schLink2, rulesHelper);
                if (schLink1.ToNode == schNodeToReduce)
                {
                    schFromNode = schLink1.FromNode;
                    iFromPort   = schLink1.FromPort;
                }
                else
                {
                    schFromNode = schLink1.ToNode;
                    iFromPort   = schLink1.ToPort;
                }

                schToNode = schLink2.ToNode;
                iToPort   = schLink2.ToPort;
            }
            else
            {
                superspanGeometry = BuildLinkGeometry(schLink2, schNodeToReduce, schLink1, rulesHelper);


                schFromNode = schLink2.FromNode;
                iFromPort   = schLink2.FromPort;

                if (schLink1.FromNode == schNodeToReduce)
                {
                    schToNode = schLink1.ToNode;
                    iToPort   = schLink1.ToPort;
                }
                else
                {
                    schToNode = schLink1.FromNode;
                    iToPort   = schLink1.FromPort;
                }
            }

            if (superspanGeometry != null)
            {
                superspanGeometry.SpatialReference = spatialRef;
            }


            // find a unique name for the superspan
            string strFromName = schFromNode.Name;
            string strtoName   = schToNode.Name;
            string strName;
            long   lCount = 1;

            while (schFeatureSuperspan == null)
            {
                strName = strFromName + ";" + strtoName + ";" + lCount.ToString();
                if (strName.Length >= 128)
                {
                    break; // too long a name
                }
                try
                {
                    schFeatureTmp = rulesHelper.AlterLink(superspanLinkClass, strName, null, superspanGeometry, -2, -2,
                                                          strFromName, strtoName, esriFlowDirection.esriFDWithFlow, iFromPort, iToPort);
                }
                catch
                {
                    schFeatureTmp = null;
                }

                if (schFeatureTmp == null)
                {
                    continue;
                }

                // valid new feature
                schFeatureSuperspan = schFeatureTmp;
            }


            // last chance for a unique name
            lCount = 1;
            while (schFeatureSuperspan == null)
            {
                strName = schNodeToReduce.Name + ";" + lCount.ToString();
                if (strName.Length >= 128)
                {
                    break; // too long a name
                }
                try
                {
                    schFeatureTmp = rulesHelper.AlterLink(superspanLinkClass, strName, null, superspanGeometry, -2, -2,
                                                          strFromName, strtoName, esriFlowDirection.esriFDWithFlow, iFromPort, iToPort);
                }
                catch
                {
                    schFeatureTmp = null;
                }

                if (schFeatureTmp == null)
                {
                    continue;
                }

                // valid new feature
                schFeatureSuperspan = schFeatureTmp;
            }

            if (schFeatureSuperspan == null)
            {
                return; // cannot find a unique name
            }
            // otherwise report the cumulated length of the reduced links to the superspan
            ReportCumulativeValues(schFeat1, schFeat2, schFeatureSuperspan);

            //    report the associations on the superspan link
            rulesHelper.ReportAssociations(schFeatureToReduce, schFeatureSuperspan);
            rulesHelper.ReportAssociations(schFeat1, schFeatureSuperspan);
            rulesHelper.ReportAssociations(schFeat2, schFeatureSuperspan);

            // hide the reduced objects
            rulesHelper.HideFeature(schFeatureToReduce);
            rulesHelper.HideFeature(schFeat1);
            rulesHelper.HideFeature(schFeat2);
        }
        private IGeometry BuildLinkGeometry(ISchematicInMemoryFeatureLink schLink1, ISchematicInMemoryFeatureNode schNodeToReduce, ISchematicInMemoryFeatureLink schLink2, ISchematicRulesHelper rulesHelper)
        {

            if (schLink1 == null || schLink2 == null || schNodeToReduce == null || rulesHelper == null)
                return null;

            if (m_keepVertices == false)
                return null; // no geometry

            Polyline newPoly = new Polyline();
            IPolyline polyLink1 = rulesHelper.GetLinkPoints(schLink1, (schLink1.FromNode == schNodeToReduce));
            IPolyline polyLink2 = rulesHelper.GetLinkPoints(schLink2, (schLink2.ToNode == schNodeToReduce));
            IPoint nodePt = rulesHelper.GetNodePoint(schNodeToReduce);
            IPoint Pt;

            IPointCollection newPts = (IPointCollection)newPoly;
            IPointCollection link1Pts = (IPointCollection)polyLink1;
            IPointCollection link2Pts = (IPointCollection)polyLink2;

            int Count = link1Pts.PointCount;
            int i;
            for (i = 0; i < Count - 1; i++)
            {
                Pt = link1Pts.get_Point(i);
                newPts.AddPoint(Pt);
            }

            newPts.AddPoint(nodePt);

            Count = link2Pts.PointCount;
            for (i = 1; i < Count; i++)
            {
                Pt = link2Pts.get_Point(i);
                newPts.AddPoint(Pt);
            }

            IGeometry buildGeometry = (IGeometry)newPoly;
            return buildGeometry;
        }