<style> p {margin-top:0px;margin-bottom:0px;} </style> <table border=0 width=100%% cellpadding=0 cellspacing=0 align=center> <tr> <td valign=top style='padding:8pt;'><font size=2><P>If you are moving the points interectively (directly on screen with the help of mouse or keys), then you may think of something equivalent to event driven machine. Where before you apply the result of moving the second point, calculate the new position of the middle point and apply all the position changes in the end to all the points.</P>
<P>Just keep the handle on the actors.<BR>
<BR>
<BR>
<BR>
<BR>
</P>
<BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<P></P>
<P></P>
<P>---------[ Received Mail Content ]----------<BR>
</P>
<P></P>
<P><B>Subject : </B>Re: [vtkusers] Dynamically connected points<BR>
</P>
<P></P>
<P><B>Date : </B>Tue, 24 Oct 2006 19:26:15 +0200<BR>
</P>
<P></P>
<P><B>From : </B>"Obada Mahdi" <omahdi@gmx.de><BR>
</P>
<P></P>
<P><B>To : </B>vtkusers@vtk.org<BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P>Hi Nelson!</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
On 10/24/06, nelson - <NELSON1977@GMAIL.COM>wrote:</P>
<P></P>
<P><BR>
> hi all,</P>
<P></P>
<P><BR>
> i'm coding an interactive geomertry program in python using VTK. I</P>
<P></P>
<P><BR>
> can't figure out how to make a Point that is dependant from the</P>
<P></P>
<P><BR>
> position of the other points. I can to explain myself by an example.</P>
<P></P>
<P><BR>
></P>
<P></P>
<P><BR>
> If i wanto conconstruct the middle point of two points in the space i</P>
<P></P>
<P><BR>
> have to build the middle point that change its position when i move</P>
<P></P>
<P><BR>
> the two points... can i make it in vtl. I see vtkAssembly but i don't</P>
<P></P>
<P><BR>
> understand if it is the right choice.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
If I understand your problem correctly, you want to construct a middle</P>
<P></P>
<P><BR>
point from two other points that can be moved independently; in other</P>
<P></P>
<P><BR>
words, have an object whose position is given implicitly by two other</P>
<P></P>
<P><BR>
objects and some kind of operation.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
vtkAssembly is useful for compound geometry, i.e. objects consisting</P>
<P></P>
<P><BR>
of multiple parts, organized in a hierarchical tree, that should be</P>
<P></P>
<P><BR>
affected simultaneously by transformations. It does not, however,</P>
<P></P>
<P><BR>
provide a means to express and maintain object properties that are</P>
<P></P>
<P><BR>
calculated from other data sources and a given operation.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
I guess there are two possible approaches to your problem--here are some ideas:</P>
<P></P>
<P><BR>
(1) Event-driven design: Monitor interactions that change positions</P>
<P></P>
<P><BR>
and update the "middle point" accordingly. I suppose this is what you</P>
<P></P>
<P><BR>
already had in mind:</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
On 10/19/06, nelson - <NELSON1977@GMAIL.COM>wrote:</P>
<P></P>
<P><BR>
> I can do it implementing my own observer pattern like</P>
<P></P>
<P><BR>
> framework or there is something already esisting in VTK i can use?</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
An observer like vtkCallbackCommand can be used to have a custom</P>
<P></P>
<P><BR>
function called on an event like "InteractionEvent" or</P>
<P></P>
<P><BR>
"EndInteractionEvent" for a given object, which can in turn</P>
<P></P>
<P><BR>
re-calculate point positions. If modifications are not only initiated</P>
<P></P>
<P><BR>
by keyboard or mouse interaction but also programmatically, observing</P>
<P></P>
<P><BR>
the less specific "Modified" event instead might help.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
The advantage of this approach is simplicity--the whole update logic</P>
<P></P>
<P><BR>
is part of an event handler, and there is no need for affected objects</P>
<P></P>
<P><BR>
(like vtkActor) to know about how their properties depend on other</P>
<P></P>
<P><BR>
objects.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
(2) Demand-driven design: If you would rather like to have a more</P>
<P></P>
<P><BR>
general way of expressing dependencies for calculated properties, as</P>
<P></P>
<P><BR>
opposed to hard-coding the information flow into an event handler, you</P>
<P></P>
<P><BR>
could create a custom subclass of e.g. vtkCoordinate that knows how to</P>
<P></P>
<P><BR>
compute its position as "middle point" from other positions given upon</P>
<P></P>
<P><BR>
initialization, maybe as instances of vtkCoordinate or vtkActor. This</P>
<P></P>
<P><BR>
custom class could then be used to maintain the calculated position,</P>
<P></P>
<P><BR>
by checking its own modification time against the input when being</P>
<P></P>
<P><BR>
accessed, and re-calculating theposition if needed.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
In order to automatically update an actor's position based on such a</P>
<P></P>
<P><BR>
computed coordinate, one would either have to use a customized</P>
<P></P>
<P><BR>
vtkActor that maintains its position as a vtkCoordinate-compatible</P>
<P></P>
<P><BR>
class, or link them by observing the "Modified" event of the</P>
<P></P>
<P><BR>
coordinate object.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
I apologize for not being more specific--I have not done something</P>
<P></P>
<P><BR>
like this before, so this is all more of a wild guess, and the details</P>
<P></P>
<P><BR>
of such an implementation largely depend on the specifics of your</P>
<P></P>
<P><BR>
application.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Hope it helps (and does not cause too much confusion :-)</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Obada</P>
<P></P>
<P><BR>
_______________________________________________</P>
<P></P>
<P><BR>
This is the private VTK discussion list. </P>
<P></P>
<P><BR>
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ</P>
<P></P>
<P><BR>
Follow this link to subscribe/unsubscribe:</P>
<P></P>
<P><BR>
http://www.vtk.org/mailman/listinfo/vtkusers</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P></BLOCKQUOTE>
<P></P></font></td></tr>
</table>