<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Dear all,<br>
<br>
I adapted the code from this example (http://www.vtk.org/Wiki/VTK/Examples/Cxx/VisualizationAlgorithms/TubesWithVaryingRadiusAndColors) to have a broken line with varying radius and colors generated from a line source (see code below). I would like to have
 a tube with radii and colors that change rapidly, i.e. display two distinct segments with different radii and colors with a clear separation. Everything works well if the points of the line source are close enough (highResTube.png, distance = 1). But when
 increasing the distance between those points, there is no clear separation between the two parts of the line anymore (see lowResTube.png, distance=10) because of the interpolation that the tube filter performs.
<br>
<br>
Is there a way to have this distinct separation (i.e. like in highResTube.png) without increasing the number of points (vtkPoints) that the lineSource takes as input ? I tried
<br>
<br>
lineSource_->SetResolution(100);<br>
<br>
but without success. Also tried to put the arrays containing the radii and colors in cell data, but no success either. Anyone would have a clue on this ? =)<br>
<br>
Regards,<br>
Toan<br>
<br>
----------------<br>
<br>
    double res = 1.; //Tube appearance changes depending on proximity of points, i.e. resolution<br>
    double start = 0.;<br>
    double end = 50.;<br>
    int nPoints = static_cast<int>((end-start) / res);<br>
<br>
    // VTK points<br>
    vtkSmartPointer<vtkPoints> points_ = vtkSmartPointer<vtkPoints>::New();<br>
    points_->SetNumberOfPoints(nPoints);<br>
    double sum = 0;<br>
    for(int ii = 0; ii < nPoints; ++ii)<br>
    {<br>
        points_->SetPoint(ii, sum, 0, 0);<br>
        sum += res;<br>
    }<br>
<br>
    // VTK line source<br>
    vtkSmartPointer<vtkLineSource> lineSource_ = vtkSmartPointer<vtkLineSource>::New();<br>
    lineSource_->SetPoints(points_);<br>
    lineSource_->Update();<br>
<br>
    // Radius<br>
    vtkSmartPointer<vtkDoubleArray> radius_ = vtkSmartPointer<vtkDoubleArray>::New();<br>
    radius_->SetName("TubeRadius");<br>
    radius_->SetNumberOfTuples(nPoints);<br>
    for(int ii = 0; ii < nPoints; ++ii)<br>
    {<br>
        if(ii < nPoints/2)<br>
            radius_->SetTuple1(ii, 2);<br>
        else<br>
            radius_->SetTuple1(ii, 4);<br>
    }<br>
<br>
    // Color<br>
    vtkSmartPointer<vtkUnsignedCharArray> color_ = vtkSmartPointer<vtkUnsignedCharArray>::New();<br>
    color_->SetName("Colors");<br>
    color_->SetNumberOfComponents(3);<br>
    color_->SetNumberOfTuples(nPoints);<br>
    for(int ii = 0; ii < nPoints; ++ii)<br>
    {<br>
        if(ii < nPoints/2)<br>
            color_->InsertTuple3(ii, 255, 0, 0);<br>
        else<br>
            color_->InsertTuple3(ii, 0, 255, 0);<br>
    }<br>
<br>
    lineSource_->GetOutput()->GetPointData()->AddArray(radius_);<br>
    lineSource_->GetOutput()->GetPointData()->SetActiveScalars(radius_->GetName());<br>
    lineSource_->GetOutput()->GetPointData()->AddArray(color_);<br>
<br>
    // VTK tube filter<br>
    vtkSmartPointer<vtkTubeFilter> tubeFilter_ = vtkSmartPointer<vtkTubeFilter>::New();<br>
    tubeFilter_->SetInputData(lineSource_->GetOutput());<br>
<br>
    tubeFilter_->CappingOn();<br>
    tubeFilter_->SetNumberOfSides(10);<br>
    tubeFilter_->SetVaryRadiusToVaryRadiusByAbsoluteScalar();<br>
<br>
    // VTK mapper<br>
    vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();<br>
    mapper->SetInputConnection(tubeFilter_->GetOutputPort());<br>
    mapper->ScalarVisibilityOn();<br>
    mapper->SetScalarModeToUsePointFieldData();<br>
    mapper->SelectColorArray(color_->GetName());<br>
<br>
    // VTK actor<br>
    vtkSmartPointer<vtkActor> actor_ = vtkSmartPointer<vtkActor>::New();<br>
    actor_->SetMapper(mapper);<br>
<br>
    renderer_->AddActor(actor_);<br>
</div>
</body>
</html>