EXPORTED void bv_clear(bitvector_t *bv, unsigned int i) { if (i < bv->length) { bv_ensure(bv, i+1); bv->bits[vidx(i)] &= ~vmask(i); } }
EXPORTED void bv_set(bitvector_t *bv, unsigned int i) { bv_ensure(bv, i+1); bv->bits[vidx(i)] |= vmask(i); if (i >= bv->length) bv->length = i+1; }
bool QgsGeometryCheckError::isEqual( QgsGeometryCheckError *other ) const { return other->check() == check() && other->layerId() == layerId() && other->featureId() == featureId() && other->vidx() == vidx(); }
bool QgsGeometrySelfIntersectionCheckError::isEqual( QgsGeometryCheckError* other ) const { return QgsGeometryCheckError::isEqual( other ) && other->featureId() == featureId() && other->vidx() == vidx() && static_cast<QgsGeometrySelfIntersectionCheckError*>( other )->intersection().segment1 == intersection().segment1 && static_cast<QgsGeometrySelfIntersectionCheckError*>( other )->intersection().segment2 == intersection().segment2; }
EXPORTED void bv_setsize(bitvector_t *bv, unsigned int len) { bv_ensure(bv, len); if (len < bv->length) { /* shrinking - need to clear old bits */ memset(bv->bits+vlen(len), 0, vlen(bv->length) - vlen(len)); bv->bits[vidx(len)] &= ~vtailmask(len); } bv->length = len; }
/* * Returns the bit position of the previous set bit which is before or * equal to position 'start'. Passing start = bv->vector-1 returns the * last set bit. Returns a bit position or -1 if there are no more set * bits. */ EXPORTED int bv_prev_set(const bitvector_t *bv, int start) { int i; if (start < 0 || start >= (int)bv->length) return -1; for (i = start ; i < (int)bv->length && !visaligned(i) ; i--) if (bv->bits[vidx(i)] & vmask(i)) return i; while (i >= 0) { if (!bv->bits[vidx(i)]) { i -= BITS_PER_UNIT; } else { if (bv->bits[vidx(i)] & vmask(i)) return i; i--; } } return -1; }
/* * Compute bitmask of all vendors present in an attribute set 'pa' * * E.g., if 'pa' contains attributes associated with vendors "gnu" * and "foo" and the vendors "gnu", "boo" and "foo" are * registered/known then 'vset(pa)' returns 0x5 since it * contains vendors #0 ("gnu") and #2 ("foo"). */ static int vset(Pmelf_attribute_set *pa) { int i,j; unsigned rval = 0; for ( i=0; i<ATTR_MAX_VENDORS; i++ ) { if ( pa->attributes[i].file_attributes ) { j = vidx(pa->attributes[i].file_attributes->pv); if ( j < 0 ) { PMELF_PRINTF(pmelf_err, PMELF_PRE"pmelf_match_attribute_set(): invalid vendor index ?? (object %s)\n", pa->obj_name); return -1; } rval |= (1<<j); } } return rval; }
static void save_molecular_type(const MolecularTypeBase* mtb, std::vector<std::pair<ParticleID, Voxel> > voxels, H5::Group* group) { const Species species(mtb->species()); boost::scoped_ptr<H5::Group> mtgroup( new H5::Group(group->createGroup(species.serial().c_str()))); h5_species_struct property; property.radius = mtb->radius(); property.D = mtb->D(); const MolecularTypeBase* loc(mtb->location()); if (loc->is_vacant()) std::strcpy(property.location, ""); else std::strcpy(property.location, loc->species().serial().c_str()); property.is_structure = mtb->is_structure() ? 1 : 0; property.dimension = mtb->get_dimension(); H5::CompType property_comp_type(get_property_comp()); mtgroup->createAttribute("property", property_comp_type, H5::DataSpace(H5S_SCALAR)).write(property_comp_type, &property); // Save voxels const Integer num_voxels(voxels.size()); std::size_t vidx(0); boost::scoped_array<h5_voxel_struct> h5_voxel_array(new h5_voxel_struct[num_voxels]); for (std::vector<std::pair<ParticleID, Voxel> >::const_iterator itr(voxels.begin()); itr != voxels.end(); ++itr) { h5_voxel_array[vidx].lot = (*itr).first.lot(); h5_voxel_array[vidx].serial = (*itr).first.serial(); h5_voxel_array[vidx].coordinate = (*itr).second.coordinate(); ++vidx; } H5::CompType voxel_comp_type(get_voxel_comp()); hsize_t dims[] = {num_voxels}; H5::DataSpace dspace(/* RANK= */1, dims); boost::scoped_ptr<H5::DataSet> dset(new H5::DataSet( mtgroup->createDataSet("voxels", voxel_comp_type, dspace))); dset->write(h5_voxel_array.get(), dset->getDataType()); }
void QgsGeometryDegeneratePolygonCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const { QMap<QString, QgsFeatureIds> featureIds = ids.isEmpty() ? allLayerFeatureIds() : ids; QgsGeometryCheckerUtils::LayerFeatures layerFeatures( mContext->featurePools, featureIds, mCompatibleGeometryTypes, progressCounter ); for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeature : layerFeatures ) { const QgsAbstractGeometry *geom = layerFeature.geometry(); for ( int iPart = 0, nParts = geom->partCount(); iPart < nParts; ++iPart ) { for ( int iRing = 0, nRings = geom->ringCount( iPart ); iRing < nRings; ++iRing ) { if ( QgsGeometryCheckerUtils::polyLineSize( geom, iPart, iRing ) < 3 ) { QgsVertexId vidx( iPart, iRing ); errors.append( new QgsGeometryCheckError( this, layerFeature, geom->vertexAt( vidx ), vidx ) ); } } } } }
EXPORTED int bv_isset(const bitvector_t *bv, unsigned int i) { if (i >= bv->length) return 0; return !!(bv->bits[vidx(i)] & vmask(i)); }