1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
ichesnok
e13c6a27b8 0033811: CAD Import - Update DE Readers with ShapeHealing logic 2024-09-19 13:10:59 +01:00
ichesnok
2afe8d66cb 0033799: Data Exchange - Shape Healing interface update
ProcessShape() function contents were moved to XSAlgo_AlgoProcessShape class.
2024-09-19 12:45:23 +01:00
29 changed files with 579 additions and 145 deletions

View File

@@ -490,3 +490,11 @@ TCollection_AsciiString DE_ShapeFixConfigurationNode::Save() const
return aResult;
}
//=======================================================================
// function : ChangeHealingParams
// purpose :
//=======================================================================
void DE_ShapeFixConfigurationNode::ChangeHealingParams()
{
}

View File

@@ -42,6 +42,9 @@ public:
//! @return result resource string
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
//! Redefined some healing parameters, depending on format
Standard_EXPORT virtual void ChangeHealingParams();
public:
DE_ShapeFixParameters HealingParameters; //!< Shape healing parameters

View File

@@ -0,0 +1,74 @@
// Copyright (c) 2024 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 <DE_ShapeFixParameters.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Shared.hxx>
#include <TCollection_AsciiString.hxx>
//! Fill healing parameters map
void DE_ShapeFixParameters::FillParamsMap(DE_ShapeFixParameters::HealingParamMap& theMap)
{
theMap.Bind("Tolerance3d", TCollection_AsciiString(Tolerance3d));
theMap.Bind("MinTolerance3d", TCollection_AsciiString(MinTolerance3d));
theMap.Bind("MaxTolerance3d", TCollection_AsciiString(MaxTolerance3d));
theMap.Bind("FixFreeShellMode", TCollection_AsciiString(static_cast<int>(FixFreeShellMode)));
theMap.Bind("FixFreeFaceMode", TCollection_AsciiString(static_cast<int>(FixFreeFaceMode)));
theMap.Bind("FixFreeFaceMode", TCollection_AsciiString(static_cast<int>(FixFreeFaceMode)));
theMap.Bind("FixFreeWireMode", TCollection_AsciiString(static_cast<int>(FixFreeWireMode)));
theMap.Bind("FixSameParameterMode", TCollection_AsciiString(static_cast<int>(FixSameParameterMode)));
theMap.Bind("FixSolidMode", TCollection_AsciiString(static_cast<int>(FixSolidMode)));
theMap.Bind("FixShellOrientationMode", TCollection_AsciiString(static_cast<int>(FixShellOrientationMode)));
theMap.Bind("CreateOpenSolidMode", TCollection_AsciiString(static_cast<int>(CreateOpenSolidMode)));
theMap.Bind("FixShellMode", TCollection_AsciiString(static_cast<int>(FixShellMode)));
theMap.Bind("FixFaceOrientationMode", TCollection_AsciiString(static_cast<int>(FixFaceOrientationMode)));
theMap.Bind("FixFaceMode", TCollection_AsciiString(static_cast<int>(FixFaceMode)));
theMap.Bind("FixWireMode", TCollection_AsciiString(static_cast<int>(FixWireMode)));
theMap.Bind("FixOrientationMode", TCollection_AsciiString(static_cast<int>(FixOrientationMode)));
theMap.Bind("FixAddNaturalBoundMode", TCollection_AsciiString(static_cast<int>(FixAddNaturalBoundMode)));
theMap.Bind("FixMissingSeamMode", TCollection_AsciiString(static_cast<int>(FixMissingSeamMode)));
theMap.Bind("FixSmallAreaWireMode", TCollection_AsciiString(static_cast<int>(FixSmallAreaWireMode)));
theMap.Bind("RemoveSmallAreaFaceMode", TCollection_AsciiString(static_cast<int>(RemoveSmallAreaFaceMode)));
theMap.Bind("FixIntersectingWiresMode", TCollection_AsciiString(static_cast<int>(FixIntersectingWiresMode)));
theMap.Bind("FixLoopWiresMode", TCollection_AsciiString(static_cast<int>(FixLoopWiresMode)));
theMap.Bind("FixSplitFaceMode", TCollection_AsciiString(static_cast<int>(FixSplitFaceMode)));
theMap.Bind("AutoCorrectPrecisionMode", TCollection_AsciiString(static_cast<int>(AutoCorrectPrecisionMode)));
theMap.Bind("ModifyTopologyMode", TCollection_AsciiString(static_cast<int>(ModifyTopologyMode)));
theMap.Bind("ClosedWireMode", TCollection_AsciiString(static_cast<int>(ClosedWireMode)));
theMap.Bind("PreferencePCurveMode", TCollection_AsciiString(static_cast<int>(PreferencePCurveMode)));
theMap.Bind("FixReorderMode", TCollection_AsciiString(static_cast<int>(FixReorderMode)));
theMap.Bind("FixSmallMode", TCollection_AsciiString(static_cast<int>(FixSmallMode)));
theMap.Bind("FixConnectedMode", TCollection_AsciiString(static_cast<int>(FixConnectedMode)));
theMap.Bind("FixEdgeCurvesMode", TCollection_AsciiString(static_cast<int>(FixEdgeCurvesMode)));
theMap.Bind("FixDegeneratedMode", TCollection_AsciiString(static_cast<int>(FixDegeneratedMode)));
theMap.Bind("FixLackingMode", TCollection_AsciiString(static_cast<int>(FixLackingMode)));
theMap.Bind("FixSelfIntersectionMode", TCollection_AsciiString(static_cast<int>(FixSelfIntersectionMode)));
theMap.Bind("RemoveLoopMode", TCollection_AsciiString(static_cast<int>(RemoveLoopMode)));
theMap.Bind("FixReversed2dMode", TCollection_AsciiString(static_cast<int>(FixReversed2dMode)));
theMap.Bind("FixRemovePCurveMode", TCollection_AsciiString(static_cast<int>(FixRemovePCurveMode)));
theMap.Bind("FixRemoveCurve3dMode", TCollection_AsciiString(static_cast<int>(FixRemoveCurve3dMode)));
theMap.Bind("FixAddPCurveMode", TCollection_AsciiString(static_cast<int>(FixAddPCurveMode)));
theMap.Bind("FixAddCurve3dMode", TCollection_AsciiString(static_cast<int>(FixAddCurve3dMode)));
theMap.Bind("FixSeamMode", TCollection_AsciiString(static_cast<int>(FixSeamMode)));
theMap.Bind("FixShiftedMode", TCollection_AsciiString(static_cast<int>(FixShiftedMode)));
theMap.Bind("FixEdgeSameParameterMode", TCollection_AsciiString(static_cast<int>(FixEdgeSameParameterMode)));
theMap.Bind("FixNotchedEdgesMode", TCollection_AsciiString(static_cast<int>(FixNotchedEdgesMode)));
theMap.Bind("FixTailMode", TCollection_AsciiString(static_cast<int>(FixTailMode)));
theMap.Bind("MaxTailAngle", TCollection_AsciiString(static_cast<int>(MaxTailAngle)));
theMap.Bind("MaxTailWidth", TCollection_AsciiString(static_cast<int>(MaxTailWidth)));
theMap.Bind("FixSelfIntersectingEdgeMode", TCollection_AsciiString(static_cast<int>(FixSelfIntersectingEdgeMode)));
theMap.Bind("FixIntersectingEdgesMode", TCollection_AsciiString(static_cast<int>(FixIntersectingEdgesMode)));
theMap.Bind("FixNonAdjacentIntersectingEdgesMode", TCollection_AsciiString(static_cast<int>(FixNonAdjacentIntersectingEdgesMode)));
theMap.Bind("FixVertexPositionMode", TCollection_AsciiString(static_cast<int>(FixVertexPositionMode)));
theMap.Bind("FixVertexToleranceMode", TCollection_AsciiString(static_cast<int>(FixVertexToleranceMode)));
}

View File

@@ -14,18 +14,24 @@
#ifndef _DE_ShapeFixParameters_HeaderFile
#define _DE_ShapeFixParameters_HeaderFile
#include <NCollection_DataMap.hxx>
#include <NCollection_Shared.hxx>
#include <TCollection_AsciiString.hxx>
//! Struct for shape healing parameters storage
struct DE_ShapeFixParameters
{
typedef NCollection_Shared<NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>> HealingParamMap;
//! Enum, classifying a type of value for parameters
enum class FixMode : char
{
FixOrNot = -1, //!< Procedure will be executed or not (depending on the situation)
NotFix = 0, //!< Procedure will be executed
Fix = 1 //!< Procedure will be executed anyway
NotFix = 0, //!< Procedure will be executed
Fix = 1 //!< Procedure will be executed anyway
};
double Tolerance3d = 1.e-6;
double Tolerance3d = 1.e-3;
double MaxTolerance3d = 1.0;
double MinTolerance3d = 1.e-7;
FixMode FixFreeShellMode = FixMode::FixOrNot;
@@ -47,7 +53,7 @@ struct DE_ShapeFixParameters
FixMode FixIntersectingWiresMode = FixMode::FixOrNot;
FixMode FixLoopWiresMode = FixMode::FixOrNot;
FixMode FixSplitFaceMode = FixMode::FixOrNot;
FixMode AutoCorrectPrecisionMode = FixMode::FixOrNot;
FixMode AutoCorrectPrecisionMode = FixMode::Fix;
FixMode ModifyTopologyMode = FixMode::NotFix;
FixMode ModifyGeometryMode = FixMode::Fix;
FixMode ClosedWireMode = FixMode::Fix;
@@ -77,6 +83,10 @@ struct DE_ShapeFixParameters
FixMode FixNonAdjacentIntersectingEdgesMode = FixMode::FixOrNot;
FixMode FixVertexPositionMode = FixMode::NotFix;
FixMode FixVertexToleranceMode = FixMode::FixOrNot;
//! Fill healing parameters map
Standard_EXPORT void DE_ShapeFixParameters::FillParamsMap(DE_ShapeFixParameters::HealingParamMap& theMap);
};
#endif // _DE_ShapeFixParameters_HeaderFile

View File

@@ -7,6 +7,7 @@ DE_Provider.cxx
DE_Provider.hxx
DE_ShapeFixConfigurationNode.cxx
DE_ShapeFixConfigurationNode.hxx
DE_ShapeFixParameters.cxx
DE_ShapeFixParameters.hxx
DE_Wrapper.cxx
DE_Wrapper.hxx

View File

@@ -18,7 +18,7 @@
#include <IGESCAFControl_Provider.hxx>
#include <NCollection_Buffer.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ShapeFixConfigurationNode)
namespace
{
@@ -37,17 +37,20 @@ namespace
// purpose :
//=======================================================================
IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode() :
DE_ConfigurationNode()
{}
DE_ShapeFixConfigurationNode()
{
ChangeHealingParams();
}
//=======================================================================
// function : IGESCAFControl_ConfigurationNode
// purpose :
//=======================================================================
IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode(const Handle(IGESCAFControl_ConfigurationNode)& theNode)
:DE_ConfigurationNode(theNode)
:DE_ShapeFixConfigurationNode(theNode)
{
InternalParameters = theNode->InternalParameters;
ChangeHealingParams();
}
//=======================================================================
@@ -456,3 +459,12 @@ bool IGESCAFControl_ConfigurationNode::CheckContent(const Handle(NCollection_Buf
}
return false;
}
//=======================================================================
// function : ChangeHealingParams
// purpose :
//=======================================================================
void IGESCAFControl_ConfigurationNode::ChangeHealingParams()
{
HealingParameters.CreateOpenSolidMode = DE_ShapeFixParameters::FixMode::Fix;
}

View File

@@ -14,7 +14,7 @@
#ifndef _IGESCAFControl_ConfigurationNode_HeaderFile
#define _IGESCAFControl_ConfigurationNode_HeaderFile
#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
@@ -27,9 +27,9 @@
//! The supported CAD extensions are ".igs", ".iges"
//! The import process is supported.
//! The export process is supported.
class IGESCAFControl_ConfigurationNode : public DE_ConfigurationNode
class IGESCAFControl_ConfigurationNode : public DE_ShapeFixConfigurationNode
{
DEFINE_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
DEFINE_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ShapeFixConfigurationNode)
public:
//! Initializes all fields by default
@@ -84,6 +84,9 @@ public:
//! @return Standard_True if file is supported by a current provider
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
//! Redefined some healing parameters, depending on format
Standard_EXPORT virtual void ChangeHealingParams() Standard_OVERRIDE;
public:
enum ReadMode_BSplineContinuity

View File

@@ -20,9 +20,12 @@
#include <IGESControl_Controller.hxx>
#include <IGESData.hxx>
#include <IGESData_IGESModel.hxx>
#include <IGESToBRep_Actor.hxx>
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <MoniTool_Macros.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
@@ -187,14 +190,19 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
IGESCAFControl_Reader aReader;
aReader.SetWS(theWS);
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
DE_ShapeFixParameters::HealingParamMap aMap = aReader.DEHealingParameters();
aNode->HealingParameters.FillParamsMap(aMap);
aReader.SetDEHealingParameters(aMap);
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadFile(thePath.ToCString());
DeclareAndCast(IGESToBRep_Actor, anActor, aReader.WS()->TransferReader()->Actor());
anActor->SetDEHealingParameters(aMap);
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
@@ -302,8 +310,15 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
IGESControl_Reader aReader;
aReader.SetWS(theWS);
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
DE_ShapeFixParameters::HealingParamMap aMap = aReader.DEHealingParameters();
aNode->HealingParameters.FillParamsMap(aMap);
aReader.SetDEHealingParameters(aMap);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadFile(thePath.ToCString());
DeclareAndCast(IGESToBRep_Actor, anActor, aReader.WS()->TransferReader()->Actor());
anActor->SetDEHealingParameters(aMap);
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<

View File

@@ -33,6 +33,7 @@
#include <TransferBRep_ShapeBinder.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSAlgo_AlgoProcessShape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IGESToBRep_Actor,Transfer_ActorOfTransientProcess)
@@ -194,11 +195,17 @@ Handle(Transfer_Binder) IGESToBRep_Actor::Transfer
// fixing shape
Handle(Standard_Transient) info;
shape = XSAlgo::AlgoContainer()->ProcessShape(shape, theeps, CAS.GetMaxTol(),
"read.iges.resource.name",
"read.iges.sequence",
info, mymodel->ReShape(),
aPS.Next(), false, TopAbs_EDGE);
XSAlgo_AlgoProcessShape aProcessShape;
aProcessShape.SetShape(shape);
aProcessShape.SetPrscfile("read.iges.resource.name");
aProcessShape.SetPseq("read.iges.sequence");
aProcessShape.SetInfo(info);
aProcessShape.SetDetalisationLevel(TopAbs_EDGE);
aProcessShape.SetProgressRange(aPS.Next());
aProcessShape.SetPrecision(theeps);
aProcessShape.SetMaxTol(CAS.GetMaxTol());
aProcessShape.SetReShape(mymodel->ReShape());
shape = aProcessShape.ProcessShape();
XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
}

View File

@@ -20,6 +20,7 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <DE_ShapeFixParameters.hxx>
#include <Standard_Integer.hxx>
#include <Transfer_ActorOfTransientProcess.hxx>
#include <Message_ProgressRange.hxx>
@@ -66,7 +67,11 @@ public:
//! the file or from statics
Standard_EXPORT Standard_Real UsedTolerance() const;
//! Returns healing parameters map
Standard_EXPORT DE_ShapeFixParameters::HealingParamMap DEHealingParameters() const { return myDEHealingParameters; }
//! Sets healing parameters map
Standard_EXPORT void SetDEHealingParameters(DE_ShapeFixParameters::HealingParamMap theDEHealingParams) { myDEHealingParameters = theDEHealingParams; }
DEFINE_STANDARD_RTTIEXT(IGESToBRep_Actor,Transfer_ActorOfTransientProcess)
@@ -82,7 +87,7 @@ private:
Handle(Interface_InterfaceModel) themodel;
Standard_Integer thecontinuity;
Standard_Real theeps;
DE_ShapeFixParameters::HealingParamMap myDEHealingParameters;
};

View File

@@ -46,6 +46,7 @@
#include <TransferBRep.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSAlgo_AlgoProcessShape.hxx>
#include <stdio.h>
//#include <ShapeCustom.hxx>
@@ -549,10 +550,17 @@ Standard_Boolean IGESToBRep_Reader::Transfer(const Standard_Integer num,
// 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);
XSAlgo_AlgoProcessShape aProcessShape;
aProcessShape.SetShape(shape);
aProcessShape.SetPrscfile("read.iges.resource.name");
aProcessShape.SetPseq("read.iges.sequence");
aProcessShape.SetInfo(info);
aProcessShape.SetDetalisationLevel(TopAbs_EDGE);
aProcessShape.SetProgressRange(theProgress);
aProcessShape.SetPrecision(eps * CAS.GetUnitFactor());
aProcessShape.SetMaxTol(CAS.GetMaxTol());
shape = aProcessShape.ProcessShape();
if (aPS.UserBreak())
return Standard_False;

View File

@@ -14,11 +14,12 @@
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
#include <DE_ShapeFixConfigurationNode.hxx>
#include <DE_PluginHolder.hxx>
#include <NCollection_Buffer.hxx>
#include <STEPCAFControl_Provider.hxx>
IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ConfigurationNode)
IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ShapeFixConfigurationNode)
namespace
{
@@ -37,17 +38,19 @@ namespace
// purpose :
//=======================================================================
STEPCAFControl_ConfigurationNode::STEPCAFControl_ConfigurationNode() :
DE_ConfigurationNode()
{}
DE_ShapeFixConfigurationNode()
{
}
//=======================================================================
// function : STEPCAFControl_ConfigurationNode
// purpose :
//=======================================================================
STEPCAFControl_ConfigurationNode::STEPCAFControl_ConfigurationNode(const Handle(STEPCAFControl_ConfigurationNode)& theNode)
:DE_ConfigurationNode(theNode),
:DE_ShapeFixConfigurationNode(theNode),
InternalParameters(theNode->InternalParameters)
{}
{
}
//=======================================================================
// function : Load

View File

@@ -14,7 +14,7 @@
#ifndef _STEPCAFControl_ConfigurationNode_HeaderFile
#define _STEPCAFControl_ConfigurationNode_HeaderFile
#include <DE_ConfigurationNode.hxx>
#include <DE_ShapeFixConfigurationNode.hxx>
#include <STEPControl_StepModelType.hxx>
#include <StepData_ConfParameters.hxx>
#include <Resource_FormatType.hxx>
@@ -30,9 +30,9 @@
//! The supported CAD extensions are ".stp", ".step", ".stpz"
//! The import process is supported.
//! The export process is supported.
class STEPCAFControl_ConfigurationNode : public DE_ConfigurationNode
class STEPCAFControl_ConfigurationNode : public DE_ShapeFixConfigurationNode
{
DEFINE_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ConfigurationNode)
DEFINE_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ShapeFixConfigurationNode)
public:
//! Initializes all field by default

View File

@@ -14,6 +14,7 @@
#include <STEPCAFControl_Provider.hxx>
#include <BinXCAFDrivers.hxx>
#include <DE_ShapeFixParameters.hxx>
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <StepData_StepModel.hxx>
@@ -23,6 +24,8 @@
#include <STEPCAFControl_Reader.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
@@ -68,12 +71,17 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
personizeWS(theWS);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
STEPCAFControl_Reader aReader;
DE_ShapeFixParameters aParameters;
DE_ShapeFixParameters::HealingParamMap aDEHealingParams = aReader.ChangeReader().DEHealingParameters();
aNode->HealingParameters.FillParamsMap(aDEHealingParams);
aReader.ChangeReader().SetDEHealingParameters(aDEHealingParams);
aReader.Init(theWS);
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
aReader.SetMetaMode(aNode->InternalParameters.ReadMetadata);
aReader.SetDEHealingParameters(aReader.ChangeReader().DEHealingParameters());
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
StepData_ConfParameters aParams;
@@ -200,6 +208,9 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
personizeWS(theWS);
STEPControl_Reader aReader;
aReader.SetWS(theWS);
DE_ShapeFixParameters::HealingParamMap aDEHealingParams = aReader.DEHealingParameters();
aNode->HealingParameters.FillParamsMap(aDEHealingParams);
aReader.SetDEHealingParameters(aDEHealingParams);
IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
StepData_ConfParameters aParams;
aReadstat = aReader.ReadFile(thePath.ToCString(), aParams);

View File

@@ -24,6 +24,7 @@
#include <HeaderSection_FileSchema.hxx>
#include <Interface_Static.hxx>
#include <Message_ProgressScope.hxx>
#include <MoniTool_Macros.hxx>
#include <NCollection_DataMap.hxx>
#include <OSD_Path.hxx>
#include <Quantity_ColorRGBA.hxx>
@@ -2341,7 +2342,8 @@ Standard_Boolean readAnnotationPlane(const Handle(StepVisual_AnnotationPlane)& t
void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
const Handle(Standard_Transient)& theGDT,
const Handle(Standard_Transient)& theDimObject,
const StepData_Factors& theLocalFactors)
const StepData_Factors& theLocalFactors,
DE_ShapeFixParameters::HealingParamMap theDEParams)
{
if (theGDT.IsNull() || theDimObject.IsNull())
return;
@@ -2370,6 +2372,7 @@ void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
Handle(StepVisual_DraughtingModel)::DownCast(aDMIA->UsedRepresentation());
XSAlgo::AlgoContainer()->PrepareForTransfer();
STEPControl_ActorRead anActor(aTP->Model());
anActor.SetDEHealingParameters(theDEParams);
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aDModel, aTP, aLocalFactors);
Standard_Real aFact = aLocalFactors.LengthFactor();
@@ -2457,7 +2460,8 @@ void readAnnotation(const Handle(XSControl_TransferReader)& theTR,
void readConnectionPoints(const Handle(XSControl_TransferReader)& theTR,
const Handle(Standard_Transient)& theGDT,
const Handle(XCAFDimTolObjects_DimensionObject)& theDimObject,
const StepData_Factors& theLocalFactors)
const StepData_Factors& theLocalFactors,
DE_ShapeFixParameters::HealingParamMap theDEParams)
{
if (theGDT.IsNull() || theDimObject.IsNull())
return;
@@ -2479,6 +2483,7 @@ void readConnectionPoints(const Handle(XSControl_TransferReader)& theTR,
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
STEPControl_ActorRead anActor(theTR->Model());
anActor.SetDEHealingParameters(theDEParams);
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aSDR, aTP, aLocalFactors);
aFact = aLocalFactors.LengthFactor();
@@ -2783,7 +2788,7 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
collectShapeAspect(aSAR->RelatingShapeAspect(), theWS, aSAs);
Handle(StepDimTol_DatumFeature) aDF = Handle(StepDimTol_DatumFeature)::DownCast(aSAR->RelatingShapeAspect());
if (!aSAR->RelatingShapeAspect()->IsKind(STANDARD_TYPE(StepDimTol_DatumTarget)))
readAnnotation(aTR, aSAR->RelatingShapeAspect(), aDatObj, theLocalFactors);
readAnnotation(aTR, aSAR->RelatingShapeAspect(), aDatObj, theLocalFactors, myDEParameters);
}
// Collect shape labels
@@ -2917,6 +2922,7 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
= Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(j));
XSAlgo::AlgoContainer()->PrepareForTransfer();
STEPControl_ActorRead anActor(aTP->Model());
anActor.SetDEHealingParameters(myDEParameters);
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aSRWP, aTP, aLocalFactors);
Handle(Geom_Axis2Placement) anAxis = StepToGeom::MakeAxis2Placement(anAx, aLocalFactors);
@@ -2964,7 +2970,7 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
aDatTargetObj->IsDatumTarget(Standard_True);
aDatTargetObj->SetDatumTargetNumber(aDT->TargetId()->IntegerValue());
readAnnotation(aTR, aDT, aDatTargetObj, theLocalFactors);
readAnnotation(aTR, aDT, aDatTargetObj, theLocalFactors, myDEParameters);
aDat->SetObject(aDatTargetObj);
isExistDatumTarget = Standard_True;
}
@@ -2993,7 +2999,7 @@ Standard_Boolean STEPCAFControl_Reader::setDatumToXCAF(const Handle(StepDimTol_D
aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
if (aDatObj->GetPresentation().IsNull()) {
// Try find annotation connected to datum entity (not right case, according recommended practices)
readAnnotation(aTR, theDat, aDatObj, theLocalFactors);
readAnnotation(aTR, theDat, aDatObj, theLocalFactors, myDEParameters);
}
aDat->SetObject(aDatObj);
}
@@ -3638,7 +3644,8 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
const TDF_Label& aDimL,
const Handle(TDocStd_Document)& theDoc,
const Handle(XSControl_WorkSession)& theWS,
const StepData_Factors& theLocalFactors)
const StepData_Factors& theLocalFactors,
DE_ShapeFixParameters::HealingParamMap theUseDEHealingParams)
{
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main());
@@ -4057,8 +4064,8 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
if (aDimL.FindAttribute(XCAFDoc_Dimension::GetID(), aDim))
{
readAnnotation(aTR, theEnt, aDimObj, theLocalFactors);
readConnectionPoints(aTR, theEnt, aDimObj, theLocalFactors);
readAnnotation(aTR, theEnt, aDimObj, theLocalFactors, theUseDEHealingParams);
readConnectionPoints(aTR, theEnt, aDimObj, theLocalFactors, theUseDEHealingParams);
aDim->SetObject(aDimObj);
}
}
@@ -4180,7 +4187,8 @@ static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
const TDF_Label& theTolL,
const Handle(TDocStd_Document)& theDoc,
const Handle(XSControl_WorkSession)& theWS,
const StepData_Factors& theLocalFactors)
const StepData_Factors& theLocalFactors,
DE_ShapeFixParameters::HealingParamMap theUseDEHealingParams)
{
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main());
@@ -4327,7 +4335,7 @@ static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
aTolObj->SetMaxValueModifier(aVal);
}
readAnnotation(aTR, theEnt, aTolObj, theLocalFactors);
readAnnotation(aTR, theEnt, aTolObj, theLocalFactors, theUseDEHealingParams);
aGTol->SetObject(aTolObj);
}
@@ -4361,10 +4369,10 @@ Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSess
TDF_Label aGDTL = createGDTObjectInXCAF(anEnt, theDoc, theWS, theLocalFactors);
if (!aGDTL.IsNull()) {
if (anEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
setGeomTolObjectToXCAF(anEnt, aGDTL, theDoc, theWS, theLocalFactors);
setGeomTolObjectToXCAF(anEnt, aGDTL, theDoc, theWS, theLocalFactors, myDEParameters);
}
else {
setDimObjectToXCAF(anEnt, aGDTL, theDoc, theWS, theLocalFactors);
setDimObjectToXCAF(anEnt, aGDTL, theDoc, theWS, theLocalFactors, myDEParameters);
}
}
}
@@ -4457,6 +4465,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSess
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
STEPControl_ActorRead anActor(aModel);
anActor.SetDEHealingParameters(myDEParameters);
Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
anActor.PrepareUnits(aDMIA->UsedRepresentation(), aTP, aLocalFactors);
aFact = aLocalFactors.LengthFactor();
@@ -4813,6 +4822,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadViews(const Handle(XSControl_WorkSes
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
STEPControl_ActorRead anActor(aTP->Model());
anActor.SetDEHealingParameters(myDEParameters);
anActor.PrepareUnits(aDModel, aTP, aLocalFactors);
}

View File

@@ -16,6 +16,7 @@
#ifndef _STEPCAFControl_Reader_HeaderFile
#define _STEPCAFControl_Reader_HeaderFile
#include <DE_ShapeFixParameters.hxx>
#include <STEPControl_Reader.hxx>
#include <StepData_Factors.hxx>
#include <IFSelect_ReturnStatus.hxx>
@@ -207,6 +208,13 @@ public:
//! Get View mode
Standard_EXPORT Standard_Boolean GetViewMode() const;
//! Returns healing parameters map
Standard_EXPORT DE_ShapeFixParameters::HealingParamMap DEHealingParameters() const { return myDEParameters; }
//! Sets healing parameters map
Standard_EXPORT void SetDEHealingParameters(DE_ShapeFixParameters::HealingParamMap theDEHealingParams) { myDEParameters = theDEHealingParams; }
const XCAFDoc_DataMapOfShapeLabel& GetShapeLabelMap() const { return myMap; }
protected:
@@ -375,6 +383,7 @@ private:
Standard_Boolean myMatMode;
Standard_Boolean myViewMode;
NCollection_DataMap<Handle(Standard_Transient), TDF_Label> myGDTMap;
DE_ShapeFixParameters::HealingParamMap myDEParameters;
};

View File

@@ -120,6 +120,7 @@
#include <UnitsMethods.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSAlgo_AlgoProcessShape.hxx>
#include <StepRepr_ConstructiveGeometryRepresentationRelationship.hxx>
#include <StepRepr_ConstructiveGeometryRepresentation.hxx>
#include <StepRepr_MechanicalDesignAndDraughtingRelationship.hxx>
@@ -935,11 +936,16 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(
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_AlgoProcessShape aProcessShape;
aProcessShape.SetShape(comp);
aProcessShape.SetPrscfile("read.step.resource.name");
aProcessShape.SetPseq("read.step.sequence");
aProcessShape.SetInfo(info);
aProcessShape.SetNonManifold(Standard_True);
aProcessShape.SetProgressRange(theProgress);
aProcessShape.SetPrecision(myPrecision);
aProcessShape.SetMaxTol(myMaxTol);
TopoDS_Shape fixedResult = aProcessShape.ProcessShape();
XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
if (fixedResult.ShapeType() == TopAbs_COMPOUND)
@@ -1555,11 +1561,15 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity
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_AlgoProcessShape aProcessShape;
aProcessShape.SetShape(mappedShape);
aProcessShape.SetPrscfile("read.step.resource.name");
aProcessShape.SetPseq("read.step.sequence");
aProcessShape.SetInfo(info);
aProcessShape.SetProgressRange(aPS.Next());
aProcessShape.SetPrecision(myPrecision);
aProcessShape.SetMaxTol(myMaxTol);
mappedShape = aProcessShape.ProcessShape();
XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
}
}
@@ -1727,10 +1737,15 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity
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);
XSAlgo_AlgoProcessShape aProcessShape;
aProcessShape.SetShape(S);
aProcessShape.SetPrscfile("read.step.resource.name");
aProcessShape.SetPseq("read.step.sequence");
aProcessShape.SetInfo(info);
aProcessShape.SetProgressRange(theProgress);
aProcessShape.SetPrecision(myPrecision);
aProcessShape.SetMaxTol(myMaxTol);
TopoDS_Shape shape = aProcessShape.ProcessShape();
// TopoDS_Shape shape = XSAlgo::AlgoContainer()->PerformFixShape( S, TP, myPrecision, myMaxTol );
if (shape != S)
sb->SetResult(shape);

View File

@@ -28,6 +28,7 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <Message_ProgressRange.hxx>
#include <Interface_InterfaceModel.hxx>
#include <DE_ShapeFixParameters.hxx>
class StepRepr_Representation;
class Standard_Transient;
@@ -115,7 +116,11 @@ public:
gp_Trsf& Trsf,
const StepData_Factors& theLocalFactors = StepData_Factors());
//! Returns healing parameters map
Standard_EXPORT DE_ShapeFixParameters::HealingParamMap DEHealingParameters() const { return myDEParameters; }
//! Sets healing parameters map
Standard_EXPORT void SetDEHealingParameters(DE_ShapeFixParameters::HealingParamMap theDEHealingParams) { myDEParameters = theDEHealingParams; }
DEFINE_STANDARD_RTTIEXT(STEPControl_ActorRead,Transfer_ActorOfTransientProcess)
@@ -226,6 +231,7 @@ private:
Standard_Real myMaxTol;
Handle(StepRepr_Representation) mySRContext;
Handle(Interface_InterfaceModel) myModel;
DE_ShapeFixParameters::HealingParamMap myDEParameters;
};

View File

@@ -1003,7 +1003,6 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape
if (hasGeometry(aShape))
{
Standard_Real maxTol = aStepModel->InternalParameters.ReadMaxPrecisionVal;
aShape = XSAlgo::AlgoContainer()->ProcessShape(xShape, Tol, maxTol,
"write.step.resource.name",
"write.step.sequence", info,

View File

@@ -130,7 +130,8 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const Standard_CString filena
WS()->InitTransferReader(4);
return status;
}
#include <STEPControl_ActorRead.hxx>
#include <MoniTool_Macros.hxx>
//=======================================================================
//function : ReadFile
//purpose :
@@ -164,6 +165,8 @@ IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const Standard_CString filena
WS()->SetModel(aStepModel);
WS()->SetLoadedFile(filename);
WS()->InitTransferReader(4);
//DeclareAndCast(STEPControl_ActorRead, anActor, WS()->TransferReader()->Actor());
//anActor->SetDEHealingParameters(DEHealingParameters());
return status;
}

View File

@@ -1,3 +1,4 @@
TKDE
TKBRep
TKernel
TKMath

View File

@@ -3,6 +3,8 @@ XSAlgo.hxx
XSAlgo_AlgoContainer.cxx
XSAlgo_AlgoContainer.hxx
XSAlgo_AlgoContainer.lxx
XSAlgo_AlgoProcessShape.cxx
XSAlgo_AlgoProcessShape.hxx
XSAlgo_Caller.hxx
XSAlgo_ToolContainer.cxx
XSAlgo_ToolContainer.hxx

View File

@@ -56,6 +56,7 @@
#include <TransferBRep_ShapeMapper.hxx>
#include <UnitsMethods.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSAlgo_AlgoProcessShape.hxx>
#include <XSAlgo_ToolContainer.hxx>
#include <TopExp_Explorer.hxx>
@@ -100,88 +101,19 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& theShape,
return theShape;
}
Handle(ShapeProcess_ShapeContext) aContext = Handle(ShapeProcess_ShapeContext)::DownCast(theInfo);
if (aContext.IsNull())
{
Standard_CString aRscfile = Interface_Static::CVal(thePrscfile);
aContext = new ShapeProcess_ShapeContext(theShape, aRscfile);
if (!aContext->ResourceManager()->IsInitialized())
{
// If resource file wasn't found, use static values instead
Interface_Static::FillMap(aContext->ResourceManager()->GetMap());
}
aContext->SetDetalisation(theDetalisationLevel);
}
aContext->SetNonManifold(theNonManifold);
theInfo = aContext;
XSAlgo_AlgoProcessShape aProcessShape;
aProcessShape.SetShape(theShape);
aProcessShape.SetPrscfile(thePrscfile);
aProcessShape.SetPseq(thePseq);
aProcessShape.SetInfo(theInfo);
aProcessShape.SetDetalisationLevel(theDetalisationLevel);
aProcessShape.SetNonManifold(theNonManifold);
aProcessShape.SetProgressRange(theProgress);
aProcessShape.SetPrecision(thePrec);
aProcessShape.SetMaxTol(theMaxTol);
aProcessShape.SetReShape(theReShape);
Standard_CString aSeq = Interface_Static::CVal(thePseq);
if (!aSeq) aSeq = thePseq;
// if resource file is not loaded or does not define <seq>.exec.op,
// do default fixes
Handle(Resource_Manager) aRsc = aContext->ResourceManager();
TCollection_AsciiString aStr(aSeq);
aStr += ".exec.op";
if (!aRsc->Find(aStr.ToCString()))
{
#ifdef OCCT_DEBUG
{
static Standard_Integer aTime = 0;
if (!aTime)
std::cout << "Warning: XSAlgo_AlgoContainer::ProcessShape(): Sequence " << aStr.ToCString() <<
" is not defined in " << thePrscfile << " resource; do default processing" << std::endl;
aTime++;
}
#endif
// if reading, do default ShapeFix
if (!strncmp(thePseq, "read.", 5))
{
try {
OCC_CATCH_SIGNALS
Handle(ShapeExtend_MsgRegistrator) aMsg = new ShapeExtend_MsgRegistrator;
Handle(ShapeFix_Shape) aSfs = ShapeAlgo::AlgoContainer()->ToolContainer()->FixShape();
aSfs->Init(theShape);
aSfs->SetMsgRegistrator(aMsg);
aSfs->SetPrecision(thePrec);
aSfs->SetMaxTolerance(theMaxTol);
aSfs->FixFaceTool()->FixWireTool()->FixSameParameterMode() = Standard_False;
aSfs->FixSolidTool()->CreateOpenSolidMode() = Standard_False;
aSfs->SetContext(theReShape);
aSfs->Perform(theProgress);
TopoDS_Shape aShape = aSfs->Shape();
if (!aShape.IsNull() && aShape != theShape)
{
aContext->RecordModification(aSfs->Context(), aMsg);
aContext->SetResult(aShape);
}
}
catch (Standard_Failure const& anException)
{
#ifdef OCCT_DEBUG
std::cout << "Error: XSAlgo_AlgoContainer::ProcessShape(): Exception in ShapeFix::Shape" << std::endl;
anException.Print(std::cout); std::cout << std::endl;
#endif
(void)anException;
}
return aContext->Result();
}
// for writing, define default sequence of DirectFaces
else if (!strncmp(thePseq, "write.", 6))
{
aRsc->SetResource(aStr.ToCString(), "DirectFaces");
}
}
// Define runtime tolerances and do Shape Processing
aRsc->SetResource("Runtime.Tolerance", thePrec);
aRsc->SetResource("Runtime.MaxTolerance", theMaxTol);
if (!ShapeProcess::Perform(aContext, aSeq, theProgress))
return theShape; // return original shape
return aContext->Result();
return aProcessShape.ProcessShape();
}
//=======================================================================

View File

@@ -19,6 +19,7 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <DE_ShapeFixParameters.hxx>
#include <Message_ProgressRange.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
@@ -46,10 +47,10 @@ public:
Standard_EXPORT XSAlgo_AlgoContainer();
//! Sets ToolContainer
void SetToolContainer (const Handle(XSAlgo_ToolContainer)& TC);
void SetToolContainer (const Handle(XSAlgo_ToolContainer)& TC);
//! Returns ToolContainer
Handle(XSAlgo_ToolContainer) ToolContainer() const;
Handle(XSAlgo_ToolContainer) ToolContainer() const;
//! Performs actions necessary for preparing environment
//! for transfer. Empty in Open version.
@@ -111,8 +112,6 @@ public:
Standard_EXPORT virtual void MergeTransferInfo (const Handle(Transfer_FinderProcess)& FP, const Handle(Standard_Transient)& info) const;
DEFINE_STANDARD_RTTIEXT(XSAlgo_AlgoContainer,Standard_Transient)
protected:
@@ -122,10 +121,8 @@ protected:
private:
Handle(XSAlgo_ToolContainer) myTC;
};

View File

@@ -0,0 +1,149 @@
// Created on: 2000-01-19
// Created by: data exchange team
// Copyright (c) 2000-2014 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 <XSAlgo_AlgoProcessShape.hxx>
#include <Interface_Static.hxx>
#include <Resource_Manager.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
#include <ShapeAlgo_ToolContainer.hxx>
#include <ShapeBuild_ReShape.hxx>
#include <ShapeExtend_MsgRegistrator.hxx>
#include <ShapeFix_Shape.hxx>
#include <ShapeProcess.hxx>
#include <ShapeProcess_ShapeContext.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XSAlgo_AlgoProcessShape, Standard_Transient)
//=======================================================================
//function : XSAlgo_AlgoProcessShape
//purpose :
//=======================================================================
XSAlgo_AlgoProcessShape::XSAlgo_AlgoProcessShape()
: myPrscfile(""),
myPseq(""),
myPrecision(0.001),
myMaxTol(1.),
myNonManifold(false),
myDetalisationLevel(TopAbs_VERTEX),
myProgressRange(Message_ProgressRange())
{
}
//=======================================================================
//function : ProcessShape
//purpose :
//=======================================================================
TopoDS_Shape XSAlgo_AlgoProcessShape::ProcessShape()
{
if (myShape.IsNull())
{
return myShape;
}
if (myReShape.IsNull())
{
myReShape = new ShapeBuild_ReShape();
}
Standard_CString aRscfile = "";
Handle(ShapeProcess_ShapeContext) aContext = Handle(ShapeProcess_ShapeContext)::DownCast(myInfo);
if (aContext.IsNull())
{
aRscfile = Interface_Static::CVal(myPrscfile);
aContext = new ShapeProcess_ShapeContext(myShape, aRscfile);
}
if (myDEParameters.IsEmpty())
{
if (!aContext->ResourceManager()->IsInitialized())
{
// If resource file wasn't found, use static values instead
Interface_Static::FillMap(aContext->ResourceManager()->GetMap());
}
}
aContext->SetDetalisation(myDetalisationLevel);
aContext->SetNonManifold(myNonManifold);
myInfo = aContext;
Standard_CString aSeq = Interface_Static::CVal(myPseq);
if (!aSeq) aSeq = myPseq;
// if resource file is not loaded or does not define <seq>.exec.op,
// do default fixes
Handle(Resource_Manager) aRsc = aContext->ResourceManager();
TCollection_AsciiString aStr(aSeq);
aStr += ".exec.op";
if (strncmp(myPseq, "read.", 5) == 0)
{
aRsc->SetResource(aStr.ToCString(), "FixShape");
try {
OCC_CATCH_SIGNALS
Handle(ShapeExtend_MsgRegistrator) aMsg = new ShapeExtend_MsgRegistrator;
Handle(ShapeFix_Shape) aSfs = ShapeAlgo::AlgoContainer()->ToolContainer()->FixShape();
aSfs->Init(myShape);
aSfs->SetMsgRegistrator(aMsg);
aSfs->SetPrecision(myPrecision);
aSfs->SetMaxTolerance(myMaxTol);
aSfs->FixFaceTool()->FixWireTool()->FixSameParameterMode() = Standard_False;
if (strcmp(aRscfile, "IGES") == 0 || strcmp(aRscfile, "XT") == 0)
{
aSfs->FixSolidTool()->CreateOpenSolidMode() = Standard_True;
}
else
{
aSfs->FixSolidTool()->CreateOpenSolidMode() = Standard_False;
}
aSfs->SetContext(myReShape);
aSfs->Perform(myProgressRange);
TopoDS_Shape aShape = aSfs->Shape();
if (!aShape.IsNull() && aShape != myShape)
{
aContext->RecordModification(aSfs->Context(), aMsg);
aContext->SetResult(aShape);
}
}
catch (Standard_Failure const& anException)
{
#ifdef OCCT_DEBUG
std::cout << "Error: XSAlgo_AlgoContainer::ProcessShape(): Exception in ShapeFix::Shape" << std::endl;
anException.Print(std::cout); std::cout << std::endl;
#endif
(void)anException;
}
return aContext->Result();
}
else if (strncmp(myPseq, "write.", 6) == 0)
{
if (strcmp(aRscfile, "STEP") == 0)
{
aRsc->SetResource(aStr.ToCString(), "SplitCommonVertex,DirectFaces");
}
else
{
aRsc->SetResource(aStr.ToCString(), "DirectFaces");
}
}
// Define runtime tolerances and do Shape Processing
aRsc->SetResource("Runtime.Tolerance", myPrecision);
aRsc->SetResource("Runtime.MaxTolerance", myMaxTol);
if (!ShapeProcess::Perform(aContext, aSeq, myProgressRange))
return myShape; // return original shape
return aContext->Result();
}

View File

@@ -0,0 +1,134 @@
// Copyright (c) 2024 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 _XSAlgo_AlgoProcessShape_HeaderFile
#define _XSAlgo_AlgoProcessShape_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <DE_ShapeFixParameters.hxx>
#include <Message_ProgressRange.hxx>
#include <NCollection_DataMap.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
class ShapeBuild_ReShape;
class XSAlgo_ToolContainer;
class TopoDS_Edge;
class TopoDS_Face;
class Transfer_TransientProcess;
class Transfer_FinderProcess;
class XSAlgo_AlgoProcessShape;
DEFINE_STANDARD_HANDLE(XSAlgo_AlgoProcessShape, Standard_Transient)
//! Class for shape processing
class XSAlgo_AlgoProcessShape : public Standard_Transient
{
public:
//! Empty constructor
Standard_EXPORT XSAlgo_AlgoProcessShape();
//! Shape processing with specified tolerances
Standard_EXPORT TopoDS_Shape ProcessShape();
//! Get shape for processing
const TopoDS_Shape& GetShape() { return myShape; }
//! Set shape for processing
void SetShape(const TopoDS_Shape& theShape) { myShape = theShape; }
//! Get name of the resource file
const Standard_CString& GetPrscfile() { return myPrscfile; }
//! Set name of the resource file
void SetPrscfile(const Standard_CString& thePrscfile) { myPrscfile = thePrscfile; }
//! Get name of the sequence of operators defined in the resource file for Shape Processing
const Standard_CString& GetPseq() { return myPseq; }
//! Set name of the sequence of operators defined in the resource file for Shape Processing
void SetPseq(const Standard_CString& thePseq) { myPseq = thePseq; }
//! Get information to be recorded in the translation map
const Handle(Standard_Transient)& GetInfo() { return myInfo; }
//! Set information to be recorded in the translation map
void SetInfo(const Handle(Standard_Transient)& theInfo) { myInfo = theInfo; }
//! Get flag to proceed with non-manifold topology
const bool GetNonManifold() { return myNonManifold; }
//! Set flag to proceed with non-manifold topology
void SetNonManifold(const bool theNonManifold) { myNonManifold = theNonManifold; }
//! Get detalisation level
const TopAbs_ShapeEnum GetDetalisationLevel() { return myDetalisationLevel; }
//! Set detalisation level
void SetDetalisationLevel(const TopAbs_ShapeEnum theDetalisationLevel) { myDetalisationLevel = theDetalisationLevel; }
//! Get progress indicator
const Message_ProgressRange& GetProgressRange() { return myProgressRange; }
//! Set progress indicator
void SetProgressRange(const Message_ProgressRange& theProgressRange) { myProgressRange = theProgressRange; }
//! Get maximum allowed tolerance
const double GetMaxTol() { return myMaxTol; }
//! Set maximum allowed tolerance
void SetMaxTol(const double theMaxTol) { myMaxTol = theMaxTol; }
//! Get basic precision
const double GetPrecision() { return myPrecision; }
//! Set basic precision
void SetPrecision(const double thePrecision) { myPrecision = thePrecision; }
//! Get tool to record the modifications of input shape
const Handle(ShapeBuild_ReShape)& GetReShape() { return myReShape; }
//! Set tool to record the modifications of input shape
void SetReShape(const Handle(ShapeBuild_ReShape)& theReShape) { myReShape = theReShape; }
//! Returns healing parameters map
DE_ShapeFixParameters::HealingParamMap DEHealingParameters() const { return myDEParameters; }
//! Sets healing parameters map
void SetDEHealingParameters(DE_ShapeFixParameters::HealingParamMap theDEHealingParams) { myDEParameters = theDEHealingParams; }
DEFINE_STANDARD_RTTIEXT(XSAlgo_AlgoProcessShape, Standard_Transient)
private:
TopoDS_Shape myShape;
Standard_CString myPrscfile;
Standard_CString myPseq;
double myPrecision;
double myMaxTol;
bool myNonManifold;
TopAbs_ShapeEnum myDetalisationLevel;
Message_ProgressRange myProgressRange;
Handle(Standard_Transient) myInfo;
Handle(ShapeBuild_ReShape) myReShape;
DE_ShapeFixParameters::HealingParamMap myDEParameters;
};
#endif // _XSAlgo_AlgoProcessShape_HeaderFile

View File

@@ -21,6 +21,7 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <DE_ShapeFixParameters.hxx>
#include <TColStd_SequenceOfTransient.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <Standard_CString.hxx>
@@ -260,7 +261,11 @@ public:
//! Gives statistics about Transfer
Standard_EXPORT void GetStatsTransfer (const Handle(TColStd_HSequenceOfTransient)& list, Standard_Integer& nbMapped, Standard_Integer& nbWithResult, Standard_Integer& nbWithFail) const;
//! Returns healing parameters map
Standard_EXPORT DE_ShapeFixParameters::HealingParamMap DEHealingParameters() const { return myDEParameters; }
//! Sets healing parameters map
Standard_EXPORT void SetDEHealingParameters(DE_ShapeFixParameters::HealingParamMap theDEHealingParams) { myDEParameters = theDEHealingParams; }
protected:
@@ -280,6 +285,7 @@ private:
Handle(XSControl_WorkSession) thesession;
TopTools_SequenceOfShape theshapes;
DE_ShapeFixParameters::HealingParamMap myDEParameters;
};

View File

@@ -835,6 +835,11 @@ static Standard_Integer ReadIges(Draw_Interpretor& theDI,
Standard_Integer onlyVisible = Interface_Static::IVal("read.iges.onlyvisible");
aReader.SetReadVisible(onlyVisible == 1);
DE_ShapeFixParameters aParameters;
DE_ShapeFixParameters::HealingParamMap aDEHealingParams = aReader.DEHealingParameters();
aParameters.FillParamsMap(aDEHealingParams);
aReader.SetDEHealingParameters(aDEHealingParams);
if (theNbArgs == 4)
{
Standard_Boolean mode = Standard_True;

View File

@@ -17,6 +17,7 @@
#include <DDF.hxx>
#include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
#include <DE_ShapeFixParameters.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
@@ -693,6 +694,11 @@ static Standard_Integer ReadStep(Draw_Interpretor& theDI,
}
STEPCAFControl_Reader aReader(XSDRAW::Session(), isFileMode);
DE_ShapeFixParameters aParameters;
DE_ShapeFixParameters::HealingParamMap aDEHealingParams = aReader.ChangeReader().DEHealingParameters();
aParameters.FillParamsMap(aDEHealingParams);
aReader.ChangeReader().SetDEHealingParameters(aDEHealingParams);
if (!aModeStr.IsEmpty())
{
Standard_Boolean aMode = Standard_True;