Beispiel #1
0
int rviewOSectionImage::makeMinterval(unsigned int num, r_Minterval &dom)
{
    r_Range low, high;
    r_Sinterval aux[3];
    dom = r_Minterval(dimMDD);
    unsigned int map;

    aux[secmap[num].x] = interv[secmap[num].x];
    aux[secmap[num].y] = interv[secmap[num].y];
    // projection dimension
    map = secmap[num].z;
    low = intersection[map] - thickness/2;
    high = low + thickness - 1;
    if (low < interv[map].low())
        low = interv[map].low();
    if (high > interv[map].high())
        high = interv[map].high();
    aux[map] = r_Sinterval(low, high);

    dom << aux[0] << aux[1] << aux[2];
    //cout << "INTERVAL " << dom << endl;

    return 0;
}
Beispiel #2
0
int rmanClientApp::LookupCollection(void)
{
    collection_desc *desc;
    char *name;

    name = ::wxGetTextFromUser(lman->lookup("promptEnterColl"), lman->lookup("titleCollLook"), (char*)(prefs->lastColl.ptr()));

    if (name == NULL) return 0;

    if ((desc = new collection_desc) == NULL)
    {
        cerr << lman->lookup("errorMemory")  << endl;
        return 0;
    }
    memset(desc, 0, sizeof(collection_desc));

    if ((desc->collName = new char [strlen(name) + 1]) == NULL)
    {
        cerr << lman->lookup("errorMemory") << endl;
        delete desc;
        return 0;
    }

    strcpy(desc->collName, name);
    prefs->lastColl = name;
    prefs->markModified();

#ifdef DUMMY_MDD_OBJECT
    desc->number = 1;
    r_Minterval iv(3);
    iv << r_Sinterval(r_Range(0),r_Range(300)) << r_Sinterval(r_Range(200),r_Range(400)) << r_Sinterval(r_Range(10), r_Range(12));
    desc->mddObjs = new mdd_frame[1];
    desc->mddObjs[0].mdd = (r_Ref <r_GMarray>) new r_Marray<DUMMY_MDD_OBJECT>(iv);
    desc->collType = new char[16];
    strcpy(desc->collType, "r_UShort");
    r_Ref < r_Marray < DUMMY_MDD_OBJECT > > mddPtr = (r_Ref < r_Marray < DUMMY_MDD_OBJECT > >) desc->mddObjs[0].mdd;
    mddPtr->set_type_by_name("UShortImage");
    r_Point point(3);
    cout << mddPtr->spatial_domain() << endl;
    for (point[0]=0; point[0]<=300; point[0]++)
        for (point[1]=200; point[1]<=400; point[1]++)
            for (point[2]=10; point[2]<=12; point[2]++)
                (*mddPtr)[point] = ((DUMMY_MDD_OBJECT)(point[0] + point[1] + point[2])) << (8*(sizeof(DUMMY_MDD_OBJECT) - 1));

    if (1)
#else
    if (database.lookupCollection(desc) != 0)
#endif
    {

        /*for (int i=0; i<desc->number; i++)
        {
          cout << "Object #" << i << ": " << desc->mddArrays[i]->spatial_domain() << endl;
        }*/

        rviewResult *result = new rviewResult(desc);

        return 1;
    }
    else
    {
        rviewDeleteCollection(desc);
    }

    return 0;
}
Beispiel #3
0
int rviewOSectionImage::performPartition(void)
{
    RMDBGONCE(3, RMDebug::module_applications, "rviewOSectionImage", "performPartition()");
    unsigned int i, j;
    section_part_t *part = partition;
    r_Point midpoint(dimMDD);

    for (i=0; i<dimMDD; i++)
        midpoint[i] = (interv[i].high() + interv[i].low() + 1) / 2;

    for (i=0; i<numSections; i++)
    {
        if (sectionValid(i))
        {
            const r_Minterval secdom = getSectionDomain(i);
            r_Range low, high;
            int map;

            // note: all MDD have 3D domains, describing their actual position within
            // the entire cube, therefore these dimensions can be used directly for the
            // spatial representation, making things a lot easier than using 2D domains
            // would.
            map = secmap[i].z;
            low = secdom[secmap[i].z].low();
            high = secdom[secmap[i].z].high();
            // check whether this section should be displayed at all (-> projection string)
            if ((pt1[map] <= high) && (pt2[map] >= low))
            {
                // yes, now clip it
                if (low < pt1[map])
                    low = pt1[map];
                if (high > pt2[map])
                    high = pt2[map];

                r_Sinterval ziv(low, high);

                for (j=0; j<4; j++)
                {
                    r_Sinterval auxdom[3];

                    auxdom[secmap[i].z] = ziv;

                    map = secmap[i].x;
                    if ((j & 1) == 0)
                    {
                        low = pt1[map];
                        high = intersection[map] - thickness/2;
                    }
                    else
                    {
                        low = intersection[map] + thickness/2;
                        high = pt2[map];
                    }
                    // the current projection string might project some of these partitions away
                    if (low <= high)
                    {
                        // this can still happen if the intersection point is outside the current projection
                        // domain for the still visible quadrant.
                        if (low < pt1[map])
                            low = pt1[map];
                        if (high > pt2[map])
                            high = pt2[map];

                        auxdom[map] = r_Sinterval(low, high);

                        map = secmap[i].y;
                        if ((j & 2) == 0)
                        {
                            low = pt1[map];
                            high = intersection[map] - thickness/2;
                        }
                        else
                        {
                            low = intersection[map] + thickness/2;
                            high = pt2[map];
                        }
                        // ditto
                        if (low <= high)
                        {
                            // see above
                            if (low < pt1[map])
                                low = pt1[map];
                            if (high > pt2[map])
                                high = pt2[map];

                            r_Minterval dom(dimMDD);  // domain of quadrant in absolute coordinates

                            auxdom[map] = r_Sinterval(low, high);
                            dom << auxdom[0] << auxdom[1] << auxdom[2];

                            // now calculate the descriptor for this domain
                            tex_desc *td = &(part->td);
                            part->section = i;
                            const r_Minterval &pardom = getSectionParent(i);
                            td->dimx = pardom[0].high() - pardom[0].low() + 1;
                            td->dimy = pardom[1].high() - pardom[1].low() + 1;
                            td->dimz = pardom[2].high() - pardom[2].low() + 1;
                            td->widthx = dom[0].high() - dom[0].low() + 1;
                            td->widthy = dom[1].high() - dom[1].low() + 1;
                            td->widthz = dom[2].high() - dom[2].low() + 1;
                            part->offset = (((dom[0].low() - pardom[0].low()) * td->dimy + (dom[1].low() - pardom[1].low())) * td->dimz + (dom[2].low() - pardom[2].low())) * baseSize;
                            td->baseSize = baseSize;
                            td->floatType = ((baseType == rbt_float) || (baseType == rbt_double));
                            part->quadrant = j;
                            //cout << "DOM " << dom << ", PARENT " << pardom << ", OFFSET " << part->offset << ", size " << pardom.cell_count() << endl;

                            vertex_fp *v, *w;

                            // this rotates the subcube's origin. The total origin is 0 for now.
                            // use gr[1] as temporary workspace for the unrotated origin
                            w = &(part->gr[1]);
                            w->x = dom[0].low() - midpoint[0];    // or is it secmap?
                            w->y = dom[1].low() - midpoint[1];
                            w->z = dom[2].low() - midpoint[2];

                            v = &(part->gr[0]);
                            v->x = cubeScale * (w->x * rot[0].x + w->y * rot[0].y + w->z * rot[0].z);
                            v->y = cubeScale * (w->x * rot[1].x + w->y * rot[1].y + w->z * rot[1].z);
                            v->z = cubeScale * (w->x * rot[2].x + w->y * rot[2].y + w->z * rot[2].z);

                            // then rotate the whole thing and calculate the center of gravity (= origin + 0.5 * diagonal)
                            unsigned int k;

                            part->grav.x = part->gr[0].x;
                            part->grav.y = part->gr[0].y;
                            part->grav.z = part->gr[0].z;
                            for (k=1; k<4; k++)
                            {
                                geomUse[k].x = 0;
                                geomUse[k].y = 0;
                                geomUse[k].z = 0;
                            }
                            geomUse[1].x = td->widthx;
                            geomUse[2].y = td->widthy;
                            geomUse[3].z = td->widthz;

                            for (k=1; k<4; k++)
                            {
                                v = &(part->gr[k]);
                                w = &(geomUse[k]);
                                // this rotates the cube's axes (edge lengths are width = dom.high() - dom.low() + 1);
                                v->x = cubeScale * (w->x * rot[0].x + w->y * rot[0].y + w->z * rot[0].z);
                                v->y = cubeScale * (w->x * rot[1].x + w->y * rot[1].y + w->z * rot[1].z);
                                v->z = cubeScale * (w->x * rot[2].x + w->y * rot[2].y + w->z * rot[2].z);
                                part->grav.x += 0.5 * (v->x);
                                part->grav.y += 0.5 * (v->y);
                                part->grav.z += 0.5 * (v->z);
                            }

                            // advance partition pointer
                            part++;
                        }
                    }
                }
            } // entire section clipped away by projection string
        }
    }
    numPartitions = part - partition;

    // sorting isn't done here because it depends on the exact current perspective view.
    RMDBGIF(4, RMDebug::module_applications, "rviewOSection", \
            for (i=0; i<numPartitions; i++)
{
    \
    RMInit::dbgFileOut  << i << ": " << partition[i].grav.z << ' ';
        \
        outputGeomData(&(partition[i].gr[j]));
        \
    }; \
    RMInit::dbgFileOut  << endl ;
           );