[TD]2 pass autoscale for DVD, DVS

This commit is contained in:
wandererfan
2020-02-12 07:37:20 -05:00
committed by WandererFan
parent 3a42205cb4
commit 48fc14efcb
6 changed files with 70 additions and 27 deletions

View File

@@ -225,6 +225,29 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
//unblock
}
detailExec(shape, dvp, dvs);
//second pass if required
if (ScaleType.isValue("Automatic")) {
if (!checkFit()) {
double newScale = autoScale();
Scale.setValue(newScale);
Scale.purgeTouched();
if (geometryObject != nullptr) {
delete geometryObject;
geometryObject = nullptr;
detailExec(shape, dvp, dvs);
}
}
}
dvp->requestPaint(); //to refresh detail highlight!
return DrawView::execute();
}
void DrawViewDetail::detailExec(TopoDS_Shape shape,
DrawViewPart* dvp,
DrawViewSection* dvs)
{
Base::Vector3d anchor = AnchorPoint.getValue(); //this is a 2D point (in unrotated coords)
Base::Vector3d dirDetail = dvp->Direction.getValue();
@@ -269,7 +292,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
TopoDS_Face aProjFace = mkFace.Face();
if(aProjFace.IsNull()) {
Base::Console().Warning("DVD::execute - %s - failed to create tool base face\n", getNameInDocument());
return DrawView::execute();
return;
}
Base::Vector3d extrudeVec = dirDetail * extrudeLength;
@@ -279,11 +302,11 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
BRepAlgoAPI_Common mkCommon(copyShape,tool);
if (!mkCommon.IsDone()) {
Base::Console().Warning("DVD::execute - %s - detail cut operation failed (1)\n", getNameInDocument());
return DrawView::execute();
return;
}
if (mkCommon.Shape().IsNull()) {
Base::Console().Warning("DVD::execute - %s - detail cut operation failed (2)\n", getNameInDocument());
return DrawView::execute();
return;
}
//Did we get a solid?
@@ -310,7 +333,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
}
dvp->requestPaint();
Base::Console().Warning("DVD::execute - %s - detail area contains no geometry\n", getNameInDocument());
return DrawView::execute();
return;
}
//for debugging show compound instead of common
@@ -358,7 +381,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
}
catch (Standard_Failure& e4) {
Base::Console().Log("LOG - DVD::execute - extractFaces failed for %s - %s **\n",getNameInDocument(),e4.GetMessageString());
return new App::DocumentObjectExecReturn(e4.GetMessageString());
return;
}
}
@@ -366,18 +389,12 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
}
catch (Standard_Failure& e1) {
Base::Console().Message("LOG - DVD::execute - failed to create detail %s - %s **\n",getNameInDocument(),e1.GetMessageString());
return new App::DocumentObjectExecReturn(e1.GetMessageString());
return;
}
addCosmeticVertexesToGeom();
addCosmeticEdgesToGeom();
addCenterLinesToGeom();
requestPaint();
dvp->requestPaint(); //to refresh detail highlight!
return DrawView::execute();
}
double DrawViewDetail::getFudgeRadius()

View File

@@ -69,7 +69,9 @@ public:
return "TechDrawGui::ViewProviderViewPart";
}
public:
void detailExec(TopoDS_Shape s,
DrawViewPart* baseView,
DrawViewSection* sectionAlias);
double getFudgeRadius(void);
protected:

View File

@@ -259,7 +259,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
auto start = std::chrono::high_resolution_clock::now();
m_saveShape = shape;
buildGeometry(shape);
partExec(shape);
//second pass if required
if (ScaleType.isValue("Automatic")) {
@@ -270,7 +270,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
if (geometryObject != nullptr) {
delete geometryObject;
geometryObject = nullptr;
buildGeometry(shape);
partExec(shape);
}
}
}
@@ -319,9 +319,9 @@ void DrawViewPart::onChanged(const App::Property* prop)
//TODO: when scale changes, any Dimensions for this View sb recalculated. DVD should pick this up subject to topological naming issues.
}
void DrawViewPart::buildGeometry(TopoDS_Shape shape)
void DrawViewPart::partExec(TopoDS_Shape shape)
{
// Base::Console().Message("DVP::buildGeometry()\n");
// Base::Console().Message("DVP::partExec()\n");
geometryObject = makeGeometryForShape(shape);
#if MOD_TECHDRAW_HANDLE_FACES
@@ -331,7 +331,7 @@ void DrawViewPart::buildGeometry(TopoDS_Shape shape)
extractFaces();
}
catch (Standard_Failure& e4) {
Base::Console().Log("LOG - DVP::execute - extractFaces failed for %s - %s **\n",getNameInDocument(),e4.GetMessageString());
Base::Console().Log("LOG - DVP::partExec - extractFaces failed for %s - %s **\n",getNameInDocument(),e4.GetMessageString());
}
}
#endif //#if MOD_TECHDRAW_HANDLE_FACES

View File

@@ -201,7 +201,7 @@ protected:
virtual TechDraw::GeometryObject* buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis); //const??
virtual TechDraw::GeometryObject* makeGeometryForShape(TopoDS_Shape shape); //const??
void buildGeometry(TopoDS_Shape shape);
void partExec(TopoDS_Shape shape);
void extractFaces();

View File

@@ -319,6 +319,29 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
//unblock
}
sectionExec(baseShape);
//second pass if required
if (ScaleType.isValue("Automatic")) {
if (!checkFit()) {
double newScale = autoScale();
Scale.setValue(newScale);
Scale.purgeTouched();
if (geometryObject != nullptr) {
delete geometryObject;
geometryObject = nullptr;
sectionExec(baseShape);
}
}
}
dvp->requestPaint(); //to refresh section line
return DrawView::execute();
}
void DrawViewSection::sectionExec(TopoDS_Shape baseShape)
{
//is SectionOrigin valid?
Bnd_Box centerBox;
BRepBndLib::Add(baseShape, centerBox);
@@ -337,7 +360,8 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
BRepBuilderAPI_MakeFace mkFace(pln, -dMax,dMax,-dMax,dMax);
TopoDS_Face aProjFace = mkFace.Face();
if(aProjFace.IsNull()) {
return new App::DocumentObjectExecReturn("DrawViewSection - Projected face is NULL");
Base::Console().Warning("DVS: Section face is NULL in %s\n",getNameInDocument());
return;
}
gp_Vec extrudeDir = dMax * gp_Vec(gpNormal);
TopoDS_Shape prism = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape();
@@ -348,7 +372,8 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
BRepAlgoAPI_Cut mkCut(myShape, prism);
if (!mkCut.IsDone()) {
return new App::DocumentObjectExecReturn("Section cut has failed");
Base::Console().Warning("DVS: Section cut has failed in %s\n",getNameInDocument());
return;
}
TopoDS_Shape rawShape = mkCut.Shape();
@@ -364,7 +389,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
testBox.SetGap(0.0);
if (testBox.IsVoid()) { //prism & input don't intersect. rawShape is garbage, don't bother.
Base::Console().Warning("DVS::execute - prism & input don't intersect - %s\n", Label.getValue());
return DrawView::execute();
return;
}
gp_Ax2 viewAxis;
@@ -400,7 +425,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
catch (Standard_Failure& e1) {
Base::Console().Warning("DVS::execute - failed to build base shape %s - %s **\n",
getNameInDocument(),e1.GetMessageString());
return DrawView::execute();
return;
}
try {
@@ -462,15 +487,12 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
catch (Standard_Failure& e2) {
Base::Console().Warning("DVS::execute - failed to build section faces for %s - %s **\n",
getNameInDocument(),e2.GetMessageString());
return DrawView::execute();
return;
}
addCosmeticVertexesToGeom();
addCosmeticEdgesToGeom();
addCenterLinesToGeom();
dvp->requestPaint(); //to refresh section line
return DrawView::execute();
}
gp_Pln DrawViewSection::getSectionPlane() const

View File

@@ -90,6 +90,8 @@ public:
virtual void unsetupObject() override;
virtual short mustExecute() const override;
void sectionExec(TopoDS_Shape s);
std::vector<TechDraw::Face*> getFaceGeometry();
void setCSFromBase(const std::string sectionName);