+ attribute Tolerance added to vertex, edge and face

+ method 'add' added to wire

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5401 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2012-01-12 12:09:45 +00:00
parent db3e0cad43
commit 7feebeb5a2
9 changed files with 113 additions and 16 deletions

View File

@ -1679,13 +1679,10 @@ TopoDS_Shape TopoShape::removeShape(const std::vector<TopoDS_Shape>& s) const
void TopoShape::sewShape()
{
//ShapeFix_Shape fixer(this->_Shape);
//fixer.Perform();
BRepBuilderAPI_Sewing sew;
sew.Load(this->_Shape/*fixer.Shape()*/);
sew.Load(this->_Shape);
sew.Perform();
//shape = ShapeUpgrade_ShellSewing().ApplySewing(shape);
this->_Shape = sew.SewedShape();
}
@ -1722,6 +1719,10 @@ bool TopoShape::fix(double precision, double mintol, double maxtol)
fix.FixFaceTool()->Perform();
this->_Shape = fix.Shape();
}
else if (type == TopAbs_WIRE) {
fix.FixWireTool()->Perform();
this->_Shape = fix.Shape();
}
else {
this->_Shape = fix.Shape();
}

View File

@ -59,6 +59,12 @@
<UserDocu>Set the tolerance for the edge.</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Tolerance">
<Documentation>
<UserDocu>Set or get the tolerance of the vertex</UserDocu>
</Documentation>
<Parameter Name="Tolerance" Type="Float"/>
</Attribute>
<Attribute Name="Length" ReadOnly="true">
<Documentation>
<UserDocu>Returns the length of the edge</UserDocu>

View File

@ -409,6 +409,19 @@ PyObject* TopoShapeEdgePy::setTolerance(PyObject *args)
// ====== Attributes ======================================================================
Py::Float TopoShapeEdgePy::getTolerance(void) const
{
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
return Py::Float(BRep_Tool::Tolerance(e));
}
void TopoShapeEdgePy::setTolerance(Py::Float tol)
{
BRep_Builder aBuilder;
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
aBuilder.UpdateEdge(e, (double)tol);
}
Py::Float TopoShapeEdgePy::getLength(void) const
{
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);

View File

@ -64,6 +64,12 @@
<UserDocu>Set the tolerance for the face.</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Tolerance">
<Documentation>
<UserDocu>Set or get the tolerance of the vertex</UserDocu>
</Documentation>
<Parameter Name="Tolerance" Type="Float"/>
</Attribute>
<Attribute Name="ParameterRange" ReadOnly="true">
<Documentation>
<UserDocu>Returns a 4 tuple with the parameter range</UserDocu>

View File

@ -417,17 +417,6 @@ PyObject* TopoShapeFacePy::makeHalfSpace(PyObject *args)
}
}
PyObject* TopoShapeFacePy::setTolerance(PyObject *args)
{
double tol;
if (!PyArg_ParseTuple(args, "d", &tol))
return 0;
BRep_Builder aBuilder;
const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape);
aBuilder.UpdateFace(f, tol);
Py_Return;
}
Py::Object TopoShapeFacePy::getSurface() const
{
const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape);
@ -518,6 +507,30 @@ Py::Object TopoShapeFacePy::getSurface() const
throw Py::TypeError("undefined surface type");
}
PyObject* TopoShapeFacePy::setTolerance(PyObject *args)
{
double tol;
if (!PyArg_ParseTuple(args, "d", &tol))
return 0;
BRep_Builder aBuilder;
const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape);
aBuilder.UpdateFace(f, tol);
Py_Return;
}
Py::Float TopoShapeFacePy::getTolerance(void) const
{
const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape);
return Py::Float(BRep_Tool::Tolerance(f));
}
void TopoShapeFacePy::setTolerance(Py::Float tol)
{
BRep_Builder aBuilder;
const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape);
aBuilder.UpdateFace(f, (double)tol);
}
Py::Tuple TopoShapeFacePy::getParameterRange(void) const
{
const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape);

View File

@ -38,6 +38,12 @@
</Documentation>
<Parameter Name="Point" Type="Object"/>
</Attribute>
<Attribute Name="Tolerance">
<Documentation>
<UserDocu>Set or get the tolerance of the vertex</UserDocu>
</Documentation>
<Parameter Name="Tolerance" Type="Float"/>
</Attribute>
<Methode Name="setTolerance">
<Documentation>
<UserDocu>Set the tolerance for the vertex.</UserDocu>

View File

@ -130,6 +130,19 @@ PyObject* TopoShapeVertexPy::setTolerance(PyObject *args)
Py_Return;
}
Py::Float TopoShapeVertexPy::getTolerance(void) const
{
const TopoDS_Vertex& v = TopoDS::Vertex(getTopoShapePtr()->_Shape);
return Py::Float(BRep_Tool::Tolerance(v));
}
void TopoShapeVertexPy::setTolerance(Py::Float tol)
{
BRep_Builder aBuilder;
const TopoDS_Vertex& v = TopoDS::Vertex(getTopoShapePtr()->_Shape);
aBuilder.UpdateVertex(v, (double)tol);
}
Py::Float TopoShapeVertexPy::getX(void) const
{
const TopoDS_Vertex& v = TopoDS::Vertex(getTopoShapePtr()->_Shape);

View File

@ -19,7 +19,12 @@
<UserDocu>Offset the shape by a given ammount</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeHomogenousWires">
<Methode Name="add">
<Documentation>
<UserDocu>Add an edge to the wire</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeHomogenousWires">
<Documentation>
<UserDocu>Make this and the given wire homogenous to have the same number of edges</UserDocu>
</Documentation>

View File

@ -42,6 +42,7 @@
#include "BSplineCurvePy.h"
#include "TopoShape.h"
#include "TopoShapeShellPy.h"
#include "TopoShapeEdgePy.h"
#include "TopoShapeWirePy.h"
#include "TopoShapeWirePy.cpp"
@ -135,6 +136,39 @@ int TopoShapeWirePy::PyInit(PyObject* args, PyObject* /*kwd*/)
return -1;
}
PyObject* TopoShapeWirePy::add(PyObject *args)
{
PyObject* edge;
if (!PyArg_ParseTuple(args, "O!",&(TopoShapePy::Type), &edge))
return 0;
const TopoDS_Wire& w = TopoDS::Wire(getTopoShapePtr()->_Shape);
BRepBuilderAPI_MakeWire mkWire(w);
const TopoDS_Shape& sh = static_cast<Part::TopoShapePy*>(edge)->getTopoShapePtr()->_Shape;
if (sh.IsNull()) {
PyErr_SetString(PyExc_TypeError, "given shape is invalid");
return 0;
}
if (sh.ShapeType() == TopAbs_EDGE)
mkWire.Add(TopoDS::Edge(sh));
else if (sh.ShapeType() == TopAbs_WIRE)
mkWire.Add(TopoDS::Wire(sh));
else {
PyErr_SetString(PyExc_TypeError, "shape is neither edge nor wire");
return 0;
}
try {
getTopoShapePtr()->_Shape = mkWire.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;