From 0ba5ae68bd48e77c0a6341e55d40530404e30c79 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 23 Mar 2015 11:57:19 +0300 Subject: [PATCH] Usage of constraint result functions instead of the builder --- src/Model/Model_AttributeSelection.cpp | 27 +++++++++++------------- src/ModuleBase/ModuleBase_ResultPrs.cpp | 14 +++++++----- src/SketchPlugin/SketchPlugin_Sketch.cpp | 3 --- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 03ccb8984..c09fff992 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -210,10 +209,12 @@ bool Model_AttributeSelection::update() } else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) { // construction: identification by the results indexes, recompute faces and // take the face that more close by the indexes - std::shared_ptr aWirePtr = - std::dynamic_pointer_cast( - std::dynamic_pointer_cast(aContext)->shape()); - if (aWirePtr && aWirePtr->hasPlane()) { // sketch sub-element + ResultConstructionPtr aConstructionContext = + std::dynamic_pointer_cast(aContext); + // sketch sub-element + if (aConstructionContext && + std::dynamic_pointer_cast(aContext).get()) + { TDF_Label aLab = myRef.myRef->Label(); // getting a type of selected shape Handle(TDataStd_Integer) aTypeAttr; @@ -236,15 +237,12 @@ bool Model_AttributeSelection::update() if (aShapeType == TopAbs_FACE) { // compound is for the whole sketch selection // If this is a wire with plane defined thin it is a sketch-like object - std::list > aFaces; - GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), - aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, aFaces); - if (aFaces.empty()) // no faces, update can not work correctly + if (!aConstructionContext->facesNum()) // no faces, update can not work correctly return false; // if there is no edges indexes, any face can be used: take the first std::shared_ptr aNewSelected; if (aNoIndexes) { - aNewSelected = *(aFaces.begin()); + aNewSelected = aConstructionContext->face(0); } else { // searching for most looks-like initial face by the indexes // prepare edges of the current resut for the fast searching TColStd_MapOfTransient allCurves; @@ -269,12 +267,11 @@ bool Model_AttributeSelection::update() } } } - // iterate new result faces and searching for these edges - std::list >::iterator aFacesIter = aFaces.begin(); double aBestFound = 0; // best percentage of found edges - for(; aFacesIter != aFaces.end(); aFacesIter++) { + for(int aFaceIndex = 0; aFaceIndex < aConstructionContext->facesNum(); aFaceIndex++) { int aFound = 0, aNotFound = 0; - TopExp_Explorer anEdgesExp((*aFacesIter)->impl(), TopAbs_EDGE); + TopExp_Explorer anEdgesExp( + aConstructionContext->face(aFaceIndex)->impl(), TopAbs_EDGE); for(; anEdgesExp.More(); anEdgesExp.Next()) { TopoDS_Edge anEdge = TopoDS::Edge(anEdgesExp.Current()); if (!anEdge.IsNull()) { @@ -291,7 +288,7 @@ bool Model_AttributeSelection::update() double aPercentage = double(aFound) / double(aFound + aNotFound); if (aPercentage > aBestFound) { aBestFound = aPercentage; - aNewSelected = *aFacesIter; + aNewSelected = aConstructionContext->face(aFaceIndex); } } } diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index a298dd297..d6bd0cde8 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -7,8 +7,8 @@ #include "ModuleBase_ResultPrs.h" #include +#include #include -#include #include #include @@ -43,11 +43,15 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t if (!aShapePtr) return; if (myIsSketchMode) { - std::shared_ptr aWirePtr = - std::dynamic_pointer_cast(aShapePtr); myFacesList.clear(); - GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), - aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList); + ResultConstructionPtr aConstruction = + std::dynamic_pointer_cast(myResult); + if (aConstruction.get()) { + int aFacesNum = aConstruction->facesNum(); + for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) { + myFacesList.push_back(aConstruction->face(aFaceIndex)); + } + } } myOriginalShape = aShapePtr->impl(); if (!myOriginalShape.IsNull()) { diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 466024127..2736bd848 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -118,9 +118,6 @@ void SketchPlugin_Sketch::execute() aBigWire->addEdge(*aShapeIt); } aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir()); - -// GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(), -// aFeaturesPreview, aLoops, aWires); std::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(aBigWire); setResult(aConstr); -- 2.39.2