Hi all,<div><br></div><div>I want to add two surfaces in to a same window. But when I add the second surface the first surface can't be seen. It worked well when I viewed only the points without creating the surfaces. </div>
<div>I have managed to show the two surfaces but in different viewports, but I want to show it in the same where the user can view the relevant positions of the surfaces.</div><div>The code I have done so far is given below.</div>
<div><br></div><div>vtkPoints *points = newPts;//ReadCFDData2();</div><div> vtkPoints *suction_points = newPtsSuction;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div> vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();</div>
<div> polydata->SetPoints(points);</div><div><br></div><div> vtkSmartPointer<vtkPolyData> suction_polydata = vtkSmartPointer<vtkPolyData>::New();</div><div> suction_polydata->SetPoints(suction_points);</div>
<div><br></div><div> vtkSmartPointer<vtkDoubleArray> weights = vtkSmartPointer<vtkDoubleArray>::New();</div><div> weights->SetNumberOfValues(PoValues.GetSize());</div><div> for(int i=0; i< PoValues.GetSize();i++){</div>
<div> weights->SetValue(i, PoValues[i]);</div><div> }</div><div><br></div><div> </div><div> vtkSmartPointer<vtkDoubleArray> suction_weights = vtkSmartPointer<vtkDoubleArray>::New();</div><div> suction_weights->SetNumberOfValues(PoValuesSuction.GetSize());</div>
<div> for(int i=0; i< PoValuesSuction.GetSize();i++){</div><div> suction_weights->SetValue(i, PoValuesSuction[i]);</div><div> }</div><div><br></div><div> </div><div> vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();</div>
<div> glyphFilter->SetInputConnection(polydata->GetProducerPort());</div><div> glyphFilter->Update();</div><div><br></div><div> vtkSmartPointer<vtkVertexGlyphFilter> suction_glyphFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();</div>
<div> suction_glyphFilter->SetInputConnection(suction_polydata->GetProducerPort());</div><div> suction_glyphFilter->Update();</div><div> </div><div> // Create a plane </div><div> // vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();</div>
<div> //plane->SetOrigin(polydata->GetCenter());</div><div> //plane->SetNormal(1,1,1);</div><div><br></div><div> </div><div> // Construct the surface and create isosurface.<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div> vtkSmartPointer<vtkSurfaceReconstructionFilter> surf = vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();</div><div><br></div><div> surf->SetInput(polydata);</div><div> //</div><div> vtkSmartPointer<vtkContourFilter> cf = vtkSmartPointer<vtkContourFilter>::New();</div>
<div> cf->SetInputConnection(surf->GetOutputPort());</div><div> cf->Update();</div><div><br></div><div> // Construct the suction blade surface and create isosurface.<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div> vtkSmartPointer<vtkSurfaceReconstructionFilter> suction_surf = vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();</div><div><br></div><div> suction_surf->SetInput(suction_polydata);</div><div> //</div>
<div> vtkSmartPointer<vtkContourFilter> suction_cf = vtkSmartPointer<vtkContourFilter>::New();</div><div> suction_cf->SetInputConnection(suction_surf->GetOutputPort());</div><div> suction_cf->Update();</div>
<div><br></div><div> vtkPolyData* outputPolyData = cf->GetOutput(); </div><div> vtkPolyData* suction_outputPolyData = suction_cf->GetOutput(); </div><div><br></div><div> //double bounds[6];</div><div> //outputPolyData->GetBounds(bounds);</div>
<div> </div><div> // Find min and max z</div><div> // double minz = bounds[4];</div><div> // double maxz = bounds[5];</div><div> </div><div> </div><div> // Create the color map</div><div> vtkSmartPointer<vtkLookupTable> colorLookupTable = vtkSmartPointer<vtkLookupTable>::New();</div>
<div>colorLookupTable->SetHueRange(0.667,0.0);</div><div>colorLookupTable->SetNumberOfColors(16);</div><div><br></div><div> // colorLookupTable->SetTableRange(minz, maxz);</div><div><br></div><div> colorLookupTable->Build();</div>
<div><br></div><div> // Create the color map</div><div> vtkSmartPointer<vtkLookupTable> colorLookupTable_s = vtkSmartPointer<vtkLookupTable>::New();</div><div>colorLookupTable_s->SetHueRange(0.667,0.0);</div>
<div>colorLookupTable_s->SetNumberOfColors(16);</div><div><br></div><div> // colorLookupTable->SetTableRange(minz, maxz);</div><div><br></div><div> colorLookupTable_s->Build();</div><div> </div><div> // Generate the colors for each point based on the color map</div>
<div>/* vtkSmartPointer<vtkUnsignedCharArray> colors = </div><div> vtkSmartPointer<vtkUnsignedCharArray>::New();</div><div> colors->SetNumberOfComponents(3);</div><div> colors->SetName("Colors");</div>
<div> for(int i = 0; i < outputPolyData->GetNumberOfPoints(); i++)</div><div> {</div><div> double p[3];</div><div> outputPolyData->GetPoint(i,p);</div><div> </div><div> double dcolor[3];</div><div> colorLookupTable->GetColor(PoValues[i], dcolor);</div>
<div> unsigned char color[3];</div><div> for(unsigned int j = 0; j < 3; j++)</div><div> {</div><div> color[j] = static_cast<unsigned char>(255.0 * dcolor[j]);</div><div> }</div><div><br></div>
<div> colors->InsertNextTupleValue(color);</div><div> }</div><div> </div><div> outputPolyData->GetPointData()->SetScalars(colors);*/</div><div> // double min = minimumValue(PoValues);</div><div> int length = PoValues.GetSize();// establish size of array</div>
<div> double max = PoValues[0]; // start with max = first element</div><div><br></div><div> for(int i = 1; i<length; i++)</div><div> {</div><div> if(PoValues[i] > max)</div><div> max = PoValues[i];</div>
<div> }</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> double min = PoValues[0];</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> for(int i = 1; i<length; i++)</div>
<div> {</div><div> if(PoValues[i] < min)</div><div> min = PoValues[i];</div><div> }</div><div> </div><div><br></div><div> colorLookupTable->SetTableRange( min,max);</div><div> outputPolyData->GetPointData()->SetScalars(weights);</div>
<div><br></div><div> int length_s = PoValuesSuction.GetSize();// establish size of array</div><div> double max_s = PoValuesSuction[0]; // start with max = first element</div><div><br></div><div> for(int i = 1; i<length_s; i++)</div>
<div> {</div><div> if(PoValuesSuction[i] > max_s)</div><div> max_s = PoValuesSuction[i];</div><div> }</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> double min_s = PoValuesSuction[0];</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> for(int i = 1; i<length_s; i++)</div><div> {</div><div> if(PoValuesSuction[i] < min_s)</div><div> min_s = PoValuesSuction[i];</div>
<div> }</div><div> </div><div><br></div><div> colorLookupTable_s->SetTableRange( min_s,max_s);</div><div> suction_outputPolyData->GetPointData()->SetScalars(suction_weights);</div><div> </div><div> // Create a mapper and actor</div>
<div> vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();</div><div> mapper->SetInputConnection(/*reverse->GetOutputPort()*/cf->GetOutputPort());</div><div> mapper->ScalarVisibilityOn();</div>
<div> mapper->SetColorModeToMapScalars();</div><div> mapper->SetLookupTable(colorLookupTable);</div><div> mapper->SetScalarMaterialModeToDefault();</div><div> mapper->SetScalarRange(min,max);</div><div> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();</div>
<div> //actor->GetProperty()->SetColor(1.0, 0.8941, 0.7686); // bisque</div><div> actor->SetMapper(mapper);</div><div><br></div><div> </div><div> // Create a mapper and actor for suction blade</div><div> vtkSmartPointer<vtkPolyDataMapper> suction_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();</div>
<div> suction_mapper->SetInputConnection(/*reverse->GetOutputPort()*/suction_cf->GetOutputPort());</div><div> suction_mapper->ScalarVisibilityOn();</div><div> suction_mapper->SetColorModeToMapScalars();</div>
<div> suction_mapper->SetLookupTable(colorLookupTable_s);</div><div> suction_mapper->SetScalarMaterialModeToDefault();</div><div> suction_mapper->SetScalarRange(min_s,max_s);</div><div> vtkSmartPointer<vtkActor> suction_actor = vtkSmartPointer<vtkActor>::New();</div>
<div> // actor->GetProperty()->SetColor(1.0, 0.8941, 0.7686); // bisque</div><div> suction_actor->SetMapper(suction_mapper);</div><div> </div><div> //Create a renderer, render window, and interactor</div><div>
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();</div><div> renderer->SetViewport( 0., 0., 0.5, 1. );</div><div> renderer->SetBackground( 0.2, 0.2, 0.8 );</div><div> </div>
<div> vtkSmartPointer<vtkRenderer> suction_renderer = vtkSmartPointer<vtkRenderer>::New();</div><div> suction_renderer->SetViewport( 0.5, 0., 1., 1. );</div><div> suction_renderer->SetBackground( 0.8, 0.2, 0.2 );</div>
<div><br></div><div> </div><div> vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();</div><div> renderWindow->AddRenderer(renderer);</div><div> renderWindow->AddRenderer(suction_renderer);</div>
<div> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div> renderWindowInteractor->SetRenderWindow(renderWindow);</div><div><br>
</div><div> // vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div> //interactor->SetRenderWindow( renderWindow );</div><div> //Add the actor to the scene</div>
<div> renderer->AddViewProp(actor);</div><div> suction_renderer->AddViewProp(suction_actor);</div><div> // renderer->SetBackground(.1, .6, .3); // Background color green</div><div> </div><div> //Render and interact</div>
<div> renderWindow->Render();</div><div> renderWindowInteractor->Start(); <br clear="all"><div><br></div><div>Please give me your ideas.</div><div>Thanks.</div>-- <br><div></div><font color="#666666">Gish</font><br>
</div>