int toprsGadlReader::getIndexBandOutputNumber( int bandNumber ) const { if(isIndexed(bandNumber)) { GDALRasterBandH band = GDALGetRasterBand(theDataset, bandNumber); if(GDALGetRasterColorInterpretation(band)==GCI_PaletteIndex) { GDALColorTableH table = GDALGetRasterColorTable(band); GDALPaletteInterp interp = GDALGetPaletteInterpretation(table); switch(interp) { case GPI_CMYK: case GPI_RGB: case GPI_HLS: { return 3; } case GPI_Gray: { return 1; } } } } return 0; }
void Field::ConstructField(const String& name, const String& value, Store store, Index index, TermVector termVector) { if (name.empty() && value.empty()) { boost::throw_exception(IllegalArgumentException(L"name and value cannot both be empty")); } if (index == INDEX_NO && store == STORE_NO) { boost::throw_exception(IllegalArgumentException(L"it doesn't make sense to have a field that is neither indexed nor stored")); } if (index == INDEX_NO && termVector != TERM_VECTOR_NO) { boost::throw_exception(IllegalArgumentException(L"cannot store term vector information for a field that is not indexed")); } this->_name = name; this->fieldsData = value; this->_isStored = isStored(store); this->_isIndexed = isIndexed(index); this->_isTokenized = isAnalyzed(index); this->_omitNorms = omitNorms(index); this->_isBinary = false; if (index == INDEX_NO) { this->omitTermFreqAndPositions = false; } setStoreTermVector(termVector); }
void StanfordImporterTest::empty() { StanfordImporter importer; CORRADE_VERIFY(importer.openFile(Utility::Directory::join(STANFORDIMPORTER_TEST_DIR, "empty.ply"))); auto mesh = importer.mesh3D(0); CORRADE_VERIFY(mesh); CORRADE_VERIFY(!mesh->isIndexed()); CORRADE_VERIFY(mesh->positions(0).empty()); }
TCHAR* Field::toString() { CL_NS(util)::StringBuffer result; if (isStored()) { result.append( _T("stored") ); } if (isIndexed()) { if (result.length() > 0) result.append( _T(",") ); result.append( _T("indexed") ); } if (isTokenized()) { if (result.length() > 0) result.append( _T(",") ); result.append( _T("tokenized") ); } if (isTermVectorStored()) { if (result.length() > 0) result.append( _T(",") ); result.append( _T("termVector") ); } if (isStoreOffsetWithTermVector()) { if (result.length() > 0) result.appendChar( ',' ); result.append( _T("termVectorOffsets") ); } if (isStorePositionWithTermVector()) { if (result.length() > 0) result.appendChar( ',' ); result.append( _T("termVectorPosition") ); } if (isBinary()) { if (result.length() > 0) result.appendChar( ',' ); result.append( _T("binary") ); } if (getOmitNorms()) { result.append( _T(",omitNorms") ); } result.appendChar('<'); result.append(name()); result.appendChar(':'); if (_stringValue != NULL) result.append(_stringValue); else if ( _readerValue != NULL ) result.append( _T("Reader") ); else if ( _streamValue != NULL ) result.append( _T("Stream") ); else result.append( _T("NULL") ); result.appendChar('>'); return result.toString(); }
/** * Constructs an AudioInput. */ AudioInput::AudioInput(AudioPathType type, unsigned char channelBase, unsigned char channels, unsigned char index) : AudioPath(channelBase, channels) { setType(type); if (isIndexed(type)) { m_index = index; } else { m_index = 0; } }
bool Project::match(const Match &p) { Path paths[] = { p.pattern(), p.pattern() }; paths[1].resolve(); const int count = paths[1].compare(paths[0]) ? 2 : 1; Scope<const FilesMap&> files = lockFilesForRead(); for (int i=0; i<count; ++i) { const Path &path = paths[i]; if (files.data().contains(path) || p.match(mPath)) return true; const uint32_t id = Location::fileId(path); if (isIndexed(id)) return true; } return false; }
int toprsGadlReader::getNumberOfInputBands() const { if(isOpen()) { if (m_outputBandList.size() > 0) { return (int) m_outputBandList.size(); } if(isIndexed(1)) { return getIndexBandOutputNumber(1); } if(!theIsComplexFlag) { return GDALGetRasterCount(theDataset); } return GDALGetRasterCount(theDataset)*2; } return 0; }
bool Project::match(const Match &p, bool *indexed) const { Path paths[] = { p.pattern(), p.pattern() }; paths[1].resolve(); const int count = paths[1].compare(paths[0]) ? 2 : 1; bool ret = false; for (int i=0; i<count; ++i) { const Path &path = paths[i]; const uint32_t id = Location::fileId(path); if (isIndexed(id)) { if (indexed) *indexed = true; return true; } else if (mFiles.contains(path) || p.match(mPath)) { if (!indexed) return true; ret = true; } } if (indexed) *indexed = false; return ret; }
/*! \internal */ void QGeoMapItemGeometry::allocateAndFill(QSGGeometry *geom) const { const QVector<QGeoMapItemGeometry::Point> &vx = screenVertices_; const QVector<quint32> &ix = screenIndices_; if (isIndexed()) { geom->allocate(vx.size(), ix.size()); if (geom->indexType() == GL_UNSIGNED_SHORT) { quint16 *its = geom->indexDataAsUShort(); for (int i = 0; i < ix.size(); ++i) its[i] = ix[i]; } else if (geom->indexType() == GL_UNSIGNED_INT) { quint32 *its = geom->indexDataAsUInt(); for (int i = 0; i < ix.size(); ++i) its[i] = ix[i]; } } else { geom->allocate(vx.size()); } QSGGeometry::Point2D *pts = geom->vertexDataAsPoint2D(); for (int i = 0; i < vx.size(); ++i) pts[i].set(vx[i].x, vx[i].y); }
bool toprsGadlReader::open() { if(isOpen()) { close(); } std::string driverNameTmp; if (theSubDatasets.size() == 0) { // Note: Cannot feed GDALOpen a NULL string! if (theImageFile.size()) { theDataset = GDALOpen(theImageFile.c_str(), GA_ReadOnly); if( theDataset == 0 ) { return false; } } else { return false; } // Check if it is nitf data for deciding whether or not open each sub-dataset //This will be removed eventually when toprs can handle 2GB nitf file. GDALDriverH driverTmp = GDALGetDatasetDriver(theDataset); bool isNtif = false; if (driverTmp != 0) { driverNameTmp = std::string(GDALGetDriverShortName(driverTmp)); std::transform(driverNameTmp.begin(), driverNameTmp.end(), driverNameTmp.begin(), [&](char ch){return toupper(ch);}); if (driverNameTmp == "NITF") { isNtif = true; } } // Check for sub data sets... char** papszMetadata = GDALGetMetadata( theDataset, "SUBDATASETS" ); if( CSLCount(papszMetadata) > 0 ) { theSubDatasets.clear(); for( int i = 0; papszMetadata[i] != 0; ++i ) { std::string os = papszMetadata[i]; if (os.find("_NAME=") != std::string::npos) { //Sub sets have already been set. Open each sub-dataset really slow down the process //specially for hdf data which sometimes has over 100 sub-datasets. Since following code //only for ntif cloud checking, so only open each sub-dataset here if the dataset is //nitf. This will be removed eventually when toprs can handle 2GB nitf file. //Otherwise open a sub-dataset when setCurrentEntry() gets called. if (isNtif) { GDALDatasetH subDataset = GDALOpen(filterSubDatasetsString(os).c_str(), GA_ReadOnly); if ( subDataset != 0 ) { // "Worldview ingest should ignore subimages when NITF_ICAT=CLOUD" // Hack: Ignore NITF subimages marked as cloud layers. std::string nitfIcatTag( GDALGetMetadataItem( subDataset, "NITF_ICAT", "" ) ); if ( nitfIcatTag.find("CLOUD") == std::string::npos ) { theSubDatasets.push_back(filterSubDatasetsString(os)); } } GDALClose(subDataset); } else { theSubDatasets.push_back(filterSubDatasetsString(os)); } } } //--- // Have multiple entries. We're going to default to open the first // entry like cidcadrg. //--- close(); theDataset = GDALOpen(theSubDatasets[theEntryNumberToRender].c_str(), GA_ReadOnly); if (theDataset == 0) { return false; } } // End of has subsets block. } // End of "if (theSubdatasets.size() == 0)" else { // Sub sets have already been set. theDataset = GDALOpen(theSubDatasets[theEntryNumberToRender].c_str(), GA_ReadOnly); if (theDataset == 0) { return false; } } // Set the driver. theDriver = GDALGetDatasetDriver( theDataset ); if(!theDriver) return false; theGdtType = GDT_Byte; theOutputGdtType = GDT_Byte; if(getNumberOfInputBands() < 1 ) { if(CSLCount(GDALGetMetadata(theDataset, "SUBDATASETS"))) { std::cout << "torsGdalReader::open WARNING:" << "\nHas multiple sub datasets and need to set the data before" << " we can get to the bands" << std::endl; } close(); std::cout << "torsGdalReader::open WARNING:" << "\nNo band data present in torsGdalReader::open" << std::endl; return false; } toprs_int32 i = 0; GDALRasterBandH bBand = GDALGetRasterBand( theDataset, 1 ); theGdtType = GDALGetRasterDataType(bBand); char** papszMetadata = GDALGetMetadata( bBand, NULL ); if (CSLCount(papszMetadata) > 0) { for(int i = 0; papszMetadata[i] != NULL; i++ ) { std::string metaStr = papszMetadata[i]; if (metaStr.find("AREA_OR_POINT") != std::string::npos) { //std::string pixel_is_point_or_area = metaStr.split("=")[1]; //pixel_is_point_or_area.downcase(); //if (pixel_is_point_or_area.contains("area")) // thePixelType = TOPRS_PIXEL_IS_AREA; break; } } } if(!isIndexed(1)) { for(i = 0; i < GDALGetRasterCount(theDataset); ++i) { if(theGdtType != GDALGetRasterDataType(GDALGetRasterBand( theDataset,i+1 ))) { std::cout << "torsGdalReader::open WARNING" << "\nWe currently do not support different scalar type bands." << std::endl; close(); return false; } } } theOutputGdtType = theGdtType; switch(theGdtType) { case GDT_CInt16: { // theOutputGdtType = GDT_Int16; theIsComplexFlag = true; break; } case GDT_CInt32: { // theOutputGdtType = GDT_Int32; theIsComplexFlag = true; break; } case GDT_CFloat32: { // theOutputGdtType = GDT_Float32; theIsComplexFlag = true; break; } case GDT_CFloat64: { // theOutputGdtType = GDT_Float64; theIsComplexFlag = true; break; } default: { theIsComplexFlag = false; break; } } if((std::string(GDALGetDriverShortName( theDriver )) == "PNG")&& (getNumberOfInputBands() == 4)) { theAlphaChannelFlag = true; } populateLut(); computeMinMax(); completeOpen(); theTile = toprsImgFactory::instance()->create(this); theSingleBandTile = toprsImgFactory::instance()->create(getInputScalarType(), 1); if ( m_preservePaletteIndexesFlag ) { theTile->setIndexedFlag(true); theSingleBandTile->setIndexedFlag(true); } theTile->initialize(); theSingleBandTile->initialize(); theGdalBuffer.resize(0); if(theIsComplexFlag) { theGdalBuffer.resize(theSingleBandTile->getSizePerBandInBytes()*2); } theImageBound = toprsIRect(0 ,0 ,GDALGetRasterXSize(theDataset)-1 ,GDALGetRasterYSize(theDataset)-1); int xSize=0, ySize=0; GDALGetBlockSize(GDALGetRasterBand( theDataset, 1 ), &xSize, &ySize); if (driverNameTmp.find("JPIP")!= std::string::npos || driverNameTmp.find("JP2")!= std::string::npos) { m_isBlocked = ((xSize > 1)&&(ySize > 1)); } else { m_isBlocked = false; } //if(m_isBlocked) //{ // setRlevelCache(); //} return true; }
void toprsGadlReader::populateLut() { theLut.reset(); // toprsRefPtr not a leak. if(isIndexed(1)&&theDataset) { GDALColorTableH aTable = GDALGetRasterColorTable(GDALGetRasterBand( theDataset, 1 )); GDALPaletteInterp interp = GDALGetPaletteInterpretation(aTable); if(aTable && ( (interp == GPI_Gray) || (interp == GPI_RGB))) { GDALColorEntry colorEntry; int numberOfElements = GDALGetColorEntryCount(aTable); int idx = 0; if(numberOfElements) { // GPI_Gray Grayscale (in GDALColorEntry.c1) // GPI_RGB Red, Green, Blue and Alpha in (in c1, c2, c3 and c4) theLut.reset(new toprsNBandLutDataObject(numberOfElements,4,TOPRS_UINT8,-1)); bool nullSet = false; for(idx = 0; idx < numberOfElements; ++idx) { switch(interp) { case GPI_RGB: { if(GDALGetColorEntryAsRGB(aTable, idx, &colorEntry)) { (*theLut)[idx][0] = colorEntry.c1; (*theLut)[idx][1] = colorEntry.c2; (*theLut)[idx][2] = colorEntry.c3; (*theLut)[idx][3] = colorEntry.c4; if ( !nullSet ) { if ( m_preservePaletteIndexesFlag ) { // If preserving palette set the null to the fix alpha of 0. if ( (*theLut)[idx][3] == 0 ) { theLut->setNullPixelIndex(idx); nullSet = true; } } else { //--- // Not using alpha. // Since the alpha is currently not used, look for the null // pixel index and set if we find. If at some point the alpha // is taken out this can be removed. //--- if ( ( (*theLut)[idx][0] == 0 ) && ( (*theLut)[idx][1] == 0 ) && ( (*theLut)[idx][2] == 0 ) ) { theLut->setNullPixelIndex(idx); nullSet = true; } } } } else { (*theLut)[idx][0] = 0; (*theLut)[idx][1] = 0; (*theLut)[idx][2] = 0; (*theLut)[idx][3] = 0; // Look for the null pixel index and set if we find. if ( !nullSet ) { if ( (*theLut)[idx][0] == 0 ) { theLut->setNullPixelIndex(idx); } } } break; } case GPI_Gray: { const GDALColorEntry* constEntry = GDALGetColorEntry(aTable, idx); if(constEntry) { (*theLut)[idx][0] = constEntry->c1; } else { (*theLut)[idx][0] = 0; } break; } default: { break; } } } } } toprs_uint32 rasterCount = GDALGetRasterCount(theDataset); for(toprs_uint32 aGdalBandIndex=1; aGdalBandIndex <= rasterCount; ++aGdalBandIndex) { GDALRasterBandH aBand = GDALGetRasterBand( theDataset, aGdalBandIndex ); if (aBand) { GDALRasterAttributeTableH hRAT = GDALGetDefaultRAT(aBand); int colCount = GDALRATGetColumnCount(hRAT); for (toprs_int32 col = 0; col < colCount; col++) { const char* colName = GDALRATGetNameOfCol(hRAT, col); if (colName) { if (strcmp(colName, "Class_Names") == 0) { std::vector<std::string> entryLabels; toprs_int32 rowCount = GDALRATGetRowCount(hRAT); for (toprs_int32 row = 0; row < rowCount; row++) { const char* className = GDALRATGetValueAsString(hRAT, row, col); std::string entryLabel(className); entryLabels.push_back(entryLabel); } theLut->setEntryLables(aGdalBandIndex-1, entryLabels); } } } } } } }
std::shared_ptr<toprsImg> toprsGadlReader::getTile( const toprsIRect& tileRect, int resLevel/*=0*/ ) { // This tile source bypassed, or invalid res level, return a blank tile. if (!theDataset) { return std::shared_ptr<toprsImg>(); } // Check for intersect. toprsIRect imageBound = getBoundingRect(resLevel); if(!tileRect.intersects(imageBound)) { theTile->setImgRect(tileRect); theTile->makeBlank(); return theTile; } if(m_isBlocked) { return getTileBlockRead(tileRect, resLevel); } // Check for overview. if(resLevel) { if ( m_preservePaletteIndexesFlag ) { // No mechanism for this coded for reduce resolution levels. std::cout << std::string("toprsGdalReader::getTile ERROR: Accessing reduced resolution level with the preservePaletteIndexesFlag set!") ; return std::shared_ptr<toprsImg>();//xizhi } //if(theOverview.valid() && theOverview->isValidRLevel(resLevel))//xizhi //{ // std::shared_ptr<toprsImg> tileData = theOverview->getTile(tileRect, resLevel); // tileData->setDataType(getOutputScalarType()); // return tileData; //} #if 1 //--- // Note: This code was shut off since we currently don't utilize gdal overviews. // toprsGdalReader::getNumberOfDecimationLevels has been fixed accordingly. //--- //else if(GDALGetRasterCount(theDataset)) //{ // GDALRasterBandH band = GDALGetRasterBand(theDataset, 1); // if(static_cast<int>(resLevel) > GDALGetOverviewCount(band)) // { // return std::shared_ptr<toprsImg>(); // } //} #endif } // Set the rectangle of the tile. theTile->setImgRect(tileRect); // Compute clip rectangle with respect to the image bounds. toprsIRect clipRect = tileRect.clipToRect(imageBound); theSingleBandTile->setImgRect(clipRect); if (tileRect.completely_within(clipRect) == false) { // Not filling whole tile so blank it out first. theTile->makeBlank(); } // Always blank the single band tile. theSingleBandTile->makeBlank(); toprs_uint32 anToprsBandIndex = 0; toprs_uint32 aGdalBandIndex = 1; toprs_uint32 rasterCount = GDALGetRasterCount(theDataset); if (m_outputBandList.size() > 0) { rasterCount = (toprs_uint32) m_outputBandList.size(); } toprs_uint32 outputBandIndex = 0; for(toprs_uint32 aBandIndex =1; aBandIndex <= rasterCount; ++aBandIndex) { if (m_outputBandList.size() > 0) { aGdalBandIndex = m_outputBandList[outputBandIndex] + 1; outputBandIndex++; } else { aGdalBandIndex = aBandIndex; } GDALRasterBandH aBand = resolveRasterBand( resLevel, aGdalBandIndex ); if ( aBand ) { bool bReadSuccess; if(!theIsComplexFlag) { bReadSuccess = (GDALRasterIO(aBand , GF_Read , clipRect.left_up().x , clipRect.left_up().y , clipRect.width() , clipRect.height() , theSingleBandTile->getBuf() , clipRect.width() , clipRect.height() , theOutputGdtType , 0 , 0 ) == CE_None) ? true : false; if ( bReadSuccess == true ) { if(isIndexed(aGdalBandIndex)) { if(isIndexTo3Band(aGdalBandIndex)) { if ( m_preservePaletteIndexesFlag ) { theTile->loadBand((void*)theSingleBandTile->getBuf(), clipRect, anToprsBandIndex); anToprsBandIndex += 1; } else { loadIndexTo3BandTile(clipRect, aGdalBandIndex, anToprsBandIndex); anToprsBandIndex+=3; } } else if(isIndexTo1Band(aGdalBandIndex)) { // ??? Ignoring (drb) anToprsBandIndex += 1; } } else { if(theAlphaChannelFlag&&(aGdalBandIndex==rasterCount)) { theTile->nullTileAlpha((toprs_uint8*)theSingleBandTile->getBuf(), theSingleBandTile->getImgRect(), clipRect, false); } else { // Note fix rectangle to represent theBuffer's rect in image space. theTile->loadBand((void*)theSingleBandTile->getBuf() , clipRect , anToprsBandIndex); ++anToprsBandIndex; } } } else { ++anToprsBandIndex; } } else // matches if(!theIsComplexFlag){} { bReadSuccess = (GDALRasterIO(aBand , GF_Read , clipRect.left_up().x , clipRect.left_up().y , clipRect.width() , clipRect.height() , &theGdalBuffer.front() , clipRect.width() , clipRect.height() , theOutputGdtType , 0 , 0 ) == CE_None) ? true : false; if ( bReadSuccess == true ) { toprs_uint32 byteSize = toprs::dataSizeInBytes(theSingleBandTile->getDataType()); toprs_uint32 byteSize2 = byteSize*2; toprs_uint8* complexBufPtr = (toprs_uint8*)(&theGdalBuffer.front()); // start at first real part toprs_uint8* outBufPtr = (toprs_uint8*)(theSingleBandTile->getBuf()); toprs_uint32 idxMax = theSingleBandTile->w()*theSingleBandTile->h(); toprs_uint32 idx = 0; for(idx = 0; idx < idxMax; ++idx) { memcpy(outBufPtr, complexBufPtr, byteSize); complexBufPtr += byteSize2; outBufPtr += byteSize; } theTile->loadBand((void*)theSingleBandTile->getBuf() , clipRect , anToprsBandIndex); ++anToprsBandIndex; complexBufPtr = (toprs_uint8*)(&theGdalBuffer.front()) + byteSize; // start at first imaginary part outBufPtr = (toprs_uint8*)(theSingleBandTile->getBuf()); for(idx = 0; idx < idxMax; ++idx) { memcpy(outBufPtr, complexBufPtr, byteSize); complexBufPtr += byteSize2; outBufPtr += byteSize; } theTile->loadBand((void*)theSingleBandTile->getBuf() , clipRect , anToprsBandIndex); ++anToprsBandIndex; } else { anToprsBandIndex += 2; } } } } theTile->validate(); return theTile; }
void checkError(char *inputFile) { // function checks for errors in the source code; // if errors are found then assembler informs the user about the errors and terminates // operation FILE *input; char lineCpy[20]={'\0'}, operandNew[20]; int code, error=0, i, found, lineCtr = 0; input = fopen(inputFile, "r"); fgets(line,20,input); readLine(); lineCtr++; while(line[0] == '.') { fgets(line,20,input); lineCtr++; } if(!strcmp(opcode,"START")) { if(strlen(programName) > 6) { printf("\nERROR: Max Length of Pgm Name is 6 characters\n"); flag=1; } fgets(line,20,input); while(line[0] == '.') { fgets(line,20,input); lineCtr++; } } strcpy(lineCpy, line); while(strcmp(lineCpy,"END")) { found=0; readLine(); lineCtr++; strcpy(lineCpy, line); lineCpy[3] = '\0'; code = getHexCode(opcode); if(code == -1) { error = isAssemblerDirective(opcode); if(error == -1) { printf("\nERROR: %s in line %d\n", opcode, lineCtr); flag=1; } else break; } strcpy(operandNew,operand); operandNew[strlen(operand)-1] = '\0'; if(isIndexed(operandNew)) { for(i=0;i<symbolCount;i++) { if(!strcmp(operandIndex,symtab[i].symbol)) found=1; } if(!found) { printf("\nERROR: %s in line %d is undefined\n",operandIndex,lineCtr); flag=1; } } else { for(i=0;i<symbolCount;i++) { if(!strcmp(operandNew,symtab[i].symbol)) found=1; } if(!found) { printf("\nERROR: %s in line %d is undefined\n",operandNew,lineCtr); flag=1; } } fgets(line,20,input); while(line[0] == '.') { fgets(line,20,input); lineCtr++; } } fclose(input); }
void passTwo(char *fileName) { // function performs pass two of the assembler FILE *intermediate, *output; char record[10000], part[20], value[6], lineCpy[20], operandNew[10], recordNew[10000], tempStr[10000], charStr[10], outputFile[20]; int curTxtLen = 0, opcodeFound, operandFound, check, operandAddr, recordAddr, code, error = 0, partLen, addrCtr = 0, countr = 0, i = 0, j = 0, k = 0, l = 0, m, param = 0, tempAddr; float testParam; fileName[strlen(fileName) - 3] = '\0'; strcat(fileName, "obj"); strcpy(outputFile, fileName); intermediate = fopen("intermediate.txt", "r"); output = fopen(outputFile, "w"); fgets(line,20,intermediate); readLine(); if(!strcmp(opcode,"START")) fgets(line,20,intermediate); printf("\n\nObject code for the above SIC program :\n"); printf("\nH^%s^%06X^%06X",programName,startAddr,length); fprintf(output,"H^%s^%06X^%06X",programName,startAddr,length); recordAddr = startAddr; record[0] = '\0'; while(strcmp(lineCpy,"END")) { operandAddr = operandFound = opcodeFound = m = l = 0; value[0] = part[0] = charStr[0] = '\0'; readLine(); strcpy(lineCpy, line); lineCpy[3] = '\0'; code = getHexCode(opcode); if(code != -1) { opcodeFound = 1; sprintf(part, "%02X", code); if(operand[0]!='\0') { strcpy(operandNew,operand); operandNew[strlen(operand)-1] = '\0'; if(isIndexed(operandNew)) { for(check = 0; check < symbolCount; check++) { if(!strcmp(symtab[check].symbol, operandIndex)) { tempAddr = symtab[check].addr; tempAddr += 0x8000; sprintf(value, "%04X", tempAddr); strcat(part, value); operandFound = 1; } } } else { for(check = 0; check < symbolCount; check++) { if(!strcmp(symtab[check].symbol, operandNew)) { sprintf(value, "%04X", symtab[check].addr); strcat(part, value); operandFound = 1; } } } if(!operandFound) strcat(part,"ERROR"); } } if(!opcodeFound) { if(!strcmp(opcode,"WORD")) { strcpy(operandNew,operand); operandNew[strlen(operand)-1] = '\0'; partLen = strlen(operandNew); while(partLen != 6) { strcat(part, "0"); partLen++; } strcat(part,operandNew); } if(!strcmp(opcode,"BYTE")) { strcpy(operandNew,operand); operandNew[strlen(operand)-1] = '\0'; for(l=0;operandNew[l]!='\0';l++) { if(operandNew[l] == '\'') { l++; while(operandNew[l] != '\'') charStr[m++] = operandNew[l++]; } } charStr[m] = '\0'; if(operandNew[0] == 'C') { if(strlen(charStr) == 1) strcat(part,"0000"); if(strlen(charStr) == 2) strcat(part,"00"); for(m=0;charStr[m]!='\0';m++) { sprintf(value,"%X",charStr[m]); strcat(part,value); } } if(operandNew[0] == 'X') { strcat(value,charStr); strcat(part,value); } } } if(part[0] != '\0') { strcat(record, "^"); strcat(record, part); curTxtLen += strlen(part); } fgets(line, 20, intermediate); } while(j < strlen(record)) { if((j!=0) && record[j] == '^') addrCtr++; if((j % 70 == 0) && (j != 0)) { recordNew[i++] = '\n'; recordNew[i++] = 'T'; recordNew[i++] = '^'; sprintf(tempStr, "%06X", address[addrCtr]); for(k=0; k<strlen(tempStr); k++) recordNew[i++] = tempStr[k]; recordNew[i++] = '^'; testParam = (float) (strlen(record) - j)/70; if(testParam > 1) { tempStr[0] = '1'; tempStr[1] = 'E'; } else { param = strlen(record) % 70; param = (param-(param/7))/2; sprintf(tempStr, "%02X", param); } for(k=0; k<2; k++) recordNew[i++] = tempStr[k]; } recordNew[i++] = record[j++]; countr++; } recordNew[i] = '\0'; if(strlen(record) > 70) curTxtLen = 30; else curTxtLen = curTxtLen/2; printf("\nT^%06X^%02X%s",recordAddr, curTxtLen, recordNew); fprintf(output,"\nT^%06X^%02X%s",recordAddr, curTxtLen, recordNew); printf("\nE^%06X\n", startAddr); fprintf(output,"\nE^%06X\n", startAddr); remove("intermediate.txt"); fclose(output); }
StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjector* prj) const { StelVertexArray ret = *this; if (isIndexed()) { switch (primitiveType) { case Triangles: { QVector<unsigned short> indicesOrig = ret.indices; ret.indices.resize(0); for (int i = 0; i < indicesOrig.size(); i += 3) { if (prj->intersectViewportDiscontinuity(vertex.at(indicesOrig.at(i)), vertex.at(indicesOrig.at(i+1))) || prj->intersectViewportDiscontinuity(vertex.at(indicesOrig.at(i+1)), vertex.at(indicesOrig.at(i+2))) || prj->intersectViewportDiscontinuity(vertex.at(indicesOrig.at(i+2)), vertex.at(indicesOrig.at(i)))) { // We have a discontinuity. } else { ret.indices << indicesOrig.at(i) << indicesOrig.at(i+1) << indicesOrig.at(i+2); } } break; } default: // Unsupported Q_ASSERT(false); } } else { ret.indices.clear(); // Create a 'Triangles' vertex array from this array. // We have different algorithms for different original mode switch (primitiveType) { case TriangleStrip: ret.indices.reserve(vertex.size() * 3); for (int i = 2; i < vertex.size(); ++i) { if (prj->intersectViewportDiscontinuity(vertex[i], vertex[i-1]) || prj->intersectViewportDiscontinuity(vertex[i-1], vertex[i-2]) || prj->intersectViewportDiscontinuity(vertex[i-2], vertex[i])) { // We have a discontinuity. } else { if (i % 2 == 0) ret.indices << i-2 << i-1 << i; else ret.indices << i-2 << i << i-1; } } break; case Triangles: ret.indices.reserve(vertex.size()); for (int i = 0; i < vertex.size(); i += 3) { if (prj->intersectViewportDiscontinuity(vertex.at(i), vertex.at(i+1)) || prj->intersectViewportDiscontinuity(vertex.at(i+1), vertex.at(i+2)) || prj->intersectViewportDiscontinuity(vertex.at(i+2), vertex.at(i))) { // We have a discontinuity. } else { ret.indices << i << i+1 << i+2; } } break; default: Q_ASSERT(false); } } // Just in case we don't have any triangles, we also remove all the vertices. // This is because we can't specify an empty indexed VertexArray. // FIXME: we should use an attribute for indexed array. if (ret.indices.isEmpty()) ret.vertex.clear(); ret.primitiveType = Triangles; return ret; }