[TD]fix misaligned PAT hatch on section
This commit is contained in:
@@ -238,11 +238,24 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou
|
||||
double scale )
|
||||
{
|
||||
std::vector<LineSet> result;
|
||||
TopoDS_Face tFace = f;
|
||||
tFace = TopoDS::Face(GeometryObject::invertGeometry(tFace));
|
||||
gp_Pln p;
|
||||
Base::Vector3d vfc = DrawUtil::getFaceCenter(f);
|
||||
gp_Pnt fc(vfc.x, vfc.y, vfc.z);
|
||||
double dir = -1.0;
|
||||
if (fc.Z() < 0.0) {
|
||||
dir = -dir;
|
||||
}
|
||||
Base::Vector3d stdZ(0.0, 0.0, 1.0);
|
||||
Base::Vector3d offset = stdZ * p.Distance(fc) * dir;
|
||||
|
||||
//f may be above or below paper plane and must be moved so Common operation in
|
||||
//getTrimmedLines succeeds
|
||||
TopoDS_Shape moved = TechDraw::moveShape(f,
|
||||
offset);
|
||||
TopoDS_Face fMoved = TopoDS::Face(GeometryObject::invertGeometry(moved));
|
||||
result = getTrimmedLines(source,
|
||||
lineSets,
|
||||
tFace,
|
||||
fMoved,
|
||||
scale );
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -774,6 +774,22 @@ bool DrawUtil::isCrazy(TopoDS_Edge e)
|
||||
return result;
|
||||
}
|
||||
|
||||
//get 3d position of a face's center
|
||||
Base::Vector3d DrawUtil::getFaceCenter(TopoDS_Face f)
|
||||
{
|
||||
BRepAdaptor_Surface adapt(f);
|
||||
double u1 = adapt.FirstUParameter();
|
||||
double u2 = adapt.LastUParameter();
|
||||
double mu = (u1 + u2) / 2.0;
|
||||
double v1 = adapt.FirstVParameter();
|
||||
double v2 = adapt.LastVParameter();
|
||||
double mv = (v1 + v2) / 2.0;
|
||||
BRepLProp_SLProps prop(adapt,mu,mv,0,Precision::Confusion());
|
||||
const gp_Pnt gv = prop.Value();
|
||||
Base::Vector3d v(gv.X(), gv.Y(), gv.Z());
|
||||
return v;
|
||||
}
|
||||
|
||||
// Supplementary mathematical functions
|
||||
// ====================================
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ class TechDrawExport DrawUtil {
|
||||
static App::Color pyTupleToColor(PyObject* pColor);
|
||||
static PyObject* colorToPyTuple(App::Color color);
|
||||
static bool isCrazy(TopoDS_Edge e);
|
||||
static Base::Vector3d getFaceCenter(TopoDS_Face f);
|
||||
|
||||
// Supplementary mathematical functions
|
||||
static int sgn(double x);
|
||||
|
||||
Reference in New Issue
Block a user