RobotStudio event

EndVertex wrong after JoinCurves or JoinEdges

I create two wires, the start point of 'wire2' being at the endpoint of 'wire1'. I then create a new wire, 'unionOfWires'  by joining the two wires. I also create a new wire 'unionOfEdges' by joining the edges:[code]Wire[] myWires;
Edge[] myEdges;
Body[] unionWire;
Body unionOfWires;
Body unionOfEdges;

// Create wires
Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.01), new
Vector3(0.01, 0.0, 0.01));
Body wire2 = Body.CreateLine(new Vector3(0.01, 0.0, 0.01), new
Vector3(0.02, 0.0, 0.01));

// Create new wire by joining wires
myWires = new Wire[2] { wire1.Shells[0].Wires[0],
wire2.Shells[0].Wires[0] };
unionWire = Body.JoinCurves(myWires);
unionOfWires = unionWire[0];

// Create new wire by joining edges
myEdges = new Edge[2] { wire1.Shells[0].Wires[0].Coedges[0].Edge,
wire2.Shells[0].Wires[0].Coedges[0].Edge };
unionWire = Body.JoinEdges(myEdges, 0.00001);
unionOfEdges = unionWire[0];[/code]
Then [code]unionOfWires.Shells[0].Wires[0].StartVertex.Position));[/code] and
[code]unionOfWires.Shells[0].Wires[0].EndVertex.Position));[/code] return the same values as for 'wire1. The same happens with 'unionOfEdges'. I would expect the EndVertex of the new wire to be the same as the EndVertex of 'wire2'. Is this behaviour correct?

Thanks,

Kevin



Comments

  • Hi Kevin,
     

    I did also expect the EndVertex of wire2 to coincide with the EndVertex of unionOfWires.

     

    If you look into the resulting Body unionOfWires, it consists of one Wire (no surprise), which in turns consists of two coedges/edges, corresponding to to wire1 and wire2.

     

    The individual coedges has the same Start/EndVertex as wire1 and wire2.

     

    The following is true:

     

    [CODE]


    Debug.Assert(wire1.Shells[0].Wires[0].StartVertex.Position == unionOfWires.Shells[0].Wires[0].Coedges[1].StartVertex.Position);
    Debug.Assert(wire1.Shells[0].Wires[0].EndVertex.Position == unionOfWires.Shells[0].Wires[0].Coedges[1].EndVertex.Position);
    Debug.Assert(wire2.Shells[0].Wires[0].StartVertex.Position == unionOfWires.Shells[0].Wires[0].Coedges[0].StartVertex.Position);
    Debug.Assert(wire2.Shells[0].Wires[0].EndVertex.Position == unionOfWires.Shells[0].Wires[0].Coedges[0].EndVertex.Position);
    [/CODE]

    [CODE]

     

    Debug.Assert(wire1.Shells[0].Wires[0].StartVertex.Position == unionOfEdges.Shells[0].Wires[0].Coedges[1].StartVertex.Position);

    Debug.Assert(wire1.Shells[0].Wires[0].EndVertex.Position == unionOfEdges.Shells[0].Wires[0].Coedges[1].EndVertex.Position);

    Debug.Assert(wire2.Shells[0].Wires[0].StartVertex.Position == unionOfEdges.Shells[0].Wires[0].Coedges[0].StartVertex.Position);

    Debug.Assert(wire2.Shells[0].Wires[0].EndVertex.Position == unionOfEdges.Shells[0].Wires[0].Coedges[0].EndVertex.Position);

    [/CODE]

     

    I noticed that if I swapped wire1 and wire2 in the array passed to Body.JoinCurves() the result is the expected.

     

    If you do that, the following will be true:

     

    [CODE]


    Debug.Assert(wire1.Shells[0].Wires[0].StartVertex.Position == unionOfWires.Shells[0].Wires[0].StartVertex.Position);
    Debug.Assert(wire2.Shells[0].Wires[0].EndVertex.Position == unionOfWires.Shells[0].Wires[0].EndVertex.Position);

    [/CODE]

     

    I will have to look in to the implementation Wire.Start/EndVertex.

     

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • Kevin
    Kevin ✭✭
    Thanks Niklas,

    Kevin