mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-01 17:36:21 +03:00
Data Exchange - Losing attributes on NonManifold STEP #284
Move step related processing from XSBase to STP module. Added history apply after reading of NonManifold
This commit is contained in:
parent
a0401c7872
commit
dbba6f1289
@ -45,9 +45,11 @@
|
||||
#include <STEPSelections_SelectForTransfer.hxx>
|
||||
#include <STEPSelections_SelectGSCurves.hxx>
|
||||
#include <STEPSelections_SelectInstances.hxx>
|
||||
#include <ShapeUpgrade_RemoveLocations.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <Transfer_ActorOfTransientProcess.hxx>
|
||||
#include <XSAlgo.hxx>
|
||||
#include <XSAlgo_ShapeProcessor.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(STEPControl_Controller,XSControl_Controller)
|
||||
@ -437,10 +439,22 @@ IFSelect_ReturnStatus STEPControl_Controller::TransferWriteShape
|
||||
Handle(STEPControl_ActorWrite) ActWrite =
|
||||
Handle(STEPControl_ActorWrite)::DownCast(myAdaptorWrite);
|
||||
// A PRESENT ON PASSE PAR LE PROFILE
|
||||
Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(model);
|
||||
if (!ActWrite.IsNull())
|
||||
ActWrite->SetGroupMode (Handle(StepData_StepModel)::DownCast(model)->InternalParameters.WriteAssembly);
|
||||
|
||||
return XSControl_Controller::TransferWriteShape(shape, FP, model, modeshape, theProgress);
|
||||
ActWrite->SetGroupMode (aModel->InternalParameters.WriteAssembly);
|
||||
TopoDS_Shape aShape = shape;
|
||||
TopTools_DataMapOfShapeShape aModifedMap;
|
||||
if (aModel->InternalParameters.WriteNonmanifold)
|
||||
{
|
||||
ShapeUpgrade_RemoveLocations aRemLoc;
|
||||
aRemLoc.SetRemoveLevel(TopAbs_COMPOUND);
|
||||
aRemLoc.Remove(aShape);
|
||||
aShape = aRemLoc.GetResult();
|
||||
aModifedMap = aRemLoc.GetModifiedShapesMap();
|
||||
}
|
||||
const IFSelect_ReturnStatus aStatus = XSControl_Controller::TransferWriteShape(aShape, FP, model, modeshape, theProgress);
|
||||
XSAlgo_ShapeProcessor::MergeShapeTransferInfo(FP, aModifedMap, Handle(ShapeExtend_MsgRegistrator)());
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
Standard_Boolean STEPControl_Controller::Init ()
|
||||
|
@ -57,24 +57,21 @@ public:
|
||||
//! Returns modified shape obtained from initial shape.
|
||||
TopoDS_Shape ModifiedShape (const TopoDS_Shape& theInitShape) const;
|
||||
|
||||
//! Returns map of modified shapes.
|
||||
const TopTools_DataMapOfShapeShape& GetModifiedShapesMap() const { return myMapNewShapes; }
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(ShapeUpgrade_RemoveLocations, Standard_Transient)
|
||||
|
||||
protected:
|
||||
private:
|
||||
Standard_EXPORT Standard_Boolean MakeNewShape(const TopoDS_Shape& theShape,
|
||||
const TopoDS_Shape& theAncShape,
|
||||
TopoDS_Shape& theNewShape,
|
||||
const Standard_Boolean theRemoveLoc);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(ShapeUpgrade_RemoveLocations,Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Standard_EXPORT Standard_Boolean MakeNewShape (const TopoDS_Shape& theShape, const TopoDS_Shape& theAncShape, TopoDS_Shape& theNewShape, const Standard_Boolean theRemoveLoc);
|
||||
|
||||
TopAbs_ShapeEnum myLevelRemoving;
|
||||
TopoDS_Shape myShape;
|
||||
TopTools_DataMapOfShapeShape myMapNewShapes;
|
||||
TopAbs_ShapeEnum myLevelRemoving;
|
||||
TopoDS_Shape myShape;
|
||||
TopTools_DataMapOfShapeShape myMapNewShapes;
|
||||
|
||||
|
||||
};
|
||||
|
@ -160,24 +160,22 @@ void XSAlgo_ShapeProcessor::addMessages(const Handle(ShapeExtend_MsgRegistrator)
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_TransientProcess)& theTransientProcess,
|
||||
const Standard_Integer theFirstTPItemIndex) const
|
||||
void XSAlgo_ShapeProcessor::MergeShapeTransferInfo(
|
||||
const Handle(Transfer_TransientProcess)& theTransientProcess,
|
||||
const TopTools_DataMapOfShapeShape& theModifiedShapesMap,
|
||||
const Standard_Integer theFirstTPItemIndex,
|
||||
Handle(ShapeExtend_MsgRegistrator) theMessages)
|
||||
{
|
||||
if (myContext.IsNull())
|
||||
if (theModifiedShapesMap.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const TopTools_DataMapOfShapeShape& aShapesMap = myContext->Map();
|
||||
Handle(ShapeExtend_MsgRegistrator) aMessages = myContext->Messages();
|
||||
if (aShapesMap.IsEmpty() && (aMessages.IsNull() || aMessages->MapShape().IsEmpty()))
|
||||
const bool aToPrint = !theMessages.IsNull() && !theMessages->MapShape().IsEmpty();
|
||||
for (Standard_Integer i = std::max(theFirstTPItemIndex, 1); i <= theTransientProcess->NbMapped();
|
||||
++i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Standard_Integer i = std::max(theFirstTPItemIndex, 1); i <= theTransientProcess->NbMapped(); ++i)
|
||||
{
|
||||
Handle(TransferBRep_ShapeBinder) aShapeBinder = Handle(TransferBRep_ShapeBinder)::DownCast(theTransientProcess->MapItem(i));
|
||||
Handle(TransferBRep_ShapeBinder) aShapeBinder =
|
||||
Handle(TransferBRep_ShapeBinder)::DownCast(theTransientProcess->MapItem(i));
|
||||
if (aShapeBinder.IsNull() || aShapeBinder->Result().IsNull())
|
||||
{
|
||||
continue;
|
||||
@ -185,17 +183,17 @@ void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_TransientPro
|
||||
|
||||
const TopoDS_Shape anOriginalShape = aShapeBinder->Result();
|
||||
|
||||
if (aShapesMap.IsBound(anOriginalShape))
|
||||
if (theModifiedShapesMap.IsBound(anOriginalShape))
|
||||
{
|
||||
aShapeBinder->SetResult(aShapesMap.Find(anOriginalShape));
|
||||
aShapeBinder->SetResult(theModifiedShapesMap.Find(anOriginalShape));
|
||||
}
|
||||
else if (!anOriginalShape.Location().IsIdentity())
|
||||
{
|
||||
TopLoc_Location aNullLoc;
|
||||
TopoDS_Shape aTemporaryShape = anOriginalShape.Located(aNullLoc);
|
||||
if (aShapesMap.IsBound(aTemporaryShape))
|
||||
if (theModifiedShapesMap.IsBound(aTemporaryShape))
|
||||
{
|
||||
aShapeBinder->SetResult(aShapesMap.Find(aTemporaryShape));
|
||||
aShapeBinder->SetResult(theModifiedShapesMap.Find(aTemporaryShape));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -206,10 +204,10 @@ void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_TransientPro
|
||||
// Remember modifications.
|
||||
for (TopExp_Explorer anExpSE(anOriginalShape, TopAbs_EDGE); anExpSE.More(); anExpSE.Next())
|
||||
{
|
||||
if (aShapesMap.IsBound(anExpSE.Current()))
|
||||
if (theModifiedShapesMap.IsBound(anExpSE.Current()))
|
||||
{
|
||||
aHasModifiedEdges = Standard_True;
|
||||
TopoDS_Shape aModifiedShape = aShapesMap.Find(anExpSE.Current());
|
||||
TopoDS_Shape aModifiedShape = theModifiedShapesMap.Find(anExpSE.Current());
|
||||
aReShaper.Replace(anExpSE.Current(), aModifiedShape);
|
||||
}
|
||||
}
|
||||
@ -222,50 +220,76 @@ void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_TransientPro
|
||||
}
|
||||
|
||||
// update messages
|
||||
addMessages(aMessages, anOriginalShape, aShapeBinder);
|
||||
if (aToPrint)
|
||||
{
|
||||
addMessages(theMessages, anOriginalShape, aShapeBinder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_FinderProcess)& theFinderProcess) const
|
||||
void XSAlgo_ShapeProcessor::MergeTransferInfo(
|
||||
const Handle(Transfer_TransientProcess)& theTransientProcess,
|
||||
const Standard_Integer theFirstTPItemIndex) const
|
||||
{
|
||||
if (myContext.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
return MergeShapeTransferInfo(theTransientProcess,
|
||||
myContext->Map(),
|
||||
theFirstTPItemIndex,
|
||||
myContext->Messages());
|
||||
}
|
||||
|
||||
const TopTools_DataMapOfShapeShape& aShapesMap = myContext->Map();
|
||||
Handle(ShapeExtend_MsgRegistrator) aMessages = myContext->Messages();
|
||||
//=============================================================================
|
||||
|
||||
for (TopTools_DataMapIteratorOfDataMapOfShapeShape ShapeShapeIterator(aShapesMap); ShapeShapeIterator.More();
|
||||
void XSAlgo_ShapeProcessor::MergeShapeTransferInfo(
|
||||
const Handle(Transfer_FinderProcess)& theFinderProcess,
|
||||
const TopTools_DataMapOfShapeShape& theModifiedShapesMap,
|
||||
Handle(ShapeExtend_MsgRegistrator) theMessages)
|
||||
{
|
||||
if (theModifiedShapesMap.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
const bool aToPrint = !theMessages.IsNull() && !theMessages->MapShape().IsEmpty();
|
||||
|
||||
for (TopTools_DataMapIteratorOfDataMapOfShapeShape ShapeShapeIterator(theModifiedShapesMap);
|
||||
ShapeShapeIterator.More();
|
||||
ShapeShapeIterator.Next())
|
||||
{
|
||||
const TopoDS_Shape anOriginalShape = ShapeShapeIterator.Key();
|
||||
const TopoDS_Shape aResultShape = ShapeShapeIterator.Value();
|
||||
const TopoDS_Shape anOriginalShape = ShapeShapeIterator.Key();
|
||||
const TopoDS_Shape aResultShape = ShapeShapeIterator.Value();
|
||||
|
||||
Handle(TransferBRep_ShapeMapper) aResultMapper = TransferBRep::ShapeMapper(theFinderProcess, aResultShape);
|
||||
Handle(Transfer_Binder) aResultBinder = theFinderProcess->Find(aResultMapper);
|
||||
Handle(TransferBRep_ShapeMapper) aResultMapper =
|
||||
TransferBRep::ShapeMapper(theFinderProcess, aResultShape);
|
||||
Handle(Transfer_Binder) aResultBinder = theFinderProcess->Find(aResultMapper);
|
||||
|
||||
if (aResultBinder.IsNull())
|
||||
{
|
||||
aResultBinder = new TransferBRep_ShapeBinder(aResultShape);
|
||||
//if <orig> shape was split, put entities corresponding to new shapes
|
||||
// into Transfer_TransientListBinder.
|
||||
// if <orig> shape was split, put entities corresponding to new shapes
|
||||
// into Transfer_TransientListBinder.
|
||||
if (anOriginalShape.ShapeType() > aResultShape.ShapeType())
|
||||
{
|
||||
TopoDS_Shape aSubShape;
|
||||
Handle(Transfer_TransientListBinder) aTransientListBinder = new Transfer_TransientListBinder;
|
||||
for (TopoDS_Iterator aSubShapeIter(aResultShape); aSubShapeIter.More(); aSubShapeIter.Next())
|
||||
Handle(Transfer_TransientListBinder) aTransientListBinder =
|
||||
new Transfer_TransientListBinder;
|
||||
for (TopoDS_Iterator aSubShapeIter(aResultShape); aSubShapeIter.More();
|
||||
aSubShapeIter.Next())
|
||||
{
|
||||
const TopoDS_Shape aCurrentSubShape = aSubShapeIter.Value();
|
||||
Handle(Transfer_Finder) aSubShapeMapper = TransferBRep::ShapeMapper(theFinderProcess, aCurrentSubShape);
|
||||
Handle(Transfer_Finder) aSubShapeMapper =
|
||||
TransferBRep::ShapeMapper(theFinderProcess, aCurrentSubShape);
|
||||
if (aSubShapeMapper.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Handle(Standard_Transient) aTransientResult = theFinderProcess->FindTransient(aSubShapeMapper);
|
||||
Handle(Standard_Transient) aTransientResult =
|
||||
theFinderProcess->FindTransient(aSubShapeMapper);
|
||||
if (aTransientResult.IsNull())
|
||||
{
|
||||
continue;
|
||||
@ -284,8 +308,9 @@ void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_FinderProces
|
||||
}
|
||||
}
|
||||
|
||||
Handle(TransferBRep_ShapeMapper) anOriginalMapper = TransferBRep::ShapeMapper(theFinderProcess, anOriginalShape);
|
||||
Handle(Transfer_Binder) anOriginalBinder = theFinderProcess->Find(anOriginalMapper);
|
||||
Handle(TransferBRep_ShapeMapper) anOriginalMapper =
|
||||
TransferBRep::ShapeMapper(theFinderProcess, anOriginalShape);
|
||||
Handle(Transfer_Binder) anOriginalBinder = theFinderProcess->Find(anOriginalMapper);
|
||||
if (anOriginalBinder.IsNull())
|
||||
{
|
||||
theFinderProcess->Bind(anOriginalMapper, aResultBinder);
|
||||
@ -296,12 +321,26 @@ void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_FinderProces
|
||||
}
|
||||
|
||||
// update messages
|
||||
addMessages(aMessages, anOriginalShape, aResultBinder);
|
||||
if (aToPrint)
|
||||
{
|
||||
addMessages(theMessages, anOriginalShape, aResultBinder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void XSAlgo_ShapeProcessor::MergeTransferInfo(const Handle(Transfer_FinderProcess)& theFinderProcess) const
|
||||
{
|
||||
if (myContext.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
return MergeShapeTransferInfo(theFinderProcess, myContext->Map(), myContext->Messages());
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
TopoDS_Edge XSAlgo_ShapeProcessor::MakeEdgeOnCurve(const TopoDS_Edge& aSourceEdge)
|
||||
{
|
||||
TopoDS_Edge aResult;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <DE_ShapeFixParameters.hxx>
|
||||
#include <ShapeProcess.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
@ -134,6 +135,27 @@ public:
|
||||
//! value associated with the key "xstep.cascade.unit".
|
||||
Standard_EXPORT static void PrepareForTransfer();
|
||||
|
||||
//! Merge the results of the shape processing with the finder process.
|
||||
//! @param theTransientProcess Transfer process to merge with.
|
||||
//! @param theModifiedShapesMap Map of modified shapes.
|
||||
//! @param theFirstTPItemIndex Index of the first item in the transfer process to merge with.
|
||||
//! @param theMessages Messages to add.
|
||||
Standard_EXPORT static void MergeShapeTransferInfo(
|
||||
const Handle(Transfer_TransientProcess)& theFinderProcess,
|
||||
const TopTools_DataMapOfShapeShape& theModifiedShapesMap,
|
||||
const Standard_Integer theFirstTPItemIndex,
|
||||
Handle(ShapeExtend_MsgRegistrator) theMessages);
|
||||
|
||||
//! Merge the results of the shape processing with the transfer process.
|
||||
//! @param theTransientProcess Transfer process to merge with.
|
||||
//! @param theModifiedShapesMap Map of modified shapes.
|
||||
//! @param theFirstTPItemIndex Index of the first item in the transfer process to merge with.
|
||||
//! @param theMessages Messages to add.
|
||||
Standard_EXPORT static void MergeShapeTransferInfo(
|
||||
const Handle(Transfer_FinderProcess)& theTransientProcess,
|
||||
const TopTools_DataMapOfShapeShape& theModifiedShapesMap,
|
||||
Handle(ShapeExtend_MsgRegistrator) theMessages);
|
||||
|
||||
private:
|
||||
//! Initialize the context with the specified shape.
|
||||
//! @param theShape Shape to process.
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <XSControl_Controller.hxx>
|
||||
#include <XSControl_TransferWriter.hxx>
|
||||
#include <XSControl_Utils.hxx>
|
||||
#include <ShapeUpgrade_RemoveLocations.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XSControl_TransferWriter,Standard_Transient)
|
||||
|
||||
@ -141,14 +140,6 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape
|
||||
if (theModel.IsNull()) return IFSelect_RetVoid;
|
||||
|
||||
TopoDS_Shape aShape = theShape;
|
||||
Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
|
||||
if (isNMMode)
|
||||
{
|
||||
ShapeUpgrade_RemoveLocations aRemLoc;
|
||||
aRemLoc.SetRemoveLevel(TopAbs_COMPOUND);
|
||||
aRemLoc.Remove(aShape);
|
||||
aShape = aRemLoc.GetResult();
|
||||
}
|
||||
|
||||
if (myTransferWriter.IsNull()) myTransferWriter = new Transfer_FinderProcess;
|
||||
// effacer l actor : Controller s en charge
|
||||
|
30
tests/bugs/step/bug33815
Normal file
30
tests/bugs/step/bug33815
Normal file
@ -0,0 +1,30 @@
|
||||
puts "===================================="
|
||||
puts "0033815: Data Exchange, Step Export - No names in STEP file when writing in non-manifold mode"
|
||||
puts "===================================="
|
||||
puts ""
|
||||
|
||||
pload OCAF
|
||||
Close D -silent
|
||||
|
||||
XNewDoc D
|
||||
box box 1 1 1
|
||||
XAddShape D box
|
||||
|
||||
param write.step.nonmanifold 1
|
||||
|
||||
SetName D 0:1:1:1 "a'''\\b\n\t\\c\\\\\\\\"
|
||||
set original_name [GetName D 0:1:1:1]
|
||||
|
||||
WriteStep D "$imagedir/${casename}.stp"
|
||||
Close D
|
||||
|
||||
ReadStep D "$imagedir/${casename}.stp"
|
||||
set imported_name [GetName D 0:1:1:1]
|
||||
|
||||
file delete "$imagedir/${casename}.stp"
|
||||
|
||||
if {$original_name != $imported_name} {
|
||||
puts "Error: 'Incorrect exporting name: $original_name != $imported_name"
|
||||
}
|
||||
|
||||
Close D
|
Loading…
x
Reference in New Issue
Block a user