From 0f6e143a5f3bfa1f3dba0dfc0b5c46bc99bd2da4 Mon Sep 17 00:00:00 2001 From: spo Date: Wed, 15 Jun 2016 11:08:53 +0300 Subject: [PATCH] Add setFillet, setHorizontal, setRigid, setVertical constraints --- src/SketchAPI/SketchAPI_Sketch.cpp | 43 ++++++++++++++++++++++++++++++ src/SketchAPI/SketchAPI_Sketch.h | 21 +++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index 27ba10f63..e13b203c2 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -243,6 +243,28 @@ std::shared_ptr SketchAPI_Sketch::setDistance( return aFeature; } +std::shared_ptr SketchAPI_Sketch::setFillet( + const std::list & thePoints, + const ModelHighAPI_Double & theRadius) +{ + 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(); + return aFeature; +} + +std::shared_ptr SketchAPI_Sketch::setHorizontal( + const ModelHighAPI_RefAttr & theLine) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintHorizontal::ID()); + fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + aFeature->execute(); + return aFeature; +} + std::shared_ptr SketchAPI_Sketch::setLength( const ModelHighAPI_RefAttr & theLine, const ModelHighAPI_Double & theValue) @@ -278,4 +300,25 @@ std::shared_ptr SketchAPI_Sketch::setPerpendicular( aFeature->execute(); return aFeature; } + +std::shared_ptr SketchAPI_Sketch::setRigid( + const ModelHighAPI_RefAttr & theObject) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintRigid::ID()); + fillAttribute(theObject, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + aFeature->execute(); + return aFeature; +} + +std::shared_ptr SketchAPI_Sketch::setVertical( + const ModelHighAPI_RefAttr & theLine) +{ + std::shared_ptr aFeature = + compositeFeature()->addFeature(SketchPlugin_ConstraintVertical::ID()); + fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); + aFeature->execute(); + return aFeature; +} + //-------------------------------------------------------------------------------------- diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h index fdbaca992..53e234cf0 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -127,6 +127,17 @@ public: const ModelHighAPI_RefAttr & theLine, const ModelHighAPI_Double & theValue); + /// Set fillet + SKETCHAPI_EXPORT + std::shared_ptr setFillet( + const std::list & thePoints, + const ModelHighAPI_Double & theRadius); + + /// Set horizontal + SKETCHAPI_EXPORT + std::shared_ptr setHorizontal( + const ModelHighAPI_RefAttr & theLine); + /// Set length SKETCHAPI_EXPORT std::shared_ptr setLength( @@ -145,6 +156,16 @@ public: const ModelHighAPI_RefAttr & theLine1, const ModelHighAPI_RefAttr & theLine2); + /// Set rigid + SKETCHAPI_EXPORT + std::shared_ptr setRigid( + const ModelHighAPI_RefAttr & theObject); + + /// Set vertical + SKETCHAPI_EXPORT + std::shared_ptr setVertical( + const ModelHighAPI_RefAttr & theLine); + // TODO(spo): set* (constraints) // TODO(spo): addMirror -- 2.39.2