[TD]remove unused code dvp & sections

This commit is contained in:
wandererfan
2023-07-04 15:38:22 -04:00
committed by WandererFan
parent 5df5be3774
commit 08237b6c2c
6 changed files with 256 additions and 405 deletions

View File

@@ -87,7 +87,6 @@ using DU = DrawUtil;
//===========================================================================
//PROPERTY_SOURCE(TechDraw::DrawViewPart, TechDraw::DrawView)
PROPERTY_SOURCE_WITH_EXTENSIONS(TechDraw::DrawViewPart, TechDraw::DrawView)
DrawViewPart::DrawViewPart(void)
@@ -101,42 +100,42 @@ DrawViewPart::DrawViewPart(void)
CosmeticExtension::initExtension(this);
double defDist = Preferences::getPreferenceGroup("General")->GetFloat("FocusDistance", 100.0);
//properties that affect Geometry
ADD_PROPERTY_TYPE(Source, (nullptr), group, App::Prop_None, "3D Shape to view");
Source.setScope(App::LinkScope::Global);
Source.setAllowExternal(true);
ADD_PROPERTY_TYPE(XSource, (nullptr), group, App::Prop_None, "External 3D Shape to view");
ADD_PROPERTY_TYPE(Direction, (0.0, -1.0, 0.0), group, App::Prop_None,
"Projection Plane normal. The direction you are looking from.");
ADD_PROPERTY_TYPE(XDirection, (0.0, 0.0, 0.0), group, App::Prop_None,
"Projection Plane X Axis in R3. Rotates/Mirrors View");
ADD_PROPERTY_TYPE(Perspective, (false), group, App::Prop_None,
"Perspective(true) or Orthographic(false) projection");
ADD_PROPERTY_TYPE(Focus, (defDist), group, App::Prop_None, "Perspective view focus distance");
ADD_PROPERTY_TYPE(Focus, (Preferences::getPreferenceGroup("General")->GetFloat("FocusDistance", 100.0)),
group, App::Prop_None, "Perspective view focus distance");
//properties that control HLR algo
bool coarseView = Preferences::getPreferenceGroup("General")->GetBool("CoarseView", false);
ADD_PROPERTY_TYPE(CoarseView, (coarseView), sgroup, App::Prop_None, "Coarse View on/off");
ADD_PROPERTY_TYPE(SmoothVisible, (prefSmoothViz()), sgroup, App::Prop_None,
"Show Visible Smooth lines");
ADD_PROPERTY_TYPE(SeamVisible, (prefSeamViz()), sgroup, App::Prop_None,
ADD_PROPERTY_TYPE(CoarseView, (Preferences::getPreferenceGroup("General")->GetBool("CoarseView", false)),
sgroup, App::Prop_None, "Coarse View on/off");
ADD_PROPERTY_TYPE(SmoothVisible, (Preferences::getPreferenceGroup("HLR")->GetBool("SmoothViz", true)),
sgroup, App::Prop_None, "Show Visible Smooth lines");
ADD_PROPERTY_TYPE(SeamVisible, (Preferences::getPreferenceGroup("HLR")->GetBool("SeamViz", false)),
sgroup, App::Prop_None,
"Show Visible Seam lines");
ADD_PROPERTY_TYPE(IsoVisible, (prefIsoViz()), sgroup, App::Prop_None,
"Show Visible Iso u, v lines");
ADD_PROPERTY_TYPE(HardHidden, (prefHardHid()), sgroup, App::Prop_None,
"Show Hidden Hard lines");
ADD_PROPERTY_TYPE(SmoothHidden, (prefSmoothHid()), sgroup, App::Prop_None,
"Show Hidden Smooth lines");
ADD_PROPERTY_TYPE(SeamHidden, (prefSeamHid()), sgroup, App::Prop_None,
"Show Hidden Seam lines");
ADD_PROPERTY_TYPE(IsoHidden, (prefIsoHid()), sgroup, App::Prop_None,
"Show Hidden Iso u, v lines");
ADD_PROPERTY_TYPE(IsoCount, (prefIsoCount()), sgroup, App::Prop_None,
"Number of iso parameters lines");
ADD_PROPERTY_TYPE(IsoVisible, (Preferences::getPreferenceGroup("HLR")->GetBool("IsoViz", false)),
sgroup, App::Prop_None, "Show Visible Iso u, v lines");
ADD_PROPERTY_TYPE(HardHidden, (Preferences::getPreferenceGroup("HLR")->GetBool("HardHid", false)),
sgroup, App::Prop_None, "Show Hidden Hard lines");
ADD_PROPERTY_TYPE(SmoothHidden, (Preferences::getPreferenceGroup("HLR")->GetBool("SmoothHid", false)),
sgroup, App::Prop_None, "Show Hidden Smooth lines");
ADD_PROPERTY_TYPE(SeamHidden, (Preferences::getPreferenceGroup("HLR")->GetBool("SeamHid", false)),
sgroup, App::Prop_None, "Show Hidden Seam lines");
ADD_PROPERTY_TYPE(IsoHidden, (Preferences::getPreferenceGroup("HLR")->GetBool("IsoHid", false)),
sgroup, App::Prop_None, "Show Hidden Iso u, v lines");
ADD_PROPERTY_TYPE(IsoCount, (Preferences::getPreferenceGroup("HLR")->GetBool("IsoCount", 0)),
sgroup, App::Prop_None, "Number of iso parameters lines");
ADD_PROPERTY_TYPE(ScrubCount, (Preferences::scrubCount()), sgroup, App::Prop_None,
"The number of times FreeCAD should try to clean the HLR result.");
@@ -158,43 +157,33 @@ DrawViewPart::~DrawViewPart()
removeAllReferencesFromGeom();
}
std::vector<TopoDS_Shape> DrawViewPart::getSourceShape2d() const
{
// Base::Console().Message("DVP::getSourceShape2d()\n");
const std::vector<App::DocumentObject*>& links = getAllSources();
return ShapeExtractor::getShapes2d(links);
}
TopoDS_Shape DrawViewPart::getSourceShape() const
TopoDS_Shape DrawViewPart::getSourceShape(bool fuse) const
{
// Base::Console().Message("DVP::getSourceShape()\n");
const std::vector<App::DocumentObject*>& links = getAllSources();
if (links.empty()) {
return TopoDS_Shape();
}
if (fuse) {
return ShapeExtractor::getShapesFused(links);
}
return ShapeExtractor::getShapes(links);
}
TopoDS_Shape DrawViewPart::getSourceShapeFused() const
{
// Base::Console().Message("DVP::getSourceShapeFused()\n");
const std::vector<App::DocumentObject*>& links = getAllSources();
if (links.empty()) {
return TopoDS_Shape();
}
return ShapeExtractor::getShapesFused(links);
}
// deliver a shape appropriate for making a detail view based on this view
// TODO: why does dvp do the thinking for detail, but section picks its own
// version of the shape? Should we have a getShapeForSection?
TopoDS_Shape DrawViewPart::getShapeForDetail() const
{
return TechDraw::rotateShape(getSourceShapeFused(), getProjectionCS(), Rotation.getValue());
return TechDraw::rotateShape(getSourceShape(true), getProjectionCS(), Rotation.getValue());
}
// combine the regular links and xlinks into a single list
std::vector<App::DocumentObject*> DrawViewPart::getAllSources() const
{
// Base::Console().Message("DVP::getAllSources()\n");
std::vector<App::DocumentObject*> links = Source.getValues();
std::vector<DocumentObject*> xLinks = XSource.getValues();
std::vector<App::DocumentObject*> xLinks = XSource.getValues();
std::vector<App::DocumentObject*> result = links;
if (!xLinks.empty()) {
@@ -207,7 +196,7 @@ std::vector<App::DocumentObject*> DrawViewPart::getAllSources() const
//add them directly to the geometry without going through HLR
void DrawViewPart::addShapes2d(void)
{
std::vector<TopoDS_Shape> shapes = getSourceShape2d();
std::vector<TopoDS_Shape> shapes = ShapeExtractor::getShapes2d(getAllSources());
for (auto& s : shapes) {
//just vertices for now
if (s.ShapeType() == TopAbs_VERTEX) {
@@ -220,17 +209,17 @@ void DrawViewPart::addShapes2d(void)
geometryObject->addVertex(v1);
}
else if (s.ShapeType() == TopAbs_EDGE) {
//not supporting edges yet.
// Base::Console().Message("DVP::add2dShapes - found loose edge - isNull: %d\n", s.IsNull());
// TopoDS_Shape sTrans = TechDraw::moveShape(s,
// m_saveCentroid * -1.0);
// TopoDS_Shape sScale = TechDraw::scaleShape(sTrans,
// getScale());
// TopoDS_Shape sMirror = TechDraw::mirrorShape(sScale);
// TopoDS_Edge edge = TopoDS::Edge(sMirror);
// BaseGeomPtr bg = projectEdge(edge);
//not supporting edges yet. Why?
//Base::Console().Message("DVP::add2dShapes - found loose edge - isNull: %d\n", s.IsNull());
TopoDS_Shape sTrans = TechDraw::moveShape(s,
m_saveCentroid * -1.0);
TopoDS_Shape sScale = TechDraw::scaleShape(sTrans,
getScale());
TopoDS_Shape sMirror = TechDraw::mirrorShape(sScale);
TopoDS_Edge edge = TopoDS::Edge(sMirror);
BaseGeomPtr bg = projectEdge(edge);
// geometryObject->addEdge(bg);
geometryObject->addEdge(bg);
//save connection between source feat and this edge
}
}
@@ -522,177 +511,188 @@ void DrawViewPart::extractFaces()
}
if (newFaceFinder()) {
std::vector<TopoDS_Edge> closedEdges;
std::vector<TopoDS_Edge> cleanEdges = DrawProjectSplit::scrubEdges(goEdges, closedEdges);
findFacesNew(goEdges);
} else {
findFacesOld(goEdges);
}
}
if (cleanEdges.empty() && closedEdges.empty()) {
//how does this happen? something wrong somewhere
// Base::Console().Message("DVP::extractFaces - no clean or closed wires\n"); //debug
return;
// use the revised face finder algo
void DrawViewPart::findFacesNew(const std::vector<BaseGeomPtr> &goEdges)
{
std::vector<TopoDS_Edge> closedEdges;
std::vector<TopoDS_Edge> cleanEdges = DrawProjectSplit::scrubEdges(goEdges, closedEdges);
if (cleanEdges.empty() && closedEdges.empty()) {
//how does this happen? something wrong somewhere
// Base::Console().Message("DVP::findFacesNew - no clean or closed wires\n"); //debug
return;
}
//use EdgeWalker to make wires from edges
EdgeWalker eWalker;
std::vector<TopoDS_Wire> sortedWires;
try {
if (!cleanEdges.empty()) {
sortedWires = eWalker.execute(cleanEdges, true);//include outer wire
}
}
catch (Base::Exception& e) {
throw Base::RuntimeError(e.what());
}
geometryObject->clearFaceGeom();
//use EdgeWalker to make wires from edges
EdgeWalker eWalker;
std::vector<TopoDS_Wire> sortedWires;
try {
if (!cleanEdges.empty()) {
sortedWires = eWalker.execute(cleanEdges, true);//include outer wire
std::vector<TopoDS_Wire> closedWires;
for (auto& e : closedEdges) {
BRepBuilderAPI_MakeWire mkWire(e);
TopoDS_Wire w = mkWire.Wire();
closedWires.push_back(w);
}
if (!closedWires.empty()) {
sortedWires.insert(sortedWires.end(), closedWires.begin(), closedWires.end());
//inserting the closedWires that did not go through EdgeWalker into
//sortedWires ruins EdgeWalker's sort by size, so we have to do it again.
sortedWires = eWalker.sortWiresBySize(sortedWires);
}
if (sortedWires.empty()) {
Base::Console().Warning(
"DVP::findFacesNew - %s - Can't make faces from projected edges\n",
getNameInDocument());
}
else {
constexpr double minWireArea = 0.000001;//arbitrary very small face size
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
for (; itWire != sortedWires.end(); itWire++) {
if (!BRep_Tool::IsClosed(*itWire)) {
continue;//can not make a face from open wire
}
}
catch (Base::Exception& e) {
throw Base::RuntimeError(e.what());
}
geometryObject->clearFaceGeom();
std::vector<TopoDS_Wire> closedWires;
for (auto& e : closedEdges) {
BRepBuilderAPI_MakeWire mkWire(e);
TopoDS_Wire w = mkWire.Wire();
closedWires.push_back(w);
}
if (!closedWires.empty()) {
sortedWires.insert(sortedWires.end(), closedWires.begin(), closedWires.end());
//inserting the closedWires that did not go through EdgeWalker into
//sortedWires ruins EdgeWalker's sort by size, so we have to do it again.
sortedWires = eWalker.sortWiresBySize(sortedWires);
}
double area = ShapeAnalysis::ContourArea(*itWire);
if (area <= minWireArea) {
continue;//can not make a face from wire with no area
}
if (sortedWires.empty()) {
Base::Console().Warning(
"DVP::extractFaces - %s - Can't make faces from projected edges\n",
getNameInDocument());
}
else {
constexpr double minWireArea = 0.000001;//arbitrary very small face size
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
for (; itWire != sortedWires.end(); itWire++) {
if (!BRep_Tool::IsClosed(*itWire)) {
continue;//can not make a face from open wire
}
double area = ShapeAnalysis::ContourArea(*itWire);
if (area <= minWireArea) {
continue;//can not make a face from wire with no area
}
TechDraw::FacePtr f(std::make_shared<TechDraw::Face>());
const TopoDS_Wire& wire = (*itWire);
f->wires.push_back(new TechDraw::Wire(wire));
if (geometryObject) {
geometryObject->addFaceGeom(f);
}
TechDraw::FacePtr f(std::make_shared<TechDraw::Face>());
const TopoDS_Wire& wire = (*itWire);
f->wires.push_back(new TechDraw::Wire(wire));
if (geometryObject) {
geometryObject->addFaceGeom(f);
}
}
}
else {//use original method
//make a copy of the input edges so the loose tolerances of face finding are
//not applied to the real edge geometry. See TopoDS_Shape::TShape().
std::vector<TopoDS_Edge> copyEdges;
bool copyGeometry = true;
bool copyMesh = false;
for (const auto& e : goEdges) {
BRepBuilderAPI_Copy copier(e->getOCCEdge(), copyGeometry, copyMesh);
copyEdges.push_back(TopoDS::Edge(copier.Shape()));
}
std::vector<TopoDS_Edge> nonZero;
for (auto& e : copyEdges) {//drop any zero edges (shouldn't be any by now!!!)
if (!DrawUtil::isZeroEdge(e)) {
nonZero.push_back(e);
}
}
}
//HLR algo does not provide all edge intersections for edge endpoints.
//need to split long edges touched by Vertex of another edge
std::vector<splitPoint> splits;
std::vector<TopoDS_Edge>::iterator itOuter = nonZero.begin();
int iOuter = 0;
for (; itOuter != nonZero.end(); ++itOuter, iOuter++) {//*** itOuter != nonZero.end() - 1
TopoDS_Vertex v1 = TopExp::FirstVertex((*itOuter));
TopoDS_Vertex v2 = TopExp::LastVertex((*itOuter));
Bnd_Box sOuter;
BRepBndLib::AddOptimal(*itOuter, sOuter);
sOuter.SetGap(0.1);
if (sOuter.IsVoid()) {
// original face finding method
void DrawViewPart::findFacesOld(const std::vector<BaseGeomPtr> &goEdges)
{
//make a copy of the input edges so the loose tolerances of face finding are
//not applied to the real edge geometry. See TopoDS_Shape::TShape().
std::vector<TopoDS_Edge> copyEdges;
bool copyGeometry = true;
bool copyMesh = false;
for (const auto& e : goEdges) {
BRepBuilderAPI_Copy copier(e->getOCCEdge(), copyGeometry, copyMesh);
copyEdges.push_back(TopoDS::Edge(copier.Shape()));
}
std::vector<TopoDS_Edge> nonZero;
for (auto& e : copyEdges) {//drop any zero edges (shouldn't be any by now!!!)
if (!DrawUtil::isZeroEdge(e)) {
nonZero.push_back(e);
}
}
//HLR algo does not provide all edge intersections for edge endpoints.
//need to split long edges touched by Vertex of another edge
std::vector<splitPoint> splits;
std::vector<TopoDS_Edge>::iterator itOuter = nonZero.begin();
int iOuter = 0;
for (; itOuter != nonZero.end(); ++itOuter, iOuter++) {//*** itOuter != nonZero.end() - 1
TopoDS_Vertex v1 = TopExp::FirstVertex((*itOuter));
TopoDS_Vertex v2 = TopExp::LastVertex((*itOuter));
Bnd_Box sOuter;
BRepBndLib::AddOptimal(*itOuter, sOuter);
sOuter.SetGap(0.1);
if (sOuter.IsVoid()) {
continue;
}
if (DrawUtil::isZeroEdge(*itOuter)) {
continue; //skip zero length edges. shouldn't happen ;)
}
int iInner = 0;
std::vector<TopoDS_Edge>::iterator itInner = nonZero.begin();//***sb itOuter + 1;
for (; itInner != nonZero.end(); ++itInner, iInner++) {
if (iInner == iOuter) {
continue;
}
if (DrawUtil::isZeroEdge(*itOuter)) {
continue; //skip zero length edges. shouldn't happen ;)
if (DrawUtil::isZeroEdge((*itInner))) {
continue;//skip zero length edges. shouldn't happen ;)
}
int iInner = 0;
std::vector<TopoDS_Edge>::iterator itInner = nonZero.begin();//***sb itOuter + 1;
for (; itInner != nonZero.end(); ++itInner, iInner++) {
if (iInner == iOuter) {
continue;
}
if (DrawUtil::isZeroEdge((*itInner))) {
continue;//skip zero length edges. shouldn't happen ;)
}
Bnd_Box sInner;
BRepBndLib::AddOptimal(*itInner, sInner);
sInner.SetGap(0.1);
if (sInner.IsVoid()) {
continue;
}
if (sOuter.IsOut(sInner)) {//bboxes of edges don't intersect, don't bother
continue;
}
Bnd_Box sInner;
BRepBndLib::AddOptimal(*itInner, sInner);
sInner.SetGap(0.1);
if (sInner.IsVoid()) {
continue;
}
if (sOuter.IsOut(sInner)) {//bboxes of edges don't intersect, don't bother
continue;
}
double param = -1;
if (DrawProjectSplit::isOnEdge((*itInner), v1, param, false)) {
gp_Pnt pnt1 = BRep_Tool::Pnt(v1);
splitPoint s1;
s1.i = iInner;
s1.v = Base::Vector3d(pnt1.X(), pnt1.Y(), pnt1.Z());
s1.param = param;
splits.push_back(s1);
}
if (DrawProjectSplit::isOnEdge((*itInner), v2, param, false)) {
gp_Pnt pnt2 = BRep_Tool::Pnt(v2);
splitPoint s2;
s2.i = iInner;
s2.v = Base::Vector3d(pnt2.X(), pnt2.Y(), pnt2.Z());
s2.param = param;
splits.push_back(s2);
}
}//inner loop
} //outer loop
double param = -1;
if (DrawProjectSplit::isOnEdge((*itInner), v1, param, false)) {
gp_Pnt pnt1 = BRep_Tool::Pnt(v1);
splitPoint s1;
s1.i = iInner;
s1.v = Base::Vector3d(pnt1.X(), pnt1.Y(), pnt1.Z());
s1.param = param;
splits.push_back(s1);
}
if (DrawProjectSplit::isOnEdge((*itInner), v2, param, false)) {
gp_Pnt pnt2 = BRep_Tool::Pnt(v2);
splitPoint s2;
s2.i = iInner;
s2.v = Base::Vector3d(pnt2.X(), pnt2.Y(), pnt2.Z());
s2.param = param;
splits.push_back(s2);
}
}//inner loop
} //outer loop
std::vector<splitPoint> sorted = DrawProjectSplit::sortSplits(splits, true);
auto last = std::unique(sorted.begin(), sorted.end(),
DrawProjectSplit::splitEqual);//duplicates to back
sorted.erase(last, sorted.end()); //remove dupl splits
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(nonZero, sorted);
std::vector<splitPoint> sorted = DrawProjectSplit::sortSplits(splits, true);
auto last = std::unique(sorted.begin(), sorted.end(),
DrawProjectSplit::splitEqual);//duplicates to back
sorted.erase(last, sorted.end()); //remove dupl splits
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(nonZero, sorted);
if (newEdges.empty()) {
return;
}
if (newEdges.empty()) {
return;
}
newEdges = DrawProjectSplit::removeDuplicateEdges(newEdges);
newEdges = DrawProjectSplit::removeDuplicateEdges(newEdges);
geometryObject->clearFaceGeom();
geometryObject->clearFaceGeom();
//find all the wires in the pile of faceEdges
std::vector<TopoDS_Wire> sortedWires;
EdgeWalker eWalker;
sortedWires = eWalker.execute(newEdges);
if (sortedWires.empty()) {
Base::Console().Warning(
"DVP::extractFaces - %s -Can't make faces from projected edges\n",
getNameInDocument());
return;
}
else {
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
for (; itWire != sortedWires.end(); itWire++) {
//version 1: 1 wire/face - no voids in 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);
if (geometryObject) {
geometryObject->addFaceGeom(f);
}
//find all the wires in the pile of faceEdges
std::vector<TopoDS_Wire> sortedWires;
EdgeWalker eWalker;
sortedWires = eWalker.execute(newEdges);
if (sortedWires.empty()) {
Base::Console().Warning(
"DVP::findFacesOld - %s -Can't make faces from projected edges\n",
getNameInDocument());
return;
}
else {
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
for (; itWire != sortedWires.end(); itWire++) {
//version 1: 1 wire/face - no voids in 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);
if (geometryObject) {
geometryObject->addFaceGeom(f);
}
}
}
@@ -956,7 +956,7 @@ QRectF DrawViewPart::getRect() const
}
//returns a compound of all the visible projected edges
TopoDS_Shape DrawViewPart::getShape() const
TopoDS_Shape DrawViewPart::getEdgeCompound() const
{
BRep_Builder builder;
TopoDS_Compound result;
@@ -982,17 +982,18 @@ TopoDS_Shape DrawViewPart::getShape() const
return TopoDS_Shape();
}
//returns the (unscaled) size of the visible lines along the alignment vector.
//alignment vector is already projected onto our CS, so only has X,Y components
// returns the (unscaled) size of the visible lines along the alignment vector.
// alignment vector is already projected onto our CS, so only has X,Y components
// used in calculating the length of a section line
double DrawViewPart::getSizeAlongVector(Base::Vector3d alignmentVector)
{
// Base::Console().Message("DVP::GetSizeAlongVector(%s)\n", DrawUtil::formatVector(alignmentVector).c_str());
double alignmentAngle = atan2(alignmentVector.y, alignmentVector.x) * -1.0;
gp_Ax2 OXYZ;//shape has already been projected and we will rotate around Z
if (getShape().IsNull()) {
if (getEdgeCompound().IsNull()) {
return 1.0;
}
TopoDS_Shape rotatedShape = rotateShape(getShape(), OXYZ, alignmentAngle * 180.0 / M_PI);
TopoDS_Shape rotatedShape = rotateShape(getEdgeCompound(), OXYZ, alignmentAngle * 180.0 / M_PI);
Bnd_Box shapeBox;
shapeBox.SetGap(0.0);
BRepBndLib::AddOptimal(rotatedShape, shapeBox);
@@ -1021,8 +1022,7 @@ Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt, bool invert)
return result;
}
//project a loose edge onto the paper plane
//TODO:: loose edges not supported yet
//project an edge onto the paper plane
BaseGeomPtr DrawViewPart::projectEdge(const TopoDS_Edge& e) const
{
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
@@ -1037,27 +1037,6 @@ BaseGeomPtr DrawViewPart::projectEdge(const TopoDS_Edge& e) const
return BaseGeom::baseFactory(TopoDS::Edge(s));
}
//simple projection of inWire with conversion of the result to TD geometry
BaseGeomPtrVector DrawViewPart::projectWire(const TopoDS_Wire& inWire) const
{
// Base::Console().Message("DVP::projectWire() - inWire.IsNull: %d\n", inWire.IsNull());
BaseGeomPtrVector result;
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
TopoDS_Face paper = BRepBuilderAPI_MakeFace(gp_Pln(getProjectionCS(stdOrg)));
BRepAlgo_NormalProjection projector(paper);
projector.Add(inWire);
projector.Build();
BRepTools::Write(projector.Projection(), "DVPprojectedWire.brep");//debug
TopExp_Explorer expShape(projector.Projection(), TopAbs_EDGE);
for (; expShape.More(); expShape.Next()) {
BaseGeomPtr edge = BaseGeom::baseFactory(TopoDS::Edge(expShape.Current()));
result.push_back(edge);
}
return result;
}
bool DrawViewPart::waitingForResult() const
{
if (waitingForHlr() || waitingForFaces()) {
@@ -1170,19 +1149,6 @@ Base::Vector3d DrawViewPart::getCurrentCentroid() const
return DU::toVector3d(gCenter);
}
Base::Vector3d DrawViewPart::getLocalOrigin3d() const
{
return getCurrentCentroid();
}
Base::Vector3d DrawViewPart::getLocalOrigin2d() const
{
Base::Vector3d centroid = getCurrentCentroid();
return projectPoint(centroid, false);
}
std::vector<DrawViewSection*> DrawViewPart::getSectionRefs() const
{
std::vector<DrawViewSection*> result;
@@ -1228,6 +1194,7 @@ bool DrawViewPart::newFaceFinder(void)
//! hatches, geomhatches, dimensions, ...
void DrawViewPart::unsetupObject()
{
// Base::Console().Message("DVP::unsetupObject()\n");
nowUnsetting = true;
App::Document* doc = getDocument();
std::string docName = doc->getName();
@@ -1283,17 +1250,6 @@ void DrawViewPart::unsetupObject()
}
}
//! is this an Isometric projection?
bool DrawViewPart::isIso() const
{
Base::Vector3d dir = Direction.getValue();
if (DrawUtil::fpCompare(fabs(dir.x), fabs(dir.y))
&& DrawUtil::fpCompare(fabs(dir.x), fabs(dir.z))) {
return true;
}
return false;
}
bool DrawViewPart::checkXDirection() const
{
// Base::Console().Message("DVP::checkXDirection()\n");
@@ -1650,58 +1606,6 @@ PyObject* DrawViewPart::getPyObject()
return Py::new_reference_to(PythonObject);
}
void DrawViewPart::handleChangedPropertyName(Base::XMLReader& reader, const char* TypeName,
const char* PropName)
{
// extHandleChangedPropertyName(reader, TypeName, PropName); // CosmeticExtension
DrawView::handleChangedPropertyName(reader, TypeName, PropName);
}
bool DrawViewPart::prefHardViz()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("HardViz", true);
}
bool DrawViewPart::prefSeamViz()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("SeamViz", false);
}
bool DrawViewPart::prefSmoothViz()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("SmoothViz", true);
}
bool DrawViewPart::prefIsoViz()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("IsoViz", false);
}
bool DrawViewPart::prefHardHid()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("HardHid", false);
}
bool DrawViewPart::prefSeamHid()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("SeamHid", false);
}
bool DrawViewPart::prefSmoothHid()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("SmoothHid", false);
}
bool DrawViewPart::prefIsoHid()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("IsoHid", false);
}
int DrawViewPart::prefIsoCount()
{
return Preferences::getPreferenceGroup("HLR")->GetBool("IsoCount", false);
}
// Python Drawing feature ---------------------------------------------------------
namespace App