Exemple #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RigReservoirBuilderMock::appendNodes(const cvf::Vec3d& min, const cvf::Vec3d& max, const cvf::Vec3st& cubeDimension, std::vector<cvf::Vec3d>& nodes)
{
    double dx = (max.x() - min.x()) / static_cast<double>(cubeDimension.x());
    double dy = (max.y() - min.y()) / static_cast<double>(cubeDimension.y());
    double dz = (max.z() - min.z()) / static_cast<double>(cubeDimension.z());

    double zPos = min.z();

    size_t k;
    for (k = 0; k < cubeDimension.z(); k++)
    {
        double yPos = min.y();

        size_t j;
        for (j = 0; j < cubeDimension.y(); j++)
        {
            double xPos = min.x();

            size_t i;
            for (i = 0; i < cubeDimension.x(); i++)
            {
                cvf::Vec3d min(xPos, yPos, zPos);
                cvf::Vec3d max(xPos + dx, yPos + dy, zPos + dz);

                appendCubeNodes(min, max, nodes);

                xPos += dx;
            }

            yPos += dy;
        }

        zPos += dz;
    }
}
Exemple #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RigReservoirBuilderMock::appendCubeNodes(const cvf::Vec3d& min, const cvf::Vec3d& max, std::vector<cvf::Vec3d>& nodes)
{
    //
    //     7---------6                Faces:
    //    /|        /|     |k           0 bottom   0, 3, 2, 1
    //   / |       / |     | /j         1 top      4, 5, 6, 7
    //  4---------5  |     |/           2 front    0, 1, 5, 4
    //  |  3------|--2     *---i        3 right    1, 2, 6, 5
    //  | /       | /                   4 back     3, 7, 6, 2
    //  |/        |/                    5 left     0, 4, 7, 3
    //  0---------1                     

    cvf::Vec3d v0(min.x(), min.y(), min.z());
    cvf::Vec3d v1(max.x(), min.y(), min.z());
    cvf::Vec3d v2(max.x(), max.y(), min.z());
    cvf::Vec3d v3(min.x(), max.y(), min.z());
             
    cvf::Vec3d v4(min.x(), min.y(), max.z());
    cvf::Vec3d v5(max.x(), min.y(), max.z());
    cvf::Vec3d v6(max.x(), max.y(), max.z());
    cvf::Vec3d v7(min.x(), max.y(), max.z());

    nodes.push_back(v0);
    nodes.push_back(v1);
    nodes.push_back(v2);
    nodes.push_back(v3);
    nodes.push_back(v4);
    nodes.push_back(v5);
    nodes.push_back(v6);
    nodes.push_back(v7);
}
int largestComponent(const cvf::Vec3d v)
{
    double maxLength = v.x();
    int idx = 0;

    if (v.y() > maxLength)
    {
        maxLength = v.y();
        idx = 1;
    }

    if (v.z() > maxLength)
    {
        maxLength = v.z();
        idx = 2;
    }

    return idx;
}
double largestComponent(const cvf::Vec3d v, cvf::uint* largestIndex)
{
    double length = v.x();
    cvf::uint idx = 0;

    if (v.y() > length)
    {
        length = v.y();
        idx = 1;
    }

    if (v.z() > length)
    {
        length = v.z();
        idx = 2;
    }

    if (largestIndex) *largestIndex = idx;

    return length;
}
Exemple #5
0
int GeometryTools::findClosestAxis(const cvf::Vec3d& vec )
{
    int closestAxis = 0;
    double maxComponent = fabs(vec.x());

    if (fabs(vec.y()) > maxComponent)
    {
        maxComponent = (float)fabs(vec.y());
        closestAxis = 1;
    }

    if (fabs(vec.z()) > maxComponent)
    {
        closestAxis = 2;
    }

    return closestAxis;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void XmlElementImpl::setAttributeVector(const String& attributeName, const cvf::Vec3d& val)
{
    String valString =  String::number(val.x()) + " " + String::number(val.y()) + " " + String::number(val.z());

    setAttributeString(attributeName, valString);
}