void ReduceSurfaceTriangulation::operate()
{
  setStretchingFactor(1.0);
  prepare();
  //writeGrid(m_Grid, "take1");
  updateNodeInfo();
  //writeGrid(m_Grid, "take2");
  pass1();
  //pass2();
  createIndices(m_Grid);
  updateNodeInfo();
  computeMeshDensity();
}
Ejemplo n.º 2
0
void updateNodeInfo(TreeNode *treeNode, int extraItems, int extraItemsetNumber)
{
	NodeVector::iterator it, endit;

	treeNode->Items += extraItems;
	treeNode->ItemsetNumber += extraItemsetNumber;
	for (it=treeNode->Children->begin(), endit=treeNode->Children->end(); it != endit; it++) {
		if ((*it)->Parent == treeNode)
				updateNodeInfo((*it), extraItems, extraItemsetNumber);
	}
}
Ejemplo n.º 3
0
void DeletePickedPoint::operate()
{
    vtkIdType id_node = GuiMainWindow::pointer()->getPickedPoint();
    cout << "You picked " << id_node << endl;
    if( id_node<0  || GuiMainWindow::pointer()->getPickedObject()!=1 ) {
        QApplication::restoreOverrideCursor();
        EG_ERR_RETURN("Error: No node picked.");
    }

    char type;
    QVector <vtkIdType> PSP;

    //IMPORTANT: to make sure only unselected nodes become fixed (redundant with previous line, but more readable)
    this->m_BoundaryCodes = GuiMainWindow::pointer()->getAllBoundaryCodes();
    qWarning()<<"m_BoundaryCodes="<<m_BoundaryCodes;

    updateNodeInfo();

    QMessageBox msgBox;
    msgBox.setText("Delete point?");
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    switch (msgBox.exec()) {
    case QMessageBox::Yes:
        cout<<"yes was clicked"<<endl;
        DeletePoint(id_node);
        break;
    case QMessageBox::No:
        cout<<"no was clicked"<<endl;
        cout<<"=== Topological neighbours ==="<<endl;
        PSP = getPotentialSnapPoints(id_node);
        cout<<"id_node="<<id_node<<" PSP="<<PSP<<endl;

        cout<<"=== NODE TYPE ==="<<endl;
        type = getNodeType(id_node);
        cout<<"id_node="<<id_node<<" is of type="<<(int)type<<"="<<VertexType2Str(type)<<endl;

        break;
    default:
        // should never be reached
        break;
    }

}
Ejemplo n.º 4
0
int MainUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updatePointView((*reinterpret_cast< hash_map<int,Entity*>*(*)>(_a[1]))); break;
        case 1: updateNodeInfo((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 2: newProject(); break;
        case 3: quit(); break;
        case 4: showAllObjects(); break;
        case 5: saveCurrentScreen(); break;
        case 6: itemView(); break;
        case 7: editorView(); break;
        case 8: filterPtsByOBAFilter(); break;
        case 9: classifyObjs(); break;
        case 10: resetEntitysType(); break;
        case 11: extractBuildingManual(); break;
        case 12: exportBuilding(); break;
        case 13: autoRun(); break;
        case 14: datasetInfo(); break;
        case 15: importDTM(); break;
        case 16: importPoint(); break;
        case 17: importRectangle(); break;
        case 18: importTIN(); break;
        case 19: text2las(); break;
        case 20: las2text(); break;
        case 21: about(); break;
        case 22: showMousePos((*reinterpret_cast< const int(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break;
        case 23: identifyObject((*reinterpret_cast< const int(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break;
        case 24: cancelBuilding((*reinterpret_cast< const int(*)>(_a[1]))); break;
        case 25: useEntityParam((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 26;
    }
    return _id;
}
Ejemplo n.º 5
0
void Pathfinder::step()
{
    if (m_PathFound) return;

    //std::cout << "\nStepping\n";

    if (!m_Map.inMapBounds(m_SourceNodePosition) || //Make sure the source and target are valid
        !m_Map.inMapBounds(m_TargetNodePosition))
    {
        //std::cout << "Source or Target is invalid\n";
        std::cout << m_SourceNodePosition.x << ", " << m_SourceNodePosition.y << "\n";
        std::cout << m_TargetNodePosition.x << ", " << m_TargetNodePosition.y << "\n";
        return;
    }

    //std::cout << "Source and Target are valid\n";

    if (m_OpenList.size() == 0 &&
        m_ClosedList.size() == 0)
    {
        //std::cout << "Adding source node\n";
        m_OpenList.push_back(m_SourceNodePosition);
    }
    else if ((m_ClosedList.size() != 0 && //make sure there is an object at the back
             m_ClosedList.back() == m_TargetNodePosition) || //If the target is in the closed list then we found a path
             m_OpenList.size() == 0) //If the open list is empty then we have checked the entire map and not found a path
    {
        //std::cout << "Path found\n";

        //Reset the nodes we have modified
        for (sf::Vector2i pos : m_ClosedList)
        {
            m_Map.getTile(pos).getNode().resetCosts();
            m_Map.getTile(pos).getNode().resetState();
        }

        for (sf::Vector2i pos : m_OpenList)
        {
            m_Map.getTile(pos).getNode().resetCosts();
            m_Map.getTile(pos).getNode().resetState();
        }

        //Draw the path
        sf::Vector2i parentPos = m_ClosedList.back();
        while (m_Map.inMapBounds(parentPos))
        {
            //std::cout << "Parent Position = [" << parentPos.x << ", " << parentPos.y << "]\n";
            m_Map.getTile(parentPos).getNode().setState(NodeState::ClosedList);
            parentPos = m_Map.getTile(parentPos).getNode().getParentNodePosition();
        }

        //Draw source and target
        m_Map.getTile(m_ClosedList.front()).getNode().setState(NodeState::Source);
        m_Map.getTile(m_ClosedList.back()).getNode().setState(NodeState::Target);

        m_PathFound = true;
    }
    else
    {
        //std::cout << "Finding lowest scored node\n";
        //Find node in open list with lowest score, and move it to closed list.
        unsigned lowestScoreNodeIndex = getLowestScoreNodeIndex(m_OpenList);
        m_ClosedList.push_back(m_OpenList[lowestScoreNodeIndex]);

        {
            Node& n = m_Map.getTile(m_ClosedList.back()).getNode();
            if (n.getState() != NodeState::Source && //If the node isn't the source or target node;
                n.getState() != NodeState::Target)
            {
                n.setState(NodeState::ClosedList);
            }
        }

        m_OpenList.erase(m_OpenList.begin() + lowestScoreNodeIndex);

        //std::cout << "Finding adjacent nodes\n";
        //Find adjacent nodes of current node
        auto adjNodePoses = getAdjacentNodes(m_ClosedList.back());
        for (sf::Vector2i& nodePos : adjNodePoses)
        {
            if (m_Map.getTile(nodePos).getState() != TileState::Wall && //Can be walked on
                std::find(m_ClosedList.begin(), m_ClosedList.end(), nodePos) == m_ClosedList.end()) //is not on the closed list
            {
                Node& n = m_Map.getTile(nodePos).getNode();

                if (std::find(m_OpenList.begin(), m_OpenList.end(), nodePos) == m_OpenList.end()) //is not on the open list
                {
                    //std::cout << "Found undiscovered valid node\n";
                    //Recalculated costs and set parent node
                    updateNodeInfo(nodePos, m_ClosedList.back());

                    if (n.getState() != NodeState::Source && //Make sure we don't override the source or target tile.
                        n.getState() != NodeState::Target)
                    {
                        n.setState(NodeState::OpenList);
                    }

                    m_OpenList.push_back(nodePos);
                }
                else if (n.getMovementCost() > calculateMovementCost(m_ClosedList.back(), nodePos))//this path to the node is shorter
                {
                    //std::cout << "Found better path\n";
                    //Recalculated costs and set parent node
                    updateNodeInfo(nodePos, m_ClosedList.back());
                }
            }
        }
    }
}
Ejemplo n.º 6
0
//int qqq;
int addSequence(struct PROJ_DB *pDB, TreeNode **currentLevelp, ReverseHashTable *reverseTable)
{
	TreeNode   *pNode, *qNode;
	TreeNode *currentLevel=*currentLevelp;

	ReverseMap pMap;
	ReverseHashTable::iterator it, endit;


	int ret, myNumOfItems;

	
	/*printf("SSN: %d Item: %d\n", ++qqq, pDB->Item);

	if (qqq == 20496) {
		printf("hello\n");
	}*/

	

	//myNumOfItems=pDB->NumOfItems + pDB->m_nMaxSup - pDB->m_nSup;
	myNumOfItems=pDB->NumOfItems + pDB->m_nMaxSup;
	//myNumOfItems=pDB->NumOfItems;

	/*if (myNumOfItems == 3378012)
			printf("GUGU\n");
	*/


	pMap=(*reverseTable).equal_range(myNumOfItems);
	for (it=pMap.first, endit=pMap.second; it != endit; it++) {
		pNode=(*it).second;
		if (pNode->Support != pDB->m_nMaxSup)
			continue;
		ret=isContained_DBSizeEqual(pDB, currentLevel, pNode);
		switch (ret) {
			case 0:
				continue;
			case 1:  //Backward SubPattern
				//(*(currentLevel->Children)).push_back(pNode);
				//(*(currentLevel->IntraChildren))[pDB->Item]=pNode;
				//qNode is a mirror of pNode, but has slight different
				//the major goal is to let closed_maxPruning much easier
				qNode= new TreeNode();
				qNode= currentLevel->AddChildWithoutChecking( pDB->Item, pDB->ItemIsIntra, pDB->m_nMaxSup);
				qNode->SetProjDBSize(myNumOfItems);
				qNode->Children=pNode->Children;
				return EQUAL_PROJECT_DB_SIZE;

			case -1: //Backward SuperPattern

				qNode= new TreeNode(pNode);
				updateOldNodeInfo(pNode->Parent, pNode, qNode);

				if (pDB->ItemIsIntra) {
					updateNodeInfo(pNode, 
								   currentLevel->Items - pNode->Parent->Items,
								   currentLevel->ItemsetNumber - pNode->Parent->ItemsetNumber);
					//checkNodeInfo(currentLevel);
					pNode->ItemIsIntra=true;
					pNode->Parent=currentLevel;
					(*(currentLevel->Children)).push_back(pNode);
					inplace_merge((*(currentLevel->Children)).begin(), (*(currentLevel->Children)).end()-1, 
								  (*(currentLevel->Children)).end(), TreeNodeLess );
				}
				else {
					updateNodeInfo(pNode, 
								   currentLevel->Items - pNode->Parent->Items,
								   currentLevel->ItemsetNumber - pNode->Parent->ItemsetNumber);
					//checkNodeInfo(currentLevel);
					//pNode->Parent->Children->erase(pNode);
					pNode->ItemIsIntra=false;
					pNode->Parent=currentLevel;
					(*(currentLevel->Children)).push_back(pNode);
					inplace_merge((*(currentLevel->Children)).begin(), (*(currentLevel->Children)).end()-1, 
								  (*(currentLevel->Children)).end(), TreeNodeLess );

				}
				
				//reverseTable->erase(it);
				//reverseTable->insert(ReverseHashTable::value_type(myNumOfItems, qNode));
					
				return EQUAL_PROJECT_DB_SIZE;
			default:
				break;
		}
	}
	
	zzz++;
	pNode= new TreeNode();
	pNode= currentLevel->AddChildWithoutChecking( pDB->Item, pDB->ItemIsIntra, pDB->m_nMaxSup);
	pNode->SetProjDBSize(myNumOfItems);
	(*currentLevelp)=pNode;
	reverseTable->insert(ReverseHashTable::value_type(myNumOfItems, pNode));

	return INEQUAL_PROJECT_DB_SIZE;

}