hey, bill, thanks very much ! I find the culprit !<br>Firstly, i try mapper->SetInput(cube->GetOutput()). And, the result is satisfactory. I reach the destination. So, i think there are must be some problems in the pipeline.<br>
Secondely, i remove the vtkDecimatePr from the pipeline, and surprisedly find that the the actor is colored correctly. And if this class is put back, the result is opposite. However, i can not find the reason why this class has a bad effect on the color of cells.<br>
<br>In conclusion, i remove that class, and the program runs correctly. Your think pattern in solving problems in the vtk programming style is great! Have a good weekend!<br><br><br>Thanks<br>Wenwu <br><br><br><div class="gmail_quote">
On Sat, Apr 17, 2010 at 9:49 AM, 朱文武 <span dir="ltr"><<a href="mailto:cool.wenwu@gmail.com">cool.wenwu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>thanks ,bill! i will try, then tell you the result . <br><br></div><div><div></div><div class="h5">
<div class="gmail_quote">On Sat, Apr 17, 2010 at 3:53 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">Another idea. It seems that one pipeline piece is changing the cell<br>data. Try changing the mapper's input to determine which filter is the<br>
culprit.<br><br>Try<br>mapper->SetInput(cube->GetOutput());<br>first.<br><br>Do you get the proper coloring?<br><font color="#888888"><br>bill<br></font>
<div>
<div></div>
<div><br><br>On Fri, Apr 16, 2010 at 3:39 PM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>> wrote:<br>> Try,<br>> smoother->GenerateErrorScalarsOff() ;<br>
><br>> On Fri, Apr 16, 2010 at 1:30 AM, 朱文武 <<a href="mailto:cool.wenwu@gmail.com" target="_blank">cool.wenwu@gmail.com</a>> wrote:<br>>> Bill, thanks very much !<br>>> Here are the all related codes:<br>
>> vtkSmartPointer<vtkBMPReader> m_read = vtkSmartPointer<vtkBMPReader>::New();<br>
>> m_read->SetFilePrefix("C:/Data/brain/TCVH_");//<br>>> m_read->SetFilePattern("%s%d.bmp"); //<br>>> m_read->Allow8BitBMPOn();<br>>> m_read->SetDataByteOrderToLittleEndian();<br>
>> m_read->SetFileNameSliceOffset(5);//<br>>> m_read->SetFileNameSliceSpacing(1);//<br>>> m_read->SetNumberOfScalarComponents(3);//<br>>> m_read->SetDataOrigin(0.0,0.0,0.0);//<br>>> m_read->SetDataSpacing(0.167*4,0.167*4,1);//<br>
>> m_read->SetDataExtent(0,299,0,345,1300,1320);//<br>>> m_read->Update();<br>>><br>>> vtkSmartPointer<vtkDiscreteMarchingCubes> cube =<br>>> vtkSmartPointer<vtkDiscreteMarchingCubes>::New() ;<br>
>> cube->SetInput((vtkDataObject*) m_read->GetOutput() );<br>>> cube->SetValue(0, 111);<br>>> cube->SetValue(1, 121);<br>>> cube->Update() ;<br>>><br>>> vtkSmartPointer<vtkDecimatePro> deci =<br>
>> vtkSmartPointer<vtkDecimatePro>::New();<br>>> deci->SetInputConnection(cube->GetOutputPort());//<br>>> deci->SetTargetReduction(0.5); //<br>>> deci->PreserveTopologyOn(); //<br>
>> deci->ReleaseDataFlagOn();<br>>><br>>> vtkSmartPointer<vtkWindowedSincPolyDataFilter> smoother=<br>>> vtkSmartPointer<vtkWindowedSincPolyDataFilter>::New();<br>>> smoother->SetInput(deci->GetOutput());<br>
>> smoother->SetNumberOfIterations(30) ;<br>>> smoother->NonManifoldSmoothingOn();<br>>> smoother->NormalizeCoordinatesOn();<br>>> smoother->GenerateErrorScalarsOn() ;<br>>> smoother->Update();<br>
>><br>>> vtkSmartPointer<vtkLookupTable> colorLookupTable=<br>>> vtkSmartPointer<vtkLookupTable>::New();<br>>><br>>> colorLookupTable->SetTableRange(0, 122);<br>>> colorLookupTable->SetNumberOfTableValues(123);<br>
>> colorLookupTable->Build();<br>>> for (int i =0; i < 111; i++)<br>>> {<br>>> colorLookupTable->SetTableValue(i , i/255.0, i/255.0,i/255.0);<br>>> }<br>>> colorLookupTable->SetTableValue(111, 1,0,0,1);<br>
>> for (int j = 112; j <120; j++)<br>>> {<br>>> colorLookupTable->SetTableValue(j , j/255.0, j/255.0, j/255.0);<br>>><br>>> }<br>>> colorLookupTable->SetTableValue(121, 0,1,1,1);<br>
>> colorLookupTable->SetTableValue(122, 0,1,1,1);<br>>><br>>> vtkSmartPointer<vtkPolyDataNormals> triangleCellNormals =<br>>> vtkSmartPointer<vtkPolyDataNormals>::New();<br>>> triangleCellNormals->SetInput(smoother->GetOutput());<br>
>> triangleCellNormals->ComputeCellNormalsOn();<br>>> triangleCellNormals->ComputePointNormalsOff();<br>>> triangleCellNormals->ConsistencyOn();<br>>> triangleCellNormals->AutoOrientNormalsOn();<br>
>> triangleCellNormals->Update() ;<br>>><br>>> vtkSmartPointer<vtkPolyDataMapper> mapper =<br>>> vtkSmartPointer<vtkPolyDataMapper>::New();<br>>> mapper->SetInput(triangleCellNormals->GetOutput()); // #this is better for<br>
>> vis<br>>> mapper->ScalarVisibilityOn() ;//#show colour<br>>> mapper->SetScalarRange(colorLookupTable->GetTableRange());<br>>> mapper->SetScalarModeToUseCellData() ; // contains the label eg. 31<br>
>> //mapper->SetScalarModeToUsePointData() ;//#the smoother error relates to<br>>> the verts<br>>> mapper->SetLookupTable(colorLookupTable);<br>>><br>>> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br>
>> actor->SetMapper(mapper);<br>>><br>>> Waiting for suggestion, thanks in advance !<br>>><br>>> Wenwu<br>>><br>>><br>>><br>>> On Fri, Apr 16, 2010 at 12:01 PM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>><br>
>> wrote:<br>>>><br>>>> The lookup table and mapper look OK to me. Can you attach the entire<br>>>> program if it is not too large?<br>>>><br>>>> Bill<br>>>><br>
>>> On Thu, Apr 15, 2010 at 9:00 PM, 朱文武 <<a href="mailto:cool.wenwu@gmail.com" target="_blank">cool.wenwu@gmail.com</a>> wrote:<br>>>> > hi all,<br>>>> ><br>>>> > I sent the message last night! However, no one responded ! So, i<br>
>>> > send<br>>>> > it again. Please forgive me, if it disrupts you!<br>>>> ><br>>>> > I use vtkDiscreteMarchingCubes to reconstruct anatomy structure, and use<br>>>> > the<br>
>>> > vtkLookupTable to map the color. Now, i design the color map as follows:<br>>>> > gray value (111) to red,<br>>>> > gray value(121) to blue.<br>>>> > Other gray value I don't care.<br>
>>> ><br>>>> > Also, the parameter I set in SetValue() of vtkDiscreteMarchingCubes is:<br>>>> > SetValue(0, 111);<br>>>> > SetValue(1, 121);<br>>>> ><br>>>> > Then i set the lookup table as follows:<br>
>>> > vtkSmartPointer<vtkLookupTable> colorLookupTable=<br>>>> > vtkSmartPointer<vtkLookupTable>::New();<br>>>> > colorLookupTable->SetTableRange(0, 122); //<br>>>> > colorLookupTable->SetNumberOfTableValues(123);<br>
>>> > colorLookupTable->Build();<br>>>> ><br>>>> > for (int i =0; i < 111; i++)<br>>>> > {<br>>>> > colorLookupTable->SetTableValue(i , i/255.0, i/255.0,i/255.0); // i<br>
>>> > don't care this loop<br>>>> > }<br>>>> > colorLookupTable->SetTableValue(111, 1,0,0,1); // this is essential for<br>>>> > me<br>>>> > for (int j = 112; j <120; j++)<br>
>>> > {<br>>>> > colorLookupTable->SetTableValue(j , j/255.0, j/255.0, j/255.0); // i<br>>>> > don't care this loop<br>>>> ><br>>>> > }<br>>>> > colorLookupTable->SetTableValue(121, 0,0,1,1);<br>
>>> > colorLookupTable->SetTableValue(122, 0,0,1,1);<br>>>> ><br>>>> > vtkSmartPointer<vtkPolyDataMapper> mapper =<br>>>> > vtkSmartPointer<vtkPolyDataMapper>::New();<br>
>>> > ...<br>>>> > mapper->ScalarVisibilityOn() ;//#show colour<br>>>> > mapper->SetScalarRange(colorLookupTable->GetTableRange());<br>>>> > mapper->SetScalarModeToUseCellData() ;<br>
>>> > mapper->SetLookupTable(colorLookupTable);<br>>>> ><br>>>> > The result of construction is that two structures whose gray value is<br>>>> > 111<br>>>> > and 121 were reconstructed.<br>
>>> > However, the color of these actors is the same- white.<br>>>> > Ccould anyone tell me why and give some suggestions?<br>>>> ><br>>>> > Thanks<br>>>> > Wenwu<br>
>>> > _______________________________________________<br>>>> > Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>>>> ><br>>>> > Visit other Kitware open-source projects at<br>
>>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>>>> ><br>>>> > Please keep messages on-topic and check the VTK FAQ at:<br>
>>> > <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>>> ><br>>>> > Follow this link to subscribe/unsubscribe:<br>>>> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>>> ><br>>>> ><br>>><br>>><br>>><br>>> --<br>>> 祝<br>>> 工作愉快,身体健康!<br>>><br>><br></div></div></blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- </font><br>
</blockquote></div><br>