]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Usage of constraint result functions instead of the builder
authormpv <mpv@opencascade.com>
Mon, 23 Mar 2015 08:57:19 +0000 (11:57 +0300)
committermpv <mpv@opencascade.com>
Mon, 23 Mar 2015 08:57:19 +0000 (11:57 +0300)
src/Model/Model_AttributeSelection.cpp
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp

index 03ccb8984e47be420ea1d0c204d1374a0dc98cda..c09fff9920d521959be52a8b9072d5a0c4e47abe 100644 (file)
@@ -15,7 +15,6 @@
 #include <ModelAPI_CompositeFeature.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_PlanarEdges.h>
-#include <GeomAlgoAPI_SketchBuilder.h>
 #include <Events_Error.h>
 
 #include <TNaming_Selector.hxx>
@@ -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<GeomAPI_PlanarEdges> aWirePtr = 
-      std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext)->shape());
-    if (aWirePtr && aWirePtr->hasPlane()) { // sketch sub-element
+    ResultConstructionPtr aConstructionContext = 
+      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+    // sketch sub-element
+    if (aConstructionContext && 
+        std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(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<std::shared_ptr<GeomAPI_Shape> > 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<GeomAPI_Shape> 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<std::shared_ptr<GeomAPI_Shape> >::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<TopoDS_Shape>(), TopAbs_EDGE);
+            TopExp_Explorer anEdgesExp(
+              aConstructionContext->face(aFaceIndex)->impl<TopoDS_Shape>(), 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);
               }
             }
           }
index a298dd29723c13b92e42b45c7d781673d795f09c..d6bd0cde8de26c65ad5b9724683b1612ec4e7ced 100644 (file)
@@ -7,8 +7,8 @@
 #include "ModuleBase_ResultPrs.h"
 
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultConstruction.h>
 #include <GeomAPI_PlanarEdges.h>
-#include <GeomAlgoAPI_SketchBuilder.h>
 
 #include <BRep_Builder.hxx>
 #include <AIS_Drawer.hxx>
@@ -43,11 +43,15 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   if (!aShapePtr)
     return;
   if (myIsSketchMode) {
-    std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
-      std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
     myFacesList.clear();
-    GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
-      aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
+    ResultConstructionPtr aConstruction = 
+      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
+    if (aConstruction.get()) {
+      int aFacesNum = aConstruction->facesNum();
+      for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
+        myFacesList.push_back(aConstruction->face(aFaceIndex));
+      }
+    }
   }
   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
   if (!myOriginalShape.IsNull()) {
index 466024127b2af00ea9d0a95bf4ad70db9b187f26..2736bd84806caec3856fbf9d6500ac61c84f5807 100644 (file)
@@ -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<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
   aConstr->setShape(aBigWire);
   setResult(aConstr);