<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=GB2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18812">
<STYLE>@font-face {
font-family: 宋体;
}
@font-face {
font-family: Verdana;
}
@font-face {
font-family: @宋体;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; layout-grid: 15.6pt; }
P.MsoNormal {
TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
LI.MsoNormal {
TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
DIV.MsoNormal {
TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
A:link {
COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
FONT-STYLE: normal; FONT-FAMILY: Verdana; COLOR: windowtext; FONT-WEIGHT: normal; TEXT-DECORATION: none; mso-style-type: personal-compose
}
DIV.Section1 {
page: Section1
}
UNKNOWN {
FONT-SIZE: 10pt
}
BLOCKQUOTE {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>
</HEAD>
<BODY style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV><FONT color=#000080 size=2 face=Verdana>Thank you for your advice.I find it
was the input problem,but I got a new one.When I run my filter ,I got an
error:<STRONG>Cell array cell types with 1 components, has only 18 tuples but there are 180 cells
.</STRONG></FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Verdana>The below is how my
RequestData() write.I am sorry to type long boring code . I have tried to settle
it by myself,but it seems a long time job. I write the
filter almost follow the source code <STRONG><FONT
color=#000000>vtkAppendFilter</FONT></STRONG> .I make my own code
bold-faced.I just want to add some lines to the input dataset. I know I
should add the cell data when I insert the line cells,but I don't know how
to add.</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>code:</FONT></DIV>
<DIV>
<DIV>//get the output info object</DIV>
<DIV>vtkInformation *outInfo= outputVector->GetInformationObject(0);</DIV>
<DIV>//get the output</DIV>
<DIV>vtkUnstructuredGrid* output = vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));</DIV>
<DIV>vtkIdType numPts,numCells,ptOffset;</DIV>
<DIV>int tenth,count,abort = 0;</DIV>
<DIV>float decimal;</DIV>
<DIV>vtkPoints *newPts;</DIV>
<DIV>vtkPointData *pd;</DIV>
<DIV>vtkCellData *cd;</DIV>
<DIV>vtkIdList *ptIds,*newPtIds;</DIV>
<DIV>int idx;</DIV>
<DIV>vtkDataSet *ds;</DIV>
<DIV>vtkIdType ptId,cellId,newCellId;</DIV>
<DIV>vtkPointData *outputPD=output->GetPointData();</DIV>
<DIV>vtkCellData *outPutCD = output ->GetCellData();</DIV>
<DIV>vtkDebugMacro(<<"Appending data together");</DIV>
<DIV></DIV>
<DIV></DIV>
<DIV>count = 0 ;</DIV>
<DIV>decimal = 0 ;</DIV>
<DIV>numPts = 0;</DIV>
<DIV>numCells = 0;</DIV>
<DIV></DIV>
<DIV>int numInputs = inputVector[0]->GetNumberOfInformationObjects();</DIV>
<DIV>vtkDataSetAttributes::FieldList ptList(numInputs);</DIV>
<DIV>vtkDataSetAttributes::FieldList cellList(numInputs);</DIV>
<DIV>int firstPD = 1;</DIV>
<DIV>int firstCD = 1;</DIV>
<DIV></DIV>
<DIV>vtkInformation *inInfo = 0;</DIV>
<DIV>for(idx = 0;idx<numInputs;++idx)</DIV>
<DIV>{</DIV>
<DIV>inInfo = inputVector[0]->GetInformationObject(idx);</DIV>
<DIV>ds = 0;</DIV>
<DIV>if(inInfo)</DIV>
<DIV>{</DIV>
<DIV>ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));</DIV>
<DIV>}</DIV>
<DIV>if(ds!=NULL)</DIV>
<DIV>{</DIV>
<DIV>{</DIV>
<DIV>if(ds->GetNumberOfPoints()<=0&&ds->GetNumberOfCells()<=0)</DIV>
<DIV>continue;</DIV>
<DIV>}</DIV>
<DIV>numPts +=ds->GetNumberOfPoints();</DIV>
<DIV>numCells+=ds->GetNumberOfCells();</DIV>
<DIV></DIV>
<DIV>pd = ds->GetPointData();</DIV>
<DIV>if(firstPD)</DIV>
<DIV>{</DIV>
<DIV>ptList.InitializeFieldList(pd);</DIV>
<DIV>firstPD = 0;</DIV>
<DIV>}</DIV>
<DIV>else ptList.IntersectFieldList(pd);</DIV>
<DIV></DIV>
<DIV>cd = ds->GetCellData();</DIV>
<DIV>if(firstCD)</DIV>
<DIV>{</DIV>
<DIV>cellList.InitializeFieldList(cd);</DIV>
<DIV>firstCD = 0;</DIV>
<DIV>}</DIV>
<DIV>else cellList.IntersectFieldList(cd);</DIV>
<DIV>}//if non-empty dataset</DIV>
<DIV>}//for all inputs</DIV>
<DIV></DIV>
<DIV>if(numPts<1)</DIV>
<DIV>{</DIV>
<DIV>vtkDebugMacro(<<"No data to append!");</DIV>
<DIV>return 1;</DIV>
<DIV>}</DIV>
<DIV>//</DIV>
<DIV> </DIV>
<DIV><STRONG>int numRays;</STRONG></DIV>
<DIV><STRONG>vector<WaveRay*> rayVector;</STRONG></DIV>
<DIV><STRONG>numRays = IcosahedronModel::GenerateRays(&rayVector,TF);</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV></DIV>
<DIV>//now can allocate</DIV>
<DIV>output->Allocate(numCells+numRays);</DIV>
<DIV>outputPD->CopyGlobalIdsOn();</DIV>
<DIV>outputPD->CopyAllocate(ptList,numPts);</DIV>
<DIV>outPutCD->CopyGlobalIdsOn();</DIV>
<DIV>outPutCD->CopyAllocate(cellList,numCells);</DIV>
<DIV></DIV>
<DIV>newPts = vtkPoints::New();</DIV>
<DIV>newPts->SetNumberOfPoints(numPts+2*numRays);</DIV>
<DIV>ptIds = vtkIdList::New();ptIds->Allocate(VTK_CELL_SIZE);</DIV>
<DIV>newPtIds = vtkIdList::New();newPtIds->Allocate(VTK_CELL_SIZE);</DIV>
<DIV></DIV>
<DIV>//append each input dataset together</DIV>
<DIV>tenth = (numPts+numCells)/10+1;</DIV>
<DIV>ptOffset = 0;</DIV>
<DIV>int inputCount = 0;</DIV>
<DIV>for(idx = 0;idx <numInputs&&!abort;++idx)</DIV>
<DIV>{</DIV>
<DIV>inInfo = inputVector[0]->GetInformationObject(idx);</DIV>
<DIV>ds = 0;</DIV>
<DIV>if(inInfo)</DIV>
<DIV>{</DIV>
<DIV>ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));</DIV>
<DIV>}</DIV>
<DIV>if(ds!=NULL&&(ds->GetNumberOfCells()>0||ds->GetNumberOfPoints()>0))</DIV>
<DIV>{</DIV>
<DIV>numPts = ds->GetNumberOfPoints();</DIV>
<DIV>numCells = ds->GetNumberOfCells();</DIV>
<DIV>pd = ds->GetPointData();</DIV>
<DIV>for(ptId = 0;ptId<numPts&&!abort;ptId++)</DIV>
<DIV>{</DIV>
<DIV>newPts->SetPoint(ptId+ptOffset,ds->GetPoint(ptId));</DIV>
<DIV>outputPD->CopyData(ptList,pd,inputCount,ptId,ptId+ptOffset);</DIV>
<DIV>//Update progress</DIV>
<DIV>count++;</DIV>
<DIV>if(!(count%tenth))</DIV>
<DIV>{</DIV>
<DIV>decimal+=0.1;</DIV>
<DIV>this->UpdateProgress(decimal);</DIV>
<DIV>abort= this->GetAbortExecute();</DIV>
<DIV>}</DIV>
<DIV>}</DIV>
<DIV>cd = ds->GetCellData();</DIV>
<DIV>for(cellId = 0;cellId<numCells&&!abort;cellId++)</DIV>
<DIV>{</DIV>
<DIV>ds->GetCellPoints(cellId,ptIds);</DIV>
<DIV>newPtIds->Reset();</DIV>
<DIV>for(int i =0;i<ptIds->GetNumberOfIds();i++)</DIV>
<DIV>{</DIV>
<DIV>newPtIds->InsertId(i,ptIds->GetId(i)+ptOffset);</DIV>
<DIV>}</DIV>
<DIV>newCellId = output->InsertNextCell(ds->GetCellType(cellId),newPtIds);</DIV>
<DIV>outPutCD->CopyData(cellList,cd,inputCount,cellId,newCellId);</DIV>
<DIV></DIV>
<DIV>//Update progress</DIV>
<DIV>count++;</DIV>
<DIV>if(!(count%tenth))</DIV>
<DIV>{</DIV>
<DIV>decimal+=0.1;</DIV>
<DIV>this->UpdateProgress(decimal);</DIV>
<DIV>abort = this->GetAbortExecute();</DIV>
<DIV>}</DIV>
<DIV>}</DIV>
<DIV>ptOffset+=numPts;</DIV>
<DIV>++inputCount;</DIV>
<DIV>}</DIV>
<DIV>}</DIV>
<DIV>//<FONT color=#ff0000>Add lines to the input dataset</FONT></DIV>
<DIV><STRONG>vtkLine* line;</STRONG></DIV>
<DIV><STRONG>for(idx = 0;idx<numRays;++idx)</STRONG></DIV>
<DIV><STRONG>{</STRONG></DIV>
<DIV><STRONG>//newPts->InsertNextPoint(();</STRONG></DIV>
<DIV><STRONG>//newPts->InsertNextPoint();</STRONG></DIV>
<DIV><STRONG>newPts->SetPoint(ptOffset++,((WaveRay*)rayVector[idx])->GetPosition());</STRONG></DIV>
<DIV><STRONG>newPts->SetPoint(ptOffset++,((WaveRay*)rayVector[idx])->GetLinePosition(2));</STRONG></DIV>
<DIV><STRONG>line = vtkLine::New();</STRONG></DIV>
<DIV><STRONG>line->GetPointIds()->SetId(0,ptOffset-2);</STRONG></DIV>
<DIV><STRONG>line->GetPointIds()->SetId(1,ptOffset-1);</STRONG></DIV>
<DIV><STRONG>output->InsertNextCell(line->GetCellType(),line->GetPointIds());</STRONG></DIV>
<DIV><STRONG>//<FONT color=#ff0000>I know I should add cell
data attributes,but how?</FONT></STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG>line->Delete();</STRONG></DIV>
<DIV><STRONG>}</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV>//Update ourselves and release memory</DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV> </DIV></DIV>
<DIV>
<DIV>output->SetPoints(newPts);</DIV>
<DIV>newPts->Delete();</DIV>
<DIV>ptIds->Delete();</DIV>
<DIV>newPtIds->Delete();</DIV></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Verdana> </FONT></DIV>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana>2009-09-24 </FONT></DIV><FONT
color=#000080 size=2 face=Verdana>
<HR style="WIDTH: 100px" align=left color=#b5c4df SIZE=1>
</FONT>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana><SPAN>young_jh123</SPAN>
</FONT></DIV>
<HR color=#b5c4df SIZE=1>
<DIV><FONT size=2 face=Verdana><STRONG>发件人:</STRONG> Utkarsh Ayachit
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发送时间:</STRONG> 2009-09-22 22:25:12
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>收件人:</STRONG> young_jh123 </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>抄送:</STRONG> Moreland, Kenneth;
paraview@paraview.org </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>主题:</STRONG> Re: [Paraview] Problems with
user defined filter </FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>So you have written a vtk filter, then I am
assuming you have some main() in which you are creating a VTK-pipeline to use
this filter? Are you setting up the inputs correctly? Try calling Update()
directly on the filter, does that result in calling of your RequestData()
method?
<DIV><BR></DIV>
<DIV>Utkarsh<BR><BR>
<DIV class=gmail_quote>On Tue, Sep 22, 2009 at 9:04 AM, young_jh123 <SPAN
dir=ltr><<A
href="mailto:young_jh123@qq.com">young_jh123@qq.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV><FONT color=#000080 size=2 face=Verdana>I want to write VTK filter
first.Because I think it will be easier coding in windows than in
linux,and if a VTK filter can work I know how to change a it to a
paraview plugin filter.</FONT></DIV>
<DIV><FONT color=#000080>I'll try to write it as a paraview plugin
directly.Thank you !</FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Verdana></FONT> </DIV>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana>2009-09-22 </FONT></DIV><FONT
color=#000080 size=2 face=Verdana>
<HR style="WIDTH: 100px" align=left color=#b5c4df SIZE=1>
</FONT>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana><SPAN>young_jh123</SPAN>
</FONT></DIV>
<HR color=#b5c4df SIZE=1>
<DIV><FONT size=2 face=Verdana><STRONG>发件人:</STRONG> Moreland, Kenneth
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发送时间:</STRONG> 2009-09-22
06:59:07 </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>收件人:</STRONG> young_jh123; <A
href="mailto:paraview@paraview.org" target=_blank>paraview@paraview.org</A>
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>抄送:</STRONG> </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>主题:</STRONG> Re: [Paraview] Problems
with user defined filter </FONT></DIV>
<DIV>
<DIV></DIV>
<DIV class=h5>
<DIV><FONT size=2 face=Verdana></FONT></DIV>
<DIV><FONT size=2 face=Verdana><FONT
face="Calibri, Verdana, Helvetica, Arial"><SPAN style="FONT-SIZE: 11pt">How
are you trying to use your filter? Are you trying to define it in a
ParaView plugin? If so, you should be able to leave out any of the
_EXPORT declarations and it should work OK.<BR><BR>-Ken<BR><BR><BR>On 9/21/09
9:02 AM, "young_jh123" <<A href="http://young_jh123@qq.com"
target=_blank>young_jh123@qq.com</A>> wrote:<BR><BR></SPAN></FONT>
<BLOCKQUOTE><SPAN style="FONT-SIZE: 11pt"><FONT
face="Verdana, Helvetica, Arial">I write a filter class just like the
vtkAppendFilter ,and change a little on the mothod
<B>RequestData</B></FONT></SPAN><FONT face="Verdana, Helvetica, Arial"><FONT
size=2><SPAN style="FONT-SIZE: 10pt"> ..My class also inherited from
vtkUnstructuredGridAlgorithm .I did the job all on windows vs2008.The
vtkAppendFilter.h defines the class with VTK_GRAPHICS_EXPORT which means
__declspec( dllimport ) on my computer,but if I used that macro to define my
own filter class it would met some link errors .If I use the macro
VTK_EXPORT or did not use macro to define my filter class ,it can
complie well,but it did not work.I tried the debug.I found it would not
invoke my RequestData function at all,and the it would not invoke
vtkUnstructuredGridAlgorithm'RequestData methord either.The program invoked
the method RequestData form vtkAlgorithm class directly.I don't know why?
what should I do if want to define my own filter? Thanks a
lot!<BR> <BR></SPAN></FONT><FONT color=#c0c0c0><SPAN
style="FONT-SIZE: 11pt">2009-09-21 <BR></SPAN></FONT><SPAN
style="FONT-SIZE: 11pt">
<HR align=left SIZE=2 width="100%">
<FONT color=#c0c0c0>young_jh123</FONT></SPAN><FONT color=#c0c0c0><FONT
size=2><SPAN style="FONT-SIZE: 10pt"> <BR></SPAN></FONT></FONT><FONT
size=2><SPAN
style="FONT-SIZE: 10pt"><BR></SPAN></FONT></FONT></BLOCKQUOTE><FONT
face="Verdana, Helvetica, Arial"><FONT size=2><SPAN
style="FONT-SIZE: 10pt"><BR></SPAN></FONT></FONT><FONT size=2><SPAN
style="FONT-SIZE: 10pt"><FONT
face="Consolas, Courier New, Courier"><BR> ****
Kenneth Moreland<BR> ***
Sandia National Laboratories<BR>***********
<BR>*** *** *** email: <A href="http://kmorel@sandia.gov"
target=_blank>kmorel@sandia.gov</A><BR>** *** ** phone:
(505) 844-8919<BR> ***
web: <A
href="http://www.cs.unm.edu/~kmorel"
target=_blank>http://www.cs.unm.edu/~kmorel</A><BR></FONT></SPAN></FONT><FONT
face="Calibri, Verdana, Helvetica, Arial"><SPAN
style="FONT-SIZE: 11pt"><BR></SPAN></FONT></FONT></DIV></DIV></DIV></DIV><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 <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 ParaView Wiki at: <A
href="http://paraview.org/Wiki/ParaView"
target=_blank>http://paraview.org/Wiki/ParaView</A><BR><BR>Follow this link to
subscribe/unsubscribe:<BR><A
href="http://www.paraview.org/mailman/listinfo/paraview"
target=_blank>http://www.paraview.org/mailman/listinfo/paraview</A><BR><BR></BLOCKQUOTE></DIV><BR></DIV></FONT></DIV></BODY></HTML>