Handle(Transfer_FinderProcess) FP = TransferProcess();
Handle(IGESData_IGESEntity) ent;
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 );
Handle(IGESSolid_Face) ent_f = Handle(IGESSolid_Face)::DownCast(ent);
if (!ent_f.IsNull())
{
TopoDS_Shape aSh = A->GetMap().FindKey(i);
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());
}
const TopoDS_Shape &sub) const
{
TDF_Label L;
- if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL))
- 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);
+ AddSubShape(shapeL, sub, L);
return L;
}
if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL))
return Standard_False;
- // Try to find already existed subshape
- if (FindSubShape(shapeL, sub, addedSubShapeL))
+ TopoDS_Shape aSubShape = sub;
+ 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;
- if (!IsSubShape(shapeL, sub))
+ // Try to find already existed subshape
+ if (FindSubShape(shapeL, aSubShape, addedSubShapeL))
return Standard_False;
TDF_TagSource aTag;
addedSubShapeL = aTag.NewChild(shapeL);
TNaming_Builder tnBuild(addedSubShapeL);
- tnBuild.Generated(sub);
+ tnBuild.Generated(aSubShape);
return Standard_True;
}
--- /dev/null
+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"
+}
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 568 ( 568 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 568 ( 568 ) FreeWire = 0 ( 0 )
-TOLERANCE : MaxTol = 0.4977710304 ( 0.4977710286 ) AvgTol = 0.00198506744 ( 0.001988149118 )
-LABELS : N0Labels = 568 ( 569 ) N1Labels = 0 ( 1209 ) N2Labels = 0 ( 0 ) TotalLabels = 568 ( 1778 ) NameLabels = 568 ( 569 ) ColorLabels = 568 ( 1777 ) LayerLabels = 568 ( 1777 )
+TOLERANCE : MaxTol = 0.4977710304 ( 0.4977710286 ) AvgTol = 0.001985043383 ( 0.001988149118 )
+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 )
NCOLORS : NColors = 1 ( 1 )
COLORS : Colors = YELLOW ( YELLOW )
CHECKSHAPE : Wires = 8 ( 12 ) Faces = 12 ( 12 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 ) FreeWire = 10 ( 10 )
-TOLERANCE : MaxTol = 0.9874083984 ( 0.9875071265 ) AvgTol = 0.01115263465 ( 0.01115875316 )
-LABELS : N0Labels = 5392 ( 5458 ) N1Labels = 18 ( 4483 ) N2Labels = 0 ( 0 ) TotalLabels = 5410 ( 9941 ) NameLabels = 5392 ( 5458 ) ColorLabels = 5391 ( 9875 ) LayerLabels = 5391 ( 9875 )
+TOLERANCE : MaxTol = 0.9874083984 ( 0.9875071265 ) AvgTol = 0.01115260658 ( 0.01115854425 )
+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 )
NCOLORS : NColors = 4 ( 4 )
COLORS : Colors = BLACK BLUE CYAN GREEN ( BLACK BLUE CYAN GREEN )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 115 ( 115 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 115 ( 115 ) FreeWire = 4 ( 4 )
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 )
NCOLORS : NColors = 1 ( 1 )
COLORS : Colors = RED ( RED )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 181 ( 181 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 181 ( 181 ) FreeWire = 3 ( 3 )
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 )
NCOLORS : NColors = 1 ( 3 )
COLORS : Colors = WHITE ( BLACK WHITE YELLOW )
NLAYERS : NLayers = 4 ( 4 )
LAYERS : Layers = 241 5 6 8 ( 241 5 6 8 )
-
}
CHECKSHAPE : Wires = 8 ( 11 ) Faces = 8 ( 7 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 ) FreeWire = 18 ( 18 )
-TOLERANCE : MaxTol = 0.9804479161 ( 0.9805459497 ) AvgTol = 0.01154143018 ( 0.0115517576 )
-LABELS : N0Labels = 5089 ( 5165 ) N1Labels = 26 ( 3878 ) N2Labels = 0 ( 0 ) TotalLabels = 5115 ( 9043 ) NameLabels = 5089 ( 5165 ) ColorLabels = 5086 ( 8967 ) LayerLabels = 5086 ( 8967 )
+TOLERANCE : MaxTol = 0.9804479161 ( 0.9805459497 ) AvgTol = 0.01154139976 ( 0.01155171873 )
+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 )
NCOLORS : NColors = 3 ( 3 )
COLORS : Colors = BLUE CYAN GREEN ( BLUE CYAN GREEN )
NLAYERS : NLayers = 3 ( 3 )
LAYERS : Layers = 1 200 51 ( 1 200 51 )
-
}