Surface makeGenCyl(const Curve &profile, const Curve &sweep ) { Surface surface; if (!checkFlat(profile)) { cerr << "genCyl profile curve must be flat on xy plane." << endl; exit(0); } // TODO: Here you should build the surface. See surf.h for details. Curve c = profile; Curve sweepL = sweep; unsigned step = sweep.size(); Matrix4f transform; Matrix4f transinverse; Curve newc; vector<Curve> clist; for(unsigned i=0;i<step;i++){//sweepL.size();i++){ CurvePoint p = sweepL[i]; transform = getTransform(p); transinverse = transform.inverse(); transinverse.transpose(); newc.clear(); for(unsigned j=0;j<c.size();j++){ Vector4f tempV = transform*Vector4f(c[j].V,1); Vector4f tempN = transinverse*Vector4f(c[j].N,1); Vector3f newV = Vector3f(tempV[0],tempV[1],tempV[2]); Vector3f newN = Vector3f(-tempN[0],-tempN[1],-tempN[2]); struct CurvePoint newp = {newV,c[j].T,newN,c[j].B}; newc.push_back(newp); } clist.push_back(newc); } for(unsigned k=0;k<clist.size()-1;k++){ pushVV(surface,clist[k]); addTriangle(surface,clist[k],clist[k+1],k); } pushVV(surface,clist[clist.size()-1]); pushVV(surface,clist[0]); addTriangle(surface,clist[clist.size()-1],clist[0],clist.size()-1); return surface; }
Curve * Volume::getMA (Entity *settings) { QVariant *type = settings->get(QString("maType")); if (! type) return 0; QVariant *period = settings->get(QString("maPeriod")); if (! period) return 0; QVariant *var = settings->get(QString("maColor")); if (! var) return 0; QColor color(var->toString()); QVariant *label = settings->get(QString("maLabel")); if (! label) return 0; QVariant *style = settings->get(QString("maStyle")); if (! style) return 0; QVariant *width = settings->get(QString("maWidth")); if (! width) return 0; BarType bt; if (! getMA(bt.indexToString(BarType::_VOLUME), label->toString(), type->toInt(), period->toInt())) return 0; Curve *curve = new Curve(QString("CurveLine")); curve->setLabel(label->toString()); CurveLineType clt; curve->setStyle(clt.stringToIndex(style->toString())); curve->setPen(width->toInt()); curve->setColor(color); curve->fill(label->toString(), QString(), QString(), QString(), color); return curve; }
Curve * OHLC::getOHLC (QString tstyle, QString key, QString tuc, QString tdc, QString tnc) { if (! g_symbol) return 0; Curve *ohlc = new Curve(QString("CurveOHLC")); ohlc->setLabel(key); CurveOHLCType ohlcType; ohlc->setStyle(ohlcType.stringToIndex(tstyle)); QColor uc(tuc); QColor dc(tdc); QColor nc(tnc); BarType bt; ohlc->fill(bt.indexToString(BarType::_OPEN), bt.indexToString(BarType::_HIGH), bt.indexToString(BarType::_LOW), bt.indexToString(BarType::_CLOSE), nc); QList<int> keys = g_symbol->keys(); for (int pos = 1; pos < keys.size(); pos++) { Bar *pbar = ohlc->bar(keys.at(pos - 1)); Bar *bar = ohlc->bar(keys.at(pos)); if (bar->close() > pbar->close()) bar->setColor(uc); else { if (bar->close() < pbar->close()) bar->setColor(dc); } } return ohlc; }
/** * This uses the local bounds functions of curves to generically intersect two. * It passes in the curves, time intervals, and keeps track of depth, while * returning the results through the Crossings parameter. */ void pair_intersect(Curve const & A, double Al, double Ah, Curve const & B, double Bl, double Bh, Crossings &ret, unsigned depth=0) { // std::cout << depth << "(" << Al << ", " << Ah << ")\n"; OptRect Ar = A.boundsLocal(Interval(Al, Ah)); if (!Ar) return; OptRect Br = B.boundsLocal(Interval(Bl, Bh)); if (!Br) return; if(! Ar->intersects(*Br)) return; //Checks the general linearity of the function if((depth > 12)) { // || (A.boundsLocal(Interval(Al, Ah), 1).maxExtent() < 0.1 //&& B.boundsLocal(Interval(Bl, Bh), 1).maxExtent() < 0.1)) { double tA, tB, c; if(linear_intersect(A.pointAt(Al), A.pointAt(Ah), B.pointAt(Bl), B.pointAt(Bh), tA, tB, c)) { tA = tA * (Ah - Al) + Al; tB = tB * (Bh - Bl) + Bl; intersect_polish_root(A, tA, B, tB); if(depth % 2) ret.push_back(Crossing(tB, tA, c < 0)); else ret.push_back(Crossing(tA, tB, c > 0)); return; } } if(depth > 12) return; double mid = (Bl + Bh)/2; pair_intersect(B, Bl, mid, A, Al, Ah, ret, depth+1); pair_intersect(B, mid, Bh, A, Al, Ah, ret, depth+1); }
int lua_Curve_setPoint(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 5: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER && (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) && (lua_type(state, 5) == LUA_TSTRING || lua_type(state, 5) == LUA_TNIL)) { // Get parameter 1 off the stack. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); // Get parameter 3 off the stack. gameplay::ScriptUtil::LuaArray<float> param3 = gameplay::ScriptUtil::getFloatPointer(4); // Get parameter 4 off the stack. Curve::InterpolationType param4 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 5)); Curve* instance = getInstance(state); instance->setPoint(param1, param2, param3, param4); return 0; } } while (0); lua_pushstring(state, "lua_Curve_setPoint - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 7: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER && (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) && (lua_type(state, 5) == LUA_TSTRING || lua_type(state, 5) == LUA_TNIL) && (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) && (lua_type(state, 7) == LUA_TTABLE || lua_type(state, 7) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); // Get parameter 3 off the stack. gameplay::ScriptUtil::LuaArray<float> param3 = gameplay::ScriptUtil::getFloatPointer(4); // Get parameter 4 off the stack. Curve::InterpolationType param4 = (Curve::InterpolationType)lua_enumFromString_CurveInterpolationType(luaL_checkstring(state, 5)); // Get parameter 5 off the stack. gameplay::ScriptUtil::LuaArray<float> param5 = gameplay::ScriptUtil::getFloatPointer(6); // Get parameter 6 off the stack. gameplay::ScriptUtil::LuaArray<float> param6 = gameplay::ScriptUtil::getFloatPointer(7); Curve* instance = getInstance(state); instance->setPoint(param1, param2, param3, param4, param5, param6); return 0; } } while (0); lua_pushstring(state, "lua_Curve_setPoint - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 5 or 7)."); lua_error(state); break; } } return 0; }
int main(int argc, char ** argv) { const char *prefix = ""; int num = -1, syncsteps = 0, bignum = 0; long maxsteps = 5000; bool debug = false, parsed = false, lazy = false; enum { BRUTEFORCE, RANDOMWALK, MONTECARLO, STUNEL, GDMIN } alg = STUNEL; char *fmeasured = 0; const char *tprefix = "."; MinChi *min = 0; float alpha = 0.1,beta = 5e-3,gamma = 500; long gdmin_set_size = -1; MPI_Init(&argc,&argv); cout << "# "; for (int i=0; i<argc; i++) cout << argv[i] << " "; cout << endl; int opt; while ((opt = getopt(argc,argv,"n:m:b:da:l:g:s:qy:t:Lp:z:N")) != EOF) switch (opt) { case 'n': num = atoi(optarg); break; case 'N': bignum = 1; break; case 'm': fmeasured = optarg; break; case 'l': alpha = atof(optarg); break; case 'b': beta = atof(optarg); break; case 'g': gamma = atof(optarg); break; case 's': maxsteps = atol(optarg); break; case 'd': debug = true; break; case 'a': if (strcasecmp(optarg,"bruteforce") == 0) alg = BRUTEFORCE; else if (strcasecmp(optarg,"random_walk")==0) alg = RANDOMWALK; else if (strcasecmp(optarg,"montecarlo")==0) alg = MONTECARLO; else if (strcasecmp(optarg,"stunnel")==0) alg = STUNEL; else if (strcasecmp(optarg, "gdmin") == 0) alg = GDMIN; else { usage(argv[0]); return 1; } break; case 'q': parsed = true; break; case 'y': syncsteps = atoi(optarg); break; case 't': tprefix = optarg; break; case 'L': lazy = true; break; case 'p': prefix = optarg; break; case 'z': gdmin_set_size = atol(optarg); break; default: usage(argv[0]); return 1; } if (num<=0 || !fmeasured) { usage(argv[0]); return 1; } /* not anymore: assert(num < 100); /* XXX: hardcoded %02d elsewhere */ /* maximal step length (alltogether, not per dimension) */ alpha /= sqrt(2. + num); /* MC scaling, 5e-3 step up accepted with 10% */ beta = - log(.1)/beta; assert(gdmin_set_size<0 || (gdmin_set_size > 0 && alg == GDMIN)); Curve measured; vector<C12Map> maps; maps.resize(num); if (measured.load(fmeasured)) return 1; for (int i=0; i<num; i++) { char buf[PATH_MAX]; /* used to align generated curves */ maps[i].setMeasured(measured); if (lazy) { if (num < 100 && !bignum) snprintf(buf,sizeof buf,"%s%02d.pdb",prefix,i+1); else snprintf(buf,sizeof buf,"%s%02d/%04d.pdb",prefix,(i+1)/100,i+1); maps[i].setQMax(measured.getQMax()); maps[i].setSize(measured.getSize()); if (maps[i].setLazy(buf,fmeasured)) return 1; } else if (parsed) { snprintf(buf, sizeof buf, "%s%02d.c12",prefix,i+1); if (maps[i].restore(buf)) return 1; maps[i].alignScale(measured); } else { snprintf(buf,sizeof buf,"%s%02d/%02d_%%.2f_%%.3f.dat",prefix,i+1,i+1); if (maps[i].load(buf)) return 1; maps[i].alignScale(measured); } } switch (alg) { case BRUTEFORCE: { BruteForce *b = new BruteForce(measured,maps); b->setStep(.01); min = b; break; } case RANDOMWALK: { RandomWalk *r = new RandomWalk(measured,maps); r->setParam(alpha); r->setMaxSteps(maxsteps); min = r; break; } case MONTECARLO: { MonteCarlo *m = new MonteCarlo(measured,maps); m->setParam(alpha,beta); m->setMaxSteps(maxsteps); min = m; break; } case STUNEL: { STunel *t = new STunel(measured,maps); t->setParam(alpha,beta,gamma); t->setMaxSteps(maxsteps); min = t; break; } case GDMIN: { GdMin *g = new GdMin(measured, maps); g->setParam(alpha); g->setMaxSteps(maxsteps); g->setSetSize(gdmin_set_size); min = g; break; } default: cerr << "algorithm " << alg << " not implemented" << endl; return 1; } min->setSyncSteps(syncsteps); int rank; MPI_Comm_rank(MPI_COMM_WORLD,&rank); if (debug) { char buf[PATH_MAX]; mkdir(tprefix,0755); snprintf(buf,PATH_MAX,"%s/ensamble-fit_%d.trc",tprefix,rank); if (min->openTrace(buf) == NULL) return 1; } min->minimize(debug); MPI_Finalize(); }
int main( int argc, char** argv ) { trace.beginBlock ( "Example FrechetShortcut" ); trace.info() << "Args:"; for ( int i = 0; i < argc; ++i ) trace.info() << " " << argv[ i ]; trace.info() << endl; std::string filename; double error; if(argc == 1) { trace.info() << "Use default file and error value\n"; filename = examplesPath + "samples/plant-frechet.dat"; error = 3; } else if(argc != 3) { trace.info() << "Please enter a filename and error value.\n"; return 0; } else { filename = argv[1]; error = atof(argv[2]); } ifstream instream; // input stream instream.open (filename.c_str(), ifstream::in); Curve c; //grid curve c.initFromVectorStream(instream); Board2D board; // Display the pixels as arrows range to show the way the curve is scanned board << c.getArrowsRange(); trace.beginBlock("Simple example"); //! [FrechetShortcutUsage] Curve::PointsRange r = c.getPointsRange(); typedef FrechetShortcut<Curve::PointsRange::ConstIterator,int> Shortcut; // Computation of one shortcut Shortcut s(error); s.init( r.begin() ); while ( ( s.end() != r.end() ) &&( s.extendFront() ) ) {} // Computation of a greedy segmentation typedef GreedySegmentation<Shortcut> Segmentation; Segmentation theSegmentation( r.begin(), r.end(), Shortcut(error) ); // the segmentation is computed here Segmentation::SegmentComputerIterator it = theSegmentation.begin(); Segmentation::SegmentComputerIterator itEnd = theSegmentation.end(); for ( ; it != itEnd; ++it) { s=Shortcut(*it); trace.info() << s << std::endl; board << s; } board.saveEPS("FrechetShortcutExample.eps", Board2D::BoundingBox, 5000 ); //! [FrechetShortcutUsage] #ifdef WITH_CAIRO board.saveCairo("FrechetShortcutExample.png"); #endif trace.endBlock(); return 0; }
bool CoilCoolingDXVariableRefrigerantFlow_Impl::setCoolingCapacityModifierCurveFunctionofFlowFraction(const Curve& curve) { bool result = setPointer(OS_Coil_Cooling_DX_VariableRefrigerantFlowFields::CoolingCapacityModifierCurveFunctionofFlowFraction, curve.handle()); return result; }
void Plot::setHighLow () { _plotSettings.high = 0; _plotSettings.low = 0; bool flag = FALSE; QHashIterator<QString, Curve *> it(_plotSettings.curves); while (it.hasNext()) { it.next(); Curve *curve = it.value(); double h, l; if (! curve->highLowRange(_plotSettings.startPos, _plotSettings.endPos, h, l)) continue; if (! flag) { _plotSettings.high = h; _plotSettings.low = l; flag = TRUE; } else { if (h > _plotSettings.high) _plotSettings.high = h; if (l < _plotSettings.low) _plotSettings.low = l; } } QHashIterator<QString, Marker *> it2(_plotSettings.markers); while (it2.hasNext()) { it2.next(); Marker *co = it2.value(); double h, l; if (! co->highLow(_plotSettings.startPos, _plotSettings.endPos, h, l)) continue; if (! flag) { _plotSettings.high = h; _plotSettings.low = l; flag = TRUE; } else { if (h > _plotSettings.high) _plotSettings.high = h; if (l < _plotSettings.low) _plotSettings.low = l; } } if(high){ setAxisScale(QwtPlot::yRight, low, high); }else{ setAxisScale(QwtPlot::yRight, _plotSettings.low, _plotSettings.high); } //TODO // setAxisScale(QwtPlot::yRight, 0, 100); }
bool EvaporativeCoolerDirectResearchSpecial_Impl::setEffectivenessFlowRatioModifierCurve(const Curve& curve) { return setPointer(OS_EvaporativeCooler_Direct_ResearchSpecialFields::EffectivenessFlowRatioModifierCurveName, curve.handle()); }
bool CurveNode::setValue (const String& strMemberName, const String* pstrValue) { bool bValueSet = false; Curve* pObject = dynamic_cast<Curve*>(m_pObject); if (strMemberName == L"Rot") { if (!pstrValue) { pObject->resetValue_Rot(); } else { pObject->setRot(EnumClockwiseImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Chord") { if (!pstrValue) { pObject->resetValue_Chord(); } else { pObject->setChord(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"CrvType") { if (!pstrValue) { pObject->resetValue_CrvType(); } else { pObject->setCrvType(EnumCurveTypeImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Delta") { if (!pstrValue) { pObject->resetValue_Delta(); } else { pObject->setDelta(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Desc") { if (!pstrValue) { pObject->resetValue_Desc(); } else { pObject->setDesc(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"DirEnd") { if (!pstrValue) { pObject->resetValue_DirEnd(); } else { pObject->setDirEnd(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"DirStart") { if (!pstrValue) { pObject->resetValue_DirStart(); } else { pObject->setDirStart(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"External") { if (!pstrValue) { pObject->resetValue_External(); } else { pObject->setExternal(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Length") { if (!pstrValue) { pObject->resetValue_Length(); } else { pObject->setLength(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"MidOrd") { if (!pstrValue) { pObject->resetValue_MidOrd(); } else { pObject->setMidOrd(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Name") { if (!pstrValue) { pObject->resetValue_Name(); } else { pObject->setName(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Radius") { if (!pstrValue) { pObject->resetValue_Radius(); } else { pObject->setRadius(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"StaStart") { if (!pstrValue) { pObject->resetValue_StaStart(); } else { pObject->setStaStart(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"State") { if (!pstrValue) { pObject->resetValue_State(); } else { pObject->setState(EnumStateTypeImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Tangent") { if (!pstrValue) { pObject->resetValue_Tangent(); } else { pObject->setTangent(DoubleObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"OID") { if (!pstrValue) { pObject->resetValue_OID(); } else { pObject->setOID(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Note") { if (!pstrValue) { pObject->resetValue_Note(); } else { pObject->setNote(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } return bValueSet; }
void Plot::createGraph() { insertLegend(new QwtLegend(), QwtPlot::BottomLegend); setAxisTitle(xBottom, "x -->"); setAxisTitle(yLeft, "y -->"); // Inicializa as variaveis pela primeira curva Curve* curve = cCurves[0]->getCurve(); std::vector<double> matrix_x = curve->getElementsX(); std::vector<double> matrix_y = curve->getElementsY(); double minX = matrix_x[0]; double maxX = matrix_x[0]; double minY = matrix_y[0]; double maxY = matrix_y[0]; for (unsigned int i = 0; i < cCurves.size(); i++) { Curve* curve = cCurves[i]->getCurve(); std::vector<double> matrix_x = curve->getElementsX(); std::vector<double> matrix_y = curve->getElementsY(); for (unsigned int j = 0; j < matrix_x.size(); j++) { if (minX > matrix_x[j]) minX = matrix_x[j]; if (maxX < matrix_x[j]) maxX = matrix_x[j]; if (minY > matrix_y[j]) minY = matrix_y[j]; if (maxY < matrix_y[j]) maxY = matrix_y[j]; } cCurves[i]->attach(this); cCurves[i]->plotGraph(); cPoints[i]->attach(this); cPoints[i]->plotExperimentalPoints(); } int py = (maxY - minY) / 10; int px = (maxX - minX) / 10; minX -= px; maxX += px; minY -= py; maxY += py; int stepY = (maxY - minY)/10; int stepX = (maxX - minX)/10; // QwtLog10ScaleEngine* logScale = new QwtLog10ScaleEngine(); // setAxisScaleEngine(QwtPlot::xBottom, logScale); // setAxisScaleEngine(QwtPlot::yLeft, logScale); setAxisScale(QwtPlot::xBottom, minX, maxX, stepX); setAxisScale(QwtPlot::yLeft, minY, maxY, stepY); replot(); }
bool CurveEditTool::MouseDown( const MouseButtonInput& e ) { bool success = true; if ( GetEditMode() == CurveEditModes::Modify ) { success = m_ControlPointManipulator->MouseDown( e ); } else { Curve* curve = NULL; { FrustumLinePickVisitor pick (m_Scene->GetViewport()->GetCamera(), e.GetPosition().x, e.GetPosition().y); m_Scene->Pick( &pick ); V_PickHitSmartPtr sorted; PickHit::Sort(m_Scene->GetViewport()->GetCamera(), pick.GetHits(), sorted, PickSortTypes::Intersection); for ( V_PickHitSmartPtr::const_iterator itr = sorted.begin(), end = sorted.end(); itr != end; ++itr ) { if ( curve = Reflect::SafeCast<Curve>( (*itr)->GetHitObject() ) ) { break; } } } if ( !curve || !m_Scene->IsEditable() ) { return false; } LinePickVisitor pick (m_Scene->GetViewport()->GetCamera(), e.GetPosition().x, e.GetPosition().y); switch ( GetEditMode() ) { case CurveEditModes::Insert: { std::pair<uint32_t, uint32_t> points; if ( !curve->ClosestControlPoints( &pick, points ) ) { return false; } CurveControlPoint* p0 = curve->GetControlPointByIndex( points.first ); CurveControlPoint* p1 = curve->GetControlPointByIndex( points.second ); Vector3 a( p0->GetPosition() ); Vector3 b( p1->GetPosition() ); Vector3 p; if ( curve->GetCurveType() == CurveType::Linear ) { float mu; if ( !pick.GetPickSpaceLine().IntersectsSegment( a, b, -1.0f, &mu ) ) { return false; } p = a * ( 1.0f - mu ) + b * mu; } else { p = ( a + b ) * 0.5f; } uint32_t index = points.first > points.second ? points.first : points.second; CurveControlPointPtr point = new CurveControlPoint(); point->SetOwner( curve->GetOwner() ); point->Initialize(); curve->GetOwner()->Push( curve->InsertControlPointAtIndex( index, point ) ); break; } case CurveEditModes::Remove: { int32_t index = curve->ClosestControlPoint( &pick ); if ( index < 0 ) { return false; } curve->GetOwner()->Push( curve->RemoveControlPointAtIndex( index ) ); break; } } curve->Dirty(); m_Scene->Execute( false ); } return success || Base::MouseDown( e ); }
void CurveEditTool::KeyPress( const KeyboardInput& e ) { if ( !m_Scene->IsEditable() ) { return; } int32_t keyCode = e.GetKeyCode(); if ( keyCode == KeyCodes::Left || keyCode == KeyCodes::Up || keyCode == KeyCodes::Right || keyCode == KeyCodes::Down ) { OS_SceneNodeDumbPtr selection = m_Scene->GetSelection().GetItems(); if ( selection.Empty() ) { return; } CurveControlPoint* point = Reflect::SafeCast<CurveControlPoint>( selection.Front() ); if ( !point ) { return; } Curve* curve = Reflect::SafeCast<Curve>( point->GetParent() ); if ( !curve ) { return; } int32_t index = curve->GetIndexForControlPoint( point ); if ( index == -1 ) { return; } uint32_t countControlPoints = curve->GetNumberControlPoints(); if ( keyCode == KeyCodes::Left || keyCode == KeyCodes::Down ) { index--; index += countControlPoints; index %= countControlPoints; } else if ( keyCode == KeyCodes::Right || keyCode == KeyCodes::Up ) { index++; index %= countControlPoints; } point = curve->GetControlPointByIndex( index ); selection.Clear(); selection.Append( point ); m_Scene->GetSelection().SetItems( selection ); } Base::KeyPress( e ); }
boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDXSingleSpeedWithoutUnitary( model::CoilCoolingDXSingleSpeed & modelObject ) { OptionalString s; IdfObject idfObject(IddObjectType::Coil_Cooling_DX_SingleSpeed); s = modelObject.name(); if( s ) { idfObject.setName(*s); } // hook up required objects try { Schedule sched = modelObject.getAvailabilitySchedule(); translateAndMapModelObject(sched); idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::AvailabilityScheduleName, sched.name().get() ); Curve cb = modelObject.getTotalCoolingCapacityFunctionOfTemperatureCurve(); translateAndMapModelObject(cb); idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::TotalCoolingCapacityFunctionofTemperatureCurveName, cb.name().get()); Curve cq = modelObject.getTotalCoolingCapacityFunctionOfFlowFractionCurve(); translateAndMapModelObject(cq); idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::TotalCoolingCapacityFunctionofFlowFractionCurveName, cq.name().get()); cb =modelObject.getEnergyInputRatioFunctionOfTemperatureCurve(); translateAndMapModelObject(cb); idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::EnergyInputRatioFunctionofTemperatureCurveName, cb.name().get()); cq=modelObject.getEnergyInputRatioFunctionOfFlowFractionCurve(); translateAndMapModelObject(cq); idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::EnergyInputRatioFunctionofFlowFractionCurveName, cq.name().get()); cq=modelObject.getPartLoadFractionCorrelationCurve(); translateAndMapModelObject(cq); idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::PartLoadFractionCorrelationCurveName, cq.name().get()); } catch (std::exception& e) { LOG(Error,"Could not translate " << modelObject.briefDescription() << ", because " << e.what() << "."); return boost::none; } OptionalDouble d = modelObject.ratedTotalCoolingCapacity(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedTotalCoolingCapacity,*d); } else { idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::GrossRatedTotalCoolingCapacity,"Autosize"); } d = modelObject.ratedSensibleHeatRatio(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedSensibleHeatRatio,*d); } else { idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::GrossRatedSensibleHeatRatio,"Autosize"); } d = modelObject.getRatedCOP(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedCoolingCOP,*d); } d = modelObject.ratedAirFlowRate(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::RatedAirFlowRate,*d); } else { idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::RatedAirFlowRate,"Autosize"); } d = modelObject.getRatedEvaporatorFanPowerPerVolumeFlowRate(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::RatedEvaporatorFanPowerPerVolumeFlowRate,*d); } OptionalModelObject omo = modelObject.inletModelObject(); if( omo ) { translateAndMapModelObject(*omo); s = omo->name(); if(s) { idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::AirInletNodeName,*s ); } } omo= modelObject.outletModelObject(); if( omo ) { translateAndMapModelObject(*omo); s = omo->name(); if(s) { idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::AirOutletNodeName,*s); } } d=modelObject.getNominalTimeForCondensateRemovalToBegin(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::NominalTimeforCondensateRemovaltoBegin,*d); } d=modelObject.getRatioOfInitialMoistureEvaporationRateAndSteadyStateLatentCapacity(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::RatioofInitialMoistureEvaporationRateandSteadyStateLatentCapacity,*d); } d=modelObject.getMaximumCyclingRate(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::MaximumCyclingRate,*d); } d=modelObject.getLatentCapacityTimeConstant(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::LatentCapacityTimeConstant,*d); } s=modelObject.getCondenserAirInletNodeName(); if(s) { idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::CondenserAirInletNodeName,*s); } idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::CondenserType,modelObject.getCondenserType()); d=modelObject.getEvaporativeCondenserEffectiveness(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserEffectiveness,*d); } d=modelObject.getEvaporativeCondenserAirFlowRate(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserAirFlowRate,*d); } d=modelObject.getEvaporativeCondenserPumpRatedPowerConsumption(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserPumpRatedPowerConsumption,*d); } d=modelObject.getCrankcaseHeaterCapacity(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::CrankcaseHeaterCapacity,*d); } d=modelObject.getMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::MaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation,*d); } //TODO //getSupplyWaterStorageTankName //getCondensateCollectionWaterStorageTankName d=modelObject.getBasinHeaterCapacity(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::BasinHeaterCapacity,*d); } d=modelObject.getBasinHeaterSetpointTemperature(); if(d) { idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::BasinHeaterSetpointTemperature,*d); } OptionalSchedule os = modelObject.getBasinHeaterOperatingSchedule(); if( os ) { translateAndMapModelObject(*os); idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::BasinHeaterOperatingScheduleName, os->name().get() ); } m_idfObjects.push_back(idfObject); return idfObject; }
void step_learn( int key ) { // one input // Eigen::VectorXd i1 = Eigen::VectorXd::Random(1); // i1 = (i1.array() - -1.0) / (1.0 - -1.0); Eigen::VectorXd i1(1); i1 << (double) (_nb_iter % 3) / 4.0 + 0.1; _rdsom->forward( i1 ); _rdsom->deltaW( i1, 0.1, 0.2, true ); _c_weights.clear(); _c_sim_input.clear(); _c_sim_rec.clear(); _c_sim_merged.clear(); _c_sim_convol.clear(); _c_sim_hn_dist.clear(); _c_sim_hn_rec.clear(); for( unsigned int i = 0; i < _rdsom->v_neur.size(); ++i) { _c_weights.add_sample( {(double)i, _rdsom->v_neur[i]->weights(0), 0.0} ); _c_sim_input.add_sample( {(double)i, _rdsom->_sim_w[i], 0.0} ); _c_sim_rec.add_sample( {(double)i, _rdsom->_sim_rec[i], 0.0} ); _c_sim_merged.add_sample( {(double)i, _rdsom->_sim_merged[i], 0.0} ); _c_sim_convol.add_sample( {(double)i, _rdsom->_sim_convol[i], 0.0} ); _c_sim_hn_dist.add_sample( {(double)i, _rdsom->_sim_hn_dist[i], 0.0} ); _c_sim_hn_rec.add_sample( {(double)i, _rdsom->_sim_hn_rec[i], 0.0} ); } _nb_iter++; }
void MeshSkin::computeBounds() { // Find the offset of the blend indices and blend weights within the mesh vertices int blendIndexOffset = -1; int blendWeightOffset = -1; for (unsigned int i = 0, count = _mesh->getVertexElementCount(); i < count; ++i) { const VertexElement& e = _mesh->getVertexElement(i); switch (e.usage) { case BLENDINDICES: blendIndexOffset = i; break; case BLENDWEIGHTS: blendWeightOffset = i; break; } } if (blendIndexOffset == -1 || blendWeightOffset == -1) { // Need blend indices and blend weights to calculate skinned bounding volume return; } LOG(2, "Computing bounds for skin of mesh: %s\n", _mesh->getId().c_str()); // Get the root joint if (_joints.size() == 0) return; Node* rootJoint = _joints[0]; Node* parent = rootJoint->getParent(); while (parent) { // Is this parent in the list of joints that form the skeleton? // If not, then it's simply a parent node to the root joint if (find(_joints.begin(), _joints.end(), parent) != _joints.end()) { rootJoint = parent; } parent = parent->getParent(); } // If the root joint has a parent node, temporarily detach it so that its transform is // not included in the bounding volume calculation below Node* rootJointParent = rootJoint->getParent(); if (rootJointParent) { rootJointParent->removeChild(rootJoint); } unsigned int jointCount = _joints.size(); unsigned int vertexCount = _mesh->getVertexCount(); LOG(3, " %u joints found.\n", jointCount); std::vector<AnimationChannel*> channels; std::vector<Node*> channelTargets; std::vector<Curve*> curves; std::vector<Vector3> vertices; _jointBounds.resize(jointCount); // Construct a list of all animation channels that target the joints affecting this mesh skin LOG(3, " Collecting animations...\n"); LOG(3, " 0%%\r"); for (unsigned int i = 0; i < jointCount; ++i) { Node* joint = _joints[i]; // Find all animations that target this joint Animations* animations = GPBFile::getInstance()->getAnimations(); for (unsigned int j = 0, animationCount = animations->getAnimationCount(); j < animationCount; ++j) { Animation* animation = animations->getAnimation(j); for (unsigned int k = 0, channelCount = animation->getAnimationChannelCount(); k < channelCount; ++k) { AnimationChannel* channel = animation->getAnimationChannel(k); if (channel->getTargetId() == joint->getId()) { if (find(channels.begin(), channels.end(), channel) == channels.end()) { channels.push_back(channel); channelTargets.push_back(joint); } } } } // Calculate the local bounding volume for this joint vertices.clear(); BoundingVolume jointBounds; jointBounds.min.set(FLT_MAX, FLT_MAX, FLT_MAX); jointBounds.max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX); for (unsigned int j = 0; j < vertexCount; ++j) { const Vertex& v = _mesh->getVertex(j); if ((v.blendIndices.x == i && !ISZERO(v.blendWeights.x)) || (v.blendIndices.y == i && !ISZERO(v.blendWeights.y)) || (v.blendIndices.z == i && !ISZERO(v.blendWeights.z)) || (v.blendIndices.w == i && !ISZERO(v.blendWeights.w))) { vertices.push_back(v.position); // Update box min/max if (v.position.x < jointBounds.min.x) jointBounds.min.x = v.position.x; if (v.position.y < jointBounds.min.y) jointBounds.min.y = v.position.y; if (v.position.z < jointBounds.min.z) jointBounds.min.z = v.position.z; if (v.position.x > jointBounds.max.x) jointBounds.max.x = v.position.x; if (v.position.y > jointBounds.max.y) jointBounds.max.y = v.position.y; if (v.position.z > jointBounds.max.z) jointBounds.max.z = v.position.z; } } if (vertices.size() > 0) { // Compute center point Vector3::add(jointBounds.min, jointBounds.max, &jointBounds.center); jointBounds.center.scale(0.5f); // Compute radius for (unsigned int j = 0, jointVertexCount = vertices.size(); j < jointVertexCount; ++j) { float d = jointBounds.center.distanceSquared(vertices[j]); if (d > jointBounds.radius) jointBounds.radius = d; } jointBounds.radius = sqrt(jointBounds.radius); } _jointBounds[i] = jointBounds; LOG(3, " %d%%\r", (int)((float)(i+1) / (float)jointCount * 100.0f)); } LOG(3, "\n"); unsigned int channelCount = channels.size(); // Create a Curve for each animation channel float maxDuration = 0.0f; LOG(3, " Building animation curves...\n"); LOG(3, " 0%%\r"); for (unsigned int i = 0; i < channelCount; ++i) { AnimationChannel* channel = channels[i]; const std::vector<float>& keyTimes = channel->getKeyTimes(); unsigned int keyCount = keyTimes.size(); if (keyCount == 0) continue; // Create a curve for this animation channel Curve* curve = NULL; switch (channel->getTargetAttribute()) { case Transform::ANIMATE_SCALE_ROTATE_TRANSLATE: curve = new Curve(keyCount, 10); curve->setQuaternionOffset(3); break; } if (curve == NULL) { // Unsupported/not implemented curve type continue; } // Copy key values into a temporary array unsigned int keyValuesCount = channel->getKeyValues().size(); float* keyValues = new float[keyValuesCount]; for (unsigned int j = 0; j < keyValuesCount; ++j) keyValues[j] = channel->getKeyValues()[j]; // Determine animation duration float startTime = keyTimes[0]; float duration = keyTimes[keyCount-1] - startTime; if (duration > maxDuration) maxDuration = duration; if (duration > 0.0f) { // Set curve points float* keyValuesPtr = keyValues; for (unsigned int j = 0; j < keyCount; ++j) { // Store time normalized, between 0-1 float t = (keyTimes[j] - startTime) / duration; // Set the curve point // TODO: Handle other interpolation types curve->setPoint(j, t, keyValuesPtr, gameplay::Curve::LINEAR); // Move to the next point on the curve keyValuesPtr += curve->getComponentCount(); } curves.push_back(curve); } delete[] keyValues; keyValues = NULL; LOG(3, " %d%%\r", (int)((float)(i+1) / (float)channelCount * 100.0f)); } LOG(3, "\n"); // Compute a total combined bounding volume for the MeshSkin that contains all possible // vertex positions for all animations targeting the skin. This rough approximation allows // us to store a volume that can be used for rough intersection tests (such as for visibility // determination) efficiently at runtime. // Backup existing node transforms so we can restore them when we are finished Matrix* oldTransforms = new Matrix[jointCount]; for (unsigned int i = 0; i < jointCount; ++i) { memcpy(oldTransforms[i].m, _joints[i]->getTransformMatrix().m, 16 * sizeof(float)); } float time = 0.0f; float srt[10]; Matrix temp; Matrix* jointTransforms = new Matrix[jointCount]; _mesh->bounds.min.set(FLT_MAX, FLT_MAX, FLT_MAX); _mesh->bounds.max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX); _mesh->bounds.center.set(0, 0, 0); _mesh->bounds.radius = 0; Vector3 skinnedPos; Vector3 tempPos; LOG(3, " Evaluating joints...\n"); LOG(3, " 0%%\r"); BoundingVolume finalBounds; while (time <= maxDuration) { // Evaluate joint transforms at this time interval for (unsigned int i = 0, curveCount = curves.size(); i < curveCount; ++i) { Node* joint = channelTargets[i]; Curve* curve = curves[i]; // Evalulate the curve at this time to get the new value float tn = time / maxDuration; if (tn > 1.0f) tn = 1.0f; curve->evaluate(tn, srt); // Update the joint's local transform Matrix::createTranslation(srt[7], srt[8], srt[9], temp.m); temp.rotate(*((Quaternion*)&srt[3])); temp.scale(srt[0], srt[1], srt[2]); joint->setTransformMatrix(temp.m); } // Store the final matrix pallette of resovled world space joint matrices std::vector<Matrix>::const_iterator bindPoseItr = _bindPoses.begin(); for (unsigned int i = 0; i < jointCount; ++i, bindPoseItr++) { BoundingVolume bounds = _jointBounds[i]; if (ISZERO(bounds.radius)) continue; Matrix& m = jointTransforms[i]; Matrix::multiply(_joints[i]->getWorldMatrix().m, bindPoseItr->m, m.m); Matrix::multiply(m.m, _bindShape, m.m); // Get a world-space bounding volume for this joint bounds.transform(m); if (ISZERO(finalBounds.radius)) finalBounds = bounds; else finalBounds.merge(bounds); } // Increment time by 1/30th of second (~ 33 ms) if (time < maxDuration && (time + 33.0f) > maxDuration) time = maxDuration; else time += 33.0f; LOG(3, " %d%%\r", (int)(time / maxDuration * 100.0f)); } LOG(3, "\n"); // Update the bounding sphere for the mesh _mesh->bounds = finalBounds; // Restore original joint transforms for (unsigned int i = 0; i < jointCount; ++i) { _joints[i]->setTransformMatrix(oldTransforms[i].m); } // Cleanup for (unsigned int i = 0, curveCount = curves.size(); i < curveCount; ++i) { delete curves[i]; } delete[] oldTransforms; delete[] jointTransforms; // Restore removed joints if (rootJointParent) { rootJointParent->addChild(rootJoint); } }
bool CurveNode::getValue (const String& strMemberName, String& strValue) { bool bValueSet = false; Curve* pObject = dynamic_cast<Curve*>(m_pObject); if (strMemberName == L"value") { ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject); if (pValueObj) { if (!pValueObj->isNothing()) { strValue = pValueObj->toString(); bValueSet = true; } } } else if (strMemberName == L"Rot") { if (pObject->hasValue_Rot()) { strValue = (EnumClockwiseImpl(pObject->getRot())).toString(); bValueSet = true; } } else if (strMemberName == L"Chord") { if (pObject->hasValue_Chord()) { strValue = (DoubleObjectImpl(pObject->getChord())).toString(); bValueSet = true; } } else if (strMemberName == L"CrvType") { if (pObject->hasValue_CrvType()) { strValue = (EnumCurveTypeImpl(pObject->getCrvType())).toString(); bValueSet = true; } } else if (strMemberName == L"Delta") { if (pObject->hasValue_Delta()) { strValue = (DoubleObjectImpl(pObject->getDelta())).toString(); bValueSet = true; } } else if (strMemberName == L"Desc") { if (pObject->hasValue_Desc()) { strValue = (StringObjectImpl(pObject->getDesc())).toString(); bValueSet = true; } } else if (strMemberName == L"DirEnd") { if (pObject->hasValue_DirEnd()) { strValue = (DoubleObjectImpl(pObject->getDirEnd())).toString(); bValueSet = true; } } else if (strMemberName == L"DirStart") { if (pObject->hasValue_DirStart()) { strValue = (DoubleObjectImpl(pObject->getDirStart())).toString(); bValueSet = true; } } else if (strMemberName == L"External") { if (pObject->hasValue_External()) { strValue = (DoubleObjectImpl(pObject->getExternal())).toString(); bValueSet = true; } } else if (strMemberName == L"Length") { if (pObject->hasValue_Length()) { strValue = (DoubleObjectImpl(pObject->getLength())).toString(); bValueSet = true; } } else if (strMemberName == L"MidOrd") { if (pObject->hasValue_MidOrd()) { strValue = (DoubleObjectImpl(pObject->getMidOrd())).toString(); bValueSet = true; } } else if (strMemberName == L"Name") { if (pObject->hasValue_Name()) { strValue = (StringObjectImpl(pObject->getName())).toString(); bValueSet = true; } } else if (strMemberName == L"Radius") { if (pObject->hasValue_Radius()) { strValue = (DoubleObjectImpl(pObject->getRadius())).toString(); bValueSet = true; } } else if (strMemberName == L"StaStart") { if (pObject->hasValue_StaStart()) { strValue = (DoubleObjectImpl(pObject->getStaStart())).toString(); bValueSet = true; } } else if (strMemberName == L"State") { if (pObject->hasValue_State()) { strValue = (EnumStateTypeImpl(pObject->getState())).toString(); bValueSet = true; } } else if (strMemberName == L"Tangent") { if (pObject->hasValue_Tangent()) { strValue = (DoubleObjectImpl(pObject->getTangent())).toString(); bValueSet = true; } } else if (strMemberName == L"OID") { if (pObject->hasValue_OID()) { strValue = (StringObjectImpl(pObject->getOID())).toString(); bValueSet = true; } } else if (strMemberName == L"Note") { if (pObject->hasValue_Note()) { strValue = (StringObjectImpl(pObject->getNote())).toString(); bValueSet = true; } } return bValueSet; }
bool EvaporativeCoolerDirectResearchSpecial_Impl::setWaterPumpPowerModifierCurve(const Curve& curve) { return setPointer(OS_EvaporativeCooler_Direct_ResearchSpecialFields::WaterPumpPowerModifierCurveName, curve.handle()); }
bool CoilHeatingFourPipeBeam_Impl::setBeamHeatingCapacityHotWaterFlowModificationFactorCurve(const Curve& curve) { bool result = setPointer(OS_Coil_Heating_FourPipeBeamFields::BeamHeatingCapacityHotWaterFlowModificationFactorCurveName, curve.handle()); return result; }
bool CoilCoolingDXVariableRefrigerantFlow_Impl::setCoolingCapacityRatioModifierFunctionofTemperatureCurve(const Curve& curve) { bool result = setPointer(OS_Coil_Cooling_DX_VariableRefrigerantFlowFields::CoolingCapacityRatioModifierFunctionofTemperatureCurve, curve.handle()); return result; }
void GrapheinClient::RemoteClientState::processMessages(void) { Threads::Mutex::Lock messageBufferLock(messageBufferMutex); /* Handle all state tracking messages: */ for(std::vector<IncomingMessage*>::iterator mIt=messages.begin(); mIt!=messages.end(); ++mIt) { /* Process all messages in this buffer: */ IO::File& msg=**mIt; while(!msg.eof()) { /* Read the next message: */ MessageIdType message=GrapheinProtocol::readMessage(msg); switch(message) { case ADD_CURVE: { unsigned int newCurveId=msg.read<Card>(); /* Check if a curve of the given ID already exists: */ if(curves.isEntry(newCurveId)) { /* Skip the curve definition: */ Curve dummy; dummy.read(msg); } else { /* Create a new curve and add it to the curve map: */ Curve* newCurve=new Curve; curves.setEntry(CurveMap::Entry(newCurveId,newCurve)); newCurve->read(msg); } break; } case APPEND_POINT: { /* Read the curve ID and index of the new vertex: */ unsigned int curveId=msg.read<Card>(); unsigned int vertexIndex=msg.read<Card>(); /* Read the vertex: */ Point newVertex=GrapheinProtocol::read<Point>(msg); /* Get a handle on the curve: */ CurveMap::Iterator cIt=curves.findEntry(curveId); if(!cIt.isFinished()) { /* Check that the curve doesn't already contains the vertex: */ if(vertexIndex>=cIt->getDest()->vertices.size()) { /* Append the vertex: */ cIt->getDest()->vertices.push_back(newVertex); } } break; } case DELETE_CURVE: { /* Read the curve ID: */ unsigned int curveId=msg.read<Card>(); /* Get a handle on the curve: */ CurveMap::Iterator cIt=curves.findEntry(curveId); if(!cIt.isFinished()) { /* Delete the curve: */ delete cIt->getDest(); curves.removeEntry(cIt); } break; } case DELETE_ALL_CURVES: { /* Delete all curves: */ for(CurveMap::Iterator cIt=curves.begin(); !cIt.isFinished(); ++cIt) delete cIt->getDest(); curves.clear(); break; } } } /* Destroy the just-read message buffer: */ delete *mIt; } /* Clear the message buffer list: */ messages.clear(); }
Curve Curve::operator+(const Curve& curve) { Curve copy = *this; return copy.add(curve); }
vector<ColorCalibrator::Curve> ColorCalibrator::computeProjectorFunctionInverse(vector<Curve> rgbCurves) { gsl_set_error_handler(gslErrorHandler); vector<Curve> projInvCurves; // Work on each curve independently unsigned int c = 0; // index of the current channel for (auto& curve : rgbCurves) { // Make sure the points are correctly ordered std::sort(curve.begin(), curve.end(), [&](Point a, Point b) { return a.second[c] < b.second[c]; }); double yOffset = curve[0].second[c]; double yRange = curve[curve.size() - 1].second[c] - curve[0].second[c]; if (yRange <= 0.f) { Log::get() << Log::WARNING << "ColorCalibrator::" << __FUNCTION__ << " - Unable to compute projector inverse function curve on a channel" << Log::endl; projInvCurves.push_back(Curve()); continue; } vector<double> rawX; vector<double> rawY; double epsilon = 0.001; double previousAbscissa = -1.0; for (auto& point : curve) { double abscissa = (point.second[c] - yOffset) / yRange; if (std::abs(abscissa - previousAbscissa) < epsilon) { Log::get() << Log::WARNING << "ColorCalibrator::" << __FUNCTION__ << " - Abscissa not strictly increasing: discarding value " << abscissa << " from channel " << c << Log::endl; } else { previousAbscissa = abscissa; rawX.push_back((point.second[c] - yOffset) / yRange); rawY.push_back(point.first); } } // Check that first and last points abscissas are 0 and 1, respectively, and shift them slightly // to prevent floating point imprecision to cause an interpolation error rawX[0] = std::max(0.0, rawX[0]) - 0.001; rawX[rawX.size() - 1] = std::min(1.0, rawX[rawX.size() - 1]) + 0.001; gsl_interp_accel* acc = gsl_interp_accel_alloc(); gsl_spline* spline = nullptr; if (rawX.size() > 4) spline = gsl_spline_alloc(gsl_interp_akima, rawX.size()); else spline = gsl_spline_alloc(gsl_interp_linear, rawX.size()); gsl_spline_init(spline, rawX.data(), rawY.data(), rawX.size()); Curve projInvCurve; for (double x = 0.0; x <= 255.0; x += 1.0) { double realX = std::min(1.0, x / 255.0); // Make sure we don't try to go past 1.0 Point point; point.first = realX; point.second[c] = gsl_spline_eval(spline, realX, acc); projInvCurve.push_back(point); } projInvCurves.push_back(projInvCurve); gsl_spline_free(spline); gsl_interp_accel_free(acc); c++; // increment the current channel } gsl_set_error_handler_off(); return projInvCurves; }
void TrackerNodePrivate::computeCornerParamsFromTracksEnd(double refTime, double maxFittingError, const QList<CornerPinData>& results) { // Make sure we get only valid results QList<CornerPinData> validResults; for (QList<CornerPinData>::const_iterator it = results.begin(); it != results.end(); ++it) { if (it->valid) { validResults.push_back(*it); } } // Get all knobs that we are going to write to and block any value changes on them KnobIntPtr smoothCornerPinKnob = smoothCornerPin.lock(); int smoothJitter = smoothCornerPinKnob->getValue(); int halfJitter = smoothJitter / 2; KnobDoublePtr fittingErrorKnob = fittingError.lock(); KnobDoublePtr fromPointsKnob[4]; KnobDoublePtr toPointsKnob[4]; KnobBoolPtr enabledPointsKnob[4]; KnobStringPtr fittingWarningKnob = fittingErrorWarning.lock(); for (int i = 0; i < 4; ++i) { fromPointsKnob[i] = fromPoints[i].lock(); toPointsKnob[i] = toPoints[i].lock(); enabledPointsKnob[i] = enableToPoint[i].lock(); } std::list<KnobIPtr> animatedKnobsChanged; fittingErrorKnob->blockValueChanges(); animatedKnobsChanged.push_back(fittingErrorKnob); for (int i = 0; i < 4; ++i) { toPointsKnob[i]->blockValueChanges(); animatedKnobsChanged.push_back(toPointsKnob[i]); } // Get reference corner pin CornerPinPoints refFrom; for (int c = 0; c < 4; ++c) { refFrom.pts[c].x = fromPointsKnob[c]->getValueAtTime(TimeValue(refTime)); refFrom.pts[c].y = fromPointsKnob[c]->getValueAtTime(TimeValue(refTime), DimIdx(1)); } // Create temporary curves and clone the toPoint internal curves at once because setValueAtTime will be slow since it emits // signals to create keyframes in keyframeSet Curve tmpToPointsCurveX[4], tmpToPointsCurveY[4]; Curve tmpFittingErrorCurve; bool mustShowFittingWarn = false; for (QList<CornerPinData>::const_iterator itResults = validResults.begin(); itResults != validResults.end(); ++itResults) { const CornerPinData& dataAtTime = *itResults; // Add the error to the curve and check if we need to turn on the RMS warning { KeyFrame kf(dataAtTime.time, dataAtTime.rms); if (dataAtTime.rms >= maxFittingError) { mustShowFittingWarn = true; } tmpFittingErrorCurve.setOrAddKeyframe(kf); } if (smoothJitter <= 1) { for (int c = 0; c < 4; ++c) { Point toPoint; toPoint = TrackerHelper::applyHomography(refFrom.pts[c], dataAtTime.h); KeyFrame kx(dataAtTime.time, toPoint.x); KeyFrame ky(dataAtTime.time, toPoint.y); tmpToPointsCurveX[c].setOrAddKeyframe(kx); tmpToPointsCurveY[c].setOrAddKeyframe(ky); //toPoints[c]->setValuesAtTime(dataAtTime[i].time, toPoint.x, toPoint.y, ViewSpec::all(), eValueChangedReasonUserEdited); } } else { // Average to points before and after if using jitter CornerPinPoints avgTos; averageDataFunctor<QList<CornerPinData>::const_iterator, CornerPinPoints, CornerPinPoints>(validResults.begin(), validResults.end(), itResults, halfJitter, &refFrom, &avgTos, 0); for (int c = 0; c < 4; ++c) { KeyFrame kx(dataAtTime.time, avgTos.pts[c].x); KeyFrame ky(dataAtTime.time, avgTos.pts[c].y); tmpToPointsCurveX[c].setOrAddKeyframe(kx); tmpToPointsCurveY[c].setOrAddKeyframe(ky); } } // use jitter } // for each result // If user wants a post-smooth, apply it if (smoothJitter > 1) { int halfSmoothJitter = smoothJitter / 2; KeyFrameSet xSet[4], ySet[4]; KeyFrameSet newXSet[4], newYSet[4]; for (int c = 0; c < 4; ++c) { xSet[c] = tmpToPointsCurveX[c].getKeyFrames_mt_safe(); ySet[c] = tmpToPointsCurveY[c].getKeyFrames_mt_safe(); } for (int c = 0; c < 4; ++c) { for (KeyFrameSet::const_iterator it = xSet[c].begin(); it != xSet[c].end(); ++it) { double avg; averageDataFunctor<KeyFrameSet::const_iterator, void, double>(xSet[c].begin(), xSet[c].end(), it, halfSmoothJitter, 0, &avg, 0); KeyFrame k(*it); k.setValue(avg); newXSet[c].insert(k); } for (KeyFrameSet::const_iterator it = ySet[c].begin(); it != ySet[c].end(); ++it) { double avg; averageDataFunctor<KeyFrameSet::const_iterator, void, double>(ySet[c].begin(), ySet[c].end(), it, halfSmoothJitter, 0, &avg, 0); KeyFrame k(*it); k.setValue(avg); newYSet[c].insert(k); } } for (int c = 0; c < 4; ++c) { tmpToPointsCurveX[c].setKeyframes(newXSet[c], true); tmpToPointsCurveY[c].setKeyframes(newYSet[c], true); } } fittingWarningKnob->setSecret(!mustShowFittingWarn); fittingErrorKnob->cloneCurve(ViewIdx(0), DimIdx(0), tmpFittingErrorCurve, 0 /*offset*/, 0 /*range*/); for (int c = 0; c < 4; ++c) { toPointsKnob[c]->cloneCurve(ViewIdx(0), DimIdx(0), tmpToPointsCurveX[c], 0 /*offset*/, 0 /*range*/); toPointsKnob[c]->cloneCurve(ViewIdx(0), DimIdx(1), tmpToPointsCurveY[c], 0 /*offset*/, 0 /*range*/); } for (std::list<KnobIPtr>::iterator it = animatedKnobsChanged.begin(); it != animatedKnobsChanged.end(); ++it) { (*it)->unblockValueChanges(); (*it)->evaluateValueChange(DimSpec::all(), TimeValue(refTime), ViewSetSpec::all(), eValueChangedReasonUserEdited); } endSolve(); } // TrackerNodePrivate::computeCornerParamsFromTracksEnd
int AROON::run (PluginData *pd) { if (! g_symbol) return 0; QVariant *period = pd->settings->get(QString("period")); if (! period) return 0; QVariant *ulabel = pd->settings->get(QString("upLabel")); if (! ulabel) return 0; QVariant *dlabel = pd->settings->get(QString("downLabel")); if (! dlabel) return 0; if (! getAROON(period->toInt(), ulabel->toString(), dlabel->toString())) return 0; // up QVariant *show = pd->settings->get(QString("upShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("upColor")); if (! var) return 0; QColor color(var->toString()); QVariant *style = pd->settings->get(QString("upStyle")); if (! style) return 0; QVariant *width = pd->settings->get(QString("upWidth")); if (! width) return 0; // up CurveLineType clt; Curve *c = new Curve(QString("CurveLine")); c->setColor(color); c->setLabel(ulabel->toString()); c->setStyle(clt.stringToIndex(style->toString())); c->fill(ulabel->toString(), QString(), QString(), QString(), QColor()); c->setPen(width->toInt()); pd->curves << c; } // down show = pd->settings->get(QString("downShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("downColor")); if (! var) return 0; QColor color(var->toString()); QVariant *style = pd->settings->get(QString("downStyle")); if (! style) return 0; QVariant *width = pd->settings->get(QString("downWidth")); if (! width) return 0; CurveLineType clt; Curve *c = new Curve(QString("CurveLine")); c->setColor(color); c->setLabel(dlabel->toString()); c->setStyle(clt.stringToIndex(style->toString())); c->fill(dlabel->toString(), QString(), QString(), QString(), QColor()); c->setPen(width->toInt()); pd->curves << c; } return 1; }
int lua_Curve_evaluate(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER && (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 2); // Get parameter 2 off the stack. gameplay::ScriptUtil::LuaArray<float> param2 = gameplay::ScriptUtil::getFloatPointer(3); Curve* instance = getInstance(state); instance->evaluate(param1, param2); return 0; } } while (0); lua_pushstring(state, "lua_Curve_evaluate - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 6: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER && lua_type(state, 4) == LUA_TNUMBER && lua_type(state, 5) == LUA_TNUMBER && (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 2); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); // Get parameter 3 off the stack. float param3 = (float)luaL_checknumber(state, 4); // Get parameter 4 off the stack. float param4 = (float)luaL_checknumber(state, 5); // Get parameter 5 off the stack. gameplay::ScriptUtil::LuaArray<float> param5 = gameplay::ScriptUtil::getFloatPointer(6); Curve* instance = getInstance(state); instance->evaluate(param1, param2, param3, param4, param5); return 0; } } while (0); lua_pushstring(state, "lua_Curve_evaluate - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3 or 6)."); lua_error(state); break; } } return 0; }
int RSI::run (PluginData *pd) { if (! g_symbol) return 0; QVariant *input = pd->settings->get(QString("input")); if (! input) return 0; QVariant *period = pd->settings->get(QString("period")); if (! period) return 0; QVariant *label = pd->settings->get(QString("label")); if (! label) return 0; if (! getRSI(input->toString(), period->toInt(), label->toString())) return 0; // rsi QVariant *show = pd->settings->get(QString("rsiShow")); if (! show) return 0; if (show->toBool()) { QVariant *style = pd->settings->get(QString("style")); if (! style) return 0; QVariant *width = pd->settings->get(QString("width")); if (! width) return 0; QVariant *var = pd->settings->get(QString("color")); if (! var) return 0; QColor color(var->toString()); CurveLineType clt; Curve *rsi = new Curve(QString("CurveLine")); rsi->setColor(color); rsi->setLabel(label->toString()); rsi->setStyle(clt.stringToIndex(style->toString())); rsi->fill(label->toString(), QString(), QString(), QString(), color); rsi->setPen(width->toInt()); pd->curves << rsi; } // ma show = pd->settings->get(QString("maShow")); if (! show) return 0; if (show->toBool()) { Curve *ma = getMA(pd->settings); if (ma) pd->curves << ma; } // buy marker show = pd->settings->get(QString("buyMarkerShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("buyMarkerColor")); if (! var) return 0; QColor color(var->toString()); QVariant *price = pd->settings->get(QString("buyMarkerPrice")); if (! price) return 0; Marker *m = newMarker(color, price->toDouble()); if (! m) return 0; pd->markers << m; } // sell marker show = pd->settings->get(QString("sellMarkerShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("sellMarkerColor")); if (! var) return 0; QColor color(var->toString()); QVariant *price = pd->settings->get(QString("sellMarkerPrice")); if (! price) return 0; Marker *m = newMarker(color, price->toDouble()); if (! m) return 0; pd->markers << m; } return 1; }
bool testSegmentation() { unsigned int nbok = 0; unsigned int nb = 0; typedef PointVector<2,int> Point; //typedef std::vector<Point>::iterator Iterator; //typedef FrechetShortcut<Iterator,int> SegmentComputer; std::vector<Point> contour; contour.push_back(Point(0,0)); contour.push_back(Point(1,0)); contour.push_back(Point(2,0)); contour.push_back(Point(3,0)); contour.push_back(Point(4,0)); contour.push_back(Point(5,0)); contour.push_back(Point(6,0)); contour.push_back(Point(7,0)); contour.push_back(Point(7,1)); contour.push_back(Point(6,1)); contour.push_back(Point(5,1)); contour.push_back(Point(4,1)); contour.push_back(Point(3,1)); contour.push_back(Point(2,1)); contour.push_back(Point(2,2)); contour.push_back(Point(3,2)); contour.push_back(Point(4,2)); contour.push_back(Point(5,2)); contour.push_back(Point(6,2)); contour.push_back(Point(7,2)); contour.push_back(Point(8,2)); contour.push_back(Point(9,2)); trace.beginBlock ( "Testing block ..." ); typedef Curve::PointsRange::ConstIterator Iterator; typedef FrechetShortcut<Iterator,int> SegmentComputer; Curve aCurve; //grid curve aCurve.initFromVector(contour); typedef Curve::PointsRange Range; //range Range r = aCurve.getPointsRange(); //range Board2D board; board << r; board << aCurve.getArrowsRange(); double error = 3; nbok =3; trace.beginBlock ( "Greedy segmentation" ); { typedef GreedySegmentation<SegmentComputer> Segmentation; Segmentation theSegmentation( r.begin(), r.end(), SegmentComputer(error) ); Segmentation::SegmentComputerIterator it = theSegmentation.begin(); Segmentation::SegmentComputerIterator itEnd = theSegmentation.end(); for ( ; it != itEnd; ++it) { SegmentComputer s(*it); trace.info() << s << std::endl; board << (*it); nb++; } //board << aCurve; trace.info() << theSegmentation << std::endl; board.saveEPS("FrechetShortcutGreedySegmentationTest.eps", Board2D::BoundingBox, 5000 ); } /* Saturated segmentation does not work for FrechetShortcut computer. Indeed, given two maximal Frechet shortcuts s1(begin, end) et s2(begin, end), we can have s1.begin < s2.begin < s2.end < s1.end. */ trace.endBlock(); return nbok == nb; }
boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDXTwoSpeedWithoutUnitary( model::CoilCoolingDXTwoSpeed & modelObject ) { //setup two boost optionals to use to store get method returns boost::optional<std::string> s; boost::optional<double> d; //create the IdfObject that will be the coil IdfObject idfObject(IddObjectType::Coil_Cooling_DX_TwoSpeed); //Name m_idfObjects.push_back(idfObject); s = modelObject.name(); if( s ) { idfObject.setName(*s); } // A2 , \field Availability Schedule Name Schedule sched = modelObject.getAvailabilitySchedule(); translateAndMapModelObject(sched); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::AvailabilityScheduleName, sched.name().get() ); // N1 , \field Rated High Speed Total Cooling Capacity d = modelObject.getRatedHighSpeedTotalCoolingCapacity(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedTotalCoolingCapacity,*d); } else { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedTotalCoolingCapacity,"Autosize"); } // N2 , \field Rated High Speed Sensible Heat Ratio d = modelObject.getRatedHighSpeedSensibleHeatRatio(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedSensibleHeatRatio,*d); } else { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedSensibleHeatRatio,"Autosize"); } // N3 , \field Rated High Speed COP d = modelObject.getRatedHighSpeedCOP(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedCOP,*d); } // N4 , \field Rated High Speed Air Flow Rate d = modelObject.getRatedHighSpeedAirFlowRate(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedAirFlowRate,*d); } else { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedAirFlowRate,"Autosize"); } //A3 , \field Air Inlet Node Name OptionalModelObject omo = modelObject.inletModelObject(); if( omo ) { translateAndMapModelObject(*omo); s = omo->name(); if(s) { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::AirInletNodeName,*s ); } } //A4 , \field Air Outlet Node Name omo= modelObject.outletModelObject(); if( omo ) { translateAndMapModelObject(*omo); s = omo->name(); if(s) { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::AirOutletNodeName,*s); } } // A5 , \field Total Cooling Capacity Function of Temperature Curve Name Curve cb = modelObject.getTotalCoolingCapacityFunctionOfTemperatureCurve(); translateAndMapModelObject(cb); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::TotalCoolingCapacityFunctionofTemperatureCurveName, cb.name().get()); // A6 , \field Total Cooling Capacity Function of Flow Fraction Curve Name cb = modelObject.getTotalCoolingCapacityFunctionOfFlowFractionCurve(); translateAndMapModelObject(cb); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::TotalCoolingCapacityFunctionofFlowFractionCurveName, cb.name().get()); // A7 , \field Energy Input Ratio Function of Temperature Curve Name cb =modelObject.getEnergyInputRatioFunctionOfTemperatureCurve(); translateAndMapModelObject(cb); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::EnergyInputRatioFunctionofTemperatureCurveName, cb.name().get()); // A8 , \field Energy Input Ratio Function of Flow Fraction Curve Name Curve cq = modelObject.getEnergyInputRatioFunctionOfFlowFractionCurve(); translateAndMapModelObject(cq); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::EnergyInputRatioFunctionofFlowFractionCurveName, cq.name().get()); // A9 , \field Part Load Fraction Correlation Curve Name cq = modelObject.getPartLoadFractionCorrelationCurve(); translateAndMapModelObject(cq); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::PartLoadFractionCorrelationCurveName, cq.name().get()); // N5 , \field Rated Low Speed Total Cooling Capacity d = modelObject.getRatedLowSpeedTotalCoolingCapacity(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedLowSpeedTotalCoolingCapacity,*d); } else { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::RatedLowSpeedTotalCoolingCapacity,"Autosize"); } // N6 , \field Rated Low Speed Sensible Heat Ratio d = modelObject.getRatedLowSpeedSensibleHeatRatio(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedLowSpeedSensibleHeatRatio,*d); } else { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::RatedLowSpeedSensibleHeatRatio,"Autosize"); } // N7 , \field Rated Low Speed COP d = modelObject.getRatedLowSpeedCOP(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedLowSpeedCOP,*d); } // N8 , \field Rated Low Speed Air Flow Rate d = modelObject.getRatedLowSpeedAirFlowRate(); if( d ) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::RatedLowSpeedAirFlowRate,*d); } else { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::RatedLowSpeedAirFlowRate,"Autosize"); } // A10, \field Low Speed Total Cooling Capacity Function of Temperature Curve Name cq = modelObject.getLowSpeedTotalCoolingCapacityFunctionOfTemperatureCurve(); translateAndMapModelObject(cq); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::LowSpeedTotalCoolingCapacityFunctionofTemperatureCurveName, cq.name().get()); // A11, \field Low Speed Energy Input Ratio Function of Temperature Curve Name cq = modelObject.getLowSpeedEnergyInputRatioFunctionOfTemperatureCurve(); translateAndMapModelObject(cq); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::LowSpeedEnergyInputRatioFunctionofTemperatureCurveName, cq.name().get()); // A12, \field Condenser Air Inlet Node Name s=modelObject.getCondenserAirInletNodeName(); if(s) { idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::CondenserAirInletNodeName,*s); } // A13, \field Condenser Type idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::CondenserType,modelObject.getCondenserType()); // N9, \field High Speed Evaporative Condenser Effectiveness d=modelObject.getHighSpeedEvaporativeCondenserEffectiveness(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::HighSpeedEvaporativeCondenserEffectiveness,*d); } // N10, \field High Speed Evaporative Condenser Air Flow Rate d=modelObject.getHighSpeedEvaporativeCondenserAirFlowRate(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::HighSpeedEvaporativeCondenserAirFlowRate,*d); } // N11, \field High Speed Evaporative Condenser Pump Rated Power Consumption d=modelObject.getHighSpeedEvaporativeCondenserPumpRatedPowerConsumption(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::HighSpeedEvaporativeCondenserPumpRatedPowerConsumption,*d); } // N12, \field Low Speed Evaporative Condenser Effectiveness d=modelObject.getLowSpeedEvaporativeCondenserEffectiveness(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::LowSpeedEvaporativeCondenserEffectiveness,*d); } // N13, \field Low Speed Evaporative Condenser Air Flow Rate d=modelObject.getLowSpeedEvaporativeCondenserAirFlowRate(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::LowSpeedEvaporativeCondenserAirFlowRate,*d); } // N14, \field Low Speed Evaporative Condenser Pump Rated Power Consumption d=modelObject.getLowSpeedEvaporativeCondenserPumpRatedPowerConsumption(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::LowSpeedEvaporativeCondenserPumpRatedPowerConsumption,*d); } //TODO // A14, \field Supply Water Storage Tank Name //getSupplyWaterStorageTankName //TODO // A15, \field Condensate Collection Water Storage Tank Name //getCondensateCollectionWaterStorageTankName // N15, \field Basin Heater Capacity d=modelObject.getBasinHeaterCapacity(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::BasinHeaterCapacity,*d); } // N16, \field Basin Heater Setpoint Temperature d=modelObject.getBasinHeaterSetpointTemperature(); if(d) { idfObject.setDouble(Coil_Cooling_DX_TwoSpeedFields::BasinHeaterSetpointTemperature,*d); } // A16; \field Basin Heater Operating Schedule Name OptionalSchedule os = modelObject.getBasinHeaterOperatingSchedule(); if( os ) { translateAndMapModelObject(*os); idfObject.setString(Coil_Cooling_DX_TwoSpeedFields::BasinHeaterOperatingScheduleName, os->name().get() ); } return idfObject; }