Skip to content

Commit 40a6038

Browse files
committed
Brand new implementation of IfcFace(Surface)
1 parent 9bf9f82 commit 40a6038

File tree

12 files changed

+521
-157
lines changed

12 files changed

+521
-157
lines changed

src/examples/faces.cpp

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/********************************************************************************
2+
* *
3+
* This file is part of IfcOpenShell. *
4+
* *
5+
* IfcOpenShell is free software: you can redistribute it and/or modify *
6+
* it under the terms of the Lesser GNU General Public License as published by *
7+
* the Free Software Foundation, either version 3.0 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* IfcOpenShell is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* Lesser GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the Lesser GNU General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
* *
18+
********************************************************************************/
19+
20+
/********************************************************************************
21+
* *
22+
* Example that generates various forms of IfcFace *
23+
* *
24+
********************************************************************************/
25+
26+
#include "../ifcparse/Ifc2x3.h"
27+
#include "../ifcparse/IfcUtil.h"
28+
#include "../ifcparse/IfcHierarchyHelper.h"
29+
30+
typedef std::string S;
31+
typedef IfcParse::IfcGlobalId guid;
32+
boost::none_t const null = (static_cast<boost::none_t>(0));
33+
34+
static int x = 0;
35+
36+
void create_testcase(IfcHierarchyHelper& file, IfcSchema::IfcFace* face, const std::string& name) {
37+
IfcSchema::IfcFace::list::ptr faces(new IfcSchema::IfcFace::list);
38+
faces->push(face);
39+
IfcSchema::IfcOpenShell* shell = new IfcSchema::IfcOpenShell(faces);
40+
41+
IfcSchema::IfcConnectedFaceSet::list::ptr shells(new IfcSchema::IfcConnectedFaceSet::list);
42+
shells->push(shell);
43+
IfcSchema::IfcFaceBasedSurfaceModel* model = new IfcSchema::IfcFaceBasedSurfaceModel(shells);
44+
45+
IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy(
46+
guid(), 0, name, null, null, 0, 0, null, null);
47+
file.addBuildingProduct(product);
48+
product->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
49+
50+
product->setObjectPlacement(file.addLocalPlacement(0, 1000 * x++, 0));
51+
52+
IfcSchema::IfcRepresentation::list::ptr reps (new IfcSchema::IfcRepresentation::list);
53+
IfcSchema::IfcRepresentationItem::list::ptr items (new IfcSchema::IfcRepresentationItem::list);
54+
55+
items->push(model);
56+
IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(
57+
file.getRepresentationContext("Model"), S("Body"), S("SurfaceModel"), items);
58+
reps->push(rep);
59+
60+
IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps);
61+
file.addEntity(shape);
62+
63+
product->setRepresentation(shape);
64+
}
65+
66+
int main(int argc, char** argv) {
67+
IfcHierarchyHelper file;
68+
{
69+
IfcSchema::IfcCartesianPoint::list::ptr points (new IfcSchema::IfcCartesianPoint::list);
70+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, -400, 0));
71+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, -400, 0));
72+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, +400, 0));
73+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, +400, 0));
74+
IfcSchema::IfcPolyLoop* loop = new IfcSchema::IfcPolyLoop(points);
75+
IfcSchema::IfcFaceOuterBound* bound = new IfcSchema::IfcFaceOuterBound(loop, true);
76+
77+
IfcSchema::IfcFaceBound::list::ptr bounds (new IfcSchema::IfcFaceBound::list);
78+
bounds->push(bound);
79+
IfcSchema::IfcFace* face = new IfcSchema::IfcFace(bounds);
80+
create_testcase(file, face, "polyloop");
81+
}
82+
{
83+
IfcSchema::IfcCartesianPoint* point1 = file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, 0., 0.);
84+
IfcSchema::IfcCartesianPoint* point2 = file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, 0., 0.);
85+
IfcSchema::IfcVertexPoint* vertex1 = new IfcSchema::IfcVertexPoint(point1);
86+
IfcSchema::IfcVertexPoint* vertex2 = new IfcSchema::IfcVertexPoint(point2);
87+
IfcSchema::IfcCircle* circle = new IfcSchema::IfcCircle(file.addPlacement2d(), 400.);
88+
IfcSchema::IfcEdgeCurve* edge1 = new IfcSchema::IfcEdgeCurve(vertex1, vertex2, circle, true);
89+
IfcSchema::IfcEdgeCurve* edge2 = new IfcSchema::IfcEdgeCurve(vertex2, vertex1, circle, true);
90+
IfcSchema::IfcOrientedEdge* oriented_edge1 = new IfcSchema::IfcOrientedEdge(edge1, true);
91+
IfcSchema::IfcOrientedEdge* oriented_edge2 = new IfcSchema::IfcOrientedEdge(edge2, true);
92+
IfcSchema::IfcOrientedEdge::list::ptr edges(new IfcSchema::IfcOrientedEdge::list);
93+
edges->push(oriented_edge1);
94+
edges->push(oriented_edge2);
95+
IfcSchema::IfcEdgeLoop* loop = new IfcSchema::IfcEdgeLoop(edges);
96+
IfcSchema::IfcFaceOuterBound* bound = new IfcSchema::IfcFaceOuterBound(loop, true);
97+
98+
IfcSchema::IfcFaceBound::list::ptr bounds (new IfcSchema::IfcFaceBound::list);
99+
bounds->push(bound);
100+
IfcSchema::IfcFace* face = new IfcSchema::IfcFace(bounds);
101+
create_testcase(file, face, "circle");
102+
}
103+
{
104+
IfcSchema::IfcCartesianPoint::list::ptr points (new IfcSchema::IfcCartesianPoint::list);
105+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, -400, 0));
106+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, -400, 0));
107+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, +400, 0));
108+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, +400, 0));
109+
IfcSchema::IfcPolyLoop* loop = new IfcSchema::IfcPolyLoop(points);
110+
IfcSchema::IfcFaceOuterBound* outer_bound = new IfcSchema::IfcFaceOuterBound(loop, true);
111+
112+
IfcSchema::IfcCartesianPoint::list::ptr points2 (new IfcSchema::IfcCartesianPoint::list);
113+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-300, -300, 0));
114+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-100, -300, 0));
115+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-100, +300, 0));
116+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-300, +300, 0));
117+
IfcSchema::IfcPolyLoop* loop2 = new IfcSchema::IfcPolyLoop(points2);
118+
IfcSchema::IfcFaceBound* inner_bound1 = new IfcSchema::IfcFaceBound(loop2, false);
119+
120+
IfcSchema::IfcCartesianPoint::list::ptr points3 (new IfcSchema::IfcCartesianPoint::list);
121+
points3->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+100, +300, 0));
122+
points3->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+300, +300, 0));
123+
points3->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+300, -300, 0));
124+
points3->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+100, -300, 0));
125+
IfcSchema::IfcPolyLoop* loop3 = new IfcSchema::IfcPolyLoop(points3);
126+
IfcSchema::IfcFaceBound* inner_bound2 = new IfcSchema::IfcFaceBound(loop3, true);
127+
128+
IfcSchema::IfcFaceBound::list::ptr bounds (new IfcSchema::IfcFaceBound::list);
129+
bounds->push(inner_bound1);
130+
bounds->push(outer_bound);
131+
bounds->push(inner_bound2);
132+
IfcSchema::IfcFace* face = new IfcSchema::IfcFace(bounds);
133+
create_testcase(file, face, "polyloop with holes");
134+
}
135+
{
136+
IfcSchema::IfcCartesianPoint::list::ptr points (new IfcSchema::IfcCartesianPoint::list);
137+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, -400, 0));
138+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-100, -400, 0));
139+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-100, +400, 0));
140+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, +400, 0));
141+
IfcSchema::IfcPolyLoop* loop = new IfcSchema::IfcPolyLoop(points);
142+
IfcSchema::IfcFaceOuterBound* bound1 = new IfcSchema::IfcFaceOuterBound(loop, true);
143+
144+
IfcSchema::IfcCartesianPoint::list::ptr points2 (new IfcSchema::IfcCartesianPoint::list);
145+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+100, +400, 0));
146+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, +400, 0));
147+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, -400, 0));
148+
points2->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+100, -400, 0));
149+
IfcSchema::IfcPolyLoop* loop2 = new IfcSchema::IfcPolyLoop(points2);
150+
IfcSchema::IfcFaceOuterBound* bound2 = new IfcSchema::IfcFaceOuterBound(loop2, false);
151+
152+
IfcSchema::IfcFaceBound::list::ptr bounds (new IfcSchema::IfcFaceBound::list);
153+
bounds->push(bound1);
154+
bounds->push(bound2);
155+
IfcSchema::IfcFace* face = new IfcSchema::IfcFace(bounds);
156+
create_testcase(file, face, "multiple outer boundaries (invalid)");
157+
}
158+
{
159+
IfcSchema::IfcCartesianPoint::list::ptr points (new IfcSchema::IfcCartesianPoint::list);
160+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, -400, 1e-6));
161+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, -400, 0));
162+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(+400, +400, 0));
163+
points->push(file.addTriplet<IfcSchema::IfcCartesianPoint>(-400, +400, 0));
164+
IfcSchema::IfcPolyLoop* loop = new IfcSchema::IfcPolyLoop(points);
165+
IfcSchema::IfcFaceOuterBound* bound = new IfcSchema::IfcFaceOuterBound(loop, true);
166+
167+
IfcSchema::IfcFaceBound::list::ptr bounds (new IfcSchema::IfcFaceBound::list);
168+
bounds->push(bound);
169+
IfcSchema::IfcFace* face = new IfcSchema::IfcFace(bounds);
170+
create_testcase(file, face, "imprecise polyloop");
171+
}
172+
const std::string filename = "faces.ifc";
173+
file.header().file_name().name(filename);
174+
std::ofstream f(filename.c_str());
175+
f << file;
176+
}

src/ifcconvert/IfcConvert.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ int main(int argc, char** argv) {
120120
"operand before applying the subtraction operation. This may "
121121
"introduce a performance improvement at the risk of failing, in "
122122
"which case the subtraction is applied one-by-one.")
123-
("force-ccw-face-orientation",
124-
"Recompute topological face normals using Newell's Method to "
125-
"guarantee that face vertices are defined in a Counter Clock "
126-
"Wise order, even if the faces are not part of a closed shell.")
127123
("disable-opening-subtractions",
128124
"Specifies whether to disable the boolean subtraction of "
129125
"IfcOpeningElement Representations from their RelatingElements.")
@@ -173,7 +169,6 @@ int main(int argc, char** argv) {
173169
const bool convert_back_units = vmap.count("convert-back-units") != 0;
174170
const bool sew_shells = vmap.count("sew-shells") != 0;
175171
const bool merge_boolean_operands = vmap.count("merge-boolean-operands") != 0;
176-
const bool force_ccw_face_orientation = vmap.count("force-ccw-face-orientation") != 0;
177172
const bool disable_opening_subtractions = vmap.count("disable-opening-subtractions") != 0;
178173
const bool include_entities = vmap.count("include") != 0;
179174
const bool include_plan = vmap.count("plan") != 0;
@@ -240,7 +235,6 @@ int main(int argc, char** argv) {
240235
settings.set(IfcGeom::IteratorSettings::SEW_SHELLS, sew_shells);
241236
settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, convert_back_units);
242237
settings.set(IfcGeom::IteratorSettings::FASTER_BOOLEANS, merge_boolean_operands);
243-
settings.set(IfcGeom::IteratorSettings::FORCE_CCW_FACE_ORIENTATION, force_ccw_face_orientation);
244238
settings.set(IfcGeom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS, disable_opening_subtractions);
245239
settings.set(IfcGeom::IteratorSettings::INCLUDE_CURVES, include_plan);
246240
settings.set(IfcGeom::IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES, !include_model);

src/ifcgeom/IfcGeom.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ class Kernel {
8181
// that consist of many faces is really detrimental for the performance.
8282
// Default: 1000
8383
GV_MAX_FACES_TO_SEW,
84-
// By default singular faces have no explicitly defined orientation, to
85-
// force faces to be defined CounterClockWise, set this value greater than zero.
86-
GV_FORCE_CCW_FACE_ORIENTATION,
8784
// The length unit used the creation of TopoDS_Shapes, primarily affects the
8885
// interpretation of IfcCartesianPoints and IfcVector magnitudes
8986
// DefaultL 1.0

0 commit comments

Comments
 (0)