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);
174 bool process(
const std::shared_ptr<ModelAPI_Document>& theDoc,
const std::string& theFileName);
180 void setDumpDir(
const std::string& theDumpDir) { myDumpDir = theDumpDir; }
182 MODELHIGHAPI_EXPORT std::string
getDumpDir()
const {
return myDumpDir; }
197 const std::string&
name(
const EntityPtr& theEntity,
bool theSaveNotDumped =
true,
198 bool theUseEntityName =
false,
bool theSetIsDumped =
false);
202 const std::string&
parentName(
const FeaturePtr& theFeature);
207 virtual void dumpFeature(
const FeaturePtr& theFeature,
const bool theForce =
false) = 0;
214 void postpone(
const EntityPtr& theEntity);
219 { myFeaturesToSkip.insert(theFeature); }
227 const FeaturePtr& theSubFeature);
231 const std::string& theAttrName)
const = 0;
261 std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&));
264 MODELHIGHAPI_EXPORT
void newline();
327 operator<<(
const std::shared_ptr<ModelAPI_Attribute>& theAttr);
330 operator<<(
const std::shared_ptr<ModelAPI_Object>& theObject);
334 operator<<(
const std::shared_ptr<ModelAPI_AttributeRefAttr>& theRefAttr);
338 operator<<(
const std::shared_ptr<ModelAPI_AttributeRefAttrList>& theRefAttrList);
342 operator<<(
const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList);
345 operator<<(
const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect);
348 operator<<(
const std::shared_ptr<ModelAPI_AttributeSelectionList>& theAttrSelList);
351 operator<<(
const std::shared_ptr<ModelAPI_AttributeReference>& theReference);
354 operator<<(
const std::shared_ptr<ModelAPI_AttributeStringArray>& theArray);
361 bool isDumped(
const EntityPtr& theEntity)
const;
364 bool isDumped(
const std::shared_ptr<ModelAPI_AttributeRefAttr>& theRefAttr)
const;
367 bool isDumped(
const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList)
const;
378 const std::string& )
const {}
393 bool process(
const std::shared_ptr<ModelAPI_Document>& theDoc);
396 bool process(
const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
397 bool isForce =
false,
398 bool isDumpModelDo =
true);
404 bool processSubs(
const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
405 bool theDumpModelDo =
false);
408 void saveResultNames(
const FeaturePtr& theFeature);
411 bool hasColoredShape(
const ResultPtr& theResult,
bool theGetSubResults =
false)
const;
414 bool isParentResult(
const ResultPtr& theResult)
const;
417 bool isDefaultColor(
const ResultPtr& theResult)
const;
420 bool isDefaultDeflection(
const ResultPtr& theResult)
const;
423 bool isDefaultTransparency(
const ResultPtr& theResult)
const;
426 void dumpPostponed(
bool theDumpFolders =
false);
429 void dumpGlobalForMultiFile(
const FeaturePtr& theEntity);
433 std::string myCurrentName;
434 std::string myUserName;
440 EntityName(
const std::string& theCurName,
const std::string& theUserName,
bool theDefault)
441 : myCurrentName(theCurName),
442 myUserName(theUserName),
443 myIsDefault(theDefault),
447 typedef std::map<EntityPtr, EntityName> EntityNameMap;
449 struct LastDumpedEntity {
453 std::list<ResultPtr> myResults;
455 LastDumpedEntity(EntityPtr theEntity,
bool theUserName,
456 const std::list<ResultPtr>& theResults = std::list<ResultPtr>())
457 : myEntity(theEntity), myUserName(theUserName), myResults(theResults)
460 typedef std::stack<LastDumpedEntity> DumpStack;
464 class DumpStorageBuffer;
465 DumpStorageBuffer* myDumpStorage;
467 ModulesSet myModules;
468 EntityNameMap myNames;
469 DumpStack myEntitiesStack;
471 NbFeaturesMap myFeatureCount;
474 std::set<FeaturePtr> myFeaturesToSkip;
476 std::list<EntityPtr> myPostponed;
477 bool myDumpPostponedInProgress;
479 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:53
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:41
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:37
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:1778
void setDumpDir(const std::string &theDumpDir)
Keep path to the true dumping directory.
Definition: ModelHighAPI_Dumper.h:180
void importModule(const std::string &theModuleName)
Add module to list of imported modules.
Definition: ModelHighAPI_Dumper.cpp:952
void setIsMultiDump(const bool theValue)
Sets multifile flag value.
Definition: ModelHighAPI_Dumper.cpp:441
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:544
const std::string & parentName(const FeaturePtr &theFeature)
Returns name of parent composite feature for specified entity.
Definition: ModelHighAPI_Dumper.cpp:672
virtual ~ModelHighAPI_Dumper()
Destructor.
Definition: ModelHighAPI_Dumper.cpp:528
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:562
void doNotDumpFeature(const FeaturePtr &theFeature)
Set a feature that should not be dumped anyway.
Definition: ModelHighAPI_Dumper.h:218
bool process(const std::shared_ptr< ModelAPI_Document > &theDoc, const std::string &theFileName)
Dump given document into the file.
Definition: ModelHighAPI_Dumper.cpp:705
void postpone(const EntityPtr &theEntity)
Set feature postponed until all its dependencies are not dumped.
Definition: ModelHighAPI_Dumper.cpp:886
void dumpSubFeatureNameAndColor(const std::string theSubFeatureGet, const FeaturePtr &theSubFeature)
Dump sub-feature name and color, without dumping feature creation.
Definition: ModelHighAPI_Dumper.cpp:929
bool isDumped(const EntityPtr &theEntity) const
Check the entity is already dumped.
Definition: ModelHighAPI_Dumper.cpp:1040
virtual void dumpFolder(const FolderPtr &theFolder)=0
Dump folder.
static ModelHighAPI_Dumper * getInstance()
Returns instance of a dumper.
Definition: ModelHighAPI_Dumper.cpp:539
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:1070
void clearCustomStorage()
Clear custom storages list.
Definition: ModelHighAPI_Dumper.cpp:549
ModelHighAPI_Dumper & operator<<(const char theChar)
Dump character.
Definition: ModelHighAPI_Dumper.cpp:1182
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:579
std::string getDumpDir() const
Return path to the true dumping directory.
Definition: ModelHighAPI_Dumper.h:182
void dumpEntitySetName()
Dump "setName" command if last entity had user-defined name.
Definition: ModelHighAPI_Dumper.cpp:957
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:1172
static void setInstance(ModelHighAPI_Dumper *theDumper)
Sets instance of a dumper.
Definition: ModelHighAPI_Dumper.cpp:533
ModelHighAPI_Dumper()
Default constructor.
Definition: ModelHighAPI_Dumper.cpp:521
std::set< EntityPtr > myNotDumpedEntities
list of entities, used by other features but not dumped yet
Definition: ModelHighAPI_Dumper.h:484
void newline()
Print std::endl from Python.
Definition: ModelHighAPI_Dumper.cpp:1704
virtual void exportVariable(const std::string &, const std::string &) const
Export one variable name to another module (implemented in python)
Definition: ModelHighAPI_Dumper.h:377
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:71