1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Compare commits

..

3 Commits

Author SHA1 Message Date
drochalo
d44b7b7442 0027832: Visualization - Scaled zbuffer trihedron
Code cleanup and test case modified.
2023-10-27 17:18:25 +01:00
drochalo
6b9af22de9 0027832: Visualization - Scaled zbuffer trihedron
Minor update on axial scale test
2023-10-20 18:40:09 +01:00
drochalo
d28545ca7b 0027832: Scaled zbuffer trihedron
Adjusted calculation of scale in Graphic3d_TransformPers::Apply().
Now takes into consideration the Axial Scale of the camera.
2023-10-20 15:11:54 +01:00
4 changed files with 62 additions and 9 deletions

View File

@@ -35,17 +35,13 @@ std::pair<Standard_Real, Standard_Real> BRepMesh_ConeRangeSplitter::GetSplitStep
Standard_Real aRadius = Max(Abs(aRefR + aRangeV.first * Sin(aSAng)),
Abs(aRefR + aRangeV.second * Sin(aSAng)));
//Face deflection used to determine circle subdivisions needs to match the one used previously
Standard_Real Dv, Du = GCPnts_TangentialDeflection::ArcAngularStep(
aRadius, GetDFace()->GetDeflection()*0.5,
aRadius, GetDFace()->GetDeflection(),
theParameters.Angle, theParameters.MinSize);
const Standard_Real aDiffU = aRangeU.second - aRangeU.first;
const Standard_Real aDiffV = aRangeV.second - aRangeV.first;
//compute subdivision factor acounting for the difference between the bottom and top radius of the cone
const Standard_Real aTopRadius = aRefR > Precision::Confusion() ? aRefR : 1.0;
const Standard_Real aSubDivFactor = Max(theParameters.MinSize, Min(1.0, aTopRadius > aRadius ? aRadius / aTopRadius : aTopRadius / aRadius));
const Standard_Real aScale = (Du * aRadius * aSubDivFactor);
const Standard_Real aScale = (Du * aRadius);
const Standard_Real aRatio = Max(1., Log(aDiffV / aScale));
const Standard_Integer nbU = (Standard_Integer)(aDiffU / Du);
const Standard_Integer nbV = (Standard_Integer)(aDiffV / aScale / aRatio);

View File

@@ -409,6 +409,17 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
}
NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
//Adjust the camera axial scale for trihedron behaviour
gp_XYZ anAxialScale = theCamera->AxialScale();
Standard_Real anAxialX = anAxialScale.X();
Standard_Real anAxialY = anAxialScale.Y();
Standard_Real anAxialZ = anAxialScale.Z();
if (anAxialX > 0.0 && anAxialY > 0.0 && anAxialZ > 0.0)
{
Graphic3d_TransformUtils::Scale (aWorldView, 1.0 / anAxialX, 1.0 / anAxialY, 1.0 / anAxialZ);
}
Graphic3d_TransformUtils::Translate (aWorldView, aCenter.X(), aCenter.Y(), aCenter.Z());
Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
theWorldView.ConvertFrom (aWorldView);

View File

@@ -210,9 +210,9 @@ namespace
{
const gp_Pnt2d aNode2d = aT->UVNode (aNodeIter);
const gp_Pnt2d aTexel = (dUmax == 0.0 || dVmax == 0.0)
? aNode2d
: gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aNode2d.X() - aUmin)) / dUmax) / theUVScale.X(),
(-theUVOrigin.Y() + (theUVRepeat.Y() * (aNode2d.Y() - aVmin)) / dVmax) / theUVScale.Y());
? aNode2d
: gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aNode2d.X() - aUmin)) / dUmax) / theUVScale.X(),
(-theUVOrigin.Y() + (theUVRepeat.Y() * (aNode2d.Y() - aVmin)) / dVmax) / theUVScale.Y());
anArray->AddVertex (aPoint, aNorm, aTexel);
}
else

View File

@@ -0,0 +1,46 @@
puts "========"
puts "0027832: Visualization - Scaled zbuffer trihedron"
puts "========"
puts ""
pload MODELING VISUALIZATION
vinit
box b 10 10 10
vdisplay b
vfit
vsetdispmode 1
vzbufftrihedron -on
#draw initial picture of box without visual scale
vdump $imagedir/${casename}_unscaled.png
#draw picture of box after visual scale
#and zoomed out
vscale 1 3 10
vzoom 0.99
set color_1 [vreadpixel 55 360 -rgb -name]
set color_2 [vreadpixel 50 350 -rgb -name]
set color_3 [vreadpixel 55 355 -rgb -name]
if {$color_1 != "RED3"} {
puts "ERROR: trihedron does not maintain position"
puts " additional investigation is needed"
puts " expected color is: RED3"
puts " current color is: $color_1"
}
if {$color_2 != "BLUE3"} {
puts "ERROR: trihedron does not maintain position"
puts " additional investigation is needed"
puts " expected color is: BLUE3"
puts " current color is: $color_2"
}
if {$color_3 != "GREEN3"} {
puts "ERROR: trihedron does not maintain position"
puts " additional investigation is needed"
puts " expected color is: GREEN3"
puts " current color is: $color_3"
}
vdump $imagedir/${casename}_scaled.png