EXPORT_C TBool CHTTPResponse::ExtractCacheControlTime(TCacheControlFieldValue aField, TTime& aTime) const { __LOG_ENTER(_L("CHTTPResponse::ExtractCacheControlTime")); __ASSERT_DEBUG(aField == ECacheCtrlMaxAge || aField == ECacheCtrlMaxStale || aField == ECacheCtrlMinFresh, User::Invariant()); TBool result = EFalse; TPtrC8 cacheControl; aTime = 0; TInt index = FindCacheControlFieldValue(aField, cacheControl); if(index != KErrNotFound) { // Have the cache control and the field position // Now we need to extract the field's delta-secs value index++; TInt time = 0; TPtrC8 integerSource = cacheControl.Mid(index); if(integerSource[0] >= 0x80) // Short integer value time = integerSource[0] & 0x7F; else // Otherwise its multi octet ExtractMultiOctetInteger(time, integerSource); TTimeIntervalSeconds timeSeconds(time); aTime += timeSeconds; // Store the seconds in the time field result = ETrue; } __LOG_RETURN; return result; }
// Method to find a named field within the Cache Control header // // In: // aSource - the descriptor containing the date value // aFrom - The position in the descriptor to start from // // Out: // aTime - a structure containing the time (and date) found in the descriptor // // NOTE THIS METHOD WAS EXPORTED FOR TESTING OF THE CACHE. IT SHOULDN'T BE // NOW, BUT CAN'T BE CHANGED SINCE IT WOULD AFFECT BC. void CHTTPResponse::ExtractFieldDateValue(const TPtrC8& aSource, TInt aFrom, TTime& aTime) const { __LOG_ENTER(_L("CHTTPResponse::ExtractFieldDateValue")); // Get num bytes encoding the date - // we are positioned at that location in the source descriptor TInt time = 0; TPtrC8 integerSource = aSource.Mid(aFrom); ExtractMultiOctetInteger(time, integerSource); // The WSP Date encoding is the number of seconds since the start of the // UNIX epoch (00:00:00.000, 01-Jan-1970), as a long integer TDateTime unixEpocDT(1970, EJanuary, 0, 0, 0, 0, 0); TTime unixEpoch(unixEpocDT); TTimeIntervalSeconds timeSeconds(time); aTime = unixEpoch + timeSeconds; __LOG_RETURN; }
MStatus particlePathsCmd::doIt( const MArgList& args ) { MStatus stat = parseArgs( args ); if( stat != MS::kSuccess ) { return stat; } MFnParticleSystem cloud( particleNode ); if( ! cloud.isValid() ) { MGlobal::displayError( "The function set is invalid!" ); return MS::kFailure; } // // Create curves from the particle system in two stages. First, sample // all particle positions from the start time to the end time. Then, // use the data that was collected to create curves. // // Create the particle hash table at a fixed size. This should work fine // for small particle systems, but may become inefficient for larger ones. // If the plugin is running very slow, increase the size. The value should // be roughly the number of particles that are expected to be emitted // within the time period. // ParticleIdHash hash(1024); MIntArray idList; // // Stage 1 // MVectorArray positions; MIntArray ids; int i = 0; for (double time = start; time <= finish + TOLERANCE; time += increment) { MTime timeSeconds(time,MTime::kSeconds); // It is necessary to query the worldPosition attribute to force the // particle positions to update. // cloud.evaluateDynamics(timeSeconds,false); // MGlobal::executeCommand(MString("getAttr ") + cloud.name() + // MString(".worldPosition")); if (!cloud.isValid()) { MGlobal::displayError( "Particle system has become invalid." ); return MS::kFailure; } MGlobal::displayInfo( MString("Received ") + (int)(cloud.count()) + " particles, at time " + time); // Request position and ID data for particles // cloud.position( positions ); cloud.particleIds( ids ); if (ids.length() != cloud.count() || positions.length() != cloud.count()) { MGlobal::displayError( "Invalid array sizes." ); return MS::kFailure; } for (int j = 0; j < (int)cloud.count(); j++) { // Uncomment to show particle positions as the plugin accumulates // samples. /* MGlobal::displayInfo(MString("(") + (positions[j])[0] + MString(",") + (positions[j])[1] + MString(",") + (positions[j])[2] + MString(")")); */ MPoint pt(positions[j]); if (hash.getPoints(ids[j]).length() == 0) { idList.append(ids[j]); } hash.insert(ids[j],pt); } i++; } // // Stage 2 // for (i = 0; i < (int)(idList.length()); i++) { MPointArray points = hash.getPoints(idList[i]); // Don't bother with single samples if (points.length() <= 1) { continue; } // Add two additional points, so that the curve covers all sampled // values. // MPoint p1 = points[0]*2 - points[1]; MPoint p2 = points[points.length()-1]*2 - points[points.length()-2]; points.insert(p1,0); points.append(p2); // Uncomment to show information about the generated curves /* MGlobal::displayInfo( MString("ID ") + (int)(idList[i]) + " has " + (int)(points.length()) + " curve points."); for (int j = 0; j < (int)(points.length()); j++) { MGlobal::displayInfo(MString("(") + points[j][0] + MString(",") + points[j][1] + MString(",") + points[j][2] + MString(")")); } */ MDoubleArray knots; knots.insert(0.0,0); for (int j = 0; j < (int)(points.length()); j++) { knots.append((double)j); } knots.append(points.length()-1); MStatus status; MObject dummy; MFnNurbsCurve curve; curve.create(points,knots,3,MFnNurbsCurve::kOpen,false,false,dummy,&status); if (!status) { MGlobal::displayError("Failed to create nurbs curve."); return MS::kFailure; } } return MS::kSuccess; }