]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Set flag "Auxiliary" for copied features during the Python dump (issue #1899)
authorazv <azv@opencascade.com>
Fri, 2 Dec 2016 14:11:31 +0000 (17:11 +0300)
committerazv <azv@opencascade.com>
Fri, 2 Dec 2016 14:13:25 +0000 (17:13 +0300)
src/SketchAPI/SketchAPI.i
src/SketchAPI/SketchAPI_Mirror.cpp
src/SketchAPI/SketchAPI_Mirror.h
src/SketchAPI/SketchAPI_Rotation.cpp
src/SketchAPI/SketchAPI_Rotation.h
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchAPI/SketchAPI_SketchEntity.cpp
src/SketchAPI/SketchAPI_SketchEntity.h
src/SketchAPI/SketchAPI_Translation.cpp
src/SketchAPI/SketchAPI_Translation.h

index 5244181562c374d5b90ec09cffb339718c3a123c..6bc6cf6c6b70944141455230c252e9615fededaa 100644 (file)
@@ -41,6 +41,7 @@
 
 // std::list -> []
 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
+%template(EntityList)    std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
 
 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
   std::shared_ptr<ModelAPI_Feature> * temp_feature;
index 375bb457835d1908c4a52c8b8f4475e9f0b73f61..9e6f40ed969c1db3fcaba1a6d422d1829f9f73d6 100644 (file)
@@ -39,7 +39,7 @@ SketchAPI_Mirror::~SketchAPI_Mirror()
 
 }
 
-std::list<std::shared_ptr<ModelHighAPI_Interface> > SketchAPI_Mirror::mirrored() const
+std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Mirror::mirrored() const
 {
   std::list<ObjectPtr> aList = mirroredObjects()->list();
   std::list<FeaturePtr> anIntermediate;
@@ -65,12 +65,29 @@ void SketchAPI_Mirror::dump(ModelHighAPI_Dumper& theDumper) const
 
   // Dump variables for a list of mirrored features
   theDumper << "[";
-  std::list<std::shared_ptr<ModelHighAPI_Interface> > aList = mirrored();
-  std::list<std::shared_ptr<ModelHighAPI_Interface> >::const_iterator anIt = aList.begin();
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> > aList = mirrored();
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> >::const_iterator anIt = aList.begin();
   for (; anIt != aList.end(); ++anIt) {
     if (anIt != aList.begin())
       theDumper << ", ";
     theDumper << theDumper.name((*anIt)->feature(), false);
   }
   theDumper << "] = " << theDumper.name(aBase) << ".mirrored()" << std::endl;
+
+  // Set necessary "auxiliary" flag for mirrored features
+  // (flag is set if it differs to base entity)
+  std::list<ObjectPtr> aMirList = aMirrorObjects->list();
+  std::list<ObjectPtr>::const_iterator aMIt = aMirList.begin();
+  for (anIt = aList.begin(); aMIt != aMirList.end(); ++aMIt, ++anIt) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(*aMIt);
+    if (!aFeature)
+      continue;
+    bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value();
+
+    aFeature = (*anIt)->feature();
+    bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value();
+    if (aFeatAux != aBaseAux)
+      theDumper << theDumper.name((*anIt)->feature(), false)
+                << ".setAuxiliary(" << aFeatAux << ")" <<std::endl;
+  }
 }
index 518dd8b197acd4e38b962d0d51b0593a680d726f..9beb958ffdac4a6ffc772f766e2dfd4835b00ebd 100644 (file)
@@ -10,6 +10,7 @@
 
 //--------------------------------------------------------------------------------------
 #include "SketchAPI.h"
+#include "SketchAPI_SketchEntity.h"
 
 #include <list>
 
@@ -53,7 +54,7 @@ public:
 
   /// List of mirrored objects
   SKETCHAPI_EXPORT
-  std::list<std::shared_ptr<ModelHighAPI_Interface> > mirrored() const;
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> > mirrored() const;
 
   /// Dump wrapped feature
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
index c53964912f02e75cd14f9cbc86cccfd19f89e580..2dc0e87d9ff4b34fdbff37b586d7febedfe69eb4 100644 (file)
@@ -46,7 +46,7 @@ SketchAPI_Rotation::~SketchAPI_Rotation()
 
 }
 
-std::list<std::shared_ptr<ModelHighAPI_Interface> > SketchAPI_Rotation::rotated() const
+std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Rotation::rotated() const
 {
   std::list<ObjectPtr> aList = rotatedObjects()->list();
   // remove all initial features
@@ -82,12 +82,32 @@ void SketchAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
 
   // Dump variables for a list of rotated features
   theDumper << "[";
-  std::list<std::shared_ptr<ModelHighAPI_Interface> > aList = rotated();
-  std::list<std::shared_ptr<ModelHighAPI_Interface> >::const_iterator anIt = aList.begin();
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> > aList = rotated();
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> >::const_iterator anIt = aList.begin();
   for (; anIt != aList.end(); ++anIt) {
     if (anIt != aList.begin())
       theDumper << ", ";
     theDumper << theDumper.name((*anIt)->feature(), false);
   }
   theDumper << "] = " << theDumper.name(aBase) << ".rotated()" << std::endl;
+
+  // Set necessary "auxiliary" flag for rotated features
+  // (flag is set if it differs to base entity)
+  std::list<ObjectPtr> aRotList = aRotObjects->list();
+  std::list<ObjectPtr>::const_iterator aRIt = aRotList.begin();
+  anIt = aList.begin();
+  for (; aRIt != aRotList.end(); ++aRIt) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(*aRIt);
+    if (!aFeature)
+      continue;
+    bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value();
+
+    for (int i = 1; i < aNbCopies->value(); ++i, ++anIt) {
+      aFeature = (*anIt)->feature();
+      bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value();
+      if (aFeatAux != aBaseAux)
+        theDumper << theDumper.name((*anIt)->feature(), false)
+                  << ".setAuxiliary(" << aFeatAux << ")" <<std::endl;
+    }
+  }
 }
index 13817ca369bbbaf997b14741396e2f68cc16ccb8..199b0250f626cb5d325e23202356902ad23f41c1 100644 (file)
@@ -10,6 +10,7 @@
 
 //--------------------------------------------------------------------------------------
 #include "SketchAPI.h"
+#include "SketchAPI_SketchEntity.h"
 
 #include <list>
 
@@ -64,7 +65,7 @@ public:
 
   /// List of rotated objects
   SKETCHAPI_EXPORT
-  std::list<std::shared_ptr<ModelHighAPI_Interface> > rotated() const;
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> > rotated() const;
 
   /// Dump wrapped feature
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
index cd9f9875cdee26607a648162bd47a0310f57c366..ffbf1bca9d621efda4b896acdd964e95a6e1dcc7 100644 (file)
@@ -491,9 +491,10 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngle(
       compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
   fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT,
       aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
+  // fill the value before llines to avoid calculation of angle value by the Angle feature
+  fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
-  fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
   aFeature->execute();
   return InterfacePtr(new ModelHighAPI_Interface(aFeature));
 }
index 914c8baa24f92196214a9ba41b2024b9a093137e..fddc34e65891980b57d2d8492befb20c700ebf6f 100644 (file)
@@ -73,22 +73,22 @@ bool SketchAPI_SketchEntity::isCopy() const
   return isCopy.get() && isCopy->value();
 }
 
-std::list<std::shared_ptr<ModelHighAPI_Interface> >
+std::list<std::shared_ptr<SketchAPI_SketchEntity> >
 SketchAPI_SketchEntity::wrap(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures)
 {
-  std::list<std::shared_ptr<ModelHighAPI_Interface> > aResult;
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> > aResult;
   std::list<std::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = theFeatures.begin();
   for (; anIt != theFeatures.end(); ++anIt) {
     if ((*anIt)->getKind() == SketchPlugin_Line::ID())
-      aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Line(*anIt)));
+      aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Line(*anIt)));
     else if ((*anIt)->getKind() == SketchPlugin_Arc::ID())
-      aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Arc(*anIt)));
+      aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Arc(*anIt)));
     else if ((*anIt)->getKind() == SketchPlugin_Circle::ID())
-      aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Circle(*anIt)));
+      aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Circle(*anIt)));
     else if ((*anIt)->getKind() == SketchPlugin_Point::ID())
-      aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Point(*anIt)));
+      aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Point(*anIt)));
     else if ((*anIt)->getKind() == SketchPlugin_IntersectionPoint::ID())
-      aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(
+      aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(
                                                     new SketchAPI_IntersectionPoint(*anIt)));
   }
   return aResult;
index edf8c665ef50437e59d7a916bc9c0a097167f67a..4322e7b149c3bb22b2c25649d9ae843646fe6ea8 100644 (file)
@@ -45,7 +45,7 @@ public:
 
   /// Convert list of features to list of appropriate wrappers
   SKETCHAPI_EXPORT
-  static std::list<std::shared_ptr<ModelHighAPI_Interface> >
+  static std::list<std::shared_ptr<SketchAPI_SketchEntity> >
   wrap(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures);
 
 protected:
index 2d5eaa38cfa1fe4734c50ba273180bdf388b360b..2b69f37eafd64cb9e5a63357711294527d31686c 100644 (file)
@@ -46,7 +46,7 @@ SketchAPI_Translation::~SketchAPI_Translation()
 
 }
 
-std::list<std::shared_ptr<ModelHighAPI_Interface> > SketchAPI_Translation::translated() const
+std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Translation::translated() const
 {
   std::list<ObjectPtr> aList = translatedObjects()->list();
   // remove all initial features
@@ -82,12 +82,32 @@ void SketchAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const
 
   // Dump variables for a list of translated features
   theDumper << "[";
-  std::list<std::shared_ptr<ModelHighAPI_Interface> > aList = translated();
-  std::list<std::shared_ptr<ModelHighAPI_Interface> >::const_iterator anIt = aList.begin();
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> > aList = translated();
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> >::const_iterator anIt = aList.begin();
   for (; anIt != aList.end(); ++anIt) {
     if (anIt != aList.begin())
       theDumper << ", ";
     theDumper << theDumper.name((*anIt)->feature(), false);
   }
   theDumper << "] = " << theDumper.name(aBase) << ".translated()" << std::endl;
+
+  // Set necessary "auxiliary" flag for translated features
+  // (flag is set if it differs to base entity)
+  std::list<ObjectPtr> aTransList = aTransObjects->list();
+  std::list<ObjectPtr>::const_iterator aTrIt = aTransList.begin();
+  anIt = aList.begin();
+  for (; aTrIt != aTransList.end(); ++aTrIt) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(*aTrIt);
+    if (!aFeature)
+      continue;
+    bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value();
+
+    for (int i = 1; i < aNbCopies->value(); ++i, ++anIt) {
+      aFeature = (*anIt)->feature();
+      bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value();
+      if (aFeatAux != aBaseAux)
+        theDumper << theDumper.name((*anIt)->feature(), false)
+                  << ".setAuxiliary(" << aFeatAux << ")" <<std::endl;
+    }
+  }
 }
index 6c6bbc9adb4d96a7d9d8478219459741a0a47c8e..1e21838ab45c3daad0865cab5ffbb34aef6639e9 100644 (file)
@@ -10,6 +10,7 @@
 
 //--------------------------------------------------------------------------------------
 #include "SketchAPI.h"
+#include "SketchAPI_SketchEntity.h"
 
 #include <list>
 
@@ -63,7 +64,7 @@ public:
 
   /// List of translated objects
   SKETCHAPI_EXPORT
-  std::list<std::shared_ptr<ModelHighAPI_Interface> > translated() const;
+  std::list<std::shared_ptr<SketchAPI_SketchEntity> > translated() const;
 
   /// Dump wrapped feature
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;