]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchAPI/SketchAPI_Sketch.cpp
Salome HOME
fix coding style
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.cpp
index 5f60ae2a759e204024cc38743020f35587973c09..de5799715a6ce748122dc6fca2215cee474b4be0 100644 (file)
@@ -425,6 +425,40 @@ std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
   return RectanglePtr(new SketchAPI_Rectangle(aFeature, theStartPoint, theEndPoint));
 }
 
+std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
+    double theX1, double theY1, double theX2, double theY2, bool isFirstPointCenter)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
+  return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1,
+                                              theX2, theY2, isFirstPointCenter));
+}
+std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
+    const std::shared_ptr<GeomAPI_Pnt2d> & theFirstPoint,
+    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint,  bool isFirstPointCenter)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
+  return RectanglePtr(new SketchAPI_Rectangle(aFeature, theFirstPoint, theEndPoint,
+                                              isFirstPointCenter));
+}
+
+std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangleCentered(
+    double theX1, double theY1, double theX2, double theY2)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
+  return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, theX2, theY2, true));
+}
+std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangleCentered(
+    const std::shared_ptr<GeomAPI_Pnt2d> & theFirstPoint,
+    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
+  return RectanglePtr(new SketchAPI_Rectangle(aFeature, theFirstPoint, theEndPoint, true));
+}
+
 //--------------------------------------------------------------------------------------
 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theCenterX,
                                                               double theCenterY,
@@ -1588,6 +1622,34 @@ void SketchAPI_Sketch::dump(ModelHighAPI_Dumper& theDumper) const
     std::list<std::list<ResultPtr> > aFaces;
     edgesOfSketchFaces(aCompFeat, aFaces);
 
+    /// remove faces that must not be dumped
+    std::vector< std::list<std::list<ResultPtr>>::iterator> aFacesToRemove;
+    for(auto itFaces = aFaces.begin(); itFaces != aFaces.end(); ++itFaces)
+    {
+      auto & facesGroup = *itFaces;
+      std::vector<std::list<ResultPtr>::iterator> subFacestoRemove;
+      for(auto itGroup = facesGroup.begin(); itGroup != facesGroup.end(); ++itGroup)
+      {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(*itGroup);
+        if(theDumper.isDumped(aFeature)){
+          subFacestoRemove.push_back(itGroup);
+        }
+      }
+      for(auto itGroup :subFacestoRemove){
+        facesGroup.erase(itGroup);
+      }
+
+      if(!facesGroup.size()){
+        aFacesToRemove.push_back(itFaces);
+      }
+    }
+    for(auto itFaces :aFacesToRemove){
+      aFaces.erase(itFaces);
+    }
+
+    if(!aFaces.size())
+      return;
+
     const std::string& aSketchName = theDumper.name(aBase);
     std::string aMethodName(".changeFacesOrder");
     std::string aSpaceShift(aSketchName.size() + aMethodName.size(), ' ');