mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Compare commits
2 Commits
V7_8_1
...
CR0_700_Fi
Author | SHA1 | Date | |
---|---|---|---|
|
7330772f97 | ||
|
87a7fc4b6d |
@@ -501,6 +501,32 @@ Standard_Integer AIS_ColorScale::HueFromValue (const Standard_Integer theValue,
|
||||
Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
||||
Quantity_Color& theColor) const
|
||||
{
|
||||
if (theValue < myMin || theValue > myMax || myMax < myMin)
|
||||
{
|
||||
theColor = Quantity_Color();
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (GetColorType() == Aspect_TOCSD_USER)
|
||||
{
|
||||
Standard_Integer anIndex = 0;
|
||||
if (Abs (myMax - myMin) > Precision::Approximation())
|
||||
{
|
||||
anIndex = (theValue - myMin < Precision::Confusion())
|
||||
? 1
|
||||
: Standard_Integer (Ceiling (( theValue - myMin ) / ( (myMax - myMin) / myInterval)));
|
||||
}
|
||||
|
||||
if (anIndex <= 0 || anIndex > myColors.Length())
|
||||
{
|
||||
theColor = Quantity_Color();
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theColor = myColors.Value (anIndex);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return FindColor (theValue, myMin, myMax, myInterval, theColor);
|
||||
}
|
||||
|
||||
|
@@ -44,6 +44,7 @@ public:
|
||||
//! Calculate color according passed value; returns true if value is in range or false, if isn't
|
||||
Standard_EXPORT Standard_Boolean FindColor (const Standard_Real theValue, Quantity_Color& theColor) const;
|
||||
|
||||
//! Calculate color according passed value; returns true if value is in range or false, if isn't
|
||||
Standard_EXPORT static Standard_Boolean FindColor (const Standard_Real theValue, const Standard_Real theMin, const Standard_Real theMax, const Standard_Integer theColorsCount, Quantity_Color& theColor);
|
||||
|
||||
//! Returns minimal value of color scale;
|
||||
@@ -280,13 +281,13 @@ private:
|
||||
Standard_Real myMax;
|
||||
TCollection_ExtendedString myTitle;
|
||||
TCollection_AsciiString myFormat;
|
||||
Standard_Integer myInterval;
|
||||
Standard_Integer myInterval; //! Number of intervals
|
||||
Aspect_TypeOfColorScaleData myColorType;
|
||||
Aspect_TypeOfColorScaleData myLabelType;
|
||||
Standard_Boolean myAtBorder;
|
||||
Standard_Boolean myReversed;
|
||||
Standard_Boolean myIsLogarithmic;
|
||||
Aspect_SequenceOfColor myColors;
|
||||
Aspect_SequenceOfColor myColors; //! Sequence of custom colors
|
||||
TColStd_SequenceOfExtendedString myLabels;
|
||||
Aspect_TypeOfColorScalePosition myLabelPos;
|
||||
Aspect_TypeOfColorScalePosition myTitlePos;
|
||||
|
@@ -185,6 +185,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
||||
Quantity_Color anEdgeColor, aLineColor;
|
||||
Standard_Boolean anEdgeOn = Standard_True, IsReflect = Standard_False,
|
||||
IsMeshSmoothShading = Standard_False;
|
||||
Standard_Boolean toSupressBackFaces = Standard_False;
|
||||
|
||||
aDrawer->GetColor ( MeshVS_DA_InteriorColor, anInteriorColor );
|
||||
aDrawer->GetColor ( MeshVS_DA_EdgeColor, anEdgeColor );
|
||||
@@ -194,6 +195,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
||||
aDrawer->GetBoolean( MeshVS_DA_ShowEdges, anEdgeOn );
|
||||
aDrawer->GetBoolean( MeshVS_DA_ColorReflection, IsReflect );
|
||||
aDrawer->GetBoolean( MeshVS_DA_SmoothShading, IsMeshSmoothShading );
|
||||
aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, toSupressBackFaces);
|
||||
|
||||
if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt) )
|
||||
anEdgeType = (Aspect_TypeOfLine) anEdgeInt;
|
||||
@@ -256,12 +258,9 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
||||
|
||||
TColStd_PackedMapOfInteger aCustomElements;
|
||||
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aGGroup = Prs3d_Root::CurrentGroup ( Prs );
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aLGroup = Prs3d_Root::CurrentGroup ( Prs );
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aSGroup = Prs3d_Root::CurrentGroup ( Prs );
|
||||
Handle(Graphic3d_Group) aGGroup = Prs3d_Root::NewGroup (Prs);
|
||||
Handle(Graphic3d_Group) aLGroup = Prs3d_Root::NewGroup (Prs);
|
||||
Handle(Graphic3d_Group) aSGroup = Prs3d_Root::NewGroup (Prs);
|
||||
|
||||
Standard_Integer aNbFacePrimitives = 0;
|
||||
Standard_Integer aNbVolmPrimitives = 0;
|
||||
@@ -452,6 +451,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
||||
aFillAspect->SetEdgeOff();
|
||||
aGGroup->SetPrimitivesAspect (aFillAspect);
|
||||
aGGroup->AddPrimitiveArray (aFaceTriangles);
|
||||
aGGroup->SetClosed (toSupressBackFaces == Standard_True);
|
||||
|
||||
if (anEdgeOn)
|
||||
{
|
||||
@@ -518,10 +518,8 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
||||
for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger aColIter2 ( aTwoColorsOfElements );
|
||||
aColIter2.More(); aColIter2.Next() )
|
||||
{
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aGroup2 = Prs3d_Root::CurrentGroup ( Prs );
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle ( Graphic3d_Group ) aGroup3 = Prs3d_Root::CurrentGroup ( Prs );
|
||||
Handle(Graphic3d_Group) aGroup2 = Prs3d_Root::NewGroup (Prs);
|
||||
Handle(Graphic3d_Group) aGroup3 = Prs3d_Root::NewGroup (Prs);
|
||||
|
||||
Standard_Integer aSize = aColIter2.Value().Extent();
|
||||
if ( aSize<=0 )
|
||||
@@ -638,6 +636,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
|
||||
}
|
||||
}
|
||||
|
||||
aGroup2->SetClosed (toSupressBackFaces == Standard_True);
|
||||
aGroup2->AddPrimitiveArray (aFaceTriangles);
|
||||
aGroup2->SetGroupPrimitivesAspect (anAsp);
|
||||
aGroup3->AddPrimitiveArray (anEdgeSegments);
|
||||
|
@@ -473,8 +473,11 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
||||
Handle(Graphic3d_AspectLine3d) anLAsp =
|
||||
new Graphic3d_AspectLine3d( anEdgeColor, anEdgeType, anEdgeWidth );
|
||||
|
||||
Prs3d_Root::NewGroup ( Prs );
|
||||
Handle(Graphic3d_Group) aGroup1 = Prs3d_Root::CurrentGroup ( Prs );
|
||||
Handle(Graphic3d_Group) aGroup1 = Prs3d_Root::NewGroup (Prs);
|
||||
|
||||
Standard_Boolean toSupressBackFaces = Standard_False;
|
||||
aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, toSupressBackFaces);
|
||||
aGroup1->SetClosed (toSupressBackFaces == Standard_True);
|
||||
|
||||
aGroup1->SetPrimitivesAspect( anAsp );
|
||||
aGroup1->AddPrimitiveArray( aFaceTriangles /*aCPolyArr*/ );
|
||||
|
@@ -3923,6 +3923,27 @@ static int VColorScale (Draw_Interpretor& theDI,
|
||||
aCS->SetColorType (Aspect_TOCSD_AUTO);
|
||||
aCS->SetLabelType (Aspect_TOCSD_AUTO);
|
||||
}
|
||||
else if (aFlag == "-findcolor")
|
||||
{
|
||||
if (anArgIter + 1 >= theArgNb)
|
||||
{
|
||||
std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString anArg1 (theArgVec[++anArgIter]);
|
||||
|
||||
if (!anArg1.IsRealValue())
|
||||
{
|
||||
std::cout << "Error: the value should be real!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Quantity_Color aColor;
|
||||
aCS->FindColor (anArg1.RealValue(), aColor);
|
||||
theDI << Quantity_Color::StringName (aColor.Name());
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << " - unknown argument!\n";
|
||||
|
@@ -1,31 +1,55 @@
|
||||
puts "============="
|
||||
puts "Drawing mesh as closed object."
|
||||
puts "============="
|
||||
puts ""
|
||||
puts "============="
|
||||
puts ""
|
||||
|
||||
##############################################################################
|
||||
## Drawing mesh as closed object.
|
||||
##############################################################################
|
||||
|
||||
pload XDE
|
||||
|
||||
set anImage1 $imagedir/${casename}_Opened.png
|
||||
set anImage2 $imagedir/${casename}_Closed.png
|
||||
set aMeshFile [locate_data_file sh1.stl]
|
||||
|
||||
vinit
|
||||
meshfromstl aMesh [locate_data_file sh1.stl]
|
||||
vsetdispmode aMesh 2
|
||||
vfront
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
|
||||
meshfromstl m0 "$aMeshFile"
|
||||
vsetdispmode m0 2
|
||||
|
||||
vsetlocation -noupdate m0 -100 0 0
|
||||
meshfromstl m1 "$aMeshFile"
|
||||
meshcolors m1 elem1 0
|
||||
vsetlocation -noupdate m1 0 0 0
|
||||
|
||||
meshfromstl m2 "$aMeshFile"
|
||||
meshcolors m2 elem2 0
|
||||
vsetlocation -noupdate m2 100 0 0
|
||||
|
||||
meshfromstl m3 "$aMeshFile"
|
||||
meshcolors m3 nodal 1
|
||||
vsetlocation -noupdate m3 0 0 100
|
||||
|
||||
meshfromstl m4 "$aMeshFile"
|
||||
meshcolors m4 nodaltex 1
|
||||
vsetlocation -noupdate m4 100 0 100
|
||||
vfit
|
||||
|
||||
vclipplane create aClipPlane
|
||||
vclipplane change aClipPlane equation 0 1 0 0
|
||||
vclipplane change aClipPlane capping on
|
||||
vclipplane change aClipPlane capping color 0.9 0.9 0.9
|
||||
vclipplane set aClipPlane object aMesh
|
||||
vclipplane create p
|
||||
vclipplane change p equation 0 1 0 0
|
||||
vclipplane change p capping on
|
||||
vclipplane change p capping color 0.9 0.9 0.9
|
||||
vclipplane set p view Driver1/Viewer1/View1
|
||||
|
||||
meshclosed aMesh 0
|
||||
vdump ${anImage1}
|
||||
for {set i 0} {$i < 5} {incr i} { meshclosed m$i 0 }
|
||||
vdump ${imagedir}/${casename}_open.png
|
||||
|
||||
meshclosed aMesh 1
|
||||
vdump ${anImage2}
|
||||
for {set i 0} {$i < 5} {incr i} { meshclosed m$i 1 }
|
||||
set aColor0 [vreadpixel 125 200 rgb name]
|
||||
set aColor1 [vreadpixel 225 300 rgb name]
|
||||
set aColor2 [vreadpixel 325 325 rgb name]
|
||||
set aColor3 [vreadpixel 225 150 rgb name]
|
||||
set aColor4 [vreadpixel 325 200 rgb name]
|
||||
|
||||
if { "$aColor0" != "GRAY61" || "$aColor1" != "GRAY61" || "$aColor2" != "GRAY61" || "$aColor3" != "GRAY61" || "$aColor4" != "GRAY61" } {
|
||||
puts "Error: capping color does not match"
|
||||
}
|
||||
|
||||
vdump ${imagedir}/${casename}_closed.png
|
||||
|
59
tests/bugs/vis/bug27573
Normal file
59
tests/bugs/vis/bug27573
Normal file
@@ -0,0 +1,59 @@
|
||||
puts "============"
|
||||
puts "0027573"
|
||||
puts "AIS_ColorScale::FindColor does not take into account custom colors."
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
vclose all
|
||||
vinit
|
||||
vclear
|
||||
vaxo
|
||||
|
||||
vcolorscale cs -demo
|
||||
vcolorscale cs -range 0 20 5
|
||||
|
||||
# Set user-defined colors and labels for color scale
|
||||
vcolorscale cs -colors white red green blue1 gray
|
||||
|
||||
# Check the first interval border color
|
||||
if {[vcolorscale cs -findcolor 0] != "WHITE"} {
|
||||
puts "ERROR: Find color result for the first segment is wrong!"
|
||||
}
|
||||
|
||||
# Check first-second intervals border
|
||||
if {[vcolorscale cs -findcolor 4] != "WHITE"} {
|
||||
puts "ERROR: Find color result for the first segment border is wrong!"
|
||||
}
|
||||
|
||||
# Check the second interval color
|
||||
if {[vcolorscale cs -findcolor 5] != "RED"} {
|
||||
puts "ERROR: Find color result for the second segment is wrong!"
|
||||
}
|
||||
|
||||
# Check the second interval color
|
||||
if {[vcolorscale cs -findcolor 9] != "GREEN"} {
|
||||
puts "ERROR: Find color result for the third segment is wrong!"
|
||||
}
|
||||
|
||||
# Check the last interval border color
|
||||
if {[vcolorscale cs -findcolor 20] != "GRAY"} {
|
||||
puts "ERROR: Find color result for the last segment is wrong!"
|
||||
}
|
||||
|
||||
# Check negative value limits
|
||||
vcolorscale cs -range -5 5 5
|
||||
|
||||
if {[vcolorscale cs -findcolor -5] != "WHITE"} {
|
||||
puts "ERROR: Find color result for the first segment is wrong!"
|
||||
}
|
||||
|
||||
if {[vcolorscale cs -findcolor 0] != "GREEN"} {
|
||||
puts "ERROR: Find color result for the middle segment is wrong!"
|
||||
}
|
||||
|
||||
if {[vcolorscale cs -findcolor 5] != "GRAY"} {
|
||||
puts "ERROR: Find color result for the last segment is wrong!"
|
||||
}
|
||||
|
||||
# Dump result
|
||||
set only_screen 1
|
Reference in New Issue
Block a user