<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#003333">
<font size="-1"><font face="Tahoma">Thanks a lot for your reply, it
solves my problem. <br>
<br>
I associate your solution with <i>vtkPolygonalSurfaceContourLineInterpolator</i></font></font>
<small>which permits </small><small>me to have a contour which stays
on the surface and whose spans lie on the surface.</small><br>
<br>
Le 17/05/2010 17:25, Karthik Krishnan a &eacute;crit&nbsp;:
<blockquote
 cite="mid:AANLkTimDV7jQgWAtzuHiLlcOk_XUjdWEvYD0WJp_JVpl@mail.gmail.com"
 type="cite">Nicolas:<br>
  <br>
Replace vtkPolyDataPointPlacer vtkPolygonalSurfacePointPlacer and now I
can no longer move the points ouside teh silhoutte.<br>
  <br>
Thanks<br>
--<br>
karthik<br>
  <br>
  <div class="gmail_quote">On Fri, May 14, 2010 at 2:25 PM, Nicolas
Sarrasin <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:nsarrasin@phenix-systems.com">nsarrasin@phenix-systems.com</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div bgcolor="#ffffff" text="#003333">
    <font size="-1"><font face="Tahoma">Here is a compiling example, I
post
a picture too to be clearer.<br>
    <br>
picture : <a moz-do-not-send="true"
 href="http://img138.imageshack.us/img138/1695/123qny.png"
 target="_blank">http://img138.imageshack.us/img138/1695/123qny.png</a><br>
    <br>
/*&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; code begins &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; */<br>
    <br>
#include &lt;vtkRenderer.h&gt;<br>
#include &lt;vtkRendererCollection.h&gt;<br>
#include &lt;vtkRenderWindow.h&gt;<br>
#include &lt;vtkRenderWindowInteractor.h&gt;<br>
#include &lt;vtkProperty.h&gt;<br>
#include &lt;vtkLODActor.h&gt;<br>
#include &lt;vtkPolyDataMapper.h&gt;<br>
#include &lt;vtkPolyData.h&gt;<br>
#include &lt;vtkCellArray.h&gt;<br>
#include &lt;vtkSphereSource.h&gt;<br>
#include &lt;vtkContourWidget.h&gt;<br>
#include &lt;vtkOrientedGlyphContourRepresentation.h&gt;<br>
#include &lt;vtkLinearContourLineInterpolator.h&gt;<br>
#include &lt;vtkGlyph3D.h&gt;<br>
#include &lt;vtkCellPicker.h&gt;<br>
#include &lt;vtkCallbackCommand.h&gt;<br>
#include &lt;vtkCamera.h&gt;<br>
#include &lt;vtkInteractorStyleTrackballCamera.h&gt;<br>
#include &lt;vtkSmartPointer.h&gt;<br>
#include &lt;vtkPolyDataPointPlacer.h&gt;<br>
    <br>
int main(int argc, char*argv[])<br>
{<br>
&nbsp;&nbsp;&nbsp; //d&eacute;finition de la sphere<br>
&nbsp;&nbsp;&nbsp; vtkSphereSource* theSphere = vtkSphereSource::New();<br>
&nbsp;&nbsp;&nbsp; theSphere-&gt;SetCenter( 0, 0, 5);<br>
&nbsp;&nbsp;&nbsp; theSphere-&gt;SetRadius(1.0);
    <div class="im"><br>
    <br>
&nbsp;&nbsp;&nbsp; vtkPolyDataMapper * sphereMapper = vtkPolyDataMapper::New();<br>
&nbsp;&nbsp;&nbsp; sphereMapper-&gt;SetInput(theSphere-&gt;GetOutput());<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; vtkLODActor* sphereActor = vtkLODActor::New();<br>
&nbsp;&nbsp;&nbsp; sphereActor-&gt;SetMapper( sphereMapper);<br>
&nbsp;&nbsp;&nbsp; <br>
    </div>
&nbsp;&nbsp;&nbsp; // d&eacute;finition Renderer + renderWindow<br>
&nbsp;&nbsp;&nbsp; vtkRenderer *renderer1 = vtkRenderer::New();<br>
&nbsp;&nbsp;&nbsp; renderer1-&gt;SetBackground(0.3, 0.45, 0.6);
    <div class="im"><br>
&nbsp;&nbsp;&nbsp; renderer1-&gt;AddActor(sphereActor);<br>
    <br>
&nbsp;&nbsp;&nbsp; vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
&nbsp;&nbsp;&nbsp; renWin-&gt;AddRenderer(renderer1);<br>
    </div>
&nbsp;&nbsp;&nbsp; renWin-&gt;SetSize(600, 600);<br>
&nbsp;&nbsp;&nbsp; renWin-&gt;SetPosition(450,150);<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; //d&eacute;finition du WindowIteractor
    <div class="im"><br>
&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor *rendIter =
vtkRenderWindowInteractor::New();<br>
&nbsp;&nbsp;&nbsp; rendIter-&gt;SetRenderWindow(renWin);<br>
    <br>
&nbsp;&nbsp;&nbsp; // Here comes the image actor constrained handle widget stuff.....<br>
&nbsp;&nbsp;&nbsp; vtkContourWidget *widget = vtkContourWidget::New();<br>
&nbsp;&nbsp;&nbsp; widget-&gt;SetInteractor(rendIter);<br>
    <br>
&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkLinearContourLineInterpolator&gt;
contourStyle =
vtkSmartPointer&lt;vtkLinearContourLineInterpolator&gt;::New();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; vtkOrientedGlyphContourRepresentation *rep
=vtkOrientedGlyphContourRepresentation::SafeDownCast(
widget-&gt;GetRepresentation() );<br>
    </div>
&nbsp;&nbsp;&nbsp; rep-&gt;GetLinesProperty()-&gt;SetColor(1, 1, 0);<br>
&nbsp;&nbsp;&nbsp; rep-&gt;GetLinesProperty()-&gt;SetLineWidth(3.0);<br>
&nbsp;&nbsp;&nbsp; rep-&gt;SetLineInterpolator(contourStyle);<br>
    <br>
&nbsp;&nbsp;&nbsp; //on d&eacute;finit un Placer pour forcer le contour a etre sur la sphere
    <div class="im"><br>
&nbsp;&nbsp;&nbsp; vtkPolyDataPointPlacer * spherePlacer =
vtkPolyDataPointPlacer::New();<br>
&nbsp;&nbsp;&nbsp; spherePlacer-&gt;AddProp(sphereActor);<br>
&nbsp;&nbsp;&nbsp; rep-&gt;SetPointPlacer(spherePlacer);<br>
    <br>
&nbsp;&nbsp;&nbsp; renWin-&gt;Render();<br>
&nbsp;&nbsp;&nbsp; rendIter-&gt;Initialize();<br>
&nbsp;&nbsp;&nbsp; widget-&gt;EnabledOn();<br>
&nbsp;&nbsp;&nbsp; rendIter-&gt;Start();<br>
&nbsp;&nbsp;&nbsp; <br>
    </div>
&nbsp;&nbsp;&nbsp; //clean<br>
&nbsp;&nbsp;&nbsp; rendIter-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; renWin-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; renderer1-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; sphereMapper-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; sphereActor-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; theSphere-&gt;Delete();<br>
    <br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
    <br>
/*&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; code ends&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; */<br>
    <br>
Thanks<br>
    <br>
    </font></font><br>
Le 14/05/2010 10:13, Karthik Krishnan a &eacute;crit&nbsp;:
    <div>
    <div class="h5">
    <blockquote type="cite">
      <div class="gmail_quote">On Fri, May 14, 2010 at 1:15 PM, Nicolas
Sarrasin <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:nsarrasin@phenix-systems.com" target="_blank">nsarrasin@phenix-systems.com</a>&gt;</span>
wrote:<br>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        <div bgcolor="#ffffff" text="#003333"><font size="-1"><font
 face="Tahoma">Ok thanks for your reply.<br>
        </font></font></div>
      </blockquote>
      <div><br>
Please keep mails on the list, so others may chime in.<br>
&nbsp;</div>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        <div bgcolor="#ffffff" text="#003333"><font size="-1"><font
 face="Tahoma"><br>
I'm gonna use </font></font><i><small><font face="Tahoma">vtkPolygonalSurfaceContourLineInterpolator</font></small></i><small><font
 face="Tahoma">, it satisfied me, for the moment.<br>
        </font></small></div>
      </blockquote>
      <div><br>
Great.<br>
&nbsp;<br>
      </div>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        <div bgcolor="#ffffff" text="#003333"><small><font face="Tahoma"><br>
        </font></small>
        <div>
        <blockquote type="cite"><small><font face="Tahoma">The
interpolator
internally traces the shortest path between the two
nodes along vertices of the mesh, so its not as good as a projection
that cuts through the cells, but if your mesh is dense enough the
traced path might be good enough.</font></small></blockquote>
        <br>
        </div>
        <small>What do you suggest me if my mesh isn't dense enough ?
How
can i
project the contour on my sphere ?</small><br>
        </div>
      </blockquote>
      <div><br>
The path is an approximation of a projection onto the mesh, such that
the projected path lies wholly along the vertices of the mesh.<br>
      <br>
      </div>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        <div bgcolor="#ffffff" text="#003333"><small><font face="Tahoma"><br>
Now I encounter a new "problem" in using contour widget. After closing
a contour, everytime I try to modify it by dragging a node, the node
can be move outside the surface (it's still inside the silhouette of
the sphere but it's not lying on any more and approach the screen).<br>
        </font></small></div>
      </blockquote>
      <div><br>
This should not happen if you are using a
vtkPolygonalSurfacePointPlacer to constrain the nodes and the
vtkPolygonalSurfaceContourLineInterpolator to constrain the path. <br>
      <br>
Please post a minimal, (compiling) example. Also take a look a look at
TestDijkstraImageGeodesicPath. The contour and the interpolated path
are confined to the surface of the mesh, while you manipulate
interactively.<br>
      <br>
--<br>
karthik<br>
&nbsp;<br>
      </div>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        <div bgcolor="#ffffff" text="#003333"><small><font face="Tahoma"><br>
How can I manage this problem and constrain the position of the node of
the contour during all its lifetime in the visualisation?<br>
        <br>
Thanks by advance,<br>
        <br>
Nicolas<br>
        </font></small><br>
Le 12/05/2010 18:43, Karthik Krishnan a &eacute;crit&nbsp;:
        <div>
        <div>
        <blockquote type="cite">Yes Nicolas:<br>
          <br>
The contour widget uses two sets of classes, which (are generally
independent of each other).<br>
          <br>
A subclass of vtkPointPlacer dictates the constraints imposed on the
nodes. <br>
A subclass of vtkContourLIneInterpolator dictates the constraints
imposed on the path in between the nodes. <br>
          <br>
In your case, you might want to look at the following combination :<br>
          <br>
&nbsp; vtkPolygonalSurfacePointPlacer -&gt;
vtkPolygonalSurfaceContourLineInterpolator<br>
          <br>
The interpolator internally traces the shortest path between the two
nodes along vertices of the mesh, so its not as good as a projection
that cuts through the cells, but if your mesh is dense enough the
traced path might be good enough.<br>
          <br>
          <br>
Something like :<br>
          <br>
          <br>
&nbsp;&nbsp; vtkContourWidget *contourWidget = vtkContourWidget::New();<br>
&nbsp; contourWidget-&gt;SetInteractor(iren);<br>
          <br>
&nbsp; vtkOrientedGlyphContourRepresentation *rep = <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkOrientedGlyphContourRepresentation::SafeDownCast(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contourWidget-&gt;GetRepresentation());<br>
          <br>
&nbsp; vtkPolygonalSurfacePointPlacer * pointPlacer <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = vtkPolygonalSurfacePointPlacer::New();<br>
&nbsp; pointPlacer-&gt;AddProp( sphereActor );<br>
&nbsp; rep-&gt;SetPointPlacer(pointPlacer);<br>
          <br>
&nbsp; vtkPolygonalSurfaceContourLineInterpolator * lineInterpolator <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = vtkPolygonalSurfaceContourLineInterpolator::New();<br>
&nbsp; rep-&gt;SetLineInterpolator(lineInterpolator);<br>
&nbsp; <br>
&nbsp; iren-&gt;Initialize();<br>
&nbsp; contourWidget-&gt;EnabledOn();<br>
          <br>
          <br>
Hope this helps.. Here is a minimal example..<br>
          <br>
--<br>
karthik<br>
          <br>
          <br>
          <div class="gmail_quote">On Wed, May 12, 2010 at 7:21 PM,
Nicolas
Sarrasin <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:nsarrasin@phenix-systems.com" target="_blank">nsarrasin@phenix-systems.com</a>&gt;</span>
wrote:<br>
          <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
            <div bgcolor="#ffffff" text="#003333">Hi all,<br>
            <br>
I'm quite new in developping with vtk and I have some questions
concerning vtkContourWidget.<br>
            <br>
I built a quick project which uses vtkContourWidget and
vtkPolyDataPointPlacer to display a contour on a sphere.<br>
            <br>
When I click on this sphere, there's no problem : the points of the
contour are well positionned on the sphere. But it's not the case for
the spans which are outside or inside the sphere (but not on).<br>
            <br>
Is there a way to force the borders of the contour to follow the
surface ?<br>
            <br>
A solution would be to project the contour on the sphere but I can find
any documentation about that.<br>
            <br>
For more clarity, I post a sample of my code.<br>
            <br>
Thanks by advance.<br>
            <br>
Nicolas<br>
            <br>
code:<br>
            <pre>    //sphere definition

     vtkSphereSource* theSphere = vtkSphereSource::New();

     vtkPolyDataMapper * sphereMapper = vtkPolyDataMapper::New();
     sphereMapper-&gt;SetInput(theSphere-&gt;GetOutput());

     vtkLODActor* sphereActor = vtkLODActor::New();
     sphereActor-&gt;SetMapper( sphereMapper);

     vtkRenderer *renderer1 = vtkRenderer::New();
     renderer1-&gt;AddActor(sphereActor);

     vtkRenderWindow *renWin = vtkRenderWindow::New();
     renWin-&gt;AddRenderer(renderer1);

     vtkRenderWindowInteractor *rendIter = vtkRenderWindowInteractor::New();
     rendIter-&gt;SetRenderWindow(renWin);

     // Here comes the image actor constrained handle widget stuff.....
     vtkContourWidget *widget = vtkContourWidget::New();
     widget-&gt;SetInteractor(rendIter);

     vtkSmartPointer&lt;vtkLinearContourLineInterpolator&gt; contourStyle = 
vtkSmartPointer&lt;vtkLinearContourLineInterpolator&gt;::New();

     vtkOrientedGlyphContourRepresentation *rep 
=vtkOrientedGlyphContourRepresentation::SafeDownCast( 
widget-&gt;GetRepresentation() );
     rep-&gt;SetLineInterpolator(contourStyle);

    // we define a Placer to force the contour to be on the sphere
     vtkPolyDataPointPlacer * spherePlacer = vtkPolyDataPointPlacer::New();
     spherePlacer-&gt;AddProp(sphereActor);
     rep-&gt;SetPointPlacer(spherePlacer);

     renWin-&gt;Render();
     rendIter-&gt;Initialize();
     widget-&gt;EnabledOn();
     rendIter-&gt;Start();/
    </pre>
            <br>
            <div>-- <br>
            <br>
            </div>
            </div>
            <br>
_______________________________________________<br>
Powered by <a moz-do-not-send="true" href="http://www.kitware.com"
 target="_blank">www.kitware.com</a><br>
            <br>
Visit other Kitware open-source projects at <a moz-do-not-send="true"
 href="http://www.kitware.com/opensource/opensource.html"
 target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
            <br>
Please keep messages on-topic and check the VTK FAQ at: <a
 moz-do-not-send="true" href="http://www.vtk.org/Wiki/VTK_FAQ"
 target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
            <br>
Follow this link to subscribe/unsubscribe:<br>
            <a moz-do-not-send="true"
 href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
            <br>
          </blockquote>
          </div>
          <br>
          <br clear="all">
          <br>
          <br>
        </blockquote>
        </div>
        </div>
        </div>
      </blockquote>
      </div>
      <br>
      <br>
    </blockquote>
    </div>
    </div>
    </div>
  </blockquote>
  </div>
  <br>
  <br>
</blockquote>
</body>
</html>