Пример #1
0
	bool top_tags(const char* str1, const char* str2)
	{
		std::list<std::string>::reverse_iterator i = tag_stack.rbegin();
		if (i == tag_stack.rend()) return false;
		if (!string_equal_nocase(i->c_str(), str2)) return false;
		++i;
		if (i == tag_stack.rend()) return false;
		if (!string_equal_nocase(i->c_str(), str1)) return false;
		return true;
	}
gfx::Color PerlinCity::noise(const std::list<gfx::VolumeGray8Sptr> &op,
    const math::vec3d &tt)
{
  float ns = 0.0f,
        wt = 1.0f;

  for(std::list<gfx::VolumeGray8Sptr>::const_reverse_iterator ii = op.rbegin(), ee = op.rend();
      (ii != ee); ++ii)
  {
    gfx::VolumeGray8 *vv = ii->get();
    ns += wt * math::abs((vv->getAveragePixel(tt.x(), tt.y(), tt.z()) - 0.5f));
    wt *= 0.5f;
  }
  //ns = ns*ns;

  //ns = ns + 0.5f;
  if(ns < 0.0f)
  {
    ns = -ns;
  }
  else if(ns > 1.0f)
  {
    ns = 2.0f - ns;
  }

  return gfx::Color(ns, ns, ns);
  //return m_gradient.getColor(ns);
}
Пример #3
0
void Variables::leaveScope(bool insideLoop)
{
    if (insideLoop) {
        // read variables are read again in subsequent run through loop
        std::set<unsigned int> const & currentVarReadInScope = _varReadInScope.back();
        for (std::set<unsigned int>::const_iterator readIter = currentVarReadInScope.begin();
             readIter != currentVarReadInScope.end();
             ++readIter) {
            read(*readIter, nullptr);
        }
    }

    std::list<std::set<unsigned int> >::reverse_iterator reverseReadIter = _varReadInScope.rbegin();
    ++reverseReadIter;
    if (reverseReadIter != _varReadInScope.rend()) {
        // Transfer read variables into previous scope

        std::set<unsigned int> const & currentVarAddedInScope = _varAddedInScope.back();
        std::set<unsigned int>  & currentVarReadInScope = _varReadInScope.back();
        for (std::set<unsigned int>::const_iterator addedIter = currentVarAddedInScope.begin();
             addedIter != currentVarAddedInScope.end();
             ++addedIter) {
            currentVarReadInScope.erase(*addedIter);
        }
        std::set<unsigned int> & previousVarReadInScope = *reverseReadIter;
        previousVarReadInScope.insert(currentVarReadInScope.begin(),
                                      currentVarReadInScope.end());
    }
    _varReadInScope.pop_back();
    _varAddedInScope.pop_back();
}
Пример #4
0
	void HeapPage::freeBlocks(std::list<HeapBlock>& newBlocks, std::list<HeapBlock>& newReleasedBlocks) {
		// Copy new blocks.
		blocks = newBlocks;

		// Check if we can join some values.
		IntPtr pageHighAddress = reinterpret_cast<IntPtr>(&memory[pagepointer]);
		std::list<HeapBlock>::reverse_iterator current = newBlocks.rbegin();

		// Start looking from the end of new blocks.
		// Use the new blocks listing, not the instance list.
		while (current != newBlocks.rend() && current->isReleased()) {
			const IntPtr blockHighAddress = reinterpret_cast<IntPtr>(current->getHandle()) + current->getSize();

			// If both are pointing to the same memory location,
			// we can join this block with the free memory region
			// of the page.
			if (blockHighAddress == pageHighAddress) {
				// Compute new high address and move page 
				// pointer back.
				pageHighAddress -= current->getSize();
				pagepointer -= current->getSize();

				// Remove from new released block listing.
				newReleasedBlocks.remove(*current);
				blocks.remove(*current);

				current++;
			} else {
				// If we can't join the first block to the free memory region,
				// there is no point going trough other blocks.
				break;
			}
		}
	}
Пример #5
0
void Preprocessor::sortRegions (std::list<RegionIterator>& regions)
{
	for ( std::list<RegionIterator>::iterator i = regions.begin(); i != regions.end(); ++i )
	{
		if ( i == regions.begin() )
			continue;

		// Get current element
		RegionIterator value = *i;

		// Get previous element
		std::list<RegionIterator>::reverse_iterator j = regions.rbegin();
		advance(j, distance(i, regions.end()));

		// Shift elements until finding final position
		while ( j != regions.rend() && *value < *(*j) )
		{
			std::list<RegionIterator>::reverse_iterator k = j;
			--k;
			*k = *j;

			++j;
		}

		// Insert current element into its final position
		std::list<RegionIterator>::reverse_iterator k = j;
		--k;
		*k = value;
	}
};
Пример #6
0
void
test_ns::matrix::
find_one_puddle_and_update(int entry_h, const entry_pos_t& entry_pos,
        entry_pos_set_t& puddle_pos, entry_pos_set_t& leaks_pos,
        std::list<puddle>& puddles,
        size_t& yet_not_found_positions) const {
    entry_pos_set_t searched_entries;
    entry_pos_set_t below_level_entries;
    bool is_puddle = find_one_puddle(entry_h, entry_pos, leaks_pos,
            searched_entries, below_level_entries);
    yet_not_found_positions -= searched_entries.size();
    if (is_puddle) {
        for (const auto & e : searched_entries) {
            puddle_pos.insert(e);
        }
        if (!below_level_entries.empty()) {
            for (auto const & below_entry : below_level_entries) {
                for (auto i = puddles.rbegin(); i != puddles.rend(); ++i) {
                    const auto & puddle = *i;
                    auto & entries = puddle.entries_;
                    if (entries.find(below_entry) != entries.end()) {
                        puddles.erase(std::prev (i.base()));
                        break;
                    }
                }
            }
        }
        puddle a_puddle{searched_entries, entry_h};
        puddles.push_back(std::move(a_puddle));
    } else {
        for (const auto & e : searched_entries) {
            leaks_pos.insert(e);
        }
    }
}
std::vector< double > guessLambdaModifiers(
    double initialAdjustmentParameter,
    const std::vector< double > &targetBitrateVector,
    const std::list< MetaLogEntry< std::vector< double > > >& metaLogEntryList )
{
  assert( !targetBitrateVector.empty( ) );
  assert( !metaLogEntryList.empty( ) );
  
  double cumulativeDelta( 0.0 );
  std::vector< double > resultVector;
  for( unsigned char i( 0 ); i < targetBitrateVector.size( ); ++i )
  {
    // Populate pointList with up to two of the previous points
    std::list< Point > pointList;
    std::list< MetaLogEntry< std::vector< double > > >::const_reverse_iterator j( metaLogEntryList.rbegin( ) );
    pointList.push_front( pointFromFullMetaLogEntry( i, *j ) );
    ++j;
    if( j != metaLogEntryList.rend( ) ) pointList.push_front( pointFromFullMetaLogEntry( i, *j ) );
    
    // Calculate the new Lambda-modifier guess and add it to the result vector
    const double newLambdaModifier( guessLambdaModifier(
        initialAdjustmentParameter,
        targetBitrateVector[ i ],  // target bitrate
        pointList,
        interDampeningFactor( 50.0, cumulativeDelta ) ) );
    resultVector.push_back( newLambdaModifier );
    
    // Increment the cumulativeDelta
    const double oldLambdaModifier( pointList.back( ).lambdaModifier );
    cumulativeDelta += std::abs( newLambdaModifier - oldLambdaModifier ) / oldLambdaModifier;
  }
  
  return resultVector;
}
Пример #8
0
void RenderChatText()
{
	// View transformation
	gGraphicsDevice->SetTransform(D3DTS_VIEW, &gOrthoViewMatrix);
	
	// Perspective transformation
	gGraphicsDevice->SetTransform(D3DTS_PROJECTION, &gScreenProjectionMatrix);

	// Render the texture
	gGraphicsDevice->BeginScene();
	{
		// render the user list
		size_t index = 0;
		int y = kFontSize / 4;
		for (auto iter=gChatUsers.rbegin(); iter != gChatUsers.rend() && index < gMaxChatLines; ++iter)
		{
			std::shared_ptr<ChatUser> user = *iter;
			RenderString(gWindowWidth-kUserListWidth, y, user->nameColorARGB, *user->font, user->username);

			y += user->font->pixelHeight + kLineSpacing;
			index++;
		}

		y = kFontSize / 4;

		// render the input text if showing
		if (gInputText != nullptr)
		{
			int x = RenderChatLine(kMessagesLeft, y, gInputText, KWhiteColor) + 2;
			RenderString(x, y, KWhiteColor, gNormalFont, "_");
			y += gInputText->font->pixelHeight + kLineSpacing;
		}

		// render the history
		for (auto iter=gChatLines.rbegin(); iter != gChatLines.rend(); ++iter)
		{
			std::shared_ptr<ChatLine> line = *iter;
			RenderChatLine(kMessagesLeft, y, line, KBlackColor);

			y += line->font->pixelHeight + kLineSpacing;
		}

		gGraphicsDevice->SetTexture(0, nullptr);
	}
	gGraphicsDevice->EndScene();
}
Пример #9
0
//*****************************************************************************
//
static bool callvote_CheckForFlooding( FString &Command, FString &Parameters, ULONG ulPlayer )
{
	NETADDRESS_s	Address = SERVER_GetClient( ulPlayer )->Address;
	ULONG			ulVoteType = callvote_GetVoteType( Command );
	time_t tNow;
	time( &tNow );

	// Remove old votes that no longer affect flooding.
	while ( g_PreviousVotes.size( ) > 0 && (( tNow - g_PreviousVotes.front( ).tTimeCalled ) > VOTE_LONGEST_INTERVAL * MINUTE ))
		g_PreviousVotes.pop_front( );

	// [BB] If the server doesn't want to limit the number of votes, there is no check anything.
	// [TP] sv_limitcommands == false also implies limitless voting.
	if ( sv_limitnumvotes == false || sv_limitcommands == false )
		return true;

	// Run through the vote cache (backwards, from recent to old) and search for grounds on which to reject the vote.
	for( std::list<VOTE_s>::reverse_iterator i = g_PreviousVotes.rbegin(); i != g_PreviousVotes.rend(); ++i )
	{
		// One *type* of vote per voter per ## minutes (excluding kick votes if they passed).
		if ( !( callvote_IsKickVote ( i->ulVoteType ) && i->bPassed ) && NETWORK_CompareAddress( i->Address, Address, true ) && ( ulVoteType == i->ulVoteType ) && (( tNow - i->tTimeCalled ) < VOTER_VOTETYPE_INTERVAL * MINUTE ))
		{
			int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTER_VOTETYPE_INTERVAL * MINUTE - tNow ) / MINUTE );
			SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another %s vote.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ), Command.GetChars() );
			return false;
		}

		// One vote per voter per ## minutes.
		if ( NETWORK_CompareAddress( i->Address, Address, true ) && (( tNow - i->tTimeCalled ) < VOTER_NEWVOTE_INTERVAL * MINUTE ))
		{
			int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTER_NEWVOTE_INTERVAL * MINUTE - tNow ) / MINUTE );
			SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another vote.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
			return false;
		}

		// Specific votes ("map map30") that fail can't be re-proposed for ## minutes.
		if (( ulVoteType == i->ulVoteType ) && ( !i->bPassed ) && (( tNow - i->tTimeCalled ) < VOTE_LITERALREVOTE_INTERVAL * MINUTE ))
		{
			int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTE_LITERALREVOTE_INTERVAL * MINUTE - tNow ) / MINUTE );

			// Kickvotes (can't give the IP to clients!).
			if ( callvote_IsKickVote ( i->ulVoteType ) && ( !i->bPassed ) && NETWORK_CompareAddress( i->KickAddress, g_KickVoteVictimAddress, true ))
			{
				SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "That specific player was recently on voted to be kicked or forced to spectate, but the vote failed. You must wait %d minute%s to call it again.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
				return false;
			}

			// Other votes.
			if ( ( callvote_IsKickVote ( i->ulVoteType ) == false ) && ( stricmp( i->fsParameter.GetChars(), Parameters.GetChars() ) == 0 ))
			{
				SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "That specific vote (\"%s %s\") was recently called, and failed. You must wait %d minute%s to call it again.\n", Command.GetChars(), Parameters.GetChars(), iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
				return false;
			}
		}
	}

	return true;
}
Пример #10
0
static std::list<TokenRec>::reverse_iterator searchBackToken(int id){
  std::list<TokenRec>::reverse_iterator iii=TokenList.rbegin();
  for ( ; iii!=TokenList.rend();iii++){
    if (id==iii->id){
      break;
    }
  }
  return iii;
}
Пример #11
0
void CRealTextParser::PopTag(std::list<Tag>& p_rlistTags, const std::wstring& p_crszTagName)
{
    for (std::list<Tag>::reverse_iterator riter = p_rlistTags.rbegin(); riter != p_rlistTags.rend(); ++riter) {
        if (riter->m_szName == p_crszTagName) {
            p_rlistTags.erase((++riter).base());
            return;
        }
    }
}
Пример #12
0
	void DrawScreenSpace (sf::RenderWindow& rwin) {
		for (typename std::list<T*>::reverse_iterator itState = stateList.rbegin();
				itState != stateList.rend(); ++itState) {
			if (!(*itState)->off) {
				(*itState)->DrawScreenSpace(rwin);
				break;
			}
		}
	}
Пример #13
0
	virtual void HandleSFEvents (std::list<sf::Event>& sfEvents) {
		for (typename std::list<T*>::reverse_iterator itState = stateList.rbegin();
				itState != stateList.rend(); ++itState) {
			if (!(*itState)->off) {
				(*itState)->HandleSFEvents(sfEvents);
				break;
			}
		}
	}
Пример #14
0
	/*
	 * Erases the last inactive element in the cache.
	 */
	bool erase_last() {
		for (auto rit = elements.rbegin(); rit != elements.rend(); ++rit) {
			if (rit->active_readers == 0) {
				erase(rit->key);
				return true;
			}
		}
		return false;
	}
Пример #15
0
	void Pop (int cntToPop) {
		int i = 0;
		for (typename std::list<T*>::reverse_iterator itState = stateList.rbegin();
				itState != stateList.rend(); itState++) {
			(*itState)->pop = true;

			if (++i == cntToPop)
				break;
		}
	}
Пример #16
0
T KernelFunction::findDecl(std::list<T> list, const clang::IdentifierInfo* ID) {
	typedef typename std::list<T>::reverse_iterator iterator;

	for (iterator it = list.rbegin(); it != list.rend(); ++it) {
		if ((*it)->ID == ID && (*it)->Parameter->isOccupied()) {
			return *it;
		}
	}

	return NULL;
}
Пример #17
0
void Sip_Request::add_routes(const std::list<Sip_Uri> &routes)
{
    std::list<Sip_Uri>::const_reverse_iterator i;
    std::list<Sip_Uri>::const_reverse_iterator first = routes.rend();

    for( i = routes.rbegin(); i != first; ++i )
    {
        const Sip_Uri &route = *i;
        add_route( route.get_string() );
    }
}
Пример #18
0
T KernelFunction::findArray(std::list<T> list, const clang::StringRef name) {
	typedef typename std::list<T>::reverse_iterator iterator;

	for (iterator it = list.rbegin(); it != list.rend(); ++it) {
		if ((*it)->ID->getName() == name) {
			return (*it);
		}
	}

	return NULL;
}
Пример #19
0
	void Update (float dT) {
	// there was some bug with this somewhere..lol.. => safe and ugly solution
	//		stateList.back()->Update(dT);

		for (typename std::list<T*>::reverse_iterator itState = stateList.rbegin();
				itState != stateList.rend(); ++itState) {
			if (!(*itState)->off) {
				(*itState)->Update(dT);
				break;
			}
		}
	}
Пример #20
0
int getLastElement(const std::list<int>& list)
{
  int result = -1;

  if (list.size() > 0)
    {
    std::list<int>::const_reverse_iterator iterator;
    iterator = list.rend();
    result = *iterator;
    }

  return result;
}
Пример #21
0
//Alt. version of reduceIdent()
Identity Graph::reduceIdent2(std::list<Identity>::iterator pid, std::list< std::list<Node>::iterator >& pidPath, bool report)
{
    std::list<Node>::iterator prightNode;
    prightNode = pid->getRight();

    //use to trace back through pidPath
    std::list< std::list<Node>::iterator >::reverse_iterator pleftPath = pidPath.rbegin();
    std::list< std::list<Node>::iterator >::reverse_iterator pleftPathPlus1 = pleftPath;
    pleftPathPlus1++;

    while (pleftPathPlus1 != pidPath.rend())
    {
        //look for pleft in pleftPlus1's xout list
        if ((*pleftPathPlus1)->isInXout(*pleftPath))
        {
            if (prightNode->isXinEmpty())
                break;
            prightNode = prightNode->getXin();
        } //look in pleftPlus1's yout list
        else if ((*pleftPathPlus1)->isInYout(*pleftPath))
        {
            if (prightNode->isYinEmpty())
                break;
            prightNode = prightNode->getYin();
        }
        else //in this case the path is not valid
        {
            std::cout << "\nBAD PATH FOR IDENTITY:\n";
            pid->printIdent();
            Identity nullid;
            return nullid;
        }

        pleftPath++;
        pleftPathPlus1++;
    }

    //make and return reduced identity;
    Identity reducedId(*pleftPath, prightNode, pid->getBase());

    if (report)
    {
        std::cout << "\nIdentity ";
        pid->printIdent();
        std::cout << "\nreduced to ";
        reducedId.printIdent();
        std::cout << "\n";
    }

    return reducedId;
}
Пример #22
0
void AStarPathFind::Floyd(std::list<ASTAR_POINT>& oListPath)
{
    ASLITER iter1 = oListPath.begin();
    ASTAR_POINT oPos1 = *(++iter1) - *iter1;
    for (ASLITER iter2 = ++iter1; iter2 != oListPath.end(); ++iter2)
    {
        ASLITER iter_tmp = iter2;
        iter_tmp--;
        ASTAR_POINT oPos2 = *iter2 - *(iter_tmp);
        if (oPos1.nX == oPos2.nX && oPos1.nY == oPos2.nY)
        {
            oListPath.erase(iter_tmp);
        }
        else
        {
            oPos1 = oPos2;
        }
    }
    ASLRITER riter = oListPath.rbegin();
    ASLRITER riter_end = oListPath.rend();
    for (; riter != riter_end; ) 
    {
        ASLRITER riter_tmp = riter;
        if (++riter_tmp == riter_end)
        {
            break;
        }
        bool bDelPoint = false;
        ASLITER iter_end = (++riter_tmp).base();
        for (ASLITER  iter = oListPath.begin(); iter != iter_end; iter++)
        {
            if (FloydCrossAble(*riter, *iter))
            {
                ASLITER iter1 = iter;
                ASLITER iter_end1 = (++riter).base();
                for (iter1++; iter1 != iter_end1; )
                {
                    oListPath.erase(iter1++);
                }
                riter = ASLRITER(++iter);
                bDelPoint = true;
                break;
            }
        }
        if (!bDelPoint)
        {
            riter++;
        }
    }
}
Пример #23
0
	const TreeNode *find_tag(std::string name) {
		std::list<const TreeNode *>::reverse_iterator it(invocation_stack.rbegin()), itEnd(invocation_stack.rend());
		const TreeNode *t = NULL;
		
		for(; it!=itEnd; ++it) {
			t = (*it)->Child(name);
			if (t)
				break;
			if (!name.empty() && name[0]=='/')
				break;
		}

		return t;
	}
Пример #24
0
static void
FillLastUsedList(WaypointSelectInfoVector &list,
                 const std::list<unsigned int> &last_used_ids,
                 const Waypoints &waypoints, const GeoPoint location)
{
  list.clear();

  if (last_used_ids.empty())
    return;

  for (auto it = last_used_ids.rbegin(); it != last_used_ids.rend(); it++) {
    const Waypoint* waypoint = waypoints.LookupId(*it);
    if (waypoint == NULL)
      continue;

    list.push_back(*waypoint, location);
  }
}
Пример #25
0
void ofxWidget::moveBy(const ofVec2f & delta_) {

	// find the iterator to the current widget
	auto it = findIt(mThis, sAllWidgets.begin(), sAllWidgets.end());
	// convert to a reverse iterator
	auto rIt = std::reverse_iterator<decltype(it)>(it);

	mRect.position += delta_;

	// all children (if any) are lined up *before* a parent in sAllWidgets.
	// we're using a reverse iterator so that we don't get a problem 
	// at the very physically first element.
	for (int i = 0; i < int(mNumChildren) && rIt != sAllWidgets.rend(); i++, rIt++) {
		if (auto w = rIt->lock()) {
			w->mRect.position += delta_;
		}
	}
}
Пример #26
0
LargeInteger LargeInteger::multiply(std::list<int> number) {

	int factor = 0;
	int carry = 0;
	std::vector<std::list<int>> rows;
	std::list<int>::reverse_iterator i = listInt.rbegin();
	std::list<int>::reverse_iterator j = number.rbegin();

	std::cout<<"Multiplying... ";
	for( j; j != number.rend(); j++) {
		std::list<int> row;
		for( i = listInt.rbegin(); i != listInt.rend(); i++) {
			int n = (*i) * (*j) + carry;
			std::cout<<"multiplying "<<*i<<" by "<<*j<<" + carry ("<<carry<<") = "<<n<<std::endl;
			carry = 0;
			if(n >= 10) {
				carry = (int)(n/10);
				n = n % 10;
				std::cout<<"carry = "<<carry<<" n = "<<n<<std::endl;
			}
			row.push_front(n);

		}
		if(carry>0)
				row.push_front(carry);
		for(int f = 0; f < factor; f++)
			row.push_back(0);
			factor++;
		rows.push_back(row);
	}

	std::cout<<"Combining products..."<<std::endl; factor--;
	LargeInteger product;
	std::vector<std::list<int>>::iterator iter;
	for(iter = rows.begin(); iter != rows.end(); iter++) {
		LargeInteger temp(*iter,false);
		for(int z = 0; z < factor; z++)
			std::cout<<" ";
		factor--;
		std::cout<<temp.str()<<std::endl;
		product = product.add(*iter);
	}
	return product;
}
Пример #27
0
//! Exercise 10.36
//! @note   reverse iterator can not conver to oridinary directly
//!         it may be done via the member base().
inline std::list<int>::iterator find_last_0(std::list<int>& l)
{
    //! assumimg : 1 2 3 4 0 5 6

    //! 1 2 3 4 0 5 6
    //!         ^
    //! to which r_it refer.
    auto r_it = std::find(l.rbegin(), l.rend(), 0);

    //! 1 2 3 4 0 5 6
    //!           ^
    //! to which it refer.
    auto it = r_it.base();

    //! 1 2 3 4 0 5 6
    //!         ^
    //! to which --it refer.
    return std::prev(it);
}
Пример #28
0
void XKeyboardInterface::SendKey(const std::list<int>& keycode)
{
    for(std::list<int>::const_iterator i = keycode.begin();
            i != keycode.end(); i++)
    {
        KeyCode key = XKeysymToKeycode(m_display, *i);
        if(key == NoSymbol) continue;

        XTestFakeKeyEvent(m_display, key, True, CurrentTime);
    }
    for(std::list<int>::const_reverse_iterator i = keycode.rbegin();
            i != keycode.rend(); i++)
    {
        KeyCode key = XKeysymToKeycode(m_display, *i);
        if(key == NoSymbol) continue;

        XTestFakeKeyEvent(m_display, key, False, CurrentTime);
    }
    XFlush(m_display);
}
Пример #29
0
void MessageManager::AddMessageToList(std::list <Message*> &messageList, Message *m)
{
	//insert sorted by delivery time
	std::list <Message*>::reverse_iterator itor = messageList.rbegin();
	
	while (itor != messageList.rend())
	{
		if ( (*itor)->GetDeliveryTime() > m->GetDeliveryTime())
		{
			itor++;
		} 
		else
		{
			break;
		}
	}

	//add it
	messageList.insert(itor.base(), m);
}
gfx::Color PerlinRubble::noise(const std::list<gfx::VolumeGray8Sptr> &op, const math::vec3d &tt)
{
  float ns = 0.0f,
        wt = 1.0f;

  for(std::list<gfx::VolumeGray8Sptr>::const_reverse_iterator ii = op.rbegin(), ee = op.rend();
      (ii != ee); ++ii)
  {
    gfx::VolumeGray8 *vv = ii->get();
    ns += wt * math::abs(vv->getAveragePixel(tt.x(), tt.y(), tt.z()) - 0.5f);
    wt *= 0.6f;
  }
  //ns = ns*ns;

  ns = ns + 0.5f;
  if(ns < 0.0f)
  {
    ns = -ns;
  }
  if(ns > 1.0f)
  {
    ns = 2.0f - ns;
  }
  if(ns < 0.0f)
  {
    ns = -ns;
  }

  /*gfx::Color ret;
  ret.r() = ns * 1.0f;
  ret.g() = ns * 0.8f;
  ret.b() = ns * 0.1f;
  ret.a() = 1.0f;
  return ret;*/

  return m_gradient.getColor(ns);
  //return gfx::Color(0.0f, 0.0f, 0.0f);
}