//如果需要参与OCC的交差并等布尔运算,就需要再进行缝合处理
TopoDS_Shape MakeBox(double x, double y, double z)
{
//顶点
gp_Pnt aPoints[8] = {
gp_Pnt(0.0, 0.0, 0.0),
gp_Pnt(x, 0.0, 0.0),
gp_Pnt(x, y, 0.0),
gp_Pnt(0.0, y, 0.0),
gp_Pnt(0.0, 0.0, z),
gp_Pnt(x, 0.0, z),
gp_Pnt(x, y, z),
gp_Pnt(0.0, y, z)
};
//线
gp_Lin aLines[12] = {
gp_Lin(aPoints[0], gp::DX()),
gp_Lin(aPoints[1], gp::DY()),
gp_Lin(aPoints[3], gp::DX()),
gp_Lin(aPoints[0], gp::DY()),
gp_Lin(aPoints[4], gp::DX()),
gp_Lin(aPoints[5], gp::DY()),
gp_Lin(aPoints[7], gp::DX()),
gp_Lin(aPoints[4], gp::DY()),
gp_Lin(aPoints[0], gp::DZ()),
gp_Lin(aPoints[1], gp::DZ()),
gp_Lin(aPoints[2], gp::DZ()),
gp_Lin(aPoints[3], gp::DZ())
};
//平面
gp_Pln aPlanes[6] = {
gp_Pln(aPoints[0], gp::DZ()), // bottom
gp_Pln(aPoints[4], gp::DZ()), // top
gp_Pln(aPoints[0], gp::DY()), // front
gp_Pln(aPoints[3], gp::DY()), // back
gp_Pln(aPoints[0], gp::DX()), // left
gp_Pln(aPoints[1], gp::DX()) // right
};
// box topology data.
TopoDS_Vertex aVertices[8];
TopoDS_Edge aEdges[12];
TopoDS_Wire aWires[6];
TopoDS_Face aFaces[6];
TopoDS_Shell aShell;
TopoDS_Solid aSolid;
BRep_Builder aBuilder;
// make vertex of the box.
//创建顶点Vertex时,可以将点的坐标信息及容差值设置进去
aBuilder.MakeVertex(aVertices[0], aPoints[0], Precision::Confusion());
aBuilder.MakeVertex(aVertices[1], aPoints[1], Precision::Confusion());
aBuilder.MakeVertex(aVertices[2], aPoints[2], Precision::Confusion());
aBuilder.MakeVertex(aVertices[3], aPoints[3], Precision::Confusion());
aBuilder.MakeVertex(aVertices[4], aPoints[4], Precision::Confusion());
aBuilder.MakeVertex(aVertices[5], aPoints[5], Precision::Confusion());
aBuilder.MakeVertex(aVertices[6], aPoints[6], Precision::Confusion());
aBuilder.MakeVertex(aVertices[7], aPoints[7], Precision::Confusion());
// make edges of the box.
//创建边的同时,将其边中的三维曲线信息也设置进去
aBuilder.MakeEdge(aEdges[0], new Geom_Line(aLines[0]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[1], new Geom_Line(aLines[1]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[2], new Geom_Line(aLines[2]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[3], new Geom_Line(aLines[3]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[4], new Geom_Line(aLines[4]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[5], new Geom_Line(aLines[5]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[6], new Geom_Line(aLines[6]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[7], new Geom_Line(aLines[7]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[8], new Geom_Line(aLines[8]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[9], new Geom_Line(aLines[9]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[10], new Geom_Line(aLines[10]), Precision::Confusion());
aBuilder.MakeEdge(aEdges[11], new Geom_Line(aLines[11]), Precision::Confusion());
// set the vertex info of the edges.
//创建的边Edge还需要与顶点Vertex关联上,且需要注意顶点的反向
// edge 0:
{
TopoDS_Vertex V1 = aVertices[0];
TopoDS_Vertex V2 = aVertices[1];
V2.Reverse();
aBuilder.Add(aEdges[0], V1);
aBuilder.Add(aEdges[0], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[0], aPoints[0]), aEdges[0], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[0], aPoints[1]), aEdges[0], Precision::Confusion());
BRepTools::Update(aEdges[0]);
}
// edge 1:
{
TopoDS_Vertex V1 = aVertices[1];
TopoDS_Vertex V2 = aVertices[2];
V2.Reverse();
aBuilder.Add(aEdges[1], V1);
aBuilder.Add(aEdges[1], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[1], aPoints[1]), aEdges[1], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[1], aPoints[2]), aEdges[1], Precision::Confusion());
BRepTools::Update(aEdges[1]);
}
// edge 2:
{
TopoDS_Vertex V1 = aVertices[3];
TopoDS_Vertex V2 = aVertices[2];
V2.Reverse();
aBuilder.Add(aEdges[2], V1);
aBuilder.Add(aEdges[2], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[2], aPoints[3]), aEdges[2], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[2], aPoints[2]), aEdges[2], Precision::Confusion());
BRepTools::Update(aEdges[2]);
}
// edge 3:
{
TopoDS_Vertex V1 = aVertices[0];
TopoDS_Vertex V2 = aVertices[3];
V2.Reverse();
aBuilder.Add(aEdges[3], V1);
aBuilder.Add(aEdges[3], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[3], aPoints[0]), aEdges[3], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[3], aPoints[3]), aEdges[3], Precision::Confusion());
BRepTools::Update(aEdges[3]);
}
// edge 4:
{
TopoDS_Vertex V1 = aVertices[4];
TopoDS_Vertex V2 = aVertices[5];
V2.Reverse();
aBuilder.Add(aEdges[4], V1);
aBuilder.Add(aEdges[4], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[4], aPoints[4]), aEdges[4], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[4], aPoints[5]), aEdges[4], Precision::Confusion());
BRepTools::Update(aEdges[4]);
}
// edge 5:
{
TopoDS_Vertex V1 = aVertices[5];
TopoDS_Vertex V2 = aVertices[6];
V2.Reverse();
aBuilder.Add(aEdges[5], V1);
aBuilder.Add(aEdges[5], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[5], aPoints[5]), aEdges[5], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[5], aPoints[6]), aEdges[5], Precision::Confusion());
BRepTools::Update(aEdges[5]);
}
// edge 6:
{
TopoDS_Vertex V1 = aVertices[7];
TopoDS_Vertex V2 = aVertices[6];
V2.Reverse();
aBuilder.Add(aEdges[6], V1);
aBuilder.Add(aEdges[6], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[6], aPoints[7]), aEdges[6], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[6], aPoints[6]), aEdges[6], Precision::Confusion());
BRepTools::Update(aEdges[6]);
}
// edge 7:
{
TopoDS_Vertex V1 = aVertices[4];
TopoDS_Vertex V2 = aVertices[7];
V2.Reverse();
aBuilder.Add(aEdges[7], V1);
aBuilder.Add(aEdges[7], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[7], aPoints[4]), aEdges[7], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[7], aPoints[7]), aEdges[7], Precision::Confusion());
BRepTools::Update(aEdges[7]);
}
// edge 8:
{
TopoDS_Vertex V1 = aVertices[0];
TopoDS_Vertex V2 = aVertices[4];
V2.Reverse();
aBuilder.Add(aEdges[8], V1);
aBuilder.Add(aEdges[8], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[8], aPoints[0]), aEdges[8], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[8], aPoints[4]), aEdges[8], Precision::Confusion());
BRepTools::Update(aEdges[8]);
}
// edge 9:
{
TopoDS_Vertex V1 = aVertices[1];
TopoDS_Vertex V2 = aVertices[5];
V2.Reverse();
aBuilder.Add(aEdges[9], V1);
aBuilder.Add(aEdges[9], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[9], aPoints[1]), aEdges[9], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[9], aPoints[5]), aEdges[9], Precision::Confusion());
BRepTools::Update(aEdges[9]);
}
// edge 10:
{
TopoDS_Vertex V1 = aVertices[2];
TopoDS_Vertex V2 = aVertices[6];
V2.Reverse();
aBuilder.Add(aEdges[10], V1);
aBuilder.Add(aEdges[10], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[10], aPoints[2]), aEdges[10], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[10], aPoints[6]), aEdges[10], Precision::Confusion());
BRepTools::Update(aEdges[10]);
}
// edge 11:
{
TopoDS_Vertex V1 = aVertices[3];
TopoDS_Vertex V2 = aVertices[7];
V2.Reverse();
aBuilder.Add(aEdges[11], V1);
aBuilder.Add(aEdges[11], V2);
aBuilder.UpdateVertex(V1, ElCLib::Parameter(aLines[11], aPoints[3]), aEdges[11], Precision::Confusion());
aBuilder.UpdateVertex(V2, ElCLib::Parameter(aLines[11], aPoints[7]), aEdges[11], Precision::Confusion());
BRepTools::Update(aEdges[11]);
}
// make wires of the box.
//接着创建Wire,创建Wire时需要注意边的反向,从而构造成一个闭合的Wire
aBuilder.MakeWire(aWires[0]);
aBuilder.MakeWire(aWires[1]);
aBuilder.MakeWire(aWires[2]);
aBuilder.MakeWire(aWires[3]);
aBuilder.MakeWire(aWires[4]);
aBuilder.MakeWire(aWires[5]);
// wire 1: bottom
{
TopoDS_Edge E1 = aEdges[0];
TopoDS_Edge E2 = aEdges[1];
TopoDS_Edge E3 = aEdges[2];
TopoDS_Edge E4 = aEdges[3];
E3.Reverse();
E4.Reverse();
aBuilder.Add(aWires[0], E1);
aBuilder.Add(aWires[0], E2);
aBuilder.Add(aWires[0], E3);
aBuilder.Add(aWires[0], E4);
BRepTools::Update(aWires[0]);
}
// wire 2: top
{
TopoDS_Edge E1 = aEdges[4];
TopoDS_Edge E2 = aEdges[5];
TopoDS_Edge E3 = aEdges[6];
TopoDS_Edge E4 = aEdges[7];
E3.Reverse();
E4.Reverse();
aBuilder.Add(aWires[1], E1);
aBuilder.Add(aWires[1], E2);
aBuilder.Add(aWires[1], E3);
aBuilder.Add(aWires[1], E4);
BRepTools::Update(aWires[1]);
}
// wire 3: front
{
TopoDS_Edge E1 = aEdges[0];
TopoDS_Edge E2 = aEdges[9];
TopoDS_Edge E3 = aEdges[4];
TopoDS_Edge E4 = aEdges[8];
E1.Reverse();
E2.Reverse();
aBuilder.Add(aWires[2], E1);
aBuilder.Add(aWires[2], E2);
aBuilder.Add(aWires[2], E3);
aBuilder.Add(aWires[2], E4);
BRepTools::Update(aWires[2]);
}
// wire 4: back
{
TopoDS_Edge E1 = aEdges[2];
TopoDS_Edge E2 = aEdges[10];
TopoDS_Edge E3 = aEdges[6];
TopoDS_Edge E4 = aEdges[11];
E1.Reverse();
E2.Reverse();
aBuilder.Add(aWires[3], E1);
aBuilder.Add(aWires[3], E2);
aBuilder.Add(aWires[3], E3);
aBuilder.Add(aWires[3], E4);
BRepTools::Update(aWires[3]);
}
// wire 5: left
{
TopoDS_Edge E1 = aEdges[3];
TopoDS_Edge E2 = aEdges[11];
TopoDS_Edge E3 = aEdges[7];
TopoDS_Edge E4 = aEdges[8];
E3.Reverse();
E4.Reverse();
aBuilder.Add(aWires[4], E1);
aBuilder.Add(aWires[4], E2);
aBuilder.Add(aWires[4], E3);
aBuilder.Add(aWires[4], E4);
BRepTools::Update(aWires[4]);
}
// wire 6: right
{
TopoDS_Edge E1 = aEdges[1];
TopoDS_Edge E2 = aEdges[10];
TopoDS_Edge E3 = aEdges[5];
TopoDS_Edge E4 = aEdges[9];
E3.Reverse();
E4.Reverse();
aBuilder.Add(aWires[5], E1);
aBuilder.Add(aWires[5], E2);
aBuilder.Add(aWires[5], E3);
aBuilder.Add(aWires[5], E4);
BRepTools::Update(aWires[5]);
}
// make faces of the box.
//关键是面的创建及面创建后,设置边与面的关联信息,即PCurve的信息。如果没有PCurve的信息,可视化显示就不能正确显示出面,即网格化算法会失败。
aBuilder.MakeFace(aFaces[0], new Geom_Plane(aPlanes[0]), Precision::Confusion());
aBuilder.MakeFace(aFaces[1], new Geom_Plane(aPlanes[1]), Precision::Confusion());
aBuilder.MakeFace(aFaces[2], new Geom_Plane(aPlanes[2]), Precision::Confusion());
aBuilder.MakeFace(aFaces[3], new Geom_Plane(aPlanes[3]), Precision::Confusion());
aBuilder.MakeFace(aFaces[4], new Geom_Plane(aPlanes[4]), Precision::Confusion());
aBuilder.MakeFace(aFaces[5], new Geom_Plane(aPlanes[5]), Precision::Confusion());
aBuilder.Add(aFaces[0], aWires[0]);
aBuilder.Add(aFaces[1], aWires[1]);
aBuilder.Add(aFaces[2], aWires[2]);
aBuilder.Add(aFaces[3], aWires[3]);
aBuilder.Add(aFaces[4], aWires[4]);
aBuilder.Add(aFaces[5], aWires[5]);
// set bottom pcurve info of between the edge and surface.
{
// pcurve 0:
double u = 0.0;
double v = 0.0;
double du = 0.0;
double dv = 0.0;
gp_Dir DX = aPlanes[0].XAxis().Direction();
gp_Dir DY = aPlanes[0].YAxis().Direction();
ElSLib::Parameters(aPlanes[0], aLines[0].Location(), u, v);
du = aLines[0].Direction() * DX;
dv = aLines[0].Direction() * DY;
aBuilder.UpdateEdge(aEdges[0], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[0], Precision::Confusion());
// pcurve 1:
ElSLib::Parameters(aPlanes[0], aLines[1].Location(), u, v);
du = aLines[1].Direction() * DX;
dv = aLines[1].Direction() * DY;
aBuilder.UpdateEdge(aEdges[1], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[0], Precision::Confusion());
// pcurve 2:
ElSLib::Parameters(aPlanes[0], aLines[2].Location(), u, v);
du = aLines[2].Direction() * DX;
dv = aLines[2].Direction() * DY;
aBuilder.UpdateEdge(aEdges[2], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[0], Precision::Confusion());
// pcurve 3:
ElSLib::Parameters(aPlanes[0], aLines[3].Location(), u, v);
du = aLines[3].Direction() * DX;
dv = aLines[3].Direction() * DY;
aBuilder.UpdateEdge(aEdges[3], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[0], Precision::Confusion());
}
// set top pcurve info of between the edge and surface.
{
// pcurve 0:
double u = 0.0;
double v = 0.0;
double du = 0.0;
double dv = 0.0;
gp_Dir DX = aPlanes[1].XAxis().Direction();
gp_Dir DY = aPlanes[1].YAxis().Direction();
ElSLib::Parameters(aPlanes[1], aLines[4].Location(), u, v);
du = aLines[4].Direction() * DX;
dv = aLines[4].Direction() * DY;
aBuilder.UpdateEdge(aEdges[4], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[1], Precision::Confusion());
// pcurve 1:
ElSLib::Parameters(aPlanes[1], aLines[5].Location(), u, v);
du = aLines[5].Direction() * DX;
dv = aLines[5].Direction() * DY;
aBuilder.UpdateEdge(aEdges[5], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[1], Precision::Confusion());
// pcurve 2:
ElSLib::Parameters(aPlanes[1], aLines[6].Location(), u, v);
du = aLines[6].Direction() * DX;
dv = aLines[6].Direction() * DY;
aBuilder.UpdateEdge(aEdges[6], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[1], Precision::Confusion());
// pcurve 3:
ElSLib::Parameters(aPlanes[1], aLines[7].Location(), u, v);
du = aLines[7].Direction() * DX;
dv = aLines[7].Direction() * DY;
aBuilder.UpdateEdge(aEdges[7], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[1], Precision::Confusion());
}
// set front pcurve info of between the edge and surface.
{
// pcurve 0:
double u = 0.0;
double v = 0.0;
double du = 0.0;
double dv = 0.0;
gp_Dir DX = aPlanes[2].XAxis().Direction();
gp_Dir DY = aPlanes[2].YAxis().Direction();
ElSLib::Parameters(aPlanes[2], aLines[0].Location(), u, v);
du = aLines[0].Direction() * DX;
dv = aLines[0].Direction() * DY;
aBuilder.UpdateEdge(aEdges[0], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[2], Precision::Confusion());
// pcurve 1:
ElSLib::Parameters(aPlanes[2], aLines[9].Location(), u, v);
du = aLines[9].Direction() * DX;
dv = aLines[9].Direction() * DY;
aBuilder.UpdateEdge(aEdges[9], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[2], Precision::Confusion());
// pcurve 2:
ElSLib::Parameters(aPlanes[2], aLines[4].Location(), u, v);
du = aLines[4].Direction() * DX;
dv = aLines[4].Direction() * DY;
aBuilder.UpdateEdge(aEdges[4], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[2], Precision::Confusion());
// pcurve 3:
ElSLib::Parameters(aPlanes[2], aLines[8].Location(), u, v);
du = aLines[8].Direction() * DX;
dv = aLines[8].Direction() * DY;
aBuilder.UpdateEdge(aEdges[8], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[2], Precision::Confusion());
}
// set back pcurve info of between the edge and surface.
{
// pcurve 0:
double u = 0.0;
double v = 0.0;
double du = 0.0;
double dv = 0.0;
gp_Dir DX = aPlanes[3].XAxis().Direction();
gp_Dir DY = aPlanes[3].YAxis().Direction();
ElSLib::Parameters(aPlanes[3], aLines[2].Location(), u, v);
du = aLines[2].Direction() * DX;
dv = aLines[2].Direction() * DY;
aBuilder.UpdateEdge(aEdges[2], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[3], Precision::Confusion());
// pcurve 1:
ElSLib::Parameters(aPlanes[3], aLines[10].Location(), u, v);
du = aLines[10].Direction() * DX;
dv = aLines[10].Direction() * DY;
aBuilder.UpdateEdge(aEdges[10], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[3], Precision::Confusion());
// pcurve 2:
ElSLib::Parameters(aPlanes[3], aLines[6].Location(), u, v);
du = aLines[6].Direction() * DX;
dv = aLines[6].Direction() * DY;
aBuilder.UpdateEdge(aEdges[6], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[3], Precision::Confusion());
// pcurve 3:
ElSLib::Parameters(aPlanes[3], aLines[11].Location(), u, v);
du = aLines[11].Direction() * DX;
dv = aLines[11].Direction() * DY;
aBuilder.UpdateEdge(aEdges[11], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[3], Precision::Confusion());
}
// set left pcurve info of between the edge and surface.
{
// pcurve 0:
double u = 0.0;
double v = 0.0;
double du = 0.0;
double dv = 0.0;
gp_Dir DX = aPlanes[4].XAxis().Direction();
gp_Dir DY = aPlanes[4].YAxis().Direction();
ElSLib::Parameters(aPlanes[4], aLines[3].Location(), u, v);
du = aLines[3].Direction() * DX;
dv = aLines[3].Direction() * DY;
aBuilder.UpdateEdge(aEdges[3], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[4], Precision::Confusion());
// pcurve 1:
ElSLib::Parameters(aPlanes[4], aLines[11].Location(), u, v);
du = aLines[11].Direction() * DX;
dv = aLines[11].Direction() * DY;
aBuilder.UpdateEdge(aEdges[11], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[4], Precision::Confusion());
// pcurve 2:
ElSLib::Parameters(aPlanes[4], aLines[7].Location(), u, v);
du = aLines[7].Direction() * DX;
dv = aLines[7].Direction() * DY;
aBuilder.UpdateEdge(aEdges[7], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[4], Precision::Confusion());
// pcurve 3:
ElSLib::Parameters(aPlanes[4], aLines[8].Location(), u, v);
du = aLines[8].Direction() * DX;
dv = aLines[8].Direction() * DY;
aBuilder.UpdateEdge(aEdges[8], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[4], Precision::Confusion());
}
// set right pcurve info of between the edge and surface.
{
// pcurve 0:
double u = 0.0;
double v = 0.0;
double du = 0.0;
double dv = 0.0;
gp_Dir DX = aPlanes[5].XAxis().Direction();
gp_Dir DY = aPlanes[5].YAxis().Direction();
ElSLib::Parameters(aPlanes[5], aLines[1].Location(), u, v);
du = aLines[1].Direction() * DX;
dv = aLines[1].Direction() * DY;
aBuilder.UpdateEdge(aEdges[1], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[5], Precision::Confusion());
// pcurve 1:
ElSLib::Parameters(aPlanes[5], aLines[10].Location(), u, v);
du = aLines[10].Direction() * DX;
dv = aLines[10].Direction() * DY;
aBuilder.UpdateEdge(aEdges[10], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[5], Precision::Confusion());
// pcurve 2:
ElSLib::Parameters(aPlanes[5], aLines[5].Location(), u, v);
du = aLines[5].Direction() * DX;
dv = aLines[5].Direction() * DY;
aBuilder.UpdateEdge(aEdges[5], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[5], Precision::Confusion());
// pcurve 3:
ElSLib::Parameters(aPlanes[5], aLines[9].Location(), u, v);
du = aLines[9].Direction() * DX;
dv = aLines[9].Direction() * DY;
aBuilder.UpdateEdge(aEdges[9], new Geom2d_Line(gp_Lin2d(gp_Pnt2d(u, v), gp_Dir2d(du, dv))), aFaces[5], Precision::Confusion());
}
BRepTools::Update(aFaces[0]);
BRepTools::Update(aFaces[1]);
BRepTools::Update(aFaces[2]);
BRepTools::Update(aFaces[3]);
BRepTools::Update(aFaces[4]);
BRepTools::Update(aFaces[5]);
// make the shell of the box.
aBuilder.MakeShell(aShell);
// add faces to the shell.
{
TopoDS_Face F1 = aFaces[0];
TopoDS_Face F2 = aFaces[1];
TopoDS_Face F3 = aFaces[2];
TopoDS_Face F4 = aFaces[3];
TopoDS_Face F5 = aFaces[4];
TopoDS_Face F6 = aFaces[5];
F1.Reverse();
F3.Reverse();
F5.Reverse();
aBuilder.Add(aShell, F1);
aBuilder.Add(aShell, F2);
aBuilder.Add(aShell, F3);
aBuilder.Add(aShell, F4);
aBuilder.Add(aShell, F5);
aBuilder.Add(aShell, F6);
}
aShell.Closed(BRep_Tool::IsClosed(aShell));
BRepTools::Update(aShell);
aBuilder.MakeSolid(aSolid);
aBuilder.Add(aSolid, aShell);
return aSolid;
}