PD: support of wires in ReferenceHighlighter
This commit is contained in:
@@ -40,6 +40,7 @@ ReferenceHighlighter::ReferenceHighlighter(const TopoDS_Shape& shape, const App:
|
||||
, objectColor(0.6f,0.0f,1.0f) // purple
|
||||
{
|
||||
TopExp::MapShapes(shape, TopAbs_EDGE, eMap);
|
||||
TopExp::MapShapes(shape, TopAbs_WIRE, wMap);
|
||||
TopExp::MapShapes(shape, TopAbs_FACE, fMap);
|
||||
}
|
||||
|
||||
@@ -52,6 +53,24 @@ void ReferenceHighlighter::getEdgeColor(const std::string& element, std::vector<
|
||||
colors[pos] = elementColor;
|
||||
}
|
||||
|
||||
void ReferenceHighlighter::getEdgeColorsOfWire(const std::string& element, std::vector<App::Color>& colors) const
|
||||
{
|
||||
int idx = std::stoi(element.substr(4));
|
||||
assert ( idx > 0 );
|
||||
// get the edges of the wire
|
||||
TopoDS_Shape wire = wMap.FindKey(idx);
|
||||
for (TopExp_Explorer xp(wire, TopAbs_EDGE); xp.More(); xp.Next()) {
|
||||
int edgeIndex = eMap.FindIndex(xp.Current());
|
||||
|
||||
// Edge found?
|
||||
if (edgeIndex > 0) {
|
||||
std::size_t pos = std::size_t(edgeIndex - 1);
|
||||
if (pos < colors.size())
|
||||
colors[pos] = elementColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReferenceHighlighter::getEdgeColorsOfFace(const std::string& element, std::vector<App::Color>& colors) const
|
||||
{
|
||||
int idx = std::stoi(element.substr(4));
|
||||
@@ -80,6 +99,9 @@ void ReferenceHighlighter::getEdgeColors(const std::vector<std::string>& element
|
||||
if (boost::starts_with(e, "Edge")) {
|
||||
getEdgeColor(e, colors);
|
||||
}
|
||||
else if (boost::starts_with(e, "Wire")) {
|
||||
getEdgeColorsOfWire(e, colors);
|
||||
}
|
||||
else if (boost::starts_with(e, "Face")) {
|
||||
getEdgeColorsOfFace(e, colors);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
|
||||
private:
|
||||
void getEdgeColor(const std::string& element, std::vector<App::Color>& colors) const;
|
||||
void getEdgeColorsOfWire(const std::string& element, std::vector<App::Color>& colors) const;
|
||||
void getEdgeColorsOfFace(const std::string& element, std::vector<App::Color>& colors) const;
|
||||
void getFaceColor(const std::string& element, std::vector<App::Color>& colors) const;
|
||||
|
||||
@@ -80,6 +81,7 @@ private:
|
||||
App::Color elementColor;
|
||||
App::Color objectColor;
|
||||
TopTools_IndexedMapOfShape eMap;
|
||||
TopTools_IndexedMapOfShape wMap;
|
||||
TopTools_IndexedMapOfShape fMap;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user