private void insertEditObjectInflectionPoints(Manifold.Interop.Drawing p_Drawing, int p_ManifoldID, Manifold.Interop.BranchSet p_ManifoldObjectBranchSet) { try { StringBuilder sbSQL = new StringBuilder(); for (int iBranchIndex = 0; iBranchIndex < p_ManifoldObjectBranchSet.Count; iBranchIndex++) { Manifold.Interop.Branch objBranch = p_ManifoldObjectBranchSet.get_Item(iBranchIndex); int iCoorCounts = objBranch.get_PointSet().Count; sbSQL.Length = 0; sbSQL.AppendLine("INSERT INTO [" + this._DrawingEdit.Name + "] "); sbSQL.AppendLine("( "); sbSQL.AppendLine(" PointIndex "); sbSQL.AppendLine(" ,[Geom (I)] "); sbSQL.AppendLine(" ,BranchMaxIndex "); sbSQL.AppendLine(" ,ThemeFeatureType "); sbSQL.AppendLine(" ,[Selection (I)]"); sbSQL.AppendLine(" ,BranchIndex "); sbSQL.AppendLine(") "); sbSQL.AppendLine("SELECT "); sbSQL.AppendLine(" CASE [Point] = StartPoint(ConvertToLine(BRANCH([ID]," + iBranchIndex.ToString() + "))) "); sbSQL.AppendLine(" WHEN TRUE THEN 0 "); sbSQL.AppendLine(" ELSE CoordCount(Branch(IntersectLine(ConvertToLine(BRANCH([ID]," + iBranchIndex.ToString() + ")), [Point]), 0)) - 1 "); sbSQL.AppendLine(" END AS [PointIndex] "); sbSQL.AppendLine(" ,[Point] "); sbSQL.AppendLine(" ,CoordCount(BRANCH([ID]," + iBranchIndex.ToString() + ")) AS [BranchPointMaxIndex] "); sbSQL.AppendLine(" , \"" + this._Edit_ThemePoint + "\""); sbSQL.AppendLine(" , 1"); sbSQL.AppendLine(" , " + iBranchIndex.ToString() + " "); sbSQL.AppendLine("FROM [" + p_Drawing.Name + "] "); sbSQL.AppendLine("WHERE ID = " + p_ManifoldID.ToString() + " "); sbSQL.AppendLine("SPLIT BY Coords(BRANCH([ID]," + iBranchIndex.ToString() + ")) AS [Point]; "); Utility.executeSQL(sbSQL.ToString()); } } catch (Exception objEx) { throw; } }
private void insertEditObjectInflectionPoints1(Manifold.Interop.Drawing p_Drawing, int p_ManifoldID, Manifold.Interop.BranchSet p_ManifoldObjectBranchSet) { Manifold.Interop.Query qryQuerySelect = p_Drawing.Document.NewQuery("Temp_EditSelect", false); Manifold.Interop.Query qryQueryInsert = p_Drawing.Document.NewQuery("Temp_EditInsert", false); try { StringBuilder sbSQL = new StringBuilder(); for (int iBranchIndex = 0; iBranchIndex < p_ManifoldObjectBranchSet.Count; iBranchIndex++) { Manifold.Interop.Branch objBranch = p_ManifoldObjectBranchSet.get_Item(iBranchIndex); int iCoorCounts = objBranch.get_PointSet().Count; sbSQL.Length = 0; sbSQL.AppendLine("SELECT "); sbSQL.AppendLine(" [ID], "); sbSQL.AppendLine(" [Geom (I)], "); sbSQL.AppendLine(" [Vertex], "); sbSQL.AppendLine(" Length([Section]) AS [Length] "); sbSQL.AppendLine("FROM "); sbSQL.AppendLine(" (SELECT "); sbSQL.AppendLine(" [ID], [Geom (I)], [Vertex], "); sbSQL.AppendLine(" IntersectLine(ReverseLine(ConvertToLine(BRANCH([ID]," + iBranchIndex.ToString() + "))), [Vertex]) AS [Sections] "); sbSQL.AppendLine(" FROM [" + p_Drawing.Name + "] "); sbSQL.AppendLine(" WHERE [ID] = " + p_ManifoldID.ToString() + " "); sbSQL.AppendLine(" SPLIT BY Coords(BRANCH([ID]," + iBranchIndex.ToString() + ")) AS [Vertex] "); sbSQL.AppendLine(" ) "); sbSQL.AppendLine("SPLIT BY Branches([Sections]) AS [Section] "); sbSQL.AppendLine("LEAVING Touches(StartPoint([Section]), StartPoint(ConvertToLine(BRANCH([ID]," + iBranchIndex.ToString() + ")))) "); qryQuerySelect.Text = sbSQL.ToString(); qryQuerySelect.RunEx(false); sbSQL.Length = 0; sbSQL.AppendLine("INSERT INTO [" + this._DrawingEdit.Name + "] "); sbSQL.AppendLine("( "); sbSQL.AppendLine(" PointIndex "); sbSQL.AppendLine(" ,[Geom (I)] "); sbSQL.AppendLine(" ,ThemeFeatureType "); sbSQL.AppendLine(" ,[Selection (I)] "); sbSQL.AppendLine(" ,BranchIndex "); sbSQL.AppendLine(") "); sbSQL.AppendLine("SELECT "); sbSQL.AppendLine(" COUNT([T2].[Length]) "); sbSQL.AppendLine(" ,[T1].[Vertex] "); sbSQL.AppendLine(" , \"" + this._Edit_ThemePoint + "\""); sbSQL.AppendLine(" , 1 "); sbSQL.AppendLine(" , " + iBranchIndex.ToString() + " "); sbSQL.AppendLine("FROM "); sbSQL.AppendLine(" [" + qryQuerySelect.Name + "] AS [T1] "); sbSQL.AppendLine(" LEFT JOIN "); sbSQL.AppendLine(" [" + qryQuerySelect.Name + "] AS [T2] "); sbSQL.AppendLine(" ON [T1].[ID] = [T2].[ID] "); sbSQL.AppendLine(" AND [T1].[Length] < [T2].[Length] "); sbSQL.AppendLine("GROUP BY [T1].[ID], [T1].[Vertex] "); qryQueryInsert.Text = sbSQL.ToString(); qryQueryInsert.RunEx(false); } } catch (Exception objEx) { throw; } finally { //Remove the query p_Drawing.Document.ComponentSet.Remove(qryQuerySelect); p_Drawing.Document.ComponentSet.Remove(qryQueryInsert); } }