theDumper << ")" << std::endl;
if(anAttrSketch->isInitialized()) {
- theDumper << aBase << ".setNestedSketch(" << anAttrSketch << ")";
+ theDumper << aBase << ".setNestedSketch(" << anAttrSketch << ")" << std::endl;
}
}
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_AttributeRefAttrList.h>
+#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
isForce = false;
dumpFeature(aFeature, isForce);
}
- // dump command to update model
- myDumpBuffer << "model.do()" << std::endl;
+ // dump empty line for appearance
+ myDumpBuffer << std::endl;
return true;
}
return *this;
}
+ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const bool theValue)
+{
+ myDumpBuffer << (theValue ? "True" : "False");
+ return *this;
+}
+
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const int theValue)
{
myDumpBuffer << theValue;
return *this;
}
+ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
+ const std::shared_ptr<ModelAPI_AttributeReference>& theReference)
+{
+ *this << theReference->value();
+ return *this;
+}
+
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList)
{
for (; anIt != aNotDumped.end(); ++anIt) {
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
theDumper.dumpFeature(aFeature, true);
+
+ // if the feature is composite, dump all its subs
+ CompositeFeaturePtr aCompFeat =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
+ if (aCompFeat)
+ theDumper.process(aCompFeat);
}
// then store currently dumped string
class ModelAPI_AttributeInteger;
class ModelAPI_AttributeRefAttr;
class ModelAPI_AttributeRefAttrList;
+class ModelAPI_AttributeReference;
class ModelAPI_AttributeRefList;
class ModelAPI_AttributeSelection;
class ModelAPI_AttributeSelectionList;
/// Dump string
MODELHIGHAPI_EXPORT
ModelHighAPI_Dumper& operator<<(const std::string& theString);
+ /// Dump boolean
+ MODELHIGHAPI_EXPORT
+ ModelHighAPI_Dumper& operator<<(const bool theValue);
/// Dump integer
MODELHIGHAPI_EXPORT
ModelHighAPI_Dumper& operator<<(const int theValue);
/// Dump AttributeSelectionList
MODELHIGHAPI_EXPORT
ModelHighAPI_Dumper& operator<<(const std::shared_ptr<ModelAPI_AttributeSelectionList>& theAttrSelList);
+ /// Dump AttributeReference
+ MODELHIGHAPI_EXPORT
+ ModelHighAPI_Dumper& operator<<(const std::shared_ptr<ModelAPI_AttributeReference>& theReference);
/// Clear dump buffer
MODELHIGHAPI_EXPORT
}
}
+%typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
+ std::shared_ptr<ModelAPI_Object> * temp_object;
+ std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
+ 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_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (temp_object) {
+ $1 = 1;
+ } else {
+ $1 = 0;
+ break;
+ }
+ } 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;
+ break;
+ }
+ }
+ Py_DECREF(item);
+ }
+ } else {
+ $1 = 0;
+ }
+}
+
// all supported interfaces (the order is very important according dependencies: base class first)
%include "SketchAPI_SketchEntity.h"
%include "SketchAPI_Point.h"
//--------------------------------------------------------------------------------------
#include "SketchAPI_Rotation.h"
//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Tools.h>
//--------------------------------------------------------------------------------------
SketchAPI_Rotation::SketchAPI_Rotation(
const std::shared_ptr<ModelAPI_Feature> & theFeature)
-: SketchAPI_SketchEntity(theFeature)
+: ModelHighAPI_Interface(theFeature)
{
initialize();
}
const ModelHighAPI_Double & theAngle,
const ModelHighAPI_Integer & theNumberOfObjects,
bool theFullValue)
-: SketchAPI_SketchEntity(theFeature)
+: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
fillAttribute(theObjects, rotationList());
fillAttribute(theCenter, center());
fillAttribute(theAngle, angle());
fillAttribute(theNumberOfObjects, numberOfObjects());
- if (theFullValue)
- fillAttribute("SingleAngle", valueType());
+ fillAttribute(theFullValue ? "FullAngle" : "SingleAngle", valueType());
execute();
}
}
//--------------------------------------------------------------------------------------
+
+void SketchAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aSketchName = theDumper.parentName(aBase);
+
+ AttributeRefListPtr aRotObjects = rotationList();
+ AttributeRefAttrPtr aCenter = center();
+ AttributeDoublePtr anAngle = angle();
+ AttributeIntegerPtr aNbCopies = numberOfObjects();
+ bool isFullValue = valueType()->value() != "SingleAngle";
+
+ theDumper << aBase << " = " << aSketchName << ".addRotation("
+ << aRotObjects << ", " << aCenter << ", " << anAngle << ", " << aNbCopies;
+ if (isFullValue)
+ theDumper << ", " << isFullValue;
+ theDumper << ")" << std::endl;
+}
#include <SketchPlugin_MultiRotation.h>
-#include "SketchAPI_SketchEntity.h"
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
//--------------------------------------------------------------------------------------
class ModelAPI_Object;
class ModelHighAPI_Double;
* \ingroup CPPHighAPI
* \brief Interface for Rotation feature
*/
-class SketchAPI_Rotation : public SketchAPI_SketchEntity
+class SketchAPI_Rotation : public ModelHighAPI_Interface
{
public:
/// Constructor without values
rotatedObjects, SketchPlugin_MultiRotation::ENTITY_B(), ModelAPI_AttributeRefList, /** Rotated objects */
)
+ /// Dump wrapped feature
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
};
//! Pointer on Rotation object
//--------------------------------------------------------------------------------------
#include "SketchAPI_Translation.h"
//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Tools.h>
//--------------------------------------------------------------------------------------
SketchAPI_Translation::SketchAPI_Translation(
const std::shared_ptr<ModelAPI_Feature> & theFeature)
-: SketchAPI_SketchEntity(theFeature)
+: ModelHighAPI_Interface(theFeature)
{
initialize();
}
const ModelHighAPI_RefAttr & thePoint2,
const ModelHighAPI_Integer & theNumberOfObjects,
bool theFullValue)
-: SketchAPI_SketchEntity(theFeature)
+: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
fillAttribute(theObjects, translationList());
fillAttribute(thePoint1, startPoint());
fillAttribute(thePoint2, endPoint());
fillAttribute(theNumberOfObjects, numberOfObjects());
- if (theFullValue)
- fillAttribute("SingleValue", valueType());
+ fillAttribute(theFullValue ? "FullValue" : "SingleValue", valueType());
execute();
}
}
//--------------------------------------------------------------------------------------
+
+void SketchAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aSketchName = theDumper.parentName(aBase);
+
+ AttributeRefListPtr aTransObjects = translationList();
+ AttributeRefAttrPtr aStart = startPoint();
+ AttributeRefAttrPtr aEnd = endPoint();
+ AttributeIntegerPtr aNbCopies = numberOfObjects();
+ bool isFullValue = valueType()->value() != "SingleValue";
+
+ theDumper << aBase << " = " << aSketchName << ".addTranslation("
+ << aTransObjects << ", " << aStart << ", " << aEnd << ", " << aNbCopies;
+ if (isFullValue)
+ theDumper << ", " << isFullValue;
+ theDumper << ")" << std::endl;
+}
#include <SketchPlugin_MultiTranslation.h>
-#include "SketchAPI_SketchEntity.h"
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
//--------------------------------------------------------------------------------------
class ModelAPI_Object;
class ModelHighAPI_Integer;
* \ingroup CPPHighAPI
* \brief Interface for Translation feature
*/
-class SketchAPI_Translation : public SketchAPI_SketchEntity
+class SketchAPI_Translation : public ModelHighAPI_Interface
{
public:
/// Constructor without values
translatedObjects, SketchPlugin_MultiTranslation::ENTITY_B(), ModelAPI_AttributeRefList, /** Translationed objects */
)
+ /// Dump wrapped feature
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
};
//! Pointer on Translation object
return [theDir[0] / aLen, theDir[1] / aLen]
def checkMirror(theListInit, theListMirr, theMirrorLine):
- TOL = 5.e-5
+ TOL = 6.e-5
aListSize = theListInit.size()
aLineStartPoint = geomDataAPI_Point2D(theMirrorLine.attribute("StartPoint"))
BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
std::list<ConstraintWrapperPtr> aMirConstrList;
- std::vector<EntityWrapperPtr>::iterator aBIt = aBaseList.begin();
+ // update mirrored features to be in the current group
std::vector<EntityWrapperPtr>::iterator aMIt = aMirrorList.begin();
- for (; aBIt != aBaseList.end(); ++aBIt, ++aMIt) {
+ for (; aMIt != aMirrorList.end(); ++aMIt)
+ myStorage->update((*aMIt)->baseFeature(), myGroupID);
+
+ std::vector<EntityWrapperPtr>::iterator aBIt = aBaseList.begin();
+ for (aMIt = aMirrorList.begin(); aBIt != aBaseList.end(); ++aBIt, ++aMIt) {
aNewConstraints = aBuilder->createConstraint(
myBaseConstraint, myGroupID, mySketchID, aConstrType,
0.0, *aBIt, *aMIt, aMirrorLine);
aMirConstrList.insert(aMirConstrList.end(), aNewConstraints.begin(), aNewConstraints.end());
}
-
- // update mirrored features to be in the current group
- for (aMIt = aMirrorList.begin(); aMIt != aMirrorList.end(); ++aMIt)
- myStorage->update((*aMIt)->baseFeature(), myGroupID);
myStorage->addConstraint(myBaseConstraint, aMirConstrList);
adjustConstraint();