TD: replace usage of raw pointers of Vertex and Face with shared pointers.
This fixes issue 4741: Broken File After Using Landmark Dimension in TechDraw
This commit is contained in:
@@ -1121,13 +1121,13 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Points(DrawV
|
||||
|
||||
double scale = partFeat->getScale();
|
||||
|
||||
std::vector<TechDraw::Vertex*> points;
|
||||
std::vector<TechDraw::VertexPtr> points;
|
||||
for (auto& vn: vertNames) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(vn) != "Vertex") {
|
||||
continue;
|
||||
}
|
||||
int idx = TechDraw::DrawUtil::getIndexFromName(vn);
|
||||
TechDraw::Vertex* v = partFeat->getProjVertexByIndex(idx);
|
||||
TechDraw::VertexPtr v = partFeat->getProjVertexByIndex(idx);
|
||||
if (v != nullptr) {
|
||||
points.push_back(v);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::s
|
||||
return result;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
TechDraw::Vertex* v = dvp->getProjVertexByIndex(idx);
|
||||
TechDraw::VertexPtr v = dvp->getProjVertexByIndex(idx);
|
||||
if (v == nullptr) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ void DrawDimHelper::makeExtentDim(DrawViewPart* dvp,
|
||||
std::vector<std::string> cvTags;
|
||||
std::string tag0;
|
||||
std::string tag1;
|
||||
TechDraw::Vertex* v0 = nullptr;
|
||||
TechDraw::Vertex* v1 = nullptr;
|
||||
TechDraw::VertexPtr v0;
|
||||
TechDraw::VertexPtr v1;
|
||||
if (subElements.size() > 1) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
|
||||
@@ -128,8 +128,8 @@ App::DocumentObjectExecReturn *DrawViewDimExtent::execute(void)
|
||||
Base::Vector3d refMin = endPoints.first;
|
||||
Base::Vector3d refMax = endPoints.second;
|
||||
|
||||
TechDraw::Vertex* v0 = nullptr;
|
||||
TechDraw::Vertex* v1 = nullptr;
|
||||
TechDraw::VertexPtr v0 = nullptr;
|
||||
TechDraw::VertexPtr v1 = nullptr;
|
||||
std::vector<std::string> cTags = CosmeticTags.getValues();
|
||||
if (cTags.size() > 1) {
|
||||
v0 = dvp->getProjVertexByCosTag(cTags[0]);
|
||||
@@ -184,8 +184,8 @@ pointPair DrawViewDimExtent::getPointsTwoVerts()
|
||||
pointPair result;
|
||||
result.first = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
result.second = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
TechDraw::Vertex* v0 = nullptr;
|
||||
TechDraw::Vertex* v1 = nullptr;
|
||||
TechDraw::VertexPtr v0 = nullptr;
|
||||
TechDraw::VertexPtr v1 = nullptr;
|
||||
TechDraw::DrawViewPart* dvp = getViewPart();
|
||||
if (dvp == nullptr) {
|
||||
return result;
|
||||
|
||||
@@ -644,9 +644,9 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
int idx2 = DrawUtil::getIndexFromName(subElements[2]);
|
||||
|
||||
TechDraw::Vertex* vert0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDraw::Vertex* vert1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
TechDraw::Vertex* vert2 = getViewPart()->getProjVertexByIndex(idx2);
|
||||
TechDraw::VertexPtr vert0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDraw::VertexPtr vert1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
TechDraw::VertexPtr vert2 = getViewPart()->getProjVertexByIndex(idx2);
|
||||
if (!vert0 || !vert1 || !vert2) {
|
||||
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
return App::DocumentObject::StdReturn;
|
||||
@@ -1134,8 +1134,8 @@ pointPair DrawViewDimension::getPointsTwoVerts()
|
||||
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDraw::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDraw::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
TechDraw::VertexPtr v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDraw::VertexPtr v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
if ((v0 == nullptr) ||
|
||||
(v1 == nullptr) ) {
|
||||
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (3)\n",getNameInDocument());
|
||||
@@ -1153,7 +1153,7 @@ pointPair DrawViewDimension::getPointsEdgeVert()
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDraw::BaseGeom* e;
|
||||
TechDraw::Vertex* v;
|
||||
TechDraw::VertexPtr v;
|
||||
if (DrawUtil::getGeomTypeFromName(subElements[0]) == "Edge") {
|
||||
e = getViewPart()->getGeomByIndex(idx0);
|
||||
v = getViewPart()->getProjVertexByIndex(idx1);
|
||||
@@ -1222,7 +1222,7 @@ bool DrawViewDimension::checkReferences2D() const
|
||||
break;
|
||||
}
|
||||
} else if (DrawUtil::getGeomTypeFromName(s) == "Vertex") {
|
||||
TechDraw::Vertex* v = getViewPart()->getProjVertexByIndex(idx);
|
||||
TechDraw::VertexPtr v = getViewPart()->getProjVertexByIndex(idx);
|
||||
if (v == nullptr) {
|
||||
result = false;
|
||||
break;
|
||||
|
||||
@@ -391,7 +391,7 @@ void DrawViewPart::addShapes2d(void)
|
||||
vp = vp - m_saveCentroid;
|
||||
//need to offset the point to match the big projection
|
||||
Base::Vector3d projected = projectPoint(vp * getScale());
|
||||
TechDraw::Vertex* v1 = new TechDraw::Vertex(projected);
|
||||
TechDraw::VertexPtr v1(std::make_shared<TechDraw::Vertex>(projected));
|
||||
geometryObject->addVertex(v1);
|
||||
} else if (s.ShapeType() == TopAbs_EDGE) {
|
||||
//not supporting edges yet.
|
||||
@@ -621,7 +621,7 @@ void DrawViewPart::extractFaces()
|
||||
// std::string wireName = ss.str();
|
||||
// BRepTools::Write((*itWire), wireName.c_str()); //debug
|
||||
//debug idb++;
|
||||
TechDraw::Face* f = new TechDraw::Face();
|
||||
TechDraw::FacePtr f(std::make_shared<TechDraw::Face>());
|
||||
const TopoDS_Wire& wire = (*itWire);
|
||||
TechDraw::Wire* w = new TechDraw::Wire(wire);
|
||||
f->wires.push_back(w);
|
||||
@@ -688,18 +688,18 @@ std::vector<TechDraw::DrawViewBalloon*> DrawViewPart::getBalloons() const
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::vector<TechDraw::Vertex *> DrawViewPart::getVertexGeometry() const
|
||||
const std::vector<TechDraw::VertexPtr> DrawViewPart::getVertexGeometry() const
|
||||
{
|
||||
std::vector<TechDraw::Vertex *> result;
|
||||
std::vector<TechDraw::VertexPtr> result;
|
||||
if (geometryObject != nullptr) {
|
||||
result = geometryObject->getVertexGeometry();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::vector<TechDraw::Face *> DrawViewPart::getFaceGeometry() const
|
||||
const std::vector<TechDraw::FacePtr> DrawViewPart::getFaceGeometry() const
|
||||
{
|
||||
std::vector<TechDraw::Face*> result;
|
||||
std::vector<TechDraw::FacePtr> result;
|
||||
if (geometryObject != nullptr) {
|
||||
result = geometryObject->getFaceGeometry();
|
||||
}
|
||||
@@ -731,9 +731,9 @@ TechDraw::BaseGeom* DrawViewPart::getGeomByIndex(int idx) const
|
||||
}
|
||||
|
||||
//! returns existing geometry of 2D Vertex(idx)
|
||||
TechDraw::Vertex* DrawViewPart::getProjVertexByIndex(int idx) const
|
||||
TechDraw::VertexPtr DrawViewPart::getProjVertexByIndex(int idx) const
|
||||
{
|
||||
const std::vector<TechDraw::Vertex *> &geoms = getVertexGeometry();
|
||||
const std::vector<TechDraw::VertexPtr> &geoms = getVertexGeometry();
|
||||
if (geoms.empty()) {
|
||||
Base::Console().Log("INFO - getProjVertexByIndex(%d) - no Vertex Geometry. Probably restoring?\n",idx);
|
||||
return NULL;
|
||||
@@ -745,10 +745,10 @@ TechDraw::Vertex* DrawViewPart::getProjVertexByIndex(int idx) const
|
||||
return geoms.at(idx);
|
||||
}
|
||||
|
||||
TechDraw::Vertex* DrawViewPart::getProjVertexByCosTag(std::string cosTag)
|
||||
TechDraw::VertexPtr DrawViewPart::getProjVertexByCosTag(std::string cosTag)
|
||||
{
|
||||
TechDraw::Vertex* result = nullptr;
|
||||
std::vector<TechDraw::Vertex*> gVerts = getVertexGeometry();
|
||||
TechDraw::VertexPtr result = nullptr;
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
if (gVerts.empty()) {
|
||||
Base::Console().Log("INFO - getProjVertexByCosTag(%s) - no Vertex Geometry.\n");
|
||||
return result;
|
||||
@@ -768,9 +768,9 @@ TechDraw::Vertex* DrawViewPart::getProjVertexByCosTag(std::string cosTag)
|
||||
std::vector<TechDraw::BaseGeom*> DrawViewPart::getFaceEdgesByIndex(int idx) const
|
||||
{
|
||||
std::vector<TechDraw::BaseGeom*> result;
|
||||
const std::vector<TechDraw::Face *>& faces = getFaceGeometry();
|
||||
const std::vector<TechDraw::FacePtr>& faces = getFaceGeometry();
|
||||
if (idx < (int) faces.size()) {
|
||||
TechDraw::Face* projFace = faces.at(idx);
|
||||
TechDraw::FacePtr projFace = faces.at(idx);
|
||||
for (auto& w: projFace->wires) {
|
||||
for (auto& g:w->geoms) {
|
||||
if (g->cosmetic) {
|
||||
@@ -789,8 +789,8 @@ std::vector<TopoDS_Wire> DrawViewPart::getWireForFace(int idx) const
|
||||
{
|
||||
std::vector<TopoDS_Wire> result;
|
||||
std::vector<TopoDS_Edge> edges;
|
||||
const std::vector<TechDraw::Face *>& faces = getFaceGeometry();
|
||||
TechDraw::Face * ourFace = faces.at(idx);
|
||||
const std::vector<TechDraw::FacePtr>& faces = getFaceGeometry();
|
||||
TechDraw::FacePtr ourFace = faces.at(idx);
|
||||
for (auto& w:ourFace->wires) {
|
||||
edges.clear();
|
||||
int i = 0;
|
||||
@@ -874,7 +874,7 @@ bool DrawViewPart::hasGeometry(void) const
|
||||
if (geometryObject == nullptr) {
|
||||
return result;
|
||||
}
|
||||
const std::vector<TechDraw::Vertex*> &verts = getVertexGeometry();
|
||||
const std::vector<TechDraw::VertexPtr> &verts = getVertexGeometry();
|
||||
const std::vector<TechDraw::BaseGeom*> &edges = getEdgeGeometry();
|
||||
if (verts.empty() &&
|
||||
edges.empty() ) {
|
||||
@@ -1107,7 +1107,7 @@ void DrawViewPart::updateReferenceVert(std::string tag, Base::Vector3d loc2d)
|
||||
void DrawViewPart::addReferencesToGeom(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::addReferencesToGeom() - %s\n", getNameInDocument());
|
||||
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
gVerts.insert(gVerts.end(), m_referenceVerts.begin(), m_referenceVerts.end());
|
||||
getGeometryObject()->setVertexGeometry(gVerts);
|
||||
}
|
||||
@@ -1122,7 +1122,7 @@ std::string DrawViewPart::addReferenceVertex(Base::Vector3d v)
|
||||
// Base::Vector3d scaledV = v * getScale();
|
||||
// TechDraw::Vertex* ref = new TechDraw::Vertex(scaledV);
|
||||
Base::Vector3d scaledV = v;
|
||||
TechDraw::Vertex* ref = new TechDraw::Vertex(scaledV);
|
||||
TechDraw::VertexPtr ref(std::make_shared<TechDraw::Vertex>(scaledV));
|
||||
ref->reference = true;
|
||||
refTag = ref->getTagAsString();
|
||||
m_referenceVerts.push_back(ref);
|
||||
@@ -1131,7 +1131,7 @@ std::string DrawViewPart::addReferenceVertex(Base::Vector3d v)
|
||||
|
||||
void DrawViewPart::removeReferenceVertex(std::string tag)
|
||||
{
|
||||
std::vector<TechDraw::Vertex*> newRefVerts;
|
||||
std::vector<TechDraw::VertexPtr> newRefVerts;
|
||||
for (auto& v: m_referenceVerts) {
|
||||
if (v->getTagAsString() != tag) {
|
||||
newRefVerts.push_back(v);
|
||||
@@ -1147,8 +1147,8 @@ void DrawViewPart::removeAllReferencesFromGeom()
|
||||
{
|
||||
// Base::Console().Message("DVP::removeAllReferencesFromGeom()\n");
|
||||
if (!m_referenceVerts.empty()) {
|
||||
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::Vertex *> newVerts;
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr> newVerts;
|
||||
for (auto& gv: gVerts) {
|
||||
if (!gv->reference) {
|
||||
newVerts.push_back(gv);
|
||||
@@ -1206,8 +1206,8 @@ void DrawViewPart::refreshCVGeoms(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::refreshCVGeoms()\n");
|
||||
|
||||
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::Vertex *> newGVerts;
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr> newGVerts;
|
||||
for (auto& gv :gVerts) {
|
||||
if (gv->cosmeticTag.empty()) { //keep only non-cv vertices
|
||||
newGVerts.push_back(gv);
|
||||
@@ -1222,7 +1222,7 @@ int DrawViewPart::getCVIndex(std::string tag)
|
||||
{
|
||||
// Base::Console().Message("DVP::getCVIndex(%s)\n", tag.c_str());
|
||||
int result = -1;
|
||||
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
|
||||
|
||||
int i = 0;
|
||||
@@ -1382,7 +1382,7 @@ void DrawViewPart::dumpVerts(std::string text)
|
||||
Base::Console().Message("no verts to dump yet\n");
|
||||
return;
|
||||
}
|
||||
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
Base::Console().Message("%s - dumping %d vertGeoms\n",
|
||||
text.c_str(), gVerts.size());
|
||||
for (auto& gv: gVerts) {
|
||||
|
||||
@@ -125,17 +125,17 @@ public:
|
||||
std::vector<TechDraw::DrawViewDimension*> getDimensions() const;
|
||||
std::vector<TechDraw::DrawViewBalloon*> getBalloons() const;
|
||||
|
||||
const std::vector<TechDraw::Vertex*> getVertexGeometry() const;
|
||||
const std::vector<TechDraw::VertexPtr> getVertexGeometry() const;
|
||||
const std::vector<TechDraw::BaseGeom*> getEdgeGeometry() const;
|
||||
const std::vector<TechDraw::BaseGeom*> getVisibleFaceEdges() const;
|
||||
const std::vector<TechDraw::Face*> getFaceGeometry() const;
|
||||
const std::vector<TechDraw::FacePtr> getFaceGeometry() const;
|
||||
|
||||
bool hasGeometry(void) const;
|
||||
TechDraw::GeometryObject* getGeometryObject(void) const { return geometryObject; }
|
||||
|
||||
TechDraw::BaseGeom* getGeomByIndex(int idx) const; //get existing geom for edge idx in projection
|
||||
TechDraw::Vertex* getProjVertexByIndex(int idx) const; //get existing geom for vertex idx in projection
|
||||
TechDraw::Vertex* getProjVertexByCosTag(std::string cosTag);
|
||||
TechDraw::VertexPtr getProjVertexByIndex(int idx) const; //get existing geom for vertex idx in projection
|
||||
TechDraw::VertexPtr getProjVertexByCosTag(std::string cosTag);
|
||||
std::vector<TechDraw::BaseGeom*> getFaceEdgesByIndex(int idx) const; //get edges for face idx in projection
|
||||
|
||||
virtual Base::BoundBox3d getBoundingBox() const;
|
||||
@@ -242,7 +242,7 @@ protected:
|
||||
bool prefIsoHid(void);
|
||||
int prefIsoCount(void);
|
||||
|
||||
std::vector<TechDraw::Vertex*> m_referenceVerts;
|
||||
std::vector<TechDraw::VertexPtr> m_referenceVerts;
|
||||
|
||||
private:
|
||||
bool nowUnsetting;
|
||||
|
||||
@@ -721,7 +721,7 @@ PyObject* DrawViewPartPy::getVertexByIndex(PyObject *args)
|
||||
|
||||
//this is scaled and +Yup
|
||||
//need unscaled and +Ydown
|
||||
TechDraw::Vertex* vert = dvp->getProjVertexByIndex(vertexIndex);
|
||||
TechDraw::VertexPtr vert = dvp->getProjVertexByIndex(vertexIndex);
|
||||
if (vert == nullptr) {
|
||||
throw Py::ValueError("wrong vertIndex");
|
||||
}
|
||||
@@ -772,7 +772,7 @@ PyObject* DrawViewPartPy::getVertexBySelection(PyObject *args)
|
||||
|
||||
//this is scaled and +Yup
|
||||
//need unscaled and +Ydown
|
||||
TechDraw::Vertex* vert = dvp->getProjVertexByIndex(vertexIndex);
|
||||
TechDraw::VertexPtr vert = dvp->getProjVertexByIndex(vertexIndex);
|
||||
if (vert == nullptr) {
|
||||
throw Py::ValueError("wrong vertIndex");
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape)
|
||||
for (; sectionExpl.More(); sectionExpl.Next()) {
|
||||
iface++;
|
||||
const TopoDS_Face& face = TopoDS::Face(sectionExpl.Current());
|
||||
TechDraw::Face* sectionFace = new TechDraw::Face();
|
||||
TechDraw::FacePtr sectionFace(std::make_shared<TechDraw::Face>());
|
||||
TopExp_Explorer expFace(face, TopAbs_WIRE);
|
||||
int iwire = 0;
|
||||
for ( ; expFace.More(); expFace.Next()) {
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
void sectionExec(TopoDS_Shape s);
|
||||
|
||||
std::vector<TechDraw::Face*> getTDFaceGeometry() {return tdSectionFaces;}
|
||||
std::vector<TechDraw::FacePtr> getTDFaceGeometry() {return tdSectionFaces;}
|
||||
|
||||
void setCSFromBase(const std::string sectionName);
|
||||
gp_Ax2 getCSFromBase(const std::string sectionName) const;
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
TechDraw::DrawViewPart* getBaseDVP() const;
|
||||
TechDraw::DrawProjGroupItem* getBaseDPGI() const;
|
||||
|
||||
TopoDS_Compound getSectionFaces() { return sectionFaces;};
|
||||
TopoDS_Compound getSectionFaces() { return sectionFaces;}
|
||||
// std::vector<TopoDS_Wire> getSectionFaceWires(void) { return sectionFaceWires; } //obs?
|
||||
TopoDS_Face getSectionTFace(int i);
|
||||
void makeLineSets(void) ;
|
||||
@@ -127,7 +127,7 @@ protected:
|
||||
TopoDS_Compound sectionFaces; //tSectionFaces
|
||||
// std::vector<TopoDS_Wire> sectionFaceWires; //obs??? getSectionFaceWires
|
||||
std::vector<LineSet> m_lineSets;
|
||||
std::vector<TechDraw::Face*> tdSectionFaces;
|
||||
std::vector<TechDraw::FacePtr> tdSectionFaces;
|
||||
|
||||
|
||||
gp_Pln getSectionPlane() const;
|
||||
|
||||
@@ -1447,10 +1447,10 @@ Vertex::Vertex(Base::Vector3d v) : Vertex(v.x,v.y)
|
||||
}
|
||||
|
||||
|
||||
bool Vertex::isEqual(Vertex* v, double tol)
|
||||
bool Vertex::isEqual(const Vertex& v, double tol)
|
||||
{
|
||||
bool result = false;
|
||||
double dist = (pnt - (v->pnt)).Length();
|
||||
double dist = (pnt - (v.pnt)).Length();
|
||||
if (dist <= tol) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace TechDraw {
|
||||
|
||||
enum ExtractionType { //obs
|
||||
@@ -297,6 +299,7 @@ class TechDrawExport Face
|
||||
TopoDS_Face toOccFace(void) const;
|
||||
std::vector<Wire *> wires;
|
||||
};
|
||||
using FacePtr = std::shared_ptr<Face>;
|
||||
|
||||
class TechDrawExport Vertex
|
||||
{
|
||||
@@ -317,7 +320,7 @@ class TechDrawExport Vertex
|
||||
int ref3D; //obs. never used.
|
||||
bool isCenter;
|
||||
TopoDS_Vertex occVertex;
|
||||
bool isEqual(Vertex* v, double tol);
|
||||
bool isEqual(const Vertex& v, double tol);
|
||||
Base::Vector3d point(void) const { return Base::Vector3d(pnt.x,pnt.y,0.0); }
|
||||
void point(Base::Vector3d v){ pnt = Base::Vector3d(v.x, v.y); }
|
||||
bool cosmetic;
|
||||
@@ -338,6 +341,7 @@ class TechDrawExport Vertex
|
||||
|
||||
boost::uuids::uuid tag;
|
||||
};
|
||||
using VertexPtr = std::shared_ptr<Vertex>;
|
||||
|
||||
/// Encapsulates some useful static methods
|
||||
class TechDrawExport GeometryUtils
|
||||
|
||||
@@ -155,16 +155,6 @@ void GeometryObject::clear()
|
||||
*it = 0;
|
||||
}
|
||||
|
||||
for(std::vector<Face *>::iterator it = faceGeom.begin(); it != faceGeom.end(); ++it) {
|
||||
delete *it;
|
||||
*it = 0;
|
||||
}
|
||||
|
||||
for(std::vector<Vertex *>::iterator it = vertexGeom.begin(); it != vertexGeom.end(); ++it) {
|
||||
delete *it;
|
||||
*it = 0;
|
||||
}
|
||||
|
||||
vertexGeom.clear();
|
||||
faceGeom.clear();
|
||||
edgeGeom.clear();
|
||||
@@ -523,26 +513,26 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
BaseGeom* lastAdded = edgeGeom.back();
|
||||
bool v1Add = true, v2Add = true;
|
||||
bool c1Add = true;
|
||||
TechDraw::Vertex* v1 = new TechDraw::Vertex(lastAdded->getStartPoint());
|
||||
TechDraw::Vertex* v2 = new TechDraw::Vertex(lastAdded->getEndPoint());
|
||||
TechDraw::VertexPtr v1 = std::make_shared<TechDraw::Vertex>(lastAdded->getStartPoint());
|
||||
TechDraw::VertexPtr v2 = std::make_shared<TechDraw::Vertex>(lastAdded->getEndPoint());
|
||||
TechDraw::Circle* circle = dynamic_cast<TechDraw::Circle*>(lastAdded);
|
||||
TechDraw::Vertex* c1 = nullptr;
|
||||
TechDraw::VertexPtr c1;
|
||||
if (circle) {
|
||||
c1 = new TechDraw::Vertex(circle->center);
|
||||
c1 = std::make_shared<TechDraw::Vertex>(circle->center);
|
||||
c1->isCenter = true;
|
||||
c1->hlrVisible = true;
|
||||
}
|
||||
|
||||
std::vector<Vertex *>::iterator itVertex = vertexGeom.begin();
|
||||
std::vector<VertexPtr>::iterator itVertex = vertexGeom.begin();
|
||||
for (; itVertex != vertexGeom.end(); itVertex++) {
|
||||
if ((*itVertex)->isEqual(v1,Precision::Confusion())) {
|
||||
if ((*itVertex)->isEqual(*v1,Precision::Confusion())) {
|
||||
v1Add = false;
|
||||
}
|
||||
if ((*itVertex)->isEqual(v2,Precision::Confusion())) {
|
||||
if ((*itVertex)->isEqual(*v2,Precision::Confusion())) {
|
||||
v2Add = false;
|
||||
}
|
||||
if (circle ) {
|
||||
if ((*itVertex)->isEqual(c1,Precision::Confusion())) {
|
||||
if ((*itVertex)->isEqual(*c1,Precision::Confusion())) {
|
||||
c1Add = false;
|
||||
}
|
||||
}
|
||||
@@ -552,13 +542,13 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
vertexGeom.push_back(v1);
|
||||
v1->hlrVisible = true;
|
||||
} else {
|
||||
delete v1;
|
||||
// delete v1;
|
||||
}
|
||||
if (v2Add) {
|
||||
vertexGeom.push_back(v2);
|
||||
v2->hlrVisible = true;
|
||||
} else {
|
||||
delete v2;
|
||||
// delete v2;
|
||||
}
|
||||
|
||||
if (circle) {
|
||||
@@ -566,14 +556,14 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
vertexGeom.push_back(c1);
|
||||
c1->hlrVisible = true;
|
||||
} else {
|
||||
delete c1;
|
||||
// delete c1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //end TopExp
|
||||
}
|
||||
|
||||
void GeometryObject::addVertex(TechDraw::Vertex* v)
|
||||
void GeometryObject::addVertex(TechDraw::VertexPtr v)
|
||||
{
|
||||
vertexGeom.push_back(v);
|
||||
}
|
||||
@@ -593,7 +583,7 @@ int GeometryObject::addCosmeticVertex(CosmeticVertex* cv)
|
||||
// Base::Console().Message("GO::addCosmeticVertex(%X)\n", cv);
|
||||
double scale = m_parent->getScale();
|
||||
Base::Vector3d pos = cv->scaled(scale);
|
||||
TechDraw::Vertex* v = new TechDraw::Vertex(pos.x, pos.y);
|
||||
TechDraw::VertexPtr v(std::make_shared<TechDraw::Vertex>(pos.x, pos.y));
|
||||
v->cosmetic = true;
|
||||
v->cosmeticLink = -1; //obs??
|
||||
v->cosmeticTag = cv->getTagAsString();
|
||||
@@ -608,7 +598,7 @@ int GeometryObject::addCosmeticVertex(CosmeticVertex* cv)
|
||||
int GeometryObject::addCosmeticVertex(Base::Vector3d pos)
|
||||
{
|
||||
Base::Console().Message("GO::addCosmeticVertex() 1 - deprec?\n");
|
||||
TechDraw::Vertex* v = new TechDraw::Vertex(pos.x, pos.y);
|
||||
TechDraw::VertexPtr v(std::make_shared<TechDraw::Vertex>(pos.x, pos.y));
|
||||
v->cosmetic = true;
|
||||
v->cosmeticTag = "tbi"; //not connected to CV
|
||||
v->hlrVisible = true;
|
||||
@@ -620,7 +610,7 @@ int GeometryObject::addCosmeticVertex(Base::Vector3d pos)
|
||||
int GeometryObject::addCosmeticVertex(Base::Vector3d pos, std::string tagString)
|
||||
{
|
||||
// Base::Console().Message("GO::addCosmeticVertex() 2\n");
|
||||
TechDraw::Vertex* v = new TechDraw::Vertex(pos.x, pos.y);
|
||||
TechDraw::VertexPtr v(std::make_shared<TechDraw::Vertex>(pos.x, pos.y));
|
||||
v->cosmetic = true;
|
||||
v->cosmeticTag = tagString; //connected to CV
|
||||
v->hlrVisible = true;
|
||||
@@ -720,7 +710,7 @@ void GeometryObject::clearFaceGeom()
|
||||
}
|
||||
|
||||
//! add a Face to Face Geometry
|
||||
void GeometryObject::addFaceGeom(Face* f)
|
||||
void GeometryObject::addFaceGeom(FacePtr f)
|
||||
{
|
||||
faceGeom.push_back(f);
|
||||
}
|
||||
@@ -802,8 +792,8 @@ Base::BoundBox3d GeometryObject::calcBoundingBox() const
|
||||
|
||||
void GeometryObject::pruneVertexGeom(Base::Vector3d center, double radius)
|
||||
{
|
||||
const std::vector<Vertex *>& oldVerts = getVertexGeometry();
|
||||
std::vector<Vertex *> newVerts;
|
||||
const std::vector<VertexPtr>& oldVerts = getVertexGeometry();
|
||||
std::vector<VertexPtr> newVerts;
|
||||
for (auto& v: oldVerts) {
|
||||
Base::Vector3d v3 = v->point();
|
||||
double length = (v3 - center).Length();
|
||||
@@ -820,7 +810,7 @@ void GeometryObject::pruneVertexGeom(Base::Vector3d center, double radius)
|
||||
bool GeometryObject::findVertex(Base::Vector3d v)
|
||||
{
|
||||
bool found = false;
|
||||
std::vector<Vertex*>::iterator it = vertexGeom.begin();
|
||||
std::vector<VertexPtr>::iterator it = vertexGeom.begin();
|
||||
for (; it != vertexGeom.end(); it++) {
|
||||
double dist = (v - (*it)->pnt).Length();
|
||||
if (dist < Precision::Confusion()) {
|
||||
|
||||
@@ -104,12 +104,12 @@ public:
|
||||
//! Returns 2D bounding box
|
||||
Base::BoundBox3d calcBoundingBox() const;
|
||||
|
||||
const std::vector<Vertex *> & getVertexGeometry() const { return vertexGeom; }
|
||||
const std::vector<VertexPtr> & getVertexGeometry() const { return vertexGeom; }
|
||||
const std::vector<BaseGeom *> & getEdgeGeometry() const { return edgeGeom; }
|
||||
const std::vector<BaseGeom *> getVisibleFaceEdges(bool smooth, bool seam) const;
|
||||
const std::vector<Face *> & getFaceGeometry() const { return faceGeom; }
|
||||
const std::vector<FacePtr> & getFaceGeometry() const { return faceGeom; }
|
||||
|
||||
void setVertexGeometry(std::vector<Vertex*> newVerts) {vertexGeom = newVerts; }
|
||||
void setVertexGeometry(std::vector<VertexPtr> newVerts) {vertexGeom = newVerts; }
|
||||
void setEdgeGeometry(std::vector<BaseGeom*> newGeoms) {edgeGeom = newGeoms; }
|
||||
|
||||
void projectShape(const TopoDS_Shape &input,
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
const gp_Ax2 &CS);
|
||||
|
||||
void extractGeometry(edgeClass category, bool visible);
|
||||
void addFaceGeom(Face * f);
|
||||
void addFaceGeom(FacePtr f);
|
||||
void clearFaceGeom();
|
||||
void setIsoCount(int i) { m_isoCount = i; }
|
||||
void setParentName(std::string n); //for debug messages
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
TopoDS_Shape getHidSeam(void) { return hidSeam; }
|
||||
TopoDS_Shape getHidIso(void) { return hidIso; }
|
||||
|
||||
void addVertex(TechDraw::Vertex* v);
|
||||
void addVertex(TechDraw::VertexPtr v);
|
||||
void addEdge(TechDraw::BaseGeom* bg);
|
||||
|
||||
|
||||
@@ -193,8 +193,8 @@ protected:
|
||||
|
||||
// Geometry
|
||||
std::vector<BaseGeom *> edgeGeom;
|
||||
std::vector<Vertex *> vertexGeom;
|
||||
std::vector<Face *> faceGeom;
|
||||
std::vector<VertexPtr> vertexGeom;
|
||||
std::vector<FacePtr> faceGeom;
|
||||
|
||||
bool findVertex(Base::Vector3d v);
|
||||
|
||||
|
||||
@@ -823,7 +823,7 @@ bool _checkDirectPlacement(const QGIViewPart *viewPart, const std::vector<std::s
|
||||
std::string geoType = TechDraw::DrawUtil::getGeomTypeFromName(subNames[0]);
|
||||
if (geoType == "Vertex") {
|
||||
int index = TechDraw::DrawUtil::getIndexFromName(subNames[0]);
|
||||
TechDraw::Vertex *vertex = static_cast<DrawViewPart *>(viewPart->getViewObject())->getProjVertexByIndex(index);
|
||||
TechDraw::VertexPtr vertex = static_cast<DrawViewPart *>(viewPart->getViewObject())->getProjVertexByIndex(index);
|
||||
if (vertex) {
|
||||
placement = viewPart->mapToScene(Rez::guiX(vertex->x()), Rez::guiX(vertex->y()));
|
||||
return true;
|
||||
|
||||
@@ -1094,7 +1094,7 @@ void execLine2Points(Gui::Command* cmd)
|
||||
if (!vertexNames.empty()) {
|
||||
for (auto& v2d: vertexNames) {
|
||||
int idx = DrawUtil::getIndexFromName(v2d);
|
||||
TechDraw::Vertex* v = baseFeat->getProjVertexByIndex(idx);
|
||||
TechDraw::VertexPtr v = baseFeat->getProjVertexByIndex(idx);
|
||||
if (v) {
|
||||
Base::Vector3d p = DrawUtil::invertY(v->pnt);
|
||||
points.push_back(p / scale);
|
||||
@@ -1213,7 +1213,7 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
|
||||
}
|
||||
}
|
||||
} else if (geomType == "Vertex") {
|
||||
TechDraw::Vertex* tdv = objFeat->getProjVertexByIndex(idx);
|
||||
TechDraw::VertexPtr tdv = objFeat->getProjVertexByIndex(idx);
|
||||
if (tdv != nullptr) {
|
||||
std::string delTag = tdv->cosmeticTag;
|
||||
if (!delTag.empty()) {
|
||||
|
||||
@@ -1610,7 +1610,7 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
if(SubNames.size() == 2) { //there are 2
|
||||
int eId,vId;
|
||||
TechDraw::BaseGeom* e;
|
||||
TechDraw::Vertex* v;
|
||||
TechDraw::VertexPtr v;
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex") {
|
||||
eId = TechDraw::DrawUtil::getIndexFromName(SubNames[0]);
|
||||
|
||||
@@ -470,8 +470,8 @@ void QGIViewPart::drawViewPart()
|
||||
// Draw Faces
|
||||
std::vector<TechDraw::DrawHatch*> hatchObjs = viewPart->getHatches();
|
||||
std::vector<TechDraw::DrawGeomHatch*> geomObjs = viewPart->getGeomHatches();
|
||||
const std::vector<TechDraw::Face *> &faceGeoms = viewPart->getFaceGeometry();
|
||||
std::vector<TechDraw::Face *>::const_iterator fit = faceGeoms.begin();
|
||||
const std::vector<TechDraw::FacePtr> &faceGeoms = viewPart->getFaceGeometry();
|
||||
std::vector<TechDraw::FacePtr>::const_iterator fit = faceGeoms.begin();
|
||||
for(int i = 0 ; fit != faceGeoms.end(); fit++, i++) {
|
||||
QGIFace* newFace = drawFace(*fit,i);
|
||||
newFace->isHatched(false);
|
||||
@@ -637,8 +637,8 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<TechDraw::Vertex *> &verts = viewPart->getVertexGeometry();
|
||||
std::vector<TechDraw::Vertex *>::const_iterator vert = verts.begin();
|
||||
const std::vector<TechDraw::VertexPtr> &verts = viewPart->getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr>::const_iterator vert = verts.begin();
|
||||
double cAdjust = vp->CenterScale.getValue();
|
||||
|
||||
for(int i = 0 ; vert != verts.end(); ++vert, i++) {
|
||||
@@ -711,7 +711,7 @@ bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item)
|
||||
return result;
|
||||
}
|
||||
|
||||
QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx)
|
||||
QGIFace* QGIViewPart::drawFace(TechDraw::FacePtr f, int idx)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::drawFace - %d\n", idx);
|
||||
std::vector<TechDraw::Wire *> fWires = f->wires;
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
protected:
|
||||
QPainterPath drawPainterPath(TechDraw::BaseGeom *baseGeom) const;
|
||||
void drawViewPart();
|
||||
QGIFace* drawFace(TechDraw::Face* f, int idx);
|
||||
QGIFace* drawFace(TechDraw::FacePtr f, int idx);
|
||||
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ void QGIViewSection::drawSectionFace()
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<TechDraw::Face *>::iterator fit = sectionFaces.begin();
|
||||
std::vector<TechDraw::FacePtr>::iterator fit = sectionFaces.begin();
|
||||
int i = 0;
|
||||
for(; fit != sectionFaces.end(); fit++, i++) {
|
||||
QGIFace* newFace = drawFace(*fit,-1);
|
||||
|
||||
Reference in New Issue
Block a user