You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the four adaptagrams libraries on windows, via the C# bindings generated with SWIG. Basic layouting and edge routing works, however I am trying to use the topology preserving addon using the Dunnart code as an example (is there any other documentation available?). It goes like this:
layout=new ConstrainedFDLayout(rectangles, edges, idealEdgeLength,true);// passing libcola an empty instance of this class will cause it to populate it // with the current topology information for nodes and edges when layout.makeFeasible() is runvartopology=new ColaTopologyAddon();
layout.setTopology(topology);
layout.makeFeasible();
layout.run();varnodes= topology.topologyNodes;// nodes count is zerovarroutes= topology.topologyRoutes;// routes count is zerovarnewTopology=(ColaTopologyAddon)layout.getTopology();// cast exception
The issue is that the getTopology() method returns an instance of the base class TopologyAddonInterface which cannot be downcasted in C#. This sounds like a problem with the SWIG-generated bindings (after I've read some related issues here http://johnnado.com/swig-csharp-java-downcast/).
Any ideas? Thanks.
The text was updated successfully, but these errors were encountered:
foolnotion
changed the title
Downcast issue with ColaTopologyAddon
Downcast issue with ColaTopologyAddon when using the C# bindings
May 1, 2015
The above code inserts a static method in the ColaTopologyAddon generated class which makes use of the underlying dynamic_cast to produce the correct result. This can then be used like this:
var topologyInterface = layout.getTopology();
topology = ColaTopologyAddon.CastToConcreteType(topologyInterface);
Hello,
I am using the four adaptagrams libraries on windows, via the C# bindings generated with SWIG. Basic layouting and edge routing works, however I am trying to use the topology preserving addon using the Dunnart code as an example (is there any other documentation available?). It goes like this:
The issue is that the getTopology() method returns an instance of the base class
TopologyAddonInterface
which cannot be downcasted in C#. This sounds like a problem with the SWIG-generated bindings (after I've read some related issues here http://johnnado.com/swig-csharp-java-downcast/).Any ideas? Thanks.
The text was updated successfully, but these errors were encountered: