[TD]improve ComplexSection handling of bad section normal choice
This commit is contained in:
@@ -35,19 +35,36 @@
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class TechDrawExport AlignedSizeResponse
|
||||
{
|
||||
public:
|
||||
AlignedSizeResponse(const TopoDS_Shape& piece, Base::Vector3d size, double zvalue) :
|
||||
alignedPiece(piece),
|
||||
pieceSize(size),
|
||||
zMax(zvalue) {}
|
||||
|
||||
TopoDS_Shape alignedPiece;
|
||||
Base::Vector3d pieceSize;
|
||||
double zMax;
|
||||
};
|
||||
|
||||
//NOLINTBEGIN
|
||||
class TechDrawExport DrawComplexSection: public DrawViewSection
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::DrawComplexSection);
|
||||
//NOLINTEND
|
||||
|
||||
public:
|
||||
DrawComplexSection();
|
||||
~DrawComplexSection() override = default;
|
||||
|
||||
//NOLINTBEGIN
|
||||
App::PropertyLink CuttingToolWireObject;
|
||||
App::PropertyEnumeration ProjectionStrategy;//Offset or Aligned
|
||||
//NOLINTEND
|
||||
|
||||
TopoDS_Shape makeCuttingTool(double dMax) override;
|
||||
gp_Ax2 getCSFromBase(const std::string sectionName) const override;
|
||||
gp_Ax2 getCSFromBase(const std::string& sectionName) const override;
|
||||
bool isBaseValid() const override;
|
||||
TopoDS_Compound findSectionPlaneIntersections(const TopoDS_Shape& cutShape) override;
|
||||
TopoDS_Shape prepareShape(const TopoDS_Shape& cutShape, double shapeSize) override;
|
||||
@@ -60,13 +77,10 @@ public:
|
||||
void makeSectionCut(const TopoDS_Shape& baseShape) override;
|
||||
|
||||
void waitingForAlign(bool s) { m_waitingForAlign = s; }
|
||||
bool waitingForAlign(void) const { return m_waitingForAlign; }
|
||||
bool waitingForAlign() const { return m_waitingForAlign; }
|
||||
|
||||
TopoDS_Shape getShapeForDetail() const override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onSectionCutFinished(void) override;
|
||||
|
||||
bool boxesIntersect(TopoDS_Face& face, TopoDS_Shape& shape);
|
||||
TopoDS_Shape shapeShapeIntersect(const TopoDS_Shape& shape0, const TopoDS_Shape& shape1);
|
||||
std::vector<TopoDS_Face> faceShapeIntersect(const TopoDS_Face& face, const TopoDS_Shape& shape);
|
||||
@@ -81,26 +95,65 @@ public Q_SLOTS:
|
||||
|
||||
ChangePointVector getChangePointsFromSectionLine() override;
|
||||
|
||||
bool validateProfilePosition(TopoDS_Wire profileWire, gp_Ax2 sectionCS,
|
||||
gp_Dir& gClosestBasis) const;
|
||||
bool validateProfilePosition(const TopoDS_Wire& profileWire, const gp_Ax2& sectionCS) const;
|
||||
bool showSegment(gp_Dir segmentNormal) const;
|
||||
gp_Vec projectVector(const gp_Vec& vec) const;
|
||||
|
||||
TopoDS_Wire makeProfileWire() const;
|
||||
static TopoDS_Wire makeProfileWire(App::DocumentObject* toolObj);
|
||||
static TopoDS_Wire makeNoseToTailWire(TopoDS_Wire inWire);
|
||||
static gp_Vec makeProfileVector(TopoDS_Wire profileWire);
|
||||
static TopoDS_Wire makeNoseToTailWire(const TopoDS_Wire& inWire);
|
||||
static gp_Vec makeProfileVector(const TopoDS_Wire& profileWire);
|
||||
static bool isProfileObject(App::DocumentObject* obj);
|
||||
static bool isMultiSegmentProfile(App::DocumentObject* obj);
|
||||
static bool isLinearProfile(App::DocumentObject* obj);
|
||||
static bool isTrulyEmpty(TopoDS_Shape inShape);
|
||||
static bool isTrulyEmpty(const TopoDS_Shape& inShape);
|
||||
static bool canBuild(gp_Ax2 sectionCS, App::DocumentObject* profileObject);
|
||||
static gp_Vec projectVector(const gp_Vec& vec, gp_Ax2 sectionCS);
|
||||
static std::pair<Base::Vector3d, Base::Vector3d> getSegmentEnds(const TopoDS_Edge& segment);
|
||||
static std::pair<Base::Vector3d, Base::Vector3d> getWireEnds(const TopoDS_Wire& wire);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onSectionCutFinished() override;
|
||||
|
||||
private:
|
||||
gp_Dir getFaceNormal(TopoDS_Face& face);
|
||||
bool validateOffsetProfile(TopoDS_Wire profile, Base::Vector3d direction, double angleThresholdDeg) const;
|
||||
std::pair<Base::Vector3d, Base::Vector3d> getSegmentEnds(TopoDS_Edge segment) const;
|
||||
Base::Vector3d getReferenceAxis();
|
||||
|
||||
// methods refactored out of makeAlignedPieces
|
||||
bool getReversers(const gp_Vec& gProfileVector, double& horizReverser, double& verticalReverser);
|
||||
AlignedSizeResponse getAlignedSize(const TopoDS_Shape& pieceRotated, int iPiece) const;
|
||||
TopoDS_Shape cutAndRotatePiece(const TopoDS_Shape& rawShape,
|
||||
const TopoDS_Face& segmentFace,
|
||||
int iPiece,
|
||||
Base::Vector3d uOrientedSegmentNormal,
|
||||
Base::Vector3d uRotateAxis,
|
||||
double& pieceVertical);
|
||||
TopoDS_Shape movePieceToPaperPlane(const TopoDS_Shape& piece, double sizeMax);
|
||||
TopoDS_Shape distributePiece(const TopoDS_Shape& piece,
|
||||
double pieceSize,
|
||||
double verticalDisplace,
|
||||
const gp_Vec& alignmentAxis,
|
||||
const gp_Vec& gMovementVector,
|
||||
double baseDistance);
|
||||
|
||||
|
||||
std::vector<std::pair<int, Base::Vector3d> >
|
||||
getSegmentViewDirections(const TopoDS_Wire& profileWire,
|
||||
Base::Vector3d sectionNormal,
|
||||
Base::Vector3d referenceAxis) const;
|
||||
|
||||
std::vector<Base::Vector3d> getPointsForClosingProfile(const TopoDS_Wire& profileWire,
|
||||
double dMax);
|
||||
|
||||
static std::vector<TopoDS_Edge> getUniqueEdges(const TopoDS_Wire& wireIn);
|
||||
static TopoDS_Shape removeEmptyShapes(const TopoDS_Shape& roughTool);
|
||||
static gp_Dir getFaceNormal(TopoDS_Face& face);
|
||||
static bool faceContainsEndpoints(const TopoDS_Edge& edgeToMatch,
|
||||
const TopoDS_Face& faceToSearch);
|
||||
static bool normalLess(const std::pair<int, Base::Vector3d>& n1,
|
||||
const std::pair<int, Base::Vector3d>& n2);
|
||||
static TopoDS_Wire closeProfile(const TopoDS_Wire& profileWire, Base::Vector3d referenceAxis, double dMax);
|
||||
static TopoDS_Shape profileToSolid(const TopoDS_Wire& closedProfileWire, Base::Vector3d referenceAxis, double dMax);
|
||||
|
||||
TopoDS_Shape m_toolFaceShape;
|
||||
TopoDS_Shape m_alignResult;
|
||||
@@ -111,7 +164,7 @@ private:
|
||||
QFuture<void> m_alignFuture;
|
||||
bool m_waitingForAlign;
|
||||
|
||||
static const char* ProjectionStrategyEnums[];
|
||||
static const char* ProjectionStrategyEnums[]; //NOLINT
|
||||
};
|
||||
|
||||
using DrawComplexSectionPython = App::FeaturePythonT<DrawComplexSection>;
|
||||
|
||||
Reference in New Issue
Block a user