Skip to content

Commit

Permalink
[TD]detail of rotated ComplexSection
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Dec 11, 2022
1 parent de96546 commit 1b707d5
Show file tree
Hide file tree
Showing 10 changed files with 1,548 additions and 1,599 deletions.
32 changes: 22 additions & 10 deletions src/Mod/TechDraw/App/DrawComplexSection.cpp
Expand Up @@ -175,7 +175,7 @@ TopoDS_Shape DrawComplexSection::getShapeToCut()

TopoDS_Shape DrawComplexSection::makeCuttingTool(double dMax)
{
// Base::Console().Message("DCS::makeCuttingTool()\n");
// Base::Console().Message("DCS::makeCuttingTool()\n");
TopoDS_Wire profileWire = makeProfileWire();
if (profileWire.IsNull()) {
throw Base::RuntimeError("Can not make wire from cutting tool (1)");
Expand Down Expand Up @@ -270,20 +270,22 @@ TopoDS_Shape DrawComplexSection::prepareShape(const TopoDS_Shape& cutShape, doub
return TopoDS_Shape();
}

TopoDS_Shape preparedShape = scaleShape(m_alignResult, getScale());
TopoDS_Shape centeredShape = TechDraw::centerShapeXY(m_alignResult, getProjectionCS());
// m_preparedShape = scaleShape(m_alignResult, getScale());
m_preparedShape = scaleShape(centeredShape, getScale());
if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) {
preparedShape =
TechDraw::rotateShape(preparedShape, getProjectionCS(), Rotation.getValue());
m_preparedShape =
TechDraw::rotateShape(m_preparedShape, getProjectionCS(), Rotation.getValue());
}

return preparedShape;
return m_preparedShape;
}


void DrawComplexSection::makeSectionCut(TopoDS_Shape& baseShape)
{
// Base::Console().Message("DCS::makeSectionCut() - %s - baseShape.IsNull: %d\n",
// getNameInDocument(), baseShape.IsNull());
// Base::Console().Message("DCS::makeSectionCut() - %s - baseShape.IsNull: %d\n",
// getNameInDocument(), baseShape.IsNull());
if (ProjectionStrategy.getValue() == 0) {
//Offset. Use regular section behaviour
return DrawViewSection::makeSectionCut(baseShape);
Expand Down Expand Up @@ -325,7 +327,7 @@ void DrawComplexSection::onSectionCutFinished()
//TODO: this process should replace the "makeSectionCut" from DVS
void DrawComplexSection::makeAlignedPieces(const TopoDS_Shape& rawShape)
{
// Base::Console().Message("DCS::makeAlignedPieces() - rawShape.isNull: %d\n", rawShape.IsNull());
// Base::Console().Message("DCS::makeAlignedPieces() - rawShape.isNull: %d\n", rawShape.IsNull());

if (!canBuild(getSectionCS(), CuttingToolWireObject.getValue())) {
throw Base::RuntimeError("Profile is parallel to Section Normal");
Expand Down Expand Up @@ -641,6 +643,16 @@ TopoDS_Shape DrawComplexSection::getShapeToIntersect()
//Aligned
return m_preparedShape;
}

TopoDS_Shape DrawComplexSection::getShapeForDetail() const
{
if (ProjectionStrategy.getValue() == 0) {//Offset
return DrawViewSection::getShapeForDetail();
}
//Aligned
return m_preparedShape;
}

TopoDS_Wire DrawComplexSection::makeProfileWire() const
{
App::DocumentObject* toolObj = CuttingToolWireObject.getValue();
Expand Down Expand Up @@ -672,7 +684,7 @@ TopoDS_Wire DrawComplexSection::makeProfileWire(App::DocumentObject* toolObj)

gp_Vec DrawComplexSection::makeProfileVector(TopoDS_Wire profileWire)
{
// Base::Console().Message("DCS::makeProfileVector()\n");
// Base::Console().Message("DCS::makeProfileVector()\n");
TopoDS_Vertex tvFirst, tvLast;
TopExp::Vertices(profileWire, tvFirst, tvLast);
gp_Pnt gpFirst = BRep_Tool::Pnt(tvFirst);
Expand Down Expand Up @@ -1003,7 +1015,7 @@ bool DrawComplexSection::showSegment(gp_Dir segmentNormal) const
//Can we make a ComplexSection using this profile and sectionNormal?
bool DrawComplexSection::canBuild(gp_Ax2 sectionCS, App::DocumentObject* profileObject)
{
// Base::Console().Message("DCS::canBuild()\n");
// Base::Console().Message("DCS::canBuild()\n");
if (!isProfileObject(profileObject)) {
return false;
}
Expand Down
38 changes: 19 additions & 19 deletions src/Mod/TechDraw/App/DrawComplexSection.h
Expand Up @@ -50,32 +50,31 @@ class TechDrawExport DrawComplexSection: public DrawViewSection
TopoDS_Shape makeCuttingTool(double dMax) 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;
TopoDS_Compound findSectionPlaneIntersections(const TopoDS_Shape& cutShape) override;
TopoDS_Shape prepareShape(const TopoDS_Shape& cutShape, double shapeSize) override;
TopoDS_Shape getShapeToPrepare() const override;
TopoDS_Shape getShapeToIntersect() override;
gp_Pln getSectionPlane() const override;
TopoDS_Compound alignSectionFaces(TopoDS_Shape faceIntersections) override;
std::pair<Base::Vector3d, Base::Vector3d> sectionLineEnds() override;

void makeSectionCut(TopoDS_Shape &baseShape) override;
void makeSectionCut(TopoDS_Shape& baseShape) override;

void waitingForAlign(bool s) { m_waitingForAlign = s; }
bool waitingForAlign(void) 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);
TopoDS_Shape extrudeWireToFace(TopoDS_Wire &wire, gp_Dir extrudeDir, double extrudeDist);
// void makeAlignedPieces(const TopoDS_Shape &rawShape, const TopoDS_Shape &toolFaceShape,
// double extrudeDistance);
void makeAlignedPieces(const TopoDS_Shape &rawShape);
TopoDS_Compound singleToolIntersections(const TopoDS_Shape &cutShape);
TopoDS_Compound alignedToolIntersections(const TopoDS_Shape &cutShape);
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);
TopoDS_Shape extrudeWireToFace(TopoDS_Wire& wire, gp_Dir extrudeDir, double extrudeDist);
void makeAlignedPieces(const TopoDS_Shape& rawShape);
TopoDS_Compound singleToolIntersections(const TopoDS_Shape& cutShape);
TopoDS_Compound alignedToolIntersections(const TopoDS_Shape& cutShape);

BaseGeomPtrVector makeSectionLineGeometry();
std::pair<Base::Vector3d, Base::Vector3d> sectionArrowDirs();
Expand All @@ -84,33 +83,34 @@ public Q_SLOTS:
ChangePointVector getChangePointsFromSectionLine() override;

bool validateProfilePosition(TopoDS_Wire profileWire, gp_Ax2 sectionCS,
gp_Dir &gClosestBasis) const;
gp_Dir& gClosestBasis) 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 makeProfileWire(App::DocumentObject* toolObj);
static TopoDS_Wire makeNoseToTailWire(TopoDS_Wire inWire);
static gp_Vec makeProfileVector(TopoDS_Wire profileWire);
static bool isProfileObject(App::DocumentObject *obj);
static bool isMultiSegmentProfile(App::DocumentObject *obj);
static bool isLinearProfile(App::DocumentObject *obj);
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 canBuild(gp_Ax2 sectionCS, App::DocumentObject* profileObject);
static gp_Vec projectVector(const gp_Vec& vec, gp_Ax2 sectionCS);

private:
gp_Dir getFaceNormal(TopoDS_Face &face);
gp_Dir getFaceNormal(TopoDS_Face& face);

TopoDS_Shape m_toolFaceShape;
TopoDS_Shape m_alignResult;
TopoDS_Shape m_preparedShape;//saved for detail views

QMetaObject::Connection connectAlignWatcher;
QFutureWatcher<void> m_alignWatcher;
QFuture<void> m_alignFuture;
bool m_waitingForAlign;

static const char *ProjectionStrategyEnums[];
static const char* ProjectionStrategyEnums[];
};

using DrawComplexSectionPython = App::FeaturePythonT<DrawComplexSection>;
Expand Down

0 comments on commit 1b707d5

Please sign in to comment.