Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...

Solution

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.

Code Block
languagecpp
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.

cpp
Code Block
language
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

...

Summary

The HOOPS Exchange data model can represent edge geometry in different ways , depending on the input file format. Using the methods method described hereabove, you can determine the best approach for obtaining the geometryreliably obtain a 3D curve for parametric evaluation.