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

0029803: STEP Import: Units (inch) not applied to entity possessing GEOMETRIC_REPRESENTATION_CONTEXT

Translation of the entities AXIS2_PLACEMENT_3D including in the entity CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP was added.
Entity  AXIS2_PLACEMENT_3D is translated to the planar face with axis equal to AXIS2_PLACEMENT_3D.
New parameter "read.step.constructivegeom.relationship" is added to enable this translation (by default it is OFF).

Added test bugs step bug29803
This commit is contained in:
gka
2020-02-17 20:24:59 +03:00
committed by bugmaster
parent 517ba7aa70
commit 89180f9822
5 changed files with 164 additions and 13 deletions

View File

@@ -112,6 +112,9 @@
#include <UnitsMethods.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <StepRepr_ConstructiveGeometryRepresentationRelationship.hxx>
#include <StepRepr_ConstructiveGeometryRepresentation.hxx>
#include <Geom_Plane.hxx>
IMPLEMENT_STANDARD_RTTIEXT(STEPControl_ActorRead,Transfer_ActorOfTransientProcess)
@@ -505,6 +508,7 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS,
// should be taken into account
Standard_Integer readSRR = Interface_Static::IVal("read.step.shape.relationship");
Standard_Integer readConstructiveGeomRR = Interface_Static::IVal("read.step.constructivegeom.relationship");
// 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
@@ -625,19 +629,35 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS,
Handle(Standard_Type) tSRR = STANDARD_TYPE(StepRepr_ShapeRepresentationRelationship);
for (subs1.Start(); subs1.More(); subs1.Next()) {
Handle(Standard_Transient) anitem = subs1.Value();
if ( anitem->DynamicType() != tSRR ) continue;
Handle(StepRepr_ShapeRepresentationRelationship) SRR =
Handle(StepRepr_ShapeRepresentationRelationship)::DownCast(anitem);
Standard_Integer nbrep = ( rep == SRR->Rep1() ? 2 : 1 );
// SKL for bug 29068: parameter useTrsf is used because if root entity has connection with other
// by ShapeRepresentationRelationship then result after such transferring need to transform also.
// This case is from test "bugs modalg_7 bug30196"
binder = TransferEntity(SRR, TP, nbrep, useTrsf);
if ( ! binder.IsNull() ) {
theResult = TransferBRep::ShapeResult (binder);
Result1 = theResult;
B.Add(Cund, theResult);
nbShapes++;
if( !anitem->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationship)))
continue;
if (anitem->DynamicType() == tSRR)
{
Handle(StepRepr_ShapeRepresentationRelationship) SRR =
Handle(StepRepr_ShapeRepresentationRelationship)::DownCast(anitem);
Standard_Integer nbrep = (rep == SRR->Rep1() ? 2 : 1);
// SKL for bug 29068: parameter useTrsf is used because if root entity has connection with other
// by ShapeRepresentationRelationship then result after such transferring need to transform also.
// This case is from test "bugs modalg_7 bug30196"
binder = TransferEntity(SRR, TP, nbrep, useTrsf);
if (! binder.IsNull()) {
theResult = TransferBRep::ShapeResult (binder);
Result1 = theResult;
B.Add(Cund, theResult);
nbShapes++;
}
}
else if(readConstructiveGeomRR && anitem->IsKind(STANDARD_TYPE(StepRepr_ConstructiveGeometryRepresentationRelationship)))
{
Handle(StepRepr_ConstructiveGeometryRepresentationRelationship) aCSRR =
Handle(StepRepr_ConstructiveGeometryRepresentationRelationship)::DownCast(anitem);
binder = TransferEntity(aCSRR, TP);
if (! binder.IsNull())
{
Result1 = TransferBRep::ShapeResult (binder);
B.Add(Cund, Result1);
nbShapes++;
}
}
}
}
@@ -1100,6 +1120,70 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(
}
//=======================================================================
//function : TransferEntity
//purpose :
//=======================================================================
Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(
const Handle(StepRepr_ConstructiveGeometryRepresentationRelationship)& theCGRR,
const Handle(Transfer_TransientProcess)& theTP)
{
Handle(TransferBRep_ShapeBinder) shbinder;
if (theCGRR.IsNull())
return shbinder;
Standard_Boolean resetUnits = Standard_False;
Handle(StepRepr_Representation) oldSRContext = mySRContext;
TopoDS_Compound aComp;
BRep_Builder aB;
aB.MakeCompound(aComp);
for (Standard_Integer i = 1; i <= 2; i ++)
{
Handle(StepRepr_ConstructiveGeometryRepresentation) aCRepr =
Handle(StepRepr_ConstructiveGeometryRepresentation)::DownCast(i == 1 ? theCGRR->Rep1() : theCGRR->Rep2() );
if(aCRepr.IsNull())
continue;
if(mySRContext.IsNull() || aCRepr->ContextOfItems() != mySRContext->ContextOfItems())
{
PrepareUnits(aCRepr,theTP);
resetUnits = Standard_True;
}
Standard_Integer j =1;
Handle(StepGeom_Axis2Placement3d) anAxis1;
Handle(StepGeom_Axis2Placement3d) anAxis2;
for( ; j <= 2; j++ )
{
Handle(StepRepr_RepresentationItem) anItem = aCRepr->ItemsValue(j);
Handle(StepGeom_Axis2Placement3d) aStepAxis =
Handle(StepGeom_Axis2Placement3d)::DownCast(anItem);
if( !aStepAxis.IsNull())
{
Handle(Geom_Axis2Placement) anAxis = StepToGeom::MakeAxis2Placement (aStepAxis);
if(anAxis.IsNull())
continue;
Handle(Geom_Plane) aPlane = new Geom_Plane(gp_Ax3(anAxis->Ax2()));
TopoDS_Face aPlaneFace;
aB.MakeFace(aPlaneFace, aPlane, Precision::Confusion());
Handle(TransferBRep_ShapeBinder) axisbinder = new TransferBRep_ShapeBinder (aPlaneFace);
theTP->Bind(aStepAxis, axisbinder);
aB.Add(aComp, aPlaneFace);
}
}
}
shbinder = new TransferBRep_ShapeBinder (aComp);
mySRContext = oldSRContext;
if(oldSRContext.IsNull() || resetUnits)
PrepareUnits(oldSRContext,theTP);
theTP->Bind(theCGRR, shbinder);
return shbinder;
}
//=======================================================================
//function : IsNeedRepresentation
//purpose :

View File

@@ -45,6 +45,7 @@ class StepRepr_MappedItem;
class StepShape_FaceSurface;
class TopoDS_Shell;
class TopoDS_Compound;
class StepRepr_ConstructiveGeometryRepresentationRelationship;
class STEPControl_ActorRead;
@@ -136,6 +137,9 @@ protected:
//! Transfers FaceSurface entity
Standard_EXPORT Handle(TransferBRep_ShapeBinder) TransferEntity (const Handle(StepShape_FaceSurface)& fs, const Handle(Transfer_TransientProcess)& TP);
Handle(TransferBRep_ShapeBinder) TransferEntity( const Handle(StepRepr_ConstructiveGeometryRepresentationRelationship)& theCGRR,
const Handle(Transfer_TransientProcess)& theTP);
//! Tranlates file by old way when CDSR are roots . Acts only if "read.step.product_mode" is equal Off.
Standard_EXPORT Handle(TransferBRep_ShapeBinder) OldWay (const Handle(Standard_Transient)& start, const Handle(Transfer_TransientProcess)& TP);

View File

@@ -199,6 +199,16 @@ STEPControl_Controller::STEPControl_Controller ()
Interface_Static::Init("step", "read.step.all.shapes", '&', "eval On");
Interface_Static::SetIVal("read.step.all.shapes", 0);
// Mode for reading constructive geometry representation relationship to read
//StepRepr_ConstructiveGeometryRepresentation method implemented only for StepGeom_MakeAxis2Placement3d
//for axis placements representing axis for suplemented geometry. Axis placements are translated to planar faces with CS
//equal to translated axis placements
Interface_Static::Init("step","read.step.constructivegeom.relationship",'e',"");
Interface_Static::Init("step","read.step.constructivegeom.relationship",'&',"enum 0");
Interface_Static::Init("step","read.step.constructivegeom.relationship",'&',"eval OFF");
Interface_Static::Init("step","read.step.constructivegeom.relationship",'&',"eval ON");
Interface_Static::SetCVal("read.step.constructivegeom.relationship","OFF");
init = Standard_True;
}