void FreeMemory ( void * ptr, size_t capacity )
	{
		if( !m_memory_init ) InitPool ();
		else if (IsPoolFull())
		{
			_mm_free(ptr);
		}

		// find the best place (insertion sort)

		FreeMemoryHolder* it(m_free_memory);
		FreeMemoryHolder * const it_end(&(m_free_memory[HMM_MAX_FREE_OBJECTS]));
		do
		{
			if (it->m_ptr == nullptr || it->m_capacity > capacity)
			{
				break;
			}
		} while (++it != it_end);

		// move other containers up by 1 index

		FreeMemoryHolder* it2(it_end);
		FreeMemoryHolder* it3(it2 - 2);
		while (--it2 != it)
		{
			it2->Copy(it3);
			it3->Zero();
			--it3;
		}
		
		it->m_ptr = ptr;
		it->m_capacity = capacity;
	}
Exemple #2
0
BlockGraph::BlockGraph(Project *project)
{
    // First look for all input blocks
    QPtrList<BlockNode> inputBlocks;
    for (QPtrListIterator<AbstractModel> it(*project->blocks()); it != 0;
         ++it) {

        BlockModel* block = dynamic_cast<BlockModel*>(*it);
        if (block != 0)  {
            if (!block->hasInputPins() && !block->hasEpisodicPins()) {
                addInputBlock(block);
            }
        }
    }

    // iterate through all pins
    QValueList<PinNode*> pins = nodeByPin_.values();
    for (QValueList<PinNode*>::Iterator it2 = pins.begin(); it2 != pins.end();
         ++it2) {

        QPtrList<PinNode> neighbours = (*it2)->neighbours();
        for (QPtrListIterator<PinNode> it3(neighbours); it3 != 0;
             ++it3) {

            if ((*it2)->parent() != (*it3)->parent()) {
                QPtrList<PinNode> seen;
                addBlockNeighbour(*it2, *it3, seen);
            }
        }
    }
}
Exemple #3
0
QList<int> TArea::getCollisionNodes()
{
    QList<int> problems;
    QMap<int, QMap<int, QMultiMap<int, int>>> kS = koordinatenSystem();
    QMapIterator<int, QMap<int, QMultiMap<int, int>>> it(kS);
    while (it.hasNext()) {
        it.next();
        QMap<int, QMultiMap<int, int>> x_val = it.value();
        QMapIterator<int, QMultiMap<int, int>> it2(x_val);
        while (it2.hasNext()) {
            it2.next();
            QMultiMap<int, int> y_val = it2.value();
            QMapIterator<int, int> it3(y_val);
            QList<int> z_coordinates;
            while (it3.hasNext()) {
                it3.next();
                int z = it3.key();
                int node = it3.value();

                if (!z_coordinates.contains(node)) {
                    z_coordinates.append(node);
                } else {
                    if (!problems.contains(node)) {
                        auto it4 = y_val.find(z);
                        problems.append(it4.value());
                        //qDebug()<<"problem node="<<node;
                    }
                }
            }
        }
    }
    return problems;
}
int CharacterEdits::exec( TextRangeRegExp* regexp )
{
    _regexp = regexp;
    negate->setChecked( regexp->negate() );
    digit->setChecked( regexp->digit() );
    _nonDigit->setChecked( regexp->nonDigit() );
    space->setChecked( regexp->space() );
    _nonSpace->setChecked( regexp->nonSpace() );
    wordChar->setChecked( regexp->wordChar() );
    _nonWordChar->setChecked( regexp->nonWordChar() );

    bool enabled = (RegExpConverter::current()->features() & RegExpConverter::CharacterRangeNonItems);
    _nonWordChar->setEnabled( enabled );
    _nonDigit->setEnabled( enabled );
    _nonSpace->setEnabled( enabled );

    // Characters

    KMultiFormListBoxEntryList list1 = _single->elements();
    for ( TQPtrListIterator<KMultiFormListBoxEntry> it(list1); *it; ++it ) {
        SingleEntry* entry = dynamic_cast<SingleEntry*>( *it );
        if (entry)
            entry->setText( TQString::fromLocal8Bit("") );
    }
    TQStringList list2 = regexp->chars();
    for ( TQStringList::Iterator it2( list2.begin() ); ! (*it2).isNull(); ++it2 ) {
        addCharacter( *it2 );
    }

    // Ranges
    KMultiFormListBoxEntryList list3 = _range->elements();
    for ( TQPtrListIterator<KMultiFormListBoxEntry> it3(list3); *it3; ++it3 ) {
        RangeEntry* entry = dynamic_cast<RangeEntry*>( *it3 );
        if (entry) {
            entry->setFrom( TQString::fromLocal8Bit("") );
            entry->setTo( TQString::fromLocal8Bit("") );
        }
    }

    TQPtrList<StringPair> ranges = regexp->range();
    for ( TQPtrListIterator<StringPair> it4(ranges); *it4; ++it4 ) {
        TQString from = (*it4)->first();
        TQString to = (*it4)->second();
        addRange(from,to);
    }

    int res = KDialogBase::exec();
    _regexp = 0;
    return res;
}
extern void TrickLinker3()
{
	FCDSceneNodeIterator it1(NULL);
	FCDSceneNodeConstIterator it2(NULL);
	FCDSceneNodeIterator it3(it1.GetNode());
	it1.Next();
	it2.GetNode();
	it2.Next();
	++it1;
	++it2;
	*it1;
	*it2;
	it1.IsDone();
	it2.IsDone();
}
TEST_F(test_ring_input_iterator, canEqualityCompareIterators) {
  iterator it1, it2;
  EXPECT_EQ(it1, it2);
  ring buff(5);
  iterator it3(&buff.front(), &buff.front() + buff.capacity());
  iterator it4(&buff.front(), &buff.front() + buff.capacity());
  EXPECT_NE(it1, it3);
  EXPECT_EQ(it3, it4);
  ++it3;
  EXPECT_NE(it3, it4);
  ++it3;
  ++it3;
  ++it3;
  ++it3;
  EXPECT_NE(it3, it4);
}
void test_serialization(const MultiIndexContainer& m)
{
  typedef typename MultiIndexContainer::iterator       iterator;
  typedef typename MultiIndexContainer::const_iterator const_iterator;

  std::ostringstream oss;
  {
    boost::archive::text_oarchive oa(oss);
    oa<<m;

    std::vector<const_iterator> its(m.size());
    const_iterator              it_end=m.end();
    for(const_iterator it=m.begin();it!=it_end;++it){
      its.push_back(it);
      oa<<const_cast<const const_iterator&>(its.back());
    }
    oa<<const_cast<const const_iterator&>(it_end);
  }

  MultiIndexContainer m2;
  std::istringstream iss(oss.str());
  boost::archive::text_iarchive ia(iss);
  ia>>m2;
  BOOST_TEST(all_indices_equal(m,m2));

  iterator it_end=m2.end();
  for(iterator it=m2.begin();it!=it_end;++it){
    iterator it2;
    ia>>it2;
    BOOST_TEST(it==it2);

    /* exercise safe mode with this (unchecked) iterator */
    BOOST_TEST(*it==*it2);
    m2.erase(it,it2);
    m2.erase(it2,it2);
    m2.erase(it2,it);
    iterator it3(++it2);
    iterator it4;
    it4=--it2;
    BOOST_TEST(it==it4);
    BOOST_TEST(it==boost::multi_index::project<0>(m2,it4));
  }
  iterator it2;
  ia>>it2;
  BOOST_TEST(it_end==it2);
  BOOST_TEST(it_end==boost::multi_index::project<0>(m2,it2));
}
Exemple #8
0
void UT::SetResultMapWithSets(QList<QMap<QString,QString > >& fql_result_set,
							  QScriptValueIterator& resultSetIter)
{
	int i = 1;
	while (resultSetIter.hasNext()) {
	    QMap<QString,QString> fql_result_set_map;
		resultSetIter.next();
		UT::getInstance()->LogToFile("# "+(i++));
	    QScriptValueIterator it3(resultSetIter.value());
		while (it3.hasNext()) {
			it3.next();
			UT::getInstance()->LogToFile(it3.name() +": " + it3.value().toString());
			fql_result_set_map.insert(it3.name(),it3.value().toString());
		}
		fql_result_set.append(fql_result_set_map);	
	}


}
void GoRegionBoard::Clear()
{
    if (DEBUG_REGION_BOARD)
        SgDebug() << "Clear\n";
    for (SgBWIterator it; it; ++it)
    {
        SgBlackWhite color(*it);
        for (SgVectorIteratorOf<GoBlock> it1(AllBlocks(color)); it1; ++it1)
            delete *it1;
        for (SgVectorIteratorOf<GoRegion> it2(AllRegions(color)); it2; ++it2)
            delete *it2;
        for (SgVectorIteratorOf<GoChain> it3(AllChains(color)); it3; ++it3)
            delete *it3;
    }
    m_allBlocks[SG_BLACK].Clear();
    m_allBlocks[SG_WHITE].Clear();
    m_allRegions[SG_BLACK].Clear();
    m_allRegions[SG_WHITE].Clear();
    m_allChains[SG_BLACK].Clear();
    m_allChains[SG_WHITE].Clear();
    m_stack.Clear();
    m_code.Invalidate();
    m_invalid = true;
    m_computedHealthy = false;
    m_boardSize = m_board.Size();

    for (SgBWIterator it; it; ++it)
    {
        SgBlackWhite color(*it);
        for (SgPoint p = SgPointUtil::Pt(1, 1);
             p <= SgPointUtil::Pt(SG_MAX_SIZE, SG_MAX_SIZE);
             ++p)
        {
            m_region[color][p] = 0;
        }
    }
    for (SgPoint p = SgPointUtil::Pt(1, 1);
         p <= SgPointUtil::Pt(SG_MAX_SIZE, SG_MAX_SIZE); ++p)
        m_block[p] = 0;
}
Exemple #10
0
static void
test_eq ()
{
    rw_info (0, __FILE__, __LINE__, "operator==");

    std::tuple<> nt1, nt2;
    // special case
    rw_assert (nt1 == nt1, __FILE__, __LINE__,
               "nt1 == nt1, got false, expected true");

#undef TEST
#define TEST(expr)      \
    rw_assert (expr, __FILE__, __LINE__, #expr \
               "; got %b, expected %b", !(expr), expr)

    TEST (nt1 == nt2);

    std::tuple<int> it1 (1), it2 (1), it3 (2);
    TEST (it1 == it1);
    TEST (it1 == it2);
    TEST (!(it1 == it3));

    UserDefined ud1 (1), ud2 (2);
    std::tuple<UserDefined> ut1 (ud1), ut2 (ud1), ut3 (ud2);
    TEST (ut1 == ut1);
    TEST (ut1 == ut2);
    TEST (!(ut1 == ut3));

    std::tuple<bool, char, int, double, void*, UserDefined>
        bt1 (true, 'a', 255, 3.14159, &nt1, ud1),
        bt2 (true, 'a', 255, 3.14159, &nt1, ud1),
        bt3 (true, 'a', 256, 3.14159, &nt1, ud1);
    TEST (bt1 == bt1);
    TEST (bt1 == bt2);
    TEST (!(bt1 == bt3));
}
	TEST(RandomIterator, init) {

		int cnt;
		std::vector<int> values = {1,2,3,4,5,6};

		RandomIterator<int> it1(values, 1); it1.randomize();
		cnt = 0; for(int i : it1) {(void) i; ++cnt;} ASSERT_EQ(1, cnt);

		RandomIterator<int> it2(values, 2); it2.randomize();
		cnt = 0; for(int i: it2) {(void) i; ++cnt;} ASSERT_EQ(2, cnt);

		RandomIterator<int> it3(values, 3); it3.randomize();
		cnt = 0; for(int i: it3) {(void) i; ++cnt;} ASSERT_EQ(3, cnt);

		RandomIterator<int> it4(values, 4); it4.randomize();
		cnt = 0; for(int i: it4) {(void) i; ++cnt;} ASSERT_EQ(4, cnt);

		RandomIterator<int> it5(values, 5); it5.randomize();
		cnt = 0; for(int i: it5) {(void) i; ++cnt;} ASSERT_EQ(5, cnt);

		RandomIterator<int> it6(values, 6); it6.randomize();
		cnt = 0; for(int i: it6) {(void) i; ++cnt;} ASSERT_EQ(6, cnt);

	}
Exemple #12
0
MGraph<ClusterAlg*, unsigned>* ClusterAlg::constructGraph(ClusterAlg* other, unsigned up)
{
  std::list<ClusterAlg*> list_graph_nodes;

  ClusterAlg *p0 = this, *p1 = other;
  // search for roots of subtrees in the cluster tree
  findRoots (p0, p1);

  if (p0 == NULL || p1 == NULL) return NULL;
  if (p0->getDepth() < up || p1->getDepth() < up) return NULL;
  for (unsigned l=0; l<up; ++l) {
    p0 = (ClusterAlg*)p0->getParent();
    p1 = (ClusterAlg*)p1->getParent();
  }

  // fill list_graph_nodes with the appropriate graph nodes
  if (p0 == p1) p1->getNodes (depth, list_graph_nodes);
  else {
    p0->getNodes (depth, list_graph_nodes);
    p1->getNodes (depth, list_graph_nodes);
  }

  // create and fill vertex array for graph (adjacency matrix)
  unsigned row_size = list_graph_nodes.size(), idx = 0;
  ClusterAlg **graph_nodes = new ClusterAlg* [row_size];

  std::list<ClusterAlg*>::iterator node_it = list_graph_nodes.begin ();
  while (node_it != list_graph_nodes.end()) {
    graph_nodes[idx++] = *node_it;
    node_it++;
  }

  // count nnz-elements, fill liA, ljA and lA
  std::list<unsigned> liA, ljA, lA;
  liA.push_back (0);
  unsigned col = 0, col_cnt;
  std::list<ClusterAlg*>::iterator it0(list_graph_nodes.begin ()), it1;
  while (it0 != list_graph_nodes.end()) {
    it1 = list_graph_nodes.begin ();
    col_cnt = 0;
    while (it1 != list_graph_nodes.end()) {
      if (it0 != it1) {
        unsigned nbr_size ((*it0)->hasNeighbour(*it1));
#ifdef VIRTUAL_DEPTH_WEIGHT
        if (nbr_size > 0) {
          ljA.push_back (col_cnt);
          col++;
          // determine weights
          if ((*it0)->isSeparator() && (*it1)->isSeparator()) {
            unsigned diff0 ((*it0)->getDepth()-(*it0)->getVirtualDepth()+1);
            unsigned diff1 ((*it1)->getDepth()-(*it1)->getVirtualDepth()+1);
            if (diff0 < diff1) lA.push_back (diff0);
            else lA.push_back(diff1);
          } else {
            if ((*it0)->isSeparator() && !(*it1)->isSeparator())
              lA.push_back ((*it0)->getDepth()-(*it0)->getVirtualDepth()+1);
            else lA.push_back ((*it1)->getDepth()-(*it1)->getVirtualDepth()+1);
          }
        }
#endif

#ifdef NEIGHBOUR_SIZE_WEIGHT
        if (nbr_size) {
          ljA.push_back (col_cnt);
          col++;
          // determine weights
          if ((*it0)->isSeparator() && (*it1)->isSeparator()) {
            unsigned mnbr_size (nbr_size > (*it1)->hasNeighbour(*it0) ? nbr_size : (*it1)->hasNeighbour(*it0));
            unsigned min_diam ((*it0)->getDiam() < (*it1)->getDiam() ? (*it0)->getDiam() : (*it1)->getDiam());
            lA.push_back (ceil((double)min_diam / mnbr_size));
          } else {
            if ((*it0)->isSeparator() && !(*it1)->isSeparator()) {
              if (ceil((double)(*it0)->getDiam()/nbr_size) == 1)
                lA.push_back (ceil(sqrt((double)(*it0)->getDiam())));
              else lA.push_back (ceil((double)(*it0)->getDiam()/nbr_size));
            } else {
              if (ceil((double)(*it1)->getDiam()/nbr_size) == 1)
                lA.push_back (ceil(sqrt((double)(*it1)->getDiam())));
              else lA.push_back (ceil((double)(*it1)->getDiam()/nbr_size));
            }
          }
        }
#endif

#ifdef UNWEIGHTED
        if (nbr_size > 0) {
          ljA.push_back (col_cnt);
          lA.push_back (1);
          col++;
        }
#endif
      }
      it1++;
      col_cnt++;
    }
    liA.push_back (col);
    it0++;
  }

  // create AdjMat in CRS-format: iA, jA, A
  unsigned *iA = new unsigned[row_size+1];
  unsigned col_ptr_size = ljA.size();
  unsigned *jA = new unsigned[col_ptr_size];
  unsigned  *A = new unsigned[col_ptr_size];

  // fill iA
  std::list<unsigned>::const_iterator it2 = liA.begin ();
  idx = 0;
  while (it2 != liA.end()) {
    iA[idx++] = *it2;
    it2++;
  }
  iA[row_size] = col_ptr_size;

  // fill jA and A
  it2 = ljA.begin ();
  std::list<unsigned>::const_iterator it3 (lA.begin());
  idx = 0;
  while (it2 != ljA.end()) {
    jA[idx] = *it2;
    A[idx] = *it3;
    it2++;
    it3++;
    idx++;
  }

  AdjMat *tmp_adj(new AdjMat (row_size, iA, jA, A));

  MGraph <ClusterAlg*, unsigned> *graph
  (new MGraph<ClusterAlg*, unsigned> (graph_nodes, tmp_adj));

  delete [] graph_nodes;
  return graph;
}
float
rich_cell::
compute_average_intensity( ImageType::Pointer intensity_image, LabelImageType::ConstPointer label_image, int dist_interior, int dist_exterior)
{
  float sum_interior = 0;
  float sum_exterior = 0;
  int count_interior = 0;
  int count_exterior = 0;

  if (dist_exterior < dist_interior) { // the entire segmented area is taken
    for (unsigned int b = 0; b<all_points_.size(); b++) {
      vnl_vector_fixed< float, 3 > const & pt = all_points_[b];
      ImageType::IndexType pos;
      pos[0] = pt[0];
      pos[1] = pt[1];
      pos[2] = pt[2];
      sum_interior += intensity_image->GetPixel(pos);
    }

    return sum_interior/all_points_.size();
  }
   
  RegionType region = bounding_box_;
  if (dist_interior < 0) { //erode the mask 
    // Generate a mask image of the cell region. Erode the region by
    // r_interior
    RegionType::SizeType size = region.GetSize();
    RegionType::IndexType start={{0,0,0}};
    ImageType::Pointer cropped_mask = ImageType::New(); 
    RegionType mask_region;
    mask_region.SetIndex( start );
    mask_region.SetSize( size );
    cropped_mask->SetRegions( mask_region );
    cropped_mask->Allocate();
    cropped_mask->FillBuffer(0);
    LabelConstRegionIteratorType it1( label_image, region);
    RegionIteratorType it2( cropped_mask, mask_region );
    for (it1.GoToBegin(), it2.GoToBegin(); !it1.IsAtEnd(); ++it1, ++it2) {
      if (it1.Get() == label_)
        it2.Set( 255 );
    }
      
    ImageType::Pointer eroded_mask;
    ErodeFilterType::Pointer f_erode = ErodeFilterType::New();
    SubFilterType::Pointer f_sub = SubFilterType::New();
    StructuringElementType  structuringElement;
    structuringElement.SetRadius( -dist_interior );
    structuringElement.CreateStructuringElement();
    f_erode->SetKernel( structuringElement );
    f_erode->SetInput(cropped_mask);
    f_sub->SetInput1( cropped_mask  );
    f_sub->SetInput2( f_erode->GetOutput() );
    try {
      f_sub->Update();
    }
    catch (itk::ExceptionObject & e) {
      std::cerr << "Exception in SubFilter: " << e << std::endl;
      exit(0);
    }
    eroded_mask = f_sub->GetOutput();
      
    // Sum the signal in the eroded region only
    ConstRegionIteratorType it3( eroded_mask, mask_region );
    ConstRegionIteratorType it4( intensity_image, region);
    for (it3.GoToBegin(), it4.GoToBegin(); !it3.IsAtEnd(); ++it1, ++it3, ++it4) {
      if (it3.Get() > 0) {
        sum_interior += it4.Get();
        count_interior ++;
      }
    }
  }
  if (dist_exterior > 0) { //dilate the mask
    // enlarge the bounding box by r on each side.
    RegionType::SizeType image_size = intensity_image->GetLargestPossibleRegion().GetSize();
    RegionType::SizeType size = region.GetSize();
    RegionType::IndexType start = region.GetIndex();
    RegionType::IndexType end;
    end[0] = vnl_math_min(start[0]+size[0]+dist_exterior, image_size[0]);
    end[1] = vnl_math_min(start[1]+size[1]+dist_exterior, image_size[1]);
    end[2] = vnl_math_min(start[2]+size[2]+dist_exterior, image_size[2]);
    start[0] = vnl_math_max(int(start[0]-dist_exterior), 0);
    start[1] = vnl_math_max(int(start[1]-dist_exterior), 0);
    start[2] = vnl_math_max(int(start[2]-dist_exterior), 0);
    
    size[0] = end[0] - start[0];
    size[1] = end[1] - start[1];
    size[2] = end[2] - start[2];
    region.SetSize( size );
    region.SetIndex( start );
    
    // Generate a mask image of the region just found. Dilate the
    // region defined by the segmentation by r. 
    ImageType::Pointer cropped_mask = ImageType::New(); 
    RegionType mask_region;
    start[0] = start[1] = start[2] = 0;
    mask_region.SetIndex( start );
    mask_region.SetSize( size );
    cropped_mask->SetRegions( mask_region );
    cropped_mask->Allocate();
    cropped_mask->FillBuffer(0);
    LabelConstRegionIteratorType it1( label_image, region);
    RegionIteratorType it2( cropped_mask, mask_region );
    for (it1.GoToBegin(), it2.GoToBegin(); !it1.IsAtEnd(); ++it1, ++it2) {
      if (it1.Get() == label_)
        it2.Set( 255 );
    }
    ImageType::Pointer dilated_mask;
    DilateFilterType::Pointer f_dilate = DilateFilterType::New();
    SubFilterType::Pointer f_sub = SubFilterType::New();
    StructuringElementType  structuringElement;
    structuringElement.SetRadius( dist_exterior );
    structuringElement.CreateStructuringElement();
    f_dilate->SetKernel( structuringElement );
    f_dilate->SetInput(cropped_mask);
    f_sub->SetInput1( f_dilate->GetOutput() );
    f_sub->SetInput2( cropped_mask );
    
    try {
      f_sub->Update();
    }
    catch (itk::ExceptionObject & e) {
      std::cerr << "Exception in SubFilter: " << e << std::endl;
      exit(0);
    }
    dilated_mask = f_sub->GetOutput();
    
    // Sum the signal in the dilated region only
    ConstRegionIteratorType it3( dilated_mask, mask_region );
    ConstRegionIteratorType it4( intensity_image, region);
    for (it3.GoToBegin(), it4.GoToBegin(); !it3.IsAtEnd(); ++it1, ++it3, ++it4) {
      if (it3.Get() > 0) {
        sum_exterior += it4.Get();
        count_exterior ++;
      }
    }
  }
  
  // average the interior and exterior signals
  return (sum_interior+sum_exterior)/float(count_interior+count_exterior);
}
int main()
{
	InputImageType::Pointer im = readImage<InputImageType>("C:/Users/arun/Research/Farsight/exe/bin/CF_1_inverted_bg_sub.tif");
	FILE *fp = fopen("C:/Users/arun/Research/Farsight/exe/bin/seeds.txt","r");

	//IteratorType initer(im,im->GetLargestPossibleRegion());
	//initer.GoToBegin();
	//
	//for(;!initer.IsAtEnd(); ++initer)
	//{
	//	initer.Set(transfer_function1(initer.Get()));
	//}
	//
	//writeImage<InputImageType>(im,"C:/Users/arun/Research/Farsight/exe/bin/hp2_cropped2_filtered.tif");
	//
	//return 0;
	typedef itk::SymmetricSecondRankTensor<double,3> HessianType;
	typedef itk::Hessian3DToVesselnessMeasureImageFilter<float> MeasureType;
	typedef itk::Image<HessianType,3> HessianImageType;
	typedef itk::MultiScaleHessianBasedMeasureImageFilter< InputImageType, HessianImageType, FloatImageType> VesselnessFilterType;
	
	std::vector<InputImageType::RegionType> in1,in2,out1,out2;

	get_tiles(im->GetLargestPossibleRegion().GetSize(),1500,1500,1500,100,100,10,in1,in2,out1,out2);
	
	InputImageType::Pointer om;
/*
	om = InputImageType::New();
	om->SetRegions(im->GetLargestPossibleRegion());
	om->Allocate();
	for(int counter = 0; counter < in1.size(); counter++)
	{
		InputImageType::Pointer imtile = InputImageType::New();//
		imtile->SetRegions(in2[counter]);
		imtile->Allocate();

		in1[counter].Print(std::cout);
		in2[counter].Print(std::cout);
		IteratorType iter1(im,in1[counter]);
		IteratorType iter2(imtile,in2[counter]);
		for(iter1.GoToBegin(),iter2.GoToBegin();!iter1.IsAtEnd(); ++iter1,++iter2)
		{
			iter2.Set(iter1.Get());
		}

		VesselnessFilterType::Pointer vfilt = VesselnessFilterType::New();
		MeasureType::Superclass::Pointer measure = MeasureType::New();
		
		vfilt->SetInput(imtile);
		vfilt->SetHessianToMeasureFilter((VesselnessFilterType::HessianToMeasureFilterType *)measure);
		vfilt->SetSigmaMinimum(3.0);
		vfilt->SetSigmaMaximum(5.0);
		vfilt->SetNumberOfSigmaSteps(3);
		vfilt->SetSigmaStepMethod(VesselnessFilterType::EquispacedSigmaSteps);
		vfilt->Update();
		FloatImageType::Pointer omtile = vfilt->GetOutput();
		
		typedef itk::ImageRegionIterator<FloatImageType> FloatIteratorType;
		FloatIteratorType iter3;
		iter1 = IteratorType(om,out1[counter]);
		iter3 = FloatIteratorType(omtile,out2[counter]);
		for(iter1.GoToBegin(),iter3.GoToBegin();!iter1.IsAtEnd();++iter1,++iter3)
		{
			iter1.Set(iter3.Get());
		}
	}
	writeImage<InputImageType>(om,"C:/Users/arun/Research/Farsight/exe/bin/vesselnesstest.tif");
*/
	om = readImage<InputImageType>("C:/Users/arun/Research/Farsight/exe/bin/vesselnesstest.tif");
	typedef itk::BinaryBallStructuringElement<InputImageType::PixelType,3> StructElementType;
	typedef itk::GrayscaleDilateImageFilter<InputImageType,InputImageType,StructElementType> FilterType1;
	FilterType1::Pointer minfilt = FilterType1::New();
	minfilt->SetInput(om);
	FilterType1::RadiusType radius;
	radius[0] = 1;
	radius[1] = 1;
	radius[2] = 1;
	StructElementType strel;
	strel.SetRadius(radius);
	minfilt->SetKernel(strel);
	minfilt->Update();

	InputImageType::Pointer seed_out  = InputImageType::New();
	seed_out->SetRegions(om->GetLargestPossibleRegion());
	seed_out->Allocate();
	seed_out->FillBuffer(0);

	int thresh_value = 6;
	int number_of_seeds = 200;
	int tnum_seeds = 0;

	typedef itk::ImageRegionIteratorWithIndex<InputImageType> IndexIteratorType;

	IndexIteratorType it1(minfilt->GetOutput(),minfilt->GetOutput()->GetLargestPossibleRegion());
	IteratorType it2(om,om->GetLargestPossibleRegion());

	for(it2.GoToBegin();!it2.IsAtEnd(); ++it2)
	{
		if(it2.Get()>thresh_value)
			tnum_seeds++;
	}
	printf("tnum_seeds = %d\n",tnum_seeds);
	IteratorType it3(seed_out,seed_out->GetLargestPossibleRegion());
	IteratorType it4(im,im->GetLargestPossibleRegion());

	std::vector<mdl::fPoint3D> seeds;
	seeds.clear();
	/*for(it1.GoToBegin(),it2.GoToBegin(),it3.GoToBegin(),it4.GoToBegin();!it1.IsAtEnd();++it1,++it2,++it3,++it4)
	{
		if(it1.Get()==it2.Get() && it4.Get() > 150)
		{
			it3.Set(255);
			InputImageType::IndexType index = it1.GetIndex();
			mdl::fPoint3D seed1;
			seed1.x = index[0];
			seed1.y = index[1];
			seed1.z = index[2];
			seeds.push_back(seed1);
		}
	}*/

	seeds.clear();
	
	while(!feof(fp))
	{
		mdl::fPoint3D seed1;
		fscanf(fp,"%f %f %f",&seed1.x,&seed1.y,&seed1.z);
		if(feof(fp))
			break;
		seed1.x*=1;
		seed1.y*=1;
		seeds.push_back(seed1);
	}
	fclose(fp);
	printf("Seeds.size = %d\n",seeds.size());
	//scanf("%*d");
	mdl::vtkFileHandler * fhd1 = new mdl::vtkFileHandler();
	fhd1->SetNodes(&seeds);
	std::vector<mdl::pairE> nullpairs;
	fhd1->SetLines(&nullpairs);
	std::string outFilename1 = "C:/Users/arun/Research/Farsight/exe/bin/mst_input.vtk";
	fhd1->Write(outFilename1.c_str());
	delete fhd1;


	int edgeRange = 50;
	int morphStrength = 0;
	mdl::MST *mst = new mdl::MST( im );
	mst->SetDebug(false);
	mst->SetUseVoxelRounding(false);
	mst->SetEdgeRange(edgeRange);
	mst->SetPower(1);
	mst->SetSkeletonPoints( &seeds );
	// can choose different weight
	//mst->CreateGraphAndMST(1);
	mst->CreateGraphAndMST(5);
	mst->ErodeAndDialateNodeDegree(morphStrength);

	std::vector<mdl::fPoint3D> nodes = mst->GetNodes();
	std::vector<mdl::pairE> bbpairs = mst->BackboneExtract();

	delete mst;

	std::cerr << "Saving\n";

	//****************************************************************
	// TREE WRITER
	mdl::vtkFileHandler * fhd2 = new mdl::vtkFileHandler();
	fhd2->SetNodes(&nodes);
	fhd2->SetLines(&bbpairs);
	std::string outFilename2 = "C:/Users/arun/Research/Farsight/exe/bin/mst_tree.vtk";
	fhd2->Write(outFilename2.c_str());
	delete fhd2;
	scanf("%*d");

	writeImage<InputImageType>(seed_out,"C:/Users/arun/Research/Farsight/exe/bin/seedimage.tif");
		
}
Exemple #15
0
  void DemonsRegistration::GenerateData2(const itk::Image<TPixel, VImageDimension>* itkImage1)
  {
    typedef typename itk::Image< TPixel, VImageDimension >  FixedImageType;
    typedef typename itk::Image< TPixel, VImageDimension >  MovingImageType;

    typedef float InternalPixelType;
    typedef typename itk::Image< InternalPixelType, VImageDimension > InternalImageType;
    typedef typename itk::CastImageFilter< FixedImageType,
                                  InternalImageType > FixedImageCasterType;
    typedef typename itk::CastImageFilter< MovingImageType,
                                  InternalImageType > MovingImageCasterType;
    typedef typename itk::Image< InternalPixelType, VImageDimension > InternalImageType;
    typedef typename itk::Vector< float, VImageDimension >    VectorPixelType;
    typedef typename itk::Image<  VectorPixelType, VImageDimension > DeformationFieldType;
    typedef typename itk::DemonsRegistrationFilter<
                                  InternalImageType,
                                  InternalImageType,
                                  DeformationFieldType>   RegistrationFilterType;
    typedef typename itk::WarpImageFilter<
                            MovingImageType,
                            MovingImageType,
                            DeformationFieldType  >     WarperType;
    typedef typename itk::LinearInterpolateImageFunction<
                                    MovingImageType,
                                    double          >  InterpolatorType;

    typedef  TPixel  OutputPixelType;
    typedef typename itk::Image< OutputPixelType, VImageDimension > OutputImageType;
    typedef typename itk::CastImageFilter<
                          MovingImageType,
                          OutputImageType > CastFilterType;
    typedef typename itk::ImageFileWriter< OutputImageType >  WriterType;
    typedef typename itk::ImageFileWriter< DeformationFieldType >  FieldWriterType;

    typename FixedImageType::Pointer fixedImage = FixedImageType::New();
    mitk::CastToItkImage(m_ReferenceImage, fixedImage);
    typename MovingImageType::ConstPointer movingImage = itkImage1;

    if (fixedImage.IsNotNull() && movingImage.IsNotNull())
    {
      typename RegistrationFilterType::Pointer filter = RegistrationFilterType::New();

      this->AddStepsToDo(4);
      typename itk::ReceptorMemberCommand<DemonsRegistration>::Pointer command = itk::ReceptorMemberCommand<DemonsRegistration>::New();
      command->SetCallbackFunction(this, &DemonsRegistration::SetProgress);
      filter->AddObserver( itk::IterationEvent(), command );

      typename FixedImageCasterType::Pointer fixedImageCaster = FixedImageCasterType::New();
      fixedImageCaster->SetInput(fixedImage);
      filter->SetFixedImage( fixedImageCaster->GetOutput() );
      typename MovingImageCasterType::Pointer movingImageCaster = MovingImageCasterType::New();
      movingImageCaster->SetInput(movingImage);
      filter->SetMovingImage(movingImageCaster->GetOutput());
      filter->SetNumberOfIterations( m_Iterations );
      filter->SetStandardDeviations( m_StandardDeviation );
      filter->Update();

      typename WarperType::Pointer warper = WarperType::New();
      typename InterpolatorType::Pointer interpolator = InterpolatorType::New();

      warper->SetInput( movingImage );
      warper->SetInterpolator( interpolator );
      warper->SetOutputSpacing( fixedImage->GetSpacing() );
      warper->SetOutputOrigin( fixedImage->GetOrigin() );
      warper->SetOutputDirection( fixedImage->GetDirection());
      warper->SetDisplacementField( filter->GetOutput() );
      warper->Update();
      Image::Pointer outputImage = this->GetOutput();
      mitk::CastToMitkImage( warper->GetOutput(), outputImage );


      typename WriterType::Pointer      writer =  WriterType::New();
      typename CastFilterType::Pointer  caster =  CastFilterType::New();

      writer->SetFileName( m_ResultName );

      caster->SetInput( warper->GetOutput() );
      writer->SetInput( caster->GetOutput()   );
      if(m_SaveResult)
      {
        writer->Update();
      }

      if (VImageDimension == 2)
      {
        typedef DeformationFieldType  VectorImage2DType;
        typedef typename DeformationFieldType::PixelType Vector2DType;

        typename VectorImage2DType::ConstPointer vectorImage2D = filter->GetOutput();

        typename VectorImage2DType::RegionType  region2D = vectorImage2D->GetBufferedRegion();
        typename VectorImage2DType::IndexType   index2D  = region2D.GetIndex();
        typename VectorImage2DType::SizeType    size2D   = region2D.GetSize();


        typedef typename itk::Vector< float,       3 >  Vector3DType;
        typedef typename itk::Image< Vector3DType, 3 >  VectorImage3DType;

        typedef typename itk::ImageFileWriter< VectorImage3DType > WriterType;

        typename WriterType::Pointer writer3D = WriterType::New();

        typename VectorImage3DType::Pointer vectorImage3D = VectorImage3DType::New();

        typename VectorImage3DType::RegionType  region3D;
        typename VectorImage3DType::IndexType   index3D;
        typename VectorImage3DType::SizeType    size3D;

        index3D[0] = index2D[0];
        index3D[1] = index2D[1];
        index3D[2] = 0;

        size3D[0]  = size2D[0];
        size3D[1]  = size2D[1];
        size3D[2]  = 1;

        region3D.SetSize( size3D );
        region3D.SetIndex( index3D );

        typename VectorImage2DType::SpacingType spacing2D   = vectorImage2D->GetSpacing();
        typename VectorImage3DType::SpacingType spacing3D;

        spacing3D[0] = spacing2D[0];
        spacing3D[1] = spacing2D[1];
        spacing3D[2] = 1.0;

        vectorImage3D->SetSpacing( spacing3D );

        vectorImage3D->SetRegions( region3D );
        vectorImage3D->Allocate();

        typedef typename itk::ImageRegionConstIterator< VectorImage2DType > Iterator2DType;

        typedef typename itk::ImageRegionIterator< VectorImage3DType > Iterator3DType;

        Iterator2DType  it2( vectorImage2D, region2D );
        Iterator3DType  it3( vectorImage3D, region3D );

        it2.GoToBegin();
        it3.GoToBegin();

        Vector2DType vector2D;
        Vector3DType vector3D;

        vector3D[2] = 0; // set Z component to zero.

        while( !it2.IsAtEnd() )
        {
          vector2D = it2.Get();
          vector3D[0] = vector2D[0];
          vector3D[1] = vector2D[1];
          it3.Set( vector3D );
          ++it2;
          ++it3;
        }

        writer3D->SetInput( vectorImage3D );
        m_DeformationField = vectorImage3D;

        writer3D->SetFileName( m_FieldName );

        try
        {
          if(m_SaveField)
          {
            writer3D->Update();
          }
        }
        catch( itk::ExceptionObject & excp )
        {
          MITK_ERROR << excp << std::endl;
        }
      }
      else
      {
        typename FieldWriterType::Pointer      fieldwriter =  FieldWriterType::New();
        fieldwriter->SetFileName(m_FieldName);
        fieldwriter->SetInput( filter->GetOutput() );
        m_DeformationField = (itk::Image<itk::Vector<float, 3>,3> *)(filter->GetOutput());
        if(m_SaveField)
        {
          fieldwriter->Update();
        }
      }
      this->SetRemainingProgress(4);
    }
  }
Exemple #16
0
void CGapList::FillGap(uint64 partstart, uint64 partend)
{
	if (!ArgCheck(partstart, partend)) {
		return;
	}

//	AddDebugLogLineN(logPartFile, CFormat(wxT("  FillGap: %5d - %5d")) % partstart % partend);

	// mark involved part(s) to be reexamined for completeness
	uint16 partlast = partend / PARTSIZE;
	for (uint16 part = partstart / PARTSIZE; part <= partlast; part++) {
		m_partsComplete[part] = unknown;
	}
	// also total gap size
	m_totalGapSizeValid = false;

	// find a place to start:
	// first gap which ends >= our part start
	iterator it = m_gaplist.lower_bound(partstart);
	while (it != m_gaplist.end()) {
		iterator it2 = it++;
		uint64 curGapStart = it2->second;
		uint64 curGapEnd   = it2->first;

		if (curGapStart >= partstart) {
			if (curGapEnd <= partend) {
				// our part fills this gap completly
				m_gaplist.erase(it2);
			} else if (curGapStart <= partend) {
				// lower part of this gap is in the part - shrink gap:
				//   (this is the most common case: curGapStart == partstart && curGapEnd > partend)
				it2->second = partend + 1;
				// end of our part was in the gap: we're done
				break;
			} else {
				// gap starts behind our part end: we're done
				break;
			}
		} else {
			// curGapStart < partstart
			if (curGapEnd > partend) {
				// our part is completely enclosed by the gap
				// cut it in two, leaving our part out:
				// shrink the gap so it becomes the second gap
				it2->second = partend + 1;
				// insert new first gap
				iterator it3(it2);
				if (it3 != m_gaplist.begin()) {
					--it3;
				}
				m_gaplist.insert(it3, std::pair<uint64,uint64>(partstart - 1, curGapStart));
				// we're done
				break;
			} else if (curGapEnd >= partstart) {
				// upper part of this gap is in the part - shrink gap:
				// insert shorter gap
				iterator it3(it2);
				if (it3 != m_gaplist.begin()) {
					--it3;
				}
				m_gaplist.insert(it3, std::pair<uint64,uint64>(partstart - 1, curGapStart));
				// and delete the old one
				m_gaplist.erase(it2);
			}
			// else: gap is before our part start (should not happen)
		}
	}
}
Exemple #17
0
static AActor *SelectTeleDest (int tid, int tag, bool norandom)
{
	AActor *searcher;

	// If tid is non-zero, select a destination from a matching actor at random.
	// If tag is also non-zero, the selection is restricted to actors in sectors
	// with a matching tag. If tid is zero and tag is non-zero, then the old Doom
	// behavior is used instead (return the first teleport dest found in a tagged
	// sector).

	// Compatibility hack for some maps that fell victim to a bug in the teleport code in 2.0.9x
	if (ib_compatflags & BCOMPATF_BADTELEPORTERS) tag = 0;

	if (tid != 0)
	{
		NActorIterator iterator (NAME_TeleportDest, tid);
		int count = 0;
		while ( (searcher = iterator.Next ()) )
		{
			if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag))
			{
				count++;
			}
		}

		// If teleport dests were not found, the sector tag is ignored for the
		// following compatibility searches.
		// Do this only when tag is 0 because this is the only case that was defined in Hexen.
		if (count == 0)
		{
			if (tag == 0)
			{
				// Try to find a matching map spot (fixes Hexen MAP10)
				NActorIterator it2 (NAME_MapSpot, tid);
				searcher = it2.Next ();
				if (searcher == NULL)
				{
					// Try to find a matching non-blocking spot of any type (fixes Caldera MAP13)
					FActorIterator it3 (tid);
					searcher = it3.Next ();
					while (searcher != NULL && (searcher->flags & MF_SOLID))
					{
						searcher = it3.Next ();
					}
					return searcher;
				}
			}
		}
		else
		{
			if (count != 1 && !norandom)
			{
				count = 1 + (pr_teleport() % count);
			}
			searcher = NULL;
			while (count > 0)
			{
				searcher = iterator.Next ();
				if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag))
				{
					count--;
				}
			}
		}
		return searcher;
	}

	if (tag != 0)
	{
		int secnum;

		FSectorTagIterator itr(tag);
		while ((secnum = itr.Next()) >= 0)
		{
			// Scanning the snext links of things in the sector will not work, because
			// TeleportDests have MF_NOSECTOR set. So you have to search *everything*.
			// If there is more than one sector with a matching tag, then the destination
			// in the lowest-numbered sector is returned, rather than the earliest placed
			// teleport destination. This means if 50 sectors have a matching tag and
			// only the last one has a destination, *every* actor is scanned at least 49
			// times. Yuck.
			TThinkerIterator<AActor> it2(NAME_TeleportDest);
			while ((searcher = it2.Next()) != NULL)
			{
				if (searcher->Sector == &level.sectors[secnum])
				{
					return searcher;
				}
			}
		}
	}

	return NULL;
}
Exemple #18
0
void ArticleView::append_data_parse_result(const gchar *real_oword, 
	ParseResult& parse_result)
{
	/* Why ParseResultItem's cannot be inserted into the pango_view_ in the 
	 * order they appear in the parse_result list? 
	 * 
	 * They can, but that limits use of the pango markup language when markup 
	 * intermixed with objects that are not expressed in pango markup. 
	 * For instance we cannot handle the following piece of data:
	 * markup: "<span foreground=\"purple\">some text"
	 * res: some image
	 * markup: "text continues</span>" 
	 * The first markup string cannot be committed because it is not a valid 
	 * markup - span tag is not closed. But if we piece two markup strings 
	 * together, commit markup and then insert the resource, everything will be
	 * fine.
	 * 
	 * Here is an outline of the rules parse_result list must adhere to.
	 * 
	 * - each list item with pango markup must contain only complete tags. Tag 
	 * may not be opened in one list item and closed in another. For example
	 * this list is not allowed:
	 * markup: "<span foreground=\"purple\" "
	 * markup: "size=\"x-large\">"
	 * 
	 * - after combining all list items with pango markup the resultant string
	 * must constitute a valid markup (correct order of tags, each tag must have
	 * a corresponding closing tag and so on). For example, the following text 
	 * is not allowed: "<b> bla bla </b><i>text end".
	 * Note: list item may contain incomplete markup like "<b>text begins".
	 * 
	 * - Delayed insert items must generate only valid markup. Items 
	 * representing images, widgets generate a pango-formated error message
	 * if the primary object cannot be inserted.
	 * 
	 * 
	 * Position in the pango markup string cannot be exactly specified by 
	 * character offset only. That is especially important for LabelPangoWidget
	 * where markup is stored in a string. In order to insert delayed insert 
	 * items in the correct place it was decided to add a temporary character
	 * in the string in the place where the delayed item must be inserted.
	 * Temporary characters are deleted at the end.
	 * 
	 * In addition to character offsets marks are used to specify position in 
	 * the text. Marks must be used instead of char offsets when possible.
	 * Marks are preferred over offsets because they preserve position across
	 * text modifications, they have a notion of right and left gravity.
	 * In general we do not know how many character would be inserted in the 
	 * text after the call the method insert_pixbuf. Normally it is only one,
	 * but it may be any number in case of error.
	 * 
	 * */
	Marks marks(pango_view_.get());
	std::string start_mark = marks.append_mark(true);
	std::list<ParseResultItemWithMark> delayed_insert_list;
	// compose markup
	{
		std::string markup_str;
		int char_offset = 0;
		const char tmp_char = 'x'; // may be any unicode char excluding '<', '&', '>'

		for (std::list<ParseResultItem>::iterator it = parse_result.item_list.begin(); 
			it != parse_result.item_list.end(); ++it) {
			switch (it->type) {
				case ParseResultItemType_mark:
					char_offset += xml_utf8_strlen(it->mark->pango.c_str());
					markup_str += it->mark->pango;
					break;
				case ParseResultItemType_link:
				{
					/* links do not insert any text, so exact mark position is
					 * not important. */
					ParseResultItemWithMark item(&*it, char_offset);
					delayed_insert_list.push_back(item);
					char_offset += xml_utf8_strlen(it->link->pango.c_str());
					markup_str += it->link->pango;
					break;
				}
				case ParseResultItemType_res:
				case ParseResultItemType_widget:
				{
					ParseResultItemWithMark item1(NULL, char_offset, true);
					delayed_insert_list.push_back(item1);
					char_offset += 1;
					markup_str += tmp_char;
					ParseResultItemWithMark item2(&*it, char_offset, true);
					delayed_insert_list.push_back(item2);
					char_offset += 1;
					markup_str += tmp_char;
					break;
				}
				case ParseResultItemType_FormatBeg:
				case ParseResultItemType_FormatEnd:
				{
					/* formats do not insert any text, so exact mark position is
					 * not important. */
					ParseResultItemWithMark item2(&*it, char_offset);
					delayed_insert_list.push_back(item2);
					break;
				}
				default:
					g_warning("Unsupported item type.");
					break;
			}
		}
		append_and_mark_orig_word(markup_str, real_oword, LinksPosList());
		markup_str.clear();
		pango_view_->flush();
	}
	// Marks that precede tmp chars. One mark - one char next to it that must be 
	// deleted. Different marks do not refer to the same char.
	std::list<std::string> tmp_char_mark_list;
	// insert marks
	for(std::list<ParseResultItemWithMark>::iterator it = delayed_insert_list.begin(); 
		it != delayed_insert_list.end(); ) {
		it->mark = marks.insert_mark(start_mark, it->char_offset, false);
		if(it->tmp_char)
			tmp_char_mark_list.push_back(it->mark);
		if(it->item)
			++it;
		else
			it = delayed_insert_list.erase(it);
	}
#ifdef DDEBUG
	std::cout << "ArticleView::append_data_parse_result. marks inserted." 
		<< std::endl; 
#endif
	// insert delayed items
	for(std::list<ParseResultItemWithMark>::iterator it = delayed_insert_list.begin(); 
		it != delayed_insert_list.end(); ) {
		bool EraseCurrent = true;
		switch(it->item->type) {
		case ParseResultItemType_link:
			pango_view_->insert_pango_text_with_links("", it->item->link->links_list, 
				it->mark.c_str());
			break;
		case ParseResultItemType_res:
		{
			bool loaded = false;
			if (it->item->res->type == "image") {
				append_data_res_image(it->item->res->key, it->mark, loaded);
			} else if (it->item->res->type == "sound") {
				append_data_res_sound(it->item->res->key, it->mark, loaded);
			} else if (it->item->res->type == "video") {
				append_data_res_video(it->item->res->key, it->mark, loaded);
			} else {
				append_data_res_attachment(it->item->res->key, it->mark, loaded);
			}
			if (!loaded) {
				std::string tmark;
				tmark += "<span foreground=\"red\">";
				glib::CharStr m_str(g_markup_escape_text(it->item->res->key.c_str(), -1));
				tmark += get_impl(m_str);
				tmark += "</span>";
				pango_view_->insert_pango_text(tmark.c_str(), it->mark.c_str());
			}
			break;
		}
		case ParseResultItemType_widget:
			pango_view_->insert_widget(it->item->widget->widget, it->mark.c_str());
			break;
		case ParseResultItemType_FormatBeg:
			// change gravity of the mark
			it->mark = marks.clone_mark(it->mark, true);
			EraseCurrent = false;
			break;
		case ParseResultItemType_FormatEnd:
		{
			// find paired ParseResultItemType_FormatBeg item
			std::list<ParseResultItemWithMark>::reverse_iterator it2(it);
			for(; it2 != delayed_insert_list.rend(); ++it2)
				if(it2->item->type == ParseResultItemType_FormatBeg)
					break;
			if(it2 != delayed_insert_list.rend() && it2->item->format_beg->type 
				== it->item->format_end->type) {
				if(it->item->format_end->type == ParseResultItemFormatType_Indent)
					pango_view_->indent_region(it2->mark.c_str(), 0, it->mark.c_str());
				std::list<ParseResultItemWithMark>::iterator it3(it2.base());
				delayed_insert_list.erase(--it3);
			} else
				g_warning("Not paired ParseResultItemType_FormatEnd item");
			break;
		}
		default:
			g_assert_not_reached();
			break;
		}
		if(EraseCurrent)
			it = delayed_insert_list.erase(it);
		else
			++it;
	}
	// remove tmp chars
	for(std::list<std::string>::iterator it = tmp_char_mark_list.begin(); 
		it != tmp_char_mark_list.end(); ++it) {
#ifdef DDEBUG
		std::cout << "tmp char mark " << *it << std::endl;
#endif
		pango_view_->delete_text(it->c_str(), 1, 0);
	}
	pango_view_->reindent();
	if(!delayed_insert_list.empty())
		g_warning("delayed_insert_list is not empty. "
			"parse_result contains not paired items.");
}
Exemple #19
0
/* Get antenna phase center variation.
 *
 * This method returns a Triple, in UEN system, with the
 * elevation and azimuth-dependent phase center variation.
 *
 * @param[in] freq      Frequency
 * @param[in] elevation Elevation (degrees)
 * @param[in] azimuth   Azimuth (degrees)
 *
 * @warning The phase center variation Triple is in UEN system.
 */
Triple Antenna::getAntennaPCVariation( frequencyType freq,
                                       double elevation,
                                       double azimuth ) const
throw(InvalidRequest)
{

    // The angle should be measured respect to zenith
    double angle( 90.0 - elevation );

    // Check that angle is within limits
    if( ( angle < zen1 ) ||
            ( angle > zen2 ) )
    {
        InvalidRequest e("Elevation is out of allowed range.");
        GPSTK_THROW(e);
    }

    // Reduce azimuth to 0 <= azimuth < 360 interval
    while( azimuth < 0.0 )
    {
        azimuth += 360.0;
    }
    while( azimuth >= 360.0 )
    {
        azimuth -= 360.0;
    }

    // Look for this frequency in pcMap
    // Define iterator
    PCDataMap::const_iterator it( pcMap.find(freq) );
    if( it != pcMap.end() )
    {

        // Get the right azimuth interval
        const double lowerAzimuth( std::floor(azimuth/dazi) * dazi );
        const double upperAzimuth( lowerAzimuth + dazi );

        // Look for data vectors
        AzimuthDataMap::const_iterator it2( (*it).second.find(lowerAzimuth) );
        AzimuthDataMap::const_iterator it3( (*it).second.find(upperAzimuth) );

        // Find the fraction from 'lowerAzimuth'
        const double fractionalAzimuth( ( azimuth - lowerAzimuth ) /
                                        ( upperAzimuth - lowerAzimuth ) );

        // Check if 'azimuth' exactly corresponds to a value in the map
        if( fractionalAzimuth == 0.0 )
        {
            // Check if there is data for 'lowerAzimuth'
            if( it2 != (*it).second.end() )
            {
                // Get the normalized angle
                const double normalizedAngle( (angle-zen1)/dzen );

                // Return result. Only the "Up" component is important.
                Triple result( linearInterpol( (*it2).second, normalizedAngle ),
                               0.0,
                               0.0 );

                return result;

            }
            else
            {
                InvalidRequest e("No data was found for this azimuth.");
                GPSTK_THROW(e);
            }
        }
        else
        {
            // We have to interpolate
            // Check if there is data for 'lowerAzimuth' and 'upperAzimuth'
            if( it2 != (*it).second.end() &&
                    it3 != (*it).second.end() )
            {
                // Get the normalized angle
                const double normalizedAngle( (angle-zen1)/dzen );

                // Find values corresponding to both azimuths
                double val1( linearInterpol( (*it2).second, normalizedAngle ) );
                double val2( linearInterpol( (*it3).second, normalizedAngle ) );

                // Return result. Only the "Up" component is important.
                Triple result( ( val1 + (val2-val1) * fractionalAzimuth ),
                               0.0,
                               0.0 );

                return result;

            }
            else
            {
                InvalidRequest e("Not enough data was found for this azimuth.");
                GPSTK_THROW(e);
            }
        }

    }
    else
    {

        InvalidRequest e("No data was found for this frequency.");
        GPSTK_THROW(e);

    }  // End of 'if( it != pcMap.end() )...'

}  // End of method 'Antenna::getAntennaPCVariation()'
Exemple #20
0
// [AM] From ZDoom SVN, modified for use with Odamex and without the
//      buggy 2.0.x teleport behavior compatibility fix.  Thanks to both
//      Randy and Graf.
static AActor* SelectTeleDest(int tid, int tag)
{
	AActor* searcher;

	// If tid is non-zero, select a destination from a matching actor at random.
	// If tag is also non-zero, the selection is restricted to actors in sectors
	// with a matching tag. If tid is zero and tag is non-zero, then the old Doom
	// behavior is used instead (return the first teleport dest found in a tagged
	// sector).

	if (tid != 0)
	{
		TThinkerIterator<AActor> iterator;
		int count = 0;
		while ((searcher = iterator.Next()))
		{
			if (!(searcher->type == MT_TELEPORTMAN || searcher->type == MT_TELEPORTMAN2))
				continue;
			if (searcher->tid != tid)
				continue;

			if (tag == 0 || searcher->subsector->sector->tag == tag)
				count++;
		}

		// If teleport dests were not found, the sector tag is ignored for the
		// following compatibility searches.
		// Do this only when tag is 0 because this is the only case that was defined in Hexen.
		if (count == 0)
		{
			if (tag == 0)
			{
				// Try to find a matching map spot (fixes Hexen MAP10)
				TThinkerIterator<AActor> it2;
				searcher = it2.Next();
				while ((searcher = it2.Next()) != NULL)
				{
					if (searcher->type == MT_MAPSPOT || searcher->type == MT_MAPSPOTGRAVITY)
						break;
				}

				if (searcher == NULL)
				{
					// Try to find a matching non-blocking spot of any type (fixes Caldera MAP13)
					FActorIterator it3(tid);
					searcher = it3.Next();
					while (searcher != NULL && (searcher->flags & MF_SOLID))
						searcher = it3.Next();
					return searcher;
				}
			}
		}
		else
		{
			if (count != 1)
				count = 1 + (P_Random() % count);

			searcher = NULL;
			while (count > 0)
			{
				searcher = iterator.Next();
				if (!(searcher->type == MT_TELEPORTMAN || searcher->type == MT_TELEPORTMAN2))
					continue;
				if (searcher->tid != tid)
					continue;
				if (tag == 0 || searcher->subsector->sector->tag == tag)
					count--;
			}
		}
		return searcher;
	}

	if (tag != 0)
	{
		int secnum = -1;

		while ((secnum = P_FindSectorFromTag(tag, secnum)) >= 0)
		{
			// Scanning the snext links of things in the sector will not work, because
			// TeleportDests have MF_NOSECTOR set. So you have to search *everything*.
			// If there is more than one sector with a matching tag, then the destination
			// in the lowest-numbered sector is returned, rather than the earliest placed
			// teleport destination. This means if 50 sectors have a matching tag and
			// only the last one has a destination, *every* actor is scanned at least 49
			// times. Yuck.
			TThinkerIterator<AActor> it2;
			while ((searcher = it2.Next()) != NULL)
			{
				if (!(searcher->type == MT_TELEPORTMAN || searcher->type == MT_TELEPORTMAN2))
					continue;

				if (searcher->subsector->sector == sectors + secnum)
					return searcher;
			}
		}
	}

	return NULL;
}
/**
 *
 * @param object
 * @param parent
 * @return
 */
ClassDialog::ClassDialog( Object *object, QWidget *parent) :
	KDialog(parent)
{
	m_object = object;
	setModal( false );

	showButtonOK( true );
	showButtonCancel( true );
	showButtonApply( false );

	m_tab = new KTabWidget( this );
	setMainWidget( m_tab );
	QWidget *widget = new QWidget( this );
	
	m_tab->addTab( widget, object->classInfo()->name() );
	
	
	//connect( this, SIGNAL(okClicked()), SLOT(slotOkClicked()) );

	QVBoxLayout *layout = new QVBoxLayout( widget );

	LabelsMetaInfo *labels = dynamic_cast<LabelsMetaInfo*>( object->classInfo()->metaInfo( "labels" ) );

	QLabel *label;
	label = new QLabel( widget );
	label->setAlignment( Qt::AlignCenter );
	if ( labels )
		label->setText( "<b>"  + labels->label( object->classInfo()->name() ) + "</b>" );
	else
		label->setText( "<b>" + object->classInfo()->name() + "</b>" );

	if ( labels )
		setCaption( labels->label( object->classInfo()->name() )  + " (" + oidToString(object->oid()) + ")" );
	else
		setCaption( object->classInfo()->name() + " (" + oidToString(object->oid()) + ")" );

	layout->addWidget( label );
	layout->addSpacing( 10 );

	QGridLayout *gridLayout = new QGridLayout( layout, object->numProperties() + object->numObjects() + object->numCollections(), 2, 5 );

	int row = 0;
	PropertiesIterator it( object->propertiesBegin() );
	PropertiesIterator end( object->propertiesEnd() );
	for ( ; it != end; ++it, ++row ) {
		Property p = *it;
		label = new QLabel( widget );
		if ( labels )
			label->setText( labels->label( p.name() ) );
		else
			label->setText( p.name() );
		gridLayout->addWidget( label, row, 0 );
		PropertyWidget *tmp = new PropertyWidget( p, widget );
		m_mapProperties.insert( p.name(), tmp );
		gridLayout->addWidget( tmp, row, 1 );
	}

	const ClassInfo *classInfo = object->classInfo();
	RelationInfosConstIterator it2( classInfo->relationsBegin() );
	RelationInfosConstIterator end2( classInfo->relationsEnd() );
	for ( ; it2 != end2; ++it2, ++row ) {
		RelationInfo *relObj = it2.data();
		label = new QLabel( widget );
		if ( labels )
			label->setText( labels->label( it2.data()->name() ) );
		else
			label->setText( it2.data()->name() );
		gridLayout->addWidget( label, row, 0 );

		QHBoxLayout *lay = new QHBoxLayout();
		gridLayout->addLayout( lay, row, 1 );
		KurlLabel *objLabel = new KurlLabel(widget);
		objLabel->setAlignment( Qt::AlignCenter );
		Object* obj = object->object( relObj->name() );
		updateObjectLabel( objLabel, obj );
		connect( objLabel, SIGNAL(leftClickedURL(const QString&)), SLOT(slotObjectSelected(const QString&)) );
		m_mapObjects.insert( relObj->name(), objLabel );
		QPushButton *but = new QPushButton( widget );
		but->setText( i18n( "Change" ) );
		connect( but, SIGNAL(clicked()), SLOT(slotChangeClicked()) );
		m_mapChangeButtons.insert( but, relObj );
		lay->addWidget( objLabel );
		lay->addWidget( but );

		Notifier *notifier = dynamic_cast<Notifier*>( Manager::self()->notificationHandler() );
//		if ( notifier && obj )
//			notifier->registerSlot( this, SLOT( slotObjectModified(const ClassInfo*,const OidType&,const PropertyInfo*,const QVariant&) ), 0, obj->oid() );
	}
	
	CollectionInfosConstIterator it3( classInfo->collectionsBegin() );
	CollectionInfosConstIterator end3( classInfo->collectionsEnd() );
	for ( ; it3 != end3; ++it3 ) {
		const CollectionInfo *info = it3.data();
		CollectionChooser *chooser = new CollectionChooser( m_tab );
		chooser->setObject( m_object );
		chooser->setCollectionName( info->name() );
		m_tab->addTab( chooser, info->name() );
	}
}
Exemple #22
0
// ---------- Generating Help messages ----------
QString Parser::compileHelp(QString progName, int helpIndent, bool useFlags)
{
	QStringList help;
	help << compileUsage(progName, useFlags) << "\r\n";

	// positionals
	if (!d_ptr->m_positionals.isEmpty())
	{
		help << "\r\n";
		help << "Positional arguments:\r\n";
		QListIterator<ParameterDefinition *> it2(d_ptr->m_positionals);
		while (it2.hasNext())
		{
			ParameterDefinition *param = it2.next();
			help << "  " << param->meta;
			help << " " << QString(helpIndent - param->meta.length() - 1, ' ');
			help << param->desc << "\r\n";
		}
	}

	// Options
	if (!d_ptr->m_options.isEmpty())
	{
		help << "\r\n";
		QString optPrefix, flagPrefix;
		d_ptr->getPrefix(optPrefix, flagPrefix);

		help << "Options & Switches:\r\n";
		QListIterator<ParameterDefinition *> it(d_ptr->m_options);
		while (it.hasNext())
		{
			ParameterDefinition *param = it.next();

			help << "  ";

			int nameLength = optPrefix.length() + param->name.length();

			for (QListIterator<QChar> it3(param->flags); it3.hasNext();)
			{
				nameLength += 3 + flagPrefix.length();
				help << flagPrefix << it3.next() << ", ";
			}
			for (QListIterator<QString> it3(param->aliases); it3.hasNext();)
			{
				QString alias = it3.next();
				nameLength += 2 + optPrefix.length() + alias.length();
				help << optPrefix << alias;
			}

			help << optPrefix << param->name;

			if (param->type == DefinitionType::Option)
			{
				QString arg = QString("%1%2").arg(
					((d_ptr->m_argStyle == ArgumentStyle::Equals) ? "=" : " "), param->meta);
				nameLength += arg.length();
				help << arg;
			}

			help << " " << QString(helpIndent - nameLength - 1, ' ');
			help << param->desc << "\r\n";
		}
	}

	return help.join("");
}
void LinguisticaMainWindow::updateTreeViewSlot()
{
  // Adapted from MFC version: CMyTree::UpdateUpperTree, CMyTree::UpdateStatistics

  int     count,    // used for various counts
          index;    // mini-lexicon index
  index = 0;
  count = 0;

//  bool      add = TRUE;

  CStem* pWord;

  Q3ListViewItem  * MiscItem      = NULL,
		  * MiscItem1       = NULL,
          * LexiconItem     = NULL,
          * WordsReadItem   = NULL,
          * PrefixesItem    = NULL,
          * SuffixesItem    = NULL,
          * WordsItem       = NULL,
 		  * CompoundsItem   = NULL,
          * ComponentItem   = NULL,
		  *	STRINGEDITITEM  = NULL,
		  * CorpusWordsItem = NULL;
		  
 
  // Clear the tree
  m_treeView->clear();
  m_treeView->setFont( GetFontPreference( "Main" ) );
  m_treeView->hideColumn(1);

//**************************************************************************************
// A NOTE ON THE ORGANIZATION OF THIS FUNCTION:
// The items are inserted into the tree in reverse order respective to their group.  They
// are organized by depth here, i.e. what is connected to the root is the first group,
// then do the groups of items connected to this first group, etc.  The only items that
// get their own name are those that have children.  The rest use MiscItem
//**************************************************************************************


//======================================================================================//
  // START CONNECTED DIRECTLY TO m_treeView
//======================================================================================//


	count = GetNumberOfTokens();
	if( count >= 0 )
	{
		MiscItem = new CTreeViewItem( m_treeView,
									  "Tokens requested: " + IntToStringWithCommas( count ),
									  TOKENS_REQUESTED );
		MiscItem->setSelectable(false);
	}  

//======================================================================================//

	if( m_lexicon->GetWords() && m_lexicon->GetMiniCount() )
	{
		count = m_lexicon->GetTokenCount();
		if ( count >= 0 )
		{
			WordsReadItem = new CTreeViewItem( m_treeView,
											   "Tokens read: " + IntToStringWithCommas( count ) );
			WordsReadItem->setSelectable(false);
			WordsReadItem->setOpen(true);
		}

//======================================================================================//

		LexiconItem = new CTreeViewItem( m_treeView,
						 "Lexicon : click items to display them" );
		LexiconItem->setSelectable(false);
		LexiconItem->setOpen(true);
	}

//======================================================================================//

  if ( m_projectDirectory.length()  )
  {
    MiscItem = new CTreeViewItem( m_treeView, "Project directory: " + m_projectDirectory );
    MiscItem->setSelectable(false);
  }
  else
  {
    MiscItem = new CTreeViewItem( m_treeView, "No project directory." );
    MiscItem->setSelectable(false);
  }

//======================================================================================//

  if ( m_logging )
  {
    MiscItem = new CTreeViewItem( m_treeView, "Log file (now on) " + GetLogFileName() );
    MiscItem->setSelectable(false);
  }
  else
  {
    MiscItem = new CTreeViewItem( m_treeView, "Log file (now off) " + GetLogFileName() );
    MiscItem->setSelectable(false);
  }

//=================================================================================================
  // END CONNECTED DIRECTLY TO m_treeView
  // START CONNECTED TO LexiconItem
//=================================================================================================

	if ( LexiconItem && m_lexicon->GetHMM() )
	{		
		MiscItem = new CTreeViewItem( LexiconItem,
									   "HMM",
									   HMM_Document);
		double dl = m_lexicon->GetHMM()->GetLogProbability();
		MiscItem1 = new CTreeViewItem(MiscItem,"HMM description length: " + IntToStringWithCommas(int( dl) )
									   );		
		MiscItem1 = new CTreeViewItem(MiscItem,
									  "Iterations: " + IntToStringWithCommas( m_lexicon->GetHMM()->m_NumberOfIterations )
									   );		
		MiscItem1 = new CTreeViewItem(MiscItem,
									  "Number of states: " + IntToStringWithCommas( m_lexicon->GetHMM()->m_countOfStates )
									   );		
	}
	MiscItem->setOpen(true);

//======================================================================================//

  if( LexiconItem )
  {
	  if( m_lexicon->GetDLHistory()->count() > 0 )
	  {
		 MiscItem = new CTreeViewItem( LexiconItem,
									   "Description length history",
									   DESCRIPTION_LENGTH_HISTORY );
	  }
  }

//////////////////////////////
//// StringEdit Display

	if ((LexiconItem != NULL) && (m_Words_InitialTemplates != NULL))
	{
		if ( m_Words_InitialTemplates ->GetCount() > 0)
		{
			STRINGEDITITEM = new CTreeViewItem( LexiconItem,
										  "StringEditDistanceTemplates: " + IntToStringWithCommas( 2 ), 
										  STRINGEDITDISTANCE, -1);

			count = m_Words_Templates ->GetCount();
			if ( count != 0)
			{
				MiscItem = new CTreeViewItem( STRINGEDITITEM,
										  "StringEdit_Templates: " + IntToStringWithCommas( count ), 
										  WORKINGSTRINGEDITTEMPLATES, -1);

			}

			count = m_Words_InitialTemplates ->GetCount();
			MiscItem = new CTreeViewItem( STRINGEDITITEM,
										  "StringEdit_InitialTemplates: " + IntToStringWithCommas( count ), 
										  INITIALSTRINGEDITTEMPLATES, -1);
		}
	}

		count = 0;
		Q3DictIterator<PrefixSet> it5( *m_lexicon->GetAllPrefixes() );
		for( ; it5.current(); ++it5 )
		{
			count += it5.current()->count();
		}
		if( count > 0 )
		{
			PrefixesItem = new CTreeViewItem( LexiconItem,
											  "All Prefixes " + IntToStringWithCommas( count ),
											  ALL_PREFIXES );
			PrefixesItem->setOpen( TRUE );
		}    
//======================================================================================//
		count = 0;
		Q3DictIterator<SuffixSet> it4( *m_lexicon->GetAllSuffixes() );
		for( ; it4.current(); ++it4 )
		{
			count += it4.current()->count();
		}
		if( count > 0 )
		{
			SuffixesItem = new CTreeViewItem( LexiconItem,
											  "All Suffixes " + IntToStringWithCommas( count ),
											  ALL_SUFFIXES );
			SuffixesItem->setOpen( TRUE );
		}
//======================================================================================//
		count = 0;
		Q3DictIterator<StemSet> it1( *m_lexicon->GetAllStems() );
		for( ; it1.current(); ++it1 )
		{
			count += it1.current()->count();
		}
		if( count > 0 )
		{
			MiscItem = new CTreeViewItem( LexiconItem,
										  "All Stems " + IntToStringWithCommas( count ),
										  ALL_STEMS );
		}
 //======================================================================================//
		count = 0;
		Q3DictIterator<StemSet> it2( *m_lexicon->GetAllWords() );
		for( ; it2.current(); ++it2 )
		{
			count += it2.current()->count();
		}

		if( count > 0 )
		{
			WordsItem = new CTreeViewItem( LexiconItem,
										  "All Words " + IntToStringWithCommas( count ),
										  ALL_WORDS );
			WordsItem->setOpen( TRUE );
		}	
//======================================================================================//
	  if( m_lexicon->GetMiniCount() )
	  {
		for( index = m_lexicon->GetMiniSize() - 1; index >= 0; index-- )
		{
			if( m_lexicon->GetMiniLexicon( index ) )
				MiscItem = GetMiniLexiconSubTree( LexiconItem, index );
		}
	  }
//======================================================================================//
		count = m_lexicon->GetCompounds()->GetCount();
		if( count > 0 )
		{
			CompoundsItem = new CTreeViewItem( LexiconItem,
											   "Compounds " + IntToStringWithCommas( count ),
											   COMPOUNDS );
			CompoundsItem->setOpen( TRUE );
            int count2 = m_lexicon->GetCompounds()->GetComponents()->GetSize();
            ComponentItem = new CTreeViewItem( CompoundsItem, "Components "+ IntToStringWithCommas (count2),
                                                COMPOUND_COMPONENTS);
		}
//======================================================================================//

	  count = m_lexicon->GetWords()->GetCount();
	  if( count > 0 )
	  {
		CorpusWordsItem = new CTreeViewItem( LexiconItem,
											 "Corpus Words " + IntToStringWithCommas( count ),
											 CORPUS_WORDS );
		CorpusWordsItem->setOpen( TRUE );
	  }
//=================================================================================================
  // END CONNECTED TO LexiconItem
  // START CONNECTED TO CorpusWordsItem
//=================================================================================================

	count = 0;
	if( CorpusWordsItem )
	{

		CCorpusWord* pCorpusWord;
		CCorpusWordCollection* pWords = m_lexicon->GetWords();

		pWords->Sort( KEY );

		for( int i = 0; i < pWords->GetCount(); i++ )
		{
			pCorpusWord = pWords->GetAtSort(i);

			if( pCorpusWord->Size() > 1 )
			{
				count++;
			}
		}

		if( count > 0 )
		{
			MiscItem = new CTreeViewItem( CorpusWordsItem,
										  "Analyzed " + IntToStringWithCommas( count ),
										  ANALYZED_CORPUS_WORDS );
		}
	}
 
//=================================================================================================
  // END CONNECTED TO CorpusWordsItem
  // START CONNECTED TO WordsItem
//=================================================================================================

	count = 0;

	bool analyzed_exists;
	Q3DictIterator<StemSet> it3( *m_lexicon->GetAllWords() );
        for( ; it3.current(); ++it3 )
	{
            analyzed_exists = FALSE;
            //for( pWord = it3.current()->first(); pWord; pWord = it3.current()->next() )
            for (int z = 0; z < it3.current()->size(); z++)
            {
                pWord = it3.current()->at(z);
                if( pWord->Size() > 1 )
                {
                        analyzed_exists = TRUE;
                        count++;
                }
            }
	}

	if( count > 0 )
	{
		MiscItem = new CTreeViewItem( WordsItem,
									  "Analyzed " + IntToStringWithCommas( count ),
									  ALL_ANALYZED_WORDS );
	}

//=================================================================================================
  // END CONNECTED TO WordsItem
  // START CONNECTED TO SuffixesItem
//=================================================================================================

	count = 0;

	Q3DictIterator<SignatureSet> it7( *m_lexicon->GetAllSuffixSigs() );
	for( ; it7.current(); ++it7 )
	{
		count += it7.current()->count();
	}
	if( count > 0 )
	{
		MiscItem = new CTreeViewItem( SuffixesItem,
									  "Signatures " + IntToStringWithCommas( count ),
									  ALL_SUFFIX_SIGNATURES );
	}

//=================================================================================================
  // END CONNECTED TO SuffixesItem
  // START CONNECTED TO PrefixesItem
//=================================================================================================

	count = 0;

	Q3DictIterator<SignatureSet> it6( *m_lexicon->GetAllPrefixSigs() );
	for( ; it6.current(); ++it6 )
	{
		count += it6.current()->count();
	}
	if( count > 0 )
	{
		MiscItem = new CTreeViewItem( PrefixesItem,
									  "Signatures " + IntToStringWithCommas( count ),
									  ALL_PREFIX_SIGNATURES );
	}

//=================================================================================================
  // END CONNECTED TO PrefixesItem
  // START CONNECTED TO WordsReadItem
//=================================================================================================

	if( WordsReadItem )
	{
		if( m_lexicon->GetWords() )
		{
			count = m_lexicon->GetWords()->GetCount();
			if( count > 0 )
			{
				MiscItem = new CTreeViewItem( WordsReadItem,
											  "Distinct types read: " + IntToStringWithCommas( count ) );
				MiscItem->setSelectable(false);
			}
		} 

//======================================================================================//

		count = m_lexicon->GetCorpusCount();
		if( count >= 0 )
		{
			MiscItem = new CTreeViewItem( WordsReadItem,
										  "Tokens included: " + IntToStringWithCommas( count ) );
			MiscItem->setSelectable(false);
		} 
	}


//=================================================================================================
  // END CONNECTED TO WordsReadItem
  // START CONNECTED TO CompoundsItem
//=================================================================================================

	count = m_lexicon->GetLinkers()->GetCount();
	if( count > 0 )
	{
		MiscItem = new CTreeViewItem( CompoundsItem,
									  "Linkers " + IntToStringWithCommas( count ),
									  LINKERS, index );
	}
}