Traverse data B_SPLINE_SURFACE

62 views
Skip to first unread message

Victor Haefner

unread,
May 4, 2016, 4:18:00 AM5/4/16
to STEPcode - Developers Mailing List
Hi,

I' having trouble to traverse the data structure based on the follwing step snipped:

#248 = ( BOUNDED_SURFACE() B_SPLINE_SURFACE(1,3,(
    (#249,#250,#251,#252)
    ,(#253,#254,#255,#256
)),.UNSPECIFIED.,.F.,.F.,.F.) B_SPLINE_SURFACE_WITH_KNOTS((2,2),(4,4),(
    9.9800399E-004,3.00099800399),(0.E+000,30.),
.PIECEWISE_BEZIER_KNOTS.) GEOMETRIC_REPRESENTATION_ITEM() 
RATIONAL_B_SPLINE_SURFACE((
    (1.,0.33333333333,0.33333333333,1.)
,(1.,0.33333333333,0.33333333333,1.
  ))) REPRESENTATION_ITEM('') SURFACE() );

The difficult part is doubble aggregate in the B_SPLINE_SURFACE:

B_SPLINE_SURFACE(1,3,
((#249,#250,#251,#252) , (#253,#254,#255,#256))                     <------- ??                       
,.UNSPECIFIED.,.F.,.F.,.F.)


I go throug as follows:

void traverseEntity(STEPentity* se, bool complexPass = 0) {
       if (se->IsComplex() && !complexPass) {
           for (auto e : unfoldComplex(se)) traverseEntity(e, 1);
           return;
       }

       STEPattribute* attr = 0;
       se->ResetAttributes();
       while ( (attr = se->NextAttribute()) != NULL ) {
           if ( attr->Entity() && !attr->IsDerived()) { traverseEntity( attr->Entity()); }
           else if ( auto a = attr->Aggregate() ) { traverseAggregate(a, attr); }
           else if ( auto s = attr->Select() ) { traverseSelect(s, attr); }
           if (attr->BaseType() != ENTITY_TYPE && attr->BaseType() != SELECT_TYPE) { // numeric value
             ;
           }
       }
}

void traverseAggregate(STEPaggregate *sa, STEPattribute* attr) {
   
auto type = attr->Type();
   
auto btype = attr->BaseType(); // ENTITY_TYPE
    auto nrtype = attr->NonRefType();

    const AttrDescriptor* adesc = attr->getADesc();
    auto atype = adesc->AggrElemType(); // LIST_TYPE


    SDAI_Select* sdsel;

   for( EntityNode* sn = (EntityNode*)sa->GetHead(); sn != NULL; sn = (EntityNode*)sn->NextNode()) {
       switch (atype) {
           case ENTITY_TYPE:
               sse = (STEPentity*)sn->node;
               break;
           case SELECT_TYPE:
               sen = (SelectNode*)sn;
               sdsel = sen->node;
               break;

           case SET_TYPE:
           case LIST_TYPE:
               
// what  here??
                break;
           case INTEGER_TYPE
           default: cout << "aggregate Type not handled:" << atype << endl;
       }
   }
}



To get the entity types works by casting
               sse = (STEPentity*)sn->node;

To get the select type works by casting:
               sen = (SelectNode*)sn;
               sdsel = sen->node;

How do I proceed for LIST_TYPE ?
To what should I cast sn / sn->node ?

Best regards and many thanks!

Victor

Anton Shabalin

unread,
May 8, 2016, 10:26:38 PM5/8/16
to STEPcode - Developers Mailing List
Hello, Victor.

Try this:
 GenericAggregate_ptr g_aggr = (GenericAggregate_ptr)attr->Aggregate();
            auto g_link = g_aggr->GetHead();
            while (g_link)
            {
                std::string agr_val;
                GenericAggrNode *gAggr_node = (GenericAggrNode*)g_link;
                const char* gAggr_str = gAggr_node->value.asStr(agr_val);

                if (gAggr_str)
                {
                    std::vector<GPDPoint> _tmp_points_list;
                    ParseCartesianPointsList(instance_manager, gAggr_str, _tmp_points_list);
....................................
                }
              g_link = g_link->NextNode();
            }

And PartseCartesianPointsList:
            ErrorDescriptor errdesc;
            EntityAggregate *ag = new EntityAggregate();

            ag->StrToVal(attr_string, &errdesc, e_cartesian_point, instance_manager, 0);

            EntityNode *sn = (EntityNode *)ag->GetHead();
            while (sn)
            {
                SdaiCartesian_point *_point = (SdaiCartesian_point *)sn->node;
............................
                sn = (EntityNode *)sn->NextNode();
            }

            delete ag;





Reply all
Reply to author
Forward
0 new messages