/// <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 { } }