X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchAPI%2FSketchAPI_Sketch.cpp;h=11c22f0ae8764b55ca27984a83c510e72e76e24d;hb=b707e7178424958f7dc1ed87a0aabd813f671d88;hp=60c8165ef0e7b6f605d903bb8055712c3cd7680a;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index 60c8165ef..11c22f0ae 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -24,12 +24,14 @@ #include #include #include +#include #include #include #include //-------------------------------------------------------------------------------------- #include #include +#include #include #include #include @@ -124,8 +126,6 @@ void SketchAPI_Sketch::setValue( const std::shared_ptr & theConstraint, const ModelHighAPI_Double & theValue) { - // TODO(spo): check somehow that the feature is a constraint or eliminate - // crash if the feature have no real attribute VALUE fillAttribute(theValue, theConstraint->feature()->real(SketchPlugin_Constraint::VALUE())); // theConstraint->execute(); @@ -156,7 +156,6 @@ std::list SketchAPI_Sketch::selectFace() const SketchPtr addSketch(const std::shared_ptr & thePart, const std::shared_ptr & thePlane) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(SketchAPI_Sketch::ID()); return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane)); } @@ -164,7 +163,6 @@ SketchPtr addSketch(const std::shared_ptr & thePart, SketchPtr addSketch(const std::shared_ptr & thePart, const ModelHighAPI_Selection & theExternal) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(SketchAPI_Sketch::ID()); return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal)); } @@ -172,7 +170,6 @@ SketchPtr addSketch(const std::shared_ptr & thePart, SketchPtr addSketch(const std::shared_ptr & thePart, const std::string & theExternalName) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(SketchAPI_Sketch::ID()); return SketchPtr( new SketchAPI_Sketch(aFeature, ModelHighAPI_Selection("FACE", theExternalName))); @@ -486,6 +483,24 @@ std::shared_ptr SketchAPI_Sketch::addSplit( return InterfacePtr(new ModelHighAPI_Interface(aFeature)); } +//-------------------------------------------------------------------------------------- +std::shared_ptr SketchAPI_Sketch::addTrim( + const ModelHighAPI_Reference& theFeature, + const std::shared_ptr& thePositionPoint) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_Trim::ID()); + fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::SELECTED_OBJECT())); + + AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::SELECTED_POINT()); + if (anAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) { + AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast(anAttribute); + fillAttribute(thePositionPoint, aPointAttr); + } + + return InterfacePtr(new ModelHighAPI_Interface(aFeature)); +} + //-------------------------------------------------------------------------------------- std::shared_ptr SketchAPI_Sketch::setAngle( const ModelHighAPI_RefAttr & theLine1, @@ -496,9 +511,10 @@ std::shared_ptr SketchAPI_Sketch::setAngle( compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID()); fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT, aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID())); + // fill the value before llines to avoid calculation of angle value by the Angle feature + fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID())); fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); - fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); aFeature->execute(); return InterfacePtr(new ModelHighAPI_Interface(aFeature)); } @@ -588,17 +604,33 @@ std::shared_ptr SketchAPI_Sketch::setEqual( } std::shared_ptr SketchAPI_Sketch::setFillet( - const std::list & thePoints, - const ModelHighAPI_Double & theRadius) + const ModelHighAPI_RefAttr & thePoint) { std::shared_ptr aFeature = - compositeFeature()->addFeature(SketchPlugin_ConstraintFillet::ID()); - fillAttribute(thePoints, aFeature->data()->refattrlist(SketchPlugin_Constraint::ENTITY_A())); - fillAttribute(theRadius, aFeature->real(SketchPlugin_Constraint::VALUE())); - aFeature->execute(); + compositeFeature()->addFeature(SketchPlugin_Fillet::ID()); + fillAttribute(thePoint, aFeature->data()->refattr(SketchPlugin_Fillet::FILLET_POINT_ID())); + apply(); // finish operation to remove Fillet feature correcly return InterfacePtr(new ModelHighAPI_Interface(aFeature)); } +std::shared_ptr SketchAPI_Sketch::setFilletWithRadius( + const ModelHighAPI_RefAttr & thePoint, + const ModelHighAPI_Double & theRadius) +{ + CompositeFeaturePtr aSketch = compositeFeature(); + int aNbSubs = aSketch->numberOfSubs(); + + // create fillet + InterfacePtr aFilletFeature = setFillet(thePoint); + + // set radius for just created arc + FeaturePtr anArc = aSketch->subFeature(aNbSubs - 1); + if (anArc->getKind() == SketchPlugin_Arc::ID()) + setRadius(ModelHighAPI_RefAttr(ObjectPtr(anArc->lastResult())), ModelHighAPI_Double(theRadius)); + + return aFilletFeature; +} + std::shared_ptr SketchAPI_Sketch::setFixed( const ModelHighAPI_RefAttr & theObject) { @@ -723,8 +755,10 @@ void SketchAPI_Sketch::dump(ModelHighAPI_Dumper& theDumper) const // Check the plane is coordinate plane std::string aPlaneName = defaultPlane(anOrigin, aNormal, aDirX); - if (anExternal->context()) { // checking for selected planes - if (!aPlaneName.empty()) { + if(anExternal->context()) { // checking for selected planes + if (!aPlaneName.empty() + && anExternal->context()->data() + && anExternal->context()->data()->name() == aPlaneName) { // dump sketch based on coordinate plane theDumper << aBase << " = model.addSketch(" << aDocName << ", model.standardPlane(\"" << aPlaneName << "\"))" << std::endl;