Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Table of Contents

Introduction

As a developer using HOOPS Exchange, you would like to evaluate exact positions and directions along the edges of a B-Rep model. While attempting to do this, you encounter A3DTopoEdge objects that have a null curve pointer. Why is this, and how do I evaluate edge geometry defined in this way?

Background

HOOPS Exchange is capable of representing B-Rep data from many different source formats. Some formats define edge geometry using a parametric evaluation of the adjacent face(s) rather than a 3D curve defined by A3DTopoEdgeData::m_pCurve.

If this is the case you will encounter a null 3D curve pointer, but each coedge referencing the edge will contain a non-null A3DTopoCoEdgeData::m_pUVCurve. This is a 2D curve that you can use with the function A3DCrvEvaluate to evaluate over its valid interval. The evaluation will return a 2D vector (Z will be 0) which are parametric values to be used with the surface evaluator.

Solutions

Helper function

One way to solve this problem is to use the A3DTopoEdgeGetOrCompute3DCurve helper function provided by HOOPS Exchange. This function obtains the 3D curve from the edge if it exists, and computes a new 3D curve if it does not. One consideration to make before using this function is that it requires a pointer to the A3DTopoBrepData that contains the edge.

bool evaluateEdgePosition( A3DTopoBrepData *brep_data, A3DTopoEdge *edge, double const t, A3DVector3dData &result ) {
    A3DCrvBase const *curve = nullptr;
    if( ! CheckResult( A3DTopoEdgeGetOrCompute3DCurve( brep_data, edge, &curve ) ) ) {
        return false;
    }
    
    return CheckResult( A3DCrvEvaluate( curve, t, 0, &result ) );
}

Direct knowledge application

Another approach to solving this problem is a direct application of your knowledge about this situation. If you encounter a null 3D curve in an edge, you must use the 2D curve in referencing coedges along with a surface evaluation to determine the edge geometry. You can achieve this by using an approach similar to the following code snippet.

bool evaluateEdgePosition( A3DTopoFace *face, A3DTopoCoEdge *coedge, A3DTopoEdge *edge, double const t, A3DVector3dData &result ) {
    ts3d::A3DTopoEdgeWrapper edge_d( edge );
    if( auto const curve = edge_d->m_p3dCurve ) {
        return CheckResult( A3DCrvEvaluate( curve, t, 0, &result ) );
    }
    
    ts3d::A3DTopoCoEdgeWrapper coedge_d( coedge );
    auto const uv_curve = coedge_d->m_pUVCurve;
    if( nullptr == uv_curve ) {
        return false;
    }
    
    A3DIntervalData interval;
    A3D_INITIALIZE_DATA( A3DIntervalData, interval );
    if( !CheckResult( A3DCrvGetInterval( uv_curve, &interval ) ) ) {
        return false;
    }
    
    A3DVector3dData pt;
    A3D_INITIALIZE_DATA( A3DVector3dData, pt );
    if( ! CheckResult( A3DCrvEvaluate( uv_curve, t, 0, &pt ) ) ) {
        return false;
    }
    
    A3DVector2dData uv;
    A3D_INITIALIZE_DATA(A3DVector2dData, uv );
    uv.m_dX = pt.m_dX;
    uv.m_dY = pt.m_dY;
    
    ts3d::A3DTopoFaceWrapper face_d( face );
    return CheckResult( A3DSurfEvaluate( face_d->m_pSurface, &uv, 0, &result ) );
}

Summary

HOOPS Exchange can define edge geometry in different ways, depending on the input file format. Using the methods described here, you can determine the best approach for obtaining the geometry.

  • No labels