From: spo Date: Wed, 15 Jun 2016 14:19:06 +0000 (+0300) Subject: Add setAngle, setCollinear, setEqual, setMiddlePoint, setRadius, setTangent X-Git-Tag: V_2.4.0~91^2~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be2c027cecdfe5a648a6ca400b2c14e24a20f30d;p=modules%2Fshaper.git Add setAngle, setCollinear, setEqual, setMiddlePoint, setRadius, setTangent --- diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index cdac5d4c5..bf9fdd1c5 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -314,6 +314,21 @@ std::shared_ptr SketchAPI_Sketch::addArc(const std::string & theE } //-------------------------------------------------------------------------------------- +std::shared_ptr SketchAPI_Sketch::setAngle( + const ModelHighAPI_RefAttr & theLine1, + const ModelHighAPI_RefAttr & theLine2, + const ModelHighAPI_Double & theValue) +{ + // TODO(spo): is support of angle type necessary? + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::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 aFeature; +} + std::shared_ptr SketchAPI_Sketch::setCoincident( const ModelHighAPI_RefAttr & thePoint1, const ModelHighAPI_RefAttr & thePoint2) @@ -326,20 +341,44 @@ std::shared_ptr SketchAPI_Sketch::setCoincident( return aFeature; } +std::shared_ptr SketchAPI_Sketch::setCollinear( + const ModelHighAPI_RefAttr & theLine1, + const ModelHighAPI_RefAttr & theLine2) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintCollinear::ID()); + fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); + aFeature->execute(); + return aFeature; +} + std::shared_ptr SketchAPI_Sketch::setDistance( const ModelHighAPI_RefAttr & thePoint, - const ModelHighAPI_RefAttr & theLine, + const ModelHighAPI_RefAttr & thePointOrLine, const ModelHighAPI_Double & theValue) { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID()); fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); - fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); + fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); aFeature->execute(); return aFeature; } +std::shared_ptr SketchAPI_Sketch::setEqual( + const ModelHighAPI_RefAttr & theObject1, + const ModelHighAPI_RefAttr & theObject2) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintEqual::ID()); + fillAttribute(theObject1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + fillAttribute(theObject2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); + aFeature->execute(); + return aFeature; +} + std::shared_ptr SketchAPI_Sketch::setFillet( const std::list & thePoints, const ModelHighAPI_Double & theRadius) @@ -374,6 +413,18 @@ std::shared_ptr SketchAPI_Sketch::setLength( return aFeature; } +std::shared_ptr SketchAPI_Sketch::setMiddlePoint( + const ModelHighAPI_RefAttr & thePoint, + const ModelHighAPI_RefAttr & theLine) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintMiddle::ID()); + fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); + aFeature->execute(); + return aFeature; +} + std::shared_ptr SketchAPI_Sketch::setParallel( const ModelHighAPI_RefAttr & theLine1, const ModelHighAPI_RefAttr & theLine2) @@ -398,9 +449,22 @@ std::shared_ptr SketchAPI_Sketch::setPerpendicular( return aFeature; } +std::shared_ptr SketchAPI_Sketch::setRadius( + const ModelHighAPI_RefAttr & theCircleOrArc, + const ModelHighAPI_Double & theValue) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID()); + fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); + aFeature->execute(); + return aFeature; +} + std::shared_ptr SketchAPI_Sketch::setRigid( const ModelHighAPI_RefAttr & theObject) { + // TODO(spo): should it be renamed to Fixed? std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintRigid::ID()); fillAttribute(theObject, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); @@ -408,6 +472,18 @@ std::shared_ptr SketchAPI_Sketch::setRigid( return aFeature; } +std::shared_ptr SketchAPI_Sketch::setTangent( + const ModelHighAPI_RefAttr & theLine, + const ModelHighAPI_RefAttr & theCircle) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintTangent::ID()); + fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + fillAttribute(theCircle, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); + aFeature->execute(); + return aFeature; +} + std::shared_ptr SketchAPI_Sketch::setVertical( const ModelHighAPI_RefAttr & theLine) { diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h index 8108524ab..50d17a364 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -181,19 +181,38 @@ public: SKETCHAPI_EXPORT std::shared_ptr addArc(const std::string & theExternalName); + /// Set angle + SKETCHAPI_EXPORT + std::shared_ptr setAngle( + const ModelHighAPI_RefAttr & theLine1, + const ModelHighAPI_RefAttr & theLine2, + const ModelHighAPI_Double & theValue); + /// Set coincident SKETCHAPI_EXPORT std::shared_ptr setCoincident( const ModelHighAPI_RefAttr & thePoint1, const ModelHighAPI_RefAttr & thePoint2); + /// Set collinear + SKETCHAPI_EXPORT + std::shared_ptr setCollinear( + const ModelHighAPI_RefAttr & theLine1, + const ModelHighAPI_RefAttr & theLine2); + /// Set distance SKETCHAPI_EXPORT std::shared_ptr setDistance( const ModelHighAPI_RefAttr & thePoint, - const ModelHighAPI_RefAttr & theLine, + const ModelHighAPI_RefAttr & thePointOrLine, const ModelHighAPI_Double & theValue); + /// Set equal + SKETCHAPI_EXPORT + std::shared_ptr setEqual( + const ModelHighAPI_RefAttr & theObject1, + const ModelHighAPI_RefAttr & theObject2); + /// Set fillet SKETCHAPI_EXPORT std::shared_ptr setFillet( @@ -211,6 +230,14 @@ public: const ModelHighAPI_RefAttr & theLine, const ModelHighAPI_Double & theValue); + /// Set middle + SKETCHAPI_EXPORT + std::shared_ptr setMiddlePoint( + const ModelHighAPI_RefAttr & thePoint, + const ModelHighAPI_RefAttr & theLine); + + // TODO(spo): setMirror + /// Set parallel SKETCHAPI_EXPORT std::shared_ptr setParallel( @@ -223,19 +250,29 @@ public: const ModelHighAPI_RefAttr & theLine1, const ModelHighAPI_RefAttr & theLine2); + /// Set radius + SKETCHAPI_EXPORT + std::shared_ptr setRadius( + const ModelHighAPI_RefAttr & theCircleOrArc, + const ModelHighAPI_Double & theValue); + /// Set rigid SKETCHAPI_EXPORT std::shared_ptr setRigid( const ModelHighAPI_RefAttr & theObject); + /// Set tangent + SKETCHAPI_EXPORT + std::shared_ptr setTangent( + const ModelHighAPI_RefAttr & theLine, + const ModelHighAPI_RefAttr & theCircle); + /// Set vertical SKETCHAPI_EXPORT std::shared_ptr setVertical( const ModelHighAPI_RefAttr & theLine); - // TODO(spo): set* (constraints) - - // TODO(spo): addMirror + // TODO(spo): addRectagle, projection, Translation, Rotation /// Set constraint value SKETCHAPI_EXPORT