]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Adding Naming DS for Placement operation.
authorszy <szy@opencascade.com>
Wed, 3 Dec 2014 15:29:35 +0000 (18:29 +0300)
committerszy <szy@opencascade.com>
Wed, 3 Dec 2014 15:29:35 +0000 (18:29 +0300)
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.h
src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp
src/GeomAPI/GeomAPI_DataMapOfShapeShape.h
src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp
src/Model/Model_ResultBody.cpp

index af86e815255c9bb88d0788cd453e9f1bec155b94..96d52d77bb31f3676e959582f57436ddd916ce3d 100644 (file)
 #include <GeomAPI_Pln.h>
 #include <GeomAlgoAPI_Placement.h>
 
+#define _MODIFIEDF_TAG 1
+#define _MODIFIEDE_TAG 2
+#define _MODIFIEDV_TAG 3
+#define _FACE 4
 FeaturesPlugin_Placement::FeaturesPlugin_Placement()
 {
 }
@@ -53,20 +57,20 @@ void FeaturesPlugin_Placement::execute()
   aFaceRef = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(
       data()->attribute(FeaturesPlugin_Placement::ATTRACT_FACE_ID()));
 
-  std::shared_ptr<GeomAPI_Shape> anAttractiveFace = 
+  std::shared_ptr<GeomAPI_Shape> aSlaveObjectFace = 
     std::dynamic_pointer_cast<GeomAPI_Shape>(aFaceRef->value());
-  if (!anAttractiveFace)
+  if (!aSlaveObjectFace)
     return;
 
-  std::shared_ptr<GeomAPI_Shape> anAttractiveFaceContext;
+  std::shared_ptr<GeomAPI_Shape> aSlaveObject;
   aContextRes = aFaceRef->context();
   if (aContextRes) {
     if (aContextRes->groupName() == ModelAPI_ResultBody::group())
-      anAttractiveFaceContext = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContextRes)->shape();
+      aSlaveObject = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContextRes)->shape();
     else if (aContextRes->groupName() == ModelAPI_ResultConstruction::group())
-      anAttractiveFaceContext = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
+      aSlaveObject = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
   }
-  if (!anAttractiveFaceContext) {
+  if (!aSlaveObject) {
     static const std::string aContextError = "The selection context is bad";
     setError(aContextError);
     return;
@@ -74,18 +78,18 @@ void FeaturesPlugin_Placement::execute()
 
   // Verify faces planarity
   std::shared_ptr<GeomAPI_Face> aBaseFace1(new GeomAPI_Face(aBaseFace));
-  std::shared_ptr<GeomAPI_Face> anAttractFace1(new GeomAPI_Face(anAttractiveFace));
-  if (!aBaseFace1->isPlanar() || !anAttractFace1->isPlanar()) {
+  std::shared_ptr<GeomAPI_Face> aSlaveFace1(new GeomAPI_Face(aSlaveObjectFace));
+  if (!aBaseFace1->isPlanar() || !aSlaveFace1->isPlanar()) {
     static const std::string aPlanarityError = "One of selected face is not planar";
     setError(aPlanarityError);
     return;
   }
 
   std::shared_ptr<GeomAPI_Pln> aBasePlane = aBaseFace1->getPlane();
-  std::shared_ptr<GeomAPI_Pln> anAttractivePlane = anAttractFace1->getPlane();
+  std::shared_ptr<GeomAPI_Pln> aSlavePlane = aSlaveFace1->getPlane();
 
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
-  GeomAlgoAPI_Placement aFeature(anAttractiveFaceContext, anAttractivePlane, aBasePlane);
+  GeomAlgoAPI_Placement aFeature(aSlaveObject, aSlavePlane, aBasePlane);
   if(!aFeature.isDone()) {
     static const std::string aFeatureError = "Placement algorithm failed";
     setError(aFeatureError);
@@ -104,7 +108,7 @@ void FeaturesPlugin_Placement::execute()
     return;
   }  
   //LoadNamingDS
-  LoadNamingDS(aFeature, aResultBody, anAttractiveFace, anAttractiveFaceContext);
+  LoadNamingDS(aFeature, aResultBody, aSlaveObject);
 
   setResult(aResultBody);
 }
@@ -113,44 +117,15 @@ void FeaturesPlugin_Placement::execute()
 void FeaturesPlugin_Placement::LoadNamingDS(
     GeomAlgoAPI_Placement& theFeature,
     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-    std::shared_ptr<GeomAPI_Shape> theBasis,
-    std::shared_ptr<GeomAPI_Shape> theContext)
+    std::shared_ptr<GeomAPI_Shape> theSlaveObject)
 {
-  theResultBody->store(theFeature.shape());
-  /// TODO: SZY
-/*
-
   //load result
-  if(theBasis->isEqual(theContext))
-    theResultBody->store(theFeature.shape());
-  else
-    theResultBody->storeGenerated(theContext, theFeature.shape()); 
+  theResultBody->storeModified(theSlaveObject, theFeature.shape()); // the initial Slave, the resulting Slave
 
   GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
   theFeature.mapOfShapes(*aSubShapes);
 
-    //Insert lateral face : Face from Edge
-  theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape(), theBasis, EDGE,_LATERAL_TAG, *aSubShapes);
-
-  //Insert bottom face
-  std::shared_ptr<GeomAPI_Shape> aBottomFace = theFeature.firstShape();  
-  if (!aBottomFace->isNull()) {
-       if (aSubShapes->isBound(aBottomFace)) {  
-               aBottomFace = aSubShapes->find(aBottomFace);            
-    }    
-    theResultBody->generated(aBottomFace, _FIRST_TAG);
-  }
-
-
-
-  //Insert top face
-  std::shared_ptr<GeomAPI_Shape> aTopFace = theFeature.lastShape();
-  if (!aTopFace->isNull()) {
-    if (aSubShapes->isBound(aTopFace)) {        
-      aTopFace = aSubShapes->find(aTopFace);   
-    }
-    theResultBody->generated(aTopFace, _LAST_TAG);
-  }
+    // put modifed faces in DF
+  theResultBody->loadAndOrientModifiedShapes(theFeature.makeShape(), theSlaveObject, _FACE, _MODIFIEDF_TAG, *aSubShapes); 
 
-*/
 }
index a98793e02b8d97e35d6dfaafc9b80e8fd6eca41d..cc9e30f3d0d0941c3b770f34138c988f6edd7719 100644 (file)
@@ -53,8 +53,7 @@ private:
   /// Load Naming data structure of the feature to the document
   void LoadNamingDS(GeomAlgoAPI_Placement& theFeature,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBasis,
-                    std::shared_ptr<GeomAPI_Shape> theContext);
+                    std::shared_ptr<GeomAPI_Shape> theSlaveObject);
 };
 
 #endif
index c20e9fd89161620b560adca7347eb54eecfa5259..23a6c6f4d19e0e0ae823b07b84dec62891d7a6e4 100644 (file)
@@ -18,6 +18,12 @@ void GeomAPI_DataMapOfShapeShape::clear()
   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
 }
 
+/// Size 
+int GeomAPI_DataMapOfShapeShape::size()
+{
+  return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
+}
+
 /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
 bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem)
 {
index 94a35b780ea9c087acf1ac4b39a07d3da7681a84..4609bf08fad6d6eae2dfa95dce066b7c1753cc79 100644 (file)
@@ -25,6 +25,9 @@ class GEOMAPI_EXPORT GeomAPI_DataMapOfShapeShape : public GeomAPI_Interface
   /// Clear 
   void clear();
 
+  /// Size of the map
+  int GeomAPI_DataMapOfShapeShape::size();
+
   /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
   bool bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem);
 
index b21ecc64d3f86cabd7c1430b6619098b0f44897f..7fb667490ae11f4399a10e0dd3317a7cc187e78f 100644 (file)
@@ -15,8 +15,7 @@
 #include <GProp_GProps.hxx>
 #include <BRepGProp.hxx>
 #include <Precision.hxx>
-
-
+#define DEB_PLACEMENT 1
 GeomAlgoAPI_Placement::GeomAlgoAPI_Placement(
     std::shared_ptr<GeomAPI_Shape> theAttractiveFace,
     std::shared_ptr<GeomAPI_Pln> theSourcePlane,
@@ -64,6 +63,12 @@ void GeomAlgoAPI_Placement::build(
         aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
         myMap.bind(aCurrentShape, aCurrentShape);
       }
+#ifdef DEB_PLACEMENT
+         int aNum = myMap.size();
+         cout << "MAP of Oriented shapes =" << aNum <<endl;
+
+#endif
+
       myShape->setImpl(new TopoDS_Shape(aResult));
       myMkShape = new GeomAlgoAPI_MakeShape (aBuilder);
     }
index 59c65ac9e470b92a2f184ee0258e8921952c62da..13db221085e56ca75a94b9671d0b843520cbd4df 100644 (file)
@@ -92,7 +92,7 @@ void Model_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOl
     TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
     if (aShapeNew.IsNull())
       return;  // null shape inside
-    aBuilder.Generated(aShapeOld, aShapeNew);
+       aBuilder.Modify(aShapeOld, aShapeNew);
   }
 }