IfcParameterizedProfileDef.Position and IfcSweptAreaSolid.Position optional in IFC4

This commit is contained in:
Thomas Krijnen
2016-06-21 11:18:16 +02:00
parent 2c2be389fb
commit 8f55aa732d
2 changed files with 172 additions and 42 deletions
+106 -20
View File
@@ -350,7 +350,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleProfileDef* l, TopoDS
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
IfcGeom::Kernel::convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[8] = {-x,-y,x,-y,x,y,-x,y}; double coords[8] = {-x,-y,x,-y,x,y,-x,y};
return profile_helper(4,coords,0,0,0,trsf2d,face); return profile_helper(4,coords,0,0,0,trsf2d,face);
} }
@@ -366,7 +373,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRoundedRectangleProfileDef* l,
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
IfcGeom::Kernel::convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[8] = {-x,-y, x,-y, x,y, -x,y}; double coords[8] = {-x,-y, x,-y, x,y, -x,y};
int fillets[4] = {0,1,2,3}; int fillets[4] = {0,1,2,3};
double radii[4] = {r,r,r,r}; double radii[4] = {r,r,r,r};
@@ -393,7 +407,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleHollowProfileDef* l,
TopoDS_Face f2; TopoDS_Face f2;
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
IfcGeom::Kernel::convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords1[8] = {-x ,-y, x ,-y, x, y, -x, y }; double coords1[8] = {-x ,-y, x ,-y, x, y, -x, y };
double coords2[8] = {-x+d,-y+d, x-d,-y+d, x-d,y-d, -x+d,y-d}; double coords2[8] = {-x+d,-y+d, x-d,-y+d, x-d,y-d, -x+d,y-d};
double radii1[4] = {r1,r1,r1,r1}; double radii1[4] = {r1,r1,r1,r1};
@@ -432,7 +453,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrapeziumProfileDef* l, TopoDS
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
IfcGeom::Kernel::convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[8] = {-x1,-y, x1,-y, dx+w-x1,y, dx-x1,y}; double coords[8] = {-x1,-y, x1,-y, dx+w-x1,y, dx-x1,y};
return profile_helper(4,coords,0,0,0,trsf2d,face); return profile_helper(4,coords,0,0,0,trsf2d,face);
} }
@@ -470,7 +498,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[24] = {-x1,-y, x1,-y, x1,-y+dy1, d1,-y+dy1, d1,y-dy2, x2,y-dy2, x2,y, -x2,y, -x2,y-dy2, -d1,y-dy2, -d1,-y+dy1, -x1,-y+dy1}; double coords[24] = {-x1,-y, x1,-y, x1,-y+dy1, d1,-y+dy1, d1,y-dy2, x2,y-dy2, x2,y, -x2,y, -x2,y-dy2, -d1,y-dy2, -d1,-y+dy1, -x1,-y+dy1};
int fillets[4] = {3,4,9,10}; int fillets[4] = {3,4,9,10};
@@ -503,7 +537,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcZShapeProfileDef* l, TopoDS_Sh
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
IfcGeom::Kernel::convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[16] = {-dx,-y, x,-y, x,-y+dy, dx,-y+dy, dx,y, -x,y, -x,y-dy, -dx,y-dy}; double coords[16] = {-dx,-y, x,-y, x,-y+dy, dx,-y+dy, dx,y, -x,y, -x,y-dy, -dx,y-dy};
int fillets[4] = {2,3,6,7}; int fillets[4] = {2,3,6,7};
@@ -530,7 +570,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCShapeProfileDef* l, TopoDS_Sh
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
IfcGeom::Kernel::convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[24] = {-x,-y,x,-y,x,-y+d2,x-d1,-y+d2,x-d1,-y+d1,-x+d1,-y+d1,-x+d1,y-d1,x-d1,y-d1,x-d1,y-d2,x,y-d2,x,y,-x,y}; double coords[24] = {-x,-y,x,-y,x,-y+d2,x-d1,-y+d2,x-d1,-y+d1,-x+d1,-y+d1,-x+d1,y-d1,x-d1,y-d1,x-d1,y-d2,x,y-d2,x,y,-x,y};
int fillets[8] = {0,1,4,5,6,7,10,11}; int fillets[8] = {0,1,4,5,6,7,10,11};
@@ -599,7 +645,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Sh
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[12] = {-x,-y, x,-y, x,-y+d-dy1, xx, xy, -x+d-dx1,y, -x,y}; double coords[12] = {-x,-y, x,-y, x,-y+d-dy1, xx, xy, -x+d-dx1,y, -x,y};
int fillets[3] = {2,3,4}; int fillets[3] = {2,3,4};
@@ -641,7 +693,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Sh
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[16] = {-x,-y, x,-y, x,-y+d2-dy2, -x+d1,-y+d2+dy1, -x+d1,y-d2-dy1, x,y-d2+dy2, x,y, -x,y}; double coords[16] = {-x,-y, x,-y, x,-y+d2-dy2, -x+d1,-y+d2+dy1, -x+d1,y-d2-dy1, x,y-d2+dy2, x,y, -x,y};
int fillets[4] = {2,3,4,5}; int fillets[4] = {2,3,4,5};
@@ -724,7 +782,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Sh
} }
gp_Trsf2d trsf2d; gp_Trsf2d trsf2d;
convert(l->Position(),trsf2d); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
double coords[16] = {d1/2.-dx2,-y, xx,xy, x,y-d2+dy2, x,y, -x,y, -x,y-d2+dy2, -xx,xy, -d1/2.+dx2,-y}; double coords[16] = {d1/2.-dx2,-y, xx,xy, x,y-d2+dy2, x,y, -x,y, -x,y-d2+dy2, -xx,xy, -d1/2.+dx2,-y};
int fillets[6] = {0,1,2,5,6,7}; int fillets[6] = {0,1,2,5,6,7};
@@ -739,13 +803,21 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleProfileDef* l, TopoDS_Sh
return false; return false;
} }
gp_Trsf2d trsf; gp_Trsf2d trsf2d;
convert(l->Position(),trsf); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
gp_Ax2 ax = gp_Ax2().Transformed(trsf2d);
BRepBuilderAPI_MakeWire w;
gp_Ax2 ax = gp_Ax2().Transformed(trsf);
Handle(Geom_Circle) circle = new Geom_Circle(ax, r); Handle(Geom_Circle) circle = new Geom_Circle(ax, r);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circle); TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circle);
BRepBuilderAPI_MakeWire w;
w.Add(edge); w.Add(edge);
TopoDS_Face f; TopoDS_Face f;
@@ -763,9 +835,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleHollowProfileDef* l, Top
return false; return false;
} }
gp_Trsf2d trsf; gp_Trsf2d trsf2d;
convert(l->Position(),trsf); bool has_position = true;
gp_Ax2 ax = gp_Ax2().Transformed(trsf); #ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
gp_Ax2 ax = gp_Ax2().Transformed(trsf2d);
BRepBuilderAPI_MakeWire outer; BRepBuilderAPI_MakeWire outer;
Handle(Geom_Circle) outerCircle = new Geom_Circle(ax, r); Handle(Geom_Circle) outerCircle = new Geom_Circle(ax, r);
@@ -793,15 +872,22 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipseProfileDef* l, TopoDS_S
} }
const bool rotated = ry > rx; const bool rotated = ry > rx;
gp_Trsf2d trsf;
convert(l->Position(),trsf); gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
gp_Ax2 ax = gp_Ax2(); gp_Ax2 ax = gp_Ax2();
if (rotated) { if (rotated) {
ax.Rotate(ax.Axis(), M_PI / 2.); ax.Rotate(ax.Axis(), M_PI / 2.);
std::swap(rx, ry); std::swap(rx, ry);
} }
ax.Transform(trsf); ax.Transform(trsf2d);
BRepBuilderAPI_MakeWire w; BRepBuilderAPI_MakeWire w;
Handle(Geom_Ellipse) ellipse = new Geom_Ellipse(ax, rx, ry); Handle(Geom_Ellipse) ellipse = new Geom_Ellipse(ax, rx, ry);
+66 -22
View File
@@ -67,6 +67,7 @@
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <TopoDS_CompSolid.hxx> #include <TopoDS_CompSolid.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <BRepPrimAPI_MakePrism.hxx> #include <BRepPrimAPI_MakePrism.hxx>
@@ -113,7 +114,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_S
if ( !convert_face(l->SweptArea(),face) ) return false; if ( !convert_face(l->SweptArea(),face) ) return false;
gp_Trsf trsf; gp_Trsf trsf;
IfcGeom::Kernel::convert(l->Position(),trsf); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf);
}
gp_Dir dir; gp_Dir dir;
convert(l->ExtrudedDirection(),dir); convert(l->ExtrudedDirection(),dir);
@@ -146,11 +153,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_S
shape = BRepPrimAPI_MakePrism(face, height*dir); shape = BRepPrimAPI_MakePrism(face, height*dir);
} }
// IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D if (has_position && !shape.IsNull()) {
// and therefore has a unit scale factor // IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D
shape.Move(trsf); // and therefore has a unit scale factor
shape.Move(trsf);
}
return ! shape.IsNull(); return !shape.IsNull();
} }
bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion* l, TopoDS_Shape& shape) { bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion* l, TopoDS_Shape& shape) {
@@ -162,17 +171,26 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion* l, T
wire = TopoDS::Wire(exp.Current()); wire = TopoDS::Wire(exp.Current());
} }
const double height = l->Depth() * getValue(GV_LENGTH_UNIT); const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
gp_Trsf trsf; gp_Trsf trsf;
IfcGeom::Kernel::convert(l->Position(),trsf); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf);
}
gp_Dir dir; gp_Dir dir;
convert(l->ExtrudedDirection(),dir); convert(l->ExtrudedDirection(),dir);
shape = BRepPrimAPI_MakePrism(wire, height*dir); shape = BRepPrimAPI_MakePrism(wire, height*dir);
// IfcSweptSurface.Position (trsf) is an IfcAxis2Placement3D if (has_position) {
// and therefore has a unit scale factor // IfcSweptSurface.Position (trsf) is an IfcAxis2Placement3D
shape.Move(trsf); // and therefore has a unit scale factor
shape.Move(trsf);
}
return !shape.IsNull(); return !shape.IsNull();
} }
@@ -190,13 +208,21 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfRevolution* l, TopoDS
IfcGeom::Kernel::convert(l->AxisPosition(), ax1); IfcGeom::Kernel::convert(l->AxisPosition(), ax1);
gp_Trsf trsf; gp_Trsf trsf;
IfcGeom::Kernel::convert(l->Position(),trsf); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf);
}
shape = BRepPrimAPI_MakeRevol(wire, ax1); shape = BRepPrimAPI_MakeRevol(wire, ax1);
// IfcSweptSurface.Position (trsf) is an IfcAxis2Placement3D if (has_position) {
// and therefore has a unit scale factor // IfcSweptSurface.Position (trsf) is an IfcAxis2Placement3D
shape.Move(trsf); // and therefore has a unit scale factor
shape.Move(trsf);
}
return !shape.IsNull(); return !shape.IsNull();
} }
@@ -211,7 +237,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRevolvedAreaSolid* l, TopoDS_S
IfcGeom::Kernel::convert(l->Axis(), ax1); IfcGeom::Kernel::convert(l->Axis(), ax1);
gp_Trsf trsf; gp_Trsf trsf;
IfcGeom::Kernel::convert(l->Position(),trsf); bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf);
}
if (ang >= M_PI * 2. - ALMOST_ZERO) { if (ang >= M_PI * 2. - ALMOST_ZERO) {
shape = BRepPrimAPI_MakeRevol(face, ax1); shape = BRepPrimAPI_MakeRevol(face, ax1);
@@ -219,9 +251,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRevolvedAreaSolid* l, TopoDS_S
shape = BRepPrimAPI_MakeRevol(face, ax1, ang); shape = BRepPrimAPI_MakeRevol(face, ax1, ang);
} }
// IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D if (has_position) {
// and therefore has a unit scale factor // IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D
shape.Move(trsf); // and therefore has a unit scale factor
shape.Move(trsf);
}
return !shape.IsNull(); return !shape.IsNull();
} }
@@ -756,8 +790,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l,
return false; return false;
} }
if (!IfcGeom::Kernel::convert(l->Position(), position) || gp_Trsf trsf;
!convert_face(l->SweptArea(), face) || bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf);
}
if (!convert_face(l->SweptArea(), face) ||
!convert_wire(l->Directrix(), wire) ) { !convert_wire(l->Directrix(), wire) ) {
return false; return false;
} }
@@ -815,9 +857,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l,
builder.MakeSolid(); builder.MakeSolid();
shape = builder.Shape(); shape = builder.Shape();
// IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D if (has_position) {
// and therefore has a unit scale factor // IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D
shape.Move(position); // and therefore has a unit scale factor
shape.Move(position);
}
return true; return true;
} }