Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > d5e74628f0e673bb8680aebce32b2c04 > files > 27

itk-doc-3.12.0-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>ITK: DataRepresentation/Mesh/RGBPointSet.cxx</title>
<link href="DoxygenStyle.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">


<!--  Section customized for INSIGHT : Tue Jul 17 01:02:45 2001 -->
<center>
<a href="index.html" class="qindex">Main Page</a>&nbsp;&nbsp; 
<a href="modules.html" class="qindex">Groups</a>&nbsp;&nbsp;
<a href="namespaces.html" class="qindex">Namespace List</a>&nbsp;&nbsp;
<a href="hierarchy.html" class="qindex">Class Hierarchy</a>&nbsp;&nbsp;
<a href="classes.html" class="qindex">Alphabetical List</a>&nbsp;&nbsp;
<a href="annotated.html" class="qindex">Compound List</a>&nbsp;&nbsp; 
<a href="files.html" class="qindex">File
List</a>&nbsp;&nbsp; 
<a href="namespacemembers.html" class="qindex">Namespace Members</a>&nbsp;&nbsp; 
<a href="functions.html" class="qindex">Compound Members</a>&nbsp;&nbsp; 
<a href="globals.html" class="qindex">File Members</a>&nbsp;&nbsp;
<a href="pages.html" class="qindex">Concepts</a></center>


<!-- Generated by Doxygen 1.5.9 -->
<div class="contents">
<h1>DataRepresentation/Mesh/RGBPointSet.cxx</h1><div class="fragment"><pre class="fragment"><span class="comment">/*=========================================================================</span>
<span class="comment"></span>
<span class="comment">  Program:   Insight Segmentation &amp; Registration Toolkit</span>
<span class="comment">  Module:    $RCSfile: RGBPointSet.cxx,v $</span>
<span class="comment">  Language:  C++</span>
<span class="comment">  Date:      $Date: 2008-01-20 21:19:51 $</span>
<span class="comment">  Version:   $Revision: 1.12 $</span>
<span class="comment"></span>
<span class="comment">  Copyright (c) Insight Software Consortium. All rights reserved.</span>
<span class="comment">  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.</span>
<span class="comment"></span>
<span class="comment">     This software is distributed WITHOUT ANY WARRANTY; without even </span>
<span class="comment">     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR </span>
<span class="comment">     PURPOSE.  See the above copyright notices for more information.</span>
<span class="comment"></span>
<span class="comment">=========================================================================*/</span>
<span class="preprocessor">#if defined(_MSC_VER)</span>
<span class="preprocessor"></span><span class="preprocessor">#pragma warning ( disable : 4786 )</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="comment">//  Software Guide : BeginLatex</span>
<span class="comment">//</span>
<span class="comment">//  The following example illustrates how a point set can be parameterized to</span>
<span class="comment">//  manage a particular pixel type. In this case, pixels of RGB type are used.</span>
<span class="comment">//  The first step is then to include the header files of the</span>
<span class="comment">//  \doxygen{RGBPixel} and \doxygen{PointSet} classes.</span>
<span class="comment">//</span>
<span class="comment">//  \index{itk::PointSet!RGBPixel}</span>
<span class="comment">//</span>
<span class="comment">//  Software Guide : EndLatex </span>

<span class="comment">// Software Guide : BeginCodeSnippet</span>
<span class="preprocessor">#include "<a class="code" href="itkRGBPixel_8h.html">itkRGBPixel.h</a>"</span>
<span class="preprocessor">#include "<a class="code" href="itkPointSet_8h.html">itkPointSet.h</a>"</span>
<span class="comment">// Software Guide : EndCodeSnippet</span>


<span class="keywordtype">int</span> <a name="a0"></a><a class="code" href="itkTestMain_8h.html#dacbe0175a79dff748855d8c9839f82b">main</a>(<span class="keywordtype">int</span>, <span class="keywordtype">char</span> *[])
{
  <span class="comment">//  Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">//  Then, the pixel type can be defined by selecting the type to be used to</span>
  <span class="comment">//  represent each one of the RGB components.</span>
  <span class="comment">//</span>
  <span class="comment">//  \index{itk::RGBPixel!Instantiation}</span>
  <span class="comment">//</span>
  <span class="comment">//  Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <span class="keyword">typedef</span> <a name="_a1"></a><a class="code" href="classitk_1_1RGBPixel.html">itk::RGBPixel&lt; float &gt;</a>    PixelType;
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">//  Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">//  The newly defined pixel type is now used to instantiate the PointSet</span>
  <span class="comment">//  type and subsequently create a point set object.</span>
  <span class="comment">//</span>
  <span class="comment">//  Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <span class="keyword">typedef</span> <a name="_a2"></a><a class="code" href="classitk_1_1PointSet.html" title="A superclass of the N-dimensional mesh structure; supports point (geometric coordinate...">itk::PointSet&lt; PixelType, 3 &gt;</a> PointSetType;
  <a name="a3"></a><a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">PointSetType::Pointer</a>  pointSet = <a name="a4"></a><a class="code" href="namespaceHardConnectedComponentImageFilter.html#870262f145e0b45206db74df8053b59c">PointSetType::New</a>();
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">//  Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">//  The following code is generating a sphere and assigning RGB values to</span>
  <span class="comment">//  the points. The components of the RGB values in this example are</span>
  <span class="comment">//  computed to represent the position of the points.</span>
  <span class="comment">//</span>
  <span class="comment">//  \index{itk::PointSet!SetPoint()}</span>
  <span class="comment">//  \index{itk::PointSet!SetPointData()}</span>
  <span class="comment">//</span>
  <span class="comment">//  Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  PointSetType::PixelType   pixel;
  PointSetType::PointType   point;
  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pointId =  0;
  <span class="keyword">const</span> <span class="keywordtype">double</span> radius = 3.0;

  <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;360; i++)
    {
    <span class="keyword">const</span> <span class="keywordtype">double</span> angle = i * atan(1.0) / 45.0;
    point[0] = radius * sin( angle );
    point[1] = radius * cos( angle );
    point[2] = 1.0;
    pixel.SetRed(    point[0] * 2.0 );
    pixel.SetGreen(  point[1] * 2.0 );
    pixel.SetBlue(   point[2] * 2.0 );
    pointSet-&gt;SetPoint( pointId, point );   
    pointSet-&gt;SetPointData( pointId, pixel );   
    pointId++;
    }
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">//  Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">//  All the points on the PointSet are visited using the following code.</span>
  <span class="comment">//</span>
  <span class="comment">//  \index{itk::PointSet!GetPoints()}</span>
  <span class="comment">//  \index{itk::PointSet!points iterator}</span>
  <span class="comment">//  \index{itk::PointSet!iterating points}</span>
  <span class="comment">//</span>
  <span class="comment">//  Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <span class="keyword">typedef</span>  PointSetType::PointsContainer::ConstIterator     PointIterator;
  PointIterator pointIterator = pointSet-&gt;GetPoints()-&gt;Begin();
  PointIterator pointEnd      = pointSet-&gt;GetPoints()-&gt;End();
  <span class="keywordflow">while</span>( pointIterator != pointEnd ) 
    {
     point = pointIterator.Value();
    std::cout &lt;&lt; point &lt;&lt; std::endl;  
    ++pointIterator;                      
    }
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">//  Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">//  Note that here the \code{ConstIterator} was used instead of the</span>
  <span class="comment">//  \code{Iterator} since the pixel values are not expected to be modified.</span>
  <span class="comment">//  ITK supports const-correctness at the API level. </span>
  <span class="comment">//</span>
  <span class="comment">//  Software Guide : EndLatex </span>


  <span class="comment">//  Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">//  All the pixel values on the PointSet are visited using the following code.</span>
  <span class="comment">//</span>
  <span class="comment">//  \index{itk::PointSet!GetPointData()}</span>
  <span class="comment">//  \index{itk::PointSet!data iterator}</span>
  <span class="comment">//  \index{itk::PointSet!iterating point data}</span>
  <span class="comment">//</span>
  <span class="comment">//  Software Guide : EndLatex </span>


  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <span class="keyword">typedef</span>  PointSetType::PointDataContainer::ConstIterator     PointDataIterator;
  PointDataIterator pixelIterator = pointSet-&gt;GetPointData()-&gt;Begin();
  PointDataIterator pixelEnd      = pointSet-&gt;GetPointData()-&gt;End();
  <span class="keywordflow">while</span>( pixelIterator != pixelEnd ) 
    {
    pixel = pixelIterator.Value();
    std::cout &lt;&lt; pixel &lt;&lt; std::endl;  
    ++pixelIterator;                      
    }
  <span class="comment">// Software Guide : EndCodeSnippet</span>

  <span class="comment">//  Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">//  Again, please note the use of the  \code{ConstIterator} instead of the</span>
  <span class="comment">//  \code{Iterator}. </span>
  <span class="comment">//</span>
  <span class="comment">//  \index{ConstIterator}</span>
  <span class="comment">//  \index{const-correctness}</span>
  <span class="comment">//</span>
  <span class="comment">//  Software Guide : EndLatex </span>




  <span class="keywordflow">return</span> 0;

}




</pre></div> </div>
<hr><address><small>
Generated at Thu May 7 22:04:08 2009 for ITK  by <a href="http://www.stack.nl/~dimitri/doxygen/index.html"> <img 
src="http://www.stack.nl/~dimitri/doxygen/doxygen.png" alt="doxygen"
align="middle" border=0 width=110 height=53>
</a> 1.5.9 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2000</small></address>
</body>
</html>