X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchAPI%2FSketchAPI_Translation.cpp;h=fafc9ee4f3c790169fd029884ddb192c7fe1bf1b;hb=099946a7d91982c9a2c4ca2ccdd934320f196413;hp=0ba3e3b3faf624e36229b5052967bf8492d7fa7d;hpb=d024af4f1ab972bfcddbd5766b9a9d99a72a9e38;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_Translation.cpp b/src/SketchAPI/SketchAPI_Translation.cpp index 0ba3e3b3f..fafc9ee4f 100644 --- a/src/SketchAPI/SketchAPI_Translation.cpp +++ b/src/SketchAPI/SketchAPI_Translation.cpp @@ -1,17 +1,22 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D // Name : SketchAPI_Translation.cpp -// Purpose: +// Purpose: // // History: // 16/06/16 - Sergey POKHODENKO - Creation of the file //-------------------------------------------------------------------------------------- #include "SketchAPI_Translation.h" +#include //-------------------------------------------------------------------------------------- +#include #include + +#include //-------------------------------------------------------------------------------------- SketchAPI_Translation::SketchAPI_Translation( const std::shared_ptr & theFeature) -: SketchAPI_SketchEntity(theFeature) +: ModelHighAPI_Interface(theFeature) { initialize(); } @@ -23,17 +28,16 @@ SketchAPI_Translation::SketchAPI_Translation( const ModelHighAPI_RefAttr & thePoint2, const ModelHighAPI_Integer & theNumberOfObjects, bool theFullValue) -: SketchAPI_SketchEntity(theFeature) +: ModelHighAPI_Interface(theFeature) { if (initialize()) { fillAttribute(theObjects, translationList()); fillAttribute(thePoint1, startPoint()); fillAttribute(thePoint2, endPoint()); fillAttribute(theNumberOfObjects, numberOfObjects()); - if (theFullValue) - fillAttribute("SingleValue", valueType()); + fillAttribute(theFullValue ? "FullValue" : "SingleValue", valueType()); - execute(); + execute(true); } } @@ -42,4 +46,68 @@ SketchAPI_Translation::~SketchAPI_Translation() } +std::list > SketchAPI_Translation::translated() const +{ + std::list aList = translatedObjects()->list(); + // remove all initial features + std::list anIntermediate; + std::list::const_iterator anIt = aList.begin(); + for (; anIt != aList.end(); ++anIt) { + FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); + AttributeBooleanPtr isCopy = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); + if (isCopy.get() && isCopy->value()) + anIntermediate.push_back(aFeature); + } + return SketchAPI_SketchEntity::wrap(anIntermediate); +} + //-------------------------------------------------------------------------------------- + +void SketchAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aSketchName = theDumper.parentName(aBase); + + AttributeRefListPtr aTransObjects = translationList(); + AttributeRefAttrPtr aStart = startPoint(); + AttributeRefAttrPtr aEnd = endPoint(); + AttributeIntegerPtr aNbCopies = numberOfObjects(); + bool isFullValue = valueType()->value() != "SingleValue"; + + 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 > aList = translated(); + std::list >::const_iterator anIt = aList.begin(); + for (; anIt != aList.end(); ++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 aTransList = aTransObjects->list(); + std::list::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 << ")" <