diff --git a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx index d0ded19cb5..d34865e396 100644 --- a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx +++ b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx @@ -194,6 +194,8 @@ bool DESTEP_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe (STEPControl_StepModelType)theResource->IntegerVal("write.model.type", InternalParameters.WriteModelType, aScope); + InternalParameters.CleanDuplicates = + theResource->BooleanVal("write.cleanduplicates", InternalParameters.CleanDuplicates, aScope); return DE_ShapeFixConfigurationNode::Load(theResource); } @@ -562,6 +564,13 @@ TCollection_AsciiString DESTEP_ConfigurationNode::Save() const aResult += aScope + "write.model.type :\t " + InternalParameters.WriteModelType + "\n"; aResult += "!\n"; + aResult += "!\n"; + aResult += "!Setting up a flag that indicates whether or not duplicate entities should be " + "removed from the model befor writing.\n"; + aResult += "!Default value: -. Available values: \"-\", \"+\"\n"; + aResult += aScope + "write.cleanduplicates :\t " + InternalParameters.CleanDuplicates + "\n"; + aResult += "!\n"; + aResult += DE_ShapeFixConfigurationNode::Save(); aResult += "!*****************************************************************************\n"; diff --git a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Parameters.hxx b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Parameters.hxx index 58ad9ee04d..d70a81f5ac 100644 --- a/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Parameters.hxx +++ b/src/DataExchange/TKDESTEP/DESTEP/DESTEP_Parameters.hxx @@ -200,6 +200,7 @@ public: bool WriteLayer = true; //InternalParameters.WriteLayer); aWriter.SetPropsMode(aNode->InternalParameters.WriteProps); aWriter.SetShapeFixParameters(aNode->ShapeFixParameters); + aWriter.SetCleanDuplicates(aNode->InternalParameters.CleanDuplicates); DESTEP_Parameters aParams = aNode->InternalParameters; Standard_Real aScaleFactorMM = 1.; if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument, @@ -274,6 +275,11 @@ bool DESTEP_Provider::Write(const TCollection_AsciiString& thePath, << "\t: abandon, no model loaded"; return false; } + if (aNode->InternalParameters.CleanDuplicates) + { + aWriter.CleanDuplicateEntities(); + } + if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone) { Message::SendFail() << "DESTEP_Provider: Error on writing file"; diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx index 4fe11237ca..bed470d315 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -292,6 +292,12 @@ void STEPCAFControl_Writer::Init(const Handle(XSControl_WorkSession)& theWS, IFSelect_ReturnStatus STEPCAFControl_Writer::Write(const Standard_CString theFileName) { + if (myIsCleanDuplicates) + { + // remove duplicates + myWriter.CleanDuplicateEntities(); + } + IFSelect_ReturnStatus aStatus = myWriter.Write(theFileName); if (aStatus != IFSelect_RetDone) { diff --git a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.hxx b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.hxx index bfc0933e8a..bd1f716a04 100644 --- a/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.hxx +++ b/src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.hxx @@ -226,6 +226,18 @@ public: Standard_Boolean GetMaterialMode() const { return myMatMode; } + //! Set clean duplicates flag. + //! If set to True, duplicates will be removed from the model. + //! @param theCleanDuplicates the flag to set. + void SetCleanDuplicates(const Standard_Boolean theCleanDuplicates) + { + myIsCleanDuplicates = theCleanDuplicates; + } + + //! Returns the flag indicating whether duplicates should be removed from the model. + //! @return the flag indicating whether duplicates should be removed from the model. + Standard_Boolean GetCleanDuplicates() const { return myIsCleanDuplicates; } + //! Sets parameters for shape processing. //! @param theParameters the parameters for shape processing. Standard_EXPORT void SetShapeFixParameters( @@ -382,7 +394,8 @@ private: MoniTool_DataMapOfShapeTransient myMapCompMDGPR; Standard_Boolean myGDTMode; Standard_Boolean myMatMode; - NCollection_Vector myGDTAnnotations; + Standard_Boolean myIsCleanDuplicates; + NCollection_Vector myGDTAnnotations; Handle(StepVisual_DraughtingModel) myGDTPresentationDM; Handle(StepVisual_HArray1OfPresentationStyleAssignment) myGDTPrsCurveStyle; Handle(StepRepr_ProductDefinitionShape) myGDTCommonPDS; diff --git a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx index 6484ec6ff1..f4a4938d25 100644 --- a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx +++ b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -197,6 +198,14 @@ void STEPControl_Writer::PrintStatsTransfer(const Standard_Integer what, thesession->TransferWriter()->PrintStats(what, mode); } +//================================================================================================= + +Standard_EXPORT void STEPControl_Writer::CleanDuplicateEntities() +{ + StepTidy_DuplicateCleaner aCleaner(thesession); + aCleaner.Perform(); +} + //============================================================================= void STEPControl_Writer::SetShapeFixParameters( diff --git a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.hxx b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.hxx index 81c706f651..7493daec2b 100644 --- a/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.hxx +++ b/src/DataExchange/TKDESTEP/STEPControl/STEPControl_Writer.hxx @@ -131,6 +131,8 @@ public: Standard_EXPORT void PrintStatsTransfer(const Standard_Integer what, const Standard_Integer mode = 0) const; + Standard_EXPORT void CleanDuplicateEntities(); + //! Sets parameters for shape processing. //! @param theParameters the parameters for shape processing. Standard_EXPORT void SetShapeFixParameters(