Set tessellation tolerance in Drawing by user
This commit is contained in:
parent
a6a5336bc5
commit
e11e4ba9ff
|
@ -105,9 +105,10 @@ projectToSVG(PyObject *self, PyObject *args)
|
|||
PyObject *pcObjDir=0;
|
||||
const char *type=0;
|
||||
float scale=1.0f;
|
||||
float tol=0.1f;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!|O!sf", &(TopoShapePy::Type), &pcObjShape,
|
||||
&(Base::VectorPy::Type), &pcObjDir, &type, &scale))
|
||||
if (!PyArg_ParseTuple(args, "O!|O!sff", &(TopoShapePy::Type), &pcObjShape,
|
||||
&(Base::VectorPy::Type), &pcObjDir, &type, &scale, &tol))
|
||||
return NULL;
|
||||
|
||||
PY_TRY {
|
||||
|
@ -121,7 +122,7 @@ projectToSVG(PyObject *self, PyObject *args)
|
|||
if (type && std::string(type) == "ShowHiddenLines")
|
||||
hidden = true;
|
||||
|
||||
Py::String result(Alg.getSVG(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale));
|
||||
Py::String result(Alg.getSVG(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale, tol));
|
||||
return Py::new_reference_to(result);
|
||||
|
||||
} PY_CATCH;
|
||||
|
@ -134,9 +135,10 @@ projectToDXF(PyObject *self, PyObject *args)
|
|||
PyObject *pcObjDir=0;
|
||||
const char *type=0;
|
||||
float scale=1.0f;
|
||||
float tol=0.1f;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!|O!sf", &(TopoShapePy::Type), &pcObjShape,
|
||||
&(Base::VectorPy::Type), &pcObjDir, &type, &scale))
|
||||
if (!PyArg_ParseTuple(args, "O!|O!sff", &(TopoShapePy::Type), &pcObjShape,
|
||||
&(Base::VectorPy::Type), &pcObjDir, &type, &scale, &tol))
|
||||
return NULL;
|
||||
|
||||
PY_TRY {
|
||||
|
@ -150,7 +152,7 @@ projectToDXF(PyObject *self, PyObject *args)
|
|||
if (type && std::string(type) == "ShowHiddenLines")
|
||||
hidden = true;
|
||||
|
||||
Py::String result(Alg.getDXF(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale));
|
||||
Py::String result(Alg.getDXF(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale, tol));
|
||||
return Py::new_reference_to(result);
|
||||
|
||||
} PY_CATCH;
|
||||
|
|
|
@ -70,6 +70,8 @@ using namespace std;
|
|||
// FeatureViewPart
|
||||
//===========================================================================
|
||||
|
||||
App::PropertyFloatConstraint::Constraints FeatureViewPart::floatRange = {0.01f,5.0f,0.05f};
|
||||
|
||||
PROPERTY_SOURCE(Drawing::FeatureViewPart, Drawing::FeatureView)
|
||||
|
||||
|
||||
|
@ -83,6 +85,8 @@ FeatureViewPart::FeatureViewPart(void)
|
|||
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Control the appearance of the dashed hidden lines");
|
||||
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Control the appearance of the smooth lines");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(0.35f),vgroup,App::Prop_None,"The thickness of the resulting lines");
|
||||
ADD_PROPERTY_TYPE(Tolerance,(0.05f),vgroup,App::Prop_None,"The tessellation tolerance");
|
||||
Tolerance.setConstraints(&floatRange);
|
||||
}
|
||||
|
||||
FeatureViewPart::~FeatureViewPart()
|
||||
|
@ -198,7 +202,7 @@ App::DocumentObjectExecReturn *FeatureViewPart::execute(void)
|
|||
ProjectionAlgos::SvgExtractionType type = ProjectionAlgos::Plain;
|
||||
if (hidden) type = (ProjectionAlgos::SvgExtractionType)(type|ProjectionAlgos::WithHidden);
|
||||
if (smooth) type = (ProjectionAlgos::SvgExtractionType)(type|ProjectionAlgos::WithSmooth);
|
||||
result << Alg.getSVG(type, this->LineWidth.getValue() / this->Scale.getValue());
|
||||
result << Alg.getSVG(type, this->LineWidth.getValue() / this->Scale.getValue(), this->Tolerance.getValue());
|
||||
|
||||
result << "</g>" << endl;
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ public:
|
|||
App::PropertyBool ShowHiddenLines;
|
||||
App::PropertyBool ShowSmoothLines;
|
||||
App::PropertyFloat LineWidth;
|
||||
|
||||
App::PropertyFloatConstraint Tolerance;
|
||||
|
||||
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
|
@ -65,6 +66,9 @@ public:
|
|||
virtual const char* getViewProviderName(void) const {
|
||||
return "DrawingGui::ViewProviderDrawingView";
|
||||
}
|
||||
|
||||
private:
|
||||
static App::PropertyFloatConstraint::Constraints floatRange;
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<FeatureViewPart> FeatureViewPartPython;
|
||||
|
|
|
@ -149,7 +149,7 @@ void ProjectionAlgos::execute(void)
|
|||
|
||||
}
|
||||
|
||||
std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale)
|
||||
std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale, float tolerance)
|
||||
{
|
||||
std::stringstream result;
|
||||
SVGOutput output;
|
||||
|
@ -187,7 +187,7 @@ std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale)
|
|||
}
|
||||
if (!VO.IsNull()) {
|
||||
float width = scale;
|
||||
BRepMesh::Mesh(VO,0.1);
|
||||
BRepMesh::Mesh(VO,tolerance);
|
||||
result << "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
|
@ -251,7 +251,7 @@ std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale)
|
|||
|
||||
/* dxf output section - Dan Falck 2011/09/25 */
|
||||
|
||||
std::string ProjectionAlgos::getDXF(SvgExtractionType type, float scale)
|
||||
std::string ProjectionAlgos::getDXF(SvgExtractionType type, float scale, float tolerance)
|
||||
{
|
||||
std::stringstream result;
|
||||
DXFOutput output;
|
||||
|
@ -279,7 +279,7 @@ std::string ProjectionAlgos::getDXF(SvgExtractionType type, float scale)
|
|||
}
|
||||
if (!HO.IsNull() && (type & WithHidden)) {
|
||||
//float width = 0.15f/scale;
|
||||
BRepMesh::Mesh(HO,0.1);
|
||||
BRepMesh::Mesh(HO,tolerance);
|
||||
result //<< "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
/*<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
|
|
|
@ -51,8 +51,8 @@ public:
|
|||
WithSmooth = 2
|
||||
};
|
||||
|
||||
std::string getSVG(SvgExtractionType type, float scale);
|
||||
std::string getDXF(SvgExtractionType type, float scale);//add by Dan Falck 2011/09/25
|
||||
std::string getSVG(SvgExtractionType type, float scale, float tolerance);
|
||||
std::string getDXF(SvgExtractionType type, float scale, float tolerance);//added by Dan Falck 2011/09/25
|
||||
|
||||
|
||||
const TopoDS_Shape &Input;
|
||||
|
|
Loading…
Reference in New Issue
Block a user