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

Function setup_project

src/examples/IfcSimplifiedAlignment.cpp:42–79  ·  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

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

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