1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-30 12:14:08 +03:00

Data Exchange, Step Export - Ignoring unit factors during tessellation export (#577)

Provide unit factors into the tessellation export methods.
This commit is contained in:
ikochetkova 2025-06-20 15:38:33 +01:00 committed by GitHub
parent 9ddcdae3f9
commit f1cb756901
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 87 additions and 18 deletions

View File

@ -173,7 +173,11 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
if (theTessellatedGeomParam == 1 || (theTessellatedGeomParam == 2 && myResult.IsNull()))
{
TopoDSToStep_MakeTessellatedItem MkTessShell(myShell, myTool, FP, aPS.Next());
TopoDSToStep_MakeTessellatedItem MkTessShell(myShell,
myTool,
FP,
theLocalFactors,
aPS.Next());
if (MkTessShell.IsDone())
{
myTessellatedResult = MkTessShell.Value();
@ -199,7 +203,7 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
Message_ProgressScope aPS(theProgress, NULL, 1);
// fourth parameter is true in order to create a tessellated_surface_set entity
// or put false to create a triangulated_face instead
MkTessFace.Init(Face, myTool, FP, Standard_True, aPS.Next());
MkTessFace.Init(Face, myTool, FP, Standard_True, theLocalFactors, aPS.Next());
}
if (MkFace.IsDone() || MkTessFace.IsDone())

View File

@ -15,6 +15,7 @@
#include <MoniTool_DataMapOfShapeTransient.hxx>
#include <Poly.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
#include <StepVisual_FaceOrSurface.hxx>
#include <StepShape_TopologicalRepresentationItem.hxx>
#include <StepVisual_TessellatedShell.hxx>
@ -40,11 +41,13 @@ static void InitTriangulation(const Handle(Poly_Triangulation)& theMesh,
Handle(TColgp_HArray1OfXYZ)& thePoints,
Handle(TColStd_HArray2OfReal)& theNormals,
Handle(TColStd_HArray1OfInteger)& theIndices,
Handle(TColStd_HArray2OfInteger)& theTrias)
Handle(TColStd_HArray2OfInteger)& theTrias,
const StepData_Factors& theLocalFactors)
{
Standard_Real aFactor = theLocalFactors.LengthFactor();
for (Standard_Integer aNodeIndex = 1; aNodeIndex <= theMesh->NbNodes(); ++aNodeIndex)
{
thePoints->SetValue(aNodeIndex, theMesh->Node(aNodeIndex).XYZ());
thePoints->SetValue(aNodeIndex, theMesh->Node(aNodeIndex).XYZ() / aFactor);
}
theCoordinates->Init(theName, thePoints);
if (!theMesh->HasNormals())
@ -86,10 +89,11 @@ TopoDSToStep_MakeTessellatedItem::TopoDSToStep_MakeTessellatedItem(
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const Standard_Boolean theToPreferSurfaceSet,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress)
: TopoDSToStep_Root()
{
Init(theFace, theTool, theFP, theToPreferSurfaceSet, theProgress);
Init(theFace, theTool, theFP, theToPreferSurfaceSet, theLocalFactors, theProgress);
}
//=================================================================================================
@ -98,10 +102,11 @@ TopoDSToStep_MakeTessellatedItem::TopoDSToStep_MakeTessellatedItem(
const TopoDS_Shell& theShell,
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress)
: TopoDSToStep_Root()
{
Init(theShell, theTool, theFP, theProgress);
Init(theShell, theTool, theFP, theLocalFactors, theProgress);
}
//=============================================================================
@ -113,6 +118,7 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Face&
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const Standard_Boolean theToPreferSurfaceSet,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress)
{
done = Standard_False;
@ -133,7 +139,14 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Face&
Handle(TColStd_HArray1OfInteger) anIndices = new TColStd_HArray1OfInteger(1, aMesh->NbNodes());
Handle(TColStd_HArray2OfInteger) aTrias =
new TColStd_HArray2OfInteger(1, aMesh->NbTriangles(), 1, 3);
InitTriangulation(aMesh, aName, aCoordinates, aPoints, aNormals, anIndices, aTrias);
InitTriangulation(aMesh,
aName,
aCoordinates,
aPoints,
aNormals,
anIndices,
aTrias,
theLocalFactors);
const Standard_Boolean aHasGeomLink = theTool.IsBound(theFace);
StepVisual_FaceOrSurface aGeomLink;
@ -182,6 +195,7 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Face&
void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Shell& theShell,
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress)
{
done = Standard_False;
@ -202,7 +216,12 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Shell&
for (anExp.Init(theShell, TopAbs_FACE); anExp.More() && aPS.More(); anExp.Next(), aPS.Next())
{
const TopoDS_Face aFace = TopoDS::Face(anExp.Current());
TopoDSToStep_MakeTessellatedItem aMakeFace(aFace, theTool, theFP, Standard_False, aPS.Next());
TopoDSToStep_MakeTessellatedItem aMakeFace(aFace,
theTool,
theFP,
Standard_False,
theLocalFactors,
aPS.Next());
if (aMakeFace.IsDone())
{
aTessFaces.Append(Handle(StepVisual_TessellatedStructuredItem)::DownCast(aMakeFace.Value()));

View File

@ -21,6 +21,7 @@
#include <TopoDSToStep_Root.hxx>
#include <Message_ProgressRange.hxx>
class StepData_Factors;
class StepVisual_TessellatedItem;
class TopoDS_Face;
class TopoDS_Shell;
@ -40,23 +41,27 @@ public:
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const Standard_Boolean theToPreferSurfaceSet,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT TopoDSToStep_MakeTessellatedItem(
const TopoDS_Shell& theShell,
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT void Init(const TopoDS_Face& theFace,
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const Standard_Boolean theToPreferSurfaceSet,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT void Init(const TopoDS_Shell& theShell,
TopoDSToStep_Tool& theTool,
const Handle(Transfer_FinderProcess)& theFP,
const StepData_Factors& theLocalFactors,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT const Handle(StepVisual_TessellatedItem)& Value() const;

View File

@ -15,12 +15,9 @@ set conf "
provider.STEP.OCC.write.schema : 5
provider.STEP.OCC.write.tessellated : 1
"
LoadConfiguration ${conf} -recursive on
param write.step.schema 5
param write.step.tessellated 1
WriteStep D1 "$imagedir/${casename}.stp"
ReadStep D2 "$imagedir/${casename}.stp"
WriteFile D1 "$imagedir/${casename}.stp" -conf ${conf}
ReadFile D2 "$imagedir/${casename}.stp"
XGetOneShape a1 D1
XGetOneShape a2 D2
@ -44,8 +41,4 @@ if {([expr abs($REF_X - [lindex $pos2 9])] > $tol) ||
Close D1
Close D2
file delete "$imagedir/${casename}.stp"
set conf "
provider.STEP.OCC.write.schema : 4
provider.STEP.OCC.write.tessellated : 2
"
LoadConfiguration ${conf} -recursive on

View File

@ -0,0 +1,48 @@
puts "================================================"
puts "OCP-1949: Apply a scaling transformation to STEP"
puts "================================================"
puts ""
pload OCAF
Close D1 -silent
Close D2 -silent
# Create simple mesh
box b 1 1 1
incmesh b 1
writestl b "$imagedir/${casename}.stl"
readstl b "$imagedir/${casename}.stl"
# Create document with meters as internal units
XNewDoc D1
XSetLengthUnit D1 m
XAddShape D1 b
# apply parameters for tessellation export
set conf "
provider.STEP.OCC.write.schema : 5
provider.STEP.OCC.write.tessellated : 1
"
WriteFile D1 "$imagedir/${casename}.stp" -conf ${conf}
ReadFile D2 "$imagedir/${casename}.stp"
XGetOneShape a1 D1
XGetOneShape a2 D2
# check sizes
set m_diag [eval distpp [bounding a1]]
set mm_diag [eval distpp [bounding a2]]
set tol 0.1
if {([expr abs($m_diag * 1000 - $mm_diag)] > $tol)} {
puts "Error: wrong size of models."
}
# cleaning
Close D1
Close D2
file delete "$imagedir/${casename}.stp"
file delete "$imagedir/${casename}.stl"