[TD]handle loose geometry via HLR

This commit is contained in:
wandererfan
2023-10-25 19:08:02 -04:00
committed by WandererFan
parent a3aeed8c03
commit 9cb4745f38
7 changed files with 350 additions and 421 deletions

View File

@@ -167,7 +167,7 @@ App::DocumentObjectExecReturn* DrawViewDetail::execute()
}
detailExec(shape, dvp, dvs);
addShapes2d();
addPoints();
dvp->requestPaint();//to refresh detail highlight in base view
return DrawView::execute();

View File

@@ -201,15 +201,12 @@ std::vector<App::DocumentObject*> DrawViewPart::getAllSources() const
return result;
}
//! pick supported 2d shapes out of the Source properties and
//! pick vertex objects out of the Source properties and
//! add them directly to the geometry without going through HLR
//! NOTE: this is for loose 2d shapes such as Part line or circle and is
//! not meant to include complex 2d shapes such as Sketches.
void DrawViewPart::addShapes2d(void)
void DrawViewPart::addPoints(void)
{
// Base::Console().Message("DVP::addShapes2d()\n");
// get all the 2d shapes in the sources, then pick through them for loose edges
// or vertices.
// Base::Console().Message("DVP::addPoints()\n");
// get all the 2d shapes in the sources, then pick through them for vertices.
std::vector<TopoDS_Shape> shapes = ShapeExtractor::getShapes2d(getAllSources());
for (auto& s : shapes) {
if (s.ShapeType() == TopAbs_VERTEX) {
@@ -221,21 +218,6 @@ void DrawViewPart::addShapes2d(void)
TechDraw::VertexPtr v1(std::make_shared<TechDraw::Vertex>(projected));
geometryObject->addVertex(v1);
}
else if (s.ShapeType() == TopAbs_EDGE) {
TopoDS_Shape sTrans = ShapeUtils::moveShape(s,
m_saveCentroid * -1.0);
TopoDS_Shape sScale = ShapeUtils::scaleShape(sTrans,
getScale());
TopoDS_Shape sMirror = ShapeUtils::mirrorShape(sScale);
TopoDS_Edge edge = TopoDS::Edge(sMirror);
BaseGeomPtr bg = projectEdge(edge);
geometryObject->addEdge(bg);
} else {
// message for developers.
//Base::Console().Message("DEVEL: DVP::addShapes2d - shape is not a vertex or edge\n");
}
}
}
@@ -448,7 +430,7 @@ void DrawViewPart::postHlrTasks(void)
addCosmeticVertexesToGeom();
addCosmeticEdgesToGeom();
addReferencesToGeom();
addShapes2d();
addPoints();
//balloons need to be recomputed here because their
//references will be invalid until the geometry exists

View File

@@ -225,7 +225,7 @@ protected:
const gp_Ax2& viewAxis);
virtual TechDraw::GeometryObjectPtr makeGeometryForShape(TopoDS_Shape& shape);//const??
void partExec(TopoDS_Shape& shape);
virtual void addShapes2d(void);
virtual void addPoints(void);
void extractFaces();
void findFacesNew(const std::vector<TechDraw::BaseGeomPtr>& goEdges);

View File

@@ -421,7 +421,7 @@ App::DocumentObjectExecReturn* DrawViewSection::execute()
}
sectionExec(baseShape);
addShapes2d();
addPoints();
return DrawView::execute();
}

View File

@@ -47,7 +47,6 @@
#include "ShapeExtractor.h"
#include "DrawUtil.h"
#include "Preferences.h"
#include "ShapeUtils.h"
@@ -55,14 +54,15 @@ using namespace TechDraw;
using DU = DrawUtil;
using SU = ShapeUtils;
std::vector<TopoDS_Shape> ShapeExtractor::getShapes2d(const std::vector<App::DocumentObject*> links, bool overridePref)
//! pick out the 2d document objects objects in the list of links and return a vector of their shapes
//! Note that point objects will not make it through the hlr/projection process.
std::vector<TopoDS_Shape> ShapeExtractor::getShapes2d(const std::vector<App::DocumentObject*> links)
{
// Base::Console().Message("SE::getShapes2d() - links: %d\n", links.size());
std::vector<TopoDS_Shape> shapes2d;
if (!prefAdd2d() && !overridePref) {
return shapes2d;
}
for (auto& l:links) {
const App::GroupExtension* gex = dynamic_cast<const App::GroupExtension*>(l);
if (gex) {
@@ -333,7 +333,7 @@ TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector<App::DocumentObjec
// if there are 2d shapes in the links they will not fuse with the 3d shapes,
// so instead we return a compound of the fused 3d shapes and the 2d shapes
std::vector<TopoDS_Shape> shapes2d = getShapes2d(links, true);
std::vector<TopoDS_Shape> shapes2d = getShapes2d(links);
if (!shapes2d.empty()) {
shapes2d.push_back(baseShape);
return DrawUtil::shapeVectorToCompound(shapes2d, false);
@@ -472,9 +472,3 @@ TopoDS_Shape ShapeExtractor::getLocatedShape(const App::DocumentObject* docObj)
return shape.getShape();
}
//! true if we should include loose 2d geometry
bool ShapeExtractor::prefAdd2d()
{
return Preferences::getPreferenceGroup("General")->GetBool("ShowLoose2d", false);
}

View File

@@ -40,7 +40,7 @@ class TechDrawExport ShapeExtractor
{
public:
static TopoDS_Shape getShapes(const std::vector<App::DocumentObject*> links, bool include2d = true);
static std::vector<TopoDS_Shape> getShapes2d(const std::vector<App::DocumentObject*> links, bool overridePref = false);
static std::vector<TopoDS_Shape> getShapes2d(const std::vector<App::DocumentObject*> links);
static std::vector<TopoDS_Shape> getXShapes(const App::Link* xLink);
static std::vector<TopoDS_Shape> getShapesFromObject(const App::DocumentObject* docObj);
static TopoDS_Shape getShapesFused(const std::vector<App::DocumentObject*> links);
@@ -51,7 +51,6 @@ public:
static bool isPointType(App::DocumentObject* obj);
static bool isDraftPoint(App::DocumentObject* obj);
static Base::Vector3d getLocation3dFromFeat(App::DocumentObject *obj);
static bool prefAdd2d();
static TopoDS_Shape stripInfiniteShapes(TopoDS_Shape inShape);