1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Compare commits

..

2 Commits

Author SHA1 Message Date
oan
5f55b8e615 0026074: BRepMesh_IncrementalMesh meshes a specific shape for a long time
Added test case
2019-07-10 18:59:28 +03:00
oan
057d4b15e3 0028089: Mesh - New algorithm for triangulation of 2d polygons
Added custom meshing core algorithm to generate base mesh using Delabella library:
https://github.com/msokalski/delabella

# Added CSF_MeshAlgo environment variable to select meshing core without necessity of recompilation
2019-07-10 13:04:25 +03:00
94 changed files with 2645 additions and 3844 deletions

View File

@@ -878,18 +878,7 @@ The test grid name is constructed depending on the type of the tested chamfers.
| dist_angle_complex | | Distance from edge and given angle |
| dist_angle_sequence | | Distance from edge and given angle |
@subsubsection testmanual_5_1_7 de
This group tests reading and writing of CAD data files (iges, step) to and from OCCT.
Test cases check transfer status, shape and attributes against expected reference values.
| Grid | Commands | Functionality |
| :---- | :----- | :------- |
| iges_1, iges_2, iges_3 | igesbrep, brepiges, ReadIges, WriteIges | IGES tests |
| step_1, step_2, step_3, step_4, step_5 | stepread, stepwrite, ReadStep, WriteStep | STEP tests |
@subsubsection testmanual_5_1_8 demo
@subsubsection testmanual_5_1_7 demo
This group allows demonstrating how testing cases are created, and testing DRAW commands and the test system as a whole.
@@ -900,7 +889,7 @@ This group allows demonstrating how testing cases are created, and testing DRAW
| samples | | OCCT samples |
@subsubsection testmanual_5_1_9 draft
@subsubsection testmanual_5_1_8 draft
This group allows testing draft operations.
@@ -911,7 +900,7 @@ DRAW module: MODELING.
| Angle | depouille | Drafts with angle (inclined walls) |
@subsubsection testmanual_5_1_10 feat
@subsubsection testmanual_5_1_9 feat
This group allows testing creation of features on a shape.
@@ -925,7 +914,7 @@ DRAW module: MODELING (package *BRepTest*).
| featrevol | | |
| featrf | | |
@subsubsection testmanual_5_1_11 heal
@subsubsection testmanual_5_1_10 heal
This group allows testing the functionality provided by *ShapeHealing* toolkit.
@@ -954,7 +943,7 @@ DRAW module: XSDRAW
| surface_to_revolution_standard | DT_ShapeConvertRev | Convert elementary surfaces to revolutions, simple cases |
| update_tolerance_locked | updatetolerance | Update the tolerance of shape so that it satisfy the rule: toler(face)<=toler(edge)<=toler(vertex) |
@subsubsection testmanual_5_1_12 mesh
@subsubsection testmanual_5_1_11 mesh
This group allows testing shape tessellation (*BRepMesh*) and shading.
@@ -971,7 +960,7 @@ DRAW modules: MODELING (package *MeshTest*), VISUALIZATION (package *ViewerTest*
| advanced_incmesh_parallel | incmesh | Meshing of complex shapes, parallel mode |
| standard_incmesh_parallel | incmesh | Meshing of simple shapes, parallel mode |
@subsubsection testmanual_5_1_13 mkface
@subsubsection testmanual_5_1_12 mkface
This group allows testing creation of simple surfaces.
@@ -986,7 +975,7 @@ DRAW module: MODELING (package *BRepTest*)
| after_revsurf_and_offset | mkface | |
| mkplane | mkplane | |
@subsubsection testmanual_5_1_14 nproject
@subsubsection testmanual_5_1_13 nproject
This group allows testing normal projection of edges and wires onto a face.
@@ -996,7 +985,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| Base | nproject | |
@subsubsection testmanual_5_1_15 offset
@subsubsection testmanual_5_1_14 offset
This group allows testing offset functionality for curves and surfaces.
@@ -1012,7 +1001,7 @@ DRAW module: MODELING (package *BRepTest*)
| shape | offsetshape | |
| wire_closed_outside_0_005, wire_closed_outside_0_025, wire_closed_outside_0_075, wire_closed_inside_0_005, wire_closed_inside_0_025, wire_closed_inside_0_075, wire_unclosed_outside_0_005, wire_unclosed_outside_0_025, wire_unclosed_outside_0_075 | mkoffset | 2d offset of closed and unclosed planar wires with different offset step and directions of offset ( inside / outside ) |
@subsubsection testmanual_5_1_16 pipe
@subsubsection testmanual_5_1_15 pipe
This group allows testing construction of pipes (sweeping of a contour along profile).
@@ -1022,7 +1011,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| Standard | pipe | |
@subsubsection testmanual_5_1_17 prism
@subsubsection testmanual_5_1_16 prism
This group allows testing construction of prisms.
@@ -1032,7 +1021,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| seminf | prism | |
@subsubsection testmanual_5_1_18 sewing
@subsubsection testmanual_5_1_17 sewing
This group allows testing sewing of faces by connecting edges.
@@ -1044,7 +1033,7 @@ DRAW module: MODELING (package *BRepTest*)
| tol_1 | sewing | Sewing faces with tolerance 1 |
| tol_100 | sewing | Sewing faces with tolerance 100 |
@subsubsection testmanual_5_1_19 thrusection
@subsubsection testmanual_5_1_18 thrusection
This group allows testing construction of shell or a solid passing through a set of sections in a given sequence (loft).
@@ -1053,7 +1042,7 @@ This group allows testing construction of shell or a solid passing through a set
| solids | thrusection | Lofting with resulting solid |
| not_solids | thrusection | Lofting with resulting shell or face |
@subsubsection testmanual_5_1_20 xcaf
@subsubsection testmanual_5_1_19 xcaf
This group allows testing extended data exchange packages.

View File

@@ -48,7 +48,7 @@ void AIS_AnimationCamera::update (const AIS_AnimationProgress& theProgress)
Handle(Graphic3d_Camera) aCamera = myView->Camera();
Graphic3d_CameraLerp aCamLerp (myCamStart, myCamEnd);
aCamLerp.Interpolate (HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
aCamLerp.Interpolate (theProgress.LocalNormalized, aCamera);
const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate (Standard_False);
myView->SetCamera (aCamera);

View File

@@ -33,9 +33,6 @@ public:
//! Return the target view.
const Handle(V3d_View)& View() const { return myView; }
//! Set target view.
void SetView (const Handle(V3d_View)& theView) { myView = theView; }
//! Return camera start position.
const Handle(Graphic3d_Camera)& CameraStart() const { return myCamStart; }

View File

@@ -187,29 +187,6 @@ AIS_InteractiveContext::~AIS_InteractiveContext()
}
}
//=======================================================================
//function : LastActiveView
//purpose :
//=======================================================================
Handle(V3d_View) AIS_InteractiveContext::LastActiveView() const
{
if (myLastActiveView == NULL
|| myMainVwr.IsNull())
{
return Handle(V3d_View)();
}
// as a precaution - check that myLastActiveView pointer is a valid active View
for (V3d_ListOfViewIterator aViewIter = myMainVwr->ActiveViewIterator(); aViewIter.More(); aViewIter.Next())
{
if (aViewIter.Value() == myLastActiveView)
{
return aViewIter.Value();
}
}
return Handle(V3d_View)();
}
//=======================================================================
//function : UpdateCurrentViewer
//purpose :
@@ -2470,10 +2447,12 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
}
//=======================================================================
//function : BoundingBoxOfSelection
//purpose :
//function : FitSelected
//purpose : Fits the view corresponding to the bounds of selected objects
//=======================================================================
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
const Standard_Real theMargin,
const Standard_Boolean theToUpdate)
{
Bnd_Box aBndSelected;
AIS_MapOfObjectOwners anObjectOwnerMap;
@@ -2512,22 +2491,12 @@ Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
aBndSelected.Add (aTmpBox);
}
return aBndSelected;
}
anObjectOwnerMap.Clear();
//=======================================================================
//function : FitSelected
//purpose : Fits the view corresponding to the bounds of selected objects
//=======================================================================
void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
const Standard_Real theMargin,
const Standard_Boolean theToUpdate)
{
Bnd_Box aBndSelected = BoundingBoxOfSelection();
if (!aBndSelected.IsVoid())
{
theView->FitAll (aBndSelected, theMargin, theToUpdate);
}
if (aBndSelected.IsVoid())
return;
theView->FitAll (aBndSelected, theMargin, theToUpdate);
}
//=======================================================================

View File

@@ -370,9 +370,6 @@ public: //! @name mouse picking logic (detection and dynamic highlighting of ent
const Standard_Integer theMode,
const Standard_Integer theNewSensitivity);
//! Returns last active View (argument of MoveTo()/Select() methods).
Standard_EXPORT Handle(V3d_View) LastActiveView() const;
//! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
//! This is done by the view theView passing this position to the main viewer and updating it.
//! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
@@ -508,9 +505,6 @@ public: //! @name Selection management
const Handle(V3d_View)& theView,
const Standard_Boolean theToUpdateViewer);
//! Returns bounding box of selected objects.
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
//! Fits the view correspondingly to the bounds of selected objects.
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
@@ -1385,7 +1379,6 @@ protected: //! @name internal fields
Handle(PrsMgr_PresentationManager3d) myMainPM;
Handle(V3d_Viewer) myMainVwr;
Handle(StdSelect_ViewerSelector3d) myMainSel;
V3d_View* myLastActiveView;
Handle(SelectMgr_EntityOwner) myLastPicked;
Standard_Boolean myToHilightSelected;
Handle(AIS_Selection) mySelection;

View File

@@ -325,7 +325,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
myCurDetected = 0;
myCurHighlighted = 0;
myDetectedSeq.Clear();
myLastActiveView = theView.get();
// preliminaires
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
@@ -496,7 +495,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
// all objects detected by the selector are taken, previous current objects are emptied,
// new objects are put...
ClearSelected (Standard_False);
myLastActiveView = theView.get();
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
@@ -536,7 +534,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
// all objects detected by the selector are taken, previous current objects are emptied,
// new objects are put...
ClearSelected (Standard_False);
myLastActiveView = theView.get();
myMainSel->Pick (thePolyline, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
@@ -568,17 +565,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate
{
if (!myLastPicked.IsNull())
{
Graphic3d_Vec2i aMousePos (-1, -1);
if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
{
aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
(Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
}
if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
{
return AIS_SOP_NothingSelected;
}
if (myAutoHilight)
{
clearDynamicHighlight();
@@ -644,7 +630,6 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
}
myLastActiveView = theView.get();
if (myAutoHilight)
{
UnhilightSelected (Standard_False);
@@ -685,7 +670,6 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
}
myLastActiveView = theView.get();
if (myAutoHilight)
{
UnhilightSelected (Standard_False);

View File

@@ -13,7 +13,6 @@
#include "AIS_ViewController.hxx"
#include <AIS_AnimationCamera.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Manipulator.hxx>
#include <AIS_Point.hxx>
@@ -48,15 +47,12 @@ AIS_ViewController::AIS_ViewController()
myToAllowZFocus (true),
myToAllowHighlight (true),
myToAllowDragging (true),
myToStickToRayOnZoom (true),
myToStickToRayOnRotation (true),
//
myWalkSpeedAbsolute (1.5f),
myWalkSpeedRelative (0.1f),
myThrustSpeed (0.0f),
myHasThrust (false),
//
myViewAnimation (new AIS_AnimationCamera ("AIS_ViewController_ViewAnimation", Handle(V3d_View)())),
myPrevMoveTo (-1, -1),
myHasHlrOnBeforeRotation (false),
//
@@ -1228,20 +1224,6 @@ AIS_WalkDelta AIS_ViewController::FetchNavigationKeys (Standard_Real theCrouchRa
return aWalk;
}
// =======================================================================
// function : AbortViewAnimation
// purpose :
// =======================================================================
void AIS_ViewController::AbortViewAnimation()
{
if (!myViewAnimation.IsNull()
&& !myViewAnimation->IsStopped())
{
myViewAnimation->Stop();
myViewAnimation->SetView (Handle(V3d_View)());
}
}
// =======================================================================
// function : handlePanning
// purpose :
@@ -1254,8 +1236,6 @@ void AIS_ViewController::handlePanning (const Handle(V3d_View)& theView)
return;
}
AbortViewAnimation();
const Handle(Graphic3d_Camera)& aCam = theView->Camera();
if (aCam->IsOrthographic()
|| !hasPanningAnchorPoint())
@@ -1296,8 +1276,6 @@ void AIS_ViewController::handleZRotate (const Handle(V3d_View)& theView)
return;
}
AbortViewAnimation();
Graphic3d_Vec2i aViewPort;
theView->Window()->Size (aViewPort.x(), aViewPort.y());
Graphic3d_Vec2d aRotPnt (0.99 * aViewPort.x(),
@@ -1321,8 +1299,6 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
return;
}
AbortViewAnimation();
const Handle(Graphic3d_Camera)& aCam = theView->Camera();
if (thePnt != NULL)
{
@@ -1395,9 +1371,9 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
Graphic3d_Vec2i aWinSize;
theView->Window()->Size (aWinSize.x(), aWinSize.y());
const Graphic3d_Vec2d aPanFromCenterPx (double(theParams.Point.x()) - 0.5 * double(aWinSize.x()),
double(aWinSize.y() - theParams.Point.y() - 1) - 0.5 * double(aWinSize.y()));
double(theParams.Point.y()) - 0.5 * double(aWinSize.y()));
aDxy.x() += -aViewDims1.X() * aPanFromCenterPx.x() / double(aWinSize.x());
aDxy.y() += -aViewDims1.Y() * aPanFromCenterPx.y() / double(aWinSize.y());
aDxy.y() += aViewDims1.X() * aPanFromCenterPx.y() / double(aWinSize.x());
}
//theView->Translate (aCam, aDxy.x(), aDxy.y());
@@ -1474,7 +1450,6 @@ void AIS_ViewController::handleOrbitRotation (const Handle(V3d_View)& theView,
return;
}
AbortViewAnimation();
if (theToLockZUp)
{
// amend camera to exclude roll angle (put camera Up vector to plane containing global Z and view direction)
@@ -1586,8 +1561,6 @@ void AIS_ViewController::handleViewRotation (const Handle(V3d_View)& theView,
return;
}
AbortViewAnimation();
Graphic3d_Vec2i aWinXY;
theView->Window()->Size (aWinXY.x(), aWinXY.y());
double aYawAngleDelta = ((myGL.ViewRotation.PointStart.x() - myGL.ViewRotation.PointTo.x()) / double (aWinXY.x())) * (M_PI * 0.5);
@@ -1663,7 +1636,7 @@ gp_Pnt AIS_ViewController::GravityPoint (const Handle(AIS_InteractiveContext)& t
}
gp_Pnt aPnt;
if (PickPoint (aPnt, theCtx, theView, aCursor, myToStickToRayOnRotation))
if (PickPoint (aPnt, theCtx, theView, aCursor, false))
{
return aPnt;
}
@@ -1884,9 +1857,12 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
if (!theView->Camera()->IsOrthographic())
{
// what is more natural to user - point on ray or point exactly on geometry in corner cases?
const bool toStickToRay = false; // true;
gp_Pnt aPnt;
if (aZoomParams.HasPoint()
&& PickPoint (aPnt, theCtx, theView, aZoomParams.Point, myToStickToRayOnZoom))
&& PickPoint (aPnt, theCtx, theView, aZoomParams.Point, toStickToRay))
{
handleZoom (theView, aZoomParams, &aPnt);
continue;
@@ -1894,7 +1870,7 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
Graphic3d_Vec2i aWinSize;
theView->Window()->Size (aWinSize.x(), aWinSize.y());
if (PickPoint (aPnt, theCtx, theView, aWinSize / 2, myToStickToRayOnZoom))
if (PickPoint (aPnt, theCtx, theView, aWinSize / 2, toStickToRay))
{
aZoomParams.ResetPoint(); // do not pretend to zoom at 'nothing'
handleZoom (theView, aZoomParams, &aPnt);
@@ -2059,6 +2035,11 @@ void AIS_ViewController::handleSelectionPick (const Handle(AIS_InteractiveContex
{
for (NCollection_Sequence<Graphic3d_Vec2i>::Iterator aPntIter (myGL.Selection.Points); aPntIter.More(); aPntIter.Next())
{
if (!myGL.Selection.IsXOR)
{
theCtx->ClearSelected (false);
}
const bool hadPrevMoveTo = HasPreviousMoveTo();
contextLazyMoveTo (theCtx, theView, aPntIter.Value());
if (!hadPrevMoveTo)
@@ -2293,15 +2274,6 @@ void AIS_ViewController::handleMoveTo (const Handle(AIS_InteractiveContext)& the
void AIS_ViewController::handleViewRedraw (const Handle(AIS_InteractiveContext)& ,
const Handle(V3d_View)& theView)
{
// manage animation state
if (!myViewAnimation.IsNull()
&& !myViewAnimation->IsStopped())
{
myViewAnimation->UpdateTimer();
ResetPreviousMoveTo();
setAskNextFrame();
}
for (V3d_ListOfViewIterator aViewIter (theView->Viewer()->ActiveViewIterator()); aViewIter.More(); aViewIter.Next())
{
const Handle(V3d_View)& aView = aViewIter.Value();

View File

@@ -30,7 +30,6 @@
#include <Precision.hxx>
#include <Standard_Mutex.hxx>
class AIS_AnimationCamera;
class AIS_InteractiveObject;
class AIS_InteractiveContext;
class AIS_Point;
@@ -57,15 +56,6 @@ public:
//! Return input buffer.
AIS_ViewInputBuffer& ChangeInputBuffer (AIS_ViewInputBufferType theType) { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }
//! Return view animation; empty (but not NULL) animation by default.
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
//! Set view animation to be handled within handleViewRedraw().
void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
//! Interrupt active view animation.
Standard_EXPORT void AbortViewAnimation();
public: //! @name global parameters
//! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default.
@@ -152,18 +142,6 @@ public: //! @name global parameters
//! Set if dynamic highlight on mouse move is allowed.
void SetAllowDragging (bool theToEnable) { myToAllowDragging = theToEnable; }
//! Return TRUE if picked point should be projected to picking ray on zooming at point; TRUE by default.
bool ToStickToRayOnZoom() const { return myToStickToRayOnZoom; }
//! Set if picked point should be projected to picking ray on zooming at point.
void SetStickToRayOnZoom (bool theToEnable) { myToStickToRayOnZoom = theToEnable; }
//! Return TRUE if picked point should be projected to picking ray on rotating around point; TRUE by default.
bool ToStickToRayOnRotation() const { return myToStickToRayOnRotation; }
//! Set if picked point should be projected to picking ray on rotating around point.
void SetStickToRayOnRotation (bool theToEnable) { myToStickToRayOnRotation = theToEnable; }
//! Return TRUE if pitch direction should be inverted while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown; FALSE by default.
bool ToInvertPitch() const { return myToInvertPitch; }
@@ -612,15 +590,12 @@ protected:
Standard_Boolean myToAllowZFocus; //!< enable ZFocus change; TRUE by default
Standard_Boolean myToAllowHighlight; //!< enable dynamic highlight on mouse move; TRUE by default
Standard_Boolean myToAllowDragging; //!< enable dragging object; TRUE by default
Standard_Boolean myToStickToRayOnZoom; //!< project picked point to ray while zooming at point, TRUE by default
Standard_Boolean myToStickToRayOnRotation; //!< project picked point to ray while rotating around point; TRUE by default
Standard_ShortReal myWalkSpeedAbsolute; //!< normal walking speed, in m/s; 1.5 by default
Standard_ShortReal myWalkSpeedRelative; //!< walking speed relative to scene bounding box; 0.1 by default
Standard_ShortReal myThrustSpeed; //!< active thrust value
Standard_Boolean myHasThrust; //!< flag indicating active thrust
Handle(AIS_AnimationCamera) myViewAnimation; //!< view animation
Handle(AIS_RubberBand) myRubberBand; //!< Rubber-band presentation
Handle(AIS_InteractiveObject) myDragObject; //!< currently dragged object
Graphic3d_Vec2i myPrevMoveTo; //!< previous position of MoveTo event in 3D viewer

View File

@@ -1,891 +0,0 @@
// Created on: 2017-07-25
// Created by: Anastasia BOBYLEVA
// Copyright (c) 2017-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_ViewCube.hxx>
#include <AIS_AnimationCamera.hxx>
#include <AIS_InteractiveContext.hxx>
#include <gp_Ax2.hxx>
#include <Graphic3d_ViewAffinity.hxx>
#include <NCollection_Lerp.hxx>
#include <Prs3d.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_Text.hxx>
#include <Prs3d_ToolDisk.hxx>
#include <Prs3d_ToolSphere.hxx>
#include <Select3D_SensitivePrimitiveArray.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
#include <V3d.hxx>
#include <V3d_View.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
IMPLEMENT_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
namespace
{
static const Standard_Integer THE_NB_ROUND_SPLITS = 8;
static const Standard_Integer THE_NB_DISK_SLICES = 20;
static const Standard_Integer THE_NB_ARROW_FACETTES = 20;
//! Return the number of non-zero components.
static Standard_Integer nbDirectionComponents (const gp_Dir& theDir)
{
Standard_Integer aNbComps = 0;
for (Standard_Integer aCompIter = 1; aCompIter <= 3; ++aCompIter)
{
if (Abs (theDir.Coord (aCompIter)) > gp::Resolution())
{
++aNbComps;
}
}
return aNbComps;
}
}
//! Simple sensitive element for picking by point only.
class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray
{
DEFINE_STANDARD_RTTI_INLINE(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
public:
//! Constructor.
AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(Graphic3d_ArrayOfTriangles)& theTris)
: Select3D_SensitivePrimitiveArray (theOwner)
{
InitTriangulation (theTris->Attributes(), theTris->Indices(), TopLoc_Location());
}
//! Checks whether element overlaps current selecting volume.
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
{
return isValidRay (theMgr)
&& Select3D_SensitivePrimitiveArray::Matches (theMgr, thePickResult);
}
//! Checks if picking ray can be used for detection.
bool isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const
{
if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
{
// disallow rectangular selection
return false;
}
if (AIS_ViewCubeOwner* anOwner = dynamic_cast<AIS_ViewCubeOwner* >(myOwnerId.get()))
{
const Standard_Real anAngleToler = 10.0 * M_PI / 180.0;
const gp_Vec aRay (theMgr.GetNearPickedPnt(), theMgr.GetFarPickedPnt());
const gp_Dir aDir = V3d::GetProjAxis (anOwner->MainOrientation());
return !aRay.IsNormal (aDir, anAngleToler);
}
return true;
}
};
//=======================================================================
//function : IsBoxSide
//purpose :
//=======================================================================
bool AIS_ViewCube::IsBoxSide (V3d_TypeOfOrientation theOrient)
{
return nbDirectionComponents (V3d::GetProjAxis (theOrient)) == 1;
}
//=======================================================================
//function : IsBoxEdge
//purpose :
//=======================================================================
bool AIS_ViewCube::IsBoxEdge (V3d_TypeOfOrientation theOrient)
{
return nbDirectionComponents (V3d::GetProjAxis (theOrient)) == 2;
}
//=======================================================================
//function : IsBoxCorner
//purpose :
//=======================================================================
bool AIS_ViewCube::IsBoxCorner (V3d_TypeOfOrientation theOrient)
{
return nbDirectionComponents (V3d::GetProjAxis (theOrient)) == 3;
}
//=======================================================================
//function : AIS_ViewCube
//purpose :
//=======================================================================
AIS_ViewCube::AIS_ViewCube()
: myBoxEdgeAspect (new Prs3d_ShadingAspect()),
myBoxCornerAspect (new Prs3d_ShadingAspect()),
mySize (1.0),
myBoxEdgeMinSize (2.0),
myBoxEdgeGap (0.0),
myBoxFacetExtension (1.0),
myAxesPadding (1.0),
myCornerMinSize (2.0),
myRoundRadius (0.0),
myToDisplayAxes (true),
myToDisplayEdges (true),
myToDisplayVertices (true),
myIsYup (false),
myViewAnimation (new AIS_AnimationCamera ("AIS_ViewCube", Handle(V3d_View)())),
myStartState(new Graphic3d_Camera()),
myEndState (new Graphic3d_Camera()),
myDuration (0.5),
myToAutoStartAnim (true),
myIsFixedAnimation (true),
myToFitSelected (true),
myToResetCameraUp (false)
{
myInfiniteState = true;
myIsMutable = true;
myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
myTransformPersistence = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100));
myDrawer->SetTextAspect (new Prs3d_TextAspect());
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
myDynHilightDrawer = new Prs3d_Drawer();
myDynHilightDrawer->SetLink (myDrawer);
myDynHilightDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
setDefaultAttributes();
setDefaultHighlightAttributes();
// setup default labels
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Front, "FRONT");
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Back, "BACK");
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Top, "TOP");
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Bottom, "BOTTOM");
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Left, "LEFT");
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Right, "RIGHT");
myAxesLabels.Bind (Prs3d_DP_XAxis, "X");
myAxesLabels.Bind (Prs3d_DP_YAxis, "Y");
myAxesLabels.Bind (Prs3d_DP_ZAxis, "Z");
// define default size
SetSize (70.0);
}
//=======================================================================
//function : setDefaultAttributes
//purpose :
//=======================================================================
void AIS_ViewCube::setDefaultAttributes()
{
myDrawer->TextAspect()->SetHorizontalJustification(Graphic3d_HTA_CENTER);
myDrawer->TextAspect()->SetVerticalJustification (Graphic3d_VTA_CENTER);
myDrawer->TextAspect()->SetColor (Quantity_NOC_BLACK);
myDrawer->TextAspect()->SetFont (Font_NOF_SANS_SERIF);
myDrawer->TextAspect()->SetHeight (16.0);
// this should be forced back-face culling regardless Closed flag
myDrawer->TextAspect()->Aspect()->SetSuppressBackFaces (true);
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_UserDefined);
aMat.SetColor (Quantity_NOC_WHITE);
aMat.SetAmbientColor (Quantity_NOC_GRAY60);
const Handle(Graphic3d_AspectFillArea3d)& aShading = myDrawer->ShadingAspect()->Aspect();
aShading->SetInteriorStyle (Aspect_IS_SOLID);
// this should be forced back-face culling regardless Closed flag
aShading->SetSuppressBackFaces (true);
aShading->SetInteriorColor (aMat.Color());
aShading->SetFrontMaterial (aMat);
myDrawer->SetFaceBoundaryDraw (false);
*myBoxEdgeAspect ->Aspect() = *aShading;
myBoxEdgeAspect->SetColor (Quantity_NOC_GRAY30);
*myBoxCornerAspect->Aspect() = *aShading;
myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
}
//=======================================================================
//function : setDefaultHighlightAttributes
//purpose :
//=======================================================================
void AIS_ViewCube::setDefaultHighlightAttributes()
{
Graphic3d_MaterialAspect aHighlightMaterial;
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
aHighlightMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
myDynHilightDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
myDynHilightDrawer->ShadingAspect()->SetMaterial (aHighlightMaterial);
myDynHilightDrawer->ShadingAspect()->SetColor (Quantity_NOC_CYAN1);
myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
}
//=======================================================================
//function : SetYup
//purpose :
//=======================================================================
void AIS_ViewCube::SetYup (Standard_Boolean theIsYup,
Standard_Boolean theToUpdateLabels)
{
if (myIsYup == theIsYup)
{
return;
}
myIsYup = theIsYup;
static const V3d_TypeOfOrientation THE_ZUP_ORI_LIST[6] =
{
V3d_TypeOfOrientation_Zup_Front, V3d_TypeOfOrientation_Zup_Back,
V3d_TypeOfOrientation_Zup_Top, V3d_TypeOfOrientation_Zup_Bottom,
V3d_TypeOfOrientation_Zup_Left, V3d_TypeOfOrientation_Zup_Right
};
static const V3d_TypeOfOrientation THE_YUP_ORI_LIST[6] =
{
V3d_TypeOfOrientation_Yup_Front, V3d_TypeOfOrientation_Yup_Back,
V3d_TypeOfOrientation_Yup_Top, V3d_TypeOfOrientation_Yup_Bottom,
V3d_TypeOfOrientation_Yup_Left, V3d_TypeOfOrientation_Yup_Right
};
if (theToUpdateLabels)
{
NCollection_Array1<TCollection_AsciiString> aLabels (0, 5);
for (Standard_Integer aLabelIter = 0; aLabelIter < 6; ++aLabelIter)
{
myBoxSideLabels.Find (!myIsYup ? THE_YUP_ORI_LIST[aLabelIter] : THE_ZUP_ORI_LIST[aLabelIter],
aLabels.ChangeValue (aLabelIter));
}
for (Standard_Integer aLabelIter = 0; aLabelIter < 6; ++aLabelIter)
{
myBoxSideLabels.Bind (myIsYup ? THE_YUP_ORI_LIST[aLabelIter] : THE_ZUP_ORI_LIST[aLabelIter],
aLabels.Value (aLabelIter));
}
}
SetToUpdate();
}
//=======================================================================
//function : ResetStyles
//purpose :
//=======================================================================
void AIS_ViewCube::ResetStyles()
{
UnsetAttributes();
UnsetHilightAttributes();
myBoxEdgeMinSize = 2.0;
myCornerMinSize = 2.0;
myBoxEdgeGap = 0.0;
myRoundRadius = 0.0;
myToDisplayAxes = true;
myToDisplayEdges = true;
myToDisplayVertices = true;
myBoxFacetExtension = 1.0;
myAxesPadding = 1.0;
SetSize (70.0);
}
//=======================================================================
//function : SetSize
//purpose :
//=======================================================================
void AIS_ViewCube::SetSize (Standard_Real theValue,
Standard_Boolean theToAdaptAnother)
{
const bool isNewSize = Abs (mySize - theValue) > Precision::Confusion();
mySize = theValue;
if (theToAdaptAnother)
{
if (myBoxFacetExtension > 0.0)
{
SetBoxFacetExtension (mySize * 0.15);
}
if (myAxesPadding > 0.0)
{
SetAxesPadding (mySize * 0.1);
}
SetFontHeight (mySize * 0.16);
}
if (isNewSize)
{
SetToUpdate();
}
}
//=======================================================================
//function : SetRoundRadius
//purpose :
//=======================================================================
void AIS_ViewCube::SetRoundRadius (const Standard_Real theValue)
{
Standard_OutOfRange_Raise_if (theValue < 0.0 || theValue > 0.5,
"AIS_ViewCube::SetRoundRadius(): theValue should be in [0; 0.5]");
if (Abs (myRoundRadius - theValue) > Precision::Confusion())
{
myRoundRadius = theValue;
SetToUpdate();
}
}
//=======================================================================
//function : createRoundRectangleTriangles
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createRoundRectangleTriangles (const gp_XY& theSize,
Standard_Real theRadius,
const gp_Trsf& theTrsf)
{
const Standard_Real aRadius = Min (theRadius, Min (theSize.X(), theSize.Y()) * 0.5);
const gp_XY aHSize (theSize.X() * 0.5 - aRadius, theSize.Y() * 0.5 - aRadius);
const gp_Dir aNorm = gp::DZ().Transformed (theTrsf);
Handle(Graphic3d_ArrayOfTriangles) aTris;
if (aRadius > 0.0)
{
const Standard_Integer aNbNodes = (THE_NB_ROUND_SPLITS + 1) * 4 + 1;
aTris = new Graphic3d_ArrayOfTriangles (aNbNodes, aNbNodes * 3, Graphic3d_ArrayFlags_VertexNormal);
aTris->AddVertex (gp_Pnt (0.0, 0.0, 0.0).Transformed (theTrsf));
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (M_PI * 0.5, 0.0, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
aTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
}
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (0.0, -M_PI * 0.5, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
aTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
}
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (-M_PI * 0.5, -M_PI, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
aTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
}
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (-M_PI, -M_PI * 1.5, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
aTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
}
// split triangle fan
for (Standard_Integer aNodeIter = 2; aNodeIter <= aTris->VertexNumber(); ++aNodeIter)
{
aTris->AddEdge (1);
aTris->AddEdge (aNodeIter - 1);
aTris->AddEdge (aNodeIter);
}
aTris->AddEdge (1);
aTris->AddEdge (aTris->VertexNumber());
aTris->AddEdge (2);
}
else
{
aTris = new Graphic3d_ArrayOfTriangles (4, 6, Graphic3d_ArrayFlags_VertexNormal);
aTris->AddVertex (gp_Pnt (-aHSize.X(), -aHSize.Y(), 0.0).Transformed (theTrsf));
aTris->AddVertex (gp_Pnt (-aHSize.X(), aHSize.Y(), 0.0).Transformed (theTrsf));
aTris->AddVertex (gp_Pnt ( aHSize.X(), aHSize.Y(), 0.0).Transformed (theTrsf));
aTris->AddVertex (gp_Pnt ( aHSize.X(), -aHSize.Y(), 0.0).Transformed (theTrsf));
aTris->AddEdges (3, 1, 2);
aTris->AddEdges (1, 3, 4);
}
for (Standard_Integer aVertIter = 1; aVertIter <= aTris->VertexNumber(); ++aVertIter)
{
aTris->SetVertexNormal (aVertIter, -aNorm);
}
return aTris;
}
//=======================================================================
//function : createBoxPartTriangles
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxPartTriangles (V3d_TypeOfOrientation theDir) const
{
if (IsBoxSide (theDir))
{
return createBoxSideTriangles (theDir);
}
else if (IsBoxEdge (theDir)
&& myToDisplayEdges)
{
return createBoxEdgeTriangles (theDir);
}
else if (IsBoxCorner (theDir)
&& myToDisplayVertices)
{
return createBoxCornerTriangles (theDir);
}
return Handle(Graphic3d_ArrayOfTriangles)();
}
//=======================================================================
//function : createBoxSideTriangles
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxSideTriangles (V3d_TypeOfOrientation theDirection) const
{
const gp_Dir aDir = V3d::GetProjAxis (theDirection);
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 + myBoxFacetExtension);
const gp_Ax2 aPosition (aPos, aDir.Reversed());
gp_Ax3 aSystem (aPosition);
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
return createRoundRectangleTriangles (gp_XY (mySize, mySize), myRoundRadius * mySize, aTrsf);
}
//=======================================================================
//function : createBoxEdgeTriangles
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxEdgeTriangles (V3d_TypeOfOrientation theDirection) const
{
const Standard_Real aThickness = Max (myBoxFacetExtension * gp_XY (1.0, 1.0).Modulus() - myBoxEdgeGap, myBoxEdgeMinSize);
const gp_Dir aDir = V3d::GetProjAxis (theDirection);
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 * gp_XY (1.0, 1.0).Modulus() + myBoxFacetExtension * Cos (M_PI_4));
const gp_Ax2 aPosition (aPos, aDir.Reversed());
gp_Ax3 aSystem (aPosition);
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
return createRoundRectangleTriangles (gp_XY (aThickness, mySize), myRoundRadius * mySize, aTrsf);
}
//=======================================================================
//function : createBoxCornerTriangles
//purpose :
//=======================================================================
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxCornerTriangles (V3d_TypeOfOrientation theDir) const
{
const Standard_Real aHSize = mySize * 0.5;
const gp_Dir aDir = V3d::GetProjAxis (theDir);
const gp_XYZ aHSizeDir = aDir.XYZ() * (aHSize * gp_Vec (1.0, 1.0, 1.0).Magnitude());
if (myRoundRadius > 0.0)
{
const Standard_Real anEdgeHWidth = myBoxFacetExtension * gp_XY (1.0, 1.0).Modulus() * 0.5;
const Standard_Real aHeight = anEdgeHWidth * Sqrt (2.0 / 3.0); // tetrahedron height
const gp_Pnt aPos = aDir.XYZ() * (aHSize * gp_Vec (1.0, 1.0, 1.0).Magnitude() + aHeight);
const gp_Ax2 aPosition (aPos, aDir.Reversed());
gp_Ax3 aSystem (aPosition);
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
const Standard_Real aRadius = Max (myBoxFacetExtension * 0.5 / Cos (M_PI_4), myCornerMinSize);
return Prs3d_ToolDisk::Create (0.0, aRadius, THE_NB_DISK_SLICES, 1, aTrsf);
}
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (3, 3, Graphic3d_ArrayFlags_VertexNormal);
aTris->AddVertex (aHSizeDir + myBoxFacetExtension * gp_Dir (aDir.X(), 0.0, 0.0).XYZ());
aTris->AddVertex (aHSizeDir + myBoxFacetExtension * gp_Dir (0.0, aDir.Y(), 0.0).XYZ());
aTris->AddVertex (aHSizeDir + myBoxFacetExtension * gp_Dir (0.0, 0.0, aDir.Z()).XYZ());
const gp_XYZ aNode1 = aTris->Vertice (1).XYZ();
const gp_XYZ aNode2 = aTris->Vertice (2).XYZ();
const gp_XYZ aNode3 = aTris->Vertice (3).XYZ();
const gp_XYZ aNormTri = ((aNode2 - aNode1).Crossed (aNode3 - aNode1));
if (aNormTri.Dot (aDir.XYZ()) < 0.0)
{
aTris->AddEdges (1, 3, 2);
}
else
{
aTris->AddEdges (1, 2, 3);
}
for (Standard_Integer aVertIter = 1; aVertIter <= aTris->VertexNumber(); ++aVertIter)
{
aTris->SetVertexNormal (aVertIter, aDir);
}
return aTris;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
thePrs->SetInfiniteState (true);
if (theMode != 0)
{
return;
}
const gp_Pnt aLocation = (mySize * 0.5 + myBoxFacetExtension + myAxesPadding) * gp_XYZ (-1.0, -1.0, -1.0);
// Display axes
if (myToDisplayAxes)
{
const Standard_Real anAxisSize = mySize + 2.0 * myBoxFacetExtension + myAxesPadding;
const Handle(Prs3d_DatumAspect)& aDatumAspect = myDrawer->DatumAspect();
for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis; ++anAxisIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts )anAxisIter;
if (!aDatumAspect->DrawDatumPart (aPart))
{
continue;
}
gp_Ax1 anAx1;
switch (aPart)
{
case Prs3d_DP_XAxis: anAx1 = gp_Ax1 (aLocation, gp::DX()); break;
case Prs3d_DP_YAxis: anAx1 = gp_Ax1 (aLocation, gp::DY()); break;
case Prs3d_DP_ZAxis: anAx1 = gp_Ax1 (aLocation, gp::DZ()); break;
default: break;
}
Handle(Graphic3d_Group) anAxisGroup = thePrs->NewGroup();
anAxisGroup->SetGroupPrimitivesAspect (aDatumAspect->ShadingAspect (aPart)->Aspect());
const Standard_Real anArrowLength = 0.2 * anAxisSize;
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray = Prs3d_Arrow::DrawShaded (anAx1, 1.0, anAxisSize, 3.0, anArrowLength, THE_NB_ARROW_FACETTES);
anAxisGroup->AddPrimitiveArray (aTriangleArray);
TCollection_AsciiString anAxisLabel;
if (aDatumAspect->ToDrawLabels()
&& myAxesLabels.Find (aPart, anAxisLabel)
&& !anAxisLabel.IsEmpty())
{
Handle(Graphic3d_Group) anAxisLabelGroup = thePrs->NewGroup();
gp_Pnt aTextOrigin = anAx1.Location().Translated (gp_Vec (anAx1.Direction().X() * (anAxisSize + anArrowLength),
anAx1.Direction().Y() * (anAxisSize + anArrowLength),
anAx1.Direction().Z() * (anAxisSize + anArrowLength)));
Prs3d_Text::Draw (anAxisLabelGroup, aDatumAspect->TextAspect(), TCollection_ExtendedString (anAxisLabel), aTextOrigin);
}
}
// Display center
{
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
Handle(Prs3d_ShadingAspect) anAspectCen = new Prs3d_ShadingAspect();
anAspectCen->SetColor (Quantity_NOC_WHITE);
aGroup->SetGroupPrimitivesAspect (anAspectCen->Aspect());
Prs3d_ToolSphere aTool (4.0, THE_NB_DISK_SLICES, THE_NB_DISK_SLICES);
gp_Trsf aTrsf;
aTrsf.SetTranslation (gp_Vec (gp::Origin(), aLocation));
Handle(Graphic3d_ArrayOfTriangles) aCenterArray;
aTool.FillArray (aCenterArray, aTrsf);
aGroup->AddPrimitiveArray (aCenterArray);
}
}
// Display box
{
Handle(Graphic3d_Group) aGroupSides = thePrs->NewGroup(), aGroupEdges = thePrs->NewGroup(), aGroupCorners = thePrs->NewGroup();
aGroupSides->SetClosed (true); // should be replaced by forced back-face culling aspect
aGroupSides->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroupEdges->SetClosed (true);
aGroupEdges->SetGroupPrimitivesAspect (myBoxEdgeAspect->Aspect());
aGroupCorners->SetClosed (true);
aGroupCorners->SetGroupPrimitivesAspect (myBoxCornerAspect->Aspect());
Handle(Graphic3d_Group) aTextGroup = thePrs->NewGroup();
//aTextGroup->SetClosed (true);
aTextGroup->SetGroupPrimitivesAspect (myDrawer->TextAspect()->Aspect());
for (Standard_Integer aPartIter = 0; aPartIter <= Standard_Integer(V3d_XnegYnegZneg); ++aPartIter)
{
const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation )aPartIter;
if (Handle(Graphic3d_ArrayOfTriangles) aTris = createBoxPartTriangles (anOrient))
{
if (IsBoxSide (anOrient))
{
aGroupSides->AddPrimitiveArray (aTris);
TCollection_AsciiString aLabel;
if (!myBoxSideLabels.Find (anOrient, aLabel)
|| aLabel.IsEmpty())
{
continue;
}
const gp_Dir aDir = V3d::GetProjAxis (anOrient);
gp_Dir anUp = myIsYup ? gp::DY() : gp::DZ();
if (myIsYup)
{
if (anOrient == V3d_Ypos
|| anOrient == V3d_Yneg)
{
anUp = -gp::DZ();
}
}
else
{
if (anOrient == V3d_Zpos)
{
anUp = gp::DY();
}
else if (anOrient == V3d_Zneg)
{
anUp = -gp::DY();
}
}
const Standard_Real anOffset = 2.0; // extra offset to avoid overlapping with triangulation
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 + myBoxFacetExtension + anOffset);
const gp_Ax2 aPosition (aPos, aDir, anUp.Crossed (aDir));
Prs3d_Text::Draw (aTextGroup, myDrawer->TextAspect(), aLabel, aPosition);
}
else if (IsBoxEdge (anOrient))
{
aGroupEdges->AddPrimitiveArray (aTris);
}
else if (IsBoxCorner (anOrient))
{
aGroupCorners->AddPrimitiveArray (aTris);
}
}
}
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_ViewCube::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
if (theMode != 0)
{
return;
}
for (Standard_Integer aPartIter = 0; aPartIter <= Standard_Integer(V3d_XnegYnegZneg); ++aPartIter)
{
const V3d_TypeOfOrientation anOri = (V3d_TypeOfOrientation )aPartIter;
if (Handle(Graphic3d_ArrayOfTriangles) aTris = createBoxPartTriangles (anOri))
{
Standard_Integer aSensitivity = 2;
if (IsBoxCorner (anOri))
{
aSensitivity = 8;
}
else if (IsBoxEdge (anOri))
{
aSensitivity = 4;
}
Handle(AIS_ViewCubeOwner) anOwner = new AIS_ViewCubeOwner (this, anOri);
Handle(AIS_ViewCubeSensitive) aTriSens = new AIS_ViewCubeSensitive (anOwner, aTris);
aTriSens->SetSensitivityFactor (aSensitivity);
theSelection->Add (aTriSens);
}
}
}
//=======================================================================
//function : HasAnimation
//purpose :
//=======================================================================
Standard_Boolean AIS_ViewCube::HasAnimation() const
{
return !myViewAnimation->IsStopped();
}
//=======================================================================
//function : StartAnimation
//purpose :
//=======================================================================
void AIS_ViewCube::StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner)
{
Handle(V3d_View) aView = GetContext()->LastActiveView();
if (theOwner.IsNull()
|| aView.IsNull())
{
return;
}
myStartState->Copy (aView->Camera());
myEndState ->Copy (aView->Camera());
{
Handle(Graphic3d_Camera) aBackupCamera = new Graphic3d_Camera (aView->Camera());
const bool wasImmediateUpdate = aView->SetImmediateUpdate (false);
aView->SetCamera (myEndState);
aView->SetProj (theOwner->MainOrientation(), myIsYup);
const gp_Dir aNewDir = aView->Camera()->Direction();
if (!myToResetCameraUp
&& !aNewDir.IsEqual (aBackupCamera->Direction(), Precision::Angular()))
{
// find the Up direction closest to current instead of default one
const gp_Ax1 aNewDirAx1 (gp::Origin(), aNewDir);
const gp_Dir anOldUp = aBackupCamera->Up();
const gp_Dir anUpList[4] =
{
aView->Camera()->Up(),
aView->Camera()->Up().Rotated (aNewDirAx1, M_PI_2),
aView->Camera()->Up().Rotated (aNewDirAx1, M_PI),
aView->Camera()->Up().Rotated (aNewDirAx1, M_PI * 1.5),
};
Standard_Real aBestAngle = Precision::Infinite();
gp_Dir anUpBest;
for (Standard_Integer anUpIter = 0; anUpIter < 4; ++anUpIter)
{
Standard_Real anAngle = anUpList[anUpIter].Angle (anOldUp);
if (aBestAngle > anAngle)
{
aBestAngle = anAngle;
anUpBest = anUpList[anUpIter];
}
}
aView->Camera()->SetUp (anUpBest);
}
const Bnd_Box aBndSelected = myToFitSelected ? GetContext()->BoundingBoxOfSelection() : Bnd_Box();
if (!aBndSelected.IsVoid())
{
aView->FitAll (aBndSelected, 0.01, false);
}
else
{
aView->FitAll (0.01, false);
}
aView->SetCamera (aBackupCamera);
aView->SetImmediateUpdate (wasImmediateUpdate);
}
myViewAnimation->SetView (aView);
myViewAnimation->SetCameraStart (myStartState);
myViewAnimation->SetCameraEnd (myEndState);
myViewAnimation->SetOwnDuration (myDuration);
myViewAnimation->StartTimer (0.0, 1.0, true, false);
}
//=======================================================================
//function : updateAnimation
//purpose :
//=======================================================================
Standard_Boolean AIS_ViewCube::updateAnimation()
{
const Standard_Real aPts = myViewAnimation->UpdateTimer();
if (aPts >= myDuration)
{
myViewAnimation->Stop();
onAnimationFinished();
myViewAnimation->SetView (Handle(V3d_View)());
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : UpdateAnimation
//purpose :
//=======================================================================
Standard_Boolean AIS_ViewCube::UpdateAnimation (const Standard_Boolean theToUpdate)
{
Handle(V3d_View) aView = myViewAnimation->View();
if (!HasAnimation()
|| !updateAnimation())
{
return Standard_False;
}
if (theToUpdate
&& !aView.IsNull())
{
aView->IsInvalidated() ? aView->Redraw() : aView->RedrawImmediate();
}
onAfterAnimation();
return Standard_True;
}
//=======================================================================
//function : HandleClick
//purpose :
//=======================================================================
void AIS_ViewCube::HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner)
{
if (!myToAutoStartAnim)
{
return;
}
StartAnimation (theOwner);
if (!myIsFixedAnimation)
{
return;
}
for (; HasAnimation(); )
{
UpdateAnimation (true);
}
}
//=======================================================================
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner)
{
if (theOwner.IsNull()
|| !thePrsMgr->IsImmediateModeOn())
{
return;
}
const Graphic3d_ZLayerId aLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer();
const AIS_ViewCubeOwner* aCubeOwner = dynamic_cast<AIS_ViewCubeOwner* >(theOwner.get());
Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation (thePrsMgr);
aHiPrs->Clear();
aHiPrs->CStructure()->ViewAffinity = thePrsMgr->StructureManager()->ObjectAffinity (Handle(Standard_Transient)(this));
aHiPrs->SetTransformPersistence (TransformPersistence());
aHiPrs->SetZLayer (aLayer);
{
Handle(Graphic3d_Group) aGroup = aHiPrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (theStyle->ShadingAspect()->Aspect());
if (Handle(Graphic3d_ArrayOfTriangles) aTris = createBoxPartTriangles (aCubeOwner->MainOrientation()))
{
aGroup->AddPrimitiveArray (aTris);
}
}
if (thePrsMgr->IsImmediateModeOn())
{
thePrsMgr->AddToImmediateList (aHiPrs);
}
}
//=======================================================================
//function : HilightSelected
//purpose :
//=======================================================================
void AIS_ViewCube::HilightSelected (const Handle(PrsMgr_PresentationManager3d)& ,
const SelectMgr_SequenceOfOwner& theSeq)
{
// this method should never be called since AIS_InteractiveObject::HandleClick() has been overridden
if (theSeq.Size() == 1)
{
//HandleClick (Handle(AIS_ViewCubeOwner)::DownCast (theSeq.First()));
}
}

View File

@@ -1,645 +0,0 @@
// Created on: 2017-07-25
// Created by: Anastasia BOBYLEVA
// Copyright (c) 2017-2019 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 _AIS_ViewCube_HeaderFile
#define _AIS_ViewCube_HeaderFile
#include <AIS_InteractiveObject.hxx>
#include <Graphic3d_Camera.hxx>
#include <Graphic3d_Vec2.hxx>
#include <Prs3d_DatumParts.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <V3d_TypeOfOrientation.hxx>
class AIS_AnimationCamera;
class AIS_ViewCubeOwner;
class Graphic3d_ArrayOfTriangles;
//! Interactive object for displaying the view manipulation cube.
//!
//! View cube consists of several parts that are responsible for different camera manipulations:
//! @li Cube sides represent main views: top, bottom, left, right, front and back.
//! @li Edges represent rotation of one of main views on 45 degrees.
//! @li Vertices represent rotation of one of man views in two directions.
//!
//! The object is expected to behave like a trihedron in the view corner,
//! therefore its position should be defined using transformation persistence flags:
//! @code SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100)); @endcode
//!
//! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection),
//! and every its owner AIS_ViewCubeOwner corresponds to camera transformation.
//! @code
//! for (aViewCube->StartAnimation (aDetectedOwner); aViewCube->HasAnimation(); )
//! {
//! aViewCube->UpdateAnimation();
//! ... // updating of application window
//! }
//! @endcode
//! or
//! @code aViewCube->HandleClick (aDetectedOwner); @endcode
//! that includes transformation loop.
//! This loop allows external actions like application updating. For this purpose AIS_ViewCube has virtual interface onAfterAnimation(),
//! that is to be redefined on application level.
class AIS_ViewCube : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
public:
//! Return TRUE if specified orientation belongs to box side.
Standard_EXPORT static bool IsBoxSide (V3d_TypeOfOrientation theOrient);
//! Return TRUE if specified orientation belongs to box edge.
Standard_EXPORT static bool IsBoxEdge (V3d_TypeOfOrientation theOrient);
//! Return TRUE if specified orientation belongs to box corner (vertex).
Standard_EXPORT static bool IsBoxCorner (V3d_TypeOfOrientation theOrient);
public:
//! Empty constructor.
Standard_EXPORT AIS_ViewCube();
//! Return view animation.
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
//! Set view animation.
void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
//! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by default.
Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
//! Enable/disable automatic camera transformation on selection (highlighting).
//! The automatic logic can be disabled if application wants performing action manually
//! basing on picking results (AIS_ViewCubeOwner).
void SetAutoStartAnimation (bool theToEnable) { myToAutoStartAnim = theToEnable; }
//! Return TRUE if camera animation should be done in uninterruptible loop; TRUE by default.
Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
//! Set if camera animation should be done in uninterruptible loop.
void SetFixedAnimationLoop (bool theToEnable) { myIsFixedAnimation = theToEnable; }
//! Reset all size and style parameters to default.
//! @warning It doesn't reset position of View Cube
Standard_EXPORT void ResetStyles();
protected:
//! Set default visual attributes
Standard_EXPORT void setDefaultAttributes();
//! Set default dynamic highlight properties
Standard_EXPORT void setDefaultHighlightAttributes();
public: //! @name Geometry management API
//! @return size (width and height) of View cube sides; 100 by default.
Standard_Real Size() const { return mySize; }
//! Sets size (width and height) of View cube sides.
//! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size
Standard_EXPORT void SetSize (Standard_Real theValue,
Standard_Boolean theToAdaptAnother = true);
//! Return box facet extension to edge/corner facet split; 10 by default.
Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
//! Set new value of box facet extension.
void SetBoxFacetExtension (Standard_Real theValue)
{
if (Abs (myBoxFacetExtension - theValue) > Precision::Confusion())
{
myBoxFacetExtension = theValue;
SetToUpdate();
}
}
//! Return padding between axes and 3D part (box); 10 by default.
Standard_Real AxesPadding() const { return myAxesPadding; }
//! Set new value of padding between axes and 3D part (box).
void SetAxesPadding (Standard_Real theValue)
{
if (Abs (myAxesPadding - theValue) > Precision::Confusion())
{
myAxesPadding = theValue;
SetToUpdate();
}
}
//! Return gap between box edges and box sides; 0 by default.
Standard_Real BoxEdgeGap() const { return myBoxEdgeGap; }
//! Set new value of box edges gap.
void SetBoxEdgeGap (Standard_Real theValue)
{
if (Abs (myBoxEdgeGap - theValue) > Precision::Confusion())
{
myBoxEdgeGap = theValue;
SetToUpdate();
}
}
//! Return minimal size of box edge; 2 by default.
Standard_Real BoxEdgeMinSize() const { return myBoxEdgeMinSize; }
//! Set new value of box edge minimal size.
void SetBoxEdgeMinSize (Standard_Real theValue)
{
if (Abs (myBoxEdgeMinSize - theValue) > Precision::Confusion())
{
myBoxEdgeMinSize = theValue;
SetToUpdate();
}
}
//! Return minimal size of box corner; 2 by default.
Standard_Real BoxCornerMinSize() const { return myCornerMinSize; }
//! Set new value of box corner minimal size.
void SetBoxCornerMinSize (Standard_Real theValue)
{
if (Abs (myCornerMinSize - theValue) > Precision::Confusion())
{
myCornerMinSize = theValue;
SetToUpdate();
}
}
//! Return relative radius of side corners (round rectangle); 0.0 by default.
//! The value in within [0, 0.5] range meaning absolute radius = RoundRadius() / Size().
Standard_Real RoundRadius() const { return myRoundRadius; }
//! Set relative radius of View Cube sides corners (round rectangle).
//! The value should be within [0, 0.5] range.
Standard_EXPORT void SetRoundRadius (const Standard_Real theValue);
//! @return TRUE if trihedron is drawn; TRUE by default.
Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
//! Enable/disable drawing of trihedron.
void SetDrawAxes (Standard_Boolean theValue)
{
if (myToDisplayAxes != theValue)
{
myToDisplayAxes = theValue;
SetToUpdate();
}
}
//! @return TRUE if edges of View Cube is drawn; TRUE by default.
Standard_Boolean ToDrawEdges() const { return myToDisplayEdges; }
//! Enable/disable drawing of edges of View Cube.
void SetDrawEdges (Standard_Boolean theValue)
{
if (myToDisplayEdges != theValue)
{
myToDisplayEdges = theValue;
SetToUpdate();
}
}
//! Return TRUE if vertices (vertex) of View Cube is drawn; TRUE by default.
Standard_Boolean ToDrawVertices() const { return myToDisplayVertices; }
//! Enable/disable drawing of vertices (corners) of View Cube.
void SetDrawVertices (Standard_Boolean theValue)
{
if (myToDisplayVertices != theValue)
{
myToDisplayVertices = theValue;
SetToUpdate();
}
}
//! Return TRUE if application expects Y-up viewer orientation instead of Z-up; FALSE by default.
Standard_Boolean IsYup() const { return myIsYup; }
//! Set if application expects Y-up viewer orientation instead of Z-up.
Standard_EXPORT void SetYup (Standard_Boolean theIsYup,
Standard_Boolean theToUpdateLabels = Standard_True);
public: //! @name Style management API
//! Return shading style of box sides.
const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
//! Return shading style of box edges.
const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
//! Return shading style of box corners.
const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
//! Return value of front color for the 3D part of object.
const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
//! Set new value of front color for the 3D part of object.
//! @param theColor [in] input color value.
void SetBoxColor (const Quantity_Color& theColor)
{
if (!myDrawer->ShadingAspect()->Color().IsEqual (theColor)
|| !myBoxEdgeAspect ->Color().IsEqual (theColor)
|| !myBoxCornerAspect->Color().IsEqual (theColor))
{
myDrawer->ShadingAspect()->SetColor (theColor);
myBoxEdgeAspect->SetColor (theColor);
myBoxCornerAspect->SetColor (theColor);
SynchronizeAspects();
}
}
//! Return transparency for 3D part of object.
Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
//! Set new value of transparency for 3D part of object.
//! @param theValue [in] input transparency value
void SetBoxTransparency (Standard_Real theValue)
{
if (Abs (myDrawer->ShadingAspect()->Transparency() - theValue) > Precision::Confusion()
|| Abs (myBoxEdgeAspect ->Transparency() - theValue) > Precision::Confusion()
|| Abs (myBoxCornerAspect->Transparency() - theValue) > Precision::Confusion())
{
myDrawer->ShadingAspect()->SetTransparency (theValue);
myBoxEdgeAspect->SetTransparency (theValue);
myBoxCornerAspect->SetTransparency (theValue);
SynchronizeAspects();
}
}
//! Return color of sides back material.
const Quantity_Color& InnerColor() const { return myDrawer->ShadingAspect()->Color (Aspect_TOFM_BACK_SIDE); }
//! Set color of sides back material. Alias for:
//! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
void SetInnerColor (const Quantity_Color& theColor)
{
myDrawer->ShadingAspect()->SetColor (theColor, Aspect_TOFM_BACK_SIDE);
SynchronizeAspects();
}
//! Return box side label or empty string if undefined.
//! Default labels: FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM.
TCollection_AsciiString BoxSideLabel (V3d_TypeOfOrientation theSide) const
{
const TCollection_AsciiString* aLabel = myBoxSideLabels.Seek (theSide);
return aLabel != NULL ? *aLabel : TCollection_AsciiString();
}
//! Set box side label.
void SetBoxSideLabel (const V3d_TypeOfOrientation theSide,
const TCollection_AsciiString& theLabel)
{
if (!IsBoxSide (theSide))
{
throw Standard_ProgramError ("AIS_ViewCube::SetBoxSideLabel(), invalid enumeration value");
}
myBoxSideLabels.Bind (theSide, theLabel);
SetToUpdate();
}
//! Return text color of labels of box sides; BLACK by default.
const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
//! Set color of text labels on box sides. Alias for:
//! @code Attributes()->TextAspect()->SetColor() @endcode
void SetTextColor (const Quantity_Color& theColor)
{
myDrawer->TextAspect()->SetColor (theColor);
SynchronizeAspects();
}
//! Return font name that is used for displaying of sides and axes text. Alias for:
//! @code Attributes()->TextAspect()->Aspect()->SetFont() @endcode
const TCollection_AsciiString& Font() const { return myDrawer->TextAspect()->Aspect()->Font(); }
//! Set font name that is used for displaying of sides and axes text. Alias for:
//! @code Attributes()->TextAspect()->SetFont() @endcode
void SetFont (const TCollection_AsciiString& theFont)
{
myDrawer->TextAspect()->Aspect()->SetFont (theFont);
SynchronizeAspects();
}
//! Return height of font
Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
//! Change font height. Alias for:
//! @code Attributes()->TextAspect()->SetHeight() @endcode
void SetFontHeight (Standard_Real theValue)
{
if (Abs (myDrawer->TextAspect()->Height() - theValue) > Precision::Confusion())
{
myDrawer->TextAspect()->SetHeight (theValue);
SetToUpdate();
}
}
//! Return axes labels or empty string if undefined.
//! Default labels: X, Y, Z.
TCollection_AsciiString AxisLabel (Prs3d_DatumParts theAxis) const
{
const TCollection_AsciiString* aLabel = myAxesLabels.Seek (theAxis);
return aLabel != NULL ? *aLabel : TCollection_AsciiString();
}
//! Set axes labels.
void SetAxesLabels (const TCollection_AsciiString& theX,
const TCollection_AsciiString& theY,
const TCollection_AsciiString& theZ)
{
myAxesLabels.Bind (Prs3d_DP_XAxis, theX);
myAxesLabels.Bind (Prs3d_DP_YAxis, theY);
myAxesLabels.Bind (Prs3d_DP_ZAxis, theZ);
SetToUpdate();
}
public:
//! Set new value of color for the whole object.
//! @param theColor [in] input color value.
virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE
{
SetBoxColor (theColor);
}
//! Reset color for the whole object.
virtual void UnsetColor() Standard_OVERRIDE
{
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
SynchronizeAspects();
}
//! Set new value of transparency for the whole object.
//! @param theValue [in] input transparency value.
virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE
{
SetBoxTransparency (theValue);
}
//! Reset transparency for the whole object.
virtual void UnsetTransparency() Standard_OVERRIDE
{
SetBoxTransparency (0.0f);
}
//! Sets the material for the interactive object.
virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
{
myDrawer->ShadingAspect()->SetMaterial (theMat);
myBoxEdgeAspect ->SetMaterial (theMat);
myBoxCornerAspect->SetMaterial (theMat);
SynchronizeAspects();
}
//! Sets the material for the interactive object.
virtual void UnsetMaterial() Standard_OVERRIDE
{
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_UserDefined);
aMat.SetColor (Quantity_NOC_WHITE);
aMat.SetAmbientColor (Quantity_NOC_GRAY60);
myDrawer->ShadingAspect()->SetMaterial (aMat);
myBoxEdgeAspect ->SetMaterial (aMat);
myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
myBoxCornerAspect->SetMaterial (aMat);
myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
SynchronizeAspects();
}
public: //! @name animation methods
//! Return duration of animation in seconds; 0.5 sec by default
Standard_Real Duration() const { return myDuration; }
//! Set duration of animation.
//! @param theValue [in] input value of duration in seconds
void SetDuration (Standard_Real theValue) { myDuration = theValue; }
//! Return TRUE if new camera Up direction should be always set to default value for a new camera Direction; FALSE by default.
//! When this flag is FALSE, the new camera Up will be set as current Up orthogonalized to the new camera Direction,
//! and will set to default Up on second click.
Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
//! Set if new camera Up direction should be always set to default value for a new camera Direction.
void SetResetCamera (Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
//! Return TRUE if animation should fit selected objects and FALSE to fit entire scene; TRUE by default.
Standard_Boolean ToFitSelected() const { return myToFitSelected; }
//! Set if animation should fit selected objects or to fit entire scene.
void SetFitSelected (Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
//! @return TRUE if View Cube has unfinished animation of view camera.
Standard_EXPORT Standard_Boolean HasAnimation() const;
//! Start camera transformation corresponding to the input detected owner.
//! @param theOwner [in] detected owner.
Standard_EXPORT virtual void StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner);
//! Perform one step of current camera transformation.
//! theToUpdate [in] enable/disable update of view.
//! @return TRUE if animation is not stopped.
Standard_EXPORT virtual Standard_Boolean UpdateAnimation (const Standard_Boolean theToUpdate);
//! Perform camera transformation corresponding to the input detected owner.
Standard_EXPORT virtual void HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner);
protected:
//! Perform internal single step of animation.
//! @return FALSE if animation has been finished
Standard_EXPORT Standard_Boolean updateAnimation();
protected: //! @name protected virtual API
//! Method that is called after one step of transformation.
virtual void onAfterAnimation() {}
//! Method that is called after transformation finish.
virtual void onAnimationFinished() {}
public: //! @name Presentation computation
//! Return TRUE for supported display mode.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
//! Global selection has no meaning for this class.
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return Handle(SelectMgr_EntityOwner)(); }
//! Compute 3D part of View Cube.
//! @param thePrsMgr [in] presentation manager.
//! @param thePrs [in] input presentation that is to be filled with flat presentation primitives.
//! @param theMode [in] display mode.
//! @warning this object accept only 0 display mode.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode = 0) Standard_OVERRIDE;
//! Redefine computing of sensitive entities for View Cube.
//! @param theSelection [in] input selection object that is to be filled with sensitive entities.
//! @param theMode [in] selection mode.
//! @warning object accepts only 0 selection mode.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
//! Method which clear all selected owners belonging to this selectable object.
//! @warning this object does not support selection.
virtual void ClearSelected() Standard_OVERRIDE {}
//! Method which highlights input owner belonging to this selectable object.
//! @param thePM [in] presentation manager
//! @param theStyle [in] style for dynamic highlighting.
//! @param theOwner [in] input entity owner.
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
//! Method which draws selected owners.
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
//! Set default parameters for visual attributes
//! @sa Attributes()
virtual void UnsetAttributes() Standard_OVERRIDE
{
setDefaultAttributes();
SetToUpdate();
}
//! Set default parameters for dynamic highlighting attributes, reset highlight attributes
virtual void UnsetHilightAttributes() Standard_OVERRIDE
{
myHilightDrawer.Nullify();
setDefaultHighlightAttributes();
SetToUpdate();
}
protected: //! @name Auxiliary classes to fill presentation with proper primitives
//! Create triangulation for a box part - for presentation and selection purposes.
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxPartTriangles (V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box side.
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxSideTriangles (V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box edge.
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxEdgeTriangles (V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box corner (vertex).
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxCornerTriangles (V3d_TypeOfOrientation theDir) const;
protected:
//! Create triangulation for a rectangle with round corners.
//! @param theSize rectangle dimensions
//! @param theRadius radius at corners
//! @param theTrsf transformation
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) createRoundRectangleTriangles (const gp_XY& theSize,
Standard_Real theRadius,
const gp_Trsf& theTrsf);
protected:
//! Trivial hasher to avoid ambiguity with enumeration type.
struct IntegerHasher
{
static Standard_Integer HashCode (Standard_Integer theValue, Standard_Integer theUpper) { return ::HashCode (theValue, theUpper); }
static Standard_Boolean IsEqual (Standard_Integer theA, Standard_Integer theB) { return theA == theB; }
};
protected:
NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString, IntegerHasher>
myBoxSideLabels; //!< map with box side labels
NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString, IntegerHasher>
myAxesLabels; //!< map with axes labels
Handle(Prs3d_ShadingAspect) myBoxEdgeAspect; //!< style for box edges
Handle(Prs3d_ShadingAspect) myBoxCornerAspect; //!< style for box corner
Standard_Real mySize; //!< size of box side, length of one axis
Standard_Real myBoxEdgeMinSize; //!< minimal size of box edge
Standard_Real myBoxEdgeGap; //!< gap between box side and box edge
Standard_Real myBoxFacetExtension; //!< box facet extension
Standard_Real myAxesPadding; //!< Padding between box and axes
Standard_Real myCornerMinSize; //!< minimal size of box corner
Standard_Real myRoundRadius; //!< relative round radius within [0; 0.5] range
Standard_Boolean myToDisplayAxes; //!< trihedron visibility
Standard_Boolean myToDisplayEdges; //!< box edges visibility
Standard_Boolean myToDisplayVertices; //!< box corners (vertices) visibility
Standard_Boolean myIsYup; //!< flag indicating that application expects Y-up viewer orientation instead of Z-up
protected: //! @name Animation options
Handle(AIS_AnimationCamera) myViewAnimation; //!< Camera animation object
Handle(Graphic3d_Camera) myStartState; //!< Start state of view camera
Handle(Graphic3d_Camera) myEndState; //!< End state of view camera
Standard_Real myDuration; //!< Duration of animation. By default it is half a second
Standard_Boolean myToAutoStartAnim; //!< start animation automatically on click
Standard_Boolean myIsFixedAnimation; //!< fixed-loop animation
Standard_Boolean myToFitSelected; //!< fit selected or fit entire scene
Standard_Boolean myToResetCameraUp; //!< always reset camera up direction to default
};
//! Redefined entity owner that is highlighted when owner is detected,
//! even if Interactive Context highlighted on last detection procedure.
class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
{
DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
public:
//! Main constructor.
AIS_ViewCubeOwner (const Handle(AIS_ViewCube)& theObject,
V3d_TypeOfOrientation theOrient,
Standard_Integer thePriority = 5)
: SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theObject, thePriority),
myMainOrient (theOrient)
{
myFromDecomposition = true;
}
//! @return TRUE. This owner will always call method
//! Hilight for its Selectable Object when the owner is detected.
virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE { return Standard_True; }
//! Return new orientation to set.
V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
//! Handle mouse button click event.
virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick) Standard_OVERRIDE
{
(void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube* >(mySelectable);
aCubePrs->HandleClick (this);
return Standard_True;
}
protected:
V3d_TypeOfOrientation myMainOrient; //!< new orientation to set
};
#endif // _AIS_ViewCube_HeaderFile

View File

@@ -182,6 +182,4 @@ AIS_TypeOfPlane.hxx
AIS_ViewController.cxx
AIS_ViewController.hxx
AIS_ViewInputBuffer.hxx
AIS_ViewCube.cxx
AIS_ViewCube.hxx
AIS_WalkDelta.hxx

View File

@@ -48,6 +48,25 @@ Aspect_GenId::Aspect_GenId (const Standard_Integer theLow,
}
}
// =======================================================================
// function : HasFree
// purpose :
// =======================================================================
Standard_Boolean Aspect_GenId::HasFree() const
{
return myFreeCount > 0
|| myFreeIds.Extent() > 0;
}
// =======================================================================
// function : Available
// purpose :
// =======================================================================
Standard_Integer Aspect_GenId::Available() const
{
return myFreeCount + myFreeIds.Extent();
}
// =======================================================================
// function : Free
// purpose :
@@ -79,38 +98,42 @@ void Aspect_GenId::Free (const Standard_Integer theId)
}
}
// =======================================================================
// function : Lower
// purpose :
// =======================================================================
Standard_Integer Aspect_GenId::Lower() const
{
return myLowerBound;
}
// =======================================================================
// function : Next
// purpose :
// =======================================================================
Standard_Integer Aspect_GenId::Next()
{
Standard_Integer aNewId = 0;
if (!Next (aNewId))
{
throw Aspect_IdentDefinitionError("Aspect_GenId::Next(), Error: Available == 0");
}
return aNewId;
}
// =======================================================================
// function : Next
// purpose :
// =======================================================================
Standard_Boolean Aspect_GenId::Next (Standard_Integer& theId)
{
if (!myFreeIds.IsEmpty())
{
theId = myFreeIds.First();
const Standard_Integer anId = myFreeIds.First();
myFreeIds.RemoveFirst();
return Standard_True;
return anId;
}
else if (myFreeCount < 1)
{
return Standard_False;
throw Aspect_IdentDefinitionError("GenId Next Error: Available == 0");
}
--myFreeCount;
theId = myLowerBound + myLength - myFreeCount - 1;
return Standard_True;
const Standard_Integer anId = myLowerBound + myLength - myFreeCount - 1;
return anId;
}
// =======================================================================
// function : Upper
// purpose :
// =======================================================================
Standard_Integer Aspect_GenId::Upper() const
{
return myUpperBound;
}

View File

@@ -49,38 +49,47 @@ public:
Standard_EXPORT void Free (const Standard_Integer theId);
//! Returns true if there are available identifiers in range.
Standard_Boolean HasFree() const
{
return myFreeCount > 0
|| myFreeIds.Extent() > 0;
}
Standard_EXPORT Standard_Boolean HasFree() const;
//! Returns the number of available identifiers.
Standard_Integer Available() const { return myFreeCount + myFreeIds.Extent(); }
Standard_EXPORT Standard_Integer Available() const;
//! Returns the lower identifier in range.
Standard_Integer Lower() const { return myLowerBound; }
Standard_EXPORT Standard_Integer Lower() const;
//! Returns the next available identifier.
//! Warning: Raises IdentDefinitionError if all identifiers are busy.
Standard_EXPORT Standard_Integer Next();
//! Generates the next available identifier.
//! @param theId [out] generated identifier
//! @return FALSE if all identifiers are busy.
Standard_EXPORT Standard_Boolean Next (Standard_Integer& theId);
//! Returns the upper identifier in range.
Standard_Integer Upper() const { return myUpperBound; }
Standard_EXPORT Standard_Integer Upper() const;
protected:
private:
Standard_Integer myFreeCount;
Standard_Integer myLength;
Standard_Integer myLowerBound;
Standard_Integer myUpperBound;
TColStd_ListOfInteger myFreeIds;
};
#endif // _Aspect_GenId_HeaderFile

View File

@@ -16,8 +16,10 @@
#include <BRepExtrema_TriangleSet.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BVH_LinearBuilder.hxx>
#include <Poly_Triangulation.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
@@ -150,6 +152,9 @@ void BRepExtrema_TriangleSet::Clear()
BVH_Array4i anEmptyTriangles;
myTriangles.swap (anEmptyTriangles);
BVH_Array2d anEmptyVertUVArray;
myVertUVArray.swap (anEmptyVertUVArray);
BVH_Array3d anEmptyVertexArray;
myVertexArray.swap (anEmptyVertexArray);
}
@@ -174,6 +179,8 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
return Standard_False;
}
BRepAdaptor_Surface aFaceAdaptor (theFaces (aFaceIdx), Standard_False);
const Standard_Integer aVertOffset =
static_cast<Standard_Integer> (myVertexArray.size()) - 1;
@@ -186,6 +193,11 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
myVertexArray.push_back (BVH_Vec3d (aVertex.X(),
aVertex.Y(),
aVertex.Z()));
const Standard_Real aU = aTriangulation->UVNodes().Value (aVertIdx).X();
const Standard_Real aV = aTriangulation->UVNodes().Value (aVertIdx).Y();
myVertUVArray.push_back (BVH_Vec2d (aU, aV));
}
for (Standard_Integer aTriIdx = 1; aTriIdx <= aTriangulation->NbTriangles(); ++aTriIdx)

View File

@@ -75,6 +75,9 @@ protected:
//! Array of vertex indices.
BVH_Array4i myTriangles;
//! Array of vertex UV params.
BVH_Array2d myVertUVArray;
//! Array of vertex coordinates.
BVH_Array3d myVertexArray;

View File

@@ -20,7 +20,9 @@
#include <BRepMesh_FaceDiscret.hxx>
#include <BRepMesh_ModelPreProcessor.hxx>
#include <BRepMesh_ModelPostProcessor.hxx>
#include <BRepMesh_MeshAlgoFactory.hxx>
#include <BRepMesh_DelabellaMeshAlgoFactory.hxx>
//=======================================================================
// Function: Constructor
@@ -28,11 +30,33 @@
//=======================================================================
BRepMesh_Context::BRepMesh_Context ()
{
enum MeshAlgo
{
MeshAlgo_Default = 0x0,
MeshAlgo_Delabella = 0x1
};
char* anAlgoVar;
anAlgoVar = getenv ("CSF_MeshAlgo");
const Standard_Integer anAlgoId = (anAlgoVar ? atoi (anAlgoVar) : MeshAlgo_Default);
Handle (IMeshTools_MeshAlgoFactory) aAlgoFactory;
switch (anAlgoId)
{
case MeshAlgo_Delabella:
aAlgoFactory = new BRepMesh_DelabellaMeshAlgoFactory;
break;
default:
aAlgoFactory = new BRepMesh_MeshAlgoFactory;
break;
}
SetModelBuilder (new BRepMesh_ModelBuilder);
SetEdgeDiscret (new BRepMesh_EdgeDiscret);
SetModelHealer (new BRepMesh_ModelHealer);
SetPreProcessor (new BRepMesh_ModelPreProcessor);
SetFaceDiscret (new BRepMesh_FaceDiscret(new BRepMesh_MeshAlgoFactory));
SetFaceDiscret (new BRepMesh_FaceDiscret (aAlgoFactory));
SetPostProcessor(new BRepMesh_ModelPostProcessor);
}

View File

@@ -49,12 +49,35 @@ protected:
Standard_EXPORT virtual void generateMesh () Standard_OVERRIDE
{
const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
const Standard_Integer aNodesNb = aStructure->NbNodes ();
buildBaseTriangulation ();
std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
const Standard_Integer aNewNodesNb = aStructure->NbNodes ();
const Standard_Boolean isRemoveAux = aNewNodesNb > aNodesNb;
if (isRemoveAux)
{
IMeshData::VectorOfInteger aAuxVertices (aNewNodesNb - aNodesNb);
for (Standard_Integer aExtNodesIt = aNodesNb + 1; aExtNodesIt <= aNewNodesNb; ++aExtNodesIt)
{
aAuxVertices.Append (aExtNodesIt);
}
// Set aux vertices if there are some to clean up mesh correctly.
aMesher.SetAuxVertices (aAuxVertices);
}
aMesher.ProcessConstraints ();
// Destruction of triangles containing aux vertices added (possibly) during base mesh computation.
if (isRemoveAux)
{
aMesher.RemoveAuxElements ();
}
BRepMesh_MeshTool aCleaner (aStructure);
aCleaner.EraseFreeLinks ();

View File

@@ -0,0 +1,155 @@
// Created on: 2019-07-05
// Copyright (c) 2019 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_DelabellaBaseMeshAlgo.hxx>
#include <BRepMesh_MeshTool.hxx>
#include <BRepMesh_Delaun.hxx>
#include "delabella.h"
//=======================================================================
// Function: Constructor
// Purpose :
//=======================================================================
BRepMesh_DelabellaBaseMeshAlgo::BRepMesh_DelabellaBaseMeshAlgo ()
{
}
//=======================================================================
// Function: Destructor
// Purpose :
//=======================================================================
BRepMesh_DelabellaBaseMeshAlgo::~BRepMesh_DelabellaBaseMeshAlgo ()
{
}
//=======================================================================
//function : buildBaseTriangulation
//purpose :
//=======================================================================
void BRepMesh_DelabellaBaseMeshAlgo::buildBaseTriangulation()
{
const Handle(BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure();
Bnd_B2d aBox;
const Standard_Integer aNodesNb = aStructure->NbNodes ();
std::vector<Standard_Real> aPoints (2 * (aNodesNb + 4));
for (Standard_Integer aNodeIt = 0; aNodeIt < aNodesNb; ++aNodeIt)
{
const BRepMesh_Vertex& aVertex = aStructure->GetNode (aNodeIt + 1);
const size_t aBaseIdx = 2 * static_cast<size_t> (aNodeIt);
aPoints[aBaseIdx + 0] = aVertex.Coord ().X ();
aPoints[aBaseIdx + 1] = aVertex.Coord ().Y ();
aBox.Add (gp_Pnt2d(aVertex.Coord ()));
}
aBox.Enlarge (0.1 * (aBox.CornerMax () - aBox.CornerMin ()).Modulus ());
const gp_XY aMin = aBox.CornerMin ();
const gp_XY aMax = aBox.CornerMax ();
aPoints[2 * aNodesNb + 0] = aMin.X ();
aPoints[2 * aNodesNb + 1] = aMin.Y ();
aStructure->AddNode (BRepMesh_Vertex (
aPoints[2 * aNodesNb + 0],
aPoints[2 * aNodesNb + 1], BRepMesh_Free));
aPoints[2 * aNodesNb + 2] = aMax.X ();
aPoints[2 * aNodesNb + 3] = aMin.Y ();
aStructure->AddNode (BRepMesh_Vertex (
aPoints[2 * aNodesNb + 2],
aPoints[2 * aNodesNb + 3], BRepMesh_Free));
aPoints[2 * aNodesNb + 4] = aMax.X ();
aPoints[2 * aNodesNb + 5] = aMax.Y ();
aStructure->AddNode (BRepMesh_Vertex (
aPoints[2 * aNodesNb + 4],
aPoints[2 * aNodesNb + 5], BRepMesh_Free));
aPoints[2 * aNodesNb + 6] = aMin.X ();
aPoints[2 * aNodesNb + 7] = aMax.Y ();
aStructure->AddNode (BRepMesh_Vertex (
aPoints[2 * aNodesNb + 6],
aPoints[2 * aNodesNb + 7], BRepMesh_Free));
const Standard_Real aDiffX = (aMax.X () - aMin.X ());
const Standard_Real aDiffY = (aMax.Y () - aMin.Y ());
for (size_t i = 0; i < aPoints.size(); i += 2)
{
aPoints[i + 0] = (aPoints[i + 0] - aMin.X ()) / aDiffX - 0.5;
aPoints[i + 1] = (aPoints[i + 1] - aMin.Y ()) / aDiffY - 0.5;
}
IDelaBella* aTriangulator = IDelaBella::Create();
try
{
if (aTriangulator != NULL)
{
const int aVerticesNb = aTriangulator->Triangulate (
static_cast<int>(aPoints.size () / 2),
&aPoints[0], &aPoints[1], 2 * sizeof (Standard_Real));
if (aVerticesNb > 0)
{
const DelaBella_Triangle* aTrianglePtr = aTriangulator->GetFirstDelaunayTriangle();
while (aTrianglePtr != NULL)
{
Standard_Integer aNodes[3] = {
aTrianglePtr->v[0]->i + 1,
aTrianglePtr->v[2]->i + 1,
aTrianglePtr->v[1]->i + 1
};
Standard_Integer aEdges [3];
Standard_Boolean aOrientations[3];
for (Standard_Integer k = 0; k < 3; ++k)
{
const BRepMesh_Edge aLink (aNodes[k], aNodes[(k + 1) % 3], BRepMesh_Free);
const Standard_Integer aLinkInfo = aStructure->AddLink (aLink);
aEdges [k] = Abs (aLinkInfo);
aOrientations[k] = aLinkInfo > 0;
}
const BRepMesh_Triangle aTriangle (aEdges, aOrientations, BRepMesh_Free);
aStructure->AddElement (aTriangle);
aTrianglePtr = aTrianglePtr->next;
}
}
aTriangulator->Destroy ();
}
}
catch (Standard_Failure const& theException)
{
if (aTriangulator != NULL)
{
aTriangulator->Destroy ();
}
throw Standard_Failure (theException);
}
catch (...)
{
if (aTriangulator != NULL)
{
aTriangulator->Destroy ();
}
throw Standard_Failure ("BRepMesh_DelabellaBaseMeshAlgo::buildBaseTriangulation: exception in triangulation algorithm");
}
}

View File

@@ -0,0 +1,46 @@
// Created on: 2019-07-05
// Copyright (c) 2019 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// 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 _BRepMesh_DelabellaBaseMeshAlgo_HeaderFile
#define _BRepMesh_DelabellaBaseMeshAlgo_HeaderFile
#include <BRepMesh_CustomBaseMeshAlgo.hxx>
#include <NCollection_Shared.hxx>
#include <IMeshTools_Parameters.hxx>
class BRepMesh_DataStructureOfDelaun;
class BRepMesh_Delaun;
//! Class provides base fuctionality to build face triangulation using Delabella project.
//! Performs generation of mesh using raw data from model.
class BRepMesh_DelabellaBaseMeshAlgo : public BRepMesh_CustomBaseMeshAlgo
{
public:
//! Constructor.
Standard_EXPORT BRepMesh_DelabellaBaseMeshAlgo ();
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_DelabellaBaseMeshAlgo ();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelabellaBaseMeshAlgo, BRepMesh_CustomBaseMeshAlgo)
protected:
//! Builds base triangulation using Delabella project.
Standard_EXPORT virtual void buildBaseTriangulation() Standard_OVERRIDE;
};
#endif

View File

@@ -0,0 +1,143 @@
// Created on: 2019-07-05
// Copyright (c) 2019 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_DelabellaMeshAlgoFactory.hxx>
#include <BRepMesh_DefaultRangeSplitter.hxx>
#include <BRepMesh_NURBSRangeSplitter.hxx>
#include <BRepMesh_SphereRangeSplitter.hxx>
#include <BRepMesh_CylinderRangeSplitter.hxx>
#include <BRepMesh_ConeRangeSplitter.hxx>
#include <BRepMesh_TorusRangeSplitter.hxx>
#include <BRepMesh_DelaunayBaseMeshAlgo.hxx>
#include <BRepMesh_DelabellaBaseMeshAlgo.hxx>
#include <BRepMesh_CustomDelaunayBaseMeshAlgo.hxx>
#include <BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx>
#include <BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx>
#include <BRepMesh_BoundaryParamsRangeSplitter.hxx>
namespace
{
struct DefaultBaseMeshAlgo
{
typedef BRepMesh_DelaunayBaseMeshAlgo Type;
};
template<class RangeSplitter>
struct DefaultNodeInsertionMeshAlgo
{
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> Type;
};
struct BaseMeshAlgo
{
typedef BRepMesh_DelabellaBaseMeshAlgo Type;
};
template<class RangeSplitter>
struct NodeInsertionMeshAlgo
{
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BRepMesh_CustomDelaunayBaseMeshAlgo<BRepMesh_DelabellaBaseMeshAlgo> > Type;
};
template<class RangeSplitter>
struct DeflectionControlMeshAlgo
{
typedef BRepMesh_DelaunayDeflectionControlMeshAlgo<RangeSplitter, BRepMesh_CustomDelaunayBaseMeshAlgo<BRepMesh_DelabellaBaseMeshAlgo> > Type;
};
}
//=======================================================================
// Function: Constructor
// Purpose :
//=======================================================================
BRepMesh_DelabellaMeshAlgoFactory::BRepMesh_DelabellaMeshAlgoFactory ()
{
}
//=======================================================================
// Function: Destructor
// Purpose :
//=======================================================================
BRepMesh_DelabellaMeshAlgoFactory::~BRepMesh_DelabellaMeshAlgoFactory ()
{
}
//=======================================================================
// Function: GetAlgo
// Purpose :
//=======================================================================
Handle(IMeshTools_MeshAlgo) BRepMesh_DelabellaMeshAlgoFactory::GetAlgo(
const GeomAbs_SurfaceType theSurfaceType,
const IMeshTools_Parameters& theParameters) const
{
switch (theSurfaceType)
{
case GeomAbs_Plane:
return theParameters.InternalVerticesMode ?
new NodeInsertionMeshAlgo<BRepMesh_DefaultRangeSplitter>::Type :
new BaseMeshAlgo::Type;
break;
case GeomAbs_Sphere:
{
NodeInsertionMeshAlgo<BRepMesh_SphereRangeSplitter>::Type* aMeshAlgo =
new NodeInsertionMeshAlgo<BRepMesh_SphereRangeSplitter>::Type;
aMeshAlgo->SetPreProcessSurfaceNodes (Standard_True);
return aMeshAlgo;
}
break;
case GeomAbs_Cylinder:
return theParameters.InternalVerticesMode ?
new DefaultNodeInsertionMeshAlgo<BRepMesh_CylinderRangeSplitter>::Type :
new DefaultBaseMeshAlgo::Type;
break;
case GeomAbs_Cone:
{
NodeInsertionMeshAlgo<BRepMesh_ConeRangeSplitter>::Type* aMeshAlgo =
new NodeInsertionMeshAlgo<BRepMesh_ConeRangeSplitter>::Type;
aMeshAlgo->SetPreProcessSurfaceNodes (Standard_True);
return aMeshAlgo;
}
break;
case GeomAbs_Torus:
{
NodeInsertionMeshAlgo<BRepMesh_TorusRangeSplitter>::Type* aMeshAlgo =
new NodeInsertionMeshAlgo<BRepMesh_TorusRangeSplitter>::Type;
aMeshAlgo->SetPreProcessSurfaceNodes (Standard_True);
return aMeshAlgo;
}
break;
case GeomAbs_SurfaceOfRevolution:
{
DeflectionControlMeshAlgo<BRepMesh_BoundaryParamsRangeSplitter>::Type* aMeshAlgo =
new DeflectionControlMeshAlgo<BRepMesh_BoundaryParamsRangeSplitter>::Type;
aMeshAlgo->SetPreProcessSurfaceNodes (Standard_True);
return aMeshAlgo;
}
break;
default:
{
DeflectionControlMeshAlgo<BRepMesh_NURBSRangeSplitter>::Type* aMeshAlgo =
new DeflectionControlMeshAlgo<BRepMesh_NURBSRangeSplitter>::Type;
aMeshAlgo->SetPreProcessSurfaceNodes (Standard_True);
return aMeshAlgo;
}
}
}

View File

@@ -0,0 +1,44 @@
// Created on: 2019-07-05
// Copyright (c) 2019 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// 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 _BRepMesh_DelabellaMeshAlgoFactory_HeaderFile
#define _BRepMesh_DelabellaMeshAlgoFactory_HeaderFile
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <IMeshTools_MeshAlgoFactory.hxx>
//! Implementation of IMeshTools_MeshAlgoFactory providing Delabella-based
//! algorithms of different compexity depending on type of target surface.
class BRepMesh_DelabellaMeshAlgoFactory : public IMeshTools_MeshAlgoFactory
{
public:
//! Constructor.
Standard_EXPORT BRepMesh_DelabellaMeshAlgoFactory ();
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_DelabellaMeshAlgoFactory ();
//! Creates instance of meshing algorithm for the given type of surface.
Standard_EXPORT virtual Handle(IMeshTools_MeshAlgo) GetAlgo(
const GeomAbs_SurfaceType theSurfaceType,
const IMeshTools_Parameters& theParameters) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelabellaMeshAlgoFactory, IMeshTools_MeshAlgoFactory)
};
#endif

View File

@@ -89,7 +89,8 @@ BRepMesh_Delaun::BRepMesh_Delaun (
const Standard_Boolean isFillCircles)
: myMeshData ( theOldMesh ),
myCircles (new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
mySupVert (3)
{
if (isFillCircles)
{
@@ -103,7 +104,8 @@ BRepMesh_Delaun::BRepMesh_Delaun (
//=======================================================================
BRepMesh_Delaun::BRepMesh_Delaun(IMeshData::Array1OfVertexOfDelaun& theVertices)
: myCircles (theVertices.Length(), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
mySupVert (3)
{
if ( theVertices.Length() > 2 )
{
@@ -123,7 +125,8 @@ BRepMesh_Delaun::BRepMesh_Delaun(
IMeshData::Array1OfVertexOfDelaun& theVertices)
: myMeshData( theOldMesh ),
myCircles ( theVertices.Length(), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
mySupVert (3)
{
if ( theVertices.Length() > 2 )
{
@@ -140,7 +143,8 @@ BRepMesh_Delaun::BRepMesh_Delaun(
IMeshData::VectorOfInteger& theVertexIndices)
: myMeshData( theOldMesh ),
myCircles ( theVertexIndices.Length(), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
mySupVert (3)
{
perform(theVertexIndices);
}
@@ -155,7 +159,8 @@ BRepMesh_Delaun::BRepMesh_Delaun (const Handle (BRepMesh_DataStructureOfDelaun)&
const Standard_Integer theCellsCountV)
: myMeshData (theOldMesh),
myCircles (theVertexIndices.Length (), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
mySupVert (3)
{
perform (theVertexIndices, theCellsCountU, theCellsCountV);
}
@@ -284,14 +289,14 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox)
Standard_Real aDeltaMax = Max( aDeltaX, aDeltaY );
Standard_Real aDelta = aDeltaX + aDeltaY;
mySupVert[0] = myMeshData->AddNode(
BRepMesh_Vertex( ( aMinX + aMaxX ) / 2, aMaxY + aDeltaMax, BRepMesh_Free ) );
mySupVert.Append (myMeshData->AddNode(
BRepMesh_Vertex( ( aMinX + aMaxX ) / 2, aMaxY + aDeltaMax, BRepMesh_Free ) ) );
mySupVert[1] = myMeshData->AddNode(
BRepMesh_Vertex( aMinX - aDelta, aMinY - aDeltaMin, BRepMesh_Free ) );
mySupVert.Append (myMeshData->AddNode(
BRepMesh_Vertex( aMinX - aDelta, aMinY - aDeltaMin, BRepMesh_Free ) ) );
mySupVert[2] = myMeshData->AddNode(
BRepMesh_Vertex( aMaxX + aDelta, aMinY - aDeltaMin, BRepMesh_Free ) );
mySupVert.Append (myMeshData->AddNode(
BRepMesh_Vertex( aMaxX + aDelta, aMinY - aDeltaMin, BRepMesh_Free ) ) );
Standard_Integer e[3];
Standard_Boolean o[3];
@@ -300,7 +305,7 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox)
Standard_Integer aFirstNode = aNodeId;
Standard_Integer aLastNode = (aNodeId + 1) % 3;
Standard_Integer aLinkIndex = myMeshData->AddLink( BRepMesh_Edge(
mySupVert[aFirstNode], mySupVert[aLastNode], BRepMesh_Free ) );
mySupVert (aFirstNode), mySupVert (aLastNode), BRepMesh_Free ) );
e[aNodeId] = Abs(aLinkIndex);
o[aNodeId] = (aLinkIndex > 0);
@@ -367,28 +372,41 @@ void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes)
createTrianglesOnNewVertices( theVertexIndexes );
}
RemoveAuxElements ();
}
//=======================================================================
//function : RemoveAuxElements
//purpose :
//=======================================================================
void BRepMesh_Delaun::RemoveAuxElements ()
{
Handle (NCollection_IncAllocator) aAllocator = new NCollection_IncAllocator (
IMeshData::MEMORY_BLOCK_SIZE_HUGE);
IMeshData::MapOfIntegerInteger aLoopEdges (10, aAllocator);
// Destruction of triangles containing a top of the super triangle
BRepMesh_SelectorOfDataStructureOfDelaun aSelector( myMeshData );
for (Standard_Integer aSupVertId = 0; aSupVertId < 3; ++aSupVertId)
aSelector.NeighboursOfNode( mySupVert[aSupVertId] );
aLoopEdges.Clear();
IMeshData::IteratorOfMapOfInteger aFreeTriangles( aSelector.Elements() );
for ( ; aFreeTriangles.More(); aFreeTriangles.Next() )
deleteTriangle( aFreeTriangles.Key(), aLoopEdges );
BRepMesh_SelectorOfDataStructureOfDelaun aSelector (myMeshData);
for (Standard_Integer aSupVertId = 0; aSupVertId < mySupVert.Size(); ++aSupVertId)
aSelector.NeighboursOfNode (mySupVert (aSupVertId));
IMeshData::IteratorOfMapOfInteger aFreeTriangles (aSelector.Elements ());
for (; aFreeTriangles.More (); aFreeTriangles.Next ())
deleteTriangle (aFreeTriangles.Key (), aLoopEdges);
// All edges that remain free are removed from aLoopEdges;
// only the boundary edges of the triangulation remain there
IMeshData::MapOfIntegerInteger::Iterator aFreeEdges( aLoopEdges );
for ( ; aFreeEdges.More(); aFreeEdges.Next() )
IMeshData::MapOfIntegerInteger::Iterator aFreeEdges (aLoopEdges);
for (; aFreeEdges.More (); aFreeEdges.Next ())
{
if ( myMeshData->ElementsConnectedTo( aFreeEdges.Key() ).IsEmpty() )
myMeshData->RemoveLink( aFreeEdges.Key() );
if (myMeshData->ElementsConnectedTo (aFreeEdges.Key ()).IsEmpty ())
myMeshData->RemoveLink (aFreeEdges.Key ());
}
// The tops of the super triangle are destroyed
for (Standard_Integer aSupVertId = 0; aSupVertId < 3; ++aSupVertId)
myMeshData->RemoveNode( mySupVert[aSupVertId] );
for (Standard_Integer aSupVertId = 0; aSupVertId < mySupVert.Size (); ++aSupVertId)
myMeshData->RemoveNode (mySupVert (aSupVertId));
}
//=======================================================================
@@ -771,9 +789,7 @@ void BRepMesh_Delaun::cleanupMesh()
myMeshData->ElementNodes (aCurTriangle, v);
for (int aNodeIdx = 0; aNodeIdx < 3 && isCanNotBeRemoved; ++aNodeIdx)
{
if (v[aNodeIdx] == mySupVert[0] ||
v[aNodeIdx] == mySupVert[1] ||
v[aNodeIdx] == mySupVert[2])
if (isSupVertex (v[aNodeIdx]))
{
isCanNotBeRemoved = Standard_False;
}

View File

@@ -147,6 +147,17 @@ public:
const Standard_Real theSqTolerance,
Standard_Integer& theEdgeOn) const;
//! Explicitly sets ids of auxiliary vertices used to build mesh and used by 3rd-party algorithms.
inline void SetAuxVertices (const IMeshData::VectorOfInteger& theSupVert)
{
mySupVert = theSupVert;
}
//! Destruction of auxiliary triangles containing the given vertices.
//! Removes auxiliary vertices also.
//! @param theAuxVertices auxiliary vertices to be cleaned up.
Standard_EXPORT void RemoveAuxElements ();
private:
enum ReplaceFlag
@@ -354,11 +365,25 @@ private:
//! Performs insertion of internal edges into mesh.
void insertInternalEdges();
//! Checks whether the given vertex id relates to super contour.
inline Standard_Boolean isSupVertex (const Standard_Integer theVertexIdx)
{
for (IMeshData::VectorOfInteger::Iterator aIt (mySupVert); aIt.More (); aIt.Next ())
{
if (theVertexIdx == aIt.Value ())
{
return Standard_True;
}
}
return Standard_False;
}
private:
Handle(BRepMesh_DataStructureOfDelaun) myMeshData;
BRepMesh_CircleTool myCircles;
Standard_Integer mySupVert[3];
IMeshData::VectorOfInteger mySupVert;
BRepMesh_Triangle mySupTrian;
};

View File

@@ -0,0 +1,22 @@
MIT License
DELABELLA - Delaunay triangulation library
Copyright (C) 2018 GUMIX - Marcin Sokalski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -86,3 +86,9 @@ BRepMesh_VertexTool.cxx
BRepMesh_VertexTool.hxx
BRepMesh_CustomBaseMeshAlgo.hxx
BRepMesh_CustomDelaunayBaseMeshAlgo.hxx
delabella.h
delabella.cpp
BRepMesh_DelabellaBaseMeshAlgo.hxx
BRepMesh_DelabellaBaseMeshAlgo.cxx
BRepMesh_DelabellaMeshAlgoFactory.hxx
BRepMesh_DelabellaMeshAlgoFactory.cxx

1021
src/BRepMesh/delabella.cpp Normal file

File diff suppressed because it is too large Load Diff

68
src/BRepMesh/delabella.h Normal file
View File

@@ -0,0 +1,68 @@
/*
DELABELLA - Delaunay triangulation library
Copyright (C) 2018 GUMIX - Marcin Sokalski
*/
#ifndef DELABELLA_H
#define DELABELLA_H
// returns: positive value: number of triangle indices, negative: number of line segment indices (degenerated input)
// triangle indices in abc array are always returned in clockwise order
// DEPRECIATED. move to new API either extern "C" or IDelaBella (C++)
int DelaBella(int points, const double* xy/*[points][2]*/, int* abc/*[2*points-5][3]*/, int (*errlog)(const char* fmt,...) = printf);
struct DelaBella_Vertex
{
int i; // index of original point
double x, y; // coordinates (input copy)
DelaBella_Vertex* next; // next silhouette vertex
};
struct DelaBella_Triangle
{
DelaBella_Vertex* v[3]; // 3 vertices spanning this triangle
DelaBella_Triangle* f[3]; // 3 adjacent faces, f[i] is at the edge opposite to vertex v[i]
DelaBella_Triangle* next; // next triangle (of delaunay set or hull set)
};
#ifdef __cplusplus
struct IDelaBella
{
static IDelaBella* Create();
virtual void Destroy() = 0;
virtual void SetErrLog(int(*proc)(void* stream, const char* fmt, ...), void* stream) = 0;
// return 0: no output
// negative: all points are colinear, output hull vertices form colinear segment list, no triangles on output
// positive: output hull vertices form counter-clockwise ordered segment contour, delaunay and hull triangles are available
// if 'y' pointer is null, y coords are treated to be located immediately after every x
// if advance_bytes is less than 2*sizeof coordinate type, it is treated as 2*sizeof coordinate type
virtual int Triangulate(int points, const float* x, const float* y = 0, int advance_bytes = 0) = 0;
virtual int Triangulate(int points, const double* x, const double* y = 0, int advance_bytes = 0) = 0;
// num of points passed to last call to Triangulate()
virtual int GetNumInputPoints() const = 0;
// num of verts returned from last call to Triangulate()
virtual int GetNumOutputVerts() const = 0;
virtual const DelaBella_Triangle* GetFirstDelaunayTriangle() const = 0; // valid only if Triangulate() > 0
virtual const DelaBella_Triangle* GetFirstHullTriangle() const = 0; // valid only if Triangulate() > 0
virtual const DelaBella_Vertex* GetFirstHullVertex() const = 0; // if Triangulate() < 0 it is list, otherwise closed contour!
};
#else
void* DelaBella_Create();
void DelaBella_Destroy(void* db);
void DelaBella_SetErrLog(void* db, int(*proc)(void* stream, const char* fmt, ...), void* stream);
int DelaBella_TriangulateFloat(void* db, int points, float* x, float* y = 0, int advance_bytes = 0);
int DelaBella_TriangulateDouble(void* db, int points, double* x, double* y = 0, int advance_bytes = 0);
int DelaBella_GetNumInputPoints(void* db);
int DelaBella_GetNumOutputVerts(void* db);
const DelaBella_Triangle* GetFirstDelaunayTriangle(void* db);
const DelaBella_Triangle* GetFirstHullTriangle(void* db);
const DelaBella_Vertex* GetFirstHullVertex(void* db);
#endif
#endif

View File

@@ -845,6 +845,7 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
// take all isolated Wires
for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) {
TopoDS_Wire S = TopoDS::Wire(Ex.Current());
AddWarning(S," a Wire alone is not an IGESBRep entity : no Transfer");
BRepToIGES_BRWire BW(*this);
BW.SetModel(GetModel());
@@ -856,6 +857,7 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
// take all isolated Edges
for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) {
TopoDS_Edge S = TopoDS::Edge(Ex.Current());
AddWarning(S," a Edge alone is not an IGESBRep entity : no Transfer");
BRepToIGES_BRWire BW(*this);
BW.SetModel(GetModel());
@@ -867,6 +869,7 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
// take all isolated Vertices
for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) {
TopoDS_Vertex S = TopoDS::Vertex(Ex.Current());
AddWarning(S," a Vertex alone is not an IGESBRep entity : no Transfer");
BRepToIGES_BRWire BW(*this);
BW.SetModel(GetModel());

View File

@@ -44,17 +44,22 @@ D3DHost_GraphicDriver::~D3DHost_GraphicDriver()
}
// =======================================================================
// function : CreateView
// function : View
// purpose :
// =======================================================================
Handle(Graphic3d_CView) D3DHost_GraphicDriver::CreateView (const Handle(Graphic3d_StructureManager)& theMgr)
{
Handle(D3DHost_View) aView = new D3DHost_View (theMgr, this, myCaps, &myStateCounter);
myMapOfView.Add (aView);
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
aView->InsertLayerAfter (aLayer->LayerId(), aLayer->LayerSettings(), Graphic3d_ZLayerId_UNKNOWN);
const Graphic3d_ZLayerId aLayerID = aLayerIt.Value();
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerID);
aView->AddZLayer (aLayerID);
aView->SetZLayerSettings (aLayerID, aSettings);
}
return aView;
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,13 +12,22 @@
// commercial license or contractual agreement.
#include <Graphic3d_CView.hxx>
#include <Graphic3d_Layer.hxx>
#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
#include <Graphic3d_StructureManager.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CView,Graphic3d_DataStructureManager)
namespace
{
static const int THE_DEFAULT_LAYERS[] = { Graphic3d_ZLayerId_Top,
Graphic3d_ZLayerId_Topmost,
Graphic3d_ZLayerId_BotOSD,
Graphic3d_ZLayerId_TopOSD };
static const int THE_NB_DEFAULT_LAYERS = sizeof(THE_DEFAULT_LAYERS) / sizeof(*THE_DEFAULT_LAYERS);
}
//=======================================================================
//function : Constructor
//purpose :
@@ -348,28 +357,6 @@ void Graphic3d_CView::Update (const Graphic3d_ZLayerId theLayerId)
InvalidateZLayerBoundingBox (theLayerId);
}
// =======================================================================
// function : InvalidateZLayerBoundingBox
// purpose :
// =======================================================================
void Graphic3d_CView::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId)
{
if (Handle(Graphic3d_Layer) aLayer = Layer (theLayerId))
{
aLayer->InvalidateBoundingBox();
return;
}
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
if (aLayer->NbOfTransformPersistenceObjects() > 0)
{
aLayer->InvalidateBoundingBox();
}
}
}
// =======================================================================
// function : ContainsFacet
// purpose :
@@ -420,25 +407,40 @@ void Graphic3d_CView::DisplayedStructures (Graphic3d_MapOfStructure& theStructur
// =======================================================================
Bnd_Box Graphic3d_CView::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const
{
Bnd_Box aResult;
if (!IsDefined())
{
return Bnd_Box();
return aResult;
}
const Handle(Graphic3d_Camera)& aCamera = Camera();
Graphic3d_Vec2i aWinSize;
Window()->Size (aWinSize.x(), aWinSize.y());
Handle(Graphic3d_Camera) aCamera = Camera();
Standard_Integer aWinWidth = 0;
Standard_Integer aWinHeight = 0;
Bnd_Box aResult;
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
Window()->Size (aWinWidth, aWinHeight);
for (Standard_Integer aLayer = 0; aLayer < THE_NB_DEFAULT_LAYERS; ++aLayer)
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
Bnd_Box aBox = aLayer->BoundingBox (Identification(),
aCamera,
aWinSize.x(), aWinSize.y(),
theToIncludeAuxiliary);
Bnd_Box aBox = ZLayerBoundingBox (THE_DEFAULT_LAYERS[aLayer],
aCamera,
aWinWidth,
aWinHeight,
theToIncludeAuxiliary);
aResult.Add (aBox);
}
Standard_Integer aMaxZLayer = ZLayerMax();
for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId <= aMaxZLayer; ++aLayerId)
{
Bnd_Box aBox = ZLayerBoundingBox (aLayerId,
aCamera,
aWinWidth,
aWinHeight,
theToIncludeAuxiliary);
aResult.Add(aBox);
}
return aResult;
}
@@ -453,15 +455,21 @@ Standard_Real Graphic3d_CView::ConsiderZoomPersistenceObjects()
return 1.0;
}
const Handle(Graphic3d_Camera)& aCamera = Camera();
Graphic3d_Vec2i aWinSize;
Window()->Size (aWinSize.x(), aWinSize.y());
Handle(Graphic3d_Camera) aCamera = Camera();
Standard_Integer aWinWidth = 0;
Standard_Integer aWinHeight = 0;
Window()->Size (aWinWidth, aWinHeight);
Standard_Real aMaxCoef = 1.0;
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
for (Standard_Integer aLayer = 0; aLayer < THE_NB_DEFAULT_LAYERS; ++aLayer)
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
aMaxCoef = Max (aMaxCoef, aLayer->considerZoomPersistenceObjects (Identification(), aCamera, aWinSize.x(), aWinSize.y()));
aMaxCoef = Max (aMaxCoef, considerZoomPersistenceObjects (THE_DEFAULT_LAYERS[aLayer], aCamera, aWinWidth, aWinHeight));
}
for (Standard_Integer aLayer = Graphic3d_ZLayerId_Default; aLayer <= ZLayerMax(); ++aLayer)
{
aMaxCoef = Max (aMaxCoef, considerZoomPersistenceObjects (aLayer, aCamera, aWinWidth, aWinHeight));
}
return aMaxCoef;

View File

@@ -46,7 +46,6 @@
class Graphic3d_CView;
class Graphic3d_GraphicDriver;
class Graphic3d_Layer;
class Graphic3d_StructureManager;
DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
@@ -268,34 +267,32 @@ public:
//! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) = 0;
//! Add a layer to the view.
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
//! @param theSettings [in] new layer settings
//! @param theLayerAfter [in] id of layer to append new layer before
virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter) = 0;
//! Add a layer to the view.
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
//! @param theSettings [in] new layer settings
//! @param theLayerBefore [in] id of layer to append new layer after
virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore) = 0;
//! Add a new top-level z layer with ID <theLayerId> for
//! the view. Z layers allow drawing structures in higher layers
//! in foreground of structures in lower layers. To add a structure
//! to desired layer on display it is necessary to set the layer
//! ID for the structure.
virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
//! Returns the maximum Z layer ID.
//! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
virtual Standard_Integer ZLayerMax() const = 0;
//! Returns the list of layers.
virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const = 0;
//! Returns layer with given ID or NULL if undefined.
virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const = 0;
//! Returns the bounding box of all structures displayed in the Z layer.
virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const = 0;
//! Returns the bounding box of all structures displayed in the Z layer.
Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
//! @param theLayerId layer identifier
//! @param theCamera camera definition
//! @param theWindowWidth viewport width (for applying transformation-persistence)
//! @param theWindowHeight viewport height (for applying transformation-persistence)
//! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
//! @return computed bounding box
virtual Bnd_Box ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
const Handle(Graphic3d_Camera)& theCamera,
const Standard_Integer theWindowWidth,
const Standard_Integer theWindowHeight,
const Standard_Boolean theToIncludeAuxiliary) const = 0;
//! Remove Z layer from the specified view. All structures
//! displayed at the moment in layer will be displayed in default layer
@@ -450,6 +447,12 @@ private:
virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
const Standard_Integer theNewPriority) = 0;
//! Returns zoom-scale factor.
virtual Standard_Real considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
const Handle(Graphic3d_Camera)& theCamera,
const Standard_Integer theWindowWidth,
const Standard_Integer theWindowHeight) const = 0;
protected:
Standard_Integer myId;

View File

@@ -103,21 +103,6 @@ Graphic3d_Camera::Graphic3d_Camera()
// purpose :
// =======================================================================
Graphic3d_Camera::Graphic3d_Camera (const Handle(Graphic3d_Camera)& theOther)
: myUp (0.0, 1.0, 0.0),
myEye (0.0, 0.0, -1500.0),
myCenter (0.0, 0.0, 0.0),
myAxialScale (1.0, 1.0, 1.0),
myProjType (Projection_Orthographic),
myFOVy (45.0),
myFOVyTan (Tan (DTR_HALF * 45.0)),
myZNear (DEFAULT_ZNEAR),
myZFar (DEFAULT_ZFAR),
myAspect (1.0),
myScale (1000.0),
myZFocus (1.0),
myZFocusType (FocusType_Relative),
myIOD (0.05),
myIODType (IODType_Relative)
{
myWorldViewProjState.Initialize (this);

View File

@@ -16,8 +16,6 @@
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Layer.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,Standard_Transient)
// =======================================================================
@@ -27,85 +25,70 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,Standard_Transient)
Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Handle(Aspect_DisplayConnection)& theDisp)
: myDisplayConnection (theDisp)
{
// default layers are always presented in display layer sequence and cannot be removed
// default layers are always presented in display layer sequence it can not be removed
{
Graphic3d_ZLayerSettings aSettings;
aSettings.SetName ("UNDERLAY");
aSettings.SetImmediate (Standard_False);
aSettings.SetRaytracable (Standard_False);
aSettings.SetEnvironmentTexture (Standard_False);
aSettings.SetEnableDepthTest (Standard_False);
aSettings.SetEnableDepthWrite (Standard_False);
aSettings.SetClearDepth (Standard_False);
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_BotOSD, 1, Handle(Select3D_BVHBuilder3d)());
aLayer->SetLayerSettings (aSettings);
myLayers.Append (aLayer);
myLayerIds.Bind (aLayer->LayerId(), aLayer);
myLayerIds.Add (Graphic3d_ZLayerId_BotOSD);
myLayerSeq.Append (Graphic3d_ZLayerId_BotOSD);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_BotOSD, aSettings);
}
{
Graphic3d_ZLayerSettings aSettings;
aSettings.SetName ("DEFAULT");
aSettings.SetImmediate (Standard_False);
aSettings.SetRaytracable (Standard_True);
aSettings.SetEnvironmentTexture (Standard_True);
aSettings.SetEnableDepthTest (Standard_True);
aSettings.SetEnableDepthWrite (Standard_True);
aSettings.SetClearDepth (Standard_False);
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_Default, 1, Handle(Select3D_BVHBuilder3d)());
aLayer->SetLayerSettings (aSettings);
myLayers.Append (aLayer);
myLayerIds.Bind (aLayer->LayerId(), aLayer);
myLayerIds.Add (Graphic3d_ZLayerId_Default);
myLayerSeq.Append (Graphic3d_ZLayerId_Default);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Default, aSettings);
}
{
Graphic3d_ZLayerSettings aSettings;
aSettings.SetName ("TOP");
aSettings.SetImmediate (Standard_True);
aSettings.SetRaytracable (Standard_False);
aSettings.SetEnvironmentTexture (Standard_True);
aSettings.SetEnableDepthTest (Standard_True);
aSettings.SetEnableDepthWrite (Standard_True);
aSettings.SetClearDepth (Standard_False);
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_Top, 1, Handle(Select3D_BVHBuilder3d)());
aLayer->SetLayerSettings (aSettings);
myLayers.Append (aLayer);
myLayerIds.Bind (aLayer->LayerId(), aLayer);
myLayerIds.Add (Graphic3d_ZLayerId_Top);
myLayerSeq.Append (Graphic3d_ZLayerId_Top);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Top, aSettings);
}
{
Graphic3d_ZLayerSettings aSettings;
aSettings.SetName ("TOPMOST");
aSettings.SetImmediate (Standard_True);
aSettings.SetRaytracable (Standard_False);
aSettings.SetEnvironmentTexture (Standard_True);
aSettings.SetEnableDepthTest (Standard_True);
aSettings.SetEnableDepthWrite (Standard_True);
aSettings.SetClearDepth (Standard_True);
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_Topmost, 1, Handle(Select3D_BVHBuilder3d)());
aLayer->SetLayerSettings (aSettings);
myLayers.Append (aLayer);
myLayerIds.Bind (aLayer->LayerId(), aLayer);
myLayerIds.Add (Graphic3d_ZLayerId_Topmost);
myLayerSeq.Append (Graphic3d_ZLayerId_Topmost);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Topmost, aSettings);
}
{
Graphic3d_ZLayerSettings aSettings;
aSettings.SetName ("OVERLAY");
aSettings.SetImmediate (Standard_True);
aSettings.SetRaytracable (Standard_False);
aSettings.SetEnvironmentTexture (Standard_False);
aSettings.SetEnableDepthTest (Standard_False);
aSettings.SetEnableDepthWrite (Standard_False);
aSettings.SetClearDepth (Standard_False);
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_TopOSD, 1, Handle(Select3D_BVHBuilder3d)());
aLayer->SetLayerSettings (aSettings);
myLayers.Append (aLayer);
myLayerIds.Bind (aLayer->LayerId(), aLayer);
myLayerIds.Add (Graphic3d_ZLayerId_TopOSD);
myLayerSeq.Append (Graphic3d_ZLayerId_TopOSD);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_TopOSD, aSettings);
}
}
@@ -142,130 +125,52 @@ void Graphic3d_GraphicDriver::RemoveIdentification(const Standard_Integer theId)
//=======================================================================
const Graphic3d_ZLayerSettings& Graphic3d_GraphicDriver::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
{
const Handle(Graphic3d_Layer)* aLayer = myLayerIds.Seek (theLayerId);
if (aLayer == NULL)
{
throw Standard_OutOfRange ("Graphic3d_GraphicDriver::ZLayerSettings, Layer with theLayerId does not exist");
}
return (*aLayer)->LayerSettings();
Standard_ASSERT_RAISE (myLayerIds.Contains (theLayerId), "Graphic3d_GraphicDriver::ZLayerSettings, Layer with theLayerId does not exist");
return myMapOfZLayerSettings.Find (theLayerId);
}
//=======================================================================
//function : ZLayers
//function : addZLayerIndex
//purpose :
//=======================================================================
void Graphic3d_GraphicDriver::ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
void Graphic3d_GraphicDriver::addZLayerIndex (const Graphic3d_ZLayerId theLayerId)
{
theLayerSeq.Clear();
// append normal layers
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
// remove index
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
if (!aLayer->IsImmediate())
if (aLayerIt.Value() == theLayerId)
{
theLayerSeq.Append (aLayer->LayerId());
myLayerSeq.Remove (aLayerIt);
break;
}
}
// append immediate layers
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
if (myMapOfZLayerSettings.Find (theLayerId).IsImmediate())
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
if (aLayer->IsImmediate())
{
theLayerSeq.Append (aLayer->LayerId());
}
myLayerSeq.Append (theLayerId);
return;
}
}
//=======================================================================
//function : InsertLayerBefore
//purpose :
//=======================================================================
void Graphic3d_GraphicDriver::InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter)
{
Standard_ASSERT_RAISE (theNewLayerId > 0,
"Graphic3d_GraphicDriver::InsertLayerBefore, negative and zero IDs are reserved");
Standard_ASSERT_RAISE (!myLayerIds.IsBound (theNewLayerId),
"Graphic3d_GraphicDriver::InsertLayerBefore, Layer with theLayerId already exists");
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, 1, Handle(Select3D_BVHBuilder3d)());
aNewLayer->SetLayerSettings (theSettings);
Handle(Graphic3d_Layer) anOtherLayer;
if (theLayerAfter != Graphic3d_ZLayerId_UNKNOWN
&& myLayerIds.Find (theLayerAfter, anOtherLayer))
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
{
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerIt.Value());
if (aSettings.IsImmediate())
{
if (aLayerIter.Value() == anOtherLayer)
aLayerIt.Previous();
if (aLayerIt.More())
{
myLayers.InsertBefore (aNewLayer, aLayerIter);
break;
myLayerSeq.InsertAfter (aLayerIt, theLayerId);
return;
}
// first non-immediate layer
myLayerSeq.Prepend (theLayerId);
return;
}
}
else
{
myLayers.Prepend (aNewLayer);
}
myLayerIds.Bind (theNewLayerId, aNewLayer);
}
//=======================================================================
//function : InsertLayerAfter
//purpose :
//=======================================================================
void Graphic3d_GraphicDriver::InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore)
{
Standard_ASSERT_RAISE (theNewLayerId > 0,
"Graphic3d_GraphicDriver::InsertLayerAfter, negative and zero IDs are reserved");
Standard_ASSERT_RAISE (!myLayerIds.IsBound (theNewLayerId),
"Graphic3d_GraphicDriver::InsertLayerAfter, Layer with theLayerId already exists");
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, 1, Handle(Select3D_BVHBuilder3d)());
aNewLayer->SetLayerSettings (theSettings);
Handle(Graphic3d_Layer) anOtherLayer;
if (theLayerBefore != Graphic3d_ZLayerId_UNKNOWN
&& myLayerIds.Find (theLayerBefore, anOtherLayer))
{
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
{
if (aLayerIter.Value() == anOtherLayer)
{
myLayers.InsertAfter (aNewLayer, aLayerIter);
break;
}
}
}
else
{
myLayers.Append (aNewLayer);
}
myLayerIds.Bind (theNewLayerId, aNewLayer);
}
//=======================================================================
//function : RemoveZLayer
//purpose :
//=======================================================================
void Graphic3d_GraphicDriver::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
{
Standard_ASSERT_RAISE (theLayerId > 0,
"Graphic3d_GraphicDriver::RemoveZLayer, negative and zero IDs are reserved and cannot be removed");
Handle(Graphic3d_Layer) aLayerDef;
myLayerIds.Find (theLayerId, aLayerDef);
Standard_ASSERT_RAISE (!aLayerDef.IsNull(),
"Graphic3d_GraphicDriver::RemoveZLayer, Layer with theLayerId does not exist");
myLayers.Remove (aLayerDef);
myLayerIds.UnBind (theLayerId);
// no immediate layers
myLayerSeq.Append (theLayerId);
}
//=======================================================================
@@ -275,9 +180,20 @@ void Graphic3d_GraphicDriver::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
void Graphic3d_GraphicDriver::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings)
{
Handle(Graphic3d_Layer) aLayerDef;
myLayerIds.Find (theLayerId, aLayerDef);
Standard_ASSERT_RAISE (!aLayerDef.IsNull(),
"Graphic3d_GraphicDriver::SetZLayerSettings, Layer with theLayerId does not exist");
aLayerDef->SetLayerSettings (theSettings);
Graphic3d_ZLayerSettings* aSettings = myMapOfZLayerSettings.ChangeSeek (theLayerId);
if (aSettings != NULL)
{
const bool isChanged = (aSettings->IsImmediate() != theSettings.IsImmediate());
*aSettings = theSettings;
if (isChanged)
{
addZLayerIndex (theLayerId);
}
}
else
{
// abnormal case
myMapOfZLayerSettings.Bind (theLayerId, theSettings);
addZLayerIndex (theLayerId);
}
}

View File

@@ -52,7 +52,6 @@
class Aspect_DisplayConnection;
class Graphic3d_CView;
class Graphic3d_GraphicDriver;
class Graphic3d_Layer;
class Graphic3d_TransformError;
class Graphic3d_Structure;
class Graphic3d_StructureManager;
@@ -66,7 +65,7 @@ DEFINE_STANDARD_HANDLE(Graphic3d_GraphicDriver, Standard_Transient)
//! for 3d interface (currently only OpenGl driver is used).
class Graphic3d_GraphicDriver : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriver, Standard_Transient)
public:
//! Request limit of graphic resource of specific type.
@@ -111,31 +110,24 @@ public:
Standard_ShortReal& theAscent,
Standard_ShortReal& theDescent) const = 0;
//! Adds a layer to all views.
//! To add a structure to desired layer on display it is necessary to set the layer ID for the structure.
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
//! @param theSettings [in] new layer settings
//! @param theLayerAfter [in] id of layer to append new layer before
Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter) = 0;
//! Adds a layer to all views.
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
//! @param theSettings [in] new layer settings
//! @param theLayerBefore [in] id of layer to append new layer after
Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore) = 0;
//! Add a new top-level z layer with ID <theLayerId> for
//! the view. Z layers allow drawing structures in higher layers
//! in foreground of structures in lower layers. To add a structure
//! to desired layer on display it is necessary to set the layer
//! ID for the structure.
virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
//! Removes Z layer. All structures displayed at the moment in layer will be displayed in
//! default layer (the bottom-level z layer). By default, there are always default
//! bottom-level layer that can't be removed. The passed theLayerId should be not less than 0
//! (reserved for default layers that can not be removed).
Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
//! Returns list of Z layers defined for the graphical driver.
Standard_EXPORT virtual void ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const;
virtual void ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
{
theLayerSeq.Assign (myLayerSeq);
}
//! Sets the settings for a single Z layer.
Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) = 0;
@@ -156,17 +148,23 @@ public:
//! Frees the identifier of a structure.
Standard_EXPORT void RemoveIdentification(const Standard_Integer theId);
DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,Standard_Transient)
protected:
//! Initializes the Driver
Standard_EXPORT Graphic3d_GraphicDriver(const Handle(Aspect_DisplayConnection)& theDisp);
//! Insert index layer at proper position.
Standard_EXPORT void addZLayerIndex (const Graphic3d_ZLayerId theLayerId);
protected:
Handle(Aspect_DisplayConnection) myDisplayConnection;
Aspect_GenId myStructGenId;
NCollection_List<Handle(Graphic3d_Layer)> myLayers;
NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
TColStd_MapOfInteger myLayerIds;
TColStd_SequenceOfInteger myLayerSeq;
Graphic3d_MapOfZLayerSettings myMapOfZLayerSettings;
};

View File

@@ -22,13 +22,11 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Layer, Standard_Transient)
// function : Graphic3d_Layer
// purpose :
// =======================================================================
Graphic3d_Layer::Graphic3d_Layer (Graphic3d_ZLayerId theId,
Standard_Integer theNbPriorities,
Graphic3d_Layer::Graphic3d_Layer (Standard_Integer theNbPriorities,
const Handle(Select3D_BVHBuilder3d)& theBuilder)
: myArray (0, theNbPriorities - 1),
myNbStructures (0),
myNbStructuresNotCulled (0),
myLayerId (theId),
myBVHPrimitivesTrsfPers (theBuilder),
myBVHIsLeftChildQueuedFirst (Standard_True),
myIsBVHPrimitivesNeedsReset (Standard_False)

View File

@@ -17,7 +17,6 @@
#include <Graphic3d_BvhCStructureSet.hxx>
#include <Graphic3d_BvhCStructureSetTrsfPers.hxx>
#include <Graphic3d_Camera.hxx>
#include <Graphic3d_ZLayerId.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
#include <Graphic3d_RenderingParams.hxx>
#include <NCollection_Array1.hxx>
@@ -39,16 +38,12 @@ class Graphic3d_Layer : public Standard_Transient
public:
//! Initializes associated priority list and layer properties
Standard_EXPORT Graphic3d_Layer (Graphic3d_ZLayerId theId,
Standard_Integer theNbPriorities,
Standard_EXPORT Graphic3d_Layer (Standard_Integer theNbPriorities,
const Handle(Select3D_BVHBuilder3d)& theBuilder);
//! Destructor.
Standard_EXPORT virtual ~Graphic3d_Layer();
//! Return layer id.
Graphic3d_ZLayerId LayerId() const { return myLayerId; }
//! Returns BVH tree builder for frustom culling.
const Handle(Select3D_BVHBuilder3d)& FrustumCullingBVHBuilder() const { return myBVHPrimitivesTrsfPers.Builder(); }
@@ -163,9 +158,6 @@ private:
//! Layer setting flags.
Graphic3d_ZLayerSettings myLayerSettings;
//! Layer id.
Graphic3d_ZLayerId myLayerId;
//! Set of Graphic3d_CStructures structures for building BVH tree.
mutable Graphic3d_BvhCStructureSet myBVHPrimitives;

View File

@@ -462,15 +462,6 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f, 0.970f, 0.970f));
break;
case Graphic3d_NOM_UserDefined:
MaterialType = Graphic3d_MATERIAL_PHYSIC;
ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f;
ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f;
ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f;
ColorCoef[Graphic3d_TOR_EMISSION] = 1.00f;
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.1f, 0.1f, 0.1f));
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.8f, 0.8f, 0.8f));
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.2f, 0.2f, 0.2f));
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f, 0.0f, 0.0f));
break;
case Graphic3d_NOM_DEFAULT:
break;

View File

@@ -38,7 +38,6 @@ struct Graphic3d_ZLayerSettings
: myCullingDistance (Precision::Infinite()),
myCullingSize (Precision::Infinite()),
myIsImmediate (Standard_False),
myToRaytrace (Standard_True),
myUseEnvironmentTexture (Standard_True),
myToEnableDepthTest (Standard_True),
myToEnableDepthWrite(Standard_True),
@@ -106,13 +105,6 @@ struct Graphic3d_ZLayerSettings
//! Set the flag indicating the immediate layer, which should be drawn after all normal (non-immediate) layers.
void SetImmediate (const Standard_Boolean theValue) { myIsImmediate = theValue; }
//! Returns TRUE if layer should be processed by ray-tracing renderer; TRUE by default.
//! Note that this flag is IGNORED for layers with IsImmediate() flag.
Standard_Boolean IsRaytracable() const { return myToRaytrace; }
//! Sets if layer should be processed by ray-tracing renderer.
void SetRaytracable (Standard_Boolean theToRaytrace) { myToRaytrace = theToRaytrace; }
//! Return flag to allow/prevent environment texture mapping usage for specific layer.
Standard_Boolean UseEnvironmentTexture() const { return myUseEnvironmentTexture; }
@@ -218,7 +210,6 @@ protected:
Standard_Real myCullingSize; //!< size to discard objects
Graphic3d_PolygonOffset myPolygonOffset; //!< glPolygonOffset() arguments
Standard_Boolean myIsImmediate; //!< immediate layer will be drawn after all normal layers
Standard_Boolean myToRaytrace; //!< option to render layer within ray-tracing engine
Standard_Boolean myUseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer
Standard_Boolean myToEnableDepthTest; //!< option to enable depth test
Standard_Boolean myToEnableDepthWrite; //!< option to enable write depth values

View File

@@ -132,7 +132,6 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
:
Tol(aTol),
done(Standard_False),
myReady(Standard_False),
nbpnt(0),
PtrOnPolyhedron(NULL),
PtrOnBndBounding(NULL),
@@ -176,7 +175,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
if (nbsu > aMaxSamples) nbsu = aMaxSamples;
if (nbsv > aMaxSamples) nbsv = aMaxSamples;
if (dU > Precision::Confusion() && dV > Precision::Confusion()) {
if (dU > gp::Resolution() && dV > gp::Resolution()) {
if (Max(dU, dV) > Min(dU, dV) * aTresh)
{
aMinSamples = 10;
@@ -191,7 +190,12 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
}
}
else {
return; // surface has no extension along one of directions
if (dU < gp::Resolution()) {
nbsu = 1;
}
if (dV < gp::Resolution()) {
nbsv = 1;
}
}
Standard_Integer NbUOnS = Hsurface->NbUIntervals(GeomAbs_C2);
@@ -211,7 +215,6 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
}
}
myReady = Standard_True;
}
//=======================================================================
//function : InternalCall
@@ -347,11 +350,6 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
const Standard_Real ParMin,
const Standard_Real ParMax)
{
done = Standard_False;
if (!myReady)
{
return;
}
done = Standard_True;
SeqPnt.Clear();
mySeqState.Clear();
@@ -430,11 +428,6 @@ void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_HCurve)& HCu,
const Standard_Real ParMin,
const Standard_Real ParMax)
{
done = Standard_False;
if (!myReady)
{
return;
}
done = Standard_True;
SeqPnt.Clear();
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin

View File

@@ -160,7 +160,6 @@ private:
IntCurveSurface_SequenceOfPnt SeqPnt;
TColStd_SequenceOfInteger mySeqState;
Standard_Boolean done;
Standard_Boolean myReady;
Standard_Integer nbpnt;
TopoDS_Face face;
Standard_Address PtrOnPolyhedron;

View File

@@ -34,12 +34,14 @@ static int OSD_OpenFile_iosMode2FileFlags (::std::ios_base::openmode theMode)
{
aFlags |= O_WRONLY;
aFlags |= O_CREAT;
aFlags |= O_TRUNC;
if (theMode & ::std::ios_base::app)
{
aFlags |= O_APPEND;
}
if (theMode & ::std::ios_base::trunc)
{
aFlags |= O_TRUNC;
}
}
#ifdef _WIN32
if (theMode & ::std::ios_base::binary)

View File

@@ -51,9 +51,6 @@ OpenGl_Caps::OpenGl_Caps()
#else
contextCompatible (Standard_False),
#endif
contextNoExtensions (Standard_False),
contextMajorVersionUpper (-1),
contextMinorVersionUpper (-1),
glslWarnings (Standard_False),
suppressExtraMsg (Standard_True),
glslDumpLevel (OpenGl_ShaderProgramDumpLevel_Off)
@@ -79,9 +76,6 @@ OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy)
contextSyncDebug = theCopy.contextSyncDebug;
contextNoAccel = theCopy.contextNoAccel;
contextCompatible = theCopy.contextCompatible;
contextNoExtensions = theCopy.contextNoExtensions;
contextMajorVersionUpper = theCopy.contextMajorVersionUpper;
contextMinorVersionUpper = theCopy.contextMinorVersionUpper;
glslWarnings = theCopy.glslWarnings;
suppressExtraMsg = theCopy.suppressExtraMsg;
glslDumpLevel = theCopy.glslDumpLevel;

View File

@@ -107,23 +107,6 @@ public: //! @name context creation parameters
*/
Standard_Boolean contextCompatible;
/**
* Disallow using OpenGL extensions.
* Should be used for debugging purposes only!
*
* OFF by default.
*/
Standard_Boolean contextNoExtensions;
/**
* Synthetically restrict upper version of OpenGL functionality to be used.
* Should be used for debugging purposes only!
*
* (-1, -1) by default, which means no restriction.
*/
Standard_Integer contextMajorVersionUpper;
Standard_Integer contextMinorVersionUpper;
public: //! @name flags to activate verbose output
//! Print GLSL program compilation/linkage warnings, if any. OFF by default.

View File

@@ -123,7 +123,6 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
hasTexRGBA8(Standard_True),
hasFlatShading (OpenGl_FeatureInCore),
#endif
hasGlslBitwiseOps (OpenGl_FeatureNotAvailable),
hasDrawBuffers (OpenGl_FeatureNotAvailable),
hasFloatBuffer (OpenGl_FeatureNotAvailable),
hasHalfFloatBuffer (OpenGl_FeatureNotAvailable),
@@ -750,10 +749,6 @@ Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const
#endif
return Standard_False;
}
else if (caps->contextNoExtensions)
{
return Standard_False;
}
#if !defined(GL_ES_VERSION_2_0)
// available since OpenGL 3.0
@@ -1222,44 +1217,6 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
ReadGlVersion (myGlVerMajor, myGlVerMinor);
myVendor = (const char* )::glGetString (GL_VENDOR);
myVendor.LowerCase();
if (caps->contextMajorVersionUpper != -1)
{
// synthetically restrict OpenGL version for testing
Standard_Integer aCtxVer[2] = { myGlVerMajor, myGlVerMinor };
bool isLowered = false;
if (myGlVerMajor > caps->contextMajorVersionUpper)
{
isLowered = true;
myGlVerMajor = caps->contextMajorVersionUpper;
#if defined(GL_ES_VERSION_2_0)
switch (myGlVerMajor)
{
case 2: myGlVerMinor = 0; break;
}
#else
switch (myGlVerMajor)
{
case 1: myGlVerMinor = 5; break;
case 2: myGlVerMinor = 1; break;
case 3: myGlVerMinor = 3; break;
}
#endif
}
if (caps->contextMinorVersionUpper != -1
&& myGlVerMinor > caps->contextMinorVersionUpper)
{
isLowered = true;
myGlVerMinor = caps->contextMinorVersionUpper;
}
if (isLowered)
{
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_MEDIUM,
TCollection_AsciiString ("OpenGL version ") + aCtxVer[0] + "." + aCtxVer[1]
+ " has been lowered to " + myGlVerMajor + "." + myGlVerMinor);
}
}
if (!caps->ffpEnable
&& !IsGlGreaterEqual (2, 0))
{
@@ -1479,9 +1436,6 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
hasSampleVariables = IsGlGreaterEqual (3, 2) ? OpenGl_FeatureInCore :
oesSampleVariables ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
hasGlslBitwiseOps = IsGlGreaterEqual (3, 0)
? OpenGl_FeatureInCore
: OpenGl_FeatureNotAvailable;
// without hasHighp, dFdx/dFdy precision is considered too low for flat shading (visual artifacts)
hasFlatShading = IsGlGreaterEqual (3, 0)
? OpenGl_FeatureInCore
@@ -1520,12 +1474,6 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
arbDrawBuffers ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
hasGlslBitwiseOps = IsGlGreaterEqual (3, 0)
? OpenGl_FeatureInCore
: CheckExtension ("GL_EXT_gpu_shader4")
? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
hasFloatBuffer = hasHalfFloatBuffer = IsGlGreaterEqual (3, 0) ? OpenGl_FeatureInCore :
CheckExtension ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
@@ -3041,16 +2989,9 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString
if ((theFlags & Graphic3d_DiagnosticInfo_Device) != 0)
{
Standard_Integer aDriverVer[2] = {};
ReadGlVersion (aDriverVer[0], aDriverVer[1]);
addInfo (theDict, "GLvendor", (const char*)::glGetString (GL_VENDOR));
addInfo (theDict, "GLdevice", (const char*)::glGetString (GL_RENDERER));
addInfo (theDict, "GLversion", (const char*)::glGetString (GL_VERSION));
if (myGlVerMajor != aDriverVer[0]
|| myGlVerMinor != aDriverVer[1])
{
addInfo (theDict, "GLversionOcct", TCollection_AsciiString (myGlVerMajor) + "." + TCollection_AsciiString (myGlVerMinor));
}
if (IsGlGreaterEqual (2, 0))
{
addInfo (theDict, "GLSLversion", (const char*)::glGetString (GL_SHADING_LANGUAGE_VERSION));
@@ -3555,23 +3496,8 @@ void OpenGl_Context::SetTypeOfLine (const Aspect_TypeOfLine theType,
if (!myActiveProgram.IsNull())
{
if (const OpenGl_ShaderUniformLocation aPatternLoc = myActiveProgram->GetStateLocation (OpenGl_OCCT_LINE_STIPPLE_PATTERN))
{
if (hasGlslBitwiseOps != OpenGl_FeatureNotAvailable)
{
myActiveProgram->SetUniform (this, aPatternLoc, aPattern);
}
else
{
Standard_Integer aPatArr[16] = {};
for (unsigned int aBit = 0; aBit < 16; ++aBit)
{
aPatArr[aBit] = ((unsigned int)(aPattern) & (1U << aBit)) != 0 ? 1 : 0;
}
myActiveProgram->SetUniform (this, aPatternLoc, 16, aPatArr);
}
myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_LINE_STIPPLE_FACTOR), theFactor);
}
myActiveProgram->SetUniform (this, "uPattern", aPattern);
myActiveProgram->SetUniform (this, "uFactor", theFactor);
return;
}

View File

@@ -889,7 +889,6 @@ public: //! @name extensions
Standard_Boolean hasUintIndex; //!< GLuint for index buffer is supported (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_element_index_uint)
Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
OpenGl_FeatureFlag hasFlatShading; //!< Complex flag indicating support of Flat shading (Graphic3d_TOSM_FACET) (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives)
OpenGl_FeatureFlag hasGlslBitwiseOps; //!< GLSL supports bitwise operations; OpenGL 3.0 / OpenGL ES 3.0 (GLSL 130 / GLSL ES 300) or OpenGL 2.1 + GL_EXT_gpu_shader4
OpenGl_FeatureFlag hasDrawBuffers; //!< Complex flag indicating support of multiple draw buffers (desktop OpenGL 2.0, OpenGL ES 3.0, GL_ARB_draw_buffers, GL_EXT_draw_buffers)
OpenGl_FeatureFlag hasFloatBuffer; //!< Complex flag indicating support of float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_float)
OpenGl_FeatureFlag hasHalfFloatBuffer; //!< Complex flag indicating support of half-float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_half_float)

View File

@@ -103,7 +103,7 @@ void OpenGl_FrameStats::updateStatistics (const Handle(Graphic3d_CView)& theView
|| (aBits & Graphic3d_RenderingParams::PerfCounters_Layers) != 0)
{
const Standard_Integer aViewId = aView->Identification();
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (aView->LayerList().Layers()); aLayerIter.More(); aLayerIter.Next())
for (OpenGl_SequenceOfLayers::Iterator aLayerIter (aView->LayerList().Layers()); aLayerIter.More(); aLayerIter.Next())
{
const Handle(OpenGl_Layer)& aLayer = aLayerIter.Value();
myCountersTmp[Graphic3d_FrameStatsCounter_NbStructs] += aLayer->NbStructures();

View File

@@ -303,10 +303,7 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext()
::Message::DefaultMessenger()->Send ("Error: EGL does not provide OpenGL ES client!", Message_Fail);
return Standard_False;
}
if (myCaps->contextMajorVersionUpper != 2)
{
myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs3);
}
myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs3);
if ((EGLContext )myEglContext == EGL_NO_CONTEXT)
{
myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs2);
@@ -529,36 +526,29 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
}
//=======================================================================
//function : InsertLayerBefore
//function : AddZLayer
//purpose :
//=======================================================================
void OpenGl_GraphicDriver::InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter)
void OpenGl_GraphicDriver::AddZLayer (const Graphic3d_ZLayerId theLayerId)
{
base_type::InsertLayerBefore (theLayerId, theSettings, theLayerAfter);
// Add layer to all views
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView); aViewIt.More(); aViewIt.Next())
if (theLayerId < 1)
{
aViewIt.Value()->InsertLayerBefore (theLayerId, theSettings, theLayerAfter);
Standard_ASSERT_RAISE (theLayerId > 0,
"OpenGl_GraphicDriver::AddZLayer, "
"negative and zero IDs are reserved");
}
}
//=======================================================================
//function : InsertLayerAfter
//purpose :
//=======================================================================
void OpenGl_GraphicDriver::InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore)
{
base_type::InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
myLayerIds.Add (theLayerId);
// Default z-layer settings
myMapOfZLayerSettings.Bind (theLayerId, Graphic3d_ZLayerSettings());
addZLayerIndex (theLayerId);
// Add layer to all views
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView); aViewIt.More(); aViewIt.Next())
NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView);
for (; aViewIt.More(); aViewIt.Next())
{
aViewIt.Value()->InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
aViewIt.Value()->AddZLayer (theLayerId);
}
}
@@ -568,21 +558,43 @@ void OpenGl_GraphicDriver::InsertLayerAfter (const Graphic3d_ZLayerId theNewLaye
//=======================================================================
void OpenGl_GraphicDriver::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
{
base_type::RemoveZLayer (theLayerId);
Standard_ASSERT_RAISE (theLayerId > 0,
"OpenGl_GraphicDriver::AddZLayer, "
"negative and zero IDs are reserved"
"and can not be removed");
Standard_ASSERT_RAISE (myLayerIds.Contains (theLayerId),
"OpenGl_GraphicDriver::RemoveZLayer, "
"Layer with theLayerId does not exist");
// Remove layer from all of the views
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView); aViewIt.More(); aViewIt.Next())
NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView);
for (; aViewIt.More(); aViewIt.Next())
{
aViewIt.Value()->RemoveZLayer (theLayerId);
}
// Unset Z layer for all of the structures.
for (NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator aStructIt (myMapOfStructure); aStructIt.More(); aStructIt.Next())
NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator aStructIt (myMapOfStructure);
for( ; aStructIt.More (); aStructIt.Next ())
{
OpenGl_Structure* aStruct = aStructIt.ChangeValue ();
if (aStruct->ZLayer() == theLayerId)
aStruct->SetZLayer (Graphic3d_ZLayerId_Default);
}
// Remove index
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
{
if (aLayerIt.Value() == theLayerId)
{
myLayerSeq.Remove (aLayerIt);
break;
}
}
myMapOfZLayerSettings.UnBind (theLayerId);
myLayerIds.Remove (theLayerId);
}
//=======================================================================
@@ -630,18 +642,23 @@ void OpenGl_GraphicDriver::RemoveStructure (Handle(Graphic3d_CStructure)& theCSt
}
// =======================================================================
// function : CreateView
// function : View
// purpose :
// =======================================================================
Handle(Graphic3d_CView) OpenGl_GraphicDriver::CreateView (const Handle(Graphic3d_StructureManager)& theMgr)
{
Handle(OpenGl_View) aView = new OpenGl_View (theMgr, this, myCaps, &myStateCounter);
myMapOfView.Add (aView);
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
aView->InsertLayerAfter (aLayer->LayerId(), aLayer->LayerSettings(), Graphic3d_ZLayerId_UNKNOWN);
const Graphic3d_ZLayerId aLayerID = aLayerIt.Value();
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerID);
aView->AddZLayer (aLayerID);
aView->SetZLayerSettings (aLayerID, aSettings);
}
return aView;
}

View File

@@ -108,21 +108,10 @@ public:
public:
//! Adds a layer to all views.
//! @param theLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
//! @param theSettings [in] new layer settings
//! @param theLayerAfter [in] id of layer to append new layer before
Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter) Standard_OVERRIDE;
//! Adds a layer to all views.
//! @param theLayerId [in] id of created layer
//! @param theSettings [in] new layer settings
//! @param theLayerBefore [in] id of layer to append new layer after
Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore) Standard_OVERRIDE;
//! Adds a new top-level z layer with ID theLayerId for all views. Z layers allow drawing structures in higher layers
//! in foreground of structures in lower layers. To add a structure to desired layer on display it is necessary to
//! set the layer index for the structure. The passed theLayerId should be not less than 0 (reserved for default layers).
Standard_EXPORT void AddZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
//! Removes Z layer. All structures displayed at the moment in layer will be displayed in
//! default layer (the bottom-level z layer). By default, there are always default

View File

@@ -16,14 +16,13 @@
#ifndef _OpenGl_LayerFilter_H__
#define _OpenGl_LayerFilter_H__
//! Tool object to specify processed OpenGL layers
//! for intermixed rendering of raytracable and non-raytracable layers.
//! Tool object to specify processed OpenGL layers.
enum OpenGl_LayerFilter
{
OpenGl_LF_All, //!< process all layers
OpenGl_LF_Upper, //!< process only top non-raytracable layers
OpenGl_LF_Bottom, //!< process only Graphic3d_ZLayerId_BotOSD
OpenGl_LF_RayTracable //!< process only normal raytracable layers (save the bottom layer)
OpenGl_LF_All, //!< process all layers
OpenGl_LF_Upper, //!< process only top layers
OpenGl_LF_Bottom, //!< process only bottom layer
OpenGl_LF_Default //!< process only default layer
};
#endif //_OpenGl_LayerFilter_H__

View File

@@ -29,13 +29,13 @@
namespace
{
//! Auxiliary class extending sequence iterator with index.
class OpenGl_IndexedLayerIterator : public NCollection_List<Handle(Graphic3d_Layer)>::Iterator
class OpenGl_IndexedLayerIterator : public OpenGl_SequenceOfLayers::Iterator
{
public:
//! Main constructor.
OpenGl_IndexedLayerIterator (const NCollection_List<Handle(Graphic3d_Layer)>& theSeq)
: NCollection_List<Handle(Graphic3d_Layer)>::Iterator (theSeq),
myIndex (1) {}
OpenGl_IndexedLayerIterator (const OpenGl_SequenceOfLayers& theSeq)
: OpenGl_SequenceOfLayers::Iterator (theSeq),
myIndex (theSeq.Lower()) {}
//! Return index of current position.
Standard_Integer Index() const { return myIndex; }
@@ -43,7 +43,7 @@ namespace
//! Move to the next position.
void Next()
{
NCollection_List<Handle(Graphic3d_Layer)>::Iterator::Next();
OpenGl_SequenceOfLayers::Iterator::Next();
++myIndex;
}
@@ -56,10 +56,12 @@ namespace
{
public:
//! Main constructor.
OpenGl_FilteredIndexedLayerIterator (const NCollection_List<Handle(Graphic3d_Layer)>& theSeq,
OpenGl_FilteredIndexedLayerIterator (const OpenGl_SequenceOfLayers& theSeq,
Standard_Integer theDefaultLayerIndex,
Standard_Boolean theToDrawImmediate,
OpenGl_LayerFilter theLayersToProcess)
: myIter (theSeq),
myDefaultLayerIndex (theDefaultLayerIndex),
myLayersToProcess (theLayersToProcess),
myToDrawImmediate (theToDrawImmediate)
{
@@ -88,8 +90,7 @@ namespace
{
for (; myIter.More(); myIter.Next())
{
const Handle(Graphic3d_Layer)& aLayer = myIter.Value();
if (aLayer->IsImmediate() != myToDrawImmediate)
if (myIter.Value()->IsImmediate() != myToDrawImmediate)
{
continue;
}
@@ -98,41 +99,39 @@ namespace
{
case OpenGl_LF_All:
{
return;
break;
}
case OpenGl_LF_Upper:
{
if (aLayer->LayerId() != Graphic3d_ZLayerId_BotOSD
&& (!aLayer->LayerSettings().IsRaytracable()
|| aLayer->IsImmediate()))
if (myIter.Index() <= myDefaultLayerIndex)
{
return;
continue;
}
break;
}
case OpenGl_LF_Bottom:
{
if (aLayer->LayerId() == Graphic3d_ZLayerId_BotOSD
&& !aLayer->LayerSettings().IsRaytracable())
if (myIter.Index() >= myDefaultLayerIndex)
{
return;
continue;
}
break;
}
case OpenGl_LF_RayTracable:
case OpenGl_LF_Default:
{
if (aLayer->LayerSettings().IsRaytracable()
&& !aLayer->IsImmediate())
if (myIter.Index() != myDefaultLayerIndex)
{
return;
continue;
}
break;
}
}
return;
}
}
private:
OpenGl_IndexedLayerIterator myIter;
Standard_Integer myDefaultLayerIndex;
OpenGl_LayerFilter myLayersToProcess;
Standard_Boolean myToDrawImmediate;
};
@@ -151,12 +150,31 @@ struct OpenGl_GlobalLayerSettings
OpenGl_LayerList::OpenGl_LayerList (const Standard_Integer theNbPriorities)
: myBVHBuilder (new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth)),
myDefaultLayerIndex (0),
myNbPriorities (theNbPriorities),
myNbStructures (0),
myImmediateNbStructures (0),
myModifStateOfRaytraceable (0)
{
//
// insert default priority layers
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
myLayerIds.Bind (Graphic3d_ZLayerId_BotOSD, myLayers.Upper());
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
myLayerIds.Bind (Graphic3d_ZLayerId_Default, myLayers.Upper());
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
myLayerIds.Bind (Graphic3d_ZLayerId_Top, myLayers.Upper());
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
myLayerIds.Bind (Graphic3d_ZLayerId_Topmost, myLayers.Upper());
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
myLayerIds.Bind (Graphic3d_ZLayerId_TopOSD, myLayers.Upper());
myDefaultLayerIndex = myLayerIds.Find (Graphic3d_ZLayerId_Default);
myTransparentToProcess.Allocate (myLayers.Length());
}
//=======================================================================
@@ -175,109 +193,85 @@ OpenGl_LayerList::~OpenGl_LayerList()
void OpenGl_LayerList::SetFrustumCullingBVHBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder)
{
myBVHBuilder = theBuilder;
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
for (OpenGl_SequenceOfLayers::Iterator anIts (myLayers); anIts.More(); anIts.Next())
{
aLayerIter.ChangeValue()->SetFrustumCullingBVHBuilder (theBuilder);
anIts.ChangeValue()->SetFrustumCullingBVHBuilder (theBuilder);
}
}
//=======================================================================
//function : InsertLayerBefore
//purpose :
//function : AddLayer
//purpose :
//=======================================================================
void OpenGl_LayerList::InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter)
void OpenGl_LayerList::AddLayer (const Graphic3d_ZLayerId theLayerId)
{
if (myLayerIds.IsBound (theNewLayerId))
if (myLayerIds.IsBound (theLayerId))
{
return;
}
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, myNbPriorities, myBVHBuilder);
aNewLayer->SetLayerSettings (theSettings);
// add the new layer
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
myLayerIds.Bind (theLayerId, myLayers.Length());
Handle(Graphic3d_Layer) anOtherLayer;
if (theLayerAfter != Graphic3d_ZLayerId_UNKNOWN
&& myLayerIds.Find (theLayerAfter, anOtherLayer))
{
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
{
if (aLayerIter.Value() == anOtherLayer)
{
myLayers.InsertBefore (aNewLayer, aLayerIter);
break;
}
}
}
else
{
myLayers.Prepend (aNewLayer);
}
myLayerIds.Bind (theNewLayerId, aNewLayer);
myTransparentToProcess.Allocate (myLayers.Size());
myTransparentToProcess.Allocate (myLayers.Length());
}
//=======================================================================
//function : InsertLayerAfter
//purpose :
//function : Layer
//purpose :
//=======================================================================
void OpenGl_LayerList::InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore)
OpenGl_Layer& OpenGl_LayerList::Layer (const Graphic3d_ZLayerId theLayerId)
{
if (myLayerIds.IsBound (theNewLayerId))
{
return;
}
return *myLayers.ChangeValue (myLayerIds.Find (theLayerId));
}
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, myNbPriorities, myBVHBuilder);
aNewLayer->SetLayerSettings (theSettings);
Handle(Graphic3d_Layer) anOtherLayer;
if (theLayerBefore != Graphic3d_ZLayerId_UNKNOWN
&& myLayerIds.Find (theLayerBefore, anOtherLayer))
{
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
{
if (aLayerIter.Value() == anOtherLayer)
{
myLayers.InsertAfter (aNewLayer, aLayerIter);
break;
}
}
}
else
{
myLayers.Append (aNewLayer);
}
myLayerIds.Bind (theNewLayerId, aNewLayer);
myTransparentToProcess.Allocate (myLayers.Size());
//=======================================================================
//function : Layer
//purpose :
//=======================================================================
const OpenGl_Layer& OpenGl_LayerList::Layer (const Graphic3d_ZLayerId theLayerId) const
{
return *myLayers.Value (myLayerIds.Find (theLayerId));
}
//=======================================================================
//function : RemoveLayer
//purpose :
//=======================================================================
void OpenGl_LayerList::RemoveLayer (const Graphic3d_ZLayerId theLayerId)
{
Handle(Graphic3d_Layer) aLayerToRemove;
if (theLayerId <= 0
|| !myLayerIds.Find (theLayerId, aLayerToRemove))
if (!myLayerIds.IsBound (theLayerId)
|| theLayerId <= 0)
{
return;
}
const Standard_Integer aRemovePos = myLayerIds.Find (theLayerId);
// move all displayed structures to first layer
myLayerIds.Find (Graphic3d_ZLayerId_Default)->Append (*aLayerToRemove);
{
const OpenGl_Layer& aLayerToMove = *myLayers.Value (aRemovePos);
myLayers.ChangeFirst()->Append (aLayerToMove);
}
// remove layer
myLayers.Remove (aLayerToRemove);
myLayers.Remove (aRemovePos);
myLayerIds.UnBind (theLayerId);
myTransparentToProcess.Allocate (myLayers.Size());
// updated sequence indexes in map
for (OpenGl_LayerSeqIds::Iterator aMapIt (myLayerIds); aMapIt.More(); aMapIt.Next())
{
Standard_Integer& aSeqIdx = aMapIt.ChangeValue();
if (aSeqIdx > aRemovePos)
aSeqIdx--;
}
myDefaultLayerIndex = myLayerIds.Find (Graphic3d_ZLayerId_Default);
myTransparentToProcess.Allocate (myLayers.Length());
}
//=======================================================================
@@ -292,11 +286,13 @@ void OpenGl_LayerList::AddStructure (const OpenGl_Structure* theStruct,
{
// add structure to associated layer,
// if layer doesn't exists, display structure in default layer
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theLayerId);
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
aLayer->Add (theStruct, thePriority, isForChangePriority);
Standard_Integer aSeqPos = myLayers.Lower();
myLayerIds.Find (theLayerId, aSeqPos);
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
aLayer.Add (theStruct, thePriority, isForChangePriority);
++myNbStructures;
if (aLayer->IsImmediate())
if (aLayer.IsImmediate())
{
++myImmediateNbStructures;
}
@@ -314,23 +310,25 @@ void OpenGl_LayerList::AddStructure (const OpenGl_Structure* theStruct,
void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
{
const Graphic3d_ZLayerId aLayerId = theStructure->ZLayer();
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (aLayerId);
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
Standard_Integer aSeqPos = myLayers.Lower();
myLayerIds.Find (aLayerId, aSeqPos);
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
Standard_Integer aPriority = -1;
// remove structure from associated list
// if the structure is not found there,
// scan through layers and remove it
if (aLayer->Remove (theStructure, aPriority))
if (aLayer.Remove (theStructure, aPriority))
{
--myNbStructures;
if (aLayer->IsImmediate())
if (aLayer.IsImmediate())
{
--myImmediateNbStructures;
}
if (aLayer->LayerSettings().IsRaytracable()
if (aLayerId == Graphic3d_ZLayerId_Default
&& theStructure->IsRaytracable())
{
++myModifStateOfRaytraceable;
@@ -340,23 +338,23 @@ void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
}
// scan through layers and remove it
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
{
const Handle(Graphic3d_Layer)& aLayerEx = aLayerIter.ChangeValue();
if (aLayerEx == aLayer)
OpenGl_Layer& aLayerEx = *anIts.ChangeValue();
if (aSeqPos == anIts.Index())
{
continue;
}
if (aLayerEx->Remove (theStructure, aPriority))
if (aLayerEx.Remove (theStructure, aPriority))
{
--myNbStructures;
if (aLayerEx->IsImmediate())
if (aLayerEx.IsImmediate())
{
--myImmediateNbStructures;
}
if (aLayerEx->LayerSettings().IsRaytracable()
if (anIts.Index() == myDefaultLayerIndex
&& theStructure->IsRaytracable())
{
++myModifStateOfRaytraceable;
@@ -372,9 +370,10 @@ void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
//=======================================================================
void OpenGl_LayerList::InvalidateBVHData (const Graphic3d_ZLayerId theLayerId)
{
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theLayerId);
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
aLayer->InvalidateBVHData();
Standard_Integer aSeqPos = myLayers.Lower();
myLayerIds.Find (theLayerId, aSeqPos);
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
aLayer.InvalidateBVHData();
}
//=======================================================================
@@ -386,24 +385,23 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure* theStructure,
const Graphic3d_ZLayerId theOldLayerId,
const Graphic3d_ZLayerId theNewLayerId)
{
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theOldLayerId);
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
Standard_Integer aSeqPos = myLayers.Lower();
myLayerIds.Find (theOldLayerId, aSeqPos);
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
Standard_Integer aPriority = -1;
// take priority and remove structure from list found by <theOldLayerId>
// if the structure is not found there, scan through all other layers
if (aLayer->Remove (theStructure, aPriority, Standard_False))
if (aLayer.Remove (theStructure, aPriority, Standard_False))
{
if (aLayer->LayerSettings().IsRaytracable()
&& !aLayer->LayerSettings().IsImmediate()
&& theStructure->IsRaytracable())
if (theOldLayerId == Graphic3d_ZLayerId_Default
&& theStructure->IsRaytracable())
{
++myModifStateOfRaytraceable;
}
--myNbStructures;
if (aLayer->IsImmediate())
if (aLayer.IsImmediate())
{
--myImmediateNbStructures;
}
@@ -415,26 +413,25 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure* theStructure,
}
// scan through layers and remove it
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
{
const Handle(OpenGl_Layer)& aLayerEx = aLayerIter.ChangeValue();
if (aLayerEx == aLayer)
if (aSeqPos == anIts.Index())
{
continue;
}
// try to remove structure and get priority value from this layer
if (aLayerEx->Remove (theStructure, aPriority, Standard_True))
OpenGl_Layer& aLayerEx = *anIts.ChangeValue();
if (aLayerEx.Remove (theStructure, aPriority, Standard_True))
{
if (aLayerEx->LayerSettings().IsRaytracable()
&& !aLayerEx->LayerSettings().IsImmediate()
&& theStructure->IsRaytracable())
if (anIts.Index() == myDefaultLayerIndex
&& theStructure->IsRaytracable())
{
++myModifStateOfRaytraceable;
}
--myNbStructures;
if (aLayerEx->IsImmediate())
if (aLayerEx.IsImmediate())
{
--myImmediateNbStructures;
}
@@ -455,15 +452,15 @@ void OpenGl_LayerList::ChangePriority (const OpenGl_Structure* theStructure,
const Graphic3d_ZLayerId theLayerId,
const Standard_Integer theNewPriority)
{
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theLayerId);
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
Standard_Integer aSeqPos = myLayers.Lower();
myLayerIds.Find (theLayerId, aSeqPos);
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
Standard_Integer anOldPriority = -1;
if (aLayer->Remove (theStructure, anOldPriority, Standard_True))
if (aLayer.Remove (theStructure, anOldPriority, Standard_True))
{
--myNbStructures;
if (aLayer->IsImmediate())
if (aLayer.IsImmediate())
{
--myImmediateNbStructures;
}
@@ -472,18 +469,18 @@ void OpenGl_LayerList::ChangePriority (const OpenGl_Structure* theStructure,
return;
}
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
{
const Handle(OpenGl_Layer)& aLayerEx = aLayerIter.ChangeValue();
if (aLayerEx == aLayer)
if (aSeqPos == anIts.Index())
{
continue;
}
if (aLayerEx->Remove (theStructure, anOldPriority, Standard_True))
OpenGl_Layer& aLayerEx = *anIts.ChangeValue();
if (aLayerEx.Remove (theStructure, anOldPriority, Standard_True))
{
--myNbStructures;
if (aLayerEx->IsImmediate())
if (aLayerEx.IsImmediate())
{
--myImmediateNbStructures;
}
@@ -501,12 +498,7 @@ void OpenGl_LayerList::ChangePriority (const OpenGl_Structure* theStructure,
void OpenGl_LayerList::SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings)
{
Graphic3d_Layer& aLayer = Layer (theLayerId);
if (aLayer.LayerSettings().IsRaytracable() != theSettings.IsRaytracable()
&& aLayer.NbStructures() != 0)
{
++myModifStateOfRaytraceable;
}
OpenGl_Layer& aLayer = Layer (theLayerId);
if (aLayer.LayerSettings().IsImmediate() != theSettings.IsImmediate())
{
if (theSettings.IsImmediate())
@@ -534,15 +526,15 @@ void OpenGl_LayerList::UpdateCulling (const Handle(OpenGl_Workspace)& theWorkspa
const Standard_Integer aViewId = theWorkspace->View()->Identification();
const Graphic3d_CullingTool& aSelector = theWorkspace->View()->BVHTreeSelector();
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.ChangeValue();
if (aLayer->IsImmediate() != theToDrawImmediate)
OpenGl_Layer& aLayer = *anIts.ChangeValue();
if (aLayer.IsImmediate() != theToDrawImmediate)
{
continue;
}
aLayer->UpdateCulling (aViewId, aSelector, theWorkspace->View()->RenderingParams().FrustumCullingState);
aLayer.UpdateCulling (aViewId, aSelector, theWorkspace->View()->RenderingParams().FrustumCullingState);
}
aTimer.Stop();
@@ -724,7 +716,7 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace,
const bool toPerformDepthPrepass = theWorkspace->View()->RenderingParams().ToEnableDepthPrepass
&& aPrevSettings.DepthMask == GL_TRUE;
const Handle(Graphic3d_LightSet) aLightsBack = aCtx->ShaderManager()->LightSourceState().LightSources();
for (OpenGl_FilteredIndexedLayerIterator aLayerIterStart (myLayers, theToDrawImmediate, theLayersToProcess); aLayerIterStart.More();)
for (OpenGl_FilteredIndexedLayerIterator aLayerIterStart (myLayers, myDefaultLayerIndex, theToDrawImmediate, theLayersToProcess); aLayerIterStart.More();)
{
bool hasSkippedDepthLayers = false;
for (int aPassIter = toPerformDepthPrepass ? 0 : 2; aPassIter < 3; ++aPassIter)

View File

@@ -29,6 +29,9 @@ class OpenGl_Structure;
class OpenGl_Workspace;
struct OpenGl_GlobalLayerSettings;
typedef NCollection_Sequence<Handle(OpenGl_Layer)> OpenGl_SequenceOfLayers;
typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
//! Class defining the list of layers.
class OpenGl_LayerList
{
@@ -50,14 +53,7 @@ public:
Standard_Integer NbImmediateStructures() const { return myImmediateNbStructures; }
//! Insert a new layer with id.
void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter);
//! Insert a new layer with id.
void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore);
void AddLayer (const Graphic3d_ZLayerId theLayerId);
//! Remove layer by its id.
void RemoveLayer (const Graphic3d_ZLayerId theLayerId);
@@ -86,10 +82,10 @@ public:
const Standard_Integer theNewPriority);
//! Returns reference to the layer with given ID.
OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) { return *myLayerIds.Find (theLayerId); }
OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId);
//! Returns reference to the layer with given ID.
const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const { return *myLayerIds.Find (theLayerId); }
const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const;
//! Assign new settings to the layer.
void SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
@@ -107,10 +103,10 @@ public:
OpenGl_FrameBuffer* theOitAccumFbo) const;
//! Returns the set of OpenGL Z-layers.
const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const { return myLayers; }
const OpenGl_SequenceOfLayers& Layers() const { return myLayers; }
//! Returns the map of Z-layer IDs to indexes.
const NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)>& LayerIDs() const { return myLayerIds; }
const OpenGl_LayerSeqIds& LayerIDs() const { return myLayerIds; }
//! Marks BVH tree for given priority list as dirty and
//! marks primitive set for rebuild.
@@ -138,14 +134,13 @@ protected:
{
if (theSize > 0)
{
myStackSpace.Resize (1, theSize, false);
myStackSpace.Init (NULL);
myBackPtr = myStackSpace.begin();
myStackSpace = new NCollection_Array1<const Graphic3d_Layer*> (1, theSize);
myStackSpace->Init (NULL);
myBackPtr = myStackSpace->begin();
}
else
{
NCollection_Array1<const Graphic3d_Layer*> aDummy;
myStackSpace.Move (aDummy);
myStackSpace.Nullify();
myBackPtr = iterator();
}
}
@@ -153,15 +148,18 @@ protected:
//! Clear stack.
void Clear()
{
myStackSpace.Init (NULL);
myBackPtr = myStackSpace.begin();
if (!myStackSpace.IsNull())
{
myStackSpace->Init (NULL);
myBackPtr = myStackSpace->begin();
}
}
//! Push a new layer reference to the stack.
void Push (const OpenGl_Layer* theLayer) { (*myBackPtr++) = theLayer; }
//! Returns iterator to the origin of the stack.
iterator Origin() const { return myStackSpace.IsEmpty() ? iterator() : myStackSpace.begin(); }
iterator Origin() const { return myStackSpace.IsNull() ? iterator() : myStackSpace->begin(); }
//! Returns iterator to the back of the stack (after last item added).
iterator Back() const { return myBackPtr; }
@@ -171,8 +169,8 @@ protected:
private:
NCollection_Array1<const OpenGl_Layer*> myStackSpace;
iterator myBackPtr;
NCollection_Handle<NCollection_Array1<const OpenGl_Layer*> > myStackSpace;
iterator myBackPtr;
};
//! Render transparent objects using blending operator.
@@ -197,9 +195,11 @@ protected:
protected:
NCollection_List<Handle(Graphic3d_Layer)> myLayers;
NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
// number of structures temporary put to default layer
OpenGl_SequenceOfLayers myLayers;
OpenGl_LayerSeqIds myLayerIds;
Handle(Select3D_BVHBuilder3d) myBVHBuilder; //!< BVH tree builder for frustom culling
Standard_Integer myDefaultLayerIndex; //!< index of Graphic3d_ZLayerId_Default layer in myLayers sequence
Standard_Integer myNbPriorities;
Standard_Integer myNbStructures;

View File

@@ -1505,8 +1505,6 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
bool theUsesDerivates) const
{
int aBits = theBits;
const bool toUseDerivates = theUsesDerivates
|| (theBits & OpenGl_PO_StippleLine) != 0;
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core32 != NULL)
{
@@ -1520,15 +1518,19 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
{
theProgram->SetHeader ("#version 130");
}
else if (myContext->CheckExtension ("GL_EXT_gpu_shader4")) // myContext->hasGlslBitwiseOps == OpenGl_FeatureInExtensions
else if (myContext->CheckExtension ("GL_EXT_gpu_shader4"))
{
// GL_EXT_gpu_shader4 defines GLSL type "unsigned int", while core GLSL specs define type "uint"
theProgram->SetHeader ("#extension GL_EXT_gpu_shader4 : enable\n"
"#define uint unsigned int");
}
else
{
aBits = aBits & ~OpenGl_PO_StippleLine;
}
}
}
(void )toUseDerivates;
(void )theUsesDerivates;
#else
// prefer "100 es" on OpenGL ES 3.0- devices (save the features unavailable before "300 es")
// and "300 es" on OpenGL ES 3.1+ devices
@@ -1555,13 +1557,10 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
else
{
aBits = aBits & ~OpenGl_PO_WriteOit;
if (!myContext->oesStdDerivatives)
{
aBits = aBits & ~OpenGl_PO_StippleLine;
}
aBits = aBits & ~OpenGl_PO_StippleLine;
}
}
if (toUseDerivates)
if (theUsesDerivates)
{
if (myContext->IsGlGreaterEqual (3, 0))
{
@@ -1820,34 +1819,28 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
const Standard_Integer aBits = defaultGlslVersion (aProgramSrc, "unlit", theBits);
if ((aBits & OpenGl_PO_StippleLine) != 0)
{
if (myContext->hasGlslBitwiseOps != OpenGl_FeatureNotAvailable)
{
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int occStipplePattern", Graphic3d_TOS_FRAGMENT));
}
else
{
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("bool occStipplePattern[16]", Graphic3d_TOS_FRAGMENT));
}
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float occStippleFactor", Graphic3d_TOS_FRAGMENT));
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uPattern", Graphic3d_TOS_FRAGMENT));
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor", Graphic3d_TOS_FRAGMENT));
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 occViewport", Graphic3d_TOS_VERTEX));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec2 ScreenSpaceCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
aSrcVertEndMain =
EOL" vec2 aPosition = gl_Position.xy / gl_Position.w;"
EOL" aPosition = aPosition * 0.5 + 0.5;"
EOL" ScreenSpaceCoord = aPosition.xy * occViewport.zw + occViewport.xy;";
aSrcFragMainGetColor = TCollection_AsciiString()
+ EOL" vec2 anAxis = vec2 (0.0, 1.0);"
aSrcFragMainGetColor =
EOL" vec2 anAxis = vec2 (0.0);"
EOL" if (abs (dFdx (ScreenSpaceCoord.x)) - abs (dFdy (ScreenSpaceCoord.y)) > 0.001)"
EOL" {"
EOL" anAxis = vec2 (1.0, 0.0);"
EOL" }"
EOL" else"
EOL" {"
EOL" anAxis = vec2 (0.0, 1.0);"
EOL" }"
EOL" float aRotatePoint = dot (gl_FragCoord.xy, anAxis);"
+ (myContext->hasGlslBitwiseOps != OpenGl_FeatureNotAvailable
? EOL" uint aBit = uint (floor (aRotatePoint / occStippleFactor + 0.5)) & 15U;"
EOL" if ((uint (occStipplePattern) & (1U << aBit)) == 0U) discard;"
: EOL" int aBit = int (mod (floor (aRotatePoint / occStippleFactor + 0.5), 16.0));"
EOL" if (!occStipplePattern[aBit]) discard;")
+ EOL" vec4 aColor = getFinalColor();"
EOL" uint aBit = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
EOL" if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
EOL" vec4 aColor = getFinalColor();"
EOL" if (aColor.a <= 0.1) discard;"
EOL" occSetFragColor (aColor);";
}

View File

@@ -81,8 +81,6 @@ Standard_CString OpenGl_ShaderProgram::PredefinedKeywords[] =
"occViewport", // OpenGl_OCCT_VIEWPORT
"occLineWidth", // OpenGl_OCCT_LINE_WIDTH
"occLineFeather", // OpenGl_OCCT_LINE_FEATHER
"occStipplePattern", // OpenGl_OCCT_LINE_STIPPLE_PATTERN
"occStippleFactor", // OpenGl_OCCT_LINE_STIPPLE_FACTOR
"occWireframeColor", // OpenGl_OCCT_WIREFRAME_COLOR
"occIsQuadMode", // OpenGl_OCCT_QUAD_MODE_STATE

View File

@@ -79,8 +79,6 @@ enum OpenGl_StateVariable
OpenGl_OCCT_VIEWPORT,
OpenGl_OCCT_LINE_WIDTH,
OpenGl_OCCT_LINE_FEATHER,
OpenGl_OCCT_LINE_STIPPLE_PATTERN, // occStipplePattern
OpenGl_OCCT_LINE_STIPPLE_FACTOR, // occStippleFactor
OpenGl_OCCT_WIREFRAME_COLOR,
OpenGl_OCCT_QUAD_MODE_STATE,

View File

@@ -31,7 +31,13 @@
namespace
{
static const OpenGl_Mat4d THE_IDENTITY_MATRIX;
static const GLdouble THE_IDENTITY_MATRIX[16] =
{
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
static const TCollection_AsciiString THE_DEFAULT_FONT (Font_NOF_ASCII_MONO);
@@ -74,7 +80,10 @@ namespace
// purpose :
// =======================================================================
OpenGl_Text::OpenGl_Text()
: myScaleHeight (1.0f),
: myWinX (0.0f),
myWinY (0.0f),
myWinZ (0.0f),
myScaleHeight (1.0f),
myPoint (0.0f, 0.0f, 0.0f),
myIs2d (false),
myHasPlane (false),
@@ -92,7 +101,10 @@ OpenGl_Text::OpenGl_Text()
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
const OpenGl_Vec3& thePoint,
const OpenGl_TextParam& theParams)
: myScaleHeight (1.0f),
: myWinX (0.0f),
myWinY (0.0f),
myWinZ (0.0f),
myScaleHeight (1.0f),
myExportHeight (1.0f),
myParams (theParams),
myString (theText),
@@ -112,7 +124,10 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
const gp_Ax2& theOrientation,
const OpenGl_TextParam& theParams,
const bool theHasOwnAnchor)
: myScaleHeight (1.0),
: myWinX (0.0),
myWinY (0.0),
myWinZ (0.0),
myScaleHeight (1.0),
myExportHeight (1.0),
myParams (theParams),
myString (theText),
@@ -347,15 +362,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
// Bind custom shader program or generate default version
aCtx->ShaderManager()->BindFontProgram (aTextAspect->ShaderProgramRes (aCtx));
if (myHasPlane && myHasAnchorPoint)
{
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
// reset translation part
myOrientationMatrix.ChangeValue (0, 3) = 0.0;
myOrientationMatrix.ChangeValue (1, 3) = 0.0;
myOrientationMatrix.ChangeValue (2, 3) = 0.0;
}
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
myProjMatrix.Convert (aCtx->ProjectionState.Current());
// use highlight color or colors from aspect
@@ -410,7 +417,8 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec3& theDVec) const
{
OpenGl_Mat4d aModViewMat, aProjectMat;
OpenGl_Mat4d aModViewMat;
OpenGl_Mat4d aProjectMat;
if (myHasPlane && myHasAnchorPoint)
{
aProjectMat = myProjMatrix * myOrientationMatrix;
@@ -428,20 +436,18 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
}
else
{
OpenGl_Vec3d anObjXYZ;
OpenGl_Vec3d aWinXYZ = myWinXYZ + OpenGl_Vec3d (theDVec);
if (!myHasPlane && !theTextAspect.Aspect()->IsTextZoomable())
{
// Align coordinates to the nearest integer to avoid extra interpolation issues.
// Note that for better readability we could also try aligning freely rotated in 3D text (myHasPlane),
// when camera orientation co-aligned with horizontal text orientation,
// but this might look awkward while rotating camera.
aWinXYZ.x() = Floor (aWinXYZ.x());
aWinXYZ.y() = Floor (aWinXYZ.y());
}
Graphic3d_TransformUtils::UnProject<Standard_Real> (aWinXYZ.x(), aWinXYZ.y(), aWinXYZ.z(),
THE_IDENTITY_MATRIX, aProjectMat, theCtx->Viewport(),
anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
// align coordinates to the nearest integer
// to avoid extra interpolation issues
GLdouble anObjX, anObjY, anObjZ;
Graphic3d_TransformUtils::UnProject<Standard_Real> (std::floor (myWinX + theDVec.x()),
std::floor (myWinY + theDVec.y()),
myWinZ + theDVec.z(),
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
OpenGl_Mat4d::Map (aProjectMat),
theCtx->Viewport(),
anObjX,
anObjY,
anObjZ);
if (myHasPlane)
{
@@ -462,12 +468,12 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
}
else
{
aModViewMat.SetColumn (3, anObjXYZ);
aModViewMat.SetColumn (3, OpenGl_Vec3d (anObjX, anObjY, anObjZ));
}
}
else
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.0, 0.0, 1.0);
}
@@ -731,7 +737,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
{
Graphic3d_TransformUtils::Project<Standard_Real> (myPoint.x(), myPoint.y(), myPoint.z(),
myModelMatrix, myProjMatrix, theCtx->Viewport(),
myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z());
myWinX, myWinY, myWinZ);
// compute scale factor for constant text height
if (theTextAspect.Aspect()->IsTextZoomable())
@@ -741,11 +747,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
else
{
Graphic3d_Vec3d aPnt1, aPnt2;
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z(),
THE_IDENTITY_MATRIX, myProjMatrix, theCtx->Viewport(),
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX, myWinY, myWinZ,
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX), myProjMatrix, theCtx->Viewport(),
aPnt1.x(), aPnt1.y(), aPnt1.z());
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y() + aPointSize, myWinXYZ.z(),
THE_IDENTITY_MATRIX, myProjMatrix, theCtx->Viewport(),
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX, myWinY + aPointSize, myWinZ,
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX), myProjMatrix, theCtx->Viewport(),
aPnt2.x(), aPnt2.y(), aPnt2.z());
myScaleHeight = (aPnt2.y() - aPnt1.y()) / aPointSize;
}

View File

@@ -160,7 +160,9 @@ protected:
mutable OpenGl_Mat4d myProjMatrix;
mutable OpenGl_Mat4d myModelMatrix;
mutable OpenGl_Mat4d myOrientationMatrix;
mutable OpenGl_Vec3d myWinXYZ;
mutable GLdouble myWinX;
mutable GLdouble myWinY;
mutable GLdouble myWinZ;
mutable GLdouble myScaleHeight;
mutable GLdouble myExportHeight;

View File

@@ -488,25 +488,12 @@ void OpenGl_View::SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle)
}
//=======================================================================
//function : InsertLayerBefore
//function : AddZLayer
//purpose :
//=======================================================================
void OpenGl_View::InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter)
void OpenGl_View::AddZLayer (const Graphic3d_ZLayerId theLayerId)
{
myZLayers.InsertLayerBefore (theLayerId, theSettings, theLayerAfter);
}
//=======================================================================
//function : InsertLayerAfter
//purpose :
//=======================================================================
void OpenGl_View::InsertLayerAfter (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore)
{
myZLayers.InsertLayerAfter (theLayerId, theSettings, theLayerBefore);
myZLayers.AddLayer (theLayerId);
}
//=======================================================================
@@ -535,74 +522,83 @@ void OpenGl_View::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
Standard_Integer OpenGl_View::ZLayerMax() const
{
Standard_Integer aLayerMax = Graphic3d_ZLayerId_Default;
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myZLayers.Layers()); aLayerIter.More(); aLayerIter.Next())
for (OpenGl_LayerSeqIds::Iterator aMapIt(myZLayers.LayerIDs()); aMapIt.More(); aMapIt.Next())
{
aLayerMax = Max (aLayerMax, aLayerIter.Value()->LayerId());
aLayerMax = Max (aLayerMax, aMapIt.Value());
}
return aLayerMax;
}
//=======================================================================
//function : Layers
//function : InvalidateZLayerBoundingBox
//purpose :
//=======================================================================
const NCollection_List<Handle(Graphic3d_Layer)>& OpenGl_View::Layers() const
void OpenGl_View::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const
{
return myZLayers.Layers();
if (myZLayers.LayerIDs().IsBound (theLayerId))
{
myZLayers.Layer (theLayerId).InvalidateBoundingBox();
}
else
{
const Standard_Integer aLayerMax = ZLayerMax();
for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId < aLayerMax; ++aLayerId)
{
if (myZLayers.LayerIDs().IsBound (aLayerId))
{
const OpenGl_Layer& aLayer = myZLayers.Layer (aLayerId);
if (aLayer.NbOfTransformPersistenceObjects() > 0)
{
aLayer.InvalidateBoundingBox();
}
}
}
}
}
//=======================================================================
//function : Layer
//function : ZLayerBoundingBox
//purpose :
//=======================================================================
Handle(Graphic3d_Layer) OpenGl_View::Layer (const Graphic3d_ZLayerId theLayerId) const
Bnd_Box OpenGl_View::ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
const Handle(Graphic3d_Camera)& theCamera,
const Standard_Integer theWindowWidth,
const Standard_Integer theWindowHeight,
const Standard_Boolean theToIncludeAuxiliary) const
{
Handle(Graphic3d_Layer) aLayer;
if (theLayerId != Graphic3d_ZLayerId_UNKNOWN)
Bnd_Box aBox;
if (myZLayers.LayerIDs().IsBound (theLayerId))
{
myZLayers.LayerIDs().Find (theLayerId, aLayer);
aBox = myZLayers.Layer (theLayerId).BoundingBox (Identification(),
theCamera,
theWindowWidth,
theWindowHeight,
theToIncludeAuxiliary);
}
return aLayer;
}
//=======================================================================
//function : MinMaxValues
//purpose :
//=======================================================================
Bnd_Box OpenGl_View::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const
{
if (!IsDefined())
{
return Bnd_Box();
}
Bnd_Box aBox = base_type::MinMaxValues (theToIncludeAuxiliary);
// add bounding box of gradient/texture background for proper Z-fit
if (theToIncludeAuxiliary
&& theLayerId == Graphic3d_ZLayerId_BotOSD
&& (myBgTextureArray->IsDefined()
|| myBgGradientArray->IsDefined()))
{
const Handle(Graphic3d_Camera)& aCamera = Camera();
Graphic3d_Vec2i aWinSize;
Window()->Size (aWinSize.x(), aWinSize.y());
// Background is drawn using 2D transformation persistence
// (e.g. it is actually placed in 3D coordinates within active camera position).
// We add here full-screen plane with 2D transformation persistence
// for simplicity (myBgTextureArray might define a little bit different options
// but it is updated within ::Render())
const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix();
const Graphic3d_Mat4d& aProjectionMat = theCamera->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = theCamera->OrientationMatrix();
Graphic3d_BndBox3d aBox2d (Graphic3d_Vec3d (0.0, 0.0, 0.0),
Graphic3d_Vec3d (double(aWinSize.x()), double(aWinSize.y()), 0.0));
Graphic3d_Vec3d (double(theWindowWidth), double(theWindowHeight), 0.0));
Graphic3d_TransformPers aTrsfPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER);
aTrsfPers.Apply (aCamera,
aTrsfPers.Apply (theCamera,
aProjectionMat,
aWorldViewMat,
aWinSize.x(),
aWinSize.y(),
theWindowWidth,
theWindowHeight,
aBox2d);
aBox.Add (gp_Pnt (aBox2d.CornerMin().x(), aBox2d.CornerMin().y(), aBox2d.CornerMin().z()));
aBox.Add (gp_Pnt (aBox2d.CornerMax().x(), aBox2d.CornerMax().y(), aBox2d.CornerMax().z()));
@@ -611,6 +607,26 @@ Bnd_Box OpenGl_View::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary)
return aBox;
}
//=======================================================================
//function : considerZoomPersistenceObjects
//purpose :
//=======================================================================
Standard_Real OpenGl_View::considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
const Handle(Graphic3d_Camera)& theCamera,
const Standard_Integer theWindowWidth,
const Standard_Integer theWindowHeight) const
{
if (myZLayers.LayerIDs().IsBound (theLayerId))
{
return myZLayers.Layer (theLayerId).considerZoomPersistenceObjects (Identification(),
theCamera,
theWindowWidth,
theWindowHeight);
}
return 1.0;
}
//=======================================================================
//function : FBO
//purpose :

View File

@@ -136,21 +136,8 @@ public:
//! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
Standard_EXPORT virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
//! Add a layer to the view.
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
//! @param theSettings [in] new layer settings
//! @param theLayerAfter [in] id of layer to append new layer before
Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter) Standard_OVERRIDE;
//! Add a layer to the view.
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
//! @param theSettings [in] new layer settings
//! @param theLayerBefore [in] id of layer to append new layer after
Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore) Standard_OVERRIDE;
//! Insert a new top-level z layer with the given ID.
Standard_EXPORT virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
//! Remove a z layer with the given ID.
Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
@@ -163,18 +150,23 @@ public:
//! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
Standard_EXPORT virtual Standard_Integer ZLayerMax() const Standard_OVERRIDE;
//! Returns the list of layers.
Standard_EXPORT virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const Standard_OVERRIDE;
//! Returns the bounding box of all structures displayed in the Z layer.
//! Never fails. If Z layer does not exist nothing happens.
Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const Standard_OVERRIDE;
//! Returns layer with given ID or NULL if undefined.
Standard_EXPORT virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const Standard_OVERRIDE;
//! Returns the bounding box of all structures displayed in the view.
//! If theToIncludeAuxiliary is TRUE, then the boundary box also includes minimum and maximum limits
//! of graphical elements forming parts of infinite and other auxiliary structures.
//! Returns the bounding box of all structures displayed in the Z layer.
//! If Z layer does not exist the empty box is returned.
//! @param theLayerId layer identifier
//! @param theCamera camera definition
//! @param theWindowWidth viewport width (for applying transformation-persistence)
//! @param theWindowHeight viewport height (for applying transformation-persistence)
//! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
//! @return computed bounding box
Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
Standard_EXPORT virtual Bnd_Box ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
const Handle(Graphic3d_Camera)& theCamera,
const Standard_Integer theWindowWidth,
const Standard_Integer theWindowHeight,
const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
//! Returns pointer to an assigned framebuffer object.
Standard_EXPORT virtual Handle(Standard_Transient) FBO() const Standard_OVERRIDE;
@@ -417,6 +409,12 @@ private:
Standard_EXPORT virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
const Standard_Integer theNewPriority) Standard_OVERRIDE;
//! Returns zoom-scale factor.
Standard_EXPORT virtual Standard_Real considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
const Handle(Graphic3d_Camera)& theCamera,
const Standard_Integer theWindowWidth,
const Standard_Integer theWindowHeight) const Standard_OVERRIDE;
private:
//! Copy content of Back buffer to the Front buffer.

View File

@@ -107,17 +107,12 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
// of changes in OpenGL scene (only for path tracing)
std::set<Standard_Integer> aNonRaytraceIDs;
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myZLayers.Layers()); aLayerIter.More(); aLayerIter.Next())
{
const Handle(OpenGl_Layer)& aLayer = aLayerIter.Value();
if (aLayer->NbStructures() == 0
|| !aLayer->LayerSettings().IsRaytracable()
|| aLayer->LayerSettings().IsImmediate())
{
continue;
}
const OpenGl_Layer& aLayer = myZLayers.Layer (Graphic3d_ZLayerId_Default);
if (aLayer.NbStructures() != 0)
{
const Graphic3d_ArrayOfIndexedMapOfStructure& aStructArray = aLayer.ArrayOfStructures();
const Graphic3d_ArrayOfIndexedMapOfStructure& aStructArray = aLayer->ArrayOfStructures();
for (Standard_Integer anIndex = 0; anIndex < aStructArray.Length(); ++anIndex)
{
for (OpenGl_Structure::StructIterator aStructIt (aStructArray.Value (anIndex)); aStructIt.More(); aStructIt.Next())

View File

@@ -1129,7 +1129,7 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
}
// Render non-polygonal elements in default layer
myZLayers.Render (myWorkspace, theToDrawImmediate, OpenGl_LF_RayTracable, theReadDrawFbo, theOitAccumFbo);
myZLayers.Render (myWorkspace, theToDrawImmediate, OpenGl_LF_Default, theReadDrawFbo, theOitAccumFbo);
}
myWorkspace->SetRenderFilter (aPrevFilter);
}

View File

@@ -14,6 +14,13 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// 26-Mar-96 : xab : inclusion des inlines trop gros
// 15-Oct-96 : alr : extraction des inlines (pas tous ceux inclus par xab)
// 19-Fev-97 : jct : ajout des methodes UVBox et UVConstraints (G1134)
// 10-Dec-97 : jag : Gros debug sur delete, et sur la methode Copy...
// 13-Jan-98 : alr : ajout des derivees pour contraintes G3 et approx. C2
// 28-Avr-98 : alr : Prise en compte des Linear*Constraint, methodes SolveTI1,SolveTI2,SolveTI3
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <math_Gauss.hxx>
@@ -767,7 +774,7 @@ void Plate_Plate::SolveTI3(const Standard_Integer IterationNumber, const Handle(
}
algo_gauss.Solve(sec_member, sol);
// iteration to refine the solution
//alr iteration pour affiner la solution
{
math_Vector sol1(0,n_dimat-1);
math_Vector sec_member1(0,n_dimat-1);
@@ -778,6 +785,7 @@ void Plate_Plate::SolveTI3(const Standard_Integer IterationNumber, const Handle(
sol += sol1;
}
}
//finalr
for(icoor=1; icoor<=3;icoor++){
for(i=0;i<nCC1;i++) Solution(i).SetCoord (icoor, sol((icoor-1)*n_dimsousmat+i));
@@ -1047,7 +1055,7 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const Standard_Inte
}
//=======================================================================
//function : Plate_Plate::CoefPol
//purpose : give back the array of power basis coefficient of
//purpose :give back the array of power basis coefficient of
// the polynomial part of the Plate function
//=======================================================================
@@ -1060,14 +1068,15 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const Standard_Inte
{
Coefs->ChangeValue(iu,iv) = Solution(i)*ddu[iu]*ddv[iv];
//Coefs->ChangeValue(idu,idv) = Solution(i);
// it is necessary to reset this line if one remove factors in method Polm.
// il faut remettre cette ligne si on enleve ls facteurs dans
// la methode Polm.
i++;
}
}
//=======================================================================
//function : Plate_Plate::Continuity
//purpose : give back the continuity order of the Plate function
//purpose :give back the continuity order of the Plate function
//=======================================================================
Standard_Integer Plate_Plate::Continuity() const
@@ -1077,7 +1086,7 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const Standard_Inte
//=======================================================================
//function : Plate_Plate::SolEm
//purpose : compute the (iu,iv)th derivative of the fundamental solution
//purpose : compute the (iu,iv)th derivative of the fondamental solution
// of Laplcian at the power order
//=======================================================================
@@ -1090,7 +1099,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
if(iv>iu)
{
// SolEm is symmetric in (u<->v) : we swap u and v if iv>iu
// SolEm is symetric in (u<->v) : we swap u and v if iv>iu
// to avoid some code
IU = iv;
IV = iu;
@@ -1126,8 +1135,8 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
//Standard_Real pr = pow(R, mm1 - IU - IV);
// this expression takes a lot of time
//(does not take into account a small integer value of the exponent)
// cette expression prend beaucoup de temps
//(ne tient pas compte de la petite valeur entiere de l'exposant)
//
Standard_Integer expo = mm1 - IU - IV;
@@ -1257,7 +1266,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real u2v2 = v2*U2;
Standard_Real r2 = r*r;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-100*ru2 + 48*L*ru2 + 140*m*ru2 - 100*L*m*ru2 - 60*m2*ru2 + 70*L*m2*ru2 + 8*m3*ru2 -
20*L*m3*ru2 + 2*L*m4*ru2 - 300*rv2 + 144*L*rv2 + 420*m*rv2 - 300*L*m*rv2 - 180*m2*rv2 + 210*L*m2*rv2 +
@@ -1282,7 +1291,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real u2v2 = v2*U2;
Standard_Real r2 = r*r;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
1644*ru2 - 720*L*ru2 - 2700*m*ru2 + 1644*L*m*ru2 + 1530*m2*ru2 - 1350*L*m2*ru2 -
360*m3*ru2 + 510*L*m3*ru2 + 30*m4*ru2 - 90*L*m4*ru2 + 6*L*m5*ru2 + 1644*rv2 - 720*L*rv2 - 2700*m*rv2 +
@@ -1326,7 +1335,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real ru2 = R*U2;
Standard_Real r2 = R*R;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-600*ru2 + 288*L*ru2 + 840*m*ru2 - 600*L*m*ru2 - 360*m2*ru2 + 420*L*m2*ru2 + 48*m3*ru2 -
120*L*m3*ru2 + 12*L*m4*ru2 + 33*r2 - 18*L*r2 - 36*m*r2 + 33*L*m*r2 + 9*m2*r2 - 18*L*m2*r2 + 3*L*m3*r2 +
@@ -1355,7 +1364,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real ru4 = r*u4;
Standard_Real r2v2 = r2*v2;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
6576*ru2v2 - 2880*L*ru2v2 - 10800*m*ru2v2 + 6576*L*m*ru2v2 + 6120*m2*ru2v2 - 5400*L*m2*ru2v2 -
1440*m3*ru2v2 + 2040*L*m3*ru2v2 + 120*m4*ru2v2 - 360*L*m4*ru2v2 + 24*L*m5*ru2v2 + 1096*ru4 - 480*L*ru4 -
@@ -1389,7 +1398,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2v2 = r2*v2;
Standard_Real ru4 = r*u4;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-42336*ru2v2 + 17280*L*ru2v2 + 77952*m*ru2v2 - 42336*L*m*ru2v2 - 52920*m2*ru2v2 +
38976*L*m2*ru2v2 + 16800*m3*ru2v2 - 17640*L*m3*ru2v2 - 2520*m4*ru2v2 + 4200*L*m4*ru2v2 + 144*m5*ru2v2 -
@@ -1425,7 +1434,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2 = R*R;
Standard_Real ru2 = R*U2;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-1000*ru2 + 480*L*ru2 + 1400*m*ru2 - 1000*L*m*ru2 - 600*m2*ru2 + 700*L*m2*ru2 + 80*m3*ru2 -
200*L*m3*ru2 + 20*L*m4*ru2 + 165*r2 - 90*L*r2 - 180*m*r2 + 165*L*m*r2 + 45*m2*r2 - 90*L*m2*r2 + 15*L*m3*r2 +
@@ -1448,7 +1457,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2 = r*r;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
5480*ru2 - 2400*L*ru2 - 9000*m*ru2 + 5480*L*m*ru2 + 5100*m2*ru2 - 4500*L*m2*ru2 - 1200*m3*ru2 +
1700*L*m3*ru2 + 100*m4*ru2 - 300*L*m4*ru2 + 20*L*m5*ru2 - 750*r2 + 360*L*r2 + 1050*m*r2 - 750*L*m*r2 -
@@ -1479,7 +1488,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2v2 = r2*v2;
Standard_Real ru4 = r*u4;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-70560*ru2v2 + 28800*L*ru2v2 + 129920*m*ru2v2 - 70560*L*m*ru2v2 - 88200*m2*ru2v2 +
@@ -1520,7 +1529,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2u2 = r2*U2;
Standard_Real ru4 = r*u4;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
16440*ru4 - 7200*L*ru4 - 27000*m*ru4 + 16440*L*m*ru4 + 15300*m2*ru4 - 13500*L*m2*ru4 -
3600*m3*ru4 + 5100*L*m3*ru4 + 300*m4*ru4 - 900*L*m4*ru4 + 60*L*m5*ru4 - 4500*r2u2 + 2160*L*r2u2 + 6300*m*r2u2 -

View File

@@ -43,24 +43,15 @@ public:
//! Returns the right-handed coordinate system set in SetComponent.
Standard_EXPORT Handle(Prs3d_ShadingAspect) ShadingAspect (Prs3d_DatumParts thePart) const;
//! Returns the text attributes for rendering labels.
//! Returns the right-handed coordinate system set in SetComponent.
const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
//! Sets text attributes for rendering labels.
void SetTextAspect (const Handle(Prs3d_TextAspect)& theTextAspect) { myTextAspect = theTextAspect; }
//! Returns the point aspect of origin wireframe presentation
const Handle(Prs3d_PointAspect)& PointAspect() const { return myPointAspect; }
//! Returns the point aspect of origin wireframe presentation
void SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect) { myPointAspect = theAspect; }
//! Returns the arrow aspect of presentation
const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; }
//! Sets the arrow aspect of presentation
void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) { myArrowAspect = theAspect; }
//! Returns the attributes for display of the first axis.
Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects.Find (Prs3d_DP_XAxis); }

View File

@@ -28,9 +28,7 @@ Prs3d_ToolDisk::Prs3d_ToolDisk (const Standard_Real theInnerRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
: myInnerRadius (theInnerRadius),
myOuterRadius (theOuterRadius),
myStartAngle (0.0),
myEndAngle (M_PI * 2.0)
myOuterRadius (theOuterRadius)
{
mySlicesNb = theNbSlices;
myStacksNb = theNbStacks;
@@ -42,13 +40,22 @@ Prs3d_ToolDisk::Prs3d_ToolDisk (const Standard_Real theInnerRadius,
//=======================================================================
gp_Pnt Prs3d_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
{
const Standard_Real aU = myStartAngle + theU * (myEndAngle - myStartAngle);
const Standard_Real aU = theU * M_PI * 2.0;
const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
return gp_Pnt (Cos (aU) * aRadius,
Sin (aU) * aRadius,
0.0);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
gp_Dir Prs3d_ToolDisk::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
{
return gp_Dir (0.0, 0.0, -1.0);
}
//=======================================================================
//function : Perform
//purpose :

View File

@@ -37,31 +37,18 @@ public:
const Standard_Real theOuterRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks);
//! Set angle range in radians [0, 2*PI] by default.
//! @param theStartAngle [in] Start angle in counter clockwise order
//! @param theEndAngle [in] End angle in counter clockwise order
void SetAngleRange (Standard_Real theStartAngle,
Standard_Real theEndAngle)
{
myStartAngle = theStartAngle;
myEndAngle = theEndAngle;
}
protected:
//! Computes vertex at given parameter location of the surface.
Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
//! Computes normal at given parameter location of the surface.
virtual gp_Dir Normal (const Standard_Real , const Standard_Real ) Standard_OVERRIDE { return gp_Dir (0.0, 0.0, -1.0); }
Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
protected:
Standard_Real myInnerRadius;
Standard_Real myOuterRadius;
Standard_Real myStartAngle; //!< Start angle in counter clockwise order
Standard_Real myEndAngle; //!< End angle in counter clockwise order
};

View File

@@ -37,17 +37,15 @@ void RWHeaderSection_RWFileDescription::ReadStep
Handle(Interface_HArray1OfHAsciiString) aDescription;
Handle(TCollection_HAsciiString) aDescriptionItem;
Standard_Integer nsub1 = data->SubListNumber(num, 1, Standard_False);
Standard_Integer nsub1;
nsub1 = data->SubListNumber(num, 1, Standard_False);
if (nsub1 !=0) {
Standard_Integer nb1 = data->NbParams(nsub1);
if (nb1 > 0)
{
aDescription = new Interface_HArray1OfHAsciiString (1, nb1);
for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
Standard_Boolean stat1 = data->ReadString
(nsub1,i1,"description",ach,aDescriptionItem);
if (stat1) aDescription->SetValue(i1,aDescriptionItem);
}
aDescription = new Interface_HArray1OfHAsciiString (1, nb1);
for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
Standard_Boolean stat1 = data->ReadString
(nsub1,i1,"description",ach,aDescriptionItem);
if (stat1) aDescription->SetValue(i1,aDescriptionItem);
}
}
else {

View File

@@ -17,7 +17,6 @@
#ifndef _SelectMgr_EntityOwner_HeaderFile
#define _SelectMgr_EntityOwner_HeaderFile
#include <Aspect_VKey.hxx>
#include <PrsMgr_PresentationManager.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <TopLoc_Location.hxx>
@@ -61,22 +60,6 @@ public:
//! Sets the selectable object.
virtual void SetSelectable (const Handle(SelectMgr_SelectableObject)& theSelObj) { mySelectable = theSelObj.get(); }
//! Handle mouse button click event.
//! Does nothing by default and returns FALSE.
//! @param thePoint mouse cursor position
//! @param theButton clicked button
//! @param theModifiers key modifiers
//! @param theIsDoubleClick flag indicating double mouse click
//! @return TRUE if object handled click
virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick)
{
(void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
return Standard_False;
}
//! Returns true if the presentation manager highlights selections corresponding to the selection mode.
virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0) const

View File

@@ -1707,11 +1707,6 @@ Standard_Boolean ShapeFix_Face::FixMissingSeam()
else if ( wire.IsSame ( w2 ) ) wire = w21;
else
{
Handle(ShapeAnalysis_Wire) anAnalyzer = new ShapeAnalysis_Wire(wire, myFace, Precision());
//To avoid addition of holes with null area (OCCT issue 0030250)
if (anAnalyzer->CheckSmallArea(wire))
continue;
// other wires (not boundary) are considered as holes; make sure to have them oriented accordingly
TopoDS_Shape curface = tmpF.EmptyCopied();
B.Add(curface,wire);

View File

@@ -77,7 +77,6 @@ Standard_PrimitiveTypes.hxx
Standard_ProgramError.hxx
Standard_RangeError.hxx
Standard_ReadBuffer.hxx
Standard_ReadLineBuffer.hxx
Standard_Real.cxx
Standard_Real.hxx
Standard_ShortReal.cxx

View File

@@ -1,198 +0,0 @@
// Copyright (c) 2019 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 _Standard_ReadLineBuffer_HeaderFile
#define _Standard_ReadLineBuffer_HeaderFile
#include <iostream>
#include <vector>
//! Auxiliary tool for buffered reading of lines from input stream.
class Standard_ReadLineBuffer
{
public:
//! Constructor with initialization.
//! @param theMaxBufferSizeBytes the length of buffer to read (in bytes)
Standard_ReadLineBuffer (size_t theMaxBufferSizeBytes)
: myUseReadBufferLastStr(false),
myBufferPos (0),
myBytesLastRead (0)
{
// allocate read buffer
myReadBuffer.resize (theMaxBufferSizeBytes);
}
//! Destructor.
virtual ~Standard_ReadLineBuffer() {}
//! Clear buffer and cached values.
void Clear()
{
myReadBufferLastStr.clear();
myUseReadBufferLastStr = false;
myBufferPos = 0;
myBytesLastRead = 0;
}
//! Read next line from the stream.
//! @return pointer to the line or NULL on error / end of reading buffer
//! (in case of NULL result theStream should be checked externally to identify the presence of errors).
//! Empty lines will be returned also with zero length.
//! @param theLineLength [out] - output parameter defined length of returned line.
template<typename Stream_T>
const char* ReadLine (Stream_T& theStream,
size_t& theLineLength)
{
int64_t aReadData = 0;
return ReadLine (theStream, theLineLength, aReadData);
}
//! Read next line from the stream.
//! @return pointer to the line or NULL on error / end of reading buffer
//! (in case of NULL result theStream should be checked externally to identify the presence of errors).
//! Empty lines will be returned also with zero length.
//! @param theLineLength [out] - output parameter defined length of returned line.
//! @param theReadData [out] - output parameter defined the number of elements successfully read from the stream during this call,
//! it can be zero if no data was read and the line is taken from the buffer.
template<typename Stream_T>
const char* ReadLine (Stream_T& theStream,
size_t& theLineLength,
int64_t& theReadData)
{
char* aResultLine = NULL;
theLineLength = 0;
theReadData = 0;
while (aResultLine == NULL)
{
if (myBufferPos == 0 || myBufferPos >= (myBytesLastRead))
{
// read new chunk from the stream
if (!readStream (theStream, myReadBuffer.size(), myBytesLastRead))
{
// error during file reading
break;
}
theReadData = myBytesLastRead;
if (myBytesLastRead > 0)
{
myBufferPos = 0;
}
else
{
// end of the stream
if (myUseReadBufferLastStr)
{
theLineLength = myReadBufferLastStr.size();
aResultLine = myReadBufferLastStr.data();
myUseReadBufferLastStr = false;
}
break;
}
}
size_t aStartLinePos = myBufferPos;
bool isEndLineFound = false;
// read next line from myReadBuffer
while (myBufferPos < myBytesLastRead)
{
if (myReadBuffer[myBufferPos] == '\n')
{
isEndLineFound = true;
}
++myBufferPos;
if (isEndLineFound) break;
}
if (isEndLineFound)
{
if (myUseReadBufferLastStr)
{
// append current string to the last "unfinished" string of the previous chunk
myReadBufferLastStr.insert (myReadBufferLastStr.end(), myReadBuffer.begin() + aStartLinePos, myReadBuffer.begin() + myBufferPos);
myUseReadBufferLastStr = false;
theLineLength = myReadBufferLastStr.size();
aResultLine = myReadBufferLastStr.data();
}
else
{
if (myReadBufferLastStr.size() > 0)
{
myReadBufferLastStr.clear();
}
theLineLength = myBufferPos - aStartLinePos;
aResultLine = myReadBuffer.data() + aStartLinePos;
}
// make string null terminated by replacing '\n' or '\r' (before '\n') symbol to null character.
if (theLineLength > 1 && aResultLine[theLineLength - 2] == '\r')
{
aResultLine[theLineLength - 2] = '\0';
theLineLength -= 2;
}
else
{
aResultLine[theLineLength - 1] = '\0';
theLineLength -= 1;
}
}
else
{
// save "unfinished" part of string to additional buffer
if (aStartLinePos != myBufferPos)
{
myReadBufferLastStr = std::vector<char>(myReadBuffer.begin() + aStartLinePos, myReadBuffer.begin() + myBufferPos);
myUseReadBufferLastStr = true;
}
}
}
return aResultLine;
}
protected:
//! Read from stl stream.
//! @return true if reading was finished without errors.
bool readStream (std::istream& theStream,
size_t theLen,
size_t& theReadLen)
{
theReadLen = theStream.read (myReadBuffer.data(), theLen).gcount();
return !theStream.bad();
}
//! Read from FILE stream.
//! @return true if reading was finished without errors.
bool readStream (FILE* theStream,
size_t theLen,
size_t& theReadLen)
{
theReadLen = ::fread (myReadBuffer.data(), 1, theLen, theStream);
return ::ferror (theStream) == 0;
}
protected:
std::vector<char> myReadBuffer; //!< Temp read buffer
std::vector<char> myReadBufferLastStr; //!< Part of last string of myReadBuffer
bool myUseReadBufferLastStr; //!< Flag to use myReadBufferLastStr during next line reading
size_t myBufferPos; //!< Current position in myReadBuffer
size_t myBytesLastRead; //!< The number of characters that were read last time from myReadBuffer.
};
#endif // _Standard_ReadLineBuffer_HeaderFile

View File

@@ -208,7 +208,7 @@ namespace
aPoint = aNodes (aNodeIter);
const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
gp_Dir aNorm (aNormArr[anId + 0], aNormArr[anId + 1], aNormArr[anId + 2]);
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
if (aFace.Orientation() == TopAbs_REVERSED)
{
aNorm.Reverse();
}
@@ -237,7 +237,7 @@ namespace
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
{
if ((aFace.Orientation() == TopAbs_REVERSED))
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
}

View File

@@ -275,37 +275,26 @@ void V3d_Viewer::DelView (const Handle(V3d_View)& theView)
}
//=======================================================================
//function : InsertLayerBefore
//function : AddZLayer
//purpose :
//=======================================================================
Standard_Boolean V3d_Viewer::InsertLayerBefore (Graphic3d_ZLayerId& theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter)
Standard_Boolean V3d_Viewer::AddZLayer (Graphic3d_ZLayerId& theLayerId)
{
if (myZLayerGenId.Next (theNewLayerId))
try
{
myLayerIds.Add (theNewLayerId);
myDriver->InsertLayerBefore (theNewLayerId, theSettings, theLayerAfter);
return Standard_True;
OCC_CATCH_SIGNALS
theLayerId = myZLayerGenId.Next();
}
catch (Aspect_IdentDefinitionError const&)
{
// new index can't be generated
return Standard_False;
}
return Standard_False;
}
//=======================================================================
//function : InsertLayerAfter
//purpose :
//=======================================================================
Standard_Boolean V3d_Viewer::InsertLayerAfter (Graphic3d_ZLayerId& theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore)
{
if (myZLayerGenId.Next (theNewLayerId))
{
myLayerIds.Add (theNewLayerId);
myDriver->InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
return Standard_True;
}
return Standard_False;
myLayerIds.Add (theLayerId);
myDriver->AddZLayer (theLayerId);
return Standard_True;
}
//=======================================================================
@@ -350,7 +339,7 @@ void V3d_Viewer::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const G
//function : ZLayerSettings
//purpose :
//=======================================================================
const Graphic3d_ZLayerSettings& V3d_Viewer::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
Graphic3d_ZLayerSettings V3d_Viewer::ZLayerSettings (const Graphic3d_ZLayerId theLayerId)
{
return myDriver->ZLayerSettings (theLayerId);
}

View File

@@ -190,39 +190,9 @@ public:
//! Add a new top-level Z layer to all managed views and get its ID as <theLayerId> value.
//! The Z layers are controlled entirely by viewer, it is not possible to add a layer to a particular view.
//! Custom layers will be inserted before Graphic3d_ZLayerId_Top (e.g. between Graphic3d_ZLayerId_Default and before Graphic3d_ZLayerId_Top).
//! @param theLayerId [out] id of created layer
//! @param theSettings [in] new layer settings
//! @return FALSE if the layer can not be created
Standard_Boolean AddZLayer (Graphic3d_ZLayerId& theLayerId,
const Graphic3d_ZLayerSettings& theSettings = Graphic3d_ZLayerSettings())
{
return InsertLayerBefore (theLayerId, theSettings, Graphic3d_ZLayerId_Top);
}
//! Add a new top-level Z layer to all managed views and get its ID as <theLayerId> value.
//! The Z layers are controlled entirely by viewer, it is not possible to add a layer to a particular view.
//! Layer rendering order is defined by its position in list (altered by theLayerAfter)
//! and IsImmediate() flag (all layers with IsImmediate() flag are drawn afterwards);
//! @param theNewLayerId [out] id of created layer; layer id is arbitrary and does not depend on layer position in the list
//! @param theSettings [in] new layer settings
//! @param theLayerAfter [in] id of layer to append new layer before
//! @return FALSE if the layer can not be created
Standard_EXPORT Standard_Boolean InsertLayerBefore (Graphic3d_ZLayerId& theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter);
//! Add a new top-level Z layer to all managed views and get its ID as <theLayerId> value.
//! The Z layers are controlled entirely by viewer, it is not possible to add a layer to a particular view.
//! Layer rendering order is defined by its position in list (altered by theLayerAfter)
//! and IsImmediate() flag (all layers with IsImmediate() flag are drawn afterwards);
//! @param theNewLayerId [out] id of created layer; layer id is arbitrary and does not depend on layer position in the list
//! @param theSettings [in] new layer settings
//! @param theLayerBefore [in] id of layer to append new layer after
//! @return FALSE if the layer can not be created
Standard_EXPORT Standard_Boolean InsertLayerAfter (Graphic3d_ZLayerId& theNewLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerBefore);
//! The method returns Standard_False if the layer can not be created.
//! The layer mechanism allows to display structures in higher layers in overlay of structures in lower layers.
Standard_EXPORT Standard_Boolean AddZLayer (Graphic3d_ZLayerId& theLayerId);
//! Remove Z layer with ID <theLayerId>.
//! Method returns Standard_False if the layer can not be removed or doesn't exists.
@@ -230,7 +200,7 @@ public:
Standard_EXPORT Standard_Boolean RemoveZLayer (const Graphic3d_ZLayerId theLayerId);
//! Returns the settings of a single Z layer.
Standard_EXPORT const Graphic3d_ZLayerSettings& ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const;
Standard_EXPORT Graphic3d_ZLayerSettings ZLayerSettings (const Graphic3d_ZLayerId theLayerId);
//! Sets the settings for a single Z layer.
Standard_EXPORT void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings);

View File

@@ -1762,8 +1762,6 @@ struct ViewerTest_AspectsChangeSet
Standard_Integer ToSetColor;
Quantity_Color Color;
Standard_Integer ToSetBackFaceColor;
Quantity_Color BackFaceColor;
Standard_Integer ToSetLineWidth;
Standard_Real LineWidth;
@@ -1850,8 +1848,6 @@ struct ViewerTest_AspectsChangeSet
Visibility (1),
ToSetColor (0),
Color (DEFAULT_COLOR),
ToSetBackFaceColor(0),
BackFaceColor (DEFAULT_COLOR),
ToSetLineWidth (0),
LineWidth (1.0),
ToSetTypeOfLine (0),
@@ -1913,7 +1909,6 @@ struct ViewerTest_AspectsChangeSet
&& ToSetTransparency == 0
&& ToSetAlphaMode == 0
&& ToSetColor == 0
&& ToSetBackFaceColor == 0
&& ToSetMaterial == 0
&& ToSetShowFreeBoundary == 0
&& ToSetFreeBoundaryColor == 0
@@ -2148,15 +2143,6 @@ struct ViewerTest_AspectsChangeSet
theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
}
}
if (ToSetBackFaceColor != 0)
{
if (ToSetBackFaceColor != -1
|| theDrawer->HasOwnShadingAspect())
{
toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
theDrawer->ShadingAspect()->SetColor (BackFaceColor, Aspect_TOFM_BACK_SIDE);
}
}
if (ToSetAlphaMode != 0)
{
if (ToSetAlphaMode != -1
@@ -2689,10 +2675,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
}
else if (anArg == "-setcolor"
|| anArg == "-color"
|| anArg == "-setbackfacecolor"
|| anArg == "-backfacecolor"
|| anArg == "-setbackcolor"
|| anArg == "-backcolor"
|| anArg == "-setfaceboundarycolor"
|| anArg == "-setboundarycolor"
|| anArg == "-faceboundarycolor"
@@ -2722,14 +2704,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
aChangeSet->ToSetFaceBoundaryColor = 1;
aChangeSet->FaceBoundaryColor = aColor;
}
else if (anArg == "-setbackfacecolor"
|| anArg == "-backfacecolor"
|| anArg == "-setbackcolor"
|| anArg == "-backcolor")
{
aChangeSet->ToSetBackFaceColor = 1;
aChangeSet->BackFaceColor = aColor;
}
else
{
aChangeSet->ToSetColor = 1;
@@ -3244,8 +3218,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
aChangeSet->AlphaCutoff = 0.5f;
aChangeSet->ToSetColor = -1;
aChangeSet->Color = DEFAULT_COLOR;
//aChangeSet->ToSetBackFaceColor = -1; // should be reset by ToSetColor
//aChangeSet->BackFaceColor = DEFAULT_COLOR;
aChangeSet->ToSetMaterial = -1;
aChangeSet->Material = Graphic3d_NOM_DEFAULT;
aChangeSet->ToSetShowFreeBoundary = -1;
@@ -6593,7 +6565,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
"vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]"
"\n\t\t: [-setVisibility 0|1]"
"\n\t\t: [-setColor ColorName] [-setcolor R G B] [-unsetColor]"
"\n\t\t: [-setBackFaceColor Color]"
"\n\t\t: [-setMaterial MatName] [-unsetMaterial]"
"\n\t\t: [-setTransparency Transp] [-unsetTransparency]"
"\n\t\t: [-setWidth LineWidth] [-unsetWidth]"

View File

@@ -16,7 +16,6 @@
#include <ViewerTest_EventManager.hxx>
#include <AIS_AnimationCamera.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_Grid.hxx>
@@ -27,16 +26,6 @@ Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_EventManager,Standard_Transient)
//=======================================================================
//function : GlobalViewAnimation
//purpose :
//=======================================================================
const Handle(AIS_AnimationCamera)& ViewerTest_EventManager::GlobalViewAnimation()
{
static Handle(AIS_AnimationCamera) THE_CAMERA_ANIM = new AIS_AnimationCamera ("ViewerTest_EventManager_ViewAnimation", Handle(V3d_View)());
return THE_CAMERA_ANIM;
}
//=======================================================================
//function : ViewerTest_EventManager
//purpose :
@@ -46,23 +35,7 @@ ViewerTest_EventManager::ViewerTest_EventManager (const Handle(V3d_View)&
: myCtx (theCtx),
myView (theView),
myToPickPnt (Standard_False)
{
myViewAnimation = GlobalViewAnimation();
}
//=======================================================================
//function : ~ViewerTest_EventManager
//purpose :
//=======================================================================
ViewerTest_EventManager::~ViewerTest_EventManager()
{
if (!myViewAnimation.IsNull()
&& myViewAnimation->View() == myView)
{
myViewAnimation->Stop();
myViewAnimation->SetView (Handle(V3d_View)());
}
}
{}
//=======================================================================
//function : UpdateMouseButtons

View File

@@ -47,17 +47,11 @@ public:
return Draw_ToExitOnCloseView;
}
//! Use global camera animation object shared across all Views in ViewerTest.
Standard_EXPORT static const Handle(AIS_AnimationCamera)& GlobalViewAnimation();
public:
//! Main constructor.
Standard_EXPORT ViewerTest_EventManager(const Handle(V3d_View)& aView, const Handle(AIS_InteractiveContext)& aCtx);
//! Destructor.
Standard_EXPORT virtual ~ViewerTest_EventManager();
//! Return interactive context.
const Handle(AIS_InteractiveContext)& Context() const { return myCtx; }

View File

@@ -606,20 +606,13 @@ static Standard_Integer VShaderProg (Draw_Interpretor& theDI,
TCollection_AsciiString anArg (theArgVec[anArgIter]);
anArg.LowerCase();
Graphic3d_TypeOfShaderObject aShaderTypeArg = Graphic3d_TypeOfShaderObject(-1);
if (!aProgram.IsNull()
&& anArg == "-uniform"
&& anArgIter + 2 < theArgNb)
{
TCollection_AsciiString aName = theArgVec[++anArgIter];
aProgram->PushVariableFloat (aName, float (Draw::Atof (theArgVec[++anArgIter])));
}
else if (anArg == "-list"
|| ((anArg == "-update"
|| anArg == "-dump"
|| anArg == "-debug"
|| anArg == "-reload"
|| anArg == "-load")
&& anArgIter + 1 < theArgNb))
if (anArg == "-list"
|| ((anArg == "-update"
|| anArg == "-dump"
|| anArg == "-debug"
|| anArg == "-reload"
|| anArg == "-load")
&& anArgIter + 1 < theArgNb))
{
Handle(OpenGl_Context) aGlCtx;
if (Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aCtx->CurrentViewer()->Driver()))
@@ -902,7 +895,6 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
"\n\t\t: [-off] [-phong] [-aspect {shading|line|point|text}=shading]"
"\n\t\t: [-header VersionHeader]"
"\n\t\t: [-tessControl TessControlShader -tesseval TessEvaluationShader]"
"\n\t\t: [-uniform Name FloatValue]"
"\n\t\t: Assign custom GLSL program to presentation aspects."
"\nvshader [-list] [-dump] [-reload] ShaderId"
"\n\t\t: -list prints the list of registered GLSL programs"

View File

@@ -25,7 +25,6 @@
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Manipulator.hxx>
#include <AIS_ViewCube.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <Aspect_Grid.hxx>
@@ -1658,9 +1657,8 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
// alternatively we can disable buffer swap at all, but this might be inappropriate for testing
//ViewerTest_myDefaultCaps.buffersNoSwap = true;
}
aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection(), false);
aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection());
aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
aGraphicDriver->InitContext();
ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
toCreateViewer = Standard_True;
@@ -5324,7 +5322,6 @@ static int VZLayer (Draw_Interpretor& theDI,
}
}
Graphic3d_ZLayerId anOtherLayerId = Graphic3d_ZLayerId_UNKNOWN;
for (; anArgIter < theArgNb; ++anArgIter)
{
// perform operation
@@ -5346,34 +5343,6 @@ static int VZLayer (Draw_Interpretor& theDI,
theDI << aLayerId;
}
else if (anArg == "-insertbefore"
&& anArgIter + 1 < theArgNb
&& ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
{
++anArgIter;
aLayerId = Graphic3d_ZLayerId_UNKNOWN;
if (!aViewer->InsertLayerBefore (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
{
std::cout << "Error: can not add a new z layer!\n";
return 0;
}
theDI << aLayerId;
}
else if (anArg == "-insertafter"
&& anArgIter + 1 < theArgNb
&& ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
{
++anArgIter;
aLayerId = Graphic3d_ZLayerId_UNKNOWN;
if (!aViewer->InsertLayerAfter (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
{
std::cout << "Error: can not add a new z layer!\n";
return 0;
}
theDI << aLayerId;
}
else if (anArg == "-del"
|| anArg == "-delete"
|| anArg == "del")
@@ -5615,10 +5584,6 @@ static int VZLayer (Draw_Interpretor& theDI,
{
aSettings.SetEnvironmentTexture (toEnable);
}
else if (aSubOp == "raytracing")
{
aSettings.SetRaytracable (toEnable);
}
aViewer->SetZLayerSettings (aLayerId, aSettings);
}
@@ -6627,8 +6592,6 @@ static int VCaps (Draw_Interpretor& theDI,
theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
theDI << "NoExt:" << (aCaps->contextNoExtensions ? "1" : "0") << "\n";
theDI << "MaxVersion:" << aCaps->contextMajorVersionUpper << "." << aCaps->contextMinorVersionUpper << "\n";
return 0;
}
@@ -6772,44 +6735,6 @@ static int VCaps (Draw_Interpretor& theDI,
}
aCaps->contextStereo = toEnable;
}
else if (anArgCase == "-noext"
|| anArgCase == "-noextensions"
|| anArgCase == "-noextension")
{
Standard_Boolean toDisable = Standard_True;
if (++anArgIter < theArgNb
&& !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
{
--anArgIter;
}
aCaps->contextNoExtensions = toDisable;
}
else if (anArgCase == "-maxversion"
|| anArgCase == "-upperversion"
|| anArgCase == "-limitversion")
{
Standard_Integer aVer[2] = { -2, -1 };
for (Standard_Integer aValIter = 0; aValIter < 2; ++aValIter)
{
if (anArgIter + 1 < theArgNb)
{
const TCollection_AsciiString aStr (theArgVec[anArgIter + 1]);
if (aStr.IsIntegerValue())
{
aVer[aValIter] = aStr.IntegerValue();
++anArgIter;
}
}
}
if (aVer[0] < -1
|| aVer[1] < -1)
{
std::cout << "Syntax error at '" << anArgCase << "'\n";
return 1;
}
aCaps->contextMajorVersionUpper = aVer[0];
aCaps->contextMinorVersionUpper = aVer[1];
}
else
{
std::cout << "Error: unknown argument '" << anArg << "'\n";
@@ -13126,258 +13051,6 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
return 0;
}
//===============================================================================================
//function : VViewCube
//purpose :
//===============================================================================================
static int VViewCube (Draw_Interpretor& ,
Standard_Integer theNbArgs,
const char** theArgVec)
{
const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
const Handle(V3d_View)& aView = ViewerTest::CurrentView();
if (aContext.IsNull() || aView.IsNull())
{
std::cout << "Error: no active view.\n";
return 1;
}
else if (theNbArgs < 2)
{
std::cout << "Syntax error: wrong number arguments\n";
return 1;
}
Handle(AIS_ViewCube) aViewCube;
ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
Quantity_Color aColorRgb;
TCollection_AsciiString aName;
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{
TCollection_AsciiString anArg (theArgVec[anArgIter]);
anArg.LowerCase();
if (anUpdateTool.parseRedrawMode (anArg))
{
//
}
else if (aViewCube.IsNull())
{
aName = theArgVec[anArgIter];
if (aName.StartsWith ("-"))
{
std::cout << "Syntax error: object name should be specified.\n";
return 1;
}
Handle(AIS_InteractiveObject) aPrs;
GetMapOfAIS().Find2 (aName, aPrs);
aViewCube = Handle(AIS_ViewCube)::DownCast (aPrs);
if (aViewCube.IsNull())
{
aViewCube = new AIS_ViewCube();
aViewCube->SetBoxColor (Quantity_NOC_GRAY50);
aViewCube->SetViewAnimation (ViewerTest::CurrentEventManager()->ViewAnimation());
aViewCube->SetFixedAnimationLoop (false);
}
}
else if (anArg == "-reset")
{
aViewCube->ResetStyles();
}
else if (anArg == "-color"
|| anArg == "-boxcolor"
|| anArg == "-boxsidecolor"
|| anArg == "-sidecolor"
|| anArg == "-boxedgecolor"
|| anArg == "-edgecolor"
|| anArg == "-boxcornercolor"
|| anArg == "-cornercolor"
|| anArg == "-innercolor"
|| anArg == "-textcolor")
{
Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
theArgVec + anArgIter + 1,
aColorRgb);
if (aNbParsed == 0)
{
std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
return 1;
}
anArgIter += aNbParsed;
if (anArg == "-boxcolor")
{
aViewCube->SetBoxColor (aColorRgb);
}
else if (anArg == "-boxsidecolor"
|| anArg == "-sidecolor")
{
aViewCube->BoxSideStyle()->SetColor (aColorRgb);
aViewCube->SynchronizeAspects();
}
else if (anArg == "-boxedgecolor"
|| anArg == "-edgecolor")
{
aViewCube->BoxEdgeStyle()->SetColor (aColorRgb);
aViewCube->SynchronizeAspects();
}
else if (anArg == "-boxcornercolor"
|| anArg == "-cornercolor")
{
aViewCube->BoxCornerStyle()->SetColor (aColorRgb);
aViewCube->SynchronizeAspects();
}
else if (anArg == "-innercolor")
{
aViewCube->SetInnerColor (aColorRgb);
}
else if (anArg == "-textcolor")
{
aViewCube->SetTextColor (aColorRgb);
}
else
{
aViewCube->SetColor (aColorRgb);
}
}
else if (anArgIter + 1 < theNbArgs
&& (anArg == "-transparency"
|| anArg == "-boxtransparency"))
{
const Standard_Real aValue = Draw::Atof (theArgVec[++anArgIter]);
if (aValue < 0.0 || aValue > 1.0)
{
std::cout << "Syntax error: invalid transparency value " << theArgVec[anArgIter] << "\n";
return 1;
}
if (anArg == "-boxtransparency")
{
aViewCube->SetBoxTransparency (aValue);
}
else
{
aViewCube->SetTransparency (aValue);
}
}
else if (anArg == "-axes"
|| anArg == "-edges"
|| anArg == "-vertices"
|| anArg == "-vertexes"
|| anArg == "-fixedanimation")
{
bool toShow = true;
if (anArgIter + 1 < theNbArgs
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShow))
{
++anArgIter;
}
if (anArg == "-fixedanimation")
{
aViewCube->SetFixedAnimationLoop (toShow);
}
else if (anArg == "-axes")
{
aViewCube->SetDrawAxes (toShow);
}
else if (anArg == "-edges")
{
aViewCube->SetDrawEdges (toShow);
}
else
{
aViewCube->SetDrawVertices (toShow);
}
}
else if (anArg == "-yup"
|| anArg == "-zup")
{
bool isOn = true;
if (anArgIter + 1 < theNbArgs
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isOn))
{
++anArgIter;
}
if (anArg == "-yup")
{
aViewCube->SetYup (isOn);
}
else
{
aViewCube->SetYup (!isOn);
}
}
else if (anArgIter + 1 < theNbArgs
&& anArg == "-font")
{
aViewCube->SetFont (theArgVec[++anArgIter]);
}
else if (anArgIter + 1 < theNbArgs
&& anArg == "-fontheight")
{
aViewCube->SetFontHeight (Draw::Atof (theArgVec[++anArgIter]));
}
else if (anArgIter + 1 < theNbArgs
&& (anArg == "-size"
|| anArg == "-boxsize"))
{
aViewCube->SetSize (Draw::Atof (theArgVec[++anArgIter]),
anArg != "-boxsize");
}
else if (anArgIter + 1 < theNbArgs
&& (anArg == "-boxfacet"
|| anArg == "-boxfacetextension"
|| anArg == "-facetextension"
|| anArg == "-extension"))
{
aViewCube->SetBoxFacetExtension (Draw::Atof (theArgVec[++anArgIter]));
}
else if (anArgIter + 1 < theNbArgs
&& (anArg == "-boxedgegap"
|| anArg == "-edgegap"))
{
aViewCube->SetBoxEdgeGap (Draw::Atof (theArgVec[++anArgIter]));
}
else if (anArgIter + 1 < theNbArgs
&& (anArg == "-boxedgeminsize"
|| anArg == "-edgeminsize"))
{
aViewCube->SetBoxEdgeMinSize (Draw::Atof (theArgVec[++anArgIter]));
}
else if (anArgIter + 1 < theNbArgs
&& (anArg == "-boxcornerminsize"
|| anArg == "-cornerminsize"))
{
aViewCube->SetBoxCornerMinSize (Draw::Atof (theArgVec[++anArgIter]));
}
else if (anArgIter + 1 < theNbArgs
&& anArg == "-axespadding")
{
aViewCube->SetAxesPadding (Draw::Atof (theArgVec[++anArgIter]));
}
else if (anArgIter + 1 < theNbArgs
&& anArg == "-roundradius")
{
aViewCube->SetRoundRadius (Draw::Atof (theArgVec[++anArgIter]));
}
else if (anArgIter + 1 < theNbArgs
&& anArg == "-duration")
{
aViewCube->SetDuration (Draw::Atof (theArgVec[++anArgIter]));
}
else
{
std::cout << "Syntax error: unknown argument '" << anArg << "'\n";
return 1;
}
}
if (aViewCube.IsNull())
{
std::cout << "Syntax error: wrong number of arguments\n";
return 1;
}
ViewerTest::Display (aName, aViewCube, false);
return 0;
}
//=======================================================================
//function : ViewerCommands
//purpose :
@@ -13663,14 +13336,12 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
__FILE__, VTile, group);
theCommands.Add("vzlayer",
"vzlayer [layerId]"
"\n\t\t: [-add|-delete|-get|-settings] [-insertBefore AnotherLayer] [-insertAfter AnotherLayer]"
"\n\t\t: [-add|-delete|-get|-settings]"
"\n\t\t: [-origin X Y Z] [-cullDist Distance] [-cullSize Size]"
"\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]"
"\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv|rayTracing}]"
"\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv}]"
"\n\t\t: ZLayer list management:"
"\n\t\t: -add add new z layer to viewer and print its id"
"\n\t\t: -insertBefore add new z layer and insert it before existing one"
"\n\t\t: -insertAfter add new z layer and insert it after existing one"
"\n\t\t: -delete delete z layer"
"\n\t\t: -get print sequence of z layers"
"\n\t\t: -settings print status of z layer settings"
@@ -13754,7 +13425,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
"\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
"\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
"\n\t\t: [-noExtensions {0|1}] [-maxVersion Major Minor]"
"\n\t\t: Modify particular graphic driver options:"
"\n\t\t: FFP - use fixed-function pipeline instead of"
"\n\t\t: built-in GLSL programs"
@@ -13769,8 +13439,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n\t\t: softMode - software OpenGL implementation"
"\n\t\t: compatibleProfile - backward-compatible profile"
"\n\t\t: quadbuffer - QuadBuffer"
"\n\t\t: noExtensions - disallow usage of extensions"
"\n\t\t: maxVersion - force upper OpenGL version to be used"
"\n\t\t: Unlike vrenderparams, these parameters control alternative"
"\n\t\t: rendering paths producing the same visual result when"
"\n\t\t: possible."
@@ -14177,37 +13845,5 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n\t\t: selMode color of selection mode"
"\n\t\t: entity color of etected entity",
__FILE__, VDumpSelectionImage, group);
theCommands.Add ("vviewcube",
"vviewcube name"
"\n\t\t: Displays interactive view manipualtion object."
"\n\t\t: Options: "
"\n\t\t: -reset reset geomertical and visual attributes'"
"\n\t\t: -size Size adapted size of View Cube"
"\n\t\t: -boxSize Size box size"
"\n\t\t: -axes {0|1 } show/hide axes (trihedron)"
"\n\t\t: -edges {0|1} show/hide edges of View Cube"
"\n\t\t: -vertices {0|1} show/hide vertices of View Cube"
"\n\t\t: -Yup {0|1} -Zup {0|1} set Y-up or Z-up view orientation"
"\n\t\t: -color Color color of View Cube"
"\n\t\t: -boxColor Color box color"
"\n\t\t: -boxSideColor Color box sides color"
"\n\t\t: -boxEdgeColor Color box edges color"
"\n\t\t: -boxCornerColor Color box corner color"
"\n\t\t: -textColor Color color of side text of view cube"
"\n\t\t: -innerColor Color inner box color"
"\n\t\t: -transparency Value transparency of object within [0, 1] range"
"\n\t\t: -boxTransparency Value transparency of box within [0, 1] range"
"\n\t\t: -font Name font name"
"\n\t\t: -fontHeight Value font height"
"\n\t\t: -boxFacetExtension Value box facet extension"
"\n\t\t: -boxEdgeGap Value gap between box edges and box sides"
"\n\t\t: -boxEdgeMinSize Value minimal box edge size"
"\n\t\t: -boxCornerMinSize Value minimal box corner size"
"\n\t\t: -axesPadding Value padding between box and arrows"
"\n\t\t: -roundRadius Value relative radius of corners of sides within [0.0, 0.5] range"
"\n\t\t: -fixedanimation {0|1} uninterruptible animation loop"
"\n\t\t: -duration Seconds animation duration in seconds",
__FILE__, VViewCube, group);
}

View File

@@ -221,7 +221,7 @@ void XCAFPrs_DocumentExplorer::Init (const Handle(TDocStd_Document)& theDocument
const XCAFPrs_DocumentExplorerFlags theFlags,
const XCAFPrs_Style& theDefStyle)
{
if ((theFlags & XCAFPrs_DocumentExplorerFlags_NoStyle) == 0)
if ((theFlags & XCAFPrs_DocumentExplorerFlags_NoStyle) != 0)
{
myColorTool = XCAFDoc_DocumentTool::ColorTool (theDocument->Main());
}
@@ -230,6 +230,7 @@ void XCAFPrs_DocumentExplorer::Init (const Handle(TDocStd_Document)& theDocument
myColorTool.Nullify();
}
///myColorTool = theColorTool;
myDefStyle = theDefStyle;
myRoots = theRoots;
myRootIter = TDF_LabelSequence::Iterator (myRoots);
@@ -262,7 +263,7 @@ void XCAFPrs_DocumentExplorer::initRoot()
if (aRootLab.IsNull())
{
// assert - invalid input
//Standard_ProgramError::Raise ("XCAFPrs_DocumentExplorer - NULL label in the input");
//Standard_ProgramError::Raise ("CadDocumentExplorer - NULL label in the input");
myRootIter.Next();
continue;
}
@@ -293,7 +294,7 @@ void XCAFPrs_DocumentExplorer::initCurrent (Standard_Boolean theIsAssmebly)
{
if (myTop < 0)
{
Standard_ProgramError::Raise ("XCAFPrs_DocumentExplorer - internal error");
Standard_ProgramError::Raise ("CadDocumentExplorer - internal error");
}
myCurrent = myNodeStack.Value (myTop);
}
@@ -333,7 +334,7 @@ void XCAFPrs_DocumentExplorer::Next()
{
if (!myHasMore)
{
Standard_ProgramError::Raise ("XCAFPrs_DocumentExplorer::Next() - out of range");
Standard_ProgramError::Raise ("CadDocumentExplorer::Next() - out of range");
return; // assert
}

View File

@@ -26,5 +26,5 @@ for {set i 1} {${i} <= ${NCycles}} {incr i } {
bop b1 b2
bopcut r
lappend listmem [meminfo h]
checktrend $listmem 0 100 "Memory leak detected"
}
checktrend $listmem 0 100 "Memory leak detected"

19
tests/bugs/mesh/bug26074 Normal file
View File

@@ -0,0 +1,19 @@
puts "========="
puts "0026074: BRepMesh_IncrementalMesh meshes a specific shape for a long time"
puts "========="
puts ""
set ::env(CSF_MeshAlgo) 1
restore [locate_data_file bug26074.brep] result
tclean result
incmesh result 0.01116 -a 15 -parallel
checktrinfo result -tri
vinit
vsetdispmode 1
vdefaults -autoTriang 0
vdisplay result
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}.png

View File

@@ -1,20 +0,0 @@
puts "========"
puts "0030829: BRepExtrema_ShapeProximity crashes with shape from STL/WRL"
puts "========"
puts ""
pload XSDRAW
box b 10 10 10
pcylinder c 5 10
incmesh b 0.1
incmesh c 0.1
writestl b ${imagedir}/${test_image}_b.stl
writestl c ${imagedir}/${test_image}_c.stl
readstl b ${imagedir}/${test_image}_b.stl
readstl c ${imagedir}/${test_image}_c.stl
file delete ${imagedir}/${test_image}_b.stl
file delete ${imagedir}/${test_image}_c.stl
proximity b c

View File

@@ -1,12 +0,0 @@
puts "# ====================================================================="
puts "# 0030628: Data Exchange - Crash on importing STEP file"
puts "# ====================================================================="
puts ""
vclear
vinit View1
vaxo
ReadStep D [locate_data_file bug30628_319892-GSE306L520-HOG-s5.stp]
XDisplay D -dispMode 1
vfit
vdump ${imagedir}/${casename}.png

View File

@@ -1,13 +0,0 @@
puts "========================"
puts "0030790: Crash when loading specific step file"
puts "========================"
puts "TODO 30790 ALL: Faulty shapes in variables faulty_1 to"
stepread [locate_data_file bug30790.step] a *
tpcompound result
checkshape result
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,48 +0,0 @@
puts "=================================================================================="
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
puts "Check that displaying of non-solid shapes (shells) is not affected by mirror transformation"
puts "=================================================================================="
pload MODELING VISUALIZATION
vclear
vinit View1
vaxo
vrotate 3 0 0
vcamera -persp
# Simple box
box b 1 1 1
explode b sh
renamevar b_1 b
vdisplay -dispMode 1 b
vaspects b -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_simple.png
verase b
# Box with mirror transformation
box a 1 1 1
bmirror a 0 0 0 1 0 0
explode a sh
renamevar a_1 a
vdisplay -dispMode 1 a
vaspects a -setBackFaceColor RED
vfit
box aa -0.5 0.5 0.5 0.1 0.1 0.1
vdisplay -dispMode 1 aa
vsetcolor aa BLUE1
vdump $imagedir/${casename}_mirror.png
if { [vreadpixel 300 200 rgb name] != "RED2" } { puts "Error: shell of mirrored box should show back faces" }
verase a
# Box with mirror transformation and reversed face
box c 1 1 1
bmirror c 0 0 0 1 0 0
orientation c R
explode c sh
renamevar c_1 c
vdisplay -dispMode 1 c
vaspects c -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_mirrev.png
if { [vreadpixel 300 200 rgb name] == "RED2" } { puts "Error: shell of reversed mirrored box should show front faces" }

View File

@@ -1,40 +0,0 @@
puts "=================================================================================="
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
puts "Check that local transformation of visualizated object"
puts "affects only position, not material place"
puts "=================================================================================="
pload MODELING VISUALIZATION
vclear
vinit View1
vaxo
vrotate 3 0 0
vcamera -persp
# Simple box
box b 1 1 1
bmirror b 0 0 0 0 0 1
vdisplay -dispMode 1 b
vaspects b -setBackFaceColor RED
box bb 0.5 0.5 -0.5 0.1 0.1 0.1
vdisplay -dispMode 1 bb
vsetcolor bb BLUE1
vfit
vdump $imagedir/${casename}_simple.png
if { [vreadpixel 195 220 rgb name] != "BLUE2" } { puts "Error: mirrored box should look inside out" }
# Box with rotation transformation
vlocation b -rotate 0 0 0 1 0 0 90
vlocation bb -rotate 0 0 0 1 0 0 90
vfit
vdump $imagedir/${casename}_rotate.png
if { [vreadpixel 215 230 rgb name] != "BLUE2" } { puts "Error: rotated mirrored box should look inside out" }
# Box with mirror transformation
vlocation b -reset
vlocation b -mirror 0 -0.5 0 0 1 0
vlocation bb -reset
vlocation bb -mirror 0 -0.5 0 0 1 0
vfit
vdump $imagedir/${casename}_mirror.png
if { [vreadpixel 215 230 rgb name] != "BLUE2" } { puts "Error: mirrored mirrored box should look inside out" }

View File

@@ -1,42 +0,0 @@
puts "=================================================================================="
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
puts "Check that solid with mirrored transformation is displayed as turned out"
puts "=================================================================================="
pload MODELING VISUALIZATION
vclear
vinit View1
vaxo
vrotate 3 0 0
vcamera -persp
# Simple box
box b 1 1 1
vdisplay -dispMode 1 b
vaspects b -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_simple.png
verase b
# Box with mirror transformation
box a 1 1 1
bmirror a 0 0 0 1 0 0
vdisplay -dispMode 1 a
vaspects a -setBackFaceColor RED
vfit
box aa -0.5 0.5 0.5 0.1 0.1 0.1
vdisplay -dispMode 1 aa
vsetcolor aa BLUE1
vdump $imagedir/${casename}_mirror.png
if { [vreadpixel 195 220 rgb name] != "BLUE2" } { puts "Error: mirrored box should look inside out" }
verase a
# Box with mirror transformation and reversed face
box c 1 1 1
bmirror c 0 0 0 1 0 0
orientation c R
vdisplay -dispMode 1 c
vaspects c -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_mirrev.png
if { [vreadpixel 195 220 rgb name] == "BLUE2" } { puts "Error: revered mirrored box should NOT look inside out" }

View File

@@ -1,7 +1,7 @@
# !!!! This file is generated automatically, do not edit manually! See end script
puts "TODO CR23096 ALL: Update of 3D-Parameters has failed"
puts "TODO CR23096 ALL: CHECKSHAPE : Faulty"
puts "TODO CR23096 ALL: Error : 2 differences with reference data found"
set filename 53921163S0.stp

View File

@@ -28,7 +28,7 @@ vzbufftrihedron
catch { vzlayer del 1 }
set aLayerId [vzlayer add]
vzlayer $aLayerId -enable depthClear -disable rayTracing
vzlayer $aLayerId -enable depthClear
vtrihedron trh
vdisplay -noupdate trh -layer $aLayerId -trihedron topRight 100 100

View File

@@ -19,4 +19,3 @@
020 anim
021 dimensions
022 transparency
023 viewcube

View File

@@ -1,36 +0,0 @@
puts "=================================="
puts "0028954: Visualization - implement interactive object AIS_ViewCube for camera manipulations"
puts "Display and erase with default settings"
puts "=================================="
vclear
vinit View1
box b 15 20 70
vdisplay -dispMode 1 b
vaxo
vfit
vviewcube vc -fixedAnimation 1 -duration 0
vmoveto 70 340
if {[vreadpixel 70 340 name rgb] != "CYAN1"} { puts "Error: Highlighting of view cube Side is wrong." }
vmoveto 0 0
vdump $imagedir/${casename}_axo.png
# check FRONT side
vselect 70 340
if {[vreadpixel 255 300 name rgb] != "BLACK"} { puts "Error: Position of FRONT camera is wrong." }
vdump $imagedir/${casename}_side.png
# check FRONT/TOP edge
vselect 100 270
if {[vreadpixel 100 300 name rgb] != "GRAY51"} { puts "Error: Position of FRONT-TOP camera is wrong." }
if {[vreadpixel 100 310 name rgb] != "CYAN1"} { puts "Error: Position of FRONT-TOP camera is wrong." }
vdump $imagedir/${casename}_edge.png
# Check vertex
vselect 140 310
if {[vreadpixel 100 290 name rgb] != "GRAY42"} { puts "Error: Position of TOP-FRONT-RIGHT camera is wrong." }
if {[vreadpixel 100 310 name rgb] != "CYAN1"} { puts "Error: Position of TOP-FRONT-RIGHT camera is wrong." }
if {[vreadpixel 100 320 name rgb] != "MATRAGRAY"} { puts "Error: Position of TOP-FRONT-RIGHT camera is wrong." }
vdump $imagedir/${casename}_corner.png

View File

@@ -1,17 +0,0 @@
puts "=================================="
puts "0030850: Visualization, OpenGl_Text - text within trihedron persistence jitters when camera is far from origin"
puts "=================================="
pload MODELING VISUALIZATION
box b 0.001 0.001 0.001
vclear
vinit View1
vaxo
vdisplay -dispMode 1 b
vlocation b -setLocation 1000000 0 0
vfit
vzlayer DEFAULT -origin 1000000 0 0
vviewcube vc
vdump $imagedir/${casename}.png

View File

@@ -1,44 +0,0 @@
puts "=================================="
puts "0028954: Visualization - implement interactive object AIS_ViewCube for camera manipulations"
puts "Display custom styled View Cube"
puts "=================================="
vclear
vinit View1
vviewcube vc -edges 0
if {[vreadpixel 70 295 name rgb] != "BLACK"} { puts "Error: Invalid display of View Cube without edges." }
vdump $imagedir/${casename}_noedges.png
vviewcube vc -edges 1 -vertices 0
if {[vreadpixel 100 308 name rgb] != "BLACK"} { puts "Error: Invalid display of View Cube without vertices." }
vdump $imagedir/${casename}_noverts.png
vviewcube vc -edges 0 -vertices 0
if {[vreadpixel 70 295 name rgb] != "BLACK" || [vreadpixel 100 308 name rgb] != "BLACK"} {
puts "Error: Invalid display of View Cube without edges & vertices."
}
vdump $imagedir/${casename}_noedgeandvert.png
vclear
# Color
vviewcube vc1 -boxColor 0.69 0.88 1 -textColor 0 0.4 0.54
vdisplay vc1 -trihedron bottomLeft 100 100
# Transparency
vviewcube vc2 -transparency 0.5
vdisplay vc2 -trihedron topLeft 100 100
# Font
vviewcube vc3 -reset -boxSideColor WHITE -font "monospace" -fontHeight 16
vdisplay vc3 -trihedron bottomRight 100 100
# Corner radius
vviewcube vc4 -reset -boxSideColor WHITE -roundRadius 0.2 -boxEdgeGap 2
vdisplay vc4 -trihedron topRight 100 100
# Padding
vviewcube vc5 -reset -boxFacetExtension 0 -axesPadding 0
vdisplay vc5 -trihedron center
vdump $imagedir/${casename}_styles.png

View File

@@ -1,22 +0,0 @@
puts "=================================="
puts "0028954: Visualization - implement interactive object AIS_ViewCube for camera manipulations"
puts "Check view affinity"
puts "=================================="
vclear
vclose ALL
vinit View1
vinit View2
vviewcube vc
verase vc -view
if {[vreadpixel 100 350 name rgb] != "BLACK"} { puts "Error: hiding Cube in View2 fails." }
vdump $imagedir/${casename}_v2.png
vactivate View1
if {[vreadpixel 100 350 name rgb] == "BLACK"} { puts "Error: showing Cube in View1 fails." }
vdump $imagedir/${casename}_v1.png
vactivate View2