#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_PointBuilder.h>
#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Face.h>
buildResult(anOrigin, aTrsf, aResultIndex);
}
else {
- GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, aPoint);
+ std::shared_ptr<GeomAlgoAPI_Symmetry> aSymmetryAlgo(
+ new GeomAlgoAPI_Symmetry(aBaseShape, aPoint));
- if (!aSymmetryAlgo.check()) {
- setError(aSymmetryAlgo.getError());
+ if (!aSymmetryAlgo->check()) {
+ setError(aSymmetryAlgo->getError());
return;
}
- aSymmetryAlgo.build();
+ aSymmetryAlgo->build();
// Checking that the algorithm worked properly.
- if(!aSymmetryAlgo.isDone()) {
+ if(!aSymmetryAlgo->isDone()) {
static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
setError(aFeatureError);
break;
}
- if(aSymmetryAlgo.shape()->isNull()) {
+ if(aSymmetryAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aSymmetryAlgo.isValid()) {
+ if(!aSymmetryAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
buildResult(anOrigin, aTrsf, aResultIndex);
}
else {
- GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, anAxis);
+ std::shared_ptr<GeomAlgoAPI_Symmetry> aSymmetryAlgo(
+ new GeomAlgoAPI_Symmetry(aBaseShape, anAxis));
- if (!aSymmetryAlgo.check()) {
- setError(aSymmetryAlgo.getError());
+ if (!aSymmetryAlgo->check()) {
+ setError(aSymmetryAlgo->getError());
return;
}
- aSymmetryAlgo.build();
+ aSymmetryAlgo->build();
// Checking that the algorithm worked properly.
- if(!aSymmetryAlgo.isDone()) {
+ if(!aSymmetryAlgo->isDone()) {
static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
setError(aFeatureError);
break;
}
- if(aSymmetryAlgo.shape()->isNull()) {
+ if(aSymmetryAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aSymmetryAlgo.isValid()) {
+ if(!aSymmetryAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
buildResult(anOrigin, aTrsf, aResultIndex);
} else {
- GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, aPlane);
+ std::shared_ptr<GeomAlgoAPI_Symmetry> aSymmetryAlgo(
+ new GeomAlgoAPI_Symmetry(aBaseShape, aPlane));
- if (!aSymmetryAlgo.check()) {
- setError(aSymmetryAlgo.getError());
+ if (!aSymmetryAlgo->check()) {
+ setError(aSymmetryAlgo->getError());
return;
}
- aSymmetryAlgo.build();
+ aSymmetryAlgo->build();
// Checking that the algorithm worked properly.
- if(!aSymmetryAlgo.isDone()) {
+ if(!aSymmetryAlgo->isDone()) {
static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
setError(aFeatureError);
break;
}
- if(aSymmetryAlgo.shape()->isNull()) {
+ if(aSymmetryAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aSymmetryAlgo.isValid()) {
+ if(!aSymmetryAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
//=================================================================================================
-void FeaturesPlugin_Symmetry::buildResult(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
- std::shared_ptr<GeomAPI_Shape> theBaseShape,
- int theResultIndex)
+void FeaturesPlugin_Symmetry::buildResult(
+ std::shared_ptr<GeomAlgoAPI_Symmetry>& theSymmetryAlgo,
+ std::shared_ptr<GeomAPI_Shape> theBaseShape, int theResultIndex)
{
+ GeomAlgoAPI_MakeShapeList anAlgoList;
+ anAlgoList.appendAlgo(theSymmetryAlgo);
// Compose source shape and the result of symmetry.
GeomShapePtr aCompound;
if (boolean(KEEP_ORIGINAL_RESULT())->value()) {
ListOfShape aShapes;
- aShapes.push_back(theBaseShape);
- aShapes.push_back(theSymmetryAlgo.shape());
+ // add a copy of a base shape otherwise selection of this base shape is bad (2592)
+ std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(theBaseShape));
+ aShapes.push_back(aCopyAlgo->shape());
+ anAlgoList.appendAlgo(aCopyAlgo);
+
+ aShapes.push_back(theSymmetryAlgo->shape());
aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
} else
- aCompound = theSymmetryAlgo.shape();
+ aCompound = theSymmetryAlgo->shape();
// Store and name the result.
ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
aResultBody->storeModified(theBaseShape, aCompound);
- loadNamingDS(theSymmetryAlgo, aResultBody, theBaseShape);
+ loadNamingDS(anAlgoList, aResultBody, theBaseShape);
setResult(aResultBody, theResultIndex);
}
}
//=================================================================================================
-void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
+void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_MakeShapeList& theAlgo,
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
std::shared_ptr<GeomAPI_Shape> theBaseShape)
{
// Name the faces
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theSymmetryAlgo.mapOfSubShapes();
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theAlgo.mapOfSubShapes();
std::string aReflectedName = "Symmetried";
- FeaturesPlugin_Tools::storeModifiedShapes(theSymmetryAlgo, theResultBody,
+ FeaturesPlugin_Tools::storeModifiedShapes(theAlgo, theResultBody,
theBaseShape, 1, 2, 3, aReflectedName,
*aSubShapes.get());
}
--- /dev/null
+## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom"), True)
+Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Symmetry_1_1_1")], model.selection("EDGE", "PartSet/OX"), True)
+model.end()
+
+# check python dump failed before the bug fix: selection in symmetry 2 changed to the whole symmetry 1 compound
+assert(model.checkPythonDump())