void FragmentCanvas::edit_drawing_settings() { for (;;) { ColorSpecVector co(1); co[0].set(TR("fragment color"), &itscolor); SettingsDialog dialog(0, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) modified(); if (!dialog.redo()) break; } }
void ArtifactCanvas::edit_drawing_settings() { for (;;) { StateSpecVector st; ColorSpecVector co(1); co[0].set(TR("artifact color"), &itscolor); SettingsDialog dialog(0, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) modified(); // call package_modified() if (!dialog.redo()) break; } }
int HueBridgeConnection::get(const QString &path, QObject *sender, const QString &slot) { if (m_baseApiUrl.isEmpty()) { qWarning() << "Not authenticated to bridge, cannot get" << path; return -1; } QUrl url(m_baseApiUrl + path); QNetworkRequest request; request.setUrl(url); QNetworkReply *reply = m_nam->get(request); connect(reply, SIGNAL(finished()), this, SLOT(slotOpFinished())); m_requestIdMap.insert(reply, m_requestCounter); CallbackObject co(sender, slot); m_requestSenderMap.insert(m_requestCounter, co); return m_requestCounter++; }
void SimpleRayCaster::renderDebugImage(int width, int height) { for (int y=0; y<height; y++) { for (int x=0; x<width; x++) { Eigen::Vector2f co((float)x/(float)width,(float)y/(float)height); auto zvalues = castRay(co); if (zvalues.size() > 0) { std::cout << "0"; } else { std::cout << " "; } } std::cout << std::endl; } }
//static SP<CompositeObject> ObjectWorld::loadModelobject(QString name, QString path, SP<Positation> posi){ SP<CompositeObject> co(new CompositeObject(name, CompositeObject::MovementStatic)); co->setPositation(posi); co->addListener(me_eventListener); SP<Model> m(new Model()); m->set_path(path); co->setModel(m); this->loadModel(m); all_comp_objs.append(co); return co; }
void DeploymentNodeCanvas::edit_drawing_settings() { for (;;) { StateSpecVector st(2); ColorSpecVector co(1); st[0].set(TR("write node instance \nhorizontally"), &write_horizontally); st[1].set(TR("show stereotype \nproperties"), &show_stereotype_properties); co[0].set(TR("Node color"), &itscolor); SettingsDialog dialog(&st, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) modified(); if (!dialog.redo()) break; } }
const Error *Node::SynchStart( void ) { // Ignore this for EtherCAT networks if( GetNetworkType() != NET_TYPE_CANOPEN ) return 0; uint32 id; const Error *err = GetSynchId( id ); if( !err ) err = SetSynchId( id | 0x40000000 ); if( err ) return err; RefObjLocker<CanOpen> co( GetNetworkRef() ); if( !co ) return &NodeError::NetworkUnavailable; co->SetSynchProducer( nodeID ); return 0; }
void RunView::locateEnergyPlus() { openstudio::runmanager::ConfigOptions co(true); boost::optional<int> major = getRequiredEnergyPlusVersion().getMajor(); boost::optional<int> minor = getRequiredEnergyPlusVersion().getMinor(); bool energyplus_not_installed; if (major && minor){ energyplus_not_installed = co.getTools().getAllByName("energyplus").getAllByVersion(openstudio::runmanager::ToolVersion(*major,*minor)).tools().size() == 0; } else { energyplus_not_installed = co.getTools().getAllByName("energyplus").getAllByVersion(openstudio::runmanager::ToolVersion(8,1)).tools().size() == 0; } if (energyplus_not_installed){ m_toolWarningLabel->show(); } else { m_toolWarningLabel->hide(); } }
void ActivityActionCanvas::edit_drawing_settings() { for (;;) { StateSpecVector st(1); ColorSpecVector co(1); st[0].set(TR("show opaque definition"), &show_opaque_action_definition); settings.complete(st, TRUE); co[0].set(TR("action color"), &itscolor); SettingsDialog dialog(&st, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) modified(); // call package_modified() if (!dialog.redo()) break; } }
void cur_write(char *str, int size) { int len; int flag; flag = 0; len = *co() + size; if (len % (cur_scrco() + 1) == 0) flag = 1; write(1, str, size); if (flag) { cur_bli(); if (*li() == cur_scrli()) cur_uroll(); else cur_nli(); } }
TEST_F(ControllerEngineTest, automaticReaction) { ScopedTemporaryFile script(makeTemporaryFile( "setUp = function() { engine.connectControl('[Channel1]','co','reaction'); }\n" "reaction = function(value) { if (value == 2.5) print('TEST PASSED: '+value);\n" "else print('TEST FAILED! TEST FAILED! TEST FAILED: '+value); " "return value; }\n")); cEngine->evaluate(script->fileName()); EXPECT_FALSE(cEngine->hasErrors(script->fileName())); ScopedControl co(new ControlObject(ConfigKey("[Channel1]", "co"))); co->set(0.0); EXPECT_TRUE(execute("setUp")); // The actual test // TODO: Have the JS call a function in this test class so the test framework // can tell if it actually passed or not co->set(2.5); }
void PackageCanvas::edit_drawing_settings() { for (;;) { StateSpecVector st(3); ColorSpecVector co(1); st[0].set(TR("name in tab"), &name_in_tab); st[1].set(TR("show context"), &show_context_mode); st[2].set(TR("show stereotype \nproperties"), &show_stereotype_properties); co[0].set(TR("Package color"), &itscolor); SettingsDialog dialog(&st, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) modified(); if (!dialog.redo()) break; } }
void StateActionCanvas::edit_drawing_settings() { for (;;) { StateSpecVector st(2); ColorSpecVector co(1); st[0].set(TR("drawing language"), &language); st[1].set(TR("show stereotype \nproperties"), &show_stereotype_properties); co[0].set(TR("state action color"), &itscolor); SettingsDialog dialog(&st, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) modified(); // call package_modified() if (!dialog.redo()) break; } }
const Error *Node::SynchStop( void ) { // Ignore this for EtherCAT networks if( GetNetworkType() != NET_TYPE_CANOPEN ) return 0; uint32 id; const Error *err = GetSynchId( id ); if( !err && (id&0x40000000) ) err = SetSynchId( id & 0x3FFFFFFF ); RefObjLocker<CanOpen> co( GetNetworkRef() ); if( !co ) return &NodeError::NetworkUnavailable; if( !err && (co->GetSynchProducer() == nodeID) ) co->SetSynchProducer(0); return err; }
int main() { int co_id; std::string co_name; int co_price; std::ifstream commodity("commodity.txt"); while( commodity>>co_id>>co_name>>co_price) { std::cout<<co_id<<" "<<co_name<<" "<<co_price<<std::endl; Commodity co( co_id, co_name, co_price); if ( co_id == 880001) { co.saveFile("output.txt"); } } return 0; }
void UcClassCanvas::edit_drawing_settings() { for (;;) { StateSpecVector st; ColorSpecVector co(1); settings.complete(st); co[0].set(TR("class color"), &itscolor); SettingsDialog dialog(&st, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) { modified(); package_modified(); } if (!dialog.redo()) break; } }
inline class_id_type basic_iarchive_impl::register_type( const basic_iserializer & bis ){ class_id_type cid(cobject_info_set.size()); cobject_type co(cid, bis); std::pair<cobject_info_set_type::const_iterator, bool> result = cobject_info_set.insert(co); if(result.second){ cobject_id_vector.push_back(cobject_id(bis)); BOOST_ASSERT(cobject_info_set.size() == cobject_id_vector.size()); } cid = result.first->m_class_id; // borland complains without this minor hack const int tid = cid; cobject_id & coid = cobject_id_vector[tid]; coid.bpis_ptr = bis.get_bpis_ptr(); return cid; }
void OdClassInstCanvas::edit_drawing_settings() { for (;;) { StateSpecVector st((browser_node->get_type() != UmlClass) ? 3 : 2); ColorSpecVector co(1); st[0].set(TR("write name:type \nhorizontally"), &write_horizontally); st[1].set(TR("show class context"), &show_context_mode); if (browser_node->get_type() != UmlClass) st[2].set(TR("show stereotypes \nproperties"), &show_stereotype_properties); co[0].set(TR("class instance color"), &itscolor); SettingsDialog dialog(&st, &co, FALSE); dialog.raise(); if (dialog.exec() != QDialog::Accepted) return; modified(); // call package_modified if (!dialog.redo()) break; } }
bool MozJSImplScope::exec(StringData code, const std::string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs) { MozJSEntry entry(this); JS::CompileOptions co(_context); setCompileOptions(&co); co.setFile(name.c_str()); JS::RootedScript script(_context); bool success = JS::Compile(_context, _global, co, code.rawData(), code.size(), &script); if (_checkErrorState(success, reportError, assertOnError)) return false; if (timeoutMs) _engine->getDeadlineMonitor().startDeadline(this, timeoutMs); JS::RootedValue out(_context); success = JS_ExecuteScript(_context, _global, script, &out); if (timeoutMs) _engine->getDeadlineMonitor().stopDeadline(this); if (_checkErrorState(success, reportError, assertOnError)) return false; ObjectWrapper(_context, _global).setValue(kExecResult, out); if (printResult && !out.isUndefined()) { // appears to only be used by shell std::cout << ValueWriter(_context, out).toString() << std::endl; } return true; }
// TODO: This function identification code is broken. Fix it up to be more robust // // See: SERVER-16703 for more info void MozJSImplScope::_MozJSCreateFunction(const char* raw, ScriptingFunction functionNumber, JS::MutableHandleValue fun) { std::string code = jsSkipWhiteSpace(raw); if (!hasFunctionIdentifier(code)) { if (code.find('\n') == std::string::npos && !hasJSReturn(code) && (code.find(';') == std::string::npos || code.find(';') == code.size() - 1)) { code = "return " + code; } code = "function(){ " + code + "}"; } code = str::stream() << "_funcs" << functionNumber << " = " << code; JS::CompileOptions co(_context); setCompileOptions(&co); _checkErrorState(JS::Evaluate(_context, _global, co, code.c_str(), code.length(), fun)); uassert(10232, "not a function", fun.isObject() && JS_ObjectIsFunction(_context, fun.toObjectOrNull())); }
void ActivityPartitionCanvas::edit_drawing_settings(Q3PtrList<DiagramItem> & l) { for (;;) { ColorSpecVector co(1); UmlColor itscolor; co[0].set(TR("activity partition color"), &itscolor); SettingsDialog dialog(0, &co, FALSE, TRUE); dialog.raise(); if ((dialog.exec() == QDialog::Accepted) && !co[0].name.isEmpty()) { Q3PtrListIterator<DiagramItem> it(l); for (; it.current(); ++it) { ((ActivityPartitionCanvas *) it.current())->itscolor = itscolor; ((ActivityPartitionCanvas *) it.current())->modified(); // call package_modified() } } if (!dialog.redo()) break; } }
ribi::trim::Winding ribi::trim::CalcWindingHorizontal(const std::vector<boost::shared_ptr<const Edge>>& edges) { //Are Edges nicely ordered // 0: A->B (edge[0] has A at its m_points[0] and has B at its m_points[1]) // 1: B->C (edge[1] has B at its m_points[0] and has C at its m_points[1]) // 2: C->A (edge[2] has C at its m_points[0] and has A at its m_points[1]) const int n_edges { static_cast<int>(edges.size()) }; //Check for indeterminate ordering for (int i=0; i!=n_edges; ++i) { const int j { (i + 1) % n_edges }; assert(i < static_cast<int>(edges.size())); assert(j < static_cast<int>(edges.size())); if (edges[i]->GetTo() != edges[j]->GetFrom()) { return Winding::indeterminate; } } //Extract the points std::vector<Coordinat3D> points; for (int i=0; i!=n_edges; ++i) { Coordinat3D co( edges[i]->GetFrom()->GetCoordinat()->GetX(), edges[i]->GetFrom()->GetCoordinat()->GetY(), edges[i]->GetFrom()->GetZ().value() ); points.push_back(co); } assert(points.size() == edges.size()); HUH, ER IS OOK EEN NORMALE sClockwiseHorizontal(points, MET ABOVE HIERO) return Geometry().IsClockwiseHorizontal(points) ? Winding::clockwise : Winding::counter_clockwise ; }
std::vector<float> get_spectrum_1d(const cv::Mat_<float> &im, const int axis, const bool windowing) { if(axis >= im.dims) throw std::invalid_argument("Matrix dimension is too small to compute the spectrum along this axis"); assert(im.isContinuous()); Convolver co(im.size[axis]); if(windowing) co.set_hanning(); std::vector<float> spectrum(co.fourier_size()); std::vector<double> tot(co.fourier_size(), 0.0); std::vector<std::complex<double> > totf(co.fourier_size(), 0.0); unsigned long int step = im.step1(axis); //whatever the real dimension, we fall back to a 3d situation where the axis of interest is y //and either x or z can be of size 1 int nbplanes = 1; for(int d=0; d<axis; ++d) nbplanes *= im.size[d]; int planestep = im.total()/nbplanes; //for each plane for(int i=0; i<nbplanes; ++i) { //for each line for(size_t j=0; j<step; ++j) { co.spectrum(reinterpret_cast<float* const>(im.data) + i*planestep + j, step, &spectrum[0]); for(size_t u=0; u<spectrum.size(); ++u) tot[u] += spectrum[u]; for(size_t u=0; u<spectrum.size(); ++u) totf[u] += co.get_fourier()[u]; } } const double icount = 1.0 / (nbplanes * step); for(size_t i=0; i<tot.size(); ++i) spectrum[i] = tot[i]*icount - std::norm(totf[i]*icount); return spectrum; }
//dynamic SP<CompositeObject> ObjectWorld::loadModelobject(QString name, QString path){ SP<CompositeObject> co(new CompositeObject(name, CompositeObject::MovementDynamic)); //randomized pos, for octtree test //they won't land by default in the same node and the octtree won't //grow in depth that fast ... SP<Positation> posi(new Positation()); posi->set_position((double)((rand() & 1000)-500), (double)((rand() & 1000)-500), (double)((rand() & 1000)-500)); co->setPositation(posi); co->addListener(me_eventListener); SP<Model> m(new Model()); m->set_path(path); co->setModel(m); this->loadModel(m); count_models_in += 1; all_comp_objs.append(co); return co; }
void PackageCanvas::edit_drawing_settings(Q3PtrList<DiagramItem> & l) { for (;;) { StateSpecVector st(3); ColorSpecVector co(1); Uml3States name_in_tab; Uml3States show_stereotype_properties; ShowContextMode show_context_mode; UmlColor itscolor; st[0].set(TR("name in tab"), &name_in_tab); st[1].set(TR("show context"), &show_context_mode); st[2].set(TR("show stereotype \nproperties"), &show_stereotype_properties); co[0].set(TR("Package color"), &itscolor); SettingsDialog dialog(&st, &co, FALSE, TRUE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) { Q3PtrListIterator<DiagramItem> it(l); for (; it.current(); ++it) { if (!st[0].name.isEmpty()) ((PackageCanvas *) it.current())->name_in_tab = name_in_tab; if (!st[1].name.isEmpty()) ((PackageCanvas *) it.current())->show_context_mode = show_context_mode; if (!st[2].name.isEmpty()) ((PackageCanvas *) it.current())->show_stereotype_properties = show_stereotype_properties; if (!co[0].name.isEmpty()) ((PackageCanvas *) it.current())->itscolor = itscolor; ((PackageCanvas *) it.current())->modified(); // call package_modified() } } if (!dialog.redo()) break; } }
void spawn(const F& f,std::size_t stack_size = coroutine_type::default_stack_size()) { coroutine_pointer co(new coroutine_type(*this,f,stack_size)); io_service_.post(boost::bind(&self_type::do_spawn,this,co)); }
void ApplyMeasureNowDialog::runMeasure() { runmanager::ConfigOptions co(true); if (co.getTools().getAllByName("ruby").tools().size() == 0) { QMessageBox::information(this, "Missing Ruby", "Ruby could not be located.\nOpenStudio will scan for tools.", QMessageBox::Ok); co.findTools(true); openstudio::runmanager::RunManager rm; rm.setConfigOptions(co); rm.showConfigGui(); rm.getConfigOptions().saveQSettings(); emit toolsUpdated(); if (co.getTools().getAllByName("ruby").tools().size() == 0) { QMessageBox::information(this, "Missing Ruby", "Ruby was not located by tool search.\nPlease ensure Ruby correctly installed.\nSimulation aborted.", QMessageBox::Ok); m_mainPaneStackedWidget->setCurrentIndex(m_inputPageIdx); m_timer->stop(); this->okButton()->hide(); this->backButton()->hide(); return; } } m_mainPaneStackedWidget->setCurrentIndex(m_runningPageIdx); m_timer->start(50); this->okButton()->hide(); this->backButton()->hide(); OS_ASSERT(m_model); openstudio::OSAppBase * app = OSAppBase::instance(); m_workingDir = openstudio::toPath(app->currentDocument()->modelTempDir()) / openstudio::toPath("ApplyMeasureNow"); openstudio::path modelPath = m_workingDir / openstudio::toPath("modelClone.osm"); openstudio::path epwPath; // DLM: todo look at how this is done in the run tab removeWorkingDir(); // save cloned model to temp directory m_model->save(modelPath,true); // remove? this is shown only in debug (EW) QString path("Measure Output Location: "); path.append(toQString(m_workingDir)); m_jobPath->setText(path); analysis::RubyMeasure rubyMeasure = m_currentMeasureItem->measure(); // DLM: should be able to assert this bool hasIncompleteArguments = m_currentMeasureItem->hasIncompleteArguments(); OS_ASSERT(!hasIncompleteArguments); runmanager::RubyJobBuilder rjb(*m_bclMeasure, rubyMeasure.arguments()); openstudio::path p = getOpenStudioRubyIncludePath(); QString arg = "-I"; arg.append(toQString(p)); rjb.addToolArgument(arg.toStdString()); openstudio::runmanager::Workflow wf; rjb.addToWorkflow(wf); wf.add(co.getTools()); wf.setInputFiles(modelPath, openstudio::path()); m_job = wf.create(m_workingDir, modelPath); // DLM: you could make rm a class member then you would not have to call waitForFinished here runmanager::RunManager rm; bool queued = rm.enqueue(*m_job, true); OS_ASSERT(queued); std::vector<runmanager::Job> jobs = rm.getJobs(); OS_ASSERT(jobs.size() == 1); rm.waitForFinished (); QTimer::singleShot(0, this, SLOT(displayResults())); }
std::string generator_opencl::co(const node& n) { switch (n.type) { case node::entry_point: return "p"; case node::const_var: return std::to_string(n.aux_var); case node::const_bool: return std::to_string(n.aux_bool); case node::const_str: throw std::runtime_error("string encountered"); case node::rotate: return "p_rotate" + pl(n); case node::rotate3: return "p_rotate3(" + co(n.input[0]) + ", (double3)(" + co(n.input[1]) + "," + co(n.input[2]) + "," + co(n.input[3]) + "), " + co(n.input[4]) + ")"; case node::scale: case node::scale3: return "(" + co(n.input[0]) + "/" + co(n.input[1]) + ")"; case node::shift: return "(" + co(n.input[0]) + "+(double2)(" + co(n.input[1]) + "," + co(n.input[2]) + "))"; case node::shift3: return "(" + co(n.input[0]) + "+(double3)(" + co(n.input[1]) + "," + co(n.input[2]) + "," + co(n.input[3]) + "))"; case node::swap: return "p_swap" + pl(n); case node::map: { std::string func_name{std::string("ip_map") + std::to_string(count_++)}; std::stringstream func_body; func_body << "inline double2 " << func_name << " (const double2 p) { return (double2)(" << co(n.input[1]) << ", " << co(n.input[2]) << "); }" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + ")"; } case node::map3: { std::string func_name{"ip_map3" + std::to_string(count_++)}; std::stringstream func_body; func_body << "inline double3 " << func_name << " (const double3 p) { return (double3)(" << co(n.input[1]) << ", " << co(n.input[2]) << ", " << co(n.input[3]) << "); }" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + ")"; } case node::turbulence: { std::string func_name("ip_turb" + std::to_string(count_++)); std::stringstream func_body; func_body << "inline double2 " << func_name << " (const double2 p) { return (double2)(" << "p.x+(" << co(n.input[1]) << "), " << "p.y+(" << co(n.input[2]) << ")); }" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + ")"; } case node::turbulence3: { std::string func_name("ip_turb3" + std::to_string(count_++)); std::stringstream func_body; func_body << "inline double3 " << func_name << " (const double3 p) { return (double3)(" << "p.x+(" << co(n.input[1]) << "), " << "p.y+(" << co(n.input[2]) << "), " << "p.z+(" << co(n.input[3]) << ")); }" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + ")"; } case node::worley: { std::string func_name("ip_worley" + std::to_string(count_++)); std::stringstream func_body; func_body << "inline double " << func_name << " (const double2 q, uint seed) { " << " double2 p = p_worley(q, seed);" << " return " << co(n.input[1]) << "; }" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + "," + co(n.input[2]) + ")"; } case node::worley3: { std::string func_name("ip_worley3" + std::to_string(count_++)); std::stringstream func_body; func_body << "inline double " << func_name << " (const double3 q, uint seed) { " << " double3 p = p_worley3(q, seed);" << " return " << co(n.input[1]) << "; }" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + "," + co(n.input[2]) + ")"; } case node::voronoi: { std::string func_name("ip_voronoi" + std::to_string(count_++)); std::stringstream func_body; func_body << "inline double " << func_name << " (const double2 q, uint seed) { " << " double2 p = p_voronoi(q, seed);" << " return " << co(n.input[1]) << "; }" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + "," + co(n.input[2]) + ")"; } case node::angle: return "p_angle" + pl(n); case node::chebyshev: return "p_chebyshev" + pl(n); case node::chebyshev3: return "p_chebyshev3" + pl(n); case node::checkerboard: return "p_checkerboard" + pl(n); case node::checkerboard3: return "p_checkerboard3" + pl(n); case node::distance: case node::distance3: return "length" + pl(n); case node::manhattan: return "p_manhattan" + pl(n); case node::manhattan3: return "p_manhattan3" + pl(n); case node::perlin: return "p_perlin" + pl(n); case node::perlin3: return "p_perlin3" + pl(n); case node::simplex: return "p_simplex" + pl(n); case node::simplex3: return "p_simplex3" + pl(n); case node::opensimplex: return "p_opensimplex" + pl(n); case node::opensimplex3: return "p_opensimplex3" + pl(n); case node::x: return co(n.input[0]) + ".x"; case node::y: return co(n.input[0]) + ".y"; case node::z: return co(n.input[0]) + ".z"; case node::xy: return co(n.input[0]) + ".xy"; case node::zplane: return "(double3)(" + co(n.input[0]) + "," + co(n.input[1]) + ")"; case node::add: return "(" + co(n.input[0]) + "+" + co(n.input[1]) + ")"; case node::sub: return "(" + co(n.input[0]) + "-" + co(n.input[1]) + ")"; case node::mul: return "(" + co(n.input[0]) + "*" + co(n.input[1]) + ")"; case node::div: return "(" + co(n.input[0]) + "/" + co(n.input[1]) + ")"; case node::abs: return "fabs" + pl(n); case node::blend: return "p_blend" + pl(n); case node::cos: return "cospi" + pl(n); case node::min: return "fmin" + pl(n); case node::max: return "fmax" + pl(n); case node::neg: return "-" + co(n.input[0]); case node::pow: { if (n.input[1].is_const) { double exp(std::floor(n.input[1].aux_var)); if (std::abs(exp - n.input[1].aux_var) < 1e-9) return "pown(" + co(n.input[0]) + "," + std::to_string((int)exp) + ")"; } return "pow" + pl(n); } case node::round: return "round" + pl(n); case node::saw: return "p_saw" + pl(n); case node::sin: return "sinpi" + pl(n); case node::sqrt: return "sqrt" + pl(n); case node::tan: return "tanpi" + pl(n); case node::band: return co(n.input[0]) + "&&" + co(n.input[1]); case node::bor: return co(n.input[0]) + "||" + co(n.input[1]); case node::bxor: return "((" + co(n.input[0]) + ")!=(" + co(n.input[1]) + "))"; case node::bnot: return "!" + co(n.input[0]); case node::is_equal: return co(n.input[0]) + "==" + co(n.input[1]); case node::is_greaterthan: return co(n.input[0]) + ">" + co(n.input[1]); case node::is_gte: return co(n.input[0]) + ">=" + co(n.input[1]); case node::is_lessthan: return co(n.input[0]) + "<" + co(n.input[1]); case node::is_lte: return co(n.input[0]) + "<=" + co(n.input[1]); case node::is_in_circle: return "p_is_in_circle" + pl(n); case node::is_in_rectangle: return "p_is_in_rectangle" + pl(n); case node::then_else: return "(" + co(n.input[0]) + ")?(" + co(n.input[1]) + "):(" + co(n.input[2]) + ")"; case node::fractal: { assert(n.input.size() == 5); if (!n.input[2].is_const) throw std::runtime_error( "fractal octave count must be a constexpr"); int octaves(std::min<int>(n.input[2].aux_var, OPENCL_OCTAVES_LIMIT)); std::string func_name("ip_fractal_" + std::to_string(count_++)); std::stringstream func_body; func_body << "double " << func_name << " (double2 p, const double lac, const double per) {" << "double result = 0.0; double div = 0.0; double step = 1.0;" << "for(int i = 0; i < " << octaves << "; ++i)" << "{" << " result += " << co(n.input[1]) << " * step;" << " div += step;" << " step *= per;" << " p *= lac;" << " p.x += 12345.0;" << "}" << "return result / div;" << "}"; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + "," + co(n.input[3]) + "," + co(n.input[4]) + ")"; } case node::fractal3: { assert(n.input.size() == 5); if (!n.input[2].is_const) throw std::runtime_error( "fractal octave count must be a constexpr"); int octaves = std::min<int>(n.input[2].aux_var, OPENCL_OCTAVES_LIMIT); std::string func_name{"ip_fractal3_" + std::to_string(count_++)}; std::stringstream func_body; func_body << "double " << func_name << " (double3 p, const double lac, const double per) {" << "double result = 0.0; double div = 0.0; double step = 1.0;" << "for(int i = 0; i < " << octaves << "; ++i)" << "{" << " result += " << co(n.input[1]) << " * step;" << " div += step;" << " step *= per;" << " p *= lac;" << " p.x += 12345.0;" << "}" << "return result / div;" << "}"; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + "," + co(n.input[3]) + "," + co(n.input[4]) + ")"; } case node::lambda_: { assert(n.input.size() == 2); std::string func_name{"ip_lambda_" + std::to_string(count_++)}; std::string type{type_string(n.input[0])}; std::stringstream func_body; func_body << "double " << func_name << " (" << type << " p) {" << "return " << co(n.input[1]) << ";}" << std::endl; functions_.emplace_back(func_body.str()); return func_name + "(" + co(n.input[0]) + ")"; } case node::external_: throw std::runtime_error("OpenCL @external not implemented yet"); case node::curve_linear: throw std::runtime_error("OpenCL curve_linear not implemented yet"); case node::curve_spline: throw std::runtime_error("OpenCL curve_spline not implemented yet"); case node::png_lookup: throw std::runtime_error("OpenCL png_lookup not implemented yet"); default: throw std::runtime_error("function not implemented in OpenCL yet"); } return std::string(); }
void getRadiancePreRunWarningsAndErrors(std::vector<std::string> &t_warnings, std::vector<std::string> &t_errors, openstudio::runmanager::RunManager &t_runManager, boost::optional<openstudio::model::Model> &t_model) { t_warnings.clear(); t_errors.clear(); openstudio::runmanager::ConfigOptions co(true); t_runManager.setConfigOptions(co); bool ruby_not_installed = co.getTools().getAllByName("ruby").tools().size() == 0; bool radiance_not_installed = co.getTools().getAllByName("rtrace").tools().size() == 0; if(radiance_not_installed){ t_errors.push_back("Radiance is required but not found, install Radiance and scan for tools."); } if(ruby_not_installed){ t_errors.push_back("Ruby is required but not found, locate Ruby in scan for tools."); } // TODO remove when fixed #if defined(Q_OS_WIN) if(QSysInfo::windowsVersion() == QSysInfo::WV_XP){ t_errors.push_back("OpenStudio is currently unable to run Radiance on XP operating systems."); } #endif if (t_model) { // ThermalZone std::vector<model::ThermalZone> thermalZones = t_model->getModelObjects<model::ThermalZone>(); if(thermalZones.size() > 0){ //for (model::ThermalZone thermalZone : thermalZones){ // std::vector<model::Space> spaces = thermalZone.spaces(); // if(spaces.size() > 0){ // } // boost::optional<model::IlluminanceMap> illuminanceMap = thermalZone.illuminanceMap(); // if(illuminanceMap){ // } // boost::optional<model::DaylightingControl> primaryDaylightingControl = thermalZone.primaryDaylightingControl(); // if(primaryDaylightingControl){ // } //} } else{ t_errors.push_back("The OpenStudio model has no ThermalZone objects."); } // Space std::vector<model::Space> spaces = t_model->getModelObjects<model::Space>(); if(spaces.size() == 0){ t_errors.push_back("The OpenStudio model has no Space objects."); } // IlluminanceMap std::vector<model::IlluminanceMap> illuminanceMaps = t_model->getModelObjects<model::IlluminanceMap>(); if(illuminanceMaps.size() > 0){ for (model::IlluminanceMap illuminanceMap : illuminanceMaps){ boost::optional<model::Space> space = illuminanceMap.space(); if(!space){ t_errors.push_back("An OpenStudio model IlluminanceMap object is not assigned to a Space object."); break; } else{ //boost::optional<model::ThermalZone> thermalZone = space->thermalZone(); //std::vector<model::DaylightingControl> daylightingControls = space->daylightingControls(); //std::vector<model::IlluminanceMap> illuminanceMaps = space->illuminanceMaps(); //std::vector<model::GlareSensor> glareSensors = space->glareSensors(); } } } else{ t_errors.push_back("The OpenStudio model has no IlluminanceMap objects."); } // DaylightingControl std::vector<model::DaylightingControl> daylightingControls = t_model->getModelObjects<model::DaylightingControl>(); if(daylightingControls.size() > 0){ for (model::DaylightingControl daylightingControl : daylightingControls){ boost::optional<model::Space> space = daylightingControl.space(); if(!space){ t_errors.push_back("An OpenStudio model DaylightingControl object is not assigned to a Space object."); break; } } } else{ t_errors.push_back("The OpenStudio model has no DaylightingControl objects."); } // GlareSensor std::vector<model::GlareSensor> glareSensors = t_model->getModelObjects<model::GlareSensor>(); if(glareSensors.size() == 0){ t_warnings.push_back("The OpenStudio model has no GlareSensor objects."); } } }
bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance) { RAS_DisplayArrayList::iterator it; iterator mit; size_t i; // verify if we can join if (m_joinSlot || m_joinedSlots.size() || target->m_joinSlot) return false; if (!Equals(target)) return false; MT_Vector3 co(&m_OpenGLMatrix[12]); MT_Vector3 targetco(&target->m_OpenGLMatrix[12]); if ((co - targetco).length() > distance) return false; MT_Matrix4x4 mat(m_OpenGLMatrix); MT_Matrix4x4 targetmat(target->m_OpenGLMatrix); targetmat.invert(); MT_Matrix4x4 transform = targetmat*mat; // m_mesh, clientobj m_joinSlot = target; m_joinInvTransform = transform; m_joinInvTransform.invert(); target->m_joinedSlots.push_back(this); MT_Matrix4x4 ntransform = m_joinInvTransform.transposed(); ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f; for (begin(mit); !end(mit); next(mit)) for (i=mit.startvertex; i<mit.endvertex; i++) mit.vertex[i].Transform(transform, ntransform); /* We know we'll need a list at least this big, reserve in advance */ target->m_displayArrays.reserve(target->m_displayArrays.size() + m_displayArrays.size()); for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { target->m_displayArrays.push_back(*it); target->m_endarray++; target->m_endvertex = target->m_displayArrays.back()->m_vertex.size(); target->m_endindex = target->m_displayArrays.back()->m_index.size(); } if (m_DisplayList) { m_DisplayList->Release(); m_DisplayList = NULL; } if (target->m_DisplayList) { target->m_DisplayList->Release(); target->m_DisplayList = NULL; } return true; #if 0 return false; #endif }