コード例 #1
0
ファイル: qgsmeshcalcutils.cpp プロジェクト: dmarteau/QGIS
std::shared_ptr<QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::create( const QString &datasetGroupName ) const
{
  const auto dp = mMeshLayer->dataProvider();
  std::shared_ptr<QgsMeshMemoryDatasetGroup> grp;
  for ( int group_i = 0; group_i < dp->datasetGroupCount(); ++group_i )
  {
    const auto meta = dp->datasetGroupMetadata( group_i );
    const QString name = meta.name();
    if ( name == datasetGroupName )
    {
      grp = std::make_shared<QgsMeshMemoryDatasetGroup>();
      grp->isScalar = meta.isScalar();
      grp->type = meta.dataType();
      grp->maximum = meta.maximum();
      grp->minimum = meta.minimum();
      grp->name = meta.name();

      int count = ( meta.dataType() == QgsMeshDatasetGroupMetadata::DataOnFaces ) ? dp->faceCount() : dp->vertexCount();
      for ( int dataset_i = 0; dataset_i < dp->datasetCount( group_i ); ++dataset_i )
      {
        const QgsMeshDatasetIndex index( group_i, dataset_i );
        const auto dsMeta = dp->datasetMetadata( index );
        std::shared_ptr<QgsMeshMemoryDataset> ds = create( grp->type );
        ds->maximum = dsMeta.maximum();
        ds->minimum = dsMeta.minimum();
        ds->time = dsMeta.time();
        ds->valid = dsMeta.isValid();

        const QgsMeshDataBlock block = dp->datasetValues( index, 0, count );
        Q_ASSERT( block.count() == count );
        for ( int value_i = 0; value_i < count; ++value_i )
          ds->values[value_i] = block.value( value_i );

        const QgsMeshDataBlock active = dp->areFacesActive( index, 0, dp->faceCount() );
        Q_ASSERT( active.count() == dp->faceCount() );
        for ( int value_i = 0; value_i < dp->faceCount(); ++value_i )
          ds->active[value_i] = active.active( value_i );

        grp->addDataset( ds );
      }

      break;
    }
  }
  return grp;
}
コード例 #2
0
ファイル: APolygonalMesh.cpp プロジェクト: ahmidou/aphid
const BoundingBox APolygonalMesh::calculateBBox(unsigned icomponent) const
{
    Vector3F * p = points();
	unsigned * v = polygonIndices(icomponent);
    const unsigned n = faceCount(icomponent);
	BoundingBox box;
    unsigned i = 0;
    for(;i<n; i++) {
        box.updateMin(p[v[i]]);
        box.updateMax(p[v[i]]);
	}
	return box;
}
コード例 #3
0
ファイル: PlyWriter.cpp プロジェクト: pblottiere/PDAL
void PlyWriter::writeHeader(PointLayoutPtr layout) const
{
    *m_stream << "ply" << std::endl;
    *m_stream << "format " << m_format << " 1.0" << std::endl;
    *m_stream << "comment Generated by PDAL" << std::endl;
    *m_stream << "element vertex " << pointCount() << std::endl;

    auto ni = m_dimNames.begin();
    for (auto dim : m_dims)
    {
        std::string name = *ni++;
        std::string typeString = getType(layout->dimType(dim));
        *m_stream << "property " << typeString << " " << name << std::endl;
    }
    if (m_faces)
    {
        *m_stream << "element face " << faceCount() << std::endl;
        *m_stream << "property list uint8 uint32 vertex_indices" << std::endl;
    }
    *m_stream << "end_header" << std::endl;
}
コード例 #4
0
ファイル: cvfPrimitiveSet.cpp プロジェクト: akva2/ResInsight
//--------------------------------------------------------------------------------------------------
/// Gets connectivity for one face in this primitive set
/// 
/// The indices array will be populated with the connectivities for the specified face. 
/// The connectivity table will have 1, 2, 3 or 4 entries. If this primitive set consists 
/// of a triangle fan, triangles will be returned. In a similar fashion, if the primitive set
/// consist of a quad strip, quads will be returned.
//--------------------------------------------------------------------------------------------------
void PrimitiveSet::getFaceIndices(size_t indexOfFace, UIntArray* indices) const
{
    CVF_TIGHT_ASSERT(indexOfFace < faceCount());
    CVF_TIGHT_ASSERT(indices);

    indices->setSizeZero();

    if (m_primitiveType == PT_POINTS)
    {
        indices->reserve(1);
        indices->add(index(indexOfFace));
    }
    else if (m_primitiveType == PT_LINES)
    {
        indices->reserve(2);
        indices->add(index(2*indexOfFace));
        indices->add(index(2*indexOfFace + 1));
    }
    else if (m_primitiveType == PT_LINE_LOOP)
    {
        indices->reserve(2);

        if (indexOfFace == faceCount() - 1)
        {
            indices->add(index(indexOfFace));
            indices->add(index(0));
        }
        else
        {
            indices->add(index(indexOfFace));
            indices->add(index(indexOfFace + 1));
        }
    }
    else if (m_primitiveType == PT_LINE_STRIP)
    {
        indices->reserve(2);
        indices->add(index(indexOfFace));
        indices->add(index(indexOfFace + 1));
    }
    else if (m_primitiveType == PT_TRIANGLES)
    {
        indices->reserve(3);

        const size_t baseIdx = 3*indexOfFace;
        indices->add(index(baseIdx));
        indices->add(index(baseIdx + 1));
        indices->add(index(baseIdx + 2));
    }
    else if (m_primitiveType == PT_TRIANGLE_FAN)
    {
        indices->reserve(3);
        indices->add(index(0));
        indices->add(index(indexOfFace + 1));
        indices->add(index(indexOfFace + 2));
    }
    else if (m_primitiveType == PT_TRIANGLE_STRIP)
    {
        indices->reserve(3);

        if (indexOfFace % 2 == 0)
        {
            indices->add(index(indexOfFace));
            indices->add(index(indexOfFace + 1));
            indices->add(index(indexOfFace + 2));
        }
        else
        {
            indices->add(index(indexOfFace + 1));
            indices->add(index(indexOfFace));
            indices->add(index(indexOfFace + 2));
        }
    }
    else
    {
        CVF_FAIL_MSG("Not implemented");
    }
}
コード例 #5
0
ファイル: CSSFontFaceSet.cpp プロジェクト: edcwconan/webkit
CSSFontFace& CSSFontFaceSet::operator[](size_t i)
{
    ASSERT(i < faceCount());
    return m_faces[i];
}