[vtkusers] Decimation problems

Stefan Huber Huber.Ste at gmx.at
Tue Mar 11 11:04:15 EDT 2008


Hi Frederic

i tried it without paramters but it didn't work.

My polydata object contains points, normals, tcoords and polys. So i thought that i have to delete the polys first before i generate new ones.

my code:
extern "C" _declspec(dllexport) bool delaunay3D(float tol, float alpha, bool bound);

vtkPolyData *poly = vtkPolyData::New();

bool loadFromOff(){

    vtkPoints *points = vtkPoints::New();
	vtkCellArray *polys = vtkCellArray::New();
	vtkFloatArray *coords = vtkFloatArray::New();
	vtkFloatArray *normals = vtkFloatArray::New();
	coords->SetNumberOfComponents(2);
	normals->SetNumberOfComponents(3);

	bool state = false;
	int n_pts,n_polys,i,j,anz = 0;
	float p[3], n[3], t[2];
	vtkIdType n_vertices = 0;
	vtkIdType v[3];
	vtkIdType vertex_id = 0;

	FILE *in = fopen("c:/surface.off","r");
	if(!in){
		state = false;
	}
	else {
		fscanf(in,"NOFF\n");
		fscanf(in,"%d %d 0\n",&n_pts,&n_polys);

		// read the points from the file
		for(i=0;i<n_pts;i++)
		{
			fscanf(in,"%f %f %f %f %f %f %f %f\n",&p[0],&p[1],&p[2],&n[0],&n[1],&n[2],&t[0],&t[1]);
			points->InsertNextPoint(p);
			coords->InsertNextTuple(t);
			normals->InsertNextTuple(n);
		}

		for(i=0;i<n_polys;i++)
		{
			fscanf(in, "%d %d %d %d \n", &anz, &v[0], &v[1], &v[2]);	
			polys->InsertNextCell(3,v);			
		}

		poly->SetPoints(points);
		points->Delete();
		poly->GetPointData()->SetNormals(normals);
		normals->Delete();
		poly->GetPointData()->SetTCoords(coords);
		coords->Delete();
		poly->SetPolys(polys);
		polys->Delete();

		state = true;
	}
	return state;
}


bool delaunay3D(float tol, float alpha, bool bound){
	bool state = false;
	vtkDelaunay3D *del3D;

	if (!loadFromOff()){
		return state;
	} else {
		//poly->GetPolys()->Delete();

		del3D = vtkDelaunay3D::New();

		del3D->SetInput(poly);
		del3D->Update();

//		del3D->GetOutput();

		writeTest();
		state = true;
		return state;
	}
}

-------- Original-Nachricht --------
> Datum: Tue, 11 Mar 2008 15:35:08 +0100
> Von: "Frederic DANESI" <frederic.danesi at dinccs.com>
> An: "\'Stefan Huber\'" <Huber.Ste at gmx.at>
> CC: "\'vtkusers\'" <vtkusers at vtk.org>
> Betreff: RE: [vtkusers] Decimation problems

> Why did you delete your polys before calling Delaunay ?
> > > poly->GetPolys()->Delete();
> 
> Be aware that Delaunay does not really work on vtkPoints included in the
> input, but on Points that are actually used by at least one cell in the
> input ...
> 
> You should simply try for example :
> vtkDelaunay3D *delaunay = vtkDelaunay3D::New();
> delaunay->SetInput(poly);
> //delaunay->SetTolerance(0.01); WARNING : this is relative to the bounding
> box !!!
> //delaunay->SetAlpha(0.2);
> //delaunay->BoundingTriangulationOn();
> delaunay->Update();
> 
> without further parameters, and without deleting the polys ... 
> just to see if it works ...
> 
> For more help, we may need more code or data example ...
> HTH
> Fred.
> 
> 
> > -----Message d'origine-----
> > De : vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] De la
> part
> de
> > Amy Squillacote
> > Envoyé : mardi 11 mars 2008 15:02
> > À : Stefan Huber
> > Cc : vtkusers
> > Objet : Re: [vtkusers] Decimation problems
> > 
> > Please keep the discussion on the vtkusers list. I'm posting your
> > response back to the list so other people may be able to help you find
> > an answer.
> > 
> > - Amy
> > 
> > Stefan Huber wrote:
> > > Hi Amy,
> > >
> > > Thanks for your answer. i am sorry that i didnt give you a good enough
> > discription of the problem.
> > >
> > > But now the problem with the decimation works. I don't know why (i
> didn't do
> > changes) but it works.
> > >
> > > The problem with the delaunay is still existing.
> > > my code:
> > >
> > > poly->GetPolys()->Delete();
> > > vtkDelaunay3D *delaunay = vtkDelaunay3D::New();
> > > delaunay->SetInput(poly);
> > > delaunay->SetTolerance(0.01);
> > > delaunay->SetAlpha(0.2);
> > > delaunay->BoundingTriangulationOn();
> > > delaunay->Update();
> > >
> > > When i want to call the Dll (which contains the code) i only get an
> access
> > violation.
> > >
> > >
> > > thanks,
> > > Stefan
> > > -------- Original-Nachricht --------
> > >
> > >> Datum: Tue, 11 Mar 2008 08:00:17 -0500
> > >> Von: Amy Squillacote <ahs at cfdrc.com>
> > >> An: Stefan Huber <Huber.Ste at gmx.at>
> > >> CC: vtkusers at vtk.org
> > >> Betreff: Re: [vtkusers] Decimation problems
> > >>
> > >
> > >
> > >> Hi Stefan,
> > >>
> > >> You have not provided enough information for anyone to help. What is
> the
> > >> problem you are seeing with the two lines of code you listed below?
> For
> > >> example, do you get an error message? If so, what message? Does your
> > >> code segfault? If so, please provide a stack trace.
> > >>
> > >> - Amy
> > >>
> > >> Stefan Huber wrote:
> > >>
> > >>> Hi,
> > >>>
> > >>> i have to call the decimationPro algorithm and a delaunay3d
> algorithm
> > >>>
> > >> but i always get problems when i run the application.
> > >>
> > >>> I have a polydata object which contains the points, normals and
> Tcoords.
> > >>>
> > >>> i always get the problem when i run following code:
> > >>>      decimate->Update();
> > >>>      poly= decimate->GetOutput();
> > >>>
> > >>> can somebody help me please? whats wrong?
> > >>>
> > >>> thanks, Stefan
> > >>>
> > >>>
> > >>>
> > >> --
> > >> Amy Squillacote                    Phone: (256) 726-4839
> > >> Computer Scientist                 Fax: (256) 726-4806
> > >> CFD Research Corporation           Web: http://www.cfdrc.com
> > >> 215 Wynn Drive, Suite 501
> > >> Huntsville, AL  35805
> > >>
> > >>
> > >
> > >
> > 
> > --
> > Amy Squillacote                    Phone: (256) 726-4839
> > Computer Scientist                 Fax: (256) 726-4806
> > CFD Research Corporation           Web: http://www.cfdrc.com
> > 215 Wynn Drive, Suite 501
> > Huntsville, AL  35805
> > 
> > 
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> 

-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free



More information about the vtkusers mailing list