+ add some repair functions for wires
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5404 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
d8109df4c7
commit
e4eb1cefe9
|
@ -19,5 +19,10 @@
|
|||
<UserDocu>Add a shape to the compound.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="connectEdgesToWires">
|
||||
<Documentation>
|
||||
<UserDocu>Build a compound of wires out of the edges of this compound.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include <BRep_Builder.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <ShapeAnalysis_FreeBounds.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
// inclusion of the generated files (generated out of TopoShapeCompoundPy.xml)
|
||||
#include "TopoShapeCompoundPy.h"
|
||||
|
@ -103,6 +107,42 @@ PyObject* TopoShapeCompoundPy::add(PyObject *args)
|
|||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* TopoShapeCompoundPy::connectEdgesToWires(PyObject *args)
|
||||
{
|
||||
PyObject *shared=Py_True;
|
||||
double tol = Precision::Confusion();
|
||||
if (!PyArg_ParseTuple(args, "|O!d",&PyBool_Type,&shared,&tol))
|
||||
return 0;
|
||||
|
||||
try {
|
||||
const TopoDS_Shape& s = getTopoShapePtr()->_Shape;
|
||||
|
||||
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
|
||||
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
|
||||
for (TopExp_Explorer xp(s, TopAbs_EDGE); xp.More(); xp.Next())
|
||||
hEdges->Append(xp.Current());
|
||||
|
||||
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, tol, (shared==Py_True), hWires);
|
||||
|
||||
TopoDS_Compound comp;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(comp);
|
||||
|
||||
int len = hWires->Length();
|
||||
for(int i=1;i<=len;i++) {
|
||||
builder.Add(comp, hWires->Value(i));
|
||||
}
|
||||
|
||||
getTopoShapePtr()->_Shape = comp;
|
||||
return new TopoShapeCompoundPy(new TopoShape(comp));
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *TopoShapeCompoundPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
<UserDocu>Add an edge to the wire</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixWire">
|
||||
<Documentation>
|
||||
<UserDocu>Fix wire</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeHomogenousWires">
|
||||
<Documentation>
|
||||
<UserDocu>Make this and the given wire homogenous to have the same number of edges</UserDocu>
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
# include <BRepAdaptor_CompCurve.hxx>
|
||||
# include <BRepBuilderAPI_MakeWire.hxx>
|
||||
# include <BRepOffsetAPI_MakeOffset.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <ShapeFix_Wire.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <gp_Ax1.hxx>
|
||||
|
@ -42,6 +44,7 @@
|
|||
#include "BSplineCurvePy.h"
|
||||
#include "TopoShape.h"
|
||||
#include "TopoShapeShellPy.h"
|
||||
#include "TopoShapeFacePy.h"
|
||||
#include "TopoShapeEdgePy.h"
|
||||
#include "TopoShapeWirePy.h"
|
||||
#include "TopoShapeWirePy.cpp"
|
||||
|
@ -169,6 +172,40 @@ PyObject* TopoShapeWirePy::add(PyObject *args)
|
|||
}
|
||||
}
|
||||
|
||||
PyObject* TopoShapeWirePy::fixWire(PyObject *args)
|
||||
{
|
||||
PyObject* face=0;
|
||||
double tol = Precision::Confusion();
|
||||
if (!PyArg_ParseTuple(args, "|O!d",&(TopoShapeFacePy::Type), &face, &tol))
|
||||
return 0;
|
||||
|
||||
try {
|
||||
ShapeFix_Wire aFix;
|
||||
const TopoDS_Wire& w = TopoDS::Wire(getTopoShapePtr()->_Shape);
|
||||
|
||||
if (face) {
|
||||
const TopoDS_Face& f = TopoDS::Face(static_cast<TopoShapePy*>(face)->getTopoShapePtr()->_Shape);
|
||||
aFix.Init(w, f, tol);
|
||||
}
|
||||
else {
|
||||
aFix.SetPrecision(tol);
|
||||
aFix.Load(w);
|
||||
}
|
||||
|
||||
aFix.FixReorder();
|
||||
aFix.FixConnected();
|
||||
aFix.FixClosed();
|
||||
getTopoShapePtr()->_Shape = aFix.Wire();
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* TopoShapeWirePy::makeOffset(PyObject *args)
|
||||
{
|
||||
float dist;
|
||||
|
|
Loading…
Reference in New Issue
Block a user