[TD]code clean ups
- QtConcurrent include and CMake for Win - include clean up dvp, dvs, dvd - variable names and nested if clean up - remove debug code
This commit is contained in:
committed by
WandererFan
parent
459dde957c
commit
e97b95341a
@@ -26,60 +26,36 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
|
||||
#include "QtConcurrent/qtconcurrentrun.h"
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <BRepAlgo_NormalProjection.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLProp_CLProps.hxx>
|
||||
#include <BRepLProp_CurveTool.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <GeomLib_Tool.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <HLRAlgo_Projector.hxx>
|
||||
#include <HLRBRep_Algo.hxx>
|
||||
#include <HLRBRep_HLRToShape.hxx>
|
||||
#include <HLRBRep_ShapeBounds.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
#include <ShapeFix_ShapeTolerance.hxx>
|
||||
#include <ShapeFix_Wire.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <BRepAlgo_NormalProjection.hxx>
|
||||
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
@@ -90,11 +66,11 @@
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "Cosmetic.h"
|
||||
#include "DrawGeomHatch.h"
|
||||
#include "DrawHatch.h"
|
||||
@@ -104,15 +80,16 @@
|
||||
#include "DrawViewBalloon.h"
|
||||
#include "DrawViewDetail.h"
|
||||
#include "DrawViewDimension.h"
|
||||
#include "LandmarkDimension.h"
|
||||
#include "DrawViewPart.h"
|
||||
#include "DrawViewSection.h"
|
||||
#include "EdgeWalker.h"
|
||||
#include "Geometry.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "LandmarkDimension.h"
|
||||
#include "LineGroup.h"
|
||||
#include "Preferences.h"
|
||||
#include "ShapeExtractor.h"
|
||||
|
||||
#include "DrawViewPart.h"
|
||||
#include <Mod/TechDraw/App/DrawViewPartPy.h> // generated from DrawViewPartPy.xml
|
||||
|
||||
using namespace TechDraw;
|
||||
@@ -160,10 +137,9 @@ DrawViewPart::DrawViewPart(void) :
|
||||
"Perspective(true) or Orthographic(false) projection");
|
||||
ADD_PROPERTY_TYPE(Focus,(defDist),group,App::Prop_None,"Perspective view focus distance");
|
||||
|
||||
//properties that control HLR algoaffect Appearance
|
||||
//properties that control HLR algo
|
||||
bool coarseView = hGrp->GetBool("CoarseView", false);
|
||||
ADD_PROPERTY_TYPE(CoarseView, (coarseView), sgroup, App::Prop_None, "Coarse View on/off");
|
||||
//add property for visible outline?
|
||||
ADD_PROPERTY_TYPE(SmoothVisible ,(prefSmoothViz()),sgroup,App::Prop_None,"Show Visible Smooth lines");
|
||||
ADD_PROPERTY_TYPE(SeamVisible ,(prefSeamViz()),sgroup,App::Prop_None,"Show Visible Seam lines");
|
||||
ADD_PROPERTY_TYPE(IsoVisible ,(prefIsoViz()),sgroup,App::Prop_None,"Show Visible Iso u,v lines");
|
||||
@@ -173,7 +149,6 @@ DrawViewPart::DrawViewPart(void) :
|
||||
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");
|
||||
|
||||
geometryObject = nullptr;
|
||||
//initialize bbox to non-garbage
|
||||
bbox = Base::BoundBox3d(Base::Vector3d(0.0, 0.0, 0.0), 0.0);
|
||||
}
|
||||
@@ -193,55 +168,31 @@ std::vector<TopoDS_Shape> DrawViewPart::getSourceShape2d() const
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
TopoDS_Shape DrawViewPart::getSourceShape() const
|
||||
{
|
||||
// Base::Console().Message("DVP::getSourceShape()\n");
|
||||
TopoDS_Shape result;
|
||||
const std::vector<App::DocumentObject*>& links = getAllSources();
|
||||
if (links.empty()) {
|
||||
bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring);
|
||||
if (isRestoring) {
|
||||
Base::Console().Warning("DVP::getSourceShape - No Sources (but document is restoring) - %s\n",
|
||||
getNameInDocument());
|
||||
} else {
|
||||
Base::Console().Error("Error: DVP::getSourceShape - No Source(s) linked. - %s\n",
|
||||
getNameInDocument());
|
||||
}
|
||||
} else {
|
||||
result = ShapeExtractor::getShapes(links);
|
||||
if (!links.empty()) {
|
||||
return ShapeExtractor::getShapes(links);
|
||||
}
|
||||
return result;
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
TopoDS_Shape DrawViewPart::getSourceShapeFused() const
|
||||
{
|
||||
// Base::Console().Message("DVP::getSourceShapeFused()\n");
|
||||
TopoDS_Shape result;
|
||||
// const std::vector<App::DocumentObject*>& links = Source.getValues();
|
||||
const std::vector<App::DocumentObject*>& links = getAllSources();
|
||||
if (links.empty()) {
|
||||
bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring);
|
||||
if (isRestoring) {
|
||||
Base::Console().Warning("DVP::getSourceShape - No Sources (but document is restoring) - %s\n",
|
||||
getNameInDocument());
|
||||
} else {
|
||||
Base::Console().Error("Error: DVP::getSourceShape - No Source(s) linked. - %s\n",
|
||||
getNameInDocument());
|
||||
}
|
||||
} else {
|
||||
result = ShapeExtractor::getShapesFused(links);
|
||||
if (!links.empty()) {
|
||||
return ShapeExtractor::getShapesFused(links);
|
||||
}
|
||||
return result;
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> DrawViewPart::getAllSources() const
|
||||
{
|
||||
// Base::Console().Message("DVP::getAllSources()\n");
|
||||
const std::vector<App::DocumentObject*> links = Source.getValues();
|
||||
std::vector<App::DocumentObject*> links = Source.getValues();
|
||||
std::vector<DocumentObject*> xLinks = XSource.getValues();
|
||||
// std::vector<DocumentObject*> xLinks;
|
||||
// XSource.getLinks(xLinks);
|
||||
|
||||
std::vector<App::DocumentObject*> result = links;
|
||||
if (!xLinks.empty()) {
|
||||
@@ -250,6 +201,8 @@ std::vector<App::DocumentObject*> DrawViewPart::getAllSources() const
|
||||
return result;
|
||||
}
|
||||
|
||||
//pick supported 2d shapes out of the Source properties and
|
||||
//add them directly to the geometry without going through HLR
|
||||
void DrawViewPart::addShapes2d(void)
|
||||
{
|
||||
std::vector<TopoDS_Shape> shapes = getSourceShape2d();
|
||||
@@ -285,20 +238,13 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
// Base::Console().Message("DVP::execute() - %s\n", getNameInDocument());
|
||||
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
if (waitingForResult()) {
|
||||
if (waitingForHlr()) {
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
const std::vector<App::DocumentObject*>& links = getAllSources();
|
||||
if (links.empty()) {
|
||||
Base::Console().Log("DVP::execute - %s - No Source(s) linked.\n",
|
||||
getNameInDocument());
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
TopoDS_Shape shape = getSourceShape();
|
||||
if (shape.IsNull()) {
|
||||
Base::Console().Log("DVP::execute - %s - Source shape is Null.\n",
|
||||
@@ -306,58 +252,46 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
//make sure the XDirection property is valid. Mostly for older models.
|
||||
if (!checkXDirection()) {
|
||||
//block touch/onChanged stuff
|
||||
Base::Vector3d newX = getXDirection();
|
||||
XDirection.setValue(newX);
|
||||
XDirection.purgeTouched(); //don't trigger updates!
|
||||
//unblock
|
||||
}
|
||||
|
||||
m_saveShape = shape;
|
||||
partExec(shape);
|
||||
addShapes2d();
|
||||
|
||||
//second pass if required
|
||||
if (ScaleType.isValue("Automatic")) {
|
||||
if (!checkFit()) {
|
||||
double newScale = autoScale();
|
||||
Scale.setValue(newScale);
|
||||
Scale.purgeTouched();
|
||||
partExec(shape);
|
||||
}
|
||||
}
|
||||
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
short DrawViewPart::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Direction.isTouched() ||
|
||||
Source.isTouched() ||
|
||||
XSource.isTouched() ||
|
||||
Perspective.isTouched() ||
|
||||
Focus.isTouched() ||
|
||||
Rotation.isTouched() ||
|
||||
SmoothVisible.isTouched() ||
|
||||
SeamVisible.isTouched() ||
|
||||
IsoVisible.isTouched() ||
|
||||
HardHidden.isTouched() ||
|
||||
SmoothHidden.isTouched() ||
|
||||
SeamHidden.isTouched() ||
|
||||
IsoHidden.isTouched() ||
|
||||
IsoCount.isTouched() ||
|
||||
CoarseView.isTouched() ||
|
||||
CosmeticVertexes.isTouched() ||
|
||||
CosmeticEdges.isTouched() ||
|
||||
CenterLines.isTouched());
|
||||
if (isRestoring()) {
|
||||
return TechDraw::DrawView::mustExecute();
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
if (Direction.isTouched() ||
|
||||
Source.isTouched() ||
|
||||
XSource.isTouched() ||
|
||||
Perspective.isTouched() ||
|
||||
Focus.isTouched() ||
|
||||
Rotation.isTouched() ||
|
||||
SmoothVisible.isTouched() ||
|
||||
SeamVisible.isTouched() ||
|
||||
IsoVisible.isTouched() ||
|
||||
HardHidden.isTouched() ||
|
||||
SmoothHidden.isTouched() ||
|
||||
SeamHidden.isTouched() ||
|
||||
IsoHidden.isTouched() ||
|
||||
IsoCount.isTouched() ||
|
||||
CoarseView.isTouched() ||
|
||||
CosmeticVertexes.isTouched() ||
|
||||
CosmeticEdges.isTouched() ||
|
||||
CenterLines.isTouched()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return TechDraw::DrawView::mustExecute();
|
||||
}
|
||||
|
||||
@@ -377,8 +311,7 @@ void DrawViewPart::partExec(TopoDS_Shape& shape)
|
||||
{
|
||||
// Base::Console().Message("DVP::partExec()\n");
|
||||
if (waitingForHlr()) {
|
||||
//finish what we are already doing before starting over
|
||||
// Base::Console().Message("DVP::partExec - %s - waiting for HLR\n", getNameInDocument());
|
||||
//finish what we are already doing before starting a new cycle
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -386,13 +319,18 @@ void DrawViewPart::partExec(TopoDS_Shape& shape)
|
||||
delete geometryObject;
|
||||
geometryObject = nullptr;
|
||||
}
|
||||
|
||||
geometryObject = makeGeometryForShape(shape);
|
||||
if (CoarseView.getValue()){
|
||||
onHlrFinished(); //poly algo does not run in separate thread, so we need to invoke
|
||||
//the post hlr processing manually
|
||||
}
|
||||
}
|
||||
|
||||
//prepare the shape for HLR processing by centering, scaling and rotating it
|
||||
GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape& shape)
|
||||
{
|
||||
// Base::Console().Message("DVP::makeGeometryForShape()\n");
|
||||
// BRepTools::Write(shape, "DVPShape.brep"); //debug
|
||||
gp_Pnt inputCenter;
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
gp_Ax2 viewAxis = getProjectionCS(stdOrg);
|
||||
@@ -420,11 +358,12 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape& shape)
|
||||
return go;
|
||||
}
|
||||
|
||||
//note: slightly different than routine with same name in DrawProjectSplit
|
||||
//create a geometry object and trigger the HLR process in another thread
|
||||
TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape& shape, gp_Ax2& viewAxis)
|
||||
{
|
||||
// Base::Console().Message("DVP::buildGeometryObject() - %s\n", getNameInDocument());
|
||||
showProgressMessage(getNameInDocument(), "is finding hidden lines");
|
||||
|
||||
TechDraw::GeometryObject* go = new TechDraw::GeometryObject(getNameInDocument(), this);
|
||||
go->setIsoCount(IsoCount.getValue());
|
||||
go->isPerspective(Perspective.getValue());
|
||||
@@ -432,12 +371,12 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape& shape,
|
||||
go->usePolygonHLR(CoarseView.getValue());
|
||||
|
||||
if (CoarseView.getValue()){
|
||||
//the polygon approximation HLR process runs quickly, so doesn't need to be in a
|
||||
//separate thread
|
||||
go->projectShapeWithPolygonAlgo(shape,
|
||||
viewAxis);
|
||||
onHlrFinished(); //poly algo does not run in separate thread, so we need to invoke
|
||||
//the post hlr processing manually
|
||||
} else {
|
||||
//project shape runs in a separate thread since if can take a long time
|
||||
//projectShape (the HLR process) runs in a separate thread since it can take a long time
|
||||
QObject::connect(&m_hlrWatcher, SIGNAL(finished()), this, SLOT(onHlrFinished()));
|
||||
m_hlrFuture = QtConcurrent::run(go, &GeometryObject::projectShape, shape, viewAxis);
|
||||
m_hlrWatcher.setFuture(m_hlrFuture);
|
||||
@@ -450,21 +389,23 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape& shape,
|
||||
void DrawViewPart::onHlrFinished(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::onHlrFinished() - %s\n", getNameInDocument());
|
||||
//the last hlr task is to make a bbox of the results
|
||||
//the last hlr related task is to make a bbox of the results
|
||||
bbox = geometryObject->calcBoundingBox();
|
||||
|
||||
waitingForHlr(false);
|
||||
QObject::disconnect(&m_hlrWatcher, SIGNAL(finished()), this, SLOT(onHlrFinished()));
|
||||
showProgressMessage(getNameInDocument(), "has finished finding hidden lines");
|
||||
|
||||
postHlrTasks();
|
||||
postHlrTasks(); //application level tasks that depend on HLR/GO being complete
|
||||
|
||||
//start face finding in a separate thread
|
||||
//start face finding in a separate thread. We don't find faces when using the polygon
|
||||
//HLR method
|
||||
if (handleFaces() && !CoarseView.getValue() && !waitingForFaces()) {
|
||||
try {
|
||||
QObject::connect(&m_faceWatcher, SIGNAL(finished()), this, SLOT(onFacesFinished()));
|
||||
m_faceFuture = QtConcurrent::run(this, &DrawViewPart::extractFaces);
|
||||
m_faceWatcher.setFuture(m_faceFuture);
|
||||
waitingForFaces(true);
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
waitingForFaces(false);
|
||||
@@ -483,6 +424,7 @@ void DrawViewPart::postHlrTasks(void)
|
||||
addCosmeticEdgesToGeom();
|
||||
addCenterLinesToGeom();
|
||||
addReferencesToGeom();
|
||||
addShapes2d();
|
||||
|
||||
//dimensions and balloons need to be recomputed here because their
|
||||
//references will be invalid until the geometry exists
|
||||
@@ -495,42 +437,49 @@ void DrawViewPart::postHlrTasks(void)
|
||||
b->recomputeFeature();
|
||||
}
|
||||
|
||||
//second pass if required
|
||||
if (ScaleType.isValue("Automatic")) {
|
||||
if (!checkFit()) {
|
||||
double newScale = autoScale();
|
||||
Scale.setValue(newScale);
|
||||
Scale.purgeTouched();
|
||||
partExec(m_saveShape);
|
||||
}
|
||||
}
|
||||
|
||||
overrideKeepUpdated(false);
|
||||
|
||||
requestPaint();
|
||||
}
|
||||
|
||||
//! make faces from the existing edge geometry
|
||||
//! make faces from the edge geometry
|
||||
void DrawViewPart::extractFaces()
|
||||
{
|
||||
// Base::Console().Message("DVP::extractFaces()\n");
|
||||
|
||||
if (!geometryObject) {
|
||||
if (!geometryObject ||
|
||||
!this->hasGeometry()) {
|
||||
//no geometry yet so don't bother
|
||||
return;
|
||||
}
|
||||
|
||||
waitingForFaces(true);
|
||||
showProgressMessage(getNameInDocument(), "is extracting faces");
|
||||
|
||||
geometryObject->clearFaceGeom();
|
||||
const std::vector<TechDraw::BaseGeomPtr>& goEdges =
|
||||
geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
|
||||
std::vector<TechDraw::BaseGeomPtr>::const_iterator itEdge = goEdges.begin();
|
||||
|
||||
//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;
|
||||
for (;itEdge != goEdges.end(); itEdge++) {
|
||||
BRepBuilderAPI_Copy copier((*itEdge)->occEdge, true, true);
|
||||
for (auto& tdEdge: goEdges) {
|
||||
BRepBuilderAPI_Copy copier(tdEdge->occEdge, true, true); //copy occEdge with its geometry (TShape) and mesh info
|
||||
copyEdges.push_back(TopoDS::Edge(copier.Shape()));
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Edge> faceEdges;
|
||||
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);
|
||||
} else {
|
||||
Base::Console().Log("INFO - DVP::extractFaces for %s found ZeroEdge!\n",getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,18 +488,16 @@ void DrawViewPart::extractFaces()
|
||||
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
|
||||
for (; itOuter != nonZero.end(); ++itOuter, iOuter++) {
|
||||
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()) {
|
||||
Base::Console().Log("DVP::Extract Faces - outer Bnd_Box is void for %s\n",getNameInDocument());
|
||||
continue;
|
||||
}
|
||||
if (DrawUtil::isZeroEdge(*itOuter)) {
|
||||
Base::Console().Log("DVP::extractFaces - outerEdge: %d is ZeroEdge\n",iOuter); //this is not finding ZeroEdges
|
||||
continue; //skip zero length edges. shouldn't happen ;)
|
||||
}
|
||||
int iInner = 0;
|
||||
@@ -567,14 +514,13 @@ void DrawViewPart::extractFaces()
|
||||
BRepBndLib::AddOptimal(*itInner, sInner);
|
||||
sInner.SetGap(0.1);
|
||||
if (sInner.IsVoid()) {
|
||||
Base::Console().Log("INFO - DVP::Extract Faces - inner Bnd_Box is void for %s\n",getNameInDocument());
|
||||
continue;
|
||||
}
|
||||
if (sOuter.IsOut(sInner)) { //bboxes of edges don't intersect, don't bother
|
||||
continue;
|
||||
}
|
||||
|
||||
double param = -1;
|
||||
double param = -1; //parametric point on edge where the vertex touches
|
||||
if (DrawProjectSplit::isOnEdge((*itInner),v1,param,false)) {
|
||||
gp_Pnt pnt1 = BRep_Tool::Pnt(v1);
|
||||
splitPoint s1;
|
||||
@@ -594,17 +540,20 @@ void DrawViewPart::extractFaces()
|
||||
} //inner loop
|
||||
} //outer loop
|
||||
|
||||
//if edge A was touched at the same point by multiple edges B, we only want to split A once
|
||||
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
|
||||
sorted.erase(last, sorted.end()); //remove duplicate splits
|
||||
|
||||
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(nonZero,sorted);
|
||||
|
||||
if (newEdges.empty()) {
|
||||
Base::Console().Log("DVP::extractFaces - no newEdges\n");
|
||||
Base::Console().Log("DVP::extractFaces - no edges return by splitting process\n");
|
||||
waitingForFaces(false);
|
||||
return;
|
||||
}
|
||||
|
||||
//try to remove any duplicated edges since they will confuse the edgeWalker
|
||||
newEdges = DrawProjectSplit::removeDuplicateEdges(newEdges);
|
||||
|
||||
//find all the wires in the pile of faceEdges
|
||||
@@ -612,7 +561,7 @@ void DrawViewPart::extractFaces()
|
||||
ew.loadEdges(newEdges);
|
||||
bool success = ew.perform();
|
||||
if (!success) {
|
||||
Base::Console().Warning("DVP::extractFaces - %s -Can't make faces from projected edges\n", getNameInDocument());
|
||||
Base::Console().Warning("DVP::extractFaces - %s - Can't make faces from projected edges\n", getNameInDocument());
|
||||
waitingForFaces(false);
|
||||
return;
|
||||
}
|
||||
@@ -620,23 +569,19 @@ void DrawViewPart::extractFaces()
|
||||
|
||||
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw,true);
|
||||
|
||||
// int idb = 0;
|
||||
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
|
||||
for (; itWire != sortedWires.end(); itWire++) {
|
||||
//version 1: 1 wire/face - no voids in face
|
||||
//debug
|
||||
// std::stringstream ss;
|
||||
// ss << "DVPSWire" << idb << ".brep";
|
||||
// std::string wireName = ss.str();
|
||||
// BRepTools::Write((*itWire), wireName.c_str()); //debug
|
||||
//debug idb++;
|
||||
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);
|
||||
geometryObject->addFaceGeom(f);
|
||||
if (geometryObject) {
|
||||
//it can happen that a new hlr cycle deletes geometryObject while we are
|
||||
//extracting faces. if it does happen, a new cycle should fix it.
|
||||
geometryObject->addFaceGeom(f);
|
||||
}
|
||||
}
|
||||
waitingForFaces(false);
|
||||
}
|
||||
|
||||
//continue processing after extractFaces thread completes
|
||||
@@ -649,28 +594,30 @@ void DrawViewPart::onFacesFinished(void)
|
||||
requestPaint();
|
||||
}
|
||||
|
||||
//retrieve all the face hatches associated with this dvp
|
||||
std::vector<TechDraw::DrawHatch*> DrawViewPart::getHatches() const
|
||||
{
|
||||
std::vector<TechDraw::DrawHatch*> result;
|
||||
std::vector<App::DocumentObject*> children = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
if ( ((*it)->getTypeId().isDerivedFrom(DrawHatch::getClassTypeId())) &&
|
||||
(!(*it)->isRemoving()) ) {
|
||||
TechDraw::DrawHatch* hatch = dynamic_cast<TechDraw::DrawHatch*>(*it);
|
||||
for (auto& child: children) {
|
||||
if ( (child->getTypeId().isDerivedFrom(DrawHatch::getClassTypeId())) &&
|
||||
(!child->isRemoving()) ) {
|
||||
TechDraw::DrawHatch* hatch = dynamic_cast<TechDraw::DrawHatch*>(child);
|
||||
result.push_back(hatch);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//retrieve all the geometric hatches associated with this dvp
|
||||
std::vector<TechDraw::DrawGeomHatch*> DrawViewPart::getGeomHatches() const
|
||||
{
|
||||
std::vector<TechDraw::DrawGeomHatch*> result;
|
||||
std::vector<App::DocumentObject*> children = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
if ( ((*it)->getTypeId().isDerivedFrom(DrawGeomHatch::getClassTypeId())) &&
|
||||
(!(*it)->isRemoving()) ) {
|
||||
TechDraw::DrawGeomHatch* geom = dynamic_cast<TechDraw::DrawGeomHatch*>(*it);
|
||||
for (auto& child: children) {
|
||||
if ( (child->getTypeId().isDerivedFrom(DrawGeomHatch::getClassTypeId())) &&
|
||||
(!child->isRemoving()) ) {
|
||||
TechDraw::DrawGeomHatch* geom = dynamic_cast<TechDraw::DrawGeomHatch*>(child);
|
||||
result.push_back(geom);
|
||||
}
|
||||
}
|
||||
@@ -678,6 +625,8 @@ std::vector<TechDraw::DrawGeomHatch*> DrawViewPart::getGeomHatches() const
|
||||
}
|
||||
|
||||
//return *unique* list of Dimensions which reference this DVP
|
||||
//if the dimension has two references to this dvp, it will appear twice in
|
||||
//the inlist
|
||||
std::vector<TechDraw::DrawViewDimension*> DrawViewPart::getDimensions() const
|
||||
{
|
||||
std::vector<TechDraw::DrawViewDimension*> result;
|
||||
@@ -892,35 +841,31 @@ BaseGeomPtr DrawViewPart::projectEdge(const TopoDS_Edge& e) const
|
||||
|
||||
bool DrawViewPart::waitingForResult() const
|
||||
{
|
||||
bool result(false);
|
||||
if (waitingForHlr()) {
|
||||
result = true;
|
||||
if (waitingForHlr() ||
|
||||
waitingForFaces()) {
|
||||
return true;
|
||||
}
|
||||
// if (waitingForFaces()) {
|
||||
// result = true;
|
||||
// }
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DrawViewPart::hasGeometry(void) const
|
||||
{
|
||||
bool result = false;
|
||||
if (!geometryObject) {
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (waitingForResult()) {
|
||||
return result;
|
||||
if (waitingForHlr()) {
|
||||
return false;
|
||||
}
|
||||
const std::vector<TechDraw::VertexPtr> &verts = getVertexGeometry();
|
||||
const std::vector<TechDraw::BaseGeomPtr> &edges = getEdgeGeometry();
|
||||
if (verts.empty() &&
|
||||
edges.empty() ) {
|
||||
result = false;
|
||||
return false;
|
||||
} else {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
gp_Ax2 DrawViewPart::getProjectionCS(const Base::Vector3d pt) const
|
||||
|
||||
Reference in New Issue
Block a user