[vtkusers] Coloring a 2D Mapper
Dirk Schmedding
dirk.schmedding at zn-ag.com
Tue Jun 17 04:34:46 EDT 2003
Hi!
I have tried this, but nothing happend. I added ScalarVisibilityOff to
the vtkPolyDataMapper2D, but I have seen no effect.
Herewith the releated code fragment, maybe someone of you can see and
tell me where ( and that seems for me to be the problem) I have to say
the mapper what it has to use (namely the z position data) to color its
content. Or what ever the problem could be...
thanks a lot!
Dirk
//====================================================================================
vtkTransform *drillTransformCylinderM = vtkTransform::New();
drillTransformCylinderM->Identity();
drillTransformCylinderM->Translate( xRangeL, yRangeL, zRangeL );
vtkCylinderSource *drillCylinderM = vtkCylinderSource::New();
drillCylinderM->SetCenter( xRangeL, yRangeL, zRangeL );
drillCylinderM->SetRadius( 4.0 );
drillCylinderM->SetHeight( 100 );
drillCylinderM->SetResolution( 5 );
vtkTransformPolyDataFilter *drillTransPDCylinderM =
vtkTransformPolyDataFilter::New();
drillTransPDCylinderM->SetInput( drillCylinderM->GetOutput() );
drillTransPDCylinderM->SetTransform( drillTransformCylinderM );
vtkPolyDataMapper *drillCylinderMapperM = vtkPolyDataMapper::New();
drillCylinderMapperM->SetInput( drillTransPDCylinderM->GetOutput() );
vtkActor *drillCylinderActorM = vtkActor::New();
drillCylinderActorM->SetMapper( drillCylinderMapperM );
drillCylinderActorM->GetProperty()->SetColor( 0.47, 0.56, 0.73);
drillCylinderActorM->SetOrigin( xRangeL, yRangeL, zRangeL );
rendererM->AddActor( drillCylinderActorM );
//transform object for drill, needed to show drill at plane 1
vtkTransform* transformDrill1 = vtkTransform::New();
transformDrill1->Identity();
transformDrill1->Scale(plane1ScaleFactorM, plane1ScaleFactorM,
plane1ScaleFactorM);
transformDrill1->Translate(-DataBoundsM[0],
-DataBoundsM[2],-DataBoundsM[4]);
//transform filter for drill and plane 1 (needed to apply transform to
drill)
vtkTransformPolyDataFilter* transformFilterDrill1 =
vtkTransformPolyDataFilter::New();
transformFilterDrill1->SetInput( drillTransPDCylinderM->GetOutput());
transformFilterDrill1->SetTransform(transformDrill1);
//transform filter for cone and plane 1 (needed to apply transform to
cone)
vtkTransformPolyDataFilter* transformFilterCone1 =
vtkTransformPolyDataFilter::New();
transformFilterCone1->SetInput(drillTransPDConeM->GetOutput());
transformFilterCone1->SetTransform(transformDrill1);
vtkPlane *plane11 = vtkPlane::New();
vtkPolyDataMapper2D *mapper11 = vtkPolyDataMapper2D::New();
mapper11->SetInput( transformFilterDrill1->GetOutput() );
mapper11->CreateDefaultLookupTable( );
mapper11->ScalarVisibilityOff();
mapper11->AddClippingPlane ( plane11 );
vtkActor2D *gridActor11 = vtkActor2D::New();
gridActor11->SetMapper( mapper11 );
plane1RendererM->AddActor2D( gridActor11 );
//====================================================================================
Wu Ruoyun schrieb:
> Hi
>
> I encounter similar (but not exactly the same) problem yesterday. Gwen's advice solves my problem. Please try
>
> mapper->ScalarVisibilityOff();
>
> Best Wishes!
> Ruoyun
>
>
> -----Original Message-----
> From: Dirk Schmedding [mailto:dirk.schmedding at zn-ag.com]
> Sent: Tuesday, June 17, 2003 12:57 AM
> To: vtkusers at public.kitware.com
> Subject: [vtkusers] Coloring a 2D Mapper
>
>
> Hi!
>
> I don't know how to color an object mapped to a 2D Actor.
>
> What I want is to map a cylinder to an 2D image and color it analogous
> to its z (position) value. So far, so easy...
>
> To map the object is no problem, but now I want to color the mapped
> object. As greater as the z (position) value of the object is, as
> brighter or darker the color have to be. (or colorfuller or what ever
> seems to be easier to realize)
>
> I hope anybody can help me!
> By the way, I am working with Visual C++ under Windows NT.
>
> best regards
> Dirk
>
>
> The current pipeline looks like this:
>
> --------------- ------------------- ---------------
> |vtkTransform | |vtkCylinderSource| |vtkTransform |
> --------------- ------------------- ---------------
> | | |
> v v v
> ---------------------------- ----------------------------
> |vtkTransformPolyDataFilter|--> |vtkTransformPolyDataFilter|
> ---------------------------- ----------------------------
> | |
> v v
> ------------------- ---------- ---------------------
> |vtkPolyDataMapper| |vtkPlane|--> |vtkPolyDataMapper2D|
> ------------------- ---------- ---------------------
> | |
> v v
> ---------- ------------
> |vtkActor| |vtkActor2D|
> ---------- ------------
> | |
> v v
> ------------------- -------------------
> |vtkRendererWidget| |vtkRendererWidget|
> ------------------- -------------------
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list