/// <summary> /// Rotates input geometry relative to the reference geom /// </summary> /// <param name="ogeom"></param> /// <returns></returns> private void RotateGeom(IGTGeometry refGeom, ref IGTPolygonGeometry inpGeom) { double dAngle = 0; IGTPolygonGeometry oPolyGeom = null; IGTMatrix tmpTMatrix = null; IGTVector transVec; try { if (refGeom == null || inpGeom == null) { return; } if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTOrientedPointGeometry") { dAngle = AngleBetweenTwoPoints(((IGTOrientedPointGeometry)refGeom).Orientation); } else if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { oPolyGeom = (IGTPolygonGeometry)refGeom.Stroke(); dAngle = AngleBetweenTwoPoints(oPolyGeom.Points[0], oPolyGeom.Points[1]); } transVec = GTClassFactory.Create <IGTVector>(); if (inpGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { oPolyGeom = (IGTPolygonGeometry)inpGeom.Stroke(); // move and rotate the geometry to the correct position transVec.I = oPolyGeom.Points[0].X * -1; transVec.J = oPolyGeom.Points[0].Y * -1; transVec.K = oPolyGeom.Points[0].Z * -1; } tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); // rotate the geometry to the angle of the tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = RotateZTransform(dAngle, 'D'); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); transVec = transVec.NegateVector(transVec); tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } }
/// <summary> /// Rotates input geometry relative to the reference geom /// </summary> /// <param name="ogeom"></param> /// <returns></returns> private void RotateGeom(IGTGeometry refGeom, ref IGTPolygonGeometry inpGeom) { double dAngle = 0; IGTPolygonGeometry oPolyGeom = null; try { if (refGeom == null || inpGeom == null) { return; } if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTOrientedPointGeometry") { dAngle = AngleBetweenTwoPoints(((IGTOrientedPointGeometry)refGeom).Orientation); } else if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { oPolyGeom = (IGTPolygonGeometry)refGeom.Stroke(); dAngle = AngleBetweenTwoPoints(oPolyGeom.Points[0], oPolyGeom.Points[1]); } if (dAngle < -90.0 || dAngle > 90.0) { dAngle = dAngle + 180.0; } IGTVector transVec = GTClassFactory.Create <IGTVector>(); if (inpGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { // move and rotate the geometry to the correct position if (m_ActiveMapWindow.DetailID == 0) { transVec.I = refGeom.FirstPoint.X * -1; transVec.J = refGeom.FirstPoint.Y * -1; transVec.K = refGeom.FirstPoint.Z * -1; } else { if (m_CentriodPoint != null) { transVec.I = m_CentriodPoint.X * -1; transVec.J = m_CentriodPoint.Y * -1; transVec.K = m_CentriodPoint.Z * -1; } } } IGTMatrix tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); // rotate the geometry to the angle of the tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = RotateZTransform(dAngle, 'D'); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); transVec = transVec.NegateVector(transVec); tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); } catch (Exception) { throw; } finally { } }
//public string node1Structure public bool ProcessSelectSet() { bool bReturnValue = false; try { m_aSortedPoints = new CablePullPoint[1]; m_aSegments = new CablePullSegment[1]; IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>(); oGTDCKeys = m_Application.SelectedObjects.GetObjects(); relationshipService.DataContext = m_Application.DataContext; int index = 0; m_SelectedFID = oGTDCKeys[index].FID; m_SelectedFNO = oGTDCKeys[index].FNO; relationshipService.ActiveFeature = m_Application.DataContext.OpenFeature(m_SelectedFNO, m_SelectedFID); if (relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value != null) { m_featureState = relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value.ToString(); } if (relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.RecordCount > 0) { relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.MoveFirst(); m_CU = relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.Fields["CU_C"].Value.ToString(); } if (CommonDT.AllowCUEdit(relationshipService.ActiveFeature)) { m_AllowCUEdit = true; } else { m_AllowCUEdit = false; } int ductBankFID = 0; try { IGTKeyObjects relatedDuctKOs = relationshipService.GetRelatedFeatures(6); if (relatedDuctKOs.Count > 0) { relationshipService.ActiveFeature = relatedDuctKOs[0]; IGTKeyObjects relatedFormationKOs = relationshipService.GetRelatedFeatures(6); if (relatedFormationKOs.Count > 0) { relationshipService.ActiveFeature = relatedFormationKOs[0]; IGTKeyObjects relatedDuctBankKOs = relationshipService.GetRelatedFeatures(3); if (relatedDuctBankKOs.Count > 0) { ductBankFID = relatedDuctBankKOs[0].FID; relationshipService.ActiveFeature = relatedDuctBankKOs[0]; IGTKeyObjects structure1 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1); IGTKeyObjects structure2 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2); if (structure1.Count > 0) { IGTKeyObject thing = structure1[0]; thing.Components.GetComponent(1).Recordset.MoveFirst(); if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF) { m_node1Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString(); } } if (structure2.Count > 0) { IGTKeyObject thing = structure2[0]; thing.Components.GetComponent(1).Recordset.MoveFirst(); if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF) { m_node2Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString(); } } } } } else { MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_NO_RELATED_DUCTBANK, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } catch { } // Get the primary geographic and primary detail componentviews from metadata // Get the selected object matching the primary geographic or primary detail componentviews in that order Recordset metadataRS = m_Application.DataContext.MetadataRecordset("G3E_FEATURES_OPTABLE", "g3e_fno = " + ConstantsDT.FNO_DUCTBANK); short primaryGeographicCNO = 0; short primaryDetailCNO = 0; if (metadataRS.RecordCount > 0) { if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value)) { primaryGeographicCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value); } if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value)) { primaryDetailCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value); } } IGTDDCKeyObjects oDuctBankGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>(); oDuctBankGTDCKeys = m_Application.DataContext.GetDDCKeyObjects(ConstantsDT.FNO_DUCTBANK, ductBankFID, GTComponentGeometryConstants.gtddcgAllPrimary); metadataRS = m_Application.DataContext.MetadataRecordset("G3E_COMPONENTVIEWS_OPTABLE"); string filter = "(g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryGeographicCNO + ") or (g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryDetailCNO + ")"; metadataRS.Filter = filter; if (metadataRS.RecordCount > 0) { metadataRS.Sort = "g3e_detail"; while (!metadataRS.EOF) { if (metadataRS.Fields["G3E_VIEW"].Value.ToString() == oDuctBankGTDCKeys[index].ComponentViewName) { //m_SelectedFID = oGTDCKeys[index].FID; //m_SelectedFNO = oGTDCKeys[index].FNO; break; } metadataRS.MoveNext(); index++; } IGTGeometry oGeometry = oDuctBankGTDCKeys[index].Geometry; IGTPolylineGeometry oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>(); if (oGeometry.Type == GTGeometryTypeConstants.gtgtPolylineGeometry || oGeometry.Type == GTGeometryTypeConstants.gtgtLineGeometry) { // Geometry is okay to use as it is. oPolyLineGeom = (IGTPolylineGeometry)oGeometry; bReturnValue = true; } else if (oGeometry.Type == GTGeometryTypeConstants.gtgtCompositePolylineGeometry) { // Any arcs must be stroked to line segments oPolyLineGeom = (IGTPolylineGeometry)oGeometry.Stroke(); bReturnValue = true; } else { // Invalid geometry type. MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_GEOMETRY, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); bReturnValue = false; } if (bReturnValue) { // Store each point of the line in the feature's geometry StoreLinePoints(oPolyLineGeom, m_SelectedFNO, m_SelectedFID); //Compute the included angles for each set of three points in the sorted array ComputeIncludedAngles(); //Build the arrays for the segments and bends that will comprise the pull if (!BuildSegmentsAndBends()) { bReturnValue = false; } } } else { MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_COMPONENT_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); bReturnValue = false; } } catch (Exception e) { m_aSegments = new CablePullSegment[1]; m_aBends = new double[1]; m_aSortedPoints = new CablePullPoint[1]; } return(bReturnValue); }