<div dir="ltr">Does your VTP file have point Normals? Can you share the file?<div><br></div><div>Thanks,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 31, 2015 at 5:30 AM, lilymo <span dir="ltr"><<a href="mailto:lilymagic2005@yahoo.com.hk" target="_blank">lilymagic2005@yahoo.com.hk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">By referencing the example of WarpScalar (<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/WarpScalar" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/WarpScalar</a><br>
<<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/WarpScalar" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/WarpScalar</a>>  ), I use a<br>
.vtp file instead of the sphere in the example, and I have edited some parts<br>
of it, mainly for the normal part.<br>
<br>
However, it seems that the point only offset towards the same normal, which<br>
results in a translation only.<br>
<br>
If I use vtkSphereSource, the following code can offset the points by its<br>
own normal, but not the same normal for all the points at the same time.<br>
<br>
What should I do? Thanks!<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
#include <vtkActor.h><br>
#include <vtkDoubleArray.h><br>
#include <vtkPointData.h><br>
#include <vtkPolyData.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkSmartPointer.h><br>
#include <vtkSphereSource.h><br>
#include <vtkWarpScalar.h><br>
#include <vtkMath.h><br>
<br>
#include <vtkXMLPolyDataReader.h><br>
<br>
#include <vtkCylinderSource.h><br>
#include <vtkUnsignedCharArray.h><br>
#include <vtkTransform.h><br>
#include <vtkTransformPolyDataFilter.h><br>
#include <vtkProperty.h><br>
<br>
<br>
int main(int, char *[])<br>
{<br>
        vtkSmartPointer<vtkXMLPolyDataReader> sphereSource =<br>
                vtkSmartPointer<vtkXMLPolyDataReader>::New();<br>
        sphereSource->SetFileName("test.vtp");<br>
<br>
        // Create Scalars<br>
        vtkSmartPointer<vtkDoubleArray> scalars =<br>
                vtkSmartPointer<vtkDoubleArray>::New();<br>
        int numberOfPoints = sphereSource->GetOutput()->GetNumberOfPoints();<br>
<br>
        sphereSource->GetOutput()->GetPointData()->SetScalars(scalars);<br>
<br>
        vtkSmartPointer<vtkWarpScalar> warpScalar =<br>
                vtkSmartPointer<vtkWarpScalar>::New();<br>
        warpScalar->SetInputConnection(sphereSource->GetOutputPort());<br>
        warpScalar->SetScaleFactor(1); // use the scalars themselves<br>
<br>
        scalars->SetNumberOfTuples(numberOfPoints);<br>
<br>
<br>
        for(vtkIdType i = 0; i < numberOfPoints; ++i)<br>
        {<br>
                scalars->SetTuple1(i,20);<br>
        }<br>
<br>
        //???<br>
        warpScalar->GetUseNormal();<br>
        warpScalar->Update();<br>
<br>
<br>
        //--------------------------------------------------------------------<br>
        vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
                vtkSmartPointer<vtkPolyDataMapper>::New();<br>
        mapper->SetInputConnection(warpScalar->GetOutputPort());<br>
<br>
        vtkSmartPointer<vtkActor> actor =<br>
                vtkSmartPointer<vtkActor>::New();<br>
        actor->GetProperty()->SetColor(1.0, 1.0, 0.0);<br>
        actor->SetMapper(mapper);<br>
<br>
        vtkSmartPointer<vtkPolyDataMapper> smapper =<br>
                vtkSmartPointer<vtkPolyDataMapper>::New();<br>
        smapper->SetInputConnection(sphereSource->GetOutputPort());<br>
<br>
        vtkSmartPointer<vtkActor> sactor =<br>
                vtkSmartPointer<vtkActor>::New();<br>
                 sactor->GetProperty()->SetColor(1.0, 0.0, 1.0);<br>
        sactor->SetMapper(smapper);<br>
<br>
        //--------------------------------------------------------------------<br>
        // Visualize<br>
        vtkSmartPointer<vtkRenderer> renderer =<br>
                vtkSmartPointer<vtkRenderer>::New();<br>
        vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
                vtkSmartPointer<vtkRenderWindow>::New();<br>
        renderWindow->AddRenderer(renderer);<br>
        vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
                vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
        renderWindowInteractor->SetRenderWindow(renderWindow);<br>
<br>
        renderer->AddActor(actor);<br>
        renderer->AddActor(sactor);<br>
        renderer->SetBackground(1,1,1);<br>
<br>
        renderWindow->Render();<br>
        renderWindowInteractor->Start();<br>
<br>
        return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/WarpScalar-Problem-about-normal-tp5733689.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/WarpScalar-Problem-about-normal-tp5733689.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>