SketchAPI for Ellipse feature.
std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
std::shared_ptr<ModelAPI_Object> * temp_object;
std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
+ ModelHighAPI_Selection* temp_selection;
int newmem = 0;
+ if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (!temp_selection) {
+ PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ return NULL;
+ }
+ temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_selection;
+ }
+ $1 = &temp;
+ } else
if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
if (!temp_attribute) {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
return NULL;
}
temp = ModelHighAPI_RefAttr(*temp_attribute);
} else
if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
if (!temp_object) {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
return NULL;
}
temp = ModelHighAPI_RefAttr(*temp_object);
} else
if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
if (!temp_interface) {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
return NULL;
}
temp = ModelHighAPI_RefAttr(*temp_interface);
} else
if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
} else {
- PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
return NULL;
}
}
$result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
}
+%typemap(out) const ModelHighAPI_RefAttr & {
+ $1_basetype * ptr = new $1_basetype(*$1);
+ $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
+}
+
// std::list -> []
%template(SelectionList) std::list<ModelHighAPI_Selection>;
%template(SelectionListList) std::list<std::list<ModelHighAPI_Selection> >;
//--------------------------------------------------------------------------------------
bool ModelHighAPI_RefAttr::isEmpty() const
{
- return !(myAttribute && myObject);
+ return !(myAttribute || myObject);
}
//--------------------------------------------------------------------------------------
#
import ModelHighAPI
+from GeomAPI import *
from GeomDataAPI import *
from ModelAPI import *
import math
return thePoint
elif issubclass(type(thePoint), GeomDataAPI_Point2D):
return [thePoint.x(), thePoint.y()]
+ elif issubclass(type(thePoint), GeomAPI_Pnt2d):
+ return [thePoint.x(), thePoint.y()]
else:
aFeature = toSketchFeature(thePoint)
aPoint = geomDataAPI_Point2D(aFeature.attribute("PointCoordinates"))
SketchAPI_Circle.h
SketchAPI_Constraint.h
SketchAPI_ConstraintAngle.h
+ SketchAPI_Ellipse.h
SketchAPI_IntersectionPoint.h
SketchAPI_Line.h
SketchAPI_MacroArc.h
SketchAPI_MacroCircle.h
+ SketchAPI_MacroEllipse.h
SketchAPI_Mirror.h
- SketchAPI_Sketch.h
- SketchAPI_SketchEntity.h
SketchAPI_Point.h
SketchAPI_Projection.h
SketchAPI_Rectangle.h
SketchAPI_Rotation.h
+ SketchAPI_Sketch.h
+ SketchAPI_SketchEntity.h
SketchAPI_Translation.h
)
SketchAPI_Circle.cpp
SketchAPI_Constraint.cpp
SketchAPI_ConstraintAngle.cpp
+ SketchAPI_Ellipse.cpp
SketchAPI_IntersectionPoint.cpp
SketchAPI_Line.cpp
SketchAPI_MacroArc.cpp
SketchAPI_MacroCircle.cpp
+ SketchAPI_MacroEllipse.cpp
SketchAPI_Mirror.cpp
- SketchAPI_Sketch.cpp
- SketchAPI_SketchEntity.cpp
SketchAPI_Point.cpp
SketchAPI_Projection.cpp
SketchAPI_Rectangle.cpp
SketchAPI_Rotation.cpp
+ SketchAPI_Sketch.cpp
+ SketchAPI_SketchEntity.cpp
SketchAPI_Translation.cpp
)
// standard definitions
%include "typemaps.i"
%include "std_list.i"
+%include "std_pair.i"
%include "std_shared_ptr.i"
// shared pointers
%shared_ptr(SketchAPI_MacroArc)
%shared_ptr(SketchAPI_Circle)
%shared_ptr(SketchAPI_MacroCircle)
+%shared_ptr(SketchAPI_Ellipse)
+%shared_ptr(SketchAPI_MacroEllipse)
%shared_ptr(SketchAPI_Constraint)
%shared_ptr(SketchAPI_ConstraintAngle)
%shared_ptr(SketchAPI_IntersectionPoint)
%template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
%template(EntityList) std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
%template(SketchPointList) std::list<std::shared_ptr<SketchAPI_Point> >;
+// std::pair -> []
+%template(PointRefAttrPair) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>;
%typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
std::shared_ptr<ModelAPI_Feature> * temp_feature;
}
}
-%typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
- std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
- std::shared_ptr<ModelAPI_Object> * temp_object;
- std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
- ModelHighAPI_Selection* temp_selection;
- int newmem = 0;
- if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
- if (!temp_selection) {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
- return NULL;
- }
- temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
- if (newmem & SWIG_CAST_NEW_MEMORY) {
- delete temp_selection;
- }
- $1 = &temp;
- } else
- if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
- if (!temp_attribute) {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
- return NULL;
- }
- temp = ModelHighAPI_RefAttr(*temp_attribute);
- if (newmem & SWIG_CAST_NEW_MEMORY) {
- delete temp_attribute;
- }
- $1 = &temp;
- } else
- if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
- if (!temp_object) {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
- return NULL;
- }
- temp = ModelHighAPI_RefAttr(*temp_object);
- if (newmem & SWIG_CAST_NEW_MEMORY) {
- delete temp_object;
- }
- $1 = &temp;
- } else
- if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
- if (!temp_interface) {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
- return NULL;
- }
- temp = ModelHighAPI_RefAttr(*temp_interface);
- if (newmem & SWIG_CAST_NEW_MEMORY) {
- delete temp_interface;
- }
- $1 = &temp;
- } else
- if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
- } else {
- PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
- return NULL;
- }
-}
-
%typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
std::shared_ptr<ModelAPI_Object> * temp_object;
std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
}
}
+%typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>, const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {
+ std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
+ std::shared_ptr<ModelAPI_Object> * temp_object;
+ std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
+ ModelHighAPI_Selection* temp_selection;
+ std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
+ std::shared_ptr<GeomAPI_Pnt2d> * temp_point;
+ ModelHighAPI_RefAttr temp_refattr;
+ int newmem = 0;
+ std::list<PyObject*> temp_inputlist;
+ if (PySequence_Check($input)) {
+ for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
+ PyObject * temp = PySequence_GetItem($input, i);
+ temp_inputlist.push_back(temp);
+ }
+ } else {
+ temp_inputlist.push_back($input);
+ }
+
+ $1 = 1;
+ for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end() && $1; ++it) {
+ PyObject* item = *it;
+
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_selection) {
+ $1 = 1;
+ } else {
+ $1 = 0;
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_attribute) {
+ $1 = 1;
+ } else {
+ $1 = 0;
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_object) {
+ $1 = 1;
+ } else {
+ $1 = 0;
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_interface) {
+ $1 = 1;
+ } else {
+ $1 = 0;
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_pair) {
+ $1 = 1;
+ } else {
+ $1 = 0;
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_point) {
+ $1 = 1;
+ } else {
+ $1 = 0;
+ }
+ } else {
+ $1 = 0;
+ }
+ }
+}
+
+%typemap(in) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & (std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> temp) {
+ std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
+ std::shared_ptr<ModelAPI_Object> * temp_object;
+ std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
+ ModelHighAPI_Selection* temp_selection;
+ std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
+ std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
+ ModelHighAPI_RefAttr temp_refattr;
+ int newmem = 0;
+ std::list<PyObject*> temp_inputlist;
+ if (PySequence_Check($input)) {
+ for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
+ PyObject * temp = PySequence_GetItem($input, i);
+ temp_inputlist.push_back(temp);
+ }
+ } else {
+ temp_inputlist.push_back($input);
+ }
+
+ for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end(); ++it) {
+ PyObject* item = *it;
+
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_selection) {
+ temp_refattr = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_selection;
+ }
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_attribute) {
+ temp_refattr = ModelHighAPI_RefAttr(*temp_attribute);
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_attribute;
+ }
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_object) {
+ temp_refattr = ModelHighAPI_RefAttr(*temp_object);
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_object;
+ }
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_interface) {
+ temp_refattr = ModelHighAPI_RefAttr(*temp_interface);
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_interface;
+ }
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_pair) {
+ temp_point = &temp_pair->first;
+ temp_refattr = temp_pair->second;
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_pair;
+ }
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ // fall through
+ }
+ }
+
+ if (temp_point || !temp_refattr.isEmpty()) {
+ if (temp_point) {
+ temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(*temp_point, temp_refattr);
+ } else {
+ temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(std::shared_ptr<GeomAPI_Pnt2d>(), temp_refattr);
+ }
+ if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
+ delete temp_point;
+ }
+ $1 = &temp;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ return NULL;
+ }
+}
+
+// fix compilarion error: 'res*' was not declared in this scope
+%typemap(freearg) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {}
+
// all supported interfaces (the order is very important according dependencies: base class first)
%include "SketchAPI_SketchEntity.h"
%include "SketchAPI_Point.h"
%include "SketchAPI_MacroCircle.h"
%include "SketchAPI_Arc.h"
%include "SketchAPI_MacroArc.h"
+%include "SketchAPI_Ellipse.h"
+%include "SketchAPI_MacroEllipse.h"
%include "SketchAPI_Projection.h"
%include "SketchAPI_Mirror.h"
%include "SketchAPI_Translation.h"
--- /dev/null
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SketchAPI_Ellipse.h"
+
+#include <GeomAPI_Pnt2d.h>
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature> & theFeature)
+ : SketchAPI_SketchEntity(theFeature)
+{
+ initialize();
+}
+
+SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ double theCenterX, double theCenterY,
+ double theFocusX, double theFocusY,
+ double theMinorRadius)
+ : SketchAPI_SketchEntity(theFeature)
+{
+ if(initialize()) {
+ setByCenterFocusAndRadius(theCenterX, theCenterY, theFocusX, theFocusY, theMinorRadius);
+ }
+}
+
+SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
+ double theMinorRadius)
+: SketchAPI_SketchEntity(theFeature)
+{
+ if(initialize()) {
+ setByCenterFocusAndRadius(theCenter, theFocus, theMinorRadius);
+ }
+}
+
+SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theExternal)
+ : SketchAPI_SketchEntity(theFeature)
+{
+ if (initialize()) {
+ setByExternal(theExternal);
+ }
+}
+
+SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::string& theExternalName)
+ : SketchAPI_SketchEntity(theFeature)
+{
+ if (initialize()) {
+ setByExternalName(theExternalName);
+ }
+}
+
+SketchAPI_Ellipse::~SketchAPI_Ellipse()
+{
+}
+
+void SketchAPI_Ellipse::setByCenterFocusAndRadius(double theCenterX, double theCenterY,
+ double theFocusX, double theFocusY,
+ double theMinorRadius)
+{
+ fillAttribute(center(), theCenterX, theCenterY);
+ fillAttribute(firstFocus(), theFocusX, theFocusY);
+ fillAttribute(theMinorRadius, myminorRadius);
+
+ execute();
+}
+
+void SketchAPI_Ellipse::setByCenterFocusAndRadius(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
+ double theMinorRadius)
+{
+ fillAttribute(theCenter, mycenter);
+ fillAttribute(theFocus, myfirstFocus);
+ fillAttribute(theMinorRadius, myminorRadius);
+
+ execute();
+}
+
+void SketchAPI_Ellipse::setByExternal(const ModelHighAPI_Selection & theExternal)
+{
+ fillAttribute(theExternal, external());
+ execute();
+}
+
+void SketchAPI_Ellipse::setByExternalName(const std::string & theExternalName)
+{
+ fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
+ execute();
+}
+
+void SketchAPI_Ellipse::setCenter(double theX, double theY)
+{
+ fillAttribute(center(), theX, theY);
+ execute();
+}
+
+void SketchAPI_Ellipse::setCenter(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter)
+{
+ fillAttribute(theCenter, mycenter);
+ execute();
+}
+
+void SketchAPI_Ellipse::setFocus(double theX, double theY)
+{
+ fillAttribute(firstFocus(), theX, theY);
+ execute();
+}
+
+void SketchAPI_Ellipse::setFocus(const std::shared_ptr<GeomAPI_Pnt2d> & theFocus)
+{
+ fillAttribute(theFocus, myfirstFocus);
+ execute();
+}
+
+void SketchAPI_Ellipse::setMinorRadius(double theMinorRadius)
+{
+ fillAttribute(theMinorRadius, myminorRadius);
+ execute();
+}
+
+ModelHighAPI_Selection SketchAPI_Ellipse::majorAxis() const
+{
+}
+
+ModelHighAPI_Selection SketchAPI_Ellipse::minorAxis() const
+{
+}
+
+void SketchAPI_Ellipse::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ if (isCopy())
+ return; // no need to dump copied feature
+
+ FeaturePtr aBase = feature();
+ const std::string& aSketchName = theDumper.parentName(aBase);
+
+ AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
+ if (anExternal->context()) {
+ // circle is external
+ theDumper << aBase << " = " << aSketchName << ".addEllipse(" << anExternal << ")" << std::endl;
+ } else {
+ // ellipse given by center, focus and radius
+ theDumper << aBase << " = " << aSketchName << ".addEllipse("
+ << center() << ", " << firstFocus() << ", " << minorRadius() << ")" << std::endl;
+ }
+ // dump "auxiliary" flag if necessary
+ SketchAPI_SketchEntity::dump(theDumper);
+}
--- /dev/null
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SketchAPI_Ellipse_H_
+#define SketchAPI_Ellipse_H_
+
+#include "SketchAPI.h"
+#include "SketchAPI_SketchEntity.h"
+
+#include <SketchPlugin_Ellipse.h>
+
+class ModelHighAPI_Selection;
+
+/// \class SketchAPI_Ellipse
+/// \ingroup CPPHighAPI
+/// \brief Interface for Ellipse feature.
+class SketchAPI_Ellipse : public SketchAPI_SketchEntity
+{
+public:
+ /// Constructor without values.
+ SKETCHAPI_EXPORT
+ explicit SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ SKETCHAPI_EXPORT
+ SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ double theCenterX, double theCenterY,
+ double theFocusX, double theFocusY,
+ double theMinorRadius);
+
+ /// Constructor with values.
+ SKETCHAPI_EXPORT
+ SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
+ double theMinorRadius);
+
+ /// Constructor with external.
+ SKETCHAPI_EXPORT
+ SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theExternal);
+
+ /// Constructor with external.
+ SKETCHAPI_EXPORT
+ SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::string& theExternalName);
+
+ /// Destructor.
+ SKETCHAPI_EXPORT
+ virtual ~SketchAPI_Ellipse();
+
+ INTERFACE_10(SketchPlugin_Ellipse::ID(),
+ center, SketchPlugin_Ellipse::CENTER_ID(),
+ GeomDataAPI_Point2D, /** Center point */,
+ firstFocus, SketchPlugin_Ellipse::FIRST_FOCUS_ID(),
+ GeomDataAPI_Point2D, /** Focus in positive direction of a major axis */,
+ secondFocus, SketchPlugin_Ellipse::SECOND_FOCUS_ID(),
+ GeomDataAPI_Point2D, /** Focus in negative direction of a major axis */,
+ majorAxisNegative, SketchPlugin_Ellipse::MAJOR_AXIS_START_ID(),
+ GeomDataAPI_Point2D, /** Start point of major axis */,
+ majorAxisPositive, SketchPlugin_Ellipse::MAJOR_AXIS_END_ID(),
+ GeomDataAPI_Point2D, /** End point of major axis */,
+ minorAxisNegative, SketchPlugin_Ellipse::MINOR_AXIS_START_ID(),
+ GeomDataAPI_Point2D, /** Start point of minor axis */,
+ minorAxisPositive, SketchPlugin_Ellipse::MINOR_AXIS_END_ID(),
+ GeomDataAPI_Point2D, /** End point of minor axis */,
+ majorRadius, SketchPlugin_Ellipse::MAJOR_RADIUS_ID(),
+ ModelAPI_AttributeDouble, /** Major radius */,
+ minorRadius, SketchPlugin_Ellipse::MINOR_RADIUS_ID(),
+ ModelAPI_AttributeDouble, /** Minor radius */,
+ external, SketchPlugin_Ellipse::EXTERNAL_ID(),
+ ModelAPI_AttributeSelection, /** External */)
+
+ /// Set by center, focus and radius.
+ SKETCHAPI_EXPORT
+ void setByCenterFocusAndRadius(double theCenterX, double theCenterY,
+ double theFocusX, double theFocusY,
+ double theMinorRadius);
+
+ /// Set by center, focus and radius.
+ SKETCHAPI_EXPORT
+ void setByCenterFocusAndRadius(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
+ double theMinorRadius);
+
+ /// Set by external.
+ SKETCHAPI_EXPORT
+ void setByExternal(const ModelHighAPI_Selection& theExternal);
+
+ /// Set by external name.
+ SKETCHAPI_EXPORT
+ void setByExternalName(const std::string& theExternalName);
+
+ /// Set center.
+ SKETCHAPI_EXPORT
+ void setCenter(double theX, double theY);
+
+ /// Set center.
+ SKETCHAPI_EXPORT
+ void setCenter(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter);
+
+ /// Set focus.
+ SKETCHAPI_EXPORT
+ void setFocus(double theX, double theY);
+
+ /// Set focus.
+ SKETCHAPI_EXPORT
+ void setFocus(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter);
+
+ /// Set radius.
+ SKETCHAPI_EXPORT
+ void setMinorRadius(double theRadius);
+
+ /// Return major axis of the ellipse
+ SKETCHAPI_EXPORT
+ ModelHighAPI_Selection majorAxis() const;
+
+ /// Return minor axis of the ellipse
+ SKETCHAPI_EXPORT
+ ModelHighAPI_Selection minorAxis() const;
+
+ /// Dump wrapped feature
+ SKETCHAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Ellipse object.
+typedef std::shared_ptr<SketchAPI_Ellipse> EllipsePtr;
+
+#endif // SketchPlugin_Ellipse_H_
--- /dev/null
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SketchAPI_MacroEllipse.h"
+
+#include <GeomAPI_Pnt2d.h>
+
+#include <ModelHighAPI_RefAttr.h>
+#include <ModelHighAPI_Tools.h>
+
+SketchAPI_MacroEllipse::SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: SketchAPI_SketchEntity(theFeature)
+{
+ initialize();
+}
+
+SketchAPI_MacroEllipse::SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ double theX1, double theY1,
+ double theX2, double theY2,
+ double theX3, double theY3,
+ bool byCenter)
+ : SketchAPI_SketchEntity(theFeature)
+{
+ if (initialize()) {
+ if (byCenter)
+ setByCenterAndPassedPoints();
+ else
+ setByMajorAxisAndPassedPoint();
+
+ initializePoints(theX1, theY1, theX2, theY2, theX3, theY3);
+ }
+}
+
+SketchAPI_MacroEllipse::SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
+ bool byCenter)
+ : SketchAPI_SketchEntity(theFeature)
+{
+ if (initialize()) {
+ if (byCenter)
+ setByCenterAndPassedPoints();
+ else
+ setByMajorAxisAndPassedPoint();
+
+ initializePoints(thePoint1, thePoint2, thePoint3);
+ }
+}
+
+SketchAPI_MacroEllipse::SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
+ const ModelHighAPI_RefAttr& thePoint1Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
+ const ModelHighAPI_RefAttr& thePoint2Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
+ const ModelHighAPI_RefAttr& thePoint3Ref,
+ bool byCenter)
+ : SketchAPI_SketchEntity(theFeature)
+{
+ if (initialize()) {
+ if (byCenter)
+ setByCenterAndPassedPoints();
+ else
+ setByMajorAxisAndPassedPoint();
+
+ initializePoints(thePoint1, thePoint1Ref, thePoint2, thePoint2Ref, thePoint3, thePoint3Ref);
+ }
+}
+
+SketchAPI_MacroEllipse::~SketchAPI_MacroEllipse()
+{
+}
+
+void SketchAPI_MacroEllipse::setByCenterAndPassedPoints()
+{
+ fillAttribute(SketchPlugin_MacroEllipse::ELLIPSE_TYPE_BY_CENTER_AXIS_POINT(), myellipseType);
+}
+
+void SketchAPI_MacroEllipse::setByMajorAxisAndPassedPoint()
+{
+ fillAttribute(SketchPlugin_MacroEllipse::ELLIPSE_TYPE_BY_AXIS_AND_POINT(), myellipseType);
+}
+
+void SketchAPI_MacroEllipse::initializePoints(double theX1, double theY1,
+ double theX2, double theY2,
+ double theX3, double theY3)
+{
+ fillAttribute(majorAxisNegativePoint(), theX1, theY1);
+ fillAttribute(majorAxisPositivePoint(), theX2, theY2);
+ fillAttribute(passedPoint(), theX3, theY3);
+
+ execute();
+}
+
+void SketchAPI_MacroEllipse::initializePoints(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
+{
+ fillAttribute(thePoint1, mymajorAxisNegativePoint);
+ fillAttribute(thePoint2, mymajorAxisPositivePoint);
+ fillAttribute(thePoint3, mypassedPoint);
+
+ execute();
+}
+
+static void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint,
+ const ModelHighAPI_RefAttr& thePointRef,
+ std::shared_ptr<GeomDataAPI_Point2D> thePointAttr,
+ AttributeRefAttrPtr thePointRefAttr)
+{
+ GeomPnt2dPtr aPoint = thePoint;
+ if (!thePointRef.isEmpty()) {
+ fillAttribute(thePointRef, thePointRefAttr);
+ std::shared_ptr<GeomDataAPI_Point2D> anAttrPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(thePointRefAttr->attr());
+ if (anAttrPnt)
+ aPoint = anAttrPnt->pnt();
+ }
+ fillAttribute(aPoint, thePointAttr);
+}
+
+void SketchAPI_MacroEllipse::initializePoints(
+ const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint1,
+ const ModelHighAPI_RefAttr& theMajorAxisPoint1Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint2,
+ const ModelHighAPI_RefAttr& theMajorAxisPoint2Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
+ const ModelHighAPI_RefAttr& thePassedPointRef)
+{
+ fillAttribute(theMajorAxisPoint1, theMajorAxisPoint1Ref,
+ mymajorAxisNegativePoint, mymajorAxisNegativePointRef);
+ fillAttribute(theMajorAxisPoint2, theMajorAxisPoint2Ref,
+ mymajorAxisPositivePoint, mymajorAxisPositivePointRef);
+ fillAttribute(thePassedPoint, thePassedPointRef, mypassedPoint, mypassedPointRef);
+
+ execute();
+}
--- /dev/null
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SketchAPI_MacroEllipse_H_
+#define SketchAPI_MacroEllipse_H_
+
+#include "SketchAPI.h"
+#include "SketchAPI_SketchEntity.h"
+
+#include <SketchPlugin_MacroEllipse.h>
+
+class ModelHighAPI_RefAttr;
+
+/// \class SketchAPI_MacroEllipse
+/// \ingroup CPPHighAPI
+/// \brief Interface for Ellipse feature.
+class SketchAPI_MacroEllipse: public SketchAPI_SketchEntity
+{
+public:
+ /// Constructor without values.
+ SKETCHAPI_EXPORT
+ explicit SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ SKETCHAPI_EXPORT
+ SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ double theX1, double theY1,
+ double theX2, double theY2,
+ double theX3, double theY3,
+ bool byCenter = true);
+
+ /// Constructor with values.
+ SKETCHAPI_EXPORT
+ SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
+ bool byCenter = true);
+
+ /// Constructor with values and/or references.
+ SKETCHAPI_EXPORT
+ SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
+ const ModelHighAPI_RefAttr& thePoint1Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
+ const ModelHighAPI_RefAttr& thePoint2Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
+ const ModelHighAPI_RefAttr& thePoint3Ref,
+ bool byCenter = true);
+
+ /// Destructor.
+ SKETCHAPI_EXPORT
+ virtual ~SketchAPI_MacroEllipse();
+
+ INTERFACE_9(SketchPlugin_MacroEllipse::ID(),
+ ellipseType, SketchPlugin_MacroEllipse::ELLIPSE_TYPE(),
+ ModelAPI_AttributeString, /** Ellipse type */,
+ centerPoint, SketchPlugin_MacroEllipse::FIRST_POINT_ID(),
+ GeomDataAPI_Point2D, /** Center point */,
+ centerPointRef, SketchPlugin_MacroEllipse::FIRST_POINT_REF_ID(),
+ ModelAPI_AttributeRefAttr, /** Reference to a center point */,
+ majorAxisNegativePoint, SketchPlugin_MacroEllipse::FIRST_POINT_ID(),
+ GeomDataAPI_Point2D, /** Major axis negative point point */,
+ majorAxisNegativePointRef, SketchPlugin_MacroEllipse::FIRST_POINT_REF_ID(),
+ ModelAPI_AttributeRefAttr, /** Reference to the negative point on a major axis */,
+ majorAxisPositivePoint, SketchPlugin_MacroEllipse::SECOND_POINT_ID(),
+ GeomDataAPI_Point2D, /** Major axis positive point point */,
+ majorAxisPositivePointRef, SketchPlugin_MacroEllipse::SECOND_POINT_REF_ID(),
+ ModelAPI_AttributeRefAttr, /** Reference to the positive point on a major axis */,
+ passedPoint, SketchPlugin_MacroEllipse::PASSED_POINT_ID(),
+ GeomDataAPI_Point2D, /** Passed point */,
+ passedPointRef, SketchPlugin_MacroEllipse::PASSED_POINT_REF_ID(),
+ ModelAPI_AttributeRefAttr, /** Reference to a passed point */)
+
+private:
+ /// Set flag of creation by center, major semi-axis and passed point.
+ void setByCenterAndPassedPoints();
+ /// Set flag of creation by major axis and passed point.
+ void setByMajorAxisAndPassedPoint();
+
+ /// Set points of ellipse.
+ void initializePoints(double theMajorAxisX1, double theMajorAxisY1,
+ double theMajorAxisX2, double theMajorAxisY2,
+ double thePassedX, double thePassedY);
+
+ /// Set points of ellipse.
+ void initializePoints(const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint1,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint2,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
+
+ /// Set points of ellipse.
+ void initializePoints(const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint1,
+ const ModelHighAPI_RefAttr& theMajorAxisPoint1Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint2,
+ const ModelHighAPI_RefAttr& theMajorAxisPoint2Ref,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
+ const ModelHighAPI_RefAttr& thePassedPointRef);
+};
+
+/// Pointer on Circle object.
+typedef std::shared_ptr<SketchAPI_MacroEllipse> MacroEllipsePtr;
+
+#endif // SketchAPI_MacroEllipse_H_
#include <ModelHighAPI_Tools.h>
//--------------------------------------------------------------------------------------
#include "SketchAPI_Arc.h"
-#include "SketchAPI_MacroArc.h"
#include "SketchAPI_Circle.h"
+#include "SketchAPI_Ellipse.h"
#include "SketchAPI_IntersectionPoint.h"
#include "SketchAPI_Line.h"
+#include "SketchAPI_MacroArc.h"
#include "SketchAPI_MacroCircle.h"
+#include "SketchAPI_MacroEllipse.h"
#include "SketchAPI_Mirror.h"
#include "SketchAPI_Point.h"
#include "SketchAPI_Projection.h"
std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::string & theExternalName)
{
- // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Circle::ID());
return CirclePtr(new SketchAPI_Circle(aFeature, theExternalName));
std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theExternalName)
{
- // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Arc::ID());
return ArcPtr(new SketchAPI_Arc(aFeature, theExternalName));
}
+//--------------------------------------------------------------------------------------
+std::shared_ptr<SketchAPI_Ellipse> SketchAPI_Sketch::addEllipse(
+ double theCenterX, double theCenterY,
+ double theFocusX, double theFocusY,
+ double theMinorRadius)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ compositeFeature()->addFeature(SketchPlugin_Ellipse::ID());
+ return EllipsePtr(new SketchAPI_Ellipse(aFeature,
+ theCenterX, theCenterY, theFocusX, theFocusY, theMinorRadius));
+}
+
+std::shared_ptr<SketchAPI_Ellipse> SketchAPI_Sketch::addEllipse(
+ const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
+ double theMinorRadius)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ compositeFeature()->addFeature(SketchPlugin_Ellipse::ID());
+ return EllipsePtr(new SketchAPI_Ellipse(aFeature, theCenter, theFocus, theMinorRadius));
+}
+
+std::shared_ptr<SketchAPI_MacroEllipse> SketchAPI_Sketch::addEllipse(
+ double thePoint1X, double thePoint1Y,
+ double thePoint2X, double thePoint2Y,
+ double thePassedX, double thePassedY,
+ bool isPoint1Center)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ compositeFeature()->addFeature(SketchPlugin_MacroEllipse::ID());
+ return MacroEllipsePtr(new SketchAPI_MacroEllipse(aFeature,
+ thePoint1X, thePoint1Y, thePoint2X, thePoint1Y, thePassedX, thePassedY, isPoint1Center));
+}
+
+std::shared_ptr<SketchAPI_MacroEllipse> SketchAPI_Sketch::addEllipse(
+ const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint1,
+ const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint2,
+ const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePassedPoint,
+ bool isPoint1Center)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ compositeFeature()->addFeature(SketchPlugin_MacroEllipse::ID());
+ MacroEllipsePtr anEllipse;
+ if (thePoint1.second.isEmpty() &&
+ thePoint2.second.isEmpty() &&
+ thePassedPoint.second.isEmpty()) {
+ anEllipse.reset(new SketchAPI_MacroEllipse(aFeature,
+ thePoint1.first, thePoint2.first, thePassedPoint.first, isPoint1Center));
+ }
+ else {
+ anEllipse.reset(new SketchAPI_MacroEllipse(aFeature,
+ thePoint1.first, thePoint1.second,
+ thePoint2.first, thePoint2.second,
+ thePassedPoint.first, thePassedPoint.second,
+ isPoint1Center));
+ }
+ return anEllipse;
+}
+
+std::shared_ptr<SketchAPI_Ellipse> SketchAPI_Sketch::addEllipse(
+ const ModelHighAPI_Selection & theExternal)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ compositeFeature()->addFeature(SketchPlugin_Ellipse::ID());
+ return EllipsePtr(new SketchAPI_Ellipse(aFeature, theExternal));
+}
+
+std::shared_ptr<SketchAPI_Ellipse> SketchAPI_Sketch::addEllipse(
+ const std::string & theExternalName)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ compositeFeature()->addFeature(SketchPlugin_Ellipse::ID());
+ return EllipsePtr(new SketchAPI_Ellipse(aFeature, theExternalName));
+}
+
//--------------------------------------------------------------------------------------
std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
const ModelHighAPI_Selection & theExternalFeature,
class SketchAPI_MacroArc;
class SketchAPI_Circle;
class SketchAPI_MacroCircle;
+class SketchAPI_Ellipse;
+class SketchAPI_MacroEllipse;
class SketchAPI_IntersectionPoint;
class SketchAPI_Line;
class SketchAPI_Mirror;
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
+ /// Add ellipse
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Ellipse> addEllipse(
+ double theCenterX, double theCenterY,
+ double theFocusX, double theFocusY,
+ double theMinorRadius);
+ /// Add ellipse
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Ellipse> addEllipse(
+ const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
+ double theRadius);
+ /// Add ellipse
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_MacroEllipse> addEllipse(
+ double thePoint1X, double thePoint1Y,
+ double thePoint2X, double thePoint2Y,
+ double thePassedX, double thePassedY,
+ bool isPoint1Center = true);
+ /// Add ellipse
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_MacroEllipse> addEllipse(
+ const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint1,
+ const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint2,
+ const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePassedPoint,
+ bool isPoint1Center = true);
+ /// Add ellipse
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Ellipse> addEllipse(const ModelHighAPI_Selection & theExternal);
+ /// Add ellipse
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Ellipse> addEllipse(const std::string & theExternalName);
+
/// Add projection
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_Projection> addProjection(
#include "SketchAPI_SketchEntity.h"
#include <SketchAPI_Arc.h>
#include <SketchAPI_Circle.h>
+#include <SketchAPI_Ellipse.h>
#include <SketchAPI_IntersectionPoint.h>
#include <SketchAPI_Line.h>
#include <SketchAPI_Point.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Ellipse.h>
#include <SketchPlugin_IntersectionPoint.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Point.h>
aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Arc(*anIt)));
else if ((*anIt)->getKind() == SketchPlugin_Circle::ID())
aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Circle(*anIt)));
+ else if ((*anIt)->getKind() == SketchPlugin_Ellipse::ID())
+ aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Ellipse(*anIt)));
else if ((*anIt)->getKind() == SketchPlugin_Point::ID())
aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Point(*anIt)));
else if ((*anIt)->getKind() == SketchPlugin_IntersectionPoint::ID())
#include "SketchAPI_MacroArc.h"
#include "SketchAPI_Circle.h"
#include "SketchAPI_MacroCircle.h"
+ #include "SketchAPI_Ellipse.h"
+ #include "SketchAPI_MacroEllipse.h"
#include "SketchAPI_Constraint.h"
#include "SketchAPI_ConstraintAngle.h"
#include "SketchAPI_IntersectionPoint.h"
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <cmath>
+
static const double tolerance = 1e-7;
data()->addAttribute(MAJOR_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(MINOR_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SECOND_FOCUS_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), MAJOR_AXIS_START_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), MAJOR_AXIS_END_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), MINOR_AXIS_START_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), MINOR_AXIS_END_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), MAJOR_RADIUS_ID());
+
data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
std::shared_ptr<GeomDataAPI_Point2D> aFocusAttr =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(FIRST_FOCUS_ID()));
- AttributeDoublePtr aMajorRadiusAttr = real(MAJOR_RADIUS_ID());
AttributeDoublePtr aMinorRadiusAttr = real(MINOR_RADIUS_ID());
if (!aCenterAttr->isInitialized() ||
!aFocusAttr->isInitialized() ||
- !aMajorRadiusAttr->isInitialized() ||
!aMinorRadiusAttr->isInitialized()) {
return false;
}
- double aMajorRadius = aMajorRadiusAttr->value();
double aMinorRadius = aMinorRadiusAttr->value();
- if (aMajorRadius < tolerance || aMinorRadius < tolerance) {
+ if (aMinorRadius < tolerance) {
return false;
}
GeomDir2dPtr aMajorDir2d(new GeomAPI_Dir2d(aFocus2d->x() - aCenter2d->x(),
aFocus2d->y() - aCenter2d->y()));
GeomDir2dPtr aMinorDir2d(new GeomAPI_Dir2d(-aMajorDir2d->y(), aMajorDir2d->x()));
+
+ AttributeDoublePtr aMajorRadiusAttr = real(MAJOR_RADIUS_ID());
+ double aFocalDist = aCenter2d->distance(aFocus2d);
+ double aMajorRadius = sqrt(aFocalDist * aFocalDist + aMinorRadius * aMinorRadius);
+ aMajorRadiusAttr->setValue(aMajorRadius);
+
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(SECOND_FOCUS_ID()))
->setValue(2.0 * aCenter2d->x() - aFocus2d->x(), 2.0 * aCenter2d->y() - aFocus2d->y());
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(MAJOR_AXIS_START_ID()))
AttributeRefAttrPtr aPointRef = refattr(aPointRefName[aPntIndex]);
// calculate ellipse parameters
- GeomPnt2dPtr aPassedPoint;
+ GeomPnt2dPtr aPassedPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aPointAttr)->pnt();
GeomShapePtr aTangentCurve;
SketchPlugin_Tools::convertRefAttrToPointOrTangentCurve(
aPointRef, aPointAttr, aTangentCurve, aPassedPoint);
AttributeDoublePtr aMinorRadiusAttr = real(MINOR_RADIUS_ID());
bool aWasBlocked = data()->blockSendAttributeUpdated(true);
- // center attribute is used in processEvent() to set reference to reentrant arc
-//// std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(FIRST_POINT_ID()))
-//// ->setValue(myCenter);
aMajorRadiusAttr->setValue(myMajorRadius);
aMinorRadiusAttr->setValue(myMinorRadius);
data()->blockSendAttributeUpdated(aWasBlocked, false);