Salome HOME
Merge remote-tracking branch 'origin/master'
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 26 May 2014 07:53:35 +0000 (11:53 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 26 May 2014 07:53:35 +0000 (11:53 +0400)
20 files changed:
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Arc.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Arc.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Circle.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Circle.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDiameter.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintDiameter.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintDistance.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintParallel.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/SketchSolver/SketchSolver_ConstraintManager.h

index 60fb882c0c186e5f45047274c60be0088e2799d4..a1ee7a3620d1000b3af52e54e21091f7644d9585 100644 (file)
@@ -7,8 +7,14 @@ SET(PROJECT_HEADERS
     SketchPlugin_Sketch.h
     SketchPlugin_Line.h
     SketchPlugin_Point.h
+    SketchPlugin_Circle.h
+    SketchPlugin_Arc.h
     SketchPlugin_Constraint.h
     SketchPlugin_ConstraintCoincidence.h
+    SketchPlugin_ConstraintDistance.h
+    SketchPlugin_ConstraintDiameter.h
+    SketchPlugin_ConstraintParallel.h
+    SketchPlugin_ConstraintPerpendicular.h
 )
 
 SET(PROJECT_SOURCES
@@ -17,7 +23,13 @@ SET(PROJECT_SOURCES
     SketchPlugin_Sketch.cpp
     SketchPlugin_Line.cpp
     SketchPlugin_Point.cpp
+    SketchPlugin_Circle.cpp
+    SketchPlugin_Arc.cpp
     SketchPlugin_ConstraintCoincidence.cpp
+    SketchPlugin_ConstraintDistance.cpp
+    SketchPlugin_ConstraintDiameter.cpp
+    SketchPlugin_ConstraintParallel.cpp
+    SketchPlugin_ConstraintPerpendicular.cpp
 )
 
 SET(PROJECT_LIBRARIES
diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp
new file mode 100644 (file)
index 0000000..ed5275b
--- /dev/null
@@ -0,0 +1,30 @@
+// File:        SketchPlugin_Arc.cpp
+// Created:     26 Apr 2014
+// Author:      Artem ZHIDKOV
+
+#include "SketchPlugin_Arc.h"
+#include "SketchPlugin_Sketch.h"
+#include <ModelAPI_Data.h>
+#include <GeomDataAPI_Point2D.h>
+
+SketchPlugin_Arc::SketchPlugin_Arc()
+  : SketchPlugin_Feature()
+{
+}
+
+void SketchPlugin_Arc::initAttributes()
+{
+  data()->addAttribute(ARC_ATTR_CENTER, GeomDataAPI_Point2D::type());
+  data()->addAttribute(ARC_ATTR_START,  GeomDataAPI_Point2D::type());
+  data()->addAttribute(ARC_ATTR_END,    GeomDataAPI_Point2D::type());
+}
+
+void SketchPlugin_Arc::execute() 
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
+{
+  /// \todo Implement preview for arc of circle
+  return getPreview();
+}
diff --git a/src/SketchPlugin/SketchPlugin_Arc.h b/src/SketchPlugin/SketchPlugin_Arc.h
new file mode 100644 (file)
index 0000000..f22e92b
--- /dev/null
@@ -0,0 +1,51 @@
+// File:        SketchPlugin_Arc.h
+// Created:     26 May 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef SketchPlugin_Arc_HeaderFile
+#define SketchPlugin_Arc_HeaderFile
+
+#include "SketchPlugin.h"
+#include <SketchPlugin_Feature.h>
+
+/// Central 2D point of the circle which contains the arc
+const std::string ARC_ATTR_CENTER("ArcCenter");
+/// Start 2D point of the arc
+const std::string ARC_ATTR_START("ArcStartPoint");
+/// End 2D point of the arc
+const std::string ARC_ATTR_END("ArcEndPoint");
+
+/**\class SketchPlugin_Arc
+ * \ingroup DataModel
+ * \brief Feature for creation of the new arc of circle in PartSet.
+ */
+class SketchPlugin_Arc: public SketchPlugin_Feature
+{
+public:
+  /// Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
+  {static std::string MY_KIND = "SketchArc"; return MY_KIND;}
+
+  /// Returns to which group in the document must be added feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// Creates a new part document if needed
+  SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// Adds sub-feature of the higher level feature (sub-element of the sketch)
+  /// \param theFeature sub-feature
+  SKETCHPLUGIN_EXPORT virtual const void addSub(
+    const boost::shared_ptr<ModelAPI_Feature>& theFeature) {};
+
+  /// Use plugin manager for features creation
+  SketchPlugin_Arc();
+};
+
+#endif
diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp
new file mode 100644 (file)
index 0000000..a083b18
--- /dev/null
@@ -0,0 +1,30 @@
+// File:        SketchPlugin_Circle.cpp
+// Created:     26 May 2014
+// Author:      Artem ZHIDKOV
+
+#include "SketchPlugin_Circle.h"
+#include "SketchPlugin_Sketch.h"
+#include <ModelAPI_Data.h>
+#include <GeomDataAPI_Point2D.h>
+#include <ModelAPI_AttributeDouble.h>
+
+SketchPlugin_Circle::SketchPlugin_Circle()
+  : SketchPlugin_Feature()
+{
+}
+
+void SketchPlugin_Circle::initAttributes()
+{
+  data()->addAttribute(CIRCLE_ATTR_CENTER, GeomDataAPI_Point2D::type());
+  data()->addAttribute(CIRCLE_ATTR_RADIUS, ModelAPI_AttributeDouble::type());
+}
+
+void SketchPlugin_Circle::execute()
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
+{
+  /// \todo Implement preview for the circle
+  return getPreview();
+}
diff --git a/src/SketchPlugin/SketchPlugin_Circle.h b/src/SketchPlugin/SketchPlugin_Circle.h
new file mode 100644 (file)
index 0000000..18fa1e7
--- /dev/null
@@ -0,0 +1,49 @@
+// File:        SketchPlugin_Circle.h
+// Created:     26 May 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef SketchPlugin_Circle_HeaderFile
+#define SketchPlugin_Circle_HeaderFile
+
+#include "SketchPlugin.h"
+#include <SketchPlugin_Feature.h>
+
+/// 2D point - center of the circle
+const std::string CIRCLE_ATTR_CENTER("CircleCenter");
+/// Radius of the circle
+const std::string CIRCLE_ATTR_RADIUS("CircleRadius");
+
+/**\class SketchPlugin_Circle
+ * \ingroup DataModel
+ * \brief Feature for creation of the new circle in PartSet.
+ */
+class SketchPlugin_Circle: public SketchPlugin_Feature
+{
+public:
+  /// Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "SketchCircle"; return MY_KIND;}
+
+  /// Returns to which group in the document must be added feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// Creates a new part document if needed
+  SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// Adds sub-feature of the higher level feature (sub-element of the sketch)
+  /// \param theFeature sub-feature
+  SKETCHPLUGIN_EXPORT virtual const void addSub(
+    const boost::shared_ptr<ModelAPI_Feature>& theFeature) {};
+
+  /// Use plugin manager for features creation
+  SketchPlugin_Circle();
+};
+
+#endif
index 57e95f5ba0260ea0e4b68fb0ec9368552f40a4dc..1c5f2adf37c7f437c787c343f7826df9b416adbd 100644 (file)
@@ -14,7 +14,8 @@
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines equivalence of two points
  *
- *  These constraint has two attributes: CONSTRAINT_ATTR_POINT_A and CONSTRAINT_ATTR_POINT_B
+ *  These constraint has two attributes:
+ *  CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
  */
 class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint
 {
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDiameter.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDiameter.cpp
new file mode 100644 (file)
index 0000000..179cce9
--- /dev/null
@@ -0,0 +1,30 @@
+// File:    SketchPlugin_ConstraintDiameter.cpp
+// Created: 26 May 2014
+// Author:  Artem ZHIDKOV
+
+#include "SketchPlugin_ConstraintDiameter.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Data.h>
+#include <SketchPlugin_Point.h>
+
+SketchPlugin_ConstraintDiameter::SketchPlugin_ConstraintDiameter()
+{
+}
+
+void SketchPlugin_ConstraintDiameter::initAttributes()
+{
+  data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
+}
+
+void SketchPlugin_ConstraintDiameter::execute()
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintDiameter::preview()
+{
+  /// \todo Preview for diameter constraint
+  return getPreview();
+}
+
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDiameter.h b/src/SketchPlugin/SketchPlugin_ConstraintDiameter.h
new file mode 100644 (file)
index 0000000..1ac7a32
--- /dev/null
@@ -0,0 +1,43 @@
+// File:    SketchPlugin_ConstraintDiameter.h
+// Created: 26 May 2014
+// Author:  Artem ZHIDKOV
+
+#ifndef SketchPlugin_ConstraintDiameter_HeaderFile
+#define SketchPlugin_ConstraintDiameter_HeaderFile
+
+#include "SketchPlugin.h"
+#include "SketchPlugin_Constraint.h"
+
+
+/** \class SketchPlugin_ConstraintDiameter
+ *  \ingroup DataModel
+ *  \brief Feature for creation of a new constraint which defines a diameter of a circle
+ *
+ *  These constraint has two attributes:
+ *  CONSTRAINT_ATTR_VALUE (diameter), CONSTRAINT_ATTR_ENTITY_A (a circle)
+ */
+class SketchPlugin_ConstraintDiameter: public SketchPlugin_Constraint
+{
+public:
+  /// \brief Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "SketchConstraintDiameter"; return MY_KIND;}
+
+  /// \brief Returns to which group in the document must be added feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// \brief Creates a new part document if needed
+  SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// \brief Request for initialization of data model of the feature: adding all attributes
+  SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+  /// \brief Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// \brief Use plugin manager for features creation
+  SketchPlugin_ConstraintDiameter();
+};
+
+#endif
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
new file mode 100644 (file)
index 0000000..57f7b62
--- /dev/null
@@ -0,0 +1,31 @@
+// File:    SketchPlugin_ConstraintDistance.cpp
+// Created: 23 May 2014
+// Author:  Artem ZHIDKOV
+
+#include "SketchPlugin_ConstraintDistance.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Data.h>
+#include <SketchPlugin_Point.h>
+
+SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
+{
+}
+
+void SketchPlugin_ConstraintDistance::initAttributes()
+{
+  data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
+}
+
+void SketchPlugin_ConstraintDistance::execute()
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintDistance::preview()
+{
+  /// \todo Preview for distance constraint
+  return getPreview();
+}
+
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h
new file mode 100644 (file)
index 0000000..4295e8c
--- /dev/null
@@ -0,0 +1,45 @@
+// File:    SketchPlugin_ConstraintDistance.h
+// Created: 23 May 2014
+// Author:  Artem ZHIDKOV
+
+#ifndef SketchPlugin_ConstraintDistance_HeaderFile
+#define SketchPlugin_ConstraintDistance_HeaderFile
+
+#include "SketchPlugin.h"
+#include "SketchPlugin_Constraint.h"
+#include <list>
+
+
+/** \class SketchPlugin_ConstraintDistance
+ *  \ingroup DataModel
+ *  \brief Feature for creation of a new constraint which defines a distance
+ *         between a point and another feature (point, line, plane or face)
+ *
+ *  These constraint has three attributes:
+ *  CONSTRAINT_ATTR_VALUE, CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ */
+class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
+{
+public:
+  /// \brief Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "SketchConstraintDistance"; return MY_KIND;}
+
+  /// \brief Returns to which group in the document must be added feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// \brief Creates a new part document if needed
+  SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// \brief Request for initialization of data model of the feature: adding all attributes
+  SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+  /// \brief Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// \brief Use plugin manager for features creation
+  SketchPlugin_ConstraintDistance();
+};
+
+#endif
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
new file mode 100644 (file)
index 0000000..91e6c4c
--- /dev/null
@@ -0,0 +1,30 @@
+// File:    SketchPlugin_ConstraintParallel.cpp
+// Created: 26 May 2014
+// Author:  Artem ZHIDKOV
+
+#include "SketchPlugin_ConstraintParallel.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Data.h>
+#include <SketchPlugin_Point.h>
+
+SketchPlugin_ConstraintParallel::SketchPlugin_ConstraintParallel()
+{
+}
+
+void SketchPlugin_ConstraintParallel::initAttributes()
+{
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
+}
+
+void SketchPlugin_ConstraintParallel::execute()
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintParallel::preview()
+{
+  /// \todo Preview for parallel constraint
+  return getPreview();
+}
+
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h
new file mode 100644 (file)
index 0000000..dfc894d
--- /dev/null
@@ -0,0 +1,43 @@
+// File:    SketchPlugin_ConstraintParallel.h
+// Created: 26 May 2014
+// Author:  Artem ZHIDKOV
+
+#ifndef SketchPlugin_ConstraintParallel_HeaderFile
+#define SketchPlugin_ConstraintParallel_HeaderFile
+
+#include "SketchPlugin.h"
+#include "SketchPlugin_Constraint.h"
+
+
+/** \class SketchPlugin_ConstraintParallel
+ *  \ingroup DataModel
+ *  \brief Feature for creation of a new constraint parallelism of two lines
+ *
+ *  These constraint has two attributes:
+ *  CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ */
+class SketchPlugin_ConstraintParallel: public SketchPlugin_Constraint
+{
+public:
+  /// \brief Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "SketchConstraintParallel"; return MY_KIND;}
+
+  /// \brief Returns to which group in the document must be added feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// \brief Creates a new part document if needed
+  SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// \brief Request for initialization of data model of the feature: adding all attributes
+  SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+  /// \brief Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// \brief Use plugin manager for features creation
+  SketchPlugin_ConstraintParallel();
+};
+
+#endif
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
new file mode 100644 (file)
index 0000000..85c543f
--- /dev/null
@@ -0,0 +1,30 @@
+// File:    SketchPlugin_ConstraintPerpendicular.cpp
+// Created: 26 May 2014
+// Author:  Artem ZHIDKOV
+
+#include "SketchPlugin_ConstraintPerpendicular.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Data.h>
+#include <SketchPlugin_Point.h>
+
+SketchPlugin_ConstraintPerpendicular::SketchPlugin_ConstraintPerpendicular()
+{
+}
+
+void SketchPlugin_ConstraintPerpendicular::initAttributes()
+{
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
+}
+
+void SketchPlugin_ConstraintPerpendicular::execute()
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintPerpendicular::preview()
+{
+  /// \todo Preview for perpendicular constraint
+  return getPreview();
+}
+
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
new file mode 100644 (file)
index 0000000..6c5074a
--- /dev/null
@@ -0,0 +1,43 @@
+// File:    SketchPlugin_ConstraintPerpendicular.h
+// Created: 26 May 2014
+// Author:  Artem ZHIDKOV
+
+#ifndef SketchPlugin_ConstraintPerpendicular_HeaderFile
+#define SketchPlugin_ConstraintPerpendicular_HeaderFile
+
+#include "SketchPlugin.h"
+#include "SketchPlugin_Constraint.h"
+
+
+/** \class SketchPlugin_ConstraintPerpendicular
+ *  \ingroup DataModel
+ *  \brief Feature for creation of a new constraint for perpendicularity of two lines
+ *
+ *  These constraint has two attributes:
+ *  CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ */
+class SketchPlugin_ConstraintPerpendicular: public SketchPlugin_Constraint
+{
+public:
+  /// \brief Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "SketchConstraintPerpendicular"; return MY_KIND;}
+
+  /// \brief Returns to which group in the document must be added feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// \brief Creates a new part document if needed
+  SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// \brief Request for initialization of data model of the feature: adding all attributes
+  SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+  /// \brief Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// \brief Use plugin manager for features creation
+  SketchPlugin_ConstraintPerpendicular();
+};
+
+#endif
index 7877a719153b9917a7098c0227823cd4a82f4460..62dc6cfa971182255e968814247646764a89cb74 100644 (file)
@@ -22,18 +22,18 @@ class SketchPlugin_Line: public SketchPlugin_Feature
 {
 public:
   /// Returns the kind of a feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
 SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = "SketchLine"; return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
   {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
 
   /// Creates a new part document if needed
- SKETCHPLUGIN_EXPORT virtual void execute();
 SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes
- SKETCHPLUGIN_EXPORT virtual void initAttributes();
 SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
index f4ecc49368546c16a3a7fc9a941cf7f11c650e8d..b18bffb08646be9264dbec3f9f26fe01bd22664f 100644 (file)
@@ -20,18 +20,18 @@ class SketchPlugin_Point: public SketchPlugin_Feature
 {
 public:
   /// Returns the kind of a feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
 SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = "SketchPoint"; return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
   {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
 
   /// Creates a new part document if needed
- SKETCHPLUGIN_EXPORT virtual void execute();
 SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes
- SKETCHPLUGIN_EXPORT virtual void initAttributes();
 SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
index 9f82b85ab8a9f310ee8b2cfc012d3971ca4f7ebc..7c0894995afb358733a1aaf8b90be271f04b398c 100644 (file)
@@ -29,18 +29,18 @@ class SketchPlugin_Sketch: public SketchPlugin_Feature
 {
 public:
   /// Returns the kind of a feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
 SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
   {static std::string MY_KIND = "Sketch"; return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
   {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
 
   /// Creates a new part document if needed
- SKETCHPLUGIN_EXPORT virtual void execute();
 SKETCHPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes
- SKETCHPLUGIN_EXPORT virtual void initAttributes();
 SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
index 706d85f3b1ae8258e016209da1e57b83403f6f9e..ca3ced4778a3cff67d1d3ab51b8ce15a5004f59f 100644 (file)
         <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
         <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
       </feature>
+      <feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon="" internal="1">
+        <point_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>
+      </feature>
+      <feature id="SketchArc" title="Arc" tooltip="Create a new arc of a circle" icon="" internal="1">
+        <point_selector id="ArcCenter" title="Center" tooltip="Center of the arc"/>
+        <point_selector id="ArcStartPoint" title="Start point" tooltip="Start point of the arc"/>
+        <point_selector id="ArcEndPoint" title="End point" tooltip="End point of the arc"/>
+      </feature>
       <feature id="SketchConstraintCoincidence" title="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
+      <feature id="SketchConstraintDistance" title="Distance between objects" tooltip="Create constraint for the distance from a point to an object" internal="1"/>
+      <feature id="SketchConstraintDiameter" title="Diameter of a circle" tooltip="Create constraint for the given diameter of a circle" internal="1"/>
+      <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines" internal="1"/>
+      <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines" internal="1"/>
     </group>
   </workbench>
 </plugin>
index d7023712fe57b03353572680b416529fd3670fff..7edc1da33916837a0db8b89b4b5f1d4b01bcf661 100644 (file)
@@ -22,8 +22,6 @@
 #include <math.h>
 #include <assert.h>
 
-#include <set>
-
 /// Tolerance for value of parameters
 const double tolerance = 1.e-10;
 
@@ -176,7 +174,7 @@ bool SketchSolver_ConstraintManager::changeConstraint(
               boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
 {
   // Search the groups which this constraint touchs
-  std::vector<Slvs_hGroup> aGroups;
+  std::set<Slvs_hGroup> aGroups;
   findGroups(theConstraint, aGroups);
 
   // Process the groups list
@@ -203,7 +201,39 @@ bool SketchSolver_ConstraintManager::changeConstraint(
   }
   else if (aGroups.size() > 1)
   { // Several groups applicable for this constraint => need to merge them
-    /// \todo Implement merging of groups
+    std::set<Slvs_hGroup>::const_iterator aGroupsIter = aGroups.begin();
+
+    // Search first group
+    std::vector<SketchSolver_ConstraintGroup*>::iterator aFirstGroupIter;
+    for (aFirstGroupIter = myGroups.begin(); aFirstGroupIter != myGroups.end(); aFirstGroupIter++)
+      if ((*aFirstGroupIter)->getId() == *aGroupsIter)
+        break;
+    if (aFirstGroupIter == myGroups.end())
+      return false;
+
+    // Append other groups to the first one
+    std::vector<SketchSolver_ConstraintGroup*>::iterator anOtherGroupIter = aFirstGroupIter + 1;
+    for (aGroupsIter++; aGroupsIter != aGroups.end(); aGroupsIter++)
+    {
+      for ( ; anOtherGroupIter != myGroups.end(); anOtherGroupIter++)
+        if ((*anOtherGroupIter)->getId() == *aGroupsIter)
+          break;
+      if (anOtherGroupIter == myGroups.end())
+      { // Group disappears
+        anOtherGroupIter = aFirstGroupIter + 1;
+        continue;
+      }
+
+      (*aFirstGroupIter)->mergeGroups(**anOtherGroupIter);
+      int aShiftFirst = aFirstGroupIter - myGroups.begin();
+      int aShiftOther = anOtherGroupIter - myGroups.begin();
+      delete *anOtherGroupIter;
+      myGroups.erase(anOtherGroupIter);
+      aFirstGroupIter  = myGroups.begin() + aShiftFirst;
+      anOtherGroupIter = myGroups.begin() + aShiftOther;
+    }
+
+    return (*aFirstGroupIter)->changeConstraint(theConstraint);
   }
 
   // Something goes wrong
@@ -243,14 +273,14 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin
 
 void SketchSolver_ConstraintManager::findGroups(
               boost::shared_ptr<SketchPlugin_Constraint> theConstraint,
-              std::vector<Slvs_hGroup>&                  theGroupIDs) const
+              std::set<Slvs_hGroup>&                     theGroupIDs) const
 {
   boost::shared_ptr<SketchPlugin_Feature> aWP = findWorkplaneForConstraint(theConstraint);
 
   std::vector<SketchSolver_ConstraintGroup*>::const_iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
     if (aWP == (*aGroupIter)->getWorkplane() && (*aGroupIter)->isInteract(theConstraint))
-      theGroupIDs.push_back((*aGroupIter)->getId());
+      theGroupIDs.insert((*aGroupIter)->getId());
 }
 
 boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWorkplaneForConstraint(
@@ -671,6 +701,88 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::resolveConstr
   myNeedToSolve = false;
 }
 
+void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::mergeGroups(
+                const SketchSolver_ConstraintGroup& theGroup)
+{
+  // NOTE: The possibility, that some elements are placed into both groups, is around 0, 
+  // so the objects should be copied with changing the indexes
+
+  // Maps between old and new indexes of SolveSpace elements:
+  std::map<Slvs_hParam, Slvs_hParam>           aParamMap;
+  std::map<Slvs_hEntity, Slvs_hEntity>         anEntityMap;
+  std::map<Slvs_hConstraint, Slvs_hConstraint> aConstrMap;
+
+  // Go through copying constraints
+  std::vector<Slvs_Constraint>::const_iterator aConstrIter = theGroup.myConstraints.begin();
+  for ( ; aConstrIter != theGroup.myConstraints.end(); aConstrIter++)
+  {
+    Slvs_Constraint aConstraintCopy = *aConstrIter;
+    // Go through constraint entities
+    Slvs_hEntity* anEntities[CONSTRAINT_ATTR_SIZE] = {
+      &(aConstraintCopy.ptA), &(aConstraintCopy.ptB), 
+      &(aConstraintCopy.entityA), &(aConstraintCopy.entityB)
+    };
+    for (int indEnt = 0; indEnt < CONSTRAINT_ATTR_SIZE; indEnt++)
+    {
+      if (*(anEntities[indEnt]) == 0)
+        continue;
+      if (anEntityMap.find(*(anEntities[indEnt])) != anEntityMap.end())
+      { // entity is already copied
+        *(anEntities[indEnt]) = anEntityMap[*(anEntities[indEnt])];
+        continue;
+      }
+
+      // Copy entity
+      Slvs_Entity anEntityCopy = theGroup.myEntities[Search(*(anEntities[indEnt]), theGroup.myEntities)];
+      // Go through entity parameters
+      const int aNbEntParams = 4; // maximal number of entity parameters
+      for (int indPrm = 0; indPrm < aNbEntParams; indPrm++)
+      {
+        if (anEntityCopy.param[indPrm] == 0)
+          continue;
+        if (aParamMap.find(anEntityCopy.param[indPrm]) != aParamMap.end())
+        {
+          anEntityCopy.param[indPrm] = aParamMap[anEntityCopy.param[indPrm]];
+          continue;
+        }
+
+        Slvs_Param aParamCopy = theGroup.myParams[Search(anEntityCopy.param[indPrm], theGroup.myParams)];
+        aParamMap[aParamCopy.h] = ++myParamMaxID;
+        aParamCopy.h = myParamMaxID;
+        myParams.push_back(aParamCopy);
+      }
+
+      anEntityMap[anEntityCopy.h] = ++myEntityMaxID;
+      anEntityCopy.h = myEntityMaxID;
+      myEntities.push_back(anEntityCopy);
+      *(anEntities[indEnt]) = anEntityCopy.h;
+    }
+
+    aConstraintCopy.h = ++myConstrMaxID;
+    myConstraints.push_back(aConstraintCopy);
+    aConstrMap[aConstrIter->h] = aConstraintCopy.h;
+  }
+
+  // Append maps of SketchPlugin to SolveSpace parameters
+  std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator
+    aSPConstrMapIter = theGroup.myConstraintMap.begin();
+  for ( ; aSPConstrMapIter!= theGroup.myConstraintMap.end(); aSPConstrMapIter++)
+    myConstraintMap[aSPConstrMapIter->first] = aConstrMap.find(aSPConstrMapIter->second)->second;
+
+  std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator
+    aSPEntMapIter = theGroup.myEntityMap.begin();
+  for ( ; aSPEntMapIter != theGroup.myEntityMap.end(); aSPEntMapIter++)
+    myEntityMap[aSPEntMapIter->first] = anEntityMap.find(aSPEntMapIter->second)->second;
+
+  // Add temporary constraints
+  std::list<Slvs_hConstraint>::const_iterator aTempConstrIter = theGroup.myTempConstraints.begin();
+  for ( ; aTempConstrIter != theGroup.myTempConstraints.end(); aTempConstrIter++)
+    myTempConstraints.push_back(aConstrMap.find(*aTempConstrIter)->second);
+  myTempConstraints.sort();
+
+  myNeedToSolve = myNeedToSolve || theGroup.myNeedToSolve;
+}
+
 bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateGroup()
 {
   // Check for valid sketch
index 9cbb23bab85a60b03f8b6758f3e2e070ca1d06a1..d49eb6ecffb76e7897b135330ccebb67dbbd6a66 100644 (file)
@@ -17,6 +17,7 @@
 #include <list>
 #include <map>
 #include <vector>
+#include <set>
 
 
 // Unknown constraint (for error reporting)
@@ -95,7 +96,7 @@ private:
    *  \param[out] theGroups     list of group indexes interacted with constraint
    */
   void findGroups(boost::shared_ptr<SketchPlugin_Constraint> theConstraint,
-                  std::vector<Slvs_hGroup>&                  theGroupIDs) const;
+                  std::set<Slvs_hGroup>&                     theGroupIDs) const;
 
   /** \brief Searches in the list of groups the workplane which constains specified constraint
    *  \param[in] theConstraint constraint to be found
@@ -165,6 +166,11 @@ public:
    */
   bool updateGroup();
 
+  /** \brief Add specified group to this one
+   *  \param[in] theGroup group of constraint to be added
+   */
+  void mergeGroups(const SketchSolver_ConstraintGroup& theGroup);
+
   /** \brief Start solution procedure if necessary and update attributes of features
    */
   void resolveConstraints();