|
| 1 | + |
| 2 | +extern void SchemaInit( class Registry & ); |
| 3 | +#include "scl_version_string.h" |
| 4 | +#include <STEPfile.h> |
| 5 | +#include <sdai.h> |
| 6 | +#include <STEPattribute.h> |
| 7 | +#include <ExpDict.h> |
| 8 | +#include <Registry.h> |
| 9 | +#include <errordesc.h> |
| 10 | +#include <algorithm> |
| 11 | +#include <string> |
| 12 | +#include <unistd.h> |
| 13 | + |
| 14 | +#include "SdaiTEST_BINARY_INDEX.h" |
| 15 | + |
| 16 | +/* TODO: simplify this as much as possible |
| 17 | + * This segfault will probably occur with the STEPattributeList base class, SingleLinkList, as well - and without a schema lib. |
| 18 | + */ |
| 19 | +int main( int argc, char * argv[] ) { |
| 20 | + |
| 21 | + if ( argc != 2 ) { |
| 22 | + cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl; |
| 23 | + exit(1); |
| 24 | + } |
| 25 | + |
| 26 | + Registry registry( SchemaInit ); |
| 27 | + InstMgr instance_list; |
| 28 | + STEPfile sfile( registry, instance_list, "", false ); |
| 29 | + |
| 30 | + sfile.ReadExchangeFile( argv[1] ); |
| 31 | + sfile.Error().PrintContents(cout); |
| 32 | + |
| 33 | + Severity readSev = sfile.Error().severity(); |
| 34 | + |
| 35 | + // Keeps track of the last processed ent id |
| 36 | + int search_index = 0; |
| 37 | + |
| 38 | + const EntityDescriptor* ed = registry.FindEntity("Buynary"); |
| 39 | + AttrDescItr aditr( ed->ExplicitAttr() ); |
| 40 | + const AttrDescriptor * attrDesc = aditr.NextAttrDesc(); |
| 41 | + while( attrDesc != 0 ) { |
| 42 | + if( attrDesc->Derived() == LTrue ) { |
| 43 | + cout << "attr: " << attrDesc->Name() << " initializer: " << ((Derived_attribute*) attrDesc)->initializer_() << endl; |
| 44 | + //how to find the value of an attribute for an entity? |
| 45 | + } |
| 46 | + attrDesc = aditr.NextAttrDesc(); |
| 47 | + } |
| 48 | + |
| 49 | + SdaiBuynary* ent; |
| 50 | + while ( ENTITY_NULL != (ent = (SdaiBuynary*) instance_list.GetApplication_instance("Buynary",search_index) ) ) { |
| 51 | + // Loop over the Buynarys in the file |
| 52 | + cout << "Ent #" << ent->StepFileId() << endl; |
| 53 | + SDAI_Binary b = ent->bin_(); |
| 54 | + int cnt = ent->AttributeCount(); |
| 55 | + cout << "bin " << b.asStr() << endl; |
| 56 | + cout << "count " << cnt << endl; |
| 57 | + |
| 58 | + STEPattributeList sal = ent->attributes; //commenting this line out prevents the segfault |
| 59 | + |
| 60 | + MgrNode* mnode = instance_list.FindFileId( ent->StepFileId() ); |
| 61 | + search_index = instance_list.GetIndex( mnode ) + 1; |
| 62 | + } |
| 63 | + /* attr: lasthalf initializer: bin[5:8] |
| 64 | + * Ent #1 |
| 65 | + * bin 15A |
| 66 | + * count 1 |
| 67 | + * |
| 68 | + * Program received signal SIGSEGV, Segmentation fault. |
| 69 | + * 0x000000000067f768 in ?? () |
| 70 | + * (gdb) bt |
| 71 | + * #0 0x000000000067f768 in ?? () |
| 72 | + * #1 0x00007ffff778962d in SingleLinkList::Empty (this=0x6755b8) |
| 73 | + * at /opt/step/scl/src/clstepcore/SingleLinkList.inline.cc:32 |
| 74 | + * #2 0x00007ffff77895b8 in SingleLinkList::~SingleLinkList (this=0x6755b8, __in_chrg=<optimized out>) |
| 75 | + * at /opt/step/scl/src/clstepcore/SingleLinkList.inline.cc:26 |
| 76 | + * #3 0x00007ffff7788f64 in STEPattributeList::~STEPattributeList (this=0x6755b8, __in_chrg=<optimized out>) |
| 77 | + * at /opt/step/scl/src/clstepcore/STEPattributeList.cc:27 |
| 78 | + * #4 0x00007ffff77778e0 in SDAI_Application_instance::~SDAI_Application_instance (this=0x6755a0, |
| 79 | + * __in_chrg=<optimized out>) at /opt/step/scl/src/clstepcore/sdaiApplication_instance.cc:42 |
| 80 | + * #5 0x00007ffff7bdb163 in SdaiBuynary::~SdaiBuynary (this=0x6755a0, __in_chrg=<optimized out>) |
| 81 | + * at /opt/step/scl/build/binary_index/SdaiTEST_BINARY_INDEX.cc:46 |
| 82 | + * #6 0x00007ffff7bdb1b6 in SdaiBuynary::~SdaiBuynary (this=0x6755a0, __in_chrg=<optimized out>) |
| 83 | + * at /opt/step/scl/build/binary_index/SdaiTEST_BINARY_INDEX.cc:46 |
| 84 | + * #7 0x00007ffff79c8656 in MgrNode::~MgrNode (this=0x67f790, __in_chrg=<optimized out>) |
| 85 | + * at /opt/step/scl/src/cleditor/mgrnode.cc:69 |
| 86 | + * #8 0x00007ffff79c86ee in MgrNode::~MgrNode (this=0x67f790, __in_chrg=<optimized out>) |
| 87 | + * at /opt/step/scl/src/cleditor/mgrnode.cc:75 |
| 88 | + * #9 0x00007ffff79c8efd in MgrNodeArray::DeleteEntries (this=0x637940) |
| 89 | + * at /opt/step/scl/src/cleditor/mgrnodearray.cc:84 |
| 90 | + * #10 0x00007ffff79c8d7f in MgrNodeArray::~MgrNodeArray (this=0x637940, __in_chrg=<optimized out>) |
| 91 | + * at /opt/step/scl/src/cleditor/mgrnodearray.cc:60 |
| 92 | + * #11 0x00007ffff79c8dde in MgrNodeArray::~MgrNodeArray (this=0x637940, __in_chrg=<optimized out>) |
| 93 | + * at /opt/step/scl/src/cleditor/mgrnodearray.cc:61 |
| 94 | + * #12 0x00007ffff79c7554 in InstMgr::~InstMgr (this=0x7fffffffe030, __in_chrg=<optimized out>) |
| 95 | + * at /opt/step/scl/src/cleditor/instmgr.cc:58 |
| 96 | + * #13 0x0000000000402133 in main (argc=2, argv=0x7fffffffe1f8) |
| 97 | + * at /opt/step/scl/test/cpp/schema_dependent/binary_index_derived.cc:25 |
| 98 | + */ |
| 99 | + |
| 100 | +} |
0 commit comments