1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0024001: Stereographic rendering support

Deleted TODOs which were used when branch was built without OpenCL.
Modified test case bugs/vis/bug23747_2 (changed textured shape)
This commit is contained in:
duv
2014-01-23 14:44:31 +04:00
committed by bugmaster
parent 1190746b3c
commit b5ac8292b0
99 changed files with 5345 additions and 7308 deletions

View File

@@ -259,18 +259,6 @@ is
---Purpose: 3D Visualiser
---Category: The classes
class ViewMapping;
---Purpose: This class describes a projection and a system of
-- coordinates called NPC.(Normalized Projection Coordinates)
---Category: The classes
class ViewOrientation;
---Purpose: This class describes the manner in which the
-- observer looks at the visualised scene.
-- It defines a coordinates system called VRC
-- (View Reference Coordinates) with 3 axes U,V,N
---Category: The classes
class TransientManager;
---Purpose: 3D Transient Visualiser
---Category: The classes

View File

@@ -84,14 +84,13 @@ uses
Structure from Graphic3d,
SequenceOfStructure from Graphic3d,
MapOfStructure from Graphic3d,
Camera_Handle from Graphic3d,
ContextView from Visual3d,
Layer from Visual3d,
Light from Visual3d,
SetOfLight from Visual3d,
TypeOfAnswer from Visual3d,
ViewMapping from Visual3d,
ViewOrientation from Visual3d,
ViewManager from Visual3d,
ViewManagerPtr from Visual3d,
@@ -136,15 +135,6 @@ is
---Purpose: Creates a view in the viewer <AManager> with a default
-- orientation and a default mapping.
Create ( AManager : mutable ViewManager from Visual3d;
VO : ViewOrientation from Visual3d;
VM : ViewMapping from Visual3d;
CTX : ContextView from Visual3d )
returns mutable View from Visual3d;
---Level: Public
---Purpose: Creates a view in the viewer <AManager> with the orientation
-- <VO>, the mapping <VM>, and the context<CTX>.
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
@@ -308,13 +298,6 @@ is
-- Warning: Raises TransformError if the matrix isn't a 4x4 matrix.
raises TransformError from Visual3d is static;
SetViewMapping ( me : mutable;
VM : ViewMapping from Visual3d )
is static;
---Level: Public
---Purpose: Modifies the mapping of the view <me>.
---Category: Methods to modify the class definition
SetViewMappingDefault ( me : mutable )
is static;
---Level: Public
@@ -323,13 +306,6 @@ is
-- done by the ViewmappingReset method.
---Category: Methods to modify the class definition
SetViewOrientation ( me : mutable;
VO : ViewOrientation from Visual3d )
is static;
---Level: Public
---Purpose: Modifies the orientation of <me>.
---Category: Methods to modify the class definition
SetViewOrientationDefault ( me : mutable )
is static;
---Level: Public
@@ -710,36 +686,24 @@ is
---Purpose: Returns the coordinates of the projection of the
-- 3d coordinates <AX>, <AY>, <AZ>.
Transform ( me )
returns Array2OfReal from TColStd
is static;
---Level: Public
---Purpose: Returns the transformation associated to the view <me>
---C++: return const &
DefaultCamera (me)
returns Camera_Handle from Graphic3d
is static;
---Level: Public
---Purpose: @return the default camera of <me>.
---C++: return const &
ViewMapping ( me )
returns ViewMapping from Visual3d
is static;
---Level: Public
---Purpose: Returns the current mapping of the view <me>.
Camera (me)
returns Camera_Handle from Graphic3d
is static;
---Level: Public
---Purpose: @return the camera of <me>.
---C++: return const &
ViewMappingDefault ( me )
returns ViewMapping from Visual3d
is static;
---Level: Public
---Purpose: Returns the current reset mapping of the view <me>.
ViewOrientation ( me )
returns ViewOrientation from Visual3d
is static;
---Level: Public
---Purpose: Returns the current orientation of the view <me>.
ViewOrientationDefault ( me )
returns ViewOrientation from Visual3d
is static;
---Level: Public
---Purpose: Returns the current reset orientation of the view <me>.
SetCamera (me : mutable; theCamera : Camera_Handle from Graphic3d) is static;
---Level: Public
---Purpose: Set camera object to provide orientation and projection matrices
-- for graphic driver.
Window ( me )
returns Window from Aspect
@@ -923,22 +887,6 @@ is
-- displayed in the view <me>.
---Category: Private methods
MatrixOfMapping ( me : mutable )
returns Array2OfReal from TColStd
is static; -- private;
---C++: return const &
---Level: Internal
---Purpose: Returns the current matrix of mapping of the view <me>.
-- Warning: Stores the current matrix of mapping.
MatrixOfOrientation ( me : mutable )
returns Array2OfReal from TColStd
is static; -- private;
---C++: return const &
---Level: Internal
---Purpose: Returns the current matrix of orientation of the view <me>.
-- Warning: Stores the current matrix of orientation.
SetRatio ( me : mutable )
is static private;
---Level: Internal
@@ -1181,9 +1129,6 @@ fields
-- Reminder : A view is defined by:
-- - a ViewManager
-- - a ContextView
-- - a ViewMapping
-- - a ViewOrientation
--
-- the associated C structure
MyCView : CView from Graphic3d;
@@ -1191,28 +1136,9 @@ fields
-- the context of the view : Aliasing, Depth-Cueing, Lights ...
MyContext : ContextView from Visual3d;
-- the current mapping of the view
MyViewMapping : ViewMapping from Visual3d;
-- the reset mapping of the view
MyViewMappingReset : ViewMapping from Visual3d;
-- the current orientation of the view
MyViewOrientation : ViewOrientation from Visual3d;
-- the reset orientation of the view
MyViewOrientationReset : ViewOrientation from Visual3d;
-- the associated window
MyWindow : Window from Aspect;
-- the transformation
MyTransformation : Array2OfReal from TColStd;
-- the matrix management
MyMatrixOfMapping : Array2OfReal from TColStd;
MyMatrixOfOrientation : Array2OfReal from TColStd;
-- association Structure_COMPUTE and Structure_Computed
MyTOCOMPUTESequence : SequenceOfStructure from Graphic3d;
MyCOMPUTEDSequence : SequenceOfStructure from Graphic3d;
@@ -1238,6 +1164,8 @@ fields
MyGTrihedron : CGraduatedTrihedron from Graphic3d;
myDefaultCamera : Camera_Handle from Graphic3d;
friends
class ViewManager from Visual3d

File diff suppressed because it is too large Load Diff

View File

@@ -119,55 +119,6 @@ is
---Purpose: Returns the group of views activated in the visualiser <me>.
---Category: Inquire methods
ConvertCoord ( me;
AWindow : Window from Aspect;
AVertex : Vertex from Graphic3d;
AU, AV : out Integer from Standard )
is static;
---Level: Public
---Purpose: Applies the view orientation transformation, the
-- view mapping transformation and view clip, the
-- display transformation to the vertex <AVertex>.
-- Returns the pixel coordinates <AU>, <AV>.
-- Warning: Returns <AU> = <AV> = IntegerLast () if the
-- evaluation is impossible.
-- -- Bad Window, Numeric error...
---Category: Inquire methods
ConvertCoord ( me;
AWindow : Window from Aspect;
AU, AV : Integer from Standard )
returns Vertex from Graphic3d
is static;
---Level: Public
---Purpose: Applies the inverse of the display transformation, the
-- inverse of the view mapping transformation and view clip,
-- the inverse of the view orientation transformation to
-- the pixel coordinates <AU>, <AV>.
-- Returns the world coordinates <AVertex>.
-- Warning: Returns AVertex (X, Y, Z) with X = Y = Z = RealLast ()
-- if the evaluation is impossible.
-- -- Bad Window, Numeric error...
---Category: Inquire methods
ConvertCoordWithProj ( me;
AWindow : Window from Aspect;
AU, AV : Integer from Standard;
Point : out Vertex from Graphic3d;
Proj : out Vector from Graphic3d )
is static;
---Level: Public
---Purpose: Applies the inverse of the display transformation, the
-- inverse of the view mapping transformation and view clip,
-- the inverse of the view orientation transformation to
-- the pixel coordinates <AU>, <AV>.
-- Returns the world coordinates <AVertex> and projection ray <AVector>.
-- Warning: Returns AVertex (X, Y, Z) with X = Y = Z = RealLast () and
-- AVector (VX, VY, VZ) with VX = VY = VZ = 0.
-- if the evaluation is impossible.
-- -- Bad Window, Numeric error...
---Category: Inquire methods
DefinedView ( me )
returns HSetOfView from Visual3d
is static;

View File

@@ -505,433 +505,6 @@ Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
}
void Visual3d_ViewManager::ConvertCoord (const Handle(Aspect_Window)& AWindow, const Graphic3d_Vertex& AVertex, Standard_Integer& AU, Standard_Integer& AV) const {
// Convert only if the data is correct
Standard_Boolean Exist;
Graphic3d_CView TheCView;
//Graphic3d_Vertex Point;
TColStd_Array2OfReal Ori_Matrix (0,3,0,3);
TColStd_Array2OfReal Map_Matrix (0,3,0,3);
Standard_Integer Width, Height;
Standard_Real AX, AY, AZ;
Standard_Real Dx, Dy, Ratio;
Exist = ViewExists (AWindow, TheCView);
if (! Exist) {
AU = AV = IntegerLast ();
}
else {
// NKV - 11.02.08 - Use graphic driver functions
Standard_Boolean Result;
AVertex.Coord (AX, AY, AZ);
Result = MyGraphicDriver->ProjectRaster (TheCView,
Standard_ShortReal (AX), Standard_ShortReal (AY), Standard_ShortReal (AZ),
AU, AV);
// the old code
if (!Result) {
Standard_Real PtX, PtY, PtZ, PtT;
Standard_Real APX, APY, APZ;
Standard_Real APT;
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
Standard_Integer stop = 0;
while ((! stop) && (MyIterator.More ())) {
if (TheCView.ViewId ==
(MyIterator.Value ())->Identification ()) {
Ori_Matrix =
(MyIterator.Value ())->MatrixOfOrientation ();
Map_Matrix =
(MyIterator.Value ())->MatrixOfMapping ();
stop = 1;
}
// MyIterator.Next () is located on the next view
MyIterator.Next ();
}
// WCS -> View Reference Coordinate Space
PtX = Ori_Matrix (0, 0) * AX
+ Ori_Matrix (0, 1) * AY
+ Ori_Matrix (0, 2) * AZ
+ Ori_Matrix (0, 3);
PtY = Ori_Matrix (1, 0) * AX
+ Ori_Matrix (1, 1) * AY
+ Ori_Matrix (1, 2) * AZ
+ Ori_Matrix (1, 3);
PtZ = Ori_Matrix (2, 0) * AX
+ Ori_Matrix (2, 1) * AY
+ Ori_Matrix (2, 2) * AZ
+ Ori_Matrix (2, 3);
PtT = Ori_Matrix (3, 0) * AX
+ Ori_Matrix (3, 1) * AY
+ Ori_Matrix (3, 2) * AZ
+ Ori_Matrix (3, 3);
// VRCS -> Normalized Projection Coordinate Space
APX = Map_Matrix (0, 0) * PtX
+ Map_Matrix (0, 1) * PtY
+ Map_Matrix (0, 2) * PtZ
+ Map_Matrix (0, 3) * PtT;
APY = Map_Matrix (1, 0) * PtX
+ Map_Matrix (1, 1) * PtY
+ Map_Matrix (1, 2) * PtZ
+ Map_Matrix (1, 3) * PtT;
APZ = Map_Matrix (2, 0) * PtX
+ Map_Matrix (2, 1) * PtY
+ Map_Matrix (2, 2) * PtZ
+ Map_Matrix (2, 3) * PtT;
APT = Map_Matrix (3, 0) * PtX
+ Map_Matrix (3, 1) * PtY
+ Map_Matrix (3, 2) * PtZ
+ Map_Matrix (3, 3) * PtT;
if (APT == 0. || stop == 0) {
AU = AV = IntegerLast ();
}
else {
APX /= APT;
APY /= APT;
APZ /= APT;
// NPCS -> Device Coordinate Space
AWindow->Size (Width, Height);
Dx = Standard_Real (Width);
Dy = Standard_Real (Height);
Ratio = Dx / Dy;
if (Ratio >= 1.) {
AU = Standard_Integer (APX * Dx);
AV = Standard_Integer (Dy - APY * Dy * Ratio);
}
else {
AU = Standard_Integer (APX * Dx / Ratio);
AV = Standard_Integer (Dy - APY * Dy);
}
}
}
}
}
Graphic3d_Vertex Visual3d_ViewManager::ConvertCoord (const Handle(Aspect_Window)& AWindow, const Standard_Integer AU, const Standard_Integer AV) const {
// Convert only if the data is correct
Graphic3d_CView TheCView;
Graphic3d_Vertex Point;
if (ViewExists (AWindow, TheCView))
{
Standard_Integer Width, Height;
Standard_ShortReal x, y, z;
Standard_Boolean Result;
AWindow->Size (Width, Height);
Result = MyGraphicDriver->UnProjectRaster (TheCView,
0, 0, Width, Height,
AU, AV, x, y, z);
// unproject is done by UnProjectRaster
if (Result) {
Point.SetCoord
(Standard_Real (x), Standard_Real (y), Standard_Real (z));
}
// unproject cannot be done by UnProjectRaster
// Code suspended since drivers Phigs and Pex are abandoned.
else {
Standard_Real NPCX, NPCY, NPCZ;
Standard_Real VRCX, VRCY, VRCZ, VRCT;
Standard_Real WCX, WCY, WCZ, WCT;
TColStd_Array2OfReal TOri_Matrix (0,3,0,3);
TColStd_Array2OfReal TMap_Matrix (0,3,0,3);
TColStd_Array2OfReal TOri_Matrix_Inv (0,3,0,3);
TColStd_Array2OfReal TMap_Matrix_Inv (0,3,0,3);
Standard_Real Dx, Dy, Ratio;
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
Standard_Integer stop = 0;
while ((! stop) && (MyIterator.More ())) {
if (TheCView.ViewId ==
(MyIterator.Value ())->Identification ()) {
TOri_Matrix =
(MyIterator.Value ())->MatrixOfOrientation ();
TMap_Matrix =
(MyIterator.Value ())->MatrixOfMapping ();
stop = 1;
}
// MyIterator.Next () is located on the next view
MyIterator.Next ();
}
// View Mapping Transformation and View Clip, inversion
Aspect::Inverse (TMap_Matrix, TMap_Matrix_Inv);
// View Orientation Transformation, inversion
Aspect::Inverse (TOri_Matrix, TOri_Matrix_Inv);
// (AU, AV) : Device Coordinate Space
// DCS -> NPCS Normalized Projection Coordinate Space
Dx = Standard_Real (Width);
Dy = Standard_Real (Height);
Ratio = Dx / Dy;
if (Ratio >= 1.) {
NPCX = Standard_Real (AU) / Dx;
NPCY = (Dy - Standard_Real (AV)) / Dx;
}
else {
NPCX = Standard_Real (AU) / Dy;
NPCY = (Dy - Standard_Real (AV)) / Dy;
}
NPCZ = 0.0;
// NPCS -> VRCS View Reference Coordinate Space
// PtVRC = Map_Matrix_Inv.Multiplied (PtNPC);
VRCX = TMap_Matrix_Inv (0, 0) * NPCX
+ TMap_Matrix_Inv (0, 1) * NPCY
+ TMap_Matrix_Inv (0, 2) * NPCZ
+ TMap_Matrix_Inv (0, 3);
VRCY = TMap_Matrix_Inv (1, 0) * NPCX
+ TMap_Matrix_Inv (1, 1) * NPCY
+ TMap_Matrix_Inv (1, 2) * NPCZ
+ TMap_Matrix_Inv (1, 3);
VRCZ = TMap_Matrix_Inv (2, 0) * NPCX
+ TMap_Matrix_Inv (2, 1) * NPCY
+ TMap_Matrix_Inv (2, 2) * NPCZ
+ TMap_Matrix_Inv (2, 3);
VRCT = TMap_Matrix_Inv (3, 0) * NPCX
+ TMap_Matrix_Inv (3, 1) * NPCY
+ TMap_Matrix_Inv (3, 2) * NPCZ
+ TMap_Matrix_Inv (3, 3);
// VRCS -> WCS World Coordinate Space
// PtWC = Ori_Matrix_Inv.Multiplied (PtVRC);
WCX = TOri_Matrix_Inv (0, 0) * VRCX
+ TOri_Matrix_Inv (0, 1) * VRCY
+ TOri_Matrix_Inv (0, 2) * VRCZ
+ TOri_Matrix_Inv (0, 3) * VRCT;
WCY = TOri_Matrix_Inv (1, 0) * VRCX
+ TOri_Matrix_Inv (1, 1) * VRCY
+ TOri_Matrix_Inv (1, 2) * VRCZ
+ TOri_Matrix_Inv (1, 3) * VRCT;
WCZ = TOri_Matrix_Inv (2, 0) * VRCX
+ TOri_Matrix_Inv (2, 1) * VRCY
+ TOri_Matrix_Inv (2, 2) * VRCZ
+ TOri_Matrix_Inv (2, 3) * VRCT;
WCT = TOri_Matrix_Inv (3, 0) * VRCX
+ TOri_Matrix_Inv (3, 1) * VRCY
+ TOri_Matrix_Inv (3, 2) * VRCZ
+ TOri_Matrix_Inv (3, 3) * VRCT;
if (WCT != 0.)
Point.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT);
}
}
return (Point);
}
void Visual3d_ViewManager::ConvertCoordWithProj (const Handle(Aspect_Window)& AWindow, const Standard_Integer AU, const Standard_Integer AV, Graphic3d_Vertex& Point, Graphic3d_Vector& Proj) const {
// Conversion only if the data is correct
Graphic3d_CView TheCView;
if (! ViewExists (AWindow, TheCView)) {
Point.SetCoord (0., 0., 0.);
Proj.SetCoord (0., 0., 0.);
}
else {
Standard_Integer Width, Height;
Standard_ShortReal x, y, z;
Standard_ShortReal dx, dy, dz;
Standard_Boolean Result;
AWindow->Size (Width, Height);
Result = MyGraphicDriver->UnProjectRasterWithRay (TheCView,
0, 0, Width, Height,
AU, AV, x, y, z, dx, dy, dz);
// unproject is done by UnProjectRaster
if (Result) {
Point.SetCoord
(Standard_Real (x), Standard_Real (y), Standard_Real (z));
Proj.SetCoord
(Standard_Real (dx), Standard_Real (dy), Standard_Real (dz));
Proj.Normalize();
}
// unproject cannot be done by UnProjectRaster
// Code is suspended since drivers Phigs are Pex abandoned.
else {
Standard_Real NPCX, NPCY, NPCZ;
Standard_Real VRCX, VRCY, VRCZ, VRCT;
Standard_Real WCX, WCY, WCZ, WCT;
TColStd_Array2OfReal TOri_Matrix (0,3,0,3);
TColStd_Array2OfReal TMap_Matrix (0,3,0,3);
TColStd_Array2OfReal TOri_Matrix_Inv (0,3,0,3);
TColStd_Array2OfReal TMap_Matrix_Inv (0,3,0,3);
Standard_Real Dx, Dy, Ratio;
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
Standard_Integer stop = 0;
while ((! stop) && (MyIterator.More ())) {
if (TheCView.ViewId ==
(MyIterator.Value ())->Identification ()) {
TOri_Matrix =
(MyIterator.Value ())->MatrixOfOrientation ();
TMap_Matrix =
(MyIterator.Value ())->MatrixOfMapping ();
stop = 1;
}
// MyIterator.Next () is located on the next view
MyIterator.Next ();
}
// View Mapping Transformation and View Clip, inversion
Aspect::Inverse (TMap_Matrix, TMap_Matrix_Inv);
// View Orientation Transformation, inversion
Aspect::Inverse (TOri_Matrix, TOri_Matrix_Inv);
// (AU, AV) : Device Coordinate Space
// DCS -> NPCS Normalized Projection Coordinate Space
Dx = Standard_Real (Width);
Dy = Standard_Real (Height);
Ratio = Dx / Dy;
if (Ratio >= 1.) {
NPCX = Standard_Real (AU) / Dx;
NPCY = (Dy - Standard_Real (AV)) / Dx;
}
else {
NPCX = Standard_Real (AU) / Dy;
NPCY = (Dy - Standard_Real (AV)) / Dy;
}
NPCZ = 0.0;
// NPCS -> VRCS View Reference Coordinate Space
// PtVRC = Map_Matrix_Inv.Multiplied (PtNPC);
VRCX = TMap_Matrix_Inv (0, 0) * NPCX
+ TMap_Matrix_Inv (0, 1) * NPCY
+ TMap_Matrix_Inv (0, 2) * NPCZ
+ TMap_Matrix_Inv (0, 3);
VRCY = TMap_Matrix_Inv (1, 0) * NPCX
+ TMap_Matrix_Inv (1, 1) * NPCY
+ TMap_Matrix_Inv (1, 2) * NPCZ
+ TMap_Matrix_Inv (1, 3);
VRCZ = TMap_Matrix_Inv (2, 0) * NPCX
+ TMap_Matrix_Inv (2, 1) * NPCY
+ TMap_Matrix_Inv (2, 2) * NPCZ
+ TMap_Matrix_Inv (2, 3);
VRCT = TMap_Matrix_Inv (3, 0) * NPCX
+ TMap_Matrix_Inv (3, 1) * NPCY
+ TMap_Matrix_Inv (3, 2) * NPCZ
+ TMap_Matrix_Inv (3, 3);
// VRCS -> WCS World Coordinate Space
// PtWC = Ori_Matrix_Inv.Multiplied (PtVRC);
WCX = TOri_Matrix_Inv (0, 0) * VRCX
+ TOri_Matrix_Inv (0, 1) * VRCY
+ TOri_Matrix_Inv (0, 2) * VRCZ
+ TOri_Matrix_Inv (0, 3) * VRCT;
WCY = TOri_Matrix_Inv (1, 0) * VRCX
+ TOri_Matrix_Inv (1, 1) * VRCY
+ TOri_Matrix_Inv (1, 2) * VRCZ
+ TOri_Matrix_Inv (1, 3) * VRCT;
WCZ = TOri_Matrix_Inv (2, 0) * VRCX
+ TOri_Matrix_Inv (2, 1) * VRCY
+ TOri_Matrix_Inv (2, 2) * VRCZ
+ TOri_Matrix_Inv (2, 3) * VRCT;
WCT = TOri_Matrix_Inv (3, 0) * VRCX
+ TOri_Matrix_Inv (3, 1) * VRCY
+ TOri_Matrix_Inv (3, 2) * VRCZ
+ TOri_Matrix_Inv (3, 3) * VRCT;
if (WCT != 0.)
Point.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT);
else
Point.SetCoord (0., 0., 0.);
// Define projection ray
NPCZ = 10.0;
// NPCS -> VRCS View Reference Coordinate Space
// PtVRC = Map_Matrix_Inv.Multiplied (PtNPC);
VRCX = TMap_Matrix_Inv (0, 0) * NPCX
+ TMap_Matrix_Inv (0, 1) * NPCY
+ TMap_Matrix_Inv (0, 2) * NPCZ
+ TMap_Matrix_Inv (0, 3);
VRCY = TMap_Matrix_Inv (1, 0) * NPCX
+ TMap_Matrix_Inv (1, 1) * NPCY
+ TMap_Matrix_Inv (1, 2) * NPCZ
+ TMap_Matrix_Inv (1, 3);
VRCZ = TMap_Matrix_Inv (2, 0) * NPCX
+ TMap_Matrix_Inv (2, 1) * NPCY
+ TMap_Matrix_Inv (2, 2) * NPCZ
+ TMap_Matrix_Inv (2, 3);
VRCT = TMap_Matrix_Inv (3, 0) * NPCX
+ TMap_Matrix_Inv (3, 1) * NPCY
+ TMap_Matrix_Inv (3, 2) * NPCZ
+ TMap_Matrix_Inv (3, 3);
// VRCS -> WCS World Coordinate Space
// PtWC = Ori_Matrix_Inv.Multiplied (PtVRC);
WCX = TOri_Matrix_Inv (0, 0) * VRCX
+ TOri_Matrix_Inv (0, 1) * VRCY
+ TOri_Matrix_Inv (0, 2) * VRCZ
+ TOri_Matrix_Inv (0, 3) * VRCT;
WCY = TOri_Matrix_Inv (1, 0) * VRCX
+ TOri_Matrix_Inv (1, 1) * VRCY
+ TOri_Matrix_Inv (1, 2) * VRCZ
+ TOri_Matrix_Inv (1, 3) * VRCT;
WCZ = TOri_Matrix_Inv (2, 0) * VRCX
+ TOri_Matrix_Inv (2, 1) * VRCY
+ TOri_Matrix_Inv (2, 2) * VRCZ
+ TOri_Matrix_Inv (2, 3) * VRCT;
WCT = TOri_Matrix_Inv (3, 0) * VRCX
+ TOri_Matrix_Inv (3, 1) * VRCY
+ TOri_Matrix_Inv (3, 2) * VRCZ
+ TOri_Matrix_Inv (3, 3) * VRCT;
if (WCT != 0.) {
Proj.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT);
Proj.Normalize();
}
else
Proj.SetCoord (0., 0., 0.);
}
}
}
Standard_Boolean Visual3d_ViewManager::ViewExists (const Handle(Aspect_Window)& AWindow, Graphic3d_CView& TheCView) const {
Standard_Boolean Exist = Standard_False;

View File

@@ -1,299 +0,0 @@
-- Created on: 1991-06-12
-- 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 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.
class ViewMapping from Visual3d
---Version:
---Purpose: This class allows the definition of a projection and
-- a system of coordinates called NPC.
-- (Normalized Projection Coordinates).
-- The projection can be parallel or perspective.
-- References: The definitions are Phigs oriented.
-- Keywords: View, Mapping, Window, View Plane, Front Plane,
-- BackPlane, Projection Type, Reset, Projection
-- Summary of 3D View Mapping --
-- The view mapping transformation defines the --
-- window-to-viewport mapping of View Reference --
-- Coordinates (VRC) to Normalized Projection --
-- Coordinates (NPC). --
-- CAS.CADE supports two kinds of projection : --
-- Parallel : --
-- The Projection Reference Point (PRP) --
-- determines the direction of projection. --
-- Perspective : --
-- The projector lines converge at the --
-- Projection Reference Point (PRP). --
-- To define a view mapping transformation you --
-- must define : --
-- The Projection Type --
-- The Projection Reference Point (PRP) --
-- The Distance from Back Plane (BPD) --
-- The Distance from Front Plane (FPD) --
-- The Distance from View Plane (VPD) --
-- The Window in the View Plane. --
uses
Vertex from Graphic3d,
HArray2OfReal from TColStd,
TypeOfProjection from Visual3d
raises
ViewMappingDefinitionError from Visual3d
is
Create
returns ViewMapping from Visual3d;
---Level: Public
---Purpose: Creates a projection.
--
-- TypeOfProjection = TOP_PARALLEL
-- PRP : Projection Reference Point= (0.5, 0.5, 2.0)
-- BPD : Distance from Back Plane = 0.0
-- FPD : Distance from Front Plane = 1.0
-- VPD : Distance from View Plane = 1.0
-- WUmin = 0.0
-- WUmax = 1.0
-- WVmin = 0.0
-- WVmax = 1.0
Create ( AType : TypeOfProjection from Visual3d;
PRP : Vertex from Graphic3d;
BPD, FPD, VPD : Real from Standard;
WUmin,WVmin : Real from Standard;
WUmax,WVmax : Real from Standard )
returns ViewMapping from Visual3d
---Level: Public
---Purpose: Creates a projection.
--
-- TypeOfProjection : TOP_PERSPECTIVE
-- TOP_PARALLEL
-- PRP : Projection Reference Point with respect to
-- coordinate system VRC, defined by the
-- class ViewOrientation.
-- BPD : Distance from Back Plane.
-- FPD : Distance from Front Plane.
-- VPD : Distance from View Plane.
-- These three values are with respect to VRP, according to
-- the N axis of the VRC coordinate system, defined by the class
-- ViewOrientation.
-- WUmin,WUmax,WVmin,WVmax : Visible part of the plane of
-- projection defined with respect to the UV axes of coordinate
-- system VRC.
-- That's what allows modification of the zoom/panning.
-- The mapping of the visible part of the plane of projection
-- on the screen is done in the window.
-- That's why multiple views on the same window is not allowed.
-- Warning: Raises ViewMappingDefinitionError
-- if the specified window is invalid.
-- if <PRP> is between the front and back planes.
-- if <PRP> is positioned on the view plane.
-- if the back plane is in front of the front plane.
raises ViewMappingDefinitionError from Visual3d;
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
SetBackPlaneDistance ( me : in out;
BPD : Real from Standard )
---Level: Public
---Purpose: Modifies the back clipping plane.
-- Category: Methods to modify the class definition
-- Warning: Raises ViewMappingDefinitionError
-- if <PRP> is between the front and back planes.
-- if <PRP> is positioned on the view plane.
-- if the back plane is in front of the front plane.
raises ViewMappingDefinitionError from Visual3d is static;
SetFrontPlaneDistance ( me : in out;
FPD : Real from Standard )
---Level: Public
---Purpose: Modifies the front clipping plane.
-- Category: Methods to modify the class definition
-- Warning: Raises ViewMappingDefinitionError
-- if <PRP> is between the front and back planes.
-- if <PRP> is positioned on the view plane.
-- if the back plane is in front of the front plane.
raises ViewMappingDefinitionError from Visual3d is static;
SetProjection ( me : in out;
AType : TypeOfProjection from Visual3d )
is static;
---Level: Public
---Purpose: Modifies the type of projection.
--
-- TypeOfProjection : TOP_PERSPECTIVE
-- TOP_PARALLEL
--
---Category: Methods to modify the class definition
SetProjectionReferencePoint ( me : in out;
PRP : Vertex from Graphic3d )
---Level: Public
---Purpose: Modifies the PRP.
-- Category: Methods to modify the class definition
-- Warning: Raises ViewMappingDefinitionError
-- if <PRP> is between the front and back planes.
-- if <PRP> is positioned on the view plane.
raises ViewMappingDefinitionError from Visual3d is static;
SetViewPlaneDistance ( me : in out;
VPD : Real from Standard )
---Level: Public
---Purpose: Modifies the distance of the view plane of projection.
-- Category: Methods to modify the class definition
-- Warning: Raises ViewMappingDefinitionError
-- if <PRP> is positioned on the view plane.
raises ViewMappingDefinitionError from Visual3d is static;
SetWindowLimit ( me : in out;
Umin,Vmin,Umax,Vmax : Real from Standard )
---Level: Public
---Purpose: Modifies the visible part of the projection plane.
-- Category: Methods to modify the class definition
-- Warning: Raises ViewMappingDefinitionError if the
-- specified window is invalid.
raises ViewMappingDefinitionError from Visual3d is static;
SetCustomProjectionMatrix( me : in out;
Mat : HArray2OfReal from TColStd ) is static;
---Level: Public
---Purpose: Sets custom PROJECTION matrix for the OpenGl context
----------------------------
-- Category: Inquire methods
----------------------------
BackPlaneDistance ( me )
returns Real from Standard
is static;
---Level: Public
---Purpose: Returns the distance from the back clipping plane
-- of this view mapping.
---Category: Inquire methods
FrontPlaneDistance ( me )
returns Real from Standard
is static;
---Level: Public
---Purpose: Returns the distance from the front clipping plane
-- of this view mapping.
---Category: Inquire methods
Projection ( me )
returns TypeOfProjection from Visual3d
is static;
---Level: Public
---Purpose: Returns the type of projection.
---Category: Inquire methods
ProjectionReferencePoint ( me )
returns Vertex from Graphic3d
is static;
---Level: Public
---Purpose: Returns the PRP.
---Category: Inquire methods
ViewPlaneDistance ( me )
returns Real from Standard
is static;
---Level: Public
---Purpose: Returns the distance from the projection plane.
---Category: Inquire methods
WindowLimit ( me;
Umin,Vmin,Umax,Vmax : out Real from Standard )
is static;
---Level: Public
---Purpose: Returns the visible part of the projection plane.
---Category: Inquire methods
IsCustomMatrix( me )
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns whether the custom PROJECTION matrix is used.
----------------------------
-- Category: Private methods
----------------------------
Assign ( me : in out;
Other : ViewMapping from Visual3d )
is static private;
---Level: Internal
---Purpose: Copies the content of <Other> into <me>.
---Category: Private methods
--
fields
--
-- Class : Visual3d_ViewMapping
--
-- Purpose : Declaration of variables specific to
-- the mapping of views.
--
-- Reminder : A view mapping is defined by :
-- - the reference point of projection
-- - the type of projection
-- - a distance from the Back Plane
-- - a distance from the Front Plane
-- - a distance from the Projection Plane
-- - the definition of the visible part of the
-- plane of projection
--
-- the reference point of projection
MyReferencePoint : Vertex from Graphic3d;
-- the type of projection
MyProjectionType : TypeOfProjection from Visual3d;
-- the distance from the Back Plane
MyBackPlaneDistance : Real from Standard;
-- the distance from the Front Plane
MyFrontPlaneDistance : Real from Standard;
-- the distance from the Projection Plane
MyViewPlaneDistance : Real from Standard;
-- the limits of the visible part of the plane
-- MyWindowLimits[0] = u left lower corner.
-- MyWindowLimits[1] = v left lower corner.
-- MyWindowLimits[2] = u right upper corner.
-- MyWindowLimits[3] = v right upper corner.
MyWindowLimits : Real[4];
-- the custom PROJECTION matrix to set directly to OpenGl context
MyProjectionMatrix : HArray2OfReal from TColStd;
friends
class View from Visual3d
end ViewMapping;

View File

@@ -1,335 +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 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
// 22-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH
// 23-07-07 : NKV ; Define custom PROJECTION matrix for OpenGl context
//-Version
//-Design Declaration of variables specific to mapping of views
//-Warning Mapping of a view is defined by :
// - reference point of projection
// - type of projection
// - distance for the Back Plane
// - distance for the Front Plane
// - distance for the Projection Plane
//-References
//-Language C++ 2.0
//-Declarations
// for the class
#include <Visual3d_ViewMapping.ixx>
#include <Precision.hxx>
// Perspective
#include <OSD_Environment.hxx>
static OSD_Environment env_walkthrow;
static Standard_Boolean Visual3dWalkthrow()
{
static Standard_Integer isWalkthrow( -1 );
if ( isWalkthrow < 0 ) {
isWalkthrow = 1;
OSD_Environment WalkThrow("CSF_WALKTHROUGH");
if ( WalkThrow.Value().IsEmpty() )
isWalkthrow = 0;
}
return ( isWalkthrow != 0 );
}
//-Aliases
//-Global data definitions
// -- le point reference de projection
// MyReferencePoint : Vertex;
// -- le type de projection
// MyProjectionType : TypeOfProjection;
// -- la distance pour le Back Plane
// MyBackPlaneDistance : Standard_Real;
// -- la distance pour le Front Plane
// MyFrontPlaneDistance : Standard_Real;
// -- la distance pour le Projection Plane
// MyViewPlaneDistance : Standard_Real;
// -- les limites de la partie visible du plan
// -- MyWindowLimits[0] = u du coin inferieur gauche.
// -- MyWindowLimits[1] = v du coin inferieur gauche.
// -- MyWindowLimits[2] = u du coin superieur droit.
// -- MyWindowLimits[3] = v du coin superieur droit.
// MyWindowLimits : Standard_Real[4];
//-Constructors
//-Destructors
//-Methods, in order
Visual3d_ViewMapping::Visual3d_ViewMapping ():
MyReferencePoint (0.5, 0.5, 2.0),
MyProjectionType (Visual3d_TOP_PARALLEL) {
if ( Visual3dWalkthrow() )
{
MyBackPlaneDistance = -1.0;
MyFrontPlaneDistance = 1.0;
MyViewPlaneDistance = 0.0;
}
else
{
MyBackPlaneDistance = 0.0;
MyFrontPlaneDistance = 1.0;
MyViewPlaneDistance = 1.0;
}
MyWindowLimits[0] = 0.0;
MyWindowLimits[1] = 0.0;
MyWindowLimits[2] = 1.0;
MyWindowLimits[3] = 1.0;
}
Visual3d_ViewMapping::Visual3d_ViewMapping (const Visual3d_TypeOfProjection AType, const Graphic3d_Vertex& PRP, const Standard_Real BPD, const Standard_Real FPD, const Standard_Real VPD, const Standard_Real WUmin, const Standard_Real WVmin, const Standard_Real WUmax, const Standard_Real WVmax):
MyReferencePoint (PRP),
MyProjectionType (AType),
MyBackPlaneDistance (BPD),
MyFrontPlaneDistance (FPD),
MyViewPlaneDistance (VPD) {
if ( (WUmin >= WUmax) || (WVmin >= WVmax) )
Visual3d_ViewMappingDefinitionError::Raise
("Invalid window; WUmin > WUmax or WVmin > WVmax");
if (BPD > FPD)
Visual3d_ViewMappingDefinitionError::Raise
("The back plane is in front of the front plane");
/*
A TESTER AVEC LE VRP ?
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point is between the front and back planes");
if (PRP.Z () == VPD)
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point cannot be positioned on the view plane");
*/
MyWindowLimits[0] = WUmin;
MyWindowLimits[1] = WVmin;
MyWindowLimits[2] = WUmax;
MyWindowLimits[3] = WVmax;
}
void Visual3d_ViewMapping::SetProjection (const Visual3d_TypeOfProjection AType) {
MyProjectionType = AType;
}
Visual3d_TypeOfProjection Visual3d_ViewMapping::Projection () const {
return (MyProjectionType);
}
void Visual3d_ViewMapping::SetProjectionReferencePoint (const Graphic3d_Vertex& PRP) {
/*
Standard_Real VPD, BPD, FPD;
VPD = MyViewPlaneDistance;
BPD = MyBackPlaneDistance;
FPD = MyFrontPlaneDistance;
A TESTER AVEC LE VRP ?
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point is between the front and back planes");
if (PRP.Z () == VPD)
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point cannot be positioned on the view plane");
*/
MyReferencePoint = PRP;
}
Graphic3d_Vertex Visual3d_ViewMapping::ProjectionReferencePoint () const {
return (MyReferencePoint);
}
void Visual3d_ViewMapping::SetViewPlaneDistance (const Standard_Real VPD) {
/*
Standard_Real PRPZ, BPD, FPD;
PRPZ = MyReferencePoint.Z ();
BPD = MyBackPlaneDistance;
FPD = MyFrontPlaneDistance;
A TESTER AVEC LE VRP ?
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point is between the front and back planes");
if (PRPZ == VPD)
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point cannot be positioned on the view plane");
*/
MyViewPlaneDistance = VPD;
}
Standard_Real Visual3d_ViewMapping::ViewPlaneDistance () const {
return (MyViewPlaneDistance);
}
void Visual3d_ViewMapping::SetBackPlaneDistance (const Standard_Real BPD) {
/*
Standard_Real VPD, PRPZ, FPD;
PRPZ = MyReferencePoint.Z ();
VPD = MyViewPlaneDistance;
FPD = MyFrontPlaneDistance;
if (BPD > FPD)
Visual3d_ViewMappingDefinitionError::Raise
("The back plane is in front of the front plane");
A TESTER AVEC LE VRP ?
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point is between the front and back planes");
*/
MyBackPlaneDistance = BPD;
}
Standard_Real Visual3d_ViewMapping::BackPlaneDistance () const {
return (MyBackPlaneDistance);
}
void Visual3d_ViewMapping::SetFrontPlaneDistance (const Standard_Real FPD) {
/*
Standard_Real VPD, BPD, PRPZ;
PRPZ = MyReferencePoint.Z ();
VPD = MyViewPlaneDistance;
BPD = MyBackPlaneDistance;
if (BPD > FPD)
Visual3d_ViewMappingDefinitionError::Raise
("The back plane is in front of the front plane");
A TESTER AVEC LE VRP ?
Visual3d_ViewMappingDefinitionError::Raise
("The projection reference point is between the front and back planes");
*/
MyFrontPlaneDistance = FPD;
}
Standard_Real Visual3d_ViewMapping::FrontPlaneDistance () const {
return (MyFrontPlaneDistance);
}
void Visual3d_ViewMapping::SetWindowLimit (const Standard_Real Umin, const Standard_Real Vmin, const Standard_Real Umax, const Standard_Real Vmax) {
if ( (Umin >= Umax) || (Vmin >= Vmax) )
Visual3d_ViewMappingDefinitionError::Raise
("Invalid window; WUmin > WUmax or WVmin > WVmax");
if( (Umax - Umin) < Precision::Confusion() || (Vmax - Vmin) < Precision::Confusion())
Visual3d_ViewMappingDefinitionError::Raise
("Window is too small");
MyWindowLimits[0] = Umin;
MyWindowLimits[1] = Vmin;
MyWindowLimits[2] = Umax;
MyWindowLimits[3] = Vmax;
}
void Visual3d_ViewMapping::WindowLimit (Standard_Real& Umin, Standard_Real& Vmin, Standard_Real& Umax, Standard_Real& Vmax) const {
Umin = MyWindowLimits[0];
Vmin = MyWindowLimits[1];
Umax = MyWindowLimits[2];
Vmax = MyWindowLimits[3];
}
void Visual3d_ViewMapping::SetCustomProjectionMatrix(const Handle(TColStd_HArray2OfReal)& Mat)
{
MyProjectionMatrix = Mat;
}
Standard_Boolean Visual3d_ViewMapping::IsCustomMatrix() const
{
return !MyProjectionMatrix.IsNull()
&& MyProjectionMatrix->LowerRow() == 0
&& MyProjectionMatrix->LowerCol() == 0
&& MyProjectionMatrix->UpperRow() == 3
&& MyProjectionMatrix->UpperCol() == 3;
}
void Visual3d_ViewMapping::Assign (const Visual3d_ViewMapping& Other) {
Standard_Real X, Y, Z;
(Other.ProjectionReferencePoint ()).Coord (X, Y, Z);
MyReferencePoint.SetCoord (X, Y, Z);
MyProjectionType = Other.Projection ();
MyBackPlaneDistance = Other.BackPlaneDistance ();
MyFrontPlaneDistance = Other.FrontPlaneDistance ();
MyViewPlaneDistance = Other.ViewPlaneDistance ();
Other.WindowLimit (MyWindowLimits[0], MyWindowLimits[1],
MyWindowLimits[2], MyWindowLimits[3]);
if ( Other.IsCustomMatrix() ) {
MyProjectionMatrix = new TColStd_HArray2OfReal( 0, 3, 0, 3 );
for (Standard_Integer i = 0; i < 4; i++)
for (Standard_Integer j = 0; j < 4; j++)
MyProjectionMatrix->SetValue( i, j, Other.MyProjectionMatrix->Value(i, j) );
}
else
MyProjectionMatrix.Nullify();
}

View File

@@ -1,256 +0,0 @@
-- Created on: 1991-06-12
-- 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 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.
class ViewOrientation from Visual3d
---Version:
---Purpose: This class allows the definition of the manner in
-- which an observer looks at the visualised scene.
-- It defines a coordinate system called VRC
-- (View Reference Coordinates) with 3 axes U,V,N
-- Summary of 3D View Orientation --
-- --
-- The view orientation transformation defines --
-- the relationship between World Coordinates --
-- (WC) and View Reference Coordinates (VRC) --
-- --
-- To define a view orientation transformation --
-- you must define : --
-- --
-- The View Reference Point (VRP) --
-- The View Plane Normal (VPN) --
-- The View Up Vector (VUP). --
--
-- Optionally, it is possible to specify anisotropic
-- (axial) scale factors. This allows to scale the scene
-- using individual scale values along each coordinate axis.
uses
Vector from Graphic3d,
Vertex from Graphic3d,
HArray2OfReal from TColStd
raises
ViewOrientationDefinitionError from Visual3d
is
Create
returns ViewOrientation from Visual3d;
---Level: Public
---Purpose: Creates a VRC coordinate system.
-- VRP : Origin of the VRC coordinate system.
-- (default value : 0.0, 0.0, 0.0)
-- VPN : Vector normal to the plane of visualisation.
-- (default value : 0.0, 0.0, 1.0)
-- VUP : Vector for which the projection in the plane
-- of visualisation defines the axis V of a VRC
-- coordinate system.
-- (default value : 0.0, 1.0, 0.0)
Create ( VRP : Vertex from Graphic3d;
VPN : Vector from Graphic3d;
VUP : Vector from Graphic3d )
returns ViewOrientation from Visual3d
---Level: Public
---Purpose: Creates a VRC coordinate system.
-- VRP : Origin of the VRC coordinate system.
-- VPN : Vector normal to the plane of visualisation.
-- VUP : Vector for which the projection in the plane
-- of visualisation defines the axis V of a VRC
-- coordinate system.
-- This vector can be likened to the
-- vertical of the observer.
-- Warning: Raises ViewOrientationDefinitionError
-- if <VPN> is null.
-- if <VUP> is null.
-- if <VPN> and <VUP> are parallel.
raises ViewOrientationDefinitionError from Visual3d;
Create ( VRP : Vertex from Graphic3d;
VPN : Vector from Graphic3d;
Twist : Real from Standard )
returns ViewOrientation from Visual3d
---Level: Internal
---Purpose: Creates a VRC coordinate system.
-- VRP : Origin of VRC coordinate system.
-- VPN : Normal vector to the plane of visualisation.
-- Twist : Angle in radians of the V axis in the VRC
-- coordinate system with the projection in
-- the plane of visualisation of the Zm axis
-- in the model space.
-- Warning: Raises ViewOrientationDefinitionError if <VPN> is null.
raises ViewOrientationDefinitionError from Visual3d;
Create ( VRP : Vertex from Graphic3d;
Azim, Inc, Twist : Real from Standard )
returns ViewOrientation from Visual3d
---Level: Internal
---Purpose: Creates a VRC coordinate system.
-- VRP : Origin of the VRC coordinate system.
-- Azim : Angle in radians of the plane of visualisation
-- with the XmYm plane of the model space.
-- Inc : Angle in radians of the plane of visualisation
-- with the YmZm plane of the model space.
-- Twist : Angle in radians of the V axis in the VRC
-- coordinate system with the projection in
-- the plane of visualisation of the Zm axis
-- in the model space.
-- Warning: Raises ViewOrientationDefinitionError
raises ViewOrientationDefinitionError from Visual3d;
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
SetViewReferencePlane ( me : in out;
VPN : Vector from Graphic3d )
---Level: Public
---Purpose: Modifies the plane of visualisation
-- defined by a normal vector.
-- Category: Methods to modify the class definition
-- Warning: Raises ViewOrientationDefinitionError if <VPN> is null.
raises ViewOrientationDefinitionError from Visual3d is static;
SetViewReferencePoint ( me : in out;
VRP : Vertex from Graphic3d )
is static;
---Level: Public
---Purpose: Modifies the origin of the VRC coordinate system
---Category: Methods to modify the class definition
SetViewReferenceUp ( me : in out;
VUP : Vector from Graphic3d )
---Level: Public
---Purpose: Modifies the vertical of the observer.
-- Category: Methods to modify the class definition
-- Warning: Raises ViewOrientationDefinitionError if <VUP> is null.
raises ViewOrientationDefinitionError from Visual3d is static;
SetAxialScale ( me : in out ;
Sx, Sy, Sz : Real from Standard )
---Level: Public
---Purpose: Sets axial scale factors of the view
raises ViewOrientationDefinitionError from Visual3d ;
-- If the one of factors <= 0
SetCustomModelViewMatrix( me : in out;
Mat : HArray2OfReal from TColStd ) is static;
---Level: Public
---Purpose: Sets custom MODELVIEW matrix for the OpenGl context
----------------------------
-- Category: Inquire methods
----------------------------
Twist ( me )
returns Real from Standard
is static;
---Level: Internal
---Purpose: Returns the angle in radians of the V axis in the VRC
-- coordinate system with the projection in the plane of
-- visualisation of the Zm axis in the model space.
---Category: Inquire methods
ViewReferencePlane ( me )
returns Vector from Graphic3d
is static;
---Level: Public
---Purpose: Returns the normal to the plane of projection.
---Category: Inquire methods
ViewReferencePoint ( me )
returns Vertex from Graphic3d
is static;
---Level: Public
---Purpose: Returns origin of the VRC coordinate system.
---Category: Inquire methods
ViewReferenceUp ( me )
returns Vector from Graphic3d
is static;
---Level: Public
---Purpose: Returns the vertical of the observer.
---Category: Inquire methods
AxialScale ( me ; Sx, Sy, Sz : out Real from Standard ) ;
---Level: Public
---Purpose: Returns current values of the axial scale factors.
IsCustomMatrix( me )
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns whether the custom MODELVIEW matrix is used.
----------------------------
-- Category: Private methods
----------------------------
Assign ( me : in out;
Other : ViewOrientation from Visual3d )
is static private;
---Level: Internal
---Purpose: Copies the content of <Other> into <me>.
---Category: Private methods
--
fields
--
-- Class : Visual3d_ViewOrientation
--
-- Purpose : Declaration of variables specific to
-- the view orientation
--
-- Reminders : the orientation of a view is defined by :
-- - the origin point of the coordinate system
-- - the normal vector to the plane of visualisation
-- - the vector vertical to the observer
--
-- the coordinate system origin point
MyViewReferencePoint : Vertex from Graphic3d;
-- the normal vector to the plane of visualisation
MyViewPlaneNormal : Vector from Graphic3d;
-- the vertical vector of the observer
MyViewUpVector : Vector from Graphic3d;
-- the scale parameter of the X axis
MyScaleX : Real from Standard;
-- the scale parameter of the Y axis
MyScaleY : Real from Standard;
-- the scale parameter of the Z axis
MyScaleZ : Real from Standard;
-- the custom MODELVIEW matrix to set directly to OpenGl context
MyModelViewMatrix : HArray2OfReal from TColStd;
friends
class View from Visual3d
end ViewOrientation;

View File

@@ -1,253 +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 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.
//-Version
//-Design Declaration of variables specific to the orientation of views
//-Warning The view orientation is defined by :
// - the point of origin of the reference mark
// - the normal vector to the visualisation plane
// - the vertical vector of the viewer
//-References
//-Language C++ 2.0
//-Declarations
// for the class
#include <Visual3d_ViewOrientation.ixx>
//-Aliases
//-Global data definitions
// -- le point origine du repere
// MyViewReferencePoint : Vertex;
// -- le vecteur normal au plan de visualisation
// MyViewPlaneNormal : Vector;
// -- le vecteur vertical de l'observateur
// MyViewUpVector : Vector;
//-Constructors
//-Destructors
//-Methods, in order
Visual3d_ViewOrientation::Visual3d_ViewOrientation ():
MyViewReferencePoint (0.0, 0.0, 0.0),
MyViewPlaneNormal (0.0, 0.0, 1.0),
MyViewUpVector (0.0, 1.0, 0.0),
MyScaleX(1.0),
MyScaleY(1.0),
MyScaleZ(1.0) {
}
Visual3d_ViewOrientation::Visual3d_ViewOrientation (const Graphic3d_Vertex& VRP, const Graphic3d_Vector& VPN, const Graphic3d_Vector& VUP):
MyViewReferencePoint (VRP),
MyViewPlaneNormal (VPN),
MyViewUpVector (VUP),
MyScaleX(1.0),
MyScaleY(1.0),
MyScaleZ(1.0) {
if (Graphic3d_Vector::NormeOf (VPN) == 0.0)
Visual3d_ViewOrientationDefinitionError::Raise
("Bad value for ViewPlaneNormal");
if (Graphic3d_Vector::NormeOf (VUP) == 0.0)
Visual3d_ViewOrientationDefinitionError::Raise
("Bad value for ViewUpVector");
if (Graphic3d_Vector::IsParallel (VPN, VUP))
Visual3d_ViewOrientationDefinitionError::Raise
("ViewPlaneNormal and ViewUpVector are parallel");
}
Visual3d_ViewOrientation::Visual3d_ViewOrientation (const Graphic3d_Vertex& VRP, const Graphic3d_Vector& VPN, const Standard_Real /*Twist*/) {
if (Graphic3d_Vector::NormeOf (VPN) == 0.0)
Visual3d_ViewOrientationDefinitionError::Raise
("Bad value for ViewPlaneNormal");
cout << "\nVisual3d_ViewOrientation : Not Yet Implemented\n\n" << flush;
MyViewReferencePoint = VRP;
MyViewPlaneNormal = VPN;
}
Visual3d_ViewOrientation::Visual3d_ViewOrientation (const Graphic3d_Vertex& VRP, const Standard_Real /*Azim*/, const Standard_Real /*Inc*/, const Standard_Real /*Twist*/) {
cout << "\nVisual3d_ViewOrientation : Not Yet Implemented\n\n" << flush;
MyViewReferencePoint = VRP;
}
void Visual3d_ViewOrientation::SetViewReferencePoint (const Graphic3d_Vertex& VRP) {
MyViewReferencePoint = VRP;
}
Graphic3d_Vertex Visual3d_ViewOrientation::ViewReferencePoint () const {
return (MyViewReferencePoint);
}
void Visual3d_ViewOrientation::SetViewReferencePlane (const Graphic3d_Vector& VPN) {
if (Graphic3d_Vector::NormeOf (VPN) == 0.0)
Visual3d_ViewOrientationDefinitionError::Raise
("Bad value for ViewPlaneNormal");
MyViewPlaneNormal = VPN;
}
Graphic3d_Vector Visual3d_ViewOrientation::ViewReferencePlane () const {
return (MyViewPlaneNormal);
}
void Visual3d_ViewOrientation::SetViewReferenceUp (const Graphic3d_Vector& VUP) {
if (Graphic3d_Vector::NormeOf (VUP) == 0.0)
Visual3d_ViewOrientationDefinitionError::Raise
("Bad value for ViewUpVector");
MyViewUpVector = VUP;
}
void Visual3d_ViewOrientation::SetAxialScale (const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz) {
if ( Sx <= 0. || Sy <= 0. || Sz <= 0. )
Visual3d_ViewOrientationDefinitionError::Raise
("Bad value for ViewUpVector");
MyScaleX = Sx;
MyScaleY = Sy;
MyScaleZ = Sz;
}
Graphic3d_Vector Visual3d_ViewOrientation::ViewReferenceUp () const {
return (MyViewUpVector);
}
void Visual3d_ViewOrientation::Assign (const Visual3d_ViewOrientation& Other) {
Standard_Real X, Y, Z;
(Other.ViewReferencePoint ()).Coord (X, Y, Z);
MyViewReferencePoint.SetCoord (X, Y, Z);
(Other.ViewReferencePlane ()).Coord (X, Y, Z);
MyViewPlaneNormal.SetCoord (X, Y, Z);
(Other.ViewReferenceUp ()).Coord (X, Y, Z);
MyViewUpVector.SetCoord (X, Y, Z);
if ( Other.IsCustomMatrix() ) {
MyModelViewMatrix = new TColStd_HArray2OfReal( 0, 3, 0, 3);
for (Standard_Integer i = 0; i < 4; i++)
for (Standard_Integer j = 0; j < 4; j++)
MyModelViewMatrix->SetValue( i, j, Other.MyModelViewMatrix->Value(i, j) );
}
else
MyModelViewMatrix.Nullify();
}
Standard_Real Visual3d_ViewOrientation::Twist () const {
cout << "\nVisual3d_ViewOrientation::Twist : Not Yet Implemented\n\n" << flush;
#ifdef OK
Standard_Real Xrp, Yrp, Zrp;
Standard_Real Xpn, Ypn, Zpn;
Standard_Real Xup, Yup, Zup;
Standard_Real a1, b1, c1, a2, b2, c2;
Standard_Real pvx, pvy, pvz;
Standard_Real an1, an2;
Standard_Real pvn, sca, angle;
MyViewReferencePoint.Coord (Xrp, Yrp, Zrp) ;
MyViewPlaneNormal.Coord (Xpn, Ypn, Zpn) ;
MyViewUpVector.Coord (Xup, Yup, Zup) ;
Xrp -= Xpn ; Yrp -= Ypn ; Zrp -= Zpn ;
Xup -= Xpn ; Yup -= Ypn ; Zup -= Zpn ;
/* Compute Plane Normal EYE, AT, UP */
a1 = Yrp*Zup - Yup*Zrp ;
b1 = Zrp*Xup - Zup*Xrp ;
c1 = Xrp*Yup - Xup*Yrp ;
/* Compute Plane Normal EYE, AT, YAXIS */
a2 = -Zrp ;
b2 = 0. ;
c2 = Xrp ;
/* Compute Cross Vector from 2 last Normals */
pvx = b1*c2 - c1*b2 ;
pvy = c1*a2 - a1*c2 ;
pvz = a1*b2 - b1*a2 ;
/* Normalize vectors */
an1 = a1*a1 + b1*b1 + c1*c1 ;
an2 = a2*a2 + b2*b2 + c2*c2 ;
pvn = pvx*pvx + pvy*pvy + pvz*pvz ;
/* Compute Angle */
if (angle > 1.) angle = 1. ;
else if ( angle < -1. ) angle = -1. ;
angle = asin (angle) / (M_PI / 180.0);
sca = a1*a2 + b1*b2 + c1*c2 ;
if (sca < 0.) angle = 180. - angle ;
if ( (angle > 0.) && (angle < 180.) ) {
sca = - (pvx*Xrp + pvy*Yrp + pvz*Zrp) ;
if (sca > 0.) angle = 360. - angle ;
}
return (angle * M_PI / 180.0);
#else
return (M_PI / 180.0);
#endif
}
void Visual3d_ViewOrientation::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz)const {
Sx = MyScaleX;
Sy = MyScaleY;
Sz = MyScaleZ;
}
void Visual3d_ViewOrientation::SetCustomModelViewMatrix(const Handle(TColStd_HArray2OfReal)& Mat)
{
MyModelViewMatrix = Mat;
}
Standard_Boolean Visual3d_ViewOrientation::IsCustomMatrix() const
{
return !MyModelViewMatrix.IsNull()
&& MyModelViewMatrix->LowerRow() == 0
&& MyModelViewMatrix->LowerCol() == 0
&& MyModelViewMatrix->UpperRow() == 3
&& MyModelViewMatrix->UpperCol() == 3;
}