Announcement

Collapse
No announcement yet.

unable to draw seismic data between horizons

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • unable to draw seismic data between horizons

    Dear Mike,

    I try to draw seismic data between two horizons.

    The codes are as following:

    // volumename : LDM data name
    // geoquadset, geoquadset1 : two horizon data list
    // transfunction : colors
    // other para: for coordinates transformation

    struct QDOFC_EXPORT GeoQuad
    {
    SFloat3D pt1,pt2,pt3,pt4;
    };

    void QSeisDataVolumeClipHorizonObj::HorizonClip(QString volumename,SbBox3f extent,QList<GeoQuad>&geoquadset, QList<GeoQuad>&geoquadset1, SoTransferFunction*transfunction, double transformcenter[3], double transformangle,int resolution,SDoubl2D coordnormal, int timeshift )
    {

    if ( volumename.isEmpty() || !transfunction ) return;

    /////////////////////////////////////////////////////////////////////////////////
    QByteArray ba=volumename.toLocal8Bit();
    SoVolumeData*pvolumedata=new SoVolumeData;
    pvolumedata->fileName.setValue(ba.data());

    pvolumedata->extent.setValue(extent);

    float xmin, xmax, ymin, ymax, zmin, zmax;
    extent.getMin().getValue( xmin, ymin, zmin );
    extent.getMax().getValue( xmax, ymax, zmax );

    pvolumedata->setLDM(true);
    pvolumedata->usePalettedTexture =TRUE;
    pvolumedata->storageHint=SoVolumeData::TEX2D;

    MEMORYSTATUS status;
    ::GlobalMemoryStatus(&status);
    int phymem=status.dwTotalPhys/(1024.0*1024.0);
    int MaxMainMem = SoPreferences::getInt("LDM_MAINMEM",phymem);
    int MaxTexMem = SoPreferences::getInt("LDM_TEXMEM",SR3D_LDM_GPU);
    pvolumedata->ldmResourceParameters.getValue()->loadPolicy.setValue(SoVolumeData::LDMResourcePara meter::NO_USER_INTERACTION);
    pvolumedata->ldmResourceParameters.getValue()->maxResolutionThreshold.setValue(resolution);

    pvolumedata->ldmResourceParameters.getValue()->tex2LoadRate = 2;
    pvolumedata->ldmResourceParameters.getValue()->tex3LoadRate = 2;

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    SoTransform *transform = new SoTransform;
    transform->translation.setValue(coordnormal.x,coordnormal.y, 0);

    transform->center.setValue(transformcenter[0]-coordnormal.x,transformcenter[1]-coordnormal.y, 0);
    if(fabs(transformangle)>0.001)
    {
    transform->rotation.setValue(SbVec3f(0, 0, 1), transformangle);
    }
    SbMatrix matri;
    SbRotation q(SbVec3f(0,1,0),SR3D_PIO2*transformangle/fabs(transformangle));
    matri.setRotate(q);
    transform->multLeft(matri);


    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    SoTransferFunction *trans = new SoTransferFunction;
    trans->colorMap.deleteValues(0, -1);
    trans->predefColorMap=transfunction->predefColorMap;
    trans->colorMap=transfunction->colorMap;

    int quadsize = geoquadset.count();
    int indexsize = quadsize * 4;
    float (*ptpos)[3] = new float[indexsize][3];
    float (*ptpos1)[3]= new float[indexsize][3];

    int *numindex=new int[quadsize];
    int i,index=0;
    for(i=0; i<quadsize; i++)
    {
    GeoQuad geoquad = geoquadset[i];
    GeoQuad geoquad1 = geoquadset1[i];

    ptpos[index][0]=geoquad.pt1.x + timeshift;
    ptpos[index][1]=geoquad.pt1.y - coordnormal.y;
    ptpos[index][2]=geoquad.pt1.z - coordnormal.x;

    ptpos1[index][0]=geoquad1.pt1.x + timeshift;
    ptpos1[index][1]=geoquad1.pt1.y - coordnormal.y;
    ptpos1[index][2]=geoquad1.pt1.z - coordnormal.x;

    index += 1;

    ptpos[index][0]=geoquad.pt2.x + timeshift;
    ptpos[index][1]=geoquad.pt2.y-coordnormal.y;
    ptpos[index][2]=geoquad.pt2.z-coordnormal.x;

    ptpos1[index][0]=geoquad1.pt2.x + timeshift;
    ptpos1[index][1]=geoquad1.pt2.y-coordnormal.y;
    ptpos1[index][2]=geoquad1.pt2.z-coordnormal.x;

    index += 1;

    ptpos[index][0]=geoquad.pt3.x + timeshift;
    ptpos[index][1]=geoquad.pt3.y-coordnormal.y;
    ptpos[index][2]=geoquad.pt3.z-coordnormal.x;

    ptpos1[index][0]=geoquad1.pt3.x + timeshift;
    ptpos1[index][1]=geoquad1.pt3.y-coordnormal.y;
    ptpos1[index][2]=geoquad1.pt3.z-coordnormal.x;

    index += 1;

    ptpos[index][0]=geoquad.pt4.x + timeshift;
    ptpos[index][1]=geoquad.pt4.y-coordnormal.y;
    ptpos[index][2]=geoquad.pt4.z-coordnormal.x;

    ptpos1[index][0]=geoquad1.pt4.x + timeshift;
    ptpos1[index][1]=geoquad1.pt4.y-coordnormal.y;
    ptpos1[index][2]=geoquad1.pt4.z-coordnormal.x;

    index += 1;

    numindex[i] = 4;
    }

    // for horizon
    SoSeparator *horSep = new SoSeparator;

    SoPolygonOffset *polyoffset = new SoPolygonOffset;
    polyoffset->factor = 1;
    polyoffset->units = 0;

    SoSwitch *horswitch = new SoSwitch;
    horswitch->whichChild = SO_SWITCH_ALL;

    SoSeparator *hor1 = new SoSeparator;
    SoSeparator *hor2 = new SoSeparator;

    horswitch->addChild( hor1 );
    horswitch->addChild( hor2 );

    horSep->addChild( polyoffset );
    horSep->addChild( horswitch );

    int sizeX = 398;
    int sizeY = 218 * 4;

    // for horizon1
    SoShapeHints *phints = new SoShapeHints;
    phints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;

    SoVertexProperty *vertexproperty = new SoVertexProperty;
    vertexproperty->orderedRGBA.set1Value(0, 0xFFFFFFFF);
    vertexproperty->vertex.setValues(0, indexsize, ptpos );

    SoQuadMesh *IShape = new SoQuadMesh;
    IShape->vertexProperty.setValue( vertexproperty );

    // setup indices
    IShape->verticesPerColumn = sizeX;
    IShape->verticesPerRow = sizeY;

    hor1->addChild( phints );
    hor1->addChild( IShape );

    // for horizon 2
    SoShapeHints *phints1 = new SoShapeHints;
    phints1->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;

    SoVertexProperty *vertexproperty1 = new SoVertexProperty;
    vertexproperty1->orderedRGBA.set1Value(0, 0xFFFFFFFF);
    vertexproperty1->vertex.setValues(0, indexsize, ptpos1 );

    SoQuadMesh *IShape1 = new SoQuadMesh;
    IShape1->vertexProperty.setValue( vertexproperty1 );

    // setup indices
    IShape1->verticesPerColumn = sizeX;
    IShape1->verticesPerRow = sizeY;

    hor2->addChild( phints1 );
    hor2->addChild( IShape1 );

    // clipgrid
    SoUniformGridProjectionClipping* gridProjectionClipping0 = new SoUniformGridProjectionClipping;
    gridProjectionClipping0->axis = SoUniformGridProjectionClipping::X;
    gridProjectionClipping0->clipBelow = TRUE;
    gridProjectionClipping0->clipAbove = FALSE;

    gridProjectionClipping0->sceneGraph = hor1;

    SoUniformGridProjectionClipping* gridProjectionClipping1 = new SoUniformGridProjectionClipping;
    gridProjectionClipping1->axis = SoUniformGridProjectionClipping::X;
    gridProjectionClipping1->clipAbove = TRUE;
    gridProjectionClipping1->clipBelow = FALSE;

    gridProjectionClipping1->sceneGraph = hor2;

    SoSwitch *clippingSwitch = new SoSwitch;
    clippingSwitch->whichChild = SO_SWITCH_ALL;

    SoGroup *gridGroup = new SoGroup;
    SoTextureUnit *gridUnit = new SoTextureUnit;
    gridUnit->unit = 3;

    gridGroup->addChild( gridUnit );
    gridGroup->addChild( gridProjectionClipping0 );

    SoGroup *gridGroup1 = new SoGroup;
    SoTextureUnit* gridUnit1 = new SoTextureUnit;
    gridUnit1->unit = 2;

    SoTextureUnit* gridUnit2 = new SoTextureUnit;
    gridUnit2->unit = 0;

    gridGroup1->addChild( gridUnit1 );
    gridGroup1->addChild( gridProjectionClipping1 );
    gridGroup1->addChild( gridUnit2 );

    clippingSwitch->addChild( gridGroup );
    clippingSwitch->addChild( gridGroup1 );

    SoSwitch* volRoot = new SoSwitch;
    volRoot->setName("VolumeRender");
    volRoot->whichChild = SO_SWITCH_ALL;

    // choose the VolumeRender style to use
    SoPickStyle *pstyle = new SoPickStyle;
    pstyle->style = SoPickStyle::UNPICKABLE;

    SoVolumeRenderingQuality *vrp = new SoVolumeRenderingQuality;
    vrp->forVolumeOnly = TRUE;
    vrp->deferredLighting = TRUE;
    vrp->ambientOcclusion = TRUE;

    // add the volumeRender node
    SoVolumeRender* volRender = new SoVolumeRender;
    volRender->numSlicesControl = SoVolumeRender::MANUAL;
    volRender->numSlices = 500;
    volRender->samplingAlignment = SoVolumeRender::VIEW_ALIGNED;
    volRender->useEarlyZ = TRUE;
    volRender->subdivideTile = TRUE;
    volRender->gpuVertexGen = TRUE;

    volRoot->addChild(pstyle);
    volRoot->addChild(vrp);
    volRoot->addChild(volRender);

    objseparator->insertChild(transform, 0 );
    objseparator->insertChild(pvolumedata, 1 );
    objseparator->insertChild(trans, 2 );
    //objseparator->insertChild(horSep, 3 );
    objseparator->insertChild(gridGroup, 3 );
    objseparator->insertChild(volRoot, 4 );


    delete [] ptpos;
    delete [] ptpos1;
    delete [] numindex;
    }


    The problem is that I used two horizons, but only the top one clip the above part of the seismic data, while the bottom one has no effect at all. Would you please check it for me?
    Attached Files

  • #2
    Originally posted by lilly_li View Post
    I try to draw seismic data between two horizons.
    &lt;snip&gt;
    The problem is that I used two horizons, but only the top one clip the above part of the seismic data, while the bottom one has no effect at all. Would you please check it for me?
    The code looks reasonable (without spending too much time). If you run the standard example program $OIVHOME\src\VolumeViz\examples\horizonClipping do you get the expected result?

    Comment

    Working...
    X