1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0023638: Data Exchange - Reading IGES file produced invalid shape

Removed double healing of Iges group entities
Added ShapeBuild_ReShape member to the IGESData_IGESModel class, shapes which are registered in ShapeBuild_ReShape class does not process to healing
This commit is contained in:
dorlov 2023-01-13 13:25:17 +00:00 committed by vglukhik
parent ffce0d66bb
commit b6388d8b34
7 changed files with 152 additions and 91 deletions

View File

@ -23,6 +23,7 @@
#include <Interface_Macros.hxx> #include <Interface_Macros.hxx>
#include <Interface_Static.hxx> #include <Interface_Static.hxx>
#include <Message_Msg.hxx> #include <Message_Msg.hxx>
#include <ShapeBuild_ReShape.hxx>
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <TCollection_HAsciiString.hxx> #include <TCollection_HAsciiString.hxx>
@ -47,6 +48,7 @@ void IGESData_VerifyDate
IGESData_IGESModel::IGESData_IGESModel () IGESData_IGESModel::IGESData_IGESModel ()
{ {
thestart = new TColStd_HSequenceOfHAsciiString(); thestart = new TColStd_HSequenceOfHAsciiString();
myReShape = new ShapeBuild_ReShape();
// thecheckstx = new Interface_Check; // thecheckstx = new Interface_Check;
// thechecksem = new Interface_Check; // thechecksem = new Interface_Check;
} }
@ -62,6 +64,7 @@ void IGESData_IGESModel::ClearHeader ()
IGESData_GlobalSection newheader; // Un peu brutal, certes IGESData_GlobalSection newheader; // Un peu brutal, certes
theheader = newheader; theheader = newheader;
thestart = new TColStd_HSequenceOfHAsciiString(); thestart = new TColStd_HSequenceOfHAsciiString();
myReShape = new ShapeBuild_ReShape();
} }

View File

@ -22,10 +22,10 @@
class IGESData_IGESEntity; class IGESData_IGESEntity;
class Interface_Check; class Interface_Check;
class ShapeBuild_ReShape;
class Standard_Transient; class Standard_Transient;
class TCollection_HAsciiString; class TCollection_HAsciiString;
class IGESData_IGESModel; class IGESData_IGESModel;
DEFINE_STANDARD_HANDLE(IGESData_IGESModel, Interface_InterfaceModel) DEFINE_STANDARD_HANDLE(IGESData_IGESModel, Interface_InterfaceModel)
@ -151,8 +151,11 @@ public:
//! i.e. a string "Dnn" with nn = directory entry number (2*N-1) //! i.e. a string "Dnn" with nn = directory entry number (2*N-1)
Standard_EXPORT Handle(TCollection_HAsciiString) StringLabel (const Handle(Standard_Transient)& ent) const Standard_OVERRIDE; Standard_EXPORT Handle(TCollection_HAsciiString) StringLabel (const Handle(Standard_Transient)& ent) const Standard_OVERRIDE;
//! Gets ReShape used to store a model's shapes changes
const Handle(ShapeBuild_ReShape)& ReShape() const { return myReShape; }
//! Sets ReShape used to store a history of changes of the model's shapes
void SetReShape(const Handle(ShapeBuild_ReShape)& theReShape) { myReShape = theReShape; }
DEFINE_STANDARD_RTTIEXT(IGESData_IGESModel,Interface_InterfaceModel) DEFINE_STANDARD_RTTIEXT(IGESData_IGESModel,Interface_InterfaceModel)
@ -166,7 +169,7 @@ private:
Handle(TColStd_HSequenceOfHAsciiString) thestart; Handle(TColStd_HSequenceOfHAsciiString) thestart;
IGESData_GlobalSection theheader; IGESData_GlobalSection theheader;
Handle(ShapeBuild_ReShape) myReShape;
}; };

View File

@ -131,8 +131,6 @@ static void TrimTolerances (const TopoDS_Shape& shape,
} }
} }
//======================================================================= //=======================================================================
//function : Transfer //function : Transfer
//purpose : //purpose :
@ -196,10 +194,11 @@ Handle(Transfer_Binder) IGESToBRep_Actor::Transfer
// fixing shape // fixing shape
Handle(Standard_Transient) info; Handle(Standard_Transient) info;
shape = XSAlgo::AlgoContainer()->ProcessShape( shape, theeps, CAS.GetMaxTol(), shape = XSAlgo::AlgoContainer()->ProcessShape(shape, theeps, CAS.GetMaxTol(),
"read.iges.resource.name", "read.iges.resource.name",
"read.iges.sequence", info, "read.iges.sequence",
aPS.Next()); info, mymodel->ReShape(),
aPS.Next());
XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems); XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
} }

View File

@ -112,18 +112,20 @@ Standard_Boolean ShapeFix_Shape::Perform(const Message_ProgressRange& theProgres
TopLoc_Location nullLoc,L; TopLoc_Location nullLoc,L;
L = myShape.Location(); L = myShape.Location();
TopoDS_Shape aShapeNullLoc = myShape; TopoDS_Shape aShapeNullLoc = myShape;
const Standard_Boolean aIsRecorded = Context()->IsNewShape(myShape);
aShapeNullLoc.Location(nullLoc); aShapeNullLoc.Location(nullLoc);
if(myMapFixingShape.Contains(aShapeNullLoc)) { if(aIsRecorded || myMapFixingShape.Contains(aShapeNullLoc))
{
myShape.Location(L, Standard_False); myShape.Location(L, Standard_False);
myResult = Context()->Apply(myShape); myResult = Context()->Apply(myShape);
status = Standard_True; status = Standard_True;
return status; return status;
} }
else myMapFixingShape.Add(aShapeNullLoc); myMapFixingShape.Add(aShapeNullLoc);
//--------------------------------------- //---------------------------------------
myShape.Location(L, Standard_False); myShape.Location(L, Standard_False);
TopoDS_Shape S = Context()->Apply(myShape); TopoDS_Shape S = Context()->Apply(myShape);
if ( NeedFix ( myFixVertexPositionMode ) ) if (NeedFix(myFixVertexPositionMode))
ShapeFix::FixVertexPosition(S,Precision(),Context()); ShapeFix::FixVertexPosition(S,Precision(),Context());
st = S.ShapeType(); st = S.ShapeType();

View File

@ -82,103 +82,131 @@ void XSAlgo_AlgoContainer::PrepareForTransfer() const
//======================================================================= //=======================================================================
//function : ProcessShape //function : ProcessShape
//purpose : //purpose :
//======================================================================= //=======================================================================
TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& theShape,
TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape, const Standard_Real thePrec,
const Standard_Real Prec, const Standard_Real theMaxTol,
const Standard_Real maxTol, const Standard_CString thePrscfile,
const Standard_CString prscfile, const Standard_CString thePseq,
const Standard_CString pseq, Handle(Standard_Transient)& theInfo,
Handle(Standard_Transient)& info, const Handle(ShapeBuild_ReShape)& theReShape,
const Message_ProgressRange& theProgress, const Message_ProgressRange& theProgress,
const Standard_Boolean NonManifold) const const Standard_Boolean theNonManifold) const
{ {
if ( shape.IsNull() ) return shape; if (theShape.IsNull())
Handle(ShapeProcess_ShapeContext) context = Handle(ShapeProcess_ShapeContext)::DownCast(info);
if ( context.IsNull() )
{ {
Standard_CString rscfile = Interface_Static::CVal(prscfile); return theShape;
if (rscfile != nullptr && strlen (rscfile) == 0) }
Handle(ShapeProcess_ShapeContext) aContext = Handle(ShapeProcess_ShapeContext)::DownCast(theInfo);
if (aContext.IsNull())
{
Standard_CString aRscfile = Interface_Static::CVal(thePrscfile);
if (aRscfile != nullptr && strlen(aRscfile) == 0)
{ {
context = new ShapeProcess_ShapeContext(shape, nullptr); aContext = new ShapeProcess_ShapeContext(theShape, nullptr);
Interface_Static::FillMap(context->ResourceManager()->GetMap()); Interface_Static::FillMap(aContext->ResourceManager()->GetMap());
} }
else else
{ {
if (!rscfile) if (!aRscfile)
rscfile = prscfile; aRscfile = thePrscfile;
context = new ShapeProcess_ShapeContext(shape, rscfile); aContext = new ShapeProcess_ShapeContext(theShape, aRscfile);
} }
context->SetDetalisation(TopAbs_EDGE); aContext->SetDetalisation(TopAbs_EDGE);
} }
context->SetNonManifold(NonManifold); aContext->SetNonManifold(theNonManifold);
info = context; theInfo = aContext;
Standard_CString seq = Interface_Static::CVal ( pseq ); Standard_CString aSeq = Interface_Static::CVal(thePseq);
if ( ! seq ) seq = pseq; if (!aSeq) aSeq = thePseq;
// if resource file is not loaded or does not define <seq>.exec.op, // if resource file is not loaded or does not define <seq>.exec.op,
// do default fixes // do default fixes
Handle(Resource_Manager) rsc = context->ResourceManager(); Handle(Resource_Manager) aRsc = aContext->ResourceManager();
TCollection_AsciiString str ( seq ); TCollection_AsciiString aStr(aSeq);
str += ".exec.op"; aStr += ".exec.op";
if ( ! rsc->Find ( str.ToCString() ) ) { if (!aRsc->Find(aStr.ToCString()))
{
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
{ {
static Standard_Integer time = 0; static Standard_Integer aTime = 0;
if ( ! time ) if (!aTime)
std::cout << "Warning: XSAlgo_AlgoContainer::ProcessShape(): Sequence " << str.ToCString() << std::cout << "Warning: XSAlgo_AlgoContainer::ProcessShape(): Sequence " << aStr.ToCString() <<
" is not defined in " << prscfile << " resource; do default processing" << std::endl; " is not defined in " << thePrscfile << " resource; do default processing" << std::endl;
time++; aTime++;
} }
#endif #endif
// if reading, do default ShapeFix // if reading, do default ShapeFix
if ( ! strncmp ( pseq, "read.", 5 ) ) { if (!strncmp(thePseq, "read.", 5))
{
try { try {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
Handle(ShapeExtend_MsgRegistrator) msg = new ShapeExtend_MsgRegistrator; Handle(ShapeExtend_MsgRegistrator) aMsg = new ShapeExtend_MsgRegistrator;
Handle(ShapeFix_Shape) sfs = ShapeAlgo::AlgoContainer()->ToolContainer()->FixShape(); Handle(ShapeFix_Shape) aSfs = ShapeAlgo::AlgoContainer()->ToolContainer()->FixShape();
sfs->Init ( shape ); aSfs->Init(theShape);
sfs->SetMsgRegistrator ( msg ); aSfs->SetMsgRegistrator(aMsg);
sfs->SetPrecision ( Prec ); aSfs->SetPrecision(thePrec);
sfs->SetMaxTolerance ( maxTol ); aSfs->SetMaxTolerance(theMaxTol);
sfs->FixFaceTool()->FixWireTool()->FixSameParameterMode() = Standard_False; aSfs->FixFaceTool()->FixWireTool()->FixSameParameterMode() = Standard_False;
sfs->FixSolidTool()->CreateOpenSolidMode() = Standard_False; aSfs->FixSolidTool()->CreateOpenSolidMode() = Standard_False;
sfs->Perform(theProgress); aSfs->SetContext(theReShape);
aSfs->Perform(theProgress);
TopoDS_Shape S = sfs->Shape(); TopoDS_Shape aShape = aSfs->Shape();
if ( ! S.IsNull() && S != shape ) { if (!aShape.IsNull() && aShape != theShape)
context->RecordModification ( sfs->Context(), msg ); {
context->SetResult ( S ); aContext->RecordModification(aSfs->Context(), aMsg);
} aContext->SetResult(aShape);
}
} }
catch (Standard_Failure const& anException) { catch (Standard_Failure const& anException)
{
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
std::cout << "Error: XSAlgo_AlgoContainer::ProcessShape(): Exception in ShapeFix::Shape" << std::endl; std::cout << "Error: XSAlgo_AlgoContainer::ProcessShape(): Exception in ShapeFix::Shape" << std::endl;
anException.Print(std::cout); std::cout << std::endl; anException.Print(std::cout); std::cout << std::endl;
#endif #endif
(void)anException; (void)anException;
} }
return context->Result(); return aContext->Result();
} }
// for writing, define default sequence of DirectFaces // for writing, define default sequence of DirectFaces
else if ( ! strncmp ( pseq, "write.", 6 ) ) { else if (!strncmp(thePseq, "write.", 6))
rsc->SetResource ( str.ToCString(), "DirectFaces" ); {
aRsc->SetResource(aStr.ToCString(), "DirectFaces");
} }
} }
// Define runtime tolerances and do Shape Processing // Define runtime tolerances and do Shape Processing
rsc->SetResource ( "Runtime.Tolerance", Prec ); aRsc->SetResource("Runtime.Tolerance", thePrec);
rsc->SetResource ( "Runtime.MaxTolerance", maxTol ); aRsc->SetResource("Runtime.MaxTolerance", theMaxTol);
if ( !ShapeProcess::Perform(context, seq, theProgress) ) if (!ShapeProcess::Perform(aContext, aSeq, theProgress))
return shape; // return original shape return theShape; // return original shape
return context->Result(); return aContext->Result();
} }
//=======================================================================
//function : ProcessShape
//purpose :
//=======================================================================
TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& theShape,
const Standard_Real thePrec,
const Standard_Real theMaxTol,
const Standard_CString thePrscfile,
const Standard_CString thePseq,
Handle(Standard_Transient)& theInfo,
const Message_ProgressRange& theProgress,
const Standard_Boolean theNonManifold) const
{
Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape();
return ProcessShape(theShape, thePrec, theMaxTol, thePrscfile,
thePseq, theInfo, aReShape, theProgress,
theNonManifold);
}
//======================================================================= //=======================================================================
//function : PerformFixShape //function : PerformFixShape
//purpose : //purpose :

View File

@ -23,6 +23,7 @@
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <Message_ProgressRange.hxx> #include <Message_ProgressRange.hxx>
class ShapeBuild_ReShape;
class XSAlgo_ToolContainer; class XSAlgo_ToolContainer;
class TopoDS_Shape; class TopoDS_Shape;
class TopoDS_Edge; class TopoDS_Edge;
@ -30,7 +31,6 @@ class TopoDS_Face;
class Transfer_TransientProcess; class Transfer_TransientProcess;
class Transfer_FinderProcess; class Transfer_FinderProcess;
class XSAlgo_AlgoContainer; class XSAlgo_AlgoContainer;
DEFINE_STANDARD_HANDLE(XSAlgo_AlgoContainer, Standard_Transient) DEFINE_STANDARD_HANDLE(XSAlgo_AlgoContainer, Standard_Transient)
@ -55,16 +55,44 @@ public:
Standard_EXPORT virtual void PrepareForTransfer() const; Standard_EXPORT virtual void PrepareForTransfer() const;
//! Does shape processing with specified tolerances //! Does shape processing with specified tolerances
//! and returns resulting shape and associated information //! @param[in] theShape shape to process
//! in the form of Transient. //! @param[in] thePrec basic precision and tolerance
//! This information should be later transmitted to //! @param[in] theMaxTol maximum allowed tolerance
//! MergeTransferInfo in order to be recorded in the //! @param[in] thePrscfile name of the resource file
//! translation map //! @param[in] thePseq name of the sequence of operators defined in the resource file for Shape Processing
Standard_EXPORT virtual TopoDS_Shape ProcessShape ( //! @param[out] theInfo information to be recorded in the translation map
const TopoDS_Shape& shape, const Standard_Real Prec, const Standard_Real MaxTol, //! @param[in] theProgress progress indicator
const Standard_CString rscfile, const Standard_CString seq, Handle(Standard_Transient)& info, //! @param[in] theNonManifold flag to proceed with non-manifold topology
const Message_ProgressRange& theProgress = Message_ProgressRange(), //! @return the processed shape
const Standard_Boolean NonManifold = Standard_False) const; Standard_EXPORT virtual TopoDS_Shape ProcessShape (const TopoDS_Shape& theShape,
const Standard_Real thePrec,
const Standard_Real theMaxTol,
const Standard_CString thePrscfile,
const Standard_CString thePseq,
Handle(Standard_Transient)& theInfo,
const Message_ProgressRange& theProgress = Message_ProgressRange(),
const Standard_Boolean theNonManifold = Standard_False) const;
//! Does shape processing with specified tolerances
//! @param[in] theShape shape to process
//! @param[in] thePrec basic precision and tolerance
//! @param[in] theMaxTol maximum allowed tolerance
//! @param[in] thePrscfile name of the resource file
//! @param[in] thePseq name of the sequence of operators defined in the resource file for Shape Processing
//! @param[out] theInfo information to be recorded in the translation map
//! @param[in] theReShape tool to record the modifications of input shape
//! @param[in] theProgress progress indicator
//! @param[in] theNonManifold flag to proceed with non-manifold topology
//! @return the processed shape
Standard_EXPORT virtual TopoDS_Shape ProcessShape(const TopoDS_Shape& theShape,
const Standard_Real thePrec,
const Standard_Real theMaxTol,
const Standard_CString thePrscfile,
const Standard_CString thePseq,
Handle(Standard_Transient)& theInfo,
const Handle(ShapeBuild_ReShape)& theReShape,
const Message_ProgressRange& theProgress = Message_ProgressRange(),
const Standard_Boolean theNonManifold = Standard_False) const;
//! Checks quality of pcurve of the edge on the given face, //! Checks quality of pcurve of the edge on the given face,
//! and corrects it if necessary. //! and corrects it if necessary.

View File

@ -1,4 +1,4 @@
puts "TODO OCC23638 ALL: Faulty shapes in variables faulty_1 to faulty_" puts "TODO OCC23638 ALL: Faulty shapes in variables faulty_1 to faulty_1"
puts "============" puts "============"
puts "CR23638" puts "CR23638"
@ -8,8 +8,6 @@ puts ""
# Reading IGES file produced invalid shape # Reading IGES file produced invalid shape
####################################################################### #######################################################################
param read.surfacecurve.mode -3
igesread [locate_data_file bug23638_cadbad.igs] result * igesread [locate_data_file bug23638_cadbad.igs] result *
checkshape result checkshape result