-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
885 lines (824 loc) · 32.9 KB
/
main.cpp
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
// IFC SDK : IFC2X3 C++ Early Classes
// Copyright (C) 2009 CSTB
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full license is in Licence.txt file included with this
// distribution or is available at :
// http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
#include <ifc2x3/SPFReader.h>
#include <ifc2x3/SPFWriter.h>
#include <ifc2x3/ExpressDataSet.h>
#include <ifc2x3/IfcProject.h>
#include <ifc2x3/IfcLocalPlacement.h>
#include <ifc2x3/IfcAxis2Placement.h>
#include <ifc2x3/IfcAxis2Placement2D.h>
#include <ifc2x3/IfcAxis2Placement3D.h>
#include <ifc2x3/IfcUnit.h>
#include "UUIDGenerator.h"
#include "geometric.h"
#include <iostream>
#include <stdio.h>
#include <vector>
#ifdef WIN32
#include <time.h>
#endif
void initOwnerHistory(ifc2x3::IfcOwnerHistory* theOwnerHistory,
std::string userID, std::string userFN, std::string userLN,
std::string orgID, std::string orgName,
std::string appVersion, std::string appID, std::string appName)
{
theOwnerHistory->getOwningUser()->getThePerson()->setId(userID);
theOwnerHistory->getOwningUser()->getThePerson()->setGivenName(userFN);
theOwnerHistory->getOwningUser()->getThePerson()->setFamilyName(userLN);
theOwnerHistory->getOwningUser()->getTheOrganization()->setId(orgID);
theOwnerHistory->getOwningUser()->getTheOrganization()->setName(orgName);
theOwnerHistory->getOwningApplication()->setVersion(appVersion);
theOwnerHistory->getOwningApplication()->setApplicationIdentifier(appID);
theOwnerHistory->getOwningApplication()->setApplicationFullName(appName);
#ifdef WIN32
time_t ltime;
time( <ime );
theOwnerHistory->setCreationDate((ifc2x3::IfcTimeStamp)ltime);
#endif
}
void initRootProperties(ifc2x3::IfcRoot* entity, std::string name)
{
entity->setGlobalId(UUIDGenerator::generateIfcGloballyUniqueId());
entity->setName(name);
}
ifc2x3::IfcRelAggregates* linkByAggregate(
ifc2x3::IfcObjectDefinition* relating,
ifc2x3::IfcObjectDefinition* related)
{
static unsigned int count = 0;
char buffer[128];
#ifdef WIN32
sprintf_s(buffer,"%d",count);
#else
sprintf(buffer,"%d", count);
#endif
Step::RefPtr< ifc2x3::ExpressDataSet > mDataSet = (ifc2x3::ExpressDataSet*)relating->getExpressDataSet();
ifc2x3::IfcRelAggregates* agg = mDataSet->createIfcRelAggregates().get();
initRootProperties(agg,std::string("Aggregate") + buffer);
agg->setRelatingObject(relating);
agg->getRelatedObjects().insert(related);
return agg;
}
ifc2x3::IfcRelContainedInSpatialStructure* linkByContainedInSpatial(
ifc2x3::IfcSpatialStructureElement* relating,
ifc2x3::IfcProduct* related)
{
static unsigned int count = 0;
char buffer[128];
Step::RefPtr< ifc2x3::ExpressDataSet > mDataSet = (ifc2x3::ExpressDataSet*)relating->getExpressDataSet();
ifc2x3::IfcRelContainedInSpatialStructure* contained =
mDataSet->createIfcRelContainedInSpatialStructure().get();
#ifdef WIN32
sprintf_s(buffer,"%d",count);
#else
sprintf(buffer,"%d", count);
#endif
initRootProperties(contained,std::string("ContainedInSpatial") + buffer);
contained->setRelatingStructure(relating);
contained->getRelatedElements().insert(related);
return contained;
}
ifc2x3::IfcRelConnectsPathElements* linkByConnectsPathElements(
ifc2x3::IfcElement* relating, ifc2x3::IfcConnectionTypeEnum relatingConnectionType,
ifc2x3::IfcElement* related, ifc2x3::IfcConnectionTypeEnum relatedConnectionType)
{
static unsigned int count = 0;
char buffer[128];
Step::RefPtr< ifc2x3::ExpressDataSet > mDataSet = (ifc2x3::ExpressDataSet*)relating->getExpressDataSet();
ifc2x3::IfcRelConnectsPathElements* connects =
mDataSet->createIfcRelConnectsPathElements().get();
#ifdef WIN32
sprintf_s(buffer,"%d",count);
#else
sprintf(buffer,"%d", count);
#endif
initRootProperties(connects,std::string("ConnectsPathElements") + buffer);
connects->setRelatingElement(relating);
connects->setRelatingConnectionType(relatingConnectionType);
connects->setRelatedElement(related);
connects->setRelatedConnectionType(relatedConnectionType);
return connects;
}
ifc2x3::IfcRelSpaceBoundary* linkBySpaceBoundary(
ifc2x3::IfcSpace* relating,
ifc2x3::IfcElement* related)
{
static unsigned int count = 0;
char buffer[128];
Step::RefPtr< ifc2x3::ExpressDataSet > mDataSet = (ifc2x3::ExpressDataSet*)relating->getExpressDataSet();
ifc2x3::IfcRelSpaceBoundary* connects =
mDataSet->createIfcRelSpaceBoundary().get();
#ifdef WIN32
sprintf_s(buffer,"%d",count);
#else
sprintf(buffer,"%d", count);
#endif
initRootProperties(connects,std::string("SpaceBoundary") + buffer);
connects->setRelatingSpace(relating);
connects->setRelatedBuildingElement(related);
connects->setPhysicalOrVirtualBoundary(ifc2x3::IfcPhysicalOrVirtualEnum_PHYSICAL);
connects->setInternalOrExternalBoundary(ifc2x3::IfcInternalOrExternalEnum_INTERNAL);
return connects;
}
ifc2x3::IfcRelVoidsElement* linkByVoidsElement(
ifc2x3::IfcElement* relatingBuildingElement,
ifc2x3::IfcFeatureElementSubtraction* relatedOpeningElement)
{
static unsigned int count = 0;
char buffer[128];
Step::RefPtr< ifc2x3::ExpressDataSet > mDataSet =
(ifc2x3::ExpressDataSet*)relatingBuildingElement->getExpressDataSet();
ifc2x3::IfcRelVoidsElement* relVoidsElement =
mDataSet->createIfcRelVoidsElement().get();
#ifdef WIN32
sprintf_s(buffer,"%d",count);
#else
sprintf(buffer,"%d", count);
#endif
initRootProperties(relVoidsElement,std::string("VoidsElement") + buffer);
ifc2x3::IfcLocalPlacement * localPlacement = (ifc2x3::IfcLocalPlacement*)relatedOpeningElement->getObjectPlacement();
localPlacement->setPlacementRelTo(relatingBuildingElement->getObjectPlacement());
relVoidsElement->setRelatingBuildingElement(relatingBuildingElement);
relVoidsElement->setRelatedOpeningElement(relatedOpeningElement);
return relVoidsElement;
}
ifc2x3::IfcRelFillsElement* linkByFillsElement(
ifc2x3::IfcOpeningElement* relatingOpeningElement,
ifc2x3::IfcElement* relatedBuildingElement)
{
static unsigned int count = 0;
char buffer[128];
Step::RefPtr< ifc2x3::ExpressDataSet > mDataSet =
(ifc2x3::ExpressDataSet*)relatingOpeningElement->getExpressDataSet();
ifc2x3::IfcRelFillsElement* relFillsElement =
mDataSet->createIfcRelFillsElement().get();
#ifdef WIN32
sprintf_s(buffer,"%d",count);
#else
sprintf(buffer,"%d", count);
#endif
initRootProperties(relFillsElement,std::string("FillsElement") + buffer);
ifc2x3::IfcLocalPlacement * localPlacement = (ifc2x3::IfcLocalPlacement*)relatedBuildingElement->getObjectPlacement();
localPlacement->setPlacementRelTo(relatingOpeningElement->getObjectPlacement());
relFillsElement->setRelatingOpeningElement(relatingOpeningElement);
relFillsElement->setRelatedBuildingElement(relatedBuildingElement);
return relFillsElement;
}
//##################################################################### my area###############################################
// this founction create an Ifcsite and links it to a project
Step::RefPtr<ifc2x3::IfcSite> createIfcSite(std::vector<double> points, Step::RefPtr< ifc2x3::ExpressDataSet > &mDataSet,
CreateGeometricRepresentationVisitor &cwrv, Step::RefPtr<ifc2x3::IfcProject> &theProject)
{
// Build an Ifc site
Step::RefPtr<ifc2x3::IfcSite> theSite = mDataSet->createIfcSite();
initRootProperties(theSite.get(), "The site");
theSite->setCompositionType(ifc2x3::IfcElementCompositionEnum_ELEMENT);
// Create representation
points.clear();
//position.clear();
//placement.clear();
cwrv.init();
cwrv.set2DPolyline(points);
//cwrv.setColor(255, 255, 255);
if (!theSite->acceptVisitor(&cwrv)) {
std::cerr << "ERROR while creating site representation" << std::endl;
}
// Link (Project <--> Site)
linkByAggregate(theProject.get(), theSite.get());
return theSite;
}
//########################################## MY AREA END ###########################################################################
int main(int argc, char **argv)
{
std::cout << "Ifc2x3 SDK simple example: how to build an Ifc model?" << std::endl;
// ** First build an ExpressDataSet
Step::RefPtr< ifc2x3::ExpressDataSet > mDataSet = new ifc2x3::ExpressDataSet();
// ** Geometric representation stuff
std::vector<double> points, points2;
std::vector<double> position, placement;
CreateGeometricRepresentationVisitor cwrv(mDataSet.get());
// ** Then, build the header
Step::SPFHeader theHeader;
theHeader.getFileDescription().description.push_back("The very first model built from CSTB Ifc2x3 C++ SDK");
#ifdef WIN32
char buf[128];
struct tm t;
time_t ltime;
time(<ime);
localtime_s(&t,<ime);
sprintf_s(buf,"%.4i-%.2i-%.2iT%.2i:%.2i:%.2i",
t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec);
theHeader.getFileName().timeStamp = buf;
#else // WIN32
theHeader.getFileName().timeStamp = "2008-07-24T18:57:00";
#endif // WIN32
theHeader.getFileSchema().schemaIdentifiers.push_back("IFC2X3");
mDataSet->setHeader(theHeader);
// Build the project
Step::RefPtr<ifc2x3::IfcProject> theProject = mDataSet->createIfcProject();
// Init root properties
initRootProperties(theProject.get(),"Simple building");
theProject->setLongName("Simple building model for testing");
// Build the project owner history
Step::RefPtr< ifc2x3::IfcOwnerHistory > theOwnerHistory = mDataSet->createIfcOwnerHistory();
// - Build the owning user
Step::RefPtr<ifc2x3::IfcPersonAndOrganization> thePersonOrg = mDataSet->createIfcPersonAndOrganization();
Step::RefPtr<ifc2x3::IfcPerson> thePerson = mDataSet->createIfcPerson();
thePersonOrg->setThePerson(thePerson);
Step::RefPtr<ifc2x3::IfcOrganization> theOrganization = mDataSet->createIfcOrganization();
thePersonOrg->setTheOrganization(theOrganization);
theOwnerHistory->setOwningUser(thePersonOrg);
// - Build the owning application
Step::RefPtr<ifc2x3::IfcApplication> theApplication = mDataSet->createIfcApplication();
theApplication->setApplicationDeveloper(theOrganization);
theOwnerHistory->setOwningApplication(theApplication);
// Init the owner history
initOwnerHistory(theOwnerHistory.get(),"GP","Guillaume","PICINBONO","CSTB_MOD-EVE",
"CSTB MOD-EVE Team","1.0.0","IFC2X3_C++_SDK","IFC 2x3 C++ SDK");
theProject->setOwnerHistory(theOwnerHistory);
// set the units
Step::RefPtr<ifc2x3::IfcUnitAssignment> theProjectUnits = mDataSet->createIfcUnitAssignment();
Step::RefPtr< ifc2x3::IfcUnit > unitSelect = new ifc2x3::IfcUnit();
Step::RefPtr< ifc2x3::IfcSIUnit > unit = mDataSet->createIfcSIUnit();
unit->setUnitType(ifc2x3::IfcUnitEnum_LENGTHUNIT);
unit->setName(ifc2x3::IfcSIUnitName_METRE);
unitSelect->setIfcNamedUnit(unit.get());
theProjectUnits->getUnits().insert(unitSelect);
theProject->setUnitsInContext(theProjectUnits);
// Build an Ifc site
Step::RefPtr<ifc2x3::IfcSite> theSite = mDataSet->createIfcSite();
initRootProperties(theSite.get(), "The site");
theSite->setCompositionType(ifc2x3::IfcElementCompositionEnum_ELEMENT);
//Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(-100.0); points.push_back(-100.0);
points.push_back(100.0); points.push_back(-100.0);
points.push_back(100.0); points.push_back(100.0);
points.push_back(-100.0); points.push_back(100.0);
//theSite=(points, mDataSet, cwrv, theProject);
cwrv.set2DPolyline(points);
if ( !theSite->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating site representation" << std::endl;
}
// Link (Project <--> Site)
linkByAggregate(theProject.get(), theSite.get());
// Build an Ifc Building
Step::RefPtr<ifc2x3::IfcBuilding> theBuilding = mDataSet->createIfcBuilding();
initRootProperties(theBuilding.get(),"The building");
theBuilding->setCompositionType(ifc2x3::IfcElementCompositionEnum_ELEMENT);
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(-10.0); points.push_back(-10.0);
points.push_back(30.0); points.push_back(-10.0);
points.push_back(30.0); points.push_back(30.0);
points.push_back(-10.0); points.push_back(30.0);
cwrv.set2DPolyline(points);
if ( !theBuilding->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating building representation" << std::endl;
}
// Link (Site <--> Building)
linkByAggregate(theSite.get(), theBuilding.get());
// Build an Ifc Building Storey
Step::RefPtr<ifc2x3::IfcBuildingStorey> theGroundFloor = mDataSet->createIfcBuildingStorey();
initRootProperties(theGroundFloor.get(),"The ground floor");
theGroundFloor->setCompositionType(ifc2x3::IfcElementCompositionEnum_ELEMENT);
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(20.0); points.push_back(0.0);
points.push_back(20.0); points.push_back(20.0);
points.push_back(0.0); points.push_back(20.0);
cwrv.set2DPolyline(points);
if ( !theGroundFloor->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating building storey representation" << std::endl;
}
// Link (Building <--> Storey)
linkByAggregate(theBuilding.get(), theGroundFloor.get());
// Build an Ifc Slab
Step::RefPtr<ifc2x3::IfcSlab> theGroundFloorSlab = mDataSet->createIfcSlab();
initRootProperties(theGroundFloorSlab.get(),"Ground floor slab");
theGroundFloorSlab->setPredefinedType(ifc2x3::IfcSlabTypeEnum_FLOOR);
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(20.0); points.push_back(0.0);
points.push_back(20.0); points.push_back(15.0);
points.push_back(15.0); points.push_back(15.0);
points.push_back(15.0); points.push_back(20.0);
points.push_back(0.0); points.push_back(20.0);
cwrv.set2DPolyline(points);
position.push_back(0.0);
position.push_back(0.0);
position.push_back(-0.3);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(0.3);
//cwrv.setColor(255, 255, 255);
if ( !theGroundFloorSlab->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating slab representation" << std::endl;
}
// Link (Storey <--> Wall)
linkByContainedInSpatial(theGroundFloor.get(), theGroundFloorSlab.get());
//################################
//build personal wall
//Step::RefPtr<ifc2x3::IfcWall> theMyWall = mDataSet->createIfcWallStandardCase();
Step::RefPtr<ifc2x3::IfcWallStandardCase> theMyWall = mDataSet->createIfcWallStandardCase();
// Step::RefPtr<ifc2x3::IfcRoof> theMyWall = mDataSet->createIfcRoof();
initRootProperties(theMyWall.get(), "mywall");
//theMyWall->setPredefinedType(ifc2x3::IfcS);
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(17.0); points.push_back(0.0);
points.push_back(17.0); points.push_back(15.0);
points.push_back(15.0); points.push_back(15.0);
points.push_back(15.0); points.push_back(20.0);
points.push_back(0.0); points.push_back(20.0);
cwrv.set2DPolyline(points);
position.push_back(0.0);
position.push_back(0.0);
position.push_back(3.5);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(0.3);
cwrv.setColor(255, 255, 255);
if (!theMyWall->acceptVisitor(&cwrv)) {
std::cerr << "ERROR while creating Mywall representation" << std::endl;
}
// Link (Storey <--> Wall)
linkByContainedInSpatial(theBuilding.get(), theMyWall.get());
// Build an Ifc Wall
Step::RefPtr<ifc2x3::IfcWallStandardCase> theWall1 = mDataSet->createIfcWallStandardCase();
// Step::RefPtr<ifc2x3::IfcWall>theWall1 = mDataSet->createIfcWall();
//Step::RefPtr<ifc2x3::IfcWallType>theWall1 = mDataSet->createIfcWallType();
// Init root properties
initRootProperties(theWall1.get(),"Wall #1");
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(14.4); points.push_back(0.0);
points.push_back(14.4); points.push_back(0.2);
points.push_back(0.0); points.push_back(0.2);
cwrv.set2DPolyline(points);
position.push_back(0.3);
position.push_back(0.0);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.5);
//cwrv.setColor(16,255,0);
if ( !theWall1->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Add a second layer to the wall
points2.clear();
position.clear();
placement.clear();
points2.push_back(0.0); points2.push_back(0.0);
points2.push_back(14.4); points2.push_back(0.0);
points2.push_back(14.4); points2.push_back(0.1);
points2.push_back(0.0); points2.push_back(0.1);
cwrv.set2DPolyline(points2);
position.push_back(0.3);
position.push_back(0.2);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.0);
// cwrv.setColor(255, 255, 255);
if ( !theWall1->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Link (Storey <--> Wall)
linkByContainedInSpatial(theGroundFloor.get(), theWall1.get());
// Build an Ifc Wall
Step::RefPtr<ifc2x3::IfcWallStandardCase> theWall4 = mDataSet->createIfcWallStandardCase();
// Init root properties
initRootProperties(theWall4.get(),"Wall #4");
// Create representation
position.clear();
placement.clear();
cwrv.set2DPolyline(points);
position.push_back(0.3);
position.push_back(14.8);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.5);
// cwrv.setColor(255, 255, 255);
if ( !theWall4->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Add a second layer to the wall
position.clear();
placement.clear();
cwrv.set2DPolyline(points2);
position.push_back(0.3);
position.push_back(14.7);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.0);
//cwrv.setColor(255, 255, 255);
if ( !theWall4->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Add a second layer to the wall
position.clear();
placement.clear();
position.push_back(0.3);
position.push_back(15.0);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.0);
// cwrv.setColor(255, 255, 255);
if ( !theWall4->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Link (Storey <--> Wall)
linkByContainedInSpatial(theGroundFloor.get(), theWall4.get());
// Build an Ifc Wall
Step::RefPtr<ifc2x3::IfcWallStandardCase> theWall5 = mDataSet->createIfcWallStandardCase();
// Init root properties
initRootProperties(theWall5.get(),"Wall #5");
// Create representation
position.clear();
placement.clear();
cwrv.set2DPolyline(points);
position.push_back(0.3);
position.push_back(19.8);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.5);
//cwrv.setColor(255, 255, 255);
if ( !theWall5->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Add a second layer to the wall
position.clear();
placement.clear();
cwrv.set2DPolyline(points2);
position.push_back(0.3);
position.push_back(19.7);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.0);
//cwrv.setColor(255, 255, 255);
if ( !theWall5->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Link (Storey <--> Wall)
linkByContainedInSpatial(theGroundFloor.get(), theWall5.get());
// Build another Ifc Wall
Step::RefPtr<ifc2x3::IfcWallStandardCase> theWall2 = mDataSet->createIfcWallStandardCase();
// Init root properties
initRootProperties(theWall2.get(),"Wall #2");
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(0.0); points.push_back(20.0);
points.push_back(0.3); points.push_back(20.0);
points.push_back(0.3); points.push_back(0.0);
cwrv.set2DPolyline(points);
cwrv.setExtrusionDepth(3.5);
//cwrv.setColor(255, 255, 255);
if ( !theWall2->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Link (Storey <--> Wall)
linkByContainedInSpatial(theGroundFloor.get(), theWall2.get());
// Link (Wall <--> Wall)
linkByConnectsPathElements(theWall2.get(),ifc2x3::IfcConnectionTypeEnum_ATSTART,
theWall1.get(),ifc2x3::IfcConnectionTypeEnum_ATSTART);
linkByConnectsPathElements(theWall2.get(),ifc2x3::IfcConnectionTypeEnum_ATPATH,
theWall4.get(),ifc2x3::IfcConnectionTypeEnum_ATSTART);
linkByConnectsPathElements(theWall2.get(),ifc2x3::IfcConnectionTypeEnum_ATEND,
theWall5.get(),ifc2x3::IfcConnectionTypeEnum_ATSTART);
#if 1
// Build another Ifc Wall
Step::RefPtr<ifc2x3::IfcWallStandardCase> theWall3 = mDataSet->createIfcWallStandardCase();
// Init root properties
initRootProperties(theWall3.get(),"Wall #3");
// Create representation
position.clear();
placement.clear();
placement.push_back(14.7);
placement.push_back(0.0);
placement.push_back(0.0);
cwrv.setLocalPlacement(placement);
cwrv.setExtrusionDepth(3.5);
//cwrv.setColor(255, 255, 255);
if ( !theWall3->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
#else
// Build another Ifc Wall
Step::RefPtr<ifc2x3::IfcWall> theWall3 = mDataSet->createIfcWall();
// Init root properties
initRootProperties(theWall3.get(),"Wall #3");
// Create representation
points.clear();
position.clear();
placement.clear();
placement.push_back(14.7);
placement.push_back(0.0);
placement.push_back(0.0);
cwrv.setLocalPlacement(placement);
if ( !theWall3->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Make this wall composed of several Layers
// Layer one
Step::RefPtr<ifc2x3::IfcBuildingElementPart> theWall3_1 = mDataSet->createIfcBuildingElementPart();
initRootProperties(theWall3_1.get(),"Wall #3 - Layer 1");
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(0.0); points.push_back(20.0);
points.push_back(0.3); points.push_back(20.0);
points.push_back(0.3); points.push_back(0.0);
cwrv.set2DPolyline(points);
placement.push_back(14.7);
placement.push_back(0.0);
placement.push_back(0.0);
cwrv.setLocalPlacement(placement);
cwrv.setExtrusionDepth(3.5);
if ( !theWall3_1->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Link (Wall <--> Wall part)
linkByAggregate(theWall3.get(), theWall3_1.get());
// Layer two
Step::RefPtr<ifc2x3::IfcBuildingElementPart> theWall3_2 = mDataSet->createIfcBuildingElementPart();
initRootProperties(theWall3_2.get(),"Wall #3 - Layer 2");
// Insulation parameters
double element_width = 1.5;
double inter_element_width = 0.02;
double wall_width = 14.4;
double assembled_element_width = inter_element_width;
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.3);
points.push_back(0.0); points.push_back(0.3+element_width);
points.push_back(0.1); points.push_back(0.3+element_width);
points.push_back(0.1); points.push_back(0.3);
cwrv.set2DPolyline(points);
position.push_back(0.0);
position.push_back(assembled_element_width);
position.push_back(0.0);
cwrv.setPosition(position);
placement.push_back(14.58);
placement.push_back(0.0);
placement.push_back(0.0);
cwrv.setExtrusionDepth(3.2);
cwrv.setLocalPlacement(placement);
if ( !theWall3_2->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Add several geometric parts
placement.clear();
assembled_element_width += element_width + inter_element_width;
while ( assembled_element_width < (wall_width - element_width - inter_element_width) ) {
position.clear();
position.push_back(0.0);
position.push_back(assembled_element_width);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.2);
if ( !theWall3_2->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
assembled_element_width += element_width + inter_element_width;
}
// Compute width of last element
double lasting_width = wall_width - assembled_element_width - inter_element_width;
points.clear();
position.clear();
points.push_back(0.0); points.push_back(0.3);
points.push_back(0.0); points.push_back(0.3+lasting_width);
points.push_back(0.1); points.push_back(0.3+lasting_width);
points.push_back(0.1); points.push_back(0.3);
cwrv.set2DPolyline(points);
position.push_back(0.0);
position.push_back(assembled_element_width);
position.push_back(0.0);
cwrv.setPosition(position);
cwrv.setExtrusionDepth(3.2);
if ( !theWall3_2->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Link (Wall <--> Wall part)
linkByAggregate(theWall3.get(), theWall3_2.get());
// Layer three
Step::RefPtr<ifc2x3::IfcBuildingElementPart> theWall3_3 = mDataSet->createIfcBuildingElementPart();
initRootProperties(theWall3_3.get(),"Wall #3 - Layer 3");
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.3);
points.push_back(0.0); points.push_back(14.7);
points.push_back(0.03); points.push_back(14.7);
points.push_back(0.03); points.push_back(0.3);
cwrv.set2DPolyline(points);
placement.push_back(14.53);
placement.push_back(0.0);
placement.push_back(0.0);
cwrv.setExtrusionDepth(3.0);
cwrv.setLocalPlacement(placement);
if ( !theWall3_3->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating wall representation" << std::endl;
}
// Link (Wall <--> Wall part)
linkByAggregate(theWall3.get(), theWall3_3.get());
#endif
// Link (Storey <--> Wall)
linkByContainedInSpatial(theGroundFloor.get(), theWall3.get());
// Define an Opening
Step::RefPtr<ifc2x3::IfcOpeningElement> opening1 = mDataSet->createIfcOpeningElement();
// Init root properties
initRootProperties(opening1.get(),"Opening #1");
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(0.0); points.push_back(0.9);
points.push_back(0.3); points.push_back(0.9);
points.push_back(0.3); points.push_back(0.0);
cwrv.set2DPolyline(points);
cwrv.setExtrusionDepth(2.0);
placement.push_back(0.0);
placement.push_back(2.0);
placement.push_back(0.0);
cwrv.setLocalPlacement(placement);
if ( !opening1->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating opening representation" << std::endl;
}
// Assign it to a wall
//linkByVoidsElement(theWall3_1.get(),opening1.get());
//linkByVoidsElement(theWall3_2.get(),opening1.get());
linkByVoidsElement(theWall3.get(),opening1.get());
// Define an Opening
Step::RefPtr<ifc2x3::IfcOpeningElement> opening2 = mDataSet->createIfcOpeningElement();
// Init root properties
initRootProperties(opening2.get(),"Opening #2");
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(0.0); points.push_back(2.0);
points.push_back(0.3); points.push_back(2.0);
points.push_back(0.3); points.push_back(0.0);
cwrv.set2DPolyline(points);
cwrv.setExtrusionDepth(1.5);
placement.push_back(0.0);
placement.push_back(6.0);
placement.push_back(1.0);
cwrv.setLocalPlacement(placement);
if ( !opening2->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating opening representation" << std::endl;
}
// Assign it to a wall
linkByVoidsElement(theWall3.get(),opening2.get());
// Define an Opening
Step::RefPtr<ifc2x3::IfcOpeningElement> opening3 = mDataSet->createIfcOpeningElement();
// Init root properties
initRootProperties(opening3.get(),"Opening #3");
// Create representation
placement.clear();
placement.push_back(0.0);
placement.push_back(10.0);
placement.push_back(1.0);
cwrv.setLocalPlacement(placement);
if ( !opening3->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating opening representation" << std::endl;
}
// Assign it to a wall
linkByVoidsElement(theWall3.get(),opening3.get());
// Define a window
Step::RefPtr<ifc2x3::IfcWindow> window1 = mDataSet->createIfcWindow();
// Init root properties
initRootProperties(window1.get(),"Window #1");
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.0); points.push_back(0.0);
points.push_back(0.0); points.push_back(2.0);
points.push_back(0.05); points.push_back(2.0);
points.push_back(0.05); points.push_back(0.0);
cwrv.set2DPolyline(points);
cwrv.setExtrusionDepth(1.5);
position.push_back(0.1);
position.push_back(0.0);
position.push_back(0.0);
cwrv.setPosition(position);
if ( !window1->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating window representation" << std::endl;
}
// Assign it to a wall
linkByContainedInSpatial(theGroundFloor.get(),window1.get());
linkByFillsElement(opening3.get(),window1.get());
// Build in Ifc Space
Step::RefPtr<ifc2x3::IfcSpace> theSpace1 = mDataSet->createIfcSpace();
// Init root properties
initRootProperties(theSpace1.get(),"Space #1");
theSpace1->setInteriorOrExteriorSpace(ifc2x3::IfcInternalOrExternalEnum_INTERNAL);
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.3); points.push_back(0.3);
points.push_back(0.3); points.push_back(14.7);
points.push_back(14.57); points.push_back(14.7);
points.push_back(14.57); points.push_back(0.3);
cwrv.set2DPolyline(points);
cwrv.setExtrusionDepth(2.5);
if ( !theSpace1->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating space representation" << std::endl;
}
// Link (Storey <--> Space)
linkByAggregate(theGroundFloor.get(), theSpace1.get());
// Link (Space <--> Building element)
linkBySpaceBoundary(theSpace1.get(),theWall1.get());
linkBySpaceBoundary(theSpace1.get(),theWall2.get());
linkBySpaceBoundary(theSpace1.get(),theWall3.get());
linkBySpaceBoundary(theSpace1.get(),theWall4.get());
linkBySpaceBoundary(theSpace1.get(),opening1.get());
linkBySpaceBoundary(theSpace1.get(),opening2.get());
linkBySpaceBoundary(theSpace1.get(),opening3.get());
// Build another Ifc Space
Step::RefPtr<ifc2x3::IfcSpace> theSpace2 = mDataSet->createIfcSpace();
// Init root properties
initRootProperties(theSpace2.get(),"Space #2");
theSpace1->setInteriorOrExteriorSpace(ifc2x3::IfcInternalOrExternalEnum_INTERNAL);
// Create representation
points.clear();
position.clear();
placement.clear();
cwrv.init();
points.push_back(0.3); points.push_back(15.1);
points.push_back(0.3); points.push_back(19.7);
points.push_back(14.7); points.push_back(19.7);
points.push_back(14.7); points.push_back(15.1);
cwrv.set2DPolyline(points);
cwrv.setExtrusionDepth(2.5);
if ( !theSpace2->acceptVisitor(&cwrv) ) {
std::cerr << "ERROR while creating space representation" << std::endl;
}
// Link (Storey <--> Space)
linkByAggregate(theGroundFloor.get(), theSpace2.get());
// Link (Space <--> Building element)
linkBySpaceBoundary(theSpace2.get(),theWall5.get());
linkBySpaceBoundary(theSpace2.get(),theWall2.get());
linkBySpaceBoundary(theSpace2.get(),theWall3.get());
linkBySpaceBoundary(theSpace2.get(),theWall4.get());
// ** Write to model to a file
ifc2x3::SPFWriter writer(mDataSet.get());
std::ofstream filestream;
filestream.open("builtModel.ifc");
bool status = writer.write(filestream);
filestream.close();
return status;
}