Closed piac closed 6 years ago
If we choose IConvertible, the only method we would override meaningfully would be http://msdn.microsoft.com/en-us/library/system.iconvertible.totype.aspx This, though, would allow the usage of Convert.ChangeType(), which is an extensively supported mechanism. Calls to Convert.ChangeType require boxing, but to Iconvertible.ToType do not necessarily.
If our interface were to contain a GeometryBase AsGeometry() method, exposed in the right flavor, no casting would be required, and a unique interface would be provided.
How would we choose what things like a BoundingBox should be? It could be a Brep, Mesh, or Extrusion
Hi Steve
I don't really have the perfect idea, that's why I was proposing two options. The code above is just the GhPython implementation.
IConvertible would have the answer, as one can specify the wanted target. But I think that BoundingBox is an edge case which does not have a precise GeometryBase counterpart and as such could even not implement the other interface.
Your question is very relevant.
Today I still think this is relevant, and BoundingBox should convert to Extrusion. Types should always convert to the simples ON_Geometry/GeometryBase type available. While Line could convert to NurbsCurve, it should just convert to LineCurve.
We should provide a way for this code to be more straightforward, future-proof, and efficient. I would suggest a IGeometryBaseTransformable interface, but IConvertible might be enough.
A conversion overview is here: http://msdn.microsoft.com/en-us/library/yy580hbd.aspx