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

0029292: Coding Rules - remove Graphic3d_Vector duplicating gp_XYZ

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.
This commit is contained in:
kgv 2017-11-02 16:29:17 +03:00 committed by bugmaster
parent 69f87d091e
commit 21b2385fcb
30 changed files with 309 additions and 1135 deletions

View File

@ -35,7 +35,6 @@
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <Prs3d_Arrow.hxx> #include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx> #include <Prs3d_ArrowAspect.hxx>

View File

@ -37,7 +37,6 @@
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Vertex.hxx>
#include <IntAna2d_AnaIntersection.hxx> #include <IntAna2d_AnaIntersection.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <Prs3d_Arrow.hxx> #include <Prs3d_Arrow.hxx>

View File

@ -150,9 +150,6 @@ Graphic3d_Vec.hxx
Graphic3d_Vec2.hxx Graphic3d_Vec2.hxx
Graphic3d_Vec3.hxx Graphic3d_Vec3.hxx
Graphic3d_Vec4.hxx Graphic3d_Vec4.hxx
Graphic3d_Vector.cxx
Graphic3d_Vector.hxx
Graphic3d_VectorError.hxx
Graphic3d_Vertex.cxx Graphic3d_Vertex.cxx
Graphic3d_Vertex.hxx Graphic3d_Vertex.hxx
Graphic3d_VerticalTextAlignment.hxx Graphic3d_VerticalTextAlignment.hxx

View File

@ -26,9 +26,7 @@
#include <Graphic3d_StructureDefinitionError.hxx> #include <Graphic3d_StructureDefinitionError.hxx>
#include <Graphic3d_StructureManager.hxx> #include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransformError.hxx> #include <Graphic3d_TransformError.hxx>
#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
#include <Standard_Type.hxx>
#include "Graphic3d_Structure.pxx" #include "Graphic3d_Structure.pxx"

View File

@ -47,7 +47,6 @@ class Graphic3d_StructureManager;
class Graphic3d_DataStructureManager; class Graphic3d_DataStructureManager;
class Bnd_Box; class Bnd_Box;
class gp_Pnt; class gp_Pnt;
class Graphic3d_Vector;
class Graphic3d_Structure; class Graphic3d_Structure;

View File

@ -1,188 +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.
// 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));
}

View File

@ -1,120 +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 _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

View File

@ -1,37 +0,0 @@
// 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

View File

@ -48,7 +48,6 @@
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
class Aspect_Window; class Aspect_Window;
class Graphic3d_Vector;
class Quantity_Color; class Quantity_Color;
class Graphic3d_Vertex; class Graphic3d_Vertex;
class TCollection_ExtendedString; class TCollection_ExtendedString;

View File

@ -4505,31 +4505,6 @@ static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, c
return 0; 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 <IntCurvesFace_ShapeIntersector.hxx>
#include <gp_Lin.hxx> #include <gp_Lin.hxx>
Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
@ -4916,7 +4891,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
theCommands.Add("OCC22301", "OCC22301", __FILE__, OCC22301, group); 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("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("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("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("CR23403", "CR23403 string", __FILE__, CR23403, group);
theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group); theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group);

View File

@ -811,14 +811,15 @@ namespace
//! Normalize the depth values. //! Normalize the depth values.
virtual void Flush() Standard_OVERRIDE virtual void Flush() Standard_OVERRIDE
{ {
Standard_Real aFrom = 0.0; float aFrom = 0.0f;
Standard_Real aDelta = 1.0; float aDelta = 1.0f;
if (myDepthMin <= myDepthMax) if (myDepthMin <= myDepthMax)
{ {
aFrom = myDepthMin; aFrom = float(myDepthMin);
if (myDepthMin != myDepthMax) aDelta = float(myDepthMax) - float(myDepthMin);
if (aDelta <= ShortRealEpsilon())
{ {
aDelta = myDepthMax - myDepthMin; aDelta = 1.0f;
} }
} }
for (Standard_Size aRowIter = 0; aRowIter < myUnnormImage.SizeY(); ++aRowIter) for (Standard_Size aRowIter = 0; aRowIter < myUnnormImage.SizeY(); ++aRowIter)
@ -834,7 +835,7 @@ namespace
continue; continue;
} }
float aNormDepth = float((Standard_Real(aDepth) - aFrom) / aDelta); float aNormDepth = (aDepth - aFrom) / aDelta;
if (myToInverse) if (myToInverse)
{ {
aNormDepth = 1.0f - aNormDepth; aNormDepth = 1.0f - aNormDepth;
@ -874,7 +875,7 @@ namespace
const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked); const SelectMgr_SortCriterion& aSortCriterion = myMainSel->PickedData (thePicked);
const float aDepth = float(aSortCriterion.Depth); 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)));
} }
}; };

View File

@ -30,100 +30,11 @@
#include <Graphic3d_AspectText3d.hxx> #include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_Vector.hxx>
#include <Quantity_NameOfColor.hxx> #include <Quantity_NameOfColor.hxx>
#include <V3d.hxx> #include <V3d.hxx>
#include <V3d_View.hxx> #include <V3d_View.hxx>
#include <V3d_Viewer.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) 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; Standard_Real Xc, Yc, Zc, Xi, Yi, Zi, Xj, Yj, Zj;

View File

@ -35,9 +35,40 @@ public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
//! Determines the orientation vector corresponding //! Determines the orientation vector corresponding to the predefined orientation type.
//! to the predefined orientation type. static gp_Dir GetProjAxis (const V3d_TypeOfOrientation theOrientation)
Standard_EXPORT static Graphic3d_Vector GetProjAxis (const V3d_TypeOfOrientation Orientation); {
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. //! Compute the graphic structure of arrow.
//! X0,Y0,Z0 : coordinate of the arrow. //! X0,Y0,Z0 : coordinate of the arrow.

View File

@ -20,7 +20,6 @@
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <TColgp_SequenceOfPnt.hxx> #include <TColgp_SequenceOfPnt.hxx>

View File

@ -11,44 +11,15 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
/*********************************************************************** #include <V3d_DirectionalLight.hxx>
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 <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_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Standard_Type.hxx>
#include <TColStd_Array2OfReal.hxx> #include <TColStd_Array2OfReal.hxx>
#include <V3d.hxx> #include <V3d.hxx>
#include <V3d_BadValue.hxx> #include <V3d_BadValue.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_View.hxx> #include <V3d_View.hxx>
#include <V3d_Viewer.hxx> #include <V3d_Viewer.hxx>
@ -64,7 +35,7 @@ V3d_DirectionalLight::V3d_DirectionalLight (const Handle(V3d_Viewer)& theViewer,
const Standard_Boolean theIsHeadlight) const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (theViewer) : V3d_PositionLight (theViewer)
{ {
Graphic3d_Vector aV = V3d::GetProjAxis (theDirection); gp_Dir aV = V3d::GetProjAxis (theDirection);
SetType (V3d_DIRECTIONAL); SetType (V3d_DIRECTIONAL);
SetColor (theColor); SetColor (theColor);
SetHeadlight (theIsHeadlight); SetHeadlight (theIsHeadlight);
@ -112,9 +83,9 @@ void V3d_DirectionalLight::SetSmoothAngle (const Standard_Real theValue)
// function : SetDirection // function : SetDirection
// purpose : // 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()); SetDirection (aV.X(), aV.Y(), aV.Z());
} }
@ -122,17 +93,11 @@ void V3d_DirectionalLight::SetDirection (const V3d_TypeOfOrientation theDirectio
// function : SetDirection // function : SetDirection
// purpose : // purpose :
// ======================================================================= // =======================================================================
void V3d_DirectionalLight::SetDirection (const Standard_Real theVx, void V3d_DirectionalLight::SetDirection (Standard_Real theVx,
const Standard_Real theVy, Standard_Real theVy,
const Standard_Real theVz) Standard_Real theVz)
{ {
V3d_BadValue_Raise_if (Sqrt (theVx * theVx + theVy * theVy + theVz * theVz) <= 0., gp_Dir aV (theVx, theVy, theVz);
"V3d_DirectionalLight::SetDirection, "
"null vector" );
Graphic3d_Vector aV (theVx, theVy, theVz);
aV.Normalize();
myLight.Direction.x() = static_cast<Standard_ShortReal> (aV.X()); myLight.Direction.x() = static_cast<Standard_ShortReal> (aV.X());
myLight.Direction.y() = static_cast<Standard_ShortReal> (aV.Y()); myLight.Direction.y() = static_cast<Standard_ShortReal> (aV.Y());
myLight.Direction.z() = static_cast<Standard_ShortReal> (aV.Z()); myLight.Direction.z() = static_cast<Standard_ShortReal> (aV.Z());
@ -142,57 +107,22 @@ void V3d_DirectionalLight::SetDirection (const Standard_Real theVx,
// function : SetDisplayPosition // function : SetDisplayPosition
// purpose : // purpose :
// ======================================================================= // =======================================================================
void V3d_DirectionalLight::SetDisplayPosition (const Standard_Real theX, void V3d_DirectionalLight::SetDisplayPosition (Standard_Real theX,
const Standard_Real theY, Standard_Real theY,
const Standard_Real theZ) Standard_Real theZ)
{ {
myDisplayPosition.SetCoord(theX, theY, theZ); myDisplayPosition.SetCoord(theX, theY, theZ);
Standard_Real aXt, aYt, aZt; gp_XYZ aTarget;
Target (aXt, aYt, aZt); Target (aTarget.ChangeCoord (1), aTarget.ChangeCoord (2), aTarget.ChangeCoord (3));
Standard_Real aXd = aXt - theX; const gp_XYZ aDispPos = aTarget - gp_XYZ(theX, theY, theZ);
Standard_Real aYd = aYt - theY; if (aDispPos.Modulus() > gp::Resolution())
Standard_Real aZd = aZt - theZ;
if (!Graphic3d_Vector (aXd, aYd, aZd).LengthZero())
{ {
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 // function : DisplayPosition
// purpose : // purpose :
@ -365,16 +295,3 @@ void V3d_DirectionalLight::Display (const Handle(V3d_View)& theView,
myTypeOfRepresentation = Pres; myTypeOfRepresentation = Pres;
myGraphicStructure->Display(); 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();
}

View File

@ -50,23 +50,23 @@ public:
const Standard_Boolean theIsHeadlight = Standard_False); const Standard_Boolean theIsHeadlight = Standard_False);
//! Defines the direction of the light source by a predefined orientation. //! 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. //! Defines the direction of the light source by the predefined vector theXm, theYm, theZm.
//! Warning: raises BadValue from V3d if the vector is null. //! Warning: raises BadValue from V3d if the vector is null.
Standard_EXPORT void SetDirection (const Standard_Real theXm, Standard_EXPORT void SetDirection (Standard_Real theXm,
const Standard_Real theYm, Standard_Real theYm,
const Standard_Real theZm); Standard_Real theZm);
//! Defines the point of light source representation. //! Defines the point of light source representation.
Standard_EXPORT void SetDisplayPosition (const Standard_Real theX, Standard_EXPORT void SetDisplayPosition (Standard_Real theX,
const Standard_Real theY, Standard_Real theY,
const Standard_Real theZ); Standard_Real theZ);
//! Calls SetDisplayPosition method. //! Calls SetDisplayPosition method.
Standard_EXPORT virtual void SetPosition (const Standard_Real theXp, virtual void SetPosition (Standard_Real theXp,
const Standard_Real theYp, Standard_Real theYp,
const Standard_Real theZp) Standard_OVERRIDE; Standard_Real theZp) Standard_OVERRIDE { SetDisplayPosition (theXp, theYp, theZp); }
//! Modifies the smoothing angle (in radians) //! Modifies the smoothing angle (in radians)
Standard_EXPORT void SetSmoothAngle (const Standard_Real theValue); Standard_EXPORT void SetSmoothAngle (const Standard_Real theValue);
@ -84,19 +84,24 @@ public:
const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE; const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE;
//! Calls DisplayPosition method. //! Calls DisplayPosition method.
Standard_EXPORT virtual void Position (Standard_Real& theX, virtual void Position (Standard_Real& theX,
Standard_Real& theY, Standard_Real& theY,
Standard_Real& theZ) const Standard_OVERRIDE; Standard_Real& theZ) const Standard_OVERRIDE { DisplayPosition (theX, theY, theZ); }
//! Returns the chosen position to represent the light source. //! Returns the chosen position to represent the light source.
Standard_EXPORT void DisplayPosition (Standard_Real& theX, void DisplayPosition (Standard_Real& theX,
Standard_Real& theY, Standard_Real& theY,
Standard_Real& theZ) const; Standard_Real& theZ) const { myDisplayPosition.Coord (theX, theY, theZ); }
//! Returns the theVx, theVy, theVz direction of the light source. //! Returns the theVx, theVy, theVz direction of the light source.
Standard_EXPORT void Direction (Standard_Real& theVx, void Direction (Standard_Real& theVx,
Standard_Real& theVy, Standard_Real& theVy,
Standard_Real& theVz) const; Standard_Real& theVz) const
{
theVx = myLight.Direction.x();
theVy = myLight.Direction.y();
theVz = myLight.Direction.z();
}
DEFINE_STANDARD_RTTIEXT(V3d_DirectionalLight,V3d_PositionLight) DEFINE_STANDARD_RTTIEXT(V3d_DirectionalLight,V3d_PositionLight)
@ -108,7 +113,7 @@ private:
private: private:
Graphic3d_Vertex myDisplayPosition; gp_Pnt myDisplayPosition;
}; };
#endif // _V3d_DirectionalLight_HeaderFile #endif // _V3d_DirectionalLight_HeaderFile

View File

@ -127,8 +127,13 @@ void V3d_Light::SetHeadlight (const Standard_Boolean theValue)
// function : SymetricPointOnSphere // function : SymetricPointOnSphere
// purpose : // 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 X0,Y0,Z0,XP,YP,ZP;
Standard_Real PXP,PYP,DeltaX,DeltaY,DeltaZ; Standard_Real PXP,PYP,DeltaX,DeltaY,DeltaZ;
Standard_Real A,B,C,Delta,Lambda; Standard_Real A,B,C,Delta,Lambda;

View File

@ -18,13 +18,6 @@
#define _V3d_Light_HeaderFile #define _V3d_Light_HeaderFile
#include <Graphic3d_CLight.hxx> #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_TypeOfLight.hxx>
#include <V3d_View.hxx> #include <V3d_View.hxx>
@ -80,12 +73,12 @@ protected:
//! Sets type of the light. //! Sets type of the light.
Standard_EXPORT void SetType (const V3d_TypeOfLight theType); 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". //! on the sphere of center "Center" and radius "Radius".
//! VX,VY,VZ is the project vector of view. //! VX,VY,VZ is the project vector of view.
Standard_EXPORT static void SymetricPointOnSphere (const Handle(V3d_View)& aView, Standard_EXPORT static void SymetricPointOnSphere (const Handle(V3d_View)& aView,
const Graphic3d_Vertex& Center, const gp_Pnt& Center,
const Graphic3d_Vertex& aPoint, const gp_Pnt& aPoint,
const Standard_Real Radius, const Standard_Real Radius,
Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Real& X, Standard_Real& Y, Standard_Real& Z,
Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ); Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ);

View File

@ -11,29 +11,17 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
/*********************************************************************** #include <V3d_PositionLight.hxx>
V3d_PositionLight.cxx
Created: 30-03-98 ZOV (ZELENKOV Oleg)
************************************************************************/
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx> #include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx> #include <gp_Vec.hxx>
#include <Graphic3d_ArrayOfSegments.hxx> #include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <V3d.hxx> #include <V3d.hxx>
#include <V3d_BadValue.hxx> #include <V3d_BadValue.hxx>
#include <V3d_PositionLight.hxx>
#include <V3d_SpotLight.hxx> #include <V3d_SpotLight.hxx>
#include <V3d_View.hxx> #include <V3d_View.hxx>
#include <V3d_Viewer.hxx> #include <V3d_Viewer.hxx>
@ -79,20 +67,14 @@ void V3d_PositionLight::SetRadius (const Standard_Real theRadius)
V3d_BadValue_Raise_if( theRadius <= 0. , "V3d_PositionLight::SetRadius, bad radius"); V3d_BadValue_Raise_if( theRadius <= 0. , "V3d_PositionLight::SetRadius, bad radius");
V3d_BadValue_Raise_if( Type() == V3d_DIRECTIONAL , "V3d_PositionLight::SetRadius, bad light type"); 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
gp_XYZ aPosOld;
// The target point remains unchanged, only the position of the light is modified Position (aPosOld.ChangeCoord (1), aPosOld.ChangeCoord (2), aPosOld.ChangeCoord (3));
// by preserving the direction. gp_XYZ aDir = aPosOld - myTarget.XYZ();
Position (Xp,Yp,Zp); aDir.Normalize();
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) ; const gp_XYZ aPosNew = myTarget.XYZ() + aDir * theRadius;
SetPosition (aPosNew.X(), aPosNew.Y(), aPosNew.Z());
} }
// ======================================================================= // =======================================================================
@ -104,8 +86,7 @@ void V3d_PositionLight::OnHideFace (const Handle(V3d_View)& theView)
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ; Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp); Position (Xp,Yp,Zp);
V3d_Light::SymetricPointOnSphere (theView, V3d_Light::SymetricPointOnSphere (theView, myTarget, gp_Pnt(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// This is a visible point // This is a visible point
if ((VX*(X-Xp) < 0.) && (VY*(Y-Yp) < 0.) && (VZ*(Z-Zp) < 0.)) if ((VX*(X-Xp) < 0.) && (VY*(Y-Yp) < 0.) && (VZ*(Z-Zp) < 0.))
@ -121,8 +102,7 @@ void V3d_PositionLight::OnSeeFace (const Handle(V3d_View)& theView)
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ; Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp); Position (Xp,Yp,Zp);
V3d_Light::SymetricPointOnSphere (theView, V3d_Light::SymetricPointOnSphere (theView, myTarget, gp_Pnt(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// This is a hidden point // This is a hidden point
if ((VX*(X-Xp) > 0.) && (VY*(Y-Yp) > 0.) && (VZ*(Z-Zp) > 0.)) if ((VX*(X-Xp) > 0.) && (VY*(Y-Yp) > 0.) && (VZ*(Z-Zp) > 0.))
@ -138,8 +118,7 @@ Standard_Boolean V3d_PositionLight::SeeOrHide (const Handle(V3d_View)& theView)
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ; Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp); Position (Xp,Yp,Zp);
V3d_Light::SymetricPointOnSphere (theView, V3d_Light::SymetricPointOnSphere (theView, myTarget, gp_Pnt(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// Is it a visible or a hidden point // Is it a visible or a hidden point
return ( (VX*(X-Xp) > 0.) || (VY*(Y-Yp) > 0.) || (VZ*(Z-Zp) > 0.) )? return ( (VX*(X-Xp) > 0.) || (VY*(Y-Yp) > 0.) || (VZ*(Z-Zp) > 0.) )?
@ -149,15 +128,6 @@ Standard_Boolean V3d_PositionLight::SeeOrHide (const Handle(V3d_View)& theView)
Standard_True; 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 // function : Display
// purpose : // purpose :
@ -295,8 +265,6 @@ void V3d_PositionLight::Tracking (const Handle(V3d_View)& theView,
const Standard_Integer theXpix, const Standard_Integer theXpix,
const Standard_Integer theYpix) 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 XPp,YPp,PXT,PYT,X,Y,Z,Rayon,Ylim;
Standard_Real XMinTrack,XMaxTrack,YMinTrack,YMaxTrack; Standard_Real XMinTrack,XMaxTrack,YMinTrack,YMaxTrack;
Standard_Real XT,YT,ZT,X0,Y0,Z0,XP,YP,ZP,VX,VY,VZ,A,B,C,Delta; Standard_Real XT,YT,ZT,X0,Y0,Z0,XP,YP,ZP,VX,VY,VZ,A,B,C,Delta;
@ -417,10 +385,12 @@ void V3d_PositionLight::Tracking (const Handle(V3d_View)& theView,
Rayon = Rayon * Rap; Rayon = Rayon * Rap;
// the source should remain at a fixed position, // the source should remain at a fixed position,
// only the target is modified. // only the target is modified.
Position (xPos, yPos, zPos);
Graphic3d_Vector Dir(Graphic3d_Vertex(xPos,yPos,zPos), myTarget); gp_XYZ aPos;
Dir.Normalize(); Position (aPos.ChangeCoord (1), aPos.ChangeCoord (2), aPos.ChangeCoord (3));
Dir.Coord(X,Y,Z); gp_XYZ aDir = myTarget.XYZ() - aPos;
aDir.Normalize();
aDir.Coord(X,Y,Z);
X = Xi + Rayon*X; X = Xi + Rayon*X;
Y = Yi + Rayon*Y; Y = Yi + Rayon*Y;
Z = Zi + Rayon*Z; Z = Zi + Rayon*Z;
@ -455,7 +425,7 @@ Standard_Real V3d_PositionLight::Radius() const
} }
// ======================================================================= // =======================================================================
// function : Radius // function : Erase
// purpose : // purpose :
// ======================================================================= // =======================================================================
void V3d_PositionLight::Erase() void V3d_PositionLight::Erase()

View File

@ -33,9 +33,9 @@ class V3d_PositionLight : public V3d_Light
public: public:
//! Defines the position of the light source. Should be redefined! //! Defines the position of the light source. Should be redefined!
Standard_EXPORT virtual void SetPosition (const Standard_Real theX, Standard_EXPORT virtual void SetPosition (Standard_Real theX,
const Standard_Real theY, Standard_Real theY,
const Standard_Real theZ) = 0; Standard_Real theZ) = 0;
//! Defines the target of the light (the center of the sphere). //! Defines the target of the light (the center of the sphere).
Standard_EXPORT void SetTarget (const Standard_Real theX, Standard_EXPORT void SetTarget (const Standard_Real theX,
@ -91,9 +91,9 @@ public:
Standard_Real& theZ) const = 0; Standard_Real& theZ) const = 0;
//! Returns the position of the target of the light source. //! Returns the position of the target of the light source.
Standard_EXPORT void Target (Standard_Real& theX, void Target (Standard_Real& theX,
Standard_Real& theY, Standard_Real& theY,
Standard_Real& theZ) const; Standard_Real& theZ) const { myTarget.Coord (theX, theY, theZ); }
DEFINE_STANDARD_RTTIEXT(V3d_PositionLight,V3d_Light) DEFINE_STANDARD_RTTIEXT(V3d_PositionLight,V3d_Light)
@ -101,7 +101,9 @@ protected:
Standard_EXPORT V3d_PositionLight (const Handle(V3d_Viewer)& theViewer); Standard_EXPORT V3d_PositionLight (const Handle(V3d_Viewer)& theViewer);
Graphic3d_Vertex myTarget; protected:
gp_Pnt myTarget;
V3d_TypeOfRepresentation myTypeOfRepresentation; V3d_TypeOfRepresentation myTypeOfRepresentation;
private: private:

View File

@ -11,45 +11,16 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
/*********************************************************************** #include <V3d_PositionalLight.hxx>
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 <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_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TColStd_Array2OfReal.hxx> #include <TColStd_Array2OfReal.hxx>
#include <V3d.hxx> #include <V3d.hxx>
#include <V3d_BadValue.hxx> #include <V3d_BadValue.hxx>
#include <V3d_PositionalLight.hxx>
#include <V3d_View.hxx> #include <V3d_View.hxx>
#include <V3d_Viewer.hxx> #include <V3d_Viewer.hxx>
@ -111,19 +82,6 @@ void V3d_PositionalLight::SetSmoothRadius (const Standard_Real theValue)
myLight.Smoothness = static_cast<Standard_ShortReal> (theValue); 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 // function : SetAttenuation
// purpose : // purpose :
@ -141,28 +99,6 @@ void V3d_PositionalLight::SetAttenuation (const Standard_Real theConstAttenuatio
myLight.ChangeLinearAttenuation() = static_cast<Standard_ShortReal> (theLinearAttenuation); 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 // function : Symbol
// purpose : // purpose :
@ -226,7 +162,6 @@ void V3d_PositionalLight::Symbol (const Handle(Graphic3d_Group)& theSymbol, cons
void V3d_PositionalLight::Display (const Handle(V3d_View)& theView, void V3d_PositionalLight::Display (const Handle(V3d_View)& theView,
const V3d_TypeOfRepresentation theRepresentation) const V3d_TypeOfRepresentation theRepresentation)
{ {
Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon; Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ; Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1; Standard_Real X1,Y1,Z1;
@ -302,7 +237,7 @@ void V3d_PositionalLight::Display (const Handle(V3d_View)& theView,
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(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.); V3d::ArrowOfRadius(gIntArrow, X0, Y0, Z0, X0-X, Y0-Y, Z0-Z, M_PI / 15., Rayon / 20.);
TCollection_AsciiString ValOfRadius(Rayon); 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); gradius->Text(ValOfRadius.ToCString(),PText,0.01);
} }

View File

@ -69,9 +69,14 @@ public:
const Standard_Real theLinearAttenuation = 0.0); const Standard_Real theLinearAttenuation = 0.0);
//! Defines the position of the light source. //! Defines the position of the light source.
Standard_EXPORT virtual void SetPosition (const Standard_Real theX, virtual void SetPosition (Standard_Real theX,
const Standard_Real theY, Standard_Real theY,
const Standard_Real theZ) Standard_OVERRIDE; Standard_Real theZ) Standard_OVERRIDE
{
myLight.Position.x() = theX;
myLight.Position.y() = theY;
myLight.Position.z() = theZ;
}
//! Defines the attenuation factors. //! Defines the attenuation factors.
//! Warning: raises BadValue from V3d //! Warning: raises BadValue from V3d
@ -96,13 +101,22 @@ public:
const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE; const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE;
//! Returns the position of the light source. //! Returns the position of the light source.
Standard_EXPORT void Position (Standard_Real& theX, void Position (Standard_Real& theX,
Standard_Real& theY, Standard_Real& theY,
Standard_Real& theZ) const Standard_OVERRIDE; Standard_Real& theZ) const Standard_OVERRIDE
{
theX = myLight.Position.x();
theY = myLight.Position.y();
theZ = myLight.Position.z();
}
//! Returns the attenuation factors. //! Returns the attenuation factors.
Standard_EXPORT void Attenuation (Standard_Real& theConstAttenuation, void Attenuation (Standard_Real& theConstAttenuation,
Standard_Real& theLinearAttenuation) const; Standard_Real& theLinearAttenuation) const
{
theConstAttenuation = myLight.ConstAttenuation();
theLinearAttenuation = myLight.LinearAttenuation();
}
DEFINE_STANDARD_RTTIEXT(V3d_PositionalLight,V3d_PositionLight) DEFINE_STANDARD_RTTIEXT(V3d_PositionalLight,V3d_PositionLight)

View File

@ -11,40 +11,15 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
/*********************************************************************** #include <V3d_SpotLight.hxx>
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 <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_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <V3d.hxx> #include <V3d.hxx>
#include <V3d_BadValue.hxx> #include <V3d_BadValue.hxx>
#include <V3d_SpotLight.hxx>
#include <V3d_View.hxx> #include <V3d_View.hxx>
#include <V3d_Viewer.hxx> #include <V3d_Viewer.hxx>
@ -66,7 +41,7 @@ V3d_SpotLight::V3d_SpotLight (const Handle(V3d_Viewer)& theViewer,
const Standard_Real theAngle) const Standard_Real theAngle)
: V3d_PositionLight (theViewer) : V3d_PositionLight (theViewer)
{ {
Graphic3d_Vector aDir = V3d::GetProjAxis (theDirection); gp_Dir aDir = V3d::GetProjAxis (theDirection);
SetType (V3d_SPOT); SetType (V3d_SPOT);
SetColor (theColor); SetColor (theColor);
SetTarget (theX + aDir.X(), theY + aDir.Y(), theZ + aDir.Z()); SetTarget (theX + aDir.X(), theY + aDir.Y(), theZ + aDir.Z());
@ -105,39 +80,13 @@ V3d_SpotLight::V3d_SpotLight (const Handle(V3d_Viewer)& theViewer,
SetAngle (theAngle); 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 // function : SetDirection
// purpose : // purpose :
// ======================================================================= // =======================================================================
void V3d_SpotLight::SetDirection (const Standard_Real theVx, void V3d_SpotLight::SetDirection (V3d_TypeOfOrientation theDirection)
const Standard_Real theVy,
const Standard_Real theVz)
{ {
myLight.Direction.x() = static_cast<Standard_ShortReal> (theVx); gp_Dir aDir = V3d::GetProjAxis (theDirection);
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);
SetDirection (aDir.X(), aDir.Y(), aDir.Z()); SetDirection (aDir.X(), aDir.Y(), aDir.Z());
} }
@ -186,62 +135,6 @@ void V3d_SpotLight::SetAngle (const Standard_Real theAngle)
myLight.ChangeAngle() = static_cast<Standard_ShortReal> (theAngle); 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 // function : Symbol
// purpose : // purpose :
@ -264,7 +157,6 @@ void V3d_SpotLight::Symbol (const Handle(Graphic3d_Group)& theSymbol,
void V3d_SpotLight::Display (const Handle(V3d_View)& theView, void V3d_SpotLight::Display (const Handle(V3d_View)& theView,
const V3d_TypeOfRepresentation theTPres) const V3d_TypeOfRepresentation theTPres)
{ {
Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon; Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ; Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1; Standard_Real X1,Y1,Z1;
@ -340,7 +232,7 @@ void V3d_SpotLight::Display (const Handle(V3d_View)& theView,
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(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.); V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,M_PI/15.,Rayon/20.);
TCollection_AsciiString ValOfRadius(Rayon); 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); gradius->Text(ValOfRadius.ToCString(),PText,0.01);
} }

View File

@ -74,19 +74,29 @@ public:
const Standard_Real theAngle = 0.523599); const Standard_Real theAngle = 0.523599);
//! Defines the position of the light source. //! Defines the position of the light source.
Standard_EXPORT virtual void SetPosition (const Standard_Real theX, virtual void SetPosition (Standard_Real theX,
const Standard_Real theY, Standard_Real theY,
const Standard_Real theZ) Standard_OVERRIDE; Standard_Real theZ) Standard_OVERRIDE
{
myLight.Position.x() = theX;
myLight.Position.y() = theY;
myLight.Position.z() = theZ;
}
//! Defines the direction of the light source. //! Defines the direction of the light source.
//! If the normal vector is NULL. //! If the normal vector is NULL.
Standard_EXPORT void SetDirection (const Standard_Real theVx, void SetDirection (Standard_Real theVx,
const Standard_Real theVy, Standard_Real theVy,
const Standard_Real theVz); 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 //! Defines the direction of the light source
//! according to a predefined directional vector. //! 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. //! Defines the coefficients of attenuation.
//! Warning! raises BadValue from V3d //! Warning! raises BadValue from V3d
@ -117,23 +127,37 @@ public:
const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE; const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE;
//! Returns the direction of the light source defined by theVx, theVy, theVz. //! Returns the direction of the light source defined by theVx, theVy, theVz.
Standard_EXPORT void Direction (Standard_Real& theVx, void Direction (Standard_Real& theVx,
Standard_Real& theVy, Standard_Real& theVy,
Standard_Real& theVz) const; Standard_Real& theVz) const
{
theVx = myLight.Direction.x();
theVy = myLight.Direction.y();
theVz = myLight.Direction.z();
}
//! Returns the position of the light source. //! Returns the position of the light source.
Standard_EXPORT void Position (Standard_Real& theX, virtual void Position (Standard_Real& theX,
Standard_Real& theY, Standard_Real& theY,
Standard_Real& theZ) const Standard_OVERRIDE; 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. //! Returns the attenuation factors A1,A2 of the light source.
Standard_EXPORT void Attenuation (Standard_Real& theConstAttentuation, void Attenuation (Standard_Real& theConstAttentuation,
Standard_Real& theLinearAttentuation) const; 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. //! Returns the spot angle.
Standard_EXPORT Standard_Real Angle() const; Standard_Real Angle() const { return myLight.Angle(); }
DEFINE_STANDARD_RTTIEXT(V3d_SpotLight,V3d_PositionLight) DEFINE_STANDARD_RTTIEXT(V3d_SpotLight,V3d_PositionLight)

View File

@ -27,7 +27,6 @@
#include <Graphic3d_MapOfStructure.hxx> #include <Graphic3d_MapOfStructure.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx> #include <Graphic3d_TextureEnv.hxx>
#include <Graphic3d_Vector.hxx>
#include <Image_AlienPixMap.hxx> #include <Image_AlienPixMap.hxx>
#include <Message.hxx> #include <Message.hxx>
#include <Message_Messenger.hxx> #include <Message_Messenger.hxx>
@ -515,15 +514,11 @@ void V3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle, const Stan
//function : SetAxis //function : SetAxis
//purpose : //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 ; myDefaultViewPoint.SetCoord (theX, theY, theZ);
myDefaultViewAxis.SetCoord (theVx, theVy, theVz);
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) ;
} }
//============================================================================= //=============================================================================
@ -732,33 +727,28 @@ void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const
//function : Rotate //function : Rotate
//purpose : //purpose :
//============================================================================= //=============================================================================
void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, void V3d_View::Rotate (const V3d_TypeOfAxe theAxe, const Standard_Real theAngle,
const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start) 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 ; if (anAngle > 0.0) while (anAngle > DEUXPI) anAngle -= DEUXPI;
else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ; else if (anAngle < 0.0) while (anAngle < -DEUXPI) anAngle += DEUXPI;
Handle(Graphic3d_Camera) aCamera = Camera(); Handle(Graphic3d_Camera) aCamera = Camera();
if (Start) if (theStart)
{ {
myGravityReferencePoint.SetCoord (X, Y, Z); myGravityReferencePoint.SetCoord (theX, theY, theZ);
myCamStartOpUp = aCamera->Up(); myCamStartOpUp = aCamera->Up();
myCamStartOpEye = aCamera->Eye(); myCamStartOpEye = aCamera->Eye();
myCamStartOpCenter = aCamera->Center(); myCamStartOpCenter = aCamera->Center();
switch (Axe) { switch (theAxe)
case V3d_X : {
myViewAxis.SetCoord(1.,0.,0.) ; case V3d_X: myViewAxis = gp::DX(); break;
break ; case V3d_Y: myViewAxis = gp::DY(); break;
case V3d_Y : case V3d_Z: myViewAxis = gp::DZ(); break;
myViewAxis.SetCoord(0.,1.,0.) ;
break ;
case V3d_Z :
myViewAxis.SetCoord(0.,0.,1.) ;
break ;
} }
myCamStartOpUp = aCamera->Up(); myCamStartOpUp = aCamera->Up();
@ -775,11 +765,11 @@ void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle,
// rotate camera around passed axis // rotate camera around passed axis
gp_Trsf aRotation; gp_Trsf aRotation;
gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z()); gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
gp_Dir aRAxis ((Axe == V3d_X) ? 1.0 : 0.0, gp_Dir aRAxis ((theAxe == V3d_X) ? 1.0 : 0.0,
(Axe == V3d_Y) ? 1.0 : 0.0, (theAxe == V3d_Y) ? 1.0 : 0.0,
(Axe == V3d_Z) ? 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); aCamera->Transform (aRotation);
@ -807,16 +797,13 @@ void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start)
myCamStartOpCenter = aCamera->Center(); myCamStartOpCenter = aCamera->Center();
} }
const Graphic3d_Vertex& aPnt = MyDefaultViewPoint;
const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
aCamera->SetUp (myCamStartOpUp); aCamera->SetUp (myCamStartOpUp);
aCamera->SetEye (myCamStartOpEye); aCamera->SetEye (myCamStartOpEye);
aCamera->SetCenter (myCamStartOpCenter); aCamera->SetCenter (myCamStartOpCenter);
gp_Trsf aRotation; gp_Trsf aRotation;
gp_Pnt aRCenter (aPnt.X(), aPnt.Y(), aPnt.Z()); gp_Pnt aRCenter (myDefaultViewPoint);
gp_Dir aRAxis (anAxis.X(), anAxis.Y(), anAxis.Z()); gp_Dir aRAxis (myDefaultViewAxis);
aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle); aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
aCamera->Transform (aRotation); aCamera->Transform (aRotation);
@ -918,11 +905,9 @@ void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
aCamera->SetEye (myCamStartOpEye); aCamera->SetEye (myCamStartOpEye);
aCamera->SetCenter (myCamStartOpCenter); aCamera->SetCenter (myCamStartOpCenter);
const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
gp_Trsf aRotation; gp_Trsf aRotation;
gp_Pnt aRCenter = aCamera->Eye(); 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); aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
aCamera->Transform (aRotation); aCamera->Transform (aRotation);
@ -939,32 +924,19 @@ void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
void V3d_View::SetTwist(const Standard_Real angle) void V3d_View::SetTwist(const Standard_Real angle)
{ {
Standard_Real Angle = angle ; Standard_Real Angle = angle ;
Standard_Boolean TheStatus;
if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ; if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ; else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
Handle(Graphic3d_Camera) aCamera = Camera(); Handle(Graphic3d_Camera) aCamera = Camera();
gp_Dir aReferencePlane (aCamera->Direction().Reversed()); const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
gp_Dir anUp; if (!screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
&& !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
anUp = gp_Dir (0.0, 0.0, 1.0); && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
{
TheStatus = ScreenAxis(aReferencePlane, anUp, throw V3d_BadValue ("V3d_ViewSetTwist, alignment of Eye,At,Up,");
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) ;
}
V3d_BadValue_Raise_if( !TheStatus,"V3d_ViewSetTwist, alignment of Eye,At,Up,");
gp_Pnt aRCenter = aCamera->Center(); gp_Pnt aRCenter = aCamera->Center();
gp_Dir aZAxis (aCamera->Direction().Reversed()); gp_Dir aZAxis (aCamera->Direction().Reversed());
@ -972,10 +944,7 @@ void V3d_View::SetTwist(const Standard_Real angle)
gp_Trsf aTrsf; gp_Trsf aTrsf;
aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle); aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle);
Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ; aCamera->SetUp (gp_Dir (myYscreenAxis));
myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
aCamera->Transform (aTrsf); aCamera->Transform (aTrsf);
AutoZFit(); AutoZFit();
@ -1081,7 +1050,7 @@ void V3d_View::SetProj( const V3d_TypeOfOrientation Orientation )
Zpn = 1.; Zpn = 1.;
} }
const Graphic3d_Vector& aBck = V3d::GetProjAxis (Orientation); const gp_Dir aBck = V3d::GetProjAxis (Orientation);
// retain camera panning from origin when switching projection // retain camera panning from origin when switching projection
Handle(Graphic3d_Camera) aCamera = Camera(); Handle(Graphic3d_Camera) aCamera = Camera();
@ -1127,40 +1096,21 @@ void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_
//function : SetUp //function : SetUp
//purpose : //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(); Handle(Graphic3d_Camera) aCamera = Camera();
gp_Dir aReferencePlane (aCamera->Direction().Reversed()); const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
gp_Dir anUp (Vx, Vy, Vz); const gp_Dir anUp (theVx, theVy, theVz);
if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
TheStatus = ScreenAxis(aReferencePlane,anUp, && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
myXscreenAxis,myYscreenAxis,myZscreenAxis) ; && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
if( !TheStatus ) { && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
anUp = gp_Dir (0.0, 0.0, 1.0); {
TheStatus = ScreenAxis(aReferencePlane,anUp, throw V3d_BadValue ("V3d_View::Setup, alignment of Eye,At,Up");
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) ;
}
V3d_BadValue_Raise_if( !TheStatus,"V3d_View::Setup, alignment of Eye,At,Up");
Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ; aCamera->SetUp (gp_Dir (myYscreenAxis));
myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
AutoZFit(); AutoZFit();
@ -1171,41 +1121,21 @@ void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standar
//function : SetUp //function : SetUp
//purpose : //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(); Handle(Graphic3d_Camera) aCamera = Camera();
gp_Dir aReferencePlane (aCamera->Direction().Reversed()); const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
gp_Dir anUp; const gp_Dir anUp = V3d::GetProjAxis (theOrientation);
if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
const Graphic3d_Vector& aViewReferenceUp = V3d::GetProjAxis(Orientation) ; && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
anUp = gp_Dir (aViewReferenceUp.X(), aViewReferenceUp.Y(), aViewReferenceUp.Z()); && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
&& !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
TheStatus = ScreenAxis(aReferencePlane,anUp, {
myXscreenAxis,myYscreenAxis,myZscreenAxis) ; throw V3d_BadValue ("V3d_View::SetUp, alignment of Eye,At,Up");
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) ;
}
V3d_BadValue_Raise_if( !TheStatus, "V3d_View::SetUp, alignment of Eye,At,Up");
Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ; aCamera->SetUp (gp_Dir (myYscreenAxis));
myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
AutoZFit(); AutoZFit();
@ -2253,45 +2183,35 @@ void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const
//============================================================================= //=============================================================================
Standard_Real V3d_View::Twist() const Standard_Real V3d_View::Twist() const
{ {
Standard_Real Xup,Yup,Zup,Xpn,Ypn,Zpn,X0,Y0,Z0 ; gp_Vec Xaxis, Yaxis, Zaxis;
Standard_Real pvx,pvy,pvz,pvn,sca,angle ; const gp_Dir aReferencePlane (Camera()->Direction().Reversed());
Graphic3d_Vector Xaxis,Yaxis,Zaxis ; if (!screenAxis (aReferencePlane, gp::DZ(), Xaxis, Yaxis, Zaxis)
Standard_Boolean TheStatus ; && !screenAxis (aReferencePlane, gp::DY(), Xaxis, Yaxis, Zaxis)
&& !screenAxis (aReferencePlane, gp::DX(), Xaxis, Yaxis, Zaxis))
gp_Dir aReferencePlane (Camera()->Direction().Reversed()); {
gp_Dir anUp; //
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) ;
}
Yaxis.Coord(X0,Y0,Z0) ;
Up(Xup,Yup,Zup) ; // Compute Cross Vector From Up & Origin
/* Compute Cross Vector From Up & Origin */ const gp_Dir aCameraUp = Camera()->Up();
pvx = Y0*Zup - Z0*Yup ; const gp_XYZ aP = Yaxis.XYZ().Crossed (aCameraUp.XYZ());
pvy = Z0*Xup - X0*Zup ;
pvz = X0*Yup - Y0*Xup ; // compute Angle
pvn = pvx*pvx + pvy*pvy + pvz*pvz ; Standard_Real anAngle = ASin (Max (Min (aP.Modulus(), 1.0), -1.0));
sca = X0*Xup + Y0*Yup + Z0*Zup ; if (Yaxis.Dot (aCameraUp.XYZ()) < 0.0)
/* Compute Angle */ {
angle = Sqrt(pvn) ; anAngle = M_PI - anAngle;
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 ;
} }
return 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 anAngle;
} }
//============================================================================= //=============================================================================
@ -2403,32 +2323,28 @@ Handle(Graphic3d_CView) V3d_View::View() const
} }
//============================================================================= //=============================================================================
//function : ScreenAxis //function : screenAxis
//purpose : //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; theXaxe = theVup.XYZ().Crossed (theVpn.XYZ());
Standard_Real dx1, dy1, dz1, xx, yy, zz; if (theXaxe.Magnitude() <= gp::Resolution())
{
return Standard_False;
}
theXaxe.Normalize();
Xpn = Vpn.X(); Ypn = Vpn.Y(); Zpn = Vpn.Z(); theYaxe = theVpn.XYZ().Crossed (theXaxe.XYZ());
Xup = Vup.X(); Yup = Vup.Y(); Zup = Vup.Z(); if (theYaxe.Magnitude() <= gp::Resolution())
xx = Yup*Zpn - Zup*Ypn; {
yy = Zup*Xpn - Xup*Zpn; return Standard_False;
zz = Xup*Ypn - Yup*Xpn; }
Xaxe.SetCoord (xx, yy, zz); theYaxe.Normalize();
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();
Zaxe.SetCoord (Xpn, Ypn, Zpn); theZaxe = theVpn.XYZ();
Zaxe.Normalize(); theZaxe.Normalize();
return Standard_True; return Standard_True;
} }

View File

@ -38,7 +38,6 @@
#include <Graphic3d_GraduatedTrihedron.hxx> #include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_RenderingParams.hxx> #include <Graphic3d_RenderingParams.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx> #include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx> #include <Graphic3d_Vertex.hxx>
#include <Image_PixMap.hxx> #include <Image_PixMap.hxx>
@ -72,12 +71,9 @@
class Aspect_Grid; class Aspect_Grid;
class Aspect_Window; class Aspect_Window;
class Bnd_Box;
class Graphic3d_Group; class Graphic3d_Group;
class Graphic3d_Structure; class Graphic3d_Structure;
class Graphic3d_TextureEnv; class Graphic3d_TextureEnv;
class Graphic3d_Vector;
class Quantity_Color;
class Standard_MultiplyDefined; class Standard_MultiplyDefined;
class Standard_TypeMismatch; class Standard_TypeMismatch;
class V3d_BadValue; class V3d_BadValue;
@ -982,7 +978,8 @@ private:
//! Determines the screen axes in the reference //! Determines the screen axes in the reference
//! framework of the view. //! 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 . //! Transforms the Vertex V according to the matrice Matrix .
Standard_EXPORT static gp_XYZ TrsPoint (const Graphic3d_Vertex& V, const TColStd_Array2OfReal& Matrix); Standard_EXPORT static gp_XYZ TrsPoint (const Graphic3d_Vertex& V, const TColStd_Array2OfReal& Matrix);
@ -1020,8 +1017,8 @@ private:
V3d_ViewerPointer MyViewer; V3d_ViewerPointer MyViewer;
V3d_ListOfLight myActiveLights; V3d_ListOfLight myActiveLights;
Graphic3d_Vector MyDefaultViewAxis; gp_Dir myDefaultViewAxis;
Graphic3d_Vertex MyDefaultViewPoint; gp_Pnt myDefaultViewPoint;
Handle(Aspect_Window) MyWindow; Handle(Aspect_Window) MyWindow;
V3d_ListOfLight::Iterator myActiveLightsIterator; V3d_ListOfLight::Iterator myActiveLightsIterator;
Standard_Integer sx; Standard_Integer sx;
@ -1042,10 +1039,10 @@ private:
TColStd_Array2OfReal MyTrsf; TColStd_Array2OfReal MyTrsf;
Handle(Graphic3d_Structure) MyGridEchoStructure; Handle(Graphic3d_Structure) MyGridEchoStructure;
Handle(Graphic3d_Group) MyGridEchoGroup; Handle(Graphic3d_Group) MyGridEchoGroup;
Graphic3d_Vector myXscreenAxis; gp_Vec myXscreenAxis;
Graphic3d_Vector myYscreenAxis; gp_Vec myYscreenAxis;
Graphic3d_Vector myZscreenAxis; gp_Vec myZscreenAxis;
Graphic3d_Vector myViewAxis; gp_Dir myViewAxis;
Graphic3d_Vertex myGravityReferencePoint; Graphic3d_Vertex myGravityReferencePoint;
Standard_Boolean myAutoZFitIsOn; Standard_Boolean myAutoZFitIsOn;
Standard_Real myAutoZFitScaleFactor; Standard_Real myAutoZFitScaleFactor;

View File

@ -35,7 +35,6 @@
#include <Graphic3d_GraphicDriver.hxx> #include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx> #include <Graphic3d_TextureEnv.hxx>
#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
#include <Standard_MultiplyDefined.hxx> #include <Standard_MultiplyDefined.hxx>
#include <Standard_TypeMismatch.hxx> #include <Standard_TypeMismatch.hxx>

View File

@ -21,7 +21,6 @@
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx> #include <Graphic3d_TextureEnv.hxx>
#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
#include <Standard_MultiplyDefined.hxx> #include <Standard_MultiplyDefined.hxx>
#include <Standard_TypeMismatch.hxx> #include <Standard_TypeMismatch.hxx>
@ -48,9 +47,9 @@ void V3d_View::Move (const Standard_Real Dx,
gp_Dir aReferencePlane (aCamera->Direction().Reversed()); gp_Dir aReferencePlane (aCamera->Direction().Reversed());
gp_Dir anUp (aCamera->Up()); 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");
} }
} }
@ -77,20 +76,15 @@ void V3d_View::Move (const Standard_Real Dx,
//function : Move //function : Move
//purpose : //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(); Handle(Graphic3d_Camera) aCamera = Camera();
if (theStart)
if( Start )
{ {
myCamStartOpEye = aCamera->Eye(); myCamStartOpEye = aCamera->Eye();
} }
aCamera->SetEye (myCamStartOpEye); aCamera->SetEye (myCamStartOpEye);
aCamera->SetEye (aCamera->Eye().XYZ() + theLength * myDefaultViewAxis.XYZ());
Standard_Real Vx, Vy, Vz;
MyDefaultViewAxis.Coord (Vx, Vy, Vz) ;
aCamera->SetEye (aCamera->Eye().XYZ() + Length * gp_Pnt (Vx, Vy, Vz).XYZ());
AutoZFit(); AutoZFit();
@ -134,30 +128,25 @@ void V3d_View::Translate (const Standard_Real Dx,
gp_Dir aReferencePlane (aCamera->Direction().Reversed()); gp_Dir aReferencePlane (aCamera->Direction().Reversed());
gp_Dir anUp (aCamera->Up()); gp_Dir anUp (aCamera->Up());
if (!ScreenAxis (aReferencePlane, anUp, if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
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");
}
} }
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->SetEye (myCamStartOpEye);
aCamera->SetCenter (myCamStartOpCenter); aCamera->SetCenter (myCamStartOpCenter);
aCamera->SetCenter (aCamera->Center().XYZ() aCamera->SetCenter (aCamera->Center().XYZ()
- Dx * gp_Pnt (XX, XY, XZ).XYZ() - Dx * myXscreenAxis.XYZ()
- Dy * gp_Pnt (YX, YY, YZ).XYZ() - Dy * myYscreenAxis.XYZ()
- Dz * gp_Pnt (ZX, ZY, ZZ).XYZ() - Dz * myZscreenAxis.XYZ()
); );
aCamera->SetEye (aCamera->Eye().XYZ() aCamera->SetEye (aCamera->Eye().XYZ()
- Dx * gp_Pnt (XX, XY, XZ).XYZ() - Dx * myXscreenAxis.XYZ()
- Dy * gp_Pnt (YX, YY, YZ).XYZ() - Dy * myYscreenAxis.XYZ()
- Dz * gp_Pnt (ZX, ZY, ZZ).XYZ() - Dz * myZscreenAxis.XYZ()
); );
AutoZFit(); AutoZFit();
@ -208,14 +197,12 @@ void V3d_View::Place (const Standard_Integer theXp,
void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart) void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart)
{ {
Handle(Graphic3d_Camera) aCamera = Camera(); Handle(Graphic3d_Camera) aCamera = Camera();
Standard_Real aVx, aVy, aVz;
if (theStart) if (theStart)
{ {
myCamStartOpCenter = aCamera->Center() ; 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); aCamera->SetCenter (aNewCenter);
AutoZFit(); AutoZFit();

View File

@ -23,7 +23,6 @@
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx> #include <Graphic3d_Structure.hxx>
#include <Graphic3d_TextureEnv.hxx> #include <Graphic3d_TextureEnv.hxx>
#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
#include <Standard_MultiplyDefined.hxx> #include <Standard_MultiplyDefined.hxx>
#include <Standard_TypeMismatch.hxx> #include <Standard_TypeMismatch.hxx>

View File

@ -1,43 +0,0 @@
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