Thursday, November 12, 2009

(III) New SDO_GEOMETRY <-> Autodesk Map3d 2010

Author: Jonio, Dennis

Before I forget I did put together a simple class to aid in manipulating the three(3) element array structures that comprise SDO_ELEM_INFO_ARRAY.
Source code (C#):

[Serializable]
public class TriInts
{
public int OFFSET
{ set { TriInt[0] = value; } get { return TriInt[0]; } }
public int ETYPE
{ set { TriInt[1] = value; } get { return TriInt[1]; } }
public int INTERP
{ set { TriInt[2] = value; } get { return TriInt[2]; } }
private int[] TriInt;

public TriInts()
{
TriInt = new int[] { 0, 0, 0 };
}
public TriInts(int o, int e, int i)
{
TriInt = new int[3];
TriInt[0] = o;
TriInt[1] = e;
TriInt[2] = i;
}
public TriInts(TriInts triint)
{
TriInt = new int[3];
TriInt[0] = triint.OFFSET;
TriInt[1] = triint.ETYPE;
TriInt[2] = triint.INTERP;
}
public int[] ToArray()
{
return new int[] { OFFSET, ETYPE, INTERP };
}
}//eoc TriInts

So now we get to the primary actor DrawAbleSdoGeometry. The container class for the NetSdoGeometry.sdogeometry type and the supporting cast of players to break sdogeometry down into DrawAble(s) and build a sdogeometry from DrawAble(s). Again the paradigm is all about this intermediate drawable construct so Autodesk/Map3d doesn’t come into play here. That is all handled in a separate class!
Source code (C#):

[Serializable]
public class DrawAbleSdoGeometry
{
private sdogeometry m_Geometry;
public const decimal DefaultSRID2236 = 2236;
public const int DefaultLRS0 = 0;
public const int DefaultDimensionality2D = 2;
public const int DefaultDimensionality3D = 3;
public decimal SRID = DefaultSRID2236;
public int LRS = DefaultLRS0;
public int Dimensionality = DefaultDimensionality2D;
public List Drawables = new List();
public List OrphanComponents = new List();
// Default ctor - nothing to do
public DrawAbleSdoGeometry() { }
// ctor from an existing SDO_GEOMETRY object
public DrawAbleSdoGeometry(sdogeometry aGeometry)
{
this.Geometry = aGeometry;
}
}//eoc DrawAbleSdoGeometry


I set a default Dimensionality, LRS and SRID but have left them totally accessible. I am not one to hide things away in some private corner somewhere unless it just is nonsensical to do otherwise. Like DrawAblesFromGeometry(), the player that decomposes a sdogeometry/SDO_GEOMETRY object into DrawAble(s). It only made sense to me to invoke this directly from the “setter” for the class’ Geometry object.
Note also that within the “setter” I deal with that Optimized Point issue.
Source code (C#):

public sdogeometry Geometry
{
get { return this.m_Geometry; }

set
{
m_Geometry = value;
try
{
m_Geometry.PropertiesFromGTYPE();
Dimensionality = m_Geometry.Dimensionality;

if (m_Geometry.sdo_point != null)
{
m_Geometry.ElemArray = new decimal[] { 1, 1, 1 };
if (m_Geometry.Dimensionality == 2)
m_Geometry.OrdinatesArray = new decimal[] { (decimal)m_Geometry.sdo_point.X, (decimal)m_Geometry.sdo_point.Y };
else if (m_Geometry.Dimensionality == 3)
m_Geometry.OrdinatesArray = new decimal[] { (decimal)m_Geometry.sdo_point.X, (decimal)m_Geometry.sdo_point.Y, (decimal)m_Geometry.sdo_point.Z };
m_Geometry.sdo_point = null;
}
if (m_Geometry.ElemArray != null && m_Geometry.OrdinatesArray != null)
DrawAblesFromGeometry();
}
catch (System.Exception) {/*Just eat it all*/}
}
}

As regards catching and eating any errors at this level I am ambivilant. I really do assume VALID geometry coming in because I produce VALID geometry on the other end. You may see it differently.

To be continued …

No comments:

Post a Comment