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

Compare commits

..

34 Commits

Author SHA1 Message Date
drazmyslovich
828a75f228 0030873: Make ReShape tool resistant to replacement loops 2019-08-07 13:25:15 +02:00
kgv
59515ca600 0030744: Visualization, TKOpenGl - stipple line does not work on OpenGL ES 2.0
OpenGl_ShaderManager now provides fallback stipple lines GLSL code for obsolete OpenGL ES 2.0 devices.
OpenGl_Caps has been extended by flags disallowing OpenGL extensions usage
and restricting upper OpenGL version to be used by OCCT for testing purposes.
2019-07-27 12:05:35 +03:00
osa
fa1710b567 0030830: Point Cloud Rendering - use temporary buffer to read lines from .pts and .ptx files
Add Standard_ReadLineBuffer - auxiliary tool for buffered reading of lines from input stream.
2019-07-27 12:04:26 +03:00
kgv
9460f8c0b9 0030853: Visualization, AIS_ViewController - fix 1 pixel Y shift while zooming
Fixed error in math converting Y-down mouse coordinates into Y-up within AIS_ViewController::handleZoom().
Added flags ToStickToRayOnZoom()/ToStickToRayOnRotation() enabled by default,
which will project picked point onto ray at mouse cursor to preserve focus on zoom out.
2019-07-27 12:04:25 +03:00
kgv
a3a3ff3d33 0030850: Visualization, OpenGl_Text - text within trihedron persistence jitters when camera is far from origin
OpenGl_Text now discards (redundant) translation part from camera orientation matrix.
Text anchor point alignment to integer coordinates is now not performed for 3D-oriented text.
2019-07-19 12:23:02 +03:00
aba
2108d9a25b 0028954: Visualization - implement interactive object for camera manipulations
Added new class AIS_ViewCube implementing interactive cube
displaying orientation of the main axes of the model space in the viewer.
Each side, edge, or corner of the cube corresponds to particular orientation of the camera,
and the class provides methods to move the camera to corresponding position (with animation if needed).

AIS_InteractiveContext::LastActiveView(), added new property returning the last View processed by MoveTo() event.
AIS_InteractiveContext::BoundingBoxOfSelection(), added method returning bounding box of selected objects.
SelectMgr_EntityOwner::HandleMouseClick(), added new callback for handling
mouse clicks by owner itself without automatic highlighting and clearing previous selection.
Called by AIS_InteractiveContext::Select() method.

AIS_ViewController::ViewAnimation() has been extened with camera animation propery,
which can be bound to AIS_ViewCube for smooth embedding into event loop.

Prs3d_ToolDisk has been extended with parameters specifying angle range.
Graphic3d_MaterialAspect now initializes all coefficients to 1.0
when Graphic3d_NOM_UserDefined is passed to class constructor.
AIS_AnimationCamera::update() now sets the end camera position if animation duration is 0.
Prs3d_DatumAspect, added missing setters.

New command vviewcube has been added.
2019-07-19 12:23:01 +03:00
msv
e8dec5e171 0030790: [REGRESSION] Modeling Algorithms - Crash when loading specific step file
The problem occurred when the algorithm IntCurvesFace_Intersector was called for a face occupying zero extension along V direction. This is obviously a bad face, but we need to have the algorithm not crashing the application. So, the algorithm has been protected against such input data. At attempt to make calculations it establishes NotDone status.

Bad test case tests/de/step_3/D9 has been updated.
False memory leak detection has been suppressed in tests/bugs/fclasses/bug7287_2.
2019-07-19 12:23:00 +03:00
mzernova
0dab581700 0030799: Draw Harness, ViewerTest - setup uniforms via vshader command
vshaderprog command now supports setup custom uniforms
2019-07-19 12:23:00 +03:00
kgv
1c728f2d6d 0030668: Visualization - revise adding ZLayer API
V3d_Viewer::AddZLayer() has been replaced by
V3d_Viewer::InsertLayerBefore() and V3d_Viewer::InsertLayerAfter() methods
allowing to specify Layer settings and index of existing layer to insert new one before/after.
The behavior of V3d_Viewer::AddZLayer() has been adjusted to append
new Layer before Graphic3d_ZLayerId_Top
(between Graphic3d_ZLayerId_Default and Graphic3d_ZLayerId_Top).

Graphic3d_Layer now provides LayerId() property.
Graphic3d_ZLayerSettings has been extended with IsRaytracable() property;
Ray-Tracing now processes multiple layers instead of Graphic3d_ZLayerId_Default.

Moved some methods from OpenGl_View to the base class Graphic3d_CView.
2019-07-19 10:23:22 +03:00
ika
6b9b7e3c92 0030630: Visualization - wrong visualization of shape with mirrored transformation
Solids with mirror location are displayed, according to their normals.

vaspects -setBackFaceColor, added command to set backface color.
2019-07-18 11:09:08 +03:00
msv
7c08e3ac6e 0030829: BRepExtrema_ShapeProximity crashes with shape from STL/WRL
The fix makes algorithm independent on geometrical data. Only triangulation is needed for its work.
2019-07-18 11:09:08 +03:00
Benjamin Bihler
718d07fe5e 0030403: Application Framework - Overwriting Big BinOcaf Files Does Not Reduce Their Size
OSD_OpenFileDescriptor(), added truncating flag to fopen() flags for std::ios_base::out,
since truncating is implied by C++ output flag.
This fixes misbehavior of OSD_OpenStream() on MinGW-w64 platform.
2019-07-17 15:46:39 +03:00
abv
bc28da5c3a 0029736: Some Warnings During Compound Transfer to IGES Look Dubious
Incorrect (legacy) warnings during IGES export are removed
2019-07-15 15:56:03 +03:00
kgv
2fb08f0132 0030628: [REGRESSION] Data Exchange - Crash on importing STEP file
RWHeaderSection_RWFileDescription::ReadStep(), added check for an empty list.
2019-07-15 15:48:00 +03:00
ysn
b8d92a7f8f 0029987: Request for translation of French comments in the code
French comments in two files have been translated in English.
2019-07-11 13:36:28 +03:00
kgv
f6abd02cdc 0030837: Data Exchange, XCAFPrs_DocumentExplorer - fix misprint in XCAFPrs_DocumentExplorerFlags_NoStyle check 2019-07-11 11:08:15 +03:00
apn
943b4e5b95 0027710: Make Data-exchange test cases more machine independent
Added description of de test grid in user guide.
2019-07-11 11:04:19 +03:00
iko
c55c8fe929 0030833: Visualization - Graphic3d_Camera constructor's exceptions
Field's initialization part has been added to Graphic3d_Camera constructor receiving Handle(Graphic3d_Camera).
2019-07-10 10:41:26 +03:00
oan
4c04741d4c 0030827: Add common functionality allowing to switch triangulation algorithm in runtime
New classes BRepMesh_ConstrainedBaseMeshAlgo, BRepMesh_CustomBaseMeshAlgo and BRepMesh_CustomDelaunayBaseMeshAlgo are added.
These classes allow to add any custom triangulation algorithm to BRepMesh and perform post-processing and optimization of base mesh generated by those algorithms.
BRepMesh_Delaun: added possibility to process constraints when base mesh is generated by different algorithm.
BRepMesh_DelaunayNodeInsertionMeshAlgo: added PreProcessSurfaceNodes flag controlling addition of surface nodes (either before creation of base mesh or after) to gain maximum performance from triangulation algorithms.

Minor changes:
Use simple algorithm for cylinders when internal vertices mode is switched off to speed up computations.
BRepMesh_IncrementalMesh: added Perform method allowing to execute algorithm using manually created Context.
2019-07-08 15:40:36 +03:00
asl
0d56f7433b 0030824: Visualization, PrsMgr_PresentableObject - A new flag to disable automatic selection of children
A new flag myToPropagateVisualState is introduced for PrsMgr_PresentableObject: by default it is true, it means that the visual state (display/erase/color) should be propagated to all children. If false, the visual state is not propagated.
The flag can be set via the method ToPropagateVisualState() or via Draw command: "vparent <parent> -ignoreVisu"
2019-07-04 19:36:30 +03:00
tiv
acc6542a1b 0030820: Draw Harness, ViewerTest - vsetcolor has no effect on objects created by vsegment and vtriangle
MyPArrayObject class (an interactive object representing some array of primitives) is improved: a possibility of color changing is added to it.
2019-07-04 19:34:27 +03:00
kgv
803bdcdf2b 0030821: Data Exchange, RWGltf_CafReader - fallback to Mesh name in case of Node name is empty
Added option to use Mesh name as fallback, enabled by default.
2019-07-01 13:31:58 +03:00
emv
b6c113d0eb 0030817: Modeling Algorithms - BRepOffsetAPI_MakePipeShell produces invalid result
BRepFill_TrimShellCorner::CheckAndOrientEdges() - When orienting next edge in a sequence take into account the Orientation of the previous edge.
Test cases for the issue.
2019-06-27 16:07:14 +03:00
kgv
82c59511b4 0030811: Data Exchange, RWGltf_CafReader - fix inaccessibility of properties
Added missing Standard_EXPORT and getters.
Fixed metadata loss.
2019-06-26 18:49:23 +03:00
kgv
d9dd07545d 0030810: Data Exchange, RWObj_CafReader - fix material assignment
RWObj_MtlReader fixed incorrect folder iteration within findRelativePath().
Fixed discarding texture-only material.
RWObj_TriangulationReader::addMesh() - fixed usage of wrong material for flushing previous group.
2019-06-26 18:48:16 +03:00
emv
88c3accd1a 0030787: BRepOffsetAPI_MakePipeShell: hangs on the attached model
Protect IntTools_EdgeEdge::FindSolutions method from cases where splitting edge on parts does not give bounding box decreasing.
Use at least Epsilon from edges parameters as a step in BRepLib::FindValidRange.
Test case for the issue.
2019-06-25 19:47:09 +03:00
oan
3c1b70842d 0030780: [Regression to 7.3.0] BRepMesh fails triangulating one face of the shape
Added new parameter KeepSmallEdges to IMeshTools_Parameters allowing to compute min size for each edge locally, depending on the length of particular edge.
Parameter -smalledges now available for incmesh command.
2019-06-25 19:46:09 +03:00
kgv
62810a3c51 0030809: Data Exchange - fix misprint in RWMesh_CafReader::generateNames() 2019-06-25 19:45:05 +03:00
aba
bbf3fcdecd 0030806: Visualization - AIS Manipulator highlighting is not affected by the view affinity
- AIS_Manipalator object view affinity is now applied to presentation for highlighting.
2019-06-25 19:44:07 +03:00
kgv
e05d8d90c0 0030805: Visualization, StdSelect_BRepSelectionTool - empty sensitivity from polygon-only Edge
StdSelect_BRepSelectionTool::GetEdgeSensitive() now takes polygon points before creating curve Adaptor.
2019-06-25 19:42:49 +03:00
kgv
841aa8c47b 0030804: Foundation Classes - Poly_Connect crashes due to out-of-range array modification
Fixed initialization of edges array based on the wrong statement.
2019-06-25 19:41:23 +03:00
kgv
95bde2af7f 0030802: Draw Harness - add scrollbars to DFBrowse 2019-06-25 19:38:47 +03:00
msv
64a4475285 0029679: Draw Harness - Command 2dapprox works wrong when giving points in command line
Correct the behavior of the command 2dapprox for the case of points input in the command line.
Restore the work of the command 2dinterpole (implemented in the same method as 2dapprox).
Add test cases.
Correct generation of snapshots for the tests lowalgos/2dinter/*.
2019-06-24 19:22:47 +03:00
kgv
0c33a0bf4d 0030748: Visualization - Marker displayed in immediate layer ruins QT Quick view controls
OpenGl_Workspace::ResetAppliedAspect() now resets active texture unit to GL_TEXTURE0.
2019-06-22 19:50:10 +03:00
136 changed files with 4991 additions and 1324 deletions

View File

@@ -878,7 +878,18 @@ 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 demo
@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
This group allows demonstrating how testing cases are created, and testing DRAW commands and the test system as a whole.
@@ -889,7 +900,7 @@ This group allows demonstrating how testing cases are created, and testing DRAW
| samples | | OCCT samples |
@subsubsection testmanual_5_1_8 draft
@subsubsection testmanual_5_1_9 draft
This group allows testing draft operations.
@@ -900,7 +911,7 @@ DRAW module: MODELING.
| Angle | depouille | Drafts with angle (inclined walls) |
@subsubsection testmanual_5_1_9 feat
@subsubsection testmanual_5_1_10 feat
This group allows testing creation of features on a shape.
@@ -914,7 +925,7 @@ DRAW module: MODELING (package *BRepTest*).
| featrevol | | |
| featrf | | |
@subsubsection testmanual_5_1_10 heal
@subsubsection testmanual_5_1_11 heal
This group allows testing the functionality provided by *ShapeHealing* toolkit.
@@ -943,7 +954,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_11 mesh
@subsubsection testmanual_5_1_12 mesh
This group allows testing shape tessellation (*BRepMesh*) and shading.
@@ -960,7 +971,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_12 mkface
@subsubsection testmanual_5_1_13 mkface
This group allows testing creation of simple surfaces.
@@ -975,7 +986,7 @@ DRAW module: MODELING (package *BRepTest*)
| after_revsurf_and_offset | mkface | |
| mkplane | mkplane | |
@subsubsection testmanual_5_1_13 nproject
@subsubsection testmanual_5_1_14 nproject
This group allows testing normal projection of edges and wires onto a face.
@@ -985,7 +996,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| Base | nproject | |
@subsubsection testmanual_5_1_14 offset
@subsubsection testmanual_5_1_15 offset
This group allows testing offset functionality for curves and surfaces.
@@ -1001,7 +1012,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_15 pipe
@subsubsection testmanual_5_1_16 pipe
This group allows testing construction of pipes (sweeping of a contour along profile).
@@ -1011,7 +1022,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| Standard | pipe | |
@subsubsection testmanual_5_1_16 prism
@subsubsection testmanual_5_1_17 prism
This group allows testing construction of prisms.
@@ -1021,7 +1032,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| seminf | prism | |
@subsubsection testmanual_5_1_17 sewing
@subsubsection testmanual_5_1_18 sewing
This group allows testing sewing of faces by connecting edges.
@@ -1033,7 +1044,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_18 thrusection
@subsubsection testmanual_5_1_19 thrusection
This group allows testing construction of shell or a solid passing through a set of sections in a given sequence (loft).
@@ -1042,7 +1053,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_19 xcaf
@subsubsection testmanual_5_1_20 xcaf
This group allows testing extended data exchange packages.

View File

@@ -5595,7 +5595,7 @@ Draw provides command to create curves and surfaces by approximation.
* **appro** fits a curve through 3d points;
* **surfapp** and **grilapp** fit a surface through 3d points by approximation;
* **surfint** fit a surface through 3d points by interpolation;
* **2dinterpolate** interpolates a curve.
* **2dinterpole** interpolates a curve.
@subsubsection occt_draw_6_8_1 appro, dapprox

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 (theProgress.LocalNormalized, aCamera);
aCamLerp.Interpolate (HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate (Standard_False);
myView->SetCamera (aCamera);

View File

@@ -33,6 +33,9 @@ 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,6 +187,29 @@ 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 :
@@ -2447,12 +2470,10 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
}
//=======================================================================
//function : FitSelected
//purpose : Fits the view corresponding to the bounds of selected objects
//function : BoundingBoxOfSelection
//purpose :
//=======================================================================
void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
const Standard_Real theMargin,
const Standard_Boolean theToUpdate)
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
{
Bnd_Box aBndSelected;
AIS_MapOfObjectOwners anObjectOwnerMap;
@@ -2491,12 +2512,22 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
aBndSelected.Add (aTmpBox);
}
anObjectOwnerMap.Clear();
return aBndSelected;
}
if (aBndSelected.IsVoid())
return;
theView->FitAll (aBndSelected, theMargin, theToUpdate);
//=======================================================================
//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);
}
}
//=======================================================================

View File

@@ -370,6 +370,9 @@ 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.
@@ -505,6 +508,9 @@ 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,
@@ -1379,6 +1385,7 @@ 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,6 +325,7 @@ 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;
@@ -495,6 +496,7 @@ 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)
{
@@ -534,6 +536,7 @@ 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)
{
@@ -565,6 +568,17 @@ 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();
@@ -630,6 +644,7 @@ 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);
@@ -670,6 +685,7 @@ 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

@@ -1035,15 +1035,21 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
{
return;
}
aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
if (anOwner->Mode() == AIS_MM_TranslationPlane)
{
Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
aStyle->SetColor(myAxes[anOwner->Index()].Color());
aStyle->SetTransparency(0.5);
aPresentation->Highlight(aStyle);
aStyle->SetColor (myAxes[anOwner->Index()].Color());
aStyle->SetTransparency (0.5);
aPresentation->Highlight (aStyle);
}
else
aPresentation->Highlight(theStyle);
{
aPresentation->Highlight (theStyle);
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
{

View File

@@ -13,6 +13,7 @@
#include "AIS_ViewController.hxx"
#include <AIS_AnimationCamera.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Manipulator.hxx>
#include <AIS_Point.hxx>
@@ -47,12 +48,15 @@ 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),
//
@@ -1224,6 +1228,20 @@ 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 :
@@ -1236,6 +1254,8 @@ void AIS_ViewController::handlePanning (const Handle(V3d_View)& theView)
return;
}
AbortViewAnimation();
const Handle(Graphic3d_Camera)& aCam = theView->Camera();
if (aCam->IsOrthographic()
|| !hasPanningAnchorPoint())
@@ -1276,6 +1296,8 @@ 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(),
@@ -1299,6 +1321,8 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
return;
}
AbortViewAnimation();
const Handle(Graphic3d_Camera)& aCam = theView->Camera();
if (thePnt != NULL)
{
@@ -1371,9 +1395,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(theParams.Point.y()) - 0.5 * double(aWinSize.y()));
double(aWinSize.y() - theParams.Point.y() - 1) - 0.5 * double(aWinSize.y()));
aDxy.x() += -aViewDims1.X() * aPanFromCenterPx.x() / double(aWinSize.x());
aDxy.y() += aViewDims1.X() * aPanFromCenterPx.y() / double(aWinSize.x());
aDxy.y() += -aViewDims1.Y() * aPanFromCenterPx.y() / double(aWinSize.y());
}
//theView->Translate (aCam, aDxy.x(), aDxy.y());
@@ -1450,6 +1474,7 @@ 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)
@@ -1561,6 +1586,8 @@ 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);
@@ -1636,7 +1663,7 @@ gp_Pnt AIS_ViewController::GravityPoint (const Handle(AIS_InteractiveContext)& t
}
gp_Pnt aPnt;
if (PickPoint (aPnt, theCtx, theView, aCursor, false))
if (PickPoint (aPnt, theCtx, theView, aCursor, myToStickToRayOnRotation))
{
return aPnt;
}
@@ -1857,12 +1884,9 @@ 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, toStickToRay))
&& PickPoint (aPnt, theCtx, theView, aZoomParams.Point, myToStickToRayOnZoom))
{
handleZoom (theView, aZoomParams, &aPnt);
continue;
@@ -1870,7 +1894,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, toStickToRay))
if (PickPoint (aPnt, theCtx, theView, aWinSize / 2, myToStickToRayOnZoom))
{
aZoomParams.ResetPoint(); // do not pretend to zoom at 'nothing'
handleZoom (theView, aZoomParams, &aPnt);
@@ -2035,11 +2059,6 @@ 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)
@@ -2274,6 +2293,15 @@ 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,6 +30,7 @@
#include <Precision.hxx>
#include <Standard_Mutex.hxx>
class AIS_AnimationCamera;
class AIS_InteractiveObject;
class AIS_InteractiveContext;
class AIS_Point;
@@ -56,6 +57,15 @@ 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.
@@ -142,6 +152,18 @@ 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; }
@@ -590,12 +612,15 @@ 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

891
src/AIS/AIS_ViewCube.cxx Normal file
View File

@@ -0,0 +1,891 @@
// 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()));
}
}

645
src/AIS/AIS_ViewCube.hxx Normal file
View File

@@ -0,0 +1,645 @@
// 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,4 +182,6 @@ AIS_TypeOfPlane.hxx
AIS_ViewController.cxx
AIS_ViewController.hxx
AIS_ViewInputBuffer.hxx
AIS_ViewCube.cxx
AIS_ViewCube.hxx
AIS_WalkDelta.hxx

View File

@@ -48,25 +48,6 @@ 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 :
@@ -99,41 +80,37 @@ void Aspect_GenId::Free (const Standard_Integer theId)
}
// =======================================================================
// function : Lower
// function : Next
// purpose :
// =======================================================================
Standard_Integer Aspect_GenId::Lower() const
Standard_Integer Aspect_GenId::Next()
{
return myLowerBound;
Standard_Integer aNewId = 0;
if (!Next (aNewId))
{
throw Aspect_IdentDefinitionError("Aspect_GenId::Next(), Error: Available == 0");
}
return aNewId;
}
// =======================================================================
// function : Next
// purpose :
// =======================================================================
Standard_Integer Aspect_GenId::Next()
Standard_Boolean Aspect_GenId::Next (Standard_Integer& theId)
{
if (!myFreeIds.IsEmpty())
{
const Standard_Integer anId = myFreeIds.First();
theId = myFreeIds.First();
myFreeIds.RemoveFirst();
return anId;
return Standard_True;
}
else if (myFreeCount < 1)
{
throw Aspect_IdentDefinitionError("GenId Next Error: Available == 0");
return Standard_False;
}
--myFreeCount;
const Standard_Integer anId = myLowerBound + myLength - myFreeCount - 1;
return anId;
}
// =======================================================================
// function : Upper
// purpose :
// =======================================================================
Standard_Integer Aspect_GenId::Upper() const
{
return myUpperBound;
theId = myLowerBound + myLength - myFreeCount - 1;
return Standard_True;
}

View File

@@ -49,47 +49,38 @@ public:
Standard_EXPORT void Free (const Standard_Integer theId);
//! Returns true if there are available identifiers in range.
Standard_EXPORT Standard_Boolean HasFree() const;
Standard_Boolean HasFree() const
{
return myFreeCount > 0
|| myFreeIds.Extent() > 0;
}
//! Returns the number of available identifiers.
Standard_EXPORT Standard_Integer Available() const;
Standard_Integer Available() const { return myFreeCount + myFreeIds.Extent(); }
//! Returns the lower identifier in range.
Standard_EXPORT Standard_Integer Lower() const;
Standard_Integer Lower() const { return myLowerBound; }
//! 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_EXPORT Standard_Integer Upper() const;
protected:
Standard_Integer Upper() const { return myUpperBound; }
private:
Standard_Integer myFreeCount;
Standard_Integer myLength;
Standard_Integer myLowerBound;
Standard_Integer myUpperBound;
TColStd_ListOfInteger myFreeIds;
};
#endif // _Aspect_GenId_HeaderFile

View File

@@ -16,10 +16,8 @@
#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)
@@ -152,9 +150,6 @@ void BRepExtrema_TriangleSet::Clear()
BVH_Array4i anEmptyTriangles;
myTriangles.swap (anEmptyTriangles);
BVH_Array2d anEmptyVertUVArray;
myVertUVArray.swap (anEmptyVertUVArray);
BVH_Array3d anEmptyVertexArray;
myVertexArray.swap (anEmptyVertexArray);
}
@@ -179,8 +174,6 @@ 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;
@@ -193,11 +186,6 @@ 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,9 +75,6 @@ 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

@@ -55,6 +55,8 @@ static Standard_Boolean findNearestValidPoint(
//
// the general step is computed using general curve resolution
Standard_Real aStep = theCurve.Resolution(theTol) * 1.01;
if (aStep < theEps)
aStep = theEps;
// aD1Mag is a threshold to consider local derivative magnitude too small
// and to accelerate going out of sphere
// (inverse of resolution is the maximal derivative);
@@ -159,11 +161,19 @@ Standard_Boolean BRepLib::FindValidRange
if (theParV2 - theParV1 < Precision::PConfusion())
return Standard_False;
Standard_Real anEps = Max(Max(theCurve.Resolution(theTolE) * 0.1,
Epsilon(Max(Abs(theParV1), Abs(theParV2)))),
Precision::PConfusion());
Standard_Boolean isInfParV1 = Precision::IsInfinite (theParV1),
isInfParV2 = Precision::IsInfinite (theParV2);
if (Precision::IsInfinite(theParV1))
Standard_Real aMaxPar = 0.0;
if (!isInfParV1)
aMaxPar = Abs (theParV1);
if (!isInfParV2)
aMaxPar = Max (aMaxPar, Abs (theParV2));
Standard_Real anEps = Max (Max (theCurve.Resolution (theTolE) * 0.1, Epsilon (aMaxPar)),
Precision::PConfusion());
if (isInfParV1)
theFirst = theParV1;
else
{
@@ -174,7 +184,7 @@ Standard_Boolean BRepLib::FindValidRange
return Standard_False;
}
if (Precision::IsInfinite(theParV2))
if (isInfParV2)
theLast = theParV2;
else
{

View File

@@ -83,6 +83,12 @@ public:
myFaceMax = theMax;
}
//! Retruns true if cell filter contains no circle.
inline Standard_Boolean IsEmpty () const
{
return mySelector.Circles ().IsEmpty ();
}
//! Binds the circle to the tool.
//! @param theIndex index a circle should be bound with.
//! @param theCircle circle to be bound.

View File

@@ -0,0 +1,60 @@
// Created on: 2019-07-08
// 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_ConstrainedBaseMeshAlgo_HeaderFile
#define _BRepMesh_ConstrainedBaseMeshAlgo_HeaderFile
#include <BRepMesh_BaseMeshAlgo.hxx>
#include <NCollection_Shared.hxx>
#include <IMeshTools_Parameters.hxx>
class BRepMesh_DataStructureOfDelaun;
class BRepMesh_Delaun;
//! Class provides base fuctionality to build face triangulation using Dealunay approach.
//! Performs generation of mesh using raw data from model.
class BRepMesh_ConstrainedBaseMeshAlgo : public BRepMesh_BaseMeshAlgo
{
public:
//! Constructor.
BRepMesh_ConstrainedBaseMeshAlgo ()
{
}
//! Destructor.
virtual ~BRepMesh_ConstrainedBaseMeshAlgo ()
{
}
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ConstrainedBaseMeshAlgo, BRepMesh_BaseMeshAlgo)
protected:
//! Returns size of cell to be used by acceleration circles grid structure.
virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer /*theVerticesNb*/)
{
return std::pair<Standard_Integer, Standard_Integer> (-1, -1);
}
//! Perfroms processing of generated mesh.
//! By default does nothing.
//! Expected to be called from method generateMesh() in successor classes.
virtual void postProcessMesh (BRepMesh_Delaun& /*theMesher*/)
{
}
};
#endif

View File

@@ -26,6 +26,7 @@
#include <Adaptor3d_HCurveOnSurface.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <Standard_Failure.hxx>
#include <GCPnts_AbscissaPoint.hxx>
//=======================================================================
//function : Constructor
@@ -79,21 +80,28 @@ void BRepMesh_CurveTessellator::init()
aPreciseLinDef *= 0.5;
}
aPreciseLinDef = Max(aPreciseLinDef, Precision::Confusion());
aPreciseAngDef = Max(aPreciseAngDef, Precision::Angular());
aPreciseLinDef = Max (aPreciseLinDef, Precision::Confusion());
aPreciseAngDef = Max (aPreciseAngDef, Precision::Angular());
Standard_Real aMinSize = myParameters.MinSize;
if (myParameters.AdjustMinSize)
{
aMinSize = Min (aMinSize, myParameters.RelMinSize() * GCPnts_AbscissaPoint::Length (
myCurve, myCurve.FirstParameter(), myCurve.LastParameter(), aPreciseLinDef));
}
mySquareEdgeDef = aPreciseLinDef * aPreciseLinDef;
mySquareMinSize = Max(mySquareEdgeDef, myParameters.MinSize * myParameters.MinSize);
mySquareMinSize = Max (mySquareEdgeDef, aMinSize * aMinSize);
myEdgeSqTol = BRep_Tool::Tolerance(myEdge);
myEdgeSqTol = BRep_Tool::Tolerance (myEdge);
myEdgeSqTol *= myEdgeSqTol;
const Standard_Integer aMinPntNb = (myCurve.GetType() == GeomAbs_Circle) ? 4 : 2; //OCC287
myDiscretTool.Initialize(myCurve,
myCurve.FirstParameter(), myCurve.LastParameter(),
aPreciseAngDef, aPreciseLinDef, aMinPntNb,
Precision::PConfusion(), myParameters.MinSize);
myDiscretTool.Initialize (myCurve,
myCurve.FirstParameter(), myCurve.LastParameter(),
aPreciseAngDef, aPreciseLinDef, aMinPntNb,
Precision::PConfusion(), aMinSize);
if (myCurve.IsCurveOnSurface())
{

View File

@@ -0,0 +1,70 @@
// Created on: 2019-06-07
// 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_CustomBaseMeshAlgo_HeaderFile
#define _BRepMesh_CustomBaseMeshAlgo_HeaderFile
#include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
#include <NCollection_Shared.hxx>
#include <IMeshTools_Parameters.hxx>
#include <BRepMesh_Delaun.hxx>
#include <BRepMesh_MeshTool.hxx>
class BRepMesh_DataStructureOfDelaun;
//! Class provides base fuctionality to build face triangulation using custom triangulation algorithm.
//! Performs generation of mesh using raw data from model.
class BRepMesh_CustomBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
{
public:
//! Constructor.
Standard_EXPORT BRepMesh_CustomBaseMeshAlgo ()
{
}
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_CustomBaseMeshAlgo ()
{
}
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
protected:
//! Generates mesh for the contour stored in data structure.
Standard_EXPORT virtual void generateMesh () Standard_OVERRIDE
{
const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
buildBaseTriangulation ();
std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
aMesher.ProcessConstraints ();
BRepMesh_MeshTool aCleaner (aStructure);
aCleaner.EraseFreeLinks ();
postProcessMesh (aMesher);
}
protected:
//! Builds base triangulation using custom triangulation algorithm.
Standard_EXPORT virtual void buildBaseTriangulation() = 0;
};
#endif

View File

@@ -0,0 +1,53 @@
// Created on: 2019-06-07
// 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_CustomDelaunayBaseMeshAlgo_HeaderFile
#define _BRepMesh_CustomDelaunayBaseMeshAlgo_HeaderFile
class BRepMesh_DataStructureOfDelaun;
class BRepMesh_Delaun;
//! Class provides base fuctionality to build face triangulation using custom
//! triangulation algorithm with possibility to modify final mesh.
//! Performs generation of mesh using raw data from model.
template<class BaseAlgo>
class BRepMesh_CustomDelaunayBaseMeshAlgo : public BaseAlgo
{
public:
//! Constructor.
BRepMesh_CustomDelaunayBaseMeshAlgo ()
{
}
//! Destructor.
virtual ~BRepMesh_CustomDelaunayBaseMeshAlgo ()
{
}
protected:
//! Perfroms processing of generated mesh.
virtual void postProcessMesh(BRepMesh_Delaun& theMesher)
{
BaseAlgo::postProcessMesh (theMesher);
const Handle(BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure();
std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes());
theMesher.InitCirclesTool (aCellsCount.first, aCellsCount.second);
}
};
#endif

View File

@@ -78,6 +78,25 @@ namespace {
}
} // anonymous namespace
//=======================================================================
//function : BRepMesh_Delaun
//purpose :
//=======================================================================
BRepMesh_Delaun::BRepMesh_Delaun (
const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV,
const Standard_Boolean isFillCircles)
: myMeshData ( theOldMesh ),
myCircles (new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
{
if (isFillCircles)
{
InitCirclesTool (theCellsCountU, theCellsCountV);
}
}
//=======================================================================
//function : BRepMesh_Delaun
//purpose : Creates the triangulation with an empty Mesh data structure
@@ -103,7 +122,8 @@ BRepMesh_Delaun::BRepMesh_Delaun(
const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
IMeshData::Array1OfVertexOfDelaun& theVertices)
: myMeshData( theOldMesh ),
myCircles ( theVertices.Length(), theOldMesh->Allocator() )
myCircles ( theVertices.Length(), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
{
if ( theVertices.Length() > 2 )
{
@@ -119,7 +139,8 @@ BRepMesh_Delaun::BRepMesh_Delaun(
const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
IMeshData::VectorOfInteger& theVertexIndices)
: myMeshData( theOldMesh ),
myCircles ( theVertexIndices.Length(), theOldMesh->Allocator() )
myCircles ( theVertexIndices.Length(), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
{
perform(theVertexIndices);
}
@@ -133,7 +154,8 @@ BRepMesh_Delaun::BRepMesh_Delaun (const Handle (BRepMesh_DataStructureOfDelaun)&
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
: myMeshData (theOldMesh),
myCircles (theVertexIndices.Length (), theOldMesh->Allocator ())
myCircles (theVertexIndices.Length (), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
{
perform (theVertexIndices, theCellsCountU, theCellsCountV);
}
@@ -157,6 +179,63 @@ void BRepMesh_Delaun::Init(IMeshData::Array1OfVertexOfDelaun& theVertices)
perform( aVertexIndexes );
}
//=======================================================================
//function : InitCirclesTool
//purpose :
//=======================================================================
void BRepMesh_Delaun::InitCirclesTool (const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
{
Bnd_Box2d aBox;
for (Standard_Integer aNodeIt = 1; aNodeIt <= myMeshData->NbNodes(); ++aNodeIt)
{
aBox.Add (gp_Pnt2d (GetVertex (aNodeIt).Coord ()));
}
aBox.Enlarge (Precision);
initCirclesTool (aBox, theCellsCountU, theCellsCountV);
IMeshData::IteratorOfMapOfInteger aTriangleIt (myMeshData->ElementsOfDomain());
for (; aTriangleIt.More(); aTriangleIt.Next())
{
Standard_Integer aNodesIndices[3];
const BRepMesh_Triangle& aTriangle = myMeshData->GetElement (aTriangleIt.Key());
myMeshData->ElementNodes (aTriangle, aNodesIndices);
myCircles.Bind (aTriangleIt.Key(),
GetVertex( aNodesIndices[0] ).Coord(),
GetVertex( aNodesIndices[1] ).Coord(),
GetVertex( aNodesIndices[2] ).Coord());
}
}
//=======================================================================
//function : initCirclesTool
//purpose :
//=======================================================================
void BRepMesh_Delaun::initCirclesTool (const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
{
Standard_Real aMinX, aMinY, aMaxX, aMaxY;
theBox.Get ( aMinX, aMinY, aMaxX, aMaxY );
const Standard_Real aDeltaX = aMaxX - aMinX;
const Standard_Real aDeltaY = aMaxY - aMinY;
Standard_Integer aScaler = 2;
if ( myMeshData->NbNodes() > 100 )
{
aScaler = 5;
}
else if( myMeshData->NbNodes() > 1000 )
{
aScaler = 7;
}
myCircles.SetMinMaxSize( gp_XY( aMinX, aMinY ), gp_XY( aMaxX, aMaxY ) );
myCircles.SetCellSize ( aDeltaX / Max (theCellsCountU, aScaler),
aDeltaY / Max (theCellsCountV, aScaler));
}
//=======================================================================
//function : perform
//purpose : Create super mesh and run triangulation procedure
@@ -180,18 +259,8 @@ void BRepMesh_Delaun::perform(IMeshData::VectorOfInteger& theVertexIndices,
aBox.Enlarge (Precision);
Standard_Integer aScaler = 2;
if ( myMeshData->NbNodes() > 100 )
{
aScaler = 5;
}
else if( myMeshData->NbNodes() > 1000 )
{
aScaler = 7;
}
superMesh (aBox, Max (theCellsCountU, aScaler),
Max (theCellsCountV, aScaler));
initCirclesTool (aBox, theCellsCountU, theCellsCountV);
superMesh (aBox);
ComparatorOfIndexedVertexOfDelaun aCmp(myMeshData);
std::make_heap(theVertexIndices.begin(), theVertexIndices.end(), aCmp);
@@ -204,9 +273,7 @@ void BRepMesh_Delaun::perform(IMeshData::VectorOfInteger& theVertexIndices,
//function : superMesh
//purpose : Build the super mesh
//=======================================================================
void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox)
{
Standard_Real aMinX, aMinY, aMaxX, aMaxY;
theBox.Get ( aMinX, aMinY, aMaxX, aMaxY );
@@ -217,9 +284,6 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox,
Standard_Real aDeltaMax = Max( aDeltaX, aDeltaY );
Standard_Real aDelta = aDeltaX + aDeltaY;
myCircles.SetMinMaxSize( gp_XY( aMinX, aMinY ), gp_XY( aMaxX, aMaxY ) );
myCircles.SetCellSize( aDeltaX / theCellsCountU, aDeltaY / theCellsCountV);
mySupVert[0] = myMeshData->AddNode(
BRepMesh_Vertex( ( aMinX + aMaxX ) / 2, aMaxY + aDeltaMax, BRepMesh_Free ) );
@@ -254,7 +318,10 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox,
void BRepMesh_Delaun::deleteTriangle(const Standard_Integer theIndex,
IMeshData::MapOfIntegerInteger& theLoopEdges )
{
myCircles.Delete( theIndex );
if (!myCircles.IsEmpty())
{
myCircles.Delete (theIndex);
}
const BRepMesh_Triangle& aElement = GetTriangle(theIndex);
const Standard_Integer(&e)[3] = aElement.myEdges;
@@ -279,8 +346,11 @@ void BRepMesh_Delaun::deleteTriangle(const Standard_Integer theIndex,
//=======================================================================
void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes)
{
// Insertion of edges of super triangles in the list of free edges:
IMeshData::MapOfIntegerInteger aLoopEdges(10, myMeshData->Allocator());
// Insertion of edges of super triangles in the list of free edges:
Handle(NCollection_IncAllocator) aAllocator = new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE);
IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator);
const Standard_Integer(&e)[3] = mySupTrian.myEdges;
aLoopEdges.Bind( e[0], Standard_True );
@@ -531,10 +601,7 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
}
}
insertInternalEdges();
// Adjustment of meshes to boundary edges
frontierAdjust();
ProcessConstraints();
}
//=======================================================================

View File

@@ -41,6 +41,12 @@ public:
DEFINE_STANDARD_ALLOC
//! Creates instance of triangulator, but do not run the algorithm automatically.
Standard_EXPORT BRepMesh_Delaun (const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV,
const Standard_Boolean isFillCircles);
//! Creates the triangulation with an empty Mesh data structure.
Standard_EXPORT BRepMesh_Delaun (IMeshData::Array1OfVertexOfDelaun& theVertices);
@@ -61,6 +67,10 @@ public:
//! Initializes the triangulation with an array of vertices.
Standard_EXPORT void Init (IMeshData::Array1OfVertexOfDelaun& theVertices);
//! Forces initialization of circles cell filter using working structure.
Standard_EXPORT void InitCirclesTool (const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV);
//! Removes a vertex from the triangulation.
Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex);
@@ -77,6 +87,15 @@ public:
return myMeshData;
}
//! Forces insertion of constraint edges into the base triangulation.
inline void ProcessConstraints()
{
insertInternalEdges();
// Adjustment of meshes to boundary edges
frontierAdjust();
}
//! Gives the list of frontier edges.
inline Handle(IMeshData::MapOfInteger) Frontier() const
{
@@ -139,6 +158,11 @@ private:
typedef NCollection_DataMap<Standard_Integer, IMeshData::MapOfInteger> DataMapOfMap;
//! Performs initialization of circles cell filter tool.
void initCirclesTool (const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV);
//! Add boundig box for edge defined by start & end point to
//! the given vector of bounding boxes for triangulation edges.
void fillBndBox (IMeshData::SequenceOfBndB2d& theBoxes,
@@ -156,9 +180,7 @@ private:
const Standard_Integer theCellsCountV = -1);
//! Build the super mesh.
void superMesh (const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV);
void superMesh (const Bnd_Box2d& theBox);
//! Computes the triangulation and adds the vertices,
//! edges and triangles to the Mesh data structure.

View File

@@ -16,7 +16,7 @@
#ifndef _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile
#define _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile
#include <BRepMesh_BaseMeshAlgo.hxx>
#include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
#include <NCollection_Shared.hxx>
#include <IMeshTools_Parameters.hxx>
@@ -25,7 +25,7 @@ class BRepMesh_Delaun;
//! Class provides base fuctionality to build face triangulation using Dealunay approach.
//! Performs generation of mesh using raw data from model.
class BRepMesh_DelaunayBaseMeshAlgo : public BRepMesh_BaseMeshAlgo
class BRepMesh_DelaunayBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
{
public:
@@ -35,24 +35,12 @@ public:
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_DelaunayBaseMeshAlgo();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelaunayBaseMeshAlgo, BRepMesh_BaseMeshAlgo)
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelaunayBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
protected:
//! Returns size of cell to be used by acceleration circles grid structure.
virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer /*theVerticesNb*/)
{
return std::pair<Standard_Integer, Standard_Integer> (-1, -1);
}
//! Generates mesh for the contour stored in data structure.
Standard_EXPORT virtual void generateMesh() Standard_OVERRIDE;
//! Perfroms processing of generated mesh.
//! By default does nothing.
virtual void postProcessMesh(BRepMesh_Delaun& /*theMesher*/)
{
}
};
#endif

View File

@@ -22,12 +22,12 @@
//! Extends node insertion Delaunay meshing algo in order to control
//! deflection of generated trianges. Splits triangles failing the check.
template<class RangeSplitter>
class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter>
template<class RangeSplitter, class BaseAlgo>
class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
{
private:
// Typedef for OCCT RTTI
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter> DelaunayInsertionBaseClass;
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> DelaunayInsertionBaseClass;
public:

View File

@@ -21,17 +21,18 @@
//! Extends base Delaunay meshing algo in order to enable possibility
//! of addition of free vertices and internal nodes into the mesh.
template<class RangeSplitter>
class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo>
template<class RangeSplitter, class BaseAlgo>
class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
{
private:
// Typedef for OCCT RTTI
typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> InsertionBaseClass;
typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> InsertionBaseClass;
public:
//! Constructor.
BRepMesh_DelaunayNodeInsertionMeshAlgo()
: myIsPreProcessSurfaceNodes (Standard_False)
{
}
@@ -40,8 +41,41 @@ public:
{
}
//! Returns PreProcessSurfaceNodes flag.
inline Standard_Boolean IsPreProcessSurfaceNodes () const
{
return myIsPreProcessSurfaceNodes;
}
//! Sets PreProcessSurfaceNodes flag.
//! If TRUE, registers surface nodes before generation of base mesh.
//! If FALSE, inserts surface nodes after generation of base mesh.
inline void SetPreProcessSurfaceNodes (const Standard_Boolean isPreProcessSurfaceNodes)
{
myIsPreProcessSurfaceNodes = isPreProcessSurfaceNodes;
}
protected:
//! Performs initialization of data structure using existing model data.
virtual Standard_Boolean initDataStructure() Standard_OVERRIDE
{
if (!InsertionBaseClass::initDataStructure())
{
return Standard_False;
}
if (myIsPreProcessSurfaceNodes)
{
const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
registerSurfaceNodes (aSurfaceNodes);
}
return Standard_True;
}
//! Returns size of cell to be used by acceleration circles grid structure.
virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer theVerticesNb) Standard_OVERRIDE
{
@@ -55,10 +89,13 @@ protected:
{
InsertionBaseClass::postProcessMesh(theMesher);
const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
if (!myIsPreProcessSurfaceNodes)
{
const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
insertNodes(aSurfaceNodes, theMesher);
insertNodes(aSurfaceNodes, theMesher);
}
}
//! Inserts nodes into mesh.
@@ -86,6 +123,37 @@ protected:
theMesher.AddVertices(aVertexIndexes);
return !aVertexIndexes.IsEmpty();
}
private:
//! Registers surface nodes in data structure.
Standard_Boolean registerSurfaceNodes(
const Handle(IMeshData::ListOfPnt2d)& theNodes)
{
if (theNodes.IsNull() || theNodes->IsEmpty())
{
return Standard_False;
}
Standard_Boolean isAdded = Standard_False;
IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
{
const gp_Pnt2d& aPnt2d = aNodesIt.Value();
if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
{
isAdded = Standard_True;
this->registerNode(this->getRangeSplitter().Point(aPnt2d),
aPnt2d, BRepMesh_Free, Standard_False);
}
}
return isAdded;
}
private:
Standard_Boolean myIsPreProcessSurfaceNodes;
};
#endif

View File

@@ -94,8 +94,6 @@ namespace
Handle(BRepMesh_FaceChecker::ArrayOfBndBoxTree)& myWiresBndBoxTree;
};
//! Selector.
//! Used to identify segments with overlapped bounding boxes.
//! Selector.
//! Used to identify segments with overlapped bounding boxes.
class BndBox2dTreeSelector : public IMeshData::BndBox2dTree::Selector

View File

@@ -86,19 +86,28 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Perform()
{
Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
Perform (aContext);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext)
{
initParameters();
Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
aContext->SetShape(Shape());
aContext->ChangeParameters() = myParameters;
aContext->ChangeParameters().CleanModel = Standard_False;
theContext->SetShape(Shape());
theContext->ChangeParameters() = myParameters;
theContext->ChangeParameters().CleanModel = Standard_False;
IMeshTools_MeshBuilder aIncMesh(aContext);
IMeshTools_MeshBuilder aIncMesh(theContext);
aIncMesh.Perform();
myStatus = IMeshData_NoError;
const Handle(IMeshData_Model)& aModel = aContext->GetModel();
const Handle(IMeshData_Model)& aModel = theContext->GetModel();
for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt)
{
const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt);

View File

@@ -16,6 +16,7 @@
#include <BRepMesh_DiscretRoot.hxx>
#include <IMeshTools_Parameters.hxx>
#include <IMeshTools_Context.hxx>
//! Builds the mesh of a shape with respect of their
//! correctly triangulated parts
@@ -51,8 +52,11 @@ public: //! @name mesher API
Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters);
//! Performs meshing ot the shape.
//! Performs meshing ot the shape.
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
//! Performs meshing using custom context;
Standard_EXPORT void Perform(const Handle(IMeshTools_Context)& theContext);
public: //! @name accessing to parameters.

View File

@@ -35,13 +35,13 @@ namespace
template<class RangeSplitter>
struct NodeInsertionMeshAlgo
{
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter> Type;
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> Type;
};
template<class RangeSplitter>
struct DeflectionControlMeshAlgo
{
typedef BRepMesh_DelaunayDeflectionControlMeshAlgo<RangeSplitter> Type;
typedef BRepMesh_DelaunayDeflectionControlMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> Type;
};
}
@@ -82,7 +82,9 @@ Handle(IMeshTools_MeshAlgo) BRepMesh_MeshAlgoFactory::GetAlgo(
break;
case GeomAbs_Cylinder:
return new NodeInsertionMeshAlgo<BRepMesh_CylinderRangeSplitter>::Type;
return theParameters.InternalVerticesMode ?
new NodeInsertionMeshAlgo<BRepMesh_CylinderRangeSplitter>::Type :
new BaseMeshAlgo::Type;
break;
case GeomAbs_Cone:

View File

@@ -1,5 +1,6 @@
BRepMesh_BaseMeshAlgo.cxx
BRepMesh_BaseMeshAlgo.hxx
BRepMesh_ConstrainedBaseMeshAlgo.hxx
BRepMesh_BoundaryParamsRangeSplitter.hxx
BRepMesh_Circle.hxx
BRepMesh_CircleInspector.hxx
@@ -82,4 +83,6 @@ BRepMesh_UVParamRangeSplitter.hxx
BRepMesh_Vertex.hxx
BRepMesh_VertexInspector.hxx
BRepMesh_VertexTool.cxx
BRepMesh_VertexTool.hxx
BRepMesh_VertexTool.hxx
BRepMesh_CustomBaseMeshAlgo.hxx
BRepMesh_CustomDelaunayBaseMeshAlgo.hxx

View File

@@ -845,7 +845,6 @@ 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());
@@ -857,7 +856,6 @@ 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());
@@ -869,7 +867,6 @@ 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

@@ -156,6 +156,13 @@ void BRepTools_ReShape::replace (const TopoDS_Shape& ashape,
TopoDS_Shape shape = ashape;
TopoDS_Shape newshape = anewshape;
if ( shape.IsNull() || shape == newshape ) return;
if (Apply (newshape) == shape)
{
#ifdef OCCT_DEBUG
cout << "Warning: BRepTools_ReShape::Replace: recording the shape will lead to a loop" << endl;
#endif
return;
}
if (shape.Orientation() == TopAbs_REVERSED)
{
@@ -181,7 +188,9 @@ void BRepTools_ReShape::replace (const TopoDS_Shape& ashape,
#ifdef OCCT_DEBUG
if ( IsRecorded ( shape ) && ((myConsiderLocation && ! Value ( shape ).IsPartner ( newshape )) ||
(!myConsiderLocation && ! Value ( shape ).IsSame ( newshape ))))
{
cout << "Warning: BRepTools_ReShape::Replace: shape already recorded" << endl;
}
#endif
myShapeToReplacement.Bind(shape, TReplacement(newshape, theKind));

View File

@@ -44,22 +44,17 @@ D3DHost_GraphicDriver::~D3DHost_GraphicDriver()
}
// =======================================================================
// function : View
// function : CreateView
// 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 (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
{
const Graphic3d_ZLayerId aLayerID = aLayerIt.Value();
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerID);
aView->AddZLayer (aLayerID);
aView->SetZLayerSettings (aLayerID, aSettings);
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
aView->InsertLayerAfter (aLayer->LayerId(), aLayer->LayerSettings(), Graphic3d_ZLayerId_UNKNOWN);
}
return aView;
}

View File

@@ -78,13 +78,19 @@ proc dftree { DDF_Browser } {
## ]
set w .$DDF_Browser
toplevel $w -height 400 -width 700 -background bisque3
toplevel $w -width 700 -height 400 -background bisque3
wm minsize $w 700 400
########
# Tree #
########
set tree1 [ttk::treeview $w.tree -show tree]
#set tree1 [ttk::treeview $w.tree -show tree]
set tree1 [ttk::treeview $w.tree -show tree -xscrollcommand "$w.tree.xscroll set" -yscrollcommand "$w.tree.yscroll set"]
set aScrollX [ttk::scrollbar $w.tree.xscroll -command "$w.tree xview" -orient horizontal]
set aScrollY [ttk::scrollbar $w.tree.yscroll -command "$w.tree yview"]
pack $aScrollX -side bottom -fill x
pack $aScrollY -side right -fill y
$tree1 tag bind Label <<TreeviewOpen>> [list DFTREE:Tree:Open $DDF_Browser $w]
$tree1 tag configure Label -font 9x15bold -foreground DarkGreen
#$tree1 tag configure Attribute -font 9x15 -background bisque3

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,7 @@
#include <DrawTrSurf_Curve2d.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Geom2dAPI_ExtremaCurveCurve.hxx>
#include <Geom2dAPI_Interpolate.hxx>
#include <Geom2dAPI_PointsToBSpline.hxx>
#include <Geom2dAPI_InterCurveCurve.hxx>
#include <Geom2d_Line.hxx>
@@ -178,7 +179,6 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
else {
// test points ou ordonnees
hasPoints = Standard_False;
Standard_Integer nc = n - 3;
if (nc == 2 * Nb) {
// points
@@ -190,6 +190,7 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
}
else if (nc - 2 == Nb) {
// YValues
hasPoints = Standard_False;
nc = 5;
X0 = Draw::Atof(a[3]);
DX = Draw::Atof(a[4]);
@@ -214,9 +215,44 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
Handle(Geom2d_BSplineCurve) TheCurve;
if (hasPoints)
TheCurve = Geom2dAPI_PointsToBSpline(Points,Dmin,Dmax,GeomAbs_C2,Tol2d);
{
if (!strcmp (a[0], "2dinterpole"))
{
Geom2dAPI_Interpolate anInterpol (new TColgp_HArray1OfPnt2d(Points), Standard_False, Tol2d);
anInterpol.Perform();
if (!anInterpol.IsDone())
{
di << "not done";
return 1;
}
TheCurve = anInterpol.Curve();
}
else
{
Geom2dAPI_PointsToBSpline anApprox (Points, Dmin, Dmax, GeomAbs_C2, Tol2d);
if (!anApprox.IsDone())
{
di << "not done";
return 1;
}
TheCurve = anApprox.Curve();
}
}
else
TheCurve = Geom2dAPI_PointsToBSpline(YValues,X0,DX,Dmin,Dmax,GeomAbs_C2,Tol2d);
{
if (!strcmp (a[0], "2dinterpole"))
{
di << "incorrect usage";
return 1;
}
Geom2dAPI_PointsToBSpline anApprox (YValues, X0, DX, Dmin, Dmax, GeomAbs_C2, Tol2d);
if (!anApprox.IsDone())
{
di << "not done";
return 1;
}
TheCurve = anApprox.Curve();
}
DrawTrSurf::Set(a[1], TheCurve);
di << a[1];

View File

@@ -12,22 +12,13 @@
// 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 :
@@ -357,6 +348,28 @@ 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 :
@@ -407,40 +420,25 @@ void Graphic3d_CView::DisplayedStructures (Graphic3d_MapOfStructure& theStructur
// =======================================================================
Bnd_Box Graphic3d_CView::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const
{
Bnd_Box aResult;
if (!IsDefined())
{
return aResult;
return Bnd_Box();
}
Handle(Graphic3d_Camera) aCamera = Camera();
Standard_Integer aWinWidth = 0;
Standard_Integer aWinHeight = 0;
const Handle(Graphic3d_Camera)& aCamera = Camera();
Graphic3d_Vec2i aWinSize;
Window()->Size (aWinSize.x(), aWinSize.y());
Window()->Size (aWinWidth, aWinHeight);
for (Standard_Integer aLayer = 0; aLayer < THE_NB_DEFAULT_LAYERS; ++aLayer)
Bnd_Box aResult;
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
{
Bnd_Box aBox = ZLayerBoundingBox (THE_DEFAULT_LAYERS[aLayer],
aCamera,
aWinWidth,
aWinHeight,
theToIncludeAuxiliary);
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
Bnd_Box aBox = aLayer->BoundingBox (Identification(),
aCamera,
aWinSize.x(), aWinSize.y(),
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;
}
@@ -455,21 +453,15 @@ Standard_Real Graphic3d_CView::ConsiderZoomPersistenceObjects()
return 1.0;
}
Handle(Graphic3d_Camera) aCamera = Camera();
Standard_Integer aWinWidth = 0;
Standard_Integer aWinHeight = 0;
Window()->Size (aWinWidth, aWinHeight);
const Handle(Graphic3d_Camera)& aCamera = Camera();
Graphic3d_Vec2i aWinSize;
Window()->Size (aWinSize.x(), aWinSize.y());
Standard_Real aMaxCoef = 1.0;
for (Standard_Integer aLayer = 0; aLayer < THE_NB_DEFAULT_LAYERS; ++aLayer)
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
{
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));
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
aMaxCoef = Max (aMaxCoef, aLayer->considerZoomPersistenceObjects (Identification(), aCamera, aWinSize.x(), aWinSize.y()));
}
return aMaxCoef;

View File

@@ -46,6 +46,7 @@
class Graphic3d_CView;
class Graphic3d_GraphicDriver;
class Graphic3d_Layer;
class Graphic3d_StructureManager;
DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
@@ -267,32 +268,34 @@ 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 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;
//! 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;
//! 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 bounding box of all structures displayed in the Z layer.
virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) 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.
//! @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;
Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
//! Remove Z layer from the specified view. All structures
//! displayed at the moment in layer will be displayed in default layer
@@ -447,12 +450,6 @@ 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,6 +103,21 @@ 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,6 +16,8 @@
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Layer.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,Standard_Transient)
// =======================================================================
@@ -25,70 +27,85 @@ 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 it can not be removed
// default layers are always presented in display layer sequence and cannot 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());
myLayerIds.Add (Graphic3d_ZLayerId_BotOSD);
myLayerSeq.Append (Graphic3d_ZLayerId_BotOSD);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_BotOSD, aSettings);
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);
}
{
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());
myLayerIds.Add (Graphic3d_ZLayerId_Default);
myLayerSeq.Append (Graphic3d_ZLayerId_Default);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Default, aSettings);
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);
}
{
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());
myLayerIds.Add (Graphic3d_ZLayerId_Top);
myLayerSeq.Append (Graphic3d_ZLayerId_Top);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Top, aSettings);
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);
}
{
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());
myLayerIds.Add (Graphic3d_ZLayerId_Topmost);
myLayerSeq.Append (Graphic3d_ZLayerId_Topmost);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Topmost, aSettings);
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);
}
{
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());
myLayerIds.Add (Graphic3d_ZLayerId_TopOSD);
myLayerSeq.Append (Graphic3d_ZLayerId_TopOSD);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_TopOSD, aSettings);
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);
}
}
@@ -125,52 +142,130 @@ void Graphic3d_GraphicDriver::RemoveIdentification(const Standard_Integer theId)
//=======================================================================
const Graphic3d_ZLayerSettings& Graphic3d_GraphicDriver::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
{
Standard_ASSERT_RAISE (myLayerIds.Contains (theLayerId), "Graphic3d_GraphicDriver::ZLayerSettings, Layer with theLayerId does not exist");
return myMapOfZLayerSettings.Find (theLayerId);
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();
}
//=======================================================================
//function : addZLayerIndex
//function : ZLayers
//purpose :
//=======================================================================
void Graphic3d_GraphicDriver::addZLayerIndex (const Graphic3d_ZLayerId theLayerId)
void Graphic3d_GraphicDriver::ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
{
// remove index
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
theLayerSeq.Clear();
// append normal layers
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
{
if (aLayerIt.Value() == theLayerId)
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
if (!aLayer->IsImmediate())
{
myLayerSeq.Remove (aLayerIt);
break;
theLayerSeq.Append (aLayer->LayerId());
}
}
if (myMapOfZLayerSettings.Find (theLayerId).IsImmediate())
// append immediate layers
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
{
myLayerSeq.Append (theLayerId);
return;
}
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
{
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerIt.Value());
if (aSettings.IsImmediate())
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
if (aLayer->IsImmediate())
{
aLayerIt.Previous();
if (aLayerIt.More())
theLayerSeq.Append (aLayer->LayerId());
}
}
}
//=======================================================================
//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 (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
{
if (aLayerIter.Value() == anOtherLayer)
{
myLayerSeq.InsertAfter (aLayerIt, theLayerId);
return;
myLayers.InsertBefore (aNewLayer, aLayerIter);
break;
}
// first non-immediate layer
myLayerSeq.Prepend (theLayerId);
return;
}
}
else
{
myLayers.Prepend (aNewLayer);
}
myLayerIds.Bind (theNewLayerId, aNewLayer);
}
// no immediate layers
myLayerSeq.Append (theLayerId);
//=======================================================================
//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);
}
//=======================================================================
@@ -180,20 +275,9 @@ void Graphic3d_GraphicDriver::addZLayerIndex (const Graphic3d_ZLayerId theLayerI
void Graphic3d_GraphicDriver::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& 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);
}
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);
}

View File

@@ -52,6 +52,7 @@
class Aspect_DisplayConnection;
class Graphic3d_CView;
class Graphic3d_GraphicDriver;
class Graphic3d_Layer;
class Graphic3d_TransformError;
class Graphic3d_Structure;
class Graphic3d_StructureManager;
@@ -65,7 +66,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.
@@ -110,24 +111,31 @@ public:
Standard_ShortReal& theAscent,
Standard_ShortReal& theDescent) const = 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;
//! 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;
//! 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).
virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
//! Returns list of Z layers defined for the graphical driver.
virtual void ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
{
theLayerSeq.Assign (myLayerSeq);
}
Standard_EXPORT virtual void ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const;
//! Sets the settings for a single Z layer.
Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) = 0;
@@ -148,23 +156,17 @@ 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;
TColStd_MapOfInteger myLayerIds;
TColStd_SequenceOfInteger myLayerSeq;
Graphic3d_MapOfZLayerSettings myMapOfZLayerSettings;
NCollection_List<Handle(Graphic3d_Layer)> myLayers;
NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
};

View File

@@ -22,11 +22,13 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Layer, Standard_Transient)
// function : Graphic3d_Layer
// purpose :
// =======================================================================
Graphic3d_Layer::Graphic3d_Layer (Standard_Integer theNbPriorities,
Graphic3d_Layer::Graphic3d_Layer (Graphic3d_ZLayerId theId,
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,6 +17,7 @@
#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>
@@ -38,12 +39,16 @@ class Graphic3d_Layer : public Standard_Transient
public:
//! Initializes associated priority list and layer properties
Standard_EXPORT Graphic3d_Layer (Standard_Integer theNbPriorities,
Standard_EXPORT Graphic3d_Layer (Graphic3d_ZLayerId theId,
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(); }
@@ -158,6 +163,9 @@ 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,6 +462,15 @@ 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,6 +38,7 @@ struct Graphic3d_ZLayerSettings
: myCullingDistance (Precision::Infinite()),
myCullingSize (Precision::Infinite()),
myIsImmediate (Standard_False),
myToRaytrace (Standard_True),
myUseEnvironmentTexture (Standard_True),
myToEnableDepthTest (Standard_True),
myToEnableDepthWrite(Standard_True),
@@ -105,6 +106,13 @@ 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; }
@@ -210,6 +218,7 @@ 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

@@ -33,7 +33,8 @@ struct IMeshTools_Parameters {
Relative (Standard_False),
InternalVerticesMode (Standard_True),
ControlSurfaceDeflection (Standard_True),
CleanModel(Standard_True)
CleanModel (Standard_True),
AdjustMinSize (Standard_False)
{
}
@@ -78,6 +79,10 @@ struct IMeshTools_Parameters {
//! Cleans temporary data model when algorithm is finished.
Standard_Boolean CleanModel;
//! Enables/disables local adjustment of min size depending on edge size.
//! Disabled by default.
Standard_Boolean AdjustMinSize;
};
#endif

View File

@@ -132,6 +132,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
:
Tol(aTol),
done(Standard_False),
myReady(Standard_False),
nbpnt(0),
PtrOnPolyhedron(NULL),
PtrOnBndBounding(NULL),
@@ -175,7 +176,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
if (nbsu > aMaxSamples) nbsu = aMaxSamples;
if (nbsv > aMaxSamples) nbsv = aMaxSamples;
if (dU > gp::Resolution() && dV > gp::Resolution()) {
if (dU > Precision::Confusion() && dV > Precision::Confusion()) {
if (Max(dU, dV) > Min(dU, dV) * aTresh)
{
aMinSamples = 10;
@@ -190,12 +191,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
}
}
else {
if (dU < gp::Resolution()) {
nbsu = 1;
}
if (dV < gp::Resolution()) {
nbsv = 1;
}
return; // surface has no extension along one of directions
}
Standard_Integer NbUOnS = Hsurface->NbUIntervals(GeomAbs_C2);
@@ -215,6 +211,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
}
}
myReady = Standard_True;
}
//=======================================================================
//function : InternalCall
@@ -350,6 +347,11 @@ 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();
@@ -428,6 +430,11 @@ 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,6 +160,7 @@ private:
IntCurveSurface_SequenceOfPnt SeqPnt;
TColStd_SequenceOfInteger mySeqState;
Standard_Boolean done;
Standard_Boolean myReady;
Standard_Integer nbpnt;
TopoDS_Face face;
Standard_Address PtrOnPolyhedron;

View File

@@ -304,7 +304,7 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
{
Standard_Boolean bIsClosed2;
Standard_Real aT11, aT12, aT21, aT22;
Bnd_Box aB2;
Bnd_Box aB1, aB2;
//
bSplit2 = Standard_False;
myRange1.Range(aT11, aT12);
@@ -313,7 +313,6 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
bIsClosed2 = IsClosed(myGeom2, aT21, aT22, myTol2, myRes2);
//
if (bIsClosed2) {
Bnd_Box aB1;
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
//
gp_Pnt aP = myGeom2->Value(aT21);
@@ -321,8 +320,9 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
}
//
if (!bIsClosed2) {
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
BndBuildBox(myCurve2, aT21, aT22, myTol2, aB2);
FindSolutions(myRange1, myRange2, aB2, theRanges1, theRanges2);
FindSolutions(myRange1, aB1, myRange2, aB2, theRanges1, theRanges2);
return;
}
//
@@ -343,10 +343,11 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
//
for (i = 1; i <= aNb1; ++i) {
const IntTools_Range& aR1 = aSegments1(i);
BndBuildBox(myCurve1, aR1.First(), aR1.Last(), myTol1, aB1);
for (j = 1; j <= aNb2; ++j) {
const IntTools_Range& aR2 = aSegments2(j);
BndBuildBox(myCurve2, aR2.First(), aR2.Last(), myTol2, aB2);
FindSolutions(aR1, aR2, aB2, theRanges1, theRanges2);
FindSolutions(aR1, aB1, aR2, aB2, theRanges1, theRanges2);
}
}
//
@@ -358,6 +359,7 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
//purpose :
//=======================================================================
void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
const Bnd_Box& theBox1,
const IntTools_Range& theR2,
const Bnd_Box& theBox2,
IntTools_SequenceOfRanges& theRanges1,
@@ -373,6 +375,7 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
theR1.Range(aT11, aT12);
theR2.Range(aT21, aT22);
//
aB1 = theBox1;
aB2 = theBox2;
//
bThin = Standard_False;
@@ -385,9 +388,7 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
aTB21 = aT21;
aTB22 = aT22;
//
//1. Build box for first edge and find parameters
// of the second one in that box
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
//1. Find parameters of the second edge in the box of first one
bOut = aB1.IsOut(aB2);
if (bOut) {
break;
@@ -435,7 +436,9 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
((aT21 - aTB21) < aSmallStep2) && ((aTB22 - aT22) < aSmallStep2)) {
bStop = Standard_True;
}
//
else
BndBuildBox (myCurve1, aT11, aT12, myTol1, aB1);
} while (!bStop);
//
if (bOut) {
@@ -498,13 +501,20 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
Standard_Integer i, aNb1;
IntTools_SequenceOfRanges aSegments1;
//
// Build box for first curve to compare
// the boxes of the splits with this one
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
const Standard_Real aB1SqExtent = aB1.SquareExtent();
//
IntTools_Range aR2(aT21, aT22);
BndBuildBox(myCurve2, aT21, aT22, myTol2, aB2);
//
aNb1 = SplitRangeOnSegments(aT11, aT12, myRes1, 3, aSegments1);
for (i = 1; i <= aNb1; ++i) {
const IntTools_Range& aR1 = aSegments1(i);
FindSolutions(aR1, aR2, aB2, theRanges1, theRanges2);
BndBuildBox(myCurve1, aR1.First(), aR1.Last(), myTol1, aB1);
if (!aB1.IsOut(aB2) && (aNb1 == 1 || aB1.SquareExtent() < aB1SqExtent))
FindSolutions(aR1, aB1, aR2, aB2, theRanges1, theRanges2);
}
}

View File

@@ -146,7 +146,8 @@ protected:
//! Looking for the exact intersection ranges
Standard_EXPORT void FindSolutions (const IntTools_Range& theR1,
Standard_EXPORT void FindSolutions (
const IntTools_Range& theR1, const Bnd_Box& theBox1,
const IntTools_Range& theR2, const Bnd_Box& theBox2,
IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2);

View File

@@ -88,7 +88,7 @@ options:\n\
-surf_def_off disables control of deflection of mesh from real\n\
surface (enabled by default)\n\
-parallel enables parallel execution (switched off by default)\n\
-adaptive enables adaptive computation of minimal value in parametric space\n";
-adjust_min enables local adjustment of min size depending on edge size (switched off by default)\n";
return 0;
}
@@ -121,6 +121,8 @@ options:\n\
aMeshParams.InternalVerticesMode = Standard_False;
else if (aOpt == "-surf_def_off")
aMeshParams.ControlSurfaceDeflection = Standard_False;
else if (aOpt == "-adjust_min")
aMeshParams.AdjustMinSize = Standard_True;
else if (i < nbarg)
{
Standard_Real aVal = Draw::Atof(argv[i++]);

View File

@@ -34,14 +34,12 @@ 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,6 +51,9 @@ 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)
@@ -76,6 +79,9 @@ 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,6 +107,23 @@ 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,6 +123,7 @@ 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),
@@ -749,6 +750,10 @@ 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
@@ -1217,6 +1222,44 @@ 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))
{
@@ -1436,6 +1479,9 @@ 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
@@ -1474,6 +1520,12 @@ 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;
@@ -2989,9 +3041,16 @@ 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));
@@ -3496,8 +3555,23 @@ void OpenGl_Context::SetTypeOfLine (const Aspect_TypeOfLine theType,
if (!myActiveProgram.IsNull())
{
myActiveProgram->SetUniform (this, "uPattern", aPattern);
myActiveProgram->SetUniform (this, "uFactor", theFactor);
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);
}
return;
}

View File

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

View File

@@ -108,10 +108,21 @@ public:
public:
//! 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;
//! 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;
//! 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,13 +16,14 @@
#ifndef _OpenGl_LayerFilter_H__
#define _OpenGl_LayerFilter_H__
//! Tool object to specify processed OpenGL layers.
//! Tool object to specify processed OpenGL layers
//! for intermixed rendering of raytracable and non-raytracable layers.
enum OpenGl_LayerFilter
{
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
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)
};
#endif //_OpenGl_LayerFilter_H__

View File

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

View File

@@ -29,9 +29,6 @@ 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
{
@@ -53,7 +50,14 @@ public:
Standard_Integer NbImmediateStructures() const { return myImmediateNbStructures; }
//! Insert a new layer with id.
void AddLayer (const Graphic3d_ZLayerId theLayerId);
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);
//! Remove layer by its id.
void RemoveLayer (const Graphic3d_ZLayerId theLayerId);
@@ -82,10 +86,10 @@ public:
const Standard_Integer theNewPriority);
//! Returns reference to the layer with given ID.
OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId);
OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) { return *myLayerIds.Find (theLayerId); }
//! Returns reference to the layer with given ID.
const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const;
const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const { return *myLayerIds.Find (theLayerId); }
//! Assign new settings to the layer.
void SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
@@ -103,10 +107,10 @@ public:
OpenGl_FrameBuffer* theOitAccumFbo) const;
//! Returns the set of OpenGL Z-layers.
const OpenGl_SequenceOfLayers& Layers() const { return myLayers; }
const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const { return myLayers; }
//! Returns the map of Z-layer IDs to indexes.
const OpenGl_LayerSeqIds& LayerIDs() const { return myLayerIds; }
const NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)>& LayerIDs() const { return myLayerIds; }
//! Marks BVH tree for given priority list as dirty and
//! marks primitive set for rebuild.
@@ -134,13 +138,14 @@ protected:
{
if (theSize > 0)
{
myStackSpace = new NCollection_Array1<const Graphic3d_Layer*> (1, theSize);
myStackSpace->Init (NULL);
myBackPtr = myStackSpace->begin();
myStackSpace.Resize (1, theSize, false);
myStackSpace.Init (NULL);
myBackPtr = myStackSpace.begin();
}
else
{
myStackSpace.Nullify();
NCollection_Array1<const Graphic3d_Layer*> aDummy;
myStackSpace.Move (aDummy);
myBackPtr = iterator();
}
}
@@ -148,18 +153,15 @@ protected:
//! Clear stack.
void Clear()
{
if (!myStackSpace.IsNull())
{
myStackSpace->Init (NULL);
myBackPtr = myStackSpace->begin();
}
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.IsNull() ? iterator() : myStackSpace->begin(); }
iterator Origin() const { return myStackSpace.IsEmpty() ? iterator() : myStackSpace.begin(); }
//! Returns iterator to the back of the stack (after last item added).
iterator Back() const { return myBackPtr; }
@@ -169,8 +171,8 @@ protected:
private:
NCollection_Handle<NCollection_Array1<const OpenGl_Layer*> > myStackSpace;
iterator myBackPtr;
NCollection_Array1<const OpenGl_Layer*> myStackSpace;
iterator myBackPtr;
};
//! Render transparent objects using blending operator.
@@ -195,11 +197,9 @@ protected:
protected:
// number of structures temporary put to default layer
OpenGl_SequenceOfLayers myLayers;
OpenGl_LayerSeqIds myLayerIds;
NCollection_List<Handle(Graphic3d_Layer)> myLayers;
NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> 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,6 +1505,8 @@ 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)
{
@@ -1518,19 +1520,15 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
{
theProgram->SetHeader ("#version 130");
}
else if (myContext->CheckExtension ("GL_EXT_gpu_shader4"))
else if (myContext->CheckExtension ("GL_EXT_gpu_shader4")) // myContext->hasGlslBitwiseOps == OpenGl_FeatureInExtensions
{
// 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 )theUsesDerivates;
(void )toUseDerivates;
#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
@@ -1557,10 +1555,13 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
else
{
aBits = aBits & ~OpenGl_PO_WriteOit;
aBits = aBits & ~OpenGl_PO_StippleLine;
if (!myContext->oesStdDerivatives)
{
aBits = aBits & ~OpenGl_PO_StippleLine;
}
}
}
if (theUsesDerivates)
if (toUseDerivates)
{
if (myContext->IsGlGreaterEqual (3, 0))
{
@@ -1819,28 +1820,34 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
const Standard_Integer aBits = defaultGlslVersion (aProgramSrc, "unlit", theBits);
if ((aBits & OpenGl_PO_StippleLine) != 0)
{
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uPattern", Graphic3d_TOS_FRAGMENT));
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor", Graphic3d_TOS_FRAGMENT));
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 ("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 =
EOL" vec2 anAxis = vec2 (0.0);"
aSrcFragMainGetColor = TCollection_AsciiString()
+ EOL" vec2 anAxis = vec2 (0.0, 1.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);"
EOL" uint aBit = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
EOL" if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
EOL" vec4 aColor = getFinalColor();"
+ (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" if (aColor.a <= 0.1) discard;"
EOL" occSetFragColor (aColor);";
}

View File

@@ -81,6 +81,8 @@ 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,6 +79,8 @@ 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,13 +31,7 @@
namespace
{
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 OpenGl_Mat4d THE_IDENTITY_MATRIX;
static const TCollection_AsciiString THE_DEFAULT_FONT (Font_NOF_ASCII_MONO);
@@ -80,10 +74,7 @@ namespace
// purpose :
// =======================================================================
OpenGl_Text::OpenGl_Text()
: myWinX (0.0f),
myWinY (0.0f),
myWinZ (0.0f),
myScaleHeight (1.0f),
: myScaleHeight (1.0f),
myPoint (0.0f, 0.0f, 0.0f),
myIs2d (false),
myHasPlane (false),
@@ -101,10 +92,7 @@ OpenGl_Text::OpenGl_Text()
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
const OpenGl_Vec3& thePoint,
const OpenGl_TextParam& theParams)
: myWinX (0.0f),
myWinY (0.0f),
myWinZ (0.0f),
myScaleHeight (1.0f),
: myScaleHeight (1.0f),
myExportHeight (1.0f),
myParams (theParams),
myString (theText),
@@ -124,10 +112,7 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
const gp_Ax2& theOrientation,
const OpenGl_TextParam& theParams,
const bool theHasOwnAnchor)
: myWinX (0.0),
myWinY (0.0),
myWinZ (0.0),
myScaleHeight (1.0),
: myScaleHeight (1.0),
myExportHeight (1.0),
myParams (theParams),
myString (theText),
@@ -362,7 +347,15 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
// Bind custom shader program or generate default version
aCtx->ShaderManager()->BindFontProgram (aTextAspect->ShaderProgramRes (aCtx));
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
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;
}
myProjMatrix.Convert (aCtx->ProjectionState.Current());
// use highlight color or colors from aspect
@@ -417,8 +410,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec3& theDVec) const
{
OpenGl_Mat4d aModViewMat;
OpenGl_Mat4d aProjectMat;
OpenGl_Mat4d aModViewMat, aProjectMat;
if (myHasPlane && myHasAnchorPoint)
{
aProjectMat = myProjMatrix * myOrientationMatrix;
@@ -436,18 +428,20 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
}
else
{
// 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);
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());
if (myHasPlane)
{
@@ -468,12 +462,12 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
}
else
{
aModViewMat.SetColumn (3, OpenGl_Vec3d (anObjX, anObjY, anObjZ));
aModViewMat.SetColumn (3, anObjXYZ);
}
}
else
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.0, 0.0, 1.0);
}
@@ -737,7 +731,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(),
myWinX, myWinY, myWinZ);
myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z());
// compute scale factor for constant text height
if (theTextAspect.Aspect()->IsTextZoomable())
@@ -747,11 +741,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
else
{
Graphic3d_Vec3d aPnt1, aPnt2;
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX, myWinY, myWinZ,
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX), myProjMatrix, theCtx->Viewport(),
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z(),
THE_IDENTITY_MATRIX, myProjMatrix, theCtx->Viewport(),
aPnt1.x(), aPnt1.y(), aPnt1.z());
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX, myWinY + aPointSize, myWinZ,
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX), myProjMatrix, theCtx->Viewport(),
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y() + aPointSize, myWinXYZ.z(),
THE_IDENTITY_MATRIX, myProjMatrix, theCtx->Viewport(),
aPnt2.x(), aPnt2.y(), aPnt2.z());
myScaleHeight = (aPnt2.y() - aPnt1.y()) / aPointSize;
}

View File

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

View File

@@ -488,12 +488,25 @@ void OpenGl_View::SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle)
}
//=======================================================================
//function : AddZLayer
//function : InsertLayerBefore
//purpose :
//=======================================================================
void OpenGl_View::AddZLayer (const Graphic3d_ZLayerId theLayerId)
void OpenGl_View::InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings,
const Graphic3d_ZLayerId theLayerAfter)
{
myZLayers.AddLayer (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);
}
//=======================================================================
@@ -522,83 +535,74 @@ void OpenGl_View::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
Standard_Integer OpenGl_View::ZLayerMax() const
{
Standard_Integer aLayerMax = Graphic3d_ZLayerId_Default;
for (OpenGl_LayerSeqIds::Iterator aMapIt(myZLayers.LayerIDs()); aMapIt.More(); aMapIt.Next())
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myZLayers.Layers()); aLayerIter.More(); aLayerIter.Next())
{
aLayerMax = Max (aLayerMax, aMapIt.Value());
aLayerMax = Max (aLayerMax, aLayerIter.Value()->LayerId());
}
return aLayerMax;
}
//=======================================================================
//function : InvalidateZLayerBoundingBox
//function : Layers
//purpose :
//=======================================================================
void OpenGl_View::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const
const NCollection_List<Handle(Graphic3d_Layer)>& OpenGl_View::Layers() const
{
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();
}
}
}
}
return myZLayers.Layers();
}
//=======================================================================
//function : ZLayerBoundingBox
//function : Layer
//purpose :
//=======================================================================
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) OpenGl_View::Layer (const Graphic3d_ZLayerId theLayerId) const
{
Bnd_Box aBox;
if (myZLayers.LayerIDs().IsBound (theLayerId))
Handle(Graphic3d_Layer) aLayer;
if (theLayerId != Graphic3d_ZLayerId_UNKNOWN)
{
aBox = myZLayers.Layer (theLayerId).BoundingBox (Identification(),
theCamera,
theWindowWidth,
theWindowHeight,
theToIncludeAuxiliary);
myZLayers.LayerIDs().Find (theLayerId, aLayer);
}
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 = theCamera->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = theCamera->OrientationMatrix();
const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix();
Graphic3d_BndBox3d aBox2d (Graphic3d_Vec3d (0.0, 0.0, 0.0),
Graphic3d_Vec3d (double(theWindowWidth), double(theWindowHeight), 0.0));
Graphic3d_Vec3d (double(aWinSize.x()), double(aWinSize.y()), 0.0));
Graphic3d_TransformPers aTrsfPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER);
aTrsfPers.Apply (theCamera,
aTrsfPers.Apply (aCamera,
aProjectionMat,
aWorldViewMat,
theWindowWidth,
theWindowHeight,
aWinSize.x(),
aWinSize.y(),
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()));
@@ -607,26 +611,6 @@ Bnd_Box OpenGl_View::ZLayerBoundingBox (const Graphic3d_ZLayerId theLayer
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,8 +136,21 @@ 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;
//! Insert a new top-level z layer with the given ID.
Standard_EXPORT virtual void AddZLayer (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;
//! Remove a z layer with the given ID.
Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
@@ -150,23 +163,18 @@ public:
//! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
Standard_EXPORT virtual Standard_Integer ZLayerMax() 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 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.
//! 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)
//! 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.
//! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
//! @return computed bounding box
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;
Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
//! Returns pointer to an assigned framebuffer object.
Standard_EXPORT virtual Handle(Standard_Transient) FBO() const Standard_OVERRIDE;
@@ -409,12 +417,6 @@ 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,12 +107,17 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
// of changes in OpenGL scene (only for path tracing)
std::set<Standard_Integer> aNonRaytraceIDs;
const OpenGl_Layer& aLayer = myZLayers.Layer (Graphic3d_ZLayerId_Default);
if (aLayer.NbStructures() != 0)
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myZLayers.Layers()); aLayerIter.More(); aLayerIter.Next())
{
const Graphic3d_ArrayOfIndexedMapOfStructure& aStructArray = aLayer.ArrayOfStructures();
const Handle(OpenGl_Layer)& aLayer = aLayerIter.Value();
if (aLayer->NbStructures() == 0
|| !aLayer->LayerSettings().IsRaytracable()
|| aLayer->LayerSettings().IsImmediate())
{
continue;
}
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_Default, theReadDrawFbo, theOitAccumFbo);
myZLayers.Render (myWorkspace, theToDrawImmediate, OpenGl_LF_RayTracable, theReadDrawFbo, theOitAccumFbo);
}
myWorkspace->SetRenderFilter (aPrevFilter);
}

View File

@@ -204,6 +204,10 @@ void OpenGl_Workspace::ResetAppliedAspect()
ApplyAspects();
myGlContext->SetTypeOfLine (myDefaultAspects.Aspect()->LineType());
myGlContext->SetLineWidth (myDefaultAspects.Aspect()->LineWidth());
if (myGlContext->core15fwd != NULL)
{
myGlContext->core15fwd->glActiveTexture (GL_TEXTURE0);
}
}
// =======================================================================

View File

@@ -14,13 +14,6 @@
// 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>
@@ -774,7 +767,7 @@ void Plate_Plate::SolveTI3(const Standard_Integer IterationNumber, const Handle(
}
algo_gauss.Solve(sec_member, sol);
//alr iteration pour affiner la solution
// iteration to refine the solution
{
math_Vector sol1(0,n_dimat-1);
math_Vector sec_member1(0,n_dimat-1);
@@ -785,7 +778,6 @@ 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));
@@ -1055,7 +1047,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
//=======================================================================
@@ -1068,15 +1060,14 @@ 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);
// il faut remettre cette ligne si on enleve ls facteurs dans
// la methode Polm.
// it is necessary to reset this line if one remove factors in method 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
@@ -1086,7 +1077,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 fondamental solution
//purpose : compute the (iu,iv)th derivative of the fundamental solution
// of Laplcian at the power order
//=======================================================================
@@ -1099,7 +1090,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
if(iv>iu)
{
// SolEm is symetric in (u<->v) : we swap u and v if iv>iu
// SolEm is symmetric in (u<->v) : we swap u and v if iv>iu
// to avoid some code
IU = iv;
IV = iu;
@@ -1135,8 +1126,8 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
//Standard_Real pr = pow(R, mm1 - IU - IV);
// cette expression prend beaucoup de temps
//(ne tient pas compte de la petite valeur entiere de l'exposant)
// this expression takes a lot of time
//(does not take into account a small integer value of the exponent)
//
Standard_Integer expo = mm1 - IU - IV;
@@ -1266,7 +1257,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real u2v2 = v2*U2;
Standard_Real r2 = r*r;
// copier-coller de mathematica
// copy-paste the mathematics
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 +
@@ -1291,7 +1282,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real u2v2 = v2*U2;
Standard_Real r2 = r*r;
// copier-coller de mathematica
// copy-paste the mathematics
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 +
@@ -1335,7 +1326,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real ru2 = R*U2;
Standard_Real r2 = R*R;
// copier-coller de mathematica
// copy-paste the mathematics
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 +
@@ -1364,7 +1355,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real ru4 = r*u4;
Standard_Real r2v2 = r2*v2;
// copier-coller de mathematica
// copy-paste the mathematics
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 -
@@ -1398,7 +1389,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2v2 = r2*v2;
Standard_Real ru4 = r*u4;
// copier-coller de mathematica
// copy-paste the mathematics
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 -
@@ -1434,7 +1425,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2 = R*R;
Standard_Real ru2 = R*U2;
// copier-coller de mathematica
// copy-paste the mathematics
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 +
@@ -1457,7 +1448,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2 = r*r;
// copier-coller de mathematica
// copy-paste the mathematics
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 -
@@ -1488,7 +1479,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2v2 = r2*v2;
Standard_Real ru4 = r*u4;
// copier-coller de mathematica
// copy-paste the mathematics
DUV =
-70560*ru2v2 + 28800*L*ru2v2 + 129920*m*ru2v2 - 70560*L*m*ru2v2 - 88200*m2*ru2v2 +
@@ -1529,7 +1520,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2u2 = r2*U2;
Standard_Real ru4 = r*u4;
// copier-coller de mathematica
// copy-paste the mathematics
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

@@ -76,13 +76,13 @@ void Poly_Connect::Load (const Handle(Poly_Triangulation)& theTriangulation)
mysense = false;
mymore = false;
const Standard_Integer nbNodes = myTriangulation->NbNodes();
const Standard_Integer nbTriangles = myTriangulation->NbTriangles();
const Standard_Integer aNbNodes = myTriangulation->NbNodes();
const Standard_Integer aNbTris = myTriangulation->NbTriangles();
{
const Standard_Integer aNbAdjs = 6 * nbTriangles;
if (myTriangles.Size() != nbNodes)
const Standard_Integer aNbAdjs = 6 * aNbTris;
if (myTriangles.Size() != aNbNodes)
{
myTriangles.Resize (1, nbNodes, Standard_False);
myTriangles.Resize (1, aNbNodes, Standard_False);
}
if (myAdjacents.Size() != aNbAdjs)
{
@@ -95,118 +95,117 @@ void Poly_Connect::Load (const Handle(Poly_Triangulation)& theTriangulation)
// We first build an array of the list of edges connected to the nodes
// create an array to store the edges starting from the vertices
Standard_Integer i;
// the last node is not used because edges are stored at the lower node index
polyedge** edges = new polyedge*[nbNodes];
for (i = 0; i < nbNodes; i++) edges[i] = 0;
NCollection_Array1<polyedge*> anEdges (1, aNbNodes);
anEdges.Init (NULL);
// loop on the triangles
Standard_Integer j,k,n[3],n1,n2;
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
for (i = 1; i <= nbTriangles; i++) {
NCollection_Vec3<Standard_Integer> aTriNodes;
NCollection_Vec2<Standard_Integer> anEdgeNodes;
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTris; ++aTriIter)
{
// get the nodes
triangles(i).Get(n[0],n[1],n[2]);
myTriangulation->Triangle (aTriIter).Get (aTriNodes[0], aTriNodes[1], aTriNodes[2]);
// Update the myTriangles array
myTriangles(n[0]) = i;
myTriangles(n[1]) = i;
myTriangles(n[2]) = i;
myTriangles.SetValue (aTriNodes[0], aTriIter);
myTriangles.SetValue (aTriNodes[1], aTriIter);
myTriangles.SetValue (aTriNodes[2], aTriIter);
// update the edge lists
for (j = 0; j < 3; j++) {
k = (j+1) % 3; // the following node of the edge
if (n[j] <= n[k]) {
n1 = n[j];
n2 = n[k];
for (Standard_Integer aNodeInTri = 0; aNodeInTri < 3; ++aNodeInTri)
{
const Standard_Integer aNodeNext = (aNodeInTri + 1) % 3; // the following node of the edge
if (aTriNodes[aNodeInTri] < aTriNodes[aNodeNext])
{
anEdgeNodes[0] = aTriNodes[aNodeInTri];
anEdgeNodes[1] = aTriNodes[aNodeNext];
}
else {
n1 = n[k];
n2 = n[j];
else
{
anEdgeNodes[0] = aTriNodes[aNodeNext];
anEdgeNodes[1] = aTriNodes[aNodeInTri];
}
// edge from n1 to n2 with n1 < n2
// insert in the list of n1
polyedge* ced = edges[n1];
while (ced != 0) {
// the edge already exists
if (ced->nd == n2)
break;
else
ced = ced->next;
// edge from node 0 to node 1 with node 0 < node 1
// insert in the list of node 0
polyedge* ced = anEdges[anEdgeNodes[0]];
for (; ced != NULL; ced = ced->next)
{
// the edge already exists
if (ced->nd == anEdgeNodes[1])
{
// just mark the adjacency if found
ced->nt[1] = aTriIter;
ced->nn[1] = aTriNodes[3 - aNodeInTri - aNodeNext]; // the third node
break;
}
}
if (ced == 0) {
// create the edge if not found
ced = new polyedge;
ced->next = edges[n1];
edges[n1] = ced;
ced->nd = n2;
ced->nt[0] = i;
ced->nn[0] = n[3-j-k]; // the third node
ced->nt[1] = 0;
ced->nn[1] = 0;
}
else {
// just mark the adjacency if found
ced->nt[1] = i;
ced->nn[1] = n[3-j-k]; // the third node
if (ced == NULL)
{
// create the edge if not found
ced = new polyedge();
ced->next = anEdges[anEdgeNodes[0]];
anEdges[anEdgeNodes[0]] = ced;
ced->nd = anEdgeNodes[1];
ced->nt[0] = aTriIter;
ced->nn[0] = aTriNodes[3 - aNodeInTri - aNodeNext]; // the third node
ced->nt[1] = 0;
ced->nn[1] = 0;
}
}
}
// now complete the myAdjacents array
Standard_Integer index = 1;
for (i = 1; i <= nbTriangles; i++) {
Standard_Integer anAdjIndex = 1;
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTris; ++aTriIter)
{
// get the nodes
triangles(i).Get(n[0],n[1],n[2]);
myTriangulation->Triangle (aTriIter).Get (aTriNodes[0], aTriNodes[1], aTriNodes[2]);
// fore each edge
for (j = 0; j < 3; j++) {
k = (j+1) % 3; // the following node of the edge
if (n[j] <= n[k]) {
n1 = n[j];
n2 = n[k];
// for each edge in triangle
for (Standard_Integer aNodeInTri = 0; aNodeInTri < 3; ++aNodeInTri)
{
const Standard_Integer aNodeNext = (aNodeInTri + 1) % 3; // the following node of the edge
if (aTriNodes[aNodeInTri] < aTriNodes[aNodeNext])
{
anEdgeNodes[0] = aTriNodes[aNodeInTri];
anEdgeNodes[1] = aTriNodes[aNodeNext];
}
else {
n1 = n[k];
n2 = n[j];
else
{
anEdgeNodes[0] = aTriNodes[aNodeNext];
anEdgeNodes[1] = aTriNodes[aNodeInTri];
}
// edge from n1 to n2 with n1 < n2
// find in the list of n1
polyedge* ced = edges[n1];
while (ced->nd != n2)
ced = ced->next;
// edge from node 0 to node 1 with node 0 < node 1
// find in the list of node 0
const polyedge* ced = anEdges[anEdgeNodes[0]];
while (ced->nd != anEdgeNodes[1])
{
ced = ced->next;
}
// Find the adjacent triangle
Standard_Integer l = 0;
if (ced->nt[0] == i) l = 1;
myAdjacents(index) = ced->nt[l];
myAdjacents(index+3) = ced->nn[l];
index++;
const Standard_Integer l = ced->nt[0] == aTriIter ? 1 : 0;
myAdjacents.SetValue (anAdjIndex, ced->nt[l]);
myAdjacents.SetValue (anAdjIndex + 3, ced->nn[l]);
++anAdjIndex;
}
index += 3;
anAdjIndex += 3;
}
// destroy the edges array
for (i = 0; i < nbNodes; i++) {
polyedge* ced = edges[i];
while (ced != 0) {
polyedge* tmp = ced->next;
delete ced;
ced = tmp;
for (Standard_Integer aNodeIter = anEdges.Lower(); aNodeIter <= anEdges.Upper(); ++aNodeIter)
{
for (polyedge* anEdgeIter = anEdges[aNodeIter]; anEdgeIter != NULL;)
{
polyedge* aTmp = anEdgeIter->next;
delete anEdgeIter;
anEdgeIter = aTmp;
}
}
delete [] edges;
}
//=======================================================================

View File

@@ -43,15 +43,24 @@ public:
//! Returns the right-handed coordinate system set in SetComponent.
Standard_EXPORT Handle(Prs3d_ShadingAspect) ShadingAspect (Prs3d_DatumParts thePart) const;
//! Returns the right-handed coordinate system set in SetComponent.
//! Returns the text attributes for rendering labels.
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,7 +28,9 @@ Prs3d_ToolDisk::Prs3d_ToolDisk (const Standard_Real theInnerRadius,
const Standard_Integer theNbSlices,
const Standard_Integer theNbStacks)
: myInnerRadius (theInnerRadius),
myOuterRadius (theOuterRadius)
myOuterRadius (theOuterRadius),
myStartAngle (0.0),
myEndAngle (M_PI * 2.0)
{
mySlicesNb = theNbSlices;
myStacksNb = theNbStacks;
@@ -40,22 +42,13 @@ 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 = theU * M_PI * 2.0;
const Standard_Real aU = myStartAngle + theU * (myEndAngle - myStartAngle);
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,18 +37,31 @@ 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.
Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
virtual gp_Dir Normal (const Standard_Real , const Standard_Real ) Standard_OVERRIDE { return gp_Dir (0.0, 0.0, -1.0); }
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

@@ -56,7 +56,8 @@ PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentat
//
myInfiniteState (Standard_False),
myIsMutable (Standard_False),
myHasOwnPresentations (Standard_True)
myHasOwnPresentations (Standard_True),
myToPropagateVisualState (Standard_True)
{
myDrawer->SetDisplayMode (-1);
}

View File

@@ -528,6 +528,14 @@ public: //! @name deprecated methods
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
//! Get value of the flag "propagate visual state"
//! It means that the display/erase/color visual state is propagated automatically to all children;
//! by default, the flag is true
Standard_Boolean ToPropagateVisualState() const { return myToPropagateVisualState; }
//! Change the value of the flag "propagate visual state"
void SetPropagateVisualState(const Standard_Boolean theFlag) { myToPropagateVisualState = theFlag; }
protected:
//! Recomputes all presentations of the object.
@@ -569,6 +577,7 @@ protected:
Standard_Boolean myIsMutable; //!< mutable flag
Standard_Boolean myHasOwnPresentations; //!< flag indicating if object should have own presentations
Standard_Boolean myToPropagateVisualState; //!< flag indicating if visual state (display/erase/color) should be propagated to all children
};
DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, Standard_Transient)

View File

@@ -69,9 +69,12 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode);
}
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Display (anIter.Value(), theMode);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Display(anIter.Value(), theMode);
}
}
}
@@ -82,9 +85,12 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Erase (anIter.Value(), theMode);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Erase(anIter.Value(), theMode);
}
}
PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
@@ -124,9 +130,12 @@ void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)&
void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Clear (anIter.Value(), theMode);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Clear(anIter.Value(), theMode);
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
@@ -144,9 +153,12 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
const Standard_Integer theMode,
const Standard_Boolean theValue)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
SetVisibility (anIter.Value(), theMode, theValue);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetVisibility(anIter.Value(), theMode, theValue);
}
}
if (!thePrsObj->HasOwnPresentations())
{
@@ -166,9 +178,12 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
// =======================================================================
void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Unhighlight (anIter.Value());
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Unhighlight(anIter.Value());
}
}
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
@@ -192,9 +207,12 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
const Standard_Integer theMode,
const Standard_Integer theNewPrior) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
SetDisplayPriority (anIter.Value(), theMode, theNewPrior);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetDisplayPriority(anIter.Value(), theMode, theNewPrior);
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
@@ -211,12 +229,15 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Standard_Integer aPriority = DisplayPriority (anIter.Value(), theMode);
if (aPriority != 0)
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
return aPriority;
Standard_Integer aPriority = DisplayPriority(anIter.Value(), theMode);
if (aPriority != 0)
{
return aPriority;
}
}
}
@@ -233,11 +254,14 @@ Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMg
Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
if (IsDisplayed (anIter.Value(), theMode))
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
return Standard_True;
if (IsDisplayed(anIter.Value(), theMode))
{
return Standard_True;
}
}
}
@@ -253,11 +277,14 @@ Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_Pr
Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
if (IsHighlighted (anIter.Value(), theMode))
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
return Standard_True;
if (IsHighlighted(anIter.Value(), theMode))
{
return Standard_True;
}
}
}
@@ -523,10 +550,14 @@ Standard_Boolean PrsMgr_PresentationManager::RemovePresentation (const Handle(Pr
void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Graphic3d_ZLayerId theLayerId)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
SetZLayer (anIter.Value(), theLayerId);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetZLayer(anIter.Value(), theLayerId);
}
}
if (!thePrsObj->HasOwnPresentations())
{
return;
@@ -579,9 +610,12 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)&
const Handle(PrsMgr_PresentableObject)& theSelObj,
const Standard_Integer theImmediateStructLayerId)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Color (anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Color(anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
}
}
if (!thePrsObj->HasOwnPresentations())
{

View File

@@ -103,7 +103,9 @@ private:
// Purpose :
//================================================================
RWGltf_CafReader::RWGltf_CafReader()
: myToParallel (false)
: myToParallel (false),
myToSkipEmptyNodes (true),
myUseMeshNameAsFallback (true)
{
myCoordSysConverter.SetInputLengthUnit (1.0); // glTF defines model in meters
myCoordSysConverter.SetInputCoordinateSystem (RWMesh_CoordinateSystem_glTF);
@@ -215,8 +217,11 @@ Standard_Boolean RWGltf_CafReader::performMesh (const TCollection_AsciiString& t
aDoc.SetFilePath (theFile);
aDoc.SetProbeHeader (theToProbe);
aDoc.SetExternalFiles (myExternalFiles);
aDoc.SetMetadata (myMetadata);
aDoc.SetErrorPrefix (anErrPrefix);
aDoc.SetCoordinateSystemConverter (myCoordSysConverter);
aDoc.SetSkipEmptyNodes (myToSkipEmptyNodes);
aDoc.SetMeshNameAsFallback (myUseMeshNameAsFallback);
if (!theToProbe)
{
aDoc.SetAttributeMap (myAttribMap);

View File

@@ -36,6 +36,18 @@ public:
//! Setup multithreaded execution.
void SetParallel (bool theToParallel) { myToParallel = theToParallel; }
//! Return TRUE if Nodes without Geometry should be ignored, TRUE by default.
bool ToSkipEmptyNodes() { return myToSkipEmptyNodes; }
//! Set flag to ignore nodes without Geometry.
void SetSkipEmptyNodes (bool theToSkip) { myToSkipEmptyNodes = theToSkip; }
//! Set flag to use Mesh name in case if Node name is empty, TRUE by default.
bool ToUseMeshNameAsFallback() { return myUseMeshNameAsFallback; }
//! Set flag to use Mesh name in case if Node name is empty.
void SetMeshNameAsFallback (bool theToFallback) { myUseMeshNameAsFallback = theToFallback; }
protected:
//! Read the mesh from specified file.
@@ -58,7 +70,9 @@ protected:
protected:
Standard_Boolean myToParallel; //!< flag to use multithreading; FALSE by default
Standard_Boolean myToParallel; //!< flag to use multithreading; FALSE by default
Standard_Boolean myToSkipEmptyNodes; //!< ignore nodes without Geometry; TRUE by default
Standard_Boolean myUseMeshNameAsFallback; //!< flag to use Mesh name in case if Node name is empty, TRUE by default
};

View File

@@ -171,6 +171,7 @@ RWGltf_GltfJsonParser::RWGltf_GltfJsonParser (TopTools_SequenceOfShape& theRootS
myIsBinary (false),
myIsGltf1 (false),
myToSkipEmptyNodes (true),
myUseMeshNameAsFallback (true),
myToProbeHeader (false)
{
myCSTrsf.SetInputLengthUnit (1.0); // meters
@@ -250,18 +251,23 @@ void RWGltf_GltfJsonParser::gltfParseAsset()
}
}
if (myMetadata == NULL)
{
return;
}
if (const RWGltf_JsonValue* aGenerator = findObjectMember (*anAsset, "generator"))
{
if (aGenerator->IsString())
{
myMetadata.Add ("generator", aGenerator->GetString());
myMetadata->Add ("generator", aGenerator->GetString());
}
}
if (const RWGltf_JsonValue* aCopyRight = findObjectMember (*anAsset, "copyright"))
{
if (aCopyRight->IsString())
{
myMetadata.Add ("copyright", aCopyRight->GetString());
myMetadata->Add ("copyright", aCopyRight->GetString());
}
}
}
@@ -1582,6 +1588,43 @@ void RWGltf_GltfJsonParser::bindNamedShape (TopoDS_Shape& theShape,
{
aShapeAttribs.Style.SetColorSurf (aLateData->BaseColor());
}
if (aShapeAttribs.Name.IsEmpty()
&& myUseMeshNameAsFallback)
{
// fallback using Mesh name
aShapeAttribs.Name = aLateData->Name();
}
}
}
else if (aShapeAttribs.Name.IsEmpty()
&& myUseMeshNameAsFallback)
{
// fallback using Mesh name
TopLoc_Location aDummy;
TCollection_AsciiString aMeshName;
for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
{
if (Handle(RWGltf_GltfLatePrimitiveArray) aLateData = Handle(RWGltf_GltfLatePrimitiveArray)::DownCast (BRep_Tool::Triangulation (TopoDS::Face (aFaceIter.Value()), aDummy)))
{
if (aLateData->Name().IsEmpty())
{
aMeshName.Clear();
break;
}
else if (aMeshName.IsEmpty())
{
aMeshName = aLateData->Name();
}
else if (!aMeshName.IsEqual (aLateData->Name()))
{
aMeshName.Clear();
break;
}
}
}
if (!aMeshName.IsEmpty())
{
aShapeAttribs.Name = aMeshName;
}
}
myAttribMap->Bind (theShape, aShapeAttribs);

View File

@@ -87,6 +87,9 @@ public:
//! Set list for storing external files.
void SetExternalFiles (NCollection_IndexedMap<TCollection_AsciiString>& theExternalFiles) { myExternalFiles = &theExternalFiles; }
//! Set metadata map.
void SetMetadata (TColStd_IndexedDataMapOfStringString& theMetadata) { myMetadata = &theMetadata; }
//! Return transformation from glTF to OCCT coordinate system.
const RWMesh_CoordinateSystemConverter& CoordinateSystemConverter() const { return myCSTrsf; }
@@ -102,12 +105,15 @@ public:
myBinBodyLen = theBinBodyLen;
}
//! Set flag to ignore nodes without Geometry, TRUE by default.
void SetSkipEmptyNodes (bool theToSkip) { myToSkipEmptyNodes = theToSkip; }
//! Set flag to use Mesh name in case if Node name is empty, TRUE by default.
void SetMeshNameAsFallback (bool theToFallback) { myUseMeshNameAsFallback = theToFallback; }
//! Parse glTF document.
Standard_EXPORT bool Parse (const Handle(Message_ProgressIndicator)& theProgress);
//! Return metadata map.
const TColStd_IndexedDataMapOfStringString& Metadata() const { return myMetadata; }
//! Return face list for loading triangulation.
NCollection_Vector<TopoDS_Face>& FaceList() { return myFaceList; }
@@ -387,8 +393,8 @@ protected:
NCollection_IndexedMap<TCollection_AsciiString>*
myExternalFiles; //!< list of external file references
RWMesh_CoordinateSystemConverter myCSTrsf; //!< transformation from glTF to OCCT coordinate system
TColStd_IndexedDataMapOfStringString* myMetadata; //!< file metadata
TColStd_IndexedDataMapOfStringString myMetadata; //!< file metadata
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialMetallicRoughness)> myMaterialsPbr;
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialCommon)> myMaterialsCommon;
NCollection_DataMap<TCollection_AsciiString, TopoDS_Shape> myShapeMap[2];
@@ -405,6 +411,7 @@ protected:
bool myIsBinary; //!< binary document
bool myIsGltf1; //!< obsolete glTF 1.0 version format
bool myToSkipEmptyNodes; //!< ignore nodes without Geometry
bool myUseMeshNameAsFallback; //!< flag to use Mesh name in case if Node name is empty, TRUE by default
bool myToProbeHeader; //!< flag to probe header without full reading, FALSE by default
#ifdef HAVE_RAPIDJSON

View File

@@ -79,12 +79,15 @@ public:
//! Add primitive array data element.
Standard_EXPORT RWGltf_GltfPrimArrayData& AddPrimArrayData (RWGltf_GltfArrayType theType);
//! Return bounding box defined within glTF file, or VOID if not specified.
const Bnd_Box& BoundingBox() const { return myBox; }
//! This method sets input bounding box and assigns a FAKE data to underlying Poly_Triangulation
//! as Min/Max corners of bounding box, so that standard tools like BRepBndLib::Add()
//! can be used transparently for computing bounding box of this face.
Standard_EXPORT void SetBoundingBox (const Bnd_Box& theBox);
private:
protected:
NCollection_Sequence<RWGltf_GltfPrimArrayData> myData;
Handle(RWGltf_MaterialMetallicRoughness) myMaterialPbr; //!< PBR material

View File

@@ -37,15 +37,17 @@ void RWHeaderSection_RWFileDescription::ReadStep
Handle(Interface_HArray1OfHAsciiString) aDescription;
Handle(TCollection_HAsciiString) aDescriptionItem;
Standard_Integer nsub1;
nsub1 = data->SubListNumber(num, 1, Standard_False);
Standard_Integer nsub1 = data->SubListNumber(num, 1, Standard_False);
if (nsub1 !=0) {
Standard_Integer nb1 = data->NbParams(nsub1);
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);
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);
}
}
}
else {

View File

@@ -90,13 +90,10 @@ Standard_Boolean RWMesh_CafReader::perform (const TCollection_AsciiString& theFi
const Standard_Boolean theToProbe)
{
Standard_Integer aNewRootsLower = 1;
Handle(XCAFDoc_ShapeTool) aShapeTool = !myXdeDoc.IsNull()
? XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())
: Handle(XCAFDoc_ShapeTool)();
if (!myXdeDoc.IsNull())
{
TDF_LabelSequence aRootLabels;
aShapeTool->GetFreeShapes (aRootLabels);
XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())->GetFreeShapes (aRootLabels);
aNewRootsLower = aRootLabels.Upper() + 1;
}
@@ -118,28 +115,11 @@ Standard_Boolean RWMesh_CafReader::perform (const TCollection_AsciiString& theFi
myExtraStatus |= RWMesh_CafReaderStatusEx_Partial;
}
BRep_Builder aBuilder;
TopoDS_Shape aShape;
if (myRootShapes.Size() > 1)
{
TopoDS_Compound aCompound;
aBuilder.MakeCompound (aCompound);
for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
{
aBuilder.Add (aCompound, aRootIter.Value());
}
aShape = aCompound;
}
else if (!myRootShapes.IsEmpty())
{
aShape = myRootShapes.First();
}
TopLoc_Location aDummyLoc;
Standard_Integer aNbNodes = 0, aNbElems = 0, aNbFaces = 0;
if (!aShape.IsNull())
for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
{
TopLoc_Location aDummyLoc;
for (TopExp_Explorer aFaceIter (aShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
for (TopExp_Explorer aFaceIter (aRootIter.Value(), TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
if (const Handle(Poly_Triangulation)& aPolyTri = BRep_Tool::Triangulation (aFace, aDummyLoc))
@@ -155,42 +135,41 @@ Standard_Boolean RWMesh_CafReader::perform (const TCollection_AsciiString& theFi
return Standard_False;
}
if (myToFillDoc
&& !myXdeDoc.IsNull())
{
const Standard_Boolean wasAutoNaming = aShapeTool->AutoNaming();
aShapeTool->SetAutoNaming (Standard_False);
const TCollection_AsciiString aRootName; // = generateRootName (theFile);
for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
{
addShapeIntoDoc (aRootIter.Value(), TDF_Label(), aRootName);
}
aShapeTool->UpdateAssemblies();
aShapeTool->SetAutoNaming (wasAutoNaming);
}
if (!myXdeDoc.IsNull())
{
generateNames (theFile, aNewRootsLower, Standard_False);
}
fillDocument();
generateNames (theFile, aNewRootsLower, Standard_False);
aLoadingTimer.Stop();
TCollection_AsciiString aStats = TCollection_AsciiString("[") + aNbNodes + " nodes] [" + aNbElems + " 2d elements]";
if (!isDone)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
+ "\n" + aStats
+ "\n[PARTIALLY read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
}
else
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
+ "\n" + aStats
+ "\n[read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
}
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Mesh ") + theFile
+ "\n[" + aNbNodes + " nodes] [" + aNbElems + " 2d elements]"
+ "\n[" + (!isDone ? "PARTIALLY " : "") + "read in " + aLoadingTimer.ElapsedTime() + " s]", Message_Info);
return Standard_True;
}
// =======================================================================
// function : fillDocument
// purpose :
// =======================================================================
void RWMesh_CafReader::fillDocument()
{
if (!myToFillDoc
|| myXdeDoc.IsNull()
|| myRootShapes.IsEmpty())
{
return;
}
const Standard_Boolean wasAutoNaming = XCAFDoc_ShapeTool::AutoNaming();
XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
const TCollection_AsciiString aRootName; // = generateRootName (theFile);
for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
{
addShapeIntoDoc (aRootIter.Value(), TDF_Label(), aRootName);
}
XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())->UpdateAssemblies();
XCAFDoc_ShapeTool::SetAutoNaming (wasAutoNaming);
}
// =======================================================================
// function : addShapeIntoDoc
// purpose :
@@ -207,14 +186,11 @@ Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (const TopoDS_Shape& theShape
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main());
TopLoc_Location aDummyLoc;
const TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
TopoDS_Shape aShapeToAdd = theShape;
Standard_Boolean toMakeAssembly = Standard_False;
if (theShape.ShapeType() == TopAbs_COMPOUND)
{
TCollection_AsciiString aFirstName;
RWMesh_NodeAttributes aSubFaceAttribs;
for (TopoDS_Iterator aSubShapeIter (theShape, Standard_True, Standard_False); !toMakeAssembly && aSubShapeIter.More(); aSubShapeIter.Next())
{
@@ -366,9 +342,7 @@ void RWMesh_CafReader::generateNames (const TCollection_AsciiString& theFile,
if (theWithSubLabels)
{
for (XCAFPrs_DocumentExplorer aDocIter (myXdeDoc,
aNewRootLabels,
XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes | XCAFPrs_DocumentExplorerFlags_NoStyle);
for (XCAFPrs_DocumentExplorer aDocIter (myXdeDoc, aNewRootLabels, XCAFPrs_DocumentExplorerFlags_NoStyle);
aDocIter.More(); aDocIter.Next())
{
if (aDocIter.CurrentDepth() == 0

View File

@@ -173,18 +173,21 @@ protected:
//! @param theFile file to read
//! @param optional progress indicator
//! @param theToProbe flag indicating that mesh data should be skipped and only basing information to be read
virtual Standard_Boolean perform (const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress,
const Standard_Boolean theToProbe);
Standard_EXPORT virtual Standard_Boolean perform (const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress,
const Standard_Boolean theToProbe);
//! Read the mesh from specified file - interface to be implemented by sub-classes.
virtual Standard_Boolean performMesh (const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress,
const Standard_Boolean theToProbe) = 0;
Standard_EXPORT virtual Standard_Boolean performMesh (const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress,
const Standard_Boolean theToProbe) = 0;
//! @name tools for filling XDE document
protected:
//! Fill document with new root shapes.
Standard_EXPORT void fillDocument();
//! Append new shape into the document (recursively).
Standard_EXPORT Standard_Boolean addShapeIntoDoc (const TopoDS_Shape& theShape,
const TDF_Label& theLabel,

View File

@@ -63,7 +63,18 @@ namespace
theRelativePath = aRelPath;
return true;
}
aPath = aFolder;
for (; aPath.Length() >= 2;)
{
if (aPath.Value (aPath.Length()) == '/'
|| aPath.Value (aPath.Length()) == '\\')
{
aPath = aPath.SubString (1, aPath.Length() - 1);
continue;
}
break;
}
}
}
}
@@ -195,6 +206,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
if (validateColor (aColor))
{
aMat.SpecularColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB);
hasAspect = true;
}
}
else if (::memcmp (aPos, "Ns", 2) == 0
@@ -207,6 +219,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
if (aSpecular >= 0.0)
{
aMat.Shininess = (float )Min (aSpecular / 1000.0, 1.0);
hasAspect = true;
}
}
else if (::memcmp (aPos, "Tr", 2) == 0
@@ -220,6 +233,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
&& aTransp <= 0.99)
{
aMat.Transparency = (float )aTransp;
hasAspect = true;
}
}
else if (*aPos == 'd' && IsSpace (aPos[1]))
@@ -233,6 +247,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
&& anAlpha >= 0.01)
{
aMat.Transparency = float(1.0 - anAlpha);
hasAspect = true;
}
}
else if (::memcmp (aPos, "map_Kd", 6) == 0
@@ -242,6 +257,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
if (RWObj_Tools::ReadName (aPos, aMat.DiffuseTexture))
{
processTexturePath (aMat.DiffuseTexture, theFolder);
hasAspect = true;
}
}
else if (::memcmp (aPos, "map_Ks", 6) == 0
@@ -251,6 +267,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
if (RWObj_Tools::ReadName (aPos, aMat.SpecularTexture))
{
processTexturePath (aMat.SpecularTexture, theFolder);
hasAspect = true;
}
}
else if (::memcmp (aPos, "map_Bump", 8) == 0
@@ -260,6 +277,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
if (RWObj_Tools::ReadName (aPos, aMat.BumpTexture))
{
processTexturePath (aMat.BumpTexture, theFolder);
hasAspect = true;
}
}
/*else if (::memcmp (aPos, "illum", 5) == 0)

View File

@@ -32,7 +32,6 @@ Standard_Boolean RWObj_TriangulationReader::addMesh (const RWObj_SubMesh& theMes
return Standard_False;
}
const RWObj_Material* aMaterial = myMaterials.Seek (theMesh.Material);
if (Handle(Poly_Triangulation) aTris = GetTriangulation())
{
myNodes.Clear();
@@ -46,7 +45,11 @@ Standard_Boolean RWObj_TriangulationReader::addMesh (const RWObj_SubMesh& theMes
{
if (myShapeReceiver != NULL)
{
myShapeReceiver->BindNamedShape (myLastGroupShape, theMesh.Group, myLastGroupShape.ShapeType() == TopAbs_FACE ? aMaterial : NULL, Standard_False);
const RWObj_Material* aMaterial = myLastGroupShape.ShapeType() == TopAbs_FACE
&& !myLastFaceMaterial.IsEmpty()
? myMaterials.Seek (myLastFaceMaterial)
: NULL;
myShapeReceiver->BindNamedShape (myLastGroupShape, myLastGroupName, aMaterial, Standard_False);
}
}
myLastGroupShape = TopoDS_Shape();
@@ -57,8 +60,10 @@ Standard_Boolean RWObj_TriangulationReader::addMesh (const RWObj_SubMesh& theMes
BRep_Builder aBuilder;
aBuilder.MakeFace (aNewFace, aTris);
addSubShape (myLastGroupShape, aNewFace, Standard_True);
myLastFaceMaterial = theMesh.Material;
if (myShapeReceiver != NULL)
{
const RWObj_Material* aMaterial = myMaterials.Seek (theMesh.Material);
myShapeReceiver->BindNamedShape (aNewFace, "", aMaterial, Standard_False);
}
}
@@ -70,7 +75,11 @@ Standard_Boolean RWObj_TriangulationReader::addMesh (const RWObj_SubMesh& theMes
{
if (myShapeReceiver != NULL)
{
myShapeReceiver->BindNamedShape (myLastGroupShape, theMesh.Group, myLastGroupShape.ShapeType() == TopAbs_FACE ? aMaterial : NULL, Standard_False);
const RWObj_Material* aMaterial = myLastGroupShape.ShapeType() == TopAbs_FACE
&& !myLastFaceMaterial.IsEmpty()
? myMaterials.Seek (myLastFaceMaterial)
: NULL;
myShapeReceiver->BindNamedShape (myLastGroupShape, myLastGroupName, aMaterial, Standard_False);
}
}
myLastGroupShape = TopoDS_Shape();

View File

@@ -117,6 +117,7 @@ protected:
TopoDS_Compound myLastObjectShape; //!< Compound containing current object groups
TopoDS_Shape myLastGroupShape; //!< current group shape - either a single Face or Compound of Faces
TCollection_AsciiString myLastGroupName; //!< current group name
TCollection_AsciiString myLastFaceMaterial;//!< last face material name
Standard_Boolean myToCreateShapes; //!< create a single triangulation
};

View File

@@ -17,6 +17,7 @@
#ifndef _SelectMgr_EntityOwner_HeaderFile
#define _SelectMgr_EntityOwner_HeaderFile
#include <Aspect_VKey.hxx>
#include <PrsMgr_PresentationManager.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <TopLoc_Location.hxx>
@@ -60,6 +61,22 @@ 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

@@ -77,6 +77,7 @@ 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

@@ -0,0 +1,198 @@
// 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)
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
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) ^ isMirrored)
if ((aFace.Orientation() == TopAbs_REVERSED))
{
aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
}

View File

@@ -443,6 +443,15 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape
Handle(Select3D_SensitiveEntity)& theSensitive)
{
const TopoDS_Edge& anEdge = TopoDS::Edge (theShape);
// try to get points from existing polygons
Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge);
if (!aPoints.IsNull()
&& !aPoints->IsEmpty())
{
theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
return;
}
BRepAdaptor_Curve cu3d;
try {
OCC_CATCH_SIGNALS
@@ -451,14 +460,6 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape
return;
}
// try to get points from existing polygons
Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge);
if (!aPoints.IsNull() && aPoints->Length() > 0)
{
theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
return;
}
Standard_Real aParamFirst = cu3d.FirstParameter();
Standard_Real aParamLast = cu3d.LastParameter();
switch (cu3d.GetType())

View File

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

Some files were not shown because too many files have changed in this diff Show More