]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' into cgt/devCEA
authorClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 22 Mar 2017 07:52:20 +0000 (08:52 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 22 Mar 2017 07:52:20 +0000 (08:52 +0100)
98 files changed:
CMakeCommon/FindTInspector.cmake
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_Recover.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/Test/Test1942.py
src/GeomAPI/GeomAPI_Trsf.cpp
src/GeomValidators/GeomValidators_DifferentShapes.cpp
src/GeomValidators/GeomValidators_IntersectionSelection.cpp
src/InitializationPlugin/InitializationPlugin_EvalListener.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_Data.cpp
src/Model/Model_Document.cpp
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultPart.cpp
src/Model/Model_Session.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeSelectionList.h
src/ModelAPI/ModelAPI_Result.h
src/ModelAPI/ModelAPI_ResultPart.h
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModelAPI/Test/TestExternalConstruction.py [new file with mode: 0644]
src/ModelGeomAlgo/CMakeLists.txt
src/ModelGeomAlgo/ModelGeomAlgo_Point2D.cpp
src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp [new file with mode: 0644]
src/ModelGeomAlgo/ModelGeomAlgo_Shape.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_ParamIntSpinBox.cpp
src/ModuleBase/ModuleBase_ParamSpinBox.cpp
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ParametersPlugin/ParametersPlugin_EvalListener.cpp
src/PartSet/PartSet_ResultSketchPrs.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_WidgetFeaturePointSelector.cpp
src/PartSet/PartSet_WidgetFeaturePointSelector.h
src/PartSet/PartSet_WidgetSubShapeSelector.cpp
src/PythonAPI/Test/TestSketcherSetFillet.py
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Trim.cpp
src/SketchPlugin/SketchPlugin_Trim.h
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/Test/TestConstraintEqual.py
src/SketchPlugin/Test/TestFillet.py
src/SketchPlugin/Test/TestFilletInteracting.py
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/CMakeLists.txt
src/SketchSolver/PlaneGCSSolver/CMakeLists.txt
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ConstraintWrapper.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Defs.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EdgeWrapper.cpp [new file with mode: 0644]
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EdgeWrapper.h [new file with mode: 0644]
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityDestroyer.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.cpp [deleted file]
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_FeatureBuilder.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_PointWrapper.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ScalarWrapper.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.h
src/SketchSolver/SketchSolver.h [deleted file]
src/SketchSolver/SketchSolver_Constraint.h
src/SketchSolver/SketchSolver_ConstraintCoincidence.h
src/SketchSolver/SketchSolver_ConstraintCollinear.cpp
src/SketchSolver/SketchSolver_ConstraintDistance.h
src/SketchSolver/SketchSolver_ConstraintEqual.h
src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_ConstraintFixed.h
src/SketchSolver/SketchSolver_ConstraintLength.h
src/SketchSolver/SketchSolver_ConstraintMirror.h
src/SketchSolver/SketchSolver_ConstraintMulti.h
src/SketchSolver/SketchSolver_ConstraintMultiRotation.h
src/SketchSolver/SketchSolver_ConstraintMultiTranslation.h
src/SketchSolver/SketchSolver_ConstraintTangent.cpp
src/SketchSolver/SketchSolver_ConstraintTangent.h
src/SketchSolver/SketchSolver_IConstraintWrapper.h [deleted file]
src/SketchSolver/SketchSolver_IEntityWrapper.h [deleted file]
src/SketchSolver/SketchSolver_Manager.h
src/SketchSolver/SketchSolver_Storage.h
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Workshop.cpp
test.models/angle30.py
test.models/bearing_puller.py
test.models/case24.py
test.models/ecran.py
test.models/wheel_rim.py

index b553776237a723494a3d46fa6e97a1ad406d9793..7ba0468a23f8fd2e9a003ed6220a155b887e5001 100644 (file)
@@ -24,6 +24,12 @@ IF(EXISTS ${TINSPECTOR_ROOT_DIR})
     FIND_LIBRARY(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}")
     SET(TKVInspector ${TKVInspector})
 
+    FIND_LIBRARY(DFBrowserAPI DFBrowserAPI "${TINSPECTOR_LIB_DIR}")
+    SET(DFBrowserAPI ${DFBrowserAPI})
+
+    FIND_LIBRARY(TKDFTreeModel TKDFTreeModel "${TINSPECTOR_LIB_DIR}")
+    SET(TKDFTreeModel ${TKDFTreeModel})
+
   ENDIF(TKTInspector)
 
 ENDIF(EXISTS ${TINSPECTOR_ROOT_DIR})
index f3941ec119ccd981fffc79b2dd5907f6e1cf786f..2add72cf8504b66fd4a61eff070a4af77f0a7b35 100644 (file)
@@ -10,6 +10,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Session.h>
index f3dbf0683f8ddf50d20bef8e1d21c56a4022f1f9..de5a25f859071ac85ae8afbad5a5dee41da75238 100644 (file)
@@ -7,6 +7,7 @@
 #include "FeaturesPlugin_CompositeBoolean.h"
 
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_Tools.h>
 
 #include <GeomAlgoAPI_Boolean.h>
index 26023890ba26deff27198ee0ebaf1e614adfcb6f..7bddd8e176f83cfe7458ae27c14bfc110dcfcb2a 100644 (file)
@@ -11,6 +11,7 @@
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
index 4bbfd76e858d294d47999b3f45cff366337897a5..3e62ab7d064447cb76a512a02c4e66b78b792b36 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Result.h>
+#include <ModelAPI_ResultBody.h>
 #include <ModelAPI_Tools.h>
 #include <GeomAlgoAPI_Copy.h>
 
index 41e0468bee760c58dfddb50d989a01d5db5d995c..27b1b859161cfc7f921d12b39b9a49bad5d2c2c2 100755 (executable)
@@ -16,6 +16,7 @@
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
 
 #include <FeaturesPlugin_Tools.h>
 
index d254eeef70bc3e9ff461c135abc20d7a2a1b06d0..2c3bd6521cd85c24a0cd5864debab0733dd86f89 100644 (file)
@@ -12,6 +12,7 @@
 #include <GeomAPI_Face.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_Trsf.h>
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
index 34e5bd1122b2e1a642e6cfdfc82a0e07c7cb171a..74ff736adc6f907ac7e0221fd70feae58756d755 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
 
index 110f62e7e559ed93e58daa9a13d8cafc1207cc4e..006c614c1abc0c38a4f4dd98f9537948115ae5cd 100644 (file)
@@ -66,6 +66,7 @@ SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(
 SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_14")
 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 30)
 SketchArc_2 = Sketch_1.addArc(-8.152231059872202, 11.25015706261054, -38.72043789437247, 5.632510332222703, -20.37351638704503, 39.82660556161157, True)
+SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 30)
 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_2.endPoint())
 SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_15")
 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_2.result())
index f0df9471f0ecd3238bbfbf5ffcfed2345b502934..7246364f13031cf51b8f097f38c69c3be94be06e 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <gp_Ax1.hxx>
 #include <gp_Ax2.hxx>
+#include <gp_GTrsf.hxx>
 #include <gp_Trsf.hxx>
 
 #define MY_TRSF implPtr<gp_Trsf>()
index 01eb0409a75857c9c14d2d6614ebc9d804a80a5d..c9c16e663664611a04362fa14bcd0f1a3b949b04 100644 (file)
@@ -11,6 +11,8 @@
 #include <ModelAPI_AttributeSelection.h>
 #include "ModelAPI_Object.h"
 
+#include <GeomAPI_Shape.h>
+
 bool GeomValidators_DifferentShapes::isValid(const AttributePtr& theAttribute,
                                       const std::list<std::string>& theArguments,
                                       Events_InfoMessage& theError) const
index 7ecbf5f3876d67e136e604caf4076174cedeb992..5e72a378bf87965f770c7f9d5b34003494bccbe2 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "GeomValidators_IntersectionSelection.h"
 
+#include <GeomAPI_Shape.h>
+
 #include <Events_InfoMessage.h>
 
 #include <ModelAPI_AttributeInteger.h>
index 86d457a7327545cbbc2b8217898f1d1f6c827245..62698cd9277912a1a4b4365bc8fba9d880d523e5 100644 (file)
@@ -21,6 +21,7 @@
 #include <ModelAPI_AttributeValidator.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 
index 7af146794ad52f652bdbc4af3d557bcb55ab22e5..9ebc852596933efb58c8747649f55e09410b5e9e 100644 (file)
@@ -15,6 +15,7 @@
 #include <Model_ResultConstruction.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_CompositeFeature.h>
@@ -231,9 +232,8 @@ bool Model_AttributeSelection::isInitialized()
         if (aConstr.get()) {
           Handle(TDataStd_Integer) anIndex;
           if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) {
-            if (anIndex->Get() == 0) // it is just reference to construction, nothing is in value
-              return true;
-            return aConstr->shape(anIndex->Get(), owner()->document()).get() != NULL;
+            // for the whole shape it may return null, so, if index exists, returns true
+            return true;
           }
         }
       }
index 16e5d73dea22784bc3ebfadeb43c651c15cdb1d7..caaee41f407425e0767de254bfb905c8e4c3f496 100644 (file)
@@ -10,6 +10,8 @@
 #include "Model_Events.h"
 #include "Model_Data.h"
 
+#include <GeomAPI_Shape.h>
+
 #include <TDF_AttributeIterator.hxx>
 #include <TDF_ChildIterator.hxx>
 #include <TDF_RelocationTable.hxx>
index 2d28604bb0b2cf75fcf9d413484fac9bd7e80275..cbe96e2b3c043caf58214590311b078b170ec851 100644 (file)
@@ -302,6 +302,12 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
       if (myWasChangedButBlocked.empty() || *(myWasChangedButBlocked.rbegin()) != theAttr)
         myWasChangedButBlocked.push_back(theAttr);
     }
+  } else {
+    // trim: need to redisplay
+    if (myObject) {
+      static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+    }
   }
 }
 
index 8053271501061fbd29be22294447dda0dd1f9c26..d4e7b2d23a2bf5bdd88e30bd4fb5a62acf31ebc3 100755 (executable)
@@ -16,6 +16,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <Events_Loop.h>
 #include <Events_InfoMessage.h>
 
index 0cd0fd5d2a472092f02532c07451c2bb6349b5cb..216aab493f212dc73adad31d62856091a34a980f 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <Model_ResultBody.h>
 #include <Model_BodyBuilder.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_Tools.h>
 #include <Config_PropManager.h>
 #include <ModelAPI_Events.h>
index fa2767f9a45a8a7f195f90875411dcacc038ea4c..a9781e1f461114e5b39db8e7f6ee7055ea2becf0 100644 (file)
@@ -9,30 +9,35 @@
 #include <Model_Data.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <Model_SelectionNaming.h>
+#include <ModelAPI_Events.h>
 #include <Config_PropManager.h>
 #include <GeomAPI_PlanarEdges.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
 #include <Events_Loop.h>
-#include <ModelAPI_Events.h>
 
+#include <TDF_Reference.hxx>
 #include <TDF_ChildIterator.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Builder.hxx>
-#include <TopoDS_Shape.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_IntPackedMap.hxx>
 #include <TDataStd_Name.hxx>
+#include <TDataStd_UAttribute.hxx>
 #include <TColStd_MapOfTransient.hxx>
 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
 #include <BRep_Tool.hxx>
 #include <BRep_Builder.hxx>
 #include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopExp_Explorer.hxx>
 #include <Precision.hxx>
 
+// identifier that it is full result selected, but in external document (for internal index is 0)
+Standard_GUID kFULL_RESULT_ID("ee87e529-da6f-46af-be25-5e0fefde52f7");
+
 
 void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName,
                                        std::string& theDefault)
@@ -117,6 +122,7 @@ static const int kSTART_VERTEX_DELTA = 1000000;
 
 static void registerSubShape(TDF_Label theMainLabel, TopoDS_Shape theShape,
   const int theID, std::shared_ptr<Model_Document> theDoc,
+  bool theSelectionMode,
   std::map<int, int>& theOrientations,
   // name of sub-elements by ID to be exported instead of indexes
   std::map<int, std::string>& theSubNames,
@@ -128,7 +134,12 @@ static void registerSubShape(TDF_Label theMainLabel, TopoDS_Shape theShape,
     TDataStd_Integer::Set(aLab, theOrientation);
   }
   TNaming_Builder aBuilder(aLab);
-  aBuilder.Generated(theShape);
+  // wire never happens as sub, it must be generated to be found
+  // by SelectionNaming TNaming_Tool::NamedShape
+  if (theSelectionMode && theShape.ShapeType() != TopAbs_WIRE)
+    aBuilder.Select(theShape, theShape);
+  else
+    aBuilder.Generated(theShape);
   std::stringstream aName;
   // #1839 : do not store name of the feature in the tree, since this name could be changed
   //aName<<theContextFeature->name();
@@ -215,10 +226,53 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
 
   // set the naming structure at index
   TDF_Label aLab = aDataLab.FindChild(anIndex, Standard_True);
-  TNaming_Builder aBuilder(aLab);
-  if (aSubShape.IsNull())
-    return anIndex - 1; // just keep empty named shape
-  aBuilder.Generated(aSubShape);
+
+  // if the subshape is part of a result face, select the whole face (#1997)
+  bool isSelectionMode = false; // and other don't set shapes - all the naming is in face label
+  if (!aSubShape.IsNull() && aSubShape.ShapeType() > TopAbs_FACE) {
+    for(int aFaceIndex = 0; aFaceIndex < facesNum(); aFaceIndex++) {
+      TopExp_Explorer anExp(face(aFaceIndex)->impl<TopoDS_Shape>(), aSubShape.ShapeType());
+      for(; anExp.More(); anExp.Next()) {
+        if (aSubShape.IsSame(anExp.Current())) { // this is the case: select the whole face
+          // here just store the face index (to update face if update of edge is needed)
+          TNaming_Builder aBuilder(aLab);
+          aBuilder.Select(aSubShape, aSubShape);
+          int aFaceSelID = select(face(aFaceIndex), theExtDoc, -1);
+          TDF_Reference::Set(aLab, aLab.Father().FindChild(aFaceSelID));
+          isSelectionMode = true;
+          break;
+        }
+      }
+    }
+  }
+
+  // external full result is not identified by index == 0, so, add here the ID
+  if (!theSubShape.get()) {
+    TDataStd_UAttribute::Set(aLab, kFULL_RESULT_ID);
+    // empty NS
+    TNaming_Builder aBuilder(aLab);
+    // store all sub-faces naming since faces may be used for extrusion, where all edges are needed
+    Handle(TDataStd_IntPackedMap) anIndices = TDataStd_IntPackedMap::Set(aLab);
+    std::list<int> aFacesIndexes;
+    for(int a = 0; a < facesNum(); a++) {
+      anIndices->Add(select(face(a), theExtDoc, -1));
+    }
+    return anIndex - 1;
+  }
+
+  { // this to have erased Builder after the shape was generated (NS on this label may be changed)
+    TNaming_Builder aBuilder(aLab);
+    if (aSubShape.IsNull()) {
+      return anIndex - 1; // just keep empty named shape
+    }
+    // wire never happens as sub, it must be generated to be found
+    // by SelectionNaming TNaming_Tool::NamedShape
+    if (isSelectionMode && aSubShape.ShapeType() != TopAbs_WIRE) {
+      aBuilder.Select(aSubShape, aSubShape);
+    } else {
+      aBuilder.Generated(aSubShape);
+    }
+  }
 
   if (anIndex == 1 && isInfinite()) { // infinitive results has no sub-selection
     return anIndex - 1;
@@ -231,6 +285,7 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
     // saving of context is enough: result construction contains exactly the needed shape
     return anIndex - 1;
   }
+
   // identify the results of sub-object of the composite by edges
   // save type of the selected shape in integer attribute
   TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType();
@@ -313,7 +368,10 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
                     TDF_Label aSubLab = aLab.FindChild(anID);
                     std::string aName = "Edge-" + Model_SelectionNaming::shortName(aConstr, 0);
                     TNaming_Builder aBuilder(aSubLab);
-                    aBuilder.Generated(anEdge);
+                    if (isSelectionMode)
+                      aBuilder.Select(anEdge, anEdge);
+                    else
+                      aBuilder.Generated(anEdge);
                     aMyDoc->addNamingName(aSubLab, aName.c_str());
                     TDataStd_Name::Set(aSubLab, aName.c_str());
 
@@ -338,7 +396,10 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
                   std::string aName = "Vertex-"
                       + Model_SelectionNaming::shortName(aConstr, aDelta / kSTART_VERTEX_DELTA);
                   TNaming_Builder aBuilder(aLab);
-                  aBuilder.Generated(aV);
+                  if (isSelectionMode)
+                    aBuilder.Select(aV, aV);
+                  else
+                    aBuilder.Generated(aV);
                   aMyDoc->addNamingName(aLab, aName.c_str());
                   TDataStd_Name::Set(aLab, aName.c_str());
                 }
@@ -350,8 +411,7 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
     }
   }
   // store the selected as primitive
-  registerSubShape(aLab, aSubShape, 0, aMyDoc, anOrientations, aSubNames, aRefs);
-
+  registerSubShape(aLab, aSubShape, 0, aMyDoc, isSelectionMode, anOrientations, aSubNames, aRefs);
   return anIndex - 1;
 }
 
@@ -368,6 +428,8 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultConstruction::shape(const int theInde
     Handle(TNaming_NamedShape) aSelection;
     if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
       TopoDS_Shape aSelShape = aSelection->Get();
+      if (aSelShape.IsNull())
+        return aResult; // shape equal to context => null
       aResult = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
       aResult->setImpl(new TopoDS_Shape(aSelShape));
     }
@@ -382,20 +444,21 @@ bool Model_ResultConstruction::update(const int theIndex,
   theModified = false;
   bool anExt;
   TDF_Label aLab = startLabel(theExtDoc, anExt).FindChild(theIndex + 1, Standard_True);
-  if (theIndex == 0) {
+  if (theIndex == 0 || aLab.IsAttribute(kFULL_RESULT_ID)) { // full for external same as index == 0
     // it is just reference to construction, not sub-shape
     // if there is a sketch, the sketch-naming must be updated
     if (!isInfinite()) {
-      BRep_Builder aCompoundBuilder;
-      TopoDS_Compound aComp;
-      aCompoundBuilder.MakeCompound(aComp);
-      for(int a = 0; a < facesNum(); a++) {
-        TopoDS_Shape aFace = face(a)->impl<TopoDS_Shape>();
-        aCompoundBuilder.Add(aComp, aFace);
+      // update all faces named by the whole result
+      bool aRes = true;
+      Handle(TDataStd_IntPackedMap) anIndices;
+      if (aLab.FindAttribute(TDataStd_IntPackedMap::GetID(), anIndices)) {
+        TColStd_MapIteratorOfPackedMapOfInteger anIndexIter(anIndices->GetMap());
+        for(; anIndexIter.More(); anIndexIter.Next()) {
+          if (!update(anIndexIter.Key(), theExtDoc, theModified))
+            aRes = false;
+        }
       }
-      std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
-      aShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aComp));
-      select(aShape, theExtDoc, theIndex);
+      return aRes;
     } else {
       // For correct naming selection, put the shape into the naming structure.
       // It seems sub-shapes are not needed: only this shape is (and can be ) selected.
@@ -408,9 +471,17 @@ bool Model_ResultConstruction::update(const int theIndex,
   // take the face that more close by the indexes
   ResultPtr aThisPtr = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
   FeaturePtr aContextFeature = document()->feature(aThisPtr);
+
   // sketch sub-element
   if (std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature).get())
   {
+    // update the referenced object if it is sub
+    Handle(TDF_Reference) aRef;
+    if (aLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
+      int aFaceIndex = aRef->Get().Tag();
+      // don't check selection ,since face may disappear, but the shape stays correct
+      Model_ResultConstruction::update(aFaceIndex, theExtDoc, theModified);
+    }
     // getting a type of selected shape
     Handle(TDataStd_Integer) aTypeAttr;
     if (!aLab.FindAttribute(TDataStd_Integer::GetID(), aTypeAttr)) {
index 74e2b22a19b74419e14c219b339ebe9bcf86744b..d3057534885e8e2b932c72a92b7451e862b12622 100644 (file)
@@ -20,6 +20,8 @@
 #include <Events_Loop.h>
 #include <ModelAPI_Events.h>
 
+#include <GeomAPI_Trsf.h>
+
 #include <TNaming_Tool.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TDataStd_Name.hxx>
index 44fcf4f18ac1086e0ca1d1b7357814c88cb09aa6..924783bb25e1955dd2ce3dbe4fda71cd65b2e054 100644 (file)
@@ -21,6 +21,8 @@
 #include <Config_ValidatorMessage.h>
 #include <Config_ModuleReader.h>
 #include <Config_ValidatorReader.h>
+
+#include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_Tools.h>
 
index 198696aefb5054d215f0cfeb7a9f8b14a8d7a20a..e227fdeab8cc997ed36f174bf68b86fa0830cfc4 100644 (file)
@@ -143,4 +143,5 @@ ADD_UNIT_TESTS(TestConstants.py
                Test1757.py
                Test1998.py
                Test1995.py
+               TestExternalConstruction.py
 )
index c5fe4c9349c007dd198181777c11c846187825ee..cdcff39d545969b2e71cf32248d5e5fec186e637 100644 (file)
@@ -10,6 +10,8 @@
 #include "ModelAPI_AttributeSelection.h"
 #include <ModelAPI_Result.h>
 
+class GeomAPI_Shape;
+
 /**\class ModelAPI_AttributeSelectionList
  * \ingroup DataModel
  * \brief Attribute that contains list of references to the sub-shapes with
@@ -25,7 +27,7 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute
   /// \param theTemporarily if it is true, do not store and name the added in the data framework
   ///           (used to remove immediately, without the following updates)
   virtual void append(const ResultPtr& theContext,
-                      const GeomShapePtr& theSubShape,
+                      const std::shared_ptr<GeomAPI_Shape>& theSubShape,
                       const bool theTemporarily = false) = 0;
 
   /// Adds the new reference to the end of the list by the naming name of the selected shape
index 3f30c57c7ced69f322ed942666723156a8bdaa82..2b86eaa4f08fc8e237d162be93d6e37bd0560a61 100644 (file)
@@ -8,7 +8,7 @@
 #define ModelAPI_Result_H_
 
 #include "ModelAPI_Object.h"
-#include <GeomAPI_Shape.h>
+class GeomAPI_Shape;
 
 class ModelAPI_Feature;
 
index f86754e8059d780aa095e37603142af771b8f14c..7a7df7ef4b17093656c105df66da64fd3b390cd7 100644 (file)
@@ -8,7 +8,7 @@
 #define ModelAPI_ResultPart_H_
 
 #include "ModelAPI_Result.h"
-#include <GeomAPI_Trsf.h>
+class GeomAPI_Trsf;
 
 #include <string>
 
index 8d65638b98da517120e959f7d42b725aaf8e1a76..963a0c31d78dd5a1cde2e8910946e8ebc0033da8 100755 (executable)
@@ -6,9 +6,11 @@
 
 #include "ModelAPI_Tools.h"
 #include <ModelAPI_Session.h>
+#include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_AttributeDocRef.h>
@@ -90,21 +92,6 @@ std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult)
   return theResult->shape();
 }
 
-void shapesOfType(const FeaturePtr& theFeature,
-                  const GeomAPI_Shape::ShapeType& theType,
-                  std::set<ResultPtr>& theShapeResults)
-{
-  theShapeResults.clear();
-  std::list<ResultPtr> aResults = theFeature->results();
-  std::list<ResultPtr>::const_iterator aRIter = aResults.cbegin();
-  for (; aRIter != aResults.cend(); aRIter++) {
-    ResultPtr aResult = *aRIter;
-    GeomShapePtr aShape = aResult->shape();
-    if (aShape.get() && aShape->shapeType() == theType)
-      theShapeResults.insert(aResult);
-  }
-}
-
 const char* toString(ModelAPI_ExecState theExecState)
 {
 #define TO_STRING(__NAME__) case __NAME__: return #__NAME__;
index 573ee12a3849096d4a3023aff69fc3819e0c9d92..a7f23a359416d77563635f4ee0316d59c1771cec 100755 (executable)
@@ -9,44 +9,41 @@
 
 #include "ModelAPI.h"
 
-#include <ModelAPI_CompositeFeature.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Result.h>
-#include <ModelAPI_ResultParameter.h>
-#include <ModelAPI_ResultCompSolid.h>
+class ModelAPI_CompositeFeature;
+class ModelAPI_Document;
+class ModelAPI_Feature;
+class ModelAPI_Result;
+class ModelAPI_ResultParameter;
+class ModelAPI_ResultCompSolid;
 
-#include <GeomAPI_Shape.h>
+class GeomAPI_Shape;
 
+#include <memory>
 #include <vector>
 #include <map>
 #include <set>
+#include <list>
 
 namespace ModelAPI_Tools {
 /// Returns shape from the given Result object
-MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
-
-/// Creates a container of shape of the feature results satisfied the given shape type
-/// \param theFeature a source feature
-/// \param theType shape type
-/// \param an output container for result of shapes
-MODELAPI_EXPORT void shapesOfType(const FeaturePtr& theFeature,
-                                  const GeomAPI_Shape::ShapeType& theType,
-                                  std::set<ResultPtr>& theShapeResults);
+MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(
+                                   const std::shared_ptr<ModelAPI_Result>& theResult);
 
 /*! Returns the feature error generated according to feature error and exec state
  * \param theFeature a feature
  * \return error value or empty string
  */
-MODELAPI_EXPORT std::string getFeatureError(const FeaturePtr& theFeature);
+MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr<ModelAPI_Feature>& theFeature);
 
 /*!
  * Searches for variable with name \param theName in \param theDocument. 
  * If found, set it value in the \param outValue and returns true.
  * theSearcher must be located later in the history than the found variable.
  */
-MODELAPI_EXPORT bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
-  const std::string& theName, double& outValue, ResultParameterPtr& theParam);
+MODELAPI_EXPORT bool findVariable(const std::shared_ptr<ModelAPI_Document>& theDocument,
+                                  std::shared_ptr<ModelAPI_Feature> theSearcher,
+                                  const std::string& theName, double& outValue,
+                                  std::shared_ptr<ModelAPI_ResultParameter>& theParam);
 
 /*!
  * Searches for variable with name \param theName in the active document (Part), when
@@ -54,9 +51,10 @@ MODELAPI_EXPORT bool findVariable(const DocumentPtr& theDocument, FeaturePtr the
  * and returns true. If \param theDocument is empty active document is used.
  * theSearcher must be located later in the history than the found variable.
  */
-MODELAPI_EXPORT bool findVariable(FeaturePtr theSearcher, const std::string& theName,
-  double& outValue, ResultParameterPtr& theParam,
-  const DocumentPtr& theDocument = DocumentPtr());
+MODELAPI_EXPORT bool findVariable(std::shared_ptr<ModelAPI_Feature> theSearcher,
+  const std::string& theName,
+  double& outValue, std::shared_ptr<ModelAPI_ResultParameter>& theParam,
+  const std::shared_ptr<ModelAPI_Document>& theDocument = std::shared_ptr<ModelAPI_Document>());
 
 /*!
  * Searches for Part result that contains the reference to the given document.
@@ -65,7 +63,9 @@ MODELAPI_EXPORT bool findVariable(FeaturePtr theSearcher, const std::string& the
  * \param theSub document that is searched, the resulting feature references to it
  * \returns null if not found
  */
-MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_Result> findPartResult(
+                                              const std::shared_ptr<ModelAPI_Document>& theMain,
+                                              const std::shared_ptr<ModelAPI_Document>& theSub);
 
 /*!
  * Searches for Part the feature that contains in result the reference to the given document.
@@ -74,33 +74,39 @@ MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const Docum
  * \param theSub document that is searched, the resulting feature references to it
  * \returns null if not found
  */
-MODELAPI_EXPORT FeaturePtr findPartFeature(const DocumentPtr& theMain, const DocumentPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> findPartFeature(
+                                           const std::shared_ptr<ModelAPI_Document>& theMain,
+                                           const std::shared_ptr<ModelAPI_Document>& theSub);
 
 /*!
  * Returns the composite feature - parent of this feature.
  * \param theFeature the sub-element of composite
  * \returns null if it is not sub-element of composite
  */
-MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_CompositeFeature> compositeOwner(
+                                        const std::shared_ptr<ModelAPI_Feature>& theFeature);
 
 /*!
  * Returns the compsolid result - parent of this result.
  * \param theSub the sub-element of comp-solid
  * \returns null if it is not sub-element of composite
  */
-MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultCompSolid> compSolidOwner(
+                                            const std::shared_ptr<ModelAPI_Result>& theSub);
 
 /*!
-* Returns true if the result contains a not empty list of sub results. It processes result compsolid.
+* Returns true if the result contains a not empty list of sub results.
+* It processes result compsolid.
 * \param theResult a result object
 * \returns boolean value
 */
-MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult);
+MODELAPI_EXPORT bool hasSubResults(const std::shared_ptr<ModelAPI_Result>& theResult);
 
 /*!
 * Adds the results of the given feature to theResults list: including disabled and sub-results
 */
-MODELAPI_EXPORT void allResults(const FeaturePtr& theFeature, std::list<ResultPtr>& theResults);
+MODELAPI_EXPORT void allResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
 
 /*!
  Returns true if there are no parts in the document, which are not activated
@@ -109,13 +115,13 @@ MODELAPI_EXPORT void allResults(const FeaturePtr& theFeature, std::list<ResultPt
  */
 MODELAPI_EXPORT bool allDocumentsActivated(std::string& theNotActivatedNames);
 
-
 /*! Removes features from the document
 * \param theFeatures a list of features to be removed
 * \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
 * \return true if at least one feature is removed
 */
-MODELAPI_EXPORT bool removeFeaturesAndReferences(const std::set<FeaturePtr>& theFeatures,
+MODELAPI_EXPORT bool removeFeaturesAndReferences(
+                       const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
                                                  const bool theFlushRedisplay = false,
                                                  const bool theUseComposite = false,
                                                  const bool theUseRecursion = true);
@@ -125,8 +131,9 @@ MODELAPI_EXPORT bool removeFeaturesAndReferences(const std::set<FeaturePtr>& the
 * \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
 * \return true if at least one feature is removed
 */
-MODELAPI_EXPORT bool removeFeatures(const std::set<FeaturePtr>& theFeatures,
-                                    const bool theFlushRedisplay);
+MODELAPI_EXPORT bool removeFeatures(
+                            const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
+                            const bool theFlushRedisplay);
 
 /*! Build a map of references for the given set of features
 * \param theFeatures a list of features
@@ -136,26 +143,30 @@ MODELAPI_EXPORT bool removeFeatures(const std::set<FeaturePtr>& theFeatures,
          list are put into the result container. E.g. if theFeatures contains "Sketch_2", map will
          contain references to this feature also.
 */
-MODELAPI_EXPORT void findAllReferences(const std::set<FeaturePtr>& theFeatures,
-                                       std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
-                                       const bool theUseComposite = true,
-                                       const bool theUseRecursion = true);
+MODELAPI_EXPORT void findAllReferences(
+  const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
+  std::map<std::shared_ptr<ModelAPI_Feature>,
+  std::set<std::shared_ptr<ModelAPI_Feature> > >& theReferences,
+  const bool theUseComposite = true,
+  const bool theUseRecursion = true);
 
 /*! In the map of references find all features referenced to the source feature
 * \param theFeatures a list of features to find references
 * \param theReferences a map of all references to the features
 * \param theFeaturesRefsTo an out list of referenced features
 */
-MODELAPI_EXPORT void findRefsToFeatures(const std::set<FeaturePtr>& aFeatures,
-                                const std::map<FeaturePtr, std::set<FeaturePtr> >& aReferences,
-                                std::set<FeaturePtr>& aFeaturesRefsTo);
+MODELAPI_EXPORT void findRefsToFeatures(
+  const std::set<std::shared_ptr<ModelAPI_Feature> >& aFeatures,
+  const std::map<std::shared_ptr<ModelAPI_Feature>,
+                 std::set<std::shared_ptr<ModelAPI_Feature> > >& aReferences,
+  std::set<std::shared_ptr<ModelAPI_Feature> >& aFeaturesRefsTo);
 
 /*! Finds referenced of the feature to objects and collects concealed results.
 * \param theFeatures a model feature
 * \param theResults container for concealed results. It has no duplications
 */
-MODELAPI_EXPORT void getConcealedResults(const FeaturePtr& theFeature,
-                                         std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
+MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                   std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
 }
 
 #endif
diff --git a/src/ModelAPI/Test/TestExternalConstruction.py b/src/ModelAPI/Test/TestExternalConstruction.py
new file mode 100644 (file)
index 0000000..d2463a3
--- /dev/null
@@ -0,0 +1,20 @@
+# The test for correct referencing for Part feature of whole construction result created in PartSet
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOZ"))
+SketchLine_1 = Sketch_1.addLine(-104, 73, 102, 265)
+SketchLine_2 = Sketch_1.addLine(102, 265, 192, -1)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(192, -1, -104, 73)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
+model.do()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "PartSet/Sketch_1")], model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_3"), 360, 0)
+model.end()
+
+assert(model.checkPythonDump())
index 3d4a48070416ac13b771192a419bb80903b2910f..260c76acf74f9a33669359a43dacf0f540ae15b3 100755 (executable)
@@ -8,10 +8,12 @@ INCLUDE(UnitTest)
 SET(PROJECT_HEADERS
     ModelGeomAlgo.h
     ModelGeomAlgo_Point2D.h
+    ModelGeomAlgo_Shape.h
 )
 
 SET(PROJECT_SOURCES
     ModelGeomAlgo_Point2D.cpp
+    ModelGeomAlgo_Shape.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 44759de7e2c3de97e820cc3bb351b8b68cb89fad..ab1d7011933b550ad6a21196800674c4c9f4b701 100755 (executable)
@@ -12,6 +12,8 @@
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Tools.h>
 
+#include <ModelGeomAlgo_Shape.h>
+
 #include <GeomAPI_ShapeIterator.h>
 
 #include <GeomAlgoAPI_ShapeTools.h>
@@ -176,7 +178,7 @@ namespace ModelGeomAlgo_Point2D {
     GeomShapePtr aFeatureShape;
     {
       std::set<ResultPtr> anEdgeShapes;
-      ModelAPI_Tools::shapesOfType(theBaseFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+      ModelGeomAlgo_Shape::shapesOfType(theBaseFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
       if (anEdgeShapes.empty())
         return;
       aFeatureShape = (*anEdgeShapes.begin())->shape();
@@ -190,7 +192,7 @@ namespace ModelGeomAlgo_Point2D {
         continue;
       if (aFeature.get()) {
         std::set<ResultPtr> anEdgeShapes;
-        ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+        ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
         if (anEdgeShapes.empty())
           continue;
         ResultPtr aResult = *anEdgeShapes.begin();
@@ -220,17 +222,11 @@ namespace ModelGeomAlgo_Point2D {
         if (thePointToAttributeOrObject.find(aProjectedPoint) != thePointToAttributeOrObject.end())
           thePointToAttributeOrObject.at(aProjectedPoint).first.push_back(anAttribute);
         else {
-          //std::list< std::shared_ptr<GeomDataAPI_Point2D> > anAttributes;
-          //anAttributes.push_back(anAttribute);
-          //thePointToAttributeOrObject.insert(aProjectedPoint, anAttributes);
-
           std::list<std::shared_ptr<GeomDataAPI_Point2D> > anAttributes;
           std::list<std::shared_ptr<ModelAPI_Object> > anObjects;
           anAttributes.push_back(anAttribute);
           thePointToAttributeOrObject[aProjectedPoint] = std::make_pair(anAttributes, anObjects);
         }
-        //thePoints.push_back(aProjectedPoint);
-        //theAttributeToPoint[anAttribute] = aProjectedPoint;
       }
     }
   }
diff --git a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp
new file mode 100644 (file)
index 0000000..fb97aec
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_Tools.cpp
+// Created:     19 Mar 2017
+// Author:      Natalia ERMOLAEVA
+
+#include <GeomAPI_Shape.h>
+
+#include "ModelGeomAlgo_Shape.h"
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
+
+
+#ifdef WIN32
+#pragma warning(disable : 4996) // for sprintf
+#endif
+
+namespace ModelGeomAlgo_Shape
+{
+  void shapesOfType(const FeaturePtr& theFeature,
+                    const GeomAPI_Shape::ShapeType& theType,
+                    std::set<ResultPtr>& theShapeResults)
+  {
+    theShapeResults.clear();
+    std::list<ResultPtr> aResults = theFeature->results();
+    std::list<ResultPtr>::const_iterator aRIter = aResults.cbegin();
+    for (; aRIter != aResults.cend(); aRIter++) {
+      ResultPtr aResult = *aRIter;
+      GeomShapePtr aShape = aResult->shape();
+      if (aShape.get() && aShape->shapeType() == theType)
+        theShapeResults.insert(aResult);
+    }
+  }
+} // namespace ModelGeomAlgo_Shape
diff --git a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.h b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.h
new file mode 100644 (file)
index 0000000..847b01b
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelGeomAlgo_Point2D.h
+// Created:     20 Jul 2016
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModelGeomAlgo_Shape_H
+#define ModelGeomAlgo_Shape_H
+
+#include "ModelGeomAlgo.h"
+#include "GeomAPI_Shape.h"
+
+#include <set>
+
+class ModelAPI_Feature;
+class ModelAPI_Result;
+
+namespace ModelGeomAlgo_Shape {
+
+  /// Searches Shape results of the feature satisfied the given shape type
+  /// \param theFeature a feature to obtain AttributeRefAttr
+  /// \param theType shape type
+  /// \param theShapeResults a list of results
+  MODELGEOMALGO_EXPORT void shapesOfType(
+                              const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                              const GeomAPI_Shape::ShapeType& theType,
+                              std::set<std::shared_ptr<ModelAPI_Result> >& theShapeResults);
+}
+
+#endif
index 5c7343cdf4909fde2b67d30c55cd07e167642db7..cdf698b7af061cae5d199d0d3a82098495cd93cb 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Tools.h>
index 7dd3e36385c7551ec1a70d349e63abf6282cbc01..c42e163b84f8c9331a28347fc890ee8f5b4067fc 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Tools.h>
index d08ccb44dfa7f6d09443c529ce2bb28014ef1569..bdbae89880150f89b0319874da495b755e2aa5c2 100755 (executable)
@@ -10,6 +10,7 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <GeomAPI_PlanarEdges.h>
 
 #include <Events_InfoMessage.h>
index ef8fa81fb4307999b8086eec468719996af2cc19..b10b335f1ca5f0411f1907ba5ef3dfe1bd72abad 100644 (file)
@@ -20,6 +20,7 @@
 #include <ModelAPI_AttributeValidator.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 
index fc8700134024d597d5fd5ad4e3552b709a792c9b..b539c6ad47d1a07146495df2a0dd525cf175aca6 100755 (executable)
@@ -11,6 +11,7 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <GeomAPI_PlanarEdges.h>
 
 #include <Events_InfoMessage.h>
index e415933371b447a04b8bd58e0ba4fb38cd5b57fd..ec18af32f5c84dc765f22f7302d21032084ab2bb 100755 (executable)
@@ -27,6 +27,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 
index d93b666ca483dbdd038b84938b5e40b1a89302b6..f2808b3ad2f929397e103f76106c99bd8ee8cc1a 100644 (file)
@@ -50,7 +50,7 @@
 PartSet_WidgetFeaturePointSelector::PartSet_WidgetFeaturePointSelector(QWidget* theParent,
                                                          ModuleBase_IWorkshop* theWorkshop,
                                                          const Config_WidgetAPI* theData)
-: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData), myBaseSelected(false)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData)
 {
 }
 
@@ -62,7 +62,8 @@ PartSet_WidgetFeaturePointSelector::~PartSet_WidgetFeaturePointSelector()
 bool PartSet_WidgetFeaturePointSelector::isValidSelection(
                                         const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
 {
-  return true;
+  return ModuleBase_WidgetShapeSelector::isValidSelection(theValue);
+  //return true;
 }
 
 //********************************************************************
@@ -76,13 +77,11 @@ bool PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActi
   Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle();
   if (toActivate) {
     std::vector<int> aColors;
-  aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
+    aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
     aColor = Quantity_Color(aColors[0] / 255., aColors[1] / 255., aColors[2] / 255.,
                             Quantity_TOC_RGB);
     myHighlightColor = aHStyle->Color();
     mySelectionColor = aSStyle->Color();
-
-    aHStyle->SetTransparency(0.5f);
   }
   else {
     aColor = myHighlightColor;
@@ -103,8 +102,6 @@ void PartSet_WidgetFeaturePointSelector::activateCustom()
 {
   ModuleBase_WidgetShapeSelector::activateCustom();
 
-  myBaseSelected = false;
-
   myWorkshop->module()->activateCustomPrs(myFeature,
                             ModuleBase_IModule::CustomizeHighlightedObjects, true);
 }
@@ -135,7 +132,25 @@ void PartSet_WidgetFeaturePointSelector::mouseReleased(ModuleBase_IViewWindow* t
   if (theEvent->button() != Qt::LeftButton)
     return;
 
-  myBaseSelected = true;
+  // set parameters of preview into parameters of selection in the feature
+  std::shared_ptr<ModelAPI_AttributeReference> aRefSelectedAttr =
+                          std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+                          feature()->data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
+  std::shared_ptr<ModelAPI_AttributeReference> aRefPreviewAttr =
+                          std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+                          feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+  aRefSelectedAttr->setValue(aRefPreviewAttr->value());
+
+  std::shared_ptr<GeomDataAPI_Point2D> aPointSelectedAttr =
+                          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+                          feature()->data()->attribute(SketchPlugin_Trim::SELECTED_POINT()));
+  std::shared_ptr<GeomDataAPI_Point2D> aPointPreviewAttr =
+                          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+                          feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
+  aPointSelectedAttr->setValue(aPointPreviewAttr->x(), aPointPreviewAttr->y());
+
+  updateObject(feature());
+
   emit focusOutWidget(this);
   // we need to deselect base feature for better visibility of selected feature
   XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(false);
@@ -159,12 +174,12 @@ bool PartSet_WidgetFeaturePointSelector::fillFeature(
 
   std::shared_ptr<ModelAPI_AttributeReference> aRef =
                           std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                          feature()->data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                          feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
   aRef->setValue(anObject);
 
   std::shared_ptr<GeomDataAPI_Point2D> anAttributePoint =
                   std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-                  feature()->data()->attribute(SketchPlugin_Trim::ENTITY_POINT()));
+                  feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
   anAttributePoint->setValue(aX, anY);
   // redisplay AIS presentation in viewer
 #ifndef HIGHLIGHT_STAYS_PROBLEM
@@ -172,6 +187,8 @@ bool PartSet_WidgetFeaturePointSelector::fillFeature(
   XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(true);
 #endif
   updateObject(feature());
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
   aFilled = true;
 
   return aFilled;
@@ -183,13 +200,6 @@ QList<ModuleBase_ViewerPrsPtr> PartSet_WidgetFeaturePointSelector::getAttributeS
   return QList<ModuleBase_ViewerPrsPtr>();
 }
 
-//********************************************************************
-void PartSet_WidgetFeaturePointSelector::updateSelectionName()
-{
-  if (myBaseSelected)
-    ModuleBase_WidgetShapeSelector::updateSelectionName();
-}
-
 //********************************************************************
 bool PartSet_WidgetFeaturePointSelector::setSelection(
                                           QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
index 56c5105bbf0783e2617b18004b2c815b8096c743..96d559d0c6f4455d5cf9b325ea507aca1c071174 100644 (file)
@@ -49,10 +49,10 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetFeaturePointSelector();
 
-  /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
-  /// next, the attribute's validating. It trying on the give selection to current attribute by
-  /// setting the value inside and calling validators. After this, the previous attribute value is
-  /// restored.The valid/invalid value is cashed.
+  /// Checks all widget validator if the owner is valid. Firstly it checks custom widget
+  /// validating, next, the attribute's validating. It trying on the give selection to current
+  /// attribute by setting the value inside and calling validators. After this, the previous
+  /// attribute value is restored.The valid/invalid value is cashed.
   /// \param theValue a selected presentation in the view
   /// \return a boolean value
   virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
@@ -81,10 +81,6 @@ Q_OBJECT
   /// \param theEvent a mouse event
   virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
 
-  /// Returns values which should be highlighted when the whidget is active
-  /// \param theValues a list of presentations
-  //virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
-
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// The method is called by the current operation to process the operation preselection.
@@ -95,7 +91,6 @@ Q_OBJECT
                             const bool theToValidate);
 
   /// Fill preselection used in mouseReleased
-  //virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
   virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
                                ModuleBase_IViewWindow* theWnd,
                                QMouseEvent* theEvent);
@@ -105,9 +100,6 @@ protected:
   /// a shape. If the attribute do not uses the shape, it is empty
   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
 
-  /// Computes and updates name of selected object in the widget
-  virtual void updateSelectionName();
-
 protected:
   /// The methiod called when widget is activated
   virtual void activateCustom();
@@ -121,7 +113,6 @@ protected:
   CompositeFeaturePtr mySketch;
   Quantity_Color myHighlightColor;
   Quantity_Color mySelectionColor;
-  bool myBaseSelected;
 };
 
 #endif
\ No newline at end of file
index b0e41e4f12abdd87875542e32bb014df8ab0210e..24dd2cad09e5bbcf18986b35d5794239c50abad0 100755 (executable)
@@ -20,6 +20,7 @@
 
 #include <GeomAlgoAPI_ShapeTools.h>
 #include <ModelGeomAlgo_Point2D.h>
+#include <ModelGeomAlgo_Shape.h>
 
 #include <ModelGeomAlgo_Point2D.h>
 
@@ -230,7 +231,7 @@ void PartSet_WidgetSubShapeSelector::fillObjectShapes(const ObjectPtr& theObject
   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
   // edges on feature
   std::set<ResultPtr> anEdgeResults;
-  ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeResults);
+  ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeResults);
   if (!anEdgeResults.empty()) {
     GeomShapePtr aFeatureShape = (*anEdgeResults.begin())->shape();
 
index 6b2b469da88ef045a55ef7ed4ebba2de45e412d4..f121be4db8b00e56d0861ae4e4b0d5cbb439189a 100644 (file)
@@ -3,12 +3,6 @@ from salome.shaper import model
 from TestSketcher import SketcherTestCase
 
 class SketcherSetFillet(SketcherTestCase):
-    # TODO: Remove tearDown method to check Python dump in super-class
-    def tearDown(self):
-        model.end()
-        #assert(model.checkPythonDump())
-        model.reset()
-
     def test_fillet(self):
         l1 = self.sketch.addLine(0, 0, 0, 1)
         l2 = self.sketch.addLine(0, 1, 1, 1)
index d9fff77cebdb054398ca78d6a3ba6589f84605ea..11c22f0ae8764b55ca27984a83c510e72e76e24d 100644 (file)
@@ -490,9 +490,9 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::addTrim(
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
     compositeFeature()->addFeature(SketchPlugin_Trim::ID());
-  fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::BASE_OBJECT()));
+  fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::SELECTED_OBJECT()));
 
-  AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::ENTITY_POINT());
+  AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::SELECTED_POINT());
   if (anAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) {
     AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttribute);
     fillAttribute(thePositionPoint, aPointAttr);
index 87ef7b27a0dbf1e1e7148928fde3c77ef57adf85..80df2df05e9bcd9561e1f79b3ad895fec25c934c 100644 (file)
@@ -78,6 +78,8 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                               new SketchPlugin_FilletVertexValidator);
   aFactory->registerValidator("SketchPlugin_SplitValidator",
                               new SketchPlugin_SplitValidator);
+  aFactory->registerValidator("SketchPlugin_TrimValidator",
+                              new SketchPlugin_TrimValidator);
   aFactory->registerValidator("SketchPlugin_MiddlePointAttr",
                               new SketchPlugin_MiddlePointAttrValidator);
   aFactory->registerValidator("SketchPlugin_ArcTangentPoint",
index 7373e34af0a530b7e28edda53149fe46d0e671e0..4ae70604570ef2ff4fa97a08f636c2c4a824394b 100644 (file)
@@ -12,6 +12,7 @@
 #include <GeomAPI_XY.h>
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
 
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeString.h>
@@ -23,6 +24,8 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_AttributeDouble.h>
 
+#include <ModelGeomAlgo_Shape.h>
+
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_ConstraintMiddle.h>
 #include <SketchPlugin_Circle.h>
@@ -64,25 +67,38 @@ SketchPlugin_Trim::SketchPlugin_Trim()
 
 void SketchPlugin_Trim::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Trim::BASE_OBJECT(), ModelAPI_AttributeReference::typeId());
-  data()->addAttribute(ENTITY_POINT(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(SketchPlugin_Trim::SELECTED_OBJECT(),
+                       ModelAPI_AttributeReference::typeId());
+  data()->addAttribute(SELECTED_POINT(), GeomDataAPI_Point2D::typeId());
+
+  data()->addAttribute(PREVIEW_POINT(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(PREVIEW_OBJECT(), ModelAPI_AttributeReference::typeId());
+
+  data()->attribute(PREVIEW_POINT())->setIsArgument(false);
+  data()->attribute(SELECTED_POINT())->setIsArgument(false);
+  data()->attribute(PREVIEW_OBJECT())->setIsArgument(false);
+
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PREVIEW_POINT());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PREVIEW_OBJECT());
 }
 
-void SketchPlugin_Trim::findShapePoints(std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
+void SketchPlugin_Trim::findShapePoints(const std::string& theObjectAttributeId,
+                                        const std::string& thePointAttributeId,
+                                        std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
                                         std::shared_ptr<GeomAPI_Pnt>& aLastPoint)
 {
   AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                            data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                                            data()->attribute(theObjectAttributeId));
   ObjectPtr aBaseObject = aBaseObjectAttr->value();
 
   AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-                                                            data()->attribute(ENTITY_POINT()));
+                                              data()->attribute(thePointAttributeId));
   std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
   std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
                                                                anAttributePnt2d->y());
 
   if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
-    fillObjectShapes(aBaseObject);
+    fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
 
   const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
   if (!aShapes.empty()) {
@@ -116,10 +132,10 @@ std::shared_ptr<GeomAPI_Pnt2d> SketchPlugin_Trim::convertPoint(
   std::shared_ptr<GeomAPI_Pnt2d> aPoint;
 
   AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                            data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                                        data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
   ObjectPtr aBaseObject = aBaseObjectAttr->value();
   if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
-    return aPoint;
+    fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
 
   bool aFound = false;
   const PointToRefsMap& aRefsMap = myObjectToPoints.at(aBaseObject);
@@ -141,7 +157,8 @@ std::shared_ptr<GeomAPI_Pnt2d> SketchPlugin_Trim::convertPoint(
     }
   }
   if (!aFound) {
-    // returns an end of the shape to define direction of split if feature's attribute participates
+    // returns an end of the shape to define direction of split if feature's attribute
+    // participates
     std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
     aPoint = thePoint->to2D(aPlane);
   }
@@ -160,7 +177,7 @@ void SketchPlugin_Trim::execute()
 
   // Check the base objects are initialized.
   AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                            data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                                        data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
   if(!aBaseObjectAttr->isInitialized()) {
     setError("Error: Base object is not initialized.");
     return;
@@ -172,7 +189,7 @@ void SketchPlugin_Trim::execute()
 
   /// points of trim
   std::shared_ptr<GeomAPI_Pnt> aStartShapePoint, aLastShapePoint;
-  findShapePoints(aStartShapePoint, aLastShapePoint);
+  findShapePoints(SELECTED_OBJECT(), SELECTED_POINT(), aStartShapePoint, aLastShapePoint);
   std::shared_ptr<GeomAPI_Pnt2d> aStartShapePoint2d = convertPoint(aStartShapePoint);
 
   std::shared_ptr<GeomAPI_Pnt2d> aLastShapePoint2d = convertPoint(aLastShapePoint);
@@ -200,8 +217,16 @@ void SketchPlugin_Trim::execute()
                aFurtherCoincidences, aModifiedAttributes);
 
     aFeaturesToDelete.insert(aBaseFeature);
-    // as circle is removed, temporary fill this attribute
+    // as circle is removed, erase it from dependencies(arguments) of this feature
+    // otherwise Trim feature will be removed with the circle before
+    // this operation is finished
     aBaseObjectAttr->setObject(ResultPtr());
+
+    AttributeReferencePtr aPreviewObjectAttr =
+                     std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+                     data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+    aPreviewObjectAttr->setObject(ResultPtr());
+
   }
   else if (aKind == SketchPlugin_Line::ID()) {
     trimLine(aStartShapePoint2d, aLastShapePoint2d,
@@ -213,6 +238,9 @@ void SketchPlugin_Trim::execute()
   }
 
   //
+  if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
+    fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
+
   const PointToRefsMap& aRefsMap = myObjectToPoints.at(aBaseObject);
   std::set<AttributePoint2DPtr>::const_iterator anIt = aFurtherCoincidences.begin(),
                                                 aLast = aFurtherCoincidences.end();
@@ -330,25 +358,63 @@ bool SketchPlugin_Trim::isMacro() const
 AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious)
 {
   AISObjectPtr anAIS = thePrevious;
-  // feature for trim
-  AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                           data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
-  ObjectPtr aBaseObject = aBaseObjectAttr->value();
-  if (!aBaseObject.get())
+
+  std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
+  GeomShapePtr aPreviewShape = getSubShape(PREVIEW_OBJECT(), PREVIEW_POINT());
+  if (aPreviewShape.get())
+    aShapes.push_back(aPreviewShape);
+  GeomShapePtr aSelectedShape = getSubShape(SELECTED_OBJECT(), SELECTED_POINT());
+  if (aSelectedShape.get())
+    aShapes.push_back(aSelectedShape);
+
+  if (aShapes.empty())
     return AISObjectPtr();
-  FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
+
+  GeomShapePtr aBaseShape = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
+  if (!aBaseShape.get())
+    return AISObjectPtr();
+
+  if (aBaseShape.get()) {
+    if (!anAIS)
+      anAIS = AISObjectPtr(new GeomAPI_AISObject);
+    anAIS->createShape(aBaseShape);
+
+    std::vector<int> aColor;
+    aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color");
+    double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
+    int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
+    anAIS->setColor(aColor[0], aColor[1], aColor[2]);
+    // width when there is not base object should be extened in several points
+    // in order to see this preview over highlight
+    anAIS->setWidth(aWidth+4);
+    anAIS->setLineStyle(aLineStyle);
+  }
+  else
+    anAIS = AISObjectPtr();
+
+  return anAIS;
+}
+
+GeomShapePtr SketchPlugin_Trim::getSubShape(const std::string& theObjectAttributeId,
+                                            const std::string& thePointAttributeId)
+{
+  GeomShapePtr aBaseShape;
+
+  AttributeReferencePtr anObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+                                                       data()->attribute(theObjectAttributeId));
+  ObjectPtr aBaseObject = anObjectAttr->value();
+  if (!aBaseObject.get())
+    return aBaseShape;
 
   // point on feature
   AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-                                           data()->attribute(ENTITY_POINT()));
+                                           data()->attribute(thePointAttributeId));
   std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
   std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
                                                                anAttributePnt2d->y());
 
   if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
-    fillObjectShapes(aBaseObject);
-
-  GeomShapePtr aBaseShape;
+    fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
 
   const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
   if (!aShapes.empty()) {
@@ -360,33 +426,7 @@ AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious)
         aBaseShape = aShape;
     }
   }
-
-  if (aBaseShape.get()) {
-    if (!anAIS)
-      anAIS = AISObjectPtr(new GeomAPI_AISObject);
-    anAIS->createShape(aBaseShape);
-
-    std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
-            aBaseFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
-
-    bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
-    std::vector<int> aColor;
-          aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color");
-    double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
-    int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
-    if (isConstruction) {
-      aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
-      aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
-    }
-    anAIS->setColor(aColor[0], aColor[1], aColor[2]);
-    // width is extened in several points in order to see this preview over highlight
-    anAIS->setWidth(aWidth + 2);
-    anAIS->setLineStyle(aLineStyle);
-  }
-  else
-    anAIS = AISObjectPtr();
-
-  return anAIS;
+  return aBaseShape;
 }
 
 void SketchPlugin_Trim::getFeaturePoints(const FeaturePtr& theFeature,
@@ -417,7 +457,7 @@ void SketchPlugin_Trim::getConstraints(std::set<FeaturePtr>& theFeaturesToDelete
 
   // Check the base objects are initialized.
   AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                            aData->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                                         aData->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
   FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
   ResultPtr aBaseFeatureResult = getFeatureResult(aBaseFeature);
 
@@ -565,7 +605,7 @@ void SketchPlugin_Trim::trimLine(const std::shared_ptr<GeomAPI_Pnt2d>& theStartS
 {
   // Check the base objects are initialized.
   AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                            data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                                        data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
   ObjectPtr aBaseObject = aBaseObjectAttr->value();
   FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
 
@@ -614,7 +654,8 @@ void SketchPlugin_Trim::trimLine(const std::shared_ptr<GeomAPI_Pnt2d>& theStartS
                                (aBaseFeature->attribute(aModifiedAttribute)));
   }
   else {
-    // result is two lines: start line point - start shape point, last shape point - last line point
+    // result is two lines: start line point - start shape point,
+    // last shape point - last line point
     // create second line
     FeaturePtr anNewFeature = createLineFeature(aBaseFeature, aLastShapePoint, aLastFeaturePoint);
     thePoints.insert(std::dynamic_pointer_cast<GeomDataAPI_Point2D>
@@ -646,7 +687,7 @@ void SketchPlugin_Trim::trimArc(const std::shared_ptr<GeomAPI_Pnt2d>& theStartSh
 {
   // Check the base objects are initialized.
   AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                            data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                                        data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
   ObjectPtr aBaseObject = aBaseObjectAttr->value();
   FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
 
@@ -730,7 +771,7 @@ FeaturePtr SketchPlugin_Trim::trimCircle(const std::shared_ptr<GeomAPI_Pnt2d>& t
 {
   // Check the base objects are initialized.
   AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                            data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+                                        data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
   ObjectPtr aBaseObject = aBaseObjectAttr->value();
   FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
 
@@ -1013,13 +1054,10 @@ std::shared_ptr<ModelAPI_Result> SketchPlugin_Trim::getFeatureResult(
 }
 
 //********************************************************************
-bool SketchPlugin_Trim::useGraphicIntersection() const
-{
-  return true;
-}
-
-//********************************************************************
-void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject)
+void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject,
+                const ObjectPtr& theSketch,
+                std::map<ObjectPtr, std::set<GeomShapePtr> >& theCashedShapes,
+                std::map<ObjectPtr, PointToRefsMap>& theObjectToPoints)
 {
   PointToRefsMap aPointsInfo;
 
@@ -1034,7 +1072,7 @@ void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject)
   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
   std::set<ResultPtr> anEdgeShapes;
   // edges on feature
-  ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+  ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
   if (!anEdgeShapes.empty()) {
     GeomShapePtr aFeatureShape = (*anEdgeShapes.begin())->shape();
 
@@ -1042,8 +1080,8 @@ void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject)
     ModelGeomAlgo_Point2D::getPointsOfReference(aFeature, SketchPlugin_ConstraintCoincidence::ID(),
                          aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID());
     // layed on feature coincidences to divide it on several shapes
-    SketchPlugin_Sketch* aSketch = sketch();
-    std::shared_ptr<ModelAPI_Data> aData = aSketch->data();
+    //SketchPlugin_Sketch* aSketch = sketch();
+    std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
     std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
         aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
     std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
@@ -1055,52 +1093,18 @@ void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject)
     ModelGeomAlgo_Point2D::getPointsInsideShape(aFeatureShape, aRefAttributes, aC->pnt(),
                                                 aX->dir(), aY, aPointsInfo);
 
-    // intersection points
-    if (useGraphicIntersection()) {
-      std::list<FeaturePtr> aFeatures;
-      for (int i = 0; i < aSketch->numberOfSubs(); i++) {
-        FeaturePtr aFeature = aSketch->subFeature(i);
-        if (aFeature.get())
-          aFeatures.push_back(aFeature);
-      }
-      ModelGeomAlgo_Point2D::getPointsIntersectedShape(aFeature, aFeatures, aPointsInfo);
+    std::list<FeaturePtr> aFeatures;
+    CompositeFeaturePtr aSketchComposite =
+                         std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theSketch);
+    for (int i = 0; i < aSketchComposite->numberOfSubs(); i++) {
+      FeaturePtr aFeature = aSketchComposite->subFeature(i);
+      if (aFeature.get())
+        aFeatures.push_back(aFeature);
     }
-    GeomAlgoAPI_ShapeTools::splitShape(aFeatureShape, aPointsInfo, aShapes);
-  }
-  myObjectToPoints[theObject] = aPointsInfo;
-  myCashedShapes[theObject] = aShapes;
-}
+    ModelGeomAlgo_Point2D::getPointsIntersectedShape(aFeature, aFeatures, aPointsInfo);
 
-//********************************************************************
-void SketchPlugin_Trim::attributeChanged(const std::string& theID)
-{
-  //data()->addAttribute(SketchPlugin_Trim::BASE_OBJECT(), ModelAPI_AttributeReference::typeId());
-  if (theID == SketchPlugin_Trim::BASE_OBJECT()) {
-    bool isValidAttribute = false;
-    // feature for trim
-    AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
-                                             data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
-    ObjectPtr aBaseObject = aBaseObjectAttr->value();
-    if (aBaseObject.get()) {
-      FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
-      // point on feature
-      AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-                                               data()->attribute(ENTITY_POINT()));
-      std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
-      std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
-                                                                   anAttributePnt2d->y());
-
-      if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
-        fillObjectShapes(aBaseObject);
-
-      const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
-      isValidAttribute = !aShapes.empty();
-
-      if (!isValidAttribute) {
-        bool aWasBlocked = data()->blockSendAttributeUpdated(true);
-        aBaseObjectAttr->setValue(ObjectPtr());
-        data()->blockSendAttributeUpdated(aWasBlocked);
-      }
-    }
+    GeomAlgoAPI_ShapeTools::splitShape(aFeatureShape, aPointsInfo, aShapes);
   }
+  theObjectToPoints[theObject] = aPointsInfo;
+  theCashedShapes[theObject] = aShapes;
 }
index 9f3702f84be8e4314f8a5e99c17fbf837fe45265..db43d5fa6ec903bf4cb8e8523075357faa573149 100644 (file)
@@ -14,6 +14,7 @@
 class GeomDataAPI_Point2D;
 class ModelAPI_Feature;
 class ModelAPI_Result;
+class ModelAPI_Object;
 
 typedef std::pair<std::string, std::shared_ptr<GeomDataAPI_Point2D> > IdToPointPair;
 
@@ -38,17 +39,31 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab
   }
 
   /// The value parameter for the constraint
-  inline static const std::string& BASE_OBJECT()
+  inline static const std::string& SELECTED_OBJECT()
   {
-    static const std::string MY_CONSTRAINT_BASE_OBJECT("BaseObject");
-    return MY_CONSTRAINT_BASE_OBJECT;
+    static const std::string MY_SELECTED_OBJECT("SelectedObject");
+    return MY_SELECTED_OBJECT;
   }
 
   /// Start 2D point of the split segment
-  inline static const std::string& ENTITY_POINT()
+  inline static const std::string& SELECTED_POINT()
   {
-    static const std::string MY_ENTITY_POINT("ConstraintEntityPoint");
-    return MY_ENTITY_POINT;
+    static const std::string MY_SELECTED_POINT("SelectedPoint");
+    return MY_SELECTED_POINT;
+  }
+
+  /// The value parameter for the preview object
+  inline static const std::string& PREVIEW_OBJECT()
+  {
+    static const std::string MY_PREVIEW_OBJECT("PreviewObject");
+    return MY_PREVIEW_OBJECT;
+  }
+
+  /// Start 2D point of the split segment
+  inline static const std::string& PREVIEW_POINT()
+  {
+    static const std::string MY_PREVIEW_POINT("PreviewPoint");
+    return MY_PREVIEW_POINT;
   }
 
   /// \brief Creates a new part document if needed
@@ -65,10 +80,6 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab
   /// This is necessary to perform execute only by apply the feature
   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
 
-  /// Called on change of any argument-attribute of this object
-  /// \param theID identifier of changed attribute
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
   /// \brief Use plugin manager for features creation
   SketchPlugin_Trim();
 
@@ -78,7 +89,19 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab
   /// Moves the feature : Empty
   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
 
+  typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
+                   std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
+                             std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
+
+  static void fillObjectShapes(const std::shared_ptr<ModelAPI_Object>& theObject,
+    const std::shared_ptr<ModelAPI_Object>& theSketch,
+    std::map<std::shared_ptr<ModelAPI_Object>, std::set<GeomShapePtr> >& theCashedShapes,
+    std::map<std::shared_ptr<ModelAPI_Object>, PointToRefsMap>& theObjectToPoints);
+
 private:
+  GeomShapePtr getSubShape(const std::string& theObjectAttributeId,
+                           const std::string& thePointAttributeId);
+
   /// Returns geom point attribute of the feature bounds. It processes line or arc.
   /// For circle feature, the result attributes are null
   /// \param theFeature a source feature
@@ -108,7 +131,7 @@ private:
   /// by the coincident attribute
   /// \param theObject an investigated object
   /// \param theCoincidencesToBaseFeature a container of list of referenced attributes
-  void getCoincidencesToObject(const ObjectPtr& theObject,
+  void getCoincidencesToObject(const std::shared_ptr<ModelAPI_Object>& theObject,
                                std::map<AttributePtr, FeaturePtr>& theCoincidencesToBaseFeature);
 
   /// Move constraints from attribute of base feature to attribute after modification
@@ -237,23 +260,16 @@ private:
                                     const std::shared_ptr<ModelAPI_Feature>& theFeature);
 
 private:
-  bool useGraphicIntersection() const;
-
-  void fillObjectShapes(const ObjectPtr& theObject);
-
-  void findShapePoints(std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
+  void findShapePoints(const std::string& theObjectAttributeId,
+                       const std::string& thePointAttributeId,
+                       std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
                        std::shared_ptr<GeomAPI_Pnt>& aLastPoint);
 
   std::shared_ptr<GeomAPI_Pnt2d> convertPoint(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
 
 private:
-  std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
-
-  typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
-                   std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
-                             std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
-
-  std::map<ObjectPtr, PointToRefsMap> myObjectToPoints;
+  std::map<std::shared_ptr<ModelAPI_Object>, std::set<GeomShapePtr> > myCashedShapes;
+  std::map<std::shared_ptr<ModelAPI_Object>, PointToRefsMap> myObjectToPoints;
 };
 
 #endif
index d42c783606ae58dc8d45bc5f5255c60d55d4c5a0..cb4b746b6de81389b3a75f4d5afef7170952ebf1 100755 (executable)
@@ -16,6 +16,7 @@
 #include "SketchPlugin_Line.h"
 #include "SketchPlugin_Point.h"
 #include "SketchPlugin_Sketch.h"
+#include "SketchPlugin_Trim.h"
 #include "SketchPlugin_Tools.h"
 
 #include "SketcherPrs_Tools.h"
@@ -36,6 +37,7 @@
 #include <ModelAPI_ResultConstruction.h>
 
 #include <ModelGeomAlgo_Point2D.h>
+#include <ModelGeomAlgo_Shape.h>
 
 #include <GeomAPI_Circ.h>
 #include <GeomAPI_Lin.h>
@@ -820,7 +822,7 @@ bool SketchPlugin_SplitValidator::isValid(const AttributePtr& theAttribute,
       aKind == SketchPlugin_Circle::ID()) {
 
     std::set<ResultPtr> anEdgeShapes;
-    ModelAPI_Tools::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+    ModelGeomAlgo_Shape::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
     if (anEdgeShapes.empty() || anEdgeShapes.size() > 1 /*there case has not existed yet*/)
       return aValid;
 
@@ -861,6 +863,63 @@ bool SketchPlugin_SplitValidator::isValid(const AttributePtr& theAttribute,
   return aValid;
 }
 
+bool SketchPlugin_TrimValidator::isValid(const AttributePtr& theAttribute,
+                                         const std::list<std::string>& theArguments,
+                                         Events_InfoMessage& theError) const
+{
+  bool aValid = false;
+
+  if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
+    theError = "The attribute with the %1 type is not processed";
+    theError.arg(theAttribute->attributeType());
+    return aValid;
+  }
+  AttributeReferencePtr aBaseObjectAttr =
+            std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+
+  std::shared_ptr<SketchPlugin_Feature> aTrimFeature =
+                 std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
+
+  ObjectPtr aBaseObject = aBaseObjectAttr->value();
+  if (!aBaseObject) {
+    AttributePtr aPreviewAttr = aTrimFeature->attribute(SketchPlugin_Trim::PREVIEW_OBJECT());
+    aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(aPreviewAttr);
+    aBaseObject = aBaseObjectAttr->value();
+
+    //return aValid;
+  }
+
+  FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObject);
+  if (!aBaseFeature)
+    return aValid;
+
+  std::string aKind = aBaseFeature->getKind();
+  if (aKind != SketchPlugin_Line::ID() &&
+      aKind != SketchPlugin_Arc::ID() &&
+      aKind != SketchPlugin_Circle::ID())
+    return aValid;
+
+  // point on feature
+  AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+                       aTrimFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
+
+  SketchPlugin_Sketch* aSketch = aTrimFeature->sketch();
+
+  std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
+  std::shared_ptr<GeomAPI_Pnt> anAttributePnt = aSketch->to3D(anAttributePnt2d->x(),
+                                                              anAttributePnt2d->y());
+
+  std::map<ObjectPtr, std::set<GeomShapePtr> > aCashedShapes;
+  std::map<ObjectPtr, std::map<std::shared_ptr<GeomAPI_Pnt>,
+           std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
+                     std::list<std::shared_ptr<ModelAPI_Object> > > > > anObjectToPoints;
+  SketchPlugin_Trim::fillObjectShapes(aBaseObject, aSketch->data()->owner(),
+                                      aCashedShapes, anObjectToPoints);
+  const std::set<GeomShapePtr>& aShapes = aCashedShapes[aBaseObject];
+
+  return aShapes.size() > 1;
+}
+
 bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
                                                const std::list<std::string>& theArguments,
                                                Events_InfoMessage& theError) const
index 70120d614a640331a6f65fc1800d725591c2d710..aaae2d95783e2bade6ab4bc715b58b6ab4979e03 100644 (file)
@@ -239,6 +239,27 @@ class SketchPlugin_SplitValidator : public ModelAPI_AttributeValidator
                        Events_InfoMessage& theError) const;
 };
 
+/**\class SketchPlugin_TrimValidator
+ * \ingroup Validators
+ * \brief Validator for the entity of the following type:
+ * - Linear segment with point(s) coinident to this line or intersected it
+ * - Arc with point(s) coincident to the arc or intersected it
+ * - Circle with at least 2 split-points on this circle or intersected it
+ *
+ * Checks that there are coincident point on selected feature.
+ */
+class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
+{
+ public:
+  //! returns true if attribute is valid
+  //! \param theAttribute the checked attribute
+  //! \param theArguments arguments of the attribute
+  //! \param theError error message
+  virtual bool isValid(const AttributePtr& theAttribute,
+                       const std::list<std::string>& theArguments,
+                       Events_InfoMessage& theError) const;
+};
+
 /**\class SketchPlugin_IntersectionValidator
  * \ingroup Validators
  * \brief Validator for the attribute to be intersected with the sketch plane.
index c8d4917b4c36ec9900225bfb6e763f1a22a0df55..49bf176586198358d9f30b70e2ac1ad7cc200760 100644 (file)
@@ -209,6 +209,13 @@ assert (math.fabs(aLine1Len - anExtLineLen) < 1.e-10)
 assert (math.fabs(aLine2Len - anExtLineLen) < 1.e-10)
 assert (model.dof(aSketchFeature) == 12)
 #=========================================================================
+# Remove costraint to check the DOF
+#=========================================================================
+aSession.startOperation()
+aDocument.removeFeature(aConstraintEqLen2)
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 13)
+#=========================================================================
 # End of test
 #=========================================================================
 
index 39762ed778d19ded02d0327425bad2adb1d5d321..59f353cb8f1e6c792f0216a3aa6ce315a2980190 100644 (file)
@@ -197,7 +197,17 @@ aSession.finishOperation()
 # Verify the objects of fillet are created
 #=========================================================================
 checkSmoothness(aSketchFeature)
-assert model.dof(aSketchFeature) == 14, "PlaneGCS limitation: if you see this message, then maybe PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 10, observed = {0}".format(model.dof(aSketchFeature))
+assert (model.dof(aSketchFeature) == 10)
+#=========================================================================
+# Move a line and check the fillet is correct
+#=========================================================================
+DELTA_X = DELTA_Y = 10.
+aSession.startOperation()
+aEndPoint1.setValue(aEndPoint1.x() + DELTA_X, aEndPoint1.y() + DELTA_Y)
+aSession.finishOperation()
+checkSmoothness(aSketchFeature)
+assert (model.dof(aSketchFeature) == 10)
+
 
 #=========================================================================
 # Create another sketch
@@ -228,12 +238,21 @@ aSession.finishOperation()
 # Verify the objects of fillet are created
 #=========================================================================
 checkSmoothness(aSketchFeature)
-assert model.dof(aSketchFeature) == 10, "PlaneGCS limitation: if you see this message, then maybe PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 8, observed = {0}".format(model.dof(aSketchFeature))
+assert (model.dof(aSketchFeature) == 8)
+#=========================================================================
+# Move a line and check the fillet is correct
+#=========================================================================
+DELTA_X = 1.
+DELTA_Y = -2.
+aSession.startOperation()
+aStartPoint1.setValue(aStartPoint1.x() + DELTA_X, aStartPoint1.y() + DELTA_Y)
+aSession.finishOperation()
+checkSmoothness(aSketchFeature)
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # End of test
 #=========================================================================
 
 # TODO: Improve Fillet test case by moving one of filleted objectes and check coincidence and tangency are correct
 
-# TODO: Checking of Python dump has been disabled until the Fillet redesigned.
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 58a222b68d0678b63696b366458c774a15b3d37e..15b101e444e24833e6a0a23ef2e2c0e2b66c006b 100644 (file)
@@ -58,8 +58,7 @@ class TestFilletInteracting(unittest.TestCase):
 
   def tearDown(self):
     model.end()
-    # TODO: Revert commented line to check Python dump
-    #self.assertTrue(model.checkPythonDump())
+    self.assertTrue(model.checkPythonDump())
     model.reset()
 
 
@@ -115,7 +114,6 @@ class TestFilletInteracting(unittest.TestCase):
     return [aFeatureA, aFeatureB]
 
 
-  @unittest.expectedFailure
   def test_fillet_two_lines(self):
     """ Test 1. Fillet on two connected lines
     """
@@ -173,7 +171,6 @@ class TestFilletInteracting(unittest.TestCase):
     # remove fillet for correct python dump
     self.myDocument.removeFeature(aFillet.feature())
 
-  @unittest.expectedFailure
   def test_fillet_arc_line(self):
     """ Test 3. Fillet on connected arc and line
     """
@@ -202,7 +199,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_two_arcs(self):
     """ Test 4. Fillet on two connected arcs
     """
@@ -231,7 +227,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_horizontal_vertical(self):
     """ Test 5. Fillet on two connected lines in case of Horizontal or Vertical constraints applied
     """
@@ -267,7 +262,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_orthogonal(self):
     """ Test 6. Fillet on two connected lines in case of Perpendicular constraint applied
     """
@@ -301,7 +295,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_parallel(self):
     """ Test 7. Fillet on two connected lines in case of Parallel constraint applied
     """
@@ -338,7 +331,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8])
 
-  @unittest.expectedFailure
   def test_fillet_with_equal_lines(self):
     """ Test 8. Fillet on two connected lines in case of Equal constraint applied
     """
@@ -355,7 +347,7 @@ class TestFilletInteracting(unittest.TestCase):
     model.do()
     self.checkDOF()
     self.mySketch.setFillet(aSketchLineA.startPoint())
-    self.myDOF += 2
+    self.myDOF += 2 # Equal has been removed
     model.do()
     self.checkFillet()
     self.checkDOF()
@@ -372,7 +364,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_equal_arcs(self):
     """ Test 9. Fillet on two connected arcs in case of Equal constraint applied
     """
@@ -389,7 +380,7 @@ class TestFilletInteracting(unittest.TestCase):
     model.do()
     self.checkDOF()
     self.mySketch.setFillet(aSketchArc1.endPoint())
-    self.myDOF += 1
+    self.myDOF += 2 # Equal has been removed
     model.do()
     self.checkFillet()
     self.checkDOF()
@@ -406,7 +397,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_length(self):
     """ Test 10. Fillet on two connected lines in case of Length constraint applied
     """
@@ -440,7 +430,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_radius(self):
     """ Test 11. Fillet on connected arc and line in case of Radius constraint is applied to arc
     """
@@ -474,7 +463,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_distance(self):
     """ Test 12. Fillet on two connected lines in case of Distance constraint applied
     """
@@ -495,7 +483,7 @@ class TestFilletInteracting(unittest.TestCase):
     model.do()
     self.checkDOF()
     self.mySketch.setFillet(aSketchLineA.startPoint())
-    self.myDOF += 1
+    self.myDOF += 2 # Distance has been removed
     model.do()
     self.checkFillet()
     self.checkDOF()
@@ -512,7 +500,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8])
 
-  @unittest.expectedFailure
   def test_fillet_with_fixed_point(self):
     """ Test 13. Fillet on two connected lines in case of Fixed constraint applied to the fillet point
     """
@@ -529,7 +516,7 @@ class TestFilletInteracting(unittest.TestCase):
     model.do()
     self.checkDOF()
     self.mySketch.setFillet(aSketchLineA.startPoint())
-    self.myDOF += 1
+    self.myDOF += 3 # Fixed constraint has been removed
     model.do()
     self.checkFillet()
     self.checkDOF()
@@ -546,7 +533,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_fixed_line(self):
     """ Test 14. Fillet on two connected lines in case of Fixed constraint applied to one of lines
     """
@@ -580,7 +566,6 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
-  @unittest.expectedFailure
   def test_fillet_with_angle(self):
     """ Test 15. Fillet on two connected lines in case of Perpendicular constraint applied
     """
@@ -615,6 +600,5 @@ class TestFilletInteracting(unittest.TestCase):
     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
 
 
-# TODO: Remove unittest.expectedFailure if the Tangency in PlaneGCS will be updated
 if __name__ == '__main__':
   unittest.main()
index ab023e2fa487a18ec9b418c331deca0c85aca68b..44f52eefb12c14240b4194801bb66f704fbc6ccd 100644 (file)
@@ -86,7 +86,7 @@
         <toolbox id="ArcType">
           <box id="CenterStartEnd" title="Center and two points" icon="icons/Sketch/arc_base_32x32.png">
             <sketch-2dpoint_selector id="ArcCenter" accept_expressions="0" title="Center" tooltip="Center of a circle"
-                                     enable_value="enable_by_preferences" />
+                                     enable_value="enable_by_preferences" reference_attribute="ArcCenterRef" />
             <!--reference_attribute="ArcCenterRef" />-->
             <sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"
                                      enable_value="enable_by_preferences"/>
                tooltip="Trim selected segment arc or circle on intersection points nearest to the graphic selection"
                icon="icons/Sketch/trim.png">
         <sketch_feature_point_selector
-            id="BaseObject"
+            id="SelectedObject"
             label="Split feature"
             tooltip="Select feature for split"
             shape_types="edge"
             use_external="false"
             use_graphic_intersection="true">
-          <!--<validator id="SketchPlugin_SplitValidator" parameters="use_graphic_intersection"/> -->
+          <validator id="SketchPlugin_TrimValidator"/>
         </sketch_feature_point_selector>
         <validator id="PartSet_SplitSelection"/>
       </feature>
index d6b370d7935baebed08ec5c1c91ac5286b913329..776221aa0419dcf7f876bb31b2c0d97dd745ffcf 100644 (file)
@@ -16,11 +16,8 @@ ENDFUNCTION(TO_FULL_PATH)
 INCLUDE(Common)
 
 SET(SKETCHSOLVER_HEADERS
-    SketchSolver.h
     SketchSolver_Error.h
     SketchSolver_Group.h
-    SketchSolver_IConstraintWrapper.h
-    SketchSolver_IEntityWrapper.h
     SketchSolver_Manager.h
     SketchSolver_Storage.h
 )
index 91bc90b795f7f0eb9c985a61605a203f588f31a1..2891c1209bff6a209f0966f773103cf0e068aac5 100644 (file)
@@ -7,7 +7,8 @@ SET(PLANEGCSSOLVER_HEADERS
     PlaneGCSSolver_Solver.h
     PlaneGCSSolver_Storage.h
     PlaneGCSSolver_ConstraintWrapper.h
-    PlaneGCSSolver_EntityWrapper.h
+    PlaneGCSSolver_EdgeWrapper.h
+    PlaneGCSSolver_EdgeWrapper.h
     PlaneGCSSolver_PointWrapper.h
     PlaneGCSSolver_ScalarWrapper.h
     PlaneGCSSolver_AngleWrapper.h
@@ -18,7 +19,7 @@ SET(PLANEGCSSOLVER_SOURCES
     PlaneGCSSolver_Solver.cpp
     PlaneGCSSolver_Storage.cpp
     PlaneGCSSolver_ConstraintWrapper.cpp
-    PlaneGCSSolver_EntityWrapper.cpp
+    PlaneGCSSolver_EdgeWrapper.cpp
     PlaneGCSSolver_PointWrapper.cpp
     PlaneGCSSolver_ScalarWrapper.cpp
     PlaneGCSSolver_AngleWrapper.cpp
index 216905155dd2e30354da5f05b6b3b77983dd2896..68109420e6d5b58c6e9f6013bcfd111bfbbc7064 100644 (file)
@@ -8,15 +8,12 @@
 #define PlaneGCSSolver_ConstraintWrapper_H_
 
 #include <PlaneGCSSolver_Defs.h>
-#include <PlaneGCSSolver_Solver.h>
 #include <PlaneGCSSolver_ScalarWrapper.h>
-#include <SketchSolver_IConstraintWrapper.h>
-
 
 /**
  *  Wrapper providing operations with PlaneGCS constraints.
  */
-class PlaneGCSSolver_ConstraintWrapper : public SketchSolver_IConstraintWrapper
+class PlaneGCSSolver_ConstraintWrapper
 {
 public:
   PlaneGCSSolver_ConstraintWrapper(const GCSConstraintPtr&            theConstraint,
@@ -31,6 +28,9 @@ public:
   void setConstraints(const std::list<GCSConstraintPtr>& theConstraints)
   { myGCSConstraints = theConstraints; }
 
+  /// \brief Return ID of current constraint
+  const ConstraintID& id() const
+  { return myID; }
   /// \brief Change constraint ID
   virtual void setId(const ConstraintID& theID);
 
@@ -50,9 +50,12 @@ public:
   { return myValueParam; }
 
 private:
+  ConstraintID                myID;
   SketchSolver_ConstraintType myType;
   ScalarWrapperPtr            myValueParam;
   std::list<GCSConstraintPtr> myGCSConstraints;
 };
 
+typedef std::shared_ptr<PlaneGCSSolver_ConstraintWrapper> ConstraintWrapperPtr;
+
 #endif
index 5a22cde9ee0fa75bd88b89a8257bef84d9553a4b..9274c2878907627ce2f9c77fa3551b8126960db7 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef PlaneGCSSolver_Defs_H_
 #define PlaneGCSSolver_Defs_H_
 
-#include <SketchSolver.h>
-
 #include <Constraints.h>
 #include <Geo.h>
 #include <memory>
@@ -17,4 +15,58 @@ typedef std::shared_ptr<GCS::Point>       GCSPointPtr;
 typedef std::shared_ptr<GCS::Curve>       GCSCurvePtr;
 typedef std::shared_ptr<GCS::Constraint>  GCSConstraintPtr;
 
+// Tolerance for value of parameters
+const double tolerance = 1.e-10;
+
+#define PI 3.1415926535897932
+
+// Types for data entities enumeration
+typedef int ConstraintID;
+
+// Predefined values for identifiers
+const ConstraintID CID_UNKNOWN  =  0;
+const ConstraintID CID_MOVEMENT = -1;
+
+/// Types of entities
+enum SketchSolver_EntityType {
+  ENTITY_UNKNOWN = 0,
+  ENTITY_SCALAR,
+  ENTITY_ANGLE,
+  ENTITY_POINT,
+  ENTITY_LINE,
+  ENTITY_CIRCLE,
+  ENTITY_ARC
+};
+
+/// Types of constraints
+enum SketchSolver_ConstraintType {
+  CONSTRAINT_UNKNOWN = 0,
+  CONSTRAINT_COINCIDENCE,      // base coincidence if we don't know exact type yet
+  CONSTRAINT_PT_PT_COINCIDENT,
+  CONSTRAINT_PT_ON_LINE,
+  CONSTRAINT_PT_ON_CIRCLE,
+  CONSTRAINT_MIDDLE_POINT,
+  CONSTRAINT_DISTANCE,         // base distance if we don't know the measured objects yet
+  CONSTRAINT_PT_PT_DISTANCE,
+  CONSTRAINT_PT_LINE_DISTANCE,
+  CONSTRAINT_RADIUS,
+  CONSTRAINT_ANGLE,
+  CONSTRAINT_FIXED,
+  CONSTRAINT_HORIZONTAL,
+  CONSTRAINT_VERTICAL,
+  CONSTRAINT_PARALLEL,
+  CONSTRAINT_PERPENDICULAR,
+  CONSTRAINT_SYMMETRIC,
+  CONSTRAINT_EQUAL,           // base equality if we don't know the measured objects yet
+  CONSTRAINT_EQUAL_LINES,
+  CONSTRAINT_EQUAL_LINE_ARC,
+  CONSTRAINT_EQUAL_RADIUS,
+  CONSTRAINT_TANGENT,         // base tangency if we don't know the measured objects yet
+  CONSTRAINT_TANGENT_CIRCLE_LINE,
+  CONSTRAINT_TANGENT_CIRCLE_CIRCLE,
+  CONSTRAINT_COLLINEAR,
+  CONSTRAINT_MULTI_TRANSLATION,
+  CONSTRAINT_MULTI_ROTATION
+};
+
 #endif
diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EdgeWrapper.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EdgeWrapper.cpp
new file mode 100644 (file)
index 0000000..51cef8c
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:    PlaneGCSSolver_EdgeWrapper.cpp
+// Created: 14 Dec 2015
+// Author:  Artem ZHIDKOV
+
+#include <PlaneGCSSolver_EdgeWrapper.h>
+
+PlaneGCSSolver_EdgeWrapper::PlaneGCSSolver_EdgeWrapper(const GCSCurvePtr theEntity)
+  : myEntity(theEntity)
+{
+  std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(myEntity);
+  if (aLine) myType = ENTITY_LINE;
+  else {
+    std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(myEntity);
+    if (anArc) myType = ENTITY_ARC;
+    else {
+      std::shared_ptr<GCS::Circle> aCircle = std::dynamic_pointer_cast<GCS::Circle>(myEntity);
+      if (aCircle) myType = ENTITY_CIRCLE;
+    }
+  }
+}
diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EdgeWrapper.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EdgeWrapper.h
new file mode 100644 (file)
index 0000000..206c8a4
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:    PlaneGCSSolver_EdgeWrapper.h
+// Created: 14 Dec 2015
+// Author:  Artem ZHIDKOV
+
+#ifndef PlaneGCSSolver_EdgeWrapper_H_
+#define PlaneGCSSolver_EdgeWrapper_H_
+
+#include <PlaneGCSSolver_Defs.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
+
+/**
+ *  Wrapper providing operations with PlaneGCS entities (lines, circles and arcs).
+ */
+class PlaneGCSSolver_EdgeWrapper : public PlaneGCSSolver_EntityWrapper
+{
+public:
+  PlaneGCSSolver_EdgeWrapper(const GCSCurvePtr theEntity);
+
+  /// \brief Return PlaneGCS geometric entity
+  const GCSCurvePtr& entity() const
+  { return myEntity; }
+  /// \brief Return PlaneGCS geometric entity to change
+  GCSCurvePtr& changeEntity()
+  { return myEntity; }
+
+  /// \brief Return type of current entity
+  virtual SketchSolver_EntityType type() const
+  { return myType; }
+
+private:
+  SketchSolver_EntityType myType;
+  GCSCurvePtr myEntity;
+};
+
+typedef std::shared_ptr<PlaneGCSSolver_EdgeWrapper> EdgeWrapperPtr;
+
+#endif
index 697d2db5c0c6f9a9be17bb49cf073ea2c1318955..97a3b83f05bf067f26295d53d0cf5299c70c04df 100644 (file)
@@ -8,7 +8,7 @@
 
 #include <PlaneGCSSolver_PointWrapper.h>
 #include <PlaneGCSSolver_ScalarWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
 
 static void destroyScalar(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
 {
@@ -26,8 +26,8 @@ static void destroyPoint(const EntityWrapperPtr& theEntity, GCS::SET_pD& thePara
 
 static void destroyLine(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
 {
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+  std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+      std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
   std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(anEntity->entity());
   theParams.insert(aLine->p1.x);
   theParams.insert(aLine->p1.y);
@@ -37,8 +37,8 @@ static void destroyLine(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParam
 
 static void destroyCircle(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
 {
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+  std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+      std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
   std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(anEntity->entity());
   theParams.insert(aCirc->center.x);
   theParams.insert(aCirc->center.y);
@@ -47,8 +47,8 @@ static void destroyCircle(const EntityWrapperPtr& theEntity, GCS::SET_pD& thePar
 
 static void destroyArc(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
 {
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+  std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+      std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
   std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEntity->entity());
   theParams.insert(anArc->center.x);
   theParams.insert(anArc->center.y);
diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_EntityWrapper.cpp
deleted file mode 100644 (file)
index 907ca61..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    PlaneGCSSolver_EntityWrapper.cpp
-// Created: 14 Dec 2015
-// Author:  Artem ZHIDKOV
-
-#include <PlaneGCSSolver_EntityWrapper.h>
-
-PlaneGCSSolver_EntityWrapper::PlaneGCSSolver_EntityWrapper(const GCSCurvePtr theEntity)
-  : myEntity(theEntity)
-{
-  std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(myEntity);
-  if (aLine) myType = ENTITY_LINE;
-  else {
-    std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(myEntity);
-    if (anArc) myType = ENTITY_ARC;
-    else {
-      std::shared_ptr<GCS::Circle> aCircle = std::dynamic_pointer_cast<GCS::Circle>(myEntity);
-      if (aCircle) myType = ENTITY_CIRCLE;
-    }
-  }
-}
index 38c92198a494a3d8d08476be9bc18a5db407cd5f..b9a3981d075b73570e3bb8b5ccc6f8f70d790c95 100644 (file)
@@ -1,37 +1,41 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
 // File:    PlaneGCSSolver_EntityWrapper.h
-// Created: 14 Dec 2015
+// Created: 30 Nov 2015
 // Author:  Artem ZHIDKOV
 
 #ifndef PlaneGCSSolver_EntityWrapper_H_
 #define PlaneGCSSolver_EntityWrapper_H_
 
 #include <PlaneGCSSolver_Defs.h>
-#include <SketchSolver_IEntityWrapper.h>
+
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Feature.h>
+
+#include <list>
+#include <memory>
 
 /**
- *  Wrapper providing operations with PlaneGCS entities (lines, circles and arcs).
+ *  Wrapper providing operations with entities regardless the solver.
  */
-class PlaneGCSSolver_EntityWrapper : public SketchSolver_IEntityWrapper
+class PlaneGCSSolver_EntityWrapper
 {
 public:
-  PlaneGCSSolver_EntityWrapper(const GCSCurvePtr theEntity);
-
-  /// \brief Return PlaneGCS geometric entity
-  const GCSCurvePtr& entity() const
-  { return myEntity; }
-  /// \brief Return PlaneGCS geometric entity to change
-  GCSCurvePtr& changeEntity()
-  { return myEntity; }
+  PlaneGCSSolver_EntityWrapper() : myExternal(false) {}
+  virtual ~PlaneGCSSolver_EntityWrapper() {}
 
   /// \brief Return type of current entity
-  virtual SketchSolver_EntityType type() const
-  { return myType; }
+  virtual SketchSolver_EntityType type() const = 0;
+
+  /// \brief Change flag indicating the entity cannot be changed in the solver
+  void setExternal(bool theExternal) { myExternal = theExternal; }
+  /// \brief Return the External flag
+  bool isExternal() const { return myExternal; }
 
 private:
-  SketchSolver_EntityType myType;
-  GCSCurvePtr myEntity;
+  bool myExternal;
 };
 
+typedef std::shared_ptr<PlaneGCSSolver_EntityWrapper> EntityWrapperPtr;
+
 #endif
index a0ffc362f8f68ef8f9426a5c588952f137e7981b..e9cf468a9aa7e8c1ab2c9dac0f8b7212172a6634 100644 (file)
@@ -5,7 +5,7 @@
 // Author:  Artem ZHIDKOV
 
 #include <PlaneGCSSolver_FeatureBuilder.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
 #include <PlaneGCSSolver_PointWrapper.h>
 #include <PlaneGCSSolver_ScalarWrapper.h>
 
@@ -117,7 +117,7 @@ EntityWrapperPtr createLine(const AttributeEntityMap& theAttributes)
       aNewLine->p2 = *(aPoint->point());
   }
 
-  return EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(aNewLine));
+  return EntityWrapperPtr(new PlaneGCSSolver_EdgeWrapper(aNewLine));
 }
 
 EntityWrapperPtr createCircle(const AttributeEntityMap& theAttributes)
@@ -138,7 +138,7 @@ EntityWrapperPtr createCircle(const AttributeEntityMap& theAttributes)
     }
   }
 
-  return EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(aNewCircle));
+  return EntityWrapperPtr(new PlaneGCSSolver_EdgeWrapper(aNewCircle));
 }
 
 static double* createParameter(PlaneGCSSolver_Storage* theStorage)
@@ -203,7 +203,7 @@ EntityWrapperPtr createArc(const AttributeEntityMap&    theAttributes,
         aNewArc->center, aNewArc->end, aNewArc->endAngle)));
   }
 
-  return EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(aNewArc));
+  return EntityWrapperPtr(new PlaneGCSSolver_EdgeWrapper(aNewArc));
 }
 
 bool isAttributeApplicable(const std::string& theAttrName, const std::string& theOwnerName)
index 6bb2ade7a7c17fdcdb0c67c334628c4af04392ad..8acd7df4b54a657828b6b94a489e3ffd42d3f295 100644 (file)
@@ -8,12 +8,12 @@
 #define PlaneGCSSolver_PointWrapper_H_
 
 #include <PlaneGCSSolver_Defs.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
 
 /**
  *  Wrapper providing operations with PlaneGCS points.
  */
-class PlaneGCSSolver_PointWrapper : public SketchSolver_IEntityWrapper
+class PlaneGCSSolver_PointWrapper : public PlaneGCSSolver_EntityWrapper
 {
 public:
   PlaneGCSSolver_PointWrapper(const GCSPointPtr thePoint);
@@ -33,4 +33,6 @@ private:
   GCSPointPtr myPoint;
 };
 
+typedef std::shared_ptr<PlaneGCSSolver_PointWrapper> PointWrapperPtr;
+
 #endif
index f0907a5882f7909347bb3f696bc901d535638a05..2838bb6afdb433ad9e277f62a68c3b233158255a 100644 (file)
@@ -8,12 +8,12 @@
 #define PlaneGCSSolver_ScalarWrapper_H_
 
 #include <PlaneGCSSolver_Defs.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
 
 /**
  *  Wrapper providing operations with PlaneGCS scalars.
  */
-class PlaneGCSSolver_ScalarWrapper : public SketchSolver_IEntityWrapper
+class PlaneGCSSolver_ScalarWrapper : public PlaneGCSSolver_EntityWrapper
 {
 public:
   PlaneGCSSolver_ScalarWrapper(double *const theParam);
index e9be8a299f31ccd34f080f5eb6185b7489d27f8e..2be2d62b5ac9bc0472d6ecc262b4f4d06c8c9037 100644 (file)
@@ -29,26 +29,16 @@ void PlaneGCSSolver_Solver::clear()
   myDOF = 0;
 }
 
-void PlaneGCSSolver_Solver::addConstraint(GCSConstraintPtr theConstraint,
-                                          const SketchSolver_ConstraintType theType)
+void PlaneGCSSolver_Solver::addConstraint(GCSConstraintPtr theConstraint)
 {
   myEquationSystem->addConstraint(theConstraint.get());
   myConstraints[theConstraint->getTag()].insert(theConstraint);
   myDOF = -1;
-
-  // Workaround: avoid tangent constraint in the list of redundant
-  if (theType == CONSTRAINT_TANGENT_CIRCLE_LINE ||
-      theType == CONSTRAINT_TANGENT_CIRCLE_CIRCLE ||
-      theType == CONSTRAINT_PT_PT_COINCIDENT ||
-      theType == CONSTRAINT_PT_ON_CIRCLE ||
-      theType == CONSTRAINT_PT_ON_LINE)
-    myConstraintIDsNotRedundant.insert(theConstraint->getTag());
 }
 
 void PlaneGCSSolver_Solver::removeConstraint(ConstraintID theID)
 {
   myConstraints.erase(theID);
-  myConstraintIDsNotRedundant.erase(theID);
   if (myConstraints.empty()) {
     myEquationSystem->clear();
     myDOF = (int)myParameters.size();
@@ -132,12 +122,6 @@ void PlaneGCSSolver_Solver::collectConflicting()
   myConflictingIDs.insert(aConflict.begin(), aConflict.end());
 
   myEquationSystem->getRedundant(aConflict);
-  // Workaround: avoid conflicting tangent constraints
-  GCS::VEC_I aTemp = aConflict;
-  aConflict.clear();
-  for (GCS::VEC_I::iterator anIt = aTemp.begin(); anIt != aTemp.end(); ++anIt)
-    if (myConstraintIDsNotRedundant.find(*anIt) == myConstraintIDsNotRedundant.end())
-      aConflict.push_back(*anIt);
   myConflictingIDs.insert(aConflict.begin(), aConflict.end());
 
   myConfCollected = true;
index b019a314c0c16327afb1e738cd3cf3d3c5355013..4da9e60dc5aa116ed4db176f28dc0b1d6f52b323 100644 (file)
@@ -7,8 +7,8 @@
 #ifndef PlaneGCSSolver_Solver_H_
 #define PlaneGCSSolver_Solver_H_
 
-#include <SketchSolver_IConstraintWrapper.h>
 #include <PlaneGCSSolver_Defs.h>
+#include <PlaneGCSSolver_ConstraintWrapper.h>
 
 #include <GCS.h>
 
@@ -32,7 +32,7 @@ public:
   void clear();
 
   /// \brief Add constraint to the system of equations
-  void addConstraint(GCSConstraintPtr theConstraint, const SketchSolver_ConstraintType theType);
+  void addConstraint(GCSConstraintPtr theConstraint);
 
   /// \brief Remove constraint from the system of equations
   void removeConstraint(ConstraintID theID);
@@ -64,10 +64,6 @@ private:
   GCS::VEC_pD                  myParameters;     ///< list of unknowns
   ConstraintMap                myConstraints;    ///< list of constraints
 
-  /// IDs of constraints (coincidence, tangency) which will not be treated as conflicting
-  /// if they are reported as redundant
-  GCS::SET_I                   myConstraintIDsNotRedundant;
-
   std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
 
   GCS::SET_I                   myConflictingIDs; ///< list of IDs of conflicting constraints
index 0735867197a867dcca9b13ecdd2e7e4d73bcd476..472f4add7ccb80c7e4041f1171191d00e225c9ca 100644 (file)
@@ -7,7 +7,7 @@
 #include <PlaneGCSSolver_Storage.h>
 #include <PlaneGCSSolver_Solver.h>
 #include <PlaneGCSSolver_ConstraintWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
 #include <PlaneGCSSolver_PointWrapper.h>
 
 #include <PlaneGCSSolver_AttributeBuilder.h>
@@ -31,7 +31,7 @@ static void constraintsToSolver(const ConstraintWrapperPtr& theConstraint,
       std::dynamic_pointer_cast<PlaneGCSSolver_ConstraintWrapper>(theConstraint)->constraints();
   std::list<GCSConstraintPtr>::const_iterator anIt = aConstraints.begin();
   for (; anIt != aConstraints.end(); ++anIt)
-    theSolver->addConstraint(*anIt, theConstraint->type());
+    theSolver->addConstraint(*anIt);
 }
 
 
@@ -193,8 +193,8 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
   if (aRelated && aRelated->type() == ENTITY_ARC) {
     /// TODO: this code should be shared with FeatureBuilder somehow
 
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-        std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(aRelated);
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+        std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(aRelated);
     std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEntity->entity());
 
     static std::shared_ptr<GeomAPI_Dir2d> OX(new GeomAPI_Dir2d(1.0, 0.0));
@@ -259,9 +259,20 @@ bool PlaneGCSSolver_Storage::removeConstraint(ConstraintPtr theConstraint)
   std::map<ConstraintPtr, ConstraintWrapperPtr>::iterator
       aFound = myConstraintMap.find(theConstraint);
   if (aFound != myConstraintMap.end()) {
-    ConstraintID anID = aFound->second->id();
+    ConstraintWrapperPtr aCW = aFound->second;
+    ConstraintID anID = aCW->id();
+
     // Remove solver's constraints
     mySketchSolver->removeConstraint(anID);
+
+    // Remove value if exists
+    const ScalarWrapperPtr& aValue = aCW->valueParameter();
+    if (aValue) {
+      GCS::SET_pD aParToRemove;
+      aParToRemove.insert(aValue->scalar());
+      removeParameters(aParToRemove);
+    }
+
     // Remove constraint
     myConstraintMap.erase(aFound);
 
@@ -295,7 +306,8 @@ void PlaneGCSSolver_Storage::removeInvalidEntities()
   for (; aFIter != myFeatureMap.end(); aFIter++)
     if (!aFIter->first->data() || !aFIter->first->data()->isValid()) {
       anInvalidFeatures.push_back(aFIter->first);
-      aDestroyer.remove(aFIter->second);
+      if (aFIter->second)
+        aDestroyer.remove(aFIter->second);
 
       // remove invalid arc
       std::map<EntityWrapperPtr, ConstraintWrapperPtr>::iterator
index 752651d3319895e25c989d5995011b4441c205a9..1855de212ac9a0be336bd95ccb8ab0d80915d7c6 100644 (file)
@@ -8,8 +8,6 @@
 #define PlaneGCSSolver_Storage_H_
 
 #include <PlaneGCSSolver_Defs.h>
-
-#include <SketchSolver.h>
 #include <SketchSolver_Storage.h>
 
 class PlaneGCSSolver_EntityBuilder;
index 3dd68b54b56d78de73ca62459bdaf9c3c1d56703..52408859619c66430373162997115b711760c8a7 100644 (file)
@@ -5,7 +5,7 @@
 // Author:  Artem ZHIDKOV
 
 #include <PlaneGCSSolver_Tools.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
 #include <PlaneGCSSolver_PointWrapper.h>
 #include <PlaneGCSSolver_ScalarWrapper.h>
 #include <PlaneGCSSolver_ConstraintWrapper.h>
@@ -41,7 +41,7 @@
 #include <cmath>
 
 
-#define GCS_ENTITY_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(x)
+#define GCS_EDGE_WRAPPER(x)   std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(x)
 #define GCS_POINT_WRAPPER(x)  std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(x)
 #define GCS_SCALAR_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(x)
 
@@ -53,7 +53,7 @@ static ConstraintWrapperPtr
 static ConstraintWrapperPtr
   createConstraintPointOnEntity(const SketchSolver_ConstraintType& theType,
                                 std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
-                                std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+                                std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
 static ConstraintWrapperPtr
   createConstraintDistancePointPoint(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
                                      std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint1,
@@ -61,36 +61,32 @@ static ConstraintWrapperPtr
 static ConstraintWrapperPtr
   createConstraintDistancePointLine(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
                                     std::shared_ptr<PlaneGCSSolver_PointWrapper>  thePoint,
-                                    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+                                    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
 static ConstraintWrapperPtr
   createConstraintRadius(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
-                         std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+                         std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
 static ConstraintWrapperPtr
   createConstraintAngle(ConstraintPtr theConstraint,
                         std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
-                        std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-                        std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
+                        std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+                        std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2);
 static ConstraintWrapperPtr
   createConstraintHorizVert(const SketchSolver_ConstraintType& theType,
-                            std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+                            std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
 static ConstraintWrapperPtr
-  createConstraintParallel(std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-                           std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
+  createConstraintParallel(std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+                           std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2);
 static ConstraintWrapperPtr
-  createConstraintPerpendicular(std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-                                std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
+  createConstraintPerpendicular(std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+                                std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2);
 static ConstraintWrapperPtr
   createConstraintEqual(const SketchSolver_ConstraintType& theType,
-                        std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-                        std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2,
+                        std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+                        std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2,
                         std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theIntermed);
-static ConstraintWrapperPtr
-  createConstraintTangent(const SketchSolver_ConstraintType& theType,
-                          std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-                          std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2);
 static ConstraintWrapperPtr
   createConstraintMiddlePoint(std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
-                              std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity);
+                              std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
 
 
 
@@ -155,10 +151,10 @@ ConstraintWrapperPtr PlaneGCSSolver_Tools::createConstraint(
     break;
   case CONSTRAINT_PT_ON_LINE:
   case CONSTRAINT_PT_ON_CIRCLE:
-    aResult = createConstraintPointOnEntity(theType, aPoint1, GCS_ENTITY_WRAPPER(theEntity1));
+    aResult = createConstraintPointOnEntity(theType, aPoint1, GCS_EDGE_WRAPPER(theEntity1));
     break;
   case CONSTRAINT_MIDDLE_POINT:
-    aResult = createConstraintMiddlePoint(aPoint1, GCS_ENTITY_WRAPPER(theEntity1));
+    aResult = createConstraintMiddlePoint(aPoint1, GCS_EDGE_WRAPPER(theEntity1));
     break;
   case CONSTRAINT_PT_PT_DISTANCE:
     aResult = createConstraintDistancePointPoint(GCS_SCALAR_WRAPPER(theValue), aPoint1, aPoint2);
@@ -166,49 +162,40 @@ ConstraintWrapperPtr PlaneGCSSolver_Tools::createConstraint(
   case CONSTRAINT_PT_LINE_DISTANCE:
     aResult = createConstraintDistancePointLine(GCS_SCALAR_WRAPPER(theValue),
                                                 aPoint1,
-                                                GCS_ENTITY_WRAPPER(theEntity1));
+                                                GCS_EDGE_WRAPPER(theEntity1));
     break;
   case CONSTRAINT_RADIUS:
     aResult = createConstraintRadius(GCS_SCALAR_WRAPPER(theValue),
-                                     GCS_ENTITY_WRAPPER(theEntity1));
+                                     GCS_EDGE_WRAPPER(theEntity1));
     break;
   case CONSTRAINT_ANGLE:
     aResult = createConstraintAngle(theConstraint,
                   GCS_SCALAR_WRAPPER(theValue),
-                  GCS_ENTITY_WRAPPER(theEntity1), GCS_ENTITY_WRAPPER(theEntity2));
+                  GCS_EDGE_WRAPPER(theEntity1), GCS_EDGE_WRAPPER(theEntity2));
     break;
   case CONSTRAINT_FIXED:
     break;
   case CONSTRAINT_HORIZONTAL:
   case CONSTRAINT_VERTICAL:
-    aResult = createConstraintHorizVert(theType, GCS_ENTITY_WRAPPER(theEntity1));
+    aResult = createConstraintHorizVert(theType, GCS_EDGE_WRAPPER(theEntity1));
     break;
   case CONSTRAINT_PARALLEL:
-    aResult = createConstraintParallel(GCS_ENTITY_WRAPPER(theEntity1),
-                                       GCS_ENTITY_WRAPPER(theEntity2));
+    aResult = createConstraintParallel(GCS_EDGE_WRAPPER(theEntity1),
+                                       GCS_EDGE_WRAPPER(theEntity2));
     break;
   case CONSTRAINT_PERPENDICULAR:
-    aResult = createConstraintPerpendicular(GCS_ENTITY_WRAPPER(theEntity1),
-                                            GCS_ENTITY_WRAPPER(theEntity2));
+    aResult = createConstraintPerpendicular(GCS_EDGE_WRAPPER(theEntity1),
+                                            GCS_EDGE_WRAPPER(theEntity2));
     break;
   case CONSTRAINT_EQUAL_LINES:
     anIntermediate = GCS_SCALAR_WRAPPER(theValue); // parameter is used to store length of lines
   case CONSTRAINT_EQUAL_LINE_ARC:
   case CONSTRAINT_EQUAL_RADIUS:
     aResult = createConstraintEqual(theType,
-                                    GCS_ENTITY_WRAPPER(theEntity1),
-                                    GCS_ENTITY_WRAPPER(theEntity2),
+                                    GCS_EDGE_WRAPPER(theEntity1),
+                                    GCS_EDGE_WRAPPER(theEntity2),
                                     anIntermediate);
     break;
-  case CONSTRAINT_TANGENT_CIRCLE_LINE:
-  case CONSTRAINT_TANGENT_CIRCLE_CIRCLE:
-    aResult = createConstraintTangent(theType,
-                                      GCS_ENTITY_WRAPPER(theEntity1),
-                                      GCS_ENTITY_WRAPPER(theEntity2));
-    break;
-  case CONSTRAINT_MULTI_TRANSLATION:
-  case CONSTRAINT_MULTI_ROTATION:
-  case CONSTRAINT_SYMMETRIC:
   default:
     break;
   }
@@ -232,8 +219,8 @@ std::shared_ptr<GeomAPI_Lin2d> PlaneGCSSolver_Tools::line(EntityWrapperPtr theEn
   if (theEntity->type() != ENTITY_LINE)
     return std::shared_ptr<GeomAPI_Lin2d>();
 
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
+  std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+      std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
   std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(anEntity->entity());
   return std::shared_ptr<GeomAPI_Lin2d>(
       new GeomAPI_Lin2d(*(aLine->p1.x), *(aLine->p1.y), *(aLine->p2.x), *(aLine->p2.y)));
@@ -278,7 +265,7 @@ ConstraintWrapperPtr createConstraintCoincidence(
 ConstraintWrapperPtr createConstraintPointOnEntity(
     const SketchSolver_ConstraintType& theType,
     std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
 {
   GCSConstraintPtr aNewConstr;
 
@@ -305,7 +292,7 @@ ConstraintWrapperPtr createConstraintPointOnEntity(
 
 ConstraintWrapperPtr createConstraintMiddlePoint(
     std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
 {
   GCSPointPtr aPoint = thePoint->point();
   std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity->entity());
@@ -338,7 +325,7 @@ ConstraintWrapperPtr createConstraintDistancePointPoint(
 ConstraintWrapperPtr createConstraintDistancePointLine(
     std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
     std::shared_ptr<PlaneGCSSolver_PointWrapper>  thePoint,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
 {
   std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity->entity());
   GCSConstraintPtr aNewConstr(new GCS::ConstraintP2LDistance(
@@ -351,7 +338,7 @@ ConstraintWrapperPtr createConstraintDistancePointLine(
 
 ConstraintWrapperPtr createConstraintRadius(
     std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
 {
   std::shared_ptr<GCS::Circle> aCircle =
     std::dynamic_pointer_cast<GCS::Circle>(theEntity->entity());
@@ -365,8 +352,8 @@ ConstraintWrapperPtr createConstraintRadius(
 ConstraintWrapperPtr createConstraintAngle(
     ConstraintPtr theConstraint,
     std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2)
 {
   std::shared_ptr<GCS::Line> aLine1 = std::dynamic_pointer_cast<GCS::Line>(theEntity1->entity());
   bool isLine1Rev = theConstraint->boolean(
@@ -391,7 +378,7 @@ ConstraintWrapperPtr createConstraintAngle(
 
 ConstraintWrapperPtr createConstraintHorizVert(
     const SketchSolver_ConstraintType& theType,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
 {
   std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity->entity());
   GCSConstraintPtr aNewConstr;
@@ -404,8 +391,8 @@ ConstraintWrapperPtr createConstraintHorizVert(
 }
 
 ConstraintWrapperPtr createConstraintParallel(
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2)
 {
   std::shared_ptr<GCS::Line> aLine1 = std::dynamic_pointer_cast<GCS::Line>(theEntity1->entity());
   std::shared_ptr<GCS::Line> aLine2 = std::dynamic_pointer_cast<GCS::Line>(theEntity2->entity());
@@ -416,8 +403,8 @@ ConstraintWrapperPtr createConstraintParallel(
 }
 
 ConstraintWrapperPtr createConstraintPerpendicular(
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2)
 {
   std::shared_ptr<GCS::Line> aLine1 = std::dynamic_pointer_cast<GCS::Line>(theEntity1->entity());
   std::shared_ptr<GCS::Line> aLine2 = std::dynamic_pointer_cast<GCS::Line>(theEntity2->entity());
@@ -429,8 +416,8 @@ ConstraintWrapperPtr createConstraintPerpendicular(
 
 ConstraintWrapperPtr createConstraintEqual(
     const SketchSolver_ConstraintType& theType,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2,
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity1,
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity2,
     std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theIntermed)
 {
   if (theType == CONSTRAINT_EQUAL_LINE_ARC)
@@ -465,60 +452,3 @@ ConstraintWrapperPtr createConstraintEqual(
     aResult->setValueParameter(theIntermed);
   return aResult;
 }
-
-ConstraintWrapperPtr createConstraintTangent(
-    const SketchSolver_ConstraintType& theType,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity1,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
-{
-  GCSConstraintPtr aNewConstr;
-  if (theType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
-    GCSCurvePtr anEntCirc, anEntLine;
-    if (theEntity1->type() == ENTITY_LINE) {
-      anEntLine = theEntity1->entity();
-      anEntCirc = theEntity2->entity();
-    } else {
-      anEntLine = theEntity2->entity();
-      anEntCirc = theEntity1->entity();
-    }
-
-    std::shared_ptr<GCS::Circle> aCirc =
-      std::dynamic_pointer_cast<GCS::Circle>(anEntCirc);
-    std::shared_ptr<GCS::Line> aLine =
-      std::dynamic_pointer_cast<GCS::Line>(anEntLine);
-
-    aNewConstr =
-      GCSConstraintPtr(new GCS::ConstraintP2LDistance(aCirc->center, *aLine, aCirc->rad));
-  } else {
-    std::shared_ptr<GCS::Circle> aCirc1 =
-      std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
-    std::shared_ptr<GCS::Circle> aCirc2 =
-      std::dynamic_pointer_cast<GCS::Circle>(theEntity2->entity());
-
-    double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
-    double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
-    double aDist = sqrt(aDX * aDX + aDY * aDY);
-    aNewConstr = GCSConstraintPtr(new GCS::ConstraintTangentCircumf(aCirc1->center, aCirc2->center,
-        aCirc1->rad, aCirc2->rad, (aDist < *(aCirc1->rad) || aDist < *(aCirc2->rad))));
-  }
-
-  return ConstraintWrapperPtr(new PlaneGCSSolver_ConstraintWrapper(aNewConstr, theType));
-}
-
-bool PlaneGCSSolver_Tools::isArcArcTangencyInternal(
-    EntityWrapperPtr theArc1, EntityWrapperPtr theArc2)
-{
-  std::shared_ptr<GCS::Circle> aCirc1 = std::dynamic_pointer_cast<GCS::Circle>(
-      GCS_ENTITY_WRAPPER(theArc1)->entity());
-  std::shared_ptr<GCS::Circle> aCirc2 = std::dynamic_pointer_cast<GCS::Circle>(
-      GCS_ENTITY_WRAPPER(theArc2)->entity());
-
-  if (!aCirc1 || !aCirc2)
-    return false;
-
-  double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
-  double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
-  double aDist = sqrt(aDX * aDX + aDY * aDY);
-
-  return (aDist < *(aCirc1->rad) || aDist < *(aCirc2->rad));
-}
index 56dfbbdbbb8793db3312707ee9eee472f5337546..db4820107eba0eb4c1e6f7983941cf2780cab9da 100644 (file)
@@ -54,11 +54,6 @@ namespace PlaneGCSSolver_Tools
   /// \brief Convert entity to line
   /// \return empty pointer if the entity is not a line
   std::shared_ptr<GeomAPI_Lin2d> line(FeaturePtr theFeature);
-
-  /// \brief Check if two connected arcs have centers
-  ///        in same direction relatively to connection point
-  bool isArcArcTangencyInternal(EntityWrapperPtr theArc1,
-                                EntityWrapperPtr theArc2);
 };
 
 #endif
index 6e66ae26e36aecda630584ac3a0bea60b5db40e1..6b1d358cb6725c8e09b4b2e4e4b3d9584415fe8a 100644 (file)
@@ -5,7 +5,7 @@
 // Author:  Artem ZHIDKOV
 
 #include <PlaneGCSSolver_UpdateCoincidence.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
 #include <PlaneGCSSolver_PointWrapper.h>
 #include <SketchSolver_Constraint.h>
 
@@ -108,7 +108,7 @@ bool PlaneGCSSolver_UpdateCoincidence::isPointOnEntity(
 
   if (theEntity->type() == ENTITY_LINE) {
     std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(
-        std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity)->entity());
+        std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity)->entity());
     return anIt->isExist(aLine->p1) || anIt->isExist(aLine->p2);
   }
   return false;
index 9d3b0eb99b1d2a26afe9bd530fcf1165ae7eb38f..558756492fa68c7406ad86e8ab59d57bf65dd04b 100644 (file)
@@ -8,7 +8,7 @@
 #define PlaneGCSSolver_UpdateCoincidence_H_
 
 #include <PlaneGCSSolver_Update.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
 
 #include <GCS.h>
 
diff --git a/src/SketchSolver/SketchSolver.h b/src/SketchSolver/SketchSolver.h
deleted file mode 100644 (file)
index 7757023..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-#ifndef SKETCHSOLVER_H
-#define SKETCHSOLVER_H
-
-#include <stdlib.h>
-
-/// Tolerance for value of parameters
-const double tolerance = 1.e-10;
-
-#define PI 3.1415926535897932
-
-// Types for data entities enumeration
-typedef int ConstraintID;
-
-// Predefined values for identifiers
-const ConstraintID CID_UNKNOWN  =  0;
-const ConstraintID CID_MOVEMENT = -1;
-
-#endif
index 5c06e0aa5434f268cfd35570011e0375cb26e696..c0545a520aae4e97cbd94cc3b8e9d0f356129a30 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_Constraint_H_
 #define SketchSolver_Constraint_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Storage.h>
 #include <PlaneGCSSolver_Update.h>
 
index 59061a302973179f667a3d7ae9e6d9ac5a76d019..83ec15b408714b155ffb7e20eb4cc9ff55743876 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintCoincidence_H_
 #define SketchSolver_ConstraintCoincidence_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 /** \class   SketchSolver_ConstraintCoincidence
index 0d35cf485945a1562d2c51f404b6d001a0a4b740..32ec0721d2b74809e6aaf0282efb1a2366d8ab9b 100644 (file)
@@ -4,7 +4,7 @@
 #include <SketchSolver_Error.h>
 
 #include <PlaneGCSSolver_ConstraintWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
 #include <PlaneGCSSolver_PointWrapper.h>
 #include <PlaneGCSSolver_UpdateCoincidence.h>
 
@@ -13,7 +13,7 @@
 static ConstraintWrapperPtr createPointsOnLine(
     std::shared_ptr<PlaneGCSSolver_PointWrapper>  thePoint1,
     std::shared_ptr<PlaneGCSSolver_PointWrapper>  thePoint2,
-    std::shared_ptr<PlaneGCSSolver_EntityWrapper> theLine)
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theLine)
 {
   std::shared_ptr<GCS::Line> aGCSLine = std::dynamic_pointer_cast<GCS::Line>(theLine->entity());
 
@@ -82,7 +82,7 @@ void SketchSolver_ConstraintCollinear::notify(const FeaturePtr&      theFeature,
   bool aConstraintToApply[4] = {false, false, false, false};
   ConstraintWrapperPtr aNewConstraint;
   std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoints[2];
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> aLine;
+  std::shared_ptr<PlaneGCSSolver_EdgeWrapper> aLine;
 
   if (isPointOnOppositeLine[0] || isPointOnOppositeLine[1]) {
     // one of points of first line is already on the second line,
@@ -95,7 +95,7 @@ void SketchSolver_ConstraintCollinear::notify(const FeaturePtr&      theFeature,
         aPoints[i] = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(myPoints[i]);
       aConstraintToApply[i] = true;
     }
-    aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(myAttributes.back());
+    aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(myAttributes.back());
   } else {
     // verify second line and add necessary constraints
     for (int i = 0; i < 2; ++i) {
@@ -106,7 +106,7 @@ void SketchSolver_ConstraintCollinear::notify(const FeaturePtr&      theFeature,
         aPoints[i] = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(myPoints[i + 2]);
       aConstraintToApply[i+2] = true;
     }
-    aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(myAttributes.front());
+    aLine = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(myAttributes.front());
   }
 
   bool isNew = false;
index 85d540ff7a324702ab1c67796bbd76d7868fd6e9..5dc192a7f1dc74e5eee5a82a0527bae78cba70a5 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintDistance_H_
 #define SketchSolver_ConstraintDistance_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 /** \class   SketchSolver_ConstraintDistance
index 3741f93dd9a7083aa9f78169ab6d4abc920bca4b..3fd677db35d873a5304185505927a146f0b4ce2e 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintEqual_H_
 #define SketchSolver_ConstraintEqual_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 /** \class   SketchSolver_ConstraintEqual
index 73f9808ebc454a638efbfa79b6aa0be77a5cf119..41ba5d46b5622a7abd141024db70631cb9d23c60 100644 (file)
@@ -4,20 +4,22 @@
 #include <SketchSolver_Error.h>
 
 #include <PlaneGCSSolver_ConstraintWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
+#include <PlaneGCSSolver_EdgeWrapper.h>
 #include <PlaneGCSSolver_PointWrapper.h>
 
+#include <GeomDataAPI_Point2D.h>
+
+#include <cmath>
+
+// Find parameters of the feature that have been updated during the movement
+static EntityWrapperPtr getChangedEntity(const FeaturePtr& theFeature,
+                                         const StoragePtr& theStorage);
+
 
 SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(ConstraintPtr theConstraint)
   : SketchSolver_Constraint(theConstraint)
 {
   myType = CONSTRAINT_FIXED;
-////  AttributeRefAttrPtr anAttribute =
-////      theConstraint->refattr(SketchPlugin_ConstraintRigid::ENTITY_A());
-////  if (anAttribute->isObject())
-////    myFixedFeature = ModelAPI_Feature::feature(anAttribute->object());
-////  else
-////    myFixedAttribute = anAttribute->attr();
 }
 
 SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(FeaturePtr theFeature)
@@ -25,7 +27,6 @@ SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(FeaturePtr theFeature
     myBaseFeature(theFeature)
 {
   myType = CONSTRAINT_FIXED;
-////  process();
 }
 
 void SketchSolver_ConstraintFixed::blockEvents(bool isBlocked)
@@ -56,8 +57,8 @@ void SketchSolver_ConstraintFixed::process()
 
 void SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr theFeature)
 {
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theFeature);
+  std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+      std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theFeature);
 
   GCS::VEC_pD aParameters; // parameters of entity to be fixed
 
@@ -125,8 +126,8 @@ void SketchSolver_ConstraintFixed::getAttributes(
 {
   if (myBaseFeature) {
     // The feature is fixed.
+    EntityWrapperPtr aSolverEntity = getChangedEntity(myBaseFeature, myStorage);
     myStorage->update(myBaseFeature);
-    EntityWrapperPtr aSolverEntity = myStorage->entity(myBaseFeature);
     if (aSolverEntity)
       theAttributes.push_back(aSolverEntity);
   } else if (myBaseConstraint) {
@@ -141,3 +142,40 @@ void SketchSolver_ConstraintFixed::getAttributes(
   } else
     myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
 }
+
+
+
+
+// ====================   Auxiliary functions   ===============================
+static bool isSameCoordinates(const AttributePoint2DPtr& thePointAttr,
+                              const PointWrapperPtr& thePointWrapper)
+{
+  GCSPointPtr aGCSPoint = thePointWrapper->point();
+  return fabs(*aGCSPoint->x - thePointAttr->x()) < tolerance &&
+         fabs(*aGCSPoint->y - thePointAttr->y()) < tolerance;
+}
+
+EntityWrapperPtr getChangedEntity(const FeaturePtr& theFeature,
+                                  const StoragePtr& theStorage)
+{
+  std::list<AttributePtr> aPoints = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
+  std::list<EntityWrapperPtr> aChangedPoints;
+
+  std::list<AttributePtr>::const_iterator aPIt = aPoints.begin();
+  for (; aPIt != aPoints.end(); ++aPIt) {
+    AttributePoint2DPtr aPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*aPIt);
+    EntityWrapperPtr anEnt = theStorage->entity(*aPIt);
+    if (!anEnt)
+      continue;
+    PointWrapperPtr aPW = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anEnt);
+    if (!isSameCoordinates(aPnt, aPW))
+      aChangedPoints.push_back(anEnt);
+  }
+
+  EntityWrapperPtr aChanged;
+  if (aChangedPoints.size() == 1)
+    aChanged = aChangedPoints.front();
+  else if (!aChangedPoints.empty()) // update whole feature
+    aChanged = theStorage->entity(theFeature);
+  return aChanged;
+}
index 35fc651be42899e3d0440ef8d227bb8dbaaeba53..61b5ec82483bad51b982364866e236892a978e9d 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintFixed_H_
 #define SketchSolver_ConstraintFixed_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 /** \class   SketchSolver_ConstraintFixed
index 3934b59ff18acbcbc8ec8cc91955207e16f33820..689f4478a3988a811ceb75d7d4b3a3d3b5b94b41 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintLength_H_
 #define SketchSolver_ConstraintLength_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 /** \class   SketchSolver_ConstraintLength
index fe0ea2e9cfbecf751fad7e6856181d3bd87dd461..8840a3bffc2e6d3700d1682e94392a538e09cd45 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintMirror_H_
 #define SketchSolver_ConstraintMirror_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 /** \class   SketchSolver_ConstraintMirror
index b317fc1dc342b97ad44e1160a0e5e32c862e05dd..969b4ae0d6f2ac5abc0d2424aef20ca854b4813a 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintMulti_H_
 #define SketchSolver_ConstraintMulti_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 #include <vector>
index faffd938012b73e7f8fdf4bd19e1ac9d5a36330a..48f367deb459576de96d5eae418d534ab6595482 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintMultiRotation_H_
 #define SketchSolver_ConstraintMultiRotation_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_ConstraintMulti.h>
 
 #include "GeomDataAPI_Point2D.h"
index 6b71d30db6ef173889e74204355b27584aa889c5..eeeb15f518e3e9563abff05669fc525579d544d5 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintMultiTranslation_H_
 #define SketchSolver_ConstraintMultiTranslation_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_ConstraintMulti.h>
 
 #include "GeomDataAPI_Point2D.h"
index 8a61e1a993834fb60894db047030f289565d6b44..709d09185bfe2ad3e4fe89ec65b5584d63321c8e 100644 (file)
@@ -3,7 +3,10 @@
 #include <SketchSolver_ConstraintTangent.h>
 #include <SketchSolver_Error.h>
 
+#include <PlaneGCSSolver_EdgeWrapper.h>
+#include <PlaneGCSSolver_PointWrapper.h>
 #include <PlaneGCSSolver_Tools.h>
+#include <PlaneGCSSolver_UpdateCoincidence.h>
 
 #include <GeomAPI_Pnt2d.h>
 #include <SketchPlugin_Circle.h>
 
 #include <cmath>
 
+#define GCS_EDGE_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(x)
 
-/// \brief Check whether the entities has only one shared point or less
-static bool hasSingleCoincidence(FeaturePtr theFeature1, FeaturePtr theFeature2)
-{
-  const std::set<AttributePtr>& aRefs1 = theFeature1->data()->refsToMe();
-  const std::set<AttributePtr>& aRefs2 = theFeature2->data()->refsToMe();
+/// \brief Obtain tangent features from the constraint
+static void getTangentFeatures(const ConstraintPtr& theConstraint,
+                               FeaturePtr& theFeature1,
+                               FeaturePtr& theFeature2);
 
-  // collect all shared coincidendes
-  std::set<FeaturePtr> aCoincidences;
-  std::set<AttributePtr>::const_iterator anIt;
-  for (anIt = aRefs1.begin(); anIt != aRefs1.end(); ++anIt) {
-    FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
-    if (aRef && aRef->getKind() == SketchPlugin_ConstraintCoincidence::ID())
-      aCoincidences.insert(aRef);
-  }
-  int aNbCoinCidentPoints = 0;
-  for (anIt = aRefs2.begin(); anIt != aRefs2.end(); ++anIt) {
-    FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
-    if (aCoincidences.find(aRef) != aCoincidences.end())
-      ++aNbCoinCidentPoints;
-  }
+/// \brief Obtain all coincident constraints between features
+static std::set<FeaturePtr> collectCoincidences(FeaturePtr theFeature1, FeaturePtr theFeature2);
 
-  return aNbCoinCidentPoints <= 1;
-}
+/// \brief Check whether the entities has only one shared point or less.
+///        Return list of coincident points.
+static std::list<AttributePtr> coincidentPoints(FeaturePtr theFeature1, FeaturePtr theFeature2);
+
+/// \brief Check if two connected arcs have centers
+///        in same direction relatively to connection point
+static bool isArcArcTangencyInternal(EntityWrapperPtr theArc1,
+                                     EntityWrapperPtr theArc2);
+
+static ConstraintWrapperPtr
+  createArcLineTangency(EntityWrapperPtr theEntity1,
+                        EntityWrapperPtr theEntity2,
+                        EntityWrapperPtr theShapedPoint = EntityWrapperPtr(),
+                        double*          theAngle = 0);
+
+static ConstraintWrapperPtr
+  createArcArcTangency(EntityWrapperPtr theEntity1,
+                       EntityWrapperPtr theEntity2,
+                       bool             theInternalTangency,
+                       EntityWrapperPtr theSharedPoint = EntityWrapperPtr(),
+                       double*          theAngle = 0);
 
-void SketchSolver_ConstraintTangent::getAttributes(
-    EntityWrapperPtr& theValue,
-    std::vector<EntityWrapperPtr>& theAttributes)
+
+void SketchSolver_ConstraintTangent::process()
 {
-  SketchSolver_Constraint::getAttributes(theValue, theAttributes);
-  if (!myErrorMsg.empty() || !theAttributes[2] || !theAttributes[3]) {
-    theAttributes.clear();
+  cleanErrorMsg();
+  if (!myBaseConstraint || !myStorage) {
+    // Not enough parameters are assigned
     return;
   }
 
+  EntityWrapperPtr aValue;
+  std::vector<EntityWrapperPtr> anAttributes;
+  SketchSolver_Constraint::getAttributes(aValue, anAttributes);
+  if (!myErrorMsg.empty())
+    return;
+
+  rebuild();
+  if (!myErrorMsg.empty())
+    return;
+
+  myStorage->subscribeUpdates(this, PlaneGCSSolver_UpdateCoincidence::GROUP());
+}
+
+void SketchSolver_ConstraintTangent::rebuild()
+{
+  if (mySolverConstraint)
+    myStorage->removeConstraint(myBaseConstraint);
+
+  mySolverConstraint = ConstraintWrapperPtr();
+  mySharedPoint = AttributePtr();
+
   // Check the quantity of entities of each type and their order (arcs first)
   int aNbLines = 0;
   int aNbCircles = 0;
-  std::vector<EntityWrapperPtr>::iterator anEntIt = theAttributes.begin() + 2;
-  for (; anEntIt != theAttributes.end(); ++anEntIt) {
+  std::list<EntityWrapperPtr>::iterator anEntIt = myAttributes.begin();
+  for (; anEntIt != myAttributes.end(); ++anEntIt) {
+    if (!(*anEntIt).get())
+      continue;
     if ((*anEntIt)->type() == ENTITY_LINE)
       ++aNbLines;
     else if ((*anEntIt)->type() == ENTITY_ARC || (*anEntIt)->type() == ENTITY_CIRCLE)
@@ -66,23 +98,38 @@ void SketchSolver_ConstraintTangent::getAttributes(
   }
   else if (aNbCircles == 2) {
     myType = CONSTRAINT_TANGENT_CIRCLE_CIRCLE;
-    isArcArcInternal =
-        PlaneGCSSolver_Tools::isArcArcTangencyInternal(theAttributes[2], theAttributes[3]);
+    isArcArcInternal = isArcArcTangencyInternal(myAttributes.front(), myAttributes.back());
   }
   else {
     myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
     return;
   }
 
-  if (myType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
-    AttributeRefAttrPtr aRefAttr = myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
-    FeaturePtr aFeature1 = ModelAPI_Feature::feature(aRefAttr->object());
-    aRefAttr = myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_B());
-    FeaturePtr aFeature2 = ModelAPI_Feature::feature(aRefAttr->object());
+  FeaturePtr aFeature1, aFeature2;
+  getTangentFeatures(myBaseConstraint, aFeature1, aFeature2);
 
-    if (!hasSingleCoincidence(aFeature1, aFeature2))
-      myErrorMsg = SketchSolver_Error::TANGENCY_FAILED();
+  // check number of coincident points
+  std::list<AttributePtr> aCoincidentPoints = coincidentPoints(aFeature1, aFeature2);
+  if (myType == CONSTRAINT_TANGENT_CIRCLE_LINE && aCoincidentPoints.size() > 1) {
+    myErrorMsg = SketchSolver_Error::TANGENCY_FAILED();
+    return;
   }
+
+  EntityWrapperPtr aSharedPointEntity;
+  if (!aCoincidentPoints.empty()) {
+    mySharedPoint = aCoincidentPoints.front();
+    aSharedPointEntity = myStorage->entity(mySharedPoint);
+  }
+
+  if (myType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
+    mySolverConstraint = createArcLineTangency(myAttributes.front(), myAttributes.back(),
+                                           aSharedPointEntity, &myCurveCurveAngle);
+  } else {
+    mySolverConstraint = createArcArcTangency(myAttributes.front(), myAttributes.back(),
+                            isArcArcInternal, aSharedPointEntity, &myCurveCurveAngle);
+  }
+
+  myStorage->addConstraint(myBaseConstraint, mySolverConstraint);
 }
 
 void SketchSolver_ConstraintTangent::adjustConstraint()
@@ -93,10 +140,220 @@ void SketchSolver_ConstraintTangent::adjustConstraint()
     EntityWrapperPtr anEntity2 =
         myStorage->entity(myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
 
-    if (isArcArcInternal != PlaneGCSSolver_Tools::isArcArcTangencyInternal(anEntity1, anEntity2)) {
-      // fully rebuld constraint, because it is unable to access attributes of PlaneGCS constraint
-      remove();
-      process();
+    if (isArcArcInternal != isArcArcTangencyInternal(anEntity1, anEntity2))
+      rebuild();
+  }
+}
+
+void SketchSolver_ConstraintTangent::notify(const FeaturePtr&      theFeature,
+                                            PlaneGCSSolver_Update* theUpdater)
+{
+  if (theFeature->getKind() != SketchPlugin_ConstraintCoincidence::ID())
+    return;
+
+  // base constraint may become invalid (for example, during undo)
+  if (!myBaseConstraint->data() || !myBaseConstraint->data()->isValid())
+    return;
+
+  FeaturePtr aTgFeat1, aTgFeat2;
+  getTangentFeatures(myBaseConstraint, aTgFeat1, aTgFeat2);
+
+  bool isRebuild = false;
+  if (theFeature->data() && theFeature->data()->isValid()) {
+    // the constraint has been created
+    if (!mySharedPoint) {
+      // features has no shared point, check whether coincidence constraint binds these features)
+      int aNbCoincidentFeatures = 0;
+      for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
+        AttributeRefAttrPtr aRefAttr = theFeature->refattr(SketchPlugin_Constraint::ATTRIBUTE(i));
+        if (!aRefAttr)
+          continue;
+
+        ObjectPtr anObj;
+        if (aRefAttr->isObject())
+          anObj = aRefAttr->object();
+        else
+          anObj = aRefAttr->attr()->owner();
+
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObj);
+        if (aFeature == aTgFeat1 || aFeature == aTgFeat2)
+          ++aNbCoincidentFeatures;
+      }
+
+      if (aNbCoincidentFeatures == 2)
+        isRebuild = true;
+    }
+  } else if (mySharedPoint) {
+    // The features are tangent in the shared point, but the coincidence has been removed.
+    // Check if the coincidence is the same.
+    std::list<AttributePtr> aCoincidentPoints = coincidentPoints(aTgFeat1, aTgFeat2);
+    isRebuild = true;
+    std::list<AttributePtr>::iterator anIt = aCoincidentPoints.begin();
+    for (; anIt != aCoincidentPoints.end() && isRebuild; ++anIt)
+      if (*anIt == mySharedPoint)
+        isRebuild = false; // the coincidence is still exists => nothing to change
+  }
+
+  if (isRebuild)
+    rebuild();
+}
+
+
+
+
+// ==================   Auxiliary functions   =================================
+void getTangentFeatures(const ConstraintPtr& theConstraint,
+                              FeaturePtr&    theFeature1,
+                              FeaturePtr&    theFeature2)
+{
+  AttributeRefAttrPtr aRefAttr = theConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
+  theFeature1 = ModelAPI_Feature::feature(aRefAttr->object());
+  aRefAttr = theConstraint->refattr(SketchPlugin_Constraint::ENTITY_B());
+  theFeature2 = ModelAPI_Feature::feature(aRefAttr->object());
+}
+
+std::set<FeaturePtr> collectCoincidences(FeaturePtr theFeature1, FeaturePtr theFeature2)
+{
+  const std::set<AttributePtr>& aRefs1 = theFeature1->data()->refsToMe();
+  const std::set<AttributePtr>& aRefs2 = theFeature2->data()->refsToMe();
+
+  std::set<FeaturePtr> aCoincidences;
+  std::set<AttributePtr>::const_iterator anIt;
+
+  // collect coincidences referred to the first feature
+  for (anIt = aRefs1.begin(); anIt != aRefs1.end(); ++anIt) {
+    FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
+    if (aRef && aRef->getKind() == SketchPlugin_ConstraintCoincidence::ID())
+      aCoincidences.insert(aRef);
+  }
+
+  // leave only coincidences referred to the second feature
+  std::set<FeaturePtr> aCoincidencesBetweenFeatures;
+  for (anIt = aRefs2.begin(); anIt != aRefs2.end(); ++anIt) {
+    FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
+    if (aCoincidences.find(aRef) != aCoincidences.end())
+      aCoincidencesBetweenFeatures.insert(aRef);
+  }
+
+  return aCoincidencesBetweenFeatures;
+}
+
+std::list<AttributePtr> coincidentPoints(FeaturePtr theFeature1, FeaturePtr theFeature2)
+{
+  std::set<FeaturePtr> aCoincidences = collectCoincidences(theFeature1, theFeature2);
+  // collect points only
+  std::list<AttributePtr> aCoincidentPoints;
+  std::set<FeaturePtr>::const_iterator aCIt = aCoincidences.begin();
+  for (; aCIt != aCoincidences.end(); ++ aCIt) {
+    for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
+      AttributeRefAttrPtr aRefAttr = (*aCIt)->refattr(SketchPlugin_Constraint::ENTITY_A());
+      if (aRefAttr && !aRefAttr->isObject()) {
+        aCoincidentPoints.push_back(aRefAttr->attr());
+        break;
+      }
     }
   }
+  return aCoincidentPoints;
+}
+
+bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, EntityWrapperPtr theArc2)
+{
+  std::shared_ptr<GCS::Circle> aCirc1 = std::dynamic_pointer_cast<GCS::Circle>(
+      GCS_EDGE_WRAPPER(theArc1)->entity());
+  std::shared_ptr<GCS::Circle> aCirc2 = std::dynamic_pointer_cast<GCS::Circle>(
+      GCS_EDGE_WRAPPER(theArc2)->entity());
+
+  if (!aCirc1 || !aCirc2)
+    return false;
+
+  double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
+  double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
+  double aDist = sqrt(aDX * aDX + aDY * aDY);
+
+  return (aDist < *(aCirc1->rad) || aDist < *(aCirc2->rad));
+}
+
+// sets angle to 0 or 180 degrees
+static void adjustAngleBetweenCurves(const GCSCurvePtr& theCurve1,
+                                     const GCSCurvePtr& theCurve2,
+                                     const GCSPointPtr& thePoint,
+                                     double*            theAngle)
+{
+  double anAngle = GCS::System().calculateAngleViaPoint(*theCurve1, *theCurve2, *thePoint);
+  // bring angle to [-pi..pi]
+  if (anAngle >  PI) anAngle -= 2.0 * PI;
+  if (anAngle < -PI) anAngle += 2.0 * PI;
+  // set angle value according to the current angle between curves
+  if (fabs(anAngle) <= PI / 2.)
+    *theAngle = 0.0;
+  else
+    *theAngle = PI;
+}
+
+
+ConstraintWrapperPtr createArcLineTangency(EntityWrapperPtr theEntity1,
+                                           EntityWrapperPtr theEntity2,
+                                           EntityWrapperPtr theSharedPoint,
+                                           double*          theAngle)
+{
+  EdgeWrapperPtr anEntLine, anEntCirc;
+  if (theEntity1->type() == ENTITY_LINE) {
+    anEntLine = GCS_EDGE_WRAPPER(theEntity1);
+    anEntCirc = GCS_EDGE_WRAPPER(theEntity2);
+  } else {
+    anEntLine = GCS_EDGE_WRAPPER(theEntity2);
+    anEntCirc = GCS_EDGE_WRAPPER(theEntity1);
+  }
+
+  std::shared_ptr<GCS::Circle> aCirc =
+      std::dynamic_pointer_cast<GCS::Circle>(anEntCirc->entity());
+  std::shared_ptr<GCS::Line> aLine =
+      std::dynamic_pointer_cast<GCS::Line>(anEntLine->entity());
+
+  GCSConstraintPtr aNewConstr;
+  if (theSharedPoint) {
+    std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(aCirc);
+    GCSPointPtr aPoint =
+        std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theSharedPoint)->point();
+
+    adjustAngleBetweenCurves(anArc, aLine, aPoint, theAngle);
+    aNewConstr =
+        GCSConstraintPtr(new GCS::ConstraintAngleViaPoint(*anArc, *aLine, *aPoint, theAngle));
+  } else {
+    aNewConstr =
+      GCSConstraintPtr(new GCS::ConstraintP2LDistance(aCirc->center, *aLine, aCirc->rad));
+  }
+
+  return  ConstraintWrapperPtr(
+      new PlaneGCSSolver_ConstraintWrapper(aNewConstr, CONSTRAINT_TANGENT_CIRCLE_LINE));
+}
+
+ConstraintWrapperPtr createArcArcTangency(EntityWrapperPtr theEntity1,
+                                          EntityWrapperPtr theEntity2,
+                                          bool             theInternalTangency,
+                                          EntityWrapperPtr theSharedPoint,
+                                          double*          theAngle)
+{
+  std::shared_ptr<GCS::Circle> aCirc1 =
+    std::dynamic_pointer_cast<GCS::Circle>(GCS_EDGE_WRAPPER(theEntity1)->entity());
+  std::shared_ptr<GCS::Circle> aCirc2 =
+    std::dynamic_pointer_cast<GCS::Circle>(GCS_EDGE_WRAPPER(theEntity2)->entity());
+
+  GCSConstraintPtr aNewConstr;
+  if (theSharedPoint) {
+    std::shared_ptr<GCS::Arc> anArc1 = std::dynamic_pointer_cast<GCS::Arc>(aCirc1);
+    std::shared_ptr<GCS::Arc> anArc2 = std::dynamic_pointer_cast<GCS::Arc>(aCirc2);
+    GCSPointPtr aPoint =
+        std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theSharedPoint)->point();
+
+    adjustAngleBetweenCurves(anArc1, anArc2, aPoint, theAngle);
+    aNewConstr =
+        GCSConstraintPtr(new GCS::ConstraintAngleViaPoint(*anArc1, *anArc2, *aPoint, theAngle));
+  } else {
+    aNewConstr = GCSConstraintPtr(new GCS::ConstraintTangentCircumf(aCirc1->center, aCirc2->center,
+                                  aCirc1->rad, aCirc2->rad, theInternalTangency));
+  }
+
+  return ConstraintWrapperPtr(
+      new PlaneGCSSolver_ConstraintWrapper(aNewConstr, CONSTRAINT_TANGENT_CIRCLE_CIRCLE));
 }
index 221450083730a2949a98e59e79f7fa7b132aca8c..3f8524c340ac0b7d1a5261293eeab1c0c0fcbd5f 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_ConstraintTangent_H_
 #define SketchSolver_ConstraintTangent_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 
 /** \class   SketchSolver_ConstraintTangent
@@ -20,15 +19,20 @@ public:
   /// Constructor based on SketchPlugin constraint
   SketchSolver_ConstraintTangent(ConstraintPtr theConstraint) :
       SketchSolver_Constraint(theConstraint),
-      isArcArcInternal(false)
+      isArcArcInternal(false),
+      myCurveCurveAngle(0.0)
   {}
 
+  /// \brief Notify this object about the feature is changed somewhere
+  virtual void notify(const FeaturePtr&      theFeature,
+                      PlaneGCSSolver_Update* theUpdater);
+
 protected:
-  /// \brief Generate list of attributes of constraint in order useful for constraints
-  /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
-  /// \param[out] theAttributes list of attributes to be filled
-  virtual void getAttributes(EntityWrapperPtr&              theValue,
-                             std::vector<EntityWrapperPtr>& theAttributes);
+  /// \brief Converts SketchPlugin constraint to a list of solver constraints
+  virtual void process();
+
+  /// \brief Remove current constraint from the storage and build is again
+  void rebuild();
 
   /// \brief This method is used in derived objects to check consistency of constraint.
   ///        E.g. the distance between line and point may be signed.
@@ -36,6 +40,8 @@ protected:
 
 private:
   bool isArcArcInternal;
+  double myCurveCurveAngle;
+  AttributePtr mySharedPoint;
 };
 
 #endif
diff --git a/src/SketchSolver/SketchSolver_IConstraintWrapper.h b/src/SketchSolver/SketchSolver_IConstraintWrapper.h
deleted file mode 100644 (file)
index 5215705..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    SketchSolver_IConstraintWrapper.h
-// Created: 30 Nov 2015
-// Author:  Artem ZHIDKOV
-
-#ifndef SketchSolver_IConstraintWrapper_H_
-#define SketchSolver_IConstraintWrapper_H_
-
-#include <SketchSolver_IEntityWrapper.h>
-
-#include <SketchPlugin_Constraint.h>
-
-#include <list>
-#include <memory>
-
-/// Types of constraints
-enum SketchSolver_ConstraintType {
-  CONSTRAINT_UNKNOWN = 0,
-  CONSTRAINT_COINCIDENCE,      // base coincidence if we don't know exact type yet
-  CONSTRAINT_PT_PT_COINCIDENT,
-  CONSTRAINT_PT_ON_LINE,
-  CONSTRAINT_PT_ON_CIRCLE,
-  CONSTRAINT_MIDDLE_POINT,
-  CONSTRAINT_DISTANCE,         // base distance if we don't know the measured objects yet
-  CONSTRAINT_PT_PT_DISTANCE,
-  CONSTRAINT_PT_LINE_DISTANCE,
-  CONSTRAINT_RADIUS,
-  CONSTRAINT_ANGLE,
-  CONSTRAINT_FIXED,
-  CONSTRAINT_HORIZONTAL,
-  CONSTRAINT_VERTICAL,
-  CONSTRAINT_PARALLEL,
-  CONSTRAINT_PERPENDICULAR,
-  CONSTRAINT_SYMMETRIC,
-  CONSTRAINT_EQUAL,           // base equality if we don't know the measured objects yet
-  CONSTRAINT_EQUAL_LINES,
-  CONSTRAINT_EQUAL_LINE_ARC,
-  CONSTRAINT_EQUAL_RADIUS,
-  CONSTRAINT_TANGENT,         // base tangency if we don't know the measured objects yet
-  CONSTRAINT_TANGENT_CIRCLE_LINE,
-  CONSTRAINT_TANGENT_CIRCLE_CIRCLE,
-  CONSTRAINT_COLLINEAR,
-  CONSTRAINT_MULTI_TRANSLATION,
-  CONSTRAINT_MULTI_ROTATION
-};
-
-/**
- *  Wrapper providing operations with constraints regardless the solver.
- */
-class SketchSolver_IConstraintWrapper
-{
-public:
-  virtual ~SketchSolver_IConstraintWrapper() {}
-
-  /// \brief Return ID of current constraint
-  const ConstraintID& id() const
-  { return myID; }
-  /// \brief Change constraint ID
-  virtual void setId( const ConstraintID& theID) = 0;
-
-  /// \brief Return type of current entity
-  virtual SketchSolver_ConstraintType type() const = 0;
-
-  /// \brief Assign numeric parameter of constraint
-  virtual void setValue(const double& theValue) = 0;
-  /// \brief Return numeric parameter of constraint
-  virtual double value() const = 0;
-
-protected:
-  ConstraintID myID;
-};
-
-typedef std::shared_ptr<SketchSolver_IConstraintWrapper> ConstraintWrapperPtr;
-
-#endif
diff --git a/src/SketchSolver/SketchSolver_IEntityWrapper.h b/src/SketchSolver/SketchSolver_IEntityWrapper.h
deleted file mode 100644 (file)
index 41f561a..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    SketchSolver_IEntityWrapper.h
-// Created: 30 Nov 2015
-// Author:  Artem ZHIDKOV
-
-#ifndef SketchSolver_IEntityWrapper_H_
-#define SketchSolver_IEntityWrapper_H_
-
-#include <SketchSolver.h>
-
-#include <ModelAPI_Attribute.h>
-#include <ModelAPI_Feature.h>
-
-#include <list>
-#include <memory>
-
-/// Types of entities
-enum SketchSolver_EntityType {
-  ENTITY_UNKNOWN = 0,
-  ENTITY_SCALAR,
-  ENTITY_ANGLE,
-  ENTITY_POINT,
-  ENTITY_LINE,
-  ENTITY_CIRCLE,
-  ENTITY_ARC
-};
-
-/**
- *  Wrapper providing operations with entities regardless the solver.
- */
-class SketchSolver_IEntityWrapper
-{
-public:
-  SketchSolver_IEntityWrapper() : myExternal(false) {}
-  virtual ~SketchSolver_IEntityWrapper() {}
-
-  /// \brief Return type of current entity
-  virtual SketchSolver_EntityType type() const = 0;
-
-  /// \brief Change flag indicating the entity cannot be changed in the solver
-  void setExternal(bool theExternal) { myExternal = theExternal; }
-  /// \brief Return the External flag
-  bool isExternal() const { return myExternal; }
-
-private:
-  bool myExternal;
-};
-
-typedef std::shared_ptr<SketchSolver_IEntityWrapper> EntityWrapperPtr;
-
-#endif
index 7d227dee456c044ce79e803b12c37b098ff7ffd9..d69cccbfd4a8e5c8a1926aded8091b0a3fbb75a6 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SketchSolver_Manager_H_
 #define SketchSolver_Manager_H_
 
-#include "SketchSolver.h"
 #include <SketchSolver_Group.h>
 
 #include <Events_Listener.h>
index 50d30987c21812edb0d2750c1fd40e41b94688c8..bfd8bc62001f731733e7f03843b19f1d8832bd31 100644 (file)
@@ -7,9 +7,8 @@
 #ifndef SketchSolver_Storage_H_
 #define SketchSolver_Storage_H_
 
-#include <SketchSolver.h>
-#include <SketchSolver_IConstraintWrapper.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_ConstraintWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
 
 #include <PlaneGCSSolver_Solver.h>
 #include <PlaneGCSSolver_UpdateFeature.h>
index e16cccf831651b9cf03b2a8702180d17c5a4bb71..dd9f98f3c6a340fe3b8f340e9bb0dc48d9eee7ba 100644 (file)
@@ -16,6 +16,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultConstruction.h>
 
 #include <AIS_InteractiveContext.hxx>
index fa48ac096d22facd30d443615e2233274e4ae810..bbf1f04206b50f0e873058fff27b4dc921b5325c 100755 (executable)
@@ -1389,7 +1389,10 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
         #endif
         aParameters.Append(MyVCallBack);
 
+        MyTCommunicator->registerPlugin("SMBrowser"); // custom plugin to view ModelAPI
+
         MyTCommunicator->init(aParameters);
+        MyTCommunicator->Activate("SMBrowser"); // to have button in TInspector
         MyTCommunicator->Activate("TKVInspector"); // to have filled callback by model
         MyTCommunicator->Activate("TKDFBrowser");
       }
index d91bec07c6b68ca8a5327a7964100e5e5b113a74..2bfbcb9f29adcf4289be8fcdd1d8a32d32b5726b 100644 (file)
@@ -754,8 +754,8 @@ model.testNbResults(Boolean_7, 1)
 model.testNbSubResults(Boolean_7, [0])
 model.testNbSubShapes(Boolean_7, GeomAPI_Shape.SOLID, [1])
 model.testNbSubShapes(Boolean_7, GeomAPI_Shape.FACE, [49])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [271])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [542])
-model.testResultsVolumes(Boolean_7, [157000.318686960934428498148918152])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [263])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [526])
+model.testResultsVolumes(Boolean_7, [157000.328896829247241839766502380])
 
 assert(model.checkPythonDump)
index 05c20e2314abd32f831236b7cd4dc95c0cf406ac..99b36f6b41cb7a7e8615f93dc7bbd49253d8493f 100644 (file)
@@ -14,6 +14,7 @@ model.addParameter(Part_1_doc, "Radius", "50", "Radius of the body")
 model.addParameter(Part_1_doc, "Width", "25", "Width of body arms")
 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
 SketchLine_1 = Sketch_1.addLine(50, 14.61148285474187, 50, 0)
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 14.61148285474187)
 SketchLine_2 = Sketch_1.addLine(50, 0, 6, 0)
 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
 SketchLine_3 = Sketch_1.addLine(7, 25, 16.13599978860571, 25)
@@ -341,8 +342,6 @@ SketchConstraintCoincidence_60 = Sketch_4.setCoincident(SketchArc_13.startPoint(
 SketchConstraintCoincidence_60.setName("SketchConstraintCoincidence_48")
 SketchConstraintCoincidence_61 = Sketch_4.setCoincident(SketchArc_13.endPoint(), SketchArc_12.endPoint())
 SketchConstraintCoincidence_61.setName("SketchConstraintCoincidence_49")
-SketchConstraintCoincidence_62 = Sketch_4.setCoincident(SketchArc_13.center(), SketchLine_32.result())
-SketchConstraintCoincidence_62.setName("SketchConstraintCoincidence_50")
 SketchConstraintMirror_1 = Sketch_4.addMirror(SketchLine_40.result(), [SketchArc_13.results()[1], SketchArc_12.results()[1]])
 [SketchArc_14, SketchArc_15] = SketchConstraintMirror_1.mirrored()
 SketchArc_15.setName("SketchArc_6")
@@ -582,12 +581,10 @@ SketchArc_22 = Sketch_6.addArc(3.457737973711348, 3.788069295318559e-014, 6.25,
 SketchArc_22.setName("SketchArc_4")
 SketchArc_22.result().setName("SketchArc_4")
 SketchArc_22.results()[1].setName("SketchArc_4_2")
-SketchConstraintCoincidence_117 = Sketch_6.setCoincident(SketchArc_22.startPoint(), SketchLine_56.startPoint())
-SketchConstraintCoincidence_117.setName("SketchConstraintCoincidence_48")
-SketchConstraintCoincidence_118 = Sketch_6.setCoincident(SketchArc_22.endPoint(), SketchArc_21.endPoint())
-SketchConstraintCoincidence_118.setName("SketchConstraintCoincidence_49")
-SketchConstraintCoincidence_119 = Sketch_6.setCoincident(SketchArc_22.center(), SketchLine_53.result())
-SketchConstraintCoincidence_119.setName("SketchConstraintCoincidence_50")
+SketchConstraintCoincidence_127 = Sketch_6.setCoincident(SketchArc_22.startPoint(), SketchLine_56.startPoint())
+SketchConstraintCoincidence_127.setName("SketchConstraintCoincidence_48")
+SketchConstraintCoincidence_128 = Sketch_6.setCoincident(SketchArc_22.endPoint(), SketchArc_21.endPoint())
+SketchConstraintCoincidence_128.setName("SketchConstraintCoincidence_49")
 SketchConstraintMirror_3 = Sketch_6.addMirror(SketchLine_61.result(), [SketchArc_22.results()[1], SketchArc_21.results()[1]])
 [SketchArc_23, SketchArc_24] = SketchConstraintMirror_3.mirrored()
 SketchArc_24.setName("SketchArc_6")
@@ -831,8 +828,6 @@ SketchConstraintCoincidence_194 = Sketch_8.setCoincident(SketchArc_31.startPoint
 SketchConstraintCoincidence_194.setName("SketchConstraintCoincidence_48")
 SketchConstraintCoincidence_195 = Sketch_8.setCoincident(SketchArc_31.endPoint(), SketchArc_30.endPoint())
 SketchConstraintCoincidence_195.setName("SketchConstraintCoincidence_49")
-SketchConstraintCoincidence_196 = Sketch_8.setCoincident(SketchArc_31.center(), SketchLine_74.result())
-SketchConstraintCoincidence_196.setName("SketchConstraintCoincidence_50")
 SketchConstraintMirror_5 = Sketch_8.addMirror(SketchLine_82.result(), [SketchArc_31.results()[1], SketchArc_30.results()[1]])
 [SketchArc_32, SketchArc_33] = SketchConstraintMirror_5.mirrored()
 SketchArc_33.setName("SketchArc_6")
@@ -1074,7 +1069,7 @@ model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [1])
 model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [52])
 model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [338])
 model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [676])
-model.testResultsVolumes(Part_1, [48835.415011945384321734309196472])
+model.testResultsVolumes(Part_1, [48835.437112214101944118738174438])
 
 model.testNbResults(Translation_4, 3)
 model.testNbSubResults(Translation_4, [0, 0, 0])
index 1d46a84040abc4bca9c3cd277d918f57bb047171..65afa9b008a1e7354b69624e1aaa22f4b83b417c 100644 (file)
@@ -278,8 +278,6 @@ SketchConstraintRadius_6 = Sketch_5.setRadius(SketchArc_6.results()[1], 8)
 SketchConstraintRadius_6.setName("SketchConstraintRadius_7")
 SketchConstraintDistance_14 = Sketch_5.setDistance(SketchLine_33.endPoint(), SketchLine_30.result(), 20)
 SketchConstraintDistance_14.setName("SketchConstraintDistance_17")
-SketchConstraintCoincidence_58 = Sketch_5.setCoincident(SketchLine_34.endPoint(), SketchLine_34.result())
-SketchConstraintCoincidence_58.setName("SketchConstraintCoincidence_65")
 SketchConstraintCoincidence_59 = Sketch_5.setCoincident(SketchLine_34.endPoint(), SketchLine_37.startPoint())
 SketchConstraintCoincidence_59.setName("SketchConstraintCoincidence_66")
 SketchConstraintDistance_15 = Sketch_5.setDistance(SketchLine_37.startPoint(), SketchLine_30.result(), "DBody")
@@ -388,8 +386,6 @@ SketchConstraintCoincidence_81 = Sketch_6.setCoincident(SketchLine_38.startPoint
 SketchConstraintCoincidence_81.setName("SketchConstraintCoincidence_153")
 SketchConstraintCoincidence_82 = Sketch_6.setCoincident(SketchLine_40.endPoint(), SketchLine_39.startPoint())
 SketchConstraintCoincidence_82.setName("SketchConstraintCoincidence_154")
-SketchConstraintCoincidence_83 = Sketch_6.setCoincident(SketchLine_41.startPoint(), SketchLine_41.result())
-SketchConstraintCoincidence_83.setName("SketchConstraintCoincidence_155")
 SketchConstraintCoincidence_84 = Sketch_6.setCoincident(SketchLine_41.startPoint(), SketchLine_39.endPoint())
 SketchConstraintCoincidence_84.setName("SketchConstraintCoincidence_156")
 model.do()
@@ -416,7 +412,7 @@ SketchLine_54.result().setName("SketchLine_55")
 SketchLine_54.setAuxiliary(True)
 SketchConstraintCoincidence_86 = Sketch_7.setCoincident(SketchLine_52.endPoint(), SketchLine_54.startPoint())
 SketchConstraintCoincidence_86.setName("SketchConstraintCoincidence_96")
-SketchLine_55 = Sketch_7.addLine(model.selection("EDGE", "RevolutionFuse_3_1/Modfied_17&RevolutionFuse_3_1/Modfied_10"))
+SketchLine_55 = Sketch_7.addLine(model.selection("EDGE", "RevolutionFuse_3_1/Modfied_13&RevolutionFuse_3_1/Modfied_10"))
 SketchLine_55.setName("SketchLine_56")
 SketchLine_55.result().setName("SketchLine_56")
 SketchConstraintCoincidence_87 = Sketch_7.setCoincident(SketchLine_54.endPoint(), SketchLine_55.result())
@@ -631,7 +627,7 @@ Sketch_10 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOY"))
 SketchLine_77 = Sketch_10.addLine(64, 20, 89, 20)
 SketchLine_77.setName("SketchLine_76")
 SketchLine_77.result().setName("SketchLine_76")
-SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_2_1/Modfied_11&RevolutionFuse_2_1/Modfied_13&RevolutionFuse_3_1/Modfied_13&RevolutionFuse_3_1/Modfied_2"))
+SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_2_1/Modfied_11&RevolutionFuse_2_1/Modfied_13&RevolutionFuse_3_1/Modfied_15&RevolutionFuse_3_1/Modfied_4"))
 SketchConstraintCoincidence_122 = Sketch_10.setCoincident(SketchLine_77.startPoint(), SketchPoint_4.result())
 SketchConstraintCoincidence_122.setName("SketchConstraintCoincidence_120")
 SketchPoint_5 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_8e-SketchLine_4e"))
@@ -640,10 +636,10 @@ SketchConstraintCoincidence_123.setName("SketchConstraintCoincidence_121")
 SketchLine_78 = Sketch_10.addLine(64, -20, 89, -20)
 SketchLine_78.setName("SketchLine_77")
 SketchLine_78.result().setName("SketchLine_77")
-SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_1_1/Modfied_4&RevolutionFuse_1_1/Modfied_9&RevolutionFuse_3_1/Modfied_15&RevolutionFuse_3_1/Modfied_6"))
+SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_1_1/Modfied_4&RevolutionFuse_1_1/Modfied_9&RevolutionFuse_3_1/Modfied_17&RevolutionFuse_3_1/Modfied_8"))
 SketchConstraintCoincidence_124 = Sketch_10.setCoincident(SketchLine_78.startPoint(), SketchPoint_6.result())
 SketchConstraintCoincidence_124.setName("SketchConstraintCoincidence_122")
-SketchPoint_7 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionFuse_2_1/Modfied_2&RevolutionFuse_1_1/Modfied_4&ExtrusionFuse_2_1/Modfied_1&RevolutionFuse_3_1/Modfied_15"))
+SketchPoint_7 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionFuse_2_1/Modfied_2&RevolutionFuse_1_1/Modfied_4&ExtrusionFuse_2_1/Modfied_1&RevolutionFuse_3_1/Modfied_17"))
 SketchConstraintCoincidence_125 = Sketch_10.setCoincident(SketchLine_78.endPoint(), SketchPoint_7.result())
 SketchConstraintCoincidence_125.setName("SketchConstraintCoincidence_123")
 SketchArc_10 = Sketch_10.addArc(89.00000104846708, 1.669244441022778e-015, 89, -20, 89, 20, False)
@@ -666,7 +662,7 @@ SketchConstraintCoincidence_129 = Sketch_10.setCoincident(SketchArc_11.startPoin
 SketchConstraintCoincidence_129.setName("SketchConstraintCoincidence_127")
 SketchConstraintTangent_19 = Sketch_10.setTangent(SketchArc_11.results()[1], SketchLine_78.result())
 SketchConstraintTangent_19.setName("SketchConstraintTangent_24")
-SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&RevolutionFuse_3_1/Modfied_7&RevolutionFuse_3_1/Modfied_6&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_5"))
+SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_9&RevolutionFuse_3_1/Modfied_7&RevolutionFuse_3_1/Modfied_8&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_9"))
 SketchConstraintCoincidence_130 = Sketch_10.setCoincident(SketchArc_11.endPoint(), SketchPoint_8.result())
 SketchConstraintCoincidence_130.setName("SketchConstraintCoincidence_128")
 SketchArc_12 = Sketch_10.addArc(64.00001789135865, 23.01137360115889, 64, 20, 61.15622559702543, 22.02080994708722, True)
@@ -677,7 +673,7 @@ SketchConstraintCoincidence_131 = Sketch_10.setCoincident(SketchArc_12.startPoin
 SketchConstraintCoincidence_131.setName("SketchConstraintCoincidence_129")
 SketchConstraintTangent_20 = Sketch_10.setTangent(SketchArc_12.results()[1], SketchLine_77.result())
 SketchConstraintTangent_20.setName("SketchConstraintTangent_25")
-SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&RevolutionFuse_3_1/Modfied_3&RevolutionFuse_3_1/Modfied_2&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_1"))
+SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_9&RevolutionFuse_3_1/Modfied_3&RevolutionFuse_3_1/Modfied_4&RevolutionFuse_3_1/Modfied_24&RevolutionFuse_3_1/Modfied_5"))
 SketchConstraintCoincidence_132 = Sketch_10.setCoincident(SketchArc_12.endPoint(), SketchPoint_9.result())
 SketchConstraintCoincidence_132.setName("SketchConstraintCoincidence_130")
 SketchLine_79 = Sketch_10.addLine(61.15622559702543, 22.02080994708722, 59.81204392543111, 22.0208099470871)
@@ -775,8 +771,8 @@ model.testNbResults(ExtrusionCut_4, 1)
 model.testNbSubResults(ExtrusionCut_4, [0])
 model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.SOLID, [1])
 model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.FACE, [81])
-model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.EDGE, [418])
-model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.VERTEX, [836])
-model.testResultsVolumes(ExtrusionCut_4, [502902.415176195616368204355239868])
+model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.EDGE, [406])
+model.testNbSubShapes(ExtrusionCut_4, GeomAPI_Shape.VERTEX, [812])
+model.testResultsVolumes(ExtrusionCut_4, [502902.431481667619664222002029419])
 
 assert(model.checkPythonDump())
index 1c2fdc5196e8424a971b3f25ca367490148fefe7..6e09d950ef5ba3244a27276f96ce0883008e63ff 100644 (file)
@@ -8,7 +8,7 @@ Part_1 = model.addPart(partSet)
 Part_1_doc = Part_1.document()
 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
 SketchLine_1 = Sketch_1.addLine(55.1, 10.3, 55.1, 0.3)
-SketchLine_2 = Sketch_1.addLine(55.1, 0.3, 2.300000098190561, 0.3)
+SketchLine_2 = Sketch_1.addLine(55.1, 0.3, 2.3, 0.3)
 SketchLine_2.setName("SketchLine_10")
 SketchLine_2.result().setName("SketchLine_10")
 SketchLine_3 = Sketch_1.addLine(55.1, 0.3, 0.3, 0.3)
@@ -16,10 +16,10 @@ SketchLine_3.setName("SketchLine_2")
 SketchLine_3.result().setName("SketchLine_2")
 SketchLine_3.setAuxiliary(True)
 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
-SketchLine_4 = Sketch_1.addLine(0.3, 2.299999958617008, 0.3, 10.3)
+SketchLine_4 = Sketch_1.addLine(0.3, 2.3, 0.3, 10.3)
 SketchLine_4.setName("SketchLine_11")
 SketchLine_4.result().setName("SketchLine_11")
-SketchLine_5 = Sketch_1.addLine(2.299981065494142, -1.390467145968888e-034, 55.4, -3.349267313974575e-033)
+SketchLine_5 = Sketch_1.addLine(2.3, 0, 55.4, 0)
 SketchLine_5.setName("SketchLine_12")
 SketchLine_5.result().setName("SketchLine_12")
 SketchLine_6 = Sketch_1.addLine(0.3, 0.3, 0.3, 10.3)
@@ -27,7 +27,7 @@ SketchLine_6.setName("SketchLine_3")
 SketchLine_6.result().setName("SketchLine_3")
 SketchLine_6.setAuxiliary(True)
 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_6.startPoint())
-SketchLine_7 = Sketch_1.addLine(0, 10.3, 0, 2.300013086422291)
+SketchLine_7 = Sketch_1.addLine(0, 10.3, 0, 2.3)
 SketchLine_7.setName("SketchLine_13")
 SketchLine_7.result().setName("SketchLine_13")
 SketchLine_8 = Sketch_1.addLine(0.3, 10.3, 0, 10.3)
@@ -38,17 +38,17 @@ SketchLine_9 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OZ"))
 SketchLine_9.setName("SketchLine_5")
 SketchLine_9.result().setName("SketchLine_5")
 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.result())
-SketchLine_10 = Sketch_1.addLine(0, 10.3, 0, -3.349267313974575e-033)
+SketchLine_10 = Sketch_1.addLine(0, 10.3, 0, 0)
 SketchLine_10.setName("SketchLine_6")
 SketchLine_10.result().setName("SketchLine_6")
 SketchLine_10.setAuxiliary(True)
 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_10.startPoint())
-SketchLine_11 = Sketch_1.addLine(0, -3.349267313974575e-033, 55.4, -3.349267313974575e-033)
+SketchLine_11 = Sketch_1.addLine(0, 0, 55.4, 0)
 SketchLine_11.setName("SketchLine_7")
 SketchLine_11.result().setName("SketchLine_7")
 SketchLine_11.setAuxiliary(True)
 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
-SketchLine_12 = Sketch_1.addLine(55.4, -3.349267313974575e-033, 55.4, 10.3)
+SketchLine_12 = Sketch_1.addLine(55.4, 0, 55.4, 10.3)
 SketchLine_12.setName("SketchLine_8")
 SketchLine_12.result().setName("SketchLine_8")
 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
@@ -72,7 +72,7 @@ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_11.result(), 55.4)
 SketchConstraintLength_3.setName("SketchConstraintLength_5")
 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
 SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 0.3)
-SketchArc_1 = Sketch_1.addArc(2.3, 2.3, 0.3, 2.299999958617008, 2.300000098190561, 0.3, False)
+SketchArc_1 = Sketch_1.addArc(2.3, 2.3, 0.3, 2.3, 2.3, 0.3, False)
 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_4.startPoint())
 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.endPoint())
 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result())
@@ -81,7 +81,7 @@ SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_3.startPoint(
 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_4.endPoint())
 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.result())
 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_6.result())
-SketchArc_2 = Sketch_1.addArc(2.3, 2.3, 0, 2.300013086422291, 2.299981065494142, -1.390467145968888e-034, False)
+SketchArc_2 = Sketch_1.addArc(2.3, 2.3, 0, 2.3, 2.3, 0, False)
 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_7.endPoint())
 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_5.startPoint())
 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_5.result())
@@ -97,12 +97,12 @@ model.do()
 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_10f-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_4f-SketchLine_8f-SketchLine_9f-SketchArc_1_2r-SketchArc_2_2f")], model.selection(), "307/2.", "307/2.")
 Extrusion_1.setName("Profil")
 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_7"))
-SketchLine_14 = Sketch_2.addLine(149.5, -2.299981065494, 153.5, -2.299981065494142)
+SketchLine_14 = Sketch_2.addLine(149.5, -2.3, 153.5, -2.3)
 SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/Generated_Face_6&Extrusion_1_1/To_Face_1"))
 SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchPoint_1.result())
-SketchLine_15 = Sketch_2.addLine(153.5, -2.299981065494142, 153.5, 7.700018934505839)
-SketchLine_16 = Sketch_2.addLine(153.5, 7.700018934505839, 149.5, 7.700018934505839)
-SketchLine_17 = Sketch_2.addLine(149.5, 7.700018934505839, 149.5, -2.299981065494)
+SketchLine_15 = Sketch_2.addLine(153.5, -2.3, 153.5, 7.7)
+SketchLine_16 = Sketch_2.addLine(153.5, 7.7, 149.5, 7.7)
+SketchLine_17 = Sketch_2.addLine(149.5, 7.7, 149.5, -2.3)
 SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchLine_14.startPoint())
 SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
 SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
@@ -111,10 +111,10 @@ SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_14.result())
 SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_15.result())
 SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_16.result())
 SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_17.result())
-SketchLine_18 = Sketch_2.addLine(-149.5, -2.299981065494142, -153.5, -2.299981065494142)
-SketchLine_19 = Sketch_2.addLine(-153.5, -2.299981065494142, -153.5, 7.700018934505858)
-SketchLine_20 = Sketch_2.addLine(-153.5, 7.700018934505858, -149.5, 7.700018934505858)
-SketchLine_21 = Sketch_2.addLine(-149.5, 7.700018934505858, -149.5, -2.299981065494142)
+SketchLine_18 = Sketch_2.addLine(-149.5, -2.3142, -153.5, -2.3142)
+SketchLine_19 = Sketch_2.addLine(-153.5, -2.3142, -153.5, 7.7)
+SketchLine_20 = Sketch_2.addLine(-153.5, 7.7, -149.5, 7.7)
+SketchLine_21 = Sketch_2.addLine(-149.5, 7.7, -149.5, -2.3142)
 SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchLine_21.endPoint(), SketchLine_18.startPoint())
 SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
 SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchLine_19.endPoint(), SketchLine_20.startPoint())
@@ -137,7 +137,7 @@ model.do()
 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")])
 ExtrusionCut_1.setName("Decoupe_Angle")
 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_8"))
-SketchLine_22 = Sketch_3.addLine(153.5, -10.3, 153.5, -8.300000000000011)
+SketchLine_22 = Sketch_3.addLine(153.5, -10.3, 153.5, -8.3)
 SketchLine_22.setName("SketchLine_29")
 SketchLine_22.result().setName("SketchLine_29")
 SketchPoint_3 = Sketch_3.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_9&ExtrusionCut_1_1/Modfied_1&Extrusion_1_1/Generated_Face_8"))
@@ -150,7 +150,7 @@ SketchLine_23.setName("SketchLine_30")
 SketchLine_23.result().setName("SketchLine_30")
 SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.result())
 SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_41")
-SketchLine_24 = Sketch_3.addLine(153.5, -8.300000000000011, 151.5, -10.3)
+SketchLine_24 = Sketch_3.addLine(153.5, -8.3, 151.5, -10.3)
 SketchLine_24.setName("SketchLine_31")
 SketchLine_24.result().setName("SketchLine_31")
 SketchConstraintCoincidence_37 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_24.startPoint())
@@ -183,21 +183,21 @@ Sketch_3.setName("Sketch_4")
 Sketch_3.result().setName("Sketch_4")
 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_1_1")])
 ExtrusionCut_2.setName("Chamfrein_1")
-Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_6"))
-SketchLine_30 = Sketch_4.addLine(-149.5, 10.3, -149.5, 8.300000000000003)
+Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_7"))
+SketchLine_30 = Sketch_4.addLine(-149.5, 10.3, -149.5, 8.3)
 SketchLine_30.setName("SketchLine_35")
 SketchLine_30.result().setName("SketchLine_35")
-SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_10&ExtrusionCut_1_1/Modfied_6&ExtrusionCut_1_1/Modfied_5"))
+SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_11&ExtrusionCut_1_1/Modfied_7&ExtrusionCut_1_1/Modfied_6"))
 SketchPoint_4.setName("SketchPoint_6")
 SketchPoint_4.result().setName("SketchPoint_6")
 SketchConstraintCoincidence_42 = Sketch_4.setCoincident(SketchLine_30.startPoint(), SketchPoint_4.result())
 SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_43")
-SketchLine_31 = Sketch_4.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_10&ExtrusionCut_1_1/Modfied_6"))
+SketchLine_31 = Sketch_4.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_11&ExtrusionCut_1_1/Modfied_7"))
 SketchLine_31.setName("SketchLine_36")
 SketchLine_31.result().setName("SketchLine_36")
 SketchConstraintCoincidence_43 = Sketch_4.setCoincident(SketchLine_30.endPoint(), SketchLine_31.result())
 SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_48")
-SketchLine_32 = Sketch_4.addLine(-149.5, 8.300000000000003, -147.5, 10.3)
+SketchLine_32 = Sketch_4.addLine(-149.5, 8.3, -147.5, 10.3)
 SketchLine_32.setName("SketchLine_37")
 SketchLine_32.result().setName("SketchLine_37")
 SketchConstraintCoincidence_44 = Sketch_4.setCoincident(SketchLine_30.endPoint(), SketchLine_32.startPoint())
@@ -267,15 +267,15 @@ SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_59")
 model.do()
 Sketch_4.setName("Sketch_5")
 Sketch_4.result().setName("Sketch_5")
-ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_5")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")])
-Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_8"))
+ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_5")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_5"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")])
+Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_9"))
 SketchLine_40 = Sketch_5.addLine(152.2999838762584, -21.04999053274691, 153.5, -21.04999053274714)
 SketchLine_40.setName("SketchLine_58")
 SketchLine_40.result().setName("SketchLine_58")
 SketchLine_41 = Sketch_5.addLine(152.2999838292651, -45.04999053274704, 153.5, -45.04999053274702)
 SketchLine_41.setName("SketchLine_57")
 SketchLine_41.result().setName("SketchLine_57")
-SketchLine_42 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"))
+SketchLine_42 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_1_1/Modfied_9"))
 SketchLine_42.setName("SketchLine_46")
 SketchLine_42.result().setName("SketchLine_46")
 SketchLine_43 = Sketch_5.addLine(150.8, -45.04999053274702, 153.5, -45.04999053274702)
@@ -287,7 +287,7 @@ SketchConstraintCoincidence_55.setName("SketchConstraintCoincidence_60")
 SketchLine_44 = Sketch_5.addLine(153.5, -45.04999053274702, 153.5, -37.04999053274702)
 SketchLine_44.setName("SketchLine_47")
 SketchLine_44.result().setName("SketchLine_47")
-SketchLine_45 = Sketch_5.addLine(150.8000000000001, -14.54997391609652, 150.8000000000001, -19.54999029833178)
+SketchLine_45 = Sketch_5.addLine(150.8, -14.54997391609652, 150.8, -19.54999029833178)
 SketchLine_45.setName("SketchLine_61")
 SketchLine_45.result().setName("SketchLine_61")
 SketchLine_46 = Sketch_5.addLine(153.5, -13.04999053274714, 152.2999838654776, -13.04999053274697)
@@ -314,10 +314,10 @@ SketchConstraintVertical_10 = Sketch_5.setVertical(SketchLine_47.result())
 SketchLine_49 = Sketch_5.addLine(153.5, -37.04999053274702, 152.2999989299055, -37.04999053274738)
 SketchLine_49.setName("SketchLine_62")
 SketchLine_49.result().setName("SketchLine_62")
-SketchLine_50 = Sketch_5.addLine(150.8, -38.54997391988981, 150.8000000000001, -43.54998998548124)
+SketchLine_50 = Sketch_5.addLine(150.8, -38.54997391988981, 150.8, -43.54998998548124)
 SketchLine_50.setName("SketchLine_63")
 SketchLine_50.result().setName("SketchLine_63")
-SketchLine_51 = Sketch_5.addLine(150.7999999999999, -21.04999053274714, 153.5, -21.04999053274714)
+SketchLine_51 = Sketch_5.addLine(150.8, -21.04999053274714, 153.5, -21.04999053274714)
 SketchLine_51.setName("SketchLine_50")
 SketchLine_51.result().setName("SketchLine_50")
 SketchLine_51.setAuxiliary(True)
@@ -326,13 +326,13 @@ SketchConstraintCoincidence_60.setName("SketchConstraintCoincidence_65")
 SketchLine_52 = Sketch_5.addLine(153.5, -21.04999053274714, 153.5, -13.04999053274714)
 SketchLine_52.setName("SketchLine_51")
 SketchLine_52.result().setName("SketchLine_51")
-SketchLine_53 = Sketch_5.addLine(150.7999999999999, -13.04999053274714, 150.7999999999999, -21.04999053274714)
+SketchLine_53 = Sketch_5.addLine(150.8, -13.04999053274714, 150.8, -21.04999053274714)
 SketchLine_53.setAuxiliary(True)
 SketchConstraintCoincidence_61 = Sketch_5.setCoincident(SketchLine_53.endPoint(), SketchLine_51.startPoint())
 SketchConstraintCoincidence_61.setName("SketchConstraintCoincidence_66")
 SketchConstraintCoincidence_62 = Sketch_5.setCoincident(SketchLine_51.endPoint(), SketchLine_52.startPoint())
 SketchConstraintCoincidence_62.setName("SketchConstraintCoincidence_67")
-SketchLine_54 = Sketch_5.addLine(153.5, -13.04999053274714, 150.7999999999999, -13.04999053274714)
+SketchLine_54 = Sketch_5.addLine(153.5, -13.04999053274714, 150.8, -13.04999053274714)
 SketchLine_54.setName("SketchLine_52")
 SketchLine_54.result().setName("SketchLine_52")
 SketchLine_54.setAuxiliary(True)
@@ -361,16 +361,16 @@ SketchLine_55.result().setName("SketchLine_54")
 SketchLine_55.setAuxiliary(True)
 SketchConstraintCoincidence_66 = Sketch_5.setCoincident(SketchPoint_5.coordinates(), SketchLine_55.startPoint())
 SketchConstraintCoincidence_66.setName("SketchConstraintCoincidence_71")
-SketchLine_56 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_1_1/Modfied_8"))
+SketchLine_56 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_1_1/Modfied_9"))
 SketchLine_56.setName("SketchLine_55")
 SketchLine_56.result().setName("SketchLine_55")
 SketchConstraintCoincidence_67 = Sketch_5.setCoincident(SketchLine_55.endPoint(), SketchLine_56.result())
 SketchConstraintCoincidence_67.setName("SketchConstraintCoincidence_72")
 SketchConstraintHorizontal_15 = Sketch_5.setHorizontal(SketchLine_55.result())
-SketchConstraintDistance_8 = Sketch_5.setDistance(SketchLine_48.result(), SketchPoint_5.coordinates(), 8.199999999999999)
+SketchConstraintDistance_8 = Sketch_5.setDistance(SketchLine_48.result(), SketchPoint_5.coordinates(), 8.2)
 SketchConstraintDistance_9 = Sketch_5.setDistance(SketchLine_51.result(), SketchPoint_5.coordinates(), 7.8)
-SketchArc_3 = Sketch_5.addArc(152.3, -43.54999053274682, 150.8000000000001, -43.54998998548124, 152.2999838292651, -45.04999053274704, False)
-SketchLine_57 = Sketch_5.addLine(150.8, -37.04999053274702, 150.8000000000001, -43.54998998548124)
+SketchArc_3 = Sketch_5.addArc(152.3, -43.54999053274682, 150.8, -43.54998998548124, 152.2999838292651, -45.04999053274704, False)
+SketchLine_57 = Sketch_5.addLine(150.8, -37.04999053274702, 150.8, -43.54998998548124)
 SketchLine_57.setName("SketchLine_56")
 SketchLine_57.result().setName("SketchLine_56")
 SketchLine_57.setAuxiliary(True)
@@ -388,8 +388,8 @@ SketchConstraintCoincidence_72 = Sketch_5.setCoincident(SketchLine_57.endPoint()
 SketchConstraintCoincidence_72.setName("SketchConstraintCoincidence_77")
 SketchConstraintCoincidence_73 = Sketch_5.setCoincident(SketchLine_41.startPoint(), SketchLine_43.result())
 SketchConstraintCoincidence_73.setName("SketchConstraintCoincidence_78")
-SketchArc_4 = Sketch_5.addArc(152.3, -19.54999053274696, 150.8000000000001, -19.54999029833178, 152.2999838762584, -21.04999053274691, False)
-SketchLine_58 = Sketch_5.addLine(150.7999999999999, -13.04999053274714, 150.8000000000001, -19.54999029833178)
+SketchArc_4 = Sketch_5.addArc(152.3, -19.54999053274696, 150.8, -19.54999029833178, 152.2999838762584, -21.04999053274691, False)
+SketchLine_58 = Sketch_5.addLine(150.8, -13.04999053274714, 150.8, -19.54999029833178)
 SketchLine_58.setName("SketchLine_59")
 SketchLine_58.result().setName("SketchLine_59")
 SketchLine_58.setAuxiliary(True)
@@ -407,7 +407,7 @@ SketchConstraintCoincidence_78 = Sketch_5.setCoincident(SketchLine_40.startPoint
 SketchConstraintCoincidence_78.setName("SketchConstraintCoincidence_83")
 SketchConstraintCoincidence_79 = Sketch_5.setCoincident(SketchLine_58.endPoint(), SketchLine_53.result())
 SketchConstraintCoincidence_79.setName("SketchConstraintCoincidence_84")
-SketchArc_5 = Sketch_5.addArc(152.2999999999999, -14.54999053274707, 152.2999838654776, -13.04999053274697, 150.8000000000001, -14.54997391609652, False)
+SketchArc_5 = Sketch_5.addArc(152.3, -14.54999053274707, 152.2999838654776, -13.04999053274697, 150.8, -14.54997391609652, False)
 SketchConstraintCoincidence_80 = Sketch_5.setCoincident(SketchArc_5.startPoint(), SketchLine_46.endPoint())
 SketchConstraintCoincidence_80.setName("SketchConstraintCoincidence_85")
 SketchConstraintCoincidence_81 = Sketch_5.setCoincident(SketchArc_5.endPoint(), SketchLine_45.startPoint())
@@ -485,25 +485,25 @@ SketchLine_68.result().setName("SketchLine_73")
 model.do()
 Sketch_5.setName("Sketch_6")
 Sketch_5.result().setName("Sketch_6")
-ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchArc_9_2f-SketchArc_10_2f-SketchLine_73r-SketchLine_74r-SketchLine_75r-SketchLine_76r"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_58f-SketchLine_61f-SketchLine_60f-SketchLine_51f-SketchArc_4_2f-SketchArc_5_2f"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_57f-SketchLine_47f-SketchLine_62f-SketchLine_63f-SketchArc_3_2f-SketchArc_6_2f")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_3_1")])
+ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchArc_9_2f-SketchArc_10_2f-SketchLine_73r-SketchLine_74r-SketchLine_75r-SketchLine_76r"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_58f-SketchLine_61f-SketchLine_60f-SketchLine_51f-SketchArc_4_2f-SketchArc_5_2f"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_57f-SketchLine_47f-SketchLine_62f-SketchLine_63f-SketchArc_3_2f-SketchArc_6_2f")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_3_1")])
 Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_4_1/Modfied_1"))
-SketchArc_11 = Sketch_6.addArc(44.88999999999999, -23.54999053274703, 43.88999999999999, -23.54999053274703, 44.88999999999999, -22.54999053274703, False)
-SketchArc_12 = Sketch_6.addArc(44.88999999999999, -13.54999053274703, 44.88999999999999, -14.54999053274703, 43.88999999999999, -13.54999053274703, False)
+SketchArc_11 = Sketch_6.addArc(44.89, -23.54999053274703, 43.89, -23.54999053274703, 44.89, -22.54999053274703, False)
+SketchArc_12 = Sketch_6.addArc(44.89, -13.54999053274703, 44.89, -14.54999053274703, 43.89, -13.54999053274703, False)
 SketchArc_13 = Sketch_6.addArc(5.89, -13.54999053274703, 6.89, -13.54999053274703, 5.89, -14.54999053274703, False)
 SketchArc_13.setName("SketchArc_14")
 SketchArc_13.result().setName("SketchArc_14")
 SketchArc_13.results()[1].setName("SketchArc_14_2")
-SketchLine_76 = Sketch_6.addLine(6.890000000000002, -23.54999053274703, 43.88999999999999, -23.54999053274703)
+SketchLine_76 = Sketch_6.addLine(6.89, -23.54999053274703, 43.89, -23.54999053274703)
 SketchLine_76.setName("SketchLine_81")
 SketchLine_76.result().setName("SketchLine_81")
 SketchConstraintCoincidence_92 = Sketch_6.setCoincident(SketchArc_11.startPoint(), SketchLine_76.endPoint())
 SketchConstraintCoincidence_92.setName("SketchConstraintCoincidence_98")
-SketchLine_77 = Sketch_6.addLine(6.89, -13.54999053274703, 43.88999999999999, -13.54999053274703)
+SketchLine_77 = Sketch_6.addLine(6.89, -13.54999053274703, 43.89, -13.54999053274703)
 SketchLine_77.setName("SketchLine_82")
 SketchLine_77.result().setName("SketchLine_82")
 SketchConstraintCoincidence_93 = Sketch_6.setCoincident(SketchArc_13.startPoint(), SketchLine_77.startPoint())
 SketchConstraintCoincidence_93.setName("SketchConstraintCoincidence_99")
-SketchLine_78 = Sketch_6.addLine(44.88999999999999, -22.54999053274703, 44.88999999999999, -14.54999053274703)
+SketchLine_78 = Sketch_6.addLine(44.89, -22.54999053274703, 44.89, -14.54999053274703)
 SketchLine_78.setName("SketchLine_83")
 SketchLine_78.result().setName("SketchLine_83")
 SketchConstraintCoincidence_94 = Sketch_6.setCoincident(SketchArc_12.startPoint(), SketchLine_78.endPoint())
@@ -547,7 +547,7 @@ SketchLine_81 = Sketch_6.addLine(model.selection("EDGE", "Sketch_6/Edge-SketchLi
 SketchLine_81.setName("SketchLine_86")
 SketchLine_81.result().setName("SketchLine_86")
 SketchConstraintDistance_13 = Sketch_6.setDistance(SketchLine_76.endPoint(), SketchLine_81.result(), 5.3)
-SketchArc_14 = Sketch_6.addArc(5.890000000000002, -23.54999053274703, 5.89, -22.54999053274703, 6.890000000000002, -23.54999053274703, False)
+SketchArc_14 = Sketch_6.addArc(5.89, -23.54999053274703, 5.89, -22.54999053274703, 6.89, -23.54999053274703, False)
 SketchArc_14.setName("SketchArc_15")
 SketchArc_14.result().setName("SketchArc_15")
 SketchArc_14.results()[1].setName("SketchArc_15_2")
@@ -689,7 +689,7 @@ SketchArc_24.results()[1].setName("SketchArc_25_2")
 SketchArc_23.setName("SketchArc_24")
 SketchArc_23.result().setName("SketchArc_24")
 SketchArc_23.results()[1].setName("SketchArc_24_2")
-SketchPoint_9 = Sketch_6.addPoint(1.460819920296274e-014, -49.84999053274704)
+SketchPoint_9 = Sketch_6.addPoint(0, -49.84999053274704)
 SketchPoint_9.setName("SketchPoint_11")
 SketchPoint_9.result().setName("SketchPoint_11")
 SketchConstraintCoincidence_112 = Sketch_6.setCoincident(SketchPoint_9.coordinates(), SketchLine_80.result())
@@ -821,12 +821,12 @@ SketchArc_35.results()[1].setName("SketchArc_36_2")
 model.do()
 Sketch_6.setName("Sketch_7")
 Sketch_6.result().setName("Sketch_7")
-ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchArc_20_2f-SketchArc_21_2f-SketchArc_22_2f-SketchArc_23_2f-SketchLine_91r-SketchLine_92f-SketchLine_93r-SketchLine_94f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_52_2f-SketchArc_53_2f-SketchArc_56_2f-SketchArc_57_2f-SketchLine_114r-SketchLine_115f-SketchLine_116r-SketchLine_121f"), model.selection("FACE", "Sketch_7/Face-SketchArc_44_2f-SketchArc_45_2f-SketchArc_48_2f-SketchArc_49_2f-SketchLine_107f-SketchLine_113f-SketchLine_117r-SketchLine_123r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_16_2f-SketchArc_17_2f-SketchArc_18_2f-SketchArc_19_2f-SketchLine_87f-SketchLine_88f-SketchLine_89r-SketchLine_90r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_11_2f-SketchArc_12_2f-SketchArc_14_2f-SketchLine_81f-SketchLine_82r-SketchLine_83f-SketchLine_84r-SketchArc_15_2f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_36_2f-SketchArc_38_2f-SketchArc_40_2f-SketchArc_41_2f-SketchLine_108r-SketchLine_119r-SketchLine_127f-SketchLine_129f"), model.selection("FACE", "Sketch_7/Face-SketchArc_37_2f-SketchArc_39_2f-SketchArc_42_2f-SketchArc_43_2f-SketchLine_118r-SketchLine_120f-SketchLine_122r-SketchLine_130f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_27_2f-SketchLine_98f-SketchLine_100r-SketchLine_101f-SketchLine_103r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_30_2f-SketchArc_31_2f-SketchArc_34_2f-SketchArc_35_2f-SketchLine_95f-SketchLine_96r-SketchLine_97f-SketchLine_105r"), model.selection("FACE", "Sketch_7/Face-SketchArc_46_2f-SketchArc_47_2f-SketchArc_50_2f-SketchArc_51_2f-SketchLine_124f-SketchLine_125r-SketchLine_126f-SketchLine_128r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_54_2f-SketchArc_55_2f-SketchArc_58_2f-SketchArc_59_2f-SketchLine_109f-SketchLine_110r-SketchLine_111r-SketchLine_112f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_28_2f-SketchArc_29_2f-SketchArc_32_2f-SketchArc_33_2f-SketchLine_99r-SketchLine_102f-SketchLine_104f-SketchLine_106r")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_4_1")])
+ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchArc_20_2f-SketchArc_21_2f-SketchArc_22_2f-SketchArc_23_2f-SketchLine_91r-SketchLine_92f-SketchLine_93r-SketchLine_94f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_52_2f-SketchArc_53_2f-SketchArc_56_2f-SketchArc_57_2f-SketchLine_114r-SketchLine_115f-SketchLine_116r-SketchLine_121f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_44_2f-SketchArc_45_2f-SketchArc_48_2f-SketchArc_49_2f-SketchLine_107f-SketchLine_113f-SketchLine_117r-SketchLine_123r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_16_2f-SketchArc_17_2f-SketchArc_18_2f-SketchArc_19_2f-SketchLine_87f-SketchLine_88f-SketchLine_89r-SketchLine_90r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_11_2f-SketchArc_12_2f-SketchArc_14_2f-SketchLine_81f-SketchLine_82r-SketchLine_83f-SketchLine_84r-SketchArc_15_2f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_36_2f-SketchArc_38_2f-SketchArc_40_2f-SketchArc_41_2f-SketchLine_108r-SketchLine_119r-SketchLine_127f-SketchLine_129f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_37_2f-SketchArc_39_2f-SketchArc_42_2f-SketchArc_43_2f-SketchLine_118r-SketchLine_120f-SketchLine_122r-SketchLine_130f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_27_2f-SketchLine_98f-SketchLine_100r-SketchLine_101f-SketchLine_103r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_30_2f-SketchArc_31_2f-SketchArc_34_2f-SketchArc_35_2f-SketchLine_95f-SketchLine_96r-SketchLine_97f-SketchLine_105r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_46_2f-SketchArc_47_2f-SketchArc_50_2f-SketchArc_51_2f-SketchLine_124f-SketchLine_125r-SketchLine_126f-SketchLine_128r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_54_2f-SketchArc_55_2f-SketchArc_58_2f-SketchArc_59_2f-SketchLine_109f-SketchLine_110r-SketchLine_111r-SketchLine_112f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_28_2f-SketchArc_29_2f-SketchArc_32_2f-SketchArc_33_2f-SketchLine_99r-SketchLine_102f-SketchLine_104f-SketchLine_106r")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_4_1")])
 Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_5_1/Modfied_1"))
 SketchLine_126 = Sketch_7.addLine(-153.5, -37.049990532747, -152.3000099350335, -37.0499905327475)
 SketchLine_126.setName("SketchLine_135")
 SketchLine_126.result().setName("SketchLine_135")
-SketchLine_127 = Sketch_7.addLine(-150.7999999999999, -38.54999290880026, -150.8, -43.54999111476925)
+SketchLine_127 = Sketch_7.addLine(-150.8, -38.54999290880026, -150.8, -43.54999111476925)
 SketchLine_127.setName("SketchLine_138")
 SketchLine_127.result().setName("SketchLine_138")
 SketchPoint_10 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_6/Vertex-SketchLine_67s-SketchLine_68e-SketchLine_69e"))
@@ -869,11 +869,11 @@ SketchPoint_11.setName("SketchPoint_13")
 SketchPoint_11.result().setName("SketchPoint_13")
 SketchConstraintCoincidence_118 = Sketch_7.setCoincident(SketchLine_132.endPoint(), SketchPoint_11.result())
 SketchConstraintCoincidence_118.setName("SketchConstraintCoincidence_125")
-SketchArc_59 = Sketch_7.addArc(-152.3, -38.54999053274712, -150.7999999999999, -38.54999290880026, -152.3000099350335, -37.0499905327475, False)
+SketchArc_59 = Sketch_7.addArc(-152.3, -38.54999053274712, -150.8, -38.54999290880026, -152.3000099350335, -37.0499905327475, False)
 SketchArc_59.setName("SketchArc_60")
 SketchArc_59.result().setName("SketchArc_60")
 SketchArc_59.results()[1].setName("SketchArc_60_2")
-SketchLine_133 = Sketch_7.addLine(-150.7999999999999, -38.54999290880026, -150.8, -45.049990532747)
+SketchLine_133 = Sketch_7.addLine(-150.8, -38.54999290880026, -150.8, -45.049990532747)
 SketchLine_133.setName("SketchLine_136")
 SketchLine_133.result().setName("SketchLine_136")
 SketchLine_133.setAuxiliary(True)
@@ -916,15 +916,15 @@ Sketch_7.setName("Sketch_8")
 Sketch_7.result().setName("Sketch_8")
 ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_8")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_5_1")])
 Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_6_1/Modfied_2"))
-SketchLine_134 = Sketch_8.addLine(0.8499999999999983, 50.75, -0.8500000000000015, 50.75)
+SketchLine_134 = Sketch_8.addLine(0.85, 50.75, -0.85, 50.75)
 SketchLine_134.setName("SketchLine_139")
 SketchLine_134.result().setName("SketchLine_139")
-SketchLine_135 = Sketch_8.addLine(-0.8500000000000015, 47.45, 0.8499999999999983, 47.45)
+SketchLine_135 = Sketch_8.addLine(-0.85, 47.45, 0.85, 47.45)
 SketchLine_135.setName("SketchLine_141")
 SketchLine_135.result().setName("SketchLine_141")
 SketchConstraintHorizontal_20 = Sketch_8.setHorizontal(SketchLine_134.result())
 SketchConstraintHorizontal_21 = Sketch_8.setHorizontal(SketchLine_135.result())
-SketchArc_61 = Sketch_8.addArc(0.8499999999999999, 49.1, 0.8499999999999983, 47.45, 0.8499999999999983, 50.75, False)
+SketchArc_61 = Sketch_8.addArc(0.85, 49.1, 0.85, 47.45, 0.85, 50.75, False)
 SketchArc_61.setName("SketchArc_63")
 SketchArc_61.result().setName("SketchArc_63")
 SketchArc_61.results()[1].setName("SketchArc_63_2")
@@ -933,7 +933,7 @@ SketchConstraintCoincidence_131.setName("SketchConstraintCoincidence_146")
 SketchConstraintCoincidence_132 = Sketch_8.setCoincident(SketchArc_61.startPoint(), SketchLine_135.endPoint())
 SketchConstraintCoincidence_132.setName("SketchConstraintCoincidence_148")
 SketchConstraintDistance_17 = Sketch_8.setDistance(SketchLine_134.result(), SketchLine_135.endPoint(), 3.3)
-SketchLine_136 = Sketch_8.addLine(0.8499999999999983, 50.75, 0.8499999999999983, 47.45)
+SketchLine_136 = Sketch_8.addLine(0.85, 50.75, 0.85, 47.45)
 SketchLine_136.setName("SketchLine_140")
 SketchLine_136.result().setName("SketchLine_140")
 SketchLine_136.setAuxiliary(True)
@@ -945,7 +945,7 @@ SketchConstraintCoincidence_135 = Sketch_8.setCoincident(SketchLine_135.endPoint
 SketchConstraintCoincidence_135.setName("SketchConstraintCoincidence_140")
 SketchConstraintCoincidence_136 = Sketch_8.setCoincident(SketchArc_61.startPoint(), SketchLine_136.endPoint())
 SketchConstraintCoincidence_136.setName("SketchConstraintCoincidence_141")
-SketchLine_137 = Sketch_8.addLine(-0.8500000000000015, 50.75, -0.8500000000000015, 47.45)
+SketchLine_137 = Sketch_8.addLine(-0.85, 50.75, -0.85, 47.45)
 SketchLine_137.setName("SketchLine_142")
 SketchLine_137.result().setName("SketchLine_142")
 SketchLine_137.setAuxiliary(True)
@@ -958,7 +958,7 @@ SketchConstraintLength_10 = Sketch_8.setLength(SketchLine_134.result(), 1.7)
 SketchConstraintLength_10.setName("SketchConstraintLength_11")
 SketchConstraintVertical_17 = Sketch_8.setVertical(SketchLine_137.result())
 SketchConstraintVertical_18 = Sketch_8.setVertical(SketchLine_136.result())
-SketchLine_138 = Sketch_8.addLine(0.8499999999999983, 50.75, -0.8500000000000015, 47.45)
+SketchLine_138 = Sketch_8.addLine(0.85, 50.75, -0.85, 47.45)
 SketchLine_138.setName("SketchLine_143")
 SketchLine_138.result().setName("SketchLine_143")
 SketchLine_138.setAuxiliary(True)
@@ -985,7 +985,7 @@ SketchLine_139.setName("SketchLine_144")
 SketchLine_139.result().setName("SketchLine_144")
 SketchConstraintCoincidence_145 = Sketch_8.setCoincident(SketchPoint_12.coordinates(), SketchLine_139.result())
 SketchConstraintCoincidence_145.setName("SketchConstraintCoincidence_157")
-SketchArc_62 = Sketch_8.addArc(-0.8500000000000004, 49.1, -0.8500000000000015, 50.75, -0.8500000000000015, 47.45, False)
+SketchArc_62 = Sketch_8.addArc(-0.85, 49.1, -0.85, 50.75, -0.85, 47.45, False)
 SketchConstraintCoincidence_146 = Sketch_8.setCoincident(SketchLine_135.startPoint(), SketchArc_62.endPoint())
 SketchConstraintCoincidence_146.setName("SketchConstraintCoincidence_149")
 SketchConstraintCoincidence_147 = Sketch_8.setCoincident(SketchLine_137.endPoint(), SketchArc_62.endPoint())
@@ -1048,8 +1048,8 @@ model.testNbResults(ExtrusionCut_7, 1)
 model.testNbSubResults(ExtrusionCut_7, [0])
 model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.SOLID, [1])
 model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.FACE, [156])
-model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.EDGE, [920])
-model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.VERTEX, [1840])
-model.testResultsVolumes(ExtrusionCut_7, [5345.689532925511230132542550564])
+model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.EDGE, [916])
+model.testNbSubShapes(ExtrusionCut_7, GeomAPI_Shape.VERTEX, [1832])
+model.testResultsVolumes(ExtrusionCut_7, [5345.689484659372283203992992640])
 
 assert(model.checkPythonDump)
index 2c456ef9f19c55480b96ddb969fbb0cf58e3723d..bb803520362bfb4fbcce27c3110f16c6621dff4a 100644 (file)
@@ -59,6 +59,16 @@ SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_7.startPoint(
 SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_20")
 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchArc_3.results()[1])
 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchArc_2.results()[1])
+model.do()
+
+# check overconstraint message appears
+assert Sketch_1.solverError().value() != "", "FAILED: Sketch should report over-constrained situation"
+# remove duplicated Tangent constraint
+Part_1_doc.removeFeature(SketchConstraintTangent_3.feature())
+model.do()
+assert Sketch_1.solverError().value() == "", "FAILED: Sketch should NOT report over-constrained situation"
+
+# continue creating model
 SketchLine_8 = Sketch_1.addLine(16.63997893808557, 190, 16.63997893808557, 184)
 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_8.startPoint())
 SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_21")
@@ -234,6 +244,6 @@ model.testNbSubShapes(Boolean_1, GeomAPI_Shape.SOLID, [1])
 model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [35])
 model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [162])
 model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [324])
-model.testResultsVolumes(Boolean_1, [2053931.831648423336446285247802734])
+model.testResultsVolumes(Boolean_1, [2053931.555419394280761480331420898])
 
 assert(model.checkPythonDump())