User 870ab5b546
29-01-2010 22:06:04
The documentation of MPolyline is sparse, and I have some questions.
First, in a straight arrow, getPoint(0) returns the tail, getPoint(1) returns the head, and getPoint(2) returns the midpoint, right?
Second, suppose I want to change the starting point of an existing arrow1 to be the same as the midpoint of an other existing arrow2. Do I use,
arrow1.setPoints(new MPoint[] {arrow2.getPointRef(2), arrow1.getPointRef(1)});
That is, do two points suffice to establish the new MPolyline, or do I need three? And, will
arrow1.getPoint(0) instanceof MMidPoint
then return true?
Third, getPoint() returns a clone of an MPoint, and getPointRef() returns the reference (I assume that means the original MPoint). Does getPoints() return clones or the original references?
Thanks in advance for your help.
ChemAxon 12eab24e0a
01-02-2010 10:59:03
Dear Bob,
First, in a straight arrow, getPoint(0) returns
the tail, getPoint(1) returns the head, and getPoint(2) returns the
midpoint, that's right.
Second, your code is perfect except that getPointRef needs two argument
in MPolyline, the second is a CTransform3D, but two points are
sufficient to set the new MPolyline.
And yes,
arrow1.getPoint(0) instanceof MMidPoint
returns true.
Finally, getPoints() returns the array of point's clones.
Best regards,
Eva
User 870ab5b546
01-02-2010 15:26:22
Thanks, Eva. May I suggest that you add a new method, getPointRef(int), which calls getPointRef(int, null)? Also, getPointRefs() and getPointRefs(CTransform3D) to return the original references of all the points?
In an acyclic MPolyline with n segments, there are n + 1 termini and n midpoints. In an MRectangle, there are n termini, a center, and n midpoints. What happens if one draws something like two triangles that share a single vertex? Is it the same as an MPolyline?
ChemAxon 12eab24e0a
02-02-2010 12:10:36
Hi Bob,
The answer is definitely yes. As we have no triangle drawing tool, man
can draw a triangle using MPolyline by closing the polyline. Than it is
going to have 4 termini, 3 midpoints.
If you draw two triangles that share a single vertex, there are two possibilities:
1. Draw the second triangle by continuing the first one with the same polyline, than you got 7 termini, 6 midpoints.
2. Finish drawing the first one, than restart drawing on the same point
the second, but with a new polyline. So you got two MPolyline object
(with two times 4 termini and two times 3 midpoints).
Best regards,
Eva
ChemAxon 12eab24e0a
03-02-2010 07:05:27
Sorry, I didn't answer the first question. So I will put these requests to the tasklist.
Thanks, Eva