forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinverse_attr3.cc
More file actions
71 lines (64 loc) · 2.33 KB
/
Copy pathinverse_attr3.cc
File metadata and controls
71 lines (64 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/** \file inverse_attr3.cc
* Oct 2013
* Test inverse attributes; uses a tiny schema similar to a subset of IFC2x3
*
* This test originally used STEPfile, which didn't work. Fixing STEPfile would have been very difficult, it uses lazyInstMgr now.
*/
#include "config.h"
#include <lazyInstMgr.h>
#include <lazyRefs.h>
#include <sdai.h>
#include <STEPattribute.h>
#include <ExpDict.h>
#include <Registry.h>
#include <errordesc.h>
#include <algorithm>
#include <string>
#include <superInvAttrIter.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sc_getopt.h>
#include "schema.h"
int main( int argc, char * argv[] ) {
int exitStatus = EXIT_SUCCESS;
if( argc != 2 ) {
cerr << "Wrong number of args!" << endl;
exit( EXIT_FAILURE );
}
lazyInstMgr lim;
lim.initRegistry( SchemaInit );
lim.openFile( argv[1] );
//find attributes
instanceTypes_t::cvector * insts = lim.getInstances( "window" );
if( !insts || insts->empty() ) {
cout << "No window instances found!" << endl;
exit( EXIT_FAILURE );
}
SdaiWindow * instance = dynamic_cast< SdaiWindow * >( lim.loadInstance( insts->at( 0 ) ) );
if( !instance ) {
cout << "Problem loading instance" << endl;
exit( EXIT_FAILURE );
}
cout << "instance #" << instance->StepFileId() << endl;
SDAI_Application_instance::iAMap_t::value_type v = instance->getInvAttr("isdefinedby");
iAstruct attr = v.second; //instance->getInvAttr(ia);
if( attr.a && attr.a->EntryCount() ) {
cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl;
} else {
cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void*) v.first << endl;
exitStatus = EXIT_FAILURE;
}
EntityAggregate * aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile...
if( attr.a != aggr ) {
cout << "Error! got different EntityAggregate's when using map vs method" << endl;
exitStatus = EXIT_FAILURE;
}
if( aggr && aggr->EntryCount() ) {
cout << "Found " << aggr->EntryCount() << " inverse references." << endl;
} else {
cout << "inverse attr is not defined" << endl;
exitStatus = EXIT_FAILURE;
}
exit( exitStatus );
}