#include <TDocStd_Application.hxx>
#include <TPrsStd_AISPresentation.hxx>
#include <ExprIntrp_GenExp.hxx>
+#include <StepData_StepModel.hxx>
+#include <XSControl_WorkSession.hxx>
#if ! defined(_WIN32)
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
//purpose :
//=======================================================================
-Standard_Boolean STEPCAFControl_ActorWrite::IsAssembly (TopoDS_Shape &S) const
+Standard_Boolean STEPCAFControl_ActorWrite::IsAssembly (const Handle(StepData_StepModel)& theModel,
+ TopoDS_Shape &S) const
{
- if ( myStdMode ) return STEPControl_ActorWrite::IsAssembly ( S );
+ if ( myStdMode ) return STEPControl_ActorWrite::IsAssembly ( theModel, S );
return myMap.Contains ( S );
}
//! Check whether shape S is assembly
//! Returns True if shape is registered in assemblies map
- Standard_EXPORT virtual Standard_Boolean IsAssembly (TopoDS_Shape& S) const Standard_OVERRIDE;
+ Standard_EXPORT virtual Standard_Boolean IsAssembly (const Handle(StepData_StepModel)& theModel,
+ TopoDS_Shape& S) const Standard_OVERRIDE;
//! Set standard mode of work
//! In standard mode Actor (default) behaves exactly as its
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
- InternalParameters.ReadBSplineContinuity = (ReadMode_BSplineContinuity)
+ InternalParameters.ReadBSplineContinuity = (StepData_ConfParameters::ReadMode_BSplineContinuity)
theResource->IntegerVal("read.iges.bspline.continuity", InternalParameters.ReadBSplineContinuity, aScope);
- InternalParameters.ReadPrecisionMode = (ReadMode_Precision)
+ InternalParameters.ReadPrecisionMode = (StepData_ConfParameters::ReadMode_Precision)
theResource->IntegerVal("read.precision.mode", InternalParameters.ReadPrecisionMode, aScope);
InternalParameters.ReadPrecisionVal =
theResource->RealVal("read.precision.val", InternalParameters.ReadPrecisionVal, aScope);
- InternalParameters.ReadMaxPrecisionMode = (ReadMode_MaxPrecision)
+ InternalParameters.ReadMaxPrecisionMode = (StepData_ConfParameters::ReadMode_MaxPrecision)
theResource->IntegerVal("read.maxprecision.mode", InternalParameters.ReadMaxPrecisionMode, aScope);
InternalParameters.ReadMaxPrecisionVal =
theResource->RealVal("read.maxprecision.val", InternalParameters.ReadMaxPrecisionVal, aScope);
InternalParameters.ReadSameParamMode =
theResource->BooleanVal("read.stdsameparameter.mode", InternalParameters.ReadSameParamMode, aScope);
- InternalParameters.ReadSurfaceCurveMode = (ReadMode_SurfaceCurve)
+ InternalParameters.ReadSurfaceCurveMode = (StepData_ConfParameters::ReadMode_SurfaceCurve)
theResource->IntegerVal("read.surfacecurve.mode", InternalParameters.ReadSurfaceCurveMode, aScope);
InternalParameters.EncodeRegAngle =
theResource->RealVal("read.encoderegularity.angle", InternalParameters.EncodeRegAngle, aScope);
- InternalParameters.AngleUnit = (AngleUnitMode)
+ InternalParameters.AngleUnit = (StepData_ConfParameters::AngleUnitMode)
theResource->IntegerVal("angleunit.mode", InternalParameters.AngleUnit, aScope);
InternalParameters.ReadResourceName =
theResource->StringVal("read.sequence", InternalParameters.ReadSequence, aScope);
InternalParameters.ReadProductMode =
theResource->BooleanVal("read.product.mode", InternalParameters.ReadProductMode, aScope);
- InternalParameters.ReadProductContext = (ReadMode_ProductContext)
+ InternalParameters.ReadProductContext = (StepData_ConfParameters::ReadMode_ProductContext)
theResource->IntegerVal("read.product.context", InternalParameters.ReadProductContext, aScope);
- InternalParameters.ReadShapeRepr = (ReadMode_ShapeRepr)
+ InternalParameters.ReadShapeRepr = (StepData_ConfParameters::ReadMode_ShapeRepr)
theResource->IntegerVal("read.shape.repr", InternalParameters.ReadShapeRepr, aScope);
- InternalParameters.ReadTessellated = (RWMode_Tessellated)
+ InternalParameters.ReadTessellated = (StepData_ConfParameters::RWMode_Tessellated)
theResource->IntegerVal("read.tessellated", InternalParameters.ReadTessellated, aScope);
- InternalParameters.ReadAssemblyLevel = (ReadMode_AssemblyLevel)
+ InternalParameters.ReadAssemblyLevel = (StepData_ConfParameters::ReadMode_AssemblyLevel)
theResource->IntegerVal("read.assembly.level", InternalParameters.ReadAssemblyLevel, aScope);
InternalParameters.ReadRelationship =
theResource->BooleanVal("read.shape.relationship", InternalParameters.ReadRelationship, aScope);
InternalParameters.ReadProps =
theResource->BooleanVal("read.props", InternalParameters.ReadProps, aScope);
- InternalParameters.WritePrecisionMode = (WriteMode_PrecisionMode)
+ InternalParameters.WritePrecisionMode = (StepData_ConfParameters::WriteMode_PrecisionMode)
theResource->IntegerVal("write.precision.mode", InternalParameters.WritePrecisionMode, aScope);
InternalParameters.WritePrecisionVal =
theResource->RealVal("write.precision.val", InternalParameters.WritePrecisionVal, aScope);
- InternalParameters.WriteAssembly = (WriteMode_Assembly)
+ InternalParameters.WriteAssembly = (StepData_ConfParameters::WriteMode_Assembly)
theResource->IntegerVal("write.assembly", InternalParameters.WriteAssembly, aScope);
- InternalParameters.WriteSchema = (WriteMode_StepSchema)
+ InternalParameters.WriteSchema = (StepData_ConfParameters::WriteMode_StepSchema)
theResource->IntegerVal("write.schema", InternalParameters.WriteSchema, aScope);
- InternalParameters.WriteTessellated = (RWMode_Tessellated)
+ InternalParameters.WriteTessellated = (StepData_ConfParameters::RWMode_Tessellated)
theResource->IntegerVal("write.tessellated", InternalParameters.WriteTessellated, aScope);
InternalParameters.WriteProductName =
theResource->StringVal("write.product.name", InternalParameters.WriteProductName, aScope);
theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
InternalParameters.WriteSequence =
theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
- InternalParameters.WriteVertexMode = (WriteMode_VertexMode)
+ InternalParameters.WriteVertexMode = (StepData_ConfParameters::WriteMode_VertexMode)
theResource->IntegerVal("write.vertex.mode", InternalParameters.WriteVertexMode, aScope);
InternalParameters.WriteSubshapeNames =
theResource->BooleanVal("write.stepcaf.subshapes.name", InternalParameters.WriteSubshapeNames, aScope);
#include <DE_ConfigurationNode.hxx>
#include <STEPControl_StepModelType.hxx>
+#include <StepData_ConfParameters.hxx>
#include <Resource_FormatType.hxx>
#include <UnitsMethods_LengthUnit.hxx>
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 AngleUnitMode
- {
- AngleUnitMode_File = 0,
- AngleUnitMode_Rad,
- AngleUnitMode_Deg
- };
- enum ReadMode_ProductContext
- {
- ReadMode_ProductContext_All = 1,
- ReadMode_ProductContext_Design,
- ReadMode_ProductContext_Analysis
- };
- enum ReadMode_ShapeRepr
- {
- ReadMode_ShapeRepr_All = 1,
- ReadMode_ShapeRepr_ABSR,
- ReadMode_ShapeRepr_MSSR,
- ReadMode_ShapeRepr_GBSSR,
- ReadMode_ShapeRepr_FBSR,
- ReadMode_ShapeRepr_EBWSR,
- ReadMode_ShapeRepr_GBWSR
- };
- enum ReadMode_AssemblyLevel
- {
- ReadMode_AssemblyLevel_All = 1,
- ReadMode_AssemblyLevel_Assembly,
- ReadMode_AssemblyLevel_Structure,
- ReadMode_AssemblyLevel_Shape
- };
- enum RWMode_Tessellated
- {
- RWMode_Tessellated_Off = 0,
- RWMode_Tessellated_On,
- RWMode_Tessellated_OnNoBRep
- };
- enum WriteMode_PrecisionMode
- {
- WriteMode_PrecisionMode_Least = -1,
- WriteMode_PrecisionMode_Average = 0,
- WriteMode_PrecisionMode_Greatest = 1,
- WriteMode_PrecisionMode_Session = 2
- };
- enum WriteMode_Assembly
- {
- WriteMode_Assembly_Off = 0,
- WriteMode_Assembly_On,
- WriteMode_Assembly_Auto
- };
- enum WriteMode_StepSchema
- {
- WriteMode_StepSchema_AP214CD = 1,
- WriteMode_StepSchema_AP214DIS,
- WriteMode_StepSchema_AP203,
- WriteMode_StepSchema_AP214IS,
- WriteMode_StepSchema_AP242DIS
- };
- enum WriteMode_VertexMode
- {
- WriteMode_VertexMode_OneCompound = 0,
- WriteMode_VertexMode_SingleVertex
- };
- struct STEPCAFControl_InternalSection
- {
- // Common
- 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
- AngleUnitMode AngleUnit = AngleUnitMode_File; //<! Indicates what angle units should be used when a STEP file is read
-
- // Read
- TCollection_AsciiString ReadResourceName = "STEP"; //<! Defines the name of the resource file to read
- TCollection_AsciiString ReadSequence = "FromSTEP"; //<! Defines the name of the sequence of operators to read
- bool ReadProductMode = true; //<! Defines the approach used for selection of top-level STEP entities for translation, and for recognition of assembly structures
- ReadMode_ProductContext ReadProductContext = ReadMode_ProductContext_All; //<! When reading AP 209 STEP files, allows selecting either only 'design' or 'analysis', or both types of products for translation
- ReadMode_ShapeRepr ReadShapeRepr = ReadMode_ShapeRepr_All; //<! Specifies preferred type of representation of the shape of the product
- RWMode_Tessellated ReadTessellated = RWMode_Tessellated_On; //!< Defines whether tessellated shapes should be translated
- ReadMode_AssemblyLevel ReadAssemblyLevel = ReadMode_AssemblyLevel_All; //<! Specifies which data should be read for the products found in the STEP file
- bool ReadRelationship = true; //<! Defines whether shapes associated with the main SHAPE_DEFINITION_REPRESENTATION entity of the product via SHAPE_REPRESENTATIONSHIP_RELATION should be translated
- bool ReadShapeAspect = true; //<! Defines whether shapes associated with the PRODUCT_DEFINITION_SHAPE entity of the product via SHAPE_ASPECT should be translated
- bool ReadConstrRelation = false; //<! Flag regulating translation of "CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP" entities
- bool ReadSubshapeNames = false; //<! Indicates whether to read sub-shape names from 'Name' attributes of STEP Representation Items
- Resource_FormatType ReadCodePage = Resource_FormatType_UTF8; //<! STEP file encoding for names translation
- bool ReadNonmanifold = false; //<! Defines non-manifold topology reading
- bool ReadIdeas = false; //<! Defines !I-Deas-like STEP processing
- bool ReadAllShapes = false; //<! Parameter to read all top level solids and shells
- bool ReadRootTransformation = true; ///<!/ Mode to variate apply or not transformation placed in the root shape representation
- 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
- bool ReadProps = true; //<! PropsMode is used to indicate read Validation properties or not
-
- // Write
- WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the STEP file
- double WritePrecisionVal = 0.0001; //<! Resolution value for an STEP file when WriteMode_PrecisionMode is Greatest
- WriteMode_Assembly WriteAssembly = WriteMode_Assembly_Off; //<! Writing assembly mode
- WriteMode_StepSchema WriteSchema = WriteMode_StepSchema_AP214CD; //<! Defines the version of schema used for the output STEP file
- RWMode_Tessellated WriteTessellated = RWMode_Tessellated_OnNoBRep; //!< Defines whether tessellated shapes should be translated
- TCollection_AsciiString WriteProductName; //<! Defines the text string that will be used for field 'name' of PRODUCT entities written to the STEP file
- bool WriteSurfaceCurMode = true; //<! Indicates whether parametric curves (curves in parametric space of surface) should be written into the STEP file
- UnitsMethods_LengthUnit WriteUnit = UnitsMethods_LengthUnit_Millimeter; //<! Defines a unit in which the STEP file should be written
- TCollection_AsciiString WriteResourceName = "STEP"; //<! Defines the name of the resource file to write
- TCollection_AsciiString WriteSequence = "ToSTEP"; //<! Defines the name of the sequence of operators to write
- WriteMode_VertexMode WriteVertexMode = WriteMode_VertexMode_OneCompound; //<! Indicates which of free vertices writing mode is switch on
- bool WriteSubshapeNames = false; //<! Indicates whether to write sub-shape names to 'Name' attributes of STEP Representation Items
- 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
- bool WriteProps = true; //<! PropsMode is used to indicate write Validation properties or not
- STEPControl_StepModelType WriteModelType = STEPControl_AsIs; //<! Gives you the choice of translation mode for an Open CASCADE shape that is being translated to STEP
-
- } InternalParameters;
-
+ StepData_ConfParameters InternalParameters;
};
#endif // _STEPCAFControl_ConfigurationNode_HeaderFile
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <StepData_StepModel.hxx>
+#include <StepData_ConfParameters.hxx>
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <STEPCAFControl_Controller.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <XCAFDoc_DocumentTool.hxx>
+#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_Provider, DE_Provider)
:DE_Provider(theNode)
{}
-//=======================================================================
-// function : initStatic
-// purpose :
-//=======================================================================
-void STEPCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
-{
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(theNode);
- STEPCAFControl_Controller::Init();
-
- // Get previous values
- myOldValues.ReadBSplineContinuity = (STEPCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal("read.iges.bspline.continuity");
- myOldValues.ReadPrecisionMode = (STEPCAFControl_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
- myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
- myOldValues.ReadMaxPrecisionMode = (STEPCAFControl_ConfigurationNode::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 = (STEPCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
- myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
- myOldValues.AngleUnit = (STEPCAFControl_ConfigurationNode::AngleUnitMode)Interface_Static::IVal("step.angleunit.mode");
-
- myOldValues.ReadResourceName = Interface_Static::CVal("read.step.resource.name");
- myOldValues.ReadSequence = Interface_Static::CVal("read.step.sequence");
- myOldValues.ReadProductMode = Interface_Static::IVal("read.step.product.mode") == 1;
- myOldValues.ReadProductContext = (STEPCAFControl_ConfigurationNode::ReadMode_ProductContext)Interface_Static::IVal("read.step.product.context");
- myOldValues.ReadShapeRepr = (STEPCAFControl_ConfigurationNode::ReadMode_ShapeRepr)Interface_Static::IVal("read.step.shape.repr");
- myOldValues.ReadTessellated = (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)Interface_Static::IVal("read.step.tessellated");
- myOldValues.ReadAssemblyLevel = (STEPCAFControl_ConfigurationNode::ReadMode_AssemblyLevel)Interface_Static::IVal("read.step.assembly.level");
- myOldValues.ReadRelationship = Interface_Static::IVal("read.step.shape.relationship") == 1;
- myOldValues.ReadShapeAspect = Interface_Static::IVal("read.step.shape.aspect") == 1;
- myOldValues.ReadConstrRelation = Interface_Static::IVal("read.step.constructivegeom.relationship") == 1;
- myOldValues.ReadSubshapeNames = Interface_Static::IVal("read.stepcaf.subshapes.name") == 1;
- myOldValues.ReadCodePage = (Resource_FormatType)Interface_Static::IVal("read.step.codepage");
- myOldValues.ReadNonmanifold = Interface_Static::IVal("read.step.nonmanifold") == 1;
- myOldValues.ReadIdeas = Interface_Static::IVal("read.step.ideas") == 1;
- myOldValues.ReadAllShapes = Interface_Static::IVal("read.step.all.shapes") == 1;
- myOldValues.ReadRootTransformation = Interface_Static::IVal("read.step.root.transformation") == 1;
-
- myOldValues.WritePrecisionMode = (STEPCAFControl_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
- myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
- myOldValues.WriteAssembly = (STEPCAFControl_ConfigurationNode::WriteMode_Assembly)Interface_Static::IVal("write.step.assembly");
- myOldValues.WriteSchema = (STEPCAFControl_ConfigurationNode::WriteMode_StepSchema)Interface_Static::IVal("write.step.schema");
- myOldValues.WriteTessellated = (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)Interface_Static::IVal("write.step.tessellated");
- myOldValues.WriteProductName = Interface_Static::CVal("write.step.product.name");
- myOldValues.WriteSurfaceCurMode = Interface_Static::IVal("write.surfacecurve.mode") == 1;
- myOldValues.WriteUnit = (UnitsMethods_LengthUnit)Interface_Static::IVal("write.step.unit");
- myOldValues.WriteResourceName = Interface_Static::CVal("write.resource.name");
- myOldValues.WriteSequence = Interface_Static::CVal("write.step.sequence");
- myOldValues.WriteVertexMode = (STEPCAFControl_ConfigurationNode::WriteMode_VertexMode)Interface_Static::IVal("write.step.vertex.mode");
- myOldValues.WriteSubshapeNames = Interface_Static::IVal("write.stepcaf.subshapes.name") == 1;
-
- // Set new values
- setStatic(aNode->InternalParameters);
-}
-
-//=======================================================================
-// function : setStatic
-// purpose :
-//=======================================================================
-void STEPCAFControl_Provider::setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection& theParameter)
-{
- Interface_Static::SetIVal("read.iges.bspline.continuity", theParameter.ReadBSplineContinuity);
- Interface_Static::SetIVal("read.precision.mode", theParameter.ReadPrecisionMode);
- Interface_Static::SetRVal("read.precision.val", theParameter.ReadPrecisionVal);
- Interface_Static::SetIVal("read.maxprecision.mode", theParameter.ReadMaxPrecisionMode);
- Interface_Static::SetRVal("read.maxprecision.val", theParameter.ReadMaxPrecisionVal);
- Interface_Static::SetIVal("read.stdsameparameter.mode", theParameter.ReadSameParamMode);
- Interface_Static::SetIVal("read.surfacecurve.mode", theParameter.ReadSurfaceCurveMode);
- Interface_Static::SetRVal("read.encoderegularity.angle", theParameter.EncodeRegAngle * M_PI / 180.0);
- Interface_Static::SetIVal("step.angleunit.mode", theParameter.AngleUnit);
-
- Interface_Static::SetCVal("read.step.resource.name", theParameter.ReadResourceName.ToCString());
- Interface_Static::SetCVal("read.step.sequence", theParameter.ReadSequence.ToCString());
- Interface_Static::SetIVal("read.step.product.mode", theParameter.ReadProductMode);
- Interface_Static::SetIVal("read.step.product.context", theParameter.ReadProductContext);
- Interface_Static::SetIVal("read.step.shape.repr", theParameter.ReadShapeRepr);
- Interface_Static::SetIVal("read.step.tessellated", theParameter.ReadTessellated);
- Interface_Static::SetIVal("read.step.assembly.level", theParameter.ReadAssemblyLevel);
- Interface_Static::SetIVal("read.step.shape.relationship", theParameter.ReadRelationship);
- Interface_Static::SetIVal("read.step.shape.aspect", theParameter.ReadShapeAspect);
- Interface_Static::SetIVal("read.step.constructivegeom.relationship", theParameter.ReadConstrRelation);
- Interface_Static::SetIVal("read.stepcaf.subshapes.name", theParameter.ReadSubshapeNames);
- Interface_Static::SetIVal("read.step.codepage", theParameter.ReadCodePage);
- Interface_Static::SetIVal("read.step.nonmanifold", theParameter.ReadNonmanifold);
- Interface_Static::SetIVal("read.step.ideas", theParameter.ReadIdeas);
- Interface_Static::SetIVal("read.step.all.shapes", theParameter.ReadAllShapes);
- Interface_Static::SetIVal("read.step.root.transformation", theParameter.ReadRootTransformation);
-
- Interface_Static::SetIVal("write.precision.mode", theParameter.WritePrecisionMode);
- Interface_Static::SetRVal("write.precision.val", theParameter.WritePrecisionVal);
- Interface_Static::SetIVal("write.step.assembly", theParameter.WriteAssembly);
- Interface_Static::SetIVal("write.step.schema", theParameter.WriteSchema);
- Interface_Static::SetIVal("write.step.tessellated", theParameter.WriteTessellated);
- Interface_Static::SetCVal("write.step.product.name", theParameter.WriteProductName.ToCString());
- Interface_Static::SetIVal("write.surfacecurve.mode", theParameter.WriteSurfaceCurMode);
- Interface_Static::SetIVal("write.step.unit", theParameter.WriteUnit);
- Interface_Static::SetCVal("write.resource.name", theParameter.WriteResourceName.ToCString());
- Interface_Static::SetCVal("write.step.sequence", theParameter.WriteSequence.ToCString());
- Interface_Static::SetIVal("write.step.vertex.mode", theParameter.WriteVertexMode);
- Interface_Static::SetIVal("write.stepcaf.subshapes.name", theParameter.WriteSubshapeNames);
-}
-
-//=======================================================================
-// function : resetStatic
-// purpose :
-//=======================================================================
-void STEPCAFControl_Provider::resetStatic()
-{
- setStatic(myOldValues);
-}
-
//=======================================================================
// function : Read
// purpose :
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
- initStatic(aNode);
-
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
STEPCAFControl_Reader aReader;
if (!theWS.IsNull())
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
-
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
- aReadStat = aReader.ReadFile(thePath.ToCString());
+ StepData_ConfParameters aParams;
+ aReadStat = aReader.ReadFile(thePath.ToCString(), aParams);
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: abandon";
- resetStatic();
return false;
}
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: Cannot read any relevant data from the STEP file";
- resetStatic();
return false;
}
- resetStatic();
return true;
}
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
- initStatic(aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
- UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter),
- UnitsMethods_LengthUnit_Millimeter);
+ UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit,
+ UnitsMethods_LengthUnit_Millimeter), UnitsMethods_LengthUnit_Millimeter);
STEPCAFControl_Writer aWriter;
if (!theWS.IsNull())
{
aWriter.Init(theWS);
}
- STEPControl_StepModelType aMode = static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
+ Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(aWriter.Writer().WS()->Model());
+ STEPControl_StepModelType aMode =
+ static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
aWriter.SetPropsMode(aNode->InternalParameters.WriteProps);
TDF_Label aLabel;
-
- if (!aWriter.Transfer(theDocument, aMode, 0, theProgress))
+ StepData_ConfParameters aParams;
+ if (!aWriter.Transfer(theDocument, aParams, aMode, 0, theProgress))
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
thePath << "\t: The document cannot be translated or gives no result";
- resetStatic();
return false;
}
IFSelect_ReturnStatus aStatus = aWriter.Write(thePath.ToCString());
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
thePath << "\t: No file written";
- resetStatic();
return false;;
}
case IFSelect_RetDone:
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
thePath << "\t: Error on writing file";
- resetStatic();
return false;
}
}
- resetStatic();
return true;
}
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
- initStatic(aNode);
STEPControl_Reader aReader;
if(!theWS.IsNull())
{
aReader.SetWS(theWS);
}
IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
- aReadstat = aReader.ReadFile(thePath.ToCString());
+ StepData_ConfParameters aParams;
+ aReadstat = aReader.ReadFile(thePath.ToCString(), aParams);
+ Handle(StepData_StepModel) aModel = aReader.StepModel();
if (aReadstat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: abandon, no model loaded";
- resetStatic();
return false;
}
- Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(aReader.Model());
aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit);
if (aReader.TransferRoots() <= 0)
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t:Cannot read any relevant data from the STEP file";
- resetStatic();
return false;
}
theShape = aReader.OneShape();
- resetStatic();
return true;
}
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
- initStatic(aNode);
STEPControl_Writer aWriter;
if(!theWS.IsNull())
IFSelect_ReturnStatus aWritestat = IFSelect_RetVoid;
Handle(StepData_StepModel) aModel = aWriter.Model();
aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter));
- aWritestat = aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, true, theProgress);
+ StepData_ConfParameters aParams;
+ aWritestat = aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, aParams, true, theProgress);
if (aWritestat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: abandon, no model loaded";
- resetStatic();
return false;
}
if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone)
{
Message::SendFail() << "STEPCAFControl_Provider: Error on writing file";
- resetStatic();
return false;
}
- resetStatic();
return true;
}
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
- private:
-
- //! Initialize static variables
- void initStatic(const Handle(DE_ConfigurationNode)& theNode);
-
- //! Initialize static variables
- void setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection& theParameter);
-
- //! Reset used interface static variables
- void resetStatic();
-
- STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection myOldValues;
};
myViewMode(Standard_True)
{
STEPCAFControl_Controller::Init();
+ if (!myReader.WS().IsNull())
+ {
+ Init(myReader.WS());
+ }
}
return myReader.ReadFile (theFileName);
}
+//=======================================================================
+//function : ReadFile
+//purpose :
+//=======================================================================
+IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile (const Standard_CString theFileName,
+ const StepData_ConfParameters& theParams)
+{
+ return myReader.ReadFile(theFileName, theParams);
+}
+
//=======================================================================
//function : ReadStream
//purpose :
return Transfer (doc, theProgress);
}
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+Standard_Boolean STEPCAFControl_Reader::Perform (const Standard_CString filename,
+ const Handle(TDocStd_Document)& doc,
+ const StepData_ConfParameters& theParams,
+ const Message_ProgressRange& theProgress)
+{
+ if (ReadFile(filename, theParams) != IFSelect_RetDone)
+ {
+ return Standard_False;
+ }
+ return Transfer(doc, theProgress);
+}
//=======================================================================
//function : Perform
return Transfer (doc, theProgress);
}
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+Standard_Boolean STEPCAFControl_Reader::Perform (const TCollection_AsciiString& filename,
+ const Handle(TDocStd_Document)& doc,
+ const StepData_ConfParameters& theParams,
+ const Message_ProgressRange& theProgress)
+{
+ if (ReadFile(filename.ToCString(), theParams) != IFSelect_RetDone)
+ {
+ return Standard_False;
+ }
+ return Transfer(doc, theProgress);
+}
//=======================================================================
//function : ExternFiles
Handle(StepVisual_DraughtingModel) aDModel =
Handle(StepVisual_DraughtingModel)::DownCast(aDMIA->UsedRepresentation());
XSAlgo::AlgoContainer()->PrepareForTransfer();
- STEPControl_ActorRead anActor;
+ STEPControl_ActorRead anActor(aTP->Model());
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aDModel, aTP, aLocalFactors);
Standard_Real aFact = aLocalFactors.LengthFactor();
if (!aSDR.IsNull())
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
- STEPControl_ActorRead anActor;
+ STEPControl_ActorRead anActor(theTR->Model());
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aSDR, aTP, aLocalFactors);
aFact = aLocalFactors.LengthFactor();
Handle(StepGeom_Axis2Placement3d) anAx
= Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(j));
XSAlgo::AlgoContainer()->PrepareForTransfer();
- STEPControl_ActorRead anActor;
+ STEPControl_ActorRead anActor(aTP->Model());
StepData_Factors aLocalFactors = theLocalFactors;
anActor.PrepareUnits(aSRWP, aTP, aLocalFactors);
Handle(Geom_Axis2Placement) anAxis = StepToGeom::MakeAxis2Placement(anAx, aLocalFactors);
if (!aDMIA.IsNull())
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
- STEPControl_ActorRead anActor;
+ STEPControl_ActorRead anActor(aModel);
Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
anActor.PrepareUnits(aDMIA->UsedRepresentation(), aTP, aLocalFactors);
aFact = aLocalFactors.LengthFactor();
if (!aDModel.IsNull())
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
- STEPControl_ActorRead anActor;
+ STEPControl_ActorRead anActor(aTP->Model());
anActor.PrepareUnits(aDModel, aTP, aLocalFactors);
}
const Handle(Transfer_TransientProcess)& TP = Reader().WS()->TransferReader()->TransientProcess();
NCollection_DataMap<TopoDS_Shape, Handle(TCollection_HAsciiString)> ShapeNameMap;
TColStd_MapOfTransient aRepItems;
-
- // Read translation control variables
- Standard_Boolean doReadSNames = (Interface_Static::IVal("read.stepcaf.subshapes.name") > 0);
-
- if (!doReadSNames)
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
+ if (!aStepModel->InternalParameters.ReadSubshapeNames)
return;
const Interface_Graph& Graph = Reader().WS()->Graph();
//! @return read status
Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString theFileName);
+ //! Loads a file and returns the read status
+ //! Provided for use like single-file reader.
+ //! @param theFileName [in] file to open
+ //! @param theParams [in] default configuration parameters
+ //! @return read status
+ Standard_EXPORT IFSelect_ReturnStatus ReadFile(const Standard_CString theFileName,
+ const StepData_ConfParameters& theParams);
+
//! Loads a file from stream and returns the read status.
//! @param theName [in] auxiliary stream name
//! @param theIStream [in] stream to read from
Standard_EXPORT Standard_Boolean Perform (const TCollection_AsciiString& filename,
const Handle(TDocStd_Document)& doc,
const Message_ProgressRange& theProgress = Message_ProgressRange());
-
+
+ Standard_EXPORT Standard_Boolean Perform (const TCollection_AsciiString& filename,
+ const Handle(TDocStd_Document)& doc,
+ const StepData_ConfParameters& theParams,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
+ //! Translate STEP file given by filename into the document
+ //! Return True if succeeded, and False in case of fail
+ Standard_EXPORT Standard_Boolean Perform (const Standard_CString filename,
+ const Handle(TDocStd_Document)& doc,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
//! Translate STEP file given by filename into the document
//! Return True if succeeded, and False in case of fail
Standard_EXPORT Standard_Boolean Perform (const Standard_CString filename,
const Handle(TDocStd_Document)& doc,
+ const StepData_ConfParameters& theParams,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Returns data on external files
const STEPControl_StepModelType theMode,
const Standard_CString theMulti,
const Message_ProgressRange& theProgress)
+{
+ const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(myWriter.WS()->Model());
+ aModel->InternalParameters.InitFromStatic();
+ return Transfer(theDoc, aModel->InternalParameters, theMode, theMulti, theProgress);
+}
+
+//=======================================================================
+//function : Transfer
+//purpose :
+//=======================================================================
+Standard_Boolean STEPCAFControl_Writer::Transfer(const Handle(TDocStd_Document)& theDoc,
+ const StepData_ConfParameters& theParams,
+ const STEPControl_StepModelType theMode,
+ const Standard_CString theMulti,
+ const Message_ProgressRange& theProgress)
{
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
if (aShTool.IsNull())
myRootLabels.Add(theDoc->Main().Root());
TDF_LabelSequence aLabels;
aShTool->GetFreeShapes(aLabels);
+ const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(myWriter.WS()->Model());
+ aModel->InternalParameters = theParams;
return transfer(myWriter, aLabels, theMode, theMulti, Standard_False, theProgress);
}
const STEPControl_StepModelType theMode,
const Standard_CString theIsMulti,
const Message_ProgressRange& theProgress)
+{
+ const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(myWriter.WS()->Model());
+ aModel->InternalParameters.InitFromStatic();
+ return Transfer(theLabel, aModel->InternalParameters, theMode, theIsMulti, theProgress);
+}
+
+//=======================================================================
+//function : Transfer
+//purpose :
+//=======================================================================
+Standard_Boolean STEPCAFControl_Writer::Transfer(const TDF_Label& theLabel,
+ const StepData_ConfParameters& theParams,
+ const STEPControl_StepModelType theMode,
+ const Standard_CString theIsMulti,
+ const Message_ProgressRange& theProgress)
{
if (theLabel.IsNull())
{
aLabels.Append(theLabel);
myRootLabels.Clear();
myRootLabels.Add(theLabel.Root());
+ const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(myWriter.WS()->Model());
+ aModel->InternalParameters = theParams;
return transfer(myWriter, aLabels, theMode, theIsMulti, Standard_False, theProgress);
}
const STEPControl_StepModelType theMode,
const Standard_CString theIsMulti,
const Message_ProgressRange& theProgress)
+{
+ const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(myWriter.WS()->Model());
+ aModel->InternalParameters.InitFromStatic();
+ return Transfer(theLabels, aModel->InternalParameters, theMode, theIsMulti, theProgress);
+}
+
+//=======================================================================
+//function : Transfer
+//purpose :
+//=======================================================================
+Standard_Boolean STEPCAFControl_Writer::Transfer(const TDF_LabelSequence& theLabels,
+ const StepData_ConfParameters& theParams,
+ const STEPControl_StepModelType theMode,
+ const Standard_CString theIsMulti,
+ const Message_ProgressRange& theProgress)
{
myRootLabels.Clear();
for (TDF_LabelSequence::Iterator aLabelIter(theLabels);
myRootLabels.Add(aLabel.Root());
}
}
+ const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(myWriter.WS()->Model());
+ aModel->InternalParameters = theParams;
return transfer(myWriter, theLabels, theMode, theIsMulti, Standard_False, theProgress);
}
return Write(theFileName) == IFSelect_RetDone;
}
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+Standard_Boolean STEPCAFControl_Writer::Perform(const Handle(TDocStd_Document)& theDoc,
+ const Standard_CString theFileName,
+ const StepData_ConfParameters& theParams,
+ const Message_ProgressRange& theProgress)
+{
+ if (!Transfer(theDoc, theParams, STEPControl_AsIs, 0L, theProgress))
+ return Standard_False;
+ return Write(theFileName) == IFSelect_RetDone;
+}
+
//=======================================================================
//function : Perform
//purpose :
const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(theWriter.WS()->Model());
prepareUnit(theLabels.First(), aModel, aLocalFactors); // set local length unit to the model
// translate free top-level shapes of the DECAF document
- const Standard_Integer aStepSchema = Interface_Static::IVal("write.step.schema");
TDF_LabelSequence aSubLabels;
Message_ProgressScope aPS(theProgress, "Labels", theLabels.Length());
// Iterate on requested shapes
if (XCAFDoc_ShapeTool::IsAssembly(aCurL) || XCAFDoc_ShapeTool::IsReference(aCurL))
anActor->RegisterAssembly(aCurShape);
- theWriter.Transfer(aCurShape, theMode, Standard_False, aRange);
+ theWriter.Transfer(aCurShape, theMode, aModel->InternalParameters, Standard_False, aRange);
anActor->SetStdMode(Standard_True); // restore default behaviour
}
else
if (aPS1.UserBreak())
return Standard_False;
- Standard_Integer assemblymode = Interface_Static::IVal("write.step.assembly");
- Interface_Static::SetCVal("write.step.assembly", "On");
- theWriter.Transfer(aSass, STEPControl_AsIs, Standard_True, aPS1.Next());
- Interface_Static::SetIVal("write.step.assembly", assemblymode);
+ StepData_ConfParameters::WriteMode_Assembly assemblymode = aModel->InternalParameters.WriteAssembly;
+ aModel->InternalParameters.WriteAssembly = StepData_ConfParameters::WriteMode_Assembly_On;
+ theWriter.Transfer(aSass, STEPControl_AsIs, aModel->InternalParameters, Standard_True, aPS1.Next());
+ aModel->InternalParameters.WriteAssembly = assemblymode;
}
}
if (aPS.UserBreak())
// write G&DTs
if (GetDimTolMode())
{
- if (aStepSchema == 5)
+ if (aModel->InternalParameters.WriteSchema == 5)
{
writeDGTsAP242(theWriter.WS(), aSubLabels, aLocalFactors);
}
theWriter.WS()->ComputeGraph(Standard_True);
// Write names for the sub-shapes
- if (Interface_Static::IVal("write.stepcaf.subshapes.name") != 0)
+ if (aModel->InternalParameters.WriteSubshapeNames != 0)
{
const Handle(XSControl_TransferWriter)& TW = this->ChangeWriter().WS()->TransferWriter();
const Handle(Transfer_FinderProcess)& aFP = TW->FinderProcess();
anExtFile->SetWS(aNewWS);
anExtFile->SetName(aNewName);
anExtFile->SetLabel(theLabel);
- Standard_Integer anAssemblymode = Interface_Static::IVal("write.step.assembly");
- Interface_Static::SetCVal("write.step.assembly", "Off");
+ StepData_ConfParameters::WriteMode_Assembly anAssemblymode = aStepWriter.Model()->InternalParameters.WriteAssembly;
+ aStepWriter.Model()->InternalParameters.WriteAssembly = StepData_ConfParameters::WriteMode_Assembly_Off;
const Standard_CString anIsMulti = 0;
anExtFile->SetTransferStatus(transfer(aStepWriter, aLabelSeq, theMode, anIsMulti, Standard_True, theProgress));
- Interface_Static::SetIVal("write.step.assembly", anAssemblymode);
+ aStepWriter.Model()->InternalParameters.WriteAssembly = anAssemblymode;
myLabEF.Bind(theLabel, anExtFile);
myFiles.Bind(aNewName->ToCString(), anExtFile);
const Handle(XSControl_TransferWriter)& aTW = theWS->TransferWriter();
const Handle(Transfer_FinderProcess)& aFP = aTW->FinderProcess();
STEPConstruct_ExternRefs anEFTool(theWS);
- Standard_Integer aStepSchema = Interface_Static::IVal("write.step.schema");
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(theWS->Model());
+ Standard_Integer aStepSchema = aStepModel->InternalParameters.WriteSchema;
// Iterate on requested shapes
for (TDF_LabelSequence::Iterator aLabelIter(theLabels);
aLabelIter.More(); aLabelIter.Next())
MakeSTEPStyles(Styles, aShape, aSettings, anOverride,
aMap, myMapCompMDGPR, DPDCs, ColRGBs, aSTool, 0, anIsComponent);
+ const Handle(XSControl_TransferWriter)& aTW = theWS->TransferWriter();
+ const Handle(Transfer_FinderProcess)& aFP = aTW->FinderProcess();
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(aFP->Model());
+
// create MDGPR and record it in model
Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR;
{
Message::SendTrace() << "Error: Current Top-Level shape have MDGPR already " << "\n";
}
- Styles.CreateMDGPR(aContext, aMDGPR);
+ Styles.CreateMDGPR(aContext, aMDGPR, aStepModel);
if (!aMDGPR.IsNull())
myMapCompMDGPR.Bind(aTopSh, aMDGPR);
}
else
{
// create SDR and add to model.
- const Handle(XSControl_TransferWriter)& aTW = theWS->TransferWriter();
- const Handle(Transfer_FinderProcess)& aFP = aTW->FinderProcess();
Handle(TransferBRep_ShapeMapper) aMapper = TransferBRep::ShapeMapper(aFP, aShape);
Handle(StepShape_ContextDependentShapeRepresentation) aCDSR;
if (aFP->FindTypedTransient(aMapper,
// find the repr item of the shape
const Handle(XSControl_TransferWriter)& aTW = theWS->TransferWriter();
const Handle(Transfer_FinderProcess)& aFP = aTW->FinderProcess();
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(aFP->Model());
Handle(TransferBRep_ShapeMapper) aMapper = TransferBRep::ShapeMapper(aFP, theShape);
Handle(StepShape_ContextDependentShapeRepresentation) aCDSR;
aFP->FindTypedTransient(aMapper,
// create MDGPR and record it in model
Message::SendTrace() << "Warning: " << __FILE__ << ": Create new MDGPR for SHUO instance" << "\n";
Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR;
- aStyles.CreateMDGPR(aContext, aMDGPR);
+ aStyles.CreateMDGPR(aContext, aMDGPR, aStepModel);
if (!aMDGPR.IsNull())
theMapCompMDGPR.Bind(aTopSh, aMDGPR);
}
#include <STEPCAFControl_DataMapOfLabelExternFile.hxx>
#include <STEPControl_Writer.hxx>
#include <StepAP242_GeometricItemSpecificUsage.hxx>
+#include <StepData_ConfParameters.hxx>
#include <StepDimTol_Datum.hxx>
#include <StepDimTol_GeometricTolerance.hxx>
#include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
const Standard_CString theIsMulti = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
+ //! Transfers a document (or single label) to a STEP model
+ //! This method uses if need to set parameters avoiding
+ //! initialization from Interface_Static
+ //! @param theParams configuration parameters
+ //! @param theMode mode of translation of shape is AsIs
+ //! @param theIsMulti if multi is not null pointer, it switches to multifile
+ //! mode (with external refs), and string pointed by <multi>
+ //! gives prefix for names of extern files (can be empty string)
+ //! @param theProgress progress indicator
+ //! Returns True if translation is OK
+ Standard_EXPORT Standard_Boolean Transfer(const Handle(TDocStd_Document)& theDoc,
+ const StepData_ConfParameters& theParams,
+ const STEPControl_StepModelType theMode = STEPControl_AsIs,
+ const Standard_CString theIsMulti = 0,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
+ //! Method to transfer part of the document specified by label
+ Standard_EXPORT Standard_Boolean Transfer(const TDF_Label& theLabel,
+ const STEPControl_StepModelType theMode = STEPControl_AsIs,
+ const Standard_CString theIsMulti = 0,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
//! Method to transfer part of the document specified by label
+ //! This method uses if need to set parameters avoiding
+ //! initialization from Interface_Static
Standard_EXPORT Standard_Boolean Transfer(const TDF_Label& theLabel,
+ const StepData_ConfParameters& theParams,
const STEPControl_StepModelType theMode = STEPControl_AsIs,
const Standard_CString theIsMulti = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
const Standard_CString theIsMulti = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
+ //! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
+ //! This method uses if need to set parameters avoiding
+ //! initialization from Interface_Static
+ Standard_EXPORT Standard_Boolean Transfer(const TDF_LabelSequence& theLabelSeq,
+ const StepData_ConfParameters& theParams,
+ const STEPControl_StepModelType theMode = STEPControl_AsIs,
+ const Standard_CString theIsMulti = 0,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
Standard_EXPORT Standard_Boolean Perform(const Handle(TDocStd_Document)& theDoc,
const TCollection_AsciiString& theFileName,
const Message_ProgressRange& theProgress = Message_ProgressRange());
const Standard_CString theFileName,
const Message_ProgressRange& theProgress = Message_ProgressRange());
+ //! Transfers a document and writes it to a STEP file
+ //! This method uses if need to set parameters avoiding
+ //! initialization from Interface_Static
+ //! Returns True if translation is OK
+ Standard_EXPORT Standard_Boolean Perform(const Handle(TDocStd_Document)& theDoc,
+ const Standard_CString theFileName,
+ const StepData_ConfParameters& theParams,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
//! Returns data on external files
//! Returns Null handle if no external files are read
const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& ExternFiles() const { return myFiles; };
#include <STEPConstruct_Assembly.hxx>
#include <STEPConstruct_ContextTool.hxx>
#include <STEPConstruct_Part.hxx>
-#include <StepData_StepModel.hxx>
#include <StepGeom_Axis2Placement3d.hxx>
#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
void STEPConstruct_ContextTool::SetModel (const Handle(StepData_StepModel)& aStepModel)
{
theAPD.Nullify(); //thePRPC.Nullify();
-
+ mySchema = aStepModel->InternalParameters.WriteSchema;
+ myProductName = aStepModel->InternalParameters.WriteProductName;
Standard_Integer i, nb = aStepModel->NbEntities();
for(i = 1; i<=nb && theAPD.IsNull(); i ++) {
Handle(Standard_Transient) ent = aStepModel->Value(i);
Standard_Boolean noapd = theAPD.IsNull();
if (noapd || enforce) theAPD = new StepBasic_ApplicationProtocolDefinition;
- switch (Interface_Static::IVal("write.step.schema")) { //j4
+ switch (mySchema) { //j4
default:
case 1:
theAPD->SetApplicationProtocolYear (1997);
if (theAPD->Application().IsNull())
theAPD->SetApplication (new StepBasic_ApplicationContext);
Handle(TCollection_HAsciiString) appl;
- switch (Interface_Static::IVal("write.step.schema")) { //j4
+ switch (mySchema) { //j4
default:
case 1:
case 2: appl = new TCollection_HAsciiString ( "core data for automotive mechanical design processes" );
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetProductName () const
{
Handle(TCollection_HAsciiString) PdtName;
- if (Interface_Static::IsSet("write.step.product.name"))
- PdtName = new TCollection_HAsciiString(Interface_Static::CVal("write.step.product.name"));
+ if (!myProductName.IsEmpty())
+ PdtName = new TCollection_HAsciiString(myProductName);
else PdtName = new TCollection_HAsciiString("Product");
for ( Standard_Integer i=1; i <= myLevel.Length(); i++ ) {
if ( ! SDRTool.PRPC().IsNull() ) seq->Append ( SDRTool.PRPC() );
// for AP203, add required product management data
- if ( Interface_Static::IVal("write.step.schema") == 3 ) {
+ if ( mySchema == 3 ) {
theAP203.Init ( SDRTool );
seq->Append (theAP203.GetProductCategoryRelationship());
seq->Append (theAP203.GetCreator());
seq->Append ( assembly.ItemValue() );
// for AP203, write required product management data
- if ( Interface_Static::IVal("write.step.schema") == 3 ) {
+ if ( mySchema == 3 ) {
theAP203.Init ( assembly.GetNAUO() );
seq->Append (theAP203.GetSecurity());
seq->Append (theAP203.GetClassificationOfficer());
#include <TColStd_SequenceOfInteger.hxx>
#include <STEPConstruct_AP203Context.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
class StepBasic_ApplicationProtocolDefinition;
class StepGeom_Axis2Placement3d;
-class StepData_StepModel;
class TCollection_HAsciiString;
class STEPConstruct_Part;
class STEPConstruct_Assembly;
STEPConstruct_AP203Context theAP203;
Handle(StepGeom_Axis2Placement3d) myAxis;
StepData_Factors myGlobalFactor;
+ StepData_ConfParameters::WriteMode_StepSchema mySchema;
+ TCollection_AsciiString myProductName;
};
#include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx>
#include <StepBasic_ProductType.hxx>
#include <STEPConstruct_Part.hxx>
+#include <StepData_StepModel.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
#include <StepShape_ShapeRepresentation.hxx>
void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR,
const Handle(TCollection_HAsciiString)& aName,
- const Handle(StepBasic_ApplicationContext)& AC)
+ const Handle(StepBasic_ApplicationContext)& AC,
+ Handle(StepData_StepModel)& theStepModel)
{
// get current schema
- Standard_Integer schema = Interface_Static::IVal("write.step.schema");
+ const Standard_Integer schema = theStepModel->InternalParameters.WriteSchema;
// create PC
Handle(StepBasic_ProductContext) PC;
// and an associated PRPC
Handle(TCollection_HAsciiString) PRPCName;
- switch (Interface_Static::IVal("write.step.schema")) {
+ switch (theStepModel->InternalParameters.WriteSchema) {
default:
case 1:
myPRPC = new StepBasic_ProductType;
class StepBasic_Product;
class StepBasic_ProductDefinitionFormation;
class StepBasic_ProductDefinition;
+class StepData_StepModel;
class StepRepr_ProductDefinitionShape;
Standard_EXPORT STEPConstruct_Part();
- Standard_EXPORT void MakeSDR (const Handle(StepShape_ShapeRepresentation)& aShape, const Handle(TCollection_HAsciiString)& aName, const Handle(StepBasic_ApplicationContext)& AC);
+ Standard_EXPORT void MakeSDR (const Handle(StepShape_ShapeRepresentation)& aShape,
+ const Handle(TCollection_HAsciiString)& aName,
+ const Handle(StepBasic_ApplicationContext)& AC,
+ Handle(StepData_StepModel)& theStepModel);
Standard_EXPORT void ReadSDR (const Handle(StepShape_ShapeDefinitionRepresentation)& aShape);
//=======================================================================
Standard_Boolean STEPConstruct_Styles::CreateMDGPR (const Handle(StepRepr_RepresentationContext) &Context,
- Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& Repr)
+ Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& Repr,
+ Handle(StepData_StepModel)& theStepModel)
{
if ( myStyles.Extent() <1 ) return Standard_False;
// Model()->AddWithRefs ( Repr ); add into the model upper
// for AP203, add subschema name
- if ( Interface_Static::IVal("write.step.schema") ==3 ) {
+ if ( theStepModel->InternalParameters.WriteSchema == 3 ) {
APIHeaderSection_MakeHeader mkHdr ( Handle(StepData_StepModel)::DownCast ( Model() ) );
Handle(TCollection_HAsciiString) subSchema =
new TCollection_HAsciiString ( "SHAPE_APPEARANCE_LAYER_MIM" );
//! Create MDGPR, fill it with all the styles previously defined,
//! and add it to the model
- Standard_EXPORT Standard_Boolean CreateMDGPR (const Handle(StepRepr_RepresentationContext)& Context, Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& MDGPR);
+ Standard_EXPORT Standard_Boolean CreateMDGPR (const Handle(StepRepr_RepresentationContext)& Context,
+ Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& MDGPR,
+ Handle(StepData_StepModel)& theStepModel);
//! Create MDGPR, fill it with all the styles previously defined,
//! and add it to the model
#include <StepBasic_SiUnitAndVolumeUnit.hxx>
#include <STEPConstruct_UnitContext.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
#include <StepRepr_GlobalUncertaintyAssignedContext.hxx>
#include <StepRepr_GlobalUnitAssignedContext.hxx>
//=======================================================================
void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d,
+ const Handle(StepData_StepModel)& theModel,
const StepData_Factors& theLocalFactors)
{
done = Standard_True;
Standard_Boolean hasPref = Standard_True;
StepBasic_SiPrefix siPref = StepBasic_spMilli;
Standard_Real aScale = 1.;
- switch (Interface_Static::IVal("write.step.unit"))
+ switch (theModel->InternalParameters.WriteUnit)
{
case 1: uName = "INCH"; aScale = 25.4; break;
default:
#include <Standard_CString.hxx>
#include <StepBasic_SiPrefix.hxx>
class StepData_Factors;
+class StepData_StepModel;
class StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx;
class StepRepr_GlobalUnitAssignedContext;
class StepBasic_NamedUnit;
//! Creates new context (units are MM and radians,
//! uncertainty equal to Tol3d)
Standard_EXPORT void Init (const Standard_Real Tol3d,
+ const Handle(StepData_StepModel)& theModel,
const StepData_Factors& theLocalFactors);
//! Returns True if Init was called successfully
// record SDR in order to have it written to the file
Model()->AddWithRefs ( PrDR );
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(Model());
+
// for AP203, add subschema name
- if ( Interface_Static::IVal("write.step.schema") ==3 ) {
- APIHeaderSection_MakeHeader mkHdr ( Handle(StepData_StepModel)::DownCast ( Model() ) );
+ if ( aStepModel->InternalParameters.WriteSchema ==3 ) {
+ APIHeaderSection_MakeHeader mkHdr ( aStepModel );
Handle(TCollection_HAsciiString) subSchema =
new TCollection_HAsciiString ( "GEOMETRIC_VALIDATION_PROPERTIES_MIM" );
mkHdr.AddSchemaIdentifier ( subSchema );
// Purpose : Empty constructor
// ============================================================================
-STEPControl_ActorRead::STEPControl_ActorRead()
+STEPControl_ActorRead::STEPControl_ActorRead(const Handle(Interface_InterfaceModel)& theModel)
: myPrecision(0.0),
- myMaxTol(0.0)
+ myMaxTol(0.0),
+ myModel(theModel)
{
}
if (start->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) return Standard_True;
- TCollection_AsciiString aProdMode = Interface_Static::CVal("read.step.product.mode");
- if(!aProdMode.IsEqual("ON"))
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(myModel);
+ if (aStepModel.IsNull())
+ {
+ return false;
+ }
+ bool aProdMode = aStepModel->InternalParameters.ReadProductMode;
+ if(!aProdMode)
if(start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) return Standard_True;
DeclareAndCast(StepShape_ShapeRepresentation,sr,start);
return Standard_False;
}
- const Standard_Boolean aCanReadTessGeom = (Interface_Static::IVal("read.step.tessellated") != 0);
+ const Standard_Boolean aCanReadTessGeom = aStepModel->InternalParameters.ReadTessellated != 0;
if (start->IsKind(STANDARD_TYPE(StepShape_FacetedBrep))) return Standard_True;
if (start->IsKind(STANDARD_TYPE(StepShape_BrepWithVoids))) return Standard_True;
}
}
// [END] Get version of preprocessor (to detect I-Deas case) (ssv; 23.11.2010)
- Standard_Boolean aTrsfUse = (Interface_Static::IVal("read.step.root.transformation") == 1);
+ Standard_Boolean aTrsfUse = (aStepModel->InternalParameters.ReadRootTransformation == 1);
return TransferShape(start, TP, aLocalFactors, Standard_True, aTrsfUse, theProgress);
}
Handle(TColStd_HSequenceOfTransient)& listSDRAspect,
const Handle(Transfer_TransientProcess)& TP)
{
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
+
// Flag indicating preferred shape representation type, to be chosen if
// several different representations are attached to the same shape
Standard_Integer delta = 100;
- Standard_Integer ICS = Interface_Static::IVal("read.step.shape.repr");
+ Standard_Integer ICS = aStepModel->InternalParameters.ReadShapeRepr;
Standard_Integer nbSDR0 = listSDR->Length();
// Iterate by entities referring PDS
continue;
}
}
+
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
// Flag indicating whether SDRs associated with the product`s main SDR
// by SRRs (which correspond to hybrid model representation in AP203 since 1998)
// should be taken into account
- Standard_Integer readSRR = Interface_Static::IVal("read.step.shape.relationship");
+ Standard_Integer readSRR = aStepModel->InternalParameters.ReadRelationship;
- Standard_Integer readConstructiveGeomRR = Interface_Static::IVal("read.step.constructivegeom.relationship");
+ Standard_Integer readConstructiveGeomRR = aStepModel->InternalParameters.ReadConstrRelation;
// Flag indicating whether SDRs associated with the product`s main SDR
// by SAs (which correspond to hybrid model representation in AP203 before 1998)
// should be taken into account
- Standard_Integer readSA = Interface_Static::IVal("read.step.shape.aspect");
+ Standard_Integer readSA = aStepModel->InternalParameters.ReadShapeAspect;
if ( ! readSA )
listSDRAspect->Clear();
// possibly attached directly to intermediate assemblies (1)
// Special mode (4) is used to translate shape attached to this product only,
// ignoring sub-assemblies if any
- Standard_Integer readAssembly = Interface_Static::IVal("read.step.assembly.level");
+ Standard_Integer readAssembly = aStepModel->InternalParameters.ReadAssemblyLevel;
if ( readAssembly ==3 || ( readAssembly ==2 && listNAUO->Length() >0 ) )
listSDR->Clear();
else if ( readAssembly == 4 )
{
NM_DETECTED = Standard_False;
Handle(TransferBRep_ShapeBinder) shbinder;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
if(!Recognize(sr))
return shbinder;
isBound = Standard_False;
Standard_Integer nsh = 0;
// [BEGIN] Proceed with non-manifold topology (ssv; 12.11.2010)
- Standard_Boolean isNMMode = Interface_Static::IVal("read.step.nonmanifold") != 0;
+ Standard_Boolean isNMMode = aStepModel->InternalParameters.ReadNonmanifold != 0;
Standard_Boolean isManifold = Standard_True;
if ( isNMMode && sr->IsKind(STANDARD_TYPE(StepShape_NonManifoldSurfaceShapeRepresentation)) ) {
isManifold = Standard_False;
}
// Special processing for I-DEAS STP case (ssv; 15.11.2010)
else {
- Standard_Integer isIDeasMode = Interface_Static::IVal("read.step.ideas");
+ Standard_Integer isIDeasMode = aStepModel->InternalParameters.ReadIdeas;
if (isNMMode && myNMTool.IsIDEASCase() && isIDeasMode) {
isManifold = Standard_False;
NM_DETECTED = Standard_True;
<< start->DynamicType()->Name() << std::endl;
chrono.Start();
#endif
-
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
//:S4136
StepData_Factors aLocalFactors = theLocalFactors;
Handle(StepRepr_Representation) oldSRContext = mySRContext;
Handle(StepRepr_Representation) context = FindContext ( start, TP );
if ( context.IsNull() ) {
TP->AddWarning ( start, "Entity with no unit context; default units taken" );
- ResetUnits(aLocalFactors);
+ ResetUnits(aStepModel, aLocalFactors);
}
else PrepareUnits ( context, TP, aLocalFactors);
}
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressScope aPS(theProgress, "Transfer stage", isManifold ? 2 : 1);
-
- const Standard_Boolean aReadTessellatedWhenNoBRepOnly = (Interface_Static::IVal("read.step.tessellated") == 2);
+ const Standard_Boolean aReadTessellatedWhenNoBRepOnly = (aStepModel->InternalParameters.ReadTessellated == 2);
Standard_Boolean aHasGeom = Standard_True;
try {
OCC_CATCH_SIGNALS
myTF.Init(fs, myTool, dummyNMTool, theLocalFactors);
Handle(StepRepr_Representation) oldSRContext = mySRContext;
StepData_Factors aLocalFactors = theLocalFactors;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
if (mySRContext.IsNull()) { // if no context, try to find it (ex: r0701_ug.stp #4790)
Handle(StepRepr_Representation) context = FindContext(fs, TP);
if (context.IsNull()) {
TP->AddWarning(fs, "Entity with no unit context; default units taken");
- ResetUnits(aLocalFactors);
+ ResetUnits(aStepModel, aLocalFactors);
}
else PrepareUnits(context, TP, aLocalFactors);
}
#endif
Handle(TransferBRep_ShapeBinder) shbinder;
-
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
// Product Definition Entities
// They should be treated with Design Manager
// case ShapeDefinitionRepresentation if ProductMode != ON
- TCollection_AsciiString aProdMode = Interface_Static::CVal("read.step.product.mode");
- if(!aProdMode.IsEqual("ON") &&
+ bool aProdMode = aStepModel->InternalParameters.ReadProductMode;
+ if(!aProdMode &&
start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
shbinder = OldWay(start,TP, theProgress);
//skl
StepData_Factors& theLocalFactors)
{
mySRContext = rep;
-
+ Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(TP->Model());
Standard_Integer stat1, stat2 = 0; // sera alimente par STEPControl_Unit
if (rep.IsNull()) {
- ResetUnits(theLocalFactors);
+ ResetUnits(aModel, theLocalFactors);
return;
}
Handle(StepRepr_RepresentationContext) theRepCont = rep->ContextOfItems();
if (theRepCont.IsNull()) {
TP->AddWarning(rep,"Bad RepresentationContext, default unit taken");
- ResetUnits(theLocalFactors);
+ ResetUnits(aModel, theLocalFactors);
return;
}
aTol = theGRCAGAUC->GlobalUncertaintyAssignedContext();
}
-
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
// ----------------------------------------------------
// Decoding and Setting the Values
// ----------------------------------------------------
if (!theGUAC.IsNull()) {
stat1 = myUnit.ComputeFactors(theGUAC, theLocalFactors);
- Standard_Integer anglemode = Interface_Static::IVal("step.angleunit.mode");
+ Standard_Integer anglemode = aStepModel->InternalParameters.AngleUnit;
Standard_Real angleFactor = ( anglemode == 0 ? myUnit.PlaneAngleFactor() :
anglemode == 1 ? 1. : M_PI/180. );
theLocalFactors.InitializeFactors(myUnit.LengthFactor(),
}
// myPrecision = Precision::Confusion();
- if (Interface_Static::IVal("read.precision.mode") == 1) //:i1 gka S4136 05.04.99
- myPrecision = Interface_Static::RVal("read.precision.val");
+ if (aStepModel->InternalParameters.ReadPrecisionMode == 1) //:i1 gka S4136 05.04.99
+ myPrecision = aStepModel->InternalParameters.ReadPrecisionVal;
else if (myUnit.HasUncertainty())
myPrecision = myUnit.Uncertainty() * myUnit.LengthFactor();
else {
TP->AddWarning(theRepCont,"No Length Uncertainty, value of read.precision.val is taken");
- myPrecision = Interface_Static::RVal("read.precision.val");
+ myPrecision = aStepModel->InternalParameters.ReadPrecisionVal;
}
- myMaxTol = Max ( myPrecision, Interface_Static::RVal("read.maxprecision.val") );
+ myMaxTol = Max ( myPrecision, aStepModel->InternalParameters.ReadMaxPrecisionVal );
// Assign uncertainty
#ifdef TRANSLOG
if (TP->TraceLevel() > 1)
//purpose :
//=======================================================================
-void STEPControl_ActorRead::ResetUnits (StepData_Factors& theLocalFactors)
+void STEPControl_ActorRead::ResetUnits (Handle(StepData_StepModel)& theModel, StepData_Factors& theLocalFactors)
{
theLocalFactors.InitializeFactors ( 1, 1, 1 );
- myPrecision = Interface_Static::RVal("read.precision.val");
- myMaxTol = Max ( myPrecision, Interface_Static::RVal("read.maxprecision.val") );
+ myPrecision = theModel->InternalParameters.ReadPrecisionVal;
+ myMaxTol = Max ( myPrecision, theModel->InternalParameters.ReadMaxPrecisionVal );
}
//=======================================================================
shellClosingsMap.Add(shellA, closingShells);
}
}
+
+//=======================================================================
+// Method : SetModel
+// Purpose :
+//=======================================================================
+void STEPControl_ActorRead::SetModel(const Handle(Interface_InterfaceModel)& theModel)
+{
+ myModel = theModel;
+}
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <Message_ProgressRange.hxx>
+#include <Interface_InterfaceModel.hxx>
class StepRepr_Representation;
class Standard_Transient;
class TopoDS_Compound;
class StepRepr_ConstructiveGeometryRepresentationRelationship;
class StepData_Factors;
+class StepData_StepModel;
class STEPControl_ActorRead;
public:
-
- Standard_EXPORT STEPControl_ActorRead();
+ Standard_EXPORT STEPControl_ActorRead(const Handle(Interface_InterfaceModel)& theModel);
Standard_EXPORT virtual Standard_Boolean Recognize (const Handle(Standard_Transient)& start) Standard_OVERRIDE;
//! reset units and tolerances context to default
//! (mm, radians, read.precision.val, etc.)
- Standard_EXPORT void ResetUnits(StepData_Factors& theLocalFactors);
+ Standard_EXPORT void ResetUnits(Handle(StepData_StepModel)& theModel,
+ StepData_Factors& theLocalFactors);
+
+ //! Set model
+ Standard_EXPORT void SetModel(const Handle(Interface_InterfaceModel)& theModel);
//! Computes transformation defined by two axis placements (in MAPPED_ITEM
//! or ITEM_DEFINED_TRANSFORMATION) taking into account their
Standard_Real myPrecision;
Standard_Real myMaxTol;
Handle(StepRepr_Representation) mySRContext;
-
+ Handle(Interface_InterfaceModel) myModel;
};
}
Standard_Real aLFactor = model->WriteLengthUnit();
aLFactor /= model->LocalLengthUnit();
- Standard_Integer anglemode = Interface_Static::IVal("step.angleunit.mode");
+ const Standard_Integer anglemode = model->InternalParameters.AngleUnit;
StepData_Factors aLocalFactors;
aLocalFactors.InitializeFactors(aLFactor, (anglemode <= 1 ? 1. : M_PI / 180.), 1.);
// create SDR
STEPConstruct_Part SDRTool;
- SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application() );
+ SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application(), model);
Handle(StepShape_ShapeDefinitionRepresentation) sdr = SDRTool.SDRValue();
// transfer shape
//==========================================
-static Standard_Real UsedTolerance (const Standard_Real mytoler,
- const TopoDS_Shape& theShape)
+static Standard_Real UsedTolerance (Handle(StepData_StepModel)& theStepModel,
+ const Standard_Real mytoler,
+ const TopoDS_Shape& theShape)
{
// COMPUTING 3D TOLERANCE
// Either from Session, or Computed (Least,Average, or Greatest)
// Then given to TopoDSToStep_Tool
-
Standard_Real Tol = mytoler;
- Standard_Integer tolmod = Interface_Static::IVal("write.precision.mode");
+ Standard_Integer tolmod = theStepModel->InternalParameters.WritePrecisionMode;
if (Tol <= 0 && tolmod == 2) Tol =
- Interface_Static::RVal("write.precision.val");
+ theStepModel->InternalParameters.WritePrecisionVal;
if (Tol <= 0) {
ShapeAnalysis_ShapeTolerance stu;
Tol = stu.Tolerance (theShape,tolmod);
// if GroupMode is >1 downgrades all compounds having single subshape to that
// subshape
-Standard_Boolean STEPControl_ActorWrite::IsAssembly (TopoDS_Shape &S) const
+Standard_Boolean STEPControl_ActorWrite::IsAssembly (const Handle(StepData_StepModel)& theModel,
+ TopoDS_Shape &S) const
{
if ( ! GroupMode() || S.ShapeType() != TopAbs_COMPOUND ) return Standard_False;
// PTV 16.09.2002 OCC725 for storing compound of vertices
- if (Interface_Static::IVal("write.step.vertex.mode") == 0) {//bug 23950
+ if (theModel->InternalParameters.WriteVertexMode == 0) {//bug 23950
if (S.ShapeType() == TopAbs_COMPOUND ) {
Standard_Boolean IsOnlyVertices = Standard_True;
TopoDS_Iterator anItr( S );
it.Next();
if ( it.More() ) return Standard_True;
S = shape;
- return IsAssembly ( S );
+ return IsAssembly ( theModel, S );
}
//=======================================================================
{
Standard_Boolean IsDone = Standard_False;
MoniTool_DataMapOfShapeTransient aMap;
- TopoDSToStep_Tool aTool(aMap, Standard_True);
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ TopoDSToStep_Tool aTool(aMap, Standard_True, aStepModel->InternalParameters.WriteSurfaceCurMode);
TopoDSToStep_MakeStepVertex aMkVrtx ( TopoDS::Vertex(aShVrtx), aTool, FP, theLocalFactors );
if (!aMkVrtx.IsDone())
STEPControl_StepModelType mymode = Mode();
Handle(TransferBRep_ShapeMapper) mapper = Handle(TransferBRep_ShapeMapper)::DownCast(start);
Handle(Transfer_Binder) binder;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
// Indicates whether to use an existing NMSSR to write items to (ss; 13.11.2010)
Standard_Boolean useExistingNMSSR = Standard_False;
}
// MODE ASSEMBLY : if Compound, (sub-)assembly
- if ( IsAssembly(theShape) )
+ if ( IsAssembly(aStepModel, theShape) )
return TransferCompound(start, SDR0, FP, theLocalFactors, theProgress);
Message_ProgressScope aPSRoot(theProgress, NULL, 2);
// [BEGIN] Separate manifold topology from non-manifold in group mode 0 (ssv; 18.11.2010)
- Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
+ Standard_Boolean isNMMode = aStepModel->InternalParameters.WriteNonmanifold != 0;
Handle(Transfer_Binder) aNMBinder;
if (isNMMode && !GroupMode() && theShape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Compound aNMCompound;
sdr = SDR0;
else {
STEPConstruct_Part SDRTool;
- SDRTool.MakeSDR( 0, myContext.GetProductName(), myContext.GetAPD()->Application() );
+ SDRTool.MakeSDR( 0, myContext.GetProductName(), myContext.GetAPD()->Application(), aStepModel );
sdr = SDRTool.SDRValue();
}
Handle(TopTools_HSequenceOfShape) RepItemSeq = new TopTools_HSequenceOfShape();
Standard_Boolean isSeparateVertices =
- Interface_Static::IVal("write.step.vertex.mode") == 0;//bug 23950
+ aStepModel->InternalParameters.WriteVertexMode == 0;//bug 23950
// PTV 16.09.2002 OCC725 separate shape from solo vertices.
Standard_Boolean isOnlyVertices = Standard_False;
if (theShape.ShapeType() == TopAbs_COMPOUND && isSeparateVertices)
// COMPUTING 3D TOLERANCE
// Either from Session, or Computed (Least,Average, or Greatest)
// Then given to TopoDSToStep_Tool
- Standard_Real Tol = UsedTolerance (mytoler,theShape);
+ Standard_Real Tol = UsedTolerance (aStepModel, mytoler,theShape);
// Create a STEP-Entity for each TopoDS_Shape
// according to the current StepModelMode
if (hasGeometry(aShape))
{
- Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val");
+ Standard_Real maxTol = aStepModel->InternalParameters.ReadMaxPrecisionVal;
aShape = XSAlgo::AlgoContainer()->ProcessShape(xShape, Tol, maxTol,
"write.step.resource.name",
GetCasted(StepRepr_RepresentationItem, ItemSeq->Value(rep));
items->SetValue(rep,repit);
}
- Standard_Integer ap = Interface_Static::IVal("write.step.schema");
+ Standard_Integer ap = aStepModel->InternalParameters.WriteSchema;
Transfer_SequenceOfBinder aSeqBindRelation;
if(ap == 3 && nbs > 1) {
Standard_Integer j = 1;
repr1->SetValue(2,items->Value(j));
ShapeRepr1->SetItems(repr1);
STEPConstruct_UnitContext mk1;
- mk1.Init(Tol, theLocalFactors);
+ mk1.Init(Tol, aStepModel, theLocalFactors);
ShapeRepr1->SetContextOfItems(mk1.Value()); // la tolerance, voir au debut
ShapeRepr1->SetName (new TCollection_HAsciiString(""));
Handle(StepShape_ShapeRepresentation) shapeTessRepr = new StepVisual_TessellatedShapeRepresentation;
shapeTessRepr->SetItems(itemsTess);
STEPConstruct_UnitContext mk1;
- mk1.Init(Tol, theLocalFactors);
+ mk1.Init(Tol, aStepModel, theLocalFactors);
shapeTessRepr->SetContextOfItems(mk1.Value());
shapeTessRepr->SetName(new TCollection_HAsciiString(""));
// init representation
STEPConstruct_UnitContext mk;
- mk.Init(Tol, theLocalFactors);
+ mk.Init(Tol, aStepModel, theLocalFactors);
shapeRep->SetContextOfItems(mk.Value()); // la tolerance, voir au debut
shapeRep->SetName (new TCollection_HAsciiString(""));
if (mapper.IsNull()) return binder;
TopoDS_Shape theShape = mapper->Value();
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+
// Inspect non-manifold topology case (ssv; 10.11.2010)
- Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
+ Standard_Boolean isNMMode = aStepModel->InternalParameters.WriteNonmanifold != 0;
Standard_Boolean isManifold;
if (isNMMode)
isManifold = IsManifoldShape(theShape);
// Prepare a collection for non-manifold group of shapes
Handle(TopTools_HSequenceOfShape) NonManifoldGroup = new TopTools_HSequenceOfShape();
Standard_Boolean isSeparateVertices =
- (Interface_Static::IVal("write.step.vertex.mode") == 0);//bug 23950
+ (aStepModel->InternalParameters.WriteVertexMode == 0);//bug 23950
// PTV OCC725 17.09.2002 -- begin --
Standard_Integer nbFreeVrtx = 0;
TopoDS_Compound aCompOfVrtx;
for (Standard_Integer rep = 1; rep <= nsub; rep++)
items->SetValue(rep,GetCasted(StepRepr_RepresentationItem, ItemSeq->Value(rep)));
shapeRep->SetItems(items);
- Standard_Real Tol = UsedTolerance (mytoler,theShape);
+ Standard_Real Tol = UsedTolerance (aStepModel, mytoler,theShape);
STEPConstruct_UnitContext mk;
- mk.Init(Tol, theLocalFactors);
+ mk.Init(Tol, aStepModel, theLocalFactors);
shapeRep->SetContextOfItems(mk.Value()); // la tolerance, voir au debut
shapeRep->SetName (new TCollection_HAsciiString(""));
Handle(Transfer_Binder) resbind = FP->Find(mapper);
Handle(StepShape_ShapeDefinitionRepresentation) sdr;
// Handle(StepShape_ShapeRepresentation) resultat;
- STEPConstruct_Part SDRTool;
+ STEPConstruct_Part SDRTool;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
// Already SDR and SR available : take them as are
Standard_Boolean iasdr = FP->GetTypedTransient
(resbind,STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation),sdr);
if ( iasdr ) SDRTool.ReadSDR ( sdr );
else {
- SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application() );
+ SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application(), aStepModel );
sdr = SDRTool.SDRValue();
}
// resultat = GetCasted(StepShape_ShapeRepresentation,sdr->UsedRepresentation());
//! Default implementation uses flag GroupMode and analyses
//! the shape itself
//! NOTE: this method can modify shape
- Standard_EXPORT virtual Standard_Boolean IsAssembly (TopoDS_Shape& S) const;
+ Standard_EXPORT virtual Standard_Boolean IsAssembly (const Handle(StepData_StepModel)& theModel,
+ TopoDS_Shape& S) const;
#include <IFSelect_SignCounter.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
+#include <MoniTool_Macros.hxx>
#include <RWHeaderSection.hxx>
#include <RWStepAP214.hxx>
#include <Standard_Type.hxx>
#include <STEPEdit.hxx>
#include <STEPEdit_EditContext.hxx>
#include <STEPEdit_EditSDR.hxx>
+#include <STEPControl_ActorRead.hxx>
+#include <StepData_StepModel.hxx>
#include <StepSelect_WorkLibrary.hxx>
#include <STEPSelections_SelectAssembly.hxx>
#include <STEPSelections_SelectDerived.hxx>
aMutex.Unlock();
Handle(STEPControl_ActorWrite) ActWrite = new STEPControl_ActorWrite;
- ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly"));
myAdaptorWrite = ActWrite;
Handle(StepSelect_WorkLibrary) swl = new StepSelect_WorkLibrary;
swl->SetDumpLabel(1);
myAdaptorLibrary = swl;
myAdaptorProtocol = STEPEdit::Protocol();
- myAdaptorRead = new STEPControl_ActorRead; // par ex pour Recognize
SetModeWrite (0,4);
SetModeWriteHelp (0,"As Is");
return STEPEdit::NewModel();
}
+//=======================================================================
+//function : ActorRead
+//purpose :
+//=======================================================================
+Handle(Transfer_ActorOfTransientProcess) STEPControl_Controller::ActorRead(const Handle(Interface_InterfaceModel)& theModel) const
+{
+ DeclareAndCast(STEPControl_ActorRead, anAdap, myAdaptorRead);
+ if (anAdap.IsNull()) {
+ anAdap = new STEPControl_ActorRead(theModel);
+ anAdap->SetModel(theModel);
+ }
+ return anAdap;
+}
+
// #### PROVISOIRE ??? ####
IFSelect_ReturnStatus STEPControl_Controller::TransferWriteShape
Handle(STEPControl_ActorWrite)::DownCast(myAdaptorWrite);
// A PRESENT ON PASSE PAR LE PROFILE
if (!ActWrite.IsNull())
- ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly"));
+ ActWrite->SetGroupMode (Handle(StepData_StepModel)::DownCast(model)->InternalParameters.WriteAssembly);
return XSControl_Controller::TransferWriteShape(shape, FP, model, modeshape, theProgress);
}
//! Creates a new empty Model ready to receive data of the Norm.
//! It is taken from STEP Template Model
Standard_EXPORT Handle(Interface_InterfaceModel) NewModel() const Standard_OVERRIDE;
-
+
+ //! Returns the Actor for Read attached to the pair (norm,appli)
+ Standard_EXPORT Handle(Transfer_ActorOfTransientProcess) ActorRead(const Handle(Interface_InterfaceModel)& theModel) const Standard_OVERRIDE;
+
Standard_EXPORT virtual void Customise (Handle(XSControl_WorkSession)& WS) Standard_OVERRIDE;
//! Takes one Shape and transfers it to the InterfaceModel
// commercial license or contractual agreement.
+#include <IFSelect_WorkLibrary.hxx>
#include <Interface_EntityIterator.hxx>
#include <Interface_Graph.hxx>
#include <Interface_Static.hxx>
+#include <Message.hxx>
+#include <Message_Messenger.hxx>
#include <StepBasic_ApplicationContext.hxx>
#include <StepBasic_ConversionBasedUnit.hxx>
#include <StepBasic_DocumentProductEquivalence.hxx>
return Handle(StepData_StepModel)::DownCast(Model());
}
+//=======================================================================
+//function : ReadFile
+//purpose :
+//=======================================================================
+IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const Standard_CString filename)
+{
+ Handle(IFSelect_WorkLibrary) aLibrary = WS()->WorkLibrary();
+ Handle(Interface_Protocol) aProtocol = WS()->Protocol();
+ if (aLibrary.IsNull()) return IFSelect_RetVoid;
+ if (aProtocol.IsNull()) return IFSelect_RetVoid;
+ Handle(StepData_StepModel) aStepModel = new StepData_StepModel;
+ aStepModel->InternalParameters.InitFromStatic();
+ aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage);
+ IFSelect_ReturnStatus status = IFSelect_RetVoid;
+ try {
+ OCC_CATCH_SIGNALS
+ Standard_Integer stat = aLibrary->ReadFile(filename, aStepModel, aProtocol);
+ if (stat == 0) status = IFSelect_RetDone;
+ else if (stat < 0) status = IFSelect_RetError;
+ else status = IFSelect_RetFail;
+ }
+ catch (Standard_Failure const& anException) {
+ Message_Messenger::StreamBuffer sout = Message::SendInfo();
+ sout << " **** Interruption ReadFile par Exception : ****\n";
+ sout << anException.GetMessageString();
+ sout << "\n Abandon" << std::endl;
+ status = IFSelect_RetFail;
+ }
+ if (status != IFSelect_RetDone) return status;
+ WS()->SetModel(aStepModel);
+ WS()->SetLoadedFile(filename);
+ WS()->InitTransferReader(4);
+ return status;
+}
+
+//=======================================================================
+//function : ReadFile
+//purpose :
+//=======================================================================
+IFSelect_ReturnStatus STEPControl_Reader::ReadFile(const Standard_CString filename,
+ const StepData_ConfParameters& theParams)
+{
+ Handle(IFSelect_WorkLibrary) aLibrary = WS()->WorkLibrary();
+ Handle(Interface_Protocol) aProtocol = WS()->Protocol();
+ if (aLibrary.IsNull()) return IFSelect_RetVoid;
+ if (aProtocol.IsNull()) return IFSelect_RetVoid;
+ Handle(StepData_StepModel) aStepModel = new StepData_StepModel;
+ aStepModel->InternalParameters = theParams;
+ aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage);
+ IFSelect_ReturnStatus status = IFSelect_RetVoid;
+ try {
+ OCC_CATCH_SIGNALS
+ Standard_Integer stat = aLibrary->ReadFile(filename, aStepModel, aProtocol);
+ if (stat == 0) status = IFSelect_RetDone;
+ else if (stat < 0) status = IFSelect_RetError;
+ else status = IFSelect_RetFail;
+ }
+ catch (Standard_Failure const& anException) {
+ Message_Messenger::StreamBuffer sout = Message::SendInfo();
+ sout << " **** Interruption ReadFile par Exception : ****\n";
+ sout << anException.GetMessageString();
+ sout << "\n Abandon" << std::endl;
+ status = IFSelect_RetFail;
+ }
+ if (status != IFSelect_RetDone) return status;
+ WS()->SetModel(aStepModel);
+ WS()->SetLoadedFile(filename);
+ WS()->InitTransferReader(4);
+ return status;
+}
+
+//=======================================================================
+//function : ReadStream
+//purpose :
+//=======================================================================
+IFSelect_ReturnStatus STEPControl_Reader::ReadStream(const Standard_CString theName,
+ std::istream& theIStream)
+{
+ Handle(IFSelect_WorkLibrary) aLibrary = WS()->WorkLibrary();
+ Handle(Interface_Protocol) aProtocol = WS()->Protocol();
+ if (aLibrary.IsNull()) return IFSelect_RetVoid;
+ if (aProtocol.IsNull()) return IFSelect_RetVoid;
+ Handle(StepData_StepModel) aStepModel = new StepData_StepModel;
+ aStepModel->InternalParameters.InitFromStatic();
+ aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage);
+ IFSelect_ReturnStatus status = IFSelect_RetVoid;
+ try {
+ OCC_CATCH_SIGNALS
+ Standard_Integer stat = aLibrary->ReadStream(theName, theIStream, aStepModel, aProtocol);
+ if (stat == 0) status = IFSelect_RetDone;
+ else if (stat < 0) status = IFSelect_RetError;
+ else status = IFSelect_RetFail;
+ }
+ catch (Standard_Failure const& anException) {
+ Message_Messenger::StreamBuffer sout = Message::SendInfo();
+ sout << " **** Interruption ReadFile par Exception : ****\n";
+ sout << anException.GetMessageString();
+ sout << "\n Abandon" << std::endl;
+ status = IFSelect_RetFail;
+ }
+ if (status != IFSelect_RetDone) return status;
+ WS()->SetModel(aStepModel);
+ WS()->SetLoadedFile(theName);
+ WS()->InitTransferReader(4);
+ return status;
+}
+
+//=======================================================================
+//function : ReadStream
+//purpose :
+//=======================================================================
+IFSelect_ReturnStatus STEPControl_Reader::ReadStream(const Standard_CString theName,
+ const StepData_ConfParameters& theParams,
+ std::istream& theIStream)
+{
+ Handle(IFSelect_WorkLibrary) aLibrary = WS()->WorkLibrary();
+ Handle(Interface_Protocol) aProtocol = WS()->Protocol();
+ if (aLibrary.IsNull()) return IFSelect_RetVoid;
+ if (aProtocol.IsNull()) return IFSelect_RetVoid;
+ Handle(StepData_StepModel) aStepModel = new StepData_StepModel;
+ aStepModel->InternalParameters = theParams;
+ aStepModel->SetSourceCodePage(aStepModel->InternalParameters.ReadCodePage);
+ IFSelect_ReturnStatus status = IFSelect_RetVoid;
+ try {
+ OCC_CATCH_SIGNALS
+ Standard_Integer stat = aLibrary->ReadStream(theName, theIStream, aStepModel, aProtocol);
+ if (stat == 0) status = IFSelect_RetDone;
+ else if (stat < 0) status = IFSelect_RetError;
+ else status = IFSelect_RetFail;
+ }
+ catch (Standard_Failure const& anException) {
+ Message_Messenger::StreamBuffer sout = Message::SendInfo();
+ sout << " **** Interruption ReadFile par Exception : ****\n";
+ sout << anException.GetMessageString();
+ sout << "\n Abandon" << std::endl;
+ status = IFSelect_RetFail;
+ }
+ if (status != IFSelect_RetDone) return status;
+ WS()->SetModel(aStepModel);
+ WS()->SetLoadedFile(theName);
+ WS()->InitTransferReader(4);
+ return status;
+}
+
//=======================================================================
//function : TransferRoot
//purpose :
if (therootsta) return theroots.Length();
therootsta = Standard_True;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(WS()->Model());
//theroots.Clear();
Standard_Integer nb = Model()->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = Model()->Value(i);
- if (Interface_Static::IVal("read.step.all.shapes") == 1) {
+ if (aStepModel->InternalParameters.ReadAllShapes == 1) {
// Special case to read invalid shape_representation without links to shapes.
if (ent->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))) {
Interface_EntityIterator aShareds = WS()->Graph().Sharings(ent);
}
// determinate roots used ProductDefinitionContext
if(IsRoot) {
- const char *str1 = Interface_Static::CVal("read.step.product.context");
- Standard_Integer ICS = Interface_Static::IVal("read.step.product.context");
+ StepData_ConfParameters::ReadMode_ProductContext aProdContMode = aStepModel->InternalParameters.ReadProductContext;
+ TCollection_AsciiString str1 = aStepModel->InternalParameters.GetString(aProdContMode);
+ Standard_Integer ICS = aStepModel->InternalParameters.ReadProductContext;
if(ICS>1) {
subs = graph.Shareds(PD);
for(subs.Start(); subs.More(); subs.Next()) {
if (PDC.IsNull()) continue;
const char *str2 = PDC->LifeCycleStage()->String().ToCString();
const char *str3 = PDC->Name()->String().ToCString();
- if( !( strcasecmp(str1,str2)==0 || strcasecmp(str1,str3)==0 ) )
+ if( !( strcasecmp(str1.ToCString(),str2)==0 || strcasecmp(str1.ToCString(),str3) == 0))
IsRoot=Standard_False;
}
}
WS()->TransferReader()->TransientProcess()->RootsForTransfer()->Append(ent);
}
}
- TCollection_AsciiString aProdMode = Interface_Static::CVal("read.step.product.mode");
- if(!aProdMode.IsEqual("ON")) {
+ bool aProdMode = aStepModel->InternalParameters.ReadProductMode;
+ if(!aProdMode) {
if(ent->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
Standard_Boolean IsRoot = Standard_True;
Handle(StepShape_ShapeDefinitionRepresentation) SDR =
//=======================================================================
void STEPControl_Reader::SetSystemLengthUnit(const Standard_Real theLengthUnit)
{
+ if (StepModel().IsNull())
+ {
+ return;
+ }
StepModel()->SetLocalLengthUnit(theLengthUnit);
}
//=======================================================================
Standard_Real STEPControl_Reader::SystemLengthUnit() const
{
+ if (StepModel().IsNull())
+ {
+ return 1.;
+ }
return StepModel()->LocalLengthUnit();
}
#include <XSControl_Reader.hxx>
#include <Standard_Integer.hxx>
+#include <StepData_ConfParameters.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <TColStd_Array1OfAsciiString.hxx>
#include <TColStd_Array1OfReal.hxx>
//! Returns the model as a StepModel.
//! It can then be consulted (header, product)
Standard_EXPORT Handle(StepData_StepModel) StepModel() const;
+
+ //! Loads a file and returns the read status
+ //! Zero for a Model which compies with the Controller
+ Standard_EXPORT virtual IFSelect_ReturnStatus ReadFile(const Standard_CString filename) Standard_OVERRIDE;
+
+ //! Loads a file from stream and returns the read status
+ Standard_EXPORT virtual IFSelect_ReturnStatus ReadStream(const Standard_CString theName,
+ std::istream& theIStream) Standard_OVERRIDE;
+
+ //! Loads a file and returns the read status
+ //! Zero for a Model which compies with the Controller
+ Standard_EXPORT IFSelect_ReturnStatus ReadFile(const Standard_CString filename,
+ const StepData_ConfParameters& theParams);
+
+ //! Loads a file from stream and returns the read status
+ Standard_EXPORT IFSelect_ReturnStatus ReadStream(const Standard_CString theName,
+ const StepData_ConfParameters& theParams,
+ std::istream& theIStream);
//! Transfers a root given its rank in the list of candidate roots
//! Default is the first one
//! found in file
Standard_EXPORT void FileUnits (TColStd_SequenceOfAsciiString& theUnitLengthNames, TColStd_SequenceOfAsciiString& theUnitAngleNames, TColStd_SequenceOfAsciiString& theUnitSolidAngleNames);
- //! Sets system length unit used by transfer process
+ //! Sets system length unit used by transfer process.
+ //! Performs only if a model is not NULL
Standard_EXPORT void SetSystemLengthUnit(const Standard_Real theLengthUnit);
- //! Returns system length unit used by transfer process
+ //! Returns system length unit used by transfer process.
+ //! Performs only if a model is not NULL
Standard_EXPORT Standard_Real SystemLengthUnit() const;
#include <Interface_Macros.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <STEPControl_Controller.hxx>
+#include <StepData_ConfParameters.hxx>
#include <StepData_StepModel.hxx>
#include <StepData_Protocol.hxx>
#include <StepData_StepWriter.hxx>
const STEPControl_StepModelType mode,
const Standard_Boolean compgraph,
const Message_ProgressRange& theProgress)
+{
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(thesession->Model());
+ if (!aStepModel.IsNull())
+ {
+ aStepModel->InternalParameters.InitFromStatic();
+ }
+ return Transfer(sh, mode, aStepModel->InternalParameters, compgraph, theProgress);
+}
+
+IFSelect_ReturnStatus STEPControl_Writer::Transfer
+ (const TopoDS_Shape& sh,
+ const STEPControl_StepModelType mode,
+ const StepData_ConfParameters& theParams,
+ const Standard_Boolean compgraph,
+ const Message_ProgressRange& theProgress)
{
Standard_Integer mws = -1;
switch (mode) {
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
Model()->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
}
+ if (!thesession->Model().IsNull())
+ {
+ Handle(StepData_StepModel)::DownCast(thesession->Model())->InternalParameters = theParams;
+ }
+ Handle(STEPControl_ActorWrite) ActWrite =
+ Handle(STEPControl_ActorWrite)::DownCast(WS()->NormAdaptor()->ActorWrite());
+ ActWrite->SetGroupMode(Handle(StepData_StepModel)::DownCast(thesession->Model())->InternalParameters.WriteAssembly);
return thesession->TransferWriteShape(sh, compgraph, theProgress);
}
#include <Standard_Real.hxx>
#include <IFSelect_ReturnStatus.hxx>
+#include <StepData_ConfParameters.hxx>
#include <STEPControl_StepModelType.hxx>
#include <Standard_Integer.hxx>
#include <Message_ProgressRange.hxx>
const Standard_Boolean compgraph = Standard_True,
const Message_ProgressRange& theProgress = Message_ProgressRange());
+ //! Translates shape sh to a STEP entity
+ Standard_EXPORT IFSelect_ReturnStatus Transfer
+ (const TopoDS_Shape& sh,
+ const STEPControl_StepModelType mode,
+ const StepData_ConfParameters& theParams,
+ const Standard_Boolean compgraph = Standard_True,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
//! Writes a STEP model in the file identified by filename.
Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString theFileName);
StepData.cxx
StepData.hxx
StepData_Array1OfField.hxx
+StepData_ConfParameters.cxx
+StepData_ConfParameters.hxx
StepData_DefaultGeneral.cxx
StepData_DefaultGeneral.hxx
StepData_Described.cxx
--- /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 <StepData_ConfParameters.hxx>
+
+//=======================================================================
+// function : StepData_ConfParameters
+// purpose :
+//=======================================================================
+StepData_ConfParameters::StepData_ConfParameters()
+{}
+
+//=======================================================================
+// function : InitParameters
+// purpose :
+//=======================================================================
+void StepData_ConfParameters::InitFromStatic()
+{
+ ReadBSplineContinuity = (StepData_ConfParameters::ReadMode_BSplineContinuity)Interface_Static::IVal("read.iges.bspline.continuity");
+ ReadPrecisionMode = (StepData_ConfParameters::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
+ ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
+ ReadMaxPrecisionMode = (StepData_ConfParameters::ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
+ ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
+ ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
+ ReadSurfaceCurveMode = (StepData_ConfParameters::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
+ EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
+ AngleUnit = (StepData_ConfParameters::AngleUnitMode)Interface_Static::IVal("step.angleunit.mode");
+
+ ReadResourceName = Interface_Static::CVal("read.step.resource.name");
+ ReadSequence = Interface_Static::CVal("read.step.sequence");
+ ReadProductMode = Interface_Static::IVal("read.step.product.mode") == 1;
+ ReadProductContext = (StepData_ConfParameters::ReadMode_ProductContext)Interface_Static::IVal("read.step.product.context");
+ ReadShapeRepr = (StepData_ConfParameters::ReadMode_ShapeRepr)Interface_Static::IVal("read.step.shape.repr");
+ ReadTessellated = (StepData_ConfParameters::RWMode_Tessellated)Interface_Static::IVal("read.step.tessellated");
+ ReadAssemblyLevel = (StepData_ConfParameters::ReadMode_AssemblyLevel)Interface_Static::IVal("read.step.assembly.level");
+ ReadRelationship = Interface_Static::IVal("read.step.shape.relationship") == 1;
+ ReadShapeAspect = Interface_Static::IVal("read.step.shape.aspect") == 1;
+ ReadConstrRelation = Interface_Static::IVal("read.step.constructivegeom.relationship") == 1;
+ ReadSubshapeNames = Interface_Static::IVal("read.stepcaf.subshapes.name") == 1;
+ ReadCodePage = (Resource_FormatType)Interface_Static::IVal("read.step.codepage");
+ ReadNonmanifold = Interface_Static::IVal("read.step.nonmanifold") == 1;
+ ReadIdeas = Interface_Static::IVal("read.step.ideas") == 1;
+ ReadAllShapes = Interface_Static::IVal("read.step.all.shapes") == 1;
+ ReadRootTransformation = Interface_Static::IVal("read.step.root.transformation") == 1;
+ ReadColor = Interface_Static::IVal("read.color") == 1;
+ ReadName = Interface_Static::IVal("read.name") == 1;
+ ReadLayer = Interface_Static::IVal("read.layer") == 1;
+ ReadProps = Interface_Static::IVal("read.props") == 1;
+
+ WritePrecisionMode = (StepData_ConfParameters::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
+ WritePrecisionVal = Interface_Static::RVal("write.precision.val");
+ WriteAssembly = (StepData_ConfParameters::WriteMode_Assembly)Interface_Static::IVal("write.step.assembly");
+ WriteSchema = (StepData_ConfParameters::WriteMode_StepSchema)Interface_Static::IVal("write.step.schema");
+ WriteTessellated = (StepData_ConfParameters::RWMode_Tessellated)Interface_Static::IVal("write.step.tessellated");
+ WriteProductName = Interface_Static::CVal("write.step.product.name");
+ WriteSurfaceCurMode = Interface_Static::IVal("write.surfacecurve.mode") == 1;
+ WriteUnit = (UnitsMethods_LengthUnit)Interface_Static::IVal("write.step.unit");
+ WriteResourceName = Interface_Static::CVal("write.step.resource.name");
+ WriteSequence = Interface_Static::CVal("write.step.sequence");
+ WriteVertexMode = (StepData_ConfParameters::WriteMode_VertexMode)Interface_Static::IVal("write.step.vertex.mode");
+ WriteSubshapeNames = Interface_Static::IVal("write.stepcaf.subshapes.name") == 1;
+ WriteColor = Interface_Static::IVal("write.color") == 1;
+ WriteNonmanifold = Interface_Static::IVal("write.step.nonmanifold") == 1;
+ WriteName = Interface_Static::IVal("write.name") == 1;
+ WriteLayer = Interface_Static::IVal("write.layer") == 1;
+ WriteProps = Interface_Static::IVal("write.props") == 1;
+ WriteModelType = (STEPControl_StepModelType)Interface_Static::IVal("write.model.type");
+}
+
+//=======================================================================
+// function : ResetParameters
+// purpose :
+//=======================================================================
+void StepData_ConfParameters::Reset()
+{
+ StepData_ConfParameters aParameters;
+ *this = aParameters;
+}
--- /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 _StepData_ConfParameters_HeaderFile
+#define _StepData_ConfParameters_HeaderFile
+
+#include <Resource_FormatType.hxx>
+#include <STEPControl_StepModelType.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <UnitsMethods_LengthUnit.hxx>
+
+class StepData_ConfParameters
+{
+
+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 AngleUnitMode
+ {
+ AngleUnitMode_File = 0,
+ AngleUnitMode_Rad,
+ AngleUnitMode_Deg
+ };
+ enum ReadMode_ProductContext
+ {
+ ReadMode_ProductContext_All = 1,
+ ReadMode_ProductContext_Design,
+ ReadMode_ProductContext_Analysis
+ };
+ enum ReadMode_ShapeRepr
+ {
+ ReadMode_ShapeRepr_All = 1,
+ ReadMode_ShapeRepr_ABSR,
+ ReadMode_ShapeRepr_MSSR,
+ ReadMode_ShapeRepr_GBSSR,
+ ReadMode_ShapeRepr_FBSR,
+ ReadMode_ShapeRepr_EBWSR,
+ ReadMode_ShapeRepr_GBWSR
+ };
+ enum ReadMode_AssemblyLevel
+ {
+ ReadMode_AssemblyLevel_All = 1,
+ ReadMode_AssemblyLevel_Assembly,
+ ReadMode_AssemblyLevel_Structure,
+ ReadMode_AssemblyLevel_Shape
+ };
+ enum RWMode_Tessellated
+ {
+ RWMode_Tessellated_Off = 0,
+ RWMode_Tessellated_On,
+ RWMode_Tessellated_OnNoBRep
+ };
+ enum WriteMode_PrecisionMode
+ {
+ WriteMode_PrecisionMode_Least = -1,
+ WriteMode_PrecisionMode_Average = 0,
+ WriteMode_PrecisionMode_Greatest = 1,
+ WriteMode_PrecisionMode_Session = 2
+ };
+ enum WriteMode_Assembly
+ {
+ WriteMode_Assembly_Off = 0,
+ WriteMode_Assembly_On,
+ WriteMode_Assembly_Auto
+ };
+ enum WriteMode_StepSchema
+ {
+ WriteMode_StepSchema_AP214CD = 1,
+ WriteMode_StepSchema_AP214DIS,
+ WriteMode_StepSchema_AP203,
+ WriteMode_StepSchema_AP214IS,
+ WriteMode_StepSchema_AP242DIS
+ };
+ enum WriteMode_VertexMode
+ {
+ WriteMode_VertexMode_OneCompound = 0,
+ WriteMode_VertexMode_SingleVertex
+ };
+
+ Standard_EXPORT StepData_ConfParameters();
+
+ //! Initialize parameters
+ Standard_EXPORT void InitFromStatic();
+
+ //! Reset used parameters
+ Standard_EXPORT void Reset();
+
+ Standard_EXPORT TCollection_AsciiString GetString(const ReadMode_ProductContext theMode)
+ {
+ switch (theMode)
+ {
+ case ReadMode_ProductContext_All:
+ return "all";
+ case ReadMode_ProductContext_Design:
+ return "design";
+ case ReadMode_ProductContext_Analysis:
+ return "analysis";
+ default:
+ return "";
+ }
+ }
+
+public:
+ // Common
+ 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
+ AngleUnitMode AngleUnit = AngleUnitMode_File; //<! Indicates what angle units should be used when a STEP file is read
+
+ // Read
+ TCollection_AsciiString ReadResourceName = "STEP"; //<! Defines the name of the resource file to read
+ TCollection_AsciiString ReadSequence = "FromSTEP"; //<! Defines the name of the sequence of operators to read
+ bool ReadProductMode = true; //<! Defines the approach used for selection of top-level STEP entities for translation, and for recognition of assembly structures
+ ReadMode_ProductContext ReadProductContext = ReadMode_ProductContext_All; //<! When reading AP 209 STEP files, allows selecting either only 'design' or 'analysis', or both types of products for translation
+ ReadMode_ShapeRepr ReadShapeRepr = ReadMode_ShapeRepr_All; //<! Specifies preferred type of representation of the shape of the product
+ RWMode_Tessellated ReadTessellated = RWMode_Tessellated_On; //!< Defines whether tessellated shapes should be translated
+ ReadMode_AssemblyLevel ReadAssemblyLevel = ReadMode_AssemblyLevel_All; //<! Specifies which data should be read for the products found in the STEP file
+ bool ReadRelationship = true; //<! Defines whether shapes associated with the main SHAPE_DEFINITION_REPRESENTATION entity of the product via SHAPE_REPRESENTATIONSHIP_RELATION should be translated
+ bool ReadShapeAspect = true; //<! Defines whether shapes associated with the PRODUCT_DEFINITION_SHAPE entity of the product via SHAPE_ASPECT should be translated
+ bool ReadConstrRelation = false; //<! Flag regulating translation of "CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP" entities
+ bool ReadSubshapeNames = false; //<! Indicates whether to read sub-shape names from 'Name' attributes of STEP Representation Items
+ Resource_FormatType ReadCodePage = Resource_FormatType_UTF8; //<! STEP file encoding for names translation
+ bool ReadNonmanifold = false; //<! Defines non-manifold topology reading
+ bool ReadIdeas = false; //<! Defines !I-Deas-like STEP processing
+ bool ReadAllShapes = false; //<! Parameter to read all top level solids and shells
+ bool ReadRootTransformation = true; ///<!/ Mode to variate apply or not transformation placed in the root shape representation
+ 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
+ bool ReadProps = true; //<! PropsMode is used to indicate read Validation properties or not
+
+ // Write
+ WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the STEP file
+ double WritePrecisionVal = 0.0001; //<! Resolution value for an STEP file when WriteMode_PrecisionMode is Greatest
+ WriteMode_Assembly WriteAssembly = WriteMode_Assembly_Off; //<! Writing assembly mode
+ WriteMode_StepSchema WriteSchema = WriteMode_StepSchema_AP214CD; //<! Defines the version of schema used for the output STEP file
+ RWMode_Tessellated WriteTessellated = RWMode_Tessellated_OnNoBRep; //!< Defines whether tessellated shapes should be translated
+ TCollection_AsciiString WriteProductName; //<! Defines the text string that will be used for field 'name' of PRODUCT entities written to the STEP file
+ bool WriteSurfaceCurMode = true; //<! Indicates whether parametric curves (curves in parametric space of surface) should be written into the STEP file
+ UnitsMethods_LengthUnit WriteUnit = UnitsMethods_LengthUnit_Millimeter; //<! Defines a unit in which the STEP file should be written
+ TCollection_AsciiString WriteResourceName = "STEP"; //<! Defines the name of the resource file to write
+ TCollection_AsciiString WriteSequence = "ToSTEP"; //<! Defines the name of the sequence of operators to write
+ WriteMode_VertexMode WriteVertexMode = WriteMode_VertexMode_OneCompound; //<! Indicates which of free vertices writing mode is switch on
+ bool WriteSubshapeNames = false; //<! Indicates whether to write sub-shape names to 'Name' attributes of STEP Representation Items
+ bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not
+ bool WriteNonmanifold = false; //<! Defines non-manifold topology writting
+ bool WriteName = true; //<! NameMode is used to indicate write Name or not
+ bool WriteLayer = true; //<! LayerMode is used to indicate write Layers or not
+ bool WriteProps = true; //<! PropsMode is used to indicate write Validation properties or not
+ STEPControl_StepModelType WriteModelType = STEPControl_AsIs; //<! Gives you the choice of translation mode for an Open CASCADE shape that is being translated to STEP
+};
+
+#endif // _StepData_ConfParameters_HeaderFile
IMPLEMENT_STANDARD_RTTIEXT(StepData_StepModel,Interface_InterfaceModel)
// Entete de fichier : liste d entites
-StepData_StepModel::StepData_StepModel () :mySourceCodePage((Resource_FormatType)Interface_Static::IVal("read.step.codepage")),
+StepData_StepModel::StepData_StepModel () :
myReadUnitIsInitialized(Standard_False), myWriteUnit (1.)
{
- switch (Interface_Static::IVal("write.step.unit"))
+ switch (InternalParameters.WriteUnit)
{
case 1: myWriteUnit = 25.4; break;
case 2: myWriteUnit = 1.; break;
#include <Interface_InterfaceModel.hxx>
#include <Resource_FormatType.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_ConfParameters.hxx>
class Standard_Transient;
class Interface_EntityIterator;
//! Return the encoding of STEP file for converting names into UNICODE.
//! Initialized from "read.step.codepage" variable by constructor, which is Resource_UTF8 by default.
- Resource_FormatType SourceCodePage() const { return mySourceCodePage; }
+ Resource_FormatType SourceCodePage() const { return InternalParameters.ReadCodePage; }
//! Return the encoding of STEP file for converting names into UNICODE.
- void SetSourceCodePage (Resource_FormatType theCode) { mySourceCodePage = theCode; }
+ void SetSourceCodePage (Resource_FormatType theCode) { InternalParameters.ReadCodePage = theCode; }
//! Sets local length unit using for transfer process
Standard_EXPORT void SetLocalLengthUnit(const Standard_Real theUnit);
//! False - the unit value was not initialized, the default value is used
Standard_Boolean IsInitializedUnit() const { return myReadUnitIsInitialized; }
+public:
+
+ StepData_ConfParameters InternalParameters;
+
DEFINE_STANDARD_RTTIEXT(StepData_StepModel,Interface_InterfaceModel)
protected:
Interface_EntityList theheader;
Handle(TColStd_HArray1OfInteger) theidnums;
- Resource_FormatType mySourceCodePage;
Standard_Boolean myReadUnitIsInitialized;
Standard_Real myWriteUnit;
Standard_Real myLocalLengthUnit;
{
DeclareAndCast(StepData_Protocol,stepro,protocol);
if (stepro.IsNull()) return 1;
- Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
- model = stepmodel;
- Standard_Integer aStatus = StepFile_Read(name, 0, stepmodel, stepro);
+ Standard_Integer aStatus = StepFile_Read(name, 0, Handle(StepData_StepModel)::DownCast(model), stepro);
return aStatus;
}
{
DeclareAndCast(StepData_Protocol, stepro, protocol);
if (stepro.IsNull()) return 1;
- Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
- model = stepmodel;
- Standard_Integer aStatus = StepFile_Read(theName, &theIStream, stepmodel, stepro);
+ Standard_Integer aStatus = StepFile_Read(theName, &theIStream, Handle(StepData_StepModel)::DownCast(model), stepro);
return aStatus;
}
#include <StdFail_NotDone.hxx>
#include <STEPControl_ActorRead.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepGeom_CompositeCurve.hxx>
#include <StepGeom_Curve.hxx>
#include <StepGeom_CurveBoundedSurface.hxx>
#include <TransferBRep.hxx>
#include <stdio.h>
-static void ResetPreci (const TopoDS_Shape& S, Standard_Real maxtol)
+static void ResetPreci (Handle(StepData_StepModel)& theStepModel,
+ const TopoDS_Shape& S, Standard_Real maxtol)
{
//:S4136
- Standard_Integer modetol = Interface_Static::IVal("read.maxprecision.mode");
+ Standard_Integer modetol = theStepModel->InternalParameters.ReadMaxPrecisionMode;
if (modetol) {
ShapeFix_ShapeTolerance STU;
STU.LimitTolerance (S,Precision::Confusion(),maxtol);
const Message_ProgressRange& theProgress)
{
Message_Messenger::StreamBuffer sout = theTP->Messenger()->SendInfo();
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(theTP->Model());
// Initialisation of the Tool
StepToTopoDS_Tool aTool;
sout << " - C2 : " << aTool.C2Cur2() << std::endl;
}
- ResetPreci (aSolid, MaxTol());
+ ResetPreci (aStepModel, aSolid, MaxTol());
}
// ============================================================================
sout << " - C2 : " << aTool.C2Cur2() << std::endl;
}
- ResetPreci (aSolid, MaxTol());
+//:S4136 ShapeFix::SameParameter (S,Standard_False);
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(theTP->Model());
+ ResetPreci (aStepModel, aSolid, MaxTol());
}
// ============================================================================
}
//:S4136 ShapeFix::SameParameter (S,Standard_False);
- ResetPreci (S, MaxTol());
- ResetPreci (Shl, MaxTol()); //skl
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
+ ResetPreci (aStepModel, S, MaxTol());
+ ResetPreci (aStepModel, Shl, MaxTol()); //skl
}
// ============================================================================
myError = ( myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther );
done = ! myResult.IsNull();
- ResetPreci (myResult, MaxTol());
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
+ ResetPreci (aStepModel, myResult, MaxTol());
}
// ============================================================================
myError = ( myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther );
done = ! myResult.IsNull();
- ResetPreci (myResult, MaxTol());
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
+ ResetPreci (aStepModel, myResult, MaxTol());
}
Standard_Boolean SurfMode = ( ! S.IsNull() && ! Surf.IsNull() );
Standard_Boolean isClosed = Standard_False;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
+
if ( SurfMode ) {
- Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode");
+ Standard_Integer modepcurve = aStepModel->InternalParameters.ReadSurfaceCurveMode;
if ( modepcurve ==-3 ) SurfMode = Standard_False;
}
#include <ShapeFix_EdgeProjAux.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepGeom_Pcurve.hxx>
#include <StepGeom_Surface.hxx>
#include <StepGeom_SurfaceCurve.hxx>
done = Standard_True;
return;
}
- Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode");
- // 0,1 : suivre le code, 2 : ne prendre que pcurve, 3 : ne prendre que C3D
BRep_Builder B;
Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model());
+ Standard_Integer modepcurve = aStepModel->InternalParameters.ReadSurfaceCurveMode;
+ // 0,1 : suivre le code, 2 : ne prendre que pcurve, 3 : ne prendre que C3D
Standard_Real preci = Precision();
TopoDS_Wire W;
#include <MoniTool_DataMapOfShapeTransient.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepShape_BrepWithVoids.hxx>
#include <StepShape_ClosedShell.hxx>
#include <StepShape_HArray1OfOrientedClosedShell.hxx>
Handle(StepShape_HArray1OfOrientedClosedShell) aVoids;
TColStd_SequenceOfTransient aTessShells;
- const Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ const Standard_Integer aWriteTessGeom = aStepModel->InternalParameters.WriteTessellated;
try
{
}
TopoDSToStep_Builder StepB;
- TopoDSToStep_Tool aTool;
+ TopoDSToStep_Tool aTool(aStepModel);
Standard_Integer nbshapes = 0;
for (It.Initialize(aSolid); It.More(); It.Next())
CurrentShell.Reverse();
//:d7 abv 16 Mar 98: try to treat 'open' shells as closed since flag
// IsClosed() is often incorrect (taken from MakeManifoldSolid(Solid))
- aTool.Init(aMap, Standard_False);
+ aTool.Init(aMap, Standard_False, aStepModel->InternalParameters.WriteSurfaceCurMode);
StepB.Init(CurrentShell, aTool, FP, aWriteTessGeom, theLocalFactors, aPS.Next());
TopoDSToStep::AddResult(FP, aTool);
if (StepB.IsDone())
#include <Message_ProgressScope.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepShape_ClosedShell.hxx>
#include <StepShape_FacetedBrep.hxx>
#include <StepShape_TopologicalRepresentationItem.hxx>
if (aShell.Closed()) {
Handle(StepShape_TopologicalRepresentationItem) aItem;
MoniTool_DataMapOfShapeTransient aMap;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ const Standard_Integer aWriteTessGeom = aStepModel->InternalParameters.WriteTessellated;
- const Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
-
- TopoDSToStep_Tool aTool(aMap, Standard_True);
+ TopoDSToStep_Tool aTool(aMap, Standard_True, aStepModel->InternalParameters.WriteSurfaceCurMode);
TopoDSToStep_Builder StepB(aShell, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress);
if (theProgress.UserBreak())
return;
if (aOuterShell.Closed()) {
Handle(StepShape_TopologicalRepresentationItem) aItem;
MoniTool_DataMapOfShapeTransient aMap;
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ const Standard_Integer aWriteTessGeom = aStepModel->InternalParameters.WriteTessellated;
- const Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
-
- TopoDSToStep_Tool aTool(aMap, Standard_True);
+ TopoDSToStep_Tool aTool(aMap, Standard_True, aStepModel->InternalParameters.WriteSurfaceCurMode);
TopoDSToStep_Builder StepB(aOuterShell, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress);
if (theProgress.UserBreak())
return;
#include <MoniTool_DataMapOfShapeTransient.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepShape_ClosedShell.hxx>
#include <StepShape_FacetedBrepAndBrepWithVoids.hxx>
#include <StepShape_HArray1OfOrientedClosedShell.hxx>
aOutShell = BRepClass3d::OuterShell(aSolid);
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
TopoDSToStep_Builder StepB;
- TopoDSToStep_Tool aTool;
+ TopoDSToStep_Tool aTool(aStepModel);
if (!aOutShell.IsNull()) {
Standard_Integer nbshapes = 0;
TopoDS_Shell CurrentShell = TopoDS::Shell(It.Value());
if (It.Value().Closed()) {
- aTool.Init(aMap, Standard_False);
+ aTool.Init(aMap, Standard_False, aStepModel->InternalParameters.WriteSurfaceCurMode);
StepB.Init(CurrentShell, aTool, FP, Standard_False, theLocalFactors, aRange);
TopoDSToStep::AddResult(FP, aTool);
#include <MoniTool_DataMapOfShapeTransient.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepShape_GeometricCurveSet.hxx>
#include <StepShape_GeometricSetSelect.hxx>
#include <StepShape_HArray1OfGeometricSetSelect.hxx>
done = Standard_False;
Handle(TColStd_HSequenceOfTransient) itemList;
MoniTool_DataMapOfShapeTransient aMap;
- TopoDSToStep_Tool aTool (aMap, Standard_False);
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ TopoDSToStep_Tool aTool (aMap, Standard_False, aStepModel->InternalParameters.WriteSurfaceCurMode);
TopoDSToStep_WireframeBuilder wirefB (aShape, aTool, theLocalFactors);
TopoDSToStep::AddResult ( FP, aTool );
#include <Message_ProgressScope.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepShape_ClosedShell.hxx>
#include <StepShape_HArray1OfFace.hxx>
#include <StepShape_ManifoldSolidBrep.hxx>
Handle(StepVisual_TessellatedItem) aTessItem;
MoniTool_DataMapOfShapeTransient aMap;
- TopoDSToStep_Tool aTool(aMap, Standard_False);
-
- const Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ TopoDSToStep_Tool aTool(aMap, Standard_False, aStepModel->InternalParameters.WriteSurfaceCurMode);
+ const Standard_Integer aWriteTessGeom = aStepModel->InternalParameters.WriteTessellated;
TopoDSToStep_Builder StepB(aShell, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress);
if (theProgress.UserBreak())
#include <Message_ProgressScope.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepShape_ClosedShell.hxx>
#include <StepShape_ConnectedFaceSet.hxx>
#include <StepShape_FaceSurface.hxx>
done = Standard_False;
MoniTool_DataMapOfShapeTransient aMap;
- Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
- const Standard_Integer aWriteTessSchema = Interface_Static::IVal("write.step.schema");
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ Standard_Integer aWriteTessGeom = aStepModel->InternalParameters.WriteTessellated;
+ const Standard_Integer aWriteTessSchema = aStepModel->InternalParameters.WriteSchema;
if (aWriteTessSchema != 5)
{
aWriteTessGeom = 0;
FP->AddWarning(anErrShape, " Tessellation can not be exported into not AP242");
}
- TopoDSToStep_Tool aTool(aMap, Standard_False);
+ TopoDSToStep_Tool aTool(aMap, Standard_False, aStepModel->InternalParameters.WriteSurfaceCurMode);
TopoDSToStep_Builder StepB(aFace, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress);
if (theProgress.UserBreak())
return;
Handle(StepShape_ClosedShell) aClosedShell;
MoniTool_DataMapOfShapeTransient aMap;
- Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
- const Standard_Integer aWriteTessSchema = Interface_Static::IVal("write.step.schema");
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ Standard_Integer aWriteTessGeom = aStepModel->InternalParameters.WriteTessellated;
+ const Standard_Integer aWriteTessSchema = aStepModel->InternalParameters.WriteSchema;
if (aWriteTessSchema != 5)
{
aWriteTessGeom = 0;
FP->AddWarning(anErrShape, " Tessellation can not be exported into not AP242");
}
- TopoDSToStep_Tool aTool(aMap, Standard_False);
+ TopoDSToStep_Tool aTool(aMap, Standard_False, aStepModel->InternalParameters.WriteSurfaceCurMode);
TopoDSToStep_Builder StepB(aShell, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress);
if (theProgress.UserBreak())
return;
TColStd_SequenceOfTransient S;
TColStd_SequenceOfTransient aTessShells;
- Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
- const Standard_Integer aWriteTessSchema = Interface_Static::IVal("write.step.schema");
+ Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(FP->Model());
+ Standard_Integer aWriteTessGeom = aStepModel->InternalParameters.WriteTessellated;
+ const Standard_Integer aWriteTessSchema = aStepModel->InternalParameters.WriteSchema;
if (aWriteTessSchema != 5)
{
aWriteTessGeom = 0;
if (It.Value().ShapeType() == TopAbs_SHELL) {
aShell = TopoDS::Shell(It.Value());
- TopoDSToStep_Tool aTool(aMap, Standard_False);
+ TopoDSToStep_Tool aTool(aMap, Standard_False, aStepModel->InternalParameters.WriteSurfaceCurMode);
TopoDSToStep_Builder StepB(aShell, aTool, FP, aWriteTessGeom, theLocalFactors, aPS.Next());
TopoDSToStep::AddResult ( FP, aTool );
#include <Interface_Static.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
+#include <StepData_StepModel.hxx>
#include <StepGeom_Line.hxx>
#include <StepGeom_SeamCurve.hxx>
#include <StepGeom_SurfaceCurve.hxx>
aTool.SetCurrentEdge(aEdge);
// [BEGIN] Processing non-manifold topology (ssv; 11.11.2010)
- Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
+ Standard_Boolean isNMMode =
+ Handle(StepData_StepModel)::DownCast(FP->Model())->InternalParameters.WriteNonmanifold != 0;
if (isNMMode) {
Handle(StepShape_EdgeCurve) anEC;
Handle(TransferBRep_ShapeMapper) aSTEPMapper = TransferBRep::ShapeMapper(FP, aEdge);
new TransferBRep_ShapeMapper(aFace); // on ne sait jamais
// [BEGIN] Processing non-manifold topology (another approach) (ssv; 10.11.2010)
- Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
+ Standard_Boolean isNMMode =
+ Handle(StepData_StepModel)::DownCast(FP->Model())->InternalParameters.WriteNonmanifold != 0;
if (isNMMode) {
Handle(StepShape_AdvancedFace) anAF;
Handle(TransferBRep_ShapeMapper) aSTEPMapper = TransferBRep::ShapeMapper(FP, aFace);
aTool.SetCurrentVertex(aVertex);
// [BEGIN] Processing non-manifold topology (ssv; 11.11.2010)
- Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
+ Standard_Boolean isNMMode =
+ Handle(StepData_StepModel)::DownCast(FP->Model())->InternalParameters.WriteNonmanifold != 0;
if (isNMMode) {
Handle(StepShape_VertexPoint) aVP;
Handle(TransferBRep_ShapeMapper) aSTEPMapper = TransferBRep::ShapeMapper(FP, aVertex);
#include <BRep_Tool.hxx>
#include <Interface_Static.hxx>
+#include <StepData_StepModel.hxx>
#include <StepShape_TopologicalRepresentationItem.hxx>
#include <TopoDSToStep_Tool.hxx>
//function : TopoDSToStep_Tool
//purpose :
//=======================================================================
-TopoDSToStep_Tool::TopoDSToStep_Tool()
- : myFacetedContext(Standard_False), myLowestTol(0.),myReversedSurface (Standard_False)
+TopoDSToStep_Tool::TopoDSToStep_Tool(const Handle(StepData_StepModel)& theModel)
+ : myFacetedContext(Standard_False),
+ myLowestTol(0.),
+ myReversedSurface(Standard_False)
{
- myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode");
+ myPCurveMode = theModel->InternalParameters.WriteSurfaceCurMode;
}
//=======================================================================
//purpose :
//=======================================================================
-TopoDSToStep_Tool::TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext)
+TopoDSToStep_Tool::TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M,
+ const Standard_Boolean FacetedContext,
+ Standard_Integer theSurfCurveMode)
:myLowestTol(0.),myReversedSurface(Standard_False)
{
- Init ( M, FacetedContext );
+ Init ( M, FacetedContext, theSurfCurveMode );
}
//=======================================================================
//purpose :
//=======================================================================
-void TopoDSToStep_Tool::Init(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext)
+void TopoDSToStep_Tool::Init(const MoniTool_DataMapOfShapeTransient& M,
+ const Standard_Boolean FacetedContext,
+ Standard_Integer theSurfCurveMode)
{
myDataMap = M;
myFacetedContext = FacetedContext;
- myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode");
+ myPCurveMode = theSurfCurveMode;
}
//=======================================================================
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <Standard_Integer.hxx>
+class StepData_StepModel;
class TopoDS_Shape;
class StepShape_TopologicalRepresentationItem;
DEFINE_STANDARD_ALLOC
- Standard_EXPORT TopoDSToStep_Tool();
+ Standard_EXPORT TopoDSToStep_Tool(const Handle(StepData_StepModel)& theModel);
- Standard_EXPORT TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext);
+ Standard_EXPORT TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M,
+ const Standard_Boolean FacetedContext,
+ Standard_Integer theSurfCurveMode);
- Standard_EXPORT void Init (const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext);
+ Standard_EXPORT void Init (const MoniTool_DataMapOfShapeTransient& M,
+ const Standard_Boolean FacetedContext,
+ Standard_Integer theSurfCurveMode);
Standard_EXPORT Standard_Boolean IsBound (const TopoDS_Shape& S);
//! Loads a file and returns the read status
//! Zero for a Model which compies with the Controller
- Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename);
+ Standard_EXPORT virtual IFSelect_ReturnStatus ReadFile (const Standard_CString filename);
//! Loads a file from stream and returns the read status
- Standard_EXPORT IFSelect_ReturnStatus ReadStream(const Standard_CString theName, std::istream& theIStream);
+ Standard_EXPORT virtual IFSelect_ReturnStatus ReadStream(const Standard_CString theName, std::istream& theIStream);
//! Returns the model. It can then be consulted (header, product)
Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <OSD_OpenFile.hxx>
+#include <OSD_Parallel.hxx>
#include <OSD_Path.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <STEPCAFControl_Writer.hxx>
//=======================================================================
//function : testreadstep
-//purpose :
+//purpose :
//=======================================================================
static Standard_Integer testreadstep(Draw_Interpretor& theDI,
Standard_Integer theNbArgs,
const char** theArgVec)
{
- if (theNbArgs < 3 || theNbArgs > 4)
+ if (theNbArgs < 3)
{
theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
theDI << " Usage : " << theArgVec[0] << " file_name shape_name [-stream]\n";
return 1;
}
- Standard_Boolean useStream = (theNbArgs > 3 && !strcasecmp(theArgVec[3], "-stream"));
-
- STEPControl_Reader Reader;
- Standard_CString filename = theArgVec[1];
- IFSelect_ReturnStatus readstat;
- if (useStream)
+ Standard_Boolean useStream = (theNbArgs > 3 && !strcasecmp(theArgVec[theNbArgs - 1], "-stream"));
+ Standard_CString aShName = useStream ? theArgVec[theNbArgs - 2] : theArgVec[theNbArgs - 1];
+ Standard_Integer aSize = useStream ? (theNbArgs - 3) : (theNbArgs - 2);
+ NCollection_Array1<TopoDS_Shape> aShapes(0, aSize);
+ NCollection_Array1<TCollection_AsciiString> aFileNames(0, aSize);
+ NCollection_DataMap<TCollection_AsciiString, TopoDS_Shape> aShapesMap;
+ for (int anInd = 1; anInd <= aSize; ++anInd)
{
- std::ifstream aStream;
- OSD_OpenStream(aStream, filename, std::ios::in | std::ios::binary);
- TCollection_AsciiString aFolder, aFileNameShort;
- OSD_Path::FolderAndFileFromPath(filename, aFolder, aFileNameShort);
- readstat = Reader.ReadStream(aFileNameShort.ToCString(), aStream);
+ aFileNames[anInd - 1] = theArgVec[anInd];
}
- else
- {
- readstat = Reader.ReadFile(filename);
- }
- theDI << "Status from reading STEP file " << filename << " : ";
- switch (readstat)
+ STEPControl_Controller::Init();
+ XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ IFSelect_ReturnStatus aReadStat;
+ StepData_ConfParameters aParameters;
+ aParameters.InitFromStatic();
+ int aNbSubShape = 0;
+ OSD_Parallel::For
+ (
+ 0, aSize,
+ [&](const Standard_Integer theIndex)
+ {
+ STEPControl_Reader aReader;
+ aReader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
+ if (useStream)
+ {
+ std::ifstream aStream;
+ OSD_OpenStream(aStream, aFileNames[theIndex].ToCString(), std::ios::in | std::ios::binary);
+ TCollection_AsciiString aFolder, aFileNameShort;
+ OSD_Path::FolderAndFileFromPath(aFileNames[theIndex].ToCString(), aFolder, aFileNameShort);
+ aReadStat = aReader.ReadStream(aFileNameShort.ToCString(), aParameters, aStream);
+ }
+ else
+ {
+ aReadStat = aReader.ReadFile(aFileNames[theIndex].ToCString(), aParameters);
+ }
+ if (aReadStat == IFSelect_RetDone)
+ {
+ aReader.TransferRoots();
+ aShapes[theIndex] = aReader.OneShape();
+ TCollection_AsciiString aName(aShName);
+ if (aSize > 1)
+ {
+ aName += theIndex;
+ }
+ aShapesMap.Bind(aName, aShapes[theIndex]);
+ aNbSubShape += aReader.NbShapes();
+ }
+ else
+ {
+ theDI << "Error: Problem with reading shape by file: " << "[" << aFileNames[theIndex] << "]";
+ }
+ }
+ );
+ NCollection_DataMap<TCollection_AsciiString, TopoDS_Shape>::Iterator anIt(aShapesMap);
+ for (; anIt.More(); anIt.Next())
{
- case IFSelect_RetVoid: { theDI << "empty file\n"; return 1; }
- case IFSelect_RetDone: { theDI << "file read\n"; break; }
- case IFSelect_RetError: { theDI << "file not found\n"; return 1; }
- case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
- default: { theDI << "failure\n"; return 1; }
+ DBRep::Set(anIt.Key().ToCString(), anIt.Value());
}
- Reader.SetSystemLengthUnit(XSDRAW::GetLengthUnit());
- Reader.TransferRoots();
- TopoDS_Shape shape = Reader.OneShape();
- DBRep::Set(theArgVec[2], shape);
- theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
+ theDI << "Count of shapes produced : " << aNbSubShape << "\n";
return 0;
}
}
//=======================================================================
-//function : testwrite
-//purpose :
+//function : testwritestep
+//purpose :
//=======================================================================
static Standard_Integer testwrite(Draw_Interpretor& theDI,
Standard_Integer theNbArgs,
const char** theArgVec)
{
- TCollection_AsciiString aFilePath;
- TopoDS_Shape aShape;
- bool toTestStream = false;
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
- anArgCase.LowerCase();
- if (anArgCase == "-stream")
- {
- toTestStream = true;
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = theArgVec[anArgIter];
- }
- else if (aShape.IsNull())
- {
- aShape = DBRep::Get(theArgVec[anArgIter]);
- if (aShape.IsNull())
- {
- theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a shape\n";
- return 1;
- }
- }
- else
- {
- theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'\n";
- return 1;
- }
- }
- if (aShape.IsNull())
+ if (theNbArgs < 3)
{
- theDI << "Syntax error: wrong number of arguments\n";
+ theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
+ theDI << " Usage : " << theArgVec[0] << " file_name shape_name [-stream]\n";
+ theDI << " Option -stream forces usage of API accepting stream\n";
return 1;
}
- STEPControl_Writer aWriter;
- IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape, STEPControl_AsIs);
- if (aStat != IFSelect_RetDone)
+ Standard_Boolean useStream = (theNbArgs > 3 && !strcasecmp(theArgVec[theNbArgs - 1], "-stream"));
+ Standard_CString aShName = useStream ? theArgVec[theNbArgs - 2] : theArgVec[theNbArgs - 1];
+ Standard_Integer aSize = useStream ? (theNbArgs - 3) : (theNbArgs - 2);
+ NCollection_Array1<TCollection_AsciiString> aFileNames(0, aSize);
+ NCollection_DataMap<TCollection_AsciiString, TopoDS_Shape> aShapesMap;
+ for (int anInd = 1; anInd <= aSize; ++anInd)
{
- theDI << "Error on transferring shape\n";
+ aFileNames[anInd - 1] = theArgVec[anInd];
+ }
+ TopoDS_Shape aShape = DBRep::Get(aShName);
+ if (aShape.IsNull())
+ {
+ theDI << "Syntax error: wrong number of arguments";
return 1;
}
- if (toTestStream)
- {
- std::ofstream aStream;
- OSD_OpenStream(aStream, aFilePath, std::ios::out | std::ios::binary);
- aStat = aWriter.WriteStream(aStream);
- aStream.close();
- if (!aStream.good()
- && aStat == IFSelect_RetDone)
+ StepData_ConfParameters aParameters;
+ aParameters.InitFromStatic();
+
+ OSD_Parallel::For
+ (
+ 0, aSize,
+ [&](const Standard_Integer theIndex)
{
- aStat = IFSelect_RetFail;
+ STEPControl_Writer aWriter;
+ if (aWriter.Transfer(aShape, STEPControl_AsIs, aParameters) != IFSelect_RetDone)
+ {
+ theDI << "Error: Can't transfer input shape";
+ return;
+ }
+ IFSelect_ReturnStatus aStat = IFSelect_RetDone;
+ if (useStream)
+ {
+ std::ofstream aStream;
+ OSD_OpenStream(aStream, aFileNames[theIndex], std::ios::out | std::ios::binary);
+ if (!aStream.good())
+ {
+ theDI << "Error: Problem with opening stream by file: " << "[" << aFileNames[theIndex] << "]";
+ return;
+ }
+ aStat = aWriter.WriteStream(aStream);
+ }
+ else
+ {
+ aStat = aWriter.Write(aFileNames[theIndex].ToCString());
+ }
+ if (aStat != IFSelect_RetDone)
+ {
+ theDI << "Error on writing file: " << "[" << aFileNames[theIndex] << "]";
+ return;
+ }
}
- }
- else
- {
- aStat = aWriter.Write(aFilePath.ToCString());
- }
- if (aStat != IFSelect_RetDone)
- {
- theDI << "Error on writing file\n";
- return 1;
- }
- theDI << "File Is Written\n";
+ );
+ theDI << "File(s) are Written";
return 0;
}
const char* aGroup = "DE: STEP"; // Step transfer file commands
theDI.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, aGroup);
- theDI.Add("testwritestep", "testwritestep filename.stp shape [-stream]",
+ theDI.Add("testwritestep", "testwritestep [file_1.stp ... file_n.stp] shape [-stream]",
__FILE__, testwrite, aGroup);
theDI.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, aGroup);
- theDI.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, aGroup);
+ theDI.Add("testreadstep", "testreadstep [file_1 ... file_n] shape [-stream]", __FILE__, testreadstep, aGroup);
theDI.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, aGroup);
theDI.Add("countexpected", "TEST", __FILE__, countexpected, aGroup);
theDI.Add("dumpassembly", "TEST", __FILE__, dumpassembly, aGroup);