const boost::shared_ptr<NekMatrix<NekDouble> > BLPoints::GetI(unsigned int numpoints, const Array<OneD, const NekDouble>& x) { Array<OneD, NekDouble> interp(GetNumPoints()*numpoints); CalculateInterpMatrix(numpoints, x, interp); NekDouble* t = interp.data(); unsigned int np = GetNumPoints(); boost::shared_ptr< NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr(numpoints,np,t)); return returnval; }
// Returns index of last point *before* or *on* the given position, // or -1 if no point before it int CVariableParameter::GetPreviousPoint(int iBar,int iFraction) const { for(int iPoint=0;iPoint<GetNumPoints();iPoint++) { if((GetPointBar(iPoint) > iBar) || (GetPointBar(iPoint) == iBar && GetPointFraction(iPoint) > iFraction)) return iPoint-1; if(GetPointBar(iPoint) == iBar && GetPointFraction(iPoint) == iFraction) return iPoint; } // Didn't find a later, so give the last point return GetNumPoints()-1; }
bool CATLineFit::GetMinMax( CATFloat64& minX, CATFloat64& minY, CATFloat64& maxX, CATFloat64& maxY) { CATUInt32 numPoints = GetNumPoints(); if (numPoints == 0) { return false; } for (CATUInt32 i=0; i<numPoints; i++) { CATPoint curPoint = fPointList[i]; if (i == 0) { minX = maxX = curPoint.x; minY = maxY = curPoint.y; } else { minX = CATMin(curPoint.x, minX); maxX = CATMax(curPoint.x, maxX); minY = CATMin(curPoint.y, minY); maxY = CATMax(curPoint.y, maxY); } } return true; }
// Returns index of next point *after* the given position, or -1 if none int CVariableParameter::GetNextPoint(int iBar,int iFraction) const { for(int iPoint=0;iPoint<GetNumPoints();iPoint++) { if((GetPointBar(iPoint) > iBar) || (GetPointBar(iPoint) == iBar && GetPointFraction(iPoint) > iFraction)) return iPoint; } return -1; }
HdBufferSourceSharedPtr HdSt_MeshTopology::GetPointsIndexBuilderComputation() { // this is simple enough to return the result right away. int numPoints = GetNumPoints(); VtIntArray indices(numPoints); for (int i = 0; i < numPoints; ++i) indices[i] = i; return HdBufferSourceSharedPtr( new HdVtBufferSource(HdTokens->indices, VtValue(indices))); }
// Save/load void CVariableParameter::Serialize(CArchive& a) { int iVersion=1; if(a.IsStoring()) { a << iVersion; a << GetNumPoints(); for(int iPoint=0;iPoint<GetNumPoints();iPoint++) { a << GetPointBar(iPoint); a << GetPointFraction(iPoint); a << GetPointValue(iPoint); } } else { a >> iVersion; if(iVersion!=1) throw "File format not supported. Make sure this is a valid file and you are " "using the latest version of leafDrums."; int iSize; a >> iSize; for(int iPoint=0;iPoint<iSize;iPoint++) { int iBar,iFraction,iValue; a >> iBar; a >> iFraction; a >> iValue; m_viPointBar.Add(iBar); m_viPointFraction.Add(iFraction); m_viPointValue.Add(iValue); } } }
// Removes a point void CVariableParameter::RemovePoint(int iBar,int iFraction) { for(int iPoint=0;iPoint<GetNumPoints();iPoint++) { if(GetPointBar(iPoint) == iBar && GetPointFraction(iPoint) == iFraction) { m_viPointBar.RemoveAt(iPoint); m_viPointFraction.RemoveAt(iPoint); m_viPointValue.RemoveAt(iPoint); return; } } ASSERT(FALSE); }
void MeshPhysicsShape::Save(Archive& archive) { PhysicsSystem::SERIAL_CreateMesh.Save(archive); int count = GetNumPoints(); archive.Write(&count); Vector3* verts = GetPoints(); for (int x = 0; x < count; ++x) { archive.Write(&verts[x].x); archive.Write(&verts[x].y); archive.Write(&verts[x].z); } Vector3& scale = GetScale(); archive.Write(&scale); }
bool VCurve2DBase::DataExchangeXML(TiXmlElement *pCurveNode, bool bWrite) { if (!pCurveNode) return false; const char *szPointNodeName = "point"; // curve points int iCount = GetNumPoints(); XMLHelper::Exchange_Int(pCurveNode,"numpoints",iCount,bWrite); if (bWrite) { // write out points VCurvePoint2D *p = m_pPoints; for (int i=0;i<iCount;i++,p++) { TiXmlElement *pPointNode = XMLHelper::SubNode(pCurveNode,szPointNodeName,bWrite); p->DataExchangeXML(pPointNode,bWrite); } } else { // allocate and read points AllocatePoints(iCount); int iIndex = 0; TiXmlNode *pFirstPoint = pCurveNode->FirstChild(szPointNodeName); if (pFirstPoint) { for (TiXmlElement *pPoint=pFirstPoint->ToElement(); pPoint!=NULL; pPoint=pPoint->NextSiblingElement(szPointNodeName),iIndex++) { VASSERT(iIndex<iCount && "More point nodes defined than defined via 'numpoints' attribute"); // First point should have x = 0.f if (iIndex == 0) m_pPoints[iIndex].m_vPos.x = 0.f; if (iIndex<iCount) m_pPoints[iIndex].DataExchangeXML(pPoint,bWrite); } } UpdateCurve(); } return true; }
bool CATLineFit::CalcFit() { // Return false if we don't have any points to calculate.... CATUInt32 numPoints = GetNumPoints(); if (numPoints < 2) { return false; } fSlope = 0.0; fIntercept = 0.0; fSlope = ((numPoints * fSumXY) - (fSumX * fSumY)) / ((numPoints * fSumXSquared) - (fSumX * fSumX)); fIntercept = (fSumY - (fSlope * fSumX)) / numPoints; // Reset dirty flag fDirty = false; return true; }
// Adds a point void CVariableParameter::AddPoint(int iBar,int iFraction,int iValue) { // Find correct place to add it in order for(int iPoint=0;iPoint<GetNumPoints();iPoint++) { if((GetPointBar(iPoint) > iBar) || (GetPointBar(iPoint) == iBar && GetPointFraction(iPoint) > iFraction)) break; if(GetPointBar(iPoint) == iBar && GetPointFraction(iPoint) == iFraction) { m_viPointBar.RemoveAt(iPoint); m_viPointFraction.RemoveAt(iPoint); m_viPointValue.RemoveAt(iPoint); break; } } m_viPointBar.InsertAt(iPoint,iBar); m_viPointFraction.InsertAt(iPoint,iFraction); m_viPointValue.InsertAt(iPoint,iValue); }
PhysicsShape* MeshPhysicsShape::Copy(PhysicsSystem* physics) { return physics->CreateMesh(GetPoints(), GetNumPoints(), sizeof(Vector3), GetScale()); }