void ExodusModel::initializeParallel() { // Do all reading from exodus file on rank 0. if (!MPI::COMM_WORLD.Get_rank()) { getInitialization(); readCoordinates(); readNodalVariables(); } // Broadcast all scalars. mNumberDimension = utilities::broadcastInt(mNumberDimension); mNumberVertices = utilities::broadcastInt(mNumberVertices); mNumberElements = utilities::broadcastInt(mNumberElements); mNumberElementBlocks = utilities::broadcastInt(mNumberElementBlocks); mNumberNodeSets = utilities::broadcastInt(mNumberNodeSets); mNumberSideSets = utilities::broadcastInt(mNumberSideSets); // Broadcast all vectors. mNodalX = utilities::broadcastStdVecFromRoot(mNodalX); mNodalY = utilities::broadcastStdVecFromRoot(mNodalY); mNodalVariables = utilities::broadcastStdVecFromRoot(mNodalVariables); mNodalVariableNames = utilities::broadcastStringVecFromFroot(mNodalVariableNames); // Broadcast dimension specific components. if (mNumberDimension > 2) { mNodalZ = utilities::broadcastStdVecFromRoot(mNodalZ); } // Create KdTree on each processor. createKdTree(); }
void Object3D::load(istream &is){ string lineStr; int count = 0; while(!is.eof()){ getline(is, lineStr); cout << "Line: " << lineStr << endl; string::size_type pos = lineStr.find(ELEMENT_GROUPS, 0); if( pos != string::npos ) { count = readElementGroups(is); } pos = lineStr.find(INCIDENCE, 0); if( pos != string::npos ) { cout << "Read incidence " << count << endl; readIncidence(is, count); } pos = lineStr.find(COORDINATES, 0); if( pos != string::npos ) { cout << "Read coordinates " << count << endl; readCoordinates(is); } } }
void EFPFragment::processLine(QTextStream& textStream) { QString line = textStream.readLine().trimmed(); if (line.contains("fragment", Qt::CaseInsensitive)) { QStringList tokens(line.split(QRegExp("\\s+"), QString::SkipEmptyParts)); if (tokens.size() >= 2) m_name = tokens[1]; readCoordinates(textStream); } m_done = true; }
void CvrpFileReader::processLine(QStringList l_wordList, QString l_line) { switch (Utils::findEnumForKeyword(l_wordList[0])) { case Utils::e_keywords::NAME: readName(l_wordList); break; case Utils::e_keywords::COMMENT: readComment(l_line); break; case Utils::e_keywords::TYPE: readVrpType(l_wordList); break; case Utils::e_keywords::DIMENSION: readDimension(l_wordList); break; case Utils::e_keywords::EDGE_WEIGHT_TYPE: readEdgesType(l_wordList); break; case Utils::e_keywords::CAPACITY: readCapacity(l_wordList); break; case Utils::e_keywords::NODE_COORD_SECTION: readCoordinates(); break; case Utils::e_keywords::DEMAND_SECTION: readDemands(); break; case Utils::e_keywords::DEPOT_SECTION: readDepots(); break; case Utils::e_keywords::END: break; case Utils::e_keywords::EDGE_WEIGHT_FORMAT: case Utils::e_keywords::EDGE_DATA_FORMAT: case Utils::e_keywords::NODE_COORD_TYPE: case Utils::e_keywords::DISPLAY_DATA_TYPE: case Utils::e_keywords::EDGE_DATA_SECTION: case Utils::e_keywords::FIXED_EDGE_SECTION: case Utils::e_keywords::DISPLAY_DATA_SECTION: case Utils::e_keywords::TOUR_SECTION: case Utils::e_keywords::EDGE_WEIGHT_SECTION: case Utils::e_keywords::UNDEFINED: throw std::runtime_error(std::string("Unimplemented token!")); default: throw std::runtime_error(std::string("Undefined token!")); } }
paint::paint(QWidget *parent) : QWidget(parent), ui(new Ui::paint) { ui->setupUi(this); scene = new paintScene(); ui->graphicsView->setScene(scene); timer = new QTimer(); connect(timer, &QTimer::timeout, this, &paint::slotTimer); timer->start(100); connect(scene, SIGNAL(mouseMoved()), this, SLOT(readCoordinates())); connect(ui->StartButton, SIGNAL(clicked()), this, SLOT(printCoordinates())); connect(ui->ClearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(this, SIGNAL(pointReached(int, point_t *)), scene, SLOT(selectPoint(int, point_t *))); }
void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annotationXml) { ossimRefPtr<ossimXmlDocument> xmlDoc = new ossimXmlDocument(annotationXml); const ossimXmlNode & xmlRoot = *xmlDoc->getRoot(); //Parse specific metadata for Sentinel1 //TODO add as members to the Sentinel1SarSensorModel const std::string & product_type = getTextFromFirstNode(xmlRoot, "adsHeader/productType"); const std::string & mode = getTextFromFirstNode(xmlRoot, "adsHeader/mode"); const std::string & swath = getTextFromFirstNode(xmlRoot, "adsHeader/swath"); const std::string & polarisation = getTextFromFirstNode(xmlRoot, "adsHeader/polarisation"); theProductType = ProductType(product_type); // First, lookup position/velocity records std::vector<ossimRefPtr<ossimXmlNode> > xnodes; xmlDoc->findNodes("/product/generalAnnotation/orbitList/orbit",xnodes); //TODO uncomment and adapt following code from s1_inverse to fill //SarSensorModel structure for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode) { OrbitRecordType orbitRecord; // Retrieve acquisition time orbitRecord.azimuthTime = getTimeFromFirstNode(**itNode, attTime); // Retrieve ECEF position ossimXmlNode const& positionNode = getExpectedFirstNode(**itNode, attPosition); orbitRecord.position[0] = getDoubleFromFirstNode(positionNode, attX); orbitRecord.position[1] = getDoubleFromFirstNode(positionNode, attY); orbitRecord.position[2] = getDoubleFromFirstNode(positionNode, attZ); // Retrieve ECEF velocity ossimXmlNode const& velocityNode = getExpectedFirstNode(**itNode, attVelocity); orbitRecord.velocity[0] = getDoubleFromFirstNode(velocityNode, attX); orbitRecord.velocity[1] = getDoubleFromFirstNode(velocityNode, attY); orbitRecord.velocity[2] = getDoubleFromFirstNode(velocityNode, attZ); //Add one orbits record theOrbitRecords.push_back(orbitRecord); } //Parse the near range time (in seconds) theNearRangeTime = getDoubleFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/slantRangeTime"); //Parse the range sampling rate theRangeSamplingRate = getDoubleFromFirstNode(xmlRoot, "generalAnnotation/productInformation/rangeSamplingRate"); //Parse the range resolution theRangeResolution = getDoubleFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/rangePixelSpacing"); //Parse the radar frequency theRadarFrequency = getDoubleFromFirstNode(xmlRoot, "generalAnnotation/productInformation/radarFrequency"); //Parse azimuth time interval const double azimuthTimeInterval = getDoubleFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/azimuthTimeInterval"); #if defined(USE_BOOST_TIME) theAzimuthTimeInterval = boost::posix_time::precise_duration(azimuthTimeInterval * 1000000.); #else theAzimuthTimeInterval = seconds(azimuthTimeInterval); #endif ossimNotify(ossimNotifyLevel_DEBUG) << "theAzimuthTimeInterval " << theAzimuthTimeInterval.total_microseconds() << "us\n"; // Now read burst records as well xnodes.clear(); xmlDoc->findNodes("/product/swathTiming/burstList/burst",xnodes); if(xnodes.empty()) { BurstRecordType burstRecord; burstRecord.startLine = 0; burstRecord.azimuthStartTime = getTimeFromFirstNode(xmlRoot,"imageAnnotation/imageInformation/productFirstLineUtcTime"); ossimNotify(ossimNotifyLevel_DEBUG)<< burstRecord.azimuthStartTime<<'\n'; burstRecord.azimuthStopTime = getTimeFromFirstNode(xmlRoot,"imageAnnotation/imageInformation/productLastLineUtcTime"); burstRecord.endLine = getTextFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/numberOfLines").toUInt16()-1; theBurstRecords.push_back(burstRecord); } else { const unsigned int linesPerBurst = xmlRoot.findFirstNode("swathTiming/linesPerBurst")->getText().toUInt16(); unsigned int burstId(0); for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode,++burstId) { BurstRecordType burstRecord; const ossimSarSensorModel::TimeType azTime = getTimeFromFirstNode(**itNode, attAzimuthTime); ossimString const& s = getTextFromFirstNode(**itNode, attFirstValidSample); long first_valid(0), last_valid(0); bool begin_found(false), end_found(false); std::vector<ossimString> ssp = s.split(" "); for (std::vector<ossimString>::const_iterator sIt = ssp.begin(), e = ssp.end() ; sIt != e && !end_found ; ++sIt ) { if(!begin_found) { if(*sIt!="-1") { begin_found = true; } else { ++first_valid; } ++last_valid; } else { if(!end_found && *sIt=="-1") { end_found = true; } else { ++last_valid; } } } burstRecord.startLine = burstId*linesPerBurst + first_valid; burstRecord.endLine = burstId*linesPerBurst + last_valid; burstRecord.azimuthStartTime = azTime + (first_valid*theAzimuthTimeInterval); burstRecord.azimuthStopTime = azTime + (last_valid*theAzimuthTimeInterval); theBurstRecords.push_back(burstRecord); } } if(isGRD()) { readCoordinates(*xmlDoc, "/product/coordinateConversion/coordinateConversionList/coordinateConversion", attSr0, attSrgrCoefficients, theSlantRangeToGroundRangeRecords); readCoordinates(*xmlDoc, "/product/coordinateConversion/coordinateConversionList/coordinateConversion", attGr0, attGrsrCoefficients, theGroundRangeToSlantRangeRecords); } xnodes.clear(); xmlDoc->findNodes("/product/geolocationGrid/geolocationGridPointList/geolocationGridPoint",xnodes); for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode) { GCPRecordType gcpRecord; // Retrieve acquisition time gcpRecord.azimuthTime = getTimeFromFirstNode(**itNode, attAzimuthTime); gcpRecord.slantRangeTime = getDoubleFromFirstNode(**itNode, attSlantRangeTime); gcpRecord.imPt.x = getDoubleFromFirstNode(**itNode, attPixel); // In TOPSAR products, GCPs are weird (they fall in black lines // between burst. This code allows moving them to a valid area of // the image. if(theBurstRecords.size()>2) { ossimSarSensorModel::TimeType acqStart; bool burstFound(false); unsigned long acqStartLine(0); for(std::vector<BurstRecordType>::reverse_iterator bIt = theBurstRecords.rbegin();bIt!=theBurstRecords.rend() && !burstFound;++bIt) { if(gcpRecord.azimuthTime >= bIt->azimuthStartTime && gcpRecord.azimuthTime < bIt->azimuthStopTime) { burstFound = true; acqStart = bIt->azimuthStartTime; acqStartLine = bIt->startLine; } } if(!burstFound) { if(gcpRecord.azimuthTime < theBurstRecords.front().azimuthStartTime) { acqStart = theBurstRecords.front().azimuthStartTime; acqStartLine = theBurstRecords.front().startLine; } else if (gcpRecord.azimuthTime >= theBurstRecords.front().azimuthStopTime) { acqStart = theBurstRecords.back().azimuthStartTime; acqStartLine = theBurstRecords.back().startLine; } } const DurationType timeSinceStart = gcpRecord.azimuthTime - acqStart; gcpRecord.imPt.y= timeSinceStart/theAzimuthTimeInterval + acqStartLine; ossimNotify(ossimNotifyLevel_DEBUG) << "timeSinceStart: " << timeSinceStart << " = " << gcpRecord.azimuthTime << " - " << acqStart << " (azTime-acqStart)"<< "\n"; ossimNotify(ossimNotifyLevel_DEBUG) << "imPt_y: " << gcpRecord.imPt.y << " = " << timeSinceStart.total_microseconds() << "/" << theAzimuthTimeInterval.total_microseconds() << "+" << acqStartLine << "\n"; } else { gcpRecord.imPt.y = getDoubleFromFirstNode(**itNode, attLine);; } ossimGpt geoPoint; gcpRecord.worldPt.lat = getDoubleFromFirstNode(**itNode, attLatitude); gcpRecord.worldPt.lon = getDoubleFromFirstNode(**itNode, attLongitude); gcpRecord.worldPt.hgt = getDoubleFromFirstNode(**itNode, attHeight); theGCPRecords.push_back(gcpRecord); } this->optimizeTimeOffsetsFromGcps(); }
int main(){ int option; do{ printMenuOptions(); scanf("%d",&option); switch(option) { case 0://Exit break; case 1://formula değerlendirme { printf("\nLutfen tablonun degeri giriniz :\n"); printf("\t \"default\" de girdiribilirsiniz :\n>"); scanf("%s",girdi); if(strcmp(girdi,"default")==0) strcpy(girdi,"4,3,10,34,37,=A1+B1+C1,40,17,34,=A2+B2+C2,=A1+A2,=B1+B2,=C1+C2,=D1+D2"); createTableFromString(girdi); calculateAndPrint(); printf("\n\n\n"); break; } case 2://satir ekleme { if(Height==MAX_ROWS){ printf("\nDaha fazla bir satir eklenmez, bir tane satir silerek yeni bir satir ekleyebilirsiniz"); break; } int newLineIndex; do{ printf("\nLutfen ekleyeceksin satir hangi satirdan sonra giriniz (0-%d) arasinda> ",Height); scanf("%d",&newLineIndex); if(newLineIndex>Height){ printf("\nSu kadar satirlar zaten yok, lutfen %d dan daha az degerler giriniz",Height); } if(newLineIndex<0){ printf("\nSifir yada sifirdan daha buyuk bir sayi giriniz."); } }while((newLineIndex>Height) || (newLineIndex<0)); //Bir satır okuyoruz kullancıdan char newLine[MAX_COLUMNS][MAX_CHARS] ; getLineContent(newLine); //okuduğumuz satır matrise ekliyoruz insertLine(inputTable,newLineIndex,newLine); //Bizim boyutlarımız güncelliyoruz Height++; //Yeniden hesaplıyoruz ve ekrende yazıyoruz calculateAndPrint(); break; } case 3://satir silme { int lineToRemoveIndex; do{ printf("\nLutfen sileceksiniz satirin indexi giriniz (1-%d) arasinda>",Height); scanf("%d",&lineToRemoveIndex); //lineToRemoveIndex--;//Because 0-based index if((lineToRemoveIndex>Height) || (lineToRemoveIndex<=0)){ printf("\nDogru bir satir indexi giriniz lutfen.\n"); } }while((lineToRemoveIndex>Height) || (lineToRemoveIndex<=0)); //Bu satır siliyoruz removeLine(inputTable, lineToRemoveIndex-1);//Because 0-based index //Boyutlarımız güncelliyoruz Height--; //Yeniden hesaplıyoruz ve ekrende yazıyoruz calculateAndPrint(); break; } case 4://Hucre degeri degiştirme { int i,j; //doğru bir hücre okuyacağız kadar yeni bir hücre yeri okuyoruz do{ readCoordinates(&i,&j); if((i>Height) || (i<0) || (j>Width) || (j<0)){ printf("\nBoyle bir hucre bulunmadi. Lutfen yeniden giriniz."); } }while((i>Height) || (i<0) || (j>Width) || (j<0)); char cell[MAX_CHARS]; printf("\nLutfen hucrenin yeni degeri giriniz>"); //Bu hücrenin değeri okuyoruz scanf("%s",cell); //doğru yerinde koyuyoruz strcpy( (*(inputTable+i))+j,cell); //Yeniden hesaplıyoruz ve ekrende yazıyoruz calculateAndPrint(); break; } case 5://Filterleme { int filter; printf("\nHangi sayi'ye gore filterleyeceksiniz>"); scanf("%d",&filter); printFilteredArray(filter); break; } } }while(option!=0);//Kullancı çıkma seçenek seçecek kadar bu menü yazıyoruz ve soruyoruz return 0; }
/** This static method reads an obj file, whose name is sent in as a parameter, and returns a pointer to a GLMesh object that it created based on the file information. This method throws errors if the file doesn't exist, is not an obj file, etc. */ GLMesh* OBJReader::loadOBJFile(const char* fileName){ if (fileName == NULL) throwError("fileName is NULL."); // Logger::out()<< "Loading mesh: " << fileName <<std::endl; FILE* f = fopen(fileName, "r"); if (f == NULL) throwError("Cannot open file \'%s\'.", fileName); GLMesh* result = new GLMesh(); result->setOriginalFilename( fileName ); //have a temporary buffer used to read the file line by line... char buffer[200]; //and this is an array of texture coordinates - the Point3d is a simple data type so I can use the DynamicArray DynamicArray<Point3d> texCoordinates; //this variable will keep getting populated with face information GLIndexedPoly temporaryPolygon; //this is where it happens. while (!feof(f)){ //get a line from the file... fgets(buffer, 200, f); //see what line it is... int lineType = getLineType(buffer); if (lineType == VERTEX_INFO){ //we need to read in the three coordinates - skip over the v Point3d vertexCoords = readCoordinates(buffer + 1); result->addVertex(vertexCoords); } if (lineType == TEXTURE_INFO){ Point3d texCoords = readCoordinates(buffer + 2); texCoordinates.push_back(texCoords); } if (lineType == FACE_INFO){ temporaryPolygon.indexes.clear(); int vIndex, tIndex; int flag; char* tmpPointer = buffer+1; while (tmpPointer = getNextIndex(tmpPointer, vIndex, tIndex, flag)){ temporaryPolygon.indexes.push_back(vIndex-1); if (flag & READ_TEXTCOORD_INDEX){ if (tIndex<0) result->setVertexTexCoordinates(vIndex, texCoordinates[texCoordinates.size()+tIndex]); else result->setVertexTexCoordinates(vIndex, texCoordinates[tIndex]); } } if (temporaryPolygon.indexes.size() == 0) tprintf("Found a polygon with zero vertices.\n"); else result->addPoly(temporaryPolygon); } } fclose(f); return result; }
bool QLandmarkFileHandlerLmx::readLandmark(QLandmark &landmark) { /* <xsd:complexType name="landmarkType"> <xsd:sequence> <xsd:element name="name" type="xsd:string" minOccurs="0" /> <xsd:element name="description" type="xsd:string" minOccurs="0" /> <xsd:element name="coordinates" type="coordinatesType" minOccurs="0" /> <xsd:element name="coverageRadius" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:float"> <xsd:minInclusive value="0"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="addressInfo" type="addressInfoType" minOccurs="0" /> <xsd:element name="mediaLink" type="mediaLinkType" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="category" type="categoryType" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> */ if(m_cancel && (*m_cancel) == true) { m_errorCode = QLandmarkManager::CancelError; m_error = "Import of lmx file was canceled"; return false; } Q_ASSERT(m_reader->isStartElement() && (m_reader->name() == "landmark")); m_landmarkCategoryNames.append(QStringList()); if (!m_reader->readNextStartElement()) return true; if (m_reader->name() == "name") { landmark.setName(m_reader->readElementText()); if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "description") { landmark.setDescription(m_reader->readElementText()); if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "coordinates") { if (!readCoordinates(landmark)) return false; if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "coverageRadius") { bool ok = false; QString s = m_reader->readElementText(); if ((s == "INF") || (s == "-INF") || (s == "NaN")) { m_reader->raiseError(QString("The element \"coverageRadius\" expected a value convertable to type real (value was \"%1\").").arg(s)); return false; } qreal rad = (qreal)(s.toDouble(&ok)); if (!ok) { m_reader->raiseError(QString("The element \"coverageRadius\" expected a value convertable to type real (value was \"%1\").").arg(s)); return false; } if (rad < 0.0) { m_reader->raiseError(QString("The element \"coverageRadius\" is expected to have a non-negative value (value was \"%1\").").arg(s)); return false; } landmark.setRadius(rad); if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "addressInfo") { if (!readAddressInfo(landmark)) return false; if (!m_reader->readNextStartElement()) return true; } // TODO need to document the fact that only the first link is read // and the others are ignored bool mediaLinkRead = false; while (m_reader->name() == "mediaLink") { if (!mediaLinkRead) { mediaLinkRead = true; if (!readMediaLink(landmark)) return false; } if (!m_reader->readNextStartElement()) return true; } QStringList categoryNames; while (m_reader->name() == "category") { QString name; if (!readCategory(name)) return false; categoryNames << name; if (!m_reader->readNextStartElement()) { m_landmarkCategoryNames.last() = categoryNames; return true; } } m_reader->raiseError(QString("The element \"landmark\" did not expect a child element named \"%1\" at this point (unknown child element or child element out of order).").arg(m_reader->name().toString())); return false; }