// --------------------------------------------------------- // 7 Dec 2005 Real maxnorm(const BoxLayoutData<NodeFArrayBox>& a_layout, const LevelData<NodeFArrayBox>& a_mask, const ProblemDomain& a_domain, const Interval& a_interval, bool a_verbose) { Real normTotal = 0.; // a_p == 0: max norm int ncomp = a_interval.size(); for (DataIterator it = a_layout.dataIterator(); it.ok(); ++it) { const NodeFArrayBox& thisNfab = a_layout[it()]; const FArrayBox& dataFab = thisNfab.getFab(); const FArrayBox& maskFab = a_mask[it()].getFab(); const Box& thisBox(a_layout.box(it())); // CELL-centered NodeFArrayBox dataMasked(thisBox, ncomp); FArrayBox& dataMaskedFab = dataMasked.getFab(); dataMaskedFab.copy(dataFab); // dataMaskedFab *= maskFab; for (int comp = a_interval.begin(); comp <= a_interval.end(); comp++) { // Set dataMaskedFab[comp] *= maskFab[0]. dataMaskedFab.mult(maskFab, 0, comp); } Real thisNfabNorm = maxnorm(dataMasked, thisBox, a_interval.begin(), a_interval.size()); if (a_verbose) cout << "maxnorm(" << thisBox << ") = " << thisNfabNorm << endl; normTotal = Max(normTotal, thisNfabNorm); } # ifdef CH_MPI Real recv; // add up (a_p is not 0) int result = MPI_Allreduce(&normTotal, &recv, 1, MPI_CH_REAL, MPI_MAX, Chombo_MPI::comm); if (result != MPI_SUCCESS) { //bark!!! MayDay::Error("sorry, but I had a communication error on norm"); } normTotal = recv; # endif return normTotal; }
Interval Tube::operator[](const ibex::Interval& intv_t) const { // Write access is not allowed for this operator: // a further call to computeTree() is needed when values change, // this call cannot be garanteed with a direct access to m_intv_y // For write access: use setY() if(intv_t.lb() == intv_t.ub()) return (*this)[intv_t.lb()]; Interval intersection = m_intv_t & intv_t; if(intersection.is_empty()) return Interval::EMPTY_SET; else if(isSlice() || intv_t == m_intv_t || intv_t.is_unbounded() || intv_t.is_superset(m_intv_t)) { if(m_tree_computation_needed) computeTree(); return m_intv_y; } else { Interval inter_firstsubtube = m_first_subtube->getT() & intersection; Interval inter_secondsubtube = m_second_subtube->getT() & intersection; if(inter_firstsubtube == inter_secondsubtube) return (*m_first_subtube)[inter_firstsubtube.lb()] & (*m_second_subtube)[inter_secondsubtube.lb()]; else if(inter_firstsubtube.lb() == inter_firstsubtube.ub() && inter_secondsubtube.lb() != inter_secondsubtube.ub()) return (*m_second_subtube)[inter_secondsubtube]; else if(inter_firstsubtube.lb() != inter_firstsubtube.ub() && inter_secondsubtube.lb() == inter_secondsubtube.ub()) return (*m_first_subtube)[inter_firstsubtube]; else return (*m_first_subtube)[inter_firstsubtube] | (*m_second_subtube)[inter_secondsubtube]; } }
void LinearizePass::processPartition(IntervalPartition & ip, Function & f) { logger->log(1) << "Partition has " << ip.getIntervals().size() << " intervals\n"; currentPartition = &ip; const vector<Interval *> & intervals = ip.getIntervals(); for (int i = 0, e = intervals.size(); i < e; i++) { Interval * currentInterval = intervals[i]; logger->log(2) << "Processing interval:\n"; currentInterval->print(logger->log(2)); set<BasicBlock *> scc; bool hasScc = findScc(*currentInterval, scc); if ( hasScc ) logger->log(2) << "SCC found\n"; else logger->log(2) << "No SCCs\n"; } }
Interval GroupManager::calculateInterval (MillisecondsSince1970 timeSlot, map<Name, Blob>& memberKeys) { // Prepare. Interval positiveResult; Interval negativeResult; memberKeys.clear(); // Get the all intervals from the schedules. vector<string> scheduleNames; database_->listAllScheduleNames(scheduleNames); for (size_t i = 0; i < scheduleNames.size(); ++i) { string& scheduleName = scheduleNames[i]; ptr_lib::shared_ptr<Schedule> schedule = database_->getSchedule(scheduleName); Schedule::Result result = schedule->getCoveringInterval(timeSlot); Interval tempInterval = result.interval; if (result.isPositive) { if (!positiveResult.isValid()) positiveResult = tempInterval; positiveResult.intersectWith(tempInterval); map<Name, Blob> map; database_->getScheduleMembers(scheduleName, map); memberKeys.insert(map.begin(), map.end()); } else { if (!negativeResult.isValid()) negativeResult = tempInterval; negativeResult.intersectWith(tempInterval); } } if (!positiveResult.isValid()) // Return an invalid interval when there is no member which has an // interval covering the time slot. return Interval(false); // Get the final interval result. Interval finalInterval; if (negativeResult.isValid()) finalInterval = positiveResult.intersectWith(negativeResult); else finalInterval = positiveResult; return finalInterval; }
pBuffer SourceBase:: readChecked( const Interval& I ) { TIME_SOURCEBASE TaskTimer tt("%s::readChecked( %s )", vartype(*this).c_str(), I.toString().c_str()); EXCEPTION_ASSERT( I.count() ); pBuffer r = read(I); // Check if read returned the first sample in interval I Interval i(I.first, I.first + 1); if ((i & r->getInterval()) != i) { TaskTimer tt("%s::readChecked( %s ) got %s", vartype(*this).c_str(), I.toString().c_str(), r->getInterval ().toString ().c_str ()); EXCEPTION_ASSERT_EQUALS( i & r->getInterval(), i ); } return r; }
Interval Interval::intersect(Interval& other) { Interval result; if (isEmpty() || other.isEmpty()) { return result; } if (intersects(*this, other)) { result = Interval(std::max(_min, other._min), std::min(_max, other._max)); } return result; }
// This method is called before rendering begins to allow the plug-in // to evaluate anything prior to the render so it can store this information. void Water::Update(TimeValue t, Interval& ivalid) { if (!texValidity.InInterval(t)) { texValidity.SetInfinite(); xyzGen->Update(t, texValidity); // pblock->GetValue(PB_COL1, t, col[0], texValidity); pblock->GetValue(water_color1, t, col[0], texValidity); col[0].ClampMinMax(); // pblock->GetValue(PB_COL2, t, col[1], texValidity); pblock->GetValue(water_color2, t, col[1], texValidity); col[1].ClampMinMax(); // pblock->GetValue(PB_NUM, t, count, texValidity); pblock->GetValue(water_num, t, count, texValidity); ClampInt(count, (int) MIN_NUM, (int) MAX_NUM); // pblock->GetValue(PB_SIZE, t, size, texValidity); pblock->GetValue(water_size, t, size, texValidity); ClampFloat(size, MIN_SIZE, MAX_SIZE); // pblock->GetValue(PB_LEN_MIN, t, minperiod, texValidity); pblock->GetValue(water_len_min, t, minperiod, texValidity); ClampFloat(minperiod, MIN_LEN_MIN, MAX_LEN_MIN); // > 6/11/02 - 2:42pm --MQM-- typo, was MIN_LEN_MIN, MAX_LEN_MAX // pblock->GetValue(PB_LEN_MAX, t, maxperiod, texValidity); pblock->GetValue(water_len_max, t, maxperiod, texValidity); ClampFloat(maxperiod, MIN_LEN_MAX, MAX_LEN_MAX); // pblock->GetValue(PB_AMP, t, amp, texValidity); pblock->GetValue(water_amp, t, amp, texValidity); ClampFloat(amp, MIN_AMP, MAX_AMP); // pblock->GetValue(PB_PHASE, t, phase, texValidity); // pblock->GetValue(PB_TYPE, t, type, texValidity); pblock->GetValue(water_phase, t, phase, texValidity); pblock->GetValue(water_type, t, type, texValidity); for (int i = 0; i < NUM_SUB_TEXMAPS; i++) { if (subTex[i]) subTex[i]->Update(t, texValidity); // pblock->GetValue(PB_SEED, t, randSeed, texValidity); pblock->GetValue(water_seed, t, randSeed, texValidity); pblock->GetValue(water_mapon1, t, mapOn[0], texValidity); pblock->GetValue(water_mapon2, t, mapOn[1], texValidity); ReInit(); } } ivalid &= texValidity; }
void Gradient::SetSubTexmap(int i, Texmap *m) { ReplaceReference(i+2,m); if (i==0) { grad_param_blk.InvalidateUI(grad_map1); ivalid.SetEmpty(); } else if (i==1) { grad_param_blk.InvalidateUI(grad_map2); ivalid.SetEmpty(); } else if (i==2) { grad_param_blk.InvalidateUI(grad_map3); ivalid.SetEmpty(); } }
void Noise::SetSubTexmap(int i, Texmap *m) { ReplaceReference(i+2,m); if (i==0) { noise_param_blk.InvalidateUI(noise_map1); ivalid.SetEmpty(); cacheValid.SetEmpty(); } else if (i==1) { noise_param_blk.InvalidateUI(noise_map2); ivalid.SetEmpty(); cacheValid.SetEmpty(); } // if (paramDlg) // paramDlg->UpdateSubTexNames(); }
void Composite::Init() { macroRecorder->Disable(); ivalid.SetEmpty(); offset = 0; subTex.Resize(0); // mapOn.Resize(0); SetNumMaps(2); macroRecorder->Enable(); }
void Plate::Init() { ivalid.SetEmpty(); nth = 1; do_nth = TRUE; applyBlur = TRUE; useEnvMap = TRUE; SetBlur(1.0f, TimeValue(0)); SetThick(0.5f, TimeValue(0)); SetRefrAmt(1.0f, TimeValue(0)); }
static double my_f (const gsl_vector *v, void *params) { double x, y; bits_n_bobs* bnb = (bits_n_bobs *)params; x = gsl_vector_get(v, 0); y = gsl_vector_get(v, 1); Bezier b0(bnb->B[0], bnb->B[0]+bnb->dB[0]*x, bnb->A[0]+bnb->dA[0]*y, bnb->A[0]); Bezier b1(bnb->B[1], bnb->B[1]+bnb->dB[1]*x, bnb->A[1]+bnb->dA[1]*y, bnb->A[1]); D2<SBasis> zeroset(b0.toSBasis(), b1.toSBasis()); SBasis comp = compose((*bnb->ff),zeroset); Interval bounds = *bounds_fast(comp); double error = (bounds.max()>-bounds.min() ? bounds.max() : -bounds.min() ); //printf("error = %g %g %g\n", bounds.max(), bounds.min(), error); return error*error; }
IOResult Matte::Load(ILoad *iload) { ULONG nb; int id; version = 0; IOResult res; opaque = FALSE; while (IO_OK==(res=iload->OpenChunk())) { switch(id = iload->CurChunkID()) { case MTL_HDR_CHUNK: res = MtlBase::Load(iload); ivalid.SetEmpty(); break; case FOGBG_CHUNK: fogBG = TRUE; break; case SHADOWBG_CHUNK: shadowBG = TRUE; break; case SHADALPHA_CHUNK: shadowAlpha = TRUE; break; case OPAQUE_CHUNK: opaque = TRUE; break; case FOG_OBJDEPTH_CHUNK: fogObjDepth = TRUE; break; case MATTE_VERSION_CHUNK: iload->Read(&version,sizeof(int), &nb); break; } iload->CloseChunk(); if (res!=IO_OK) return res; } if (version < 2) { // JBW: register old version ParamBlock to ParamBlock2 converter ParamBlock2PLCB* plcb = new ParamBlock2PLCB(versions, NUM_OLDVERSIONS, &matte_param_blk, this, PB_REF); iload->RegisterPostLoadCallback(plcb); MattePostLoadCallback* matteplcb = new MattePostLoadCallback(this); iload->RegisterPostLoadCallback(matteplcb); } // iload->RegisterPostLoadCallback( // new ParamBlockPLCB(versions,NUM_OLDVERSIONS,&curVersion,this,PB_REF)); return IO_OK; }
RefResult Matte::NotifyRefChanged( const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) { switch (message) { case REFMSG_CHANGE: if (hTarget == pblock) { ivalid.SetEmpty(); // see if this message came from a changing parameter in the pblock, // if so, limit rollout update to the changing item and update any active viewport texture ParamID changing_param = pblock->LastNotifyParamID(); matte_param_blk.InvalidateUI(changing_param); if( (changing_param == matte_receive_shadows) ||(changing_param == matte_shadow_brightness) ||(changing_param == matte_color) ||(changing_param == matte_reflection_amount) ||(changing_param == matte_use_reflection_map)) { mReshadeRQ = RR_NeedReshade; } else if (changing_param == -1) mReshadeRQ = RR_NeedPreshade; else mReshadeRQ = RR_None; } if (hTarget != NULL) { switch (hTarget->SuperClassID()) { case TEXMAP_CLASS_ID: { mReshadeRQ = RR_NeedPreshade; } break; // default: // mReshadeRQ =RR_NeedReshade; // break; } } break; case REFMSG_SUBANIM_STRUCTURE_CHANGED: // if (partID == 0) // mReshadeRQ = RR_None; // else { // mReshadeRQ = RR_NeedPreshade; // NotifyChanged(); // } break; } return REF_SUCCEED; }
void IntervalSet::add(const Interval &addition) { if (_readonly) { throw IllegalStateException("can't alter read only IntervalSet"); } if (addition.b < addition.a) { return; } // find position in list for (auto iterator = _intervals.begin(); iterator != _intervals.end(); ++iterator) { Interval r = *iterator; if (addition == r) { return; } if (addition.adjacent(r) || !addition.disjoint(r)) { // next to each other, make a single larger interval Interval bigger = addition.Union(r); *iterator = bigger; // make sure we didn't just create an interval that // should be merged with next interval in list while (iterator + 1 != _intervals.end()) { Interval next = *++iterator; if (!bigger.adjacent(next) && bigger.disjoint(next)) { break; } // if we bump up against or overlap next, merge iterator = _intervals.erase(iterator);// remove this one --iterator; // move backwards to what we just set *iterator = bigger.Union(next); // set to 3 merged ones // ml: no need to advance iterator, we do that in the next round anyway. ++iterator; // first call to next after previous duplicates the result } return; } if (addition.startsBeforeDisjoint(r)) { // insert before r //--iterator; _intervals.insert(iterator, addition); return; } // if disjoint and after r, a future iteration will handle it } // ok, must be after last interval (and disjoint from last interval) // just add it _intervals.push_back(addition); }
void TimeInterpolatorRK4::interpolate(/// interpolated solution on this level coarsened LevelData<FArrayBox>& a_U, /// time interpolation coefficient in range [0:1] const Real& a_timeInterpCoeff, /// interval of a_U to fill in const Interval& a_intvl) { CH_assert(m_defined); CH_assert(m_gotFullTaylorPoly); CH_assert(a_U.nComp() == m_numStates); LevelData<FArrayBox> UComp; aliasLevelData(UComp, &a_U, a_intvl); // For i in 0:m_numCoeffs-1, // coeffFirst[i] is index of first component of m_taylorCoeffs // that corresponds to a coefficient of t^i. Vector<int> coeffFirst(m_numCoeffs); int intervalLength = a_intvl.size(); for (int i = 0; i < m_numCoeffs; i++) { coeffFirst[i] = a_intvl.begin() + i * m_numStates; } DataIterator dit = UComp.dataIterator(); for (dit.begin(); dit.ok(); ++dit) { FArrayBox& UFab = UComp[dit]; const FArrayBox& taylorFab = m_taylorCoeffs[dit]; // Evaluate a0 + a1*t + a2*t^2 + a3*t^3 // as a0 + t * (a1 + t * (a2 + t * a3)). UFab.copy(taylorFab, coeffFirst[m_numCoeffs-1], 0, intervalLength); for (int ind = m_numCoeffs - 2; ind >=0; ind--) { UFab *= a_timeInterpCoeff; UFab.plus(taylorFab, coeffFirst[ind], 0, intervalLength); } } // dummy statement in order to get around gdb bug int dummy_unused = 0; dummy_unused = 0; }
void Gradient::Update(TimeValue t, Interval& valid) { if (!ivalid.InInterval(t)) { ivalid.SetInfinite(); uvGen->Update(t,ivalid); texout->Update(t,ivalid); pblock->GetValue( grad_color1, t, col[0], ivalid ); col[0].ClampMinMax(); pblock->GetValue( grad_color2, t, col[1], ivalid ); col[1].ClampMinMax(); pblock->GetValue( grad_color3, t, col[2], ivalid ); col[2].ClampMinMax(); pblock->GetValue( grad_map1_on, t, mapOn[0], ivalid); pblock->GetValue( grad_map2_on, t, mapOn[1], ivalid); pblock->GetValue( grad_map3_on, t, mapOn[2], ivalid); pblock->GetValue( grad_type, t, type, ivalid ); pblock->GetValue( grad_noise_type, t, noiseType, ivalid ); pblock->GetValue( grad_amount, t, amount, ivalid ); pblock->GetValue( grad_size, t, size, ivalid ); pblock->GetValue( grad_phase, t, phase, ivalid ); pblock->GetValue( grad_center, t, center, ivalid ); pblock->GetValue( grad_levels, t, levels, ivalid ); pblock->GetValue( grad_high_thresh, t, high, ivalid ); pblock->GetValue( grad_low_thresh, t, low, ivalid ); pblock->GetValue( grad_thresh_smooth, t, smooth, ivalid ); if (low>high) { float temp = low; low = high; high = temp; } hminusl = (high-low); sd = hminusl*0.5f*smooth; if (size!=0.0f) size1 = 20.0f/size; else size1 = 0.0f; for (int i=0; i<NSUBTEX; i++) { if (subTex[i]) subTex[i]->Update(t,ivalid); } EnableStuff(); } valid &= ivalid; }
void EBMGInterp::pwcInterpFAB(EBCellFAB& a_refCoar, const Box& a_coarBox, const EBCellFAB& a_coar, const DataIndex& a_datInd, const Interval& a_variables) const { CH_TIMERS("EBMGInterp::interp"); CH_TIMER("regular_interp", t1); CH_TIMER("irregular_interp", t2); CH_assert(isDefined()); const Box& coarBox = a_coarBox; for (int ivar = a_variables.begin(); ivar <= a_variables.end(); ivar++) { m_interpEBStencil[a_datInd]->cache(a_refCoar, ivar); //do all cells as if they were regular Box refBox(IntVect::Zero, IntVect::Zero); refBox.refine(m_refRat); const BaseFab<Real>& coarRegFAB = a_coar.getSingleValuedFAB(); BaseFab<Real>& refCoarRegFAB = a_refCoar.getSingleValuedFAB(); CH_START(t1); FORT_REGPROLONG(CHF_FRA1(refCoarRegFAB,ivar), CHF_CONST_FRA1(coarRegFAB,ivar), CHF_BOX(coarBox), CHF_BOX(refBox), CHF_CONST_INT(m_refRat)); CH_STOP(t1); m_interpEBStencil[a_datInd]->uncache(a_refCoar, ivar); CH_START(t2); m_interpEBStencil[a_datInd]->apply(a_refCoar, a_coar, true, ivar); CH_STOP(t2); } }
void EBCoarToFineRedist::increment(const BaseIVFAB<Real>& a_coarseMass, const DataIndex& a_coarseDataIndex, const Interval& a_variables) { BaseIVFAB<Real>& coarBuf = m_regsCoar[a_coarseDataIndex]; const EBISBox& ebisBox = m_ebislCoar[a_coarseDataIndex]; const IntVectSet& ivsLoc = m_setsCoar[a_coarseDataIndex]; CH_assert(a_coarseMass.getIVS().contains(ivsLoc)); CH_assert(coarBuf.getIVS().contains(ivsLoc)); for (VoFIterator vofit(ivsLoc, ebisBox.getEBGraph()); vofit.ok(); ++vofit) { const VolIndex& vof = vofit(); for (int ivar = a_variables.begin(); ivar <= a_variables.end(); ivar++) { coarBuf(vof, ivar) += a_coarseMass(vof, ivar); } } }
void TreeNode::insert(Interval i){ if(i.contains(center)){ left_end.push_back(i.a); right_end.push_back(i.b); return; } if(i.b < center){ //interval is left to center if(!left) left = new TreeNode(i.middle()); left->insert(i); } else{ //interval is right to center if(!right) right = new TreeNode(i.middle()); right->insert(i); } }
RefResult Mask::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate ) { switch (message) { case REFMSG_CHANGE: ivalid.SetEmpty(); mapValid.SetEmpty(); if (hTarget == pblock) { //if (paramDlg&&!paramDlg->isActive) ParamID changing_param = pblock->LastNotifyParamID(); mask_param_blk.InvalidateUI(changing_param); } // if (paramDlg) // paramDlg->Invalidate(); break; } return(REF_SUCCEED); }
void Output::Update(TimeValue t, Interval& valid) { if (Param1) { pblock->SetValue( output_map1_on, 0, mapOn[0]); Param1 = FALSE; } if (!ivalid.InInterval(t)) { ivalid.SetInfinite(); texout->Update(t,ivalid); pblock->GetValue( output_map1_on, t, mapOn[0], ivalid); for (int i=0; i<NSUBTEX; i++) { if (subTex[i]) subTex[i]->Update(t,ivalid); } } valid &= ivalid; }
bool MillingCutter::singleVertexPush(const Fiber& f, Interval& i, const Point& p, CCType cctyp) const { bool result = false; if ( ( p.z >= f.p1.z ) && ( p.z <= (f.p1.z+ this->getLength()) ) ) { // p.z is within cutter Point pq = p.xyClosestPoint(f.p1, f.p2); // closest point on fiber double q = (p-pq).xyNorm(); // distance in XY-plane from fiber to p double h = p.z - f.p1.z; assert( h>= 0.0); double cwidth = this->width( h ); if ( q <= cwidth ) { // we are going to hit the vertex p double ofs = sqrt( square( cwidth ) - square(q) ); // distance along fiber Point start = pq - ofs*f.dir; Point stop = pq + ofs*f.dir; CCPoint cc_tmp( p, cctyp ); i.updateUpper( f.tval(stop) , cc_tmp ); i.updateLower( f.tval(start) , cc_tmp ); result = true; } } return result; }
// This method is responsible for responding to the change notification // messages sent by the texmap dependants. RefResult Speckle::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message ) { switch (message) { case REFMSG_CHANGE: texValidity.SetEmpty(); if (hTarget == pblock) { ParamID changing_param = pblock->LastNotifyParamID(); speckle_param_blk.InvalidateUI(changing_param); #ifdef SHOW_3DMAPS_WITH_2D if (changing_param != -1) DiscardTexHandle(); #endif } #ifdef SHOW_3DMAPS_WITH_2D else if (hTarget == xyzGen) { DiscardTexHandle(); } #endif // One of the texmap dependants have changed. We set our // validity interval to empty and invalidate the dialog // so it gets redrawn. // texValidity.SetEmpty(); // if (hTarget != xyzGen) { // if (paramDlg) // paramDlg->pmap->Invalidate(); // } break; /* case REFMSG_GET_PARAM_DIM: { // This returns the 'dimension' of the parameter. This is // the type and order of magnitude of the parameter. GetParamDim *gpd = (GetParamDim *)partID; switch (gpd->index) { case PB_SIZE: gpd->dim = stdWorldDim; break; case PB_COL1: case PB_COL2: gpd->dim = stdColor255Dim; break; } return REF_STOP; } case REFMSG_GET_PARAM_NAME: { // This returns the name that will appear in track view // of the parameter. GetParamName *gpn = (GetParamName *)partID; gpn->name = GetString(nameIDs[gpn->index]); return REF_STOP; } */ } return(REF_SUCCEED); }
//TODO: handle the case when B is "behind" A for the natural orientation of the level set. //TODO: more generally, there might be up to 4 solutions. Choose the best one! D2<SBasis> sb2d_cubic_solve(SBasis2d const &f, Geom::Point const &A, Geom::Point const &B){ D2<SBasis>result;//(Linear(A[X],B[X]),Linear(A[Y],B[Y])); //g_warning("check 0 = %f = %f!", f.apply(A[X],A[Y]), f.apply(B[X],B[Y])); SBasis2d f_u = partial_derivative(f , 0); SBasis2d f_v = partial_derivative(f , 1); SBasis2d f_uu = partial_derivative(f_u, 0); SBasis2d f_uv = partial_derivative(f_v, 0); SBasis2d f_vv = partial_derivative(f_v, 1); Geom::Point dfA(f_u.apply(A[X],A[Y]),f_v.apply(A[X],A[Y])); Geom::Point dfB(f_u.apply(B[X],B[Y]),f_v.apply(B[X],B[Y])); Geom::Point V0 = rot90(dfA); Geom::Point V1 = rot90(dfB); double D2fVV0 = f_uu.apply(A[X],A[Y])*V0[X]*V0[X]+ 2*f_uv.apply(A[X],A[Y])*V0[X]*V0[Y]+ f_vv.apply(A[X],A[Y])*V0[Y]*V0[Y]; double D2fVV1 = f_uu.apply(B[X],B[Y])*V1[X]*V1[X]+ 2*f_uv.apply(B[X],B[Y])*V1[X]*V1[Y]+ f_vv.apply(B[X],B[Y])*V1[Y]*V1[Y]; std::vector<D2<SBasis> > candidates = cubics_fitting_curvature(A,B,V0,V1,D2fVV0,D2fVV1); if (candidates.empty()) { return D2<SBasis>(Linear(A[X],B[X]),Linear(A[Y],B[Y])); } //TODO: I'm sure std algorithm could do that for me... double error = -1; unsigned best = 0; for (unsigned i=0; i<candidates.size(); i++){ Interval bounds = *bounds_fast(compose(f,candidates[i])); double new_error = (fabs(bounds.max())>fabs(bounds.min()) ? fabs(bounds.max()) : fabs(bounds.min()) ); if ( new_error < error || error < 0 ){ error = new_error; best = i; } } return candidates[best]; }
Interval AnimExportUtil::getKeyFramedRotationRange( INode* node3ds, Interval animRange ) { require( node3ds->GetTMController() ); TimeValue start = animRange.Start(); TimeValue end = animRange.End(); // target defines rotation if ( node3ds->GetTarget() ) return Interval( start, start ); Control* cont = node3ds->GetTMController()->GetRotationController(); IKeyControl* ikeys = cont ? GetKeyControlInterface( cont ) : 0; if ( ikeys ) { ITCBRotKey key1; IBezQuatKey key2; ILinRotKey key3; IKey* keyp = 0; if ( cont->ClassID() == Class_ID(TCBINTERP_ROTATION_CLASS_ID, 0) ) keyp = &key1; else if ( cont->ClassID() == Class_ID(HYBRIDINTERP_ROTATION_CLASS_ID, 0) ) keyp = &key2; else if ( cont->ClassID() == Class_ID(LININTERP_ROTATION_CLASS_ID, 0) ) keyp = &key3; if ( keyp ) { if ( 0 == ikeys->GetNumKeys() ) return Interval( start, start ); ikeys->GetKey( 0, keyp ); start = keyp->time; ikeys->GetKey( ikeys->GetNumKeys()-1, keyp ); end = keyp->time; } } return Interval( start, end ); }
void StraussShader::CopyStdParams( Shader* pFrom ) { macroRecorder->Disable(); // don't want to see this parameter copying in macrorecorder SetAmbientClr( pFrom->GetAmbientClr(0,0), 0 ); SetDiffuseClr( pFrom->GetDiffuseClr(0,0), 0 ); SetGlossiness( pFrom->GetGlossiness(0,0), 0 ); macroRecorder->Enable(); ivalid.SetEmpty(); }
TEST ( engineGeometryInterval, intervalCollision ) { Interval < int > a { 1, 0 }; Interval < int > b { 2, 8 }; Interval < int > c { -5, 15 }; EXPECT_FALSE ( a.collides ( b ) ); EXPECT_TRUE ( a.collides ( a ) ); EXPECT_TRUE ( c.collides ( b ) ); EXPECT_TRUE ( b.collides ( c ) ); }
Affine2Main<AF_iAF>::Affine2Main(int n, int m, const Interval& itv) : _n (n), _elt (NULL,0.0) { assert((n>=0) && (m>=0) && (m<=n)); if (!(itv.is_unbounded()||itv.is_empty())) { _elt._val =new Interval[n + 1]; _elt._val[0] = itv.mid(); for (int i = 1; i <= n; i++){ _elt._val[i] = 0.0; } if (m == 0) { _elt._err = itv.rad(); } else { _elt._val[m] = itv.rad(); } } else { *this = itv; } }
//from IUnReplaceableControl Control * EulerExposeControl::GetReplacementClone() { Control *control = NewDefaultRotationController(); if(control) { // set key per frame Interval range =GetCOREInterface()->GetAnimRange(); TimeValue tpf = GetTicksPerFrame(); SuspendAnimate(); AnimateOn(); Quat v; for(TimeValue t= range.Start(); t<=range.End();t+=tpf) { GetValue(t,&v,Interval(t,t)); control->SetValue(t,&v,1,CTRL_ABSOLUTE); } ResumeAnimate(); } return control; }