diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index f34030644..9636d63c9 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -79,7 +79,6 @@ DrawView::~DrawView() App::DocumentObjectExecReturn *DrawView::execute(void) { - Base::Console().Message("TRACE - DV::execute\n"); TechDraw::DrawPage *page = findParentPage(); if(page) { if (ScaleType.isValue("Document")) { diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 6b53b1151..06b347d79 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -99,16 +99,18 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0) static const char *fgroup = "Format"; static const char *lgroup = "SectionLine"; - ADD_PROPERTY_TYPE(Direction ,(0,0,1.0) ,group,App::Prop_None,"Projection direction. The direction you are looking."); + //properties that affect Geometry ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"3D Shape to view"); - ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Hidden lines on/off"); - ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Smooth lines on/off"); - ADD_PROPERTY_TYPE(ShowSeamLines ,(false),group,App::Prop_None,"Seam lines on/off"); - //ADD_PROPERTY_TYPE(ShowIsoLines ,(false),group,App::Prop_None,"Iso u,v lines on/off"); - ADD_PROPERTY_TYPE(Tolerance,(0.05f),group,App::Prop_None,"Internal tolerance"); - Tolerance.setConstraints(&floatRange); + ADD_PROPERTY_TYPE(Direction ,(0,0,1.0) ,group,App::Prop_None,"Projection direction. The direction you are looking from."); ADD_PROPERTY_TYPE(XAxisDirection ,(1,0,0) ,group,App::Prop_None,"Where to place projection's XAxis (rotation)"); + ADD_PROPERTY_TYPE(Tolerance,(0.05f),group,App::Prop_None,"Internal tolerance for calculations"); + Tolerance.setConstraints(&floatRange); + //properties that affect Appearance + ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),fgroup,App::Prop_None,"Hidden lines on/off"); + ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),fgroup,App::Prop_None,"Smooth lines on/off"); + ADD_PROPERTY_TYPE(ShowSeamLines ,(false),fgroup,App::Prop_None,"Seam lines on/off"); + //ADD_PROPERTY_TYPE(ShowIsoLines ,(false),group,App::Prop_None,"Iso u,v lines on/off"); ADD_PROPERTY_TYPE(LineWidth,(0.7f),fgroup,App::Prop_None,"The thickness of visible lines"); ADD_PROPERTY_TYPE(HiddenWidth,(0.15),fgroup,App::Prop_None,"The thickness of hidden lines, if enabled"); ADD_PROPERTY_TYPE(ShowCenters ,(true),fgroup,App::Prop_None,"Center marks on/off"); @@ -116,12 +118,12 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0) ADD_PROPERTY_TYPE(HorizCenterLine ,(false),fgroup,App::Prop_None,"Show a horizontal centerline through view"); ADD_PROPERTY_TYPE(VertCenterLine ,(false),fgroup,App::Prop_None,"Show a vertical centerline through view"); + //properties that affect Section Line ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,lgroup,App::Prop_None,"Show/hide section line if applicable"); ADD_PROPERTY_TYPE(HorizSectionLine ,(true) ,lgroup,App::Prop_None,"Section line is horizontal"); ADD_PROPERTY_TYPE(ArrowUpSection ,(false) ,lgroup,App::Prop_None,"Section line arrows point up"); ADD_PROPERTY_TYPE(SymbolSection,("A") ,lgroup,App::Prop_None,"Section identifier"); - geometryObject = new TechDrawGeometry::GeometryObject(); } @@ -133,7 +135,6 @@ DrawViewPart::~DrawViewPart() App::DocumentObjectExecReturn *DrawViewPart::execute(void) { - //Base::Console().Message("TRACE - DVP::execute: %s\n",getNameInDocument()); App::DocumentObject *link = Source.getValue(); if (!link) { return new App::DocumentObjectExecReturn("FVP - No Source object linked"); @@ -175,15 +176,16 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void) return new App::DocumentObjectExecReturn(e->GetMessageString()); } + //TODO: not sure about this // There is a guaranteed change so check any references linked to this and touch // We need to update all views pointing at this (ProjectionGroup, ClipGroup, Section, etc) - std::vector parent = getInList(); - for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) { - TechDraw::DrawView *view = static_cast(*it); - view->touch(); - } - } +// std::vector parent = getInList(); +// for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { +// if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) { +// TechDraw::DrawView *view = static_cast(*it); +// view->touch(); +// } +// } return DrawView::execute(); } @@ -196,20 +198,22 @@ short DrawViewPart::mustExecute() const Source.isTouched() || Scale.isTouched() || ScaleType.isTouched() || - Tolerance.isTouched() || - ShowHiddenLines.isTouched() || - ShowSmoothLines.isTouched() || - ShowSeamLines.isTouched() || - LineWidth.isTouched() || - HiddenWidth.isTouched() || - ShowCenters.isTouched() || - CenterScale.isTouched() || - ShowSectionLine.isTouched() || - HorizSectionLine.isTouched() || - ArrowUpSection.isTouched() || - SymbolSection.isTouched() || - HorizCenterLine.isTouched() || - VertCenterLine.isTouched()); + Tolerance.isTouched()); + +// don't have to execute DVP, but should update Gui +// ShowHiddenLines.isTouched() || +// ShowSmoothLines.isTouched() || +// ShowSeamLines.isTouched() || +// LineWidth.isTouched() || +// HiddenWidth.isTouched() || +// ShowCenters.isTouched() || +// CenterScale.isTouched() || +// ShowSectionLine.isTouched() || +// HorizSectionLine.isTouched() || +// ArrowUpSection.isTouched() || +// SymbolSection.isTouched() || +// HorizCenterLine.isTouched() || +// VertCenterLine.isTouched()); } if (result) { @@ -228,20 +232,21 @@ void DrawViewPart::onChanged(const App::Property* prop) prop == &XAxisDirection || prop == &Source || prop == &Scale || - prop == &ScaleType || - prop == &ShowHiddenLines || - prop == &ShowSmoothLines || - prop == &ShowSeamLines || - prop == &LineWidth || - prop == &HiddenWidth || - prop == &ShowCenters || - prop == &CenterScale || - prop == &ShowSectionLine || - prop == &HorizSectionLine || - prop == &ArrowUpSection || - prop == &SymbolSection || - prop == &HorizCenterLine || - prop == &VertCenterLine) { + prop == &ScaleType) { +//don't need to execute, but need to update Gui +// prop == &ShowHiddenLines || +// prop == &ShowSmoothLines || +// prop == &ShowSeamLines || +// prop == &LineWidth || +// prop == &HiddenWidth || +// prop == &ShowCenters || +// prop == &CenterScale || +// prop == &ShowSectionLine || +// prop == &HorizSectionLine || +// prop == &ArrowUpSection || +// prop == &SymbolSection || +// prop == &HorizCenterLine || +// prop == &VertCenterLine) { try { App::DocumentObjectExecReturn *ret = recompute(); delete ret; @@ -258,36 +263,38 @@ void DrawViewPart::onChanged(const App::Property* prop) void DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Pnt& inputCenter) { Base::Vector3d baseProjDir = Direction.getValue(); + Base::Vector3d validXDir = getValidXDir(); saveParamSpace(baseProjDir, - getValidXDir()); + validXDir); geometryObject->projectShape(shape, inputCenter, Direction.getValue(), - getValidXDir()); + validXDir); + //TODO: why not be all line type in 1 call to extract geometry geometryObject->extractGeometry(TechDrawGeometry::ecHARD, true); geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE, true); - if (ShowSmoothLines.getValue()) { + //if (ShowSmoothLines.getValue()) { geometryObject->extractGeometry(TechDrawGeometry::ecSMOOTH, true); - } - if (ShowSeamLines.getValue()) { + //} + //if (ShowSeamLines.getValue()) { geometryObject->extractGeometry(TechDrawGeometry::ecSEAM, true); - } + //} //if (ShowIsoLines.getValue()) { // geometryObject->extractGeometry(TechDrawGeometry::ecUVISO, // true); //} - if (ShowHiddenLines.getValue()) { + //if (ShowHiddenLines.getValue()) { geometryObject->extractGeometry(TechDrawGeometry::ecHARD, false); //geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE, //hidden outline,smooth,seam?? // true); - } + //} bbox = geometryObject->calcBoundingBox(); } @@ -362,7 +369,7 @@ void DrawViewPart::extractFaces() // if we remove duplicates after sortstrip, then the outerWire won't be a duplicate // still ok as long as we draw biggest first? - std::vector sortedWires = ew.sortStrip(fw,false); //false==>do not include biggest wires + std::vector sortedWires = ew.sortStrip(fw,false); //false==>do not include OuterWire std::vector::iterator itWire = sortedWires.begin(); for (; itWire != sortedWires.end(); itWire++) { diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 91b33cb6e..073fa3524 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -80,18 +80,20 @@ PROPERTY_SOURCE(TechDraw::DrawViewSection, TechDraw::DrawViewPart) DrawViewSection::DrawViewSection() { static const char *sgroup = "Section"; - static const char *lgroup = "Line"; + static const char *fgroup = "Format"; + //static const char *lgroup = "Line"; Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CutSurfaceColor", 0xC8C8C800)); + ADD_PROPERTY_TYPE(BaseView ,(0),sgroup,App::Prop_None,"2D View with SectionLine"); ADD_PROPERTY_TYPE(SectionNormal ,(0,0,1.0) ,sgroup,App::Prop_None,"Section Plane normal direction"); //direction of extrusion of cutting prism ADD_PROPERTY_TYPE(SectionOrigin ,(0,0,0) ,sgroup,App::Prop_None,"Section Plane Origin"); - ADD_PROPERTY_TYPE(ShowCutSurface ,(true),sgroup,App::Prop_None,"Show the cut surface"); - ADD_PROPERTY_TYPE(CutSurfaceColor,(fcColor),sgroup,App::Prop_None,"The color to shade the cut surface"); - ADD_PROPERTY_TYPE(BaseView ,(0),lgroup,App::Prop_None,"2D View with SectionLine"); + ADD_PROPERTY_TYPE(ShowCutSurface ,(true),fgroup,App::Prop_None,"Show the cut surface"); + ADD_PROPERTY_TYPE(CutSurfaceColor,(fcColor),fgroup,App::Prop_None,"The color to shade the cut surface"); + geometryObject = new TechDrawGeometry::GeometryObject(); } @@ -106,13 +108,15 @@ short DrawViewSection::mustExecute() const if (!isRestoring()) { result = (Scale.isTouched() || ScaleType.isTouched() || + Direction.isTouched() || + XAxisDirection.isTouched() || BaseView.isTouched() || SectionNormal.isTouched() || - Direction.isTouched() || - SectionOrigin.isTouched() || - XAxisDirection.isTouched() || - ShowCutSurface.isTouched() || - CutSurfaceColor.isTouched() ); + SectionOrigin.isTouched() ); + +//don't need to execute, but need to update Gui +// ShowCutSurface.isTouched() || +// CutSurfaceColor.isTouched() ); } if (result) { return result; @@ -122,9 +126,6 @@ short DrawViewSection::mustExecute() const App::DocumentObjectExecReturn *DrawViewSection::execute(void) { - //Base::Console().Message("TRACE - DVS::execute: %s\n",getNameInDocument()); - //auto system_start = chrono::high_resolution_clock::now(); - App::DocumentObject* link = Source.getValue(); App::DocumentObject* base = BaseView.getValue(); if (!link || !base) { @@ -238,10 +239,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) std::string(e1->GetMessageString())); } - //auto diff = chrono::system_clock::now() - system_start; - //auto dur = chrono::duration_cast(diff); - //Base::Console().Message("TRACE - DVS::execute - took %.3f millisecs\n",dur.count()); - return DrawView::execute(); } @@ -379,37 +376,12 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face, // } // } -// std::vector uniqueVert = makeUniqueVList(faceEdges); -// std::vector walkerEdges = makeWalkerEdges(faceEdges,uniqueVert); - //recreate the wires for this single face EdgeWalker ew; ew.loadEdges(faceEdges); ew.perform(); std::vector fw = ew.getResultNoDups(); -// EdgeWalker ew; -// ew.setSize(uniqueVert.size()); -// ew.loadEdges(walkerEdges); -// ew.perform(); -// facelist result = ew.getResult(); - -//>>>>>>>>. result = TechDraw::EdgeWalker::removeDuplicateFaces(result); - -// facelist::iterator iFace = result.begin(); - -// std::vector fw; -// int dbi = 0; -// for (;iFace != result.end(); iFace++,dbi++) { -// edgelist::iterator iEdge = (*iFace).begin(); -// std::vector fe; -// for (;iEdge != (*iFace).end(); iEdge++) { -// fe.push_back(faceEdges.at((*iEdge).idx)); -// } -// TopoDS_Wire w = makeCleanWire(fe); -// fw.push_back(w); -// } - TopoDS_Face projectedFace; if (!fw.empty()) { diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index 3ffd09cad..8cdb06989 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -131,6 +131,10 @@ void GeometryObject::projectShape(const TopoDS_Shape& input, // Clear previous Geometry clear(); + //next 2 lines might make HLR quicker, but not dramatically + BRepMesh_IncrementalMesh(input, Tolerance); + BRepLib::BuildCurves3d(input); + Handle_HLRBRep_Algo brep_hlr = NULL; try { brep_hlr = new HLRBRep_Algo(); //leak? when does this get freed? handle/smart pointer? @@ -164,16 +168,17 @@ void GeometryObject::projectShape(const TopoDS_Shape& input, hidOutline = hlrToShape.OutLineHCompound(); hidIso = hlrToShape.IsoLineHCompound(); - BRepLib::BuildCurves3d(visHard); - BRepLib::BuildCurves3d(visSmooth); - BRepLib::BuildCurves3d(visSeam); - BRepLib::BuildCurves3d(visOutline); - BRepLib::BuildCurves3d(visIso); - BRepLib::BuildCurves3d(hidHard); - BRepLib::BuildCurves3d(hidSmooth); - BRepLib::BuildCurves3d(hidSeam); - BRepLib::BuildCurves3d(hidOutline); - BRepLib::BuildCurves3d(hidIso); +//just made 3d curves before starting HLR +// BRepLib::BuildCurves3d(visHard); +// BRepLib::BuildCurves3d(visSmooth); +// BRepLib::BuildCurves3d(visSeam); +// BRepLib::BuildCurves3d(visOutline); +// BRepLib::BuildCurves3d(visIso); +// BRepLib::BuildCurves3d(hidHard); +// BRepLib::BuildCurves3d(hidSmooth); +// BRepLib::BuildCurves3d(hidSeam); +// BRepLib::BuildCurves3d(hidOutline); +// BRepLib::BuildCurves3d(hidIso); } catch (...) { Standard_Failure::Raise("GeometryObject::projectShape - error occurred while extracting edges"); @@ -227,7 +232,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca } // build a mesh to explore the shape - BRepMesh_IncrementalMesh(edgeCompound, Tolerance); //no idea why we need to mesh shape + //BRepMesh_IncrementalMesh(edgeCompound, Tolerance); //TODO: is this needed? no idea why we need to mesh shape doesn't seem to change anything // Explore all edges of edgeCompound and calculate base geometry representation BaseGeom* base; @@ -261,14 +266,14 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca std::vector::iterator itVertex = vertexGeom.begin(); for (; itVertex != vertexGeom.end(); itVertex++) { - if ((*itVertex)->isEqual(v1,Tolerance)) { + if ((*itVertex)->isEqual(v1,Precision::Confusion())) { v1Add = false; } - if ((*itVertex)->isEqual(v2,Tolerance)) { + if ((*itVertex)->isEqual(v2,Precision::Confusion())) { v2Add = false; } if (circle) { - if ((*itVertex)->isEqual(c1,Tolerance)) { + if ((*itVertex)->isEqual(c1,Precision::Confusion())) { c1Add = true; } } diff --git a/src/Mod/TechDraw/Gui/QGIViewSection.cpp b/src/Mod/TechDraw/Gui/QGIViewSection.cpp index 7d6d41cfe..5a5469896 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSection.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSection.cpp @@ -92,7 +92,6 @@ void QGIViewSection::updateView(bool update) if( viewPart == nullptr ) { return; } - Base::Console().Message("TRACE - QGIVS::updateView(%d) - %s\n",update,getViewObject()->getNameInDocument()); if(update || viewPart->SectionNormal.isTouched() ||