#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
+#include <ios>
+
ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(FeaturePtr theFeature) {
storeData(theFeature->data(), myAttrs);
// iterate results to store
// output the main characteristics
aResult<<"Volume: "<<setprecision(2)<<GeomAlgoAPI_ShapeTools::volume(theShape)<<std::endl;
std::shared_ptr<GeomAPI_Pnt> aCenter = GeomAlgoAPI_ShapeTools::centreOfMass(theShape);
- aResult<<"Center of mass: "
+ aResult<<"Center of mass: "<<std::fixed<<setprecision(7)
<<aCenter->x()<<" "<<aCenter->y()<<" "<<aCenter->z()<<std::endl;
return aResult.str();
}
}
}
+%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;
+ ModelHighAPI_Selection* temp_selection;
+ int newmem = 0;
+ if (PySequence_Check($input)) {
+ for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
+ PyObject * item = PySequence_GetItem($input, i);
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (!temp_selection) {
+ PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
+ return NULL;
+ }
+ temp.push_back(temp_selection->resultSubShapePair().first);
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_selection;
+ }
+ } else
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (!temp_object) {
+ PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
+ return NULL;
+ }
+ temp.push_back(*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) {
+ PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
+ return NULL;
+ }
+ temp.push_back((*temp_interface)->defaultResult());
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_interface;
+ }
+ }
+ Py_DECREF(item);
+ }
+ $1 = &temp;
+ } else {
+ PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
+ return NULL;
+ }
+}
+
// all supported interfaces (the order is very important according dependencies: base class first)
%include "SketchAPI_SketchEntity.h"
%include "SketchAPI_Point.h"
SketchPlugin_ConstraintBase::erase();
}
+#include <ModelAPI_AttributeRefAttrList.h>
void SketchPlugin_ConstraintMirror::attributeChanged(const std::string& theID)
{
if (theID == MIRROR_LIST_ID()) {
AttributeRefListPtr aMirrorObjectRefs = reflist(MIRROR_LIST_ID());
if (aMirrorObjectRefs->size() == 0) {
+ DocumentPtr aDoc = document();
// Clear list of objects
AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
data()->attribute(SketchPlugin_Constraint::ENTITY_C()));
std::list<ObjectPtr> aTargetList = aRefListOfMirrored->list();
- std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
- for (; aTargetIter != aTargetList.end(); aTargetIter++) {
- aRefListOfMirrored->remove(*aTargetIter);
- // remove the corresponding feature from the sketch
- ResultConstructionPtr aRC =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aTargetIter);
- DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
- FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr();
+ std::list<ObjectPtr>::reverse_iterator aTargetIter = aTargetList.rbegin();
+ for (; aTargetIter != aTargetList.rend(); aTargetIter++) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
if (aFeature)
aDoc->removeFeature(aFeature);
}
aSketchArc = aSketchFeature.addFeature("SketchArc")
assert (aSketchArc.getKind() == "SketchArc")
anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
-assert (anArcCentr.x() == 0)
-assert (anArcCentr.y() == 0)
assert (not anArcCentr.isInitialized())
anArcCentr.setValue(10., 10.)
anArcStartPoint = geomDataAPI_Point2D(
aSketchArc.attribute("ArcStartPoint"))
-assert (anArcStartPoint.x() == 0)
-assert (anArcStartPoint.y() == 0)
assert (not anArcStartPoint.isInitialized())
anArcStartPoint.setValue(0., 50.)
anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
-assert (anArcEndPoint.x() == 0)
-assert (anArcEndPoint.y() == 0)
assert (not anArcEndPoint.isInitialized())
anArcEndPoint.setValue(50., 0.)
aSession.finishOperation()
aSketchCircle = aSketchFeature.addFeature("SketchCircle")
assert (aSketchCircle.getKind() == "SketchCircle")
anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-assert (anCircleCentr.x() == 0)
-assert (anCircleCentr.y() == 0)
assert (not anCircleCentr.isInitialized())
aCircleRadius = aSketchCircle.real("CircleRadius")
assert (type(aCircleRadius) == ModelAPI_AttributeDouble)
# ModelAPI_AttributeDouble.typeId() is checked in ModelAPI_TestConstants
assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.typeId())
-assert (aCircleRadius.value() == 0)
anCircleCentr.setValue(-25., -25)
aCircleRadius.setValue(25.)
assert (anCircleCentr.x() == -25)
aSketchPoint = aSketchFeature.addFeature("SketchPoint")
assert (aSketchPoint.getKind() == "SketchPoint")
coords = geomDataAPI_Point2D(aSketchPoint.attribute("PointCoordindates"))
-assert (coords.x() == 0)
-assert (coords.y() == 0)
assert (not coords.isInitialized())
# Simulate SketchPlugin_Point::move(...)
coords.setValue(10., 10.)
assert (len(aSketchReflist.list()) == 2)
aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
-assert (aLineStartPoint.x() == 0)
-assert (aLineStartPoint.y() == 0)
assert (not aLineStartPoint.isInitialized())
-assert (aLineEndPoint.x() == 0)
-assert (aLineEndPoint.y() == 0)
assert (not aLineEndPoint.isInitialized())
# Simulate SketchPlugin_Line::move(...)
aLineStartPoint.setValue(50., 50.)