<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi all,<div><br></div><div>I am using MS visual studio 2008 and vtk 5.10</div><div><br></div><div>I want compare two vtkPolyData objects, so I have written below function:</div><div><div>bool Matched(vtkPolyData* data1, vtkPolyData* data2, double tolerance)</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>if (data1 && data2) // Initial check</div><div><span class="Apple-tab-span" style="white-space:pre">         </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                    </span>int pointCount1 = data1->GetNumberOfPoints(); // Get number of data1's point number</div><div><span class="Apple-tab-span" style="white-space:pre">                       </span>int pointCount2 = data2->GetNumberOfPoints(); <span style="font-size: 12pt;">// Get number of data2's point number</span></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                     </span>if (pointCount1 == pointCount2) // Check numbers</div><div><span class="Apple-tab-span" style="white-space:pre">                     </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                            </span>vtkPointLocator* locator = vtkPointLocator::New(); // Create new locator for data2</div><div><span class="Apple-tab-span" style="white-space:pre">                           </span>locator->SetDataSet(data2);</div><div><span class="Apple-tab-span" style="white-space:pre">                               </span>locator->BuildLocator();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                         </span>for (int i = 0; i < pointCount1; i++) // Loop each point from data1 and compare with closest point from data2</div><div><span class="Apple-tab-span" style="white-space:pre">                             </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                                    </span>int pointID;</div><div><span class="Apple-tab-span" style="white-space:pre">                                 </span>double point1[3], point2[3];</div><div><span class="Apple-tab-span" style="white-space:pre">                                 </span>data1->GetPoint(i, point1); // Get point from data1</div><div><span class="Apple-tab-span" style="white-space:pre">                                       </span>pointID = locator->FindClosestPoint(point1); // Get closest point ID from data2</div><div><span class="Apple-tab-span" style="white-space:pre">                                   </span>data2->GetPoint(pointID, point2);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>if (abs(point1[0] - point2[0]) > tolerance || abs(point1[2] - point2[2]) > tolerance) // Check difference for x and z coordinates</div><div><span class="Apple-tab-span" style="white-space:pre">                                      </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                                            </span>locator->Delete(); // Free memory</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>return false; // No need for check other points</div><div><span class="Apple-tab-span" style="white-space:pre">                                      </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                            </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                           </span>locator->Delete(); // Free memory</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>return true;</div><div><span class="Apple-tab-span" style="white-space:pre">                 </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">            </span></div><div><span class="Apple-tab-span" style="white-space:pre">             </span>return false;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div></div><div><br></div><div>Please note that I ignore y coordinate.</div><div><br></div><div>Any better suggestion will be appreciated.</div><div><br></div><div>Thank you all</div><div><br></div><div><br></div>                                    </div></body>
</html>