PolygonForegroundBase::PolygonForegroundBase(void) : _sfMaterial (), _mfTexCoords (), _mfPositions (), _sfNormalizedX (bool(true)), _sfNormalizedY (bool(true)), _sfAspectHeight (UInt16(0)), _sfAspectWidth (UInt16(0)), _sfScale (Real32(1.0)), _sfTile (bool(true)), Inherited() { }
PolygonBackgroundBase::PolygonBackgroundBase(void) : Inherited(), _sfMaterial (NULL), _mfTexCoords (), _mfPositions (), _sfNormalizedX (bool(true)), _sfNormalizedY (bool(true)), _sfAspectHeight (UInt16(0)), _sfAspectWidth (UInt16(0)), _sfScale (Real32(1.0)), _sfCleanup (bool(true)) { }
DynamicSubdivisionCCBase<MESH>::DynamicSubdivisionCCBase(void) : _sfMinProjSize (Real32(5.0)), _sfMaxProjSize (Real32(15.0)), _sfVertexClassifier (Real32(0.01)), _sfNormalConeAperture (Real32(0.01)), _sfMinDepth (UInt16(0)), _sfMaxDepth (UInt16(4)), _sfBackfaceCulling (bool(false)), _sfMesh (OpenMeshP(NULL)), _sfTesselator (OpenMeshTesselatorP(NULL)), _sfAutoUpdate (bool(true)), Inherited() { }
void runTests(bool write,BinaryDataHandler &pMem) { runTest (write,pMem, std::string("Hallo") ); runTest1 (write,pMem, Time(222.22) ); runTest (write,pMem, Color3f(1.1,2.2,3.3) ); runTest (write,pMem, Color4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Color3ub(1,2,3) ); runTest (write,pMem, Color4ub(1,2,3,4) ); runTest (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) ); runTest (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) ); runTest1 (write,pMem, BitVector(0xabcd) ); runTest (write,pMem, Plane(Vec3f(1.0,0),0.222) ); runTest (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ); runTest (write,pMem, Quaternion(Vec3f(1,2,3),22) ); runTest2<bool>(write,pMem, true ); runTest (write,pMem, Int8(-22) ); runTest (write,pMem, UInt8(11) ); runTest (write,pMem, Int16(-10233) ); runTest (write,pMem, UInt16(20233) ); runTest (write,pMem, Int32(-222320233) ); runTest (write,pMem, UInt32(522320233) ); runTest<Int64> (write,pMem, Int64(-522323334) ); runTest (write,pMem, UInt64(44523423) ); runTest (write,pMem, Real32(22.333224) ); runTest (write,pMem, Real64(52.334534533224) ); runTest (write,pMem, Vec2f(1.1,2.2) ); runTest (write,pMem, Vec3f(1.1,2.2,3.3) ); runTest (write,pMem, Vec4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt2f(1.1,2.2) ); runTest (write,pMem, Pnt2d(1.1,2.2) ); runTest (write,pMem, Pnt3f(1.1,2.2,3.3) ); runTest (write,pMem, Pnt3d(1.1,2.2,3.3) ); runTest (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) ); }
ImageBase::ImageBase(void) : _mfParents (), _sfDimension (Int32(0)), _sfWidth (Int32(0)), _sfHeight (Int32(1)), _sfDepth (Int32(1)), _sfBpp (Int32(1)), _sfMipMapCount (Int32(1)), _sfFrameCount (Int32(1)), _sfFrameDelay (Time(0)), _sfPixelFormat (UInt32(0)), _mfPixel (), _sfFrameSize (Int32(0)), _sfName (), _sfDataType (Int32(GL_UNSIGNED_BYTE)), _sfComponentSize (Int32(1)), _sfSideCount (Int32(1)), _sfSideSize (Int32(0)), _sfForceCompressedData (bool(false)), _sfForceAlphaChannel (bool(false)), _sfForceColorChannel (bool(false)), _sfForceAlphaBinary (bool(false)), _sfResX (Real32(72.0f)), _sfResY (Real32(72.0f)), _sfResUnit (UInt16(2)), Inherited() { }
void NFIOBase::writeSFAttachmentMap(SFAttachmentMap *amap, UInt32 numElems, bool hasBinding) { AttachmentMap::const_iterator mapIt = amap->getValue().begin(); AttachmentMap::const_iterator mapEnd = amap->getValue().end (); _out->putValue(numElems); for(; mapIt != mapEnd; ++mapIt) { // skip Attachments marked as internal if( mapIt->second != NullFC && mapIt->second->getSFInternal()->getValue() == true ) { continue; } writeFCId(mapIt->second); } if(hasBinding == true) { mapIt = amap->getValue().begin(); for(; mapIt != mapEnd; ++mapIt) { UInt16 binding = UInt16(mapIt->first & 0x0000ffff); _out->putValue(binding); } } }
//--------------------------------------------------------------------------- void __fastcall TFrDeviceExplorer::btnWriteClick(TObject *Sender) { TBluetoothLEDevice * ADevice = NULL; ADevice = GetCurrentDevice(); if(ADevice != NULL) { TBluetoothGattService * AService = ADevice->Services->Items[CurrentService]; TBluetoothGattCharacteristic * AChar = AService->Characteristics->Items[CurrentCharacteristic]; if((AChar->Properties.Contains(TBluetoothProperty::Write)) || (AChar->Properties.Contains(TBluetoothProperty::WriteNoResponse)) || (AChar->Properties.Contains(TBluetoothProperty::SignedWrite))) { if(CbWriteTypes->ItemIndex == 0) AChar->SetValueAsString(EdCharacWrite->Text); if(CbWriteTypes->ItemIndex == 1) AChar->SetValueAsString(EdCharacWrite->Text, false); if(CbWriteTypes->ItemIndex == 2) AChar->SetValueAsUInt8(UInt8(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 3) AChar->SetValueAsUInt16(UInt16(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 4) AChar->SetValueAsUInt32(UInt32(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 5) AChar->SetValueAsUInt64(StrToInt(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 6) AChar->SetValueAsInt8(Int8(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 7) AChar->SetValueAsInt16(Int16(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 8) AChar->SetValueAsInt32(Int32(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 9) AChar->SetValueAsInt64(StrToInt(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 10) AChar->SetValueAsDouble(StrToFloat(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 11) AChar->SetValueAsSingle(StrToFloat(EdCharacWrite->Text)); ADevice->WriteCharacteristic(AChar); } else { ShowMessage("This characteristic doesn''t allow Write"); } } else { ShowMessage(EdCurrentDevice->Text + " is not available"); } }
QVariant UInt16Codec::value( const PODData& data, int* byteCount ) const { const quint16* pointer = (quint16*)data.pointer( 2 ); *byteCount = pointer ? 2 : 0; return pointer ? QVariant::fromValue<UInt16>( UInt16(*pointer) ) : QVariant(); }
void deepCloneAttachments( OSG::AttachmentContainer const *src, OSG::AttachmentContainer *dst, const std::vector<const OSG::ReflexiveContainerType *> &shareTypes, const std::vector<const OSG::ReflexiveContainerType *> &ignoreTypes, const std::vector<OSG::UInt16> &shareGroupIds, const std::vector<OSG::UInt16> &ignoreGroupIds) { #if 0 const FieldContainerType &type = dst->getType(); const FieldDescriptionBase *fDesc = type.getFieldDesc("attachments"); const UInt32 fieldId = fDesc->getFieldId(); const Field *srcField = src->getField("attachments"); fDesc->cloneValuesV(srcField, fieldId, dst, shareTypes, ignoreTypes, shareGroupIds, ignoreGroupIds); #else const SFAttachmentPtrMap *pAttMap = src->getSFAttachments(); AttachmentMap::const_iterator mapIt = pAttMap->getValue().begin(); AttachmentMap::const_iterator mapEnd = pAttMap->getValue().end(); for(; mapIt != mapEnd; ++mapIt) { AttachmentUnrecPtr att = mapIt->second; UInt16 uiBinding = UInt16(mapIt->first & 0x0000FFFF ); if(att != NULL) { const FieldContainerType &attType = att->getType(); // test if att type should NOT be ignored if(!TypePredicates::typeInGroupIds (ignoreGroupIds.begin(), ignoreGroupIds.end(), attType ) && !TypePredicates::typeDerivedFrom(ignoreTypes.begin(), ignoreTypes.end(), attType ) ) { // test if att should cloned if(!TypePredicates::typeInGroupIds (shareGroupIds.begin(), shareGroupIds.end(), attType ) && !TypePredicates::typeDerivedFrom(shareTypes.begin(), shareTypes.end(), attType ) ) { att = dynamic_pointer_cast<Attachment>( OSG::deepClone(att, shareTypes, ignoreTypes, shareGroupIds, ignoreGroupIds)); } } } dst->addAttachment(att, uiBinding); } #endif }
LineChunkBase::LineChunkBase(void) : Inherited(), _sfWidth (Real32(1)), _sfStippleRepeat (Int32(1)), _sfStipplePattern (UInt16(0xffff)), _sfSmooth (bool(GL_FALSE)) { }
ConditionalParticleAffectorBase::ConditionalParticleAffectorBase(void) : Inherited(), _sfConditionalAttribute (), _sfConditionalOperator (UInt16(1)), _sfConditionalValue (UInt32(0.0)), _mfAffectors () { }
void EditSFieldHandle<SFAttachmentPtrMap>::cloneValues( GetFieldHandlePtr pSrc, const TypePtrVector &shareTypes, const TypePtrVector &ignoreTypes, const TypeIdVector &shareGroupIds, const TypeIdVector &ignoreGroupIds) const { SFAttachmentPtrMap::GetHandlePtr pGetHandle = boost::dynamic_pointer_cast< SFAttachmentPtrMap::GetHandle>(pSrc); if(pGetHandle == NULL || pGetHandle->isValid() == false) return; const SFAttachmentPtrMap &pAttMap = **pGetHandle; AttachmentMap::const_iterator mapIt = pAttMap.getValue().begin(); AttachmentMap::const_iterator mapEnd = pAttMap.getValue().end(); for(; mapIt != mapEnd; ++mapIt) { AttachmentUnrecPtr att = mapIt->second; UInt16 uiBinding = UInt16(mapIt->first & 0x0000FFFF ); if(att != NULL) { const FieldContainerType &attType = att->getType(); // test if att type should NOT be ignored if(!TypePredicates::typeInGroupIds (ignoreGroupIds.begin(), ignoreGroupIds.end(), attType ) && !TypePredicates::typeDerivedFrom(ignoreTypes.begin(), ignoreTypes.end(), attType ) ) { // test if att should cloned if(!TypePredicates::typeInGroupIds (shareGroupIds.begin(), shareGroupIds.end(), attType ) && !TypePredicates::typeDerivedFrom(shareTypes.begin(), shareTypes.end(), attType ) ) { att = dynamic_pointer_cast<Attachment>( OSG::deepClone(att, shareTypes, ignoreTypes, shareGroupIds, ignoreGroupIds)); } } } if(_fAddMethod) { _fAddMethod(att, uiBinding); } } }
UInt16 CInArchive::ReadUInt16() { UInt16 value = 0; for (int i = 0; i < 2; i++) { Byte b = ReadByte(); value |= (UInt16(b) << (8 * i)); } return value; }
MorphGeometryBase::MorphGeometryBase(void) : Inherited(), _sfBaseGeometry (NULL), _mfInternalTargetGeometries(), _sfInternalWeights (this, InternalWeightsFieldId, GeoVectorProperty::ParentsFieldId), _mfMorphProperties (), _sfBlendingMethod (UInt16(MorphGeometry::Normalized)) { }
/*! Set parameter value, create it if not set yet. */ bool ProgramChunk::setParameter(Int16 index, const Vec4f& value) { if(index < 0) return true; if(getMFParamValues()->size() <= UInt16(index)) { editMFParamValues()->resize(index + 1); } editParamValues(index) = value; return false; }
ArcUIDrawObjectBase::ArcUIDrawObjectBase(void) : Inherited(), _sfCenter (Pnt2f(0,0)), _sfWidth (Real32(1)), _sfHeight (Real32(1)), _sfStartAngleRad (Real32(0.0)), _sfEndAngleRad (Real32(6.283185307)), _sfSubDivisions (UInt16(24)), _sfColor (Color4f(1.0,1.0,1.0,1.0)), _sfLineWidth (Real32(1.0)), _sfOpacity (Real32(1.0)) { }
/*! Add a named parameter */ bool ProgramChunk::addParameter(const char *name, Int16 index) { if(index < 0) return true; if(getMFParamNames()->size() <= UInt16(index)) { editMFParamNames()->resize(index + 1); } editParamNames(index) = name; return false; }
const Vec4f& ProgramChunk::getParameter(Int16 index) { static const Vec4f bad(-1e10,-1e10,-1e10); if(index < 0) return bad; if(getMFParamValues()->size() <= UInt16(index)) { return getParamValues(index); } return bad; }
void VoodooI2CHIDDevice::i2c_hid_get_input(OSObject* owner, IOTimerEventSource* sender) { // IOLog("getting input\n"); if (hid_device->reading) return; UInt rsize; int ret; rsize = UInt16(ihid->hdesc.wMaxInputLength); unsigned char* rdesc = (unsigned char *)IOMalloc(rsize); ret = i2c_hid_command(ihid, &hid_input_cmd, rdesc, rsize); // IOLog("===Input (%d)===\n", rsize); // for (int i = 0; i < rsize; i++) // IOLog("0x%02x ", (UInt8) rdesc[i]); // IOLog("\n"); int return_size = rdesc[0] | rdesc[1] << 8; if (return_size == 0) { /* host or device initiated RESET completed */ // test/clear bit? hid_device->timerSource->setTimeoutMS(10); return; } if (return_size > rsize) { IOLog("%s: Incomplete report %d/%d\n", __func__, rsize, return_size); } IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, return_size); buffer->writeBytes(0, rdesc + 2, return_size - 2); IOReturn err = _wrapper->handleReport(buffer, kIOHIDReportTypeInput); if (err != kIOReturnSuccess) IOLog("Error handling report: 0x%.8x\n", err); buffer->release(); IOFree(rdesc, rsize); hid_device->timerSource->setTimeoutMS(10); }
UInt16 hsSqrt32(UInt32 value) { UInt32 curr = 0; UInt32 root = 0; int bits = 16; do { curr = (curr << 2) | TOP2BITS(value); value <<= 2; UInt32 guess = root << 2; root <<= 1; if (guess < curr) { curr -= guess + 1; root |= 1; } } while (--bits); return UInt16(root); }
UInt16 hsCubeRoot(UInt32 value) { UInt32 curr; UInt32 root = 0; UInt32 bits = 11; curr = (unsigned)value >> 30; value <<= 2; do { root <<= 1; UInt32 guess = 3 * (root * root + root); if (guess < curr) { curr -= guess + 1; root |= 1; } curr = (curr << 3) | TOP3BITS(value); value <<= 3; } while (--bits); return UInt16(root); }
void VoodooI2CHIDDevice::write_report_descriptor_to_buffer(IOBufferMemoryDescriptor *buffer){ UInt rsize; int ret; IOLog("Report descriptor register: 0x%x\n",ihid->hdesc.wReportDescRegister); rsize = UInt16(ihid->hdesc.wReportDescLength); unsigned char* rdesc = (unsigned char *)IOMalloc(rsize); i2c_hid_hwreset(ihid); ret = i2c_hid_command(ihid, &hid_report_desc_cmd, rdesc, rsize); if (!ret) IOLog("Report descriptor was fetched\n"); buffer->writeBytes(0, rdesc, rsize); IOLog("Report Descriptor written to buffer (%d)\n", rsize); IOFree(rdesc, rsize); }
void SensorKeepAliveImpl::Unpack() { CommandId = Buffer[1] | (UInt16(Buffer[2]) << 8); KeepAliveIntervalMs= Buffer[3] | (UInt16(Buffer[4]) << 8); }
void VoodooI2CHIDDevice::i2c_hid_get_input(OSObject* owner, IOTimerEventSource* sender) { // IOLog("getting input\n"); UInt rsize; int ret; static unsigned char* rdesc_prev = NULL; static UInt rsize_prev = 0; bool new_report = true; rsize = UInt16(ihid->hdesc.wMaxInputLength); unsigned char* rdesc = (unsigned char *)IOMalloc(rsize); ret = i2c_hid_command(ihid, &hid_input_cmd, rdesc, rsize); // IOLog("===Input (%d)===\n", rsize); // for (int i = 0; i < rsize; i++) // IOLog("0x%02x ", (UInt8) rdesc[i]); // IOLog("\n"); int return_size = rdesc[0] | rdesc[1] << 8; if (return_size == 0) { /* host or device initiated RESET completed */ // test/clear bit? hid_device->timerSource->setTimeoutMS(10); return; } if (return_size > rsize) { IOLog("%s: Incomplete report %d/%d\n", __func__, rsize, return_size); } IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, return_size); buffer->writeBytes(0, rdesc + 2, return_size - 2); #define FILTER_REPEATED_REPORTS /* Needed on my ASUS/Skylake ELAN1000 */ #ifdef FILTER_REPEATED_REPORTS /* Compare to previous report */ if (rdesc_prev) { /* See if they're different! */ if (rsize == rsize_prev) { if (memcmp(rdesc_prev, rdesc, rsize)) { new_report = true; } else { new_report = false; } } else { new_report = true; } /* We don't need the previous report anymore */ IOFree(rdesc_prev, rsize_prev); } else { new_report = true; } /* Keep for next comparison */ rdesc_prev = rdesc; rsize_prev = rsize; if (new_report) { IOReturn err = _wrapper->handleReport(buffer, kIOHIDReportTypeInput); if (err != kIOReturnSuccess) IOLog("Error handling report: 0x%.8x\n", err); } #else /* non filtered for repeating reports */ IOReturn err = _wrapper->handleReport(buffer, kIOHIDReportTypeInput); if (err != kIOReturnSuccess) IOLog("Error handling report: 0x%.8x\n", err); #endif buffer->release(); #ifndef FILTER_REPEATED_REPORTS IOFree(rdesc, rsize); #endif hid_device->timerSource->setTimeoutMS(10); }
bool CSMClusterWindow::init(void) { MultiDisplayWindowUnrecPtr pCMDWindow = NULL; BalancedMultiWindowUnrecPtr pCBMWindow = NULL; SortFirstWindowUnrecPtr pCSFWindow = NULL; SortLastWindowUnrecPtr pCSLWindow = NULL; if(_sfClusterMode.getValue() == "Multi") { pCMDWindow = MultiDisplayWindow::create(); _pWindow = pCMDWindow; _pClusterWindow = pCMDWindow; } else if(_sfClusterMode.getValue() == "Balanced") { pCBMWindow = BalancedMultiWindow::create(); pCMDWindow = pCBMWindow; _pWindow = pCBMWindow; _pClusterWindow = pCBMWindow; } else if(_sfClusterMode.getValue() == "SortFirst") { pCSFWindow = SortFirstWindow::create(); _pWindow = pCSFWindow; _pClusterWindow = pCSFWindow; } else if(_sfClusterMode.getValue() == "SortLast") { pCSLWindow = SortLastWindow::create(); _pWindow = pCSLWindow; _pClusterWindow = pCSLWindow; } else { fprintf(stderr, "Unknown cluster mode %s\n", _sfClusterMode.getValue().c_str()); } MFString::const_iterator serverIt = this->getMFServers()->begin(); MFString::const_iterator serverEnd = this->getMFServers()->end (); UInt32 uiNumServer = 0; while(serverIt != serverEnd) { fprintf(stderr, "Connecting to %s\n", serverIt->c_str()); _pClusterWindow->editMFServers()->push_back(serverIt->c_str()); ++uiNumServer; ++serverIt; } _pClusterWindow->editMFServerIds()->setValues(*(this->getMFServerIds())); _pClusterWindow->setSize(UInt16(this->getXSize()), UInt16(this->getYSize())); _pClusterWindow->setConnectionType(this->getConnectionType()); if(this->getSFComposer()->getValue() != NULL) { _pClusterWindow->setComposer(this->getSFComposer()->getValue()); } if(pCMDWindow != NULL) { if(uiNumServer != 0) { pCMDWindow->setHServers(uiNumServer / this->getServerRows()); pCMDWindow->setVServers(this->getServerRows()); } else { pCMDWindow->setHServers(1); pCMDWindow->setVServers(1); } CSMMultiWinOptions *pOpts = dynamic_cast<CSMMultiWinOptions *>(this->getOptions()); if(pOpts != NULL) { pCMDWindow->setXOverlap(pOpts->getXOverlap()); pCMDWindow->setYOverlap(pOpts->getYOverlap()); pCMDWindow->setManageClientViewports( pOpts->getManageClientViewports()); } } if(pCBMWindow != NULL) { CSMMultiWinOptions *pOpts = dynamic_cast<CSMMultiWinOptions *>(this->getOptions()); if(pOpts != NULL) { pCBMWindow->setBalance (pOpts->getBalance ()); pCBMWindow->setBestCut (pOpts->getBestCut ()); pCBMWindow->setShowBalancing(pOpts->getShowBalancing()); } } if(pCSFWindow != NULL) { CSMSortFirstWinOptions *pOpts = dynamic_cast<CSMSortFirstWinOptions *>(this->getOptions()); if(pOpts != NULL) { pCSFWindow->setCompression (pOpts->getCompression ()); pCSFWindow->setCompose (pOpts->getCompose ()); pCSFWindow->setSubtileSize (pOpts->getSubtileSize ()); pCSFWindow->setUseFaceDistribution(pOpts->getUseFaceDistribution()); } } if(_sfClientWindow.getValue() != NULL) { _sfClientWindow.getValue()->init(); if(this->getRenderClient() == true) { _pClusterWindow->setClientWindow( _sfClientWindow.getValue()->getWindow()); } } _pClusterWindow->init(); Inherited::init(); return true; }
short PhysSequence::codeGen(Generator *generator) { // Get a local handle on some of the generator objects. // CollHeap *wHeap = generator->wHeap(); Space *space = generator->getSpace(); ExpGenerator *expGen = generator->getExpGenerator(); MapTable *mapTable = generator->getMapTable(); // Allocate a new map table for this node. This must be done // before generating the code for my child so that this local // map table will be sandwiched between the map tables already // generated and the map tables generated by my offspring. // // Only the items available as output from this node will // be put in the local map table. Before exiting this function, all of // my offsprings map tables will be removed. Thus, none of the outputs // from nodes below this node will be visible to nodes above it except // those placed in the local map table and those that already exist in // my ancestors map tables. This is the standard mechanism used in the // generator for managing the access to item expressions. // MapTable *localMapTable = generator->appendAtEnd(); // Since this operation doesn't modify the row on the way down the tree, // go ahead and generate the child subtree. Capture the given composite row // descriptor and the child's returned TDB and composite row descriptor. // ex_cri_desc * givenCriDesc = generator->getCriDesc(Generator::DOWN); child(0)->codeGen(generator); ComTdb *childTdb = (ComTdb*)generator->getGenObj(); ex_cri_desc * childCriDesc = generator->getCriDesc(Generator::UP); ExplainTuple *childExplainTuple = generator->getExplainTuple(); // Make all of my child's outputs map to ATP 1. The child row is only // accessed in the project expression and it will be the second ATP // (ATP 1) passed to this expression. // localMapTable->setAllAtp(1); // My returned composite row has an additional tupp. // Int32 numberTuples = givenCriDesc->noTuples() + 1; ex_cri_desc * returnCriDesc #pragma nowarn(1506) // warning elimination = new (space) ex_cri_desc(numberTuples, space); #pragma warn(1506) // warning elimination // For now, the history buffer row looks just the return row. Later, // it may be useful to add an additional tupp for sequence function // itermediates that are not needed above this node -- thus, this // ATP is kept separate from the returned ATP. // const Int32 historyAtp = 0; const Int32 historyAtpIndex = numberTuples-1; #pragma nowarn(1506) // warning elimination ex_cri_desc *historyCriDesc = new (space) ex_cri_desc(numberTuples, space); #pragma warn(1506) // warning elimination ExpTupleDesc *historyDesc = 0; //seperate the read and retur expressions seperateReadAndReturnItems(wHeap); // The history buffer consists of items projected directly from the // child, the root sequence functions, the value arguments of the // offset functions, and running sequence functions. These elements must // be materialized in the history buffer in order to be able to compute // the outputs of this node -- the items projected directly from the child // (projectValues) and the root sequence functions (sequenceFunctions). // // Compute the set of sequence function items that must be materialized // int the history buffer. -- sequenceItems // // Compute the set of items in the history buffer: the union of the // projected values and the value arguments. -- historyIds // // Compute the set of items in the history buffer that are computed: // the difference between all the elements in the history buffer // and the projected items. -- computedHistoryIds // // KB---will need to return atp with 3 tups only 0,1 and 2 // 2 -->values from history buffer after ther are moved to it addCheckPartitionChangeExpr(generator, TRUE); ValueIdSet historyIds; historyIds += movePartIdsExpr(); historyIds += sequencedColumns(); ValueIdSet outputFromChild = child(0)->getGroupAttr()->getCharacteristicOutputs(); getHistoryAttributes(readSeqFunctions(),outputFromChild, historyIds, TRUE, wHeap); // Add in the top level sequence functions. historyIds += readSeqFunctions(); getHistoryAttributes(returnSeqFunctions(),outputFromChild, historyIds, TRUE, wHeap); // Add in the top level functions. historyIds += returnSeqFunctions(); // Layout the work tuple format which consists of the projected // columns and the computed sequence functions. First, compute // the number of attributes in the tuple. // ULng32 numberAttributes = ((NOT historyIds.isEmpty()) ? historyIds.entries() : 0); // Allocate an attribute pointer vector from the working heap. // Attributes **attrs = new(wHeap) Attributes*[numberAttributes]; // Fill in the attributes vector for the history buffer including // adding the entries to the map table. Also, compute the value ID // set for the elements to project from the child row. // //??????????re-visit this function?? computeHistoryAttributes(generator, localMapTable, attrs, historyIds); // Create the tuple descriptor for the history buffer row and // assign the offsets to the attributes. For now, this layout is // identical to the returned row. Set the tuple descriptors for // the return and history rows. // ULng32 historyRecLen; expGen->processAttributes(numberAttributes, attrs, ExpTupleDesc::SQLARK_EXPLODED_FORMAT, historyRecLen, historyAtp, historyAtpIndex, &historyDesc, ExpTupleDesc::SHORT_FORMAT); NADELETEBASIC(attrs, wHeap); #pragma nowarn(1506) // warning elimination returnCriDesc->setTupleDescriptor(historyAtpIndex, historyDesc); #pragma warn(1506) // warning elimination #pragma nowarn(1506) // warning elimination historyCriDesc->setTupleDescriptor(historyAtpIndex, historyDesc); #pragma warn(1506) // warning elimination // If there are any sequence function items, generate the sequence // function expressions. // ex_expr * readSeqExpr = NULL; if(NOT readSeqFunctions().isEmpty()) { ValueIdSet seqVals = readSeqFunctions(); seqVals += sequencedColumns(); seqVals += movePartIdsExpr(); expGen->generateSequenceExpression(seqVals, readSeqExpr); } ex_expr *checkPartChangeExpr = NULL; if (!checkPartitionChangeExpr().isEmpty()) { ItemExpr * newCheckPartitionChangeTree= checkPartitionChangeExpr().rebuildExprTree(ITM_AND,TRUE,TRUE); expGen->generateExpr(newCheckPartitionChangeTree->getValueId(), ex_expr::exp_SCAN_PRED, &checkPartChangeExpr); } //unsigned long rowLength; ex_expr * returnExpr = NULL; if(NOT returnSeqFunctions().isEmpty()) { expGen->generateSequenceExpression(returnSeqFunctions(), returnExpr); } // Generate expression to evaluate predicate on the output // ex_expr *postPred = 0; if (! selectionPred().isEmpty()) { ItemExpr * newPredTree = selectionPred().rebuildExprTree(ITM_AND,TRUE,TRUE); expGen->generateExpr(newPredTree->getValueId(), ex_expr::exp_SCAN_PRED, &postPred); } // Reset ATP's to zero for parent. // localMapTable->setAllAtp(0); // Generate expression to evaluate the cancel expression // ex_expr *cancelExpression = 0; if (! cancelExpr().isEmpty()) { ItemExpr * newCancelExprTree = cancelExpr().rebuildExprTree(ITM_AND,TRUE,TRUE); expGen->generateExpr(newCancelExprTree->getValueId(), ex_expr::exp_SCAN_PRED, &cancelExpression); } // // For overflow // // ( The following are meaningless if ! unlimitedHistoryRows() ) NABoolean noOverflow = CmpCommon::getDefault(EXE_BMO_DISABLE_OVERFLOW) == DF_ON ; NABoolean logDiagnostics = CmpCommon::getDefault(EXE_DIAGNOSTIC_EVENTS) == DF_ON ; NABoolean possibleMultipleCalls = generator->getRightSideOfFlow() ; short scratchTresholdPct = (short) CmpCommon::getDefaultLong(SCRATCH_FREESPACE_THRESHOLD_PERCENT); // determione the memory usage (amount of memory as percentage from total // physical memory used to initialize data structures) unsigned short memUsagePercent = (unsigned short) getDefault(BMO_MEMORY_USAGE_PERCENT); short memPressurePct = (short)getDefault(GEN_MEM_PRESSURE_THRESHOLD); historyRecLen = ROUND8(historyRecLen); Lng32 maxNumberOfOLAPBuffers; Lng32 maxRowsInOLAPBuffer; Lng32 minNumberOfOLAPBuffers; Lng32 numberOfWinOLAPBuffers; Lng32 olapBufferSize; computeHistoryParams(historyRecLen, maxRowsInOLAPBuffer, minNumberOfOLAPBuffers, numberOfWinOLAPBuffers, maxNumberOfOLAPBuffers, olapBufferSize); ComTdbSequence *sequenceTdb = new(space) ComTdbSequence(readSeqExpr, returnExpr, postPred, cancelExpression, getMinFollowingRows(), #pragma nowarn(1506) // warning elimination historyRecLen, historyAtpIndex, childTdb, givenCriDesc, returnCriDesc, (queue_index)getDefault(GEN_SEQFUNC_SIZE_DOWN), (queue_index)getDefault(GEN_SEQFUNC_SIZE_UP), getDefault(GEN_SEQFUNC_NUM_BUFFERS), getDefault(GEN_SEQFUNC_BUFFER_SIZE), olapBufferSize, maxNumberOfOLAPBuffers, numHistoryRows(), getUnboundedFollowing(), logDiagnostics, possibleMultipleCalls, scratchTresholdPct, memUsagePercent, memPressurePct, maxRowsInOLAPBuffer, minNumberOfOLAPBuffers, numberOfWinOLAPBuffers, noOverflow, checkPartChangeExpr); #pragma warn(1506) // warning elimination generator->initTdbFields(sequenceTdb); // update the estimated value of HistoryRowLength with actual value //setEstHistoryRowLength(historyIds.getRowLength()); double sequenceMemEst = getEstimatedRunTimeMemoryUsage(sequenceTdb); generator->addToTotalEstimatedMemory(sequenceMemEst); if(!generator->explainDisabled()) { Lng32 seqMemEstInKBPerCPU = (Lng32)(sequenceMemEst / 1024) ; seqMemEstInKBPerCPU = seqMemEstInKBPerCPU/ (MAXOF(generator->compilerStatsInfo().dop(),1)); generator->setOperEstimatedMemory(seqMemEstInKBPerCPU); generator-> setExplainTuple(addExplainInfo(sequenceTdb, childExplainTuple, 0, generator)); generator->setOperEstimatedMemory(0); } sequenceTdb->setScratchIOVectorSize((Int16)getDefault(SCRATCH_IO_VECTOR_SIZE_HASH)); sequenceTdb->setOverflowMode(generator->getOverflowMode()); sequenceTdb->setBmoMinMemBeforePressureCheck((Int16)getDefault(EXE_BMO_MIN_SIZE_BEFORE_PRESSURE_CHECK_IN_MB)); if(generator->getOverflowMode() == ComTdb::OFM_SSD ) sequenceTdb->setBMOMaxMemThresholdMB((UInt16)(ActiveSchemaDB()-> getDefaults()). getAsLong(SSD_BMO_MAX_MEM_THRESHOLD_IN_MB)); else sequenceTdb->setBMOMaxMemThresholdMB((UInt16)(ActiveSchemaDB()-> getDefaults()). getAsLong(EXE_MEMORY_AVAILABLE_IN_MB)); // The CQD EXE_MEM_LIMIT_PER_BMO_IN_MB has precedence over the mem quota sys NADefaults &defs = ActiveSchemaDB()->getDefaults(); UInt16 mmu = (UInt16)(defs.getAsDouble(EXE_MEM_LIMIT_PER_BMO_IN_MB)); UInt16 numBMOsInFrag = (UInt16)generator->getFragmentDir()->getNumBMOs(); if (mmu != 0) sequenceTdb->setMemoryQuotaMB(mmu); else { // Apply quota system if either one the following two is true: // 1. the memory limit feature is turned off and more than one BMOs // 2. the memory limit feature is turned on NABoolean mlimitPerCPU = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0; if ( mlimitPerCPU || numBMOsInFrag > 1 ) { double memQuota = computeMemoryQuota(generator->getEspLevel() == 0, mlimitPerCPU, generator->getBMOsMemoryLimitPerCPU().value(), generator->getTotalNumBMOsPerCPU(), generator->getTotalBMOsMemoryPerCPU().value(), numBMOsInFrag, generator->getFragmentDir()->getBMOsMemoryUsage() ); sequenceTdb->setMemoryQuotaMB( UInt16(memQuota) ); } } generator->setCriDesc(givenCriDesc, Generator::DOWN); generator->setCriDesc(returnCriDesc, Generator::UP); generator->setGenObj(this, sequenceTdb); return 0; }
bool CSMClusterWindow::init(void) { MultiDisplayWindowUnrecPtr pCMDWindow = NULL; BalancedMultiWindowUnrecPtr pCBMWindow = NULL; SortFirstWindowUnrecPtr pCSFWindow = NULL; SortLastWindowUnrecPtr pCSLWindow = NULL; if(_sfClusterMode.getValue() == "Multi") { pCMDWindow = MultiDisplayWindow::create(); _pWindow = pCMDWindow; _pClusterWindow = pCMDWindow; } else if(_sfClusterMode.getValue() == "Balanced") { pCBMWindow = BalancedMultiWindow::create(); pCMDWindow = pCBMWindow; _pWindow = pCBMWindow; _pClusterWindow = pCBMWindow; } else if(_sfClusterMode.getValue() == "SortFirst") { pCSFWindow = SortFirstWindow::create(); _pWindow = pCSFWindow; _pClusterWindow = pCSFWindow; } else if(_sfClusterMode.getValue() == "SortLast") { pCSLWindow = SortLastWindow::create(); _pWindow = pCSLWindow; _pClusterWindow = pCSLWindow; } else { fprintf(stderr, "Unknown cluster mode %s\n", _sfClusterMode.getValue().c_str()); } MFString::const_iterator serverIt = this->getMFServers()->begin(); MFString::const_iterator serverEnd = this->getMFServers()->end (); UInt32 uiNumServer = 0; while(serverIt != serverEnd) { fprintf(stderr, "Connecting to %s\n", serverIt->c_str()); _pClusterWindow->editMFServers()->push_back(serverIt->c_str()); ++uiNumServer; ++serverIt; } bool bServerIdsValid = false; if(this->getMFServers()->size() <= this->getMFServerIds()->size()) { _pClusterWindow->editMFServerIds()->setValues( *(this->getMFServerIds())); bServerIdsValid = true; } else { if(this->getMFServerIds()->size() != 0) { FWARNING(("Not enough server ids (%d/%d), field ignored\n", this->getMFServerIds()->size(), this->getMFServers ()->size() )); } } _pClusterWindow->setSize(UInt16(this->getXSize()), UInt16(this->getYSize())); _pClusterWindow->setConnectionType(this->getConnectionType()); if(this->getSFComposer()->getValue() != NULL) { _pClusterWindow->setComposer(this->getSFComposer()->getValue()); } if(pCMDWindow != NULL) { if(uiNumServer != 0) { pCMDWindow->setHServers(uiNumServer / this->getServerRows()); pCMDWindow->setVServers(this->getServerRows()); } else { pCMDWindow->setHServers(1); pCMDWindow->setVServers(1); } CSMMultiWinOptions *pOpts = dynamic_cast<CSMMultiWinOptions *>(this->getOptions()); if(pOpts != NULL) { pCMDWindow->setXOverlap(pOpts->getXOverlap()); pCMDWindow->setYOverlap(pOpts->getYOverlap()); pCMDWindow->setManageClientViewports( pOpts->getManageClientViewports()); } } if(pCBMWindow != NULL) { CSMMultiWinOptions *pOpts = dynamic_cast<CSMMultiWinOptions *>(this->getOptions()); if(pOpts != NULL) { pCBMWindow->setBalance (pOpts->getBalance ()); pCBMWindow->setBestCut (pOpts->getBestCut ()); pCBMWindow->setShowBalancing(pOpts->getShowBalancing()); } } if(pCSFWindow != NULL) { CSMSortFirstWinOptions *pOpts = dynamic_cast<CSMSortFirstWinOptions *>(this->getOptions()); if(pOpts != NULL) { pCSFWindow->setCompression (pOpts->getCompression ()); pCSFWindow->setCompose (pOpts->getCompose ()); pCSFWindow->setSubtileSize (pOpts->getSubtileSize ()); pCSFWindow->setUseFaceDistribution(pOpts->getUseFaceDistribution()); } } if(pCMDWindow != NULL) { MFUnrecCSMViewportPtr::const_iterator vIt = getMFViewports()->begin(); MFUnrecCSMViewportPtr::const_iterator vEnd = getMFViewports()->end (); while(vIt != vEnd) { if((*vIt)->getServerId() != -1) { UInt32 uiRealServerId = (*vIt)->getServerId(); if(bServerIdsValid == true) { Int32 iIdx = this->getMFServerIds()->findIndex(uiRealServerId); if(iIdx != -1) uiRealServerId = iIdx; } UInt32 uiHor = uiRealServerId % pCMDWindow->getHServers(); UInt32 uiVert = uiRealServerId / pCMDWindow->getHServers(); Real32 rHFact = 1.f / Real32(pCMDWindow->getHServers()); Real32 rVFact = 1.f / Real32(pCMDWindow->getVServers()); Vec2f leftBottom(Real32(uiHor ) * rHFact, Real32(uiVert) * rVFact); Vec2f rightTop (Real32(uiHor + 1) * rHFact, Real32(uiVert + 1) * rVFact); (*vIt)->setLeftBottom(leftBottom); (*vIt)->setRightTop (rightTop ); } ++vIt; } } if(_sfClientWindow.getValue() != NULL) { _sfClientWindow.getValue()->init(); if(this->getRenderClient() == true) { _pClusterWindow->setClientWindow( _sfClientWindow.getValue()->getWindow()); } } _pClusterWindow->init(); Inherited::init(); return true; }
bool JPGImageFileType::write(const Image *OSG_JPG_ARG(pImage ), std::ostream &OSG_JPG_ARG(os ), const std::string &OSG_JPG_ARG(mimetype)) { #ifdef OSG_WITH_JPG if((pImage->getBpp() != 1 && pImage->getBpp() != 3) || pImage->getDepth() != 1) { SWARNING << getMimeType() << " JPEG write only works for 2D 1 or 3 bpp images " << std::endl; return false; } struct osg_jpeg_error_mgr jerr; struct jpeg_compress_struct cinfo; cinfo.err = jpeg_std_error(&jerr.pub); if (setjmp(jerr.setjmp_buffer)) return false; cinfo.err->error_exit = osg_jpeg_error_exit; cinfo.err->output_message = osg_jpeg_output_message; cinfo.density_unit = 1; // dpi cinfo.X_density = UInt16(pImage->getResX() < 0.0f ? pImage->getResX() - 0.5f : pImage->getResX() + 0.5f); cinfo.Y_density = UInt16(pImage->getResY() < 0.0f ? pImage->getResY() - 0.5f : pImage->getResY() + 0.5f); jpeg_create_compress(&cinfo); DestinationManager *destinationManager = new ((*cinfo.mem->alloc_small)(j_common_ptr(&cinfo), JPOOL_IMAGE, sizeof(DestinationManager))) DestinationManager(&cinfo, os); cinfo.dest = reinterpret_cast<jpeg_destination_mgr*>(destinationManager); cinfo.image_width = pImage->getWidth(); cinfo.image_height = pImage->getHeight(); cinfo.input_components = pImage->getBpp(); cinfo.in_color_space = (pImage->getBpp() == 1) ? JCS_GRAYSCALE : JCS_RGB; jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, _quality, TRUE); jpeg_start_compress(&cinfo, TRUE); unsigned char *srcData = const_cast<UInt8 *>(pImage->getData()) + pImage->getSize(); int row_stride = cinfo.image_width * cinfo.input_components; while (cinfo.next_scanline < cinfo.image_height) { srcData -= row_stride; jpeg_write_scanlines(&cinfo, &srcData, 1); } jpeg_finish_compress (&cinfo); jpeg_destroy_compress(&cinfo); return true; #else SWARNING << getMimeType() << " write is not compiled into the current binary " << std::endl; return false; #endif }
bool JPGImageFileType::read( Image *OSG_JPG_ARG(pImage ), std::istream &OSG_JPG_ARG(is ), const std::string &OSG_JPG_ARG(mimetype)) { #ifdef OSG_WITH_JPG struct osg_jpeg_error_mgr jerr; struct jpeg_decompress_struct cinfo; cinfo.err = jpeg_std_error(&jerr.pub); if (setjmp(jerr.setjmp_buffer)) return false; cinfo.err->error_exit = osg_jpeg_error_exit; cinfo.err->output_message = osg_jpeg_output_message; jpeg_create_decompress(&cinfo); SourceManager *sourceManager = new ((*cinfo.mem->alloc_small)(j_common_ptr(&cinfo), JPOOL_IMAGE, sizeof(SourceManager))) SourceManager(&cinfo, is); cinfo.src = reinterpret_cast<jpeg_source_mgr *>(sourceManager); jpeg_read_header(&cinfo, TRUE); jpeg_start_decompress(&cinfo); Image::PixelFormat pixelFormat; switch (cinfo.output_components) { case 1: pixelFormat = Image::OSG_L_PF; break; case 3: pixelFormat = Image::OSG_RGB_PF; break; default: pixelFormat = Image::OSG_INVALID_PF; break; }; bool retCode; if(pImage->set(pixelFormat, cinfo.output_width, cinfo.output_height) == true) { Real32 res_x = Real32(cinfo.X_density); Real32 res_y = Real32(cinfo.Y_density); UInt16 res_unit = UInt16(cinfo.density_unit); if(res_unit == 2) // centimeter { // convert dpcm to dpi. res_x *= 2.54f; res_y *= 2.54f; res_unit = Image::OSG_RESUNIT_INCH; } pImage->setResX(res_x); pImage->setResY(res_y); pImage->setResUnit(res_unit); unsigned char *destData = pImage->editData() + pImage->getSize(); int row_stride = cinfo.output_width * cinfo.output_components; while (cinfo.output_scanline < cinfo.output_height) { destData -= row_stride; jpeg_read_scanlines(&cinfo, &destData, 1); } retCode = true; } else { retCode = false; } jpeg_finish_decompress (&cinfo); jpeg_destroy_decompress(&cinfo); return retCode; #else SWARNING << getMimeType() << " read is not compiled into the current binary " << std::endl; return false; #endif }