bool isModified = false;
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
- Handle(Prs3d_Drawer) aDrawer = anAIS->Attributes();
- if (fabs(aDrawer->DeviationCoefficient() - theDeflection) > Precision::Confusion()) {
- aDrawer->SetDeviationCoefficient(theDeflection);
- isModified = true;
+ Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+ if (!anAISShape.IsNull()) {
+ Standard_Real aCoefficient, aPreviousCoefficient;
+ anAISShape->OwnDeviationCoefficient(aCoefficient, aPreviousCoefficient);
+ if (fabs(aCoefficient-theDeflection) > Precision::Confusion()) {
+ isModified = true;
+ anAISShape->SetOwnDeviationCoefficient(theDeflection);
+ }
}
}
-
return isModified;
}
return RESULT_BODY_COLOR;
}
+ /// default deflection for a result body
+ inline static const std::string DEFAULT_DEFLECTION()
+ {
+ return "0.001";
+ }
+
/// Iternal enumeration for storage the information of connected topology flag
enum ConnectedTopologyFlag {
ConnectionNotComputed, ///< not yet computed
return RESULT_CONSTRUCTION_COLOR;
}
+ /// default deflection for a result construction
+ inline static const std::string DEFAULT_DEFLECTION()
+ {
+ return "0.0001";
+ }
+
/// Sets the result
virtual void setShape(std::shared_ptr<GeomAPI_Shape> theShape) = 0;
Set(myOriginalShape);
}
// change deviation coefficient to provide more precise circle
- ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
+ //ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
if (!aReadyToDisplay) {
}
}
-bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
+/*bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
{
if (!theGeomShape.get())
return false;
GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE);
bool anEmpty = anExp.empty();
return !anExp.more();
-}
+}*/
-void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
+/*void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
const Handle(Prs3d_Drawer)& theDrawer)
{
if (!theResult.get())
if (aUseDeviation)
theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
}
-
+*/
void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer)
{
std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
aGeomShape->setImpl(new TopoDS_Shape(theShape));
- if (setDefaultDeviationCoefficient(aGeomShape))
- theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
+
+ // 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);
+ bool isConstruction = !anExp.more();
+
+ double aDeflection;
+ if (isConstruction)
+ aDeflection = Config_PropManager::real("Visualization", "construction_deflection",
+ ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+ else
+ aDeflection = Config_PropManager::real("Visualization", "body_deflection",
+ ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+
+ theDrawer->SetDeviationCoefficient(aDeflection);
}
Quantity_Color color(const std::string& theSection,
/// It provides 1.e-4 for results of construction type
/// \param theResult a result object to define the deviation coeffient
/// \param theDrawer a drawer
-MODULEBASE_EXPORT void setDefaultDeviationCoefficient(
- const std::shared_ptr<ModelAPI_Result>& theResult,
- const Handle(Prs3d_Drawer)& theDrawer);
+//MODULEBASE_EXPORT void setDefaultDeviationCoefficient(
+// const std::shared_ptr<ModelAPI_Result>& theResult,
+// const Handle(Prs3d_Drawer)& theDrawer);
/// Sets the default coeffient into the driver calculated accordingly the shape type.
/// It provides 1.e-4 for a shape withe Edge shape type
setAuxiliaryPresentationStyle(false);
// change deviation coefficient to provide more precise circle
- ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
+ //ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
if (!myAuxiliaryCompound.IsNull()) {
return;
bool aShapeIsChanged = false;
+ double aPrevDeviation = Attributes()->DeviationCoefficient();
if (aMode == SketcherPrs_Tools::Sel_Sketch_Face ||
aMode == SketcherPrs_Tools::Sel_Sketch_Wire) {
aMode = (aMode == SketcherPrs_Tools::Sel_Sketch_Face) ? AIS_Shape::SelectionMode(TopAbs_FACE)
debugInfo(aComp, TopAbs_FACE); // 2
#endif
Set(aComp);
+ double aBodyDefDeflection = Config_PropManager::real("Visualization", "body_deflection",
+ ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+ Attributes()->SetDeviationCoefficient(aBodyDefDeflection);
aShapeIsChanged = true;
}
else
AIS_Shape::ComputeSelection(aSelection, aMode);
- if (aShapeIsChanged)
+ if (aShapeIsChanged) {
+ Attributes()->SetDeviationCoefficient(aPrevDeviation);
Set(myOriginalShape);
+ }
}
void PartSet_ResultSketchPrs::appendShapeSelection(const Handle(SelectMgr_Selection)& theSelection,
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Session.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+
+#include <GeomAPI_ShapeExplorer.h>
+
#include <Config_PropManager.h>
#include <Events_InfoMessage.h>
if (theResult.get() != NULL &&
theResult->data()->attribute(ModelAPI_Result::DEFLECTION_ID()).get() != NULL) {
AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
- if (aDoubleAttr.get() && aDoubleAttr->isInitialized())
- aDeflection = aDoubleAttr->value();
+ if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
+ double aValue = aDoubleAttr->value();
+ if (aValue > 0) /// zero value should not be used as a deflection(previous studies)
+ aDeflection = aDoubleAttr->value();
+ }
}
return aDeflection;
}
double XGUI_CustomPrs::getDefaultDeflection(const ObjectPtr& theObject)
{
- return Config_PropManager::real("Visualization", "result_deflection", "0.001");
+ double aDeflection = -1;
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ bool isConstruction = false;
+
+ std::string aResultGroup = aResult->groupName();
+ if (aResultGroup == ModelAPI_ResultConstruction::group())
+ isConstruction = true;
+ else if (aResultGroup == ModelAPI_ResultBody::group()) {
+ GeomShapePtr aGeomShape = aResult->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)
+ aDeflection = Config_PropManager::real("Visualization", "construction_deflection",
+ ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+ else
+ aDeflection = Config_PropManager::real("Visualization", "body_deflection",
+ ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+ }
+ return aDeflection;
}
XGUI_CustomPrs::XGUI_CustomPrs(XGUI_Workshop* theWorkshop)
anAIS = aPrs->getAISObject(anAIS);
if (anAIS.get()) {
// correct deviation coefficient for
- Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
+ /*Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISPrs.IsNull()) {
Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
if (!aShapePrs.IsNull()) {
TopoDS_Shape aShape = aShapePrs->Shape();
if (!aShape.IsNull())
- ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
+ //ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
}
- }
+ }*/
}
} else {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_deflection", "Result deflection",
- Config_Prop::Double, "0.001");
+ Config_PropManager::registerProp("Visualization", "body_deflection", "Body deflection coefficient",
+ Config_Prop::Double, ModelAPI_ResultBody::DEFAULT_DEFLECTION());//"0.001");
+
+ Config_PropManager::registerProp("Visualization", "construction_deflection", "Construction deflection coefficient",
+ Config_Prop::Double, ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());//"0.0001");
if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "face-selection", true))
myViewerSelMode.append(TopAbs_FACE);