bool ConvexHull2<Real>::Load (const char* filename, int mode) { FileIO inFile(filename, mode); if (!inFile) { return false; } ConvexHull<Real>::Load(inFile); delete0(mQuery); delete1(mSVertices); if (mOwner) { delete1(mVertices); } mOwner = true; mVertices = new1<Vector2<Real> >(mNumVertices); mSVertices = new1<Vector2<Real> >(mNumVertices); inFile.Read(sizeof(Real), 2*mNumVertices, mVertices); inFile.Read(sizeof(Real), 2*mNumVertices, mSVertices); inFile.Read(sizeof(Real), 2, &mLineOrigin); inFile.Read(sizeof(Real), 2, &mLineDirection); inFile.Close(); switch (mQueryType) { case Query::QT_INT64: { mQuery = new0 Query2Int64<Real>(mNumVertices, mSVertices); break; } case Query::QT_INTEGER: { mQuery = new0 Query2Integer<Real>(mNumVertices, mSVertices); break; } case Query::QT_RATIONAL: { mQuery = new0 Query2Rational<Real>(mNumVertices, mSVertices); break; } case Query::QT_REAL: { mQuery = new0 Query2<Real>(mNumVertices, mSVertices); break; } case Query::QT_FILTERED: { mQuery = new0 Query2Filtered<Real>(mNumVertices, mSVertices, mEpsilon); break; } } return true; }
//---------------------------------------------------------------------------- void LogShutdown () { for (int i=0; i<sNumHandlers; i++) { delete0(sHandlers[i]); sHandlers[i] = 0; } }
MiniPS::Parser::~Parser() { /* We delete the master here! */ if (master!=NULLP) delete master; /* recursive ~Parser() call */ if (free_level>=2) delete tok; if (free_level>=3) delete rd; if (free_level>=4) fclose(PTS_align_cast(FILE*,f)); if (specRunsDelete) delete0((VALUE)specRuns); }
//---------------------------------------------------------------------------- void Delaunay3D::OnTerminate () { delete0(mDelaunay); mScene = 0; mCullState = 0; WindowApplication3::OnTerminate(); }
ConvexHull2<Real>::~ConvexHull2 () { if ( mOwner ) { delete1( mVertices ); } delete1( mSVertices ); delete0( mQuery ); }
//---------------------------------------------------------------------------- SegmentGraph::~SegmentGraph () { VMap::iterator iter = mVertexMap.begin(); VMap::iterator end = mVertexMap.end(); for (/**/; iter != end; ++iter) { Vertex* vertex = iter->second; delete0(vertex); } }
//---------------------------------------------------------------------------- SceneBuilder::~SceneBuilder () { delete1(mFileName); mScene = 0; std::vector<ModifierInfo*>::iterator iter; for (iter=mModifierList.begin(); iter<mModifierList.end(); iter++) { delete0(*iter); } }
void ConvexHull3<Real>::DeleteHull () { typename std::set<Triangle*>::iterator iter = mHull.begin(); typename std::set<Triangle*>::iterator end = mHull.end(); for (/**/; iter != end; ++iter) { Triangle* tri = *iter; delete0(tri); } mHull.clear(); }
//---------------------------------------------------------------------------- void CollisionsBoundTree::OnTerminate () { delete0(mGroup); mScene = 0; mCylinder0 = 0; mCylinder1 = 0; mWireState = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void IntersectingBoxes::OnTerminate () { delete0(mManager); mScene = 0; mWireState = 0; mNoIntersectEffect = 0; mIntersectEffect = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- Smoke2D::~Smoke2D () { delete1(mVortexCenter); delete1(mVortexVariance); delete1(mVortexAmplitude); delete2(mTimelessDensity); delete3(mTimelessVortex); delete2(mTimelessWind); delete2(mTimelessVelocity); delete0(mIP); }
//---------------------------------------------------------------------------- void Rope::OnTerminate () { delete0(mModule); mScene = 0; mTrnNode = 0; mWireState = 0; mRope = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void WaterDropFormation::OnTerminate () { delete0(mSpline); delete0(mCircle); delete1(mCtrlPoints); delete1(mTargets); mScene = 0; mTrnNode = 0; mWaterRoot = 0; mWireState = 0; mPlane = 0; mWall = 0; mWaterSurface = 0; mWaterDrop = 0; mWaterEffect = 0; mWaterTexture = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void GelatinCube::OnTerminate () { delete0(mModule); mScene = 0; mTrnNode = 0; mWireState = 0; mBox = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void Fluids3D::OnTerminate () { delete0(mSmoke); mScene = 0; mCube = 0; #ifdef USE_PARTICLES delete1(mIndices); #endif WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void BouncingBall::OnTerminate () { delete0(mBall); mPREffect = 0; mScene = 0; mBallNode = 0; mFloor = 0; mWall = 0; mWireState = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void PhysicsModule::Initialize (double time, double deltaTime, double x, double w, double theta, double xDot, double wDot, double thetaDot) { mTime = time; mDeltaTime = deltaTime; // state variables mState[0] = x; mState[1] = xDot; mState[2] = w; mState[3] = wDot; mState[4] = theta; mState[5] = thetaDot; // auxiliary variables SinAngle = Mathd::Sin(Angle); CosAngle = Mathd::Cos(Angle); mAux[0] = Mu*Gravity; // c/m in the one-particle system example mAux[1] = Gravity*SinAngle; // RK4 differential equation solver. Since mSolver is a base class // pointer, you can instead create a solver of whatever class you prefer. delete0(mSolver); mSolver = new0 OdeRungeKutta4d(4, mDeltaTime, OdeFunction, mAux); // Set up for angular speed. mTheta0 = theta; mThetaDer0 = thetaDot; double xx = XLocExt*XLocExt; double xy = XLocExt*YLocExt; double yy = YLocExt*YLocExt; double tmp1 = xx + yy; double tmp2 = Mathd::Sqrt(tmp1); double tmp3 = 4.0*xy/3.0; double tmp4 = 0.5*Mathd::Log((tmp2 + XLocExt)/(tmp2 - XLocExt)); double tmp5 = 0.5*Mathd::Log((tmp2 + YLocExt)/(tmp2 - YLocExt)); double numer = tmp3*tmp2 + XLocExt*xx*tmp5 + YLocExt*yy*tmp4; double denom = tmp3*tmp1; double coeff = Mu*Gravity*numer/denom; double angSpeed = Mathd::FAbs(thetaDot); if (angSpeed > Mathd::ZERO_TOLERANCE) { mAngVelCoeff = coeff/angSpeed; } else { mAngVelCoeff = 0.0; } }
//---------------------------------------------------------------------------- void PointInPolyhedron::DeleteQuery () { delete0(mQuery); #ifdef TRIANGLE_FACES delete1(mTFaces); #endif #if defined(CVXFACES0) || defined(CVXFACES1) || defined(CVXFACES2) delete1(mCFaces); #endif #if defined (SIMFACES0) || defined (SIMFACES1) delete1(mSFaces); #endif }
//---------------------------------------------------------------------------- void PhysicsModule::Initialize (double time, double deltaTime, double radius, double theta, double radiusDot, double thetaDot) { mTime = time; mDeltaTime = deltaTime; // state variables mState[0] = theta; mState[1] = thetaDot; mState[2] = radius; mState[3] = radiusDot; // Compute c0 and c1 in the potential energy function V(theta). double gm = Gravity*Mass; double gm2 = gm*Mass; double radiusSqr = radius*radius; double alpha = Mass*radiusSqr*thetaDot; double g2m4da2 = gm2*gm2/(alpha*alpha); double v0 = -gm/radius; double dv0 = gm2*radiusDot/alpha; double v0Plus = v0 + g2m4da2; double sinTheta0 = Mathd::Sin(theta); double cosTheta0 = Mathd::Cos(theta); double c0 = v0Plus*sinTheta0 + dv0*cosTheta0; double c1 = v0Plus*cosTheta0 - dv0*sinTheta0; // Auxiliary variables needed by function DTheta(...). mAux[0] = c0; mAux[1] = c1; mAux[2] = g2m4da2; mAux[3] = alpha/(gm*gm2); // ellipse parameters double gamma0 = radiusSqr*Mathd::FAbs(thetaDot); double tmp0 = radiusSqr*radius*thetaDot*thetaDot - gm; double tmp1 = radiusSqr*radiusDot*thetaDot; double gamma1 = Mathd::Sqrt(tmp0*tmp0 + tmp1*tmp1); mEccentricity = gamma1/gm; mRho = gamma0*gamma0/gamma1; double tmp2 = 1.0 - mEccentricity*mEccentricity; assertion(tmp2 > 0.0, "Invalid eccentricity.\n"); mMajorAxis = mRho*mEccentricity/tmp2; mMinorAxis = mMajorAxis*Mathd::Sqrt(tmp2); // RK4 differential equation solver. Since mSolver is a base class // pointer, you can instead create a solver of whatever class you prefer. delete0(mSolver); mSolver = new0 OdeRungeKutta4d(1, mDeltaTime, OdeFunction, mAux); }
//---------------------------------------------------------------------------- int SimplePendulum::Main (int, char**) { msImage = new0 ImageRGB82D(SIZE, SIZE); SolveMethod(ExplicitEuler, "Data/explicit.im", "Data/explicit.txt"); SolveMethod(ImplicitEuler, "Data/implicit.im", "Data/implicit.txt"); SolveMethod(RungeKutta, "Data/runge.im", "Data/runge.txt"); SolveMethod(LeapFrog, "Data/leapfrog.im", "Data/leapfrog.txt"); Stiff1(); Stiff2True(); Stiff2Approximate(); delete0(msImage); return 0; }
void ConvexHull2<Real>::Edge::DeleteSelf () { if ( E[0] ) { E[0]->E[1] = 0; } if ( E[1] ) { E[1]->E[0] = 0; } Edge* tmpThis = this; delete0( tmpThis ); }
//---------------------------------------------------------------------------- void ConvexHull3D::OnTerminate () { mPicker.Records.clear(); delete1(mVertices); delete1(mColors); delete0(mHull); mScene = 0; mHullNode = 0; mSphere = 0; mWireState = 0; mCullState = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void BouncingSpheres::OnTerminate() { for (int i = 0; i < NUM_BALLS; ++i) { delete0(mBalls[i]); mBallNodes[i] = 0; } mScene = 0; mWireState = 0; mFloor = 0; mSideWall1 = 0; mSideWall2 = 0; mBackWall = 0; WindowApplication3::OnTerminate(); }
void delete1 (arbore **t, int info, arbore **rad) { if ((*t)->dr != NULL && (*t)->stg !=NULL) // are 2 fii { arbore *pred; int a; rad=*t; pred=findMax((*t)->stg); //pred=findMin((*t)->dr); a=(*t)->info; (*t)->info = pred->info; pred->info=a; delete0(&rad, pred->info, 1); } }
//---------------------------------------------------------------------------- void BouncingTetrahedra::OnTerminate() { for (int i = 0; i < NUM_TETRA; ++i) { delete0(mTetras[i]); mTetraNodes[i] = 0; } mScene = 0; mWireState = 0; mFloor = 0; mBackWall = 0; mSideWall1 = 0; mSideWall2 = 0; WindowApplication3::OnTerminate(); }
//---------------------------------------------------------------------------- void NURBSCurveExample::NextConfiguration () { delete1(mTargets); mTargets = 0; const int numCtrlPoints = 14; const int degree = 2; delete1(mCtrlPoints); mCtrlPoints = new1<Vector2f>(numCtrlPoints); float* weights = new1<float>(numCtrlPoints); // spline mCtrlPoints[0] = mSpline->GetControlPoint(0); mCtrlPoints[1] = mSpline->GetControlPoint(1); mCtrlPoints[2] = 0.5f*(mSpline->GetControlPoint(1) + mSpline->GetControlPoint(2)); mCtrlPoints[3] = mSpline->GetControlPoint(11); mCtrlPoints[4] = mSpline->GetControlPoint(12); // circle int i, j; for (i = 2, j = 5; i <= 10; ++i, ++j) { mCtrlPoints[j] = mSpline->GetControlPoint(i); } for (i = 0; i < numCtrlPoints; ++i) { weights[i] = 1.0f; } weights[ 6] = mSpline->GetControlWeight(3); weights[ 8] = mSpline->GetControlWeight(5); weights[10] = mSpline->GetControlWeight(7); weights[12] = mSpline->GetControlWeight(9); delete0(mSpline); mSpline = new0 NURBSCurve2f(5, mCtrlPoints, weights, degree, false, true); mCircle = new0 NURBSCurve2f(9, &mCtrlPoints[5], &weights[5], degree, true, false); delete1(weights); }
void Clear () { for (size_t i=0; i<(int)mMaxSlot; i++) { Element *pcur = mTable[i]; while (pcur) { Element *ptmp = pcur; pcur = pcur->pnext; delete0(ptmp); } } for (int i=0; i<(int)mMaxSlot; i++) { mTable[i] = 0; } }
//---------------------------------------------------------------------------- void FreeFormDeformation::OnTerminate () { delete0(mVolume); delete1(mParameters); mPicker.Records.clear(); mScene = 0; mTrnNode = 0; mWireState = 0; mMesh = 0; mPolysegmentRoot = 0; mControlRoot = 0; mSelected = 0; mControlActive = 0; mControlInactive = 0; WindowApplication3::OnTerminate(); }
void ConvexHull3<Real>::ExtractIndices () { mNumSimplices = (int)mHull.size(); mIndices = new1<int>(3*mNumSimplices); typename std::set<Triangle*>::iterator iter = mHull.begin(); typename std::set<Triangle*>::iterator end = mHull.end(); for (int i = 0; iter != end; ++iter) { Triangle* tri = *iter; for (int j = 0; j < 3; ++j, ++i) { mIndices[i] = tri->V[j]; } delete0(tri); } mHull.clear(); }
//---------------------------------------------------------------------------- void PhysicsModule::Initialize (double time, double deltaTime, double theta, double thetaDot) { mTime = time; mDeltaTime = deltaTime; // state variables mState[0] = theta; mState[1] = thetaDot; // auxiliary variables mAux[0] = GDivL; mAux[1] = CDivM; // RK4 differential equation solver. Since mSolver is a base class // pointer, you can instead create a solver of whatever class you prefer. delete0(mSolver); mSolver = new0 OdeRungeKutta4d(2, mDeltaTime, OdeFunction, mAux); }