How to read complex entities (AP203)?

255 views
Skip to first unread message

Anton Shabalin

unread,
Dec 19, 2013, 5:26:32 AM12/19/13
to scl...@googlegroups.com
Hello everyone! 
I have a STEP(AP203) file. And I don't know how to read complex entity (#97):

#140=ADVANCED_FACE('',(#184),#97,.T.);
#97=(
BOUNDED_SURFACE()
B_SPLINE_SURFACE(3,3,((#1023,#1024,#1025,#1026),(#1027,#1028,#1029,#1030),
(#1031,#1032,#1033,#1034),(#1035,#1036,#1037,#1038)),.UNSPECIFIED.,.F.,.F.,
 .F.)
B_SPLINE_SURFACE_WITH_KNOTS((4,4),(4,4),(0.,1.),(0.,1.),.UNSPECIFIED.)
GEOMETRIC_REPRESENTATION_ITEM()
RATIONAL_B_SPLINE_SURFACE(((1.,0.949253021674191,0.949253021674191,1.),(0.804737854124365,
0.763899839683158,0.763899839683158,0.804737854124365),(0.804737854124365,
0.763899839683158,0.763899839683158,0.804737854124365),(1.,0.949253021674191,
0.949253021674191,1.)))
REPRESENTATION_ITEM('')
SURFACE()
);

Ok. I have an Advanced_Face and can take face geometry:

SdaiAdvanced_face *adv_face = ...; //#140
SdaiSurface_ptr surfPtr = adv_face->face_geometry_();

Then I need to know what type of geometry it is:

std::string ent_name = surfPtr->eDesc->Name(); // I got "B_Spline_Surface"

And then when I try to cast it to SdaiB_spline_surface I got NULL:

SdaiB_spline_surface* b_spline_surf    = dynamic_cast<SdaiB_spline_surface *>(surfPtr);

So, the Question is: How to read this in a right way ?


Mark

unread,
Dec 27, 2013, 5:56:53 PM12/27/13
to scl...@googlegroups.com
Hi Anton,

I was going to suggest that the pointer could be null before the dynamic cast, but of course you wouldn't be able to read the eDesc if that was the case.

Complex instances can be difficult to work with, and I'm not sure exactly what's going on here.  Do you have an example (preferably small) that you can share via pastebin? If you can't share your code publicly, you could also email it directly to me.

BRL-CAD uses Advanced_Face ( http://sourceforge.net/p/brlcad/code/HEAD/tree/brlcad/trunk/src/conv/step/g-step/ON_Brep.cpp#l431 ) and B_spline_surface_with_knots (in ON_Brep.cpp and ON_NurbsSurface.cpp), but it looks like they are not doing the same thing that you are doing.

Regards
Mark




--
You received this message because you are subscribed to the Google Groups "STEPcode - Developers Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scl-dev+u...@googlegroups.com.
To post to this group, send email to scl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scl-dev/67a880e7-25d7-4e13-828f-bf5fae29cea5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Anton Shabalin

unread,
Jan 12, 2014, 6:49:07 AM1/12/14
to scl...@googlegroups.com
Hi Mark, 

The pointer is not null. I attached the step-file I want to parse. So have a look at instance #140. It has an SdaiAdvanced_Face type.
I can read complex entities just as in the example below:

#include "stdafx.h"
#include <string>
#include <STEPfile.h>
#include <STEPComplex.h>
#include <SdaiCONFIG_CONTROL_DESIGN.h>

int _tmain(int argc, _TCHAR* argv[])
{

   
InstMgr *instance_list;
   
Registry *registry;    
   
STEPfile *sfile;

    instance_list
= new InstMgr();
    registry
= new Registry(SchemaInit);
    sfile
= new STEPfile(*registry, *instance_list);

    std
::string filename = "skrugl2.stp";
       
   
if (sfile->ReadExchangeFile(filename)<SEVERITY_WARNING) {
       
const ErrorDescriptor SCLError=sfile->Error();
        printf
("%s\n",SCLError.UserMsg());
        printf
("Details:(%s)\n",SCLError.DetailMsg());            
       
return -1;
   
}

//Find our entity

   
auto Ent = instance_list->GetSTEPentity(140);

   
SdaiAdvanced_face* adv_face = (SdaiAdvanced_face*)Ent;
   
SdaiSurface_ptr surf_ptr =  (SdaiSurface_ptr)adv_face->face_geometry_();

    std
::string ent_name = surf_ptr->eDesc->Name(); // I got "B_Spline_Surface"

   
bool isComplex = (bool)surf_ptr->IsComplex();
   
if (isComplex)
   
{                            
         
auto sc = ( ( STEPcomplex * )surf_ptr )->head;

         
//Now I can parse all sub-entities...          
         
while (sc)
         
{
              sc
->ResetAttributes();
              std
::string sc_name = sc->eDesc->Name();
             
             
if ( sc->IsA(config_control_design::e_b_spline_surface) )
             
{
                 
auto _instPtr = sc->eDesc->NewSTEPentity();
                 
                 
//SdaiB_spline_surface* b_spl_surfPtr1 = (SdaiB_spline_surface*)sc->eDesc->NewSTEPentity();   //WRONG
                 
//SdaiB_spline_surface* b_spl_surfPtr2 = (SdaiB_spline_surface*)sc;                           //WRONG
             
}

             
//... and all the attributes
             
STEPattribute * attr;
             
while (attr = sc->NextAttribute())
             
{
                  std
::string atrName = attr->aDesc->Name();
                 
auto atrTypeName = attr->TypeName();

                 
unsigned int u_degree = 0;

                 
if (atrName=="u_degree")
                 
{
                    u_degree
= *attr->ptr.i;
                 
}
             
}
            sc
= sc->sc;
         
}      

       
}
   
delete instance_list;
   
delete registry;
   
delete sfile;

   
return 0;
}



But if there is a less complicated method to read such entities ?
skrugl2.stp

Mark

unread,
Jan 13, 2014, 5:03:33 PM1/13/14
to scl...@googlegroups.com
Hi Anton,

I believe you're doing it the best way. I want to simplify working with complex instances, but haven't had an opportunity to look into it yet. If you have suggestions, I'm interested in hearing them. If you had the inclination to create a patch, I'd also be interested in that ;)

Regards
Mark


--
You received this message because you are subscribed to the Google Groups "STEPcode - Developers Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scl-dev+u...@googlegroups.com.
To post to this group, send email to scl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages