1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0024291: Visualization - move Z-buffer trihedron presentation from TKOpenGl to TKV3d

Not implemented method V3d_View::TriedronEcho() and enum Aspect_TypeOfTriedronEcho have been removed.
The following methods have been removed from Graphic3d_CView class:
TriedronDisplay(), TriedronErase(), ZBufferTriedronSetup(), TriedronEcho().
New class V3d_Trihedron has been added as replacement of removed OpenGl_Trihedron
which now uses Graphic3d_TMF_TriedronPers persistence.
This commit is contained in:
isk 2016-07-08 15:01:08 +03:00 committed by apn
parent 2ec85268a1
commit caf231b050
38 changed files with 620 additions and 1744 deletions

View File

@ -1,52 +0,0 @@
// Created by: NW,JPB,CAL
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2014 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 _Aspect_TypeOfTriedronEcho_HeaderFile
#define _Aspect_TypeOfTriedronEcho_HeaderFile
//! Definition of the Triedron echo zone to highlight
//!
//! TOTE_NONE no echo zone
//! TOTE_ORIGIN a box on origin of the Triedron
//! TOTE_AXIS_X highlights the X axis
//! TOTE_AXIS_Y highlights the Y axis
//! TOTE_AXIS_Z highlights the Z axis
//! TOTE_TEXT_X highlights the X character
//! TOTE_TEXT_Y highlights the Y character
//! TOTE_TEXT_Z highlights the Z character
//! TOTE_01 to TOTE_10 not yet implemented.
enum Aspect_TypeOfTriedronEcho
{
Aspect_TOTE_NONE,
Aspect_TOTE_ORIGIN,
Aspect_TOTE_AXIS_X,
Aspect_TOTE_AXIS_Y,
Aspect_TOTE_AXIS_Z,
Aspect_TOTE_TEXT_X,
Aspect_TOTE_TEXT_Y,
Aspect_TOTE_TEXT_Z,
Aspect_TOTE_01,
Aspect_TOTE_02,
Aspect_TOTE_03,
Aspect_TOTE_04,
Aspect_TOTE_05,
Aspect_TOTE_06,
Aspect_TOTE_07,
Aspect_TOTE_08,
Aspect_TOTE_09,
Aspect_TOTE_10
};
#endif // _Aspect_TypeOfTriedronEcho_HeaderFile

View File

@ -52,7 +52,6 @@ Aspect_TypeOfMarker.hxx
Aspect_TypeOfPrimitive.hxx
Aspect_TypeOfResize.hxx
Aspect_TypeOfStyleText.hxx
Aspect_TypeOfTriedronEcho.hxx
Aspect_TypeOfTriedronPosition.hxx
Aspect_TypeOfUpdate.hxx
Aspect_Units.hxx

View File

@ -16,8 +16,6 @@
#include <Aspect_Handle.hxx>
#include <Aspect_RenderingContext.hxx>
#include <Aspect_TypeOfTriedronEcho.hxx>
#include <Aspect_TypeOfTriedronPosition.hxx>
#include <Aspect_TypeOfUpdate.hxx>
#include <Aspect_Window.hxx>
#include <Graphic3d_BufferType.hxx>
@ -261,26 +259,6 @@ public:
//! Returns True if the window associated to the view is defined.
virtual Standard_Boolean IsDefined() const = 0;
//! Displays z-buffer trihedron.
virtual void TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition = Aspect_TOTP_CENTER,
const Quantity_NameOfColor theColor = Quantity_NOC_WHITE,
const Standard_Real theScale = 0.02,
const Standard_Boolean theAsWireframe = Standard_True) = 0;
//! Erases z-buffer trihedron.
virtual void TriedronErase() = 0;
//! Setup parameters of z-buffer trihedron.
virtual void ZBufferTriedronSetup (const Quantity_NameOfColor theXColor = Quantity_NOC_RED,
const Quantity_NameOfColor theYColor = Quantity_NOC_GREEN,
const Quantity_NameOfColor theZColor = Quantity_NOC_BLUE1,
const Standard_Real theSizeRatio = 0.8,
const Standard_Real theAxisDiametr = 0.05,
const Standard_Integer theNbFacettes = 12) = 0;
//! Displays trihedron echo.
virtual void TriedronEcho (const Aspect_TypeOfTriedronEcho theType = Aspect_TOTE_NONE) = 0;
//! Returns data of a graduated trihedron
virtual const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() = 0;

View File

@ -32,7 +32,6 @@
#include <Quantity_NameOfColor.hxx>
#include <Standard_Real.hxx>
#include <Aspect_TypeOfTriedronPosition.hxx>
#include <Aspect_TypeOfTriedronEcho.hxx>
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_Vec3.hxx>
#include <Standard_ShortReal.hxx>

View File

@ -33,8 +33,6 @@ OpenGl_View.cxx
OpenGl_View_Raytrace.cxx
OpenGl_View_Redraw.cxx
OpenGl_Light.hxx
OpenGl_Trihedron.hxx
OpenGl_Trihedron.cxx
OpenGl_GraduatedTrihedron.hxx
OpenGl_GraduatedTrihedron.cxx
OpenGl_MapOfZLayerSettings.hxx
@ -74,10 +72,6 @@ OpenGl_Clipping.hxx
OpenGl_Context.cxx
OpenGl_Context.hxx
OpenGl_Context_1.mm
OpenGl_Cylinder.cxx
OpenGl_Cylinder.hxx
OpenGl_Disk.cxx
OpenGl_Disk.hxx
OpenGl_ExtGS.hxx
OpenGl_GlFunctions.hxx
OpenGl_Flipper.cxx
@ -108,8 +102,6 @@ OpenGl_IndexBuffer.cxx
OpenGl_IndexBuffer.hxx
OpenGl_Layer.cxx
OpenGl_Layer.hxx
OpenGl_Quadric.cxx
OpenGl_Quadric.hxx
OpenGl_RenderFilter.cxx
OpenGl_RenderFilter.hxx
OpenGl_Sampler.cxx
@ -125,8 +117,6 @@ OpenGl_ShaderProgram.cxx
OpenGl_ShaderProgram.hxx
OpenGl_ShaderStates.cxx
OpenGl_ShaderStates.hxx
OpenGl_Sphere.cxx
OpenGl_Sphere.hxx
OpenGl_StencilTest.cxx
OpenGl_StencilTest.hxx
OpenGl_TileSampler.hxx

View File

@ -1,71 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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.
#include <OpenGl_Cylinder.hxx>
// =======================================================================
// function : OpenGl_Cylinder
// purpose :
// =======================================================================
OpenGl_Cylinder::OpenGl_Cylinder()
: myBotRad (1.0f),
myTopRad (1.0f),
myHeight (1.0f)
{
//
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
Standard_Boolean OpenGl_Cylinder::Init (const Standard_ShortReal theBotRad,
const Standard_ShortReal theTopRad,
const Standard_ShortReal theHeight,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
{
myBotRad = theBotRad;
myTopRad = theTopRad;
myHeight = theHeight;
return OpenGl_Quadric::init (theNbSlices, theNbStacks);
}
// =======================================================================
// function : evalVertex
// purpose :
// =======================================================================
OpenGl_Vec3 OpenGl_Cylinder::evalVertex (const Standard_ShortReal theU,
const Standard_ShortReal theV) const
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aRadius = myBotRad + (myTopRad - myBotRad) * theV;
return OpenGl_Vec3 (cosf (aU) * aRadius,
sinf (aU) * aRadius,
theV * myHeight);
}
// =======================================================================
// function : evalNormal
// purpose :
// =======================================================================
OpenGl_Vec3 OpenGl_Cylinder::evalNormal (const Standard_ShortReal theU,
const Standard_ShortReal /*theV*/) const
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
return OpenGl_Vec3 (cosf (aU) * myHeight,
sinf (aU) * myHeight,
myBotRad - myTopRad).Normalized();
}

View File

@ -1,54 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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 OpenGl_Cylinder_Header
#define OpenGl_Cylinder_Header
#include <OpenGl_Quadric.hxx>
//! Tool class for generating cylinder tessellation of quadric surface.
class OpenGl_Cylinder : public OpenGl_Quadric
{
public:
//! Create undefined cylinder primitive.
Standard_EXPORT OpenGl_Cylinder();
//! Initialize cylinder primitive.
Standard_EXPORT Standard_Boolean Init (const Standard_ShortReal theBotRad,
const Standard_ShortReal theTopRad,
const Standard_ShortReal theHeight,
const Standard_Integer theNbSlices = 10,
const Standard_Integer theNbStacks = 10);
protected:
//! Returns surface point for the given parameters.
Standard_EXPORT virtual OpenGl_Vec3 evalVertex (const Standard_ShortReal theU,
const Standard_ShortReal theV) const Standard_OVERRIDE;
//! Returns surface normal for the given parameters.
Standard_EXPORT virtual OpenGl_Vec3 evalNormal (const Standard_ShortReal theU,
const Standard_ShortReal theV) const Standard_OVERRIDE;
private:
Standard_ShortReal myBotRad; //!< Radius of the cylinder at bottom
Standard_ShortReal myTopRad; //!< Radius of the cylinder at top
Standard_ShortReal myHeight; //!< Height of the cylinder
};
#endif // OpenGl_Cylinder_Header

View File

@ -1,63 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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.
#include <OpenGl_Disk.hxx>
// =======================================================================
// function : OpenGl_Disk
// purpose :
// =======================================================================
OpenGl_Disk::OpenGl_Disk()
: myInnerRadius (1.0f),
myOuterRadius (1.0f)
{
//
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
Standard_Boolean OpenGl_Disk::Init (const Standard_ShortReal theInnerRadius,
const Standard_ShortReal theOuterRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
{
myInnerRadius = theInnerRadius;
myOuterRadius = theOuterRadius;
return OpenGl_Quadric::init (theNbSlices, theNbStacks);
}
// =======================================================================
// function : evalVertex
// purpose :
// =======================================================================
OpenGl_Vec3 OpenGl_Disk::evalVertex (const Standard_ShortReal theU,
const Standard_ShortReal theV) const
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
return OpenGl_Vec3 (cosf (aU) * aRadius, sinf (aU) * aRadius, 0.0f);
}
// =======================================================================
// function : evalNormal
// purpose :
// =======================================================================
OpenGl_Vec3 OpenGl_Disk::evalNormal (const Standard_ShortReal /*theU*/,
const Standard_ShortReal /*theV*/) const
{
return OpenGl_Vec3 (0.0f, 0.0f, -1.0f);
}

View File

@ -1,52 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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 OpenGl_Disk_Header
#define OpenGl_Disk_Header
#include <OpenGl_Quadric.hxx>
//! Tool class for generating disk (circle) tessellation.
class OpenGl_Disk : public OpenGl_Quadric
{
public:
//! Create uninitialized disk (circle) primitive.
Standard_EXPORT OpenGl_Disk();
//! Initialize disk (circle) primitive.
Standard_EXPORT Standard_Boolean Init (const Standard_ShortReal theInnerRadius,
const Standard_ShortReal theOuterRadius,
const Standard_Integer theNbSlices = 10,
const Standard_Integer theNbStacks = 10);
protected:
//! Returns surface point for the given parameters.
Standard_EXPORT virtual OpenGl_Vec3 evalVertex (const Standard_ShortReal theU,
const Standard_ShortReal theV) const Standard_OVERRIDE;
//! Returns surface normal for the given parameters.
Standard_EXPORT virtual OpenGl_Vec3 evalNormal (const Standard_ShortReal theU,
const Standard_ShortReal theV) const Standard_OVERRIDE;
private:
Standard_ShortReal myInnerRadius; //!< Inner radius of the disk
Standard_ShortReal myOuterRadius; //!< Outer radius of the disk
};
#endif // OpenGl_Disk_Header

View File

@ -26,7 +26,6 @@
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Cylinder.hxx>
#include <Precision.hxx>
#ifndef _WIN32

View File

@ -25,7 +25,6 @@
#include <OpenGl_View.hxx>
#include <OpenGl_StencilTest.hxx>
#include <OpenGl_Text.hxx>
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_Workspace.hxx>
#include <Aspect_GraphicDeviceDefinitionError.hxx>

View File

@ -23,7 +23,6 @@
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_FillMethod.hxx>
#include <Aspect_TypeOfTriedronPosition.hxx>
#include <Aspect_TypeOfTriedronEcho.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_RenderingContext.hxx>
#include <gp_Ax2.hxx>

View File

@ -1,117 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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.
#include <OpenGl_Quadric.hxx>
#include <NCollection_AlignedAllocator.hxx>
// =======================================================================
// function : OpenGl_Quadric
// purpose :
// =======================================================================
OpenGl_Quadric::OpenGl_Quadric()
: OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_TRIANGLES, NULL, NULL, NULL),
myNbSlices (0),
myNbStacks (0)
{
myDrawMode = GL_TRIANGLES;
}
// =======================================================================
// function : init
// purpose :
// =======================================================================
Standard_Boolean OpenGl_Quadric::init (const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
{
myNbSlices = theNbSlices;
myNbStacks = theNbStacks;
return createArrays();
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_Quadric::Release (OpenGl_Context* theContext)
{
myNbSlices = 0;
myNbStacks = 0;
OpenGl_PrimitiveArray::Release (theContext);
}
// =======================================================================
// function : createArrays
// purpose :
// =======================================================================
Standard_Boolean OpenGl_Quadric::createArrays() const
{
// Evaluate surface points and normals
Graphic3d_Attribute anAttribsInfo[] =
{
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC3 },
{ Graphic3d_TOA_NORM, Graphic3d_TOD_VEC3 }
};
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
myAttribs = new Graphic3d_Buffer (anAlloc);
myIndices = new Graphic3d_IndexBuffer (anAlloc);
if (!myAttribs->Init (NbVertices(), anAttribsInfo, 2))
{
return Standard_False;
}
const Standard_Integer aNbIndices = NbTriangles() * 3;
if (aNbIndices < Standard_Integer(USHRT_MAX))
{
if (!myIndices->Init<GLushort> (aNbIndices))
{
return Standard_False;
}
}
else if (!myIndices->Init<GLuint> (aNbIndices))
{
return Standard_False;
}
const Standard_ShortReal aStepU = 1.0f / myNbSlices;
const Standard_ShortReal aStepV = 1.0f / myNbStacks;
for (Standard_Integer aU = 0; aU <= myNbSlices; ++aU)
{
const Standard_ShortReal aParamU = aU * aStepU;
for (Standard_Integer aV = 0; aV <= myNbStacks; ++aV)
{
const Standard_ShortReal aParamV = aV * aStepV;
const Standard_Integer aVertId = aU * (myNbStacks + 1) + aV;
Graphic3d_Vec3* aVertData = reinterpret_cast<Graphic3d_Vec3* >(myAttribs->changeValue (aVertId));
aVertData[0] = evalVertex (aParamU, aParamV);
aVertData[1] = evalNormal (aParamU, aParamV);
}
}
// Extract triangle indices
for (Standard_Integer aU = 0, aLastIndex = -1; aU < myNbSlices; ++aU)
{
for (Standard_Integer aV = 0; aV < myNbStacks; ++aV)
{
myIndices->SetIndex (++aLastIndex, aU * (myNbStacks + 1) + aV);
myIndices->SetIndex (++aLastIndex, (aU + 1) * (myNbStacks + 1) + aV);
myIndices->SetIndex (++aLastIndex, (aU + 1) * (myNbStacks + 1) + (aV + 1));
myIndices->SetIndex (++aLastIndex, (aU + 1) * (myNbStacks + 1) + (aV + 1));
myIndices->SetIndex (++aLastIndex, aU * (myNbStacks + 1) + (aV + 1));
myIndices->SetIndex (++aLastIndex, aU * (myNbStacks + 1) + aV);
}
}
return Standard_True;
}

View File

@ -1,74 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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 OpenGl_Quadric_Header
#define OpenGl_Quadric_Header
#include <OpenGl_PrimitiveArray.hxx>
//! Class for rendering of arbitrary primitive array.
//! Tool class for generating tessellation of quadric surface.
class OpenGl_Quadric : public OpenGl_PrimitiveArray
{
public:
//! Creates undefined abstract quadric surface
Standard_EXPORT OpenGl_Quadric();
//! Returns true if quadric has been defined
Standard_Boolean IsDefined() const { return myNbSlices != 0; }
//! Returns number of slices
Standard_Integer NbSlices() const { return myNbSlices; }
//! Returns number of stacks
Standard_Integer NbStacks() const { return myNbStacks; }
//! Returns total number of vertices
Standard_Integer NbVertices() const { return (myNbSlices + 1) * (myNbStacks + 1); }
//! Returns total number of triangles
Standard_Integer NbTriangles() const { return myNbSlices * myNbStacks * 2; }
//! Release GL resources
virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
protected:
//! Returns surface point for the given parameters.
virtual OpenGl_Vec3 evalVertex (const Standard_ShortReal theU,
const Standard_ShortReal theV) const = 0;
//! Returns surface normal for the given parameters.
virtual OpenGl_Vec3 evalNormal (const Standard_ShortReal theU,
const Standard_ShortReal theV) const = 0;
//! Initialize primitive.
Standard_EXPORT Standard_Boolean init (const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks);
private:
//! Initialize arrays.
Standard_Boolean createArrays() const;
private:
Standard_Integer myNbSlices; //!< Number of slices (u partitions)
Standard_Integer myNbStacks; //!< Number of stacks (v partitions)
};
#endif // OpenGl_Quadric_Header

View File

@ -1,66 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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.
#include <OpenGl_Sphere.hxx>
// =======================================================================
// function : OpenGl_Sphere
// purpose :
// =======================================================================
OpenGl_Sphere::OpenGl_Sphere()
: myRadius (1.0f)
{
//
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
Standard_Boolean OpenGl_Sphere::Init (const Standard_ShortReal theRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
{
myRadius = theRadius;
return OpenGl_Quadric::init (theNbSlices, theNbStacks);
}
// =======================================================================
// function : evalVertex
// purpose :
// =======================================================================
OpenGl_Vec3 OpenGl_Sphere::evalVertex (const Standard_ShortReal theU,
const Standard_ShortReal theV) const
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
return OpenGl_Vec3 (myRadius * cosf (aU) * sinf (aV),
-myRadius * sinf (aU) * sinf (aV),
myRadius * cosf (aV));
}
// =======================================================================
// function : evalNormal
// purpose :
// =======================================================================
OpenGl_Vec3 OpenGl_Sphere::evalNormal (const Standard_ShortReal theU,
const Standard_ShortReal theV) const
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
return OpenGl_Vec3 (cosf (aU) * sinf (aV),
-sinf (aU) * sinf (aV),
cosf (aV));
}

View File

@ -1,50 +0,0 @@
// Created on: 2014-10-15
// Created by: Denis Bogolepov
// Copyright (c) 2014 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 OpenGl_Sphere_Header
#define OpenGl_Sphere_Header
#include <OpenGl_Quadric.hxx>
//! Tool class for generating sphere tessellation.
class OpenGl_Sphere : public OpenGl_Quadric
{
public:
//! Creates undefined sphere primitive.
Standard_EXPORT OpenGl_Sphere();
//! Initialize sphere primitive.
Standard_EXPORT Standard_Boolean Init (const Standard_ShortReal theRadius,
const Standard_Integer theNbSlices = 10,
const Standard_Integer theNbStacks = 10);
protected:
//! Returns surface point for the given parameters.
Standard_EXPORT virtual OpenGl_Vec3 evalVertex (const Standard_ShortReal theU,
const Standard_ShortReal theV) const Standard_OVERRIDE;
//! Returns surface normal for the given parameters.
Standard_EXPORT virtual OpenGl_Vec3 evalNormal (const Standard_ShortReal theU,
const Standard_ShortReal theV) const Standard_OVERRIDE;
protected:
Standard_ShortReal myRadius; //!< Sphere radius
};
#endif // OpenGl_Sphere_Header

View File

@ -1,659 +0,0 @@
// Created on: 2011-09-20
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2014 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.
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_GlCore11.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_TransformUtils.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Workspace.hxx>
#include <Precision.hxx>
namespace
{
static const OpenGl_TextParam THE_LABEL_PARAMS =
{
16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
};
}
// =======================================================================
// function : resetTransformations
// purpose :
// =======================================================================
void OpenGl_Trihedron::resetTransformations (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
const Handle(Graphic3d_Camera)& aCamera = theWorkspace->View()->Camera();
double anU = 1.0;
double aV = 1.0;
if (aCamera->ViewDimensions().X() < aCamera->ViewDimensions().Y())
{
aV = aCamera->ViewDimensions().Y() / aCamera->ViewDimensions().X();
}
else
{
anU = aCamera->ViewDimensions().X() / aCamera->ViewDimensions().Y();
}
// Reading the transformation matrices and projection of sight
// to cancel translations (last columns of matrices).
OpenGl_Mat4d aModelMatrix;
OpenGl_Mat4d aProjMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
// Cancel the translation that can be assigned to the view
aModelMatrix.ChangeValue (0, 3) = 0.0;
aModelMatrix.ChangeValue (1, 3) = 0.0;
aModelMatrix.ChangeValue (2, 3) = 0.0;
aProjMatrix.ChangeValue (0, 0) = 2.0 / anU;
aProjMatrix.ChangeValue (1, 0) = 0.0;
aProjMatrix.ChangeValue (2, 0) = 0.0;
aProjMatrix.ChangeValue (3, 0) = 0.0;
aProjMatrix.ChangeValue (0, 1) = 0.0;
aProjMatrix.ChangeValue (1, 1) = 2.0 / aV;
aProjMatrix.ChangeValue (2, 1) = 0.0;
aProjMatrix.ChangeValue (3, 1) = 0.0;
aProjMatrix.ChangeValue (0, 2) = 0.0;
aProjMatrix.ChangeValue (1, 2) = 0.0;
aProjMatrix.ChangeValue (2, 2) = -2.0 * 0.01;
aProjMatrix.ChangeValue (3, 2) = 0.0;
aProjMatrix.ChangeValue (0, 3) = 0.0;
aProjMatrix.ChangeValue (1, 3) = 0.0;
aProjMatrix.ChangeValue (2, 3) = 0.0;
aProjMatrix.ChangeValue (3, 3) = 1.0;
// Define trihedron position in the view
switch (myPos)
{
case Aspect_TOTP_LEFT_LOWER:
{
Graphic3d_TransformUtils::Translate (aProjMatrix,
-0.5 * anU + myScale, -0.5 * aV + myScale, 0.0);
break;
}
case Aspect_TOTP_LEFT_UPPER:
{
Graphic3d_TransformUtils::Translate (aProjMatrix,
-0.5 * anU + myScale, 0.5 * aV - myScale - myScale / 3.0, 0.0);
break;
}
case Aspect_TOTP_RIGHT_LOWER:
{
Graphic3d_TransformUtils::Translate (aProjMatrix,
0.5 * anU - myScale - myScale / 3.0, -0.5 * aV + myScale, 0.0);
break;
}
case Aspect_TOTP_RIGHT_UPPER:
{
Graphic3d_TransformUtils::Translate (aProjMatrix,
0.5 * anU - myScale - myScale / 3.0, 0.5 * aV - myScale - myScale / 3.0, 0.0);
break;
}
//case Aspect_TOTP_CENTER:
default:
break;
}
aContext->ProjectionState.SetCurrent<Standard_Real> (aProjMatrix);
aContext->ApplyProjectionMatrix();
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelMatrix);
aContext->ApplyWorldViewMatrix();
}
// =======================================================================
// function : redraw
// purpose :
// =======================================================================
void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
aContext->WorldViewState.Push();
aContext->ProjectionState.Push();
resetTransformations (theWorkspace);
// Set trihedron size parameters
GLdouble aScale = myScale;
aScale *= myRatio;
const Standard_Real aLineRatio = 0.75;
const GLdouble aLineLength = aScale * aLineRatio;
const GLdouble aConeDiametr = aScale * myDiameter;
const GLdouble aConeLength = aScale * (1.0 - aLineRatio);
const GLdouble aRayon = aScale / 30.0;
// Create primitive line here for changing length
if (!myLine.IsInitialized())
{
Handle(Graphic3d_ArrayOfSegments) aGraphicArray = new Graphic3d_ArrayOfSegments (2);
aGraphicArray->AddVertex (0.0, 0.0, 0.0);
aGraphicArray->AddVertex (0.0, 0.0, aLineLength);
myLine.InitBuffers (aContext, Graphic3d_TOPA_SEGMENTS, aGraphicArray->Indices(),
aGraphicArray->Attributes(),
aGraphicArray->Bounds());
}
if (!myCircle.IsInitialized())
{
const Standard_Integer THE_CIRCLE_SERMENTS_NB = 24;
Handle(Graphic3d_ArrayOfPolylines) anCircleArray = new Graphic3d_ArrayOfPolylines (THE_CIRCLE_SERMENTS_NB + 2);
const Standard_Real THE_CIRCLE_SEGMENT_ANGLE = 2.0 * M_PI / THE_CIRCLE_SERMENTS_NB;
for (Standard_Integer anIt = THE_CIRCLE_SERMENTS_NB; anIt >= 0; --anIt)
{
anCircleArray->AddVertex (aRayon * sin (anIt * THE_CIRCLE_SEGMENT_ANGLE),
aRayon * cos (anIt * THE_CIRCLE_SEGMENT_ANGLE), 0.0);
}
anCircleArray->AddVertex (aRayon * sin (THE_CIRCLE_SERMENTS_NB * THE_CIRCLE_SEGMENT_ANGLE),
aRayon * cos (THE_CIRCLE_SERMENTS_NB * THE_CIRCLE_SEGMENT_ANGLE), 0.0);
myCircle.InitBuffers (aContext, Graphic3d_TOPA_POLYLINES, anCircleArray->Indices(),
anCircleArray->Attributes(), anCircleArray->Bounds());
}
if (!myDisk.IsInitialized())
{
myDisk.Init (0.0, static_cast<GLfloat> (aConeDiametr), myNbFacettes, 1);
}
if (!myCone.IsInitialized())
{
myCone.Init (static_cast<GLfloat> (aConeDiametr), 0.0f, static_cast<GLfloat> (aConeLength), myNbFacettes, 1);
}
OpenGl_AspectFace anAspectX;
OpenGl_AspectFace anAspectY;
OpenGl_AspectFace anAspectZ;
OpenGl_AspectLine anAspectLine;
anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb()));
anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb()));
anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb()));
OpenGl_Mat4d aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
OpenGl_Mat4d aModelViewX (aModelMatrix);
OpenGl_Mat4d aModelViewY (aModelMatrix);
OpenGl_Mat4d aModelViewZ (aModelMatrix);
// Set line aspect
const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->ApplyAspectLine();
Handle(Graphic3d_AspectLine3d) anAspectLine3d = new Graphic3d_AspectLine3d (Quantity_Color(), aCurrentAspectLine->Aspect()->Type(), aCurrentAspectLine->Aspect()->Width());
anAspectLine.SetAspect (anAspectLine3d);
// Disable depth test and face culling
GLboolean wasDepthMaskEnabled = GL_FALSE;
GLint aDepthFuncBack = 0, aCullFaceModeBack = GL_BACK;
const GLboolean wasDepthEnabled = aContext->core11fwd->glIsEnabled (GL_DEPTH_TEST);
const GLboolean wasCullFaceEnabled = aContext->core11fwd->glIsEnabled (GL_CULL_FACE);
aContext->core11fwd->glGetIntegerv (GL_DEPTH_FUNC, &aDepthFuncBack);
aContext->core11fwd->glGetIntegerv (GL_CULL_FACE_MODE, &aCullFaceModeBack);
aContext->core11fwd->glGetBooleanv (GL_DEPTH_WRITEMASK, &wasDepthMaskEnabled);
if (!wasDepthEnabled)
{
aContext->core11fwd->glEnable (GL_DEPTH_TEST);
aContext->core11fwd->glClear (GL_DEPTH_BUFFER_BIT);
}
if (!wasDepthMaskEnabled)
{
aContext->core11fwd->glDepthMask (GL_TRUE);
}
aContext->core11fwd->glCullFace (GL_BACK);
if (!wasCullFaceEnabled)
{
aContext->core11fwd->glEnable (GL_CULL_FACE);
}
// Origin
myCircle.Render (theWorkspace);
// Z axis
const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace(&anAspectZ);
anAspectLine3d->SetColor (Quantity_Color (myZColor.rgb()));
theWorkspace->SetAspectLine (&anAspectLine);
myLine.Render (theWorkspace);
Graphic3d_TransformUtils::Translate (aModelViewZ, 0.0, 0.0, aLineLength);
aContext->WorldViewState.SetCurrent<Standard_Real>(aModelViewZ);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
myCone.Render (theWorkspace);
// X axis
theWorkspace->SetAspectFace (&anAspectX);
Graphic3d_TransformUtils::Rotate (aModelViewX, 90.0, 0.0, aScale, 0.0);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
anAspectLine3d->SetColor (Quantity_Color (myXColor.rgb()));
theWorkspace->SetAspectLine (&anAspectLine);
myLine.Render (theWorkspace);
Graphic3d_TransformUtils::Translate (aModelViewX, 0.0, 0.0, aLineLength);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
myCone.Render (theWorkspace);
// Y axis
theWorkspace->SetAspectFace (&anAspectY);
Graphic3d_TransformUtils::Rotate (aModelViewY, -90.0, aScale, 0.0, 0.0);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
anAspectLine3d->SetColor (Quantity_Color (myYColor.rgb()));
theWorkspace->SetAspectLine (&anAspectLine);
myLine.Render (theWorkspace);
Graphic3d_TransformUtils::Translate (aModelViewY, 0.0, 0.0, aLineLength);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
myCone.Render (theWorkspace);
// Restore aspects
theWorkspace->SetAspectFace (anOldAspectFace);
if (!wasDepthEnabled)
{
aContext->core11fwd->glDisable (GL_DEPTH_TEST);
}
if (!wasDepthMaskEnabled)
{
aContext->core11fwd->glDepthMask (GL_FALSE);
}
if (!wasCullFaceEnabled)
{
aContext->core11fwd->glDisable (GL_CULL_FACE);
}
aContext->core11fwd->glCullFace (aCullFaceModeBack);
// Always write the text
aContext->core11fwd->glDepthFunc (GL_ALWAYS);
// Render labels
myLabelX.SetPosition (OpenGl_Vec3 (float (aScale + 2.0 * aRayon), 0.0f, float (-aRayon)));
myLabelY.SetPosition (OpenGl_Vec3 (float (aRayon), float (aScale + 3.0 * aRayon), float (2.0 * aRayon)));
myLabelZ.SetPosition (OpenGl_Vec3 (float (-2.0 * aRayon), float (0.5 * aRayon), float (aScale + 3.0 * aRayon)));
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelMatrix);
aContext->ApplyWorldViewMatrix();
myLabelX.Render (theWorkspace);
myLabelY.Render (theWorkspace);
myLabelZ.Render (theWorkspace);
aContext->core11fwd->glDepthFunc (aDepthFuncBack);
aContext->WorldViewState.Pop();
aContext->ProjectionState.Pop();
aContext->ApplyProjectionMatrix();
}
// =======================================================================
// function : redrawZBuffer
// purpose :
// =======================================================================
void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspace) const
{
Handle(OpenGl_Context) aContext = theWorkspace->GetGlContext();
aContext->WorldViewState.Push();
aContext->ProjectionState.Push();
resetTransformations (theWorkspace);
const GLdouble aScale = myScale * myRatio;
const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
const OpenGl_Vec4& aLineColor = anAspectLine->Aspect()->ColorRGBA();
// Create the trihedron
const Standard_Real THE_CYLINDER_LENGTH = 0.75;
const GLdouble aCylinderLength = aScale * THE_CYLINDER_LENGTH;
const GLdouble aCylinderDiametr = aScale * myDiameter;
const GLdouble aConeDiametr = aCylinderDiametr * 2.0;
const GLdouble aConeLength = aScale * (1.0 - THE_CYLINDER_LENGTH);
// Position des Axes
GLdouble aTriedronAxeX[3] = { aScale, 0.0, 0.0 };
GLdouble aTriedronAxeY[3] = { 0.0, aScale, 0.0 };
if (!myDisk.IsInitialized())
{
myDisk.Init (static_cast<GLfloat> (aCylinderDiametr),
static_cast<GLfloat> (aConeDiametr),
myNbFacettes, 1);
}
if (!mySphere.IsInitialized())
{
mySphere.Init (static_cast<GLfloat> (aCylinderDiametr * 2.0), myNbFacettes, myNbFacettes);
}
if (!myCone.IsInitialized())
{
myCone.Init (static_cast<GLfloat> (aConeDiametr), 0.0f, static_cast<GLfloat> (aConeLength), myNbFacettes, 1);
}
if (!myCylinder.IsInitialized())
{
myCylinder.Init (static_cast<GLfloat> (aCylinderDiametr),
static_cast<GLfloat> (aCylinderDiametr),
static_cast<GLfloat> (aCylinderLength),
myNbFacettes, 1);
}
GLboolean wasDepthMaskEnabled = GL_FALSE;
GLint aDepthFuncBack = 0, aCullFaceModeBack = GL_BACK;
const GLboolean wasDepthEnabled = aContext->core11fwd->glIsEnabled (GL_DEPTH_TEST);
const GLboolean wasCullFaceEnabled = aContext->core11fwd->glIsEnabled (GL_CULL_FACE);
aContext->core11fwd->glGetIntegerv (GL_DEPTH_FUNC, &aDepthFuncBack);
aContext->core11fwd->glGetIntegerv (GL_CULL_FACE_MODE, &aCullFaceModeBack);
aContext->core11fwd->glGetBooleanv (GL_DEPTH_WRITEMASK, &wasDepthMaskEnabled);
if (!wasDepthEnabled)
{
aContext->core11fwd->glEnable (GL_DEPTH_TEST);
aContext->core11fwd->glClear (GL_DEPTH_BUFFER_BIT);
}
if (!wasDepthMaskEnabled)
{
aContext->core11fwd->glDepthMask (GL_TRUE);
}
aContext->core11fwd->glCullFace (GL_BACK);
if (!wasCullFaceEnabled)
{
aContext->core11fwd->glEnable (GL_CULL_FACE);
}
OpenGl_AspectFace anAspectC;
OpenGl_AspectFace anAspectX;
OpenGl_AspectFace anAspectY;
OpenGl_AspectFace anAspectZ;
anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb()));
anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb()));
anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb()));
anAspectC.Aspect()->SetInteriorColor (Quantity_Color (aLineColor.rgb()));
OpenGl_Mat4d aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
for (Standard_Integer aPass = 0; aPass < 2; ++aPass)
{
OpenGl_Mat4d aModelViewX (aModelMatrix);
OpenGl_Mat4d aModelViewY (aModelMatrix);
OpenGl_Mat4d aModelViewZ (aModelMatrix);
aContext->core11fwd->glDepthFunc (aPass == 0 ? GL_ALWAYS : GL_LEQUAL);
const OpenGl_AspectFace* anOldAspect = theWorkspace->SetAspectFace (&anAspectC);
// Origin
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelMatrix);
aContext->ApplyWorldViewMatrix();
mySphere.Render (theWorkspace);
// Z axis
theWorkspace->SetAspectFace (&anAspectZ);
myCylinder.Render (theWorkspace);
Graphic3d_TransformUtils::Translate (aModelViewZ, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewZ);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
myCone.Render (theWorkspace);
// X axis
theWorkspace->SetAspectFace (&anAspectX);
Graphic3d_TransformUtils::Rotate (aModelViewX, 90.0, aTriedronAxeY[0], aTriedronAxeY[1], aTriedronAxeY[2]);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
myCylinder.Render (theWorkspace);
Graphic3d_TransformUtils::Translate (aModelViewX, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
myCone.Render (theWorkspace);
// Y axis
theWorkspace->SetAspectFace (&anAspectY);
Graphic3d_TransformUtils::Rotate (aModelViewY, -90.0, aTriedronAxeX[0], aTriedronAxeX[1], aTriedronAxeX[2]);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
myCylinder.Render (theWorkspace);
Graphic3d_TransformUtils::Translate (aModelViewY, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
myCone.Render (theWorkspace);
theWorkspace->SetAspectFace (anOldAspect);
}
if (!wasDepthEnabled)
{
aContext->core11fwd->glDisable (GL_DEPTH_TEST);
}
if (!wasDepthMaskEnabled)
{
aContext->core11fwd->glDepthMask (GL_FALSE);
}
if (!wasCullFaceEnabled)
{
aContext->core11fwd->glDisable (GL_CULL_FACE);
}
aContext->core11fwd->glCullFace (aCullFaceModeBack);
// Always write the text
aContext->core11fwd->glDepthFunc (GL_ALWAYS);
// draw axes labels
const GLdouble rayon = aScale / 30.0;
myLabelX.SetPosition (OpenGl_Vec3(float(aScale + 2.0 * rayon), 0.0f, float(-rayon)));
myLabelY.SetPosition (OpenGl_Vec3(float(rayon), float(aScale + 3.0 * rayon), float(2.0 * rayon)));
myLabelZ.SetPosition (OpenGl_Vec3(float(-2.0 * rayon), float(0.5 * rayon), float(aScale + 3.0 * rayon)));
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelMatrix);
aContext->ApplyWorldViewMatrix();
myLabelX.Render (theWorkspace);
myLabelY.Render (theWorkspace);
myLabelZ.Render (theWorkspace);
aContext->core11fwd->glDepthFunc (aDepthFuncBack);
aContext->WorldViewState.Pop();
aContext->ProjectionState.Pop();
aContext->ApplyProjectionMatrix();
}
// =======================================================================
// function : OpenGl_Trihedron
// purpose :
// =======================================================================
OpenGl_Trihedron::OpenGl_Trihedron()
: myPos (Aspect_TOTP_LEFT_LOWER),
myScale (1.0),
myIsWireframe (Standard_False),
myXColor (1.0f, 0.0f, 0.0f, 0.6f),
myYColor (0.0f, 1.0f, 0.0f, 0.6f),
myZColor (0.0f, 0.0f, 1.0f, 0.6f),
myRatio (0.8f),
myDiameter (0.05f),
myNbFacettes (12),
myLabelX ("X", OpenGl_Vec3(1.0f, 0.0f, 0.0f), THE_LABEL_PARAMS),
myLabelY ("Y", OpenGl_Vec3(0.0f, 1.0f, 0.0f), THE_LABEL_PARAMS),
myLabelZ ("Z", OpenGl_Vec3(0.0f, 0.0f, 1.0f), THE_LABEL_PARAMS),
myLine (NULL), // do not register arrays UID - trihedron is not intended to be drawn by Ray Tracing engine
myCircle (NULL)
{
myAspectLine.SetAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
myAspectText.Aspect()->SetColor (Quantity_NOC_WHITE);
myAspectText.Aspect()->SetFont ("Courier");
}
// =======================================================================
// function : ~OpenGl_Trihedron
// purpose :
// =======================================================================
OpenGl_Trihedron::~OpenGl_Trihedron()
{
//
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_Trihedron::Release (OpenGl_Context* theCtx)
{
myLabelX.Release (theCtx);
myLabelY.Release (theCtx);
myLabelZ.Release (theCtx);
myAspectLine.Release (theCtx);
myAspectText.Release (theCtx);
myCone .Release (theCtx);
myDisk .Release (theCtx);
mySphere .Release (theCtx);
myCylinder.Release (theCtx);
myLine.Release (theCtx);
myCircle.Release (theCtx);
}
// =======================================================================
// function : invalidate
// purpose :
// =======================================================================
void OpenGl_Trihedron::invalidate()
{
myCone .Invalidate();
myDisk .Invalidate();
mySphere .Invalidate();
myCylinder.Invalidate();
myLine .Invalidate();
myCircle .Invalidate();
}
// =======================================================================
// function : SetScale
// purpose :
// =======================================================================
void OpenGl_Trihedron::SetScale (const Standard_Real theScale)
{
if (Abs (myScale - theScale) > Precision::Confusion())
{
invalidate();
}
myScale = theScale;
}
// =======================================================================
// function : SetSizeRatio
// purpose :
// =======================================================================
void OpenGl_Trihedron::SetSizeRatio (const Standard_Real theRatio)
{
if (Abs (Standard_Real(myRatio) - theRatio) > Precision::Confusion())
{
invalidate();
}
myRatio = float(theRatio);
}
// =======================================================================
// function : SetArrowDiameter
// purpose :
// =======================================================================
void OpenGl_Trihedron::SetArrowDiameter (const Standard_Real theDiam)
{
if (Abs (Standard_Real(myDiameter) - theDiam) > Precision::Confusion())
{
invalidate();
}
myDiameter = float(theDiam);
}
// =======================================================================
// function : SetNbFacets
// purpose :
// =======================================================================
void OpenGl_Trihedron::SetNbFacets (const Standard_Integer theNbFacets)
{
if (Abs (myNbFacettes - theNbFacets) > 0)
{
invalidate();
}
myNbFacettes = theNbFacets;
}
// =======================================================================
// function : SetLabelsColor
// purpose :
// =======================================================================
void OpenGl_Trihedron::SetLabelsColor (const Quantity_Color& theColor)
{
myAspectText.Aspect()->SetColor (theColor);
}
// =======================================================================
// function : SetArrowsColors
// purpose :
// =======================================================================
void OpenGl_Trihedron::SetArrowsColors (const Quantity_Color& theColorX,
const Quantity_Color& theColorY,
const Quantity_Color& theColorZ)
{
myXColor = OpenGl_Vec4 (float(theColorX.Red()), float(theColorX.Green()), float(theColorX.Blue()), 0.6f);
myYColor = OpenGl_Vec4 (float(theColorY.Red()), float(theColorY.Green()), float(theColorY.Blue()), 0.6f);
myZColor = OpenGl_Vec4 (float(theColorZ.Red()), float(theColorZ.Green()), float(theColorZ.Blue()), 0.6f);
}
// =======================================================================
// function : Render
// purpose :
// =======================================================================
void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->SetAspectLine (&myAspectLine);
const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectText);
/* check if GL_LIGHTING should be disabled
no enabling 'cause it will be done (if necessary: kinda Polygon types )
during redrawing structures
*/
if (!theWorkspace->UseGLLight())
{
#if !defined(GL_ES_VERSION_2_0)
glDisable (GL_LIGHTING);
#endif
}
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
theWorkspace->GetGlContext()->ApplyModelViewMatrix();
if (myIsWireframe)
{
redraw (theWorkspace);
}
else
{
redrawZBuffer (theWorkspace);
}
// restore aspects
if (!aPrevTexture.IsNull())
{
theWorkspace->EnableTexture (aPrevTexture);
}
theWorkspace->SetAspectText (aPrevAspectText);
theWorkspace->SetAspectLine (aPrevAspectLine);
}

View File

@ -1,118 +0,0 @@
// Created on: 2011-09-20
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2013 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 _OpenGl_Trihedron_Header
#define _OpenGl_Trihedron_Header
#include <OpenGl_Element.hxx>
#include <Aspect_TypeOfTriedronPosition.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Cylinder.hxx>
#include <OpenGl_Disk.hxx>
#include <OpenGl_Sphere.hxx>
#include <OpenGl_Text.hxx>
#include <Quantity_NameOfColor.hxx>
//! Class render trihedron
class OpenGl_Trihedron : public OpenGl_Element
{
public:
//! Default constructor.
OpenGl_Trihedron();
//! Destructor.
virtual ~OpenGl_Trihedron();
//! Render the element.
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
//! Release OpenGL resources.
virtual void Release (OpenGl_Context* theCtx);
public:
//! Switch wireframe / shaded trihedron.
void SetWireframe (const Standard_Boolean theAsWireframe) { myIsWireframe = theAsWireframe; }
//! Setup the corner to draw the trihedron.
void SetPosition (const Aspect_TypeOfTriedronPosition thePosition) { myPos = thePosition; }
//! Setup the scale factor.
void SetScale (const Standard_Real theScale);
//! Setup the size ratio factor.
void SetSizeRatio (const Standard_Real theRatio);
//! Setup the arrow diameter.
void SetArrowDiameter (const Standard_Real theDiam);
//! Setup the number of facets for tessellation.
void SetNbFacets (const Standard_Integer theNbFacets);
//! Setup color of text labels.
void SetLabelsColor (const Quantity_Color& theColor);
//! Setup per-arrow color.
void SetArrowsColors (const Quantity_Color& theColorX,
const Quantity_Color& theColorY,
const Quantity_Color& theColorZ);
protected:
//! Invalidate Primitive Arrays.
void invalidate();
void redraw(const Handle(OpenGl_Workspace)& theWorkspace) const;
void redrawZBuffer(const Handle(OpenGl_Workspace)& theWorkspace) const;
//! Resets current model-view and projection transformations and sets
//! translation for trihedron position
//! @sa Aspect_TypeOfTriedronPosition
void resetTransformations (const Handle(OpenGl_Workspace)& theWorkspace) const;
protected:
Aspect_TypeOfTriedronPosition myPos;
Standard_Real myScale;
Standard_Boolean myIsWireframe;
OpenGl_Vec4 myXColor;
OpenGl_Vec4 myYColor;
OpenGl_Vec4 myZColor;
float myRatio;
float myDiameter;
int myNbFacettes;
OpenGl_AspectLine myAspectLine;
OpenGl_AspectText myAspectText;
mutable OpenGl_Text myLabelX;
mutable OpenGl_Text myLabelY;
mutable OpenGl_Text myLabelZ;
mutable OpenGl_Cylinder myCylinder;
mutable OpenGl_Sphere mySphere;
mutable OpenGl_Cylinder myCone;
mutable OpenGl_Disk myDisk;
mutable OpenGl_PrimitiveArray myLine;
mutable OpenGl_PrimitiveArray myCircle;
public:
DEFINE_STANDARD_ALLOC
};
#endif //_OpenGl_Trihedron_Header

View File

@ -29,7 +29,6 @@
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_Window.hxx>
#include <OpenGl_Workspace.hxx>
#include <Standard_CLocaleSentry.hxx>
@ -60,7 +59,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
myBgColor (Quantity_NOC_BLACK),
myCamera (new Graphic3d_Camera()),
myUseGLLight (Standard_True),
myToShowTrihedron (false),
myToShowGradTrihedron (false),
myStateCounter (theCounter),
myLastLightSourceState (0, 0),
@ -124,7 +122,6 @@ OpenGl_View::~OpenGl_View()
// =======================================================================
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
{
myTrihedron .Release (theCtx.operator->());
myGraduatedTrihedron.Release (theCtx.operator->());
if (!myTextureEnv.IsNull())
@ -259,58 +256,6 @@ void OpenGl_View::Resized()
myWindow->Resize();
}
// =======================================================================
// function : TriedronDisplay
// purpose :
// =======================================================================
void OpenGl_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
const Quantity_NameOfColor theColor,
const Standard_Real theScale,
const Standard_Boolean theAsWireframe)
{
myToShowTrihedron = true;
myTrihedron.SetWireframe (theAsWireframe);
myTrihedron.SetPosition (thePosition);
myTrihedron.SetScale (theScale);
myTrihedron.SetLabelsColor (theColor);
}
// =======================================================================
// function : TriedronErase
// purpose :
// =======================================================================
void OpenGl_View::TriedronErase()
{
myToShowTrihedron = false;
myTrihedron.Release (myWorkspace->GetGlContext().operator->());
}
// =======================================================================
// function : ZBufferTriedronSetup
// purpose :
// =======================================================================
void OpenGl_View::ZBufferTriedronSetup (const Quantity_NameOfColor theXColor,
const Quantity_NameOfColor theYColor,
const Quantity_NameOfColor theZColor,
const Standard_Real theSizeRatio,
const Standard_Real theAxisDiametr,
const Standard_Integer theNbFacettes)
{
myTrihedron.SetArrowsColors (theXColor, theYColor, theZColor);
myTrihedron.SetSizeRatio (theSizeRatio);
myTrihedron.SetNbFacets (theNbFacettes);
myTrihedron.SetArrowDiameter (theAxisDiametr);
}
// =======================================================================
// function : TriedronEcho
// purpose :
// =======================================================================
void OpenGl_View::TriedronEcho (const Aspect_TypeOfTriedronEcho /*theType*/)
{
// do nothing
}
// =======================================================================
// function : SetMinMaxValuesCallback
// purpose :

View File

@ -26,7 +26,6 @@
#include <Quantity_NameOfColor.hxx>
#include <Aspect_FillMethod.hxx>
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_TypeOfTriedronPosition.hxx>
#include <Graphic3d_CView.hxx>
#include <Graphic3d_GraduatedTrihedron.hxx>
@ -46,7 +45,6 @@
#include <OpenGl_LineAttributes.hxx>
#include <OpenGl_SceneGeometry.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_Window.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_TileSampler.hxx>
@ -129,26 +127,6 @@ public:
//! Return true if view content cache has been invalidated.
virtual Standard_Boolean IsInvalidated() Standard_OVERRIDE { return !myBackBufferRestored; }
//! Displays z-buffer trihedron.
Standard_EXPORT virtual void TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition = Aspect_TOTP_CENTER,
const Quantity_NameOfColor theColor = Quantity_NOC_WHITE,
const Standard_Real theScale = 0.02,
const Standard_Boolean theAsWireframe = Standard_True) Standard_OVERRIDE;
//! Erases z-buffer trihedron.
Standard_EXPORT virtual void TriedronErase() Standard_OVERRIDE;
//! Setup parameters of z-buffer trihedron.
Standard_EXPORT virtual void ZBufferTriedronSetup (const Quantity_NameOfColor theXColor = Quantity_NOC_RED,
const Quantity_NameOfColor theYColor = Quantity_NOC_GREEN,
const Quantity_NameOfColor theZColor = Quantity_NOC_BLUE1,
const Standard_Real theSizeRatio = 0.8,
const Standard_Real theAxisDiametr = 0.05,
const Standard_Integer theNbFacettes = 12) Standard_OVERRIDE;
//! Displays trihedron echo.
Standard_EXPORT virtual void TriedronEcho (const Aspect_TypeOfTriedronEcho theType = Aspect_TOTE_NONE) Standard_OVERRIDE;
//! Returns data of a graduated trihedron
const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() Standard_OVERRIDE
{ return myGTrihedronData; }
@ -330,9 +308,6 @@ public:
//! Returns background color.
const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
//! Change trihedron.
OpenGl_Trihedron& ChangeTrihedron() { return myTrihedron; }
//! Change graduated trihedron.
OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
@ -486,7 +461,6 @@ protected:
Handle(Graphic3d_Camera) myCamera;
Handle(OpenGl_FrameBuffer) myFBO;
Standard_Boolean myUseGLLight;
Standard_Boolean myToShowTrihedron;
Standard_Boolean myToShowGradTrihedron;
TCollection_AsciiString myBackgroundImagePath;
Handle(Graphic3d_TextureEnv) myTextureEnvData;
@ -509,7 +483,6 @@ protected:
//! Is needed for selection of overlapping objects and storage of the current view volume
OpenGl_BVHTreeSelector myBVHSelector;
OpenGl_Trihedron myTrihedron;
OpenGl_GraduatedTrihedron myGraduatedTrihedron;
Handle(OpenGl_Texture) myTextureEnv;

View File

@ -31,7 +31,6 @@
#include <OpenGl_Matrix.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_GraduatedTrihedron.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_ShaderManager.hxx>
@ -1024,18 +1023,6 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
//=======================================================================
void OpenGl_View::renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace)
{
// display global trihedron
if (myToShowTrihedron)
{
// disable environment texture
Handle(OpenGl_Texture) anEnvironmentTexture = theWorkspace->EnvironmentTexture();
theWorkspace->SetEnvironmentTexture (Handle(OpenGl_Texture)());
myTrihedron.Render (theWorkspace);
// restore environment texture
theWorkspace->SetEnvironmentTexture (anEnvironmentTexture);
}
if (myToShowGradTrihedron)
{
myGraduatedTrihedron.Render (theWorkspace);

View File

@ -215,28 +215,12 @@ static Standard_Integer OCC367 (Draw_Interpretor& di, Standard_Integer argc, con
return 0;
}
static Standard_Integer OCC71bug (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if(aContext.IsNull()) {
di << argv[0] << "ERROR : use 'vinit' command before \n";
return 1;
}
Handle(V3d_View) V3dView = ViewerTest::CurrentView();
V3dView->EnableGLLight( Standard_False );
V3dView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.07);
aContext->UpdateCurrentViewer();
return 0;
}
void QABugs::Commands_18(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
theCommands.Add("OCC267", "OCC267 DOC path", __FILE__, OCC267, group);
theCommands.Add("OCC181", "OCC181 FileName path1 path2 verbose=0/1", __FILE__, OCC181, group);
theCommands.Add("OCC367", "OCC367 shape step goodX goodY goodZ percent_tolerance", __FILE__, OCC367, group);
theCommands.Add("OCC71", "OCC71", __FILE__, OCC71bug, group);
return;
}

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPrs_ToolCylinder.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
@ -25,17 +24,17 @@
//function : Constructor
//purpose :
//=======================================================================
StdPrs_ToolCylinder::StdPrs_ToolCylinder (const Standard_ShortReal theBottomRad,
const Standard_ShortReal theTopRad,
const Standard_ShortReal theHeight,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb)
StdPrs_ToolCylinder::StdPrs_ToolCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
: myBottomRadius (theBottomRad),
myTopRadius (theTopRad),
myHeight (theHeight)
{
myStacksNb = theStacksNb;
mySlicesNb = theSlicesNb;
myStacksNb = theNbStacks;
mySlicesNb = theNbSlices;
}
//=======================================================================
@ -44,10 +43,10 @@ StdPrs_ToolCylinder::StdPrs_ToolCylinder (const Standard_ShortReal theBottomRad,
//=======================================================================
gp_Pnt StdPrs_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV)
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aRadius = myBottomRadius + (myTopRadius - myBottomRadius) * (Standard_ShortReal)theV;
return gp_Pnt (cosf(aU) * aRadius,
sinf(aU) * aRadius,
const Standard_Real aU = theU * M_PI * 2.0;
const Standard_Real aRadius = myBottomRadius + (myTopRadius - myBottomRadius) * theV;
return gp_Pnt (Cos (aU) * aRadius,
Sin (aU) * aRadius,
theV * myHeight);
}
@ -57,8 +56,25 @@ gp_Pnt StdPrs_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Rea
//=======================================================================
gp_Dir StdPrs_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real /*theV*/)
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
return gp_Dir (gp_Vec(cosf(aU) * myHeight,
sinf(aU) * myHeight,
myBottomRadius - myTopRadius).Normalized().XYZ());
const Standard_Real aU = theU * M_PI * 2.0;
return gp_Dir (Cos (aU) * myHeight,
Sin (aU) * myHeight,
myBottomRadius - myTopRadius);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolCylinder::Create (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks,
const gp_Trsf& theTrsf)
{
Handle(Graphic3d_ArrayOfTriangles) anArray;
StdPrs_ToolCylinder aTool (theBottomRad, theTopRad, theHeight, theNbSlices, theNbStacks);
aTool.FillArray (anArray, theTrsf);
return anArray;
}

View File

@ -24,14 +24,23 @@ class StdPrs_ToolCylinder : public StdPrs_ToolQuadric
{
public:
//! Generate primitives for 3D quadric surface and return a filled array.
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks,
const gp_Trsf& theTrsf);
public:
DEFINE_STANDARD_ALLOC
//! Initializes the algorithm.
Standard_EXPORT StdPrs_ToolCylinder (const Standard_ShortReal theBottomRad,
const Standard_ShortReal theTopRad,
const Standard_ShortReal theHeight,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb);
Standard_EXPORT StdPrs_ToolCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks);
protected:
@ -43,9 +52,10 @@ protected:
protected:
Standard_ShortReal myBottomRadius;
Standard_ShortReal myTopRadius;
Standard_ShortReal myHeight;
Standard_Real myBottomRadius;
Standard_Real myTopRadius;
Standard_Real myHeight;
};
#endif // _StdPrs_ToolCylinder_HeaderFile

View File

@ -13,7 +13,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPrs_ToolDisk.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
@ -24,15 +23,15 @@
//function : Constructor
//purpose :
//=======================================================================
StdPrs_ToolDisk::StdPrs_ToolDisk (const Standard_ShortReal theInnerRadius,
const Standard_ShortReal theOuterRadius,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb)
StdPrs_ToolDisk::StdPrs_ToolDisk (const Standard_Real theInnerRadius,
const Standard_Real theOuterRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
: myInnerRadius (theInnerRadius),
myOuterRadius (theOuterRadius)
{
mySlicesNb = theSlicesNb;
myStacksNb = theStacksNb;
mySlicesNb = theNbSlices;
myStacksNb = theNbStacks;
}
//=======================================================================
@ -41,11 +40,11 @@ StdPrs_ToolDisk::StdPrs_ToolDisk (const Standard_ShortReal theInnerRadius,
//=======================================================================
gp_Pnt StdPrs_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * (Standard_ShortReal)theV;
return gp_Pnt (cosf(aU) * aRadius,
sinf(aU) * aRadius,
0.0f);
const Standard_Real aU = theU * M_PI * 2.0;
const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
return gp_Pnt (Cos (aU) * aRadius,
Sin (aU) * aRadius,
0.0);
}
//=======================================================================
@ -54,5 +53,21 @@ gp_Pnt StdPrs_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real th
//=======================================================================
gp_Dir StdPrs_ToolDisk::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
{
return gp_Dir(0.0f, 0.0f, -1.0f);
return gp_Dir (0.0, 0.0, -1.0);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolDisk::Create (const Standard_Real theInnerRadius,
const Standard_Real theOuterRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks,
const gp_Trsf& theTrsf)
{
Handle(Graphic3d_ArrayOfTriangles) anArray;
StdPrs_ToolDisk aTool (theInnerRadius, theOuterRadius, theNbSlices, theNbStacks);
aTool.FillArray (anArray, theTrsf);
return anArray;
}

View File

@ -24,14 +24,21 @@ class StdPrs_ToolDisk : public StdPrs_ToolQuadric
{
public:
//! Generate primitives for 3D quadric surface and return a filled array.
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theInnerRadius,
const Standard_Real theOuterRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks,
const gp_Trsf& theTrsf);
public:
DEFINE_STANDARD_ALLOC
//! Initializes the algorithm.
Standard_EXPORT StdPrs_ToolDisk (const Standard_ShortReal theInnerRadius,
const Standard_ShortReal theOuterRadius,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb);
Standard_EXPORT StdPrs_ToolDisk (const Standard_Real theInnerRadius,
const Standard_Real theOuterRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks);
protected:
//! Computes vertex at given parameter location of the surface.
@ -42,9 +49,9 @@ protected:
protected:
Standard_ShortReal myInnerRadius;
Standard_ShortReal myOuterRadius;
Standard_Real myInnerRadius;
Standard_Real myOuterRadius;
};
#endif

View File

@ -23,13 +23,13 @@
//function : Constructor
//purpose :
//=======================================================================
StdPrs_ToolSphere::StdPrs_ToolSphere (const Standard_ShortReal theRadius,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb)
StdPrs_ToolSphere::StdPrs_ToolSphere (const Standard_Real theRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
: myRadius (theRadius)
{
mySlicesNb = theSlicesNb;
myStacksNb = theStacksNb;
mySlicesNb = theNbSlices;
myStacksNb = theNbStacks;
}
//=======================================================================
@ -38,11 +38,11 @@ StdPrs_ToolSphere::StdPrs_ToolSphere (const Standard_ShortReal theRadius,
//=======================================================================
gp_Pnt StdPrs_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV)
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
return gp_Pnt (myRadius * cosf(aU) * sinf(aV),
-myRadius * sinf(aU) * sinf(aV),
myRadius * cosf(aV));
const Standard_Real aU = theU * M_PI * 2.0;
const Standard_Real aV = theV * M_PI;
return gp_Pnt (myRadius * Cos (aU) * Sin (aV),
-myRadius * Sin (aU) * Sin (aV),
myRadius * Cos (aV));
}
//=======================================================================
@ -51,9 +51,24 @@ gp_Pnt StdPrs_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real
//=======================================================================
gp_Dir StdPrs_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV)
{
const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
return gp_Dir (cosf(aU) * sinf(aV),
-sinf(aU) * sinf(aV),
cosf(aV));
const Standard_Real aU = theU * M_PI * 2.0;
const Standard_Real aV = theV * M_PI;
return gp_Dir (Cos (aU) * Sin (aV),
-Sin (aU) * Sin (aV),
Cos (aV));
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolSphere::Create (const Standard_Real theRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks,
const gp_Trsf& theTrsf)
{
Handle(Graphic3d_ArrayOfTriangles) anArray;
StdPrs_ToolSphere aTool (theRadius, theNbSlices, theNbStacks);
aTool.FillArray (anArray, theTrsf);
return anArray;
}

View File

@ -31,12 +31,19 @@ class StdPrs_ToolSphere : public StdPrs_ToolQuadric
{
public:
//! Generate primitives for 3D quadric surface and return a filled array.
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks,
const gp_Trsf& theTrsf);
public:
DEFINE_STANDARD_ALLOC
//! Initializes the algorithm.
Standard_EXPORT StdPrs_ToolSphere (const Standard_ShortReal theRadius,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb);
Standard_EXPORT StdPrs_ToolSphere (const Standard_Real theRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks);
protected:
@ -48,8 +55,8 @@ protected:
protected:
Standard_ShortReal myRadius;
Standard_Real myRadius;
};
#endif

View File

@ -25,6 +25,8 @@ V3d_RectangularGrid.hxx
V3d_SpotLight.cxx
V3d_SpotLight.hxx
V3d_StereoDumpOptions.hxx
V3d_Trihedron.cxx
V3d_Trihedron.hxx
V3d_TypeOfAxe.hxx
V3d_TypeOfBackfacingModel.hxx
V3d_TypeOfLight.hxx

355
src/V3d/V3d_Trihedron.cxx Normal file
View File

@ -0,0 +1,355 @@
// Created on: 2016-10-11
// Created by: Ilya SEVRIKOV
// 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.
#include <V3d_Trihedron.hxx>
#include <gp_Ax3.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_Camera.hxx>
#include <Graphic3d_TransformPers.hxx>
#include <Prs3d.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_Text.hxx>
#include <Prs3d_TextAspect.hxx>
#include <StdPrs_ToolCylinder.hxx>
#include <StdPrs_ToolDisk.hxx>
#include <StdPrs_ToolSphere.hxx>
#include <V3d_View.hxx>
IMPLEMENT_STANDARD_RTTIEXT (V3d_Trihedron, Standard_Transient)
namespace
{
//! Compensates difference between old implementation (without transform persistence) and current implementation.
static const Standard_Real THE_INTERNAL_SCALE_FACTOR = 500.0;
static const Standard_ShortReal THE_CYLINDER_LENGTH = 0.75f;
static const Standard_Integer THE_CIRCLE_SERMENTS_NB = 24;
static const Standard_Real THE_CIRCLE_SEGMENT_ANGLE = 2.0 * M_PI / THE_CIRCLE_SERMENTS_NB;
}
//! Dummy implementation of Graphic3d_Structure overriding ::Compute() method for handling Device Lost.
class V3d_Trihedron::TrihedronStructure : public Graphic3d_Structure
{
public:
//! Main constructor.
TrihedronStructure (const Handle(Graphic3d_StructureManager)& theManager, V3d_Trihedron* theTrihedron)
: Graphic3d_Structure (theManager), myTrihedron (theTrihedron) {}
//! Override method to redirect to V3d_Trihedron.
virtual void Compute() Standard_OVERRIDE { myTrihedron->compute(); }
private:
V3d_Trihedron* myTrihedron;
};
// ============================================================================
// function : V3d_Trihedron
// purpose :
// ============================================================================
V3d_Trihedron::V3d_Trihedron()
: myScale (1.0),
myRatio (0.8),
myDiameter (0.05),
myNbFacettes (12),
myIsWireframe(Standard_False),
myToCompute (Standard_True)
{
myTransformPers = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
SetPosition (Aspect_TOTP_LEFT_LOWER);
// Set material.
Graphic3d_MaterialAspect aShadingMaterial;
aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
myArrowShadingAspects[anIt] = new Prs3d_ShadingAspect();
myArrowLineAspects[anIt] = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
// mark texture map ON to actually disable environment map
myArrowShadingAspects[anIt]->Aspect()->SetTextureMapOn();
myArrowShadingAspects[anIt]->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myArrowShadingAspects[anIt]->SetMaterial (aShadingMaterial);
}
myArrowShadingAspects[0]->SetColor (Quantity_NOC_RED);
myArrowLineAspects [0]->SetColor (Quantity_NOC_RED);
myArrowShadingAspects[1]->SetColor (Quantity_NOC_GREEN);
myArrowLineAspects [1]->SetColor (Quantity_NOC_GREEN);
myArrowShadingAspects[2]->SetColor (Quantity_NOC_BLUE1);
myArrowLineAspects [2]->SetColor (Quantity_NOC_BLUE1);
mySphereShadingAspect = new Prs3d_ShadingAspect();
mySphereLineAspect = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
// mark texture map ON to actually disable environment map
mySphereShadingAspect->Aspect()->SetTextureMapOn();
mySphereShadingAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
mySphereShadingAspect->SetMaterial (aShadingMaterial);
mySphereShadingAspect->SetColor (Quantity_NOC_WHITE);
myTextAspect = new Prs3d_TextAspect();
myTextAspect->SetFont ("Courier");
myTextAspect->SetHeight (16);
myTextAspect->SetHorizontalJustification (Graphic3d_HTA_LEFT);
myTextAspect->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
}
// ============================================================================
// function : SetLabelsColor
// purpose :
// ============================================================================
void V3d_Trihedron::SetLabelsColor (const Quantity_Color& theColor)
{
myTextAspect->SetColor (theColor);
}
// ============================================================================
// function : SetArrowsColor
// purpose :
// ============================================================================
void V3d_Trihedron::SetArrowsColor (const Quantity_Color& theXColor,
const Quantity_Color& theYColor,
const Quantity_Color& theZColor)
{
const Quantity_Color aColors[3] = { theXColor, theYColor, theZColor };
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
myArrowShadingAspects[anIt]->SetColor (aColors[anIt]);
myArrowLineAspects [anIt]->SetColor (aColors[anIt]);
}
}
// ============================================================================
// function : SetScale
// purpose :
// ============================================================================
void V3d_Trihedron::SetScale (const Standard_Real theScale)
{
if (Abs (myScale - theScale) > Precision::Confusion())
{
invalidate();
}
myScale = theScale;
}
// =======================================================================
// function : SetSizeRatio
// purpose :
// =======================================================================
void V3d_Trihedron::SetSizeRatio (const Standard_Real theRatio)
{
if (Abs (myRatio - theRatio) > Precision::Confusion())
{
invalidate();
}
myRatio = theRatio;
}
// =======================================================================
// function : SetArrowDiameter
// purpose :
// =======================================================================
void V3d_Trihedron::SetArrowDiameter (const Standard_Real theDiam)
{
if (Abs (myDiameter - theDiam) > Precision::Confusion())
{
invalidate();
}
myDiameter = theDiam;
}
// =======================================================================
// function : SetNbFacets
// purpose :
// =======================================================================
void V3d_Trihedron::SetNbFacets (const Standard_Integer theNbFacets)
{
if (Abs (myNbFacettes - theNbFacets) > 0)
{
invalidate();
}
myNbFacettes = theNbFacets;
}
// ============================================================================
// function : Display
// purpose :
// ============================================================================
void V3d_Trihedron::Display (const V3d_View& theView)
{
if (myStructure.IsNull())
{
myStructure = new TrihedronStructure (theView.Viewer()->StructureManager(), this);
myStructure->SetTransformPersistence (myTransformPers);
myStructure->SetZLayer (Graphic3d_ZLayerId_Topmost);
myStructure->SetDisplayPriority (9);
myStructure->SetInfiniteState (Standard_True);
myStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
myStructure->CStructure()->ViewAffinity->SetVisible (Standard_False);
myStructure->CStructure()->ViewAffinity->SetVisible (theView.View()->Identification(), true);
}
if (myToCompute)
{
compute();
}
myStructure->Display();
}
// ============================================================================
// function : Erase
// purpose :
// ============================================================================
void V3d_Trihedron::Erase()
{
if (!myStructure.IsNull())
{
myStructure->Erase();
myStructure.Nullify();
}
}
// ============================================================================
// function : SetPosition
// purpose :
// ============================================================================
void V3d_Trihedron::SetPosition (const Aspect_TypeOfTriedronPosition thePosition)
{
Graphic3d_Vec2i anOffset (0, 0);
if ((thePosition & (Aspect_TOTP_LEFT | Aspect_TOTP_RIGHT)) != 0)
{
anOffset.x() = static_cast<Standard_Integer> (myScale * THE_INTERNAL_SCALE_FACTOR);
}
if ((thePosition & (Aspect_TOTP_TOP | Aspect_TOTP_BOTTOM)) != 0)
{
anOffset.y() = static_cast<Standard_Integer> (myScale * THE_INTERNAL_SCALE_FACTOR);
}
myTransformPers->SetCorner2d (thePosition);
myTransformPers->SetOffset2d (anOffset);
}
// ============================================================================
// function : compute
// purpose :
// ============================================================================
void V3d_Trihedron::compute()
{
myStructure->GraphicClear (Standard_False);
// Create trihedron.
const Standard_Real aScale = myScale * myRatio * THE_INTERNAL_SCALE_FACTOR;
const Standard_Real aCylinderLength = aScale * THE_CYLINDER_LENGTH;
const Standard_Real aCylinderDiametr = aScale * myDiameter;
const Standard_Real aConeDiametr = myIsWireframe ? aCylinderDiametr : (aCylinderDiametr * 2.0);
const Standard_Real aConeLength = aScale * (1.0 - THE_CYLINDER_LENGTH);
const Standard_Real aSphereRadius = aCylinderDiametr * 2.0;
const Standard_Real aRayon = aScale / 30.0;
{
Handle(Graphic3d_Group) aSphereGroup = myStructure->NewGroup();
// Display origin.
if (myIsWireframe)
{
Handle(Graphic3d_ArrayOfPolylines) anCircleArray = new Graphic3d_ArrayOfPolylines (THE_CIRCLE_SERMENTS_NB + 2);
for (Standard_Integer anIt = THE_CIRCLE_SERMENTS_NB; anIt >= 0; --anIt)
{
anCircleArray->AddVertex (aRayon * Sin (anIt * THE_CIRCLE_SEGMENT_ANGLE),
aRayon * Cos (anIt * THE_CIRCLE_SEGMENT_ANGLE), 0.0);
}
anCircleArray->AddVertex (aRayon * Sin (THE_CIRCLE_SERMENTS_NB * THE_CIRCLE_SEGMENT_ANGLE),
aRayon * Cos (THE_CIRCLE_SERMENTS_NB * THE_CIRCLE_SEGMENT_ANGLE), 0.0);
aSphereGroup->SetGroupPrimitivesAspect (mySphereLineAspect->Aspect());
aSphereGroup->AddPrimitiveArray (anCircleArray);
}
else
{
gp_Trsf aSphereTransform;
aSphereGroup->SetGroupPrimitivesAspect (mySphereShadingAspect->Aspect());
aSphereGroup->AddPrimitiveArray (StdPrs_ToolSphere::Create (aSphereRadius, myNbFacettes, myNbFacettes, aSphereTransform));
}
}
// Display axes.
{
const gp_Ax1 anAxes[3] = { gp::OX(), gp::OY(), gp::OZ() };
for (Standard_Integer anIter = 0; anIter < 3; ++anIter)
{
Handle(Graphic3d_Group) anAxisGroup = myStructure->NewGroup();
anAxisGroup->SetGroupPrimitivesAspect (myArrowShadingAspects[anIter]->Aspect());
gp_Ax1 aPosition (anAxes[anIter]);
// Create a tube.
if (myIsWireframe)
{
Handle(Graphic3d_ArrayOfPrimitives) anArray = new Graphic3d_ArrayOfSegments (2);
anArray->AddVertex (0.0f, 0.0f, 0.0f);
anArray->AddVertex (anAxes[anIter].Direction().XYZ() * aCylinderLength);
anAxisGroup->SetGroupPrimitivesAspect (myArrowLineAspects[anIter]->Aspect());
anAxisGroup->AddPrimitiveArray (anArray);
}
else
{
gp_Ax3 aSystem (aPosition.Location(), aPosition.Direction());
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
anAxisGroup->AddPrimitiveArray (StdPrs_ToolCylinder::Create (aCylinderDiametr, aCylinderDiametr, aCylinderLength, myNbFacettes, 1, aTrsf));
}
aPosition.Translate (gp_Vec (aPosition.Direction().X() * aCylinderLength,
aPosition.Direction().Y() * aCylinderLength,
aPosition.Direction().Z() * aCylinderLength));
// Create a disk.
{
gp_Ax3 aSystem (aPosition.Location(), aPosition.Direction());
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
anAxisGroup->AddPrimitiveArray (StdPrs_ToolDisk::Create (0.0, aConeDiametr, myNbFacettes, 1, aTrsf));
}
// Create a cone.
{
gp_Ax3 aSystem (aPosition.Location(), aPosition.Direction());
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
anAxisGroup->AddPrimitiveArray (StdPrs_ToolCylinder::Create (aConeDiametr, 0.0, aConeLength, myNbFacettes, 1, aTrsf));
}
}
}
// Display labels.
{
Handle(Graphic3d_Group) aLabelGroup = myStructure->NewGroup();
const TCollection_ExtendedString aLabels[3] = { "X", "Y", "Z" };
const gp_Pnt aPoints[3] = { gp_Pnt (aScale + 2.0 * aRayon, 0.0, -aRayon),
gp_Pnt ( aRayon, aScale + 3.0 * aRayon, 2.0 * aRayon),
gp_Pnt ( -2.0 * aRayon, 0.5 * aRayon, aScale + 3.0 * aRayon) };
for (Standard_Integer anAxisIter = 0; anAxisIter < 3; ++anAxisIter)
{
Prs3d_Text::Draw (aLabelGroup, myTextAspect, aLabels[anAxisIter], aPoints[anAxisIter]);
}
}
}

113
src/V3d/V3d_Trihedron.hxx Normal file
View File

@ -0,0 +1,113 @@
// Created on: 2016-10-11
// Created by: Ilya SEVRIKOV
// 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 _V3d_Trihedron_HeaderFile
#define _V3d_Trihedron_HeaderFile
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransformPers.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_TextAspect.hxx>
class V3d_View;
//! Class for presentation of zbuffer trihedron object.
class V3d_Trihedron : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(V3d_Trihedron, Standard_Transient)
public:
//! Creates a default trihedron.
Standard_EXPORT V3d_Trihedron();
//! Switch wireframe / shaded trihedron.
void SetWireframe (const Standard_Boolean theAsWireframe) { myIsWireframe = theAsWireframe; }
//! Setup the corner to draw the trihedron.
Standard_EXPORT void SetPosition (const Aspect_TypeOfTriedronPosition thePosition);
//! Setup the scale factor.
Standard_EXPORT void SetScale (const Standard_Real theScale);
//! Setup the size ratio factor.
Standard_EXPORT void SetSizeRatio (const Standard_Real theRatio);
//! Setup the arrow diameter.
Standard_EXPORT void SetArrowDiameter (const Standard_Real theDiam);
//! Setup the number of facets for tessellation.
Standard_EXPORT void SetNbFacets (const Standard_Integer theNbFacets);
//! Setup color of text labels.
Standard_EXPORT void SetLabelsColor (const Quantity_Color& theColor);
//! Setup colors of arrows.
Standard_EXPORT void SetArrowsColor (const Quantity_Color& theXColor,
const Quantity_Color& theYColor,
const Quantity_Color& theZColor);
//! Display trihedron.
Standard_EXPORT void Display (const V3d_View& theView);
//! Erase trihedron.
Standard_EXPORT void Erase();
protected:
//! Fills Graphic3d_Group.
Standard_EXPORT void compute();
//! Invalidates objects. It leads recompute.
void invalidate()
{
myToCompute = Standard_True;
}
//! Sets offset 2d for transform persistence.
Standard_EXPORT void setOffset2d();
private:
//! Custom Graphic3d_Structure implementation.
class TrihedronStructure;
protected:
Handle(Prs3d_ShadingAspect) mySphereShadingAspect;
Handle(Prs3d_LineAspect) mySphereLineAspect;
Handle(Prs3d_TextAspect) myTextAspect;
Handle(Prs3d_ShadingAspect) myArrowShadingAspects[3];
Handle(Prs3d_LineAspect) myArrowLineAspects[3];
Handle(Graphic3d_Structure) myStructure;
Handle(Graphic3d_TransformPers) myTransformPers;
Standard_Real myScale;
Standard_Real myRatio;
Standard_Real myDiameter;
Standard_Integer myNbFacettes;
Standard_Boolean myIsWireframe;
Standard_Boolean myToCompute;
};
DEFINE_STANDARD_HANDLE (V3d_Trihedron, Standard_Transient)
#endif

View File

@ -68,6 +68,7 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView th
: MyViewer (theViewer.operator->()),
SwitchSetFront (Standard_False),
myZRotation (Standard_False),
myTrihedron (new V3d_Trihedron()),
MyTrsf (1, 4, 1, 4)
{
myView = theViewer->Driver()->CreateView (theViewer->StructureManager());

View File

@ -24,7 +24,6 @@
#include <Aspect_Handle.hxx>
#include <Aspect_RenderingContext.hxx>
#include <Aspect_TypeOfTriedronPosition.hxx>
#include <Aspect_TypeOfTriedronEcho.hxx>
#include <Bnd_Box.hxx>
@ -68,6 +67,7 @@
#include <V3d_Coordinate.hxx>
#include <V3d_ImageDumpOptions.hxx>
#include <V3d_Trihedron.hxx>
#include <V3d_TypeOfAxe.hxx>
#include <V3d_TypeOfBackfacingModel.hxx>
@ -302,9 +302,6 @@ public:
//! Erases the Triedron.
Standard_EXPORT void TriedronErase();
//! Highlights the echo zone of the Triedron.
Standard_EXPORT void TriedronEcho (const Aspect_TypeOfTriedronEcho theType = Aspect_TOTE_NONE);
//! Returns data of a graduated trihedron.
Standard_EXPORT const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() const;
@ -1050,6 +1047,7 @@ private:
Standard_Boolean myZRotation;
Standard_Integer MyZoomAtPointX;
Standard_Integer MyZoomAtPointY;
Handle(V3d_Trihedron) myTrihedron;
Handle(Aspect_Grid) MyGrid;
gp_Ax3 MyPlane;
TColStd_Array2OfReal MyTrsf;
@ -1062,6 +1060,7 @@ private:
Graphic3d_Vertex myGravityReferencePoint;
Standard_Boolean myAutoZFitIsOn;
Standard_Real myAutoZFitScaleFactor;
};
#endif // _V3d_View_HeaderFile

View File

@ -274,12 +274,10 @@ void V3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor theXColor,
const Standard_Real theAxisDiametr,
const Standard_Integer theNbFacettes)
{
myView->ZBufferTriedronSetup (theXColor,
theYColor,
theZColor,
theSizeRatio,
theAxisDiametr,
theNbFacettes);
myTrihedron->SetArrowsColor (theXColor, theYColor, theZColor);
myTrihedron->SetSizeRatio (theSizeRatio);
myTrihedron->SetNbFacets (theNbFacettes);
myTrihedron->SetArrowDiameter (theAxisDiametr);
}
//=============================================================================
@ -291,7 +289,12 @@ void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
const Standard_Real theScale,
const V3d_TypeOfVisualization theMode)
{
myView->TriedronDisplay (thePosition, theColor, theScale, (theMode == V3d_WIREFRAME));
myTrihedron->SetLabelsColor (theColor);
myTrihedron->SetScale (theScale);
myTrihedron->SetPosition (thePosition);
myTrihedron->SetWireframe (theMode == V3d_WIREFRAME);
myTrihedron->Display (*this);
}
//=============================================================================
@ -300,16 +303,7 @@ void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
//=============================================================================
void V3d_View::TriedronErase()
{
myView->TriedronErase();
}
//=============================================================================
//function : TriedronEcho
//purpose :
//=============================================================================
void V3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho theType)
{
myView->TriedronEcho (theType);
myTrihedron->Erase();
}
//=============================================================================

View File

@ -1,28 +0,0 @@
puts "============"
puts "OCC23363"
puts "============"
puts ""
####################################################################################
# ZBufer trihedron drawn without shading
####################################################################################
vinit
vzbufftrihedron
pcylinder p 100 200
vdisplay p
vsetdispmode p 1
vsetinteriorstyle p 1
set x_coord 59
set y_coord 380
checkcolor $x_coord $y_coord 0.54 0 0
set x_coord 50
set y_coord 362
checkcolor $x_coord $y_coord 0 0.77 0
set x_coord 41
set y_coord 354
checkcolor $x_coord $y_coord 0 0 0.62
checkview -screenshot -3d -path ${imagedir}/${test_image}.png

View File

@ -1,25 +0,0 @@
puts "========"
puts "OCC25500"
puts "========"
puts ""
###################################################################################################
# Visualization, TKOpenGl - global trihedron should not inherit transformation from last object
###################################################################################################
box b 1 2 3
vinit View1
vclear
vaxo
vdisplay b
vfit
vzbufftrihedron
vsetlocation b 0.2 0 0
vcaps -ffp 0
vrepaint
checkcolor 60 379 1 0.058823529630899429 0.058823529630899429
checkview -screenshot -3d -path ${imagedir}/${test_image}.png

View File

@ -1,28 +0,0 @@
puts "========"
puts "OCC26424"
puts "========"
puts ""
################################################################
# Text is not rendered within core profile on Windows platform
################################################################
vcaps -core
vinit View1
vclear
vaxo
vzbufftrihedron
if { [checkplatform -windows] } {
# Windows platform
set ok_color "GRAY52"
} else {
# Linux platform
set ok_color "GRAY85"
}
set bug_info [vreadpixel 71 350 rgb name]
if {$bug_info != $ok_color} {
puts "ERROR: OCC26424 is reproduced. Trihedron does non have text labels."
}
checkview -screenshot -3d -path ${imagedir}/${test_image}.png

View File

@ -1,53 +0,0 @@
puts "================"
puts "OCC71"
puts "BUC61045"
puts "================"
puts ""
# Data
set Triedron_X 29
set Triedron_Y 380
set Shape_X 120
set Shape_Y 250
# Display box
vinit
box b 10 10 10
vdisplay b
# Display triedron
OCC71
vfit
# Check triedron color
checkcolor ${Triedron_X} ${Triedron_Y} 1 1 1
# Shading box
vsetdispmode b 1
# Check box color
checkcolor ${Shape_X} ${Shape_Y} 0.78 0.54 0.09
# Check triedron color
checkcolor ${Triedron_X} ${Triedron_Y} 1 1 1
# Select box
vselect ${Shape_X} ${Shape_Y}
# Check box color
checkcolor ${Shape_X} ${Shape_Y} 0.78 0.54 0.09
# Check triedron color
checkcolor ${Triedron_X} ${Triedron_Y} 1 1 1
# Select empty view
vselect 1 1
# Check box color
checkcolor ${Shape_X} ${Shape_Y} 0.78 0.54 0.09
# Check triedron color
checkcolor ${Triedron_X} ${Triedron_Y} 1 1 1
checkview -screenshot -3d -path ${imagedir}/${test_image}.png