void TrackingKymoView::DeleteDiffTData(std::set<unsigned int> difft_selection) { std::set<unsigned int>::iterator sel_iter; for(sel_iter = difft_selection.begin(); sel_iter!= difft_selection.end(); ++sel_iter) { unsigned int vtk_cell_id = *sel_iter; TraceLine *tline = reinterpret_cast<TraceLine*>(m_tobj->hashc[vtk_cell_id]); std::cout<<"deleting cell:"<<vtk_cell_id<<" with id: "<<tline->GetId()<<std::endl; TraceBit tb1 = tline->subtrace_hash[vtk_cell_id].at(0); TraceBit tb2 = tline->subtrace_hash[vtk_cell_id].at(1); int maxtime = MAX(tb1.time,tb2.time); std::vector<TraceLine*>* trace_lines = m_tobj->GetTraceLinesPointer(); std::vector<TraceLine*>::iterator trace_lines_iter; for(trace_lines_iter = trace_lines->begin() ;trace_lines_iter!= trace_lines->end(); ++trace_lines_iter) { if(tline->GetId() == (*trace_lines_iter)->GetId()) { int new_id = this->GetMaxId()+1; trace_lines->erase(trace_lines_iter); TraceLine::TraceBitsType::iterator tbit_iter = tline->GetTraceBitIteratorBegin(); TraceLine * new_tline1 = new TraceLine(); TraceLine * new_tline2 = new TraceLine(); ObjectSelection::Point point; while(tbit_iter != tline->GetTraceBitIteratorEnd()) { if((*tbit_iter).time < maxtime) { new_tline1->AddTraceBit(*tbit_iter); } else { point.id = tbit_iter->id; point.time = tbit_iter->time; (*tbit_iter).id = new_id; point.new_id = new_id; points_from_delete.push_back(point); new_tline2->AddTraceBit(*tbit_iter); } ++tbit_iter; } trace_lines->push_back(new_tline1); new_tline2->SetId(new_id); trace_lines->push_back(new_tline2); break; } } } }
bool TrackingKymoView::IsValidNodeConnection(void) { if(NSelection.empty()|| NSelection.size()!=2) return false; std::set<unsigned int>::iterator node_vtk_ids_iter; std::vector<unsigned int> node_ids; for(node_vtk_ids_iter = NSelection.begin(); node_vtk_ids_iter!= NSelection.end(); ++node_vtk_ids_iter) { TraceLine *tline = reinterpret_cast<TraceLine*>(m_tobj->hashp[*node_vtk_ids_iter]); int tbit_time = tline->points_hash[*node_vtk_ids_iter].time; TraceLine::TraceBitsType::iterator tbit_iter = tline->GetTraceBitIteratorBegin(); bool endNode = true; bool beginNode = true; std::vector<bool> tmp_vector; //bool singleNode = false; while(tbit_iter!=tline->GetTraceBitIteratorEnd()) { if(tbit_iter->time > tbit_time) endNode = false; else if (tbit_iter->time < tbit_time) beginNode = false; ++tbit_iter; } tline->points_hash[*node_vtk_ids_iter].end = endNode; tline->points_hash[*node_vtk_ids_iter].begin = beginNode; node_ids.push_back(*node_vtk_ids_iter); } // now compare the two nodes: if(node_ids.size()!=2) { printf("something is up with the selection\n"); return false; } TraceBit tbit1 = (reinterpret_cast<TraceLine*>(m_tobj->hashp[node_ids.at(0)]))->points_hash[node_ids.at(0)]; TraceBit tbit2 = (reinterpret_cast<TraceLine*>(m_tobj->hashp[node_ids.at(1)]))->points_hash[node_ids.at(1)]; bool isvalid = false; // one is at end and the other is at begin: if(tbit1.end == true && tbit1.begin == false && tbit2.end == false && tbit2.begin == true) { int timediff = (tbit2.time - tbit1.time); if( timediff >0 && timediff< 3) isvalid = true; } else if (tbit1.end == false && tbit1.begin == true && tbit2.end == true && tbit2.begin == false) { int timediff = (tbit1.time - tbit2.time); if( timediff >0 && timediff< 4) isvalid = true; } // one is at end or begin and the other is a single node: else if (tbit1.end == true && tbit1.begin == true && tbit2.end == true && tbit2.begin == false) { int timediff = (tbit1.time - tbit2.time); if( timediff >0 && timediff< 3) isvalid = true; } else if (tbit1.end == true && tbit1.begin == true && tbit2.end == false && tbit2.begin == true) { int timediff = (tbit2.time - tbit1.time); if( timediff >0 && timediff< 3) isvalid = true; } else if (tbit1.end == false && tbit1.begin == true && tbit2.end == true && tbit2.begin == true) { int timediff = (tbit1.time - tbit2.time); if( timediff >0 && timediff< 3) isvalid = true; } else if (tbit1.end == true && tbit1.begin == false && tbit2.end == true && tbit2.begin == true) { int timediff = (tbit2.time - tbit1.time); if( timediff >0 && timediff< 3) isvalid = true; } return isvalid; }