cloth::SwCloth::SwCloth( SwFactory& factory, SwFabric& fabric, Range<const PxVec4> particles) : mFactory(factory), mFabric(fabric), mNumVirtualParticles(0), mUserData(0) { PX_ASSERT(!particles.empty()); initialize(*this, particles.begin(), particles.end()); #if defined(PX_WINDOWS) const uint32_t kSimdWidth = 8; // avx #elif defined(PX_X360) || defined(PX_PS3) const uint32_t kSimdWidth = 8; // unrolled loop #else const uint32_t kSimdWidth = 4; // sse #endif mCurParticles.reserve(particles.size() + kSimdWidth-1); mCurParticles.assign( reinterpret_cast<const PxVec4*>(particles.begin()), reinterpret_cast<const PxVec4*>(particles.end())); // 7 dummy particles used in SIMD solver mCurParticles.resize(particles.size() + kSimdWidth-1, PxVec4(0.0f)); mPrevParticles = mCurParticles; mCurParticles.resize(particles.size()); mPrevParticles.resize(particles.size()); mFabric.incRefCount(); }
extern "C" char * getsub(int i) { static char *res = NULL; if (r) { if (i < r->groups() && i >= 0) { if (!r) return ("CALLING GETSUB WITH NO REGULAR EXPRESSION"); Range range = r->getgroup(i); if (res) free(res); int ll = range.length(); res = (char *) malloc(ll + 1); if ((range.start() == range.end()) && (target[range.end()] == '\0')) ll = 0; else strncpy(res, target + range.start(), range.end() - range.start() + 1); res[ll] = '\0'; /* cout << "group #" << i <<" length = "<< range.length() << endl; cout * << "spos = " <<range.start()<<", endp = "<< range.end() << endl; * cout << "(int) res[range.start()]:" << ((int) res[range.start()]) * << endl; cout << "(int) res[range.end()]:" << ((int) * res[range.end()]) << endl; cout << "The group is = |" << res <<"|" * <<endl; */ return (res); } else return ("INDEX OUT OF RANGE"); } else return ("NO RESULTS"); }
cloth::SwCloth::SwCloth(SwFactory& factory, SwFabric& fabric, Range<const PxVec4> particles) : mFactory(factory) , mFabric(fabric) , mNumVirtualParticles(0) #if APEX_UE4 , mSimulationTask(nullptr) #endif , mUserData(0) { PX_ASSERT(!particles.empty()); initialize(*this, particles.begin(), particles.end()); #if PX_WINDOWS_FAMILY const uint32_t kSimdWidth = 8; // avx #else const uint32_t kSimdWidth = 4; // sse #endif mCurParticles.reserve(particles.size() + kSimdWidth - 1); mCurParticles.assign(reinterpret_cast<const PxVec4*>(particles.begin()), reinterpret_cast<const PxVec4*>(particles.end())); // 7 dummy particles used in SIMD solver mCurParticles.resize(particles.size() + kSimdWidth - 1, PxVec4(0.0f)); mPrevParticles = mCurParticles; mCurParticles.resize(particles.size()); mPrevParticles.resize(particles.size()); mFabric.incRefCount(); }
void ThreadLocalCollector::scan_with_layout(const Range &range, const unsigned char* map) { // convert to double indirect void **reference = (void **)range.address(); void ** const end = (void **)range.end(); Range subrange; // while not '\0' terminator while (unsigned data = *map++) { // extract the skip and run unsigned skip = data >> 4; unsigned run = data & 0xf; // advance the reference by the skip reference += skip; // scan runs as a range. subrange.set_range(reference, reference + run); if (subrange.address() < end && subrange.end() <= end) { // <rdar://problem/6516045>: make sure we only scan valid ranges. scan_range(subrange); } else { break; } reference += run; } if (reference < end) { // since objects can be allocated with extra data at end, scan the remainder conservatively. subrange.set_range((void *)reference, end); scan_range(subrange); } }
void estimateGeometry(Shape& s, const double& h, const Range& r, vector<Point>& points, vector<Point>& tangents, vector<Quantity>& curvatures) { typedef typename Range::ConstIterator ConstIterator; typedef ParametricShapeTangentFunctor< Shape > TangentFunctor; typedef ParametricShapeCurvatureFunctor< Shape > CurvatureFunctor; for (ConstIterator i = r.begin(); i != r.end(); ++i) { Point p( *i ); p *= h; points.push_back(p); } TrueLocalEstimatorOnPoints< ConstIterator, Shape, TangentFunctor > trueTangentEstimator; TrueLocalEstimatorOnPoints< ConstIterator, Shape, CurvatureFunctor > trueCurvatureEstimator; trueTangentEstimator.init( h, r.begin(), r.end(), &s, false); tangents = estimateQuantity( trueTangentEstimator, r.begin(), r.end() ); trueCurvatureEstimator.init( h, r.begin(), r.end(), &s, false); curvatures = estimateQuantity( trueCurvatureEstimator, r.begin(), r.end() ); }
int main() { ErrorCode rval; Core moab; Interface& mb = moab; // load test file rval = mb.load_file( default_input_file ); if (MB_SUCCESS != rval) { std::cerr << default_input_file <<": failed to load file." << std::endl; return 1; } // get all region elements Range vols; rval = mb.get_entities_by_dimension( 0, 3, vols ); if (MB_SUCCESS != rval) return 2; if (vols.empty()) return 1; // create internal face elements Range faces; rval = mb.get_adjacencies( vols, 2, true, faces, Interface::UNION ); if (MB_SUCCESS != rval) return 2; assert(faces.size() > vols.size()); // time query of all adjacent volumes std::vector<EntityHandle> adj; clock_t t_0 = clock(); for (Range::iterator i = faces.begin(); i != faces.end(); ++i) { adj.clear(); rval = mb.get_adjacencies( &*i, 1, 3, false, adj ); if (MB_SUCCESS != rval) return 2; assert( adj.size() == 1 || adj.size() == 2 ); } clock_t t_up = clock() - t_0; std::cout << "Querying of volumes for " << faces.size() << " faces: " << t_up/(double)CLOCKS_PER_SEC << " seconds" << std::endl; // time downward adjacency query from volumes to faces t_0 = clock(); for (Range::iterator i = vols.begin(); i != vols.end(); ++i) { adj.clear(); rval = mb.get_adjacencies( &*i, 1, 1, false, adj ); if (MB_SUCCESS != rval) return 2; assert( adj.size() > 3 ); } clock_t t_down = clock() - t_0; std::cout << "Querying of faces for " << vols.size() << " volumes: " << t_down/(double)CLOCKS_PER_SEC << " seconds" << std::endl; return 0; }
bool pairwise_all_of(const Range& a, const Range& b, Binary_Predicate p) { auto a1 = a.begin(), a2 = a.end(); auto b1 = b.begin(), b2 = b.end(); while (a1 != a2 && b1 != b2 && p(*a1, *b1)) { ++a1; ++b1; } return a1 == a2 || b1 == b2; }
set_env_(const Range &envs) { std::size_t s = std::accumulate(envs.begin(), envs.end(), std::size_t(0), &set_env_::get_size); env_.resize(s + 1); std::for_each(envs.begin(), envs.end(), copy_env(env_.data())); env_[env_.size() - 1] = 0; }
bool lambda64ByPoint () { Segmentation segmenter ( curve.begin(), curve.end(), SegmentComputer() ); LambdaMST2D < Segmentation > lmst64; lmst64.attach ( segmenter ); for ( ConstIterator it = curve.begin(); it != curve.end(); ++it ) lmst64.eval ( *it ); return true; }
bool lambda64() { Segmentation segmenter ( curve.begin(), curve.end(), SegmentComputer() ); LambdaMST2D < Segmentation > lmst64; lmst64.attach ( segmenter ); lmst64.init ( curve.begin(), curve.end() ); std::vector < RealVector > tangent; lmst64.eval < back_insert_iterator< vector < RealVector > > > ( curve.begin(), curve.end(), back_inserter ( tangent ) ); return true; }
RequestFile::RequestFile(const Range &remote_name, const Range &type, const Range &content) : data_(content.begin(), static_cast<std::streamsize>(content.size())) { if (!remote_name.empty()) { remote_name_.assign(remote_name.begin(), remote_name.end()); } if (!type.empty()) { type_.assign(type.begin(), type.end()); } }
start_for( const Range& range, const Body& body, Partitioner& partitioner, test_partitioner_utils::BinaryTree* tree ) : my_range(range), my_body(body), my_partition(partitioner), m_executedBegin(0), m_executedEnd(0), m_firstTimeRun(true), m_joinedBegin(/* grows left */ range.end()), m_joinedEnd(range.end()), m_tree(tree) { if (m_tree) { m_tree->push_node( test_partitioner_utils::make_node(my_range.begin(), my_range.end(), affinity()) ); } }
bool Range::overlaps( const Range& range ) const { if (range.start() <= start()) return range.end() > start(); else if (range.end() >= end()) return range.start() < end(); else return contains(range); }
BOOST_AUTO_TEST_CASE_TEMPLATE(test_too_large, Range, checker_test_types) { enum { MAX_SIZE = 20 }; request_checker checker(MAX_SIZE); Range range = as<Range>("GET / HTTP/1.1\nHost: xiva.yandex.net\n\n"); BOOST_CHECK(range.size() > MAX_SIZE); std::pair<typename Range::iterator, bool> result = checker(range.begin(), range.end()); BOOST_CHECK(result.first == range.end()); BOOST_CHECK(result.second); }
//! Run body for range, serves as callback for partitioner void run_body( Range &r ) { my_body(r); if (m_firstTimeRun) { m_firstTimeRun = false; m_executedBegin = m_executedEnd = r.begin(); } ASSERT(m_executedBegin <= r.begin() && m_executedEnd < r.end(), "Non-continuous execution"); m_executedEnd = r.end(); }
/** parent_ remains left child. Newly constructed object is right child. */ start_for( start_for& parent_, const Range& r, depth_t d ) : my_range(r), my_body(parent_.my_body), my_partition(parent_.my_partition, tbb::split()), m_executedBegin(0), m_executedEnd(0), m_firstTimeRun(true), m_joinedBegin(/* grows left */ r.end()), m_joinedEnd(r.end()), m_tree(parent_.m_tree) { set_parent(parent_.parent()); my_partition.set_affinity(*this); my_partition.align_depth( d ); }
ErrorCode WriteVtk::write_bit_tag(std::ostream& stream, Tag tag, const Range& entities, const Range& tagged) { ErrorCode rval; const unsigned long n = entities.size(); // Get tag properties std::string name; int vals_per_tag; if (MB_SUCCESS != mbImpl->tag_get_name(tag, name) || MB_SUCCESS != mbImpl->tag_get_length(tag, vals_per_tag)) return MB_FAILURE; if (vals_per_tag > 8) { MB_SET_ERR(MB_FAILURE, "Invalid tag size for bit tag \"" << name << "\""); } // Get a tag value for each entity. // Get bits for each entity and unpack into // one integer in the 'data' array for each bit. // Initialize 'data' to zero because we will skip // those entities for which the tag is not set. std::vector<unsigned short> data; data.resize(n * vals_per_tag, 0); Range::const_iterator t = tagged.begin(); std::vector<unsigned short>::iterator d = data.begin(); for (Range::const_iterator i = entities.begin(); i != entities.end() && t != tagged.end(); ++i) { if (*i == *t) { ++t; unsigned char value; rval = mbImpl->tag_get_data(tag, &(*i), 1, &value); for (int j = 0; j < vals_per_tag; ++j, ++d) *d = (unsigned short)(value & (1 << j) ? 1 : 0); if (MB_SUCCESS != rval) return rval; } else { // If tag is not set for entity, skip values in array d += vals_per_tag; } } // Write the tag values, one entity per line. write_data(stream, data, vals_per_tag); return MB_SUCCESS; }
ErrorCode compute_velocity_case1(Interface * mb, EntityHandle euler_set, Tag & tagh, int rank, int tStep) { ErrorCode rval = MB_SUCCESS; Range polygons; rval = mb->get_entities_by_dimension(euler_set, 2, polygons); if (MB_SUCCESS != rval) return rval; Range connecVerts; rval = mb->get_connectivity(polygons, connecVerts); if (MB_SUCCESS != rval) return rval; void *data; // pointer to the velo in memory, for each vertex int count; rval = mb->tag_iterate(tagh, connecVerts.begin(), connecVerts.end(), count, data); CHECK_ERR(rval); // here we are checking contiguity assert(count == (int) connecVerts.size()); double * ptr_velo=(double*)data; // lambda is for longitude, theta for latitude for (Range::iterator vit=connecVerts.begin();vit!=connecVerts.end(); vit++ ) { EntityHandle oldV=*vit; CartVect posi; rval = mb->get_coords(&oldV, 1, &(posi[0]) ); CHECK_ERR(rval); CartVect velo ; double t = T * tStep/numSteps; // velocity_case1(posi, t, velo); ptr_velo[0]= velo[0]; ptr_velo[1]= velo[1]; ptr_velo[2]= velo[2]; // increment to the next node ptr_velo+=3;// to next velocity } std::stringstream velos; velos<<"Tracer" << rank<<"_"<<tStep<< ".vtk"; rval = mb->write_file(velos.str().c_str(), 0, 0, &euler_set, 1, &tagh, 1); CHECK_ERR(rval); return MB_SUCCESS; }
bool Range::expandToRange(const Range& range) { if (start() > range.start()) if (end() < range.end()) setRange(range); else start() = range.start(); else if (end() < range.end()) end() = range.end(); else return false; return true; }
inline bool contains( Range const &_range, T const &_value ) { return ::std::find( _range.begin(), _range.end(), _value ) != _range.end(); }
bool drawingTestStabbingCircleComputer(const TCurve& curve, const string& suffix) { typedef typename TCurve::IncidentPointsRange Range; //range Range r = curve.getIncidentPointsRange(); //range { typedef typename Range::ConstIterator ConstIterator; //iterator StabbingCircleComputer<ConstIterator> s; longestSegment(s,r.begin(),r.end()); Board2D board; board << r << s; std::stringstream ss; ss << "StabbingCircleComputerDrawingTest" << suffix << ".eps"; board.saveEPS(ss.str().c_str()); } { typedef typename Range::ConstReverseIterator ConstReverseIterator; //iterator StabbingCircleComputer<ConstReverseIterator> s; longestSegment(s,r.rbegin(),r.rend()); Board2D board; board << r << s; std::stringstream ss; ss << "StabbingCircleComputerDrawingTest" << suffix << "2.eps"; board.saveEPS(ss.str().c_str()); } return true; }
/** * Calculates the minimum and maximum co-ordinates over the given array * range. * \param range point range. */ void operator()(const Range& range) { // get pointers locally. Point min = pointsIn[0]; Point max = pointsIn[0]; // calculate the minimum and maximum co-ordinates over the range. for (index_t i = range.begin(); i != range.end(); ++i) { if (pointsIn[i].x < min.x) { min.x = pointsIn[i].x; } if (pointsIn[i].y < min.y) { min.y = pointsIn[i].y; } if (pointsIn[i].x > max.x) { max.x = pointsIn[i].x; } if (pointsIn[i].y > max.y) { max.y = pointsIn[i].y; } } // refresh member variables. minPoint = min; maxPoint = max; }
iterator_range< boost::transform_iterator< F, typename boost::range_iterator<const Range>::type> > make_transformed(const Range& range, F f) { return { boost::make_transform_iterator(range.begin(), f), boost::make_transform_iterator(range.end(), f) }; }
ErrorCode ReadDamsel::process_entity_tags(int count, damsel_container tag_container, damsel_container app_cont, Range &these_ents) { // process tags on these entities ErrorCode rval = MB_SUCCESS; for (int i = 0; i < count; i++) { damsel_handle dtagh = DMSLcontainer_handle_at_position(tag_container, i); // don't do conventional tags here std::vector<DamselUtil::tinfo>::iterator vit = std::find_if(dU.tagMap.begin(), dU.tagMap.end(), DamselUtil::DtagP<DamselUtil::tinfo>(dtagh)); if ((*vit).tagType == MB_TAG_ANY) continue; else if (vit == dU.tagMap.end()) CHK_MB_ERR(MB_FAILURE, "Failed to find tag."); Tag tagh = (*vit).mTagh; assert(tagh); void *tag_data; int ecount = these_ents.size(); rval = mbImpl->tag_iterate(tagh, these_ents.begin(), these_ents.end(), ecount, tag_data); CHK_MB_ERR(rval, "Problem getting tag iterator."); assert(ecount == (int)these_ents.size()); damsel_err_t err = DMSLmodel_map_tag(tag_data, app_cont, (damsel_handle_ptr)&tagh); CHK_DMSL_ERR(err, " "); } return rval; }
Range::Range(const Range& copy) : m_start(new Cursor(copy.start())) , m_end(new Cursor(copy.end())) { m_start->setRange(this); m_end->setRange(this); }
Range KTextEditor::Range::intersect( const Range & range ) const { if (!isValid() || !range.isValid() || *this > range || *this < range) return invalid(); return Range(qMax(start(), range.start()), qMin(end(), range.end())); }
void ClothImpl<SwCloth>::setSelfCollisionIndices(Range<const uint32_t> indices) { ContextLockType lock(mCloth.mFactory); mCloth.mSelfCollisionIndices.assign(indices.begin(), indices.end()); mCloth.notifyChanged(); mCloth.wakeUp(); }
bool contains::operator()(Range v) const { if (exp==Expression(v)) return true; Expression start=v.start(), end=v.end(); bool rs = apply(start); bool re = apply(end); return rs || re; }
void estimateGeometry(Shape& s, const double& h, const Range& r, std::vector<Point>& points, std::vector<Point>& tangents, std::vector<Quantity>& curvatures) { typedef typename Range::ConstIterator ConstIterator; for (ConstIterator i = r.begin(); i != r.end(); ++i) { Point p( *i ); p *= h; points.push_back(p); } typedef typename Range::ConstCirculator ConstCirculator; typedef ParametricShapeTangentFunctor< Shape > TangentFunctor; TrueLocalEstimatorOnPoints< ConstCirculator, Shape, TangentFunctor > trueTangentEstimator; trueTangentEstimator.attach(&s); trueTangentEstimator.init( h, r.c(), r.c()); trueTangentEstimator.eval(r.c(), r.c(), std::back_inserter(tangents) ); typedef ParametricShapeCurvatureFunctor< Shape > CurvatureFunctor; TrueLocalEstimatorOnPoints< ConstCirculator, Shape, CurvatureFunctor > trueCurvatureEstimator; trueCurvatureEstimator.attach(&s); trueCurvatureEstimator.init( h, r.c(), r.c()); trueCurvatureEstimator.eval(r.c(), r.c(), std::back_inserter(curvatures) ); }
bool testPairsRange(const Range &aRange) { trace.info() << endl; trace.info() << "Testing Range (" << aRange.size() << " pairs)" << endl; { trace.info() << "Forward" << endl; typename Range::ConstIterator i = aRange.begin(); typename Range::ConstIterator end = aRange.end(); for ( ; i != end; ++i) { cout << (*i).first << " " << (*i).second << endl; } } { trace.info() << "Backward" << endl; typename Range::ConstReverseIterator i = aRange.rbegin(); typename Range::ConstReverseIterator end = aRange.rend(); for ( ; i != end; ++i) { cout << i->first << " " << i->second << endl; } } return true; }