Graphic3d_Vector has been replaced by gp_Pnt/gp_XYZ/gp_Dir depending on context.
StdSelect_ViewerSelector3d::ToPixMap() - fixed unsafe float math causing out-of-range color results.
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Vertex.hxx>
#include <Precision.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Vertex.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <Precision.hxx>
#include <Prs3d_Arrow.hxx>
Graphic3d_Vec2.hxx
Graphic3d_Vec3.hxx
Graphic3d_Vec4.hxx
-Graphic3d_Vector.cxx
-Graphic3d_Vector.hxx
-Graphic3d_VectorError.hxx
Graphic3d_Vertex.cxx
Graphic3d_Vertex.hxx
Graphic3d_VerticalTextAlignment.hxx
#include <Graphic3d_StructureDefinitionError.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransformError.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx>
-#include <Standard_Type.hxx>
#include "Graphic3d_Structure.pxx"
class Graphic3d_DataStructureManager;
class Bnd_Box;
class gp_Pnt;
-class Graphic3d_Vector;
class Graphic3d_Structure;
+++ /dev/null
-// 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.
-
-// Modified 27/12/98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
-//-Version
-//-Design Declaration des variables specifiques aux vecteurs
-//-Warning Un vecteur est defini par ses composantes ou par
-// deux points
-// Il peut etre normalise
-//-References
-//-Language C++ 2.0
-//-Declarations
-// for the class
-
-#include <Graphic3d_Vector.hxx>
-#include <Graphic3d_VectorError.hxx>
-#include <Standard_Boolean.hxx>
-
-//-Aliases
-//-Global data definitions
-#define Graphic3d_Vector_MyEpsilon 0.000001
-
-// -- les coordonnees du vecteur
-// MyX : Standard_ShortReal;
-// MyY : Standard_ShortReal;
-// MyZ : Standard_ShortReal;
-
-// -- la norme du vecteur
-// MyNorme : Standard_ShortReal;
-
-//-Constructors
-
-Graphic3d_Vector::Graphic3d_Vector ():
-MyX (Standard_ShortReal (1.0)),
-MyY (Standard_ShortReal (1.0)),
-MyZ (Standard_ShortReal (1.0)),
-MyNorme (Standard_ShortReal (1.0)) {
-}
-
-Graphic3d_Vector::Graphic3d_Vector (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ):
-MyX (Standard_ShortReal (AX)),
-MyY (Standard_ShortReal (AY)),
-MyZ (Standard_ShortReal (AZ)),
-MyNorme (Standard_ShortReal (Graphic3d_Vector::NormeOf (AX, AY, AZ))) {
-}
-
-Graphic3d_Vector::Graphic3d_Vector (const Graphic3d_Vertex& APoint1, const Graphic3d_Vertex& APoint2) {
-
- MyX = APoint2.X() - APoint1.X();
- MyY = APoint2.Y() - APoint1.Y();
- MyZ = APoint2.Z() - APoint1.Z();
-
- MyNorme = Standard_ShortReal (Graphic3d_Vector::NormeOf (MyX, MyY, MyZ));
-
-}
-
-//-Destructors
-
-//-Methods, in order
-
-void Graphic3d_Vector::Coord (Standard_Real& AX, Standard_Real& AY, Standard_Real& AZ) const {
-
- AX = Standard_Real (MyX);
- AY = Standard_Real (MyY);
- AZ = Standard_Real (MyZ);
-
-}
-
-Standard_Real Graphic3d_Vector::X () const {
-
- return Standard_Real (MyX);
-
-}
-
-Standard_Real Graphic3d_Vector::Y () const {
-
- return Standard_Real (MyY);
-
-}
-
-Standard_Real Graphic3d_Vector::Z () const {
-
- return Standard_Real (MyZ);
-
-}
-
-void Graphic3d_Vector::Normalize () {
-
- if (Abs (MyNorme) <= RealEpsilon ())
- throw Graphic3d_VectorError("The norm is null");
-
- if (!IsNormalized()) // CQO CTS40181
- {
- MyX = MyX / MyNorme;
- MyY = MyY / MyNorme;
- MyZ = MyZ / MyNorme;
- }
-
- MyNorme = Standard_ShortReal (1.0);
-
-}
-
-void Graphic3d_Vector::SetCoord (const Standard_Real Xnew, const Standard_Real Ynew, const Standard_Real Znew) {
-
- MyX = Standard_ShortReal (Xnew);
- MyY = Standard_ShortReal (Ynew);
- MyZ = Standard_ShortReal (Znew);
-
- MyNorme = Standard_ShortReal (Graphic3d_Vector::NormeOf (Standard_Real (MyX), Standard_Real (MyY), Standard_Real (MyZ)));
-
-}
-
-void Graphic3d_Vector::SetXCoord (const Standard_Real Xnew) {
-
- MyX = Standard_ShortReal (Xnew);
-
- MyNorme = Standard_ShortReal (Graphic3d_Vector::NormeOf (Standard_Real (MyX), Standard_Real (MyY), Standard_Real (MyZ)));
-
-}
-
-void Graphic3d_Vector::SetYCoord (const Standard_Real Ynew) {
-
- MyY = Standard_ShortReal (Ynew);
-
- MyNorme = Standard_ShortReal (Graphic3d_Vector::NormeOf (Standard_Real (MyX), Standard_Real (MyY), Standard_Real (MyZ)));
-
-}
-
-void Graphic3d_Vector::SetZCoord (const Standard_Real Znew) {
-
- MyZ = Standard_ShortReal (Znew);
-
- MyNorme = Standard_ShortReal (Graphic3d_Vector::NormeOf (Standard_Real (MyX), Standard_Real (MyY), Standard_Real (MyZ)));
-
-}
-
-Standard_Boolean Graphic3d_Vector::LengthZero () const {
-
- return (Abs (Standard_Real (MyNorme)) <= RealEpsilon ());
-
-}
-
-Standard_Boolean Graphic3d_Vector::IsNormalized () const {
-
- return (Abs (Standard_Real (MyNorme) - 1.0) <=
- Graphic3d_Vector_MyEpsilon);
-
-}
-
-Standard_Boolean Graphic3d_Vector::IsParallel (const Graphic3d_Vector& AV1, const Graphic3d_Vector& AV2) {
-
- Standard_Real aDif1 = 0, aDif2 = 0, aDif3 = 0;
-
- aDif1 = AV1.X () * AV2.Y () - AV1.Y () * AV2.X ();
- aDif2 = AV1.X () * AV2.Z () - AV1.Z () * AV2.X ();
- aDif3 = AV1.Y () * AV2.Z () - AV1.Z () * AV2.Y ();
-
- return ( (Abs (aDif1) <= Graphic3d_Vector_MyEpsilon) &&
- (Abs (aDif2) <= Graphic3d_Vector_MyEpsilon) &&
- (Abs (aDif3) <= Graphic3d_Vector_MyEpsilon) );
-}
-
-Standard_Real Graphic3d_Vector::NormeOf (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ) {
-
- return (Sqrt (AX*AX+AY*AY+AZ*AZ));
-
-}
-
-Standard_Real Graphic3d_Vector::NormeOf (const Graphic3d_Vector& AVector) {
-
-Standard_Real X, Y, Z;
-
- AVector.Coord(X, Y, Z);
- return (Graphic3d_Vector::NormeOf (X, Y, Z));
-
-}
+++ /dev/null
-// 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 _Graphic3d_Vector_HeaderFile
-#define _Graphic3d_Vector_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Standard_ShortReal.hxx>
-#include <Standard_Real.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Standard_Boolean.hxx>
-class Graphic3d_VectorError;
-
-
-//! This class allows the creation and update
-//! of a 3D vector.
-class Graphic3d_Vector
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
-
- //! Creates a vector with 1.0, 0.0, 0.0 coordinates.
- Standard_EXPORT Graphic3d_Vector();
-
- //! Creates a vector with <AX>, <AY>, <AZ> coordinates.
- Standard_EXPORT Graphic3d_Vector(const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ);
-
- //! Creates a vector from 2 points <APoint1> and <APoint2>.
- Standard_EXPORT Graphic3d_Vector(const Graphic3d_Vertex& APoint1, const Graphic3d_Vertex& APoint2);
-
- //! Normalises <me>.
- //! Category: Methods to modify the class definition
- //! Warning: Raises VectorError if <me> is null.
- Standard_EXPORT void Normalize();
-
- //! Modifies the coordinates of the vector <me>.
- Standard_EXPORT void SetCoord (const Standard_Real Xnew, const Standard_Real Ynew, const Standard_Real Znew);
-
- //! Modifies the X coordinate of the vector <me>.
- Standard_EXPORT void SetXCoord (const Standard_Real Xnew);
-
- //! Modifies the Y coordinate of the vector <me>.
- Standard_EXPORT void SetYCoord (const Standard_Real Ynew);
-
- //! Modifies the Z coordinate of the vector <me>.
- Standard_EXPORT void SetZCoord (const Standard_Real Znew);
-
- //! Returns the coordinates of the vector <me>.
- Standard_EXPORT void Coord (Standard_Real& AX, Standard_Real& AY, Standard_Real& AZ) const;
-
- //! Returns Standard_True if <me> has length 1.
- Standard_EXPORT Standard_Boolean IsNormalized() const;
-
- //! Returns Standard_True if <me> has length zero.
- Standard_EXPORT Standard_Boolean LengthZero() const;
-
- //! Returns the X coordinates of the vector <me>.
- Standard_EXPORT Standard_Real X() const;
-
- //! Returns the Y coordinate of the vector <me>.
- Standard_EXPORT Standard_Real Y() const;
-
- //! Returns the Z coordinate of the vector <me>.
- Standard_EXPORT Standard_Real Z() const;
-
- //! Returns Standard_True if the vector <AV1> and
- //! <AV2> are parallel.
- Standard_EXPORT static Standard_Boolean IsParallel (const Graphic3d_Vector& AV1, const Graphic3d_Vector& AV2);
-
- //! Returns the norm of the vector <AX>, <AY>, <AZ>.
- Standard_EXPORT static Standard_Real NormeOf (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ);
-
- //! Returns the norm of the vector <AVector>.
- Standard_EXPORT static Standard_Real NormeOf (const Graphic3d_Vector& AVector);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
- Standard_ShortReal MyX;
- Standard_ShortReal MyY;
- Standard_ShortReal MyZ;
- Standard_ShortReal MyNorme;
-
-
-};
-
-
-
-
-
-
-
-#endif // _Graphic3d_Vector_HeaderFile
+++ /dev/null
-// Created on: 1993-03-31
-// Created by: NW,JPB,CAL
-// Copyright (c) 1993-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 _Graphic3d_VectorError_HeaderFile
-#define _Graphic3d_VectorError_HeaderFile
-
-#include <Standard_Type.hxx>
-#include <Standard_DefineException.hxx>
-#include <Standard_SStream.hxx>
-#include <Standard_OutOfRange.hxx>
-
-class Graphic3d_VectorError;
-DEFINE_STANDARD_HANDLE(Graphic3d_VectorError, Standard_OutOfRange)
-
-#if !defined No_Exception && !defined No_Graphic3d_VectorError
- #define Graphic3d_VectorError_Raise_if(CONDITION, MESSAGE) \
- if (CONDITION) throw Graphic3d_VectorError(MESSAGE);
-#else
- #define Graphic3d_VectorError_Raise_if(CONDITION, MESSAGE)
-#endif
-
-DEFINE_STANDARD_EXCEPTION(Graphic3d_VectorError, Standard_OutOfRange)
-
-#endif // _Graphic3d_VectorError_HeaderFile
#include <TColStd_MapOfInteger.hxx>
class Aspect_Window;
-class Graphic3d_Vector;
class Quantity_Color;
class Graphic3d_Vertex;
class TCollection_ExtendedString;
return 0;
}
-#include <Graphic3d_Vector.hxx>
-Standard_Integer OCC22762 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- if (argc!=7)
- {
- di << "Wrong number of arguments\n";
- return -1;
- }
- Standard_Real X1_Pnt = Draw::Atof(argv[1]);
- Standard_Real Y1_Pnt = Draw::Atof(argv[2]);
- Standard_Real Z1_Pnt = Draw::Atof(argv[3]);
- Standard_Real X2_Pnt = Draw::Atof(argv[4]);
- Standard_Real Y2_Pnt = Draw::Atof(argv[5]);
- Standard_Real Z2_Pnt = Draw::Atof(argv[6]);
-
- Graphic3d_Vector AV1(X1_Pnt, Y1_Pnt, Z1_Pnt);
- Graphic3d_Vector AV2(X2_Pnt, Y2_Pnt, Z2_Pnt);
-
- di << "Result is: " << (Graphic3d_Vector::IsParallel(AV1, AV2) ? "true" : "false") << "\n" ;
- return 0;
-}
-
-
-
-
#include <IntCurvesFace_ShapeIntersector.hxx>
#include <gp_Lin.hxx>
Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
theCommands.Add("OCC22301", "OCC22301", __FILE__, OCC22301, group);
theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);
- theCommands.Add("OCC22762", "OCC22762 x1 y1 z1 x2 y2 z3", __FILE__, OCC22762, group);
theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);
theCommands.Add("CR23403", "CR23403 string", __FILE__, CR23403, group);
theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group);
//! Normalize the depth values.
virtual void Flush() Standard_OVERRIDE
{
- Standard_Real aFrom = 0.0;
- Standard_Real aDelta = 1.0;
+ float aFrom = 0.0f;
+ float aDelta = 1.0f;
if (myDepthMin <= myDepthMax)
{
- aFrom = myDepthMin;
- if (myDepthMin != myDepthMax)
+ aFrom = float(myDepthMin);
+ aDelta = float(myDepthMax) - float(myDepthMin);
+ if (aDelta <= ShortRealEpsilon())
{
- aDelta = myDepthMax - myDepthMin;
+ aDelta = 1.0f;
}
}
for (Standard_Size aRowIter = 0; aRowIter < myUnnormImage.SizeY(); ++aRowIter)
continue;
}
- float aNormDepth = float((Standard_Real(aDepth) - aFrom) / aDelta);
+ float aNormDepth = (aDepth - aFrom) / aDelta;
if (myToInverse)
{
aNormDepth = 1.0f - aNormDepth;
const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked);
const float aDepth = float(aSortCriterion.Depth);
- myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (aDepth, aDepth, aDepth, 1.0f));
+ myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (Graphic3d_Vec4 (aDepth, aDepth, aDepth, 1.0f)));
}
};
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Quantity_NameOfColor.hxx>
#include <V3d.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
-Graphic3d_Vector V3d::GetProjAxis(const V3d_TypeOfOrientation Orientation) {
-Standard_Real Xpn=0,Ypn=0,Zpn=0 ;
-Graphic3d_Vector Vec ;
-
- switch (Orientation) {
- case V3d_Xpos :
- Xpn = 1. ; Ypn = 0. ; Zpn = 0. ;
- break ;
- case V3d_Ypos :
- Xpn = 0. ; Ypn = 1. ; Zpn = 0. ;
- break ;
- case V3d_Zpos :
- Xpn = 0. ; Ypn = 0. ; Zpn = 1. ;
- break ;
- case V3d_Xneg :
- Xpn = -1. ; Ypn = 0. ; Zpn = 0. ;
- break ;
- case V3d_Yneg :
- Xpn = 0. ; Ypn = -1. ; Zpn = 0. ;
- break ;
- case V3d_Zneg :
- Xpn = 0. ; Ypn = 0. ; Zpn = -1. ;
- break ;
- case V3d_XposYposZpos :
- Xpn = 1. ; Ypn = 1. ; Zpn = 1. ;
- break ;
- case V3d_XposYposZneg :
- Xpn = 1. ; Ypn = 1. ; Zpn = -1. ;
- break ;
- case V3d_XposYnegZpos :
- Xpn = 1. ; Ypn = -1. ; Zpn = 1. ;
- break ;
- case V3d_XposYnegZneg :
- Xpn = 1. ; Ypn = -1. ; Zpn = -1. ;
- break ;
- case V3d_XnegYposZpos :
- Xpn = -1. ; Ypn = 1. ; Zpn = 1. ;
- break ;
- case V3d_XnegYposZneg :
- Xpn = -1. ; Ypn = 1. ; Zpn = -1. ;
- break ;
- case V3d_XnegYnegZpos :
- Xpn = -1. ; Ypn = -1. ; Zpn = 1. ;
- break ;
- case V3d_XnegYnegZneg :
- Xpn = -1. ; Ypn = -1. ; Zpn = -1. ;
- break ;
- case V3d_XposYpos :
- Xpn = 1. ; Ypn = 1. ; Zpn = 0. ;
- break ;
- case V3d_XposYneg :
- Xpn = 1. ; Ypn = -1. ; Zpn = 0. ;
- break ;
- case V3d_XnegYpos :
- Xpn = -1. ; Ypn = 1. ; Zpn = 0. ;
- break ;
- case V3d_XnegYneg :
- Xpn = -1. ; Ypn = -1. ; Zpn = 0. ;
- break ;
- case V3d_XposZpos :
- Xpn = 1. ; Ypn = 0. ; Zpn = 1. ;
- break ;
- case V3d_XposZneg :
- Xpn = 1. ; Ypn = 0. ; Zpn = -1. ;
- break ;
- case V3d_XnegZpos :
- Xpn = -1. ; Ypn = 0. ; Zpn = 1. ;
- break ;
- case V3d_XnegZneg :
- Xpn = -1. ; Ypn = 0. ; Zpn = -1. ;
- break ;
- case V3d_YposZpos :
- Xpn = 0. ; Ypn = 1. ; Zpn = 1. ;
- break ;
- case V3d_YposZneg :
- Xpn = 0. ; Ypn = 1. ; Zpn = -1. ;
- break ;
- case V3d_YnegZpos :
- Xpn = 0. ; Ypn = -1. ; Zpn = 1. ;
- break ;
- case V3d_YnegZneg :
- Xpn = 0. ; Ypn = -1. ; Zpn = -1. ;
- break ;
- }
- Vec.SetCoord(Xpn,Ypn,Zpn) ; Vec.Normalize() ;
- return Vec ;
-}
-
void V3d::ArrowOfRadius(const Handle(Graphic3d_Group)& garrow,const Standard_Real X0,const Standard_Real Y0,const Standard_Real Z0,const Standard_Real Dx,const Standard_Real Dy,const Standard_Real Dz,const Standard_Real Alpha,const Standard_Real Lng)
{
Standard_Real Xc, Yc, Zc, Xi, Yi, Zi, Xj, Yj, Zj;
DEFINE_STANDARD_ALLOC
- //! Determines the orientation vector corresponding
- //! to the predefined orientation type.
- Standard_EXPORT static Graphic3d_Vector GetProjAxis (const V3d_TypeOfOrientation Orientation);
+ //! Determines the orientation vector corresponding to the predefined orientation type.
+ static gp_Dir GetProjAxis (const V3d_TypeOfOrientation theOrientation)
+ {
+ switch (theOrientation)
+ {
+ case V3d_Xpos: return gp::DX();
+ case V3d_Ypos: return gp::DY();
+ case V3d_Zpos: return gp::DZ();
+ case V3d_Xneg: return -gp::DX();
+ case V3d_Yneg: return -gp::DY();
+ case V3d_Zneg: return -gp::DZ();
+ case V3d_XposYposZpos: return gp_Dir ( 1, 1, 1);
+ case V3d_XposYposZneg: return gp_Dir ( 1, 1, -1);
+ case V3d_XposYnegZpos: return gp_Dir ( 1, -1, 1);
+ case V3d_XposYnegZneg: return gp_Dir ( 1, -1, -1);
+ case V3d_XnegYposZpos: return gp_Dir (-1, 1, 1);
+ case V3d_XnegYposZneg: return gp_Dir (-1, 1, -1);
+ case V3d_XnegYnegZpos: return gp_Dir (-1, -1, 1);
+ case V3d_XnegYnegZneg: return gp_Dir (-1, -1, -1);
+ case V3d_XposYpos: return gp_Dir ( 1, 1, 0);
+ case V3d_XposYneg: return gp_Dir ( 1, -1, 0);
+ case V3d_XnegYpos: return gp_Dir (-1, 1, 0);
+ case V3d_XnegYneg: return gp_Dir (-1, -1, 0);
+ case V3d_XposZpos: return gp_Dir ( 1, 0, 1);
+ case V3d_XposZneg: return gp_Dir ( 1, 0, -1);
+ case V3d_XnegZpos: return gp_Dir (-1, 0, 1);
+ case V3d_XnegZneg: return gp_Dir (-1, 0, -1);
+ case V3d_YposZpos: return gp_Dir ( 0, 1, 1);
+ case V3d_YposZneg: return gp_Dir ( 0, 1, -1);
+ case V3d_YnegZpos: return gp_Dir ( 0, -1, 1);
+ case V3d_YnegZneg: return gp_Dir ( 0, -1, -1);
+ }
+ return gp_Dir (0, 0, 0);
+ }
//! Compute the graphic structure of arrow.
//! X0,Y0,Z0 : coordinate of the arrow.
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Vertex.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Type.hxx>
#include <TColgp_SequenceOfPnt.hxx>
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-/***********************************************************************
- FONCTION :
- ----------
- Classe V3d_DirectionalLight :
- HISTORIQUE DES MODIFICATIONS :
- --------------------------------
- 00-09-92 : GG ; Creation.
- 18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
- 24-12-97 : FMN ; Remplacement de math par MathGra
- 31-12-97 : CAL ; Suppression de MathGra
- 21-01-98 : CAL ; Window de Xw et WNT remplacee par Aspect_Window
- 23-02-98 : FMN ; Remplacement PI par Standard_PI
- 30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
-************************************************************************/
-/*----------------------------------------------------------------------*/
-/*
- * Includes
- */
+#include <V3d_DirectionalLight.hxx>
-#include <Aspect_Window.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_Vec.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Vector.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Standard_Type.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <V3d.hxx>
#include <V3d_BadValue.hxx>
-#include <V3d_DirectionalLight.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (theViewer)
{
- Graphic3d_Vector aV = V3d::GetProjAxis (theDirection);
+ gp_Dir aV = V3d::GetProjAxis (theDirection);
SetType (V3d_DIRECTIONAL);
SetColor (theColor);
SetHeadlight (theIsHeadlight);
// function : SetDirection
// purpose :
// =======================================================================
-void V3d_DirectionalLight::SetDirection (const V3d_TypeOfOrientation theDirection)
+void V3d_DirectionalLight::SetDirection (V3d_TypeOfOrientation theDirection)
{
- Graphic3d_Vector aV = V3d::GetProjAxis (theDirection);
+ gp_Dir aV = V3d::GetProjAxis (theDirection);
SetDirection (aV.X(), aV.Y(), aV.Z());
}
// function : SetDirection
// purpose :
// =======================================================================
-void V3d_DirectionalLight::SetDirection (const Standard_Real theVx,
- const Standard_Real theVy,
- const Standard_Real theVz)
+void V3d_DirectionalLight::SetDirection (Standard_Real theVx,
+ Standard_Real theVy,
+ Standard_Real theVz)
{
- V3d_BadValue_Raise_if (Sqrt (theVx * theVx + theVy * theVy + theVz * theVz) <= 0.,
- "V3d_DirectionalLight::SetDirection, "
- "null vector" );
-
- Graphic3d_Vector aV (theVx, theVy, theVz);
- aV.Normalize();
-
+ gp_Dir aV (theVx, theVy, theVz);
myLight.Direction.x() = static_cast<Standard_ShortReal> (aV.X());
myLight.Direction.y() = static_cast<Standard_ShortReal> (aV.Y());
myLight.Direction.z() = static_cast<Standard_ShortReal> (aV.Z());
// function : SetDisplayPosition
// purpose :
// =======================================================================
-void V3d_DirectionalLight::SetDisplayPosition (const Standard_Real theX,
- const Standard_Real theY,
- const Standard_Real theZ)
+void V3d_DirectionalLight::SetDisplayPosition (Standard_Real theX,
+ Standard_Real theY,
+ Standard_Real theZ)
{
myDisplayPosition.SetCoord(theX, theY, theZ);
- Standard_Real aXt, aYt, aZt;
- Target (aXt, aYt, aZt);
+ gp_XYZ aTarget;
+ Target (aTarget.ChangeCoord (1), aTarget.ChangeCoord (2), aTarget.ChangeCoord (3));
- Standard_Real aXd = aXt - theX;
- Standard_Real aYd = aYt - theY;
- Standard_Real aZd = aZt - theZ;
- if (!Graphic3d_Vector (aXd, aYd, aZd).LengthZero())
+ const gp_XYZ aDispPos = aTarget - gp_XYZ(theX, theY, theZ);
+ if (aDispPos.Modulus() > gp::Resolution())
{
- SetDirection (aXd, aYd, aZd);
+ SetDirection (aDispPos.X(), aDispPos.Y(), aDispPos.Z());
}
}
-// =======================================================================
-// function : SetPosition
-// purpose :
-// =======================================================================
-void V3d_DirectionalLight::SetPosition (const Standard_Real theXp,
- const Standard_Real theYp,
- const Standard_Real theZp)
-{
- SetDisplayPosition (theXp, theYp, theZp);
-}
-
-// =======================================================================
-// function : Position
-// purpose :
-// =======================================================================
-void V3d_DirectionalLight::Position (Standard_Real& theXp,
- Standard_Real& theYp,
- Standard_Real& theZp) const
-{
- DisplayPosition (theXp, theYp, theZp) ;
-}
-
-// =======================================================================
-// function : DisplayPosition
-// purpose :
-// =======================================================================
-void V3d_DirectionalLight::DisplayPosition (Standard_Real& theXp,
- Standard_Real& theYp,
- Standard_Real& theZp) const
-{
- myDisplayPosition.Coord (theXp, theYp, theZp) ;
-}
-
// =======================================================================
// function : DisplayPosition
// purpose :
myTypeOfRepresentation = Pres;
myGraphicStructure->Display();
}
-
-// =======================================================================
-// function : Direction
-// purpose :
-// =======================================================================
-void V3d_DirectionalLight::Direction (Standard_Real& theVx,
- Standard_Real& theVy,
- Standard_Real& theVz) const
-{
- theVx = myLight.Direction.x();
- theVy = myLight.Direction.y();
- theVz = myLight.Direction.z();
-}
const Standard_Boolean theIsHeadlight = Standard_False);
//! Defines the direction of the light source by a predefined orientation.
- Standard_EXPORT void SetDirection (const V3d_TypeOfOrientation theDirection);
+ Standard_EXPORT void SetDirection (V3d_TypeOfOrientation theDirection);
//! Defines the direction of the light source by the predefined vector theXm, theYm, theZm.
//! Warning: raises BadValue from V3d if the vector is null.
- Standard_EXPORT void SetDirection (const Standard_Real theXm,
- const Standard_Real theYm,
- const Standard_Real theZm);
+ Standard_EXPORT void SetDirection (Standard_Real theXm,
+ Standard_Real theYm,
+ Standard_Real theZm);
//! Defines the point of light source representation.
- Standard_EXPORT void SetDisplayPosition (const Standard_Real theX,
- const Standard_Real theY,
- const Standard_Real theZ);
+ Standard_EXPORT void SetDisplayPosition (Standard_Real theX,
+ Standard_Real theY,
+ Standard_Real theZ);
//! Calls SetDisplayPosition method.
- Standard_EXPORT virtual void SetPosition (const Standard_Real theXp,
- const Standard_Real theYp,
- const Standard_Real theZp) Standard_OVERRIDE;
+ virtual void SetPosition (Standard_Real theXp,
+ Standard_Real theYp,
+ Standard_Real theZp) Standard_OVERRIDE { SetDisplayPosition (theXp, theYp, theZp); }
//! Modifies the smoothing angle (in radians)
Standard_EXPORT void SetSmoothAngle (const Standard_Real theValue);
const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE;
//! Calls DisplayPosition method.
- Standard_EXPORT virtual void Position (Standard_Real& theX,
- Standard_Real& theY,
- Standard_Real& theZ) const Standard_OVERRIDE;
+ virtual void Position (Standard_Real& theX,
+ Standard_Real& theY,
+ Standard_Real& theZ) const Standard_OVERRIDE { DisplayPosition (theX, theY, theZ); }
//! Returns the chosen position to represent the light source.
- Standard_EXPORT void DisplayPosition (Standard_Real& theX,
- Standard_Real& theY,
- Standard_Real& theZ) const;
+ void DisplayPosition (Standard_Real& theX,
+ Standard_Real& theY,
+ Standard_Real& theZ) const { myDisplayPosition.Coord (theX, theY, theZ); }
//! Returns the theVx, theVy, theVz direction of the light source.
- Standard_EXPORT void Direction (Standard_Real& theVx,
- Standard_Real& theVy,
- Standard_Real& theVz) const;
+ void Direction (Standard_Real& theVx,
+ Standard_Real& theVy,
+ Standard_Real& theVz) const
+ {
+ theVx = myLight.Direction.x();
+ theVy = myLight.Direction.y();
+ theVz = myLight.Direction.z();
+ }
DEFINE_STANDARD_RTTIEXT(V3d_DirectionalLight,V3d_PositionLight)
private:
- Graphic3d_Vertex myDisplayPosition;
+ gp_Pnt myDisplayPosition;
};
#endif // _V3d_DirectionalLight_HeaderFile
// function : SymetricPointOnSphere
// purpose :
// =======================================================================
-void V3d_Light::SymetricPointOnSphere (const Handle(V3d_View)& aView, const Graphic3d_Vertex &Center, const Graphic3d_Vertex &aPoint, const Standard_Real Rayon, Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ ) {
-
+void V3d_Light::SymetricPointOnSphere (const Handle(V3d_View)& aView,
+ const gp_Pnt& Center,
+ const gp_Pnt& aPoint,
+ const Standard_Real Rayon,
+ Standard_Real& X, Standard_Real& Y, Standard_Real& Z,
+ Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ )
+{
Standard_Real X0,Y0,Z0,XP,YP,ZP;
Standard_Real PXP,PYP,DeltaX,DeltaY,DeltaZ;
Standard_Real A,B,C,Delta,Lambda;
#define _V3d_Light_HeaderFile
#include <Graphic3d_CLight.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Standard_Transient.hxx>
-#include <Quantity_Color.hxx>
-#include <Standard.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Type.hxx>
#include <V3d_TypeOfLight.hxx>
#include <V3d_View.hxx>
//! Sets type of the light.
Standard_EXPORT void SetType (const V3d_TypeOfLight theType);
- //! Returns the symetric point coordinates of "aPoint"
+ //! Returns the symmetric point coordinates of "aPoint"
//! on the sphere of center "Center" and radius "Radius".
//! VX,VY,VZ is the project vector of view.
Standard_EXPORT static void SymetricPointOnSphere (const Handle(V3d_View)& aView,
- const Graphic3d_Vertex& Center,
- const Graphic3d_Vertex& aPoint,
+ const gp_Pnt& Center,
+ const gp_Pnt& aPoint,
const Standard_Real Radius,
Standard_Real& X, Standard_Real& Y, Standard_Real& Z,
Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ);
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-/***********************************************************************
- V3d_PositionLight.cxx
- Created: 30-03-98 ZOV (ZELENKOV Oleg)
-************************************************************************/
+#include <V3d_PositionLight.hxx>
-#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Vector.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <V3d.hxx>
#include <V3d_BadValue.hxx>
-#include <V3d_PositionLight.hxx>
#include <V3d_SpotLight.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
V3d_BadValue_Raise_if( theRadius <= 0. , "V3d_PositionLight::SetRadius, bad radius");
V3d_BadValue_Raise_if( Type() == V3d_DIRECTIONAL , "V3d_PositionLight::SetRadius, bad light type");
- Standard_Real X0,Y0,Z0, Xn,Yn,Zn, Xp,Yp,Zp;
-
- // The target point remains unchanged, only the position of the light is modified
- // by preserving the direction.
- Position (Xp,Yp,Zp);
- Graphic3d_Vector D(myTarget, Graphic3d_Vertex(Xp, Yp, Zp));
- D.Normalize();
- D.Coord(Xn,Yn,Zn);
- myTarget.Coord(X0,Y0,Z0);
- Xn = X0 + theRadius*Xn;
- Yn = Y0 + theRadius*Yn;
- Zn = Z0 + theRadius*Zn;
-
- SetPosition(Xn,Yn,Zn) ;
+ // The target point remains unchanged, only the position of the light is modified by preserving the direction
+ gp_XYZ aPosOld;
+ Position (aPosOld.ChangeCoord (1), aPosOld.ChangeCoord (2), aPosOld.ChangeCoord (3));
+ gp_XYZ aDir = aPosOld - myTarget.XYZ();
+ aDir.Normalize();
+
+ const gp_XYZ aPosNew = myTarget.XYZ() + aDir * theRadius;
+ SetPosition (aPosNew.X(), aPosNew.Y(), aPosNew.Z());
}
// =======================================================================
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp);
- V3d_Light::SymetricPointOnSphere (theView,
- myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
+ V3d_Light::SymetricPointOnSphere (theView, myTarget, gp_Pnt(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// This is a visible point
if ((VX*(X-Xp) < 0.) && (VY*(Y-Yp) < 0.) && (VZ*(Z-Zp) < 0.))
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp);
- V3d_Light::SymetricPointOnSphere (theView,
- myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
+ V3d_Light::SymetricPointOnSphere (theView, myTarget, gp_Pnt(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// This is a hidden point
if ((VX*(X-Xp) > 0.) && (VY*(Y-Yp) > 0.) && (VZ*(Z-Zp) > 0.))
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp);
- V3d_Light::SymetricPointOnSphere (theView,
- myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
+ V3d_Light::SymetricPointOnSphere (theView, myTarget, gp_Pnt(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// Is it a visible or a hidden point
return ( (VX*(X-Xp) > 0.) || (VY*(Y-Yp) > 0.) || (VZ*(Z-Zp) > 0.) )?
Standard_True;
}
-// =======================================================================
-// function : Target
-// purpose :
-// =======================================================================
-void V3d_PositionLight::Target (Standard_Real& theXp, Standard_Real& theYp, Standard_Real& theZp) const
-{
- myTarget.Coord (theXp, theYp, theZp);
-}
-
// =======================================================================
// function : Display
// purpose :
const Standard_Integer theXpix,
const Standard_Integer theYpix)
{
-// Quantity_Color Col ;
- Standard_Real xPos, yPos, zPos;
Standard_Real XPp,YPp,PXT,PYT,X,Y,Z,Rayon,Ylim;
Standard_Real XMinTrack,XMaxTrack,YMinTrack,YMaxTrack;
Standard_Real XT,YT,ZT,X0,Y0,Z0,XP,YP,ZP,VX,VY,VZ,A,B,C,Delta;
Rayon = Rayon * Rap;
// the source should remain at a fixed position,
// only the target is modified.
- Position (xPos, yPos, zPos);
- Graphic3d_Vector Dir(Graphic3d_Vertex(xPos,yPos,zPos), myTarget);
- Dir.Normalize();
- Dir.Coord(X,Y,Z);
+
+ gp_XYZ aPos;
+ Position (aPos.ChangeCoord (1), aPos.ChangeCoord (2), aPos.ChangeCoord (3));
+ gp_XYZ aDir = myTarget.XYZ() - aPos;
+ aDir.Normalize();
+ aDir.Coord(X,Y,Z);
X = Xi + Rayon*X;
Y = Yi + Rayon*Y;
Z = Zi + Rayon*Z;
}
// =======================================================================
-// function : Radius
+// function : Erase
// purpose :
// =======================================================================
void V3d_PositionLight::Erase()
public:
//! Defines the position of the light source. Should be redefined!
- Standard_EXPORT virtual void SetPosition (const Standard_Real theX,
- const Standard_Real theY,
- const Standard_Real theZ) = 0;
+ Standard_EXPORT virtual void SetPosition (Standard_Real theX,
+ Standard_Real theY,
+ Standard_Real theZ) = 0;
//! Defines the target of the light (the center of the sphere).
Standard_EXPORT void SetTarget (const Standard_Real theX,
Standard_Real& theZ) const = 0;
//! Returns the position of the target of the light source.
- Standard_EXPORT void Target (Standard_Real& theX,
- Standard_Real& theY,
- Standard_Real& theZ) const;
+ void Target (Standard_Real& theX,
+ Standard_Real& theY,
+ Standard_Real& theZ) const { myTarget.Coord (theX, theY, theZ); }
DEFINE_STANDARD_RTTIEXT(V3d_PositionLight,V3d_Light)
Standard_EXPORT V3d_PositionLight (const Handle(V3d_Viewer)& theViewer);
- Graphic3d_Vertex myTarget;
+protected:
+
+ gp_Pnt myTarget;
V3d_TypeOfRepresentation myTypeOfRepresentation;
private:
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-/***********************************************************************
- FONCTION :
- ----------
- Classe V3d_PositionalLight :
- HISTORIQUE DES MODIFICATIONS :
- --------------------------------
- 00-09-92 : GG ; Creation.
- 18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
- 24-12-97 : FMN ; Remplacement de math par MathGra
- 31-12-97 : CAL ; Suppression de MathGra
- 21-01-98 : CAL ; Window de Xw et WNT remplacee par Aspect_Window
- 23-02-98 : FMN ; Remplacement PI par Standard_PI
- 30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
-************************************************************************/
-/*----------------------------------------------------------------------*/
-/*
- * Includes
- */
+#include <V3d_PositionalLight.hxx>
-#include <Aspect_Window.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_Vec.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Vector.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <V3d.hxx>
#include <V3d_BadValue.hxx>
-#include <V3d_PositionalLight.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
myLight.Smoothness = static_cast<Standard_ShortReal> (theValue);
}
-// =======================================================================
-// function : SetPosition
-// purpose :
-// =======================================================================
-void V3d_PositionalLight::SetPosition (const Standard_Real theXp,
- const Standard_Real theYp,
- const Standard_Real theZp)
-{
- myLight.Position.x() = theXp;
- myLight.Position.y() = theYp;
- myLight.Position.z() = theZp;
-}
-
// =======================================================================
// function : SetAttenuation
// purpose :
myLight.ChangeLinearAttenuation() = static_cast<Standard_ShortReal> (theLinearAttenuation);
}
-// =======================================================================
-// function : Position
-// purpose :
-// =======================================================================
-void V3d_PositionalLight::Position (Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const
-{
- theX = myLight.Position.x();
- theY = myLight.Position.y();
- theZ = myLight.Position.z();
-}
-
-// =======================================================================
-// function : Attenuation
-// purpose :
-// =======================================================================
-void V3d_PositionalLight::Attenuation (Standard_Real& theConstAttenuation,
- Standard_Real& theLinearAttenuation) const
-{
- theConstAttenuation = myLight.ConstAttenuation();
- theLinearAttenuation = myLight.LinearAttenuation();
-}
-
// =======================================================================
// function : Symbol
// purpose :
void V3d_PositionalLight::Display (const Handle(V3d_View)& theView,
const V3d_TypeOfRepresentation theRepresentation)
{
- Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1;
V3d::ArrowOfRadius(gExtArrow,X-.1*(X-X0),Y-.1*(Y-Y0),Z-.1*(Z-Z0),X-X0,Y-Y0,Z-Z0,M_PI/15.,Rayon/20.);
V3d::ArrowOfRadius(gIntArrow, X0, Y0, Z0, X0-X, Y0-Y, Z0-Z, M_PI / 15., Rayon / 20.);
TCollection_AsciiString ValOfRadius(Rayon);
- PText.SetCoord( 0.5*(X0+X), 0.5*(Y0+Y), 0.5*(Z0+Z) );
+ Graphic3d_Vertex PText (0.5*(X0+X), 0.5*(Y0+Y), 0.5*(Z0+Z));
gradius->Text(ValOfRadius.ToCString(),PText,0.01);
}
const Standard_Real theLinearAttenuation = 0.0);
//! Defines the position of the light source.
- Standard_EXPORT virtual void SetPosition (const Standard_Real theX,
- const Standard_Real theY,
- const Standard_Real theZ) Standard_OVERRIDE;
+ virtual void SetPosition (Standard_Real theX,
+ Standard_Real theY,
+ Standard_Real theZ) Standard_OVERRIDE
+ {
+ myLight.Position.x() = theX;
+ myLight.Position.y() = theY;
+ myLight.Position.z() = theZ;
+ }
//! Defines the attenuation factors.
//! Warning: raises BadValue from V3d
const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE;
//! Returns the position of the light source.
- Standard_EXPORT void Position (Standard_Real& theX,
- Standard_Real& theY,
- Standard_Real& theZ) const Standard_OVERRIDE;
+ void Position (Standard_Real& theX,
+ Standard_Real& theY,
+ Standard_Real& theZ) const Standard_OVERRIDE
+ {
+ theX = myLight.Position.x();
+ theY = myLight.Position.y();
+ theZ = myLight.Position.z();
+ }
//! Returns the attenuation factors.
- Standard_EXPORT void Attenuation (Standard_Real& theConstAttenuation,
- Standard_Real& theLinearAttenuation) const;
+ void Attenuation (Standard_Real& theConstAttenuation,
+ Standard_Real& theLinearAttenuation) const
+ {
+ theConstAttenuation = myLight.ConstAttenuation();
+ theLinearAttenuation = myLight.LinearAttenuation();
+ }
DEFINE_STANDARD_RTTIEXT(V3d_PositionalLight,V3d_PositionLight)
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-/***********************************************************************
- FONCTION :
- ----------
- Classe V3d_SpotLight :
- HISTORIQUE DES MODIFICATIONS :
- --------------------------------
- 00-09-92 : GG ; Creation.
- 18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
- 30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
- 02.15.100 : JR : Clutter
-************************************************************************/
-/*----------------------------------------------------------------------*/
-/*
- * Includes
- */
+#include <V3d_SpotLight.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_Vec.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Vector.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <V3d.hxx>
#include <V3d_BadValue.hxx>
-#include <V3d_SpotLight.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
const Standard_Real theAngle)
: V3d_PositionLight (theViewer)
{
- Graphic3d_Vector aDir = V3d::GetProjAxis (theDirection);
+ gp_Dir aDir = V3d::GetProjAxis (theDirection);
SetType (V3d_SPOT);
SetColor (theColor);
SetTarget (theX + aDir.X(), theY + aDir.Y(), theZ + aDir.Z());
SetAngle (theAngle);
}
-// =======================================================================
-// function : SetPosition
-// purpose :
-// =======================================================================
-void V3d_SpotLight::SetPosition (const Standard_Real theXp,
- const Standard_Real theYp,
- const Standard_Real theZp)
-{
- myLight.Position.x() = theXp;
- myLight.Position.y() = theYp;
- myLight.Position.z() = theZp;
-}
-
// =======================================================================
// function : SetDirection
// purpose :
// =======================================================================
-void V3d_SpotLight::SetDirection (const Standard_Real theVx,
- const Standard_Real theVy,
- const Standard_Real theVz)
+void V3d_SpotLight::SetDirection (V3d_TypeOfOrientation theDirection)
{
- myLight.Direction.x() = static_cast<Standard_ShortReal> (theVx);
- myLight.Direction.y() = static_cast<Standard_ShortReal> (theVy);
- myLight.Direction.z() = static_cast<Standard_ShortReal> (theVz);
-}
-
-// =======================================================================
-// function : SetDirection
-// purpose :
-// =======================================================================
-void V3d_SpotLight::SetDirection (const V3d_TypeOfOrientation theDirection)
-{
- Graphic3d_Vector aDir = V3d::GetProjAxis (theDirection);
+ gp_Dir aDir = V3d::GetProjAxis (theDirection);
SetDirection (aDir.X(), aDir.Y(), aDir.Z());
}
myLight.ChangeAngle() = static_cast<Standard_ShortReal> (theAngle);
}
-
-// =======================================================================
-// function : Direction
-// purpose :
-// =======================================================================
-void V3d_SpotLight::Direction (Standard_Real& theVx,
- Standard_Real& theVy,
- Standard_Real& theVz) const
-{
- theVx = myLight.Direction.x();
- theVy = myLight.Direction.y();
- theVz = myLight.Direction.z();
-}
-
-// =======================================================================
-// function : Direction
-// purpose :
-// =======================================================================
-void V3d_SpotLight::Position (Standard_Real& theXp,
- Standard_Real& theYp,
- Standard_Real& theZp) const
-{
- theXp = myLight.Position.x();
- theYp = myLight.Position.y();
- theZp = myLight.Position.z();
-}
-
-// =======================================================================
-// function : Attenuation
-// purpose :
-// =======================================================================
-void V3d_SpotLight::Attenuation (Standard_Real& theConstAttenuation,
- Standard_Real& theLinearAttenuation) const
-{
- theConstAttenuation = myLight.ConstAttenuation();
- theLinearAttenuation = myLight.LinearAttenuation();
-}
-
-// =======================================================================
-// function : Concentration
-// purpose :
-// =======================================================================
-Standard_Real V3d_SpotLight::Concentration ()const
-{
- return myLight.Concentration();
-}
-
-// =======================================================================
-// function : Concentration
-// purpose :
-// =======================================================================
-Standard_Real V3d_SpotLight::Angle()const
-{
- return myLight.Angle();
-}
-
// =======================================================================
// function : Symbol
// purpose :
void V3d_SpotLight::Display (const Handle(V3d_View)& theView,
const V3d_TypeOfRepresentation theTPres)
{
- Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1;
V3d::ArrowOfRadius(gExtArrow,X-.1*(X-X0),Y-.1*(Y-Y0),Z-.1*(Z-Z0),X-X0,Y-Y0,Z-Z0,M_PI/15.,Rayon/20.);
V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,M_PI/15.,Rayon/20.);
TCollection_AsciiString ValOfRadius(Rayon);
- PText.SetCoord( .5*(X0+X), .5*(Y0+Y), .5*(Z0+Z) );
+ Graphic3d_Vertex PText ( .5*(X0+X), .5*(Y0+Y), .5*(Z0+Z) );
gradius->Text(ValOfRadius.ToCString(),PText,0.01);
}
const Standard_Real theAngle = 0.523599);
//! Defines the position of the light source.
- Standard_EXPORT virtual void SetPosition (const Standard_Real theX,
- const Standard_Real theY,
- const Standard_Real theZ) Standard_OVERRIDE;
+ virtual void SetPosition (Standard_Real theX,
+ Standard_Real theY,
+ Standard_Real theZ) Standard_OVERRIDE
+ {
+ myLight.Position.x() = theX;
+ myLight.Position.y() = theY;
+ myLight.Position.z() = theZ;
+ }
//! Defines the direction of the light source.
//! If the normal vector is NULL.
- Standard_EXPORT void SetDirection (const Standard_Real theVx,
- const Standard_Real theVy,
- const Standard_Real theVz);
+ void SetDirection (Standard_Real theVx,
+ Standard_Real theVy,
+ Standard_Real theVz)
+ {
+ myLight.Direction.x() = static_cast<Standard_ShortReal> (theVx);
+ myLight.Direction.y() = static_cast<Standard_ShortReal> (theVy);
+ myLight.Direction.z() = static_cast<Standard_ShortReal> (theVz);
+ }
//! Defines the direction of the light source
//! according to a predefined directional vector.
- Standard_EXPORT void SetDirection (const V3d_TypeOfOrientation theOrientation);
+ Standard_EXPORT void SetDirection (V3d_TypeOfOrientation theOrientation);
//! Defines the coefficients of attenuation.
//! Warning! raises BadValue from V3d
const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE;
//! Returns the direction of the light source defined by theVx, theVy, theVz.
- Standard_EXPORT void Direction (Standard_Real& theVx,
- Standard_Real& theVy,
- Standard_Real& theVz) const;
+ void Direction (Standard_Real& theVx,
+ Standard_Real& theVy,
+ Standard_Real& theVz) const
+ {
+ theVx = myLight.Direction.x();
+ theVy = myLight.Direction.y();
+ theVz = myLight.Direction.z();
+ }
//! Returns the position of the light source.
- Standard_EXPORT void Position (Standard_Real& theX,
- Standard_Real& theY,
- Standard_Real& theZ) const Standard_OVERRIDE;
+ virtual void Position (Standard_Real& theX,
+ Standard_Real& theY,
+ Standard_Real& theZ) const Standard_OVERRIDE
+ {
+ theX = myLight.Position.x();
+ theY = myLight.Position.y();
+ theZ = myLight.Position.z();
+ }
//! Returns the attenuation factors A1,A2 of the light source.
- Standard_EXPORT void Attenuation (Standard_Real& theConstAttentuation,
- Standard_Real& theLinearAttentuation) const;
+ void Attenuation (Standard_Real& theConstAttentuation,
+ Standard_Real& theLinearAttentuation) const
+ {
+ theConstAttentuation = myLight.ConstAttenuation();
+ theLinearAttentuation = myLight.LinearAttenuation();
+ }
- Standard_EXPORT Standard_Real Concentration() const;
+ Standard_Real Concentration() const { return myLight.Concentration(); }
//! Returns the spot angle.
- Standard_EXPORT Standard_Real Angle() const;
+ Standard_Real Angle() const { return myLight.Angle(); }
DEFINE_STANDARD_RTTIEXT(V3d_SpotLight,V3d_PositionLight)
#include <Graphic3d_MapOfStructure.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Image_AlienPixMap.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
//function : SetAxis
//purpose :
//=============================================================================
-void V3d_View::SetAxis(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz)
+void V3d_View::SetAxis (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
+ const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
{
- Standard_Real D,Nx = Vx,Ny = Vy,Nz = Vz ;
-
- D = Sqrt( Vx*Vx + Vy*Vy + Vz*Vz ) ;
- V3d_BadValue_Raise_if ( D <= 0. , "V3d_View::SetAxis, bad axis");
- Nx /= D ; Ny /= D ; Nz /= D ;
- MyDefaultViewPoint.SetCoord(X,Y,Z) ;
- MyDefaultViewAxis.SetCoord(Nx,Ny,Nz) ;
+ myDefaultViewPoint.SetCoord (theX, theY, theZ);
+ myDefaultViewAxis.SetCoord (theVx, theVy, theVz);
}
//=============================================================================
//function : Rotate
//purpose :
//=============================================================================
-void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle,
- const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
+void V3d_View::Rotate (const V3d_TypeOfAxe theAxe, const Standard_Real theAngle,
+ const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, const Standard_Boolean theStart)
{
- Standard_Real Angle = angle ;
+ Standard_Real anAngle = theAngle;
- if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
- else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
+ if (anAngle > 0.0) while (anAngle > DEUXPI) anAngle -= DEUXPI;
+ else if (anAngle < 0.0) while (anAngle < -DEUXPI) anAngle += DEUXPI;
Handle(Graphic3d_Camera) aCamera = Camera();
- if (Start)
+ if (theStart)
{
- myGravityReferencePoint.SetCoord (X, Y, Z);
+ myGravityReferencePoint.SetCoord (theX, theY, theZ);
myCamStartOpUp = aCamera->Up();
myCamStartOpEye = aCamera->Eye();
myCamStartOpCenter = aCamera->Center();
- switch (Axe) {
- case V3d_X :
- myViewAxis.SetCoord(1.,0.,0.) ;
- break ;
- case V3d_Y :
- myViewAxis.SetCoord(0.,1.,0.) ;
- break ;
- case V3d_Z :
- myViewAxis.SetCoord(0.,0.,1.) ;
- break ;
+ switch (theAxe)
+ {
+ case V3d_X: myViewAxis = gp::DX(); break;
+ case V3d_Y: myViewAxis = gp::DY(); break;
+ case V3d_Z: myViewAxis = gp::DZ(); break;
}
myCamStartOpUp = aCamera->Up();
// rotate camera around passed axis
gp_Trsf aRotation;
gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
- gp_Dir aRAxis ((Axe == V3d_X) ? 1.0 : 0.0,
- (Axe == V3d_Y) ? 1.0 : 0.0,
- (Axe == V3d_Z) ? 1.0 : 0.0);
+ gp_Dir aRAxis ((theAxe == V3d_X) ? 1.0 : 0.0,
+ (theAxe == V3d_Y) ? 1.0 : 0.0,
+ (theAxe == V3d_Z) ? 1.0 : 0.0);
- aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
+ aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), anAngle);
aCamera->Transform (aRotation);
myCamStartOpCenter = aCamera->Center();
}
- const Graphic3d_Vertex& aPnt = MyDefaultViewPoint;
- const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
-
aCamera->SetUp (myCamStartOpUp);
aCamera->SetEye (myCamStartOpEye);
aCamera->SetCenter (myCamStartOpCenter);
gp_Trsf aRotation;
- gp_Pnt aRCenter (aPnt.X(), aPnt.Y(), aPnt.Z());
- gp_Dir aRAxis (anAxis.X(), anAxis.Y(), anAxis.Z());
+ gp_Pnt aRCenter (myDefaultViewPoint);
+ gp_Dir aRAxis (myDefaultViewAxis);
aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
aCamera->Transform (aRotation);
aCamera->SetEye (myCamStartOpEye);
aCamera->SetCenter (myCamStartOpCenter);
- const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
-
gp_Trsf aRotation;
gp_Pnt aRCenter = aCamera->Eye();
- gp_Dir aRAxis (anAxis.X(), anAxis.Y(), anAxis.Z());
+ gp_Dir aRAxis (myDefaultViewAxis);
aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
aCamera->Transform (aRotation);
void V3d_View::SetTwist(const Standard_Real angle)
{
Standard_Real Angle = angle ;
- Standard_Boolean TheStatus;
if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
Handle(Graphic3d_Camera) aCamera = Camera();
- gp_Dir aReferencePlane (aCamera->Direction().Reversed());
- gp_Dir anUp;
-
- anUp = gp_Dir (0.0, 0.0, 1.0);
-
- TheStatus = ScreenAxis(aReferencePlane, anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- if( !TheStatus ) {
- anUp = gp_Dir (0.0, 1.0, 0.0);
- TheStatus = ScreenAxis(aReferencePlane, anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- }
- if( !TheStatus ) {
- anUp = gp_Dir (1.0, 0.0, 0.0);
- TheStatus = ScreenAxis(aReferencePlane, anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
+ const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+ if (!screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
+ {
+ throw V3d_BadValue ("V3d_ViewSetTwist, alignment of Eye,At,Up,");
}
-
- V3d_BadValue_Raise_if( !TheStatus,"V3d_ViewSetTwist, alignment of Eye,At,Up,");
gp_Pnt aRCenter = aCamera->Center();
gp_Dir aZAxis (aCamera->Direction().Reversed());
gp_Trsf aTrsf;
aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle);
- Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
- myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
-
- aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+ aCamera->SetUp (gp_Dir (myYscreenAxis));
aCamera->Transform (aTrsf);
AutoZFit();
Zpn = 1.;
}
- const Graphic3d_Vector& aBck = V3d::GetProjAxis (Orientation);
+ const gp_Dir aBck = V3d::GetProjAxis (Orientation);
// retain camera panning from origin when switching projection
Handle(Graphic3d_Camera) aCamera = Camera();
//function : SetUp
//purpose :
//=============================================================================
-void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standard_Real Vz)
+void V3d_View::SetUp (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
{
- Standard_Boolean TheStatus ;
- V3d_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0. ,
- "V3d_View::SetUp, nullUp vector");
-
Handle(Graphic3d_Camera) aCamera = Camera();
- gp_Dir aReferencePlane (aCamera->Direction().Reversed());
- gp_Dir anUp (Vx, Vy, Vz);
-
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- if( !TheStatus ) {
- anUp = gp_Dir (0.0, 0.0, 1.0);
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- }
- if( !TheStatus ) {
- anUp = gp_Dir (0.0, 1.0, 0.0);
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- }
- if( !TheStatus ) {
- anUp = gp_Dir (1.0, 0.0, 0.0);
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
+ const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+ const gp_Dir anUp (theVx, theVy, theVz);
+ if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
+ {
+ throw V3d_BadValue ("V3d_View::Setup, alignment of Eye,At,Up");
}
- V3d_BadValue_Raise_if( !TheStatus,"V3d_View::Setup, alignment of Eye,At,Up");
- Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
- myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
-
- aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+ aCamera->SetUp (gp_Dir (myYscreenAxis));
AutoZFit();
//function : SetUp
//purpose :
//=============================================================================
-void V3d_View::SetUp( const V3d_TypeOfOrientation Orientation )
+void V3d_View::SetUp (const V3d_TypeOfOrientation theOrientation)
{
- Standard_Boolean TheStatus ;
-
Handle(Graphic3d_Camera) aCamera = Camera();
- gp_Dir aReferencePlane (aCamera->Direction().Reversed());
- gp_Dir anUp;
-
- const Graphic3d_Vector& aViewReferenceUp = V3d::GetProjAxis(Orientation) ;
- anUp = gp_Dir (aViewReferenceUp.X(), aViewReferenceUp.Y(), aViewReferenceUp.Z());
-
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- if( !TheStatus ) {
- anUp = gp_Dir (0.,0.,1.);
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- }
- if( !TheStatus ) {
- anUp = gp_Dir (0.,1.,0.);
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
- }
- if( !TheStatus ) {
- anUp = gp_Dir (1.,0.,0.);
- TheStatus = ScreenAxis(aReferencePlane,anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
+ const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+ const gp_Dir anUp = V3d::GetProjAxis (theOrientation);
+ if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+ && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
+ {
+ throw V3d_BadValue ("V3d_View::SetUp, alignment of Eye,At,Up");
}
- V3d_BadValue_Raise_if( !TheStatus, "V3d_View::SetUp, alignment of Eye,At,Up");
-
- Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
- myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
- aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+ aCamera->SetUp (gp_Dir (myYscreenAxis));
AutoZFit();
//=============================================================================
Standard_Real V3d_View::Twist() const
{
- Standard_Real Xup,Yup,Zup,Xpn,Ypn,Zpn,X0,Y0,Z0 ;
- Standard_Real pvx,pvy,pvz,pvn,sca,angle ;
- Graphic3d_Vector Xaxis,Yaxis,Zaxis ;
- Standard_Boolean TheStatus ;
+ gp_Vec Xaxis, Yaxis, Zaxis;
+ const gp_Dir aReferencePlane (Camera()->Direction().Reversed());
+ if (!screenAxis (aReferencePlane, gp::DZ(), Xaxis, Yaxis, Zaxis)
+ && !screenAxis (aReferencePlane, gp::DY(), Xaxis, Yaxis, Zaxis)
+ && !screenAxis (aReferencePlane, gp::DX(), Xaxis, Yaxis, Zaxis))
+ {
+ //
+ }
- gp_Dir aReferencePlane (Camera()->Direction().Reversed());
- gp_Dir anUp;
+ // Compute Cross Vector From Up & Origin
+ const gp_Dir aCameraUp = Camera()->Up();
+ const gp_XYZ aP = Yaxis.XYZ().Crossed (aCameraUp.XYZ());
- Proj(Xpn,Ypn,Zpn);
- anUp = gp_Dir (0.,0.,1.) ;
- TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
- if( !TheStatus ) {
- anUp = gp_Dir (0.,1.,0.) ;
- TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
- }
- if( !TheStatus ) {
- anUp = gp_Dir (1.,0.,0.) ;
- TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
+ // compute Angle
+ Standard_Real anAngle = ASin (Max (Min (aP.Modulus(), 1.0), -1.0));
+ if (Yaxis.Dot (aCameraUp.XYZ()) < 0.0)
+ {
+ anAngle = M_PI - anAngle;
}
- Yaxis.Coord(X0,Y0,Z0) ;
-
- Up(Xup,Yup,Zup) ;
- /* Compute Cross Vector From Up & Origin */
- pvx = Y0*Zup - Z0*Yup ;
- pvy = Z0*Xup - X0*Zup ;
- pvz = X0*Yup - Y0*Xup ;
- pvn = pvx*pvx + pvy*pvy + pvz*pvz ;
- sca = X0*Xup + Y0*Yup + Z0*Zup ;
- /* Compute Angle */
- angle = Sqrt(pvn) ;
- if( angle > 1. ) angle = 1. ;
- else if( angle < -1. ) angle = -1. ;
- angle = asin(angle) ;
- if( sca < 0. ) angle = M_PI - angle ;
- if( angle > 0. && angle < M_PI ) {
- sca = pvx*Xpn + pvy*Ypn + pvz*Zpn ;
- if( sca < 0. ) angle = DEUXPI - angle ;
+ if (anAngle > 0.0
+ && anAngle < M_PI)
+ {
+ const gp_Dir aProjDir = Camera()->Direction().Reversed();
+ if (aP.Dot (aProjDir.XYZ()) < 0.0)
+ {
+ anAngle = DEUXPI - anAngle;
+ }
}
- return angle ;
+ return anAngle;
}
//=============================================================================
}
//=============================================================================
-//function : ScreenAxis
+//function : screenAxis
//purpose :
//=============================================================================
-Standard_Boolean V3d_View::ScreenAxis( const gp_Dir &Vpn, const gp_Dir &Vup, Graphic3d_Vector &Xaxe, Graphic3d_Vector &Yaxe, Graphic3d_Vector &Zaxe)
+Standard_Boolean V3d_View::screenAxis (const gp_Dir& theVpn, const gp_Dir& theVup,
+ gp_Vec& theXaxe, gp_Vec& theYaxe, gp_Vec& theZaxe)
{
- Standard_Real Xpn, Ypn, Zpn, Xup, Yup, Zup;
- Standard_Real dx1, dy1, dz1, xx, yy, zz;
+ theXaxe = theVup.XYZ().Crossed (theVpn.XYZ());
+ if (theXaxe.Magnitude() <= gp::Resolution())
+ {
+ return Standard_False;
+ }
+ theXaxe.Normalize();
- Xpn = Vpn.X(); Ypn = Vpn.Y(); Zpn = Vpn.Z();
- Xup = Vup.X(); Yup = Vup.Y(); Zup = Vup.Z();
- xx = Yup*Zpn - Zup*Ypn;
- yy = Zup*Xpn - Xup*Zpn;
- zz = Xup*Ypn - Yup*Xpn;
- Xaxe.SetCoord (xx, yy, zz);
- if (Xaxe.LengthZero()) return Standard_False;
- Xaxe.Normalize();
- Xaxe.Coord(dx1, dy1, dz1);
- xx = Ypn*dz1 - Zpn*dy1;
- yy = Zpn*dx1 - Xpn*dz1;
- zz = Xpn*dy1 - Ypn*dx1;
- Yaxe.SetCoord (xx, yy, zz) ;
- if (Yaxe.LengthZero()) return Standard_False;
- Yaxe.Normalize();
+ theYaxe = theVpn.XYZ().Crossed (theXaxe.XYZ());
+ if (theYaxe.Magnitude() <= gp::Resolution())
+ {
+ return Standard_False;
+ }
+ theYaxe.Normalize();
- Zaxe.SetCoord (Xpn, Ypn, Zpn);
- Zaxe.Normalize();
+ theZaxe = theVpn.XYZ();
+ theZaxe.Normalize();
return Standard_True;
}
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_RenderingParams.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Image_PixMap.hxx>
class Aspect_Grid;
class Aspect_Window;
-class Bnd_Box;
class Graphic3d_Group;
class Graphic3d_Structure;
class Graphic3d_TextureEnv;
-class Graphic3d_Vector;
-class Quantity_Color;
class Standard_MultiplyDefined;
class Standard_TypeMismatch;
class V3d_BadValue;
//! Determines the screen axes in the reference
//! framework of the view.
- Standard_EXPORT static Standard_Boolean ScreenAxis (const gp_Dir& Vpn, const gp_Dir& Vup, Graphic3d_Vector& Xaxe, Graphic3d_Vector& Yaxe, Graphic3d_Vector& Zaxe);
+ Standard_EXPORT static Standard_Boolean screenAxis (const gp_Dir& theVpn, const gp_Dir& theVup,
+ gp_Vec& theXaxe, gp_Vec& theYaxe, gp_Vec& theZaxe);
//! Transforms the Vertex V according to the matrice Matrix .
Standard_EXPORT static gp_XYZ TrsPoint (const Graphic3d_Vertex& V, const TColStd_Array2OfReal& Matrix);
V3d_ViewerPointer MyViewer;
V3d_ListOfLight myActiveLights;
- Graphic3d_Vector MyDefaultViewAxis;
- Graphic3d_Vertex MyDefaultViewPoint;
+ gp_Dir myDefaultViewAxis;
+ gp_Pnt myDefaultViewPoint;
Handle(Aspect_Window) MyWindow;
V3d_ListOfLight::Iterator myActiveLightsIterator;
Standard_Integer sx;
TColStd_Array2OfReal MyTrsf;
Handle(Graphic3d_Structure) MyGridEchoStructure;
Handle(Graphic3d_Group) MyGridEchoGroup;
- Graphic3d_Vector myXscreenAxis;
- Graphic3d_Vector myYscreenAxis;
- Graphic3d_Vector myZscreenAxis;
- Graphic3d_Vector myViewAxis;
+ gp_Vec myXscreenAxis;
+ gp_Vec myYscreenAxis;
+ gp_Vec myZscreenAxis;
+ gp_Dir myViewAxis;
Graphic3d_Vertex myGravityReferencePoint;
Standard_Boolean myAutoZFitIsOn;
Standard_Real myAutoZFitScaleFactor;
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_TypeMismatch.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_TypeMismatch.hxx>
gp_Dir aReferencePlane (aCamera->Direction().Reversed());
gp_Dir anUp (aCamera->Up());
- if (!ScreenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
+ if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
{
- throw V3d_BadValue("V3d_View::Translate, alignment of Eye,At,Up");
+ throw V3d_BadValue("V3d_View::Translate, alignment of Eye,At,Up");
}
}
//function : Move
//purpose :
//=============================================================================
-void V3d_View::Move (const Standard_Real Length, const Standard_Boolean Start)
+void V3d_View::Move (const Standard_Real theLength, const Standard_Boolean theStart)
{
Handle(Graphic3d_Camera) aCamera = Camera();
-
- if( Start )
+ if (theStart)
{
myCamStartOpEye = aCamera->Eye();
}
aCamera->SetEye (myCamStartOpEye);
-
- Standard_Real Vx, Vy, Vz;
- MyDefaultViewAxis.Coord (Vx, Vy, Vz) ;
-
- aCamera->SetEye (aCamera->Eye().XYZ() + Length * gp_Pnt (Vx, Vy, Vz).XYZ());
+ aCamera->SetEye (aCamera->Eye().XYZ() + theLength * myDefaultViewAxis.XYZ());
AutoZFit();
gp_Dir aReferencePlane (aCamera->Direction().Reversed());
gp_Dir anUp (aCamera->Up());
- if (!ScreenAxis (aReferencePlane, anUp,
- myXscreenAxis,myYscreenAxis,myZscreenAxis))
- throw V3d_BadValue("V3d_View::Translate, alignment of Eye,At,Up");
+ if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
+ {
+ throw V3d_BadValue("V3d_View::Translate, alignment of Eye,At,Up");
+ }
}
- Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
-
- myXscreenAxis.Coord (XX,XY,XZ);
- myYscreenAxis.Coord (YX,YY,YZ);
- myZscreenAxis.Coord (ZX,ZY,ZZ);
-
aCamera->SetEye (myCamStartOpEye);
aCamera->SetCenter (myCamStartOpCenter);
aCamera->SetCenter (aCamera->Center().XYZ()
- - Dx * gp_Pnt (XX, XY, XZ).XYZ()
- - Dy * gp_Pnt (YX, YY, YZ).XYZ()
- - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ - Dx * myXscreenAxis.XYZ()
+ - Dy * myYscreenAxis.XYZ()
+ - Dz * myZscreenAxis.XYZ()
);
aCamera->SetEye (aCamera->Eye().XYZ()
- - Dx * gp_Pnt (XX, XY, XZ).XYZ()
- - Dy * gp_Pnt (YX, YY, YZ).XYZ()
- - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ - Dx * myXscreenAxis.XYZ()
+ - Dy * myYscreenAxis.XYZ()
+ - Dz * myZscreenAxis.XYZ()
);
AutoZFit();
void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart)
{
Handle(Graphic3d_Camera) aCamera = Camera();
-
- Standard_Real aVx, aVy, aVz;
if (theStart)
{
myCamStartOpCenter = aCamera->Center() ;
}
- MyDefaultViewAxis.Coord (aVx, aVy, aVz);
- gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - gp_Pnt (aVx, aVy, aVz).XYZ() * theLength);
+
+ gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - myDefaultViewAxis.XYZ() * theLength);
aCamera->SetCenter (aNewCenter);
AutoZFit();
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_TypeMismatch.hxx>
+++ /dev/null
-puts "================"
-puts "OCC22762"
-puts "================"
-puts ""
-######################################################################################
-# Bug in Graphic3d_Vector::IsParallel
-######################################################################################
-
-set BugNumber OCC22762
-
-set x0 0
-set y0 0
-set z0 0
-set x1 0.57735026
-set y1 0.57735026
-set z1 0.57735026
-set x2 -0.40824828
-set y2 -0.40824828
-set z2 0.81649655
-
-vinit
-vpoint p0 $x0 $y0 $z0
-vpoint p1 $x1 $y1 $z1
-vpoint p2 $x2 $y2 $z2
-vline line1 p0 p1
-vline line2 p0 p2
-vfit
-
-set info [ OCC22762 $x1 $y1 $z1 $x2 $y2 $z2]
-set Word [string compare [lindex ${info} end] "false"]
-
-# Resume
-puts ""
-if { ${Word} == 0 } {
- puts "OK ${BugNumber}"
-} else {
- puts "Faulty ${BugNumber}"
-}
-
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png
-
-
-