Initial version of Cosmetic Eraser
This commit is contained in:
@@ -256,7 +256,6 @@ bool CosmeticEdge::fromCSV(std::string& lineSpec)
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = split(lineSpec);
|
||||
Base::Console().Message("CE::fromCSV - values: %d\n",values.size());
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "CosmeticEdge::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
@@ -293,7 +292,7 @@ bool CosmeticEdge::fromCSV(std::string& lineSpec)
|
||||
//duplicate of CV routine. make static? or base class?
|
||||
std::vector<std::string> CosmeticEdge::split(std::string csvLine)
|
||||
{
|
||||
Base::Console().Message("CE::split - csvLine: %s\n",csvLine.c_str());
|
||||
// Base::Console().Message("CE::split - csvLine: %s\n",csvLine.c_str());
|
||||
std::vector<std::string> result;
|
||||
std::stringstream lineStream(csvLine);
|
||||
std::string cell;
|
||||
|
||||
@@ -1019,8 +1019,13 @@ int DrawViewPart::addRandomVertex(Base::Vector3d pos)
|
||||
int newIdx = -1;
|
||||
TechDraw::CosmeticVertex* rVert = new TechDraw::CosmeticVertex(pos);
|
||||
cosmoVertex.push_back(rVert);
|
||||
stuffCosmeticVertexList();
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
//stuff stringList
|
||||
void DrawViewPart::stuffCosmeticVertexList(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::stuffCosmeticVertexList()\n");
|
||||
std::vector<std::string> saveVerts;
|
||||
const std::vector<TechDraw::CosmeticVertex*> cosVerts = getCosmeticVertex();
|
||||
for (auto& cv: cosVerts) {
|
||||
@@ -1028,18 +1033,50 @@ int DrawViewPart::addRandomVertex(Base::Vector3d pos)
|
||||
saveVerts.push_back(csv);
|
||||
}
|
||||
CosmeticVertexList.setValues(saveVerts);
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomVertex(TechDraw::CosmeticVertex* cv)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeRandomVertex(cv) - cvs in: %d\n", cosmoVertex.size());
|
||||
bool found = false;
|
||||
std::vector<TechDraw::CosmeticVertex*> newCosmoVertex;
|
||||
for (auto& v: cosmoVertex) {
|
||||
if (cv == v) {
|
||||
found = true;
|
||||
continue;
|
||||
} else {
|
||||
newCosmoVertex.push_back(v);
|
||||
}
|
||||
}
|
||||
if ( (cv != nullptr) &&
|
||||
(found) ) {
|
||||
delete cv;
|
||||
}
|
||||
|
||||
cosmoVertex = newCosmoVertex;
|
||||
stuffCosmeticVertexList();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomVertex(int idx)
|
||||
{
|
||||
if (idx < (int) cosmoVertex.size()) {
|
||||
TechDraw::CosmeticVertex* cvSave = cosmoVertex.at(idx);
|
||||
cosmoVertex.erase(cosmoVertex.begin() + idx);
|
||||
delete cvSave;
|
||||
}
|
||||
|
||||
stuffCosmeticVertexList();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByIndex(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticVertexByIndex(%d)\n", idx);
|
||||
int cosmoOffset = 1000;
|
||||
int realIdx = idx - cosmoOffset;
|
||||
CosmeticVertex* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticVertex*> verts = getCosmeticVertex();
|
||||
if ((unsigned) realIdx < verts.size()) {
|
||||
result = verts.at(realIdx);
|
||||
if ((unsigned) idx < verts.size()) {
|
||||
result = verts.at(idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1084,7 +1121,7 @@ int DrawViewPart::addRandomEdge(Base::Vector3d p1, Base::Vector3d p2)
|
||||
std::string csv = ce->toCSV();
|
||||
saveEdges.push_back(csv);
|
||||
}
|
||||
CosmeticEdgeList.setValues(saveEdges);
|
||||
stuffCosmeticEdgeList();
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
@@ -1094,15 +1131,7 @@ int DrawViewPart::addRandomEdge(TopoDS_Edge e)
|
||||
int newIdx = -1;
|
||||
TechDraw::CosmeticEdge* rEdge = new TechDraw::CosmeticEdge(e);
|
||||
cosmoEdge.push_back(rEdge);
|
||||
|
||||
//stuff stringList
|
||||
std::vector<std::string> saveEdges;
|
||||
const std::vector<TechDraw::CosmeticEdge*> cosEdges = getCosmeticEdge();
|
||||
for (auto& ce: cosEdges) {
|
||||
std::string csv = ce->toCSV();
|
||||
saveEdges.push_back(csv);
|
||||
}
|
||||
CosmeticEdgeList.setValues(saveEdges);
|
||||
stuffCosmeticEdgeList();
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
@@ -1111,8 +1140,13 @@ int DrawViewPart::addRandomEdge(CosmeticEdge* ce)
|
||||
// Base::Console().Message("DVP::addRandomEdge(CosmeticEdge)\n");
|
||||
int newIdx = -1;
|
||||
cosmoEdge.push_back(ce);
|
||||
stuffCosmeticEdgeList();
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
//stuff stringList
|
||||
void DrawViewPart::stuffCosmeticEdgeList(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::stuffCosmeticEdgeList()\n");
|
||||
std::vector<std::string> saveEdges;
|
||||
const std::vector<TechDraw::CosmeticEdge*> cosEdges = getCosmeticEdge();
|
||||
for (auto& ce: cosEdges) {
|
||||
@@ -1120,18 +1154,49 @@ int DrawViewPart::addRandomEdge(CosmeticEdge* ce)
|
||||
saveEdges.push_back(csv);
|
||||
}
|
||||
CosmeticEdgeList.setValues(saveEdges);
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomEdge(TechDraw::CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeRandomEdge(ce) - ces in: %d\n", cosmoEdge.size());
|
||||
bool found = false;
|
||||
std::vector<TechDraw::CosmeticEdge*> newCosmoEdge;
|
||||
for (auto& e: cosmoEdge) {
|
||||
if (ce == e) {
|
||||
found = true;
|
||||
continue;
|
||||
} else {
|
||||
newCosmoEdge.push_back(e);
|
||||
}
|
||||
}
|
||||
if ( (ce != nullptr) &&
|
||||
(found) ) {
|
||||
delete ce;
|
||||
}
|
||||
cosmoEdge = newCosmoEdge;
|
||||
stuffCosmeticEdgeList();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomEdge(int idx)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeRandomEdge(%d) - ces in: %d\n", idx, cosmoEdge.size());
|
||||
if (idx < (int) cosmoEdge.size()) {
|
||||
TechDraw::CosmeticEdge* ceSave = cosmoEdge.at(idx);
|
||||
cosmoEdge.erase(cosmoEdge.begin() + idx);
|
||||
delete ceSave;
|
||||
}
|
||||
stuffCosmeticEdgeList();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByIndex(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticEdgeByIndex(%d)\n", idx);
|
||||
int cosmoOffset = 1000;
|
||||
int realIdx = idx - cosmoOffset;
|
||||
CosmeticEdge* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdge();
|
||||
if ((unsigned) realIdx < edges.size()) {
|
||||
result = edges.at(realIdx);
|
||||
if (idx < (int) edges.size()) {
|
||||
result = edges.at(idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -168,6 +168,8 @@ public:
|
||||
bool isIso(void) const;
|
||||
|
||||
virtual int addRandomVertex(Base::Vector3d pos);
|
||||
virtual void removeRandomVertex(TechDraw::CosmeticVertex* cv);
|
||||
virtual void removeRandomVertex(int idx);
|
||||
const std::vector<TechDraw::CosmeticVertex*> & getCosmeticVertex(void) const { return cosmoVertex; }
|
||||
TechDraw::CosmeticVertex* getCosmeticVertexByIndex(int idx) const;
|
||||
TechDraw::CosmeticVertex* getCosmeticVertexByLink(int idx) const;
|
||||
@@ -176,6 +178,8 @@ public:
|
||||
virtual int addRandomEdge(Base::Vector3d start, Base::Vector3d end);
|
||||
virtual int addRandomEdge(TopoDS_Edge e);
|
||||
virtual int addRandomEdge(TechDraw::CosmeticEdge*);
|
||||
virtual void removeRandomEdge(TechDraw::CosmeticEdge* ce);
|
||||
virtual void removeRandomEdge(int idx);
|
||||
const std::vector<TechDraw::CosmeticEdge*> & getCosmeticEdge(void) const { return cosmoEdge; }
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByIndex(int idx) const;
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByLink(int idx) const;
|
||||
@@ -205,9 +209,12 @@ protected:
|
||||
//Cosmetics
|
||||
std::vector<TechDraw::CosmeticVertex*> cosmoVertex;
|
||||
void rebuildCosmoVertex(void);
|
||||
void stuffCosmeticVertexList(void);
|
||||
|
||||
std::vector<TechDraw::CosmeticEdge*> cosmoEdge;
|
||||
void rebuildCosmoEdge(void);
|
||||
void stuffCosmeticEdgeList(void);
|
||||
|
||||
|
||||
private:
|
||||
bool nowUnsetting;
|
||||
|
||||
@@ -481,6 +481,18 @@ int GeometryObject::addRandomVertex(Base::Vector3d pos)
|
||||
return idx;
|
||||
}
|
||||
|
||||
//void GeometryObject::removeRandomVertex(TechDraw::CosmeticVertex* cv)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomVertex(cv)\n");
|
||||
|
||||
//}
|
||||
|
||||
//void GeometryObject::removeRandomVertex(int idx)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomVertex(%d)\n", idx);
|
||||
|
||||
//}
|
||||
|
||||
int GeometryObject::addRandomEdge(TechDrawGeometry::BaseGeom* base)
|
||||
{
|
||||
// Base::Console().Message("GO::addRandomEdge() - cosmetic: %d\n", base->cosmetic);
|
||||
@@ -490,6 +502,18 @@ int GeometryObject::addRandomEdge(TechDrawGeometry::BaseGeom* base)
|
||||
return idx;
|
||||
}
|
||||
|
||||
//void GeometryObject::removeRandomEdge(TechDraw::CosmeticEdge* ce)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomEdge(ce)\n");
|
||||
|
||||
//}
|
||||
|
||||
//void GeometryObject::removeRandomEdge(int idx)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomEdge(%d)\n",idx);
|
||||
|
||||
//}
|
||||
|
||||
//! empty Face geometry
|
||||
void GeometryObject::clearFaceGeom()
|
||||
{
|
||||
|
||||
@@ -127,8 +127,13 @@ public:
|
||||
TopoDS_Shape getHidSeam(void) { return hidSeam; }
|
||||
TopoDS_Shape getHidIso(void) { return hidIso; }
|
||||
|
||||
//Are removeXXXXX functions really needed for GO?
|
||||
int addRandomVertex(Base::Vector3d pos);
|
||||
/* void removeRandomVertex(TechDraw::CosmeticVertex* cv);*/
|
||||
/* void removeRandomVertex(int idx);*/
|
||||
int addRandomEdge(TechDrawGeometry::BaseGeom* bg);
|
||||
/* void removeRandomEdge(TechDraw::CosmeticEdge* ce);*/
|
||||
/* void removeRandomEdge(int idx);*/
|
||||
|
||||
protected:
|
||||
//HLR output
|
||||
|
||||
Reference in New Issue
Block a user