#include "FeaturesAPI_RevolutionBoolean.h"
#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Reference.h>
#include <ModelHighAPI_Tools.h>
//==================================================================================================
{
}
+//==================================================================================================
+void FeaturesAPI_RevolutionBoolean::setNestedSketch(const ModelHighAPI_Reference& theSketch)
+{
+ mysketch->setValue(theSketch.feature());
+ mybaseObjects->clear();
+ mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr());
+
+ execIfBaseNotEmpty();
+}
+
//==================================================================================================
void FeaturesAPI_RevolutionBoolean::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
{
+ mysketch->setValue(ObjectPtr());
+ mybaseObjects->clear();
fillAttribute(theBaseObjects, mybaseObjects);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
{
fillAttribute(theAxis, myaxis);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theToAngle, mytoAngle);
fillAttribute(theFromAngle, myfromAngle);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theAngle, mytoAngle);
fillAttribute(ModelHighAPI_Double(), myfromAngle);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theFromObject, myfromObject);
fillAttribute(theFromOffset, myfromOffset);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
{
fillAttribute(theBooleanObjects, mybooleanObjects);
- execute();
+ execIfBaseNotEmpty();
+}
+
+//==================================================================================================
+void FeaturesAPI_RevolutionBoolean::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_Revolution::SKETCH_ID());
+ AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Revolution::BASE_OBJECTS_ID());
+ AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Revolution::AXIS_OBJECT_ID());
+
+ theDumper << aBase << " = model.addRevolution";
+ if(aBase->getKind() == FeaturesPlugin_RevolutionCut::ID()) {
+ theDumper << "Cut";
+ } else if(aBase->getKind() == FeaturesPlugin_RevolutionFuse::ID()) {
+ theDumper << "Fuse";
+ }
+ theDumper << "(" << aDocName << ", ";
+ anAttrSketch->isInitialized() ? theDumper << "[]" : theDumper << anAttrObjects;
+ theDumper << ", " << anAttrAxis;
+
+ std::string aCreationMethod = aBase->string(FeaturesPlugin_Revolution::CREATION_METHOD())->value();
+
+ if(aCreationMethod == FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES()) {
+ AttributeDoublePtr anAttrToAngle = aBase->real(FeaturesPlugin_Revolution::TO_ANGLE_ID());
+ AttributeDoublePtr anAttrFromAngle = aBase->real(FeaturesPlugin_Revolution::FROM_ANGLE_ID());
+
+ theDumper << ", " << anAttrToAngle << ", " << anAttrFromAngle;
+ } else if(aCreationMethod == FeaturesPlugin_Revolution::CREATION_METHOD_BY_PLANES()) {
+ AttributeSelectionPtr anAttrToObject = aBase->selection(FeaturesPlugin_Revolution::TO_OBJECT_ID());
+ AttributeDoublePtr anAttrToOffset = aBase->real(FeaturesPlugin_Revolution::TO_OFFSET_ID());
+ AttributeSelectionPtr anAttrFromObject = aBase->selection(FeaturesPlugin_Revolution::FROM_OBJECT_ID());
+ AttributeDoublePtr anAttrFromOffset = aBase->real(FeaturesPlugin_Revolution::FROM_OFFSET_ID());
+
+ theDumper << ", " << anAttrToObject << ", " << anAttrToOffset << ", " << anAttrFromObject << ", " << anAttrFromOffset;
+ }
+
+ AttributeSelectionListPtr anAttrBoolObjects = aBase->selectionList(FeaturesPlugin_CompositeBoolean::OBJECTS_ID());
+ theDumper << ", " << anAttrBoolObjects << ")" << std::endl;
+
+ if(anAttrSketch->isInitialized()) {
+ theDumper << aBase << ".setNestedSketch(" << anAttrSketch << ")" << std::endl;
+ }
+}
+
+//==================================================================================================
+void FeaturesAPI_RevolutionBoolean::execIfBaseNotEmpty()
+{
+ if(mybaseObjects->size() > 0) {
+ execute();
+ }
}
//==================================================================================================
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
fillAttribute(theSize, mytoAngle);
fillAttribute(ModelHighAPI_Double(), myfromAngle);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
fillAttribute(theToAngle, mytoAngle);
fillAttribute(theFromAngle, myfromAngle);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_PLANES(), mycreationMethod);
fillAttribute(theToObject, mytoObject);
fillAttribute(theToOffset, mytoOffset);
fillAttribute(theFromObject, myfromObject);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
fillAttribute(theSize, mytoAngle);
fillAttribute(ModelHighAPI_Double(), myfromAngle);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
fillAttribute(theToAngle, mytoAngle);
fillAttribute(theFromAngle, myfromAngle);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theAxis, myaxis);
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_PLANES(), mycreationMethod);
fillAttribute(theToObject, mytoObject);
fillAttribute(theToOffset, mytoOffset);
fillAttribute(theFromObject, myfromObject);
#include <ModelHighAPI_Macro.h>
class ModelHighAPI_Double;
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Reference;
class ModelHighAPI_Selection;
/// \class FeaturesAPI_RevolutionBoolean
virtual ~FeaturesAPI_RevolutionBoolean();
INTERFACE_11("",
- sketchLauncher, FeaturesPlugin_Revolution::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */,
+ sketch, FeaturesPlugin_Revolution::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */,
baseObjects, FeaturesPlugin_Revolution::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */,
axis, FeaturesPlugin_Revolution::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection, /** Axis */,
creationMethod, FeaturesPlugin_Revolution::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
fromOffset, FeaturesPlugin_Revolution::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */,
booleanObjects, FeaturesPlugin_CompositeBoolean::OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Boolean objects */)
+ /// Modify base attribute of the feature.
+ FEATURESAPI_EXPORT
+ void setNestedSketch(const ModelHighAPI_Reference& theSketch);
+
/// Modify base attribute of the feature.
FEATURESAPI_EXPORT
void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
FEATURESAPI_EXPORT
void setBooleanObjects(const std::list<ModelHighAPI_Selection>& theBooleanObjects);
+ /// Dump wrapped feature
+ FEATURESAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+
protected:
/// Constructor without values.
FEATURESAPI_EXPORT
explicit FeaturesAPI_RevolutionBoolean(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+private:
+ void execIfBaseNotEmpty();
};
class FeaturesAPI_RevolutionCut: public FeaturesAPI_RevolutionBoolean
{
public:
- FEATURESAPI_EXPORT
- virtual std::string getID() {
- return FeaturesPlugin_RevolutionCut::ID();
- }
+
+ static std::string ID() { return FeaturesPlugin_RevolutionCut::ID(); }
+ virtual std::string getID() { return ID(); }
/// Constructor without values.
FEATURESAPI_EXPORT
class FeaturesAPI_RevolutionFuse: public FeaturesAPI_RevolutionBoolean
{
public:
- FEATURESAPI_EXPORT
- virtual std::string getID() {
- return FeaturesPlugin_RevolutionFuse::ID();
- }
+
+ static std::string ID() { return FeaturesPlugin_RevolutionFuse::ID(); }
+ virtual std::string getID() { return ID(); }
/// Constructor without values.
FEATURESAPI_EXPORT