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

Function main

src/examples/csg_primitive.cpp:135–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133};
134
135int main(int argc, char** argv) {
136 const char filename[] = "csg_primitive.ifc";
137 IfcHierarchyHelper<IfcSchema> file;
138 file.header().file_name()->setname(filename);
139
140 IfcSchema::IfcRepresentationItem* csg1 = Node::Box(8000.,6000.,3000.).subtract(
141 Node::Box(7600.,5600.,2800.).move(200.,200.,200.)
142 ).add(
143 Node::Pyramid(8000.,6000.,3000.).move(0,0,3000.).add(
144 Node::Cylinder(1000.,4000.).move(4000.,1000.,4000., 0.,1.,0.)
145 ).subtract(
146 Node::Pyramid(7600.,5600.,2800.).move(200.,200.,3000.)
147 ).subtract(
148 Node::Cylinder(900.,4000.).move(4000.,1000.,4000., 0.,1.,0.).intersect(
149 Node::Box(2000.,4000.,1000.).move(3000.,1000.,4000.)
150 )
151 )
152 ).serialize(file);
153
154 const double x = 1000.; const double y = -4000.;
155
156 IfcSchema::IfcRepresentationItem* csg2 = Node::Sphere(5000.).move(x,y,-4500.).intersect(
157 Node::Box(6000., 6000., 6000.).move(x-3000., y-3000., 0.)
158 ).add(
159 Node::Cone(500., 3000.).move(x,y).add(
160 Node::Cone(1500., 1000.).move(x,y, 900.).add(
161 Node::Cone(1100., 1000.).move(x,y, 1800.).add(
162 Node::Cone(750., 600.).move(x,y, 2700.)
163 )))).serialize(file);
164
165 IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy(
166 guid(), 0, S("IfcCsgPrimitive"), null, null, 0, 0, null, null);
167
168 file.addBuildingProduct(product);
169
170 product->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
171
172 product->setObjectPlacement(file.addLocalPlacement());
173
174 IfcSchema::IfcRepresentation::list::ptr reps (new IfcSchema::IfcRepresentation::list());
175 IfcSchema::IfcRepresentationItem::list::ptr items (new IfcSchema::IfcRepresentationItem::list());
176
177 items->push(csg1);
178 items->push(csg2);
179 IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(
180 file.getSingle<IfcSchema::IfcRepresentationContext>(), S("Body"), S("CSG"), items);
181 reps->push(rep);
182
183 IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(null, null, reps);
184 file.addEntity(rep);
185 file.addEntity(shape);
186
187 product->setRepresentation(shape);
188
189 using namespace std::string_literals;
190 file.getSingle<IfcSchema::IfcProject>()->setName("csg_primitive"s);
191
192 std::ofstream f(filename);

Callers

nothing calls this directly

Calls 12

setnameMethod · 0.80
moveMethod · 0.80
addBuildingProductMethod · 0.80
addLocalPlacementMethod · 0.80
addEntityMethod · 0.80
file_nameMethod · 0.45
headerMethod · 0.45
serializeMethod · 0.45
addMethod · 0.45
subtractMethod · 0.45
intersectMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected