[vtkusers] HELP!! What am I doing wrong???

Jean M. Favre jfavre at cscs.ch
Mon Jul 7 06:12:12 EDT 2003


marisa aurelio wrote:
> 
> Hi vtkUsers,
> 
> I have 2 superquadrics that I add to a vtkActtorCollection and then try to
> visualize them.
> But the only superquadrics I see is the last one that I add to my
> vtkActorCollection.
> 
> void main()
> {
>      vtkActorCollection *imageActorCollection = vtkActorCollection::New();
>      int n_elipsoid = 2;
> 
>      for(int i = 0; i < n_elipsoid; i++)
>      {
>           vtkSuperquadricSource *Superquadric =
> vtkSuperquadricSource::New();
>           vtkPolyDataMapper *eliMapper = vtkPolyDataMapper::New();
>           vtkActor *SuperquadricActor = vtkActor::New();
> 
>           if(n_elipsoid == 1)
>           {
>                 Superquadric->SetThetaResolution( 100.0 );
>                 Superquadric->SetPhiResolution( 100.0 );
>                 Superquadric->SetPhiRoundness( 1 );
>                 Superquadric->SetThetaRoundness(1);
>                 Superquadric->SetScale(0.25,0.35,0.25);
>           }
>           else
>           {
>                 Superquadric->SetThetaResolution( 100.0 );
>                 Superquadric->SetPhiResolution( 100.0 );
>                 Superquadric->SetPhiRoundness( 1 );
>                 Superquadric->SetThetaRoundness(1);
>                 Superquadric->SetScale(0.5,0.6,0.5);
> 
>         SuperquadricActor->GetProperty()->SetRepresentationToWireframe();
>           }
> 
>           eliMapper->SetInput(Superquadric->GetOutput());
>           SuperquadricActor->SetMapper( eliMapper );
> 
>           imageActorCollection->AddItem(SuperquadricActor);
>      }


Your if() test is wrong and the if-body is never executed, thus, you
have 2 actors which are exactly the same since the else-body get
executed twice.

replace if(n_elipsoid == 1) by if(i == 1) and it will work.


-- 
Dr. Jean M. Favre,                            email:favre at cscs.ch
http://www.cscs.ch/people/Favre.html
CSCS, Swiss Center for Scientific Computing | Tel:  +41 (91) 610.82.40
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82



More information about the vtkusers mailing list