static inline void readAndPrintRequest(std::istream &in, std::ostream &out, Edge *currentEdge) { std::string tmp; in >> tmp; ci_string whatToPrint(tmp.c_str()); if (whatToPrint == ci_string("current")) { printEdge(out,currentEdge); } else if (whatToPrint == ci_string("left")) { printFace(out,currentEdge->Left()); } else if (whatToPrint == ci_string("right")) { printFace(out,currentEdge->Right()); } else { out << "Unknown print operation requested..." << std::endl; } }
void printFaces (const Mesh& mesh) { std::cout << "Faces:\n"; for (FaceConstIterator it = mesh.beginFaces (); it!=mesh.endFaces (); ++it) { printFace (mesh, *it); } }
int main(int argc, char** argv) { EmoEngineEventHandle eEvent = EE_EmoEngineEventCreate(); EmoStateHandle eState = EE_EmoStateCreate(); unsigned int userID = 0; float secs = 1; unsigned int datarate = 0; bool readytocollect = false; int state = 0; bool connected = true; long long count = 0; // Connect to the EE_Engine. if (EE_EngineConnect() != EDK_OK) { std::cout << "Could not connect to EEG" << std::endl; return 0; } std::string directory = argv[2]; std::string filename = argv[1]; filename = directory + filename + "-EEGLogger.csv"; std::cout << filename << std::endl; // were the file will be saved std::cout << "Start receiving EEG Data! Press any key to stop logging...\n" << std::endl; std::ofstream ofs(filename.c_str(),std::ios::trunc); ofs << header << std::endl; if(connected){ DataHandle hData = EE_DataCreate(); EE_DataSetBufferSizeInSec(secs); std::cout << "Buffer size in secs:" << secs << std::endl; while (!kbhit()){ state = EE_EngineGetNextEvent(eEvent); if(!printFace(count)){ break; } // print new face to make every 20 seconds if (state == EDK_OK){ EE_Event_t eventType = EE_EmoEngineEventGetType(eEvent); EE_EmoEngineEventGetUserId(eEvent, &userID); // Log the EmoState if it has been updated if (eventType == EE_UserAdded){ std::cout << "User added" << std::endl; EE_DataAcquisitionEnable(userID,true); readytocollect = true; } } if (readytocollect){ EE_DataUpdateHandle(0, hData); unsigned int nSamplesTaken=0; EE_DataGetNumberOfSample(hData,&nSamplesTaken); if (nSamplesTaken != 0) { double* data = new double[nSamplesTaken]; for (int sampleIdx=0 ; sampleIdx<(int)nSamplesTaken ; ++ sampleIdx) { for (int i = 0 ; i<sizeof(targetChannelList)/sizeof(EE_DataChannel_t) ; i++) { EE_DataGet(hData, targetChannelList[i], data, nSamplesTaken); ofs << data[sampleIdx] << ","; } ofs << std::endl; count++; } delete[] data; } } } ofs.close(); EE_DataFree(hData); } std::cout << "Disconnected" << std::endl; EE_EngineDisconnect(); EE_EmoStateFree(eState); EE_EmoEngineEventFree(eEvent); return 0; }
int main () { Mesh mesh; VertexIndexes vi; // Create a closed circle around vertex 0 // // 1 - 6 // // / \ / \ // // 2 - 0 - 5 // // \ / \ / // // 3 - 4 // vi.push_back (mesh.addVertex (MyVertexData (0))); vi.push_back (mesh.addVertex (MyVertexData (1))); vi.push_back (mesh.addVertex (MyVertexData (2))); vi.push_back (mesh.addVertex (MyVertexData (3))); vi.push_back (mesh.addVertex (MyVertexData (4))); vi.push_back (mesh.addVertex (MyVertexData (5))); vi.push_back (mesh.addVertex (6)); // Converted to MyVertexData vi.push_back (mesh.addVertex (7)); // Will not be connected -> isolated vertex mesh.addFace (vi[0], vi[1], vi[2]); mesh.addFace (vi[0], vi[2], vi[3]); mesh.addFace (vi[0], vi[3], vi[4]); mesh.addFace (vi[0], vi[4], vi[5]); mesh.addFace (vi[0], vi[5], vi[6]); mesh.addFace (0, 6, 1); // Converted to VertexIndex printVertexes (mesh); printFaces (mesh); ////////////////////////////////////////////////////////////////////////////// std::cout << "Outgoing half-edges of vertex 0:" << std::endl; OHEAVCC circ_oheav = mesh.getOutgoingHalfEdgeAroundVertexConstCirculator (vi[0]); const OHEAVCC circ_oheav_end = circ_oheav; do { std::cout << " " << circ_oheav->getOriginatingVertex (mesh) << " " << circ_oheav->getTerminatingVertex (mesh) << std::endl; ++circ_oheav; } while (circ_oheav!=circ_oheav_end); ////////////////////////////////////////////////////////////////////////////// std::cout << "Circulate around the boundary half-edges:" << std::endl; const HalfEdgeIndex& idx_he_boundary = mesh.getElement (vi[0]). getOutgoingHalfEdge (mesh). getTerminatingVertex (mesh). getOutgoingHalfEdgeIndex (); HEABCC circ_heab = mesh.getHalfEdgeAroundBoundaryConstCirculator (idx_he_boundary); const HEABCC circ_heab_end = circ_heab; do { std::cout << " " << circ_heab->getOriginatingVertex (mesh) << " " << circ_heab->getTerminatingVertex (mesh) << std::endl; ++circ_heab; } while (circ_heab!=circ_heab_end); ////////////////////////////////////////////////////////////////////////////// std::cout << std::endl << "Deleting face 1 and 4 ...\n"; std::cout << "(If the mesh is set to manifold further faces are removed automatically)\n\n"; mesh.deleteFace (FaceIndex (1)); mesh.deleteFace (4); // Converted to FaceIndex mesh.cleanUp (false); // Delete (true) or don't delete (false) isolated vertexes vi.clear (); // The vertex indexes are no longer synchronized with the mesh! printVertexes (mesh); printFaces (mesh); ////////////////////////////////////////////////////////////////////////// std::cout << "Circulate around all faces of vertex 0:\n"; FAVCC circ_fav = mesh.getFaceAroundVertexConstCirculator (mesh.frontVertexes ()); const FAVCC circ_fav_end = circ_fav; do { // Very important: Some half_edges are on the boundary // -> have an invalid face index if (circ_fav.isValid ()) { printFace (mesh, *circ_fav); } else { std::cout << " invalid face -> boundary half-edge\n"; } ++circ_fav; } while (circ_fav!=circ_fav_end); return (0); }