Skip to content

Commit

Permalink
Data Exchange - DE Wrapper Shape Healing Parameters #282
Browse files Browse the repository at this point in the history
Propagate shape healing parameters to STP and IGES nodes.
Update naming to avoid misunderstanding.
  • Loading branch information
dpasukhi committed Jan 24, 2025
1 parent f5a02d2 commit 1e0d8c3
Show file tree
Hide file tree
Showing 41 changed files with 786 additions and 695 deletions.
345 changes: 174 additions & 171 deletions src/DE/DE_ShapeFixConfigurationNode.cxx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/DE/DE_ShapeFixConfigurationNode.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public:
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;

public:
DE_ShapeFixParameters HealingParameters; //!< Shape healing parameters
DE_ShapeFixParameters ShapeFixParameters; //!< Shape healing parameters
};

#endif // _DE_ShapeFixConfigurationNode_HeaderFile
1 change: 1 addition & 0 deletions src/DE/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DE_ConfigurationNode.hxx
DE_PluginHolder.hxx
DE_Provider.cxx
DE_Provider.hxx
DE_ShapeFixConfigurationNode.cxx
DE_ShapeFixConfigurationNode.hxx
DE_ShapeFixParameters.hxx
DE_ShapeFixParameters.cxx
Expand Down
44 changes: 7 additions & 37 deletions src/DEIGES/DEIGES_ConfigurationNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <DE_PluginHolder.hxx>
#include <NCollection_Buffer.hxx>

IMPLEMENT_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ConfigurationNode)
IMPLEMENT_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ShapeFixConfigurationNode)

namespace
{
Expand All @@ -35,14 +35,16 @@ DE_PluginHolder<DEIGES_ConfigurationNode> THE_OCCT_IGES_COMPONENT_PLUGIN;
//=================================================================================================

DEIGES_ConfigurationNode::DEIGES_ConfigurationNode()
: DE_ConfigurationNode()
: DE_ShapeFixConfigurationNode()
{
DE_ShapeFixConfigurationNode::ShapeFixParameters =
DEIGES_Parameters::GetDefaultShapeFixParameters();
}

//=================================================================================================

DEIGES_ConfigurationNode::DEIGES_ConfigurationNode(const Handle(DEIGES_ConfigurationNode)& theNode)
: DE_ConfigurationNode(theNode)
: DE_ShapeFixConfigurationNode(theNode)
{
InternalParameters = theNode->InternalParameters;
}
Expand Down Expand Up @@ -85,10 +87,6 @@ bool DEIGES_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe

InternalParameters.ReadApproxd1 =
theResource->BooleanVal("read.bspline.approxd1.mode", InternalParameters.ReadApproxd1, aScope);
InternalParameters.ReadResourceName =
theResource->StringVal("read.resource.name", InternalParameters.ReadResourceName, aScope);
InternalParameters.ReadSequence =
theResource->StringVal("read.sequence", InternalParameters.ReadSequence, aScope);
InternalParameters.ReadFaultyEntities =
theResource->BooleanVal("read.fau_lty.entities", InternalParameters.ReadFaultyEntities, aScope);
InternalParameters.ReadOnlyVisible =
Expand Down Expand Up @@ -117,10 +115,6 @@ bool DEIGES_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
theResource->StringVal("write.header.product", InternalParameters.WriteHeaderProduct, aScope);
InternalParameters.WriteHeaderReciever =
theResource->StringVal("write.header.receiver", InternalParameters.WriteHeaderReciever, aScope);
InternalParameters.WriteResourceName =
theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
InternalParameters.WriteSequence =
theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
InternalParameters.WritePrecisionMode =
(DEIGES_Parameters::WriteMode_PrecisionMode)theResource->IntegerVal(
"write.precision.mode",
Expand All @@ -139,8 +133,7 @@ bool DEIGES_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
theResource->BooleanVal("write.name", InternalParameters.WriteName, aScope);
InternalParameters.WriteLayer =
theResource->BooleanVal("write.layer", InternalParameters.WriteLayer, aScope);

return true;
return DE_ShapeFixConfigurationNode::Load(theResource);
}

//=================================================================================================
Expand Down Expand Up @@ -239,18 +232,6 @@ TCollection_AsciiString DEIGES_ConfigurationNode::Save() const
aResult += aScope + "read.bspline.approxd1.mode :\t " + InternalParameters.ReadApproxd1 + "\n";
aResult += "!\n";

aResult += "!\n";
aResult += "!Defines the name of the resource file\n";
aResult += "!Default value: \"IGES\". Available values: <string>\n";
aResult += aScope + "read.resource.name :\t " + InternalParameters.ReadResourceName + "\n";
aResult += "!\n";

aResult += "!\n";
aResult += "!Defines the name of the sequence of operators\n";
aResult += "!Default value: \"FromIGES\". Available values: <string>\n";
aResult += aScope + "read.sequence :\t " + InternalParameters.ReadSequence + "\n";
aResult += "!\n";

aResult += "!\n";
aResult += "!Parameter for reading fa-iled entities\n";
aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
Expand Down Expand Up @@ -332,18 +313,6 @@ TCollection_AsciiString DEIGES_ConfigurationNode::Save() const
aResult += aScope + "write.header.receiver :\t " + InternalParameters.WriteHeaderReciever + "\n";
aResult += "!\n";

aResult += "!\n";
aResult += "!Defines the name of the resource file\n";
aResult += "!Default value: \"IGES\". Available values: <string>\n";
aResult += aScope + "write.resource.name :\t " + InternalParameters.WriteResourceName + "\n";
aResult += "!\n";

aResult += "!\n";
aResult += "!Defines the name of the sequence of operators\n";
aResult += "!Default value: \"To\". Available values: <string>\n";
aResult += aScope + "write.sequence :\t " + InternalParameters.WriteSequence + "\n";
aResult += "!\n";

aResult += "!\n";
aResult += "!Specifies the mode of writing the resolution value into the IGES file\n";
aResult += "!Default value: Average(0). Available values: \"Least\"(-1), \"Average\"(0), ";
Expand Down Expand Up @@ -388,6 +357,7 @@ TCollection_AsciiString DEIGES_ConfigurationNode::Save() const
aResult += aScope + "write.layer :\t " + InternalParameters.WriteLayer + "\n";
aResult += "!\n";

aResult += DE_ShapeFixConfigurationNode::Save();
aResult += "!*****************************************************************************\n";
return aResult;
}
Expand Down
6 changes: 3 additions & 3 deletions src/DEIGES/DEIGES_ConfigurationNode.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define _DEIGES_ConfigurationNode_HeaderFile

#include <DEIGES_Parameters.hxx>
#include <DE_ConfigurationNode.hxx>
#include <DE_ShapeFixConfigurationNode.hxx>
#include <UnitsMethods_LengthUnit.hxx>

//! The purpose of this class is to configure the transfer process for IGES format
Expand All @@ -28,9 +28,9 @@
//! The supported CAD extensions are ".igs", ".iges"
//! The import process is supported.
//! The export process is supported.
class DEIGES_ConfigurationNode : public DE_ConfigurationNode
class DEIGES_ConfigurationNode : public DE_ShapeFixConfigurationNode
{
DEFINE_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ConfigurationNode)
DEFINE_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ShapeFixConfigurationNode)
public:
//! Initializes all fields by default
Standard_EXPORT DEIGES_ConfigurationNode();
Expand Down
56 changes: 18 additions & 38 deletions src/DEIGES/DEIGES_Parameters.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,37 @@

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;
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");
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");
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;
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;
}

//=================================================================================================
Expand All @@ -69,19 +61,7 @@ void DEIGES_Parameters::Reset()

//=================================================================================================

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 DEIGES_Parameters::GetDefaultShapeFixParameters()
{
DE_ShapeFixParameters aShapeFixParameters;
aShapeFixParameters.DetalizationLevel = TopAbs_EDGE;
Expand Down
11 changes: 2 additions & 9 deletions src/DEIGES/DEIGES_Parameters.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ public:
//! 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();
//! Returns default shape fix parameters for transferring IGES files.
Standard_EXPORT static DE_ShapeFixParameters GetDefaultShapeFixParameters();

public:
// Common
Expand All @@ -106,8 +103,6 @@ public:

//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
Expand All @@ -121,8 +116,6 @@ public:
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
Expand Down
15 changes: 5 additions & 10 deletions src/DEIGES/DEIGES_Provider.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ void DEIGES_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;

myOldValues.ReadApproxd1 = Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
myOldValues.ReadResourceName = Interface_Static::CVal("read.iges.resource.name");
myOldValues.ReadSequence = Interface_Static::CVal("read.iges.sequence");
myOldValues.ReadFaultyEntities = Interface_Static::IVal("read.iges.faulty.entities") == 1;
myOldValues.ReadOnlyVisible = Interface_Static::IVal("read.iges.onlyvisible") == 1;

Expand All @@ -94,8 +92,6 @@ void DEIGES_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
myOldValues.WriteHeaderCompany = Interface_Static::CVal("write.iges.header.company");
myOldValues.WriteHeaderProduct = Interface_Static::CVal("write.iges.header.product");
myOldValues.WriteHeaderReciever = Interface_Static::CVal("write.iges.header.receiver");
myOldValues.WriteResourceName = Interface_Static::CVal("write.iges.resource.name");
myOldValues.WriteSequence = Interface_Static::CVal("write.iges.sequence");
myOldValues.WritePrecisionMode =
(DEIGES_Parameters::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
Expand Down Expand Up @@ -130,8 +126,6 @@ void DEIGES_Provider::setStatic(const DEIGES_Parameters& theParameter)
theParameter.EncodeRegAngle * M_PI / 180.0);

Interface_Static::SetIVal("read.iges.bspline.approxd1.mode", theParameter.ReadApproxd1);
Interface_Static::SetCVal("read.iges.resource.name", theParameter.ReadResourceName.ToCString());
Interface_Static::SetCVal("read.iges.sequence", theParameter.ReadSequence.ToCString());
Interface_Static::SetIVal("read.iges.faulty.entities", theParameter.ReadFaultyEntities);
Interface_Static::SetIVal("read.iges.onlyvisible", theParameter.ReadOnlyVisible);

Expand All @@ -144,8 +138,6 @@ void DEIGES_Provider::setStatic(const DEIGES_Parameters& theParameter)
theParameter.WriteHeaderProduct.ToCString());
Interface_Static::SetCVal("write.iges.header.receiver",
theParameter.WriteHeaderReciever.ToCString());
Interface_Static::SetCVal("write.iges.resource.name", theParameter.WriteResourceName.ToCString());
Interface_Static::SetCVal("write.iges.sequence", theParameter.WriteSequence.ToCString());
Interface_Static::SetIVal("write.precision.mode", theParameter.WritePrecisionMode);
Interface_Static::SetRVal("write.precision.val", theParameter.WritePrecisionVal);
Interface_Static::SetIVal("write.iges.plane.mode", theParameter.WritePlaneMode);
Expand Down Expand Up @@ -194,7 +186,7 @@ bool DEIGES_Provider::Read(const TCollection_AsciiString& thePath,
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);

aReader.SetShapeFixParameters(aNode->ShapeFixParameters);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
Expand Down Expand Up @@ -260,7 +252,7 @@ bool DEIGES_Provider::Write(const TCollection_AsciiString& thePath,
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);

aWriter.SetShapeFixParameters(aNode->ShapeFixParameters);
if (!aWriter.Transfer(theDocument, theProgress))
{
Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
Expand Down Expand Up @@ -319,6 +311,8 @@ bool DEIGES_Provider::Read(const TCollection_AsciiString& thePath,
IGESControl_Reader aReader;
aReader.SetWS(theWS);
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
aReader.SetShapeFixParameters(aNode->ShapeFixParameters);

IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
Expand Down Expand Up @@ -367,6 +361,7 @@ bool DEIGES_Provider::Write(const TCollection_AsciiString& thePath,
aGS.SetScale(aNode->GlobalParameters.LengthUnit);
}
aWriter.Model()->SetGlobalSection(aGS);
aWriter.SetShapeFixParameters(aNode->ShapeFixParameters);
Standard_Boolean aIsOk = aWriter.AddShape(theShape);
if (!aIsOk)
{
Expand Down
Loading

0 comments on commit 1e0d8c3

Please sign in to comment.