#ifndef _DE_ShapeFixParameters_HeaderFile
#define _DE_ShapeFixParameters_HeaderFile
+#include <Standard_Macro.hxx>
#include <TopAbs_ShapeEnum.hxx>
//! Struct for shape healing parameters storage
double Tolerance3d = 1.e-6;
double MaxTolerance3d = 1.0;
double MinTolerance3d = 1.e-7;
- TopAbs_ShapeEnum DetalizationLevel = TopAbs_ShapeEnum::TopAbs_FACE;
+ TopAbs_ShapeEnum DetalizationLevel = TopAbs_ShapeEnum::TopAbs_VERTEX;
bool NonManifold = false;
FixMode FixFreeShellMode = FixMode::FixOrNot;
FixMode FixFreeFaceMode = FixMode::FixOrNot;
DE_PluginHolder.hxx
DE_Provider.cxx
DE_Provider.hxx
-DE_ShapeFixConfigurationNode.cxx
DE_ShapeFixConfigurationNode.hxx
DE_ShapeFixParameters.hxx
+DE_ShapeFixParameters.cxx
DE_Wrapper.cxx
DE_Wrapper.hxx
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.ReadBSplineContinuity =
- (ReadMode_BSplineContinuity)theResource->IntegerVal("read.iges.bspline.continuity",
- InternalParameters.ReadBSplineContinuity,
- aScope);
+ (DEIGES_Parameters::ReadMode_BSplineContinuity)theResource->IntegerVal(
+ "read.iges.bspline.continuity",
+ InternalParameters.ReadBSplineContinuity,
+ aScope);
InternalParameters.ReadPrecisionMode =
- (ReadMode_Precision)theResource->IntegerVal("read.precision.mode",
- InternalParameters.ReadPrecisionMode,
- aScope);
+ (DEIGES_Parameters::ReadMode_Precision)
+ theResource->IntegerVal("read.precision.mode", InternalParameters.ReadPrecisionMode, aScope);
InternalParameters.ReadPrecisionVal =
theResource->RealVal("read.precision.val", InternalParameters.ReadPrecisionVal, aScope);
InternalParameters.ReadMaxPrecisionMode =
- (ReadMode_MaxPrecision)theResource->IntegerVal("read.maxprecision.mode",
- InternalParameters.ReadMaxPrecisionMode,
- aScope);
+ (DEIGES_Parameters::ReadMode_MaxPrecision)theResource->IntegerVal(
+ "read.maxprecision.mode",
+ InternalParameters.ReadMaxPrecisionMode,
+ aScope);
InternalParameters.ReadMaxPrecisionVal =
theResource->RealVal("read.maxprecision.val", InternalParameters.ReadMaxPrecisionVal, aScope);
InternalParameters.ReadSameParamMode =
InternalParameters.ReadSameParamMode,
aScope);
InternalParameters.ReadSurfaceCurveMode =
- (ReadMode_SurfaceCurve)theResource->IntegerVal("read.surfacecurve.mode",
- InternalParameters.ReadSurfaceCurveMode,
- aScope);
+ (DEIGES_Parameters::ReadMode_SurfaceCurve)theResource->IntegerVal(
+ "read.surfacecurve.mode",
+ InternalParameters.ReadSurfaceCurveMode,
+ aScope);
InternalParameters.EncodeRegAngle =
theResource->RealVal("read.encoderegularity.angle", InternalParameters.EncodeRegAngle, aScope);
theResource->BooleanVal("read.layer", InternalParameters.ReadLayer, aScope);
InternalParameters.WriteBRepMode =
- (WriteMode_BRep)theResource->IntegerVal("write.brep.mode",
- InternalParameters.WriteBRepMode,
- aScope);
+ (DEIGES_Parameters::WriteMode_BRep)theResource->IntegerVal("write.brep.mode",
+ InternalParameters.WriteBRepMode,
+ aScope);
InternalParameters.WriteConvertSurfaceMode =
- (WriteMode_ConvertSurface)theResource->IntegerVal("write.convertsurface.mode",
- InternalParameters.WriteConvertSurfaceMode,
- aScope);
+ (DEIGES_Parameters::WriteMode_ConvertSurface)theResource->IntegerVal(
+ "write.convertsurface.mode",
+ InternalParameters.WriteConvertSurfaceMode,
+ aScope);
InternalParameters.WriteHeaderAuthor =
theResource->StringVal("write.header.author", InternalParameters.WriteHeaderAuthor, aScope);
InternalParameters.WriteHeaderCompany =
InternalParameters.WriteSequence =
theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
InternalParameters.WritePrecisionMode =
- (WriteMode_PrecisionMode)theResource->IntegerVal("write.precision.mode",
- InternalParameters.WritePrecisionMode,
- aScope);
+ (DEIGES_Parameters::WriteMode_PrecisionMode)theResource->IntegerVal(
+ "write.precision.mode",
+ InternalParameters.WritePrecisionMode,
+ aScope);
InternalParameters.WritePrecisionVal =
theResource->RealVal("write.precision.val", InternalParameters.WritePrecisionVal, aScope);
InternalParameters.WritePlaneMode =
- (WriteMode_PlaneMode)theResource->IntegerVal("write.plane.mode",
- InternalParameters.WritePlaneMode,
- aScope);
+ (DEIGES_Parameters::WriteMode_PlaneMode)
+ theResource->IntegerVal("write.plane.mode", InternalParameters.WritePlaneMode, aScope);
InternalParameters.WriteOffsetMode =
theResource->BooleanVal("write.offset", InternalParameters.WriteOffsetMode, aScope);
InternalParameters.WriteColor =
#ifndef _DEIGES_ConfigurationNode_HeaderFile
#define _DEIGES_ConfigurationNode_HeaderFile
+#include <DEIGES_Parameters.hxx>
#include <DE_ConfigurationNode.hxx>
#include <UnitsMethods_LengthUnit.hxx>
Standard_OVERRIDE;
public:
- enum ReadMode_BSplineContinuity
- {
- ReadMode_BSplineContinuity_C0 = 0,
- ReadMode_BSplineContinuity_C1,
- ReadMode_BSplineContinuity_C2
- };
-
- enum ReadMode_Precision
- {
- ReadMode_Precision_File = 0,
- ReadMode_Precision_User
- };
-
- enum ReadMode_MaxPrecision
- {
- ReadMode_MaxPrecision_Preferred = 0,
- ReadMode_MaxPrecision_Forced
- };
-
- enum ReadMode_SurfaceCurve
- {
- ReadMode_SurfaceCurve_Default = 0,
- ReadMode_SurfaceCurve_2DUse_Preferred = 2,
- ReadMode_SurfaceCurve_2DUse_Forced = -2,
- ReadMode_SurfaceCurve_3DUse_Preferred = 3,
- ReadMode_SurfaceCurve_3DUse_Forced = -3
- };
-
- enum WriteMode_BRep
- {
- WriteMode_BRep_Faces = 0,
- WriteMode_BRep_BRep
- };
-
- enum WriteMode_ConvertSurface
- {
- WriteMode_ConvertSurface_Off = 0,
- WriteMode_ConvertSurface_On
- };
-
- enum WriteMode_PrecisionMode
- {
- WriteMode_PrecisionMode_Least = -1,
- WriteMode_PrecisionMode_Average = 0,
- WriteMode_PrecisionMode_Greatest = 1,
- WriteMode_PrecisionMode_Session = 2
- };
-
- enum WriteMode_PlaneMode
- {
- WriteMode_PlaneMode_Plane = 0,
- WriteMode_PlaneMode_BSpline
- };
-
- struct IGESCAFControl_InternalSection
- {
- // Common
- // clang-format off
- ReadMode_BSplineContinuity ReadBSplineContinuity = ReadMode_BSplineContinuity_C1; //<! Manages the continuity of BSpline curves
- ReadMode_Precision ReadPrecisionMode = ReadMode_Precision_File; //<! Reads the precision mode value
- double ReadPrecisionVal = 0.0001; //<! ReadMode_Precision for shape construction (if enabled user mode)
- ReadMode_MaxPrecision ReadMaxPrecisionMode = ReadMode_MaxPrecision_Preferred; //<! Defines the mode of applying the maximum allowed tolerance
- double ReadMaxPrecisionVal = 1; //<! Defines the maximum allowable tolerance
- bool ReadSameParamMode = false; //<! Defines the using of BRepLib::SameParameter
- ReadMode_SurfaceCurve ReadSurfaceCurveMode = ReadMode_SurfaceCurve_Default; //<! reference for the computation of curves in case of 2D/3D
- double EncodeRegAngle = 0.57295779513; //<! Continuity which these two faces are connected with at that edge
-
- //Read
- bool ReadApproxd1 = false; //<! Flag to split bspline curves of degree 1
- TCollection_AsciiString ReadResourceName = "IGES"; //<! Defines the name of the resource file to read
- TCollection_AsciiString ReadSequence = "FromIGES"; //<! Defines the name of the sequence of operators to read
- bool ReadFaultyEntities = false; //<! Parameter for reading failed entities
- bool ReadOnlyVisible = false; //<! Parameter for reading invisible entities
- bool ReadColor = true; //<! ColorMode is used to indicate read Colors or not
- bool ReadName = true; //<! NameMode is used to indicate read Name or not
- bool ReadLayer = true; //<! LayerMode is used to indicate read Layers or not
-
- // Write
- WriteMode_BRep WriteBRepMode = WriteMode_BRep_Faces; //<! Flag to define entities type to write
- WriteMode_ConvertSurface WriteConvertSurfaceMode = WriteMode_ConvertSurface_Off; //<! Flag to convert surface to elementary
- TCollection_AsciiString WriteHeaderAuthor; //<! Name of the author of the file
- TCollection_AsciiString WriteHeaderCompany; //<! Name of the sending company
- TCollection_AsciiString WriteHeaderProduct; //<! Name of the sending product
- TCollection_AsciiString WriteHeaderReciever; //<! Name of the receiving company
- TCollection_AsciiString WriteResourceName = "IGES"; //<! Defines the name of the resource file to write
- TCollection_AsciiString WriteSequence = "ToIGES"; //<! Defines the name of the sequence of operators to write
- WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the IGES file
- double WritePrecisionVal = 0.0001; //<! Resolution value for an IGES file when WriteMode_PrecisionMode is Greatest
- WriteMode_PlaneMode WritePlaneMode = WriteMode_PlaneMode_Plane; //<! Flag to convert plane to the BSline
- // clang-format on
- bool WriteOffsetMode = false; //<! Writing offset curves like BSplines
- bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not
- bool WriteName = true; //<! NameMode is used to indicate write Name or not
- bool WriteLayer = true; //<! LayerMode is used to indicate write Layers or not
- } InternalParameters;
+ DEIGES_Parameters InternalParameters;
};
#endif // _DEIGES_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2023 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Interface_Static.hxx>
+
+#include <DEIGES_Parameters.hxx>
+
+//=================================================================================================
+
+void DEIGES_Parameters::InitFromStatic()
+{
+ ReadBSplineContinuity = (ReadMode_BSplineContinuity)Interface_Static::IVal(
+ "read.iges.bspline.continuity");
+ ReadPrecisionMode =
+ (ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
+ ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
+ ReadMaxPrecisionMode =
+ (ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
+ ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
+ ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
+ ReadSurfaceCurveMode = (ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
+ EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle");
+
+ ReadApproxd1 = Interface_Static::IVal("read.bspline.approxd1.mode") == 1;
+ ReadResourceName = Interface_Static::CVal("read.resource.name");
+ ReadSequence = Interface_Static::CVal("read.sequence");
+ ReadFaultyEntities = Interface_Static::IVal("read.fau_lty.entities") == 1;
+ ReadOnlyVisible = Interface_Static::IVal("read.onlyvisible") == 1;
+ ReadColor = Interface_Static::IVal("read.color") == 1;
+ ReadName = Interface_Static::IVal("read.name") == 1;
+ ReadLayer = Interface_Static::IVal("read.layer") == 1;
+
+ WriteBRepMode = (WriteMode_BRep)Interface_Static::IVal("write.brep.mode");
+ WriteConvertSurfaceMode = (WriteMode_ConvertSurface)Interface_Static::IVal(
+ "write.convertsurface.mode");
+ WriteHeaderAuthor = Interface_Static::CVal("write.header.author");
+ WriteHeaderCompany = Interface_Static::CVal("write.header.company");
+ WriteHeaderProduct = Interface_Static::CVal("write.header.product");
+ WriteHeaderReciever = Interface_Static::CVal("write.header.receiver");
+ WriteResourceName = Interface_Static::CVal("write.resource.name");
+ WriteSequence = Interface_Static::CVal("write.sequence");
+ WritePrecisionMode =
+ (WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
+ WritePrecisionVal = Interface_Static::RVal("write.precision.val");
+ WritePlaneMode =
+ (WriteMode_PlaneMode)Interface_Static::IVal("write.plane.mode");
+ WriteOffsetMode = Interface_Static::IVal("write.offset") == 1;
+ WriteColor = Interface_Static::IVal("write.color") == 1;
+ WriteName = Interface_Static::IVal("write.name") == 1;
+ WriteLayer = Interface_Static::IVal("write.layer") == 1;
+}
+
+//=================================================================================================
+
+void DEIGES_Parameters::Reset()
+{
+ *this = DEIGES_Parameters();
+}
+
+//=================================================================================================
+
+DE_ShapeFixParameters DEIGES_Parameters::GetDefaultReadingParamsIGES()
+{
+ DE_ShapeFixParameters aShapeFixParameters;
+ aShapeFixParameters.DetalizationLevel = TopAbs_EDGE;
+ aShapeFixParameters.CreateOpenSolidMode = DE_ShapeFixParameters::FixMode::Fix;
+ aShapeFixParameters.FixTailMode = DE_ShapeFixParameters::FixMode::FixOrNot;
+ aShapeFixParameters.MaxTailAngle = DE_ShapeFixParameters::FixMode::FixOrNot;
+ return aShapeFixParameters;
+}
+
+//=================================================================================================
+
+DE_ShapeFixParameters DEIGES_Parameters::GetDefaultWritingParamsIGES()
+{
+ DE_ShapeFixParameters aShapeFixParameters;
+ aShapeFixParameters.DetalizationLevel = TopAbs_EDGE;
+ aShapeFixParameters.CreateOpenSolidMode = DE_ShapeFixParameters::FixMode::Fix;
+ aShapeFixParameters.FixTailMode = DE_ShapeFixParameters::FixMode::FixOrNot;
+ aShapeFixParameters.MaxTailAngle = DE_ShapeFixParameters::FixMode::FixOrNot;
+ return aShapeFixParameters;
+}
--- /dev/null
+// Copyright (c) 2023 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEIGES_Parameters_HeaderFile
+#define _DEIGES_Parameters_HeaderFile
+
+#include <DE_ShapeFixParameters.hxx>
+#include <Resource_FormatType.hxx>
+#include <STEPControl_StepModelType.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <UnitsMethods_LengthUnit.hxx>
+
+class DEIGES_Parameters
+{
+public:
+ enum ReadMode_BSplineContinuity
+ {
+ ReadMode_BSplineContinuity_C0 = 0,
+ ReadMode_BSplineContinuity_C1,
+ ReadMode_BSplineContinuity_C2
+ };
+
+ enum ReadMode_Precision
+ {
+ ReadMode_Precision_File = 0,
+ ReadMode_Precision_User
+ };
+
+ enum ReadMode_MaxPrecision
+ {
+ ReadMode_MaxPrecision_Preferred = 0,
+ ReadMode_MaxPrecision_Forced
+ };
+
+ enum ReadMode_SurfaceCurve
+ {
+ ReadMode_SurfaceCurve_Default = 0,
+ ReadMode_SurfaceCurve_2DUse_Preferred = 2,
+ ReadMode_SurfaceCurve_2DUse_Forced = -2,
+ ReadMode_SurfaceCurve_3DUse_Preferred = 3,
+ ReadMode_SurfaceCurve_3DUse_Forced = -3
+ };
+
+ enum WriteMode_BRep
+ {
+ WriteMode_BRep_Faces = 0,
+ WriteMode_BRep_BRep
+ };
+
+ enum WriteMode_ConvertSurface
+ {
+ WriteMode_ConvertSurface_Off = 0,
+ WriteMode_ConvertSurface_On
+ };
+
+ enum WriteMode_PrecisionMode
+ {
+ WriteMode_PrecisionMode_Least = -1,
+ WriteMode_PrecisionMode_Average = 0,
+ WriteMode_PrecisionMode_Greatest = 1,
+ WriteMode_PrecisionMode_Session = 2
+ };
+
+ enum WriteMode_PlaneMode
+ {
+ WriteMode_PlaneMode_Plane = 0,
+ WriteMode_PlaneMode_BSpline
+ };
+
+public:
+ DEIGES_Parameters() = default;
+
+ //! Initialize parameters
+ Standard_EXPORT void InitFromStatic();
+
+ //! Reset used parameters
+ Standard_EXPORT void Reset();
+
+ //! Returns default parameters for reading STEP files.
+ Standard_EXPORT static DE_ShapeFixParameters GetDefaultReadingParamsIGES();
+
+ //! Returns default parameters for writing STEP files.
+ Standard_EXPORT static DE_ShapeFixParameters GetDefaultWritingParamsIGES();
+
+public:
+ // Common
+ // clang-format off
+ ReadMode_BSplineContinuity ReadBSplineContinuity = ReadMode_BSplineContinuity_C1; //<! Manages the continuity of BSpline curves
+ ReadMode_Precision ReadPrecisionMode = ReadMode_Precision_File; //<! Reads the precision mode value
+ double ReadPrecisionVal = 0.0001; //<! ReadMode_Precision for shape construction (if enabled user mode)
+ ReadMode_MaxPrecision ReadMaxPrecisionMode = ReadMode_MaxPrecision_Preferred; //<! Defines the mode of applying the maximum allowed tolerance
+ double ReadMaxPrecisionVal = 1; //<! Defines the maximum allowable tolerance
+ bool ReadSameParamMode = false; //<! Defines the using of BRepLib::SameParameter
+ ReadMode_SurfaceCurve ReadSurfaceCurveMode = ReadMode_SurfaceCurve_Default; //<! reference for the computation of curves in case of 2D/3D
+ double EncodeRegAngle = 0.57295779513; //<! Continuity which these two faces are connected with at that edge
+
+ //Read
+ bool ReadApproxd1 = false; //<! Flag to split bspline curves of degree 1
+ TCollection_AsciiString ReadResourceName = "IGES"; //<! Defines the name of the resource file to read
+ TCollection_AsciiString ReadSequence = "FromIGES"; //<! Defines the name of the sequence of operators to read
+ bool ReadFaultyEntities = false; //<! Parameter for reading failed entities
+ bool ReadOnlyVisible = false; //<! Parameter for reading invisible entities
+ bool ReadColor = true; //<! ColorMode is used to indicate read Colors or not
+ bool ReadName = true; //<! NameMode is used to indicate read Name or not
+ bool ReadLayer = true; //<! LayerMode is used to indicate read Layers or not
+
+ // Write
+ WriteMode_BRep WriteBRepMode = WriteMode_BRep_Faces; //<! Flag to define entities type to write
+ WriteMode_ConvertSurface WriteConvertSurfaceMode = WriteMode_ConvertSurface_Off; //<! Flag to convert surface to elementary
+ TCollection_AsciiString WriteHeaderAuthor; //<! Name of the author of the file
+ TCollection_AsciiString WriteHeaderCompany; //<! Name of the sending company
+ TCollection_AsciiString WriteHeaderProduct; //<! Name of the sending product
+ TCollection_AsciiString WriteHeaderReciever; //<! Name of the receiving company
+ TCollection_AsciiString WriteResourceName = "IGES"; //<! Defines the name of the resource file to write
+ TCollection_AsciiString WriteSequence = "ToIGES"; //<! Defines the name of the sequence of operators to write
+ WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the IGES file
+ double WritePrecisionVal = 0.0001; //<! Resolution value for an IGES file when WriteMode_PrecisionMode is Greatest
+ WriteMode_PlaneMode WritePlaneMode = WriteMode_PlaneMode_Plane; //<! Flag to convert plane to the BSline
+ bool WriteOffsetMode = false; //<! Writing offset curves like BSplines
+ bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not
+ bool WriteName = true; //<! NameMode is used to indicate write Name or not
+ bool WriteLayer = true; //<! LayerMode is used to indicate write Layers or not
+ // clang-format on
+};
+
+#endif // _DESTEP_Parameters_HeaderFile
// Get previous values
myOldValues.ReadBSplineContinuity =
- (DEIGES_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal(
+ (DEIGES_Parameters::ReadMode_BSplineContinuity)Interface_Static::IVal(
"read.iges.bspline.continuity");
myOldValues.ReadPrecisionMode =
- (DEIGES_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
+ (DEIGES_Parameters::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
myOldValues.ReadMaxPrecisionMode =
- (DEIGES_ConfigurationNode::ReadMode_MaxPrecision)Interface_Static::IVal(
- "read.maxprecision.mode");
+ (DEIGES_Parameters::ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
myOldValues.ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
myOldValues.ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
myOldValues.ReadSurfaceCurveMode =
- (DEIGES_ConfigurationNode::ReadMode_SurfaceCurve)Interface_Static::IVal(
- "read.surfacecurve.mode");
+ (DEIGES_Parameters::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
myOldValues.ReadApproxd1 = Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
myOldValues.ReadOnlyVisible = Interface_Static::IVal("read.iges.onlyvisible") == 1;
myOldValues.WriteBRepMode =
- (DEIGES_ConfigurationNode::WriteMode_BRep)Interface_Static::IVal("write.iges.brep.mode");
+ (DEIGES_Parameters::WriteMode_BRep)Interface_Static::IVal("write.iges.brep.mode");
myOldValues.WriteConvertSurfaceMode =
- (DEIGES_ConfigurationNode::WriteMode_ConvertSurface)Interface_Static::IVal(
+ (DEIGES_Parameters::WriteMode_ConvertSurface)Interface_Static::IVal(
"write.convertsurface.mode");
myOldValues.WriteHeaderAuthor = Interface_Static::CVal("write.iges.header.author");
myOldValues.WriteHeaderCompany = Interface_Static::CVal("write.iges.header.company");
myOldValues.WriteResourceName = Interface_Static::CVal("write.iges.resource.name");
myOldValues.WriteSequence = Interface_Static::CVal("write.iges.sequence");
myOldValues.WritePrecisionMode =
- (DEIGES_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal(
- "write.precision.mode");
+ (DEIGES_Parameters::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
myOldValues.WritePlaneMode =
- (DEIGES_ConfigurationNode::WriteMode_PlaneMode)Interface_Static::IVal("write.iges.plane.mode");
+ (DEIGES_Parameters::WriteMode_PlaneMode)Interface_Static::IVal("write.iges.plane.mode");
myOldValues.WriteOffsetMode = Interface_Static::IVal("write.iges.offset.mode") == 1;
myOldLengthUnit = Interface_Static::IVal("xstep.cascade.unit");
//=================================================================================================
-void DEIGES_Provider::setStatic(
- const DEIGES_ConfigurationNode::IGESCAFControl_InternalSection& theParameter)
+void DEIGES_Provider::setStatic(const DEIGES_Parameters& theParameter)
{
Interface_Static::SetIVal("read.iges.bspline.continuity", theParameter.ReadBSplineContinuity);
Interface_Static::SetIVal("read.precision.mode", theParameter.ReadPrecisionMode);
void initStatic(const Handle(DE_ConfigurationNode)& theNode);
//! Initialize static variables
- void setStatic(const DEIGES_ConfigurationNode::IGESCAFControl_InternalSection& theParameter);
+ void setStatic(const DEIGES_Parameters& theParameter);
//! Reset used interface static variables
void resetStatic();
- DEIGES_ConfigurationNode::IGESCAFControl_InternalSection myOldValues;
- int myOldLengthUnit = 1;
+ DEIGES_Parameters myOldValues;
+ int myOldLengthUnit = 1;
};
#endif // _DEIGES_Provider_HeaderFile
DEIGES_ConfigurationNode.cxx
DEIGES_ConfigurationNode.hxx
+DEIGES_Parameters.cxx
+DEIGES_Parameters.hxx
DEIGES_Provider.cxx
DEIGES_Provider.hxx
DESTEP_Parameters aParameters;
*this = aParameters;
}
+
+//=================================================================================================
+
+DE_ShapeFixParameters DESTEP_Parameters::GetDefaultReadingParamsSTEP()
+{
+ return DE_ShapeFixParameters();
+}
+
+//=================================================================================================
+
+DE_ShapeFixParameters DESTEP_Parameters::GetDefaultWritingParamsSTEP()
+{
+ return DE_ShapeFixParameters();
+}
#ifndef _DESTEP_Parameters_HeaderFile
#define _DESTEP_Parameters_HeaderFile
+#include <DE_ShapeFixParameters.hxx>
#include <Resource_FormatType.hxx>
#include <STEPControl_StepModelType.hxx>
#include <TCollection_AsciiString.hxx>
WriteMode_VertexMode_SingleVertex
};
+public:
Standard_EXPORT DESTEP_Parameters();
//! Initialize parameters
}
}
+ //! Returns default parameters for reading STEP files.
+ Standard_EXPORT static DE_ShapeFixParameters GetDefaultReadingParamsSTEP();
+
+ //! Returns default parameters for writing STEP files.
+ Standard_EXPORT static DE_ShapeFixParameters GetDefaultWritingParamsSTEP();
+
public:
// Common
// clang-format off
#include <XCAFDoc_LayerTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
Standard_Real aScaleFactorMM = 1.;
if (!XCAFDoc_DocumentTool::GetLengthUnit(doc, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter))
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
aScaleFactorMM = UnitsMethods::GetCasCadeLengthUnit();
// set length unit to the document
XCAFDoc_DocumentTool::SetLengthUnit(doc, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter);
}
aModel->ChangeGlobalSection().SetCascadeUnit(aScaleFactorMM);
-
TransferRoots(theProgress); // replaces the above
num = NbShapes();
if ( num <=0 ) return Standard_False;
#include <XCAFPrs.hxx>
#include <XCAFPrs_Style.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
}
else
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
Model()->ChangeGlobalSection().SetCascadeUnit(UnitsMethods::GetCasCadeLengthUnit());
}
}
#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
#include <XCAFPrs_DataMapOfStyleTransient.hxx>
#include <TopTools_MapOfShape.hxx>
+
class XSControl_WorkSession;
class TDocStd_Document;
class TCollection_AsciiString;
#include <Transfer_TransientMapper.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IGESControl_ActorWrite,Transfer_ActorOfFinderProcess)
-IGESControl_ActorWrite::IGESControl_ActorWrite () { ModeTrans() = 0; }
+//=============================================================================
+
+IGESControl_ActorWrite::IGESControl_ActorWrite()
+{
+ ModeTrans() = 0;
+}
+
+//=============================================================================
Standard_Boolean IGESControl_ActorWrite::Recognize
(const Handle(Transfer_Finder)& start)
return Standard_False;
}
+//=============================================================================
+
Handle(Transfer_Binder) IGESControl_ActorWrite::Transfer
(const Handle(Transfer_Finder)& start,
const Handle(Transfer_FinderProcess)& FP,
const Message_ProgressRange& theProgress)
{
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
DeclareAndCast(IGESData_IGESModel,modl,FP->Model());
if (modl.IsNull()) return NullResult();
Handle(Standard_Transient) ent;
DeclareAndCast(TransferBRep_ShapeMapper,shmap,start);
- if (!shmap.IsNull()) {
+ if (!shmap.IsNull())
+ {
TopoDS_Shape shape = shmap->Value();
- if (shape.IsNull()) return NullResult();
-// modified by NIZHNY-EAP Tue Aug 29 11:16:54 2000 ___BEGIN___
- Handle(Standard_Transient) info;
- Standard_Real Tol = Interface_Static::RVal("write.precision.val");
- Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
- shape = XSAlgo::AlgoContainer()->ProcessShape( shape, Tol, maxTol,
- "write.iges.resource.name",
- "write.iges.sequence", info,
- theProgress, false, TopAbs_EDGE);
-// modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
+ if (shape.IsNull())
+ {
+ return NullResult();
+ }
+
+ XSAlgo_ShapeProcessor aShapeProcessor(GetParameters());
+ shape = aShapeProcessor.ProcessShape(shape, GetShapeProcessFlags().first, theProgress);
BRepToIGES_BREntity BR0; BR0.SetModel(modl); BR0.SetTransferProcess(FP);
BRepToIGESBRep_Entity BR1; BR1.SetModel(modl); BR1.SetTransferProcess(FP);
if (themodetrans == 0) ent = BR0.TransferShape(shape, theProgress);
if (themodetrans == 1) ent = BR1.TransferShape(shape, theProgress);
-// modified by NIZHNY-EAP Tue Aug 29 11:37:18 2000 ___BEGIN___
- XSAlgo::AlgoContainer()->MergeTransferInfo(FP, info);
-// modified by NIZHNY-EAP Tue Aug 29 11:37:25 2000 ___END___
+ aShapeProcessor.MergeTransferInfo(FP);
if (!ent.IsNull()) return TransientResult(ent);
}
DeclareAndCast(Transfer_TransientMapper,gemap,start);
#include <Standard_Type.hxx>
#include <Transfer_ActorOfFinderProcess.hxx>
+
class Transfer_Finder;
class Transfer_Binder;
class Transfer_FinderProcess;
-
-
class IGESControl_ActorWrite;
+
DEFINE_STANDARD_HANDLE(IGESControl_ActorWrite, Transfer_ActorOfFinderProcess)
//! Actor to write Shape to IGES
class IGESControl_ActorWrite : public Transfer_ActorOfFinderProcess
{
-
public:
-
-
Standard_EXPORT IGESControl_ActorWrite();
//! Recognizes a ShapeMapper
const Handle(Transfer_FinderProcess)& FP,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(IGESControl_ActorWrite,Transfer_ActorOfFinderProcess)
-
-protected:
-
-
-
-
-private:
-
-
-
-
};
//abv 10.04.99 S4136: eliminate using BRepAPI::Precision()
#include <BRepLib.hxx>
+#include <DEIGES_Parameters.hxx>
+#include <DE_ShapeFixParameters.hxx>
#include <IFSelect_CheckCounter.hxx>
#include <IFSelect_Functions.hxx>
#include <IGESControl_Controller.hxx>
#include <Transfer_Binder.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
return Handle(IGESData_IGESModel)::DownCast(Model());
}
-
-
//=======================================================================
//function : NbRootsForTransfer
//purpose :
}
}
}
+
+//=================================================================================================
+
+DE_ShapeFixParameters IGESControl_Reader::GetDefaultParameters() const
+{
+ return DEIGES_Parameters::GetDefaultReadingParamsIGES();
+}
+
+//=================================================================================================
+
+ShapeProcess::OperationsFlags IGESControl_Reader::GetDefaultShapeProcessFlags() const
+{
+ ShapeProcess::OperationsFlags aFlags;
+ aFlags.set(ShapeProcess::Operation::FixShape);
+ return aFlags;
+}
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-
#include <XSControl_Reader.hxx>
#include <Standard_Integer.hxx>
#include <IFSelect_PrintFail.hxx>
#include <IFSelect_PrintCount.hxx>
-class XSControl_WorkSession;
-class IGESData_IGESModel;
-
+class IGESData_IGESModel;
//! Reads IGES files, checks them and translates their contents into Open CASCADE models.
//! The IGES data can be that of a whole model or that of a specific list of entities in the model.
class IGESControl_Reader : public XSControl_Reader
{
public:
-
DEFINE_STANDARD_ALLOC
-
//! Creates a Reader from scratch
Standard_EXPORT IGESControl_Reader();
//! Prints Statistics and check list for Transfer
Standard_EXPORT void PrintTransferInfo (const IFSelect_PrintFail failwarn, const IFSelect_PrintCount mode) const;
-
-
-
protected:
+ //! Returns default parameters for shape fixing.
+ //! @return default parameters for shape fixing.
+ Standard_EXPORT virtual DE_ShapeFixParameters GetDefaultParameters() const Standard_OVERRIDE;
-
-
-
+ //! Returns default flags for shape processing.
+ //! @return Default flags for shape processing.
+ Standard_EXPORT virtual ShapeProcess::OperationsFlags GetDefaultShapeProcessFlags() const Standard_OVERRIDE;
private:
-
-
-
Standard_Boolean theReadOnlyVisible;
-
-
};
-
#include <IGESControl_Reader.lxx>
-
-
-
-
#endif // _IGESControl_Reader_HeaderFile
#include <BndLib_AddSurface.hxx>
#include <BRepBndLib.hxx>
#include <BRepToIGESBRep_Entity.hxx>
+#include <DEIGES_Parameters.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomToIGES_GeomCurve.hxx>
#include <TopoDS_Shape.hxx>
#include <Transfer_FinderProcess.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <errno.h>
-IGESControl_Writer::IGESControl_Writer ()
- : myTP (new Transfer_FinderProcess(10000)) ,
- myIsComputed (Standard_False)
+
+//=============================================================================
+
+IGESControl_Writer::IGESControl_Writer()
+: myTP(new Transfer_FinderProcess(10000)),
+ myIsComputed(Standard_False)
{
-// faudrait aussi (?) prendre les parametres par defaut ... ?
IGESControl_Controller::Init();
myEditor.Init(IGESSelect_WorkLibrary::DefineProtocol());
- myEditor.SetUnitName(Interface_Static::CVal ("write.iges.unit"));
- myEditor.ApplyUnit();
- myWriteMode = Interface_Static::IVal ("write.iges.brep.mode");
- myModel = myEditor.Model();
+ myEditor.SetUnitName(Interface_Static::CVal("write.iges.unit"));
+ myEditor.ApplyUnit();
+ myWriteMode = Interface_Static::IVal("write.iges.brep.mode");
+ myModel = myEditor.Model();
}
-IGESControl_Writer::IGESControl_Writer
- (const Standard_CString unit, const Standard_Integer modecr)
- : myTP (new Transfer_FinderProcess(10000)) ,
- myWriteMode (modecr) , myIsComputed (Standard_False)
+//=============================================================================
+
+IGESControl_Writer::IGESControl_Writer(const Standard_CString theUnit,
+ const Standard_Integer theModecr)
+: myTP(new Transfer_FinderProcess(10000)),
+ myWriteMode(theModecr),
+ myIsComputed(Standard_False)
{
-// faudrait aussi (?) prendre les parametres par defaut ... ?
IGESControl_Controller::Init();
myEditor.Init(IGESSelect_WorkLibrary::DefineProtocol());
- myEditor.SetUnitName(unit);
+ myEditor.SetUnitName(theUnit);
myEditor.ApplyUnit();
myModel = myEditor.Model();
}
-IGESControl_Writer::IGESControl_Writer
- (const Handle(IGESData_IGESModel)& model, const Standard_Integer modecr)
- : myTP (new Transfer_FinderProcess(10000)) ,
- myModel (model) ,
- myEditor (model,IGESSelect_WorkLibrary::DefineProtocol()) ,
- myWriteMode (modecr) , myIsComputed (Standard_False) { }
+//=============================================================================
+
+IGESControl_Writer::IGESControl_Writer(const Handle(IGESData_IGESModel)& theModel,
+ const Standard_Integer theModecr)
+: myTP(new Transfer_FinderProcess(10000)),
+ myModel(theModel),
+ myEditor(theModel, IGESSelect_WorkLibrary::DefineProtocol()),
+ myWriteMode(theModecr),
+ myIsComputed(Standard_False)
+{}
+
+//=============================================================================
Standard_Boolean IGESControl_Writer::AddShape (const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (theShape.IsNull()) return Standard_False;
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
+
+ InitializeMissingParameters();
Message_ProgressScope aPS(theProgress, NULL, 2);
- // modified by NIZHNY-EAP Tue Aug 29 11:16:54 2000 ___BEGIN___
- Handle(Standard_Transient) info;
- Standard_Real Tol = Interface_Static::RVal("write.precision.val");
- Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
- TopoDS_Shape Shape = XSAlgo::AlgoContainer()->ProcessShape( theShape, Tol, maxTol,
- "write.iges.resource.name",
- "write.iges.sequence", info,
- aPS.Next(), false, TopAbs_EDGE);
+
+ XSAlgo_ShapeProcessor aShapeProcessor(myShapeProcParams);
+ TopoDS_Shape Shape = aShapeProcessor.ProcessShape(theShape, myShapeProcFlags.first, aPS.Next());
+
if (!aPS.More())
return Standard_False;
- // modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
BRepToIGES_BREntity B0; B0.SetTransferProcess(myTP); B0.SetModel(myModel);
BRepToIGESBRep_Entity B1; B1.SetTransferProcess(myTP); B1.SetModel(myModel);
Handle(IGESData_IGESEntity) ent = myWriteMode?
if(ent.IsNull())
return Standard_False;
-// modified by NIZHNY-EAP Tue Aug 29 11:37:18 2000 ___BEGIN___
- XSAlgo::AlgoContainer()->MergeTransferInfo(myTP, info);
-// modified by NIZHNY-EAP Tue Aug 29 11:37:25 2000 ___END___
+ aShapeProcessor.MergeTransferInfo(myTP);
//22.10.98 gka BUC60080
return AddEntity (ent);
}
+//=============================================================================
+
Standard_Boolean IGESControl_Writer::AddEntity (const Handle(IGESData_IGESEntity)& ent)
{
if (ent.IsNull()) return Standard_False;
return Standard_True;
}
+//=============================================================================
+
void IGESControl_Writer::ComputeModel ()
{
if (!myIsComputed) {
}
}
+//=============================================================================
+
Standard_Boolean IGESControl_Writer::Write
(Standard_OStream& S, const Standard_Boolean fnes)
{
if (!S) return Standard_False;
ComputeModel();
Standard_Integer nbEnt = myModel->NbEntities();
-#ifdef OCCT_DEBUG
- std::cout<<" IGES Write : "<<nbEnt<<" ent.s"<< std::flush;
-#endif
if(!nbEnt)
return Standard_False;
IGESData_IGESWriter IW (myModel);
// ne pas oublier le mode fnes ... a transmettre a IW
IW.SendModel (IGESSelect_WorkLibrary::DefineProtocol());
-#ifdef OCCT_DEBUG
- std::cout<<" ... ecriture ..."<<std::flush;
-#endif
if (fnes) IW.WriteMode() = 10;
Standard_Boolean status = IW.Print(S);
-#ifdef OCCT_DEBUG
- std::cout<<" ... fichier ecrit ..."<<std::endl;
-#endif
return status;
}
+//=============================================================================
+
Standard_Boolean IGESControl_Writer::Write
(const Standard_CString file, const Standard_Boolean fnes)
{
{
return Standard_False;
}
-#ifdef OCCT_DEBUG
- std::cout<<" Ecriture fichier ("<< (fnes ? "fnes" : "IGES") <<"): "<<file<<std::endl;
-#endif
Standard_Boolean res = Write (*aStream,fnes);
errno = 0;
return res;
}
+
+//=============================================================================
+
+void IGESControl_Writer::SetParameters(const ParameterMap& theParameters)
+{
+ myShapeProcParams = theParameters;
+}
+
+//=============================================================================
+
+void IGESControl_Writer::SetParameters(ParameterMap&& theParameters)
+{
+ myShapeProcParams = std::move(theParameters);
+}
+
+//=============================================================================
+
+void IGESControl_Writer::SetParameters(const DE_ShapeFixParameters& theParameters, const ParameterMap& theAdditionalParameters)
+{
+ myShapeProcParams.clear();
+ XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams);
+ for (const auto& aParam : theAdditionalParameters)
+ {
+ if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
+ {
+ myShapeProcParams[aParam.first] = aParam.second;
+ }
+ }
+}
+
+//=============================================================================
+
+void IGESControl_Writer::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ myShapeProcFlags.first = theFlags;
+ myShapeProcFlags.second = true;
+}
+
+//=============================================================================
+
+void IGESControl_Writer::InitializeMissingParameters()
+{
+ if (GetParameters().empty())
+ {
+ SetParameters(DEIGES_Parameters::GetDefaultWritingParamsIGES());
+ }
+
+ if (!myShapeProcFlags.second)
+ {
+ myShapeProcFlags.first.set(ShapeProcess::Operation::DirectFaces);
+ myShapeProcFlags.second = true;
+ }
+}
#ifndef _IGESControl_Writer_HeaderFile
#define _IGESControl_Writer_HeaderFile
+#include <ShapeProcess.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-
#include <IGESData_BasicEditor.hxx>
#include <Standard_Integer.hxx>
#include <Standard_CString.hxx>
#include <Standard_OStream.hxx>
#include <Message_ProgressRange.hxx>
+#include <unordered_map>
+
+struct DE_ShapeFixParameters;
class Transfer_FinderProcess;
class IGESData_IGESModel;
class TopoDS_Shape;
class IGESControl_Writer
{
public:
-
DEFINE_STANDARD_ALLOC
-
+
+ using ParameterMap = std::unordered_map<std::string, std::string>;
+ // Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
+ // we use a pair. The first element is the flags, the second element is a boolean value that indicates
+ // whether the flags were set.
+ using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
+
+public:
//! Creates a writer object with the
//! default unit (millimeters) and write mode (Face).
//! IGESControl_Writer (const Standard_CString unit,
//! Creates a writer with given
//! values for units and for write mode.
- //! unit may be any unit that is accepted by the IGES standard.
+ //! theUnit may be any unit that is accepted by the IGES standard.
//! By default, it is the millimeter.
- //! modecr defines the write mode and may be:
+ //! theModecr defines the write mode and may be:
//! - 0: Faces (default)
//! - 1: BRep.
- Standard_EXPORT IGESControl_Writer(const Standard_CString unit, const Standard_Integer modecr = 0);
+ Standard_EXPORT IGESControl_Writer(const Standard_CString theUnit,
+ const Standard_Integer theModecr = 0);
//! Creates a writer object with the
- //! prepared IGES model model in write mode.
- //! modecr defines the write mode and may be:
+ //! prepared IGES model theModel in write mode.
+ //! theModecr defines the write mode and may be:
//! - 0: Faces (default)
//! - 1: BRep.
- Standard_EXPORT IGESControl_Writer(const Handle(IGESData_IGESModel)& model, const Standard_Integer modecr = 0);
+ Standard_EXPORT IGESControl_Writer(const Handle(IGESData_IGESModel)& theModel,
+ const Standard_Integer theModecr = 0);
//! Returns the IGES model to be written in output.
const Handle(IGESData_IGESModel) & Model() const
//! if the processor could not create the file).
Standard_EXPORT Standard_Boolean Write (const Standard_CString file, const Standard_Boolean fnes = Standard_False);
- private:
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
+
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ inline const ParameterMap& GetParameters() const { return myShapeProcParams; }
+
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
+
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return The flags defining operations to be performed on shapes.
+ inline const ShapeProcess::OperationsFlags& GetShapeProcessFlags() const { return myShapeProcFlags.first; }
+
+ private:
+ //! If parameters haven't yet been provided, initializes them with default values
+ //! provided by GetDefaultParameters() method.
+ void InitializeMissingParameters();
+
+ private:
Handle(Transfer_FinderProcess) myTP;
- Handle(IGESData_IGESModel) myModel;
- IGESData_BasicEditor myEditor;
- Standard_Integer myWriteMode;
- Standard_Boolean myIsComputed;
+ Handle(IGESData_IGESModel) myModel;
+ IGESData_BasicEditor myEditor;
+ Standard_Integer myWriteMode;
+ Standard_Boolean myIsComputed;
+ ParameterMap myShapeProcParams; //!< Parameters for shape processing.
+ ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
};
#endif // _IGESControl_Writer_HeaderFile
#include <Quantity_Date.hxx>
#include <TCollection_HAsciiString.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <UnitsMethods.hxx>
#include <stdio.h>
//Message_Msg Msg48 ("XSTEP_48");
//Message_Msg Msg49 ("XSTEP_49");
//======================================
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
theSeparator = ','; theEndMark = ';';
theSendName.Nullify(); theFileName.Nullify(); theSystemId.Nullify();
theInterfaceVersion.Nullify();
#include <Transfer_TransientProcess.hxx>
#include <TransferBRep_ShapeBinder.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IGESToBRep_Actor,Transfer_ActorOfTransientProcess)
-//=======================================================================
-//function : IGESToBRep_Actor
-//purpose :
-//=======================================================================
-IGESToBRep_Actor::IGESToBRep_Actor ()
-{ thecontinuity = 0; theeps = 0.0001; }
+namespace
+{
+ //=======================================================================
+ //function : EncodeRegul
+ //purpose : INTERNAL to encode regularity on edges
+ //=======================================================================
+ static Standard_Boolean EncodeRegul(const TopoDS_Shape& theShape)
+ {
+ const Standard_Real aToleranceAngle = Interface_Static::RVal("read.encoderegularity.angle");
+ if (theShape.IsNull())
+ {
+ return Standard_True;
+ }
+ if (aToleranceAngle <= 0.)
+ {
+ return Standard_True;
+ }
+
+ try
+ {
+ OCC_CATCH_SIGNALS
+ BRepLib::EncodeRegularity(theShape, aToleranceAngle);
+ }
+ catch (const Standard_Failure&)
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+ }
+ //=======================================================================
+ //function : TrimTolerances
+ //purpose : Trims tolerances of the shape according to static parameters
+ //=======================================================================
+ static void TrimTolerances(const TopoDS_Shape& theShape, const Standard_Real theTolerance)
+ {
+ if (Interface_Static::IVal("read.maxprecision.mode") == 1)
+ {
+ ShapeFix_ShapeTolerance aSFST;
+ aSFST.LimitTolerance(theShape, 0, Max(theTolerance, Interface_Static::RVal("read.maxprecision.val")));
+ }
+ }
+}
//=======================================================================
-//function : SetModel
-//purpose :
+
+IGESToBRep_Actor::IGESToBRep_Actor() : thecontinuity(0), theeps(0.0001)
+{}
+
//=======================================================================
+
void IGESToBRep_Actor::SetModel (const Handle(Interface_InterfaceModel)& model)
{
themodel = model;
theeps = Handle(IGESData_IGESModel)::DownCast(themodel)->GlobalSection().Resolution();
}
-
-//=======================================================================
-//function : SetContinuity
-//purpose :
//=======================================================================
+
void IGESToBRep_Actor::SetContinuity (const Standard_Integer continuity)
{
thecontinuity = continuity;
}
-
-//=======================================================================
-//function : GetContinuity
-//purpose :
//=======================================================================
+
Standard_Integer IGESToBRep_Actor::GetContinuity () const
{
return thecontinuity;
}
//=======================================================================
-//function : Recognize
-//purpose :
-//=======================================================================
+
Standard_Boolean IGESToBRep_Actor::Recognize
(const Handle(Standard_Transient)& start)
{
// Cas restants : non reconnus
return Standard_False;
}
-//=======================================================================
-//function : EncodeRegul
-//purpose : INTERNAL to encode regularity on edges
-//=======================================================================
-static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh)
-{
- Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
- if (sh.IsNull()) return Standard_True;
- if (tolang <= 0) return Standard_True;
- try {
- OCC_CATCH_SIGNALS
- BRepLib::EncodeRegularity (sh,tolang);
- }
- catch(Standard_Failure const&) {
- return Standard_False;
- }
- return Standard_True;
-}
-//=======================================================================
-//function : TrimTolerances
-//purpose : Trims tolerances of the shape according to static parameters
-//
//=======================================================================
-static void TrimTolerances (const TopoDS_Shape& shape,
- const Standard_Real tol)
-{
- if( Interface_Static::IVal("read.maxprecision.mode")==1) {
- ShapeFix_ShapeTolerance SFST;
- SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val")));
- }
-}
-
-//=======================================================================
-//function : Transfer
-//purpose :
-//=======================================================================
Handle(Transfer_Binder) IGESToBRep_Actor::Transfer
(const Handle(Standard_Transient)& start, const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress)
return NullResult();
TopoDS_Shape shape;
-// appeler le transfert seulement si type OK
+ // Call the transfer only if type is OK.
Standard_Integer typnum = ent->TypeNumber();
Standard_Integer fornum = ent->FormNumber();
Standard_Real eps;
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressScope aPS(theProgress, "Transfer stage", 2);
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
IGESToBRep_CurveAndSurface CAS;
CAS.SetModel(mymodel);
CAS.SetContinuity(thecontinuity);
if (eps > 1.E-08) {
CAS.SetEpsGeom(eps);
theeps = eps*CAS.GetUnitFactor();
-// Interface_Static::SetRVal("lastpreci",theeps);
}
Standard_Integer nbTPitems = TP->NbMapped();
{
shape.Nullify();
}
}
-
+
// fixing shape
- Handle(Standard_Transient) info;
- shape = XSAlgo::AlgoContainer()->ProcessShape(shape, theeps, CAS.GetMaxTol(),
- "read.iges.resource.name",
- "read.iges.sequence",
- info, aPS.Next(),
- false, TopAbs_EDGE);
- XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
+
+ // Set tolerances for shape processing.
+ // These parameters are calculated inside IGESToBRep_Actor::Transfer() and cannot be set from outside.
+ Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetParameters();
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", theeps, true, aParameters);
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", CAS.GetMaxTol(), true, aParameters);
+
+ XSAlgo_ShapeProcessor aShapeProcessor(aParameters);
+ shape = aShapeProcessor.ProcessShape(shape, GetProcessingFlags().first, aPS.Next());
+ aShapeProcessor.MergeTransferInfo(TP, nbTPitems);
}
ShapeExtend_Explorer SBE;
return binder;
}
+//=============================================================================
- Standard_Real IGESToBRep_Actor::UsedTolerance () const
- { return theeps; }
+Standard_Real IGESToBRep_Actor::UsedTolerance() const
+{
+ return theeps;
+}
#include <Transfer_ActorOfTransientProcess.hxx>
#include <Message_ProgressRange.hxx>
+struct DE_ShapeFixParameters;
class Interface_InterfaceModel;
class Standard_Transient;
class Transfer_Binder;
//! then returns the Binder which contains the Result
class IGESToBRep_Actor : public Transfer_ActorOfTransientProcess
{
-
public:
-
-
Standard_EXPORT IGESToBRep_Actor();
Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& model);
//! the file or from statics
Standard_EXPORT Standard_Real UsedTolerance() const;
-
-
-
DEFINE_STANDARD_RTTIEXT(IGESToBRep_Actor,Transfer_ActorOfTransientProcess)
-protected:
-
-
-
-
private:
-
-
Handle(Interface_InterfaceModel) themodel;
Standard_Integer thecontinuity;
Standard_Real theeps;
-
-
};
-
-
-
-
-
-
#endif // _IGESToBRep_Actor_HeaderFile
#include <BRep_Builder.hxx>
#include <BRepLib.hxx>
+#include <DEIGES_Parameters.hxx>
#include <IGESAppli.hxx>
#include <IGESAppli_Protocol.hxx>
#include <IGESData_FileProtocol.hxx>
#include <Transfer_TransientProcess.hxx>
#include <TransferBRep.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <stdio.h>
//#include <ShapeCustom.hxx>
static Handle(IGESData_FileProtocol) protocol;
+namespace
+{
+ //=======================================================================
+ //function : EncodeRegul
+ //purpose : INTERNAL to encode regularity on edges
+ //=======================================================================
+ static Standard_Boolean EncodeRegul(const TopoDS_Shape& theShape)
+ {
+ const Standard_Real aToleranceAngle = Interface_Static::RVal("read.encoderegularity.angle");
+ if (theShape.IsNull())
+ {
+ return Standard_True;
+ }
+ if (aToleranceAngle <= 0.)
+ {
+ return Standard_True;
+ }
+
+ try
+ {
+ OCC_CATCH_SIGNALS
+ BRepLib::EncodeRegularity(theShape, aToleranceAngle);
+ }
+ catch (const Standard_Failure&)
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+ }
+
+ //=======================================================================
+ //function : TrimTolerances
+ //purpose : Trims tolerances of the shape according to static parameters
+ //=======================================================================
+ static void TrimTolerances(const TopoDS_Shape& theShape, const Standard_Real theTolerance)
+ {
+ if (Interface_Static::IVal("read.maxprecision.mode") == 1)
+ {
+ ShapeFix_ShapeTolerance SFST;
+ SFST.LimitTolerance(theShape, 0, Max(theTolerance, Interface_Static::RVal("read.maxprecision.val")));
+ }
+ }
+}
+
+//=============================================================================
-//=======================================================================
-//function : IGESToBRep_Reader
-//purpose :
-//=======================================================================
- IGESToBRep_Reader::IGESToBRep_Reader ()
+IGESToBRep_Reader::IGESToBRep_Reader()
+: theDone(Standard_False)
{
- theDone = Standard_False;
- if (protocol.IsNull()) {
- IGESAppli::Init(); IGESSolid::Init();
+ if (protocol.IsNull())
+ {
+ IGESAppli::Init();
+ IGESSolid::Init();
protocol = new IGESData_FileProtocol;
protocol->Add(IGESAppli::Protocol());
protocol->Add(IGESSolid::Protocol());
}
theActor = new IGESToBRep_Actor;
- theProc = new Transfer_TransientProcess;
+ theProc = new Transfer_TransientProcess;
}
-
-//=======================================================================
-//function : LoadFile
-//purpose : loads a Model from a file
-//=======================================================================
+//=============================================================================
Standard_Integer IGESToBRep_Reader::LoadFile (const Standard_CString filename)
{
return StatusFile;
}
+//=============================================================================
-//=======================================================================
-//function : SetModel
-//purpose : Specifies a Model to work on
-//=======================================================================
- void IGESToBRep_Reader::SetModel (const Handle(IGESData_IGESModel)& model)
+void IGESToBRep_Reader::SetModel (const Handle(IGESData_IGESModel)& model)
{
theModel = model;
theDone = Standard_False;
theProc->Clear();
}
+//=============================================================================
-//=======================================================================
-//function : Model
-//purpose : returns the Model to be worked on
-//=======================================================================
- Handle(IGESData_IGESModel) IGESToBRep_Reader::Model () const
- { return theModel; }
-
-
-//=======================================================================
-//function : SetTransientProcess
-//purpose : Specifies a TransferProcess
-//=======================================================================
- void IGESToBRep_Reader::SetTransientProcess
- (const Handle(Transfer_TransientProcess)& TP)
- { theProc = TP; }
-
-//=======================================================================
-//function : TransientProcess
-//purpose : Returns the TransferProcess
-//=======================================================================
- Handle(Transfer_TransientProcess) IGESToBRep_Reader::TransientProcess () const
- { return theProc; }
-
-//=======================================================================
-//function : Actor
-//purpose : returns theActor
-//=======================================================================
- Handle(IGESToBRep_Actor) IGESToBRep_Reader::Actor () const
- { return theActor; }
-
-
-//=======================================================================
-//function : Clear
-//purpose : Clears the result and Done status
-//=======================================================================
- void IGESToBRep_Reader::Clear ()
+Handle(IGESData_IGESModel) IGESToBRep_Reader::Model() const
{
- theDone = Standard_False;
+ return theModel;
+}
+
+//=============================================================================
+
+void IGESToBRep_Reader::SetTransientProcess(const Handle(Transfer_TransientProcess)& TP)
+{
+ theProc = TP;
+}
+
+//=============================================================================
+
+Handle(Transfer_TransientProcess) IGESToBRep_Reader::TransientProcess() const
+{
+ return theProc;
+}
+
+//=============================================================================
+
+Handle(IGESToBRep_Actor) IGESToBRep_Reader::Actor() const
+{
+ return theActor;
+}
+
+//=============================================================================
+
+void IGESToBRep_Reader::Clear()
+{
+ theDone = Standard_False;
theShapes.Clear();
}
+//=============================================================================
-//=======================================================================
-//function : Check
-//purpose : Checks the Model
-//=======================================================================
- Standard_Boolean IGESToBRep_Reader::Check
- (const Standard_Boolean withprint) const
+Standard_Boolean IGESToBRep_Reader::Check(const Standard_Boolean withprint) const
{
Interface_CheckTool cht (theModel,protocol);
Interface_CheckIterator chl = cht.CompleteCheckList();
return chl.IsEmpty(Standard_True);
}
+//=============================================================================
-//=======================================================================
-//function : IsDone
-//purpose : returns True if the last transfert was a success
-//=======================================================================
- Standard_Boolean IGESToBRep_Reader::IsDone () const
- { return theDone; }
-
-
-//=======================================================================
-//function : EncodeRegul
-//purpose : INTERNAL to encode regularity on edges
-//=======================================================================
-
-static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh)
+Standard_Boolean IGESToBRep_Reader::IsDone() const
{
- Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
- if (sh.IsNull()) return Standard_True;
- if (tolang <= 0) return Standard_True;
- try {
- OCC_CATCH_SIGNALS
- BRepLib::EncodeRegularity (sh,tolang);
- }
- catch(Standard_Failure const&) {
- return Standard_False;
- }
- return Standard_True;
+ return theDone;
}
-//=======================================================================
-//function : UpdateMap
-//purpose : Updates the correspondence map (Transfer_TransientProcess),
-// setting as translation results, the shapes received after
-// modification by modifier (BRepTools_Modifier)
-//warning : BRepTools_Modifier raises exception when it cannot find input
-// shape in its internal list
-//=======================================================================
-
-// comment as unused PTV 18.09.2000
-// static void UpdateMap (const Handle(Transfer_TransientProcess)& map,
-// const BRepTools_Modifier& modifier)
-// {
-// Transfer_IteratorOfProcessForTransient iterator = map->CompleteResult(Standard_True);
-// for (iterator.Start(); iterator.More(); iterator.Next()) {
-// const Handle(Transfer_Binder) binder = iterator.Value();
-// try { //to avoid exception in BRepTools_Modifier
-// OCC_CATCH_SIGNALS
-// if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeBinder))) {
-// DeclareAndCast(TransferBRep_ShapeBinder, shapebinder, binder);
-// if (shapebinder->HasResult()) {
-// TopoDS_Shape result = shapebinder->Result();
-// TopoDS_Shape modified = modifier.ModifiedShape (result);
-// if (shapebinder->Status() != Transfer_StatusUsed) //to avoid exception
-// shapebinder->SetResult (modified);
-// }
-// }
-// else if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeListBinder))) {
-// DeclareAndCast(TransferBRep_ShapeListBinder, shapelistbinder, binder);
-// for (Standard_Integer i = 1; i <= shapelistbinder->NbShapes(); i++) {
-// TopoDS_Shape result = shapelistbinder->Shape (i);
-// TopoDS_Shape modified = modifier.ModifiedShape (result);
-// shapelistbinder->SetResult (i, modified);
-// }
-// }
-// }
-// catch(Standard_Failure) {
-// continue;
-// }
-// }
-// }
-
-//=======================================================================
-//function : TrimTolerances
-//purpose : Trims tolerances of the shape according to static parameters
-//
-//=======================================================================
-
-static void TrimTolerances (const TopoDS_Shape& shape,
- const Standard_Real tol)
-{
- if( Interface_Static::IVal("read.maxprecision.mode")==1) {
- ShapeFix_ShapeTolerance SFST;
- SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val")));
- }
-}
-
-//=======================================================================
-//function : TransferRoots
-//purpose : Transfers all Roots Entities
-//=======================================================================
+//=============================================================================
+
void IGESToBRep_Reader::TransferRoots (const Standard_Boolean onlyvisible,
const Message_ProgressRange& theProgress)
{
TF->Send (msg2065, Message_Info);
}
+//=============================================================================
-//=======================================================================
-//function : Transfer
-//purpose : Transfers an Entity given
-//=======================================================================
Standard_Boolean IGESToBRep_Reader::Transfer(const Standard_Integer num,
const Message_ProgressRange& theProgress)
{
Message_ProgressScope aPS(theProgress, "OneEnt", 2);
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
IGESToBRep_CurveAndSurface CAS;
CAS.SetModel(theModel);
Standard_Real eps;
exceptionRaised = Standard_True;
}
}
- if (!exceptionRaised) {
- // fixing shape
-// shape = XSAlgo::AlgoContainer()->PerformFixShape ( shape, theProc, eps*CAS.GetUnitFactor(), CAS.GetMaxTol() );
-
- Handle(Standard_Transient) info;
- shape = XSAlgo::AlgoContainer()->ProcessShape( shape, eps*CAS.GetUnitFactor(), CAS.GetMaxTol(),
- "read.iges.resource.name",
- "read.iges.sequence", info,
- aPS.Next(), false, TopAbs_EDGE);
+ if (!exceptionRaised)
+ {
+ InitializeMissingParameters();
+
+ // Set tolerances for shape processing.
+ // These parameters are calculated inside IGESToBRep_Reader::Transfer() and cannot be set from outside.
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", eps * CAS.GetUnitFactor(), true, myShapeProcParams);
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", CAS.GetMaxTol(), true, myShapeProcParams);
+
+ XSAlgo_ShapeProcessor aShapeProcessor(myShapeProcParams);
+ shape = aShapeProcessor.ProcessShape(shape, myShapeProcFlags.first, aPS.Next());
+
if (aPS.UserBreak())
+ {
return Standard_False;
+ }
- XSAlgo::AlgoContainer()->MergeTransferInfo(theProc, info, nbTPitems);
+ aShapeProcessor.MergeTransferInfo(theProc, nbTPitems);
ShapeExtend_Explorer SBE;
if (SBE.ShapeType (shape,Standard_True) != TopAbs_SHAPE) {
return Standard_True;
}
+//=============================================================================
+
+Standard_Real IGESToBRep_Reader::UsedTolerance() const
+{
+ return theActor->UsedTolerance();
+}
-//=======================================================================
-//function : UsedTolerance
-//purpose : Returns the used tolerance (input)
-//=======================================================================
- Standard_Real IGESToBRep_Reader::UsedTolerance () const
- { return theActor->UsedTolerance(); }
+//=============================================================================
-//=======================================================================
-//function : NbShapes
-//purpose : Returns the count of produced Shapes
-//=======================================================================
- Standard_Integer IGESToBRep_Reader::NbShapes () const
- { return theShapes.Length(); }
+Standard_Integer IGESToBRep_Reader::NbShapes() const
+{
+ return theShapes.Length();
+}
+//=============================================================================
-//=======================================================================
-//function : Shape
-//purpose : Returns a Shape given its rank
-//=======================================================================
- TopoDS_Shape IGESToBRep_Reader::Shape (const Standard_Integer num) const
+TopoDS_Shape IGESToBRep_Reader::Shape(const Standard_Integer num) const
{
TopoDS_Shape res;
if (num > 0 && num <= theShapes.Length()) res = theShapes.Value(num);
return res;
}
+//=============================================================================
-//=======================================================================
-//function : OneShape
-//purpose : Returns a unique Shape
-//=======================================================================
- TopoDS_Shape IGESToBRep_Reader::OneShape () const
+TopoDS_Shape IGESToBRep_Reader::OneShape() const
{
TopoDS_Shape res;
Standard_Integer nb = theShapes.Length();
return C;
}
}
+
+//=============================================================================
+
+void IGESToBRep_Reader::SetParameters(const ParameterMap& theParameters)
+{
+ myShapeProcParams = theParameters;
+}
+
+//=============================================================================
+
+void IGESToBRep_Reader::SetParameters(ParameterMap&& theParameters)
+{
+ myShapeProcParams = std::move(theParameters);
+}
+
+//=============================================================================
+
+void IGESToBRep_Reader::SetParameters(const DE_ShapeFixParameters& theParameters, const ParameterMap& theAdditionalParameters)
+{
+ myShapeProcParams.clear();
+ XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams);
+ for (const auto& aParam : theAdditionalParameters)
+ {
+ if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
+ {
+ myShapeProcParams[aParam.first] = aParam.second;
+ }
+ }
+}
+
+//=============================================================================
+
+void IGESToBRep_Reader::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ myShapeProcFlags.first = theFlags;
+ myShapeProcFlags.second = true;
+}
+
+//=============================================================================
+
+void IGESToBRep_Reader::InitializeMissingParameters()
+{
+ if (GetParameters().empty())
+ {
+ SetParameters(DEIGES_Parameters::GetDefaultReadingParamsIGES());
+ }
+
+ if (!myShapeProcFlags.second)
+ {
+ myShapeProcFlags.first.set(ShapeProcess::Operation::FixShape);
+ myShapeProcFlags.second = true;
+ }
+}
#ifndef _IGESToBRep_Reader_HeaderFile
#define _IGESToBRep_Reader_HeaderFile
+#include <Message_ProgressRange.hxx>
+#include <ShapeProcess.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-
-#include <TopTools_SequenceOfShape.hxx>
#include <Standard_Integer.hxx>
#include <Standard_CString.hxx>
-#include <Message_ProgressRange.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+
+#include <unordered_map>
+struct DE_ShapeFixParameters;
class IGESData_IGESModel;
class IGESToBRep_Actor;
class Transfer_TransientProcess;
class IGESToBRep_Reader
{
public:
-
DEFINE_STANDARD_ALLOC
-
+ using ParameterMap = std::unordered_map<std::string, std::string>;
+ // Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
+ // we use a pair. The first element is the flags, the second element is a boolean value that indicates
+ // whether the flags were set.
+ using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
+
+public:
//! Creates a Reader
Standard_EXPORT IGESToBRep_Reader();
//! - a compound containing the resulting shapes if there are several.
Standard_EXPORT TopoDS_Shape OneShape() const;
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
-protected:
-
-
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ inline const ParameterMap& GetParameters() const { return myShapeProcParams; }
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return The flags defining operations to be performed on shapes.
+ inline const ShapeProcess::OperationsFlags& GetShapeProcessFlags() const { return myShapeProcFlags.first; }
private:
+ //! If parameters haven't yet been provided, initializes them with default values.
+ void InitializeMissingParameters();
-
-
- Handle(IGESData_IGESModel) theModel;
- Standard_Boolean theDone;
- TopTools_SequenceOfShape theShapes;
- Handle(IGESToBRep_Actor) theActor;
+private:
+ Handle(IGESData_IGESModel) theModel;
+ Standard_Boolean theDone;
+ TopTools_SequenceOfShape theShapes;
+ Handle(IGESToBRep_Actor) theActor;
Handle(Transfer_TransientProcess) theProc;
-
-
+ ParameterMap myShapeProcParams; //!< Parameters for shape processing.
+ ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
};
-
-
-
-
-
-
#endif // _IGESToBRep_Reader_HeaderFile
#include <XCAFDimTolObjects_DatumObject.hxx>
#include <XCAFView_Object.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
#include <StepAP242_DraughtingModelItemAssociation.hxx>
Standard_Real aScaleFactorMM = 1.;
if (!XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter))
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
aScaleFactorMM = UnitsMethods::GetCasCadeLengthUnit();
// Sets length unit to the document
XCAFDoc_DocumentTool::SetLengthUnit(theDoc, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter);
// calculate units
Handle(StepVisual_DraughtingModel) aDModel =
Handle(StepVisual_DraughtingModel)::DownCast(aDMIA->UsedRepresentation());
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
STEPControl_ActorRead anActor(aTP->Model());
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aDModel, aTP, aLocalFactors);
}
if (!aSDR.IsNull())
{
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
STEPControl_ActorRead anActor(theTR->Model());
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aSDR, aTP, aLocalFactors);
{
Handle(StepGeom_Axis2Placement3d) anAx
= Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(j));
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
STEPControl_ActorRead anActor(aTP->Model());
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aSRWP, aTP, aLocalFactors);
StepData_Factors aLocalFactors = theLocalFactors;
if (!aDMIA.IsNull())
{
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
STEPControl_ActorRead anActor(aModel);
Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
anActor.PrepareUnits(aDMIA->UsedRepresentation(), aTP, aLocalFactors);
StepData_Factors aLocalFactors = theLocalFactors;
if (!aDModel.IsNull())
{
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
STEPControl_ActorRead anActor(aTP->Model());
anActor.PrepareUnits(aDModel, aTP, aLocalFactors);
}
return myViewMode;
}
+//=============================================================================
+
+void STEPCAFControl_Reader::SetParameters(const ParameterMap& theParameters)
+{
+ myReader.SetParameters(theParameters);
+}
+
+//=============================================================================
+
+void STEPCAFControl_Reader::SetParameters(ParameterMap&& theParameters)
+{
+ myReader.SetParameters(std::move(theParameters));
+}
+
+//=============================================================================
+
+void STEPCAFControl_Reader::SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters)
+{
+ myReader.SetParameters(theParameters, theAdditionalParameters);
+}
+
+//=============================================================================
+
+const STEPCAFControl_Reader::ParameterMap& STEPCAFControl_Reader::GetParameters() const
+{
+ return myReader.GetParameters();
+}
+
+//=============================================================================
+
+void STEPCAFControl_Reader::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ return myReader.SetShapeProcessFlags(theFlags);
+}
+
+//=============================================================================
+
+const STEPCAFControl_Reader::ProcessingFlags& STEPCAFControl_Reader::GetShapeProcessFlags() const
+{
+ return myReader.GetShapeProcessFlags();
+}
+
//=======================================================================
//function : ReadMetadata
//purpose :
class STEPCAFControl_Reader
{
public:
-
DEFINE_STANDARD_ALLOC
-
+ using ParameterMap = XSControl_Reader::ParameterMap;
+ using ProcessingFlags = XSControl_Reader::ProcessingFlags;
+
+public:
//! Creates a reader with an empty
//! STEP model and sets ColorMode, LayerMode, NameMode and
//! PropsMode to Standard_True.
const XCAFDoc_DataMapOfShapeLabel& GetShapeLabelMap() const { return myMap; }
-protected:
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
+
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ Standard_EXPORT const ParameterMap& GetParameters() const;
+
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
+
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return Pair of values defining operations to be performed on shapes and a boolean value
+ //! that indicates whether the flags were set.
+ Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const;
-
+protected:
//! Translates STEP file already loaded into the reader
//! into the document
//! If num==0, translates all roots, else only root number num
Standard_EXPORT virtual TCollection_ExtendedString convertName (const TCollection_AsciiString& theName) const;
private:
-
//! Internal method. Import all Datum attributes and set them to XCAF object. Set connection of Datum to GeomTolerance (theGDTL).
Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
const TDF_Label theGDTL,
Handle(TDataStd_NamedData)& theAttr) const;
private:
-
STEPControl_Reader myReader;
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
XCAFDoc_DataMapOfShapeLabel myMap;
Standard_Boolean myMatMode;
Standard_Boolean myViewMode;
NCollection_DataMap<Handle(Standard_Transient), TDF_Label> myGDTMap;
-
};
#endif // _STEPCAFControl_Reader_HeaderFile
#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
#include <XCAFPrs_Style.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_TransferWriter.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
}
else
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
theModel->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
theLocalFactors.SetCascadeUnit(UnitsMethods::GetCasCadeLengthUnit());
}
return Standard_True;
}
+//=============================================================================
+
+void STEPCAFControl_Writer::SetParameters(const ParameterMap& theParameters)
+{
+ myWriter.SetParameters(theParameters);
+}
+
+//=============================================================================
+
+void STEPCAFControl_Writer::SetParameters(ParameterMap&& theParameters)
+{
+ myWriter.SetParameters(std::move(theParameters));
+}
+
+//=============================================================================
+
+void STEPCAFControl_Writer::SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters)
+{
+ myWriter.SetParameters(theParameters, theAdditionalParameters);
+}
+
+//=============================================================================
+
+const STEPCAFControl_Writer::ParameterMap& STEPCAFControl_Writer::GetParameters() const
+{
+ return myWriter.GetParameters();
+}
+
+//=============================================================================
+
+void STEPCAFControl_Writer::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ myWriter.SetShapeProcessFlags(theFlags);
+}
+
+//=============================================================================
+
+const STEPCAFControl_Writer::ProcessingFlags& STEPCAFControl_Writer::GetShapeProcessFlags() const
+{
+ return myWriter.GetShapeProcessFlags();
+}
+
//=======================================================================
//function : Transfer
//purpose :
public:
DEFINE_STANDARD_ALLOC
-public:
+ using ParameterMap = STEPControl_Writer::ParameterMap;
+ using ProcessingFlags = STEPControl_Writer::ProcessingFlags;
+public:
//! Creates a writer with an empty
//! STEP model and sets ColorMode, LayerMode, NameMode and
//! PropsMode to Standard_True.
Standard_Boolean GetMaterialMode() const { return myMatMode; }
-protected:
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
+
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ Standard_EXPORT const ParameterMap& GetParameters() const;
+
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
+
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return Pair of values defining operations to be performed on shapes and a boolean value
+ //! that indicates whether the flags were set.
+ Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const;
+protected:
//! Transfers labels to a STEP model
//! Returns True if translation is OK
//! isExternFile setting from transferExternFiles method
#include <TransferBRep_ShapeBinder.hxx>
#include <UnitsMethods.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <StepRepr_ConstructiveGeometryRepresentationRelationship.hxx>
#include <StepRepr_ConstructiveGeometryRepresentation.hxx>
#include <StepRepr_MechanicalDesignAndDraughtingRelationship.hxx>
Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast ( TP->Model() );
if (!aStepModel->IsInitializedUnit())
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
aStepModel->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
aLocalFactors.SetCascadeUnit(UnitsMethods::GetCasCadeLengthUnit());
}
return shbinder;
isBound = Standard_False;
Standard_Integer nb = sr->NbItems();
- // Used in XSAlgo::AlgoContainer()->ProcessShape (ssv; 13.11.2010)
Standard_Integer nbTPitems = TP->NbMapped();
Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo();
#ifdef TRANSLOG
}
// [BEGIN] Proceed with non-manifold topology (ssv; 12.11.2010)
- if (!isManifold) {
+ if (!isManifold)
+ {
Message_ProgressScope aPS1 (aPSRoot.Next(), "Process", 1);
- Handle(Standard_Transient) info;
- // IMPORTANT: any fixing on non-manifold topology must be done after the shape is transferred from STEP
- TopoDS_Shape fixedResult =
- XSAlgo::AlgoContainer()->ProcessShape( comp, myPrecision, myMaxTol,
- "read.step.resource.name",
- "read.step.sequence", info,
- aPS1.Next(), Standard_True);
- XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
+ // Set tolerances for shape processing.
+ // These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set from outside.
+ Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetParameters();
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters);
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters);
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.NonManifold", std::to_string(true), true, aParameters);
+ XSAlgo_ShapeProcessor aShapeProcessor(aParameters);
+ TopoDS_Shape fixedResult = aShapeProcessor.ProcessShape(comp, GetProcessingFlags().first, aPS1.Next());
+ aShapeProcessor.MergeTransferInfo(TP, nbTPitems);
if (fixedResult.ShapeType() == TopAbs_COMPOUND)
{
if (found && myShapeBuilder.IsDone()) {
mappedShape = myShapeBuilder.Value();
// Apply ShapeFix (on manifold shapes only. Non-manifold topology is processed separately: ssv; 13.11.2010)
- if (isManifold && aHasGeom)
+ if (isManifold && aHasGeom)
{
- Handle(Standard_Transient) info;
- mappedShape =
- XSAlgo::AlgoContainer()->ProcessShape( mappedShape, myPrecision, myMaxTol,
- "read.step.resource.name",
- "read.step.sequence", info,
- aPS.Next());
- XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
+ // Set tolerances for shape processing.
+ // These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set from outside.
+ Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetParameters();
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters);
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters);
+ XSAlgo_ShapeProcessor aShapeProcessor(aParameters);
+ mappedShape = aShapeProcessor.ProcessShape(mappedShape, GetProcessingFlags().first, aPS.Next());
+ aShapeProcessor.MergeTransferInfo(TP, nbTPitems);
}
}
found = !mappedShape.IsNull();
// Apply ShapeFix
Handle(Transfer_Binder) binder = TP->Find(fs);
sb = Handle(TransferBRep_ShapeBinder)::DownCast(binder);
- if (!sb.IsNull() && !sb->Result().IsNull()) {
+ if (!sb.IsNull() && !sb->Result().IsNull())
+ {
TopoDS_Shape S = sb->Result();
- Handle(Standard_Transient) info;
- TopoDS_Shape shape = XSAlgo::AlgoContainer()->ProcessShape(S, myPrecision, myMaxTol,
- "read.step.resource.name",
- "read.step.sequence", info,
- theProgress);
- // TopoDS_Shape shape = XSAlgo::AlgoContainer()->PerformFixShape( S, TP, myPrecision, myMaxTol );
+ Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetParameters();
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters);
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters);
+ XSAlgo_ShapeProcessor aShapeProcessor(aParameters);
+ TopoDS_Shape shape = aShapeProcessor.ProcessShape(S, GetProcessingFlags().first, theProgress);
+ aShapeProcessor.MergeTransferInfo(TP, nbTPitems);
+
if (shape != S)
+ {
sb->SetResult(shape);
+ }
- XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
+ aShapeProcessor.MergeTransferInfo(TP, nbTPitems);
}
{
public:
-
Standard_EXPORT STEPControl_ActorRead(const Handle(Interface_InterfaceModel)& theModel);
Standard_EXPORT virtual Standard_Boolean Recognize (const Handle(Standard_Transient)& start) Standard_OVERRIDE;
const StepData_Factors& theLocalFactors = StepData_Factors());
-
-
DEFINE_STANDARD_RTTIEXT(STEPControl_ActorRead,Transfer_ActorOfTransientProcess)
protected:
-
-
//! Transfers product definition entity
//! theUseTrsf - special flag for using Axis2Placement from ShapeRepresentation for transform root shape
Standard_EXPORT Handle(TransferBRep_ShapeBinder) TransferEntity (
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress);
-
-
private:
-
-
Standard_EXPORT TopoDS_Shell closeIDEASShell (const TopoDS_Shell& shell, const TopTools_ListOfShape& closingShells);
Standard_EXPORT void computeIDEASClosings (const TopoDS_Compound& comp, TopTools_IndexedDataMapOfShapeListOfShape& shellClosingMap);
TopoDS_Compound& theCund,
Message_ProgressScope& thePS);
+private:
StepToTopoDS_NMTool myNMTool;
Standard_Real myPrecision;
Standard_Real myMaxTol;
Handle(StepRepr_Representation) mySRContext;
Handle(Interface_InterfaceModel) myModel;
-
};
-
-
-
-
-
-
#endif // _STEPControl_ActorRead_HeaderFile
#include <TransferBRep_ShapeMapper.hxx>
#include <UnitsMethods.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
IMPLEMENT_STANDARD_RTTIEXT(STEPControl_ActorWrite,Transfer_ActorOfFinderProcess)
myContext.SetLevel ( 1 ); // set assembly level to 1 (to ensure)
if (!model->IsInitializedUnit())
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
model->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
}
Standard_Real aLFactor = model->WriteLengthUnit();
return IsAssembly ( theModel, S );
}
-//=======================================================================
-//function : TransferShape
-//purpose :
-//=======================================================================
-
-/*
-static void UpdateMap (const TopoDS_Shape &shape,
- BRepTools_Modifier &M1,
- BRepTools_Modifier &M2,
- const Handle(Transfer_FinderProcess) &FinderProcess)
-{
- TopoDS_Shape S = M1.ModifiedShape ( shape );
- S = M2.ModifiedShape ( S );
- if ( S == shape ) return;
-
- Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FinderProcess, S );
- Handle(Transfer_Binder) binder = FinderProcess->Find ( mapper );
- if ( ! binder.IsNull() ) {
- mapper = TransferBRep::ShapeMapper ( FinderProcess, shape );
- FinderProcess->Bind ( mapper, binder );
- }
-
- for ( TopoDS_Iterator it(shape); it.More(); it.Next() )
- UpdateMap ( it.Value(), M1, M2, FinderProcess );
-}
-*/
-
// PTV 16.09.2002 added for transferring vertices.
static Standard_Boolean transferVertex (const Handle(Transfer_FinderProcess)& FP,
Handle(StepShape_HArray1OfGeometricSetSelect)& aGSS,
default : trmode =STEPControl_GeometricCurveSet; break;
}
}
- //:abv 24Jan99 CAX-IF TRJ3: expanded Shape Processing
-// TopoDS_Shape aShape = xShape;
- // eliminate conical surfaces with negative semiangles
-// Handle(TopoDSToStep_ConicalSurfModif) CSM = new TopoDSToStep_ConicalSurfModif();
-// BRepTools_Modifier CSMT(aShape,CSM);
-// if ( CSMT.IsDone() ) aShape = CSMT.ModifiedShape ( aShape );
-// // eliminate indirect elementary surfaces
-// Handle(TopoDSToStep_DirectModification) DM = new TopoDSToStep_DirectModification();
-// BRepTools_Modifier DMT(aShape,DM);
-// if ( DMT.IsDone() ) aShape = DMT.ModifiedShape ( aShape );
-//// aShape = TopoDSToStep::DirectFaces(xShape);
+
Message_ProgressScope aPS1(aPS.Next(), NULL, 2);
TopoDS_Shape aShape = xShape;
- Handle(Standard_Transient) info;
- if (hasGeometry(aShape))
+ Transfer_ActorOfFinderProcess::ParameterMap aParameters = GetParameters();
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", Tol, true, aParameters);
+ XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d",
+ aStepModel->InternalParameters.ReadMaxPrecisionVal,
+ true,
+ aParameters);
+ XSAlgo_ShapeProcessor aShapeProcessor(aParameters);
+
+ if (hasGeometry(aShape))
{
- Standard_Real maxTol = aStepModel->InternalParameters.ReadMaxPrecisionVal;
+ aShape = aShapeProcessor.ProcessShape(xShape, GetShapeProcessFlags().first, aPS1.Next());
- aShape = XSAlgo::AlgoContainer()->ProcessShape(xShape, Tol, maxTol,
- "write.step.resource.name",
- "write.step.sequence", info,
- aPS1.Next());
if (aPS1.UserBreak())
+ {
return Handle(Transfer_Binder)();
+ }
}
if (!isManifold)
{
- mergeInfoForNM(FP, info);
+ mergeInfoForNM(FP, aShapeProcessor.GetContext());
}
// create a STEP entity corresponding to shape
subbind->AddResult(TransientResult(itemTess));
}
- //:abv 24Jan99 CAX-IF TRJ3: Update FinderProcess map to take into account shape processing
-// UpdateMap ( xShape, CSMT, DMT, FP );
- if (!info.IsNull())
- XSAlgo::AlgoContainer()->MergeTransferInfo(FP, info);
+ // If shape is not processed, this function does nothing. Intentionally.
+ aShapeProcessor.MergeTransferInfo(FP);
}
// - Make Shape Representation
{
public:
-
-
Standard_EXPORT STEPControl_ActorWrite();
Standard_EXPORT virtual Standard_Boolean Recognize (const Handle(Transfer_Finder)& start) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsAssembly (const Handle(StepData_StepModel)& theModel,
TopoDS_Shape& S) const;
-
-
-
DEFINE_STANDARD_RTTIEXT(STEPControl_ActorWrite,Transfer_ActorOfFinderProcess)
-protected:
-
-
-
-
private:
-
-
//! Non-manifold shapes are stored in NMSSR group
//! (NON_MANIFOLD_SURFACE_SHAPE_REPRESENTATION).
//! Use this method to get the corresponding NMSSR (or
Standard_Boolean separateShapeToSoloVertex(const TopoDS_Shape& theShape,
TopTools_SequenceOfShape& theVertices);
-
-
+private:
Standard_Integer mygroup;
Standard_Real mytoler;
STEPConstruct_ContextTool myContext;
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
+#include <DE_ShapeFixParameters.hxx>
#include <IFSelect_WorkLibrary.hxx>
#include <Interface_EntityIterator.hxx>
#include <Interface_Graph.hxx>
#include <TColStd_MapOfAsciiString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <Transfer_TransientProcess.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
{
STEPControl_Controller::Init();
SetWS (WS,scratch);
- SetNorm ("STEP");
+ SetNorm("STEP");
}
//=======================================================================
return aName;
}
+//=================================================================================================
+
+DE_ShapeFixParameters STEPControl_Reader::GetDefaultParameters() const
+{
+ return DESTEP_Parameters::GetDefaultReadingParamsSTEP();
+}
+
+//=================================================================================================
+
+ShapeProcess::OperationsFlags STEPControl_Reader::GetDefaultShapeProcessFlags() const
+{
+ ShapeProcess::OperationsFlags aFlags;
+ aFlags.set(ShapeProcess::Operation::FixShape);
+ return aFlags;
+}
+
+
//=======================================================================
//function : findUnits
//purpose :
//! Performs only if a model is not NULL
Standard_EXPORT Standard_Real SystemLengthUnit() const;
-
protected:
+ //! Returns default parameters for shape fixing.
+ //! This method is used by the base class to get default parameters for shape fixing.
+ //! @return default parameters for shape fixing.
+ Standard_EXPORT virtual DE_ShapeFixParameters GetDefaultParameters() const Standard_OVERRIDE;
-
-
+ //! Returns default flags for shape processing.
+ //! @return Default flags for shape processing.
+ Standard_EXPORT virtual ShapeProcess::OperationsFlags GetDefaultShapeProcessFlags() const Standard_OVERRIDE;
private:
-
-
//! Returns units for length , angle and solidangle for shape representations
Standard_EXPORT Standard_Boolean findUnits (const Handle(StepRepr_RepresentationContext)& theReprContext, TColStd_Array1OfAsciiString& theNameUnits, TColStd_Array1OfReal& theFactorUnits);
-
-
-
-
};
#include <STEPControl_Writer.hxx>
+#include <DE_ShapeFixParameters.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Macros.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Shape.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
{
STEPControl_Controller::Init();
- SetWS (WS,scratch);
+ SetWS(WS, scratch);
}
thesession->TransferWriter()->SetTransferMode (mws);
if (!Model()->IsInitializedUnit())
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
Model()->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
}
if (!thesession->Model().IsNull())
Handle(STEPControl_ActorWrite) ActWrite =
Handle(STEPControl_ActorWrite)::DownCast(WS()->NormAdaptor()->ActorWrite());
ActWrite->SetGroupMode(Handle(StepData_StepModel)::DownCast(thesession->Model())->InternalParameters.WriteAssembly);
+ InitializeMissingParameters();
return thesession->TransferWriteShape(sh, compgraph, theProgress);
}
{
thesession->TransferWriter()->PrintStats (what,mode);
}
+//=============================================================================
+
+void STEPControl_Writer::SetParameters(const ParameterMap& theParameters)
+{
+ if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor())
+ {
+ anActor->SetParameters(theParameters);
+ }
+}
+
+//=============================================================================
+
+void STEPControl_Writer::SetParameters(ParameterMap&& theParameters)
+{
+ if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor())
+ {
+ anActor->SetParameters(std::move(theParameters));
+ }
+}
+
+//=============================================================================
+
+void STEPControl_Writer::SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters)
+{
+ if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor())
+ {
+ anActor->SetParameters(theParameters, theAdditionalParameters);
+ }
+}
+
+//=============================================================================
+
+const STEPControl_Writer::ParameterMap& STEPControl_Writer::GetParameters() const
+{
+ static const ParameterMap anEmptyMap;
+ const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor();
+ return anActor.IsNull() ? anEmptyMap : anActor->GetParameters();
+}
+
+//=============================================================================
+
+void STEPControl_Writer::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor())
+ {
+ anActor->SetShapeProcessFlags(theFlags);
+ }
+}
+
+//=============================================================================
+
+const STEPControl_Writer::ProcessingFlags& STEPControl_Writer::GetShapeProcessFlags() const
+{
+ static const ProcessingFlags anEmptyFlags;
+ const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor();
+ return anActor.IsNull() ? anEmptyFlags : anActor->GetShapeProcessFlags();
+}
+
+//=============================================================================
+
+Handle(Transfer_ActorOfFinderProcess) STEPControl_Writer::GetActor() const
+{
+ Handle(XSControl_WorkSession) aSession = WS();
+ if (aSession.IsNull())
+ {
+ return nullptr;
+ }
+
+ Handle(XSControl_Controller) aController = aSession->NormAdaptor();
+ if (aController.IsNull())
+ {
+ return nullptr;
+ }
+
+ return aController->ActorWrite();
+}
+
+//=============================================================================
+
+void STEPControl_Writer::InitializeMissingParameters()
+{
+ if (GetParameters().empty())
+ {
+ SetParameters(DESTEP_Parameters::GetDefaultWritingParamsSTEP());
+ }
+ if (GetShapeProcessFlags().second == false)
+ {
+ ShapeProcess::OperationsFlags aFlags;
+ aFlags.set(ShapeProcess::Operation::SplitCommonVertex);
+ aFlags.set(ShapeProcess::Operation::DirectFaces);
+ SetShapeProcessFlags(aFlags);
+ }
+}
#ifndef _STEPControl_Writer_HeaderFile
#define _STEPControl_Writer_HeaderFile
+#include <ShapeProcess.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-
#include <Standard_Real.hxx>
#include <IFSelect_ReturnStatus.hxx>
#include <DESTEP_Parameters.hxx>
#include <Standard_Integer.hxx>
#include <Message_ProgressRange.hxx>
+#include <unordered_map>
+
+struct DE_ShapeFixParameters;
class XSControl_WorkSession;
class StepData_StepModel;
class TopoDS_Shape;
-
+class Transfer_ActorOfFinderProcess;
//! This class creates and writes
//! STEP files from Open CASCADE models. A STEP file can be
class STEPControl_Writer
{
public:
-
DEFINE_STANDARD_ALLOC
+ using ParameterMap = std::unordered_map<std::string, std::string>;
+ // Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
+ // we use a pair. The first element is the flags, the second element is a boolean value that indicates
+ // whether the flags were set.
+ using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
//! Creates a Writer from scratch
Standard_EXPORT STEPControl_Writer();
//! AND the list of entity numbers in the STEP model.
Standard_EXPORT void PrintStatsTransfer (const Standard_Integer what, const Standard_Integer mode = 0) const;
-
-
-
-protected:
-
-
-
-
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
+
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ Standard_EXPORT const ParameterMap& GetParameters() const;
+
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
+
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return Pair of values defining operations to be performed on shapes and a boolean value
+ //! that indicates whether the flags were set.
+ Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const;
private:
+ //! Returns the Actor for the Transfer of an Entity.
+ //! This Actor is used by the Writer to perform the Transfer.
+ //! @return the Actor for the Transfer of an Entity. May be nullptr.
+ Handle(Transfer_ActorOfFinderProcess) GetActor() const;
+ //! If parameters haven't yet been provided, initializes them with default values
+ //! provided by GetDefaultParameters() method.
+ void InitializeMissingParameters();
-
+private:
Handle(XSControl_WorkSession) thesession;
-
-
};
-
-
-
-
-
-
#endif // _STEPControl_Writer_HeaderFile
return anIsAnySuccess;
}
+//=================================================================================================
+
+std::pair<ShapeProcess::Operation, bool> ShapeProcess::ToOperationFlag(const char* theName)
+{
+ if (!theName)
+ {
+ return {Operation::First, false};
+ }
+
+ for (std::underlying_type<Operation>::type anOperation = Operation::First; anOperation <= Operation::Last; ++anOperation)
+ {
+ const char* anOperationName = toOperationName(static_cast<Operation>(anOperation));
+ if (anOperationName && !strcmp(theName, anOperationName))
+ {
+ return {static_cast<Operation>(anOperation), true};
+ }
+ }
+ return {Operation::First, false};
+}
+
//=======================================================================
//function : getOperators
//purpose :
const OperationsFlags& theOperations,
const Message_ProgressRange& theProgress = Message_ProgressRange());
+ //! Converts operation name to operation flag.
+ //! @param theName Operation name.
+ //! @return Operation flag and true if the operation name is valid, false otherwise.
+ Standard_EXPORT static std::pair<Operation, bool> ToOperationFlag(const char* theName);
+
private:
//! Returns operators to be performed according to the specified flags.
//! @param theFlags Bitset of operations flags.
#include <TopoDS_Wire.hxx>
#include <Transfer_TransientProcess.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
// ============================================================================
// Method : RemoveSinglePCurve
// advanced check
- XSAlgo::AlgoContainer()->CheckPCurve (myEdge, aFace, preci, sbwd->IsSeam(i));
+ XSAlgo_ShapeProcessor::CheckPCurve(myEdge, aFace, preci, sbwd->IsSeam(i));
}
}
#include <Transfer_ProcessForFinder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_TransientMapper.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Transfer_ActorOfFinderProcess,Transfer_ActorOfProcessForFinder)
+//=============================================================================
+
Transfer_ActorOfFinderProcess::Transfer_ActorOfFinderProcess () { themodetrans = 0; }
+//=============================================================================
+
Standard_Integer& Transfer_ActorOfFinderProcess::ModeTrans ()
{ return themodetrans; }
+//=============================================================================
+
Handle(Transfer_Binder) Transfer_ActorOfFinderProcess::Transfer
(const Handle(Transfer_Finder)& fnd,
const Handle(Transfer_FinderProcess)& FP,
return TransientResult (res);
}
+//=============================================================================
+
Handle(Transfer_Binder) Transfer_ActorOfFinderProcess::Transferring
(const Handle(Transfer_Finder)& ent,
const Handle(Transfer_ProcessForFinder)& TP,
return Transfer(ent,Handle(Transfer_FinderProcess)::DownCast(TP), theProgress);
}
+//=============================================================================
+
Handle(Standard_Transient) Transfer_ActorOfFinderProcess::TransferTransient
(const Handle(Standard_Transient)& /*ent*/,
const Handle(Transfer_FinderProcess)&,
Handle(Standard_Transient) nulres;
return nulres;
}
+
+//=============================================================================
+
+void Transfer_ActorOfFinderProcess::SetParameters(const ParameterMap& theParameters)
+{
+ myShapeProcParams = theParameters;
+}
+
+//=============================================================================
+
+void Transfer_ActorOfFinderProcess::SetParameters(ParameterMap&& theParameters)
+{
+ myShapeProcParams = std::move(theParameters);
+}
+
+//=============================================================================
+
+void Transfer_ActorOfFinderProcess::SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters)
+{
+ myShapeProcParams.clear();
+ XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams);
+ for (const auto& aParam : theAdditionalParameters)
+ {
+ if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
+ {
+ myShapeProcParams[aParam.first] = aParam.second;
+ }
+ }
+}
+
+//=============================================================================
+
+void Transfer_ActorOfFinderProcess::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ myShapeProcFlags.first = theFlags;
+ myShapeProcFlags.second = true;
+}
#define _Transfer_ActorOfFinderProcess_HeaderFile
#include <Standard.hxx>
-
+#include <ShapeProcess.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx>
+
+#include <unordered_map>
+
+struct DE_ShapeFixParameters;
class Transfer_Binder;
class Transfer_Finder;
class Transfer_ProcessForFinder;
//! a user. To be interpreted for each norm
class Transfer_ActorOfFinderProcess : public Transfer_ActorOfProcessForFinder
{
-
public:
+ using ParameterMap = std::unordered_map<std::string, std::string>;
+ // Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
+ // we use a pair. The first element is the flags, the second element is a boolean value that indicates
+ // whether the flags were set.
+ using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
-
+public:
Standard_EXPORT Transfer_ActorOfFinderProcess();
//! Returns the Transfer Mode, modifiable
const Handle(Transfer_FinderProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
-
-
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
+
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ inline const ParameterMap& GetParameters() const { return myShapeProcParams; }
+
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
+
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return Pair of values defining operations to be performed on shapes and a boolean value
+ //! that indicates whether the flags were set.
+ inline const ProcessingFlags& GetShapeProcessFlags() const { return myShapeProcFlags; }
DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfFinderProcess,Transfer_ActorOfProcessForFinder)
protected:
-
-
Standard_Integer themodetrans;
-
private:
-
-
-
-
+ ParameterMap myShapeProcParams; //!< Parameters for shape processing.
+ ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
};
#include <Transfer_ProcessForTransient.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_TransientProcess.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Transfer_ActorOfTransientProcess,Transfer_ActorOfProcessForTransient)
-Transfer_ActorOfTransientProcess::Transfer_ActorOfTransientProcess () { }
+Transfer_ActorOfTransientProcess::Transfer_ActorOfTransientProcess()
+{}
+
+//=============================================================================
Handle(Transfer_Binder) Transfer_ActorOfTransientProcess::Transfer
(const Handle(Standard_Transient)& start,
return TransientResult (res);
}
+//=============================================================================
+
Handle(Transfer_Binder) Transfer_ActorOfTransientProcess::Transferring
(const Handle(Standard_Transient)& ent,
const Handle(Transfer_ProcessForTransient)& TP,
return Transfer(ent,Handle(Transfer_TransientProcess)::DownCast(TP), theProgress);
}
+//=============================================================================
+
Handle(Standard_Transient) Transfer_ActorOfTransientProcess::TransferTransient
(const Handle(Standard_Transient)& /*ent*/,
const Handle(Transfer_TransientProcess)& /*TP*/,
Handle(Standard_Transient) nulres;
return nulres;
}
+
+//=============================================================================
+
+void Transfer_ActorOfTransientProcess::SetParameters(const ParameterMap& theParameters)
+{
+ myShapeProcParams = theParameters;
+}
+
+//=============================================================================
+
+void Transfer_ActorOfTransientProcess::SetParameters(ParameterMap&& theParameters)
+{
+ myShapeProcParams = std::move(theParameters);
+}
+
+//=============================================================================
+
+void Transfer_ActorOfTransientProcess::SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters)
+{
+ myShapeProcParams.clear();
+ XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams);
+ for (const auto& aParam : theAdditionalParameters)
+ {
+ if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
+ {
+ myShapeProcParams[aParam.first] = aParam.second;
+ }
+ }
+}
+
+//=============================================================================
+
+void Transfer_ActorOfTransientProcess::SetProcessingFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ myShapeProcFlags.first = theFlags;
+ myShapeProcFlags.second = true;
+}
#ifndef _Transfer_ActorOfTransientProcess_HeaderFile
#define _Transfer_ActorOfTransientProcess_HeaderFile
+#include <ShapeProcess.hxx>
#include <Standard.hxx>
-
#include <Transfer_ActorOfProcessForTransient.hxx>
+
+#include <unordered_map>
+
+struct DE_ShapeFixParameters;
class Transfer_Binder;
class Standard_Transient;
class Transfer_ProcessForTransient;
//! The original class was renamed. Compatibility only
class Transfer_ActorOfTransientProcess : public Transfer_ActorOfProcessForTransient
{
-
public:
+ using ParameterMap = std::unordered_map<std::string, std::string>;
+ // Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
+ // we use a pair. The first element is the flags, the second element is a boolean value that indicates
+ // whether the flags were set.
+ using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
-
+public:
Standard_EXPORT Transfer_ActorOfTransientProcess();
Standard_EXPORT virtual Handle(Transfer_Binder) Transferring
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
-
-
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
+
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ inline const ParameterMap& GetParameters() const { return myShapeProcParams; }
+
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetProcessingFlags(const ShapeProcess::OperationsFlags& theFlags);
+
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return Pair: the flags defining operations to be performed on shapes and a boolean value that indicates
+ //! whether the flags were set.
+ inline const ProcessingFlags& GetProcessingFlags() const { return myShapeProcFlags; }
DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfTransientProcess,Transfer_ActorOfProcessForTransient)
-protected:
-
-
-
-
private:
-
-
-
-
+ ParameterMap myShapeProcParams; //!< Parameters for shape processing.
+ ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
};
-
-
-
-
-
-
#endif // _Transfer_ActorOfTransientProcess_HeaderFile
Message_ProgressScope aScope(theProgress, NULL, 1, true);
while (!actor.IsNull())
{
- if (actor->Recognize(start)) binder = actor->Transferring(start, this, aScope.Next());
- else binder.Nullify();
- if (!binder.IsNull()) break;
+ if (actor->Recognize(start))
+ {
+ binder = actor->Transferring(start, this, aScope.Next());
+ }
+ else
+ {
+ binder.Nullify();
+ }
+ if (!binder.IsNull())
+ {
+ break;
+ }
actor = actor->Next();
}
if (aScope.UserBreak())
#include <XCAFDoc_ShapeTool.hxx>
#include <XDEDRAW_Shapes.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <UnitsMethods.hxx>
#include <stdio.h>
Standard_Real aLengthUnit = 1.;
if (!XCAFDoc_DocumentTool::GetLengthUnit(Doc, aLengthUnit))
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
aLengthUnit = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
XCAFDoc_DocumentTool::SetLengthUnit(Doc, aLengthUnit);
}
#include <Transfer_TransientProcess.hxx>
#include <UnitsMethods.hxx>
+#include <sstream>
+#include <unordered_set>
+
+namespace
+{
+ //! Function to split a string based on multiple delimiters.
+ //! @param aString String to split.
+ //! @param delimiters Set of delimiters.
+ //! @return Vector of tokens.
+ std::vector<std::string> splitString(const std::string& aString, const std::unordered_set<char>& delimiters)
+ {
+ std::vector<std::string> aResult;
+ std::string aCurrentToken;
+
+ for (char aCurrentCharacter : aString)
+ {
+ if (delimiters.find(aCurrentCharacter) != delimiters.end())
+ {
+ if (!aCurrentToken.empty())
+ {
+ aResult.emplace_back(std::move(aCurrentToken));
+ aCurrentToken.clear();
+ }
+ }
+ else
+ {
+ aCurrentToken += aCurrentCharacter;
+ }
+ }
+
+ if (!aCurrentToken.empty())
+ {
+ aResult.emplace_back(std::move(aCurrentToken));
+ }
+
+ return aResult;
+ }
+}
+
//=============================================================================
XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const ParameterMap& theParameters,
const DE_ShapeFixParameters& theShapeFixParameters)
: myParameters(theParameters)
{
- FillParameterMap(theShapeFixParameters, myParameters);
+ FillParameterMap(theShapeFixParameters, false, myParameters);
}
//=============================================================================
XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const DE_ShapeFixParameters& theParameters)
{
ParameterMap aMap;
- FillParameterMap(theParameters, aMap);
+ FillParameterMap(theParameters, false, aMap);
myParameters = aMap;
}
const OperationsFlags& theOperations,
const Message_ProgressRange& theProgress)
{
+ if (theShape.IsNull())
+ {
+ return theShape;
+ }
+
initializeContext(theShape);
return ShapeProcess::Perform(myContext, theOperations, theProgress) ? myContext->Result() : theShape;
}
//=============================================================================
+XSAlgo_ShapeProcessor::ProcessingData XSAlgo_ShapeProcessor::ReadProcessingData(const std::string& theFileResourceName,
+ const std::string& theScopeResourceName)
+{
+ const Standard_CString aFileName = Interface_Static::CVal(theFileResourceName.c_str());
+ Handle(ShapeProcess_ShapeContext) aContext = new ShapeProcess_ShapeContext(TopoDS_Shape(), aFileName);
+ if (!aContext->ResourceManager()->IsInitialized())
+ {
+ // If resource file wasn't found, use static values instead
+ Interface_Static::FillMap(aContext->ResourceManager()->GetMap());
+ }
+ const std::string aScope = Interface_Static::CVal(theScopeResourceName.c_str());
+
+ // Copy parameters to the result.
+ ParameterMap aResultParameters;
+ OperationsFlags aResultFlags;
+ const Resource_DataMapOfAsciiStringAsciiString& aMap = aContext->ResourceManager()->GetMap();
+ using RMapIter = Resource_DataMapOfAsciiStringAsciiString::Iterator;
+ for (RMapIter anIter(aMap); anIter.More(); anIter.Next())
+ {
+ std::string aKey = anIter.Key().ToCString();
+ const size_t aScopePosition = aKey.find(aScope);
+ if (aScopePosition != 0)
+ {
+ // Ignore all parameters that don't start with the specified scope.
+ continue;
+ }
+ // Remove the scope from the key + 1 for the dot.
+ // "FromIGES.FixShape.FixFreeFaceMode" -> "FixShape.FixFreeFaceMode"
+ aKey.erase(0, aScope.size() + 1);
+ if (aKey != "exec.op")
+ {
+ // If it is not an operation flag, add it to the parameters.
+ aResultParameters[aKey] = anIter.Value().ToCString();
+ }
+ else
+ {
+ // Parse operations flags.
+ const std::vector<std::string> anOperationStrings = splitString(anIter.Value().ToCString(), {' ', '\t', ',', ';'});
+ for (const auto& anOperationString : anOperationStrings)
+ {
+ std::pair<ShapeProcess::Operation, bool> anOperationFlag = ShapeProcess::ToOperationFlag(anOperationString.c_str());
+ if (anOperationFlag.second)
+ {
+ aResultFlags.set(anOperationFlag.first);
+ }
+ }
+ }
+ }
+ return {aResultParameters, aResultFlags};
+}
+
+//=============================================================================
+
void XSAlgo_ShapeProcessor::FillParameterMap(const DE_ShapeFixParameters& theParameters,
+ const bool theIsReplace,
XSAlgo_ShapeProcessor::ParameterMap& theMap)
{
- // Helper lambda to convert enum to string.
- auto makeString = [](const DE_ShapeFixParameters::FixMode theMode)
+ SetParameter("FixShape.Tolerance3d", theParameters.Tolerance3d, theIsReplace, theMap);
+ SetParameter("FixShape.MaxTolerance3d", theParameters.MaxTolerance3d, theIsReplace, theMap);
+ SetParameter("FixShape.MinTolerance3d", theParameters.MinTolerance3d, theIsReplace, theMap);
+ SetParameter("DetalizationLevel", std::to_string(theParameters.DetalizationLevel), theIsReplace, theMap);
+ SetParameter("NonManifold", std::to_string(theParameters.NonManifold), theIsReplace, theMap);
+ SetParameter("FixShape.FixFreeShellMode", theParameters.FixFreeShellMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixFreeFaceMode", theParameters.FixFreeFaceMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixFreeWireMode", theParameters.FixFreeWireMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixSameParameterMode", theParameters.FixSameParameterMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixSolidMode", theParameters.FixSolidMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixShellOrientationMode", theParameters.FixShellOrientationMode, theIsReplace, theMap);
+ SetParameter("FixShape.CreateOpenSolidMode", theParameters.CreateOpenSolidMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixShellMode", theParameters.FixShellMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixFaceOrientationMode", theParameters.FixFaceOrientationMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixFaceMode", theParameters.FixFaceMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixWireMode", theParameters.FixWireMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixOrientationMode", theParameters.FixOrientationMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixAddNaturalBoundMode", theParameters.FixAddNaturalBoundMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixMissingSeamMode", theParameters.FixMissingSeamMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixSmallAreaWireMode", theParameters.FixSmallAreaWireMode, theIsReplace, theMap);
+ SetParameter("FixShape.RemoveSmallAreaFaceMode", theParameters.RemoveSmallAreaFaceMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixIntersectingWiresMode", theParameters.FixIntersectingWiresMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixLoopWiresMode", theParameters.FixLoopWiresMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixSplitFaceMode", theParameters.FixSplitFaceMode, theIsReplace, theMap);
+ SetParameter("FixShape.AutoCorrectPrecisionMode", theParameters.AutoCorrectPrecisionMode, theIsReplace, theMap);
+ SetParameter("FixShape.ModifyTopologyMode", theParameters.ModifyTopologyMode, theIsReplace, theMap);
+ SetParameter("FixShape.ModifyGeometryMode", theParameters.ModifyGeometryMode, theIsReplace, theMap);
+ SetParameter("FixShape.ClosedWireMode", theParameters.ClosedWireMode, theIsReplace, theMap);
+ SetParameter("FixShape.PreferencePCurveMode", theParameters.PreferencePCurveMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixReorderMode", theParameters.FixReorderMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixSmallMode", theParameters.FixSmallMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixConnectedMode", theParameters.FixConnectedMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixEdgeCurvesMode", theParameters.FixEdgeCurvesMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixDegeneratedMode", theParameters.FixDegeneratedMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixLackingMode", theParameters.FixLackingMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixSelfIntersectionMode", theParameters.FixSelfIntersectionMode, theIsReplace, theMap);
+ SetParameter("FixShape.RemoveLoopMode", theParameters.RemoveLoopMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixReversed2dMode", theParameters.FixReversed2dMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixRemovePCurveMode", theParameters.FixRemovePCurveMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixRemoveCurve3dMode", theParameters.FixRemoveCurve3dMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixAddPCurveMode", theParameters.FixAddPCurveMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixAddCurve3dMode", theParameters.FixAddCurve3dMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixSeamMode", theParameters.FixSeamMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixShiftedMode", theParameters.FixShiftedMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixEdgeSameParameterMode", theParameters.FixEdgeSameParameterMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixNotchedEdgesMode", theParameters.FixNotchedEdgesMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixTailMode", theParameters.FixTailMode, theIsReplace, theMap);
+ SetParameter("FixShape.MaxTailAngle", theParameters.MaxTailAngle, theIsReplace, theMap);
+ SetParameter("FixShape.MaxTailWidth", theParameters.MaxTailWidth, theIsReplace, theMap);
+ SetParameter("FixShape.FixSelfIntersectingEdgeMode", theParameters.FixSelfIntersectingEdgeMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixIntersectingEdgesMode", theParameters.FixIntersectingEdgesMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixNonAdjacentIntersectingEdgesMode",
+ theParameters.FixNonAdjacentIntersectingEdgesMode,
+ theIsReplace,
+ theMap);
+ SetParameter("FixShape.FixVertexPositionMode", theParameters.FixVertexPositionMode, theIsReplace, theMap);
+ SetParameter("FixShape.FixVertexToleranceMode", theParameters.FixVertexToleranceMode, theIsReplace, theMap);
+}
+
+//=============================================================================
+
+void XSAlgo_ShapeProcessor::SetParameter(const char* theKey,
+ DE_ShapeFixParameters::FixMode theValue,
+ const bool theIsReplace,
+ ParameterMap& theMap)
+{
+ SetParameter(theKey,
+ std::to_string(static_cast<std::underlying_type<DE_ShapeFixParameters::FixMode>::type>(theValue)),
+ theIsReplace,
+ theMap);
+}
+
+//=============================================================================
+
+void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, double theValue, const bool theIsReplace, ParameterMap& theMap)
+{
+ // Note that conversion with std::to_string() here is not possible, since it normally preserves
+ // only first 6 digits (before C++26). As a result, any value of 1e-7 or below will turn into 0.
+ // By using std::ostringstream with std::setprecision(6) formatting we will preserve first 6
+ // SIGNIFICANT digits.
+ std::ostringstream aStrStream;
+ aStrStream << std::setprecision(6) << theValue;
+ SetParameter(theKey, aStrStream.str(), theIsReplace, theMap);
+}
+
+//=============================================================================
+
+void XSAlgo_ShapeProcessor::SetParameter(const char* theKey,
+ std::string&& theValue,
+ const bool theIsReplace,
+ ParameterMap& theMap)
+{
+ if (theIsReplace)
{
- return std::to_string(static_cast<std::underlying_type<DE_ShapeFixParameters::FixMode>::type>(theMode));
- };
-
- theMap.emplace("ShapeFix.Tolerance3d", std::to_string(theParameters.Tolerance3d));
- theMap.emplace("ShapeFix.MaxTolerance3d", std::to_string(theParameters.MaxTolerance3d));
- theMap.emplace("ShapeFix.MinTolerance3d", std::to_string(theParameters.MinTolerance3d));
- theMap.emplace("DetalizationLevel", std::to_string(theParameters.DetalizationLevel));
- theMap.emplace("NonManifold", std::to_string(theParameters.NonManifold));
- theMap.emplace("ShapeFix.FixFreeShellMode", makeString(theParameters.FixFreeShellMode));
- theMap.emplace("ShapeFix.FixFreeFaceMode", makeString(theParameters.FixFreeFaceMode));
- theMap.emplace("ShapeFix.FixFreeWireMode", makeString(theParameters.FixFreeWireMode));
- theMap.emplace("ShapeFix.FixSameParameterMode", makeString(theParameters.FixSameParameterMode));
- theMap.emplace("ShapeFix.FixSolidMode", makeString(theParameters.FixSolidMode));
- theMap.emplace("ShapeFix.FixShellOrientationMode", makeString(theParameters.FixShellOrientationMode));
- theMap.emplace("ShapeFix.CreateOpenSolidMode", makeString(theParameters.CreateOpenSolidMode));
- theMap.emplace("ShapeFix.FixShellMode", makeString(theParameters.FixShellMode));
- theMap.emplace("ShapeFix.FixFaceOrientationMode", makeString(theParameters.FixFaceOrientationMode));
- theMap.emplace("ShapeFix.FixFaceMode", makeString(theParameters.FixFaceMode));
- theMap.emplace("ShapeFix.FixWireMode", makeString(theParameters.FixWireMode));
- theMap.emplace("ShapeFix.FixOrientationMode", makeString(theParameters.FixOrientationMode));
- theMap.emplace("ShapeFix.FixAddNaturalBoundMode", makeString(theParameters.FixAddNaturalBoundMode));
- theMap.emplace("ShapeFix.FixMissingSeamMode", makeString(theParameters.FixMissingSeamMode));
- theMap.emplace("ShapeFix.FixSmallAreaWireMode", makeString(theParameters.FixSmallAreaWireMode));
- theMap.emplace("ShapeFix.RemoveSmallAreaFaceMode", makeString(theParameters.RemoveSmallAreaFaceMode));
- theMap.emplace("ShapeFix.FixIntersectingWiresMode", makeString(theParameters.FixIntersectingWiresMode));
- theMap.emplace("ShapeFix.FixLoopWiresMode", makeString(theParameters.FixLoopWiresMode));
- theMap.emplace("ShapeFix.FixSplitFaceMode", makeString(theParameters.FixSplitFaceMode));
- theMap.emplace("ShapeFix.AutoCorrectPrecisionMode", makeString(theParameters.AutoCorrectPrecisionMode));
- theMap.emplace("ShapeFix.ModifyTopologyMode", makeString(theParameters.ModifyTopologyMode));
- theMap.emplace("ShapeFix.ModifyGeometryMode", makeString(theParameters.ModifyGeometryMode));
- theMap.emplace("ShapeFix.ClosedWireMode", makeString(theParameters.ClosedWireMode));
- theMap.emplace("ShapeFix.PreferencePCurveMode", makeString(theParameters.PreferencePCurveMode));
- theMap.emplace("ShapeFix.FixReorderMode", makeString(theParameters.FixReorderMode));
- theMap.emplace("ShapeFix.FixSmallMode", makeString(theParameters.FixSmallMode));
- theMap.emplace("ShapeFix.FixConnectedMode", makeString(theParameters.FixConnectedMode));
- theMap.emplace("ShapeFix.FixEdgeCurvesMode", makeString(theParameters.FixEdgeCurvesMode));
- theMap.emplace("ShapeFix.FixDegeneratedMode", makeString(theParameters.FixDegeneratedMode));
- theMap.emplace("ShapeFix.FixLackingMode", makeString(theParameters.FixLackingMode));
- theMap.emplace("ShapeFix.FixSelfIntersectionMode", makeString(theParameters.FixSelfIntersectionMode));
- theMap.emplace("ShapeFix.RemoveLoopMode", makeString(theParameters.RemoveLoopMode));
- theMap.emplace("ShapeFix.FixReversed2dMode", makeString(theParameters.FixReversed2dMode));
- theMap.emplace("ShapeFix.FixRemovePCurveMode", makeString(theParameters.FixRemovePCurveMode));
- theMap.emplace("ShapeFix.FixRemoveCurve3dMode", makeString(theParameters.FixRemoveCurve3dMode));
- theMap.emplace("ShapeFix.FixAddPCurveMode", makeString(theParameters.FixAddPCurveMode));
- theMap.emplace("ShapeFix.FixAddCurve3dMode", makeString(theParameters.FixAddCurve3dMode));
- theMap.emplace("ShapeFix.FixSeamMode", makeString(theParameters.FixSeamMode));
- theMap.emplace("ShapeFix.FixShiftedMode", makeString(theParameters.FixShiftedMode));
- theMap.emplace("ShapeFix.FixEdgeSameParameterMode", makeString(theParameters.FixEdgeSameParameterMode));
- theMap.emplace("ShapeFix.FixNotchedEdgesMode", makeString(theParameters.FixNotchedEdgesMode));
- theMap.emplace("ShapeFix.FixTailMode", makeString(theParameters.FixTailMode));
- theMap.emplace("ShapeFix.MaxTailAngle", makeString(theParameters.MaxTailAngle));
- theMap.emplace("ShapeFix.MaxTailWidth", makeString(theParameters.MaxTailWidth));
- theMap.emplace("ShapeFix.FixSelfIntersectingEdgeMode", makeString(theParameters.FixSelfIntersectingEdgeMode));
- theMap.emplace("ShapeFix.FixIntersectingEdgesMode", makeString(theParameters.FixIntersectingEdgesMode));
- theMap.emplace("ShapeFix.FixNonAdjacentIntersectingEdgesMode", makeString(theParameters.FixNonAdjacentIntersectingEdgesMode));
- theMap.emplace("ShapeFix.FixVertexPositionMode", makeString(theParameters.FixVertexPositionMode));
- theMap.emplace("ShapeFix.FixVertexToleranceMode", makeString(theParameters.FixVertexToleranceMode));
+ theMap[theKey] = std::move(theValue);
+ }
+ else
+ {
+ theMap.emplace(theKey, std::move(theValue));
+ }
}
//=============================================================================
public:
using OperationsFlags = ShapeProcess::OperationsFlags;
using ParameterMap = std::unordered_map<std::string, std::string>;
+ using ProcessingData = std::pair<ParameterMap, OperationsFlags>;
public:
//! Constructor.
const Standard_Real thePrecision,
const Standard_Boolean theIsSeam);
+ //! Reads the parameter map from and operation flags from the file specified in static interface.
+ //! @param theFileResourceName Name of the parameter in interface static that contains the name
+ //! of the file. For example, parameter "read.iges.resource.name" may contain string "IGES".
+ //! @param theScopeResourceName Name of the parameter in interface static that contains the name
+ //! of the scope. For example, parameter "read.iges.sequence" may contain string "FromIGES".
+ //! @return Read parameter map.
+ Standard_EXPORT static ProcessingData ReadProcessingData(const std::string& theFileResourceName,
+ const std::string& theScopeResourceName);
+
//! Fill the parameter map with the values from the specified parameters.
//! @param theParameters Parameters to be used in the processing.
+ //! @param theIsForce Flag indicating whether parameter should be replaced if it already exists in the map.
//! @param theMap Map to fill.
- Standard_EXPORT static void FillParameterMap(const DE_ShapeFixParameters& theParameters, ParameterMap& theMap);
+ Standard_EXPORT static void FillParameterMap(const DE_ShapeFixParameters& theParameters,
+ const bool theIsReplace,
+ ParameterMap& theMap);
+
+ //! Set the parameter in the map.
+ //! @param theKey Key of the parameter.
+ //! @param theValue Value of the parameter.
+ //! @param theIsReplace Flag indicating whether parameter should be replaced if it already exists in the map.
+ //! @param theMap Map to set the parameter in.
+ Standard_EXPORT static void SetParameter(const char* theKey,
+ DE_ShapeFixParameters::FixMode theValue,
+ const bool theIsReplace,
+ ParameterMap& theMap);
+
+ //! Set the parameter in the map.
+ //! @param theKey Key of the parameter.
+ //! @param theValue Value of the parameter.
+ //! @param theIsReplace Flag indicating whether parameter should be replaced if it already exists in the map.
+ //! @param theMap Map to set the parameter in.
+ Standard_EXPORT static void SetParameter(const char* theKey, double theValue, const bool theIsReplace, ParameterMap& theMap);
+
+ //! Set the parameter in the map.
+ //! @param theKey Key of the parameter.
+ //! @param theValue Value of the parameter.
+ //! @param theIsReplace Flag indicating whether parameter should be replaced if it already exists in the map.
+ //! @param theMap Map to set the parameter in.
+ Standard_EXPORT static void SetParameter(const char* theKey,
+ std::string&& theValue,
+ const bool theIsReplace,
+ ParameterMap& theMap);
//! The function is designed to set the length unit for the application before performing a
//! transfer operation. It ensures that the length unit is correctly configured based on the
#include <TopoDS_Shape.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
+#include <Transfer_ActorOfTransientProcess.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_Reader.hxx>
#include <XSControl_TransferReader.hxx>
if (start.IsNull()) return Standard_False;
const Handle(XSControl_TransferReader) &TR = thesession->TransferReader();
TR->BeginTransfer();
+ InitializeMissingParameters();
if (TR->TransferOne (start, Standard_True, theProgress) == 0) return Standard_False;
TopoDS_Shape sh = TR->ShapeResult(start);
//ShapeExtend_Explorer STU;
Standard_Integer i, nb = list->Length();
const Handle(XSControl_TransferReader) &TR = thesession->TransferReader();
TR->BeginTransfer();
+ InitializeMissingParameters();
ClearShapes();
ShapeExtend_Explorer STU;
Message_ProgressScope PS(theProgress, NULL, nb);
const Handle(XSControl_TransferReader) &TR = thesession->TransferReader();
TR->BeginTransfer();
+ InitializeMissingParameters();
ClearShapes();
ShapeExtend_Explorer STU;
Message_ProgressScope PS (theProgress, "Root", nb);
}
}
}
-
+
+//=============================================================================
+
+void XSControl_Reader::SetParameters(const ParameterMap& theParameters)
+{
+ if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor())
+ {
+ anActor->SetParameters(theParameters);
+ }
+}
+
+//=============================================================================
+
+void XSControl_Reader::SetParameters(ParameterMap&& theParameters)
+{
+ if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor())
+ {
+ anActor->SetParameters(std::move(theParameters));
+ }
+}
+
+//=============================================================================
+
+void XSControl_Reader::SetParameters(const DE_ShapeFixParameters& theParameters, const ParameterMap& theAdditionalParameters)
+{
+ if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor())
+ {
+ anActor->SetParameters(theParameters, theAdditionalParameters);
+ }
+}
+
+//=============================================================================
+
+const XSControl_Reader::ParameterMap& XSControl_Reader::GetParameters() const
+{
+ static const ParameterMap anEmptyMap;
+ const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor();
+ return anActor.IsNull() ? anEmptyMap : anActor->GetParameters();
+}
+
+//=============================================================================
+
+void XSControl_Reader::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
+{
+ if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor())
+ {
+ anActor->SetProcessingFlags(theFlags);
+ }
+}
+
+//=============================================================================
+
+const XSControl_Reader::ProcessingFlags& XSControl_Reader::GetShapeProcessFlags() const
+{
+ static const ProcessingFlags anEmptyFlags;
+ const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor();
+ return anActor.IsNull() ? anEmptyFlags : anActor->GetProcessingFlags();
+}
+
+//=============================================================================
+
+Handle(Transfer_ActorOfTransientProcess) XSControl_Reader::GetActor() const
+{
+ Handle(XSControl_WorkSession) aSession = WS();
+ if (aSession.IsNull())
+ {
+ return nullptr;
+ }
+
+ Handle(XSControl_TransferReader) aReader = aSession->TransferReader();
+ if (aReader.IsNull())
+ {
+ return nullptr;
+ }
+
+ return aReader->Actor();
+}
+
+//=============================================================================
+
+void XSControl_Reader::InitializeMissingParameters()
+{
+ if (GetParameters().empty())
+ {
+ SetParameters(GetDefaultParameters());
+ }
+ if (!GetShapeProcessFlags().second)
+ {
+ SetShapeProcessFlags(GetDefaultShapeProcessFlags());
+ }
+}
#ifndef _XSControl_Reader_HeaderFile
#define _XSControl_Reader_HeaderFile
+#include <DE_ShapeFixParameters.hxx>
+#include <ShapeProcess.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-
#include <TColStd_SequenceOfTransient.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <Standard_CString.hxx>
#include <IFSelect_PrintCount.hxx>
#include <Message_ProgressRange.hxx>
+#include <unordered_map>
+
class XSControl_WorkSession;
class Interface_InterfaceModel;
class Standard_Transient;
+class Transfer_ActorOfTransientProcess;
class TopoDS_Shape;
-
//! A groundwork to convert a shape to data which complies
//! with a particular norm. This data can be that of a whole
//! model or that of a specific list of entities in the model.
class XSControl_Reader
{
public:
-
DEFINE_STANDARD_ALLOC
+ using ParameterMap = std::unordered_map<std::string, std::string>;
+ // Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
+ // we use a pair. The first element is the flags, the second element is a boolean value that indicates
+ // whether the flags were set.
+ using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
//! Creates a Reader from scratch (creates an empty WorkSession)
//! A WorkSession or a Controller must be provided before running
//! Gives statistics about Transfer
Standard_EXPORT void GetStatsTransfer (const Handle(TColStd_HSequenceOfTransient)& list, Standard_Integer& nbMapped, Standard_Integer& nbWithResult, Standard_Integer& nbWithFail) const;
-
-
+ //! Sets parameters for shape processing.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters are moved from the input map.
+ //! @param theParameters the parameters for shape processing.
+ Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
+
+ //! Sets parameters for shape processing.
+ //! Parameters from @p theParameters are copied to the internal map.
+ //! Parameters from @p theAdditionalParameters are copied to the internal map
+ //! if they are not present in @p theParameters.
+ //! @param theParameters the parameters for shape processing.
+ //! @param theAdditionalParameters the additional parameters for shape processing.
+ Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
+ const ParameterMap& theAdditionalParameters = {});
+
+ //! Returns parameters for shape processing that was set by SetParameters() method.
+ //! @return the parameters for shape processing. Empty map if no parameters were set.
+ Standard_EXPORT const ParameterMap& GetParameters() const;
+
+ //! Sets flags defining operations to be performed on shapes.
+ //! @param theFlags The flags defining operations to be performed on shapes.
+ Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
+
+ //! Returns flags defining operations to be performed on shapes.
+ //! @return Pair of values defining operations to be performed on shapes and a boolean value
+ //! that indicates whether the flags were set.
+ Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const;
protected:
-
-
//! Returns a sequence of produced shapes
Standard_EXPORT TopTools_SequenceOfShape& Shapes();
+ //! Returns default parameters for shape fixing.
+ //! This method should be implemented in the derived classes to return default parameters for shape fixing.
+ //! @return Default parameters for shape fixing.
+ virtual DE_ShapeFixParameters GetDefaultParameters() const { return DE_ShapeFixParameters(); }
- Standard_Boolean therootsta;
- TColStd_SequenceOfTransient theroots;
-
+ //! Returns default flags for shape processing.
+ //! This method should be implemented in the derived classes to return default flags for shape processing.
+ //! @return Default flags for shape processing.
+ virtual ShapeProcess::OperationsFlags GetDefaultShapeProcessFlags() const { return ShapeProcess::OperationsFlags(); }
private:
+ //! Returns the Actor for the Transfer of an Entity.
+ //! This Actor is used by the Reader to perform the Transfer.
+ //! @return the Actor for the Transfer of an Entity. May be nullptr.
+ Handle(Transfer_ActorOfTransientProcess) GetActor() const;
+ //! If parameters haven't yet been provided, initializes them with default values
+ //! provided by GetDefaultParameters() method.
+ void InitializeMissingParameters();
+protected:
+ Standard_Boolean therootsta;
+ TColStd_SequenceOfTransient theroots;
+private:
Handle(XSControl_WorkSession) thesession;
TopTools_SequenceOfShape theshapes;
-
-
};
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx>
modepri = Draw::Atoi(str);
}
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("read.iges.resource.name", "read.iges.sequence");
+ Reader.SetParameters(std::move(aProcessingData.first));
+ Reader.SetShapeProcessFlags(aProcessingData.second);
+
if (modepri == 0)
{ //fin
theDI << "Bye and good luck! \n";
break;
}
-
else if (modepri <= 2)
{ // 1 : Visible Roots, 2 : All Roots
theDI << "All Geometry Transfer\n";
case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
default: { theDI << "failure\n"; return 1; }
}
+
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("read.iges.resource.name", "read.iges.sequence");
+ Reader.SetParameters(std::move(aProcessingData.first));
+ Reader.SetShapeProcessFlags(aProcessingData.second);
+
Reader.TransferRoots();
TopoDS_Shape shape = Reader.OneShape();
DBRep::Set(theArgVec[2], shape);
Message_ProgressScope aRootProgress(aProgress->Start(), "Translating", 100);
aProgress->Show(aRootProgress);
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("write.iges.resource.name", "write.iges.sequence");
+ anIgesWriter.SetParameters(std::move(aProcessingData.first));
+ anIgesWriter.SetShapeProcessFlags(aProcessingData.second);
+
Message_ProgressScope aStepProgress(aRootProgress.Next(90), NULL, theNbArgs);
for (Standard_Integer i = 1; i < theNbArgs && aStepProgress.More(); i++)
{
return 1;
}
IGESControl_Writer Writer;
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("write.iges.resource.name", "write.iges.sequence");
+ Writer.SetParameters(std::move(aProcessingData.first));
+ Writer.SetShapeProcessFlags(aProcessingData.second);
Standard_CString filename = theArgVec[1];
TopoDS_Shape shape = DBRep::Get(theArgVec[2]);
Standard_Boolean ok = Writer.AddShape(shape);
IGESControl_Reader aReader;
aReader.ReadFile(theArgVec[1]);
aReader.SetReadVisible(Standard_True);
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("read.iges.resource.name", "read.iges.sequence");
+ aReader.SetParameters(std::move(aProcessingData.first));
+ aReader.SetShapeProcessFlags(aProcessingData.second);
aReader.TransferRoots();
TopoDS_Shape shape = aReader.OneShape();
DBRep::Set(theArgVec[2], shape);
return 1;
}
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("read.iges.resource.name", "read.iges.sequence");
+ aReader.SetParameters(std::move(aProcessingData.first));
+ aReader.SetShapeProcessFlags(aProcessingData.second);
+
Handle(TDocStd_Document) aDocument;
if (!DDocStd::GetDocument(theArgVec[1], aDocument, Standard_False))
{
case 'l': aWriter.SetLayerMode(mode); break;
}
}
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("write.iges.resource.name", "write.iges.sequence");
+ aWriter.SetParameters(std::move(aProcessingData.first));
+ aWriter.SetShapeProcessFlags(aProcessingData.second);
aWriter.Transfer(aDocument, aRootScope.Next());
if (isModified)
#include <TopoDS_Shape.hxx>
#include <UnitsMethods.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx>
}
sr.SetSystemLengthUnit(XSDRAW::GetLengthUnit());
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("read.step.resource.name", "read.step.sequence");
+ sr.SetParameters(std::move(aProcessingData.first));
+ sr.SetShapeProcessFlags(aProcessingData.second);
// nom = "." -> fichier deja lu
Standard_Integer i, num, nbs, modepri = 1;
aFileNames[anInd - 1] = theArgVec[anInd];
}
STEPControl_Controller::Init();
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
IFSelect_ReturnStatus aReadStat;
DESTEP_Parameters aParameters;
aParameters.InitFromStatic();
0, aSize,
[&](const Standard_Integer theIndex)
{
- STEPControl_Reader aReader;
+ STEPControl_Reader aReader;
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("read.step.resource.name", "read.step.sequence");
+ aReader.SetParameters(std::move(aProcessingData.first));
+ aReader.SetShapeProcessFlags(aProcessingData.second);
aReader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
if (useStream)
{
Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100);
progress->Show(aPSRoot);
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("write.step.resource.name", "write.step.sequence");
+ sw.SetParameters(std::move(aProcessingData.first));
+ sw.SetShapeProcessFlags(aProcessingData.second);
Standard_Integer stat = sw.Transfer(shape, mode, Standard_True, aPSRoot.Next(90));
if (stat == IFSelect_RetDone)
{
0, aSize,
[&](const Standard_Integer theIndex)
{
- STEPControl_Writer aWriter;
+ STEPControl_Writer aWriter;
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("write.step.resource.name", "write.step.sequence");
+ aWriter.SetParameters(std::move(aProcessingData.first));
+ aWriter.SetShapeProcessFlags(aProcessingData.second);
+
if (aWriter.Transfer(aShape, STEPControl_AsIs, aParameters) != IFSelect_RetDone)
{
theDI << "Error: Can't transfer input shape";
Draw::Set(aDocumentName, aDrawDoc);
}
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("read.step.resource.name", "read.step.sequence");
+ aReader.SetParameters(std::move(aProcessingData.first));
+ aReader.SetShapeProcessFlags(aProcessingData.second);
+
if (!aReader.Transfer(aDocument, aRootScope.Next()))
{
theDI << "Cannot read any relevant data from the STEP file\n";
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
Message_ProgressScope aRootScope(aProgress->Start(), "STEP export", isFileMode ? 2 : 1);
+ XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
+ XSAlgo_ShapeProcessor::ReadProcessingData("write.step.resource.name", "write.step.sequence");
+ aWriter.SetParameters(std::move(aProcessingData.first));
+ aWriter.SetShapeProcessFlags(aProcessingData.second);
+
if (!aLabel.IsNull())
{
theDI << "Translating label " << aLabelName << " of document " << aDocumentName << " to STEP\n";
#include <VrmlData_Scene.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx>
Standard_Real aScaleFactor = 1.;
if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactor))
{
- XSAlgo::AlgoContainer()->PrepareForTransfer();
+ XSAlgo_ShapeProcessor::PrepareForTransfer();
aScaleFactor = UnitsMethods::GetCasCadeLengthUnit();
}
Standard_Real aScaleFactorM = 1.;
if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM))
{
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ XSAlgo_ShapeProcessor::PrepareForTransfer(); // update unit info
aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
}
if (!writer.WriteDoc(aDoc, argv[2], aScaleFactorM))