Improve dumping of the following entities to provide correct update of the sketch elements they produce:
* Linear Copy
* Angular Copy
* Mirror
return true;
}
+size_t ModelHighAPI_Dumper::indexOfFirstNotDumped(
+ const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList) const
+{
+ size_t anIndex = 0;
+ std::list<ObjectPtr> anObjects = theRefList->list();
+ for (std::list<ObjectPtr>::const_iterator anIt = anObjects.begin();
+ anIt != anObjects.end(); ++anIt, ++anIndex)
+ if (!isDumped(ModelAPI_Feature::feature(*anIt)))
+ break;
+ return anIndex;
+}
+
static bool isSketchSub(const FeaturePtr& theFeature)
{
static const std::string SKETCH("Sketch");
if (aFilters)
return false;
// all other features should be commented before the dump
- return true;
+ return !isDumped(theFeature);
}
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar)
bool isAdded = false;
std::list<ObjectPtr>::const_iterator anIt = aList.begin();
for (; anIt != aList.end(); ++anIt) {
+ if (!isDumped(ModelAPI_Feature::feature(*anIt)))
+ break; // stop if the object is not dumped yet (parent feature should be postponed)
+
if (isAdded)
*myDumpStorage << ", ";
else
MODELHIGHAPI_EXPORT
bool isDumped(const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList) const;
+ /// Returns the index of the first object in the list which is not dumped yet.
+ MODELHIGHAPI_EXPORT
+ size_t indexOfFirstNotDumped(const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList) const;
+
/// Export variables names to another module (calls exportVariable implemented in python)
MODELHIGHAPI_EXPORT virtual void exportVariables() const;
void fillAttribute(const std::list<std::shared_ptr<ModelAPI_Object> > & theValue,
const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute)
{
- theAttribute->clear();
- for (auto it = theValue.begin(); it != theValue.end(); ++it)
+ int aSize = theAttribute->size();
+ // keep objects at the beginning of the list if they the same
+ auto it = theValue.begin();
+ for (int anIndex = 0; it != theValue.end() && anIndex < aSize; ++it, ++anIndex)
+ if (theAttribute->object(anIndex) != *it) {
+ // remove the tail of the list
+ while (++anIndex <= aSize)
+ theAttribute->removeLast();
+ break;
+ }
+ // append the rest of elements
+ for (; it != theValue.end(); ++it)
theAttribute->append(*it);
}
{
if (initialize()) {
fillAttribute(theMirrorLine, mirrorLine());
- fillAttribute(theObjects, mirrorList());
-
- execute();
+ setMirrorList(theObjects);
}
}
SketchAPI_Mirror::~SketchAPI_Mirror()
{
+}
+void SketchAPI_Mirror::setMirrorList(const std::list<std::shared_ptr<ModelAPI_Object> >& theObjects)
+{
+ fillAttribute(theObjects, mirrorList());
+ execute();
}
std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Mirror::mirrored() const
FeaturePtr aBase = feature();
const std::string& aSketchName = theDumper.parentName(aBase);
-
AttributeRefAttrPtr aMirrorLine = mirrorLine();
AttributeRefListPtr aMirrorObjects = mirrorList();
// Check all attributes are already dumped. If not, store the constraint as postponed.
- if (!theDumper.isDumped(aMirrorLine) || !theDumper.isDumped(aMirrorObjects)) {
+ size_t aFirstNotDumped = theDumper.indexOfFirstNotDumped(aMirrorObjects);
+ if (!theDumper.isDumped(aMirrorLine) || aFirstNotDumped == 0) {
+ theDumper.postpone(aBase);
+ return;
+ }
+
+
+ // the number of dumped aMirrorObjects is not changed, no need to dump anything
+ static std::map<FeaturePtr, size_t> aNbDumpedArguments;
+ std::map<FeaturePtr, size_t>::iterator aFound = aNbDumpedArguments.find(aBase);
+ if (aFound != aNbDumpedArguments.end() && aFound->second == aFirstNotDumped) {
theDumper.postpone(aBase);
return;
}
+ else
+ aNbDumpedArguments[aBase] = aFirstNotDumped;
- theDumper << aBase << " = " << aSketchName << ".addMirror(" << aMirrorLine << ", "
- << aMirrorObjects << ")" << std::endl;
+ if (theDumper.isDumped(aBase)) {
+ // the feature is already dumped, but it was postponed, because of some arguments
+ // were not dumped yet, thus, it is necessary to update the list of rotated objects
+ theDumper << "\n### Update " << aBase->getKind() << std::endl;
+ theDumper << aBase << ".setMirrorList(" << aMirrorObjects << ")" << std::endl;
+ }
+ else {
+ // the feature is not dumped yet, make the full dump
+ theDumper << aBase << " = " << aSketchName << ".addMirror(" << aMirrorLine << ", "
+ << aMirrorObjects << ")" << std::endl;
+ }
// Dump variables for a list of mirrored features
theDumper << "[";
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) {
+ for (size_t anIndex = 0; anIndex < aFirstNotDumped; ++anIndex, ++anIt) {
if (anIt != aList.begin())
theDumper << ", ";
theDumper << (*anIt)->feature();
}
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();
+ if (theDumper.isDumped(aMirrorObjects)) {
+ aNbDumpedArguments.erase(aBase);
+ // 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;
+ 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;
+ }
+ }
+ else {
+ // If all refereced objects are not dumped yet, mark the feature as postponed.
+ theDumper.postpone(aBase);
}
}
ModelAPI_AttributeRefList, /** Mirrored objects */
)
+ /// Set list of original objects
+ SKETCHAPI_EXPORT
+ void setMirrorList(const std::list<std::shared_ptr<ModelAPI_Object> >& theObjects);
+
/// List of mirrored objects
SKETCHAPI_EXPORT
std::list<std::shared_ptr<SketchAPI_SketchEntity> > mirrored() const;
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
- fillAttribute(theObjects, rotationList());
fillAttribute(theCenter, center());
fillAttribute(theFullValue ? "FullAngle" : "SingleAngle", valueType());
fillAttribute(theAngle, angle());
fillAttribute(theReversed, reversed());
fillAttribute(theNumberOfObjects, numberOfObjects());
- execute(true);
+ setRotationList(theObjects);
}
}
}
+void SketchAPI_Rotation::setRotationList(
+ const std::list<std::shared_ptr<ModelAPI_Object> >& theObjects)
+{
+ fillAttribute(theObjects, rotationList());
+ execute(true);
+}
+
std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Rotation::rotated() const
{
std::list<ObjectPtr> aList = rotatedObjects()->list();
bool isReversed = reversed()->value();
// Check all attributes are already dumped. If not, store the constraint as postponed.
- if (!theDumper.isDumped(aCenter) || !theDumper.isDumped(aRotObjects)) {
+ size_t aFirstNotDumped = theDumper.indexOfFirstNotDumped(aRotObjects);
+ if (!theDumper.isDumped(aCenter) || aFirstNotDumped == 0) {
theDumper.postpone(aBase);
return;
}
- theDumper << aBase << " = " << aSketchName << ".addRotation("
- << aRotObjects << ", " << aCenter << ", " << anAngle << ", " << aNbCopies;
- if (isFullValue || isReversed)
- {
- theDumper << ", " << isFullValue;
- if (isReversed)
- theDumper << ", " << isReversed;
+ // the number of dumped aRotObjects is not changed, no need to dump anything
+ static std::map<FeaturePtr, size_t> aNbDumpedArguments;
+ std::map<FeaturePtr, size_t>::iterator aFound = aNbDumpedArguments.find(aBase);
+ if (aFound != aNbDumpedArguments.end() && aFound->second == aFirstNotDumped) {
+ theDumper.postpone(aBase);
+ return;
+ }
+ else
+ aNbDumpedArguments[aBase] = aFirstNotDumped;
+
+ if (theDumper.isDumped(aBase)) {
+ // the feature is already dumped, but it was postponed, because of some arguments
+ // were not dumped yet, thus, it is necessary to update the list of rotated objects
+ theDumper << "\n### Update " << aBase->getKind() << std::endl;
+ theDumper << aBase << ".setRotationList(" << aRotObjects << ")" << std::endl;
+ }
+ else {
+ // the feature is not dumped yet, make the full dump
+ theDumper << aBase << " = " << aSketchName << ".addRotation("
+ << aRotObjects << ", " << aCenter << ", " << anAngle << ", " << aNbCopies;
+ if (isFullValue || isReversed)
+ {
+ theDumper << ", " << isFullValue;
+ if (isReversed)
+ theDumper << ", " << isReversed;
+ }
+ theDumper << ")" << std::endl;
}
- theDumper << ")" << std::endl;
// Dump variables for a list of rotated features
theDumper << "[";
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 << (*anIt)->feature();
- }
+ for (size_t anIndex = 0; anIndex < aFirstNotDumped; ++anIndex)
+ for (int i = 1; i < aNbCopies->value() && anIt != aList.end(); ++i, ++anIt) {
+ if (anIt != aList.begin())
+ theDumper << ", ";
+ theDumper << (*anIt)->feature();
+ }
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;
+ if (theDumper.isDumped(aRotObjects)) {
+ aNbDumpedArguments.erase(aBase);
+ // 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;
+ }
}
}
+ else {
+ // If all refereced objects are not dumped yet, mark the feature as postponed.
+ theDumper.postpone(aBase);
+ }
}
ModelAPI_AttributeRefList, /** Rotated objects */
)
+ /// Set list of objects to be rotated
+ SKETCHAPI_EXPORT
+ void setRotationList(const std::list<std::shared_ptr<ModelAPI_Object> >& theObjects);
+
/// List of rotated objects
SKETCHAPI_EXPORT
std::list<std::shared_ptr<SketchAPI_SketchEntity> > rotated() const;
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
- fillAttribute(theObjects, translationList());
fillAttribute(thePoint1, startPoint());
fillAttribute(thePoint2, endPoint());
fillAttribute(theNumberOfObjects, numberOfObjects());
fillAttribute(theFullValue ? "FullValue" : "SingleValue", valueType());
- execute(true);
+ setTranslationList(theObjects);
}
}
SketchAPI_Translation::~SketchAPI_Translation()
{
+}
+void SketchAPI_Translation::setTranslationList(
+ const std::list<std::shared_ptr<ModelAPI_Object> >& theObjects)
+{
+ fillAttribute(theObjects, translationList());
+ execute(true);
}
std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Translation::translated() const
bool isFullValue = valueType()->value() != "SingleValue";
// Check all attributes are already dumped. If not, store the constraint as postponed.
- if (!theDumper.isDumped(aStart) || !theDumper.isDumped(aEnd) ||
- !theDumper.isDumped(aTransObjects)) {
+ size_t aFirstNotDumped = theDumper.indexOfFirstNotDumped(aTransObjects);
+ if (!theDumper.isDumped(aStart) || !theDumper.isDumped(aEnd) || aFirstNotDumped == 0) {
theDumper.postpone(aBase);
return;
}
- theDumper << aBase << " = " << aSketchName << ".addTranslation("
- << aTransObjects << ", " << aStart << ", " << aEnd << ", " << aNbCopies;
- if (isFullValue)
- theDumper << ", " << isFullValue;
- theDumper << ")" << std::endl;
+ // the number of dumped aTransObjects is not changed, no need to dump anything
+ static std::map<FeaturePtr, size_t> aNbDumpedArguments;
+ std::map<FeaturePtr, size_t>::iterator aFound = aNbDumpedArguments.find(aBase);
+ if (aFound != aNbDumpedArguments.end() && aFound->second == aFirstNotDumped) {
+ theDumper.postpone(aBase);
+ return;
+ }
+ else
+ aNbDumpedArguments[aBase] = aFirstNotDumped;
+
+ if (theDumper.isDumped(aBase)) {
+ // the feature is already dumped, but it was postponed, because of some arguments
+ // were not dumped yet, thus, it is necessary to update the list of rotated objects
+ theDumper << "\n### Update " << aBase->getKind() << std::endl;
+ theDumper << aBase << ".setTranslationList(" << aTransObjects << ")" << std::endl;
+ }
+ else {
+ // the feature is not dumped yet, make the full dump
+ theDumper << aBase << " = " << aSketchName << ".addTranslation("
+ << aTransObjects << ", " << aStart << ", " << aEnd << ", " << aNbCopies;
+ if (isFullValue)
+ theDumper << ", " << isFullValue;
+ theDumper << ")" << std::endl;
+ }
// Dump variables for a list of translated features
theDumper << "[";
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 << (*anIt)->feature();
- }
+ for (size_t anIndex = 0; anIndex < aFirstNotDumped; ++anIndex)
+ for (int i = 1; i < aNbCopies->value() && anIt != aList.end(); ++i, ++anIt) {
+ if (anIt != aList.begin())
+ theDumper << ", ";
+ theDumper << (*anIt)->feature();
+ }
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;
+ if (theDumper.isDumped(aTransObjects)) {
+ aNbDumpedArguments.erase(aBase);
+ // 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;
+ }
}
}
+ else {
+ // If all refereced objects are not dumped yet, mark the feature as postponed.
+ theDumper.postpone(aBase);
+ }
}
ModelAPI_AttributeRefList, /** Translationed objects */
)
+ /// Set list of objects to be translated
+ SKETCHAPI_EXPORT
+ void setTranslationList(const std::list<std::shared_ptr<ModelAPI_Object> >& theObjects);
+
/// List of translated objects
SKETCHAPI_EXPORT
std::list<std::shared_ptr<SketchAPI_SketchEntity> > translated() const;
Test3240.py
Test19089.py
Test19101.py
+ Test20274_1.py
+ Test20274_2.py
+ Test20274_3.py
+
TestArcBehavior.py
TestBSplineAddPole.py
TestChangeSketchPlane1.py
if (isUpdateFlushed)
Events_Loop::loop()->setFlushed(anUpdateEvent, false);
+ // Save the current feature of the document, because new features may appear while executing.
+ // In this case, they will become current. But if the number of copies is updated from outside
+ // of sketch (e.g. by parameter change), the history line should not hold in sketch.
+ keepCurrentFeature();
+
std::shared_ptr<ModelAPI_Data> aData = data();
AttributeRefListPtr aRefListOfShapes = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
}
}
+ restoreCurrentFeature();
+
// send events to update the sub-features by the solver
if (isUpdateFlushed)
Events_Loop::loop()->setFlushed(anUpdateEvent, true);
if (isUpdateFlushed)
Events_Loop::loop()->setFlushed(anUpdateEvent, false);
+ // Save the current feature of the document, because new features may appear while executing.
+ // In this case, they will become current. But if the number of copies is updated from outside
+ // of sketch (e.g. by parameter change), the history line should not hold in sketch.
+ keepCurrentFeature();
+
// 5. Gather wires and make offset for each wire
ListOfMakeShape anOffsetAlgos;
std::set<FeaturePtr> aProcessedEdgesSet;
// created features in CREATED_ID() to remove them on next execute()
addToSketch(anOffsetAlgos);
+ restoreCurrentFeature();
+
// send events to update the sub-features by the solver
if (isUpdateFlushed)
Events_Loop::loop()->setFlushed(anUpdateEvent, true);
--- /dev/null
+# Copyright (C) 2020 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
+#
+
+from GeomAlgoAPI import *
+from SketchAPI import *
+
+from salome.shaper import model
+
+import math
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(50, 0, 41.0188620508502, 41.01886205085074)
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_2 = SketchProjection_1.createdFeature()
+Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result())
+
+### Create SketchLine
+SketchLine_3 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 0, 50)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
+
+### Create SketchProjection
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_4 = SketchProjection_2.createdFeature()
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result())
+
+### Create SketchLine
+SketchLine_5 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 70.71067811865088, 70.71067811866516)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.startPoint())
+
+### Create SketchCircle
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 100)
+SketchCircle_1.setAuxiliary(True)
+Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_1.center())
+Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).endPoint(), SketchCircle_1.results()[1])
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchCircle_1.results()[1])
+Sketch_1.setMiddlePoint(SketchLine_1.startPoint(), SketchLine_2.result())
+Sketch_1.setMiddlePoint(SketchLine_3.endPoint(), SketchLine_4.result())
+Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result())
+Sketch_1.setEqual(SketchLine_1.result(), SketchLine_5.result())
+Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.result())
+
+### Create SketchMultiRotation
+SketchMultiRotation_1_objects = [SketchLine_1.result(), SketchLine_3.result(), SketchLine_5.result()]
+SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchCircle_1.center(), 360, 4, True)
+[SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12, SketchLine_13, SketchLine_14] = SketchMultiRotation_1.rotated()
+model.do()
+
+### Create Extrusion
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0, "Edges")
+model.end()
+
+### Store volumes of sub-shapes as a reference
+TOLERANCE = 1.e-7
+REFERENCE = []
+resultExtrusion_1 = Extrusion_1.result()
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ REFERENCE.append(GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()))
+
+### Add new edges to Sketch_1 then check the Extrusion and update reference data
+model.begin()
+SketchLine_6 = Sketch_1.addLine(70.71067811865088, 70.71067811866516, 77.78174593052023, 77.78174593052023)
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_6.result())
+Sketch_1.setLength(SketchLine_6.result(), 10)
+
+SketchMultiRotation_1.rotationList().append(SketchLine_6.defaultResult())
+model.end()
+
+resultExtrusion_1 = Extrusion_1.result()
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())
+ if (ind < len(REFERENCE)):
+ assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE)
+ else:
+ REFERENCE.append(area)
+
+assert(model.checkPythonDump(model.CHECK_NAMING))
+
+### Check results after dump
+resultExtrusion_1 = Extrusion_1.result()
+assert(len(REFERENCE) == resultExtrusion_1.numberOfSubs())
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())
+ assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE)
--- /dev/null
+# Copyright (C) 2020 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
+#
+
+from GeomAlgoAPI import *
+from SketchAPI import *
+
+from salome.shaper import model
+
+import math
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(50, 0, 41.0188620508502, 41.01886205085074)
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_2 = SketchProjection_1.createdFeature()
+Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result())
+
+### Create SketchLine
+SketchLine_3 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 0, 50)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
+
+### Create SketchProjection
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_4 = SketchProjection_2.createdFeature()
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result())
+
+### Create SketchLine
+SketchLine_5 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 70.71067811865088, 70.71067811866516)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.startPoint())
+
+### Create SketchCircle
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 100)
+SketchCircle_1.setAuxiliary(True)
+Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_1.center())
+Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).endPoint(), SketchCircle_1.results()[1])
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchCircle_1.results()[1])
+Sketch_1.setMiddlePoint(SketchLine_1.startPoint(), SketchLine_2.result())
+Sketch_1.setMiddlePoint(SketchLine_3.endPoint(), SketchLine_4.result())
+Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result())
+Sketch_1.setEqual(SketchLine_1.result(), SketchLine_5.result())
+Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.result())
+
+### Create SketchMultiTranslation
+SketchMultiTranslation_1_objects = [SketchLine_1.result(), SketchLine_3.result(), SketchLine_5.result()]
+SketchMultiTranslation_1 = Sketch_1.addTranslation(SketchMultiTranslation_1_objects, SketchAPI_Line(SketchLine_4).startPoint(), SketchLine_5.endPoint(), 2)
+[SketchLine_7, SketchLine_8, SketchLine_9] = SketchMultiTranslation_1.translated()
+model.do()
+
+### Create Extrusion
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0, "Edges")
+model.end()
+
+### Store volumes of sub-shapes as a reference
+TOLERANCE = 1.e-7
+REFERENCE = []
+resultExtrusion_1 = Extrusion_1.result()
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ REFERENCE.append(GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()))
+
+### Add new edges to Sketch_1 then check the Extrusion and update reference data
+model.begin()
+SketchLine_6 = Sketch_1.addLine(70.71067811865088, 70.71067811866516, 77.78174593052023, 77.78174593052023)
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_6.result())
+Sketch_1.setLength(SketchLine_6.result(), 10)
+
+SketchMultiTranslation_1.translationList().append(SketchLine_6.defaultResult())
+model.end()
+
+resultExtrusion_1 = Extrusion_1.result()
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())
+ if (ind < len(REFERENCE)):
+ assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE)
+ else:
+ REFERENCE.append(area)
+
+assert(model.checkPythonDump(model.CHECK_NAMING))
+
+### Check results after dump
+resultExtrusion_1 = Extrusion_1.result()
+assert(len(REFERENCE) == resultExtrusion_1.numberOfSubs())
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())
+ assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE)
--- /dev/null
+# Copyright (C) 2020 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
+#
+
+from GeomAlgoAPI import *
+from SketchAPI import *
+
+from salome.shaper import model
+
+import math
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(50, 0, 41.0188620508502, 41.01886205085074)
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_2 = SketchProjection_1.createdFeature()
+Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result())
+
+### Create SketchLine
+SketchLine_3 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 0, 50)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
+
+### Create SketchProjection
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_4 = SketchProjection_2.createdFeature()
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result())
+
+### Create SketchLine
+SketchLine_5 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 70.71067811865088, 70.71067811866516)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.startPoint())
+
+### Create SketchCircle
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 100)
+SketchCircle_1.setAuxiliary(True)
+Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_1.center())
+Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).endPoint(), SketchCircle_1.results()[1])
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchCircle_1.results()[1])
+Sketch_1.setMiddlePoint(SketchLine_1.startPoint(), SketchLine_2.result())
+Sketch_1.setMiddlePoint(SketchLine_3.endPoint(), SketchLine_4.result())
+Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result())
+Sketch_1.setEqual(SketchLine_1.result(), SketchLine_5.result())
+Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.result())
+
+### Create SketchConstraintMirror
+SketchConstraintMirror_1_objects = [SketchLine_1.result(), SketchLine_3.result(), SketchLine_5.result()]
+SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), SketchConstraintMirror_1_objects)
+[SketchLine_7, SketchLine_8, SketchLine_9] = SketchConstraintMirror_1.mirrored()
+model.do()
+
+### Create Extrusion
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0, "Edges")
+model.end()
+
+### Store volumes of sub-shapes as a reference
+TOLERANCE = 1.e-7
+REFERENCE = []
+resultExtrusion_1 = Extrusion_1.result()
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ REFERENCE.append(GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()))
+
+### Add new edges to Sketch_1 then check the Extrusion and update reference data
+model.begin()
+SketchLine_6 = Sketch_1.addLine(70.71067811865088, 70.71067811866516, 77.78174593052023, 77.78174593052023)
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_6.result())
+Sketch_1.setLength(SketchLine_6.result(), 10)
+
+SketchConstraintMirror_1.mirrorList().append(SketchLine_6.defaultResult())
+model.end()
+
+resultExtrusion_1 = Extrusion_1.result()
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())
+ if (ind < len(REFERENCE)):
+ assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE)
+ else:
+ REFERENCE.append(area)
+
+assert(model.checkPythonDump(model.CHECK_NAMING))
+
+### Check results after dump
+resultExtrusion_1 = Extrusion_1.result()
+assert(len(REFERENCE) == resultExtrusion_1.numberOfSubs())
+for ind in range(resultExtrusion_1.numberOfSubs()):
+ area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())
+ assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE)