const LLVector3 LLDrawable::getPositionAgent() const { if (getVOVolume()) { if (isActive()) { LLVector3 pos(0,0,0); if (!isRoot()) { pos = mVObjp->getPosition(); } return pos * getRenderMatrix(); } else { return mVObjp->getPositionAgent(); } } else { return getWorldPosition(); } }
bool VariableAccessData::tallyVotesForShouldUseDoubleFormat() { ASSERT(isRoot()); if (local().isArgument() || shouldNeverUnbox() || (flags() & NodeBytecodeUsesAsArrayIndex)) return DFG::mergeDoubleFormatState(m_doubleFormatState, NotUsingDoubleFormat); if (m_doubleFormatState == CantUseDoubleFormat) return false; bool newValueOfShouldUseDoubleFormat = shouldUseDoubleFormatAccordingToVote(); if (!newValueOfShouldUseDoubleFormat) { // We monotonically convert to double. Hence, if the fixpoint leads us to conclude that we should // switch back to int, we instead ignore this and stick with double. return false; } if (m_doubleFormatState == UsingDoubleFormat) return false; return DFG::mergeDoubleFormatState(m_doubleFormatState, UsingDoubleFormat); }
QString FAlbum::namePath(bool leadingSlash) const { if (isRoot()) { return leadingSlash ? QString("/") : QString(); } QString u; if (parent()) { u = ((FAlbum*)parent())->namePath(leadingSlash); if (!parent()->isRoot()) { u += '/'; } } u += title(); return u; }
QString TAlbum::tagPath(bool leadingSlash) const { if (isRoot()) { return leadingSlash ? "/" : ""; } QString u; if (parent()) { u = ((TAlbum*)parent())->tagPath(leadingSlash); if (!parent()->isRoot()) { u += '/'; } } u += title(); return u; }
inline void TDockPlaceholder::buildGeometry() { DockPlaceholder::buildGeometry(); if (isRoot()) { // Solution 2: Set associated widgets QRect geom(geometry()); QSize horSize(geom.width(), 6); QSize vertSize(6, geom.height() + 12); setGeometry(QRect(geom.topLeft() - QPoint(6, 6), vertSize)); m_associated[0] = new TDockPlaceholder(0, 0, 0, 0); m_associated[0]->setGeometry(QRect(geom.topLeft() - QPoint(0, 6), horSize)); m_associated[1] = new TDockPlaceholder(0, 0, 0, 0); m_associated[1]->setGeometry( QRect(geom.topRight() + QPoint(1, -6), vertSize)); m_associated[2] = new TDockPlaceholder(0, 0, 0, 0); m_associated[2]->setGeometry( QRect(geom.bottomLeft() + QPoint(0, 1), horSize)); } }
// common code for submission and delivery void ReductionMgr::mergeAndDeliver(ReductionSet *set, int seqNum) { //iout << "seq " << seqNum << " complete on " << CkMyPe() << "\n" << endi; set->nextSequenceNumber++; // should match all clients ReductionSetData *data = set->getData(seqNum); if ( data->submitsRecorded != set->submitsRegistered ) { NAMD_bug("ReductionMgr::mergeAndDeliver not ready to deliver."); } if ( isRoot() ) { if ( set->requireRegistered ) { if ( set->threadIsWaiting && set->waitingForSequenceNumber == seqNum) { // awaken the thread so it can take the data CthAwaken(set->waitingThread); } } else { NAMD_die("ReductionSet::deliver will never deliver data"); } } else { // send data to parent int size = set->dataSize; ReductionSubmitMsg *msg = new(&size,1) ReductionSubmitMsg; msg->reductionSetID = set->reductionSetID; msg->sourceNode = CkMyPe(); msg->sequenceNumber = seqNum; msg->dataSize = set->dataSize; for ( int i = 0; i < msg->dataSize; ++i ) { msg->data[i] = data->data[i]; } CProxy_ReductionMgr reductionProxy(thisgroup); reductionProxy[myParent].remoteSubmit(msg); delete set->removeData(seqNum); } }
void LLDrawable::updateTexture() { LLMemType mt(LLMemType::MTYPE_DRAWABLE); if (isDead()) { llwarns << "Dead drawable updating texture!" << llendl; return; } if (getNumFaces() != mVObjp->getNumTEs()) { //drawable is transitioning its face count return; } if (getVOVolume()) { if (!isActive()) { //gPipeline.markMoved(this); } else { if (isRoot()) { mQuietCount = 0; } else { getParent()->mQuietCount = 0; } } gPipeline.markRebuild(this, LLDrawable::REBUILD_MATERIAL, TRUE); } }
void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results, BOOL for_select) { mVisible = sCurVisible; #if 0 && !LL_RELEASE_FOR_DOWNLOAD //crazy paranoid rules checking if (getVOVolume()) { if (!isRoot()) { if (isActive() && !mParent->isActive()) { llerrs << "Active drawable has static parent!" << llendl; } if (isStatic() && !mParent->isStatic()) { llerrs << "Static drawable has active parent!" << llendl; } if (mSpatialBridge) { llerrs << "Child drawable has spatial bridge!" << llendl; } } else if (isActive() && !mSpatialBridge) { llerrs << "Active root drawable has no spatial bridge!" << llendl; } else if (isStatic() && mSpatialBridge.notNull()) { llerrs << "Static drawable has spatial bridge!" << llendl; } } #endif }
//------------------------------------------------------------------------------ bool FatFile::getSFN(char* name) { dir_t* dir; if (!isOpen()) { DBG_FAIL_MACRO; goto fail; } if (isRoot()) { name[0] = '/'; name[1] = '\0'; return true; } // cache entry dir = cacheDirEntry(FatCache::CACHE_FOR_READ); if (!dir) { DBG_FAIL_MACRO; goto fail; } // format name dirName(dir, name); return true; fail: return false; }
void DBGProfileListViewItem::loadData(int view) { if(isRoot()) { switch(view) { case DBGProfileListView::ModuleView: setText(DBGProfileListView::LocationCol, m_data->location()->moduleName().section('/',-1)); break; case DBGProfileListView::ContextView: setText(DBGProfileListView::LocationCol, m_data->location()->contextName()); break; case DBGProfileListView::DetailedView: setText(DBGProfileListView::LocationCol, m_data->location()->moduleName().section('/',-1)); setText(DBGProfileListView::LineCol, QString::number(m_data->location()->line())); setText(DBGProfileListView::HitsCol, QString::number(m_data->hitCount())); setText(DBGProfileListView::AvgCol, QString().sprintf("%.3f", m_data->timeAvgHit())); setText(DBGProfileListView::TotalCol, QString().sprintf("%.3f", m_data->totalTime())); setText(DBGProfileListView::MinCol, QString().sprintf("%.3f", m_data->minTime())); setText(DBGProfileListView::MaxCol, QString().sprintf("%.3f", m_data->maxTime())); break; } // this->moveItem(lastItem()); } else { setText(DBGProfileListView::LocationCol, m_data->location()->moduleName().section('/',-1)); setText(DBGProfileListView::LineCol, QString::number(m_data->location()->line())); setText(DBGProfileListView::HitsCol, QString::number(m_data->hitCount())); setText(DBGProfileListView::AvgCol, QString().sprintf("%.3f", m_data->timeAvgHit())); setText(DBGProfileListView::TotalCol, QString().sprintf("%.3f", m_data->totalTime())); setText(DBGProfileListView::MinCol, QString().sprintf("%.3f", m_data->minTime())); setText(DBGProfileListView::MaxCol, QString().sprintf("%.3f", m_data->maxTime())); calculateTotalTime(); } }
void CameraController::run() { double averageEnergy = 0; double initialised = false; torque = new double[numMotors]; previousPosition = new double[numMotors]; angularDisplacement = new double[numMotors]; position = new double[numMotors]; energy = new double[numMotors]; initialize(); std::vector<Motor*> motor = initializeMotors(); std::vector<PositionSensor*> positionSensor = initializePositionSensors(); double lastTime = 0; while (step(TIME_STEP) != -1) { if(!initialised){ for(int i=0;i<numMotors;i++){ position[i] = 0; previousPosition[i] = 0; } } if(battery <= 0){ std::cout << "We ran out of battery! " << std::endl; return; } double time = getTime(); // camera->getImage(); // camera->saveImage("camera-"+std::to_string(t)+".png", 100); for(int i=0;i<numMotors;i++){ // Conversion calculation from // http://en.wikipedia.org/wiki/Torque#Units // E = torque * Angle position[i] = positionSensor[i]->getValue(); // Radians // std::cout << getName() << " Current motor position: " << position[i] << " previous position: " << previousPosition[i] << std::endl; torque[i] = std::abs(motor[i]->getTorqueFeedback()); // Nm angularDisplacement[i] = std::abs(previousPosition[i] - position[i]); // std:: cout << getName() << " angular displacement: " << angularDisplacement[i] << " ( " << previousPosition[i] - position[i] << " )" << std::endl; energy[i] = torque[i] * angularDisplacement[i]; // std:: cout << getName() << " energy cost: " << energy[i] << std::endl; if(i==0||i==2){ motor[i]->setPosition(sin(time+i)); } previousPosition[i] = position[i]; } if(!isRoot()){ // std::cout << getName() << "Sending energy usage: " << energy[0]+energy[1]+energy[2] << std::endl; sendEnergyUsage(energy[0]+energy[1]+energy[2]); }else{ double energyUsage = energy[0]+energy[1]+energy[2]; while(receiver->getQueueLength() > 0) { std::string message = (char*)receiver->getData(); // std::cout << getName() << "Received message: " << message << std::endl; if (message.substr(0,15).compare("[ENERGY_UPDATE]") == 0) { // std::cout << "Received energy usage from: " << MessagesManager::get(message,"ID") << ": " << MessagesManager::get(message,"ENERGY") << std::endl; energyUsage += boost::lexical_cast<double>(MessagesManager::get(message,"ENERGY")); } receiver->nextPacket(); } // energy usage in Joules battery -= energyUsage * EFFICIENCY_FACTOR; averageEnergy += energyUsage * EFFICIENCY_FACTOR; if(time - lastTime > 10) { std::cout << getName() << " Energy usage: " << averageEnergy / (time-lastTime) << " BatteryLevel: " << battery << " (" << (((double)battery/(double)batteryMax)*100.0) << "%)" << std::endl; lastTime = time; averageEnergy = 0; } } } delete [] torque; delete [] previousPosition; delete [] angularDisplacement; delete [] position; delete [] energy; }
bool BufferNode::hasCumulativeMarkedAncestor() { return isRoot()?false:parent->isCumulativeMarked() || parent->hasCumulativeMarkedAncestor(); }
// virtual nuiTreeNode* nuiFileTree::GetNewNode(const nglPath& rPath) { nuiHBox* pBox = NULL; nuiImage* pIcon = NULL; nuiLabel* pLabel = NULL; nglPath pathName = rPath; if (pathName.IsLeaf() || pathName.IsBundle()) { // no file is filtered if (mFilters.size() == 0) return NULL; else if (IsFilterSet(_T("*"))) { if (pathName.IsBundle()) pathName = pathName.GetRemovedExtension(); pBox = new nuiHBox(2); pIcon = new nuiImage(); pIcon->SetObjectName(_T("nuiFileTree::FileIcon")); pIcon->SetObjectClass(_T("nuiFileTree::FileIcon")); pLabel = new nuiLabel(pathName.GetNodeName().IsEmpty()?_T("/"):pathName.GetNodeName()); pLabel->SetObjectName(_T("nuiFileTree::FileLabel")); pLabel->SetObjectClass(_T("nuiFileTree::FileLabel")); } else { if (!IsFileFiltered(rPath.GetNodeName())) return NULL; else { if (pathName.IsBundle()) pathName = pathName.GetRemovedExtension(); pBox = new nuiHBox(2); pIcon = new nuiImage(); nglString objectName; objectName.Format(_T("nuiFileTree::FileIcon::%s"), rPath.GetExtension().ToLower().GetChars()); pIcon->SetObjectName(objectName); pIcon->SetObjectClass(objectName); pLabel = new nuiLabel(pathName.GetNodeName().IsEmpty()?_T("/"):pathName.GetNodeName()); pLabel->SetObjectName(_T("nuiFileTree::FileLabel")); pLabel->SetObjectClass(_T("nuiFileTree::FileLabel")); } } } else { if (!mShowHiddenFiles && (rPath.GetNodeName().GetChar(0) == _T('.'))) return NULL; nglString iconObjectName, labelObjectName; if (isRoot(rPath)) { iconObjectName = _T("nuiFileTree::VolumeIcon"); labelObjectName = _T("nuiFileTree::FolderLabel"); } else { iconObjectName = _T("nuiFileTree::FolderIcon"); labelObjectName = _T("nuiFileTree::FolderLabel"); } pBox = new nuiHBox(2); pIcon = new nuiImage(); pIcon->SetObjectName(iconObjectName); pIcon->SetObjectClass(iconObjectName); pLabel = new nuiLabel(rPath.GetNodeName().IsEmpty() ? rPath.GetPathName() : rPath.GetNodeName()); pLabel->SetObjectName(labelObjectName); pLabel->SetObjectClass(labelObjectName); } pBox->SetCell(0, pIcon, nuiCenter); pBox->SetCell(1, pLabel); if (!pBox) return NULL; nuiFileSelectorNode* pNewNode = new nuiFileSelectorNode(this, rPath, pBox); mEventSink.Connect(pNewNode->Activated, &nuiFileTree::OnNodeActivated, (void*)pNewNode); return pNewNode; }
void BrickAggregationFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(Level& currentLevel) const { FactoryMonitor m(*this, "Build", currentLevel); typedef Xpetra::MultiVector<double,LO,GO,NO> MultiVector_d; const ParameterList& pL = GetParameterList(); RCP<MultiVector_d> coords = Get<RCP<MultiVector_d> >(currentLevel, "Coordinates"); RCP<Matrix> A = Get< RCP<Matrix> > (currentLevel, "A"); RCP<const Map> rowMap = A->getRowMap(); RCP<const Map> colMap = A->getColMap(); RCP<const Teuchos::Comm<int> > comm = rowMap->getComm(); int numProcs = comm->getSize(); int myRank = comm->getRank(); int numPoints = colMap->getNodeNumElements(); bx_ = pL.get<int>("aggregation: brick x size"); by_ = pL.get<int>("aggregation: brick y size"); bz_ = pL.get<int>("aggregation: brick z size"); if (numProcs > 1) { // TODO: deal with block size > 1 (see comments above) TEUCHOS_TEST_FOR_EXCEPTION(bx_ > 3 || by_ > 3 || bz_ > 3, Exceptions::RuntimeError, "Currently cannot deal with brick size > 3"); } RCP<MultiVector_d> overlappedCoords = coords; RCP<const Import> importer = ImportFactory::Build(coords->getMap(), colMap); if (!importer.is_null()) { overlappedCoords = Xpetra::MultiVectorFactory<double,LO,GO,NO>::Build(colMap, coords->getNumVectors()); overlappedCoords->doImport(*coords, *importer, Xpetra::INSERT); } // Setup misc structures // Logically, we construct enough data to query topological information of a rectangular grid Setup(comm, overlappedCoords, colMap); GetOStream(Runtime0) << "Using brick size: " << bx_ << (nDim_ > 1 ? "x " + toString(by_) : "") << (nDim_ > 2 ? "x " + toString(bz_) : "") << std::endl; // Construct aggregates RCP<Aggregates> aggregates = rcp(new Aggregates(colMap)); aggregates->setObjectLabel("Brick"); ArrayRCP<LO> vertex2AggId = aggregates->GetVertex2AggId()->getDataNonConst(0); ArrayRCP<LO> procWinner = aggregates->GetProcWinner() ->getDataNonConst(0); // In the first pass, we set a mapping from a vertex to aggregate global id. We deal with a structured // rectangular mesh, therefore we know the structure of aggregates. For each vertex we can tell exactly // which aggregate it belongs to. // If we determine that the aggregate does not belong to us (i.e. the root vertex does not belong to this // processor, or is outside and we lost "" arbitration), we record the global aggregate id in order to // fetch the local info from the processor owning the aggregate. This is required for aggregates, as it // uses the local aggregate ids of the owning processor. std::set<GO> myAggGIDs, remoteAggGIDs; for (LO LID = 0; LID < numPoints; LID++) { GO aggGID = getAggGID(LID); if ((revMap_.find(getRoot(LID)) != revMap_.end()) && rowMap->isNodeGlobalElement(colMap->getGlobalElement(revMap_[getRoot(LID)]))) { // Root of the brick aggregate containing GID (<- LID) belongs to us vertex2AggId[LID] = aggGID; myAggGIDs.insert(aggGID); if (isRoot(LID)) aggregates->SetIsRoot(LID); } else { remoteAggGIDs.insert(aggGID); } } size_t numAggregates = myAggGIDs .size(); size_t numRemote = remoteAggGIDs.size(); aggregates->SetNumAggregates(numAggregates); std::map<GO,LO> AggG2L; // Map: Agg GID -> Agg LID (possibly on a different processor) std::map<GO,int> AggG2R; // Map: Agg GID -> processor rank owning aggregate Array<GO> myAggGIDsArray(numAggregates), remoteAggGIDsArray(numRemote); // Fill in the maps for aggregates that we own size_t ind = 0; for (typename std::set<GO>::const_iterator it = myAggGIDs.begin(); it != myAggGIDs.end(); it++) { AggG2L[*it] = ind; AggG2R[*it] = myRank; myAggGIDsArray[ind++] = *it; } // The map is a convenient way to fetch remote local indices from global indices. RCP<Map> aggMap = MapFactory::Build(rowMap->lib(), Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid(), myAggGIDsArray, 0, comm); ind = 0; for (typename std::set<GO>::const_iterator it = remoteAggGIDs.begin(); it != remoteAggGIDs.end(); it++) remoteAggGIDsArray[ind++] = *it; // Fetch the required aggregate local ids and ranks Array<int> remoteProcIDs(numRemote); Array<LO> remoteLIDs (numRemote); aggMap->getRemoteIndexList(remoteAggGIDsArray, remoteProcIDs, remoteLIDs); // Fill in the maps for aggregates that we don't own but which have some of our vertices for (size_t i = 0; i < numRemote; i++) { AggG2L[remoteAggGIDsArray[i]] = remoteLIDs [i]; AggG2R[remoteAggGIDsArray[i]] = remoteProcIDs[i]; } // Remap aggregate GIDs to LIDs and set up owning processors for (LO LID = 0; LID < numPoints; LID++) { if (revMap_.find(getRoot(LID)) != revMap_.end() && rowMap->isNodeGlobalElement(colMap->getGlobalElement(revMap_[getRoot(LID)]))) { GO aggGID = vertex2AggId[LID]; vertex2AggId[LID] = AggG2L[aggGID]; procWinner [LID] = AggG2R[aggGID]; } } GO numGlobalRemote; MueLu_sumAll(comm, as<GO>(numRemote), numGlobalRemote); aggregates->AggregatesCrossProcessors(numGlobalRemote); Set(currentLevel, "Aggregates", aggregates); GetOStream(Statistics0) << aggregates->description() << std::endl; }
void PropertyStorage::setProperty( LocationProperty inNode, const boost::python::object& inValue, const std::set< LocationProperty >& inNewDowntreeValues ) { /**************** * to update a property we must do several things: * * update the property value * update the property list * make sure we go through old dependencies and orphan any new orphans * check that the value is different. if so, mark anybody "uptree" of this property as "dirty" * update the level of the boost::python::object. We assume that the levels in the system are correct for * - mutables (0) * - clean nodes with everything clean below * we have to be careful, in case a dirty property depends on another dirty property. * *******************/ if (!mNode_LazyCleanAndLevel.hasKey(inNode)) mNode_LazyCleanAndLevel.set(inNode, make_pair(make_pair(inNode.isLazy(), true), 0)); bool valueChanged = true; bool valueExisted = mValues.find(inNode) != mValues.end(); if (mValues.find(inNode) != mValues.end()) { boost::python::object oldValue = mValues[inNode]; if (mValues[inNode] == inValue) valueChanged = false; } else { //this property is new. by default it's orphaned. markOrphaned(inNode); mLocationProperties.insert(inNode.getLocation(), inNode.getPropertyID()); mClassPropertyLocations.insert(inNode.getLocation().getType()->getClassID(), inNode); } mValues[inNode] = inValue; mDirtyingProperties.erase(inNode); setDependencies(inNode, inNewDowntreeValues); //std::set dirtiness setClean(inNode, true); recomputeLevel(inNode); recomputeLaziness(inNode); //now we have to std::set the cleanliness of our parents if (valueChanged) { //we mark all our uptrees as dirty const std::set<LocationProperty>& uptree(mDependencies.getKeys(inNode)); for (std::set<LocationProperty>::const_iterator it = uptree.begin(); it != uptree.end(); ++it) { setClean(*it, false); mDirtyingProperties[*it].insert(inNode); } if (valueExisted && isRoot(inNode)) { std::set<WeakRootPtr> toDrop; std::set<WeakRootPtr>::const_iterator end = mNodeRoots.find(inNode)->second.end(); std::set<WeakRootPtr>::const_iterator it = mNodeRoots.find(inNode)->second.begin(); for (;it != end; ++it) { RootPtr r = it->lock(); if (!r) toDrop.insert(*it); else r->changed(); } end = toDrop.end(); it = toDrop.begin(); for (;it != end; ++it) dropRootNode(inNode, *it); } } }
/* if prefix is omitted: if PFX_OPT set return NULL, otherwise use longjmp */ extern prefix * read_prefix(unsigned pfx_flags) { bool f_optional = !!(pfx_flags & PFX_OPT); bool fSurvey = !!(pfx_flags & PFX_SURVEY); bool fSuspectTypo = !!(pfx_flags & PFX_SUSPECT_TYPO); prefix *back_ptr, *ptr; char *name; size_t name_len = 32; size_t i; bool fNew; bool fImplicitPrefix = fTrue; int depth = -1; filepos fp_firstsep; skipblanks(); #ifndef NO_DEPRECATED if (isRoot(ch)) { if (!(pfx_flags & PFX_ALLOW_ROOT)) { compile_diagnostic(DIAG_ERR|DIAG_COL, /*ROOT is deprecated*/25); LONGJMP(file.jbSkipLine); } if (root_depr_count < 5) { compile_diagnostic(DIAG_WARN|DIAG_COL, /*ROOT is deprecated*/25); if (++root_depr_count == 5) compile_diagnostic(DIAG_WARN, /*Further uses of this deprecated feature will not be reported*/95); } nextch(); ptr = root; if (!isNames(ch)) { if (!isSep(ch)) return ptr; /* Allow optional SEPARATOR after ROOT */ get_pos(&fp_firstsep); nextch(); } fImplicitPrefix = fFalse; #else if (0) { #endif } else { if ((pfx_flags & PFX_ANON) && (isSep(ch) || (pcs->dash_for_anon_wall_station && ch == '-'))) { int first_ch = ch; filepos here; get_pos(&here); nextch(); if (isBlank(ch) || isEol(ch)) { if (!isSep(first_ch)) goto anon_wall_station; /* A single separator alone ('.' by default) is an anonymous * station which is on a point inside the passage and implies * the leg to it is a splay. */ if (TSTBIT(pcs->flags, FLAGS_ANON_ONE_END)) { set_pos(&here); compile_diagnostic(DIAG_ERR|DIAG_TOKEN, /*Can't have a leg between two anonymous stations*/3); LONGJMP(file.jbSkipLine); } pcs->flags |= BIT(FLAGS_ANON_ONE_END) | BIT(FLAGS_IMPLICIT_SPLAY); return new_anon_station(); } if (isSep(first_ch) && ch == first_ch) { nextch(); if (isBlank(ch) || isEol(ch)) { /* A double separator ('..' by default) is an anonymous station * which is on the wall and implies the leg to it is a splay. */ prefix * pfx; anon_wall_station: if (TSTBIT(pcs->flags, FLAGS_ANON_ONE_END)) { set_pos(&here); compile_diagnostic(DIAG_ERR|DIAG_TOKEN, /*Can't have a leg between two anonymous stations*/3); LONGJMP(file.jbSkipLine); } pcs->flags |= BIT(FLAGS_ANON_ONE_END) | BIT(FLAGS_IMPLICIT_SPLAY); pfx = new_anon_station(); pfx->sflags |= BIT(SFLAGS_WALL); return pfx; } if (ch == first_ch) { nextch(); if (isBlank(ch) || isEol(ch)) { /* A triple separator ('...' by default) is an anonymous * station, but otherwise not handled specially (e.g. for * a single leg down an unexplored side passage to a station * which isn't refindable). */ if (TSTBIT(pcs->flags, FLAGS_ANON_ONE_END)) { set_pos(&here); compile_diagnostic(DIAG_ERR|DIAG_TOKEN, /*Can't have a leg between two anonymous stations*/3); LONGJMP(file.jbSkipLine); } pcs->flags |= BIT(FLAGS_ANON_ONE_END); return new_anon_station(); } } } set_pos(&here); } ptr = pcs->Prefix; } i = 0; name = NULL; do { fNew = fFalse; if (name == NULL) { /* Need a new name buffer */ name = osmalloc(name_len); } /* i==0 iff this is the first pass */ if (i) { i = 0; nextch(); } while (isNames(ch)) { if (i < pcs->Truncate) { /* truncate name */ name[i++] = (pcs->Case == LOWER ? tolower(ch) : (pcs->Case == OFF ? ch : toupper(ch))); if (i >= name_len) { name_len = name_len + name_len; name = osrealloc(name, name_len); } } nextch(); } if (isSep(ch)) { fImplicitPrefix = fFalse; get_pos(&fp_firstsep); } if (i == 0) { osfree(name); if (!f_optional) { if (isEol(ch)) { if (fSurvey) { compile_diagnostic(DIAG_ERR|DIAG_COL, /*Expecting survey name*/89); } else { compile_diagnostic(DIAG_ERR|DIAG_COL, /*Expecting station name*/28); } } else { /* TRANSLATORS: Here "station" is a survey station, not a train station. */ compile_diagnostic(DIAG_ERR|DIAG_COL, /*Character “%c” not allowed in station name (use *SET NAMES to set allowed characters)*/7, ch); } LONGJMP(file.jbSkipLine); } return (prefix *)NULL; } name[i++] = '\0'; back_ptr = ptr; ptr = ptr->down; if (ptr == NULL) { /* Special case first time around at each level */ name = osrealloc(name, i); ptr = osnew(prefix); ptr->ident = name; name = NULL; ptr->right = ptr->down = NULL; ptr->pos = NULL; ptr->shape = 0; ptr->stn = NULL; ptr->up = back_ptr; ptr->filename = file.filename; ptr->line = file.line; ptr->min_export = ptr->max_export = 0; ptr->sflags = BIT(SFLAGS_SURVEY); if (fSuspectTypo && !fImplicitPrefix) ptr->sflags |= BIT(SFLAGS_SUSPECTTYPO); back_ptr->down = ptr; fNew = fTrue; } else { /* Use caching to speed up adding an increasing sequence to a * large survey */ static prefix *cached_survey = NULL, *cached_station = NULL; prefix *ptrPrev = NULL; int cmp = 1; /* result of strcmp ( -ve for <, 0 for =, +ve for > ) */ if (cached_survey == back_ptr) { cmp = strcmp(cached_station->ident, name); if (cmp <= 0) ptr = cached_station; } while (ptr && (cmp = strcmp(ptr->ident, name))<0) { ptrPrev = ptr; ptr = ptr->right; } if (cmp) { /* ie we got to one that was higher, or the end */ prefix *newptr; name = osrealloc(name, i); newptr = osnew(prefix); newptr->ident = name; name = NULL; if (ptrPrev == NULL) back_ptr->down = newptr; else ptrPrev->right = newptr; newptr->right = ptr; newptr->down = NULL; newptr->pos = NULL; newptr->shape = 0; newptr->stn = NULL; newptr->up = back_ptr; newptr->filename = file.filename; newptr->line = file.line; newptr->min_export = newptr->max_export = 0; newptr->sflags = BIT(SFLAGS_SURVEY); if (fSuspectTypo && !fImplicitPrefix) newptr->sflags |= BIT(SFLAGS_SUSPECTTYPO); ptr = newptr; fNew = fTrue; } cached_survey = back_ptr; cached_station = ptr; } depth++; f_optional = fFalse; /* disallow after first level */ if (isSep(ch)) get_pos(&fp_firstsep); } while (isSep(ch)); if (name) osfree(name); /* don't warn about a station that is referred to twice */ if (!fNew) ptr->sflags &= ~BIT(SFLAGS_SUSPECTTYPO); if (fNew) { /* fNew means SFLAGS_SURVEY is currently set */ SVX_ASSERT(TSTBIT(ptr->sflags, SFLAGS_SURVEY)); if (!fSurvey) { ptr->sflags &= ~BIT(SFLAGS_SURVEY); if (TSTBIT(pcs->infer, INFER_EXPORTS)) ptr->min_export = USHRT_MAX; } } else { /* check that the same name isn't being used for a survey and station */ if (fSurvey ^ TSTBIT(ptr->sflags, SFLAGS_SURVEY)) { /* TRANSLATORS: Here "station" is a survey station, not a train station. * * Here "survey" is a "cave map" rather than list of questions - it should be * translated to the terminology that cavers using the language would use. */ compile_diagnostic(DIAG_ERR, /*“%s” can’t be both a station and a survey*/27, sprint_prefix(ptr)); } if (!fSurvey && TSTBIT(pcs->infer, INFER_EXPORTS)) ptr->min_export = USHRT_MAX; } /* check the export level */ #if 0 printf("R min %d max %d depth %d pfx %s\n", ptr->min_export, ptr->max_export, depth, sprint_prefix(ptr)); #endif if (ptr->min_export == 0 || ptr->min_export == USHRT_MAX) { if (depth > ptr->max_export) ptr->max_export = depth; } else if (ptr->max_export < depth) { prefix *survey = ptr; char *s; const char *p; int level; for (level = ptr->max_export + 1; level; level--) { survey = survey->up; SVX_ASSERT(survey); } s = osstrdup(sprint_prefix(survey)); p = sprint_prefix(ptr); if (survey->filename) { compile_diagnostic_pfx(DIAG_ERR, survey, /*Station “%s” not exported from survey “%s”*/26, p, s); } else { compile_diagnostic(DIAG_ERR, /*Station “%s” not exported from survey “%s”*/26, p, s); } osfree(s); #if 0 printf(" *** pfx %s warning not exported enough depth %d " "ptr->max_export %d\n", sprint_prefix(ptr), depth, ptr->max_export); #endif } if (!fImplicitPrefix && (pfx_flags & PFX_WARN_SEPARATOR)) { filepos fp_tmp; get_pos(&fp_tmp); set_pos(&fp_firstsep); compile_diagnostic(DIAG_WARN|DIAG_COL, /*Separator in survey name*/392); set_pos(&fp_tmp); } return ptr; } /* if numeric expr is omitted: if f_optional return HUGE_REAL, else longjmp */ static real read_number(bool f_optional) { bool fPositive, fDigits = fFalse; real n = (real)0.0; filepos fp; int ch_old; get_pos(&fp); ch_old = ch; fPositive = !isMinus(ch); if (isSign(ch)) nextch(); while (isdigit(ch)) { n = n * (real)10.0 + (char)(ch - '0'); nextch(); fDigits = fTrue; } if (isDecimal(ch)) { real mult = (real)1.0; nextch(); while (isdigit(ch)) { mult *= (real).1; n += (char)(ch - '0') * mult; fDigits = fTrue; nextch(); } } /* !'fRead' => !fDigits so fDigits => 'fRead' */ if (fDigits) return (fPositive ? n : -n); /* didn't read a valid number. If it's optional, reset filepos & return */ set_pos(&fp); if (f_optional) { return HUGE_REAL; } if (isOmit(ch_old)) { compile_diagnostic(DIAG_ERR|DIAG_COL, /*Field may not be omitted*/8); } else { compile_diagnostic_token_show(DIAG_ERR, /*Expecting numeric field, found “%s”*/9); } LONGJMP(file.jbSkipLine); return 0.0; /* for brain-fried compilers */ }
filename_t* filename_t::concat (filename_t* other) { ___CBTPUSH; char* name; int* indices; filename_t* result; if (other->isAbsolute ()) { result = NULL; } else if (other->isReflexive ()) { result = this; reserve (); } else if (isReflexive ()) { result = other; other->reserve (); } else if (other->m_parentDirs == 0) { const int otherLen = other->m_indices[other->m_indexCount - 1]; if (isRoot ()) { allocateNameAndIndices (&name, 1 + otherLen, &indices, other->m_indexCount); memcpy (mempcpy (name, "/", 1), other->m_name, otherLen + 1); addIndices (indices, other->m_indices, other->m_indexCount, 1); result = new filename_t (name, indices, other->m_indexCount, m_parentDirs); } else { const int thisLen = m_indices[m_indexCount - 1]; allocateNameAndIndices (&name, thisLen + otherLen + 1, &indices, m_indexCount + other->m_indexCount); memcpy (mempcpy (mempcpy (name, m_name, thisLen), "/", 1), other->m_name, otherLen + 1); memcpy (indices, m_indices, sizeof (int) * m_indexCount); addIndices (indices + m_indexCount, other->m_indices, other->m_indexCount, thisLen + 1); result = new filename_t (name, indices, m_indexCount + other->m_indexCount, m_parentDirs); } } else if (m_indexCount - (m_parentDirs != 0) > other->m_parentDirs) { const int otherIndexCount = other->m_indexCount - 1; const int thisIndexCount = m_indexCount - other->m_parentDirs; const int thisLen = m_indices[thisIndexCount - 1]; const int otherLen = other->m_indices[otherIndexCount] - other->m_indices[0]; allocateNameAndIndices (&name, thisLen + otherLen, &indices, thisIndexCount + otherIndexCount); memcpy (mempcpy (name, m_name, thisLen), other->m_name + other->m_indices[0], otherLen + 1); memcpy (indices, m_indices, sizeof (int) * thisIndexCount); addIndices (indices + thisIndexCount, other->m_indices + 1, otherIndexCount, thisLen - other->m_indices[0]); result = new filename_t (name, indices, thisIndexCount + otherIndexCount, m_parentDirs); } else if (isAbsolute ()) { if (other->m_indexCount > 1) { const int otherIndexCount = other->m_indexCount - 1; const int otherLen = other->m_indices[otherIndexCount] - other->m_indices[0]; allocateNameAndIndices (&name, otherLen, &indices, otherIndexCount); memcpy (name, other->m_name + other->m_indices[0], otherLen + 1); addIndices (indices, other->m_indices + 1, otherIndexCount, -other->m_indices[0]); result = new filename_t (name, indices, otherIndexCount, 0); } else { allocateNameAndIndices (&name, 1, &indices, 1); memcpy (name, "/", 2); indices[0] = 1; result = new filename_t (name, indices, 1, 0); } } else if (m_parentDirs == 0) { const int parentDirs = other->m_parentDirs - m_indexCount; if (parentDirs > 0 || other->m_indexCount > 1) { const int indexCount = other->m_indexCount - (parentDirs == 0); const int nameOffset = other->m_indices[0] + 1 - 3 * parentDirs; const int nameLen = other->m_indices[other->m_indexCount - 1] - nameOffset; allocateNameAndIndices (&name, nameLen, &indices, indexCount); memcpy (name, other->m_name + nameOffset, nameLen + 1); addIndices (indices, other->m_indices + (parentDirs == 0), indexCount, -nameOffset); result = new filename_t (name, indices, indexCount, parentDirs); } else { allocateNameAndIndices (&name, 1, &indices, 1); memcpy (name, ".", 2); indices[0] = 1; result = new filename_t (name, indices, 1, 0); } } else { const int extraParentDirs = other->m_parentDirs - m_indexCount + 1; if (extraParentDirs > 0 || other->m_indexCount > 1) { const int indexCount = other->m_indexCount; const int nameOffset = other->m_indices[0] + 1 - 3 * extraParentDirs; const int nameLen = other->m_indices[other->m_indexCount - 1] - nameOffset; allocateNameAndIndices (&name, nameLen + 3 * m_parentDirs, &indices, indexCount); memcpy (mempcpy (name, m_name, 3 * m_parentDirs), other->m_name + nameOffset, nameLen + 1); name[3 * m_parentDirs - 1] = '/'; addIndices (indices, other->m_indices, indexCount, 3 * m_parentDirs - nameOffset); result = new filename_t (name, indices, indexCount, m_parentDirs + extraParentDirs); } else { allocateNameAndIndices (&name, 3 * m_parentDirs - 1, &indices, 1); mempcpy (name, m_name, 3 * m_parentDirs - 1); indices[0] = 3 * m_parentDirs - 1; name[3 * m_parentDirs - 1] = 0; result = new filename_t (name, indices, 1, m_parentDirs); } } ___CBTPOP; return result; }
struct _sthread *rbt_remove(struct rbt *tree, int vruntime) { struct node *delete_node = rbt_find(tree, vruntime); struct node *y; struct node *x; struct _sthread *thread; if(delete_node == NULL){ printf("Node with vruntime = %d doesn't exist\n", vruntime); return NULL; } if (delete_node->queue->first->next != NULL) return queue_remove(delete_node->queue); if(delete_node->left == tree->nil || delete_node->right == tree->nil) y = delete_node; else { y = sucessor(tree, delete_node); if(!(y->color == RED || !black_leef(tree, y))) y = predecessor(tree, delete_node); } if (y->left != tree->nil) x = y->left; else x = y->right; x->parent = y->parent; if (y->parent == tree->nil) tree->root = x; else { if (y == y->parent->left) y->parent->left = x; else y->parent->right = x; } if(y != delete_node){ substitute(tree, delete_node, y); if (isRoot(tree, y)) tree->root = y; } if (y == tree->first){ if (y->parent == tree->nil && y->right != tree->nil) tree->first = minimum(tree, y->right); else tree->first = x->parent; } if(y->color == BLACK) delete_fixup(tree, x); treeRoot(tree); lower(tree); thread = queue_remove(y->queue); destroy_node(y); return thread; }
void Dialog::on_pushButton_clicked() { qDebug() << isRoot(ui->treeWidget->currentItem()); }
// Returns "distance" between target destination and resulting xfrom F32 LLDrawable::updateXform(BOOL undamped) { BOOL damped = !undamped; // Position LLVector3 old_pos(mXform.getPosition()); LLVector3 target_pos; if (mXform.isRoot()) { // get root position in your agent's region target_pos = mVObjp->getPositionAgent(); } else { // parent-relative position target_pos = mVObjp->getPosition(); } // Rotation LLQuaternion old_rot(mXform.getRotation()); LLQuaternion target_rot = mVObjp->getRotation(); //scaling LLVector3 target_scale = mVObjp->getScale(); LLVector3 old_scale = mCurrentScale; LLVector3 dest_scale = target_scale; // Damping F32 dist_squared = 0.f; F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera); if (damped && isVisible()) { F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); dist_squared = dist_vec_squared(new_pos, target_pos); LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); dist_squared += dist_vec_squared(new_scale, target_scale); if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) { // interpolate target_pos = new_pos; target_rot = new_rot; target_scale = new_scale; } else { // snap to final position dist_squared = 0.0f; if (getVOVolume() && !isRoot()) { //child prim snapping to some position, needs a rebuild gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); } } } if ((mCurrentScale != target_scale) || (!isRoot() && (dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED || !mVObjp->getAngularVelocity().isExactlyZero() || target_pos != mXform.getPosition() || target_rot != mXform.getRotation()))) { //child prim moving or scale change requires immediate rebuild gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); } else if (!getVOVolume() && !isAvatar()) { movePartition(); } // Update mXform.setPosition(target_pos); mXform.setRotation(target_rot); mXform.setScale(LLVector3(1,1,1)); //no scale in drawable transforms (IT'S A RULE!) mXform.updateMatrix(); mCurrentScale = target_scale; if (mSpatialBridge) { gPipeline.markMoved(mSpatialBridge, FALSE); } return dist_squared; }
const LLMatrix4& LLDrawable::getRenderMatrix() const { return isRoot() ? getWorldMatrix() : getParent()->getWorldMatrix(); }
void drawBranchObject(node a, BranchAttributeObj branchAttributes, float radius1,float radius2) // Draw a cylinder subtending a node, using precomputed values from trig routine // This is currently the only place in the code I need GL_LIGHTING on // This is drawn in the original object coordinate system in which the tree is centered on 0,0 // TO DO enable attenuate on/off flag // Not doing blending or lod_cutoff for tubes yet // Currently doing the lod_cutoff for branchStyle==line only ; makes a big difference { extern GLUquadricObj *qobj; GLfloat params[4]; GLboolean valid; float darkness; float xdist,ydist,zdist; float sknots[8] = { 0,0,0,0,1,1,1,1}; GLfloat ctlpoints[4][4]; // four control points = 2 end points + two "control" points area A,Aanc; double dx,dy,dz,zr,xcross,ycross,theta, color, color_anc; A=(area)(a->data); float r1,r2,z1,z2; if (branchAttributes->branchCurvy == nurbs) // set up control points { // TO DO. CURRENTLY THESE CONTROL POINTS ARE ALL IN A VERTICAL PLANE. MAKE THE TREE CURVIER YET BY MOVING THEM OFF THIS PLANE. // Setting up the two endpoints of the edge; cubic spline will interpolate these two points // NB. These are bogus for circle layout, because there is no variation in the z-axis there, ctlpoints[0][0]=A->x_anc; ctlpoints[0][1]=A->y_anc; ctlpoints[0][2]=A->z_anc; ctlpoints[0][3]=1.0; ctlpoints[3][0]=A->x_center; ctlpoints[3][1]=A->y_center; ctlpoints[3][2]=A->z; ctlpoints[3][3]=1.0; // Setting up the two control points. These are each tweaked with a z parameter and an r parameter in the vertical plane // defined by the two endpoints of the edge, such that both when (r,z) is (0,0) at anc node and (1,1) at desc node. // So we need an (r,z) for each control point: r1,z1,r2,z2. xdist = A->x_center - A->x_anc; ydist = A->y_center - A->y_anc; zdist = A->z - A->z_anc; extern float gr1,gr2,gz1,gz2; r1 = gr1; //branchAttributes->ctlpointParms[0]; z1 = gz1; //branchAttributes->ctlpointParms[1]; r2 = gr2; //branchAttributes->ctlpointParms[2]; z2 = gz2; //branchAttributes->ctlpointParms[3]; ctlpoints[1][0]=A->x_anc + xdist*r1; ctlpoints[1][1]=A->y_anc + ydist*r1; ctlpoints[1][2]=A->z_anc + zdist*z1; ctlpoints[1][3]=1.0; ctlpoints[2][0]=A->x_anc + xdist*r2; ctlpoints[2][1]=A->y_anc + ydist*r2; ctlpoints[2][2]=A->z_anc + zdist*z2; ctlpoints[2][3]=1.0; } switch (branchAttributes->branchStyle) { case tube: { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); switch (branchAttributes->branchCurvy) { case nurbs: { if (a->marked) { darkness=1; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); } else darkness = setColorWithAttenuationLineSegment(A->x_center,A->y_center,A->z, A->x_anc,A->y_anc,A->z_anc, &(branchAttributes->color[0]), branchAttributes->attenuateFactor); // Turn off actual rendering here...no need to draw the line, just get callbacks...use GLU_tesselator gluNurbsProperty(theNurbs,GLU_NURBS_MODE,GLU_NURBS_TESSELLATOR); gluBeginCurve(theNurbs); gluNurbsCurve(theNurbs, 8, sknots, 4, &ctlpoints[0][0], 4, GL_MAP1_VERTEX_4); gluEndCurve(theNurbs); gluNurbsProperty(theNurbs,GLU_NURBS_MODE,GLU_NURBS_RENDERER); int i; float gleColor[500][4]; double gleRadius[500]; for (i=0; i<gNpoints; i++) // set the vectors of colors and radii { if (gNpoints > 500) exit(1); gleColor[i][0]= branchAttributes->color[0]; gleColor[i][1]= branchAttributes->color[1]; gleColor[i][2]= branchAttributes->color[2]; gleColor[i][3]= darkness; // don't seem to need this shit; taken care of by glMaterial if (gNpoints > 1) gleRadius[i] = radius1 + (radius2-radius1)*i/(gNpoints-1); // interpolate to vary radius between nodes of branch else gleRadius[i] = radius1; } params[0]=branchAttributes->color[0]; params[1]=branchAttributes->color[1]; params[2]=branchAttributes->color[2]; params[3]=darkness; params[3]=1.0; //override for now; I don't like how the blending looks glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); //glEnable(GL_LINE_SMOOTH); //glHint(GL_LINE_SMOOTH_HINT,GL_NICEST); // Antialiasing not working in this gle environment //glEnable(GL_POLYGON_SMOOTH); //glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, params); gleSetJoinStyle(TUBE_JN_ROUND) ; //glePolyCylinder(gNpoints,gPoint_array,gleColor,radius2); //glePolyCone_c4f(gNpoints,gPoint_array,gleColor,gleRadius); // Note if we pass gleColor, that overrides the material color and its alpha blending; // so to enable blending pass NULL in place of gleColor, and set glMaterial above glePolyCone_c4f(gNpoints,gPoint_array,NULL,gleRadius); //drawCylinder(gPoint_array[0][0],gPoint_array[0][1],gPoint_array[0][2], gPoint_array[1][0],gPoint_array[1][1],gPoint_array[1][2],radius1, radius1); // add gumby cyls at ends of gle cylinder //drawCylinder(gPoint_array[gNpoints-2][0],gPoint_array[gNpoints-2][1],gPoint_array[gNpoints-2][2], gPoint_array[gNpoints-1][0],gPoint_array[gNpoints-1][1],gPoint_array[gNpoints-1][2],radius2, radius2); // Because gle does not extrude at the two endpoints, I draw cylinders at each endpoint. To avoid gappiness at borders, I overlap the cylinder with the extruded tube by one segment (one point on the polyline), thus I run the cylinder from, e.g., point 0 to point 2, where the extrusion starts at 1. drawCylinder(gPoint_array[0][0],gPoint_array[0][1],gPoint_array[0][2], gPoint_array[2][0],gPoint_array[2][1],gPoint_array[2][2],gleRadius[0], gleRadius[2]); // add gumby cyls at ends of gle cylinder drawCylinder(gPoint_array[gNpoints-3][0],gPoint_array[gNpoints-3][1],gPoint_array[gNpoints-3][2], gPoint_array[gNpoints-1][0],gPoint_array[gNpoints-1][1],gPoint_array[gNpoints-1][2],gleRadius[gNpoints-3],gleRadius[gNpoints-1]); //glDisable(GL_LIGHTING); break; } case straight: { params[0]=branchAttributes->color[0]; params[1]=branchAttributes->color[1]; params[2]=branchAttributes->color[2]; params[3]=darkness; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, params); drawCylinder(A->x_anc,A->y_anc,A->z_anc, A->x_center,A->y_center,A->z, radius1, radius2); break; } } glDisable(GL_LIGHTING); break; } case line: { if (!isRoot(a)) { glLineWidth(branchAttributes->lineWidth); if (a->marked) { darkness=1; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(branchAttributes->color[0],branchAttributes->color[1],branchAttributes->color[2],darkness); } else darkness = setColorWithAttenuationLineSegment(A->x_center,A->y_center,A->z, A->x_anc,A->y_anc,A->z_anc, &(branchAttributes->color[0]), branchAttributes->attenuateFactor); // there is similar code in function setColorWithAttenuation() in tree_openGL, but here we have something more elaborate... switch (branchAttributes->branchCurvy) { case nurbs: { if (branchAttributes->lod_cutoff < darkness) { gluNurbsProperty(theNurbs,GLU_NURBS_MODE,GLU_NURBS_RENDERER); gluBeginCurve(theNurbs); gluNurbsCurve(theNurbs, 8, sknots, 4, &ctlpoints[0][0], 4, GL_MAP1_VERTEX_4); gluEndCurve(theNurbs); } break; } case straight: { if (branchAttributes->lod_cutoff < darkness) { glBegin(GL_LINES); glVertex3d(A->x_anc,A->y_anc,A->z_anc); glVertex3d(A->x_center,A->y_center,A->z); glEnd(); } } } break; } } } }
// Returns "distance" between target destination and resulting xfrom F32 LLDrawable::updateXform(BOOL undamped) { BOOL damped = !undamped; // Position LLVector3 old_pos(mXform.getPosition()); LLVector3 target_pos; if (mXform.isRoot()) { // get root position in your agent's region target_pos = mVObjp->getPositionAgent(); } else { // parent-relative position target_pos = mVObjp->getPosition(); } // Rotation LLQuaternion old_rot(mXform.getRotation()); LLQuaternion target_rot = mVObjp->getRotation(); //scaling LLVector3 target_scale = mVObjp->getScale(); LLVector3 old_scale = mCurrentScale; // Damping F32 dist_squared = 0.f; F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera); if (damped && isVisible()) { F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); dist_squared = dist_vec_squared(new_pos, target_pos); LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); // FIXME: This can be negative! It is be possible for some rots to 'cancel out' pos or size changes. dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); dist_squared += dist_vec_squared(new_scale, target_scale); if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) { // interpolate target_pos = new_pos; target_rot = new_rot; target_scale = new_scale; } else if (mVObjp->getAngularVelocity().isExactlyZero()) { // snap to final position (only if no target omega is applied) dist_squared = 0.0f; if (getVOVolume() && !isRoot()) { //child prim snapping to some position, needs a rebuild gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); } } } else { // The following fixes MAINT-1742 but breaks vehicles similar to MAINT-2275 // dist_squared = dist_vec_squared(old_pos, target_pos); // The following fixes MAINT-2247 but causes MAINT-2275 //dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; //dist_squared += dist_vec_squared(old_scale, target_scale); } LLVector3 vec = mCurrentScale-target_scale; if (vec*vec > MIN_INTERPOLATE_DISTANCE_SQUARED) { //scale change requires immediate rebuild mCurrentScale = target_scale; gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); } else if (!isRoot() && (!mVObjp->getAngularVelocity().isExactlyZero() || dist_squared > 0.f)) { //child prim moving relative to parent, tag as needing to be rendered atomically and rebuild dist_squared = 1.f; //keep this object on the move list if (!isState(LLDrawable::ANIMATED_CHILD)) { setState(LLDrawable::ANIMATED_CHILD); gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); mVObjp->dirtySpatialGroup(); } } else if (!isRoot() && ((dist_vec_squared(old_pos, target_pos) > 0.f) || (1.f - dot(old_rot, target_rot)) > 0.f)) { //fix for BUG-840, MAINT-2275, MAINT-1742, MAINT-2247 gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); } else if (!getVOVolume() && !isAvatar()) { movePartition(); } // Update mXform.setPosition(target_pos); mXform.setRotation(target_rot); mXform.setScale(LLVector3(1,1,1)); //no scale in drawable transforms (IT'S A RULE!) mXform.updateMatrix(); if (mSpatialBridge) { gPipeline.markMoved(mSpatialBridge, FALSE); } return dist_squared; }
/////////////////////////////////////////////////////////////////////////////////////////////////// //-- void BPTree::insert_entry(_F_FileAddr L, pKey_Attr pPrimKey, _F_FileAddr pRec) { BPTreeNode NodeL; NodeL.readNodeFromFile(L); //if L has less than n-1 key values if(NodeL.ItemOnNode < NodeL.MaxItem) { if(NodeL.IsLeaf ==1) NodeL.insertKeyInLeaf(pRec, pPrimKey); else NodeL.insertKeyNotLeaf(pPrimKey, pRec); } else { //create a new node _F_FileAddr L_ = createNodeInFile(); BPTreeNode NodeL_; pKey_Attr pPrimKey_; int n = NodeL.MaxItem + 1; if(NodeL.IsLeaf ==1) { NodeL_.IsLeaf = 1; int m; if( !(n%2) ) m = n/2 ; else m = n/2 + 1; //p[0]k[0]...k[m-1]p[m] | k[m]... // pPrimKey < k[m-1] if( NodeL.compare(NodeL.k[m-1], pPrimKey) > 0) { m--; pPrimKey_ = NodeL.createKey(NodeL.k[m]); } // k[m] > pPrimKey >= k[m-1] else if( (m == n - 1) || ( NodeL.compare(NodeL.k[m], pPrimKey) > 0 ) ) pPrimKey_ = NodeL.createKey(pPrimKey); else // pPrimKey > k[m] pPrimKey_ = NodeL.createKey(NodeL.k[m]); //copy p[m]....to L_ for(int i=m; i<NodeL.MaxItem; i++) { NodeL_.p[i-m] = NodeL.p[i]; NodeL_.k[i-m] = NodeL.k[i]; //erase NodeL.k[i] = NULL; NodeL.p[i].ulFilePageID = 0; NodeL.p[i].uiOffset = 0; NodeL_.ItemOnNode++; NodeL.ItemOnNode--; } if(NodeL.compare(pPrimKey, pPrimKey_) < 0) NodeL.insertKeyInLeaf(pRec,pPrimKey); else NodeL_.insertKeyInLeaf(pRec,pPrimKey); } else { //NodeL is not a leaf NodeL_.IsLeaf = 0; int m; if( !(n%2) ) m = n/2 ; else m = n/2 + 1; m = NodeL.MaxItem - m; //p[0],k[0]....k[m]p[m+1] | k[m+1]... //pPrimKey > k[m+1] if( NodeL.compare(pPrimKey, NodeL.k[m+1]) > 0 ) { m++; pPrimKey_ = NodeL.createKey(NodeL.k[m]); } // k[m] < pPrimKey <= k[m+1] else if( NodeL.compare(pPrimKey, NodeL.k[m]) > 0 ) { m++; pPrimKey_ = NodeL.createKey(pPrimKey); } // pPrimKey <= k[m] else { pPrimKey_ = NodeL.createKey(NodeL.k[m]); } // move and delete NodeL_.p[0].ulFilePageID = 0; NodeL_.p[0].uiOffset = 0; NodeL_.k[0] = NodeL.k[m]; NodeL.k[m] = NULL; NodeL_.ItemOnNode++; NodeL.ItemOnNode--; for(int i=m+1; i<NodeL.MaxItem; i++) { NodeL_.p[i-m] = NodeL.p[i]; NodeL_.k[i-m] = NodeL.k[i]; //erase NodeL.k[i] = NULL; NodeL.p[i].ulFilePageID = 0; NodeL.p[i].uiOffset = 0; NodeL_.ItemOnNode++; NodeL.ItemOnNode--; } NodeL_.p[i-m] = NodeL.p[i]; NodeL.p[i].ulFilePageID = 0; NodeL.p[i].uiOffset = 0; if( NodeL.compare(pPrimKey, pPrimKey_) < 0 ) NodeL.insertKeyNotLeaf(pPrimKey, pRec); else NodeL_.insertKeyNotLeaf(pPrimKey,pRec); NodeL_.deleteFirstKey(); } if( !isRoot(L) ) insert_entry(getParent(L), pPrimKey_, L_); else createNewRoot(L, pPrimKey_, L_); if(NodeL.IsLeaf == 1) { NodeL_.p[NodeL.MaxItem] = NodeL.p[NodeL.MaxItem]; NodeL.p[NodeL.MaxItem] = L_; } NodeL_.writeNodeToFile(L_); } NodeL.writeNodeToFile(L); }
void LLDrawable::makeActive() { #if !LL_RELEASE_FOR_DOWNLOAD if (mVObjp.notNull()) { U32 pcode = mVObjp->getPCode(); if (pcode == LLViewerObject::LL_VO_WATER || pcode == LLViewerObject::LL_VO_VOID_WATER || pcode == LLViewerObject::LL_VO_SURFACE_PATCH || pcode == LLViewerObject::LL_VO_PART_GROUP || pcode == LLViewerObject::LL_VO_HUD_PART_GROUP || pcode == LLViewerObject::LL_VO_GROUND || pcode == LLViewerObject::LL_VO_SKY) { llerrs << "Static viewer object has active drawable!" << llendl; } } #endif if (!isState(ACTIVE)) // && mGeneration > 0) { setState(ACTIVE); //parent must be made active first if (!isRoot() && !mParent->isActive()) { mParent->makeActive(); } //all child objects must also be active llassert_always(mVObjp); LLViewerObject::const_child_list_t& child_list = mVObjp->getChildren(); for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); iter != child_list.end(); iter++) { LLViewerObject* child = *iter; LLDrawable* drawable = child->mDrawable; if (drawable) { drawable->makeActive(); } } if (mVObjp->getPCode() == LL_PCODE_VOLUME) { if (mVObjp->isFlexible()) { return; } } if (mVObjp->getPCode() == LL_PCODE_VOLUME) { gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME, TRUE); } updatePartition(); } if (isRoot()) { mQuietCount = 0; } else { getParent()->mQuietCount = 0; } }
void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) { if (IsShown()) return; onShow(); // find selection selected_item = selection(); // width size_t count = itemCount(); if (item_size.width == 100) { // not initialized wxClientDC dc(this); dc.SetFont(*wxNORMAL_FONT); for (size_t i = 0 ; i < count ; ++i) { int text_width; dc.GetTextExtent(capitalize(itemText(i)), &text_width, 0); item_size.width = max(item_size.width, text_width + icon_size.width + 14); // 14 = room for popup arrow + padding } } // height int line_count = 0; for (size_t i = 0 ; i < count ; ++i) if (lineBelow(i)) line_count += 1; // size RealSize border_size(2,2); // GetClientSize() - GetSize(), assume 1px borders RealSize size( item_size.width + marginW * 2, item_size.height * count + marginH * 2 + line_count ); // placement int parent_height = 0; if (!in_place && viewer) { // Position the drop down list below the editor control (based on the style) Rotation rot = viewer->viewer.getRotation(); Rotater rr(rot, viewer->getRotation()); RealRect r = rot.trRectToBB(rect ? *rect : rot.getInternalRect()); if (viewer->viewer.nativeLook()) { pos = RealPoint(r.x - 3, r.y - 3); size.width = max(size.width, r.width + 6); parent_height = (int)r.height + 6; } else { pos = RealPoint(r.x - 1, r.y - 1); parent_height = (int)r.height; } } else if (parent_menu) { parent_height = -(int)item_size.height - 1; } pos = GetParent()->ClientToScreen(pos); // virtual size = item size RealSize virtual_size = size; SetVirtualSize(virtual_size); item_size.width = virtual_size.width - marginW * 2; // is there enough room for all items, or do we need a scrollbar? int room_below = wxGetDisplaySize().y - border_size.height - pos.y - parent_height - 50; int max_height = max(300, room_below); if (size.height > max_height) { size.height = max_height; size.width += wxSystemSettings::GetMetric(wxSYS_VSCROLL_ARROW_X); // width of scrollbar SetScrollbar(wxVERTICAL, 0, size.height, virtual_size.height, false); } else { SetScrollbar(wxVERTICAL,0,0,0,false); } // move & resize SetSize(add_diagonal(size, border_size)); Position(pos, wxSize(0, parent_height)); // visible item visible_start = 0; ensureSelectedItemVisible(); // set event handler if (hider) { assert(hider2); wxGetTopLevelParent(GetParent())->PushEventHandler(hider); GetParent() ->PushEventHandler(hider2); } // show if (selected_item == NO_SELECTION && itemCount() > 0) selected_item = 0; // select first item by default mouse_down = false; close_on_mouse_out = false; wxPopupWindow::Show(); if (isRoot() && GetParent()->HasCapture()) { // release capture on parent GetParent()->ReleaseMouse(); } // fix drop down arrow redrawArrowOnParent(); }
int ASNCheck::checkField(ASNTree * field) { if (!field) { return -1; } if (!m_oFormatMap[m_uiCurIdx]) { return 0; // 没有装载到校验数据则直接返回成功 } ASNUTree * tmp = NULL; if (isRoot(field->m_oNode)) { m_oFormatMap[m_uiCurIdx]->current = m_oFormatMap[m_uiCurIdx]->UTree; m_oFormatMap[m_uiCurIdx]->current->m_iCurNum = 0; } int iRet = m_oFormatMap[m_uiCurIdx]->current->UTreeCheckField(field, tmp); if (m_oFormatMap[m_uiCurIdx]->current == tmp) { m_oFormatMap[m_uiCurIdx]->current->m_iCurNum++; if (m_oFormatMap[m_uiCurIdx]->current->m_iCurNum > 1 && m_oFormatMap[m_uiCurIdx]->current->m_iCurNum > m_oFormatMap[m_uiCurIdx]->current->m_iNum && m_oFormatMap[m_uiCurIdx]->current->m_iNum > 0) { printf("ASNCheck::checkField num of the node is too big!"); return -9; // 节点出现次数超出定义的节点数 } } else { if (m_oFormatMap[m_uiCurIdx]->current->m_usFather != tmp->m_usTag) { m_oFormatMap[m_uiCurIdx]->current = tmp; m_oFormatMap[m_uiCurIdx]->current->m_iCurNum = 1; } else { m_oFormatMap[m_uiCurIdx]->current = tmp; m_oFormatMap[m_uiCurIdx]->current->m_iCurNum++; if (m_oFormatMap[m_uiCurIdx]->current->m_iCurNum > 1 && m_oFormatMap[m_uiCurIdx]->current->m_iCurNum > m_oFormatMap[m_uiCurIdx]->current->m_iNum && m_oFormatMap[m_uiCurIdx]->current->m_iNum > 0) { printf("ASNCheck::checkField num of the node is too big!"); return -9; // 节点出现次数超出定义的节点数 } } } /* TList * tmp = m_oFormatMap[2]->current->m_oNode.poNext; if (!m_oFormatMap[2]->current->m_iNum) { if (isLeaf(m_oFormatMap[2]->current->m_oNode)) { while(m_oFormatMap[2]->current->m_usFather == listObject(tmp, ASNUTree, m_oNode)->m_usTag) { m_oFormatMap[2]->current = listObject(tmp, ASNUTree, m_oNode); tmp = m_oFormatMap[2]->current->m_oNode.poNext; } } else { tmp = m_oFormatMap[2]->current->m_oNode.poPrev; } m_oFormatMap[2]->current = listObject(tmp, ASNUTree, m_oNode); } */ return iRet; }
int main(int count, char *strings[]) { SSL_CTX *ctx; int server,err; char *portnum; char *msg = "sagar"; printf("1"); if(!isRoot()) { printf("This program must be run as root/sudo user!!"); exit(0); } if ( count != 2 ) { printf("Usage: %s <portnum>\n", strings[0]); exit(0); } printf("12"); SSL_library_init(); portnum = strings[1]; ctx = InitServerCTX(); /* initialize SSL */ LoadCertificates(ctx, "mycert.pem", "mycert.pem"); /* load certs */ server = OpenListener(atoi(portnum)); /* create server socket */ while (1) { struct sockaddr_in addr; socklen_t len = sizeof(addr); SSL *ssl,*ssl1; int client = accept(server, (struct sockaddr*)&addr, &len); /* accept connection as usual */ printf("Connection: %s:%d\n",inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); ssl = SSL_new(ctx); /* get new SSL state with context */ SSL_set_fd(ssl, client); /* set connection socket to SSL state */ Servlet(ssl); // ssl1 = SSL_new(ctx); /* get new SSL state with context */ //SSL_set_fd(ssl1, client); /* set connection socket to SSL state */ // err=SSL_write(ssl1,msg,strlen(msg)); //RETURN_SSL(err); // Servlet(ssl1); //tostring(a,p); //printf("%s %d\n",a,p); //printf("%s",has1); // //hash(p); printf("22"); /* service connection */ } close(server); /* close server socket */ SSL_CTX_free(ctx); /* release context */ }
/** handle the results of the BottomUp operator * pid == 0 -> no operator or node have no holistic operator * pid == -1 -> can't start process * return -1 - error * return 0 - delete 'this' * return 1 - analyze is ready * return 2 - processing * remember: a node without SNode is a "Trash-Node" * this node must have children */ int INode::evalBottomUp(int pid) { #ifdef DEBUGMSG qDebug("#* INode::evalBottomUp(%s): pid=%d (%p)\n", (const char *) name(), pid, this); #endif if (pid <= 0) { #ifdef DEBUGMSG qDebug("# (ERROR) evalBottomUp(%p): BottomUp operator have no result \n", this); #endif //! hier noch das Icon im Browser auf rot setzen (Problem) status(TRASH); if (parent()) parent()->decrementCount(); return -1; } execState(BU); if (isRoot()) { //! Debug qDebug("INode::evalBottomUp: is Root"); #ifdef WIN32 QMessageBox::information(0,"INode","evalBottomUp: is Root",QMessageBox::Cancel); #endif } analysis_->nodeChange(this); QList < INode > &nodeList = sNode_->evalBottomUp(this); //new composition analysis_->nodeChange(this); #ifdef DEBUGMSG qDebug("# (INFO) nodeList count: %d\n", nodeList.count()); #endif if (isRoot()) { switch (nodeList.count()) { case 0: #ifdef DEBUGMSG qDebug("# (ERROR) No szene found(%p)\n", this); #endif #ifdef WIN32 QMessageBox::warning(0,"INode","evalBottomUp: No szene found"); #endif return 1; case 1:{ #ifdef DEBUGMSG qDebug("# Root node is unique (%p)\n", this); #endif //alle bis auf die zurückgegebenen aus this entfernen { //! eigentlich können die children direkt gelöscht werden! INode *trashNode = new INode(*this); #ifdef WIN32 if (trashNode == 0){ cout << "Out of Memory..11"; exit(1); } #endif trashNode->status(TRASH); { // normally this code should do nothing because the children are already moved INode *el; while (children().count()) { el = (children()).first(); trashNode->childLink(el); analysis_->nodeChange(el); } } #if 0 delete trashNode; #else analysis_->setTrashRoot(trashNode); #endif } { INode *el; INode *iNode = nodeList.first(); update(iNode->attribList()); labelImage(iNode->labelImage()); el = (iNode->children()).first(); while (el) { childLink(el); analysis_->nodeChange(el); el = (iNode->children()).first(); } delete iNode; } delete & nodeList; return 1; //=> analyze is ready } default: #ifdef DEBUGMSG qDebug("# (ERROR) Root node must be unique (%p)\n", this); #endif #ifdef WIN32 QMessageBox::warning(0,"INode","evalBottomUp: Root node must be unique"); #endif delete & nodeList; return -1; } } if (nodeList.isEmpty()) { #ifdef DEBUGMSG qDebug ("# (ERROR) evalBottomUp: QList<<INode> nodeList is empty - all trash\n"); #endif status(TRASH); parent()->decrementCount(); delete & nodeList; //return 0; // XXX TEST - fuer die Ergebnisdarstellung return 2; //=> } QListIterator < INode > it(nodeList); for (; it.current(); ++it) { INode *iNode = it.current(); analysis_->nodeChange(iNode); parent()->childLink(iNode); iNode->status(CI); INode *el; for (el = iNode->children().first(); el != 0; el = iNode->children().next()) { if (el->status() <= MI) iNode->status(MI); analysis_->nodeChange(el); //info to the rest of the world } } INode *p = parent(); //for later access if ((this->children()).isEmpty()) { #ifdef DEBUGMSG qDebug("# (INFO) evalBottomUp: empty list - no trash\n"); // #endif parent()->childUnlink(this); p->decrementCount(); delete & nodeList; return 0; // delete this; } else { //this->sNode(0); //make a TRASH Node; -> has no SNode this->status(TRASH); p->decrementCount(); delete & nodeList; //return 0; // XXX TEST - fuer die Ergebnisdarstellung return 2; } }
filename_t* filename_t::withExtension (const char* extension) { ___CBTPUSH; char* name; int namelen; int* indices; filename_t* result; const int extensionLength = strlen (extension); if (m_indexCount > 1) { /* /a/b, a/b, ../a */ const char* baseEnd = strrchr (m_name + m_indices[m_indexCount - 2] + 1, '.'); if (baseEnd == NULL) { baseEnd = m_name + m_indices[m_indexCount - 1]; } namelen = baseEnd - m_name + extensionLength + 1; allocateNameAndIndices (&name, namelen, &indices, m_indexCount); stpcpy (stpcpy ((char*) mempcpy (name, m_name, baseEnd - m_name), "."), extension); memcpy (indices, m_indices, sizeof (int) * (m_indexCount - 1)); indices[m_indexCount - 1] = namelen; result = new filename_t (name, indices, m_indexCount, m_parentDirs); } else if (m_parentDirs > 0) { /* .., ../.. */ if (extensionLength > 0) { int indexCount = 1 + (m_parentDirs > 1); namelen = m_indices[m_indexCount - 1] + extensionLength; allocateNameAndIndices (&name, namelen, &indices, indexCount); stpcpy (stpcpy (name, m_name), extension); indices[indexCount - 1] = namelen; if (indexCount > 1) { indices[0] = m_indices[m_indexCount - 1] - 3; } result = new filename_t (name, indices, indexCount, m_parentDirs - 1); } else { result = this; reserve (); } } else if (extensionLength == 0 && isRoot ()) { result = this; reserve (); } else { /* ., a, /, /a */ const char* baseEnd = strrchr (m_name, '.'); if (baseEnd == NULL) { baseEnd = m_name + m_indices[0]; } namelen = baseEnd - m_name + extensionLength + 1; allocateNameAndIndices (&name, namelen, &indices, 1); stpcpy (stpcpy ((char*) mempcpy (name, m_name, baseEnd - m_name), "."), extension); indices[0] = namelen; result = new filename_t (name, indices, 1, 0); } ___CBTPOP; return result; }