20 #ifndef ModelHighAPI_Dumper_H_
21 #define ModelHighAPI_Dumper_H_
23 #include "ModelHighAPI.h"
63 typedef std::shared_ptr<ModelAPI_Document> DocumentPtr;
64 typedef std::shared_ptr<ModelAPI_Entity> EntityPtr;
65 typedef std::shared_ptr<ModelAPI_Feature> FeaturePtr;
66 typedef std::shared_ptr<ModelAPI_Folder> FolderPtr;
67 typedef std::shared_ptr<ModelAPI_Result> ResultPtr;
69 typedef std::set<std::string> ModulesSet;
70 typedef std::map<DocumentPtr, std::map<std::string, std::pair<int, int> > > NbFeaturesMap;
96 void setFilenameSuffix(
const std::string& theSuffix) { myFilenameSuffix = theSuffix; }
99 std::ostringstream& buffer() {
return myDumpBuffer; }
100 std::ostringstream& fullDump() {
return myFullDump; }
102 MODELHIGHAPI_EXPORT
virtual void reserveBuffer();
103 MODELHIGHAPI_EXPORT
virtual void restoreReservedBuffer();
106 virtual void write(
const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect);
109 virtual bool exportTo(
const std::string& theFilename,
const ModulesSet& theUsedModules);
112 std::string myFilenameSuffix;
113 std::ostringstream myDumpBuffer;
114 std::ostringstream myFullDump;
116 std::stack<std::string> myDumpBufferHideout;
120 typedef std::shared_ptr<DumpStorage> DumpStoragePtr;
130 virtual void write(
const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect);
141 virtual void write(
const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect);
170 bool process(
const std::shared_ptr<ModelAPI_Document>& theDoc,
const std::string& theFileName);
176 void setDumpDir(
const std::string& theDumpDir) { myDumpDir = theDumpDir; }
178 MODELHIGHAPI_EXPORT std::string
getDumpDir()
const {
return myDumpDir; }
193 const std::string&
name(
const EntityPtr& theEntity,
bool theSaveNotDumped =
true,
194 bool theUseEntityName =
false,
bool theSetIsDumped =
false);
198 const std::string&
parentName(
const FeaturePtr& theFeature);
203 virtual void dumpFeature(
const FeaturePtr& theFeature,
const bool theForce =
false) = 0;
210 void postpone(
const EntityPtr& theEntity);
215 { myFeaturesToSkip.insert(theFeature); }
223 const FeaturePtr& theSubFeature);
227 const std::string& theAttrName)
const = 0;
257 std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&));
260 MODELHIGHAPI_EXPORT
void newline();
323 operator<<(
const std::shared_ptr<ModelAPI_Attribute>& theAttr);
326 operator<<(
const std::shared_ptr<ModelAPI_Object>& theObject);
330 operator<<(
const std::shared_ptr<ModelAPI_AttributeRefAttr>& theRefAttr);
334 operator<<(
const std::shared_ptr<ModelAPI_AttributeRefAttrList>& theRefAttrList);
338 operator<<(
const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList);
341 operator<<(
const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect);
344 operator<<(
const std::shared_ptr<ModelAPI_AttributeSelectionList>& theAttrSelList);
347 operator<<(
const std::shared_ptr<ModelAPI_AttributeReference>& theReference);
350 operator<<(
const std::shared_ptr<ModelAPI_AttributeStringArray>& theArray);
357 bool isDumped(
const EntityPtr& theEntity)
const;
360 bool isDumped(
const std::shared_ptr<ModelAPI_AttributeRefAttr>& theRefAttr)
const;
363 bool isDumped(
const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList)
const;
374 const std::string& )
const {}
389 bool process(
const std::shared_ptr<ModelAPI_Document>& theDoc);
392 bool process(
const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
393 bool isForce =
false,
394 bool isDumpModelDo =
true);
400 bool processSubs(
const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
401 bool theDumpModelDo =
false);
404 void saveResultNames(
const FeaturePtr& theFeature);
407 bool isDefaultColor(
const ResultPtr& theResult)
const;
410 bool isDefaultDeflection(
const ResultPtr& theResult)
const;
413 bool isDefaultTransparency(
const ResultPtr& theResult)
const;
416 void dumpPostponed(
bool theDumpFolders =
false);
420 std::string myCurrentName;
421 std::string myUserName;
427 EntityName(
const std::string& theCurName,
const std::string& theUserName,
bool theDefault)
428 : myCurrentName(theCurName),
429 myUserName(theUserName),
430 myIsDefault(theDefault),
434 typedef std::map<EntityPtr, EntityName> EntityNameMap;
436 struct LastDumpedEntity {
440 std::list<ResultPtr> myResults;
442 LastDumpedEntity(EntityPtr theEntity,
bool theUserName,
443 const std::list<ResultPtr>& theResults = std::list<ResultPtr>())
444 : myEntity(theEntity), myUserName(theUserName), myResults(theResults)
447 typedef std::stack<LastDumpedEntity> DumpStack;
451 class DumpStorageBuffer;
452 DumpStorageBuffer* myDumpStorage;
454 ModulesSet myModules;
455 EntityNameMap myNames;
456 DumpStack myEntitiesStack;
458 NbFeaturesMap myFeatureCount;
461 std::set<FeaturePtr> myFeaturesToSkip;
463 std::list<EntityPtr> myPostponed;
464 bool myDumpPostponedInProgress;
466 std::string myDumpDir;
3D direction defined by three normalized coordinates
Definition: GeomAPI_Dir.h:34
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
Attribute that contains 3D direction coordinates.
Definition: GeomDataAPI_Dir.h:35
Attribute that contains array of 2D point coordinates.
Definition: GeomDataAPI_Point2DArray.h:34
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
Attribute that contains 3D point coordinates.
Definition: GeomDataAPI_Point.h:36
Attribute that contains boolean value.
Definition: ModelAPI_AttributeBoolean.h:31
API for the attribute that contains several double in the array inside.
Definition: ModelAPI_AttributeDoubleArray.h:32
Attribute that contains real value with double precision.
Definition: ModelAPI_AttributeDouble.h:34
API for the attribute that contains several integers in the array inside.
Definition: ModelAPI_AttributeIntArray.h:36
API for the attribute that contains integer (int).
Definition: ModelAPI_AttributeInteger.h:34
Attribute that contains list of references to features (located in the same document) or references t...
Definition: ModelAPI_AttributeRefAttrList.h:34
Attribute that contains reference to an attribute of a feature or reference to a feature (switchable)
Definition: ModelAPI_AttributeRefAttr.h:33
Attribute that contains list of references to features (located in the same document).
Definition: ModelAPI_AttributeRefList.h:33
Attribute that contains reference to feature (located in the same document).
Definition: ModelAPI_AttributeReference.h:32
Attribute that contains list of references to the sub-shapes with possibility to manage them.
Definition: ModelAPI_AttributeSelectionList.h:37
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: ModelAPI_AttributeSelection.h:35
API for the attribute that contains several strings in the array inside.
Definition: ModelAPI_AttributeStringArray.h:32
API for the attribute that contains std (null terminated) string.
Definition: ModelAPI_AttributeString.h:33
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
Feature that consists of other features: like sketcher with edges inside.
Definition: ModelAPI_CompositeFeature.h:33
Document for internal data structure of any object storage.
Definition: ModelAPI_Document.h:52
Represents a common parent class for Objects and documents.
Definition: ModelAPI_Entity.h:32
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
Folder feature (groups the features).
Definition: ModelAPI_Folder.h:31
Represents any object in the data model and in the object browser.
Definition: ModelAPI_Object.h:45
The result of a feature.
Definition: ModelAPI_Result.h:35
Process selection attributes to be dumped by geometric properties.
Definition: ModelHighAPI_Dumper.h:127
Process selection attributes to be dumped by weak naming.
Definition: ModelHighAPI_Dumper.h:138
Storage for the dumped data.
Definition: ModelHighAPI_Dumper.h:88
Dump engine for the model.
Definition: ModelHighAPI_Dumper.h:81
virtual void exportVariables() const
Export variables names to another module (calls exportVariable implemented in python)
Definition: ModelHighAPI_Dumper.cpp:1684
void setDumpDir(const std::string &theDumpDir)
Keep path to the true dumping directory.
Definition: ModelHighAPI_Dumper.h:176
void importModule(const std::string &theModuleName)
Add module to list of imported modules.
Definition: ModelHighAPI_Dumper.cpp:895
virtual std::string attributeGetter(const FeaturePtr &theFeature, const std::string &theAttrName) const =0
Return name of getter for corresponding attribute.
void addCustomStorage(const DumpStoragePtr &theStorage)
Add custom storage to collect corresponding dump.
Definition: ModelHighAPI_Dumper.cpp:538
const std::string & parentName(const FeaturePtr &theFeature)
Returns name of parent composite feature for specified entity.
Definition: ModelHighAPI_Dumper.cpp:666
virtual ~ModelHighAPI_Dumper()
Destructor.
Definition: ModelHighAPI_Dumper.cpp:522
virtual void dumpFeature(const FeaturePtr &theFeature, const bool theForce=false)=0
Dump given feature.
void clearNotDumped()
clear list of not dumped entities
Definition: ModelHighAPI_Dumper.cpp:556
void doNotDumpFeature(const FeaturePtr &theFeature)
Set a feature that should not be dumped anyway.
Definition: ModelHighAPI_Dumper.h:214
bool process(const std::shared_ptr< ModelAPI_Document > &theDoc, const std::string &theFileName)
Dump given document into the file.
Definition: ModelHighAPI_Dumper.cpp:699
void postpone(const EntityPtr &theEntity)
Set feature postponed until all its dependencies are not dumped.
Definition: ModelHighAPI_Dumper.cpp:835
void dumpSubFeatureNameAndColor(const std::string theSubFeatureGet, const FeaturePtr &theSubFeature)
Dump sub-feature name and color, without dumping feature creation.
Definition: ModelHighAPI_Dumper.cpp:872
bool isDumped(const EntityPtr &theEntity) const
Check the entity is already dumped.
Definition: ModelHighAPI_Dumper.cpp:965
virtual void dumpFolder(const FolderPtr &theFolder)=0
Dump folder.
static ModelHighAPI_Dumper * getInstance()
Returns instance of a dumper.
Definition: ModelHighAPI_Dumper.cpp:533
virtual void dumpParameter(const FeaturePtr &theFeature)=0
Dump parameter feature only.
size_t indexOfFirstNotDumped(const std::shared_ptr< ModelAPI_AttributeRefList > &theRefList) const
Returns the index of the first object in the list which is not dumped yet.
Definition: ModelHighAPI_Dumper.cpp:995
void clearCustomStorage()
Clear custom storages list.
Definition: ModelHighAPI_Dumper.cpp:543
ModelHighAPI_Dumper & operator<<(const char theChar)
Dump character.
Definition: ModelHighAPI_Dumper.cpp:1089
const std::string & name(const EntityPtr &theEntity, bool theSaveNotDumped=true, bool theUseEntityName=false, bool theSetIsDumped=false)
Returns name of specified entity.
Definition: ModelHighAPI_Dumper.cpp:573
std::string getDumpDir() const
Return path to the true dumping directory.
Definition: ModelHighAPI_Dumper.h:178
void dumpEntitySetName()
Dump "setName" command if last entity had user-defined name.
Definition: ModelHighAPI_Dumper.cpp:900
bool dumpCommentBeforeFeature(const FeaturePtr &theFeature) const
Returns true if the special comment line to improve the readability should be printed before the feat...
Definition: ModelHighAPI_Dumper.cpp:1079
static void setInstance(ModelHighAPI_Dumper *theDumper)
Sets instance of a dumper.
Definition: ModelHighAPI_Dumper.cpp:527
ModelHighAPI_Dumper()
Default constructor.
Definition: ModelHighAPI_Dumper.cpp:516
std::set< EntityPtr > myNotDumpedEntities
list of entities, used by other features but not dumped yet
Definition: ModelHighAPI_Dumper.h:470
void newline()
Print std::endl from Python.
Definition: ModelHighAPI_Dumper.cpp:1610
virtual void exportVariable(const std::string &, const std::string &) const
Export one variable name to another module (implemented in python)
Definition: ModelHighAPI_Dumper.h:373
virtual std::string featureWrapper(const FeaturePtr &theFeature) const =0
Return name of wrapper feature.
Class for filling ModelAPI_Folder.
Definition: ModelHighAPI_Folder.h:39
Interface for Sketch feature.
Definition: SketchAPI_Sketch.h:70