mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0026047: Data Exchange - Lost colors for IGES export
- Fix problem with write shape with locations ( IGESCAFControl_Writer.cxx ) - Add support for adding sub-shapes (labels) together with sub-shapes without location ( XCAFDoc_ShapeTool.cxx )
This commit is contained in:
parent
0f5a1a9485
commit
65eed8ff8e
@ -333,7 +333,9 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S,
|
|||||||
Handle(Transfer_FinderProcess) FP = TransferProcess();
|
Handle(Transfer_FinderProcess) FP = TransferProcess();
|
||||||
Handle(IGESData_IGESEntity) ent;
|
Handle(IGESData_IGESEntity) ent;
|
||||||
Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S );
|
Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S );
|
||||||
if ( FP->FindTypedTransient ( mapper, STANDARD_TYPE(IGESData_IGESEntity), ent ) ) {
|
Handle(TransferBRep_ShapeMapper) aNoLocMapper = TransferBRep::ShapeMapper(FP, S.Located(TopLoc_Location()));
|
||||||
|
if ( FP->FindTypedTransient ( mapper, STANDARD_TYPE(IGESData_IGESEntity), ent ) ||
|
||||||
|
FP->FindTypedTransient(aNoLocMapper, STANDARD_TYPE(IGESData_IGESEntity), ent)) {
|
||||||
ent->InitColor ( colent, rank );
|
ent->InitColor ( colent, rank );
|
||||||
Handle(IGESSolid_Face) ent_f = Handle(IGESSolid_Face)::DownCast(ent);
|
Handle(IGESSolid_Face) ent_f = Handle(IGESSolid_Face)::DownCast(ent);
|
||||||
if (!ent_f.IsNull())
|
if (!ent_f.IsNull())
|
||||||
|
@ -491,6 +491,13 @@ TDF_Label XCAFDoc_ShapeTool::addShape (const TopoDS_Shape& S, const Standard_Boo
|
|||||||
{
|
{
|
||||||
TopoDS_Shape aSh = A->GetMap().FindKey(i);
|
TopoDS_Shape aSh = A->GetMap().FindKey(i);
|
||||||
mySubShapes.Bind(aSh,ShapeLabel);
|
mySubShapes.Bind(aSh,ShapeLabel);
|
||||||
|
//if shape has location, make a reference to the same shape without location
|
||||||
|
if (!aSh.Location().IsIdentity()) {
|
||||||
|
TopoDS_Shape S0 = aSh;
|
||||||
|
TopLoc_Location loc;
|
||||||
|
S0.Location(loc);
|
||||||
|
mySubShapes.Bind(S0, ShapeLabel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//mySubShapes.Bind(ShapeLabel,A->GetMap());
|
//mySubShapes.Bind(ShapeLabel,A->GetMap());
|
||||||
}
|
}
|
||||||
@ -1088,19 +1095,7 @@ TDF_Label XCAFDoc_ShapeTool::AddSubShape (const TDF_Label &shapeL,
|
|||||||
const TopoDS_Shape &sub) const
|
const TopoDS_Shape &sub) const
|
||||||
{
|
{
|
||||||
TDF_Label L;
|
TDF_Label L;
|
||||||
if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL))
|
AddSubShape(shapeL, sub, L);
|
||||||
return L;
|
|
||||||
|
|
||||||
if ( FindSubShape ( shapeL, sub, L ) ) return L;
|
|
||||||
|
|
||||||
if (!IsSubShape(shapeL, sub))
|
|
||||||
return TDF_Label();
|
|
||||||
|
|
||||||
TDF_TagSource aTag;
|
|
||||||
L = aTag.NewChild(shapeL);
|
|
||||||
|
|
||||||
TNaming_Builder tnBuild(L);
|
|
||||||
tnBuild.Generated(sub);
|
|
||||||
|
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
@ -1119,17 +1114,39 @@ Standard_Boolean XCAFDoc_ShapeTool::AddSubShape(const TDF_Label &shapeL,
|
|||||||
if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL))
|
if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
// Try to find already existed subshape
|
TopoDS_Shape aSubShape = sub;
|
||||||
if (FindSubShape(shapeL, sub, addedSubShapeL))
|
Standard_Boolean isDefined = Standard_True;
|
||||||
|
if (!IsSubShape(shapeL, sub))
|
||||||
|
{
|
||||||
|
isDefined = Standard_False;
|
||||||
|
// Try to find a subshape as a part of the main shape.
|
||||||
|
// If location of subshape has been removed,
|
||||||
|
// take the shape with the location from the main shape
|
||||||
|
if (sub.Location().IsIdentity())
|
||||||
|
{
|
||||||
|
TDF_LabelSequence aShapeLSeq;
|
||||||
|
for (TopoDS_Iterator it(GetShape(shapeL)); it.More() && !isDefined; it.Next())
|
||||||
|
{
|
||||||
|
TopoDS_Shape aShape = it.Value();
|
||||||
|
if (sub.IsSame(aShape.Located(TopLoc_Location())))
|
||||||
|
{
|
||||||
|
isDefined = Standard_True;
|
||||||
|
aSubShape = aShape;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isDefined)
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
if (!IsSubShape(shapeL, sub))
|
// Try to find already existed subshape
|
||||||
|
if (FindSubShape(shapeL, aSubShape, addedSubShapeL))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
TDF_TagSource aTag;
|
TDF_TagSource aTag;
|
||||||
addedSubShapeL = aTag.NewChild(shapeL);
|
addedSubShapeL = aTag.NewChild(shapeL);
|
||||||
TNaming_Builder tnBuild(addedSubShapeL);
|
TNaming_Builder tnBuild(addedSubShapeL);
|
||||||
tnBuild.Generated(sub);
|
tnBuild.Generated(aSubShape);
|
||||||
|
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
93
tests/bugs/iges/bug26047
Normal file
93
tests/bugs/iges/bug26047
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "0026047: Data Exchange - Lost colors for IGES export"
|
||||||
|
puts "============"
|
||||||
|
|
||||||
|
pload MODELING VISUALIZATION OCAF XDE
|
||||||
|
|
||||||
|
catch { Close D }
|
||||||
|
catch { Close D_Cope }
|
||||||
|
|
||||||
|
# create original
|
||||||
|
box b 0 -20 -10 100 40 20
|
||||||
|
compound b b b a
|
||||||
|
explode a
|
||||||
|
trotate a_1 0 0 0 1 0 0 60
|
||||||
|
trotate a_2 0 0 0 1 0 0 -60
|
||||||
|
bcommon b a a_1
|
||||||
|
bcommon b b a_2
|
||||||
|
|
||||||
|
pcylinder c 4 100
|
||||||
|
trotate c 0 0 0 0 1 0 90
|
||||||
|
|
||||||
|
psphere s 1.4
|
||||||
|
ttranslate s 99.2 0 0
|
||||||
|
bfuse cx c s
|
||||||
|
|
||||||
|
pcone e 60 0.5 101
|
||||||
|
trotate e 0 0 0 0 1 0 90
|
||||||
|
|
||||||
|
bcommon body b e
|
||||||
|
bcut body body c
|
||||||
|
bcommon core cx e
|
||||||
|
|
||||||
|
text2brep text "CAD Assistant" -font Times -height 10
|
||||||
|
ttranslate text 10 -4 10
|
||||||
|
prism tr text 0 0 -1
|
||||||
|
bfuse body body tr
|
||||||
|
|
||||||
|
donly body core
|
||||||
|
|
||||||
|
#vdisplay body core
|
||||||
|
#vsetcolor body yellow
|
||||||
|
#vsetcolor core red
|
||||||
|
|
||||||
|
explode body so
|
||||||
|
explode body_1 f
|
||||||
|
explode core so
|
||||||
|
|
||||||
|
NewDocument D
|
||||||
|
XAddShape D body_1
|
||||||
|
XAddShape D core_1
|
||||||
|
|
||||||
|
for {set i 1} {$i <= 26} {incr i} {XSetColor D body_1_$i BLUE}
|
||||||
|
XSetColor D body_1_1 E68066
|
||||||
|
XSetColor D body_1_9 E68066
|
||||||
|
for {set i 10} {$i <= 22} {incr i} {XSetColor D body_1_$i 99B300}
|
||||||
|
XSetColor D core_1 1A1AFF
|
||||||
|
foreach ff [explode core_1 f] { XSetColor D $ff 1A1AFF ; puts "set color $ff" }
|
||||||
|
|
||||||
|
vinit
|
||||||
|
vclear
|
||||||
|
XDisplay D -dispMode 1
|
||||||
|
vfit
|
||||||
|
vdump "$::imagedir/${::casename}_orig.png"
|
||||||
|
set aColorOrig [vreadpixel 360 290 rgb name]
|
||||||
|
|
||||||
|
# export a copy
|
||||||
|
set anIgesCopy "$::imagedir/${::casename}_exported.igs"
|
||||||
|
WriteIges D $anIgesCopy
|
||||||
|
|
||||||
|
# display an exported model
|
||||||
|
ReadIges D_Copy $anIgesCopy
|
||||||
|
file delete $anIgesCopy
|
||||||
|
|
||||||
|
vinit
|
||||||
|
vclear
|
||||||
|
XDisplay D_Copy -dispMode 1
|
||||||
|
vfit
|
||||||
|
vdump "$::imagedir/${::casename}_exported.png"
|
||||||
|
|
||||||
|
# check color
|
||||||
|
set aColorNew [vreadpixel 360 290 rgb name]
|
||||||
|
if { "$aColorOrig" == "$aColorNew" } {
|
||||||
|
puts "OK: Image of exported model matches original"
|
||||||
|
} else {
|
||||||
|
puts "Error: Image of exported model is wrong!"
|
||||||
|
}
|
||||||
|
|
||||||
|
set xst [ XStat D_Copy 1]
|
||||||
|
regexp {Number +of +labels +with +color +link += +([-0-9.+eE]+)} $xst full nbshcolor_Copy
|
||||||
|
|
||||||
|
if {$nbshcolor_Copy != 31} {
|
||||||
|
puts "Error: incorect count of color links to shapes"
|
||||||
|
}
|
@ -10,8 +10,8 @@ TPSTAT : Faulties = 0 ( 0 ) Warnings = 14 ( 298 ) Summary = 14 ( 298
|
|||||||
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
||||||
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 568 ( 568 )
|
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 568 ( 568 )
|
||||||
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 568 ( 568 ) FreeWire = 0 ( 0 )
|
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 568 ( 568 ) FreeWire = 0 ( 0 )
|
||||||
TOLERANCE : MaxTol = 0.4977710304 ( 0.4977710286 ) AvgTol = 0.00198506744 ( 0.001988149118 )
|
TOLERANCE : MaxTol = 0.4977710304 ( 0.4977710286 ) AvgTol = 0.001985043383 ( 0.001988149118 )
|
||||||
LABELS : N0Labels = 568 ( 569 ) N1Labels = 0 ( 1209 ) N2Labels = 0 ( 0 ) TotalLabels = 568 ( 1778 ) NameLabels = 568 ( 569 ) ColorLabels = 568 ( 1777 ) LayerLabels = 568 ( 1777 )
|
LABELS : N0Labels = 568 ( 569 ) N1Labels = 0 ( 1210 ) N2Labels = 0 ( 0 ) TotalLabels = 568 ( 1779 ) NameLabels = 568 ( 569 ) ColorLabels = 568 ( 1778 ) LayerLabels = 568 ( 1778 )
|
||||||
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
||||||
NCOLORS : NColors = 1 ( 1 )
|
NCOLORS : NColors = 1 ( 1 )
|
||||||
COLORS : Colors = YELLOW ( YELLOW )
|
COLORS : Colors = YELLOW ( YELLOW )
|
||||||
|
@ -10,8 +10,8 @@ TPSTAT : Faulties = 0 ( 0 ) Warnings = 345 ( 5241 ) Summary = 345 ( 5
|
|||||||
CHECKSHAPE : Wires = 8 ( 12 ) Faces = 12 ( 12 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
CHECKSHAPE : Wires = 8 ( 12 ) Faces = 12 ( 12 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
||||||
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 )
|
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 )
|
||||||
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 ) FreeWire = 10 ( 10 )
|
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 ) FreeWire = 10 ( 10 )
|
||||||
TOLERANCE : MaxTol = 0.9874083984 ( 0.9875071265 ) AvgTol = 0.01115263465 ( 0.01115875316 )
|
TOLERANCE : MaxTol = 0.9874083984 ( 0.9875071265 ) AvgTol = 0.01115260658 ( 0.01115854425 )
|
||||||
LABELS : N0Labels = 5392 ( 5458 ) N1Labels = 18 ( 4483 ) N2Labels = 0 ( 0 ) TotalLabels = 5410 ( 9941 ) NameLabels = 5392 ( 5458 ) ColorLabels = 5391 ( 9875 ) LayerLabels = 5391 ( 9875 )
|
LABELS : N0Labels = 5392 ( 5458 ) N1Labels = 18 ( 4541 ) N2Labels = 0 ( 0 ) TotalLabels = 5410 ( 9999 ) NameLabels = 5392 ( 5458 ) ColorLabels = 5391 ( 9933 ) LayerLabels = 5391 ( 9933 )
|
||||||
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
||||||
NCOLORS : NColors = 4 ( 4 )
|
NCOLORS : NColors = 4 ( 4 )
|
||||||
COLORS : Colors = BLACK BLUE CYAN GREEN ( BLACK BLUE CYAN GREEN )
|
COLORS : Colors = BLACK BLUE CYAN GREEN ( BLACK BLUE CYAN GREEN )
|
||||||
|
@ -11,7 +11,7 @@ CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) So
|
|||||||
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 115 ( 115 )
|
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 115 ( 115 )
|
||||||
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 115 ( 115 ) FreeWire = 4 ( 4 )
|
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 115 ( 115 ) FreeWire = 4 ( 4 )
|
||||||
TOLERANCE : MaxTol = 0.4134968839 ( 0.4134968924 ) AvgTol = 0.006591900949 ( 0.00663549168 )
|
TOLERANCE : MaxTol = 0.4134968839 ( 0.4134968924 ) AvgTol = 0.006591900949 ( 0.00663549168 )
|
||||||
LABELS : N0Labels = 278 ( 286 ) N1Labels = 6 ( 151 ) N2Labels = 0 ( 0 ) TotalLabels = 284 ( 437 ) NameLabels = 278 ( 286 ) ColorLabels = 270 ( 429 ) LayerLabels = 270 ( 429 )
|
LABELS : N0Labels = 278 ( 286 ) N1Labels = 6 ( 159 ) N2Labels = 0 ( 0 ) TotalLabels = 284 ( 445 ) NameLabels = 278 ( 286 ) ColorLabels = 270 ( 437 ) LayerLabels = 270 ( 437 )
|
||||||
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
||||||
NCOLORS : NColors = 1 ( 1 )
|
NCOLORS : NColors = 1 ( 1 )
|
||||||
COLORS : Colors = RED ( RED )
|
COLORS : Colors = RED ( RED )
|
||||||
|
@ -12,11 +12,10 @@ CHECKSHAPE : Wires = 1 ( 1 ) Faces = 1 ( 1 ) Shells = 0 ( 0 ) So
|
|||||||
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 181 ( 181 )
|
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 181 ( 181 )
|
||||||
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 181 ( 181 ) FreeWire = 3 ( 3 )
|
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 181 ( 181 ) FreeWire = 3 ( 3 )
|
||||||
TOLERANCE : MaxTol = 0.1814235482 ( 0.1814235485 ) AvgTol = 0.00374562953 ( 0.003756748249 )
|
TOLERANCE : MaxTol = 0.1814235482 ( 0.1814235485 ) AvgTol = 0.00374562953 ( 0.003756748249 )
|
||||||
LABELS : N0Labels = 184 ( 359 ) N1Labels = 0 ( 59 ) N2Labels = 0 ( 0 ) TotalLabels = 184 ( 418 ) NameLabels = 184 ( 360 ) ColorLabels = 181 ( 243 ) LayerLabels = 181 ( 243 )
|
LABELS : N0Labels = 184 ( 359 ) N1Labels = 0 ( 139 ) N2Labels = 0 ( 0 ) TotalLabels = 184 ( 498 ) NameLabels = 184 ( 440 ) ColorLabels = 181 ( 323 ) LayerLabels = 181 ( 323 )
|
||||||
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
||||||
NCOLORS : NColors = 1 ( 3 )
|
NCOLORS : NColors = 1 ( 3 )
|
||||||
COLORS : Colors = WHITE ( BLACK WHITE YELLOW )
|
COLORS : Colors = WHITE ( BLACK WHITE YELLOW )
|
||||||
NLAYERS : NLayers = 4 ( 4 )
|
NLAYERS : NLayers = 4 ( 4 )
|
||||||
LAYERS : Layers = 241 5 6 8 ( 241 5 6 8 )
|
LAYERS : Layers = 241 5 6 8 ( 241 5 6 8 )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,11 @@ TPSTAT : Faulties = 0 ( 0 ) Warnings = 293 ( 5002 ) Summary = 293 ( 5
|
|||||||
CHECKSHAPE : Wires = 8 ( 11 ) Faces = 8 ( 7 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
CHECKSHAPE : Wires = 8 ( 11 ) Faces = 8 ( 7 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
||||||
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 )
|
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 )
|
||||||
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 ) FreeWire = 18 ( 18 )
|
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 ) FreeWire = 18 ( 18 )
|
||||||
TOLERANCE : MaxTol = 0.9804479161 ( 0.9805459497 ) AvgTol = 0.01154143018 ( 0.0115517576 )
|
TOLERANCE : MaxTol = 0.9804479161 ( 0.9805459497 ) AvgTol = 0.01154139976 ( 0.01155171873 )
|
||||||
LABELS : N0Labels = 5089 ( 5165 ) N1Labels = 26 ( 3878 ) N2Labels = 0 ( 0 ) TotalLabels = 5115 ( 9043 ) NameLabels = 5089 ( 5165 ) ColorLabels = 5086 ( 8967 ) LayerLabels = 5086 ( 8967 )
|
LABELS : N0Labels = 5089 ( 5165 ) N1Labels = 26 ( 3936 ) N2Labels = 0 ( 0 ) TotalLabels = 5115 ( 9101 ) NameLabels = 5089 ( 5165 ) ColorLabels = 5086 ( 9025 ) LayerLabels = 5086 ( 9025 )
|
||||||
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
||||||
NCOLORS : NColors = 3 ( 3 )
|
NCOLORS : NColors = 3 ( 3 )
|
||||||
COLORS : Colors = BLUE CYAN GREEN ( BLUE CYAN GREEN )
|
COLORS : Colors = BLUE CYAN GREEN ( BLUE CYAN GREEN )
|
||||||
NLAYERS : NLayers = 3 ( 3 )
|
NLAYERS : NLayers = 3 ( 3 )
|
||||||
LAYERS : Layers = 1 200 51 ( 1 200 51 )
|
LAYERS : Layers = 1 200 51 ( 1 200 51 )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user