Example #1
0
void TestSerialization() {
    Stream stream(L"test.dat", true);
    List<int> l;
    l.Add(1);
    l.Add(2);
    l.Add(3);
    l.Serialize(stream);
    l.Clear();
    stream.Close();

    stream.Open(L"test.dat");
    l.Deserialize(stream);

    List<Point> b;
    b.Add(Point(1, 2, 3));
    b.Add(Point(4, 5, 6));
    b.Add(Point(7, 8, 9));
    stream.Close();
    stream.Open(L"test.dat", true);
    b.Serialize(stream);
    
    stream.Close();

    stream.Open(L"test.dat");
    b.Deserialize(stream);
}
Example #2
0
/** Used to tokenize with some characters used to start and stop the tokenization procedure temporarily.
	Sample use-case would be to tokenize the string "Aim(7,3), Guard(2,3)" and returning "Aim(7,3)" and "Guard(2,3)",
	using the tokenizer ',' and ignoreparts "()". 
	Ignore parts should be in pairs, one starting the ignore part, the other stopping it.
*/
List<String> TokenizeIgnore(String string, String tokenizers, String ignoreParts)
{
	List<String> tokens;
	int inIgnorePart = 0;
	const char * cString = string.c_str();
	String str;
	for (int i = 0; i < string.Length(); ++i)
	{
		char c = cString[i];
		for (int i = 0; i < ignoreParts.Length(); i += 2)
		{
			if (c == ignoreParts.c_str()[i])
				++inIgnorePart;
			if (c == ignoreParts.c_str()[i+1])
				--inIgnorePart;
		}

		if (tokenizers.Contains(c) && inIgnorePart == 0)
		{
			tokens.Add(str);
			str = String();
		}
		else 
		{
			str += c;
		}
	}
	// Add final one.
	tokens.Add(str);
	return tokens;
}
Example #3
0
void TestStoryboard() {
    List<Point> points;
    points.Add(Point(0, 0, 0));
    points.Add(Point(1, 1, 1));
    points.Add(Point(2, 2, 2));
    points.Add(Point(3, 3, 3));

    Shape shape(points);
    IAction* a = new TranslateAction(3, 3 , 3);
    IAction* b = new TranslateAction(2, 2 , 2);
    IAction* c = new TranslateAction(5, 5 , 5);
    a->SetSteps(3);
    b->SetSteps(3);
    c->SetSteps(4);
    b->SetWithPrevious(true);

    Storyboard sb;
    sb.Actions().Add(a);
    sb.Actions().Add(b);
    sb.Actions().Add(c);
    sb.SetShapeObject(shape);

    assert(sb.TotalSteps() == 10);
    assert(sb.CurrentAction() == NULL);

    sb.Play();
    for(size_t i = 0; i < sb.TotalSteps(); i++) {
        sb.NextStep();
    }
}
Example #4
0
void GraphicsWindow::FixConstraintsForPointBeingDeleted(hEntity hpt) {
    List<hEntity> ld;
    ZERO(&ld);

    Constraint *c;
    SK.constraint.ClearTags();
    for(c = SK.constraint.First(); c; c = SK.constraint.NextAfter(c)) {
        if(c->type != Constraint::POINTS_COINCIDENT) continue;
        if(c->group.v != SS.GW.activeGroup.v) continue;

        if(c->ptA.v == hpt.v) {
            ld.Add(&(c->ptB));
            c->tag = 1;
        }
        if(c->ptB.v == hpt.v) {
            ld.Add(&(c->ptA));
            c->tag = 1;
        }
    }
    // These would get removed anyways when we regenerated, but do it now;
    // that way subsequent calls of this function (if multiple coincident
    // points are getting deleted) will work correctly.
    SK.constraint.RemoveTagged();

    // If more than one point was constrained coincident with hpt, then
    // those two points were implicitly coincident with each other. By
    // deleting hpt (and all constraints that mention it), we will delete
    // that relationship. So put it back here now.
    int i;
    for(i = 1; i < ld.n; i++) {
        Constraint::ConstrainCoincident(ld.elem[i-1], ld.elem[i]);
    }
    ld.Clear();
}
Example #5
0
		void SymbolTable::EvalFunctionReferenceClosure()
		{
			for (auto & func : Functions)
			{
				List<String> funcList;
				EnumerableHashSet<String> funcSet;
				for (auto & ref : func.Value->ReferencedFunctions)
				{
					funcList.Add(ref);
					funcSet.Add(ref);
				}
				for (int i = 0; i < funcList.Count(); i++)
				{
					RefPtr<FunctionSymbol> funcSym;
					if (Functions.TryGetValue(funcList[i], funcSym))
					{
						for (auto rfunc : funcSym->ReferencedFunctions)
						{
							if (funcSet.Add(rfunc))
								funcList.Add(rfunc);
						}
					}
				}
				func.Value->ReferencedFunctions = _Move(funcSet);
			}
		}
Example #6
0
	void UIBase::UnFocus() {
		List<UIBase*> childs;
		childs.Add(this);

		bool found = false;

		UIBase* c = nullptr;
		while (childs.Count > 0) {
			c = childs[childs.Count - 1];
			childs.RemoveAt(childs.Count - 1);

			if (this->UIMan != nullptr && c == this->UIMan->FocusPanel) {
				found = true;
				break;
			} else {
				for (unsigned int i = 0; i < c->Children.size(); i++) {
					childs.Add(c->Children[i]);
				}
			}
		}

		if (!found) return;

		if (this->UIMan != nullptr) this->UIMan->FocusPanel = nullptr;
		c->OnFocus(false);
	}
Example #7
0
List* operator+ (List& ls1, List& ls2)
{

	List *newList = new List();
	List *temp = ls1.head;

	while (temp)
	{
		newList->Add(temp->getNumber());
		temp = temp->next;
	}

	temp = ls2.head;

	while (temp)
	{


		newList->Add(temp->getNumber());
		temp = temp->next;

	}

	return newList;

}
Example #8
0
    virtual void Deserialize(Stream &stream) {
        ClearActions();
        size_t count;
        stream.Read(count);

        for(size_t i = 0; i < count; i++) {
            int temp;
            stream.Read(temp);
            ActionType type = (ActionType)temp;

            switch(type) {
                case ACTION_TRANSLATE: {
                    TranslateAction *action = new TranslateAction();
                    stream.Read(*action);
                    actions_.Add(action);
                    break;
                }
                case ACTION_SCALE: {
                    ScaleAction *action = new ScaleAction();
                    stream.Read(*action);
                    actions_.Add(action);
                    break;
                }
                case ACTION_ROTATE: {
                    RotateAction *action = new RotateAction();
                    stream.Read(*action);
                    actions_.Add(action);
                    break;
                }
            }
        }
    }
int main()
{
	List myList = List();
	List myList2 = List();
	myList.Add(1);
	myList.Add(2);
	myList.Add(3);
	myList.Add(4);
	myList.Add(5);
	myList.Add(6);

	myList2.Add(1);
	myList2.Add(2);
	myList2.Add(3);
	myList2.Add(4);
	myList2.Add(5);
	myList2.Add(6);

	myList.tail->next = myList.head->next;

	checkForDuplicates(myList2.head);
	

	system("pause");
	return 0;
}
Example #10
0
void FntLabel::UpdateMesh()
{
	if (mString.IsEmpty())
	{
		if (mFont->HasSinglePage() && mFont->IsFixed())
		{
			SetMesh(nullptr);
			SetMaterial(nullptr);
		}

		if (!mManagedNodes.IsEmpty())
		{
			DeleteAllChilds(NodeRemoveFlags::OnlyManaged);
		}
		SetSize(Size2F::Zero);
		mInternalMeshes.Clear();
		return;
	}
	else if (mRenderingObject.Mesh() ==nullptr)
	{
		CreateMesh();
	}


	Size2F outSize;

	if (mIsMultipleLine)
	{
		TextLayouter::LayoutMultipleLineText(mInternalMeshes, mInternalPages, outSize, *mFont, mString, mAlignment, mRestrictSize, this, mIsStatic);
	}
	else
	{
		TextLayouter::LayoutSingleLineText(mInternalMeshes, mInternalPages, outSize, *mFont, mString, mAlignment, mRestrictSize, this, mIsStatic);
	}

	SetSize(outSize);

	//check if there are some mesh has no char after layout,this is rarely hit
	size_t meshCount = mInternalMeshes.Count();
	if (meshCount>1)
	{
		List<size_t> unusedIndices;
		List<INode*> unusedSprites;
		FOR_EACH_SIZE(i, meshCount)
		{
			BaseFontMesh* mesh = mInternalMeshes[i];
			if (!mesh->HasChars())
			{
				unusedIndices.Add(i);
				unusedSprites.Add(mManagedNodes[i]);
			}
		}
int get_processes ( List &processes , List &uptimes )
{
  PROCESSENTRY32 process;
  HANDLE handle;
  HANDLE phandle;
  int mypid;
  int ret = TRUE;

/* Getting my process ID */
  mypid = GetCurrentProcessId ();

/* Cleaning list */
  processes.Clear ();
  uptimes.Clear ();

/* Getting process list */
  handle = CreateToolhelp32Snapshot ( TH32CS_SNAPALL , 0 );

/* Initializing structure */
  process.dwSize = sizeof ( PROCESSENTRY32 );

/* Getting first process */
  Process32First ( handle , &process );

/* Adding the PID */
  processes.Add ( ( void * ) process.th32ProcessID );

/* Getting the uptime of this process */
  uptimes.Add ( ( void * ) get_process_uptime ( process.th32ProcessID ) );

/* Getting the rest of the processes */
  while ( Process32Next ( handle , &process ) == TRUE )
  {
  /* If it's not me */
    if ( mypid != process.th32ProcessID )
    {
    /* Adding the PID */
      processes.Add ( ( void * ) process.th32ProcessID );

    /* Getting the uptime of this process */
      uptimes.Add ( ( void * ) get_process_uptime ( process.th32ProcessID ) );
    }
  }

/* Ordering process list */
  processes.SortCouple ( uptimes );

/* Closing handle */
  CloseHandle ( handle );

  return ( ret );
}
Example #12
0
void Node::CreateIndices()
{
	for (int n=0;n < m_list.GetNum();n++)
	{
		unsigned short i;
		i = this->AddVector(m_list[n].a);
		m_indices.Add(i);
		i = this->AddVector(m_list[n].b);
		m_indices.Add(i);
		i = this->AddVector(m_list[n].c);
		m_indices.Add(i);
	}
	m_list.Clean();
}
Example #13
0
void TestList() {
    List<int> a;
    a.Add(3);
    a.Add(5);
    assert(a.Count() == 2);
    assert(a.Contains(3));
    assert(a.Contains(5));
    assert(a[0] == 3);

    List<int> b(a);
    b.Add(a);
    assert(b.Count() == 4);
    a.Remove(3);
    assert(a.Count() == 1);
    assert(a.Contains(3) == false);
    assert(a[0] = 5);
    
    a.Insert(4, 0);
    a.Insert(6, 1);
    a.Insert(7, a.Count() - 1);
    assert(a[0] == 4);
    assert(a[1] == 6);
    assert(a[2] == 7);

    a.Remove(6);
    assert(a[2] == 5);
}
Example #14
0
List<SRPWindows*> *Gui::GetMouseEnabledWindows()
{
	// create an empty list
	List<SRPWindows*> *pList = new List<SRPWindows*>;

	// get the iterator for all the windows
	Iterator<SRPWindows*> cIterator = m_pWindows->GetIterator();
	// loop trough the windows
	while (cIterator.HasNext())
	{
		SRPWindows *pSRPWindows = cIterator.Next();
		if (pSRPWindows->GetData()->bIsVisable && pSRPWindows->GetData()->bMouseEnabled)
		{
			// if the window is visible and the mouse for the window is enabled then add the window to the list
			pList->Add(pSRPWindows);
		}
	}

	if (pList->GetNumOfElements() > 0)
	{
		// list has items so return the list
		return pList;
	}
	else
	{
		// return nothing because the list is empty
		return nullptr;
	}
}
Example #15
0
		void Application::Dispose()
		{
			{
				List<BaseForm *> forms;
				for (auto & c : *components)
				{
					if (c.Value)
					{
						BaseForm * ctrl = dynamic_cast<BaseForm*>(c.Value);
						if (ctrl)
						{
							forms.Add(ctrl);		
						}
						c.Value = 0;
					}
				}
				for (int i=0; i<forms.Count(); i++)
					delete forms[i];
				delete components;
				delete cmdLine;
				delete objMap;
				delete onMainLoop;
			}
			GdiplusShutdown(gdiToken);

			_CrtDumpMemoryLeaks();
		}
Example #16
0
int StepFileWriter::ExportCurveLoop(SBezierLoop *loop, bool inner) {
    if(loop->l.n < 1) oops();

    List<int> listOfTrims;
    ZERO(&listOfTrims);

    SBezier *sb = &(loop->l.elem[loop->l.n - 1]);

    // Generate "exactly closed" contours, with the same vertex id for the
    // finish of a previous edge and the start of the next one. So we need
    // the finish of the last Bezier in the loop before we start our process.
    fprintf(f, "#%d=CARTESIAN_POINT('',(%.10f,%.10f,%.10f));\n",
        id, CO(sb->Finish()));
    fprintf(f, "#%d=VERTEX_POINT('',#%d);\n", id+1, id);
    int lastFinish = id + 1, prevFinish = lastFinish;
    id += 2;

    for(sb = loop->l.First(); sb; sb = loop->l.NextAfter(sb)) {
        int curveId = ExportCurve(sb);

        int thisFinish;
        if(loop->l.NextAfter(sb) != NULL) {
            fprintf(f, "#%d=CARTESIAN_POINT('',(%.10f,%.10f,%.10f));\n",
                id, CO(sb->Finish()));
            fprintf(f, "#%d=VERTEX_POINT('',#%d);\n", id+1, id);
            thisFinish = id + 1;
            id += 2;
        } else {
            thisFinish = lastFinish;
        }

        fprintf(f, "#%d=EDGE_CURVE('',#%d,#%d,#%d,%s);\n",
            id, prevFinish, thisFinish, curveId, ".T.");
        fprintf(f, "#%d=ORIENTED_EDGE('',*,*,#%d,.T.);\n",
            id+1, id);

        int oe = id+1;
        listOfTrims.Add(&oe);
        id += 2;

        prevFinish = thisFinish;
    }

    fprintf(f, "#%d=EDGE_LOOP('',(", id);
    int *oe;
    for(oe = listOfTrims.First(); oe; oe = listOfTrims.NextAfter(oe)) {
        fprintf(f, "#%d", *oe);
        if(listOfTrims.NextAfter(oe) != NULL) fprintf(f, ",");
    }
    fprintf(f, "));\n");

    int fb = id + 1;
        fprintf(f, "#%d=%s('',#%d,.T.);\n",
            fb, inner ? "FACE_BOUND" : "FACE_OUTER_BOUND", id);

    id += 2;
    listOfTrims.Clear();

    return fb;
}
Example #17
0
size_t IStream::ReadAllLinesTo(List<WHeapString>& outLines, size_t maxCount/*=1024*/, bool isTrim/*=true*/, bool ignoreEmptyLine/*=true*/)const
{
	size_t count = 0;
	WHeapString temp;
	temp.ReserveLength(maxCount);
	while (true)
	{
		temp.Clear();
		size_t readCount = ReadLineToString(temp);
		count += readCount;
		BREAK_IF_ZERO(readCount);
		if (ignoreEmptyLine)
		{
			CONTINUE_IF_EMPTY(temp);
		}

		if (isTrim)
		{
			temp.TrimAll();
		}
		outLines.Add(temp);
		temp.ForceSetLength(0);
	}
	return count;
}
Example #18
0
List<Triangle> Mesh::GetTris(){
	List<Triangle> triangles;
	for (int i = 0; i < numFaces; ++i){
		// Just copy shit from it
		MeshFace * f = &faces[i];
		assert((f->numVertices <= 4 || f->numVertices >= 3) && "Bad vertices count in faces");

		Vector3f p1 = vertices[f->vertices[0]],
			p2 = vertices[f->vertices[1]],
			p3 = vertices[f->vertices[2]];

		if (f->numVertices == 4){
			assert(false && "faces has quads!");
// 			Vector3f p4 = vertices[faces->vertices[3]];
// 			Quad * quad = new Quad();
// 			quad->Set4Points(p1, p2, p3, p4);
// 			quads.Add(quad);
		}
		else if (f->numVertices == 3){
			Triangle tri;
			tri.Set3Points(p1, p2, p3);
			triangles.Add(tri);
		}
	}
	assert(triangles.Size() > 0);
	return triangles;
}
Example #19
0
		List<ImportPath> PipelineSymbol::FindImportOperatorChain(String worldSrc, String worldDest)
		{
			List<ImportPath> resultPathes;
			if (worldSrc == worldDest)
				return resultPathes;
			List<ImportPath> pathes, pathes2;
			pathes.Add(ImportPath());
			pathes[0].Nodes.Add(ImportPath::Node(worldSrc, nullptr));
			while (pathes.Count())
			{
				pathes2.Clear();
				for (auto & p : pathes)
				{
					String world0 = p.Nodes.Last().TargetWorld;
					for (auto op : SyntaxNode->ImportOperators)
					{
						if (op->SourceWorld.Content == world0)
						{
							ImportPath np = p;
							np.Nodes.Add(ImportPath::Node(op->DestWorld.Content, op.Ptr()));
							if (op->DestWorld.Content == worldDest)
								resultPathes.Add(np);
							else
								pathes2.Add(np);
						}
					}
				}
				pathes.SwapWith(pathes2);
			}
			return resultPathes;
		}
Example #20
0
		List<String>& PipelineSymbol::GetWorldTopologyOrder()
		{
			if (WorldTopologyOrder.Count() != 0)
				return WorldTopologyOrder;
			List<String> rs;
			HashSet<String> rsSet;
			bool changed = true;
			while (changed)
			{
				changed = false;
				for (auto & w : WorldDependency)
				{
					if (!rsSet.Contains(w.Key))
					{
						bool canAdd = true;
						for (auto & dw : w.Value)
							if (!rsSet.Contains(dw))
							{
								canAdd = false;
								break;
							}
						if (canAdd)
						{
							rsSet.Add(w.Key);
							rs.Add(w.Key);
							changed = true;
						}
					}
				}
			}
			WorldTopologyOrder = _Move(rs);
			return WorldTopologyOrder;
		}
Example #21
0
// Тестовый пример
void main()
{
    // Создаем объект класса List
    List lst;

    // Тестовая строка
    char s[] = "Hello, World !!!\n";
    // Выводим строку
    cout << s << "\n\n";
    // Определяем длину строки
    int len = strlen(s);
    // Загоняем строку в список
    for(int i = 0; i < len; i++)
        lst.Add(s[i]);
    // Распечатываем содержимое списка
    lst.Print();
    // Удаляем три элемента списка
    lst.Del();
    lst.Del();
    lst.Del();
    //Распечатываем содержимое списка
    lst.Print();

    //Вставляем 3-й символ, согласно нумерации массива с нуля
    lst.Insert('+',2);
    lst.Print();

    //удаляем 3-й символ
    lst.Delete(2);
    lst.Print();

    //находим позицию элемента 'l'
    cout<<"First position of 'l': "<<lst.Search('l')<<endl<<endl;
}
Example #22
0
/// Sorts by assigned values.
void SortStrings(List<String> & listToSort, bool debugPrint /*= false*/)
{
	//// Sort the LIST!
	List<String> sorted;
	List<Sortable*> unsortedList, sortedList;

	/// copy pointers of all strings.
	for (int i = 0; i < listToSort.Size(); ++i)
	{
		unsortedList.Add((Sortable*)(&listToSort[i]));
	}

	// Assign them sorting values.
	InsertionSort insertionSort;
	insertionSort.Sort(unsortedList, sortedList, true);
	for (int i = 0; i < sortedList.Size(); ++i)
	{
		String & string = *(String*)sortedList[i];	
		if (debugPrint)
			std::wcout<<"\nSorted list "<<i<<": "<<string;
		sorted.Add(string);
	}
	// Copy list.
	listToSort = sorted;
}
Example #23
0
void MessageManager::ProcessMessages()
{
	/// Fetch available messages, then process them later, or lese mutexes will deadlock if trying to process the messages while locked with e.g. the graphics thread.
    msgQueueMutex.Claim(-1);
	List<Message*> messagesToProcess;
	// Clear it.
	while(messageQueue.Size())
	{
		messagesToProcess = messageQueue;
		messageQueue.Clear();
	}
	/// Fetch all delayed messages too.
	Time now = Time::Now();
	for (int i = 0; i < delayedMessages.Size(); ++i)
	{
		Message * mes = delayedMessages[i];
		if (mes->timeToProcess < now)
		{
			delayedMessages.Remove(mes);
			messagesToProcess.Add(mes);
			--i;
			continue;
		}
	}
	msgQueueMutex.Release();

	// And then process them.
	for (int i = 0; i < messagesToProcess.Size(); ++i)
	{
		Message * message = messagesToProcess[i];
		ProcessMessage(message);	
	}
	messagesToProcess.ClearAndDelete();
}
Example #24
0
	static void Parse(const Regex& regexEec, vint order, const WString& electron, vint& notationOrder, WString& notationName, List<ElementElectron>& ecs)
	{
		if(order<=2)
		{
			notationOrder=0;
			notationName=L"";
		}
		else if(order<=10)
		{
			notationOrder=2;
			notationName=L"[He]";
		}
		else if(order<=18)
		{
			notationOrder=10;
			notationName=L"[Ne]";
		}
		else if(order<=36)
		{
			notationOrder=18;
			notationName=L"[Ar]";
		}
		else if(order<=54)
		{
			notationOrder=36;
			notationName=L"[Kr]";
		}
		else if(order<=86)
		{
			notationOrder=54;
			notationName=L"[Xe]";
		}
		else
		{
			notationOrder=86;
			notationName=L"[Rn]";
		}

		ecs.Clear();
		RegexMatch::List matches;
		regexEec.Search(electron, matches);
		FOREACH(Ptr<RegexMatch>, match, matches)
		{
			ElementElectron ec;
			ec.level=wtoi(match->Groups()[L"level"].Get(0).Value());
			ec.type=match->Groups()[L"type"].Get(0).Value()[0];
			ec.count=wtoi(match->Groups()[L"count"].Get(0).Value());
			ec.typeOrder=-1;

			switch(ec.type)
			{
			case L's': ec.typeOrder=0; break;
			case L'p': ec.typeOrder=1; break;
			case L'd': ec.typeOrder=2; break;
			case L'f': ec.typeOrder=3; break;
			}

			ecs.Add(ec);
		}
Example #25
0
	List<ShaderLibFile> CompileUnits(Spire::Compiler::CompileResult & compileResult,
		ShaderCompiler * compiler, List<CompileUnit> & units,
		Spire::Compiler::CompileOptions & options)
	{
		List<ShaderLibFile> resultFiles;
		List<ImportOperatorHandler*> importHandlers;
		List<ExportOperatorHandler*> exportHandlers;
		CreateGLSLImportOperatorHandlers(importHandlers);
		CreateGLSLExportOperatorHandlers(exportHandlers);
		for (auto handler : exportHandlers)
			compiler->RegisterExportOperator(L"glsl", handler);
		for (auto handler : importHandlers)
			compiler->RegisterImportOperator(L"glsl", handler);
		try
		{
			if (compileResult.ErrorList.Count() == 0)
				compiler->Compile(compileResult, units, options);
			DestroyImportOperatorHanlders(importHandlers);
			DestroyExportOperatorHanlders(exportHandlers);
		}
		catch (...)
		{
			DestroyImportOperatorHanlders(importHandlers);
			DestroyExportOperatorHanlders(exportHandlers);
			throw;
		}
		if (compileResult.Success)
		{
			if (options.Mode == CompilerMode::ProduceShader)
			{
				EnumerableDictionary<String, ShaderLibFile> shaderLibs;
				for (auto file : compileResult.CompiledSource)
				{
					auto shaderName = Path::GetFileNameWithoutEXT(file.Key);
					ShaderLibFile * libFile = shaderLibs.TryGetValue(shaderName);
					if (!libFile)
					{
						shaderLibs.Add(shaderName, ShaderLibFile());
						libFile = shaderLibs.TryGetValue(shaderName);
						libFile->MetaData.ShaderName = shaderName;
					}
					libFile->Sources = file.Value;
				}
				for (auto & libFile : shaderLibs)
				{
					for (auto & shader : compileResult.Program->Shaders)
					{
						if (shader->MetaData.ShaderName == libFile.Key)
						{
							// fill in meta data
							libFile.Value.MetaData = shader->MetaData;
						}
					}
					resultFiles.Add(libFile.Value);
				}
			}
		}
		return resultFiles;
	}
Example #26
0
int Node::AddVector(VECTOR3 &v)
{
	for (int n=0;n < m_vertices.GetNum();n++)
	{
		if (v == m_vertices[n])
			return n;
	}
	return m_vertices.Add(v);
}
Example #27
0
		List<std::string> Split(const std::string &s, char delim) {
			List<std::string> elems;
			std::stringstream ss(s);
			std::string item;
			while (std::getline(ss, item, delim)) {
				elems.Add(item);
			}
			return elems;
		}
Example #28
0
int CVLinePersistence::Process(CVPipeline * pipe)
{
	previousFramesLines.Add(pipe->lines);
	if (previousFramesLines.Size() > maxFrames->GetInt())
	{
		previousFramesLines.RemoveIndex(0, ListOption::RETAIN_ORDER);
	}

	/// Temporary lines list.
	List<Line> lines;

	/// For each frame..
	for (int i = 0; i < pipe->lines.Size(); ++i)
	{
		List<Line> & frameLines = previousFramesLines[i];	

		/// Look at each line...
		for (int j = 0; j < frameLines.Size(); ++j)
		{
			Line & line = frameLines[j];
	
			/// And compare it to identified lines within a temporary list.
			bool foundIt = false;
			for (int k = 0; k < lines.Size(); ++k)
			{
				Line & mergedLine = lines[k];
				/// Is it there?
				bool equal = false;
				float dist = (line.start - mergedLine.start).Length();	
				if (dist < maxDistance->GetFloat())
					equal = true;
				if (equal)
				{
					/// Then merge it.
					foundIt = true;
					mergedLine.Merge(line);
				}
			}
			
			/// If not?
			if (!foundIt)
			{
				/// Then add it to the list of identified lines.
				lines.Add(line);
			}
		}
	}
	/// At the end, all lines should have been either added or merged together with other lines.

	/// Now a final filtering can be made to remove those lines with least weight (least merges), if wanted.

	/// Output the smoooothed liiines to the pipeline.
	pipe->lines = lines;

	returnType = CVReturnType::CV_LINES;
	return returnType;
}
Example #29
0
void SearchDirectoriesAndFiles(const WString& path, List<WString>& directories, List<WString>& files)
{
	// Use FindFirstFile, FindNextFile and FindClose to enumerate all directories and files
	WIN32_FIND_DATA findData;
	HANDLE findHandle=INVALID_HANDLE_VALUE;

	while(true)
	{
		if(findHandle==INVALID_HANDLE_VALUE)
		{
			WString searchPath=path+L"\\*";
			findHandle=FindFirstFile(searchPath.Buffer(), &findData);
			if(findHandle==INVALID_HANDLE_VALUE)
			{
				break;
			}
		}
		else
		{
			BOOL result=FindNextFile(findHandle, &findData);
			if(result==0)
			{
				FindClose(findHandle);
				break;
			}
		}

		if(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			if(wcscmp(findData.cFileName, L".")!=0 && wcscmp(findData.cFileName, L"..")!=0)
			{
				directories.Add(findData.cFileName);
			}
		}
		else
		{
			files.Add(findData.cFileName);
		}
	}

	Func<vint(WString a, WString b)> comparer=[](WString a, WString b){return _wcsicmp(a.Buffer(), b.Buffer());};
	CopyFrom(directories, From(directories).OrderBy(comparer));
	CopyFrom(files, From(files).OrderBy(comparer));
}
Example #30
0
List<int> StringListToIntList(List<String> & stringList) 
{
	List<int> ints;
	for (int i = 0; i < stringList.Size(); ++i)
	{
		float f = stringList[i].ParseInt();
		ints.Add(f);
	}
	return ints;
}