MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / setup_project

Function setup_project

src/examples/IfcAlignment.cpp:46–83  ·  view source on GitHub ↗

performs basic project setup including created the IfcProject object and initializing the project units to FEET

Source from the content-addressed store, hash-verified

44// performs basic project setup including created the IfcProject object
45// and initializing the project units to FEET
46Schema::IfcProject* setup_project(IfcHierarchyHelper<Schema>& file) {
47 std::vector<std::string> file_description;
48 file_description.push_back("ViewDefinition[Alignment-basedReferenceView]");
49 file.header().file_description()->setdescription(file_description);
50
51 auto project = file.addProject();
52 project->setName(std::string("FHWA Bridge Geometry Manual Example Alignment"));
53 project->setDescription(std::string("C++ Example"));
54
55 // set up project units for feet
56 // the call to file.addProject() sets up length units as millimeter.
57 auto units_in_context = project->UnitsInContext();
58 auto units = units_in_context->Units();
59 auto begin = units->begin();
60 auto iter = begin;
61 auto end = units->end();
62 for (; iter != end; iter++) {
63 auto unit = *iter;
64 if (unit->as<Schema::IfcSIUnit>() && unit->as<Schema::IfcSIUnit>()->UnitType() == Schema::IfcUnitEnum::IfcUnit_LENGTHUNIT) {
65 auto dimensions = new Schema::IfcDimensionalExponents(1, 0, 0, 0, 0, 0, 0);
66 file.addEntity(dimensions);
67
68 auto conversion_factor = new Schema::IfcMeasureWithUnit(new Schema::IfcLengthMeasure(304.80), unit->as<Schema::IfcSIUnit>());
69 file.addEntity(conversion_factor);
70
71 auto conversion_based_unit = new Schema::IfcConversionBasedUnit(dimensions, Schema::IfcUnitEnum::IfcUnit_LENGTHUNIT, "FEET", conversion_factor);
72 file.addEntity(conversion_based_unit);
73
74 units->remove(unit); // remove the millimeter unit
75 units->push(conversion_based_unit); // add the feet unit
76 units_in_context->setUnits(units); // update the UnitsInContext
77
78 break; // Done!, the length unit was found, so break out of the loop
79 }
80 }
81
82 return project;
83}
84
85// creates geometry and business logic segments for horizontal alignment tangent runs
86std::pair<typename Schema::IfcCurveSegment*, typename Schema::IfcAlignmentSegment*> create_tangent(typename Schema::IfcCartesianPoint* p, double dir, double length) {

Callers 1

mainFunction · 0.70

Calls 10

push_backMethod · 0.80
setdescriptionMethod · 0.80
addProjectMethod · 0.80
addEntityMethod · 0.80
file_descriptionMethod · 0.45
headerMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
removeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected