//--------------------------------------------------------------------------------------
#include "ModelHighAPI_Dumper.h"
+#include <Config_PropManager.h>
+
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Dir.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <GeomDataAPI_Dir.h>
#include <GeomDataAPI_Point.h>
#include <ModelAPI_Entity.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Result.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultPart.h>
#include <PartSetPlugin_Part.h>
<< ", " << aColor->value(2) << ")" << std::endl;
}
}
+ // set result deflection
+ if (!isDefaultDeflection(*aResIt)) {
+ AttributeDoublePtr aDeflectionAttr = (*aResIt)->data()->real(ModelAPI_Result::DEFLECTION_ID());
+ if(aDeflectionAttr && aDeflectionAttr->isInitialized()) {
+ *this << *aResIt;
+ myDumpBuffer << ".setDeflection(" << aDeflectionAttr->value() << ")" << std::endl;
+ }
+ }
}
myEntitiesStack.pop();
return aDefault == aColorInfo.str();
}
+bool ModelHighAPI_Dumper::isDefaultDeflection(const ResultPtr& theResult) const
+{
+ AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
+ if(!aDeflectionAttr && !aDeflectionAttr->isInitialized()) {
+ return true;
+ }
+
+ double aCurrent = aDeflectionAttr->value();
+ double aDefault = -1;
+
+ bool isConstruction = false;
+ std::string aResultGroup = theResult->groupName();
+ if (aResultGroup == ModelAPI_ResultConstruction::group())
+ isConstruction = true;
+ else if (aResultGroup == ModelAPI_ResultBody::group()) {
+ GeomShapePtr aGeomShape = theResult->shape();
+ if (aGeomShape.get()) {
+ // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+ // correction of deviation for them should not influence to the application performance
+ GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
+ isConstruction = !anExp.more();
+ }
+ }
+ if (isConstruction)
+ aDefault = Config_PropManager::real("Visualization", "construction_deflection",
+ ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+ else
+ aDefault = Config_PropManager::real("Visualization", "body_deflection",
+ ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+
+
+ return abs(aCurrent - aDefault) < 1.e-12;
+}
+
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar)
{
myDumpBuffer << theChar;
const std::list<ResultPtr>& aResults = theEntity->results();
std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
for (; aResIt != aResults.end(); ++aResIt)
- if (!myNames[*aResIt].myIsDefault || !isDefaultColor(*aResIt))
+ if (!myNames[*aResIt].myIsDefault || !isDefaultColor(*aResIt) || !isDefaultDeflection(*aResIt))
aResultsWithNameOrColor.push_back(*aResIt);
// store just dumped entity to stack
myEntitiesStack.push(LastDumpedEntity(theEntity, isUserDefinedName, aResultsWithNameOrColor));
//--------------------------------------------------------------------------------------
#include "ModelHighAPI_Selection.h"
+#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
aColor->setValue(1, theGreen);
aColor->setValue(2, theBlue);
}
+
+void ModelHighAPI_Selection::setDeflection(double theValue)
+{
+ if (myVariantType != VT_ResultSubShapePair)
+ return;
+
+ AttributeDoublePtr aDeflectionAttr = myResultSubShapePair.first->data()->real(ModelAPI_Result::DEFLECTION_ID());
+
+ aDeflectionAttr->setValue(theValue);
+}
--- /dev/null
+import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(-325.90051457976, -18.010291595197, 258.003584159371)
+model.do()
+Sketch_1.result()[0].setDeflection(5e-006)
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0)
+Extrusion_1.result()[0].setDeflection(0.5)
+model.end()
+
+assert(model.checkPythonDump())