mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0022582: Visualization - provide an API for dumping a sub-region of the viewport
Graphic3d_Camera definition has been exended by optional Tile property (Graphic3d_CameraTile structure). V3d_View::ToPixMap() now performs tiled dump when image size exceeds hardware limits. OpenGl_View::Redraw() - fixed dump of immediate Z layers in no stereo and no MSAA case. OpenGl_Context now tracks viewport values. Draw Harness command vdump has been extended with new argument -tileSize.
This commit is contained in:
@@ -37,6 +37,7 @@ Graphic3d_Buffer.hxx
|
||||
Graphic3d_BufferType.hxx
|
||||
Graphic3d_Camera.cxx
|
||||
Graphic3d_Camera.hxx
|
||||
Graphic3d_CameraTile.hxx
|
||||
Graphic3d_CappingFlags.hxx
|
||||
Graphic3d_CLight.hxx
|
||||
Graphic3d_ClipPlane.cxx
|
||||
@@ -132,6 +133,7 @@ Graphic3d_TypeOfBackground.hxx
|
||||
Graphic3d_TypeOfComposition.hxx
|
||||
Graphic3d_TypeOfConnection.hxx
|
||||
Graphic3d_TypeOfLightSource.hxx
|
||||
Graphic3d_TypeOfLimit.hxx
|
||||
Graphic3d_TypeOfMaterial.hxx
|
||||
Graphic3d_TypeOfPrimitiveArray.hxx
|
||||
Graphic3d_TypeOfReflection.hxx
|
||||
|
@@ -112,6 +112,7 @@ void Graphic3d_Camera::CopyMappingData (const Handle(Graphic3d_Camera)& theOther
|
||||
SetZFocus (theOtherCamera->ZFocusType(), theOtherCamera->ZFocus());
|
||||
SetIOD (theOtherCamera->GetIODType(), theOtherCamera->IOD());
|
||||
SetProjectionType (theOtherCamera->ProjectionType());
|
||||
SetTile (theOtherCamera->myTile);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -425,6 +426,21 @@ void Graphic3d_Camera::SetIOD (const IODType theType, const Standard_Real theIOD
|
||||
InvalidateProjection();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetTile
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Camera::SetTile (const Graphic3d_CameraTile& theTile)
|
||||
{
|
||||
if (myTile == theTile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myTile = theTile;
|
||||
InvalidateProjection();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OrthogonalizeUp
|
||||
// purpose :
|
||||
@@ -824,6 +840,17 @@ Graphic3d_Camera::TransformMatrices<Elem_t>&
|
||||
? static_cast<Elem_t> (myZFocus * Distance())
|
||||
: static_cast<Elem_t> (myZFocus);
|
||||
|
||||
if (myTile.IsValid())
|
||||
{
|
||||
const Elem_t aDXFull = Elem_t(2) * aDXHalf;
|
||||
const Elem_t aDYFull = Elem_t(2) * aDYHalf;
|
||||
const Graphic3d_Vec2i anOffset = myTile.OffsetLowerLeft();
|
||||
aLeft = -aDXHalf + aDXFull * static_cast<Elem_t> (anOffset.x()) / static_cast<Elem_t> (myTile.TotalSize.x());
|
||||
aRight = -aDXHalf + aDXFull * static_cast<Elem_t> (anOffset.x() + myTile.TileSize.x()) / static_cast<Elem_t> (myTile.TotalSize.x());
|
||||
aBot = -aDYHalf + aDYFull * static_cast<Elem_t> (anOffset.y()) / static_cast<Elem_t> (myTile.TotalSize.y());
|
||||
aTop = -aDYHalf + aDYFull * static_cast<Elem_t> (anOffset.y() + myTile.TileSize.y()) / static_cast<Elem_t> (myTile.TotalSize.y());
|
||||
}
|
||||
|
||||
switch (myProjType)
|
||||
{
|
||||
case Projection_Orthographic :
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#ifndef _Graphic3d_Camera_HeaderFile
|
||||
#define _Graphic3d_Camera_HeaderFile
|
||||
|
||||
#include <Graphic3d_CameraTile.hxx>
|
||||
#include <Graphic3d_Mat4d.hxx>
|
||||
#include <Graphic3d_Mat4.hxx>
|
||||
#include <Graphic3d_Vec3.hxx>
|
||||
@@ -375,6 +376,14 @@ public:
|
||||
return myIODType;
|
||||
}
|
||||
|
||||
//! Get current tile.
|
||||
const Graphic3d_CameraTile& Tile() const { return myTile; }
|
||||
|
||||
//! Sets the Tile defining the drawing sub-area within View.
|
||||
//! Note that tile defining a region outside the view boundaries is also valid - use method Graphic3d_CameraTile::Cropped() to assign a cropped copy.
|
||||
//! @param theTile tile definition
|
||||
Standard_EXPORT void SetTile (const Graphic3d_CameraTile& theTile);
|
||||
|
||||
//! @name Basic camera operations
|
||||
public:
|
||||
|
||||
@@ -639,6 +648,8 @@ private:
|
||||
Standard_Real myIOD; //!< Intraocular distance value.
|
||||
IODType myIODType; //!< Intraocular distance definition type.
|
||||
|
||||
Graphic3d_CameraTile myTile;//!< Tile defining sub-area for drawing
|
||||
|
||||
mutable TransformMatrices<Standard_Real> myMatricesD;
|
||||
mutable TransformMatrices<Standard_ShortReal> myMatricesF;
|
||||
|
||||
|
88
src/Graphic3d/Graphic3d_CameraTile.hxx
Normal file
88
src/Graphic3d/Graphic3d_CameraTile.hxx
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright (c) 2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_CameraTile_HeaderFile
|
||||
#define _Graphic3d_CameraTile_HeaderFile
|
||||
|
||||
#include <Graphic3d_Vec2.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
//! Class defines the area (Tile) inside a view.
|
||||
class Graphic3d_CameraTile
|
||||
{
|
||||
public:
|
||||
|
||||
Graphic3d_Vec2i TotalSize; //!< total size of the View area, in pixels
|
||||
Graphic3d_Vec2i TileSize; //!< size of the Tile, in pixels
|
||||
Graphic3d_Vec2i Offset; //!< the lower-left corner of the Tile relative to the View area (or upper-left if IsTopDown is true), in pixels
|
||||
bool IsTopDown; //!< indicate the offset coordinate system - lower-left (default) or top-down
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
//! Initializes the empty Tile of zero size and lower-left offset orientation.
|
||||
//! Such Tile is considered uninitialized (invalid).
|
||||
Graphic3d_CameraTile() : IsTopDown (false) {}
|
||||
|
||||
//! Return true if Tile has been defined.
|
||||
bool IsValid() const
|
||||
{
|
||||
return TotalSize.x() > 0 && TotalSize.y() > 0
|
||||
&& TileSize.x() > 0 && TileSize.y() > 0;
|
||||
}
|
||||
|
||||
//! Return offset position from lower-left corner.
|
||||
Graphic3d_Vec2i OffsetLowerLeft() const
|
||||
{
|
||||
return Graphic3d_Vec2i (Offset.x(),
|
||||
!IsTopDown
|
||||
? Offset.y()
|
||||
: TotalSize.y() - Offset.y() - 1);
|
||||
}
|
||||
|
||||
//! Return the copy cropped by total size
|
||||
Graphic3d_CameraTile Cropped() const
|
||||
{
|
||||
Graphic3d_CameraTile aTile = *this;
|
||||
if (!IsValid())
|
||||
{
|
||||
return aTile;
|
||||
}
|
||||
|
||||
aTile.Offset.x() = Max (Offset.x(), 0);
|
||||
aTile.Offset.y() = Max (Offset.y(), 0);
|
||||
|
||||
const Standard_Integer anX = Min (Offset.x() + TileSize.x(), TotalSize.x());
|
||||
const Standard_Integer anY = Min (Offset.y() + TileSize.y(), TotalSize.y());
|
||||
aTile.TileSize.x() = anX - Offset.x();
|
||||
aTile.TileSize.y() = anY - Offset.y();
|
||||
return aTile;
|
||||
}
|
||||
|
||||
//! Equality check.
|
||||
bool operator== (const Graphic3d_CameraTile& theOther) const
|
||||
{
|
||||
const Graphic3d_Vec2i anOffset1 = OffsetLowerLeft();
|
||||
const Graphic3d_Vec2i anOffset2 = theOther.OffsetLowerLeft();
|
||||
return TotalSize.x() == theOther.TotalSize.x()
|
||||
&& TotalSize.y() == theOther.TotalSize.y()
|
||||
&& TileSize.x() == theOther.TileSize.x()
|
||||
&& TileSize.y() == theOther.TileSize.y()
|
||||
&& anOffset1.x() == anOffset2.x()
|
||||
&& anOffset1.y() == anOffset2.y();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_CameraTile_HeaderFile
|
@@ -46,6 +46,7 @@
|
||||
#include <Graphic3d_ZLayerId.hxx>
|
||||
#include <Graphic3d_ZLayerSettings.hxx>
|
||||
#include <Graphic3d_CLight.hxx>
|
||||
#include <Graphic3d_TypeOfLimit.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
|
||||
@@ -68,16 +69,20 @@ class Graphic3d_GraphicDriver : public MMgt_TShared
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! call_togl_inquirelight
|
||||
virtual Standard_Integer InquireLightLimit() = 0;
|
||||
|
||||
//! call_togl_inquireplane
|
||||
virtual Standard_Integer InquirePlaneLimit() = 0;
|
||||
|
||||
//! call_togl_inquireview
|
||||
virtual Standard_Integer InquireViewLimit() = 0;
|
||||
|
||||
//! Request limit of graphic resource of specific type.
|
||||
virtual Standard_Integer InquireLimit (const Graphic3d_TypeOfLimit theType) const = 0;
|
||||
|
||||
//! Request maximum number of active light sources supported by driver and hardware.
|
||||
Standard_Integer InquireLightLimit() const { return InquireLimit (Graphic3d_TypeOfLimit_MaxNbLights); }
|
||||
|
||||
//! Request maximum number of active clipping planes supported by driver and hardware.
|
||||
Standard_Integer InquirePlaneLimit() const { return InquireLimit (Graphic3d_TypeOfLimit_MaxNbClipPlanes); }
|
||||
|
||||
//! Request maximum number of views supported by driver.
|
||||
Standard_Integer InquireViewLimit() const { return InquireLimit (Graphic3d_TypeOfLimit_MaxNbViews); }
|
||||
|
||||
public:
|
||||
|
||||
//! Creates new empty graphic structure
|
||||
virtual Handle(Graphic3d_CStructure) CreateStructure (const Handle(Graphic3d_StructureManager)& theManager) = 0;
|
||||
|
||||
|
@@ -115,6 +115,7 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Integer aVPSizeY = theCamera->Tile().IsValid() ? theCamera->Tile().TotalSize.y() : theViewportHeight;
|
||||
if (Flags == Graphic3d_TMF_TriedronPers)
|
||||
{
|
||||
// reset Z focus for trihedron persistence
|
||||
@@ -126,7 +127,7 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
|
||||
// scale factor to pixels
|
||||
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
|
||||
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(theViewportHeight);
|
||||
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
|
||||
|
||||
// offset from the corner
|
||||
const Standard_Real anOffset = Point.z() * aScale;
|
||||
@@ -171,7 +172,7 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
|
||||
// scale factor to pixels
|
||||
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
|
||||
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(theViewportHeight);
|
||||
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
|
||||
gp_XYZ aCenter (0.0, 0.0, -aFocus);
|
||||
if (Point.x() != 0.0)
|
||||
{
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#ifndef _Graphic3d_TransformUtils_HeaderFile
|
||||
#define _Graphic3d_TransformUtils_HeaderFile
|
||||
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <Graphic3d_Vec.hxx>
|
||||
#include <Standard_math.hxx> // M_PI
|
||||
|
||||
|
28
src/Graphic3d/Graphic3d_TypeOfLimit.hxx
Normal file
28
src/Graphic3d/Graphic3d_TypeOfLimit.hxx
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_TypeOfLimit_HeaderFile
|
||||
#define _Graphic3d_TypeOfLimit_HeaderFile
|
||||
|
||||
//! Type of graphic resource limit.
|
||||
enum Graphic3d_TypeOfLimit
|
||||
{
|
||||
Graphic3d_TypeOfLimit_MaxNbLights, //!< maximum number of active light sources
|
||||
Graphic3d_TypeOfLimit_MaxNbClipPlanes, //!< maximum number of active clipping planes
|
||||
Graphic3d_TypeOfLimit_MaxNbViews, //!< maximum number of views
|
||||
Graphic3d_TypeOfLimit_MaxTextureSize, //!< maximum size of texture
|
||||
Graphic3d_TypeOfLimit_MaxMsaa, //!< maximum number of MSAA samples
|
||||
Graphic3d_TypeOfLimit_NB //!< number of elements in this enumeration
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TypeOfLimit_HeaderFile
|
Reference in New Issue
Block a user