[vtkusers] Normal vector of the surface of ellipstic cylinder

Girish Lande girish.lande at agiliad.com
Thu Jul 27 06:10:02 EDT 2017


Hi,

Please refer to attached program. I hope it helps.

On 27 July 2017 at 13:21, arwtyxouymz <arw.tyx-ouy_mz at ezweb.ne.jp> wrote:

>
> I want to make normal vector of the surface of ellipstic cylinder.
> To each surface point, I want to render normal vector, and get surface
> point.
> The current code is this.
>
> #include "vtkPoints.h"
> #include "vtkSmartPointer.h"
> #include "vtkLinearExtrusionFilter.h"
> #include "vtkDataSetMapper.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkProperty.h"
> #include "vtkCamera.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkInteractorStyleTrackballCamera.h"
> #include "vtkPolyLine.h"
>
>
> int main(int argc, char *argv[])
> {
>
>     double angle = 0;
>     double r1, r2;
>     int id = 0;
>     int CenterX, CenterY;
>     r1 = 50;
>     r2 = 30;
>     CenterX = 0; CenterY = 0;
>
>     vtkSmartPointer<vtkPoints> points =
>             vtkSmartPointer<vtkPoints>::New();
>     points->SetNumberOfPoints(31);
>     while (angle <= 2.0 * vtkMath::Pi() + (vtkMath::Pi() / 360.0))
>     {
>         points->InsertPoint(id, r1 * cos(angle) + CenterX, r2 * sin(angle)
> +
> CenterY, 0);
>         angle = angle + (vtkMath::Pi() / 360.0);
>         id++;
>     }
>
>     vtkSmartPointer<vtkPolyLine> line =
>             vtkSmartPointer<vtkPolyLine>::New();
>     line->GetPointIds()->SetNumberOfIds(id);
>     for (int k = 0; k < id; ++k) {
>         line->GetPointIds()->SetId(k, k);
>     }
>
>     vtkSmartPointer<vtkCellArray> lines =
>             vtkSmartPointer<vtkCellArray>::New();
>     lines->InsertNextCell(line);
>
>     vtkSmartPointer<vtkPolyData> polyData =
>             vtkSmartPointer<vtkPolyData>::New();
>     polyData->GlobalReleaseDataFlagOff();
>     polyData->Allocate(1, 1);
>     polyData->SetPoints(points);
>     polyData->SetLines(lines);
>
>     vtkSmartPointer<vtkLinearExtrusionFilter> extrude =
>             vtkSmartPointer<vtkLinearExtrusionFilter>::New();
>     extrude->SetInputData(polyData);
>     extrude->SetExtrusionTypeToNormalExtrusion();
>     extrude->SetVector(0, 0, 100.0);
>     extrude->SetScaleFactor(0.5);
>     extrude->Update();
>
>     vtkSmartPointer<vtkPolyDataMapper> mapper =
>             vtkSmartPointer<vtkPolyDataMapper>::New();
>     mapper->SetInputConnection(extrude->GetOutputPort());
>
>     /*
>     vtkSmartPointer<vtkCylinderSource> cylinder =
>             vtkSmartPointer<vtkCylinderSource>::New();
>     cylinder->SetRadius(5.0);
>     cylinder->SetHeight(10.0);
>     cylinder->SetResolution(100);
>
>     vtkSmartPointer<vtkPolyDataMapper> mapper =
>             vtkSmartPointer<vtkPolyDataMapper>::New();
>     mapper->SetInputConnection(cylinder->GetOutputPort());
>     */
>
>     vtkSmartPointer<vtkActor> actor =
>             vtkSmartPointer<vtkActor>::New();
>     actor->SetMapper(mapper);
>     actor->GetProperty()->SetColor(0.8900, 0.8100, 0.3400);
>
>     vtkSmartPointer<vtkRenderer> ren =
>             vtkSmartPointer<vtkRenderer>::New();
>     ren->SetBackground(.4, .5, .7);
>     ren->AddActor(actor);
>
>
>     vtkSmartPointer<vtkRenderWindow> renWin =
>             vtkSmartPointer<vtkRenderWindow>::New();
>     renWin->AddRenderer(ren);
>     renWin->SetSize(600, 600);
>
>     vtkSmartPointer<vtkRenderWindowInteractor> iren =
>             vtkSmartPointer<vtkRenderWindowInteractor>::New();
>     iren->SetRenderWindow(renWin);
>
>     vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
>             vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
>     iren->SetInteractorStyle(style);
>
>     renWin->Render();
>     iren->Initialize();
>     iren->Start();
>
>     return EXIT_SUCCESS;
> }
>
> please help me!
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.
> com/Normal-vector-of-the-surface-of-ellipstic-cylinder-tp5744171.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
thanks & regards,
Girish

-- 
------------------------------------------------------------
-------------------------------------------------------------
*Disclaimer:* This email message including any attachments is confidential, 
and may be privileged and proprietary to Agiliad. If you are not the 
intended recipient, please notify us immediately by replying to this 
message and destroy all copies of this message including any attachments. 
You are NOT authorized to read, print, retain, copy, disseminate, 
distribute, or use this message or any part thereof. Thank you.
------------------------------------------------------------
------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170727/59884cd3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: normals_at_Each_point_on_sphere.cpp
Type: text/x-c++src
Size: 7751 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170727/59884cd3/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: normals_at_Each_point_on_sphere.png
Type: image/png
Size: 29790 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170727/59884cd3/attachment.png>


More information about the vtkusers mailing list