[vtkusers] Oups ! Making our own vtkAppendPolyData...(Could use some help !)

tutu lamotte tutulamotte at yahoo.com
Fri Sep 26 14:10:56 EDT 2003


I forgot to explain the attachment.

We're trying to make this work with a simple demo
application.
A class myVTKApp is created and in the constructor, we
call the member function "make" x times.

For each make execution, a cylinder is produced and we
use the functions "Execute (vtkPolyData *)" to append
it to an already existing polydata
instance...myVTKApp::m_base.

So we took the 4 functions from vtkAppendPolyData :
  1) Execute
  2) AppendData
  3) AppendDifferentPoints
  4) AppendCells

2, 3 and 4 don't really need to be modified and are
used by Execute.

Thanks !

--- tutu lamotte <tutulamotte at yahoo.com> wrote:
> Dear list !
> 
> I am currently trying to implement my own version of
> the Execute function of vtkAppendPolydata. The goal
> is
> to make it so that it appends a “newPoly” to an
> already existing vtkPolyData instance called
> “m_base”.
> 
> Since we wont be generating an output but simply
> modifying an already existing dataset, we must
> Resize
> m_base. I can do that but the MaxID of the points
> data
> array doesn’t get updated. And this I causing
> problems
> in the function AppendData on line 765 (See
> attachment):
> 
> if (src->GetNumberOfTuples() + offset >
> dest->GetNumberOfTuples())
> {
>   return;
> }
> 
> GetNumberOfTuples doesn’t look at the size of the
> array but the MaxID. And divides it by the number of
> components (3).
> 
> In all cases, our goal is to get the best possible
> way
> to really append a polydata to an already existing
> one.
> 
> Thanks for any help !
> 
> 
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product
> search
> http://shopping.yahoo.com> //
> // This example is a windows application (instead of
> a console application)
> // version of Examples/Tutorial/Step1/Cxx/Cone.cxx.
> It is organized in a more
> // object oriented manner and shows a fairly minimal
> windows VTK application.
> //
> 
> 
> // first include the required header files for the
> vtk classes we are using
> #include "vtkConeSource.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include <vtkFeatureEdges.h>
> #include <vtkRotationalExtrusionFilter.h>
> #include "vtkMath.h"
> #include "vtkIdList.h"
> #include "vtkObjectFactory.h"
> #include <vtkPolyDataNormals.h>
> #include <vtkFeatureEdges.h>
> #include <vtkPointLocator.h>
> #include <vtkAppendPolyData.h>
> #include <vtkTransformPolyDataFilter.h> 
> #include <vtkInteractorStyleTrackball.h> 
> #include <vtkPointSource.h>
> #include <vtkFloatArray.h>
> 
> static HANDLE hinst; 
> long FAR PASCAL WndProc(HWND, UINT, UINT, LONG);
> // define the vtk part as a simple c++ class 
> 
> 
> class test
> {
> public:
> 
> 	float m_test[100000];
> };
> 
> 
> class myVTKApp   
> {
> public: 
> 	myVTKApp(HWND parent);     
> 	~myVTKApp();
> 	void make(vtkPolyData* m_base);
> 	void Execute(vtkPolyData* newPoly);
> 	void AppendData(vtkDataArray *dest, vtkDataArray
> *src, vtkIdType offset);
> 	vtkIdType *AppendCells(vtkIdType *pDest,
> vtkCellArray *src, vtkIdType offset);
> 	
> 	void AppendDifferentPoints(vtkDataArray *dest,
> vtkDataArray *src, vtkIdType offset);
> private:
> 	vtkPolyData* m_base;
> 	vtkAppendPolyData* m_append;
> 	test* atest;
> 	vtkRenderWindow *renWin;
> 	vtkRenderer *renderer;
> 	vtkRenderWindowInteractor *iren;
> 
> 	vtkPolyDataNormals* m_normal;
> 	float tr[3];
> 
> };
> 
> 
> int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE
> hPrevInstance,
> 		    LPSTR lpszCmdParam, int nCmdShow) 
> {
>   static char szAppName[] = "Win32Cone";
>   HWND        hwnd ;
>   MSG         msg ;
>   WNDCLASS    wndclass ;
> 
>   if (!hPrevInstance)
>     {
>     wndclass.style         = CS_HREDRAW | CS_VREDRAW
> | CS_OWNDC;
>     wndclass.lpfnWndProc   = WndProc ;
>     wndclass.cbClsExtra    = 0 ;
>     wndclass.cbWndExtra    = 0 ;
>     wndclass.hInstance     = hInstance;
>     wndclass.hIcon         =
> LoadIcon(NULL,IDI_APPLICATION);
>     wndclass.hCursor       = LoadCursor (NULL,
> IDC_ARROW);         
>     wndclass.lpszMenuName  = NULL;
>     wndclass.hbrBackground =
> (HBRUSH)GetStockObject(BLACK_BRUSH);
>     wndclass.lpszClassName = szAppName;
>     RegisterClass (&wndclass);
>     }
>   
>   hinst = hInstance;
>   hwnd = CreateWindow ( szAppName,
>                         "Draw Window",
>                         WS_OVERLAPPEDWINDOW,
>                         CW_USEDEFAULT,
>                         CW_USEDEFAULT,
>                         400,
>                         480,
>                         NULL,
>                         NULL,
>                         hInstance,
>                         NULL);
>   ShowWindow (hwnd, nCmdShow);
>   UpdateWindow (hwnd);
>   
>   double * aTest = new double [10000000];
>   while (GetMessage (&msg, NULL, 0, 0))
>     {     
>     TranslateMessage (&msg);
>     DispatchMessage (&msg);
>     }
>   delete[] aTest;
>   return msg.wParam;
> }
> 
> long FAR PASCAL WndProc (HWND hwnd, UINT message,   
>                       
>                          UINT wParam, LONG lParam)
> {
>   static HWND ewin;
>   static myVTKApp *theVTKApp;
> 
>   switch (message)
>     {
>     case WM_CREATE:
>       {
>       ewin = CreateWindow("button","Exit",
>                           WS_CHILD | WS_VISIBLE |
> SS_CENTER,                   
>                           0,400,400,60, 
>                           hwnd,(HMENU)2, 
>                          
> (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),
>                           NULL);
>       theVTKApp = new myVTKApp(hwnd);
>       return 0;
>       }
>       
>     case WM_COMMAND:
>       switch (wParam)
>         {
>         case 2:
>           PostQuitMessage (0);
>           if (theVTKApp)
>             {
>             delete theVTKApp;
>             theVTKApp = NULL;
>             }
>           break;
>         }
>       return 0;
>       
>     case WM_DESTROY:
>       PostQuitMessage (0);
>       if (theVTKApp)
>         {
>         delete theVTKApp;
>         theVTKApp = NULL;
>         }
>       return 0; 
>     }
>   return DefWindowProc (hwnd, message, wParam,
> lParam);
> }
> 
> 
>  void myVTKApp::make(vtkPolyData* m_base){
> 
> 
> //  vtkConeSource *cone;
> 
> 
> 	vtkPoints* inPts = vtkPoints::New();
> 	inPts->SetNumberOfPoints (4);
> 	inPts->SetPoint( 0, 2, 0.0, 0.0);
> 	inPts->SetPoint( 1, 10, 0.0, 0.0);
> 	inPts->SetPoint( 2, 10, 0.0, 20);
> 	inPts->SetPoint( 3, 0, 0.0,20);
> 
> 	vtkCellArray* lines = vtkCellArray::New();
> 		lines->InsertNextCell( 4);
> 		lines->InsertCellPoint( 0);
> 		lines->InsertCellPoint( 1);
> 		lines->InsertCellPoint( 2);
> 		lines->InsertCellPoint( 3);
> 		//lines->InsertCellPoint( 0);
> 
> 		
> 
> 	vtkPolyData* profile = vtkPolyData::New();
> 	profile->SetPoints( inPts);
> 	profile->SetLines (lines);
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com



More information about the vtkusers mailing list