1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0028426: Implementation of the EdgesToFaces function

1. The two new methods have been implemented:
a. BOPAlgo_Tools::EdgesToWires - allows creating planar wires from edges.
The input edges may be not shared, but the output wires will be sharing the coinciding vertices and edges.
It is possible to skip the sharing if the input edges are already shared by passing the corresponding flag into the method.
The input edges are expected to be planar, but the method does not check it. Thus, if the input edges are not planar, the output wires will also be not planar.
In general, the output wires will be non-manifold and may contain free vertices.

b. BOPAlgo_Tools::WiresToFaces - allows creating planar faces from the planar wires.
In general, the input wires are non-manifold and may be not closed, but should share the coinciding parts.
The wires located in the same plane and completely included into other wires will create holes in the faces built from bigger wires

These two methods combined allow building faces from set of edges randomly located in 3D space.

2. The DRAW command *edgestofaces* has been implemented.

3. The documentation has been updated with the new section in Modeling Algorithms - Topological Tools.

4. Test cases for the issue.
This commit is contained in:
emv
2017-02-03 14:24:28 +03:00
committed by apn
parent ea3193f52e
commit e6ae74fd42
48 changed files with 1716 additions and 4 deletions

View File

@@ -23,10 +23,12 @@
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <Draw.hxx>
#include <BOPAlgo_Tools.hxx>
static Standard_Integer attachpcurve (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer edgestowire (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer edgestofaces (Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : BOPCommands
@@ -43,6 +45,7 @@ static Standard_Integer edgestowire (Draw_Interpretor&, Standard_Integer, const
theCommands.Add("attachpcurve", "attachpcurve eold enew face", __FILE__, attachpcurve, group);
theCommands.Add("edgestowire" , "edgestowire wire edges" , __FILE__, edgestowire , group);
theCommands.Add("edgestofaces" , "edgestofaces faces edges [-a AngTol -s Shared(0/1)]", __FILE__, edgestofaces , group);
}
//=======================================================================
@@ -128,3 +131,55 @@ static Standard_Integer edgestowire(Draw_Interpretor& theDI,
DBRep::Set(theArgVal[1], anEdges);
return 0;
}
//=======================================================================
//function : edgestofaces
//purpose : Creates planar faces from linear edges
//=======================================================================
static Standard_Integer edgestofaces(Draw_Interpretor& theDI,
Standard_Integer theNArg,
const char ** theArgVal)
{
if (theNArg < 3) {
theDI << "Use: edgestofaces faces edges [-a AngTol -s Shared(0/1)]\n";
theDI << " AngTol - angular tolerance for comparing the planes;\n";
theDI << " Shared - boolean flag which defines whether the input\n";
theDI << " edges are already shared or have to be intersected.\n";
return 1;
}
//
TopoDS_Shape anEdges = DBRep::Get(theArgVal[2]);
if (anEdges.IsNull()) {
theDI << "no edges\n";
return 1;
}
//
Standard_Real anAngTol = 1.e-8;
Standard_Boolean bShared = Standard_False;
//
for (Standard_Integer i = 3; i < theNArg; ++i) {
if (!strcmp(theArgVal[i], "-a") && (i+1 < theNArg)) {
anAngTol = Draw::Atof(theArgVal[i+1]);
}
if (!strcmp(theArgVal[i], "-s") && (i+1 < theNArg)) {
bShared = (Draw::Atoi(theArgVal[i+1]) == 1);
}
}
//
TopoDS_Shape aWires;
Standard_Integer iErr = BOPAlgo_Tools::EdgesToWires(anEdges, aWires, bShared, anAngTol);
if (iErr) {
theDI << "Unable to build wires from given edges\n";
return 0;
}
//
TopoDS_Shape aFaces;
Standard_Boolean bDone = BOPAlgo_Tools::WiresToFaces(aWires, aFaces, anAngTol);
if (!bDone) {
theDI << "Unable to build faces from wires\n";
return 0;
}
//
DBRep::Set(theArgVal[1], aFaces);
return 0;
}