Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authormpv <mpv@opencascade.com>
Wed, 25 Mar 2015 09:00:51 +0000 (12:00 +0300)
committermpv <mpv@opencascade.com>
Wed, 25 Mar 2015 09:00:51 +0000 (12:00 +0300)
Conflicts:
src/SketchPlugin/SketchPlugin_Sketch.cpp

12 files changed:
CMakeLists.txt
src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeReference.cpp
src/Model/Model_AttributeSelection.cpp
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp

index f1042dade8d9700e911dd188a865d35ee3b9dbc9..789636f2afb261daeeb20d5ab08302d473979efc 100644 (file)
@@ -65,7 +65,6 @@ ADD_SUBDIRECTORY (src/GeomApp)
 ADD_SUBDIRECTORY (src/ExchangePlugin)
 ADD_SUBDIRECTORY (src/GeomValidators)
 ADD_SUBDIRECTORY (src/InitializationPlugin)
-ADD_SUBDIRECTORY (src/ParametersPlugin)
 
 IF(${HAVE_SALOME})
     ADD_SUBDIRECTORY (src/NewGeom)
index f4ae420490bada6d8d4b177459ba93c67198fb94..8f053f7cf90a838a5741d17fb442dc9d6e85ee29 100644 (file)
@@ -311,9 +311,9 @@ void GeomAPI_AISObject::getColor(int& theR, int& theG, int& theB)
     return;
 
   Quantity_Color aColor = anAIS->Color();
-  theR = aColor.Red()*255.;
-  theG = aColor.Green()*255.;
-  theB = aColor.Blue()*255.;
+  theR = (int)(aColor.Red()*255.);
+  theG = (int)(aColor.Green()*255.);
+  theB = (int)(aColor.Blue()*255.);
 }
 
 bool GeomAPI_AISObject::empty() const
index 4b815e3a10a584bcb2ca22f6f3d892c1bac8fee6..9933454463b8291eeb282c427c6cda2f7708dcc0 100644 (file)
@@ -176,6 +176,8 @@ void GeomAlgoAPI_Placement::build(
   gp_Trsf aTrsf;
   gp_Vec aSrcDir = aSrcDstNormals[0];
   gp_Vec aDstDir = aSrcDstNormals[1];
+  gp_Vec aSrcDir = aSrcDstNormals[0];
+  gp_Vec aDstDir = aSrcDstNormals[1];
   // Calculate rotation
   gp_Quaternion aRot(aSrcDir, aDstDir);
   aTrsf.SetRotation(aRot);
index effa56db232cb21a0989fc801baad662fcf283a1..c9722835887b00258b8e1acbac9797dac0dd06c1 100644 (file)
@@ -16,6 +16,12 @@ void Model_AttributeRefList::append(ObjectPtr theObject)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theObject->data());
   myRef->Append(aData->label().Father());  // store label of the object
+  // do it before the transaction finish to make just created/removed objects know dependencies
+  // and reference from composite feature is removed automatically
+  FeaturePtr anOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+  if (anOwnerFeature.get()) {
+    aData->addBackReference(anOwnerFeature, id());
+  }
 
   owner()->data()->sendAttributeUpdated(this);
 }
index 43bbabe658fff74259890026c982b1302d55670c..91de64eb567de9f94889a6274c98f8ae8c6dcebc 100644 (file)
@@ -22,9 +22,9 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
   if(!theObject)
     return;
   if (!myIsInitialized || value() != theObject) {
-      std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
-          theObject->data());
-      TDF_Label anObjLab = aData->label().Father(); // object label
+    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
+        theObject->data());
+    TDF_Label anObjLab = aData->label().Father(); // object label
 
     if (owner()->document() == theObject->document()) { // same document, use reference attribute
 
@@ -41,6 +41,12 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
       TDF_Tool::Entry(anObjLab, anEntry);
       TDataStd_AsciiString::Set(myRef->Label(), anEntry);
     }
+    // do it before the transaction finish to make just created/removed objects know dependencies
+    // and reference from composite feature is removed automatically
+    FeaturePtr anOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+    if (anOwnerFeature.get()) {
+      aData->addBackReference(anOwnerFeature, id());
+    }
 
     owner()->data()->sendAttributeUpdated(this);
   }
index 4e1f21b91afd30e2121a6e55db511d24dd1566cf..f1cf7fa5b42f4b8266c9cfac080b76ed11ed2e57 100644 (file)
@@ -15,7 +15,6 @@
 #include <ModelAPI_CompositeFeature.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_PlanarEdges.h>
-#include <GeomAlgoAPI_SketchBuilder.h>
 #include <Events_Error.h>
 
 #include <TNaming_Selector.hxx>
@@ -217,10 +216,12 @@ bool Model_AttributeSelection::update()
   } else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) {
     // construction: identification by the results indexes, recompute faces and
     // take the face that more close by the indexes
-    std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
-      std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext)->shape());
-    if (aWirePtr && aWirePtr->hasPlane()) { // sketch sub-element
+    ResultConstructionPtr aConstructionContext = 
+      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+    // sketch sub-element
+    if (aConstructionContext && 
+        std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContext).get())
+    {
       TDF_Label aLab = myRef.myRef->Label();
       // getting a type of selected shape
       Handle(TDataStd_Integer) aTypeAttr;
@@ -243,15 +244,12 @@ bool Model_AttributeSelection::update()
 
       if (aShapeType == TopAbs_FACE) { // compound is for the whole sketch selection
         // If this is a wire with plane defined thin it is a sketch-like object
-        std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
-        GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
-          aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, aFaces);
-        if (aFaces.empty()) // no faces, update can not work correctly
+        if (!aConstructionContext->facesNum()) // no faces, update can not work correctly
           return false;
         // if there is no edges indexes, any face can be used: take the first
         std::shared_ptr<GeomAPI_Shape> aNewSelected;
         if (aNoIndexes) {
-          aNewSelected = *(aFaces.begin());
+          aNewSelected = aConstructionContext->face(0);
         } else { // searching for most looks-like initial face by the indexes
           // prepare edges of the current resut for the fast searching
           TColStd_MapOfTransient allCurves;
@@ -276,12 +274,11 @@ bool Model_AttributeSelection::update()
               }
             }
           }
-          // iterate new result faces and searching for these edges
-          std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFacesIter = aFaces.begin();
           double aBestFound = 0; // best percentage of found edges
-          for(; aFacesIter != aFaces.end(); aFacesIter++) {
+          for(int aFaceIndex = 0; aFaceIndex < aConstructionContext->facesNum(); aFaceIndex++) {
             int aFound = 0, aNotFound = 0;
-            TopExp_Explorer anEdgesExp((*aFacesIter)->impl<TopoDS_Shape>(), TopAbs_EDGE);
+            TopExp_Explorer anEdgesExp(
+              aConstructionContext->face(aFaceIndex)->impl<TopoDS_Shape>(), TopAbs_EDGE);
             for(; anEdgesExp.More(); anEdgesExp.Next()) {
               TopoDS_Edge anEdge = TopoDS::Edge(anEdgesExp.Current());
               if (!anEdge.IsNull()) {
@@ -298,7 +295,7 @@ bool Model_AttributeSelection::update()
               double aPercentage = double(aFound) / double(aFound + aNotFound);
               if (aPercentage > aBestFound) {
                 aBestFound = aPercentage;
-                aNewSelected = *aFacesIter;
+                aNewSelected = aConstructionContext->face(aFaceIndex);
               }
             }
           }
index a298dd29723c13b92e42b45c7d781673d795f09c..d6bd0cde8de26c65ad5b9724683b1612ec4e7ced 100644 (file)
@@ -7,8 +7,8 @@
 #include "ModuleBase_ResultPrs.h"
 
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultConstruction.h>
 #include <GeomAPI_PlanarEdges.h>
-#include <GeomAlgoAPI_SketchBuilder.h>
 
 #include <BRep_Builder.hxx>
 #include <AIS_Drawer.hxx>
@@ -43,11 +43,15 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   if (!aShapePtr)
     return;
   if (myIsSketchMode) {
-    std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
-      std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
     myFacesList.clear();
-    GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
-      aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
+    ResultConstructionPtr aConstruction = 
+      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
+    if (aConstruction.get()) {
+      int aFacesNum = aConstruction->facesNum();
+      for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
+        myFacesList.push_back(aConstruction->face(aFaceIndex));
+      }
+    }
   }
   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
   if (!myOriginalShape.IsNull()) {
index f4bc7f93e3e5aca6c75a8b88e3d620cbcc6ab5fd..0cb74987a0e63c5a060f709a26142415cdce9834 100644 (file)
@@ -190,7 +190,7 @@ double SketchPlugin_Arc::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& t
 }
 
 bool SketchPlugin_Arc::isFixed() {
-  return data()->selection(EXTERNAL_ID())->context().get();
+  return data()->selection(EXTERNAL_ID())->context().get() != NULL;
 }
 
 bool SketchPlugin_Arc::isFeatureValid()
index 50b387414b82402e10bec366908b2d2d856f24fa..934f40a04eb331cf8a0fb0a37ba044140e29b9c7 100644 (file)
@@ -101,7 +101,7 @@ double SketchPlugin_Circle::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>
 }
 
 bool SketchPlugin_Circle::isFixed() {
-  return data()->selection(EXTERNAL_ID())->context().get();
+  return data()->selection(EXTERNAL_ID())->context().get() != NULL;
 }
 
 void SketchPlugin_Circle::attributeChanged(const std::string& theID) {
index f0c76538a92ff0973a46813f32945c8299bf854c..ea5d0a42b1e57039053e2a7ff2c63b1d0b34d0c5 100644 (file)
@@ -101,7 +101,7 @@ double SketchPlugin_Line::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>&
 }
 
 bool SketchPlugin_Line::isFixed() {
-  return data()->selection(EXTERNAL_ID())->context().get();
+  return data()->selection(EXTERNAL_ID())->context().get() != NULL;
 }
 
 void SketchPlugin_Line::attributeChanged(const std::string& theID) {
index 798140611b2755a7b86248a055617fa84aed4e44..036fde19db093340f6a632a0b73b2f860e7e26a7 100644 (file)
@@ -73,7 +73,7 @@ double SketchPlugin_Point::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>&
 }
 
 bool SketchPlugin_Point::isFixed() {
-  return data()->selection(EXTERNAL_ID())->context().get();
+  return data()->selection(EXTERNAL_ID())->context().get() != NULL;
 }
 
 void SketchPlugin_Point::attributeChanged(const std::string& theID) {
index 365db4ca69b59d5d4aca8311afa65980b1aca50a..b57c1e3ba21e7b587c0a4fd950c6a516fa3d082b 100644 (file)
@@ -115,9 +115,6 @@ void SketchPlugin_Sketch::execute()
     aBigWire->addEdge(*aShapeIt);
   }
   aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aNorm->dir());
-
-//  GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
-//                                         aFeaturesPreview, aLoops, aWires);
   std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
   aConstr->setShape(aBigWire);
   setResult(aConstr);