/** * Removes all the Frame objects from the array */ void NURBSSurface::ClearFrames() { if(!FrameSize()) return; for(int ifr=FrameSize()-1; ifr>=0; ifr--) { RemoveFrame(ifr); } }
/** * Returns the u-parameter for a given value along the axis and a given v parameter * Proceeds by iteration - time consuming, * @param pos the point coordinate for which the parameter u is requested * @param v the specified value of the v-parameter * @return the value of the u-parameter */ double NURBSSurface::Getu(double pos, double v) { if(pos<=m_pFrame.first()->m_Position[m_uAxis]) return 0.0; if(pos>=m_pFrame.last()->m_Position[m_uAxis]) return 1.0; if(qAbs(m_pFrame.last()->m_Position[m_uAxis] - m_pFrame.first()->m_Position[m_uAxis])<0.0000001) return 0.0; int iter=0; double u2, u1, b, c, u, zz, zh; u1 = 0.0; u2 = 1.0; // v = 0.0;//use top line, but doesn't matter while(qAbs(u2-u1)>1.0e-6 && iter<200) { u=(u1+u2)/2.0; zz = 0.0; for(int iu=0; iu<FrameSize(); iu++) //browse all points { zh = 0.0; for(int jv=0; jv<FramePointCount(); jv++) { c = SplineBlend(jv, m_ivDegree, v, m_vKnots); zh += m_pFrame[iu]->m_Position[m_uAxis] * c; } b = SplineBlend(iu, m_iuDegree, u, m_uKnots); zz += zh * b; } if(zz>pos) u2 = u; else u1 = u; iter++; } return (u1+u2)/2.0; }
/** * Creates the knot array for the two directions */ void NURBSSurface::SetKnots() { int j; double b; if(!FrameSize())return; if(!FramePointCount())return; m_iuDegree = qMin(m_iuDegree, FrameSize()); m_nuKnots = m_iuDegree + FrameSize() + 1; b = (double)(m_nuKnots-2*m_iuDegree-1); for (j=0; j<m_nuKnots; j++) { if (j<m_iuDegree+1) m_uKnots[j] = 0.0; else { if (j<FrameSize()) { if(qAbs(b)>0.0) m_uKnots[j] = (double)(j-m_iuDegree)/b; else m_uKnots[j] = 1.0; } else m_uKnots[j] = 1.0; } } m_ivDegree = qMin(m_ivDegree, m_pFrame.first()->m_CtrlPoint.size()); m_nvKnots = m_ivDegree + FramePointCount() + 1; b = (double)(m_nvKnots-2*m_ivDegree-1); for (j=0; j<m_nvKnots; j++) { if (j<m_ivDegree+1) m_vKnots[j] = 0.0; else { if (j<FramePointCount()) { if(qAbs(b)>0.0) m_vKnots[j] = (double)(j-m_ivDegree)/b; else m_vKnots[j] = 1.0; } else m_vKnots[j] = 1.0; } } }
/** * Inserts a Frame in the array. The Frame is positioned in crescending position along the u-axis * @param pNewFrame a pointer to the Frame object to insert. */ void NURBSSurface::InsertFrame(Frame *pNewFrame) { for(int ifr=0; ifr<FrameSize(); ifr++) { if(pNewFrame->m_Position[m_uAxis] < m_pFrame.at(ifr)->m_Position[m_uAxis]) { m_pFrame.insert(ifr, pNewFrame); return; } } m_pFrame.append(pNewFrame); //either the first if none, either the last... }
ffRational ffStream::PictureRatio() { ffRational aspRatio; aspRatio.setValue(&m_pAVStream->display_aspect_ratio); if (! aspRatio.isValid()) { QSize size = FrameSize(); aspRatio.setValue((size.width() / (float)size.height()) * 100, 100); } return aspRatio; }
/** * Returns the point corresponding to the pair of parameters (u,v) * Assumes that the knots have been set previously * * Scans the u-direction first, then v-direction * @param u the specified u-parameter * @param v the specified v-parameter * @param Pt a reference to the point defined by the pair (u,v) */ void NURBSSurface::GetPoint(double u, double v, CVector &Pt) { CVector V, Vv; double wx, weight; if(u>=1.0) u=0.99999999999; if(v>=1.0) v=0.99999999999; weight = 0.0; for(int iu=0; iu<FrameSize(); iu++) { Vv.Set(0.0,0.0,0.0); wx = 0.0; for(int jv=0; jv<FramePointCount(); jv++) { cs = SplineBlend(jv, m_ivDegree, v, m_vKnots) * Weight(m_EdgeWeightv, jv, FramePointCount()); Vv.x += m_pFrame[iu]->m_CtrlPoint[jv].x * cs; Vv.y += m_pFrame[iu]->m_CtrlPoint[jv].y * cs; Vv.z += m_pFrame[iu]->m_CtrlPoint[jv].z * cs; wx += cs; } bs = SplineBlend(iu, m_iuDegree, u, m_uKnots) * Weight(m_EdgeWeightu, iu, FrameSize()); V.x += Vv.x * bs; V.y += Vv.y * bs; V.z += Vv.z * bs; weight += wx * bs; } Pt.x = V.x / weight; Pt.y = V.y / weight; Pt.z = V.z / weight; }
bool KRT2Device::DataReceived(const void *_data, size_t length, struct NMEAInfo &info) { assert(length > 0); const char *data = static_cast<const char *>(_data); const char *end = data + length; bool result = false; unsigned expected_size = 0; do { if (!input_buffer.empty()) { input_buffer.append(*data); if (!expected_size) expected_size = FrameSize(input_buffer[1]); if (input_buffer.size() == expected_size) { // frame complete result |= ParseFrame(info); input_buffer.clear(); } else if (input_buffer.full()) { // too much data (will never happen when buffer >= max(expected_size)) input_buffer.clear(); } } else if (*data == SYNC) { // reply to SYNC from radio port.Write(SYNC_ACK); } else if (*data == STX) { // found start of new frame input_buffer.append(*data); expected_size = 0; } else if (*data == ACK) { // previous command accepted } else if (*data == NAK) { // previous command rejected } } while (++data != end); return result; }
/* A frame slot is marked iff it is in the chain of environments for one of the frozen execution states, regardless of contents. */ static CVOID__PROTO(markFrames, frame_t *frame, bcp_t l) { /* Mark frame chain */ tagged_t *ev; while (OffStacktop(frame,Gc_Stack_Start)) { ev= (tagged_t *)StackCharOffset(frame,FrameSize(l)); while (ev!=frame->term) { tagged_t v; StackDecr(ev); if (gc_IsMarked(v= *ev)) return; if (IsHeapTerm(v)) markVariable(Arg, ev); else gc_MarkM(*ev); } l= frame->next_insn; frame= frame->frame; } }
static CVOID__PROTO(shuntVariables) { tagged_t *pt = w->trail_top; node_t *cp = Gc_Aux_Node; node_t *prevcp = w->node; try_node_t *alt = fail_alt; intmach_t i; tagged_t *limit; frame_t *frame; while (ChoiceYounger(cp,Gc_Choice_Start)) { limit = TagToPointer(prevcp->trail_top); while (TrailYounger(pt,limit)) { tagged_t v = TrailPop(pt); if (v!=0 && IsVar(v) && !gc_IsMarked(*TagToPointer(v))) gc_MarkM(*TagToPointer(v)); else gc_MarkM(pt[0]); } gc_ReverseChoice(cp,prevcp,alt); } while (ChoiceYounger(Gc_Aux_Node,cp)) { gc_UndoChoice(cp,prevcp,alt); limit = TagToPointer(cp->trail_top); pt = TagToPointer(prevcp->trail_top); while (TrailYounger(limit,pt)) { tagged_t v = *pt++; if (!gc_IsMarked(v)) gc_UnmarkM(*TagToPointer(v)); } pt = TagToPointer(prevcp->trail_top); while (TrailYounger(limit,pt)) { tagged_t v = *pt++; if (gc_IsMarked(v)) gc_UnmarkM(pt[-1]); else gc_shuntVariable(*TagToPointer(v)); } pt = NodeGlobalTop(prevcp); while (HeapYounger(NodeGlobalTop(cp),pt)) { tagged_t v = *pt++; if (v&QMask) pt += LargeArity(v); else if (!gc_IsMarked(v)) { if (v==Tag(CVA,pt-1)) gc_MarkM(Cvas_Found), pt[-1] = Cvas_Found, Cvas_Found = v, pt += 2; else { gc_shuntVariable(pt[-1]); } } } i = FrameSize(cp->next_insn); frame = cp->frame; while (OffStacktop(frame,NodeLocalTop(prevcp))) { pt = (tagged_t *)StackCharOffset(frame,i); while (pt!=frame->term) if (!gc_IsMarked(*(--pt))) gc_shuntVariable(*pt); i = FrameSize(frame->next_insn); frame = frame->frame; } pt = cp->term+OffsetToArity(alt->node_offset); while (pt!=cp->term) { --pt; gc_shuntVariable(*pt); } } }
/** * Specifies the degree in the u-direction. * If the degree specified by the input parameter is equal or greater than the Frame count, * then the degree is set to the number of frames minus 1. * @param nuDegree the specified degree * @return the degree which has been set */ int NURBSSurface::SetuDegree(int nuDegree) { if(FrameSize()>nuDegree) m_iuDegree = nuDegree; else m_iuDegree = FrameSize()-1; return m_iuDegree; }