mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8bf036a056 | ||
|
a22151d83c | ||
|
990d032c90 | ||
|
b383a61fbd | ||
|
07f2064617 | ||
|
fb64d0f4a2 | ||
|
115d350e09 | ||
|
3dd193aa6d | ||
|
87018b452a | ||
|
61f73653ba | ||
|
8ed0708507 | ||
|
077a220c51 | ||
|
c5cee3222f | ||
|
e837b3a26c | ||
|
846245d4b2 | ||
|
d7fa57a7a3 |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.6 KiB |
@@ -1716,6 +1716,41 @@ aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array
|
||||
aGroup->AddPrimitiveArray (aLines);
|
||||
~~~~
|
||||
|
||||
@subsection upgrade_740_text Changes in Graphic3d_Text and OpenGl_Text API
|
||||
|
||||
Parameters of *Text* in *Graphic3d_Group* are moved into a new *Graphic3d_Text* class. *AddText* of *Graphic3d_Group* should be used instead of the previous *Text*.
|
||||
|
||||
The previous code:
|
||||
~~~~
|
||||
Standard_Real x, y, z;
|
||||
theAttachmentPoint.Coord(x,y,z);
|
||||
theGroup->Text (theText,
|
||||
Graphic3d_Vertex(x,y,z),
|
||||
theAspect->Height(),
|
||||
theAspect->Angle(),
|
||||
theAspect->Orientation(),
|
||||
theAspect->HorizontalJustification(),
|
||||
theAspect->VerticalJustification());
|
||||
~~~~
|
||||
should be replaced by the new code:
|
||||
~~~~
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (theAspect->Height());
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (theAttachmentPoint);
|
||||
aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
|
||||
aText->SetVerticalAlignment (theAspect->VerticalJustification());
|
||||
theGroup->AddText (aText);
|
||||
~~~~
|
||||
|
||||
*OpenGl_Text* contains *Graphic3d_Text* field.
|
||||
|
||||
*OpenGl_TextParam* struct is removed. Constructor and *Init* of *OpenGl_Text* with *OpenGl_TextParam* are also removed.
|
||||
Instead of using them, change *OpenGl_Text*.
|
||||
|
||||
Please, note, that after modifying *OpenGl_Text*, *Reset* of *OpenGl_Text* should be called.
|
||||
|
||||
*FormatParams* of *OpenGl_Text* is replaced by *Text*.
|
||||
|
||||
@subsection upgrade_740_prsupdate Presentation invalidation
|
||||
|
||||
Historically AIS_InteractiveObject provided two independent mechanisms invalidating presentation (asking presentation manager to recompute specific display mode or all modes):
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
@@ -78,6 +79,31 @@ namespace
|
||||
Standard_Real aSaturation = NCollection_Lerp<Standard_Real>::Interpolate (theHlsMin[2], theHlsMax[2], aValue);
|
||||
return Quantity_Color (AIS_ColorScale::hueToValidRange (aHue), aLightness, aSaturation, Quantity_TOC_HLS);
|
||||
}
|
||||
|
||||
//! Return the index of discrete interval for specified value.
|
||||
//! Note that when value lies exactly on the border between two intervals,
|
||||
//! determining which interval to return is undefined operation;
|
||||
//! Current implementation returns the following interval in this case.
|
||||
//! @param theValue [in] value to map
|
||||
//! @param theMin [in] values range, lower value
|
||||
//! @param theMax [in] values range, upper value
|
||||
//! @param theNbIntervals [in] number of discrete intervals
|
||||
//! @return index of interval within [1, theNbIntervals] range
|
||||
static Standard_Integer colorDiscreteInterval (Standard_Real theValue,
|
||||
Standard_Real theMin,
|
||||
Standard_Real theMax,
|
||||
Standard_Integer theNbIntervals)
|
||||
{
|
||||
if (Abs (theMax - theMin) <= Precision::Approximation())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Integer anInterval = 1 + (Standard_Integer )Floor (Standard_Real (theNbIntervals) * (theValue - theMin) / (theMax - theMin));
|
||||
// map the very upper value (theValue==theMax) to the largest color interval
|
||||
anInterval = Min (anInterval, theNbIntervals);
|
||||
return anInterval;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -347,21 +373,14 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
||||
|
||||
if (myColorType == Aspect_TOCSD_USER)
|
||||
{
|
||||
Standard_Integer anIndex = 0;
|
||||
if (Abs (myMax - myMin) > Precision::Approximation())
|
||||
{
|
||||
anIndex = (theValue - myMin < Precision::Confusion())
|
||||
? 1
|
||||
: Standard_Integer (Ceiling (( theValue - myMin ) / ( (myMax - myMin) / myNbIntervals)));
|
||||
}
|
||||
|
||||
if (anIndex <= 0 || anIndex > myColors.Length())
|
||||
const Standard_Integer anInterval = colorDiscreteInterval (theValue, myMin, myMax, myNbIntervals);
|
||||
if (anInterval < myColors.Lower() || anInterval > myColors.Upper())
|
||||
{
|
||||
theColor = Quantity_Color();
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theColor = myColors.Value (anIndex);
|
||||
theColor = myColors.Value (anInterval);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -385,13 +404,8 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Real anInterval = 0.0;
|
||||
if (Abs (theMax - theMin) > Precision::Approximation())
|
||||
{
|
||||
anInterval = Floor (Standard_Real (theColorsCount) * (theValue - theMin) / (theMax - theMin));
|
||||
}
|
||||
|
||||
theColor = colorFromValueEx (anInterval, 0, theColorsCount - 1, theColorHlsMin, theColorHlsMax);
|
||||
const Standard_Integer anInterval = colorDiscreteInterval (theValue, theMin, theMax, theColorsCount);
|
||||
theColor = colorFromValueEx (anInterval - 1, 0, theColorsCount - 1, theColorHlsMin, theColorHlsMax);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -796,16 +810,14 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
|
||||
const Graphic3d_VerticalTextAlignment theVertAlignment)
|
||||
{
|
||||
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
|
||||
theGroup->Text (theText,
|
||||
gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
|
||||
anAspect->Height(),
|
||||
anAspect->Angle(),
|
||||
anAspect->Orientation(),
|
||||
Graphic3d_HTA_LEFT,
|
||||
theVertAlignment,
|
||||
Standard_True,
|
||||
Standard_False); // has own anchor
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)anAspect->Height());
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetOrientation (gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()));
|
||||
aText->SetOwnAnchorPoint (Standard_False);
|
||||
aText->SetVerticalAlignment (theVertAlignment);
|
||||
|
||||
theGroup->AddText (aText);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -633,9 +633,6 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
|
||||
{
|
||||
aShadedGroup = thePrs->NewGroup();
|
||||
aShadedGroup->SetClosed (isClosed);
|
||||
if (isClosed
|
||||
&& !myCappingStyle.IsNull())
|
||||
aShadedGroup->SetGroupPrimitivesAspect (myCappingStyle);
|
||||
}
|
||||
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
|
||||
aShadedGroup->AddPrimitiveArray (aTriangles);
|
||||
|
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
@@ -84,37 +83,6 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCappingStyle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveObject::SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
{
|
||||
myCappingStyle = theStyle;
|
||||
|
||||
// Modify existing presentations
|
||||
for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
|
||||
{
|
||||
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter);
|
||||
if (!aPrs3d.IsNull())
|
||||
{
|
||||
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
|
||||
if (!aStruct.IsNull())
|
||||
{
|
||||
const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
|
||||
if (aGrp.IsNull())
|
||||
continue;
|
||||
|
||||
aGrp->SetGroupPrimitivesAspect (theStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasPresentation
|
||||
//purpose :
|
||||
|
@@ -104,12 +104,6 @@ public:
|
||||
void ClearOwner() { myOwner.Nullify(); }
|
||||
|
||||
public:
|
||||
//! Set style of filling capping section created by clipping planes.
|
||||
Standard_EXPORT virtual void SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
|
||||
|
||||
//! Returns style for filling capping section created by clipping planes.
|
||||
const Handle(Graphic3d_AspectFillCapping)& CappingStyle() const { return myCappingStyle; }
|
||||
|
||||
|
||||
//! Returns the context pointer to the interactive context.
|
||||
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
|
||||
@@ -134,7 +128,6 @@ protected:
|
||||
|
||||
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
|
||||
Handle(Standard_Transient) myOwner; //!< application-specific owner object
|
||||
Handle(Graphic3d_AspectFillCapping) myCappingStyle;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -180,7 +180,10 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myCappingStyle);
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
|
||||
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
|
||||
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
|
||||
myUVOrigin, myUVRepeat, myUVScale);
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <Graphic3d_ViewAffinity.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <NCollection_Lerp.hxx>
|
||||
#include <Prs3d.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
@@ -193,6 +194,7 @@ void AIS_ViewCube::setDefaultAttributes()
|
||||
myDrawer->TextAspect()->SetColor (Quantity_NOC_BLACK);
|
||||
myDrawer->TextAspect()->SetFont (Font_NOF_SANS_SERIF);
|
||||
myDrawer->TextAspect()->SetHeight (16.0);
|
||||
myDrawer->TextAspect()->Aspect()->SetTextZoomable (true); // the whole object is drawn within transformation-persistence
|
||||
// this should be forced back-face culling regardless Closed flag
|
||||
myDrawer->TextAspect()->Aspect()->SetSuppressBackFaces (true);
|
||||
|
||||
@@ -717,7 +719,14 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
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);
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)myDrawer->TextAspect()->Height());
|
||||
aText->SetText (aLabel);
|
||||
aText->SetOrientation (aPosition);
|
||||
aText->SetOwnAnchorPoint (false);
|
||||
aText->SetHorizontalAlignment(myDrawer->TextAspect()->HorizontalJustification());
|
||||
aText->SetVerticalAlignment (myDrawer->TextAspect()->VerticalJustification());
|
||||
aTextGroup->AddText (aText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1395,7 +1395,7 @@ BRepCheck_Status BRepCheck_Wire::SelfIntersect(const TopoDS_Face& F,
|
||||
if (aCT1==GeomAbs_Line && aCT2==GeomAbs_Line) {
|
||||
// check for the two lines coincidence
|
||||
Standard_Real aPAR_T, aT11, aT12, aT21, aT22, aT1m, aT2m;
|
||||
Standard_Real aD2, aTolE1, aTolE2, aTol2, aDot;
|
||||
Standard_Real aD2, aTolE1, aTolE2, aTol2;
|
||||
gp_Lin2d aL1, aL2;
|
||||
gp_Pnt2d aP1m;
|
||||
//
|
||||
@@ -1423,14 +1423,10 @@ BRepCheck_Status BRepCheck_Wire::SelfIntersect(const TopoDS_Face& F,
|
||||
if (aT2m>aT21 && aT2m<aT22) {
|
||||
const gp_Dir2d& aDir1=aL1.Direction();
|
||||
const gp_Dir2d& aDir2=aL2.Direction();
|
||||
aDot=aDir1*aDir2;
|
||||
if (aDot<0.) {
|
||||
aDot=-aDot;
|
||||
}
|
||||
//
|
||||
if ((1.-aDot)<5.e-11){//0.00001 rad
|
||||
localok = Standard_False;
|
||||
break;// from for (k = 0; k < 2; ++k){...
|
||||
if (aDir1.IsParallel (aDir2, Precision::Angular()))
|
||||
{
|
||||
localok = Standard_False;
|
||||
break;// from for (k = 0; k < 2; ++k){...
|
||||
}
|
||||
}//if (aT2m>aT21 && aT2m<aT22) {
|
||||
}//if (aD2<aTol2) {
|
||||
|
@@ -1,25 +1,26 @@
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
// This file is part of commercial software by OPEN CASCADE SAS,
|
||||
// furnished in accordance with the terms and conditions of the contract
|
||||
// and with the inclusion of this copyright notice.
|
||||
// This file or any part thereof may not be provided or otherwise
|
||||
// made available to any third party.
|
||||
//
|
||||
// No ownership title to the software is transferred hereby.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
//
|
||||
// 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 <BRepGProp_MeshProps.hxx>
|
||||
|
||||
#include <BRepGProp.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <GProp.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Poly_Triangle.hxx>
|
||||
#include<ElSLib.hxx>
|
||||
#include<gp_Ax3.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <GProp.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : CalculateElSProps
|
||||
|
@@ -1,23 +1,19 @@
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
// This file is part of commercial software by OPEN CASCADE SAS,
|
||||
// furnished in accordance with the terms and conditions of the contract
|
||||
// and with the inclusion of this copyright notice.
|
||||
// This file or any part thereof may not be provided or otherwise
|
||||
// made available to any third party.
|
||||
//
|
||||
// No ownership title to the software is transferred hereby.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
//
|
||||
// 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 _BRepGProp_MeshProps_HeaderFile
|
||||
#define _BRepGProp_MeshProps_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <TopAbs_Orientation.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
@@ -36,11 +32,11 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Describes types of geometric objects.
|
||||
//! - Vinert is 3D closed region of space delimited with
|
||||
//! Point and surface mesh;
|
||||
//! - Sinert is surface mesh in 3D space.
|
||||
typedef enum { Vinert = 0, Sinert } BRepGProp_MeshObjType;
|
||||
//! Describes types of geometric objects.
|
||||
//! - Vinert is 3D closed region of space delimited with
|
||||
//! Point and surface mesh;
|
||||
//! - Sinert is surface mesh in 3D space.
|
||||
typedef enum { Vinert = 0, Sinert } BRepGProp_MeshObjType;
|
||||
|
||||
//! Constructor takes the type of object.
|
||||
BRepGProp_MeshProps(const BRepGProp_MeshObjType theType) :
|
||||
|
@@ -25,14 +25,14 @@
|
||||
//! Class implements functionality of model healer tool.
|
||||
//! Iterates over model's faces and checks consistency of their wires,
|
||||
//! i.e.whether wires are closed and do not contain self - intersections.
|
||||
//! In case if wire contains disconnected parts, ends of adjacent edges
|
||||
//! forming the gaps are connected in parametric space forcibly. The notion
|
||||
//! of this operation is to create correct discrete model defined relatively
|
||||
//! In case if wire contains disconnected parts, ends of adjacent edges
|
||||
//! forming the gaps are connected in parametric space forcibly. The notion
|
||||
//! of this operation is to create correct discrete model defined relatively
|
||||
//! parametric space of target face taking into account connectivity and
|
||||
//! tolerances of 3D space only. This means that there are no specific
|
||||
//! computations are made for the sake of determination of U and V tolerance.
|
||||
//! Registers intersections on edges forming the face<EFBFBD>s shape and tries to
|
||||
//! amplify discrete represenation by decreasing of deflection for the target edge.
|
||||
//! Registers intersections on edges forming the face's shape and tries to
|
||||
//! amplify discrete represenation by decreasing of deflection for the target edge.
|
||||
//! Checks can be performed in parallel mode.
|
||||
class BRepMesh_ModelHealer : public IMeshTools_ModelAlgo
|
||||
{
|
||||
|
@@ -363,8 +363,8 @@ TopoDS_Shape BRepTools_ReShape::Apply (const TopoDS_Shape& shape,
|
||||
return res;
|
||||
}
|
||||
|
||||
TopAbs_ShapeEnum st = shape.ShapeType(); //, subt;
|
||||
if ( st >= until ) return newsh; // critere d arret
|
||||
TopAbs_ShapeEnum st = shape.ShapeType();
|
||||
if (st > until || (st == until && until > TopAbs_COMPOUND)) return newsh; // stopping criteria
|
||||
if(st == TopAbs_VERTEX || st == TopAbs_SHAPE)
|
||||
return shape;
|
||||
// define allowed types of components
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
@@ -36,7 +37,7 @@ void DsgPrs_XYZAxisPresentation::Add(
|
||||
const Handle(Prs3d_LineAspect)& aLineAspect,
|
||||
const gp_Dir & aDir,
|
||||
const Standard_Real aVal,
|
||||
const Standard_CString aText,
|
||||
const Standard_CString theText,
|
||||
const gp_Pnt& aPfirst,
|
||||
const gp_Pnt& aPlast)
|
||||
{
|
||||
@@ -50,10 +51,12 @@ void DsgPrs_XYZAxisPresentation::Add(
|
||||
|
||||
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast,aDir, M_PI/180.*10., aVal/10.);
|
||||
|
||||
if (*aText != '\0')
|
||||
if (*theText != '\0')
|
||||
{
|
||||
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (aPlast);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->AddText (aText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +67,7 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
|
||||
const Handle(Prs3d_TextAspect)& aTextAspect,
|
||||
const gp_Dir & aDir,
|
||||
const Standard_Real aVal,
|
||||
const Standard_CString aText,
|
||||
const Standard_CString theText,
|
||||
const gp_Pnt& aPfirst,
|
||||
const gp_Pnt& aPlast)
|
||||
{
|
||||
@@ -81,9 +84,11 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
|
||||
|
||||
G->SetPrimitivesAspect(aTextAspect->Aspect());
|
||||
|
||||
if (*aText != '\0')
|
||||
if (*theText != '\0')
|
||||
{
|
||||
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (aPlast);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->AddText(aText);
|
||||
}
|
||||
}
|
||||
|
@@ -593,6 +593,12 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
{
|
||||
U1 = parameters(i);
|
||||
U2 = parameters(i + 1);
|
||||
|
||||
if (U2 - U1 <= uTol)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check maximal deflection on interval;
|
||||
Standard_Real dmax = 0.;
|
||||
Standard_Real umax = 0.;
|
||||
|
@@ -15,8 +15,6 @@ Graphic3d_Aspects.cxx
|
||||
Graphic3d_Aspects.hxx
|
||||
Graphic3d_AspectFillArea3d.cxx
|
||||
Graphic3d_AspectFillArea3d.hxx
|
||||
Graphic3d_AspectFillCapping.cxx
|
||||
Graphic3d_AspectFillCapping.hxx
|
||||
Graphic3d_AspectLine3d.cxx
|
||||
Graphic3d_AspectLine3d.hxx
|
||||
Graphic3d_AspectMarker3d.cxx
|
||||
@@ -50,6 +48,15 @@ Graphic3d_ClipPlane.hxx
|
||||
Graphic3d_CStructure.cxx
|
||||
Graphic3d_CStructure.hxx
|
||||
Graphic3d_CTexture.hxx
|
||||
Graphic3d_CubeMap.cxx
|
||||
Graphic3d_CubeMap.hxx
|
||||
Graphic3d_CubeMapOrder.cxx
|
||||
Graphic3d_CubeMapOrder.hxx
|
||||
Graphic3d_CubeMapPacked.cxx
|
||||
Graphic3d_CubeMapPacked.hxx
|
||||
Graphic3d_CubeMapSeparate.cxx
|
||||
Graphic3d_CubeMapSeparate.hxx
|
||||
Graphic3d_CubeMapSide.hxx
|
||||
Graphic3d_CullingTool.cxx
|
||||
Graphic3d_CullingTool.hxx
|
||||
Graphic3d_CView.cxx
|
||||
@@ -129,6 +136,8 @@ Graphic3d_StructureDefinitionError.hxx
|
||||
Graphic3d_StructureManager.cxx
|
||||
Graphic3d_StructureManager.hxx
|
||||
Graphic3d_TextPath.hxx
|
||||
Graphic3d_Text.cxx
|
||||
Graphic3d_Text.hxx
|
||||
Graphic3d_Texture1D.cxx
|
||||
Graphic3d_Texture1D.hxx
|
||||
Graphic3d_Texture1Dmanual.cxx
|
||||
|
@@ -1,110 +0,0 @@
|
||||
// Created on: 2017-04-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2017 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 <Graphic3d_AspectFillCapping.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_AspectFillCapping
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_AspectFillCapping::Graphic3d_AspectFillCapping()
|
||||
: myFlags (Flags_None),
|
||||
myHatchingState (0)
|
||||
{
|
||||
Graphic3d_MaterialAspect aMaterial;
|
||||
aMaterial.SetColor (Quantity_NOC_BLACK);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
|
||||
aMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
|
||||
SetHatchStyle (Aspect_HS_HORIZONTAL);
|
||||
SetHatchMaterial (aMaterial);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Aspect_HatchStyle theStyle)
|
||||
{
|
||||
myStippleHatch = new Graphic3d_HatchStyle (theStyle);
|
||||
myTextureHatch.Nullify();
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle)
|
||||
{
|
||||
myStippleHatch = theStyle;
|
||||
myTextureHatch.Nullify();
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture)
|
||||
{
|
||||
myStippleHatch.Nullify();
|
||||
myTextureHatch = theTexture;
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial)
|
||||
{
|
||||
myHatchMaterial = theMaterial;
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetToDrawHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetToDrawHatch (const Standard_Boolean theToDraw)
|
||||
{
|
||||
setFlag (theToDraw, Flags_DrawHatching);
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchZoomPeristent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchZoomPeristent (const Standard_Boolean theToSet)
|
||||
{
|
||||
setFlag (theToSet, Flags_HatchZoomPersistent);
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchRotationPeristent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchRotationPeristent (const Standard_Boolean theToSet)
|
||||
{
|
||||
setFlag (theToSet, Flags_HatchRotationPersistent);
|
||||
myHatchingState++;
|
||||
}
|
@@ -1,164 +0,0 @@
|
||||
// Created on: 2017-04-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_AspectFillCapping_HeaderFile
|
||||
#define _Graphic3d_AspectFillCapping_HeaderFile
|
||||
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <Graphic3d_Aspects.hxx>
|
||||
#include <Graphic3d_HatchStyle.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
//! Defines graphical attributes for drawing section planes on solids resulted from clipping (cutting) planes.
|
||||
class Graphic3d_AspectFillCapping : public Graphic3d_Aspects
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Standard_EXPORT Graphic3d_AspectFillCapping();
|
||||
|
||||
public:
|
||||
|
||||
//! Sets material for filling section created by clipping.
|
||||
void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) { myMaterial = theMaterial; }
|
||||
|
||||
//! Returns material for filling section created by clipping.
|
||||
const Graphic3d_MaterialAspect& Material() const { return myMaterial; }
|
||||
|
||||
//! Sets flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectMaterial (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectMaterial); }
|
||||
|
||||
//! Returns flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectMaterial() const { return (myFlags & Flags_UseObjectMaterial) != 0; }
|
||||
|
||||
//! Sets texture for filling section created by clipping.
|
||||
void SetTexture (const Handle(Graphic3d_TextureMap)& theTexture) { myTexture = theTexture; }
|
||||
|
||||
//! Returns texture for filling section created by clipping.
|
||||
const Handle(Graphic3d_TextureMap)& Texture() const { return myTexture; }
|
||||
|
||||
//! Sets flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectTexture (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectTexture); }
|
||||
|
||||
//! Returns flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectTexture() const { return (myFlags & Flags_UseObjectTexture) != 0; }
|
||||
|
||||
//! Sets OpenGL/GLSL shader program.
|
||||
void SetShader (const Handle(Graphic3d_ShaderProgram)& theShader) { myShader = theShader; }
|
||||
|
||||
//! Returns OpenGL/GLSL shader program.
|
||||
const Handle(Graphic3d_ShaderProgram)& Shader() const { return myShader; }
|
||||
|
||||
//! Sets flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectShader (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectShader); }
|
||||
|
||||
//! Returns flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectShader() const { return (myFlags & Flags_UseObjectShader) != 0; }
|
||||
|
||||
public:
|
||||
|
||||
//! Sets style of hatch defined by predefined stipple mask.
|
||||
Standard_EXPORT void SetHatchStyle (const Aspect_HatchStyle theStyle);
|
||||
|
||||
//! Sets style of hatch defined by custom stipple mask.
|
||||
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle);
|
||||
|
||||
//! Sets style of hatch defined by texture map (decal texture with alpha channel should be used).
|
||||
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture);
|
||||
|
||||
//! Sets material style for hatch lines (texture).
|
||||
Standard_EXPORT void SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial);
|
||||
|
||||
//! Returns material style for hatch lines (texture).
|
||||
const Graphic3d_MaterialAspect& HatchMaterial() const { return myHatchMaterial; }
|
||||
|
||||
//! Sets boolean flag indicating whether the hatch layer should be drawn or not.
|
||||
Standard_EXPORT void SetToDrawHatch (const Standard_Boolean theToDraw);
|
||||
|
||||
//! Returns boolean flag indicating whether the hatch layer should be drawn or not.
|
||||
Standard_Boolean ToDrawHatch() const { return (myFlags & Flags_DrawHatching) != 0; }
|
||||
|
||||
//! Sets flag controlling behavior of hatch texture mapping on zooming.
|
||||
//! @param theToSet [in] if passed TRUE the texture will keep constant screen-scale independent of zooming.
|
||||
Standard_EXPORT void SetHatchZoomPeristent (const Standard_Boolean theToSet);
|
||||
|
||||
//! Returns value of flag controlling behavior of hatch texture mapping on zooming.
|
||||
Standard_Boolean IsHatchZoomPersistent() { return (myFlags & Flags_HatchZoomPersistent) != 0; }
|
||||
|
||||
//! Sets flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
|
||||
Standard_EXPORT void SetHatchRotationPeristent (const Standard_Boolean theToSet);
|
||||
|
||||
//! Returns value of flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
|
||||
Standard_Boolean IsHatchRotationPersistent() { return (myFlags & Flags_HatchRotationPersistent) != 0; }
|
||||
|
||||
//! Returns true if hatch is defined by texture.
|
||||
Standard_Boolean IsTextureHatch() const { return !myTextureHatch.IsNull(); }
|
||||
|
||||
//! Returns texture map defining the hatch.
|
||||
const Handle(Graphic3d_TextureMap)& TextureHatch() const { return myTextureHatch; }
|
||||
|
||||
//! Returns true if hatch is defined by stipple mask.
|
||||
Standard_Boolean IsStippleHatch() const { return !myStippleHatch.IsNull(); }
|
||||
|
||||
//! Returns the stipple mask.
|
||||
const Handle(Graphic3d_HatchStyle)& StippleHatch() const { return myStippleHatch; }
|
||||
|
||||
//! Returns modification counter for hatching state.
|
||||
Standard_Size HatchingState() const { return myHatchingState; }
|
||||
|
||||
private:
|
||||
|
||||
enum Flags
|
||||
{
|
||||
Flags_None = 0x00, //!< no flags
|
||||
Flags_UseObjectMaterial = 0x01, //!< use object material
|
||||
Flags_UseObjectTexture = 0x02, //!< use object texture
|
||||
Flags_UseObjectShader = 0x04, //!< use object GLSL program
|
||||
Flags_HatchZoomPersistent = 0x08, //!< zoom-persistent texturing
|
||||
Flags_HatchRotationPersistent = 0x10, //!< rotation-persistent texturing
|
||||
Flags_DrawHatching = 0x20, //!< draw hatching
|
||||
Flags_UseObjectProperties = //!< use entire fill area aspect from object
|
||||
Flags_UseObjectMaterial
|
||||
| Flags_UseObjectTexture
|
||||
| Flags_UseObjectShader
|
||||
};
|
||||
|
||||
void setFlag (const Standard_Boolean theToUse, const unsigned int theFlag)
|
||||
{
|
||||
myFlags = theToUse ? myFlags | theFlag : myFlags & ~theFlag;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Graphic3d_MaterialAspect myMaterial;
|
||||
Handle(Graphic3d_TextureMap) myTexture;
|
||||
Handle(Graphic3d_ShaderProgram) myShader;
|
||||
Handle(Graphic3d_HatchStyle) myStippleHatch;
|
||||
Handle(Graphic3d_TextureMap) myTextureHatch;
|
||||
Graphic3d_MaterialAspect myHatchMaterial;
|
||||
unsigned int myFlags;
|
||||
Standard_Size myHatchingState;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Graphic3d_Aspects)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_AspectFillCapping, Graphic3d_Aspects)
|
||||
|
||||
#endif // _Graphic3d_AspectFillCapping_HeaderFile
|
@@ -19,6 +19,7 @@
|
||||
#include <Aspect_Window.hxx>
|
||||
#include <Graphic3d_BufferType.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <Graphic3d_CLight.hxx>
|
||||
#include <Graphic3d_CStructure.hxx>
|
||||
#include <Graphic3d_DataStructureManager.hxx>
|
||||
@@ -373,6 +374,12 @@ public:
|
||||
//! Sets background image fill style.
|
||||
virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) = 0;
|
||||
|
||||
//! Returns cubemap being setted last time on background.
|
||||
virtual Handle(Graphic3d_CubeMap) BackgroundCubeMap() const = 0;
|
||||
|
||||
//! Sets environment cubemap as background.
|
||||
virtual void SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap) = 0;
|
||||
|
||||
//! Returns environment texture set for the view.
|
||||
virtual Handle(Graphic3d_TextureEnv) TextureEnv() const = 0;
|
||||
|
||||
|
@@ -24,6 +24,19 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
|
||||
namespace
|
||||
{
|
||||
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
|
||||
|
||||
static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
|
||||
{
|
||||
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
|
||||
anAspect->SetDistinguishOff();
|
||||
anAspect->SetFrontMaterial (aMaterial);
|
||||
anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetInteriorColor (aMaterial.Color());
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
return anAspect;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -31,8 +44,19 @@ namespace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (0.0, 0.0, 1.0, 0.0),
|
||||
myEquation (0.0, 0.0, 1.0, 0.0),
|
||||
myEquationRev(0.0, 0.0,-1.0, 0.0),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
init();
|
||||
makeId();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -40,8 +64,19 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
|
||||
myEquation (theEquation),
|
||||
myEquationRev(0.0, 0.0,-1.0, 0.0),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
init (gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.a()));
|
||||
makeId();
|
||||
updateInversedPlane();
|
||||
}
|
||||
|
||||
@@ -49,27 +84,42 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
|
||||
// function : Graphic3d_ClipPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_ClipPlane& theOther)
|
||||
: Standard_Transient (theOther)
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
|
||||
: Standard_Transient(theOther),
|
||||
myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (theOther.myPlane),
|
||||
myEquation (theOther.myEquation),
|
||||
myEquationRev(theOther.myEquationRev),
|
||||
myChainLenFwd(1),
|
||||
myFlags (theOther.myFlags),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (theOther.myIsOn),
|
||||
myIsCapping (theOther.myIsCapping)
|
||||
{
|
||||
*mySectionStyle = *theOther.CappingSectionStyle();
|
||||
init (theOther.myPlane,
|
||||
theOther.myEquationRev,
|
||||
theOther.myIsOn,
|
||||
theOther.myIsCapping,
|
||||
theOther.ToOverrideCappingAspect(),
|
||||
theOther.CappingSectionStyle());
|
||||
updateInversedPlane();
|
||||
makeId();
|
||||
*myAspect = *theOther.CappingAspect();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_ClipPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const gp_Pln& thePlane)
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (thePlane),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
init (thePlane);
|
||||
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
updateInversedPlane();
|
||||
makeId();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -81,7 +131,7 @@ void Graphic3d_ClipPlane::SetEquation (const Graphic3d_Vec4d& theEquation)
|
||||
myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
|
||||
myEquation = theEquation;
|
||||
updateInversedPlane();
|
||||
myOrientationDirty = Standard_True;
|
||||
myEquationMod++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -93,7 +143,7 @@ void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
|
||||
myPlane = thePlane;
|
||||
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
updateInversedPlane();
|
||||
myOrientationDirty = Standard_True;
|
||||
myEquationMod++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -128,106 +178,119 @@ Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingSectionStyle
|
||||
// function : SetCappingMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
|
||||
{
|
||||
mySectionStyle = theStyle;
|
||||
myAspect->SetFrontMaterial (theMat);
|
||||
myAspect->SetInteriorColor (theMat.Color());
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OrientationMatrix
|
||||
// function : SetCappingTexture
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_Mat4& Graphic3d_ClipPlane::OrientationMatrix() const
|
||||
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
|
||||
{
|
||||
if (myOrientationDirty)
|
||||
if (!theTexture.IsNull())
|
||||
{
|
||||
const Standard_ShortReal aDirection[] = {
|
||||
static_cast<Standard_ShortReal> (myEquation[0]),
|
||||
static_cast<Standard_ShortReal> (myEquation[1]),
|
||||
static_cast<Standard_ShortReal> (myEquation[2])
|
||||
};
|
||||
|
||||
const Standard_ShortReal aTranslate[] = {
|
||||
static_cast<Standard_ShortReal> (myEquation[0] * -myEquation[3]),
|
||||
static_cast<Standard_ShortReal> (myEquation[1] * -myEquation[3]),
|
||||
static_cast<Standard_ShortReal> (myEquation[2] * -myEquation[3])
|
||||
};
|
||||
|
||||
Standard_ShortReal aSide1[] = { 0.0f, 0.0f, 0.0f };
|
||||
Standard_ShortReal aSide2[] = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
const Standard_ShortReal aMagintude = static_cast<Standard_ShortReal> (Sqrt (myEquation[0] * myEquation[0] + myEquation[2] * myEquation[2]));
|
||||
|
||||
if (aMagintude < ShortRealSmall())
|
||||
myAspect->SetTextureMapOn();
|
||||
Handle(Graphic3d_TextureSet) aTextureSet = myAspect->TextureSet();
|
||||
if (aTextureSet.IsNull() || aTextureSet->Size() != 1)
|
||||
{
|
||||
aSide1[0] = 1.0f;
|
||||
aTextureSet = new Graphic3d_TextureSet (theTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSide1[0] = aDirection[2] / aMagintude;
|
||||
aSide1[2] = -aDirection[0] / aMagintude;
|
||||
aTextureSet->SetFirst (theTexture);
|
||||
}
|
||||
|
||||
aSide2[0] = (-aSide1[1] * aDirection[2]) - (-aSide1[2] * aDirection[1]);
|
||||
aSide2[1] = (-aSide1[2] * aDirection[0]) - (-aSide1[0] * aDirection[2]);
|
||||
aSide2[2] = (-aSide1[0] * aDirection[1]) - (-aSide1[1] * aDirection[0]);
|
||||
|
||||
myOrientationMat.SetValue (0, 0, aSide1[0]);
|
||||
myOrientationMat.SetValue (1, 0, aSide1[1]);
|
||||
myOrientationMat.SetValue (2, 0, aSide1[2]);
|
||||
myOrientationMat.SetValue (3, 0, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 1, aDirection[0]);
|
||||
myOrientationMat.SetValue (1, 1, aDirection[1]);
|
||||
myOrientationMat.SetValue (2, 1, aDirection[2]);
|
||||
myOrientationMat.SetValue (3, 1, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 2, aSide2[0]);
|
||||
myOrientationMat.SetValue (1, 2, aSide2[1]);
|
||||
myOrientationMat.SetValue (2, 2, aSide2[2]);
|
||||
myOrientationMat.SetValue (3, 2, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 3, aTranslate[0]);
|
||||
myOrientationMat.SetValue (1, 3, aTranslate[1]);
|
||||
myOrientationMat.SetValue (2, 3, aTranslate[2]);
|
||||
myOrientationMat.SetValue (3, 3, 1.0F);
|
||||
|
||||
myOrientationDirty = Standard_False;
|
||||
myAspect->SetTextureSet (aTextureSet);
|
||||
}
|
||||
|
||||
return myOrientationMat;
|
||||
else
|
||||
{
|
||||
myAspect->SetTextureMapOff();
|
||||
myAspect->SetTextureSet (Handle(Graphic3d_TextureSet)());
|
||||
}
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : init
|
||||
// function : SetCappingHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::init (const gp_Pln& thePlane,
|
||||
const Graphic3d_Vec4d& theEquationRev,
|
||||
const Standard_Boolean theIsOn,
|
||||
const Standard_Boolean theIsCapping,
|
||||
const Standard_Boolean theOverrideStyle,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
|
||||
{
|
||||
if (myEntityUID.IsEmpty())
|
||||
{
|
||||
myEntityUID = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
|
||||
}
|
||||
myAspect->SetHatchStyle (theStyle);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
myPrevInChain = NULL;
|
||||
myEquationRev = theEquationRev;
|
||||
myChainLenFwd = 1;
|
||||
myPlane = thePlane;
|
||||
myPlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
myIsOn = theIsOn;
|
||||
myIsCapping = theIsCapping;
|
||||
myOverrideObjectStyle = theOverrideStyle;
|
||||
mySectionStyle = theStyle.IsNull() ? new Graphic3d_AspectFillCapping() : theStyle;
|
||||
myOrientationDirty = Standard_True;
|
||||
// =======================================================================
|
||||
// function : SetCappingCustomHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle)
|
||||
{
|
||||
myAspect->SetHatchStyle (theStyle);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatchOn
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingHatchOn()
|
||||
{
|
||||
myAspect->SetInteriorStyle (Aspect_IS_HATCH);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatchOff
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingHatchOff()
|
||||
{
|
||||
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||
{
|
||||
myAspect = theAspect;
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setCappingFlag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
|
||||
{
|
||||
if (theToUse)
|
||||
{
|
||||
myFlags |= theFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
myFlags &= ~(theFlag);
|
||||
}
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : makeId
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::makeId()
|
||||
{
|
||||
myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -249,7 +312,7 @@ void Graphic3d_ClipPlane::updateChainLen()
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||
{
|
||||
myOrientationDirty = Standard_True;
|
||||
++myEquationMod;
|
||||
if (!myNextInChain.IsNull())
|
||||
{
|
||||
myNextInChain->myPrevInChain = NULL;
|
||||
|
@@ -19,12 +19,9 @@
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_BndBox3d.hxx>
|
||||
#include <Graphic3d_CappingFlags.hxx>
|
||||
#include <Graphic3d_Mat4.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
@@ -169,6 +166,44 @@ public:
|
||||
|
||||
public: // @name user-defined graphical attributes
|
||||
|
||||
//! Set material for rendering capping surface.
|
||||
//! @param theMat [in] the material.
|
||||
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
|
||||
|
||||
//! @return capping material.
|
||||
const Graphic3d_MaterialAspect& CappingMaterial() const { return myAspect->FrontMaterial(); }
|
||||
|
||||
//! Set texture to be applied on capping surface.
|
||||
//! @param theTexture [in] the texture.
|
||||
Standard_EXPORT void SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture);
|
||||
|
||||
//! @return capping texture map.
|
||||
Handle(Graphic3d_TextureMap) CappingTexture() const { return !myAspect->TextureSet().IsNull() && !myAspect->TextureSet()->IsEmpty()
|
||||
? myAspect->TextureSet()->First()
|
||||
: Handle(Graphic3d_TextureMap)(); }
|
||||
|
||||
//! Set hatch style (stipple) and turn hatching on.
|
||||
//! @param theStyle [in] the hatch style.
|
||||
Standard_EXPORT void SetCappingHatch (const Aspect_HatchStyle theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
Aspect_HatchStyle CappingHatch() const { return (Aspect_HatchStyle)myAspect->HatchStyle()->HatchType(); }
|
||||
|
||||
//! Set custom hatch style (stipple) and turn hatching on.
|
||||
//! @param theStyle [in] the hatch pattern.
|
||||
Standard_EXPORT void SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
const Handle(Graphic3d_HatchStyle)& CappingCustomHatch() const { return myAspect->HatchStyle(); }
|
||||
|
||||
//! Turn on hatching.
|
||||
Standard_EXPORT void SetCappingHatchOn();
|
||||
|
||||
//! Turn off hatching.
|
||||
Standard_EXPORT void SetCappingHatchOff();
|
||||
|
||||
//! @return True if hatching mask is turned on.
|
||||
Standard_Boolean IsHatchOn() const { return myAspect->InteriorStyle() == Aspect_IS_HATCH; }
|
||||
|
||||
//! This ID is used for managing associated resources in graphical driver.
|
||||
//! The clip plane can be assigned within a range of IO which can be
|
||||
@@ -179,18 +214,41 @@ public: // @name user-defined graphical attributes
|
||||
//! @return clip plane resource identifier string.
|
||||
const TCollection_AsciiString& GetId() const
|
||||
{
|
||||
return myEntityUID;
|
||||
return myId;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Returns style used for drawing capping section.
|
||||
//! Return capping aspect.
|
||||
//! @return capping surface rendering aspect.
|
||||
const Handle(Graphic3d_AspectFillCapping)& CappingSectionStyle() const { return mySectionStyle; }
|
||||
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
|
||||
|
||||
//! Sets clipping section filling aspect.
|
||||
Standard_EXPORT void SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
|
||||
//! Assign capping aspect.
|
||||
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
|
||||
|
||||
//! Flag indicating whether material for capping plane should be taken from object.
|
||||
//! Default value: FALSE (use dedicated capping plane material).
|
||||
bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane material.
|
||||
void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); }
|
||||
|
||||
//! Flag indicating whether texture for capping plane should be taken from object.
|
||||
//! Default value: FALSE.
|
||||
bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane texture.
|
||||
void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); }
|
||||
|
||||
//! Flag indicating whether shader program for capping plane should be taken from object.
|
||||
//! Default value: FALSE.
|
||||
bool ToUseObjectShader() const { return (myFlags & Graphic3d_CappingFlags_ObjectShader) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane shader program.
|
||||
void SetUseObjectShader(bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectShader); }
|
||||
|
||||
//! Return true if some fill area aspect properties should be taken from object.
|
||||
bool ToUseObjectProperties() const { return myFlags != Graphic3d_CappingFlags_None; }
|
||||
|
||||
public:
|
||||
|
||||
@@ -326,25 +384,14 @@ public: // @name modification counters
|
||||
{
|
||||
return myAspectMod;
|
||||
}
|
||||
//! Flag indicating whether section style of the plane should overrides similar property of object presentation.
|
||||
//! Default value: FALSE (use dedicated presentation aspect style).
|
||||
bool ToOverrideCappingAspect() const { return myOverrideObjectStyle; }
|
||||
|
||||
//! Sets flag for controlling the preference of using section style between clip plane and object.
|
||||
void SetToOverrideCappingAspect (const bool theToOverride) { myOverrideObjectStyle = theToOverride; }
|
||||
|
||||
//! Returns plane's orientation matrix.
|
||||
Standard_EXPORT const Graphic3d_Mat4& OrientationMatrix() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Initializes plane and makes unique identifier (UID) to differentiate clipping plane entities.
|
||||
void init (const gp_Pln& thePlane = gp_Pln(),
|
||||
const Graphic3d_Vec4d& theEquationRev = Graphic3d_Vec4d(0.0, 0.0,-1.0, 0.0),
|
||||
const Standard_Boolean theIsOn = Standard_True,
|
||||
const Standard_Boolean theIsCapping = Standard_False,
|
||||
const Standard_Boolean theOverrideStyle = Standard_False,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theStyle = Handle(Graphic3d_AspectFillCapping)());
|
||||
//! Generate unique object id for OpenGL graphic resource manager.
|
||||
void makeId();
|
||||
|
||||
//! Set capping flag.
|
||||
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
|
||||
|
||||
//! Update chain length in backward direction.
|
||||
void updateChainLen();
|
||||
@@ -359,10 +406,10 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
Handle(Graphic3d_AspectFillCapping) mySectionStyle; //!< Style set for drawing capped solid section.
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
|
||||
Handle(Graphic3d_ClipPlane) myNextInChain; //!< next plane in a chain of planes defining logical AND operation
|
||||
Graphic3d_ClipPlane* myPrevInChain; //!< previous plane in a chain of planes defining logical AND operation
|
||||
TCollection_AsciiString myEntityUID; //!< Unique identifier for the plane
|
||||
TCollection_AsciiString myId; //!< resource id
|
||||
gp_Pln myPlane; //!< plane definition
|
||||
Graphic3d_Vec4d myEquation; //!< plane equation vector
|
||||
Graphic3d_Vec4d myEquationRev; //!< reversed plane equation
|
||||
@@ -372,9 +419,6 @@ private:
|
||||
unsigned int myAspectMod; //!< modification counter of aspect
|
||||
Standard_Boolean myIsOn; //!< state of the clipping plane
|
||||
Standard_Boolean myIsCapping; //!< state of graphic driver capping
|
||||
Standard_Boolean myOverrideObjectStyle; //!< Flag forcing to use plane's section style rather than section style defined for object
|
||||
mutable Standard_Boolean myOrientationDirty; //!< Boolean flag indicating whether orientation matrix is dirty or not.
|
||||
mutable Graphic3d_Mat4 myOrientationMat; //!< Plane orientation matrix (for visualization purposes).
|
||||
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
// Created on: 2011-09-20
|
||||
// Created by: Sergey ZERCHANINOV
|
||||
// Copyright (c) 2011-2014 OPEN CASCADE SAS
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
@@ -13,18 +12,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _OpenGl_TextParam_Header
|
||||
#define _OpenGl_TextParam_Header
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
|
||||
struct OpenGl_TextParam
|
||||
{
|
||||
int Height;
|
||||
Graphic3d_HorizontalTextAlignment HAlign;
|
||||
Graphic3d_VerticalTextAlignment VAlign;
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
|
||||
#endif //_OpenGl_TextParam_Header
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMap, Graphic3d_TextureMap)
|
110
src/Graphic3d/Graphic3d_CubeMap.hxx
Normal file
110
src/Graphic3d/Graphic3d_CubeMap.hxx
Normal file
@@ -0,0 +1,110 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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 _Graphic3d_CubeMap_HeaderFile
|
||||
#define _Graphic3d_CubeMap_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMapOrder.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
|
||||
//! Base class for cubemaps.
|
||||
//! It is iterator over cubemap sides.
|
||||
class Graphic3d_CubeMap : public Graphic3d_TextureMap
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMap, Graphic3d_TextureMap)
|
||||
public:
|
||||
|
||||
//! Constructor defining loading cubemap from file.
|
||||
Graphic3d_CubeMap (const TCollection_AsciiString& theFileName) :
|
||||
Graphic3d_TextureMap (theFileName, Graphic3d_TOT_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myIsTopDown (true),
|
||||
myZIsInverted (false)
|
||||
{}
|
||||
|
||||
//! Constructor defining direct cubemap initialization from PixMap.
|
||||
Graphic3d_CubeMap (const Handle(Image_PixMap)& thePixmap = Handle(Image_PixMap)()) :
|
||||
Graphic3d_TextureMap (thePixmap, Graphic3d_TOT_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myIsTopDown (true),
|
||||
myZIsInverted (false)
|
||||
{}
|
||||
|
||||
//! Returns whether the iterator has reached the end (true if it hasn't).
|
||||
Standard_Boolean More() const { return !myEndIsReached; }
|
||||
|
||||
//! Returns current cubemap side (iterator state).
|
||||
Graphic3d_CubeMapSide CurrentSide() const { return myCurrentSide; }
|
||||
|
||||
//! Moves iterator to the next cubemap side.
|
||||
//! Uses OpenGL cubemap sides order +X -> -X -> +Y -> -Y -> +Z -> -Z.
|
||||
void Next()
|
||||
{
|
||||
if (!myEndIsReached && myCurrentSide == Graphic3d_CMS_NEG_Z)
|
||||
{
|
||||
myEndIsReached = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
myCurrentSide = Graphic3d_CubeMapSide (myCurrentSide + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//! Returns whether row's memory layout is top-down.
|
||||
Standard_Boolean IsTopDown() const
|
||||
{
|
||||
return myIsTopDown;
|
||||
}
|
||||
|
||||
//! Sets Z axis inversion (vertical flipping).
|
||||
void SetZInversion (Standard_Boolean theZIsInverted)
|
||||
{
|
||||
myZIsInverted = theZIsInverted;
|
||||
}
|
||||
|
||||
//! Returns whether Z axis is inverted.
|
||||
Standard_Boolean ZIsInverted() const
|
||||
{
|
||||
return myZIsInverted;
|
||||
}
|
||||
|
||||
//! Returns PixMap containing current side of cubemap.
|
||||
//! Returns null handle if current side is invalid.
|
||||
virtual Handle(Image_PixMap) Value() = 0;
|
||||
|
||||
//! Sets iterator state to +X cubemap side.
|
||||
Graphic3d_CubeMap& Reset()
|
||||
{
|
||||
myCurrentSide = Graphic3d_CMS_POS_X;
|
||||
myEndIsReached = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Empty destructor.
|
||||
~Graphic3d_CubeMap() {}
|
||||
|
||||
protected:
|
||||
|
||||
Graphic3d_CubeMapSide myCurrentSide; //!< Iterator state
|
||||
Standard_Boolean myEndIsReached; //!< Indicates whether end of iteration has been reached or hasn't
|
||||
Standard_Boolean myIsTopDown; //!< Stores rows's memory layout
|
||||
Standard_Boolean myZIsInverted; //!< Indicates whether Z axis is inverted that allows to synchronize vertical flip of cubemap
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_CubeMap, Graphic3d_TextureMap)
|
||||
|
||||
#endif // _Graphic3d_CubeMap_HeaderFile
|
278
src/Graphic3d/Graphic3d_CubeMapOrder.cxx
Normal file
278
src/Graphic3d/Graphic3d_CubeMapOrder.cxx
Normal file
@@ -0,0 +1,278 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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.
|
||||
|
||||
#include <Graphic3d_CubeMapOrder.hxx>
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
#include <bitset>
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder::Graphic3d_CubeMapOrder()
|
||||
:
|
||||
myConvolution (0),
|
||||
myHasOverflows (false)
|
||||
{}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder::Graphic3d_CubeMapOrder (unsigned char thePosXLocation,
|
||||
unsigned char theNegXLocation,
|
||||
unsigned char thePosYLocation,
|
||||
unsigned char theNegYLocation,
|
||||
unsigned char thePosZLocation,
|
||||
unsigned char theNegZLocation)
|
||||
:
|
||||
myConvolution (0),
|
||||
myHasOverflows (false)
|
||||
{
|
||||
Set (Graphic3d_CMS_POS_X, thePosXLocation);
|
||||
Set (Graphic3d_CMS_NEG_X, theNegXLocation);
|
||||
Set (Graphic3d_CMS_POS_Y, thePosYLocation);
|
||||
Set (Graphic3d_CMS_NEG_Y, theNegYLocation);
|
||||
Set (Graphic3d_CMS_POS_Z, thePosZLocation);
|
||||
Set (Graphic3d_CMS_NEG_Z, theNegZLocation);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder::Graphic3d_CubeMapOrder (const Graphic3d_ValidatedCubeMapOrder theOrder)
|
||||
:
|
||||
myConvolution (theOrder.Order.myConvolution),
|
||||
myHasOverflows (theOrder.Order.myHasOverflows)
|
||||
{}
|
||||
|
||||
// =======================================================================
|
||||
// function : Set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Set (const Graphic3d_CubeMapOrder& theOrder)
|
||||
{
|
||||
myConvolution = theOrder.myConvolution;
|
||||
myHasOverflows = theOrder.myHasOverflows;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : operator=
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ValidatedCubeMapOrder Graphic3d_CubeMapOrder::Validated() const
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
throw Standard_Failure("Try of Graphic3d_ValidatedCubeMapOrder creation using invalid Graphic3d_CubeMapOrder");
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue)
|
||||
{
|
||||
if (theValue > 5)
|
||||
{
|
||||
myHasOverflows = true;
|
||||
return *this;
|
||||
}
|
||||
set (theCubeMapSide, theValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Get
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
unsigned char Graphic3d_CubeMapOrder::Get (Graphic3d_CubeMapSide theCubeMapSide) const
|
||||
{
|
||||
return get (static_cast<unsigned char> (theCubeMapSide));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : operator[]
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
unsigned char Graphic3d_CubeMapOrder::operator[] (Graphic3d_CubeMapSide theCubeMapSide) const
|
||||
{
|
||||
return Get (theCubeMapSide);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetDefault
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::SetDefault()
|
||||
{
|
||||
for (unsigned char i = 0; i < 6; ++i)
|
||||
{
|
||||
set (Graphic3d_CubeMapSide (i), i);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Permute
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Permute (Graphic3d_ValidatedCubeMapOrder thePermutation)
|
||||
{
|
||||
for (unsigned char i = 0; i < 6; ++i)
|
||||
{
|
||||
set (i, thePermutation->get (get (i)));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Permuted
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder Graphic3d_CubeMapOrder::Permuted (Graphic3d_ValidatedCubeMapOrder thePermutation) const
|
||||
{
|
||||
Graphic3d_CubeMapOrder anOrder = *this;
|
||||
anOrder.Permute (thePermutation);
|
||||
return anOrder;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Swap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Swap (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide)
|
||||
{
|
||||
unsigned char aTmp = Get (theFirstSide);
|
||||
set (theFirstSide, Get(theSecondSide));
|
||||
set (theSecondSide, aTmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Swapped
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder Graphic3d_CubeMapOrder::Swapped (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide) const
|
||||
{
|
||||
Graphic3d_CubeMapOrder anOrder = *this;
|
||||
anOrder.Swap (theFirstSide, theSecondSide);
|
||||
return anOrder;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Clear
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Clear()
|
||||
{
|
||||
myConvolution = 0;
|
||||
myHasOverflows = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsEmpty
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::IsEmpty() const
|
||||
{
|
||||
return myConvolution == 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasRepetitions
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::HasRepetitions() const
|
||||
{
|
||||
std::bitset<6> aBitSet;
|
||||
for (unsigned char i = 0; i < 6; ++i)
|
||||
{
|
||||
std::bitset<6>::reference aFlag = aBitSet[get (i)];
|
||||
if (aFlag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
aFlag = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasOverflows
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::HasOverflows() const
|
||||
{
|
||||
return myHasOverflows;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsValid
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::IsValid() const
|
||||
{
|
||||
return !HasRepetitions() && !HasOverflows();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : get
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
unsigned char Graphic3d_CubeMapOrder::get (unsigned char theCubeMapSide) const
|
||||
{
|
||||
return (myConvolution / (1 << (theCubeMapSide * 3))) % (1 << 3);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapOrder::set (unsigned char theCubeMapSide, unsigned char theValue)
|
||||
{
|
||||
unsigned int aValuePlace = 1 << (theCubeMapSide * 3);
|
||||
myConvolution -= aValuePlace * get (theCubeMapSide);
|
||||
myConvolution += aValuePlace * theValue;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapOrder::set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue)
|
||||
{
|
||||
set (static_cast<unsigned char> (theCubeMapSide), theValue);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Default
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_ValidatedCubeMapOrder& Graphic3d_CubeMapOrder::Default()
|
||||
{
|
||||
static const Graphic3d_ValidatedCubeMapOrder aCubeMapOrder = Graphic3d_CubeMapOrder().SetDefault().Validated();
|
||||
return aCubeMapOrder;
|
||||
}
|
158
src/Graphic3d/Graphic3d_CubeMapOrder.hxx
Normal file
158
src/Graphic3d/Graphic3d_CubeMapOrder.hxx
Normal file
@@ -0,0 +1,158 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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 _Graphic3d_CubeMapOrder_HeaderFile
|
||||
#define _Graphic3d_CubeMapOrder_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMapSide.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
class Graphic3d_ValidatedCubeMapOrder;
|
||||
|
||||
//! Graphic3d_CubeMapOrder maps sides of cubemap on tiles in packed cubemap image
|
||||
//! to support different tiles order in such images.
|
||||
//! Also it can be considered as permutation of numbers from 0 to 5.
|
||||
//! It stores permutation in one integer as convolution.
|
||||
class Graphic3d_CubeMapOrder
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
//! Creates empty order with zero convolution.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder();
|
||||
|
||||
//! Initializes order with values.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder (unsigned char thePosXLocation,
|
||||
unsigned char theNegXLocation,
|
||||
unsigned char thePosYLocation,
|
||||
unsigned char theNegYLocation,
|
||||
unsigned char thePosZLocation,
|
||||
unsigned char theNegZLocation);
|
||||
|
||||
//! Creates Graphic3d_CubeMapOrder using Graphic3d_ValidatedCubeMapOrder.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder (const Graphic3d_ValidatedCubeMapOrder theOrder);
|
||||
|
||||
//! Alias of 'operator='.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Set (const Graphic3d_CubeMapOrder& theOrder);
|
||||
|
||||
//! Checks whether order is valid and returns object containing it.
|
||||
//! If order is invalid then exception will be thrown.
|
||||
//! This method is only way to create Graphic3d_ValidatedCubeMapOrder except copy constructor.
|
||||
Standard_EXPORT Graphic3d_ValidatedCubeMapOrder Validated() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Sets number of tile in packed cubemap image according passed cubemap side.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue);
|
||||
|
||||
//! Sets default order (just from 0 to 5)
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& SetDefault();
|
||||
|
||||
//! Applies another cubemap order as permutation for the current one.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Permute (Graphic3d_ValidatedCubeMapOrder anOrder);
|
||||
|
||||
//! Returns permuted by other cubemap order copy of current one.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder Permuted (Graphic3d_ValidatedCubeMapOrder anOrder) const;
|
||||
|
||||
//! Swaps values of two cubemap sides.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Swap (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide);
|
||||
|
||||
//! Returns copy of current order with swapped values of two cubemap sides.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder Swapped (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide) const;
|
||||
|
||||
//! Returns value of passed cubemap side.
|
||||
Standard_EXPORT unsigned char Get (Graphic3d_CubeMapSide theCubeMapSide) const;
|
||||
|
||||
//! Alias of 'Get'.
|
||||
Standard_EXPORT unsigned char operator[] (Graphic3d_CubeMapSide theCubeMapSide) const;
|
||||
|
||||
//! Makes order empty.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Clear();
|
||||
|
||||
//! Checks whether order is empty.
|
||||
Standard_EXPORT bool IsEmpty() const;
|
||||
|
||||
//! Checks whether order has repetitions.
|
||||
Standard_EXPORT bool HasRepetitions() const;
|
||||
|
||||
//! Checks whether attempts to assign index greater than 5 to any side happed.
|
||||
Standard_EXPORT bool HasOverflows() const;
|
||||
|
||||
//! Checks whether order is valid.
|
||||
//! Order is valid when it doesn't have repetitions
|
||||
//! and there were not attempts to assign indexes greater than 5.
|
||||
Standard_EXPORT bool IsValid() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns default order in protector container class.
|
||||
//! It is guaranteed to be valid.
|
||||
Standard_EXPORT static const Graphic3d_ValidatedCubeMapOrder& Default();
|
||||
|
||||
private:
|
||||
|
||||
//! Alias of 'Get' with other parameter's type for more handful iteration.
|
||||
unsigned char get (unsigned char theCubeMapSide) const;
|
||||
|
||||
//! Alias of 'set' with other parameter's type for more handful iteration and applying permutations.
|
||||
void set (unsigned char theCubeMapSide, unsigned char theValue);
|
||||
|
||||
//! 'Set' without overflow's checking.
|
||||
void set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue);
|
||||
|
||||
private:
|
||||
|
||||
unsigned int myConvolution; //!< Contains all values of permutation as power convolution
|
||||
bool myHasOverflows; //!< Indicates if there are attempts to assign index greater than 5
|
||||
};
|
||||
|
||||
//! Graphic3d_ValidatedCubeMapOrder contains completely valid order object.
|
||||
//! The only way to create this class except copy constructor is 'Validated' method of Graphic3d_CubeMapOrder.
|
||||
//! This class can initialize Graphic3d_CubeMapOrder.
|
||||
//! It is supposed to be used in case of necessity of completely valid order (in function argument as example).
|
||||
//! It helps to automate order's valid checks.
|
||||
class Graphic3d_ValidatedCubeMapOrder
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
friend class Graphic3d_CubeMapOrder;
|
||||
|
||||
//! Allows skip access to 'Order' field and work directly.
|
||||
const Graphic3d_CubeMapOrder* operator->() const
|
||||
{
|
||||
return &Order;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
const Graphic3d_CubeMapOrder Order; //!< Completely valid order
|
||||
|
||||
private:
|
||||
|
||||
//! Only Graphic3d_CubeMapOrder can generate Graphic3d_ValidatedCubeMapOrder in 'Validated' method.
|
||||
Graphic3d_ValidatedCubeMapOrder(const Graphic3d_CubeMapOrder theOrder)
|
||||
:
|
||||
Order(theOrder)
|
||||
{}
|
||||
|
||||
//! Deleted 'operator='
|
||||
Graphic3d_ValidatedCubeMapOrder& operator= (const Graphic3d_ValidatedCubeMapOrder&);
|
||||
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_CubeMapOrder_HeaderFile
|
196
src/Graphic3d/Graphic3d_CubeMapPacked.cxx
Normal file
196
src/Graphic3d/Graphic3d_CubeMapPacked.cxx
Normal file
@@ -0,0 +1,196 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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.
|
||||
|
||||
#include <Graphic3d_CubeMapPacked.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapPacked
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapPacked::Graphic3d_CubeMapPacked (const TCollection_AsciiString& theFilePath,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder)
|
||||
:
|
||||
Graphic3d_CubeMap (theFilePath),
|
||||
myOrder (theOrder),
|
||||
myTileNumberX (1)
|
||||
{}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapPacked
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapPacked::Graphic3d_CubeMapPacked (const Handle(Image_PixMap)& theImage,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder)
|
||||
:
|
||||
Graphic3d_CubeMap (Handle(Image_PixMap)()),
|
||||
myOrder (theOrder),
|
||||
myTileNumberX (1)
|
||||
{
|
||||
if (checkImage (theImage, myTileNumberX))
|
||||
{
|
||||
myPixMap = theImage;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Value
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Image_PixMap) Graphic3d_CubeMapPacked::Value()
|
||||
{
|
||||
if (myTileNumberX != 0)
|
||||
{
|
||||
if (myPixMap.IsNull())
|
||||
{
|
||||
TCollection_AsciiString aFilePath;
|
||||
myPath.SystemName (aFilePath);
|
||||
if (!aFilePath.IsEmpty())
|
||||
{
|
||||
tryLoadImage (aFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!myPixMap.IsNull())
|
||||
{
|
||||
Handle(Image_PixMap) aWrapper = new Image_PixMap();
|
||||
|
||||
Standard_Size aTileSize = myPixMap->SizeX() / myTileNumberX;
|
||||
|
||||
myIsTopDown = myPixMap->IsTopDown();
|
||||
|
||||
Graphic3d_CubeMapOrder anOrder = myOrder;
|
||||
|
||||
if (!myIsTopDown)
|
||||
{
|
||||
myPixMap->SetTopDown (true);
|
||||
anOrder.Swap (Graphic3d_CMS_POS_Y, Graphic3d_CMS_NEG_Y);
|
||||
}
|
||||
|
||||
unsigned int aTileIndexX = anOrder[myCurrentSide] % myTileNumberX;
|
||||
unsigned int aTileIndexY = anOrder[myCurrentSide] / myTileNumberX;
|
||||
|
||||
aTileIndexY = myIsTopDown ? aTileIndexY : (6 / myTileNumberX - 1 - aTileIndexY);
|
||||
|
||||
if (aWrapper->InitWrapper (myPixMap->Format(),
|
||||
myPixMap->ChangeRawValue(aTileIndexY * aTileSize, aTileIndexX * aTileSize),
|
||||
aTileSize,
|
||||
aTileSize,
|
||||
myPixMap->SizeRowBytes()))
|
||||
{
|
||||
myPixMap->SetTopDown (myIsTopDown);
|
||||
return aWrapper;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPixMap->SetTopDown(myIsTopDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : checkOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_CubeMapPacked::checkOrder (const NCollection_Array1<unsigned int>& theOrder)
|
||||
{
|
||||
Standard_Boolean anOrderIsValid = Standard_True;
|
||||
|
||||
if (theOrder.Size() != 6)
|
||||
{
|
||||
anOrderIsValid = Standard_False;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < 6 && anOrderIsValid; ++i)
|
||||
{
|
||||
if (theOrder[i] > 5)
|
||||
{
|
||||
anOrderIsValid = Standard_False;
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned int j = i + 1; j < 6; ++j)
|
||||
{
|
||||
if (theOrder[i] == theOrder[j])
|
||||
{
|
||||
anOrderIsValid = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!anOrderIsValid)
|
||||
{
|
||||
throw Standard_Failure ("Ivalid order format in tiles of Graphic3d_CubeMapPacked");
|
||||
}
|
||||
|
||||
return anOrderIsValid;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : checkImage
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_CubeMapPacked::checkImage (const Handle(Image_PixMap)& theImage,
|
||||
unsigned int& theTileNumberX)
|
||||
{
|
||||
Standard_Size aSizeX = theImage->SizeX();
|
||||
Standard_Size aSizeY = theImage->SizeY();
|
||||
|
||||
if ((aSizeY % aSizeX == 0) && (aSizeY / aSizeX == 6))
|
||||
{
|
||||
theTileNumberX = 1;
|
||||
}
|
||||
else if ((aSizeX % aSizeY == 0) && (aSizeX / aSizeY == 6))
|
||||
{
|
||||
theTileNumberX = 6;
|
||||
}
|
||||
else if ((aSizeX % 2 == 0) && (aSizeY % 3 == 0) && (aSizeX / 2 == aSizeY / 3))
|
||||
{
|
||||
theTileNumberX = 2;
|
||||
}
|
||||
else if ((aSizeX % 3 == 0) && (aSizeY % 2 == 0) && (aSizeX / 3 == aSizeY / 2))
|
||||
{
|
||||
theTileNumberX = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : tryLoadImage
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapPacked::tryLoadImage (const TCollection_AsciiString& theFilePath)
|
||||
{
|
||||
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap;
|
||||
if (anImage->Load (theFilePath))
|
||||
{
|
||||
if (checkImage (anImage, myTileNumberX))
|
||||
{
|
||||
myPixMap = anImage;
|
||||
}
|
||||
}
|
||||
}
|
71
src/Graphic3d/Graphic3d_CubeMapPacked.hxx
Normal file
71
src/Graphic3d/Graphic3d_CubeMapPacked.hxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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 _Graphic3d_CubeMapPacked_HeaderFile
|
||||
#define _Graphic3d_CubeMapPacked_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
||||
//! Class is intended to process cubemap packed into single image plane.
|
||||
class Graphic3d_CubeMapPacked : public Graphic3d_CubeMap
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
|
||||
public:
|
||||
|
||||
//! Initialization to load cubemef from file.
|
||||
//! @theFileName - path to the cubemap image
|
||||
//! @theOrder - array conaining six different indexes of cubemap sides which maps tile grid to cubemap sides
|
||||
Standard_EXPORT Graphic3d_CubeMapPacked (const TCollection_AsciiString& theFileName,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default());
|
||||
|
||||
//! Initialization to set cubemap directly by PixMap.
|
||||
//! @thePixMap - origin PixMap
|
||||
//! @theOrder - array conaining six different indexes of cubemap sides which maps tile grid to cubemap sides
|
||||
Standard_EXPORT Graphic3d_CubeMapPacked (const Handle(Image_PixMap)& theImage,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default());
|
||||
|
||||
//! Returns current cubemap side as PixMap.
|
||||
//! Resulting PixMap is memory wrapper over original image.
|
||||
//! Returns null handle if current side or whole cubemap is invalid.
|
||||
//! Origin image has to contain six quad tiles having one sizes without any gaps to be valid.
|
||||
Standard_EXPORT Handle(Image_PixMap) Value() Standard_OVERRIDE;
|
||||
|
||||
//! Empty destructor.
|
||||
~Graphic3d_CubeMapPacked() {}
|
||||
|
||||
private:
|
||||
|
||||
//! Checks whether given tiles order is valid.
|
||||
static Standard_Boolean checkOrder (const NCollection_Array1<unsigned int>& theOrder);
|
||||
|
||||
//! Checks whether given pixmap is valid to contain six tiles.
|
||||
static Standard_Boolean checkImage (const Handle(Image_PixMap)& theImage,
|
||||
unsigned int& theTileNumberX);
|
||||
|
||||
//! Tries to load image from file and checks it after that.
|
||||
//! Does nothing in case of fail.
|
||||
void tryLoadImage (const TCollection_AsciiString &theFilePath);
|
||||
|
||||
protected:
|
||||
|
||||
Graphic3d_CubeMapOrder myOrder; //!< order mapping tile grit to cubemap sides
|
||||
unsigned int myTileNumberX; //!< width of tile grid
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
|
||||
|
||||
#endif // _Graphic3d_CubeMapPacked_HeaderFile
|
185
src/Graphic3d/Graphic3d_CubeMapSeparate.cxx
Normal file
185
src/Graphic3d/Graphic3d_CubeMapSeparate.cxx
Normal file
@@ -0,0 +1,185 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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.
|
||||
|
||||
#include <Graphic3d_CubeMapSeparate.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapSeparate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapSeparate::Graphic3d_CubeMapSeparate (const NCollection_Array1<TCollection_AsciiString>& thePaths)
|
||||
{
|
||||
if (thePaths.Size() == 6)
|
||||
{
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
myPaths[i] = thePaths[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Standard_Failure("Invalid number of paths to load Graphic3d_CubeMapSeparate");
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapSeparate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapSeparate::Graphic3d_CubeMapSeparate (const NCollection_Array1<Handle(Image_PixMap)>& theImages)
|
||||
{
|
||||
if (theImages.Size() == 6)
|
||||
{
|
||||
if (theImages[0].IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theImages[0]->SizeX() != theImages[0]->SizeY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myImages[0] = theImages[0];
|
||||
myIsTopDown = myImages[0]->IsTopDown();
|
||||
|
||||
for (unsigned int i = 1; i < 6; ++i)
|
||||
{
|
||||
if (!theImages[i].IsNull())
|
||||
{
|
||||
if (theImages[i]->SizeX() == myImages[0]->SizeX()
|
||||
&& theImages[i]->SizeY() == myImages[0]->SizeY()
|
||||
&& theImages[i]->Format() == myImages[0]->Format()
|
||||
&& theImages[i]->IsTopDown() == myImages[0]->IsTopDown())
|
||||
{
|
||||
myImages[i] = theImages[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
resetImages();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Standard_Failure("Invalid number of images in Graphic3d_CubeMapSeparate initialization");
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Value
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Image_PixMap) Graphic3d_CubeMapSeparate::Value()
|
||||
{
|
||||
Graphic3d_CubeMapOrder anOrder = Graphic3d_CubeMapOrder::Default();
|
||||
if (!myIsTopDown)
|
||||
{
|
||||
anOrder.Swap(Graphic3d_CMS_POS_Y, Graphic3d_CMS_NEG_Y);
|
||||
}
|
||||
|
||||
if (!myImages[anOrder[myCurrentSide]].IsNull())
|
||||
{
|
||||
return myImages[anOrder[myCurrentSide]];
|
||||
}
|
||||
else
|
||||
{
|
||||
TCollection_AsciiString aFilePath;
|
||||
myPaths[anOrder[myCurrentSide]].SystemName(aFilePath);
|
||||
if (!aFilePath.IsEmpty())
|
||||
{
|
||||
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap;
|
||||
if (anImage->Load(aFilePath))
|
||||
{
|
||||
if (anImage->SizeX() == anImage->SizeY())
|
||||
{
|
||||
if (myCurrentSide == 0)
|
||||
{
|
||||
mySize = anImage->SizeX();
|
||||
myFormat = anImage->Format();
|
||||
myIsTopDown = anImage->IsTopDown();
|
||||
return anImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (anImage->Format() == myFormat
|
||||
&& anImage->SizeX() == mySize
|
||||
&& anImage->IsTopDown() == myIsTopDown)
|
||||
{
|
||||
return anImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send(TCollection_AsciiString() +
|
||||
"'" + aFilePath + "' inconsistent image format or dimension in Graphic3d_CubeMapSeparate");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send(TCollection_AsciiString() +
|
||||
"Unable to load '" + aFilePath + "' image of Graphic3d_CubeMapSeparate");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send(TCollection_AsciiString() +
|
||||
"[" + myCurrentSide + "] path of Graphic3d_CubeMapSeparate is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsDone
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_CubeMapSeparate::IsDone() const
|
||||
{
|
||||
if (!myImages[0].IsNull())
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
OSD_File aCubeMapFile(myPaths[i]);
|
||||
if (!aCubeMapFile.Exists())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : resetImages
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapSeparate::resetImages()
|
||||
{
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
myImages[i].Nullify();
|
||||
}
|
||||
}
|
71
src/Graphic3d/Graphic3d_CubeMapSeparate.hxx
Normal file
71
src/Graphic3d/Graphic3d_CubeMapSeparate.hxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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 _Graphic3d_CubeMapSeparate_HeaderFile
|
||||
#define _Graphic3d_CubeMapSeparate_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
||||
//! Class to manage cubemap located in six different images.
|
||||
class Graphic3d_CubeMapSeparate : public Graphic3d_CubeMap
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
|
||||
public:
|
||||
|
||||
//! Initializes cubemap to be loaded from file.
|
||||
//! @thePaths - array of paths to separate image files (has to have size equal 6).
|
||||
Standard_EXPORT Graphic3d_CubeMapSeparate (const NCollection_Array1<TCollection_AsciiString>& thePaths);
|
||||
|
||||
//! Initializes cubemap to be setted directly from PixMaps.
|
||||
//! @theImages - array if PixMaps (has to have size equal 6).
|
||||
Standard_EXPORT Graphic3d_CubeMapSeparate(const NCollection_Array1<Handle(Image_PixMap)>& theImages);
|
||||
|
||||
//! Returns current side of cubemap as PixMap.
|
||||
//! Returns null handle if current side or whole cubemap is invalid.
|
||||
//! All origin images have to have the same sizes, format and quad shapes to form valid cubemap.
|
||||
Standard_EXPORT Handle(Image_PixMap) Value() Standard_OVERRIDE;
|
||||
|
||||
//! Returns NULL.
|
||||
virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE
|
||||
{
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
//! Checks if a texture class is valid or not.
|
||||
//! Returns true if the construction of the class is correct.
|
||||
Standard_EXPORT Standard_Boolean IsDone() const Standard_OVERRIDE;
|
||||
|
||||
//! Empty destructor.
|
||||
~Graphic3d_CubeMapSeparate() {}
|
||||
|
||||
protected:
|
||||
|
||||
OSD_Path myPaths[6]; //!< array of paths to cubemap images
|
||||
Handle(Image_PixMap) myImages[6]; //!< array of cubemap images
|
||||
|
||||
Standard_Size mySize; //!< size of each side of cubemap
|
||||
Image_Format myFormat; //!< format each side of cubemap
|
||||
|
||||
private:
|
||||
|
||||
//! Nulifies whole images array.
|
||||
void resetImages();
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
|
||||
|
||||
#endif // _Graphic3d_CubeMapSeparate_HeaderFile
|
29
src/Graphic3d/Graphic3d_CubeMapSide.hxx
Normal file
29
src/Graphic3d/Graphic3d_CubeMapSide.hxx
Normal file
@@ -0,0 +1,29 @@
|
||||
// Author: Ilya Khramov
|
||||
// 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 _Graphic3d_CubeMapSide_HeaderFile
|
||||
#define _Graphic3d_CubeMapSide_HeaderFile
|
||||
|
||||
//! Sides of cubemap in order of OpenGL rules
|
||||
enum Graphic3d_CubeMapSide
|
||||
{
|
||||
Graphic3d_CMS_POS_X, //!< X axis positive direction side
|
||||
Graphic3d_CMS_NEG_X, //!< X axis negative direction side
|
||||
Graphic3d_CMS_POS_Y, //!< Y axis positive direction side
|
||||
Graphic3d_CMS_NEG_Y, //!< Y axis negative direction side
|
||||
Graphic3d_CMS_POS_Z, //!< Z axis positive direction side
|
||||
Graphic3d_CMS_NEG_Z, //!< Z axis negative direction side
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_CubeMapSide_HeaderFile
|
@@ -29,6 +29,7 @@
|
||||
#include <Graphic3d_Structure.hxx>
|
||||
#include "Graphic3d_Structure.pxx"
|
||||
#include <Graphic3d_StructureManager.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Graphic3d_TransModeFlags.hxx>
|
||||
#include <Message.hxx>
|
||||
@@ -310,31 +311,21 @@ void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
|
||||
// function : Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
||||
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real /*theHeight*/,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
Standard_ShortReal x, y, z;
|
||||
thePoint.Coord (x, y, z);
|
||||
myStructure->CStructure()->Is2dText = Standard_True;
|
||||
myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (x),
|
||||
static_cast<Standard_ShortReal> (y),
|
||||
static_cast<Standard_ShortReal> (z),
|
||||
1.0f));
|
||||
}
|
||||
Update();
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -346,8 +337,10 @@ void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
Text (theText, thePoint, theHeight, 0.0,
|
||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -357,15 +350,18 @@ void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(), thePoint, theHeight, theAngle,
|
||||
theTp, theHta, theVta, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -375,53 +371,43 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTP,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTP*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(),
|
||||
theOrientation,
|
||||
theHeight,
|
||||
theAngle,
|
||||
theTP,
|
||||
theHTA,
|
||||
theVTA,
|
||||
theToEvalMinMax,
|
||||
theHasOwnAnchor);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetOrientation (theOrientation);
|
||||
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
||||
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real /*theHeight*/,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean /*theHasOwnAnchor*/)
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
myStructure->CStructure()->Is2dText = Standard_False;
|
||||
myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (theOrientation.Location().X()),
|
||||
static_cast<Standard_ShortReal> (theOrientation.Location().Y()),
|
||||
static_cast<Standard_ShortReal> (theOrientation.Location().Z()),
|
||||
1.0f));
|
||||
}
|
||||
Update();
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetOrientation (theOrientation);
|
||||
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -433,7 +419,31 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(), thePoint, theHeight, 0.0,
|
||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddText
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
myStructure->CStructure()->Is2dText = !theTextParams->HasPlane();
|
||||
|
||||
gp_Pnt aPosition = theTextParams->Position();
|
||||
myBounds.Add (Graphic3d_Vec4 ((Standard_ShortReal)aPosition.X(), (Standard_ShortReal)aPosition.Y(), (Standard_ShortReal)aPosition.Z(), 1.0f));
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@
|
||||
|
||||
class Graphic3d_Structure;
|
||||
class Graphic3d_ArrayOfPrimitives;
|
||||
class Graphic3d_AspectFillCapping;
|
||||
class Graphic3d_Text;
|
||||
|
||||
//! This class allows the definition of groups
|
||||
//! of primitives inside of graphic objects (presentations).
|
||||
@@ -105,96 +105,22 @@ public:
|
||||
//! Modifies the current context of the group to give another aspect for all the primitives created after this call in the group.
|
||||
virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
|
||||
|
||||
//! Returns style of filling clipping sections on closed shell primitives.
|
||||
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const = 0;
|
||||
|
||||
//! Update presentation aspects after their modification.
|
||||
virtual void SynchronizeAspects() = 0;
|
||||
|
||||
//! Replace aspects specified in the replacement map.
|
||||
virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
|
||||
|
||||
public:
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_EXPORT virtual void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_EXPORT void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Adds a text for display
|
||||
Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
|
||||
//! Adds an array of primitives for display
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, const Handle(Graphic3d_IndexBuffer)& theIndices, const Handle(Graphic3d_Buffer)& theAttribs, const Handle(Graphic3d_BoundBuffer)& theBounds, const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
|
||||
//! Adds an array of primitives for display
|
||||
Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
@@ -244,6 +170,112 @@ public:
|
||||
//! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
|
||||
bool IsClosed() const { return myIsClosed; }
|
||||
|
||||
//! @name obsolete methods
|
||||
public:
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const Standard_CString AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Real AAngle,
|
||||
const Graphic3d_TextPath ATp,
|
||||
const Graphic3d_HorizontalTextAlignment AHta,
|
||||
const Graphic3d_VerticalTextAlignment AVta,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const Standard_CString AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Real AAngle,
|
||||
const Graphic3d_TextPath ATp,
|
||||
const Graphic3d_HorizontalTextAlignment AHta,
|
||||
const Graphic3d_VerticalTextAlignment AVta,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates a group in the structure <AStructure>.
|
||||
|
@@ -21,15 +21,13 @@
|
||||
//! - ASPECT_LINE: aspect for line primitives;
|
||||
//! - ASPECT_TEXT: aspect for text primitives;
|
||||
//! - ASPECT_MARKER: aspect for marker primitives;
|
||||
//! - ASPECT_FILL_AREA: aspect for face primitives;
|
||||
//! - Graphic3d_ASPECT_FILL_CAPPING: aspect for filling clipping sections.
|
||||
//! - ASPECT_FILL_AREA: aspect for face primitives.
|
||||
enum Graphic3d_GroupAspect
|
||||
{
|
||||
Graphic3d_ASPECT_LINE,
|
||||
Graphic3d_ASPECT_TEXT,
|
||||
Graphic3d_ASPECT_MARKER,
|
||||
Graphic3d_ASPECT_FILL_AREA,
|
||||
Graphic3d_ASPECT_FILL_CAPPING
|
||||
Graphic3d_ASPECT_FILL_AREA
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_GroupAspect_HeaderFile
|
||||
|
49
src/Graphic3d/Graphic3d_Text.cxx
Normal file
49
src/Graphic3d/Graphic3d_Text.cxx
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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.
|
||||
|
||||
#include <Graphic3d_Text.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Text::Graphic3d_Text (const Standard_ShortReal theHeight)
|
||||
: myHeight (theHeight),
|
||||
myHAlign (Graphic3d_HTA_LEFT),
|
||||
myVAlign (Graphic3d_VTA_BOTTOM),
|
||||
myHasPlane (Standard_False),
|
||||
myHasOwnAnchor (Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetOrientation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Text::SetOrientation (const gp_Ax2& theOrientation)
|
||||
{
|
||||
myOrientation = theOrientation;
|
||||
myHasPlane = Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ResetOrientation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Text::ResetOrientation()
|
||||
{
|
||||
myOrientation = gp_Ax2();
|
||||
myHasPlane = Standard_False;
|
||||
}
|
115
src/Graphic3d/Graphic3d_Text.hxx
Normal file
115
src/Graphic3d/Graphic3d_Text.hxx
Normal file
@@ -0,0 +1,115 @@
|
||||
// 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 _Graphic3d_Text_HeaderFile
|
||||
#define _Graphic3d_Text_HeaderFile
|
||||
|
||||
#include <gp_Ax2.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
#include <NCollection_String.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
//! This class allows the definition of a text object for display.
|
||||
//! The text might be defined in one of ways, using:
|
||||
//! - text value and position,
|
||||
//! - text value, orientation and the state whether the text uses position as point of attach.
|
||||
//! - text formatter. Formatter contains text, height and alignment parameter.
|
||||
//!
|
||||
//! This class also has parameters of the text height and H/V alignments.
|
||||
class Graphic3d_Text : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
public:
|
||||
|
||||
//! Creates default text parameters.
|
||||
Standard_EXPORT Graphic3d_Text (const Standard_ShortReal theHeight);
|
||||
|
||||
//! Destructor.
|
||||
virtual ~Graphic3d_Text() {}
|
||||
|
||||
//! Returns text value.
|
||||
const NCollection_String& Text() const { return myText; }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (const NCollection_String& theText) { myText = theText; }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (const TCollection_AsciiString& theText) { myText = theText.ToCString(); }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (Standard_CString theText) { myText = theText; }
|
||||
|
||||
//! The 3D point of attachment is projected.
|
||||
//! If the orientation is defined, the text is written in the plane of projection.
|
||||
const gp_Pnt& Position() const { return myOrientation.Location(); }
|
||||
|
||||
//! Sets text point.
|
||||
void SetPosition (const gp_Pnt& thePoint) { myOrientation.SetLocation (thePoint); }
|
||||
|
||||
//! Returns text orientation in 3D space.
|
||||
const gp_Ax2& Orientation() const { return myOrientation; }
|
||||
|
||||
//! Returns true if the text is filled by a point
|
||||
Standard_Boolean HasPlane() const { return myHasPlane; }
|
||||
|
||||
//! Sets text orientation in 3D space.
|
||||
Standard_EXPORT void SetOrientation (const gp_Ax2& theOrientation);
|
||||
|
||||
//! Reset text orientation in 3D space.
|
||||
Standard_EXPORT void ResetOrientation();
|
||||
|
||||
//! Returns true if the text has an anchor point
|
||||
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchor; }
|
||||
|
||||
//! Returns true if the text has an anchor point
|
||||
void SetOwnAnchorPoint (const Standard_Boolean theHasOwnAnchor) { myHasOwnAnchor = theHasOwnAnchor; }
|
||||
|
||||
//! Sets height of text. (Relative to the Normalized Projection Coordinates (NPC) Space).
|
||||
Standard_ShortReal Height() const { return myHeight; }
|
||||
|
||||
//! Returns height of text
|
||||
void SetHeight (const Standard_ShortReal theHeight) { myHeight = theHeight; }
|
||||
|
||||
//! Returns horizontal alignment of text.
|
||||
Graphic3d_HorizontalTextAlignment HorizontalAlignment() const { return myHAlign; }
|
||||
|
||||
//! Sets horizontal alignment of text.
|
||||
void SetHorizontalAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
|
||||
|
||||
//! Returns vertical alignment of text.
|
||||
Graphic3d_VerticalTextAlignment VerticalAlignment() const { return myVAlign; }
|
||||
|
||||
//! Sets vertical alignment of text.
|
||||
void SetVerticalAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
|
||||
|
||||
protected:
|
||||
NCollection_String myText; //!< text value
|
||||
gp_Ax2 myOrientation; //!< Text orientation in 3D space.
|
||||
|
||||
Standard_ShortReal myHeight; //!< height of text
|
||||
Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
|
||||
Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
|
||||
|
||||
Standard_Boolean myHasPlane; //!< Check if text have orientation in 3D space.
|
||||
Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_Text_HeaderFile
|
@@ -40,6 +40,8 @@ enum Graphic3d_TextureUnit
|
||||
//Graphic3d_TextureUnit_MetallicRoughness = Graphic3d_TextureUnit_2, //!< metalness+roughness of the material
|
||||
//Graphic3d_TextureUnit_Emissive = Graphic3d_TextureUnit_3, //!< emissive map controls the color and intensity of the light being emitted by the material
|
||||
//Graphic3d_TextureUnit_Occlusion = Graphic3d_TextureUnit_4, //!< occlusion map indicating areas of indirect lighting
|
||||
|
||||
Graphic3d_TextureUnit_EnvMap = Graphic3d_TextureUnit_0 //!< environment cubemap for background
|
||||
};
|
||||
enum
|
||||
{
|
||||
|
@@ -20,9 +20,15 @@
|
||||
//! Describes type of view background.
|
||||
enum Graphic3d_TypeOfBackground
|
||||
{
|
||||
Graphic3d_TOB_NONE,
|
||||
Graphic3d_TOB_NONE = -1,
|
||||
Graphic3d_TOB_GRADIENT,
|
||||
Graphic3d_TOB_TEXTURE
|
||||
Graphic3d_TOB_TEXTURE,
|
||||
Graphic3d_TOB_CUBEMAP
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Graphic3d_TypeOfBackground_NB = Graphic3d_TOB_CUBEMAP + 1
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TypeOfBackground_HeaderFile
|
||||
|
@@ -22,7 +22,8 @@ enum Graphic3d_TypeOfTexture
|
||||
{
|
||||
Graphic3d_TOT_1D,
|
||||
Graphic3d_TOT_2D,
|
||||
Graphic3d_TOT_2D_MIPMAP
|
||||
Graphic3d_TOT_2D_MIPMAP,
|
||||
Graphic3d_TOT_CUBEMAP
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TypeOfTexture_HeaderFile
|
||||
|
@@ -42,7 +42,7 @@
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
//
|
||||
static void ComputeSamplePars(const Handle(Adaptor3d_HSurface)& Hsurface,
|
||||
const Standard_Integer nbsu,
|
||||
@@ -259,16 +259,12 @@ void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
|
||||
for(; anExp.More(); anExp.Next())
|
||||
{
|
||||
TopoDS_Edge anE = TopoDS::Edge(anExp.Current());
|
||||
Standard_Real curtol = BRep_Tool::Tolerance(anE);
|
||||
Standard_Real tol2d = Max(Hsurface->UResolution(curtol), Hsurface->VResolution(curtol));
|
||||
tol2d = Max(tol2d, Tol);
|
||||
Standard_Real f, l;
|
||||
Handle(Geom2d_Curve) aPC = BRep_Tool::CurveOnSurface(anE, face, f, l);
|
||||
Geom2dAPI_ProjectPointOnCurve aProj(Puv, aPC, f, l);
|
||||
if(aProj.NbPoints() > 0)
|
||||
Handle(Geom_Curve) aPC = BRep_Tool::Curve (anE, f, l);
|
||||
GeomAPI_ProjectPointOnCurve aProj (HICSPointindex.Pnt(), aPC, f, l);
|
||||
if (aProj.NbPoints() > 0)
|
||||
{
|
||||
Standard_Real d = aProj.LowerDistance();
|
||||
if(d <= tol2d)
|
||||
if (aProj.LowerDistance() <= maxtol3d)
|
||||
{
|
||||
//Nearest edge is found, state is really ON
|
||||
currentstate = TopAbs_ON;
|
||||
|
@@ -837,141 +837,139 @@ void IntTools_EdgeEdge::FindBestSolution(const Standard_Real aT11,
|
||||
//=======================================================================
|
||||
void IntTools_EdgeEdge::ComputeLineLine()
|
||||
{
|
||||
Standard_Boolean IsParallel, IsCoincide;
|
||||
Standard_Real aSin, aCos, aAng, aTol;
|
||||
Standard_Real aT1, aT2, aT11, aT12, aT21, aT22;
|
||||
gp_Pnt aP11, aP12;
|
||||
gp_Lin aL1, aL2;
|
||||
gp_Dir aD1, aD2;
|
||||
IntTools_CommonPrt aCommonPrt;
|
||||
//
|
||||
IsParallel = Standard_False;
|
||||
IsCoincide = Standard_False;
|
||||
aTol = myTol*myTol;
|
||||
aL1 = myCurve1.Line();
|
||||
aL2 = myCurve2.Line();
|
||||
aD1 = aL1.Position().Direction();
|
||||
aD2 = aL2.Position().Direction();
|
||||
myRange1.Range(aT11, aT12);
|
||||
myRange2.Range(aT21, aT22);
|
||||
//
|
||||
aCommonPrt.SetEdge1(myEdge1);
|
||||
aCommonPrt.SetEdge2(myEdge2);
|
||||
//
|
||||
aCos = aD1.Dot(aD2);
|
||||
aAng = (aCos >= 0.) ? 2.*(1. - aCos) : 2.*(1. + aCos);
|
||||
//
|
||||
if(aAng <= Precision::Angular()) {
|
||||
IsParallel = Standard_True;
|
||||
if(aL1.SquareDistance(aL2.Location()) <= aTol) {
|
||||
IsCoincide = Standard_True;
|
||||
aP11 = ElCLib::Value(aT11, aL1);
|
||||
aP12 = ElCLib::Value(aT12, aL1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aP11 = ElCLib::Value(aT11, aL1);
|
||||
aP12 = ElCLib::Value(aT12, aL1);
|
||||
if(aL2.SquareDistance(aP11) <= aTol && aL2.SquareDistance(aP12) <= aTol) {
|
||||
IsCoincide = Standard_True;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (IsCoincide) {
|
||||
Standard_Real t21, t22;
|
||||
//
|
||||
t21 = ElCLib::Parameter(aL2, aP11);
|
||||
t22 = ElCLib::Parameter(aL2, aP12);
|
||||
if((t21 > aT22 && t22 > aT22) || (t21 < aT21 && t22 < aT21)) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
Standard_Real temp;
|
||||
if(t21 > t22) {
|
||||
temp = t21;
|
||||
t21 = t22;
|
||||
t22 = temp;
|
||||
}
|
||||
//
|
||||
if(t21 >= aT21) {
|
||||
if(t22 <= aT22) {
|
||||
aCommonPrt.SetRange1(aT11, aT12);
|
||||
aCommonPrt.SetAllNullFlag(Standard_True);
|
||||
aCommonPrt.AppendRange2(t21, t22);
|
||||
}
|
||||
else {
|
||||
aCommonPrt.SetRange1(aT11, aT12 - (t22 - aT22));
|
||||
aCommonPrt.AppendRange2(t21, aT22);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aCommonPrt.SetRange1(aT11 + (aT21 - t21), aT12);
|
||||
aCommonPrt.AppendRange2(aT21, t22);
|
||||
}
|
||||
aCommonPrt.SetType(TopAbs_EDGE);
|
||||
myCommonParts.Append(aCommonPrt);
|
||||
return;
|
||||
}
|
||||
//
|
||||
if (IsParallel) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
Standard_Real aTol = myTol * myTol;
|
||||
|
||||
gp_Lin aL1 = myCurve1.Line();
|
||||
gp_Lin aL2 = myCurve2.Line();
|
||||
|
||||
gp_Dir aD1 = aL1.Direction();
|
||||
gp_Dir aD2 = aL2.Direction();
|
||||
|
||||
Standard_Real anAngle = aD1.Angle (aD2);
|
||||
Standard_Boolean IsCoincide = anAngle < Precision::Angular();
|
||||
if (IsCoincide)
|
||||
{
|
||||
TopoDS_Iterator aIt1, aIt2;
|
||||
aIt1.Initialize(myEdge1);
|
||||
for (; aIt1.More(); aIt1.Next()) {
|
||||
const TopoDS_Shape& aV1 = aIt1.Value();
|
||||
aIt2.Initialize(myEdge2);
|
||||
for (; aIt2.More(); aIt2.Next()) {
|
||||
const TopoDS_Shape& aV2 = aIt2.Value();
|
||||
if (aV2.IsSame(aV1)) {
|
||||
if (aL1.SquareDistance (aL2.Location()) > aTol)
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Real aT11, aT12, aT21, aT22;
|
||||
myRange1.Range (aT11, aT12);
|
||||
myRange2.Range (aT21, aT22);
|
||||
|
||||
gp_Pnt aP11 = ElCLib::Value (aT11, aL1);
|
||||
gp_Pnt aP12 = ElCLib::Value (aT12, aL1);
|
||||
|
||||
if (!IsCoincide)
|
||||
{
|
||||
gp_Pnt O2 (aL2.Location());
|
||||
if (!Precision::IsInfinite (aT21) && !Precision::IsInfinite (aT22))
|
||||
O2 = ElCLib::Value ((aT21 + aT22) / 2., aL2);
|
||||
|
||||
gp_Vec aVec1 = gp_Vec (O2, aP11).Crossed (aD2);
|
||||
gp_Vec aVec2 = gp_Vec (O2, aP12).Crossed (aD2);
|
||||
|
||||
Standard_Real aSqDist1 = aVec1.SquareMagnitude();
|
||||
Standard_Real aSqDist2 = aVec2.SquareMagnitude();
|
||||
|
||||
IsCoincide = (aSqDist1 <= aTol && aSqDist2 <= aTol);
|
||||
|
||||
if (!IsCoincide && aVec1.Dot (aVec2) > 0)
|
||||
// the lines do not intersect
|
||||
return;
|
||||
}
|
||||
|
||||
IntTools_CommonPrt aCommonPrt;
|
||||
aCommonPrt.SetEdge1 (myEdge1);
|
||||
aCommonPrt.SetEdge2 (myEdge2);
|
||||
|
||||
if (IsCoincide)
|
||||
{
|
||||
Standard_Real t21 = ElCLib::Parameter (aL2, aP11);
|
||||
Standard_Real t22 = ElCLib::Parameter (aL2, aP12);
|
||||
|
||||
if ((t21 > aT22 && t22 > aT22) || (t21 < aT21 && t22 < aT21))
|
||||
// projections are out of range
|
||||
return;
|
||||
|
||||
if (t21 > t22)
|
||||
std::swap (t21, t22);
|
||||
|
||||
if (t21 >= aT21)
|
||||
{
|
||||
if (t22 <= aT22)
|
||||
{
|
||||
aCommonPrt.SetRange1 (aT11, aT12);
|
||||
aCommonPrt.SetAllNullFlag (Standard_True);
|
||||
aCommonPrt.AppendRange2 (t21, t22);
|
||||
}
|
||||
else
|
||||
{
|
||||
aCommonPrt.SetRange1 (aT11, aT12 - (t22 - aT22));
|
||||
aCommonPrt.AppendRange2 (t21, aT22);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aCommonPrt.SetRange1 (aT11 + (aT21 - t21), aT12);
|
||||
aCommonPrt.AppendRange2 (aT21, t22);
|
||||
}
|
||||
aCommonPrt.SetType (TopAbs_EDGE);
|
||||
myCommonParts.Append (aCommonPrt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gp_Vec O1O2 (aL1.Location(), aL2.Location());
|
||||
gp_XYZ aCross = aD1.XYZ().Crossed (aD2.XYZ());
|
||||
Standard_Real aDistLL = O1O2.Dot (gp_Vec (aCross.Normalized()));
|
||||
if (Abs (aDistLL) > myTol)
|
||||
return;
|
||||
|
||||
{
|
||||
// Fast check that no intersection needs to be added
|
||||
for (TopoDS_Iterator it1 (myEdge1); it1.More(); it1.Next())
|
||||
{
|
||||
for (TopoDS_Iterator it2 (myEdge2); it2.More(); it2.Next())
|
||||
{
|
||||
if (it1.Value().IsSame (it2.Value()))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
aSin = 1. - aCos*aCos;
|
||||
gp_Pnt O1 = aL1.Location();
|
||||
gp_Pnt O2 = aL2.Location();
|
||||
gp_Vec O1O2 (O1, O2);
|
||||
//
|
||||
aT2 = (aD1.XYZ()*(O1O2.Dot(aD1))-(O1O2.XYZ())).Dot(aD2.XYZ());
|
||||
aT2 /= aSin;
|
||||
//
|
||||
if(aT2 < aT21 || aT2 > aT22) {
|
||||
|
||||
Standard_Real aSqSin = aCross.SquareModulus();
|
||||
Standard_Real aT2 = (aD1.XYZ() * (O1O2.Dot (aD1)) - (O1O2.XYZ())).Dot (aD2.XYZ());
|
||||
aT2 /= aSqSin;
|
||||
|
||||
if (aT2 < aT21 || aT2 > aT22)
|
||||
// out of range
|
||||
return;
|
||||
}
|
||||
//
|
||||
gp_Pnt aP2(ElCLib::Value(aT2, aL2));
|
||||
aT1 = (gp_Vec(O1, aP2)).Dot(aD1);
|
||||
//
|
||||
if(aT1 < aT11 || aT1 > aT12) {
|
||||
|
||||
gp_Pnt aP2 = ElCLib::Value (aT2, aL2);
|
||||
Standard_Real aT1 = gp_Vec (aL1.Location(), aP2).Dot (aD1);
|
||||
|
||||
if (aT1 < aT11 || aT1 > aT12)
|
||||
// out of range
|
||||
return;
|
||||
}
|
||||
//
|
||||
gp_Pnt aP1(ElCLib::Value(aT1, aL1));
|
||||
Standard_Real aDist = aP1.SquareDistance(aP2);
|
||||
//
|
||||
if (aDist > aTol) {
|
||||
|
||||
gp_Pnt aP1 = ElCLib::Value (aT1, aL1);
|
||||
Standard_Real aDist = aP1.SquareDistance (aP2);
|
||||
|
||||
if (aDist > aTol)
|
||||
// no intersection
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
||||
// compute correct range on the edges
|
||||
Standard_Real anAngle, aDt1, aDt2;
|
||||
//
|
||||
anAngle = aD1.Angle(aD2);
|
||||
//
|
||||
aDt1 = IntTools_Tools::ComputeIntRange(myTol1, myTol2, anAngle);
|
||||
aDt2 = IntTools_Tools::ComputeIntRange(myTol2, myTol1, anAngle);
|
||||
//
|
||||
aCommonPrt.SetRange1(aT1 - aDt1, aT1 + aDt1);
|
||||
aCommonPrt.AppendRange2(aT2 - aDt2, aT2 + aDt2);
|
||||
aCommonPrt.SetType(TopAbs_VERTEX);
|
||||
aCommonPrt.SetVertexParameter1(aT1);
|
||||
aCommonPrt.SetVertexParameter2(aT2);
|
||||
myCommonParts.Append(aCommonPrt);
|
||||
Standard_Real aDt1 = IntTools_Tools::ComputeIntRange (myTol1, myTol2, anAngle);
|
||||
Standard_Real aDt2 = IntTools_Tools::ComputeIntRange (myTol2, myTol1, anAngle);
|
||||
|
||||
aCommonPrt.SetRange1 (aT1 - aDt1, aT1 + aDt1);
|
||||
aCommonPrt.AppendRange2 (aT2 - aDt2, aT2 + aDt2);
|
||||
aCommonPrt.SetType (TopAbs_VERTEX);
|
||||
aCommonPrt.SetVertexParameter1 (aT1);
|
||||
aCommonPrt.SetVertexParameter2 (aT2);
|
||||
myCommonParts.Append (aCommonPrt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <Graphic3d_ArrayOfPoints.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
@@ -251,8 +252,11 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
||||
}
|
||||
|
||||
aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
|
||||
Graphic3d_Vertex aPoint (X, Y, Z);
|
||||
aTextGroup->Text (aStr.ToCString(), aPoint, aHeight);
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)aHeight);
|
||||
aText->SetText (aStr);
|
||||
aText->SetPosition (gp_Pnt (X, Y, Z));
|
||||
aTextGroup->AddText(aText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,16 @@
|
||||
// Created by: Kirill Gavrilov
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
// Copyright (c) 2017-2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of commercial software by OPEN CASCADE SAS.
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This software is furnished in accordance with the terms and conditions
|
||||
// of the contract and with the inclusion of this copyright notice.
|
||||
// This software or any other copy thereof may not be provided or otherwise
|
||||
// be made available to any third party.
|
||||
// No ownership title to the software is transferred hereby.
|
||||
// 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.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <OSD_ThreadPool.hxx>
|
||||
|
||||
|
@@ -1,17 +1,16 @@
|
||||
// Created by: Kirill Gavrilov
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
// Copyright (c) 2017-2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of commercial software by OPEN CASCADE SAS.
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This software is furnished in accordance with the terms and conditions
|
||||
// of the contract and with the inclusion of this copyright notice.
|
||||
// This software or any other copy thereof may not be provided or otherwise
|
||||
// be made available to any third party.
|
||||
// No ownership title to the software is transferred hereby.
|
||||
// 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.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _OSD_ThreadPool_HeaderFile
|
||||
#define _OSD_ThreadPool_HeaderFile
|
||||
|
@@ -43,7 +43,6 @@ OpenGl_Material.hxx
|
||||
OpenGl_MaterialState.hxx
|
||||
OpenGl_Matrix.hxx
|
||||
OpenGl_MatrixState.hxx
|
||||
OpenGl_TextParam.hxx
|
||||
OpenGl_LineAttributes.hxx
|
||||
OpenGl_LineAttributes.cxx
|
||||
OpenGl_Window.hxx
|
||||
|
@@ -206,12 +206,10 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
|
||||
&& aTexture->GetId() == aResource->ResourceId()
|
||||
&& aTexture->Revision() != aResource->Revision())
|
||||
{
|
||||
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
|
||||
if (aResource->Init(theCtx, aTexture))
|
||||
{
|
||||
aResource->Sampler()->SetParameters (aTexture->GetParams());
|
||||
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
|
||||
aResource->Sampler()->SetParameters(aTexture->GetParams());
|
||||
aResource->SetRevision (aTexture->Revision());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,9 +233,9 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
|
||||
|| !theCtx->GetResource<Handle(OpenGl_Texture)> (aTextureKeyNew, aResource))
|
||||
{
|
||||
aResource = new OpenGl_Texture (aTextureKeyNew, aTexture->GetParams());
|
||||
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
|
||||
|
||||
if (aResource->Init(theCtx, aTexture))
|
||||
{
|
||||
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
|
||||
aResource->SetRevision (aTexture->Revision());
|
||||
}
|
||||
if (!aTextureKeyNew.IsEmpty())
|
||||
@@ -249,9 +247,8 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
if (aTexture->Revision() != aResource->Revision())
|
||||
{
|
||||
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
|
||||
if (aResource->Init(theCtx, aTexture))
|
||||
{
|
||||
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
|
||||
aResource->SetRevision (aTexture->Revision());
|
||||
}
|
||||
}
|
||||
|
@@ -119,6 +119,7 @@ bool OpenGl_BackgroundArray::IsDefined() const
|
||||
{
|
||||
case Graphic3d_TOB_GRADIENT: return myGradientParams.type != Aspect_GFM_NONE;
|
||||
case Graphic3d_TOB_TEXTURE: return myFillMethod != Aspect_FM_NONE;
|
||||
case Graphic3d_TOB_CUBEMAP: return Standard_True;
|
||||
case Graphic3d_TOB_NONE: return Standard_False;
|
||||
}
|
||||
return Standard_False;
|
||||
@@ -157,6 +158,14 @@ Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& t
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOB_CUBEMAP:
|
||||
{
|
||||
if (!createCubeMapArray())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOB_NONE:
|
||||
default:
|
||||
{
|
||||
@@ -378,7 +387,33 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// method : createTextureArray
|
||||
// method : createCubeMapArray
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_BackgroundArray::createCubeMapArray() const
|
||||
{
|
||||
Graphic3d_Attribute aCubeMapAttribInfo[] =
|
||||
{
|
||||
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC2}
|
||||
};
|
||||
|
||||
if (!myAttribs->Init(4, aCubeMapAttribInfo, 1))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
OpenGl_Vec2* aData = reinterpret_cast<OpenGl_Vec2*>(myAttribs->changeValue(0));
|
||||
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
{
|
||||
aData[i] = (OpenGl_Vec2(Standard_ShortReal(i / 2), Standard_ShortReal(i % 2)) - OpenGl_Vec2(0.5f)) * 2.f;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// method : Render
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_BackgroundArray::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
@@ -402,8 +437,12 @@ void OpenGl_BackgroundArray::Render (const Handle(OpenGl_Workspace)& theWorkspac
|
||||
|
||||
OpenGl_Mat4 aProjection = aCtx->ProjectionState.Current();
|
||||
OpenGl_Mat4 aWorldView = aCtx->WorldViewState.Current();
|
||||
myTrsfPers.Apply (theWorkspace->View()->Camera(), aProjection, aWorldView,
|
||||
aCtx->Viewport()[2], aCtx->Viewport()[3]);
|
||||
|
||||
if (myType != Graphic3d_TOB_CUBEMAP)
|
||||
{
|
||||
myTrsfPers.Apply(theWorkspace->View()->Camera(), aProjection, aWorldView,
|
||||
aCtx->Viewport()[2], aCtx->Viewport()[3]);
|
||||
}
|
||||
|
||||
aCtx->ProjectionState.Push();
|
||||
aCtx->WorldViewState.Push();
|
||||
|
@@ -85,6 +85,9 @@ protected:
|
||||
//! @param theWorkspace OpenGl workspace that stores texture in the current enabled face aspect.
|
||||
Standard_EXPORT Standard_Boolean createTextureArray (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
|
||||
//! Initializes cubemap arrays.
|
||||
Standard_EXPORT Standard_Boolean createCubeMapArray() const;
|
||||
|
||||
//! Marks array parameters as changed,
|
||||
//! on next rendering stage array data is to be updated.
|
||||
Standard_EXPORT void invalidateData();
|
||||
|
@@ -21,16 +21,11 @@
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
#include <OpenGl_CappingPlaneResource.hxx>
|
||||
#include <OpenGl_Vec.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static const OpenGl_CappingPlaneResource THE_DEFAULT_ASPECT = OpenGl_CappingPlaneResource (new Graphic3d_AspectFillCapping);
|
||||
static const TCollection_AsciiString THE_QUAD_PARRAY = "OpenGl_CappingAlgo_Quad";
|
||||
static const TCollection_AsciiString THE_PLANE_STYLE = "OpenGl_CappingAlgo_CappingStyle_";
|
||||
|
||||
//! Auxiliary sentry object managing stencil test.
|
||||
struct StencilTestSentry
|
||||
{
|
||||
@@ -63,113 +58,21 @@ namespace
|
||||
GLint myDepthFuncPrev;
|
||||
};
|
||||
|
||||
class OpenGl_SharedElement : public OpenGl_Resource
|
||||
{
|
||||
public:
|
||||
OpenGl_SharedElement (OpenGl_Element* theGlElement) : myGlElement (theGlElement) {}
|
||||
virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE
|
||||
{
|
||||
OpenGl_Element::Destroy (theGlCtx, myGlElement);
|
||||
}
|
||||
OpenGl_Element* GlElement() const { return myGlElement; }
|
||||
|
||||
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
|
||||
Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
private:
|
||||
OpenGl_Element* myGlElement;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE (OpenGl_SharedElement, OpenGl_Resource)
|
||||
};
|
||||
|
||||
//! Iitializes and returns vertex buffer for plane section
|
||||
OpenGl_PrimitiveArray* initQuad (const Handle(OpenGl_Context)& theContext)
|
||||
{
|
||||
Handle(OpenGl_SharedElement) aSharedResource;
|
||||
|
||||
if (!theContext->GetResource (THE_QUAD_PARRAY, aSharedResource))
|
||||
{
|
||||
aSharedResource = new OpenGl_SharedElement (OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices());
|
||||
theContext->ShareResource (THE_QUAD_PARRAY, aSharedResource);
|
||||
}
|
||||
|
||||
return dynamic_cast<OpenGl_PrimitiveArray*> (aSharedResource->GlElement());
|
||||
}
|
||||
|
||||
//! Render section plane using the given aspects.
|
||||
void renderSection (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const OpenGl_PrimitiveArray* theQuad,
|
||||
const OpenGl_Aspects* theCappingAspect,
|
||||
const OpenGl_Aspects* theHatchAspect,
|
||||
const OpenGl_Mat4& theCappingMatrix,
|
||||
const Standard_ShortReal theHatchScale,
|
||||
const Standard_ShortReal theHatchRotate)
|
||||
//! Render infinite capping plane.
|
||||
//! @param theWorkspace [in] the GL workspace, context state.
|
||||
//! @param thePlane [in] the graphical plane, for which the capping surface is rendered.
|
||||
static void renderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane)
|
||||
{
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
const bool wasCullAllowed = theWorkspace->SetAllowFaceCulling (true);
|
||||
|
||||
const Standard_Boolean isTextureHatch =
|
||||
theHatchAspect != NULL
|
||||
&& theHatchAspect->Aspect()->TextureMapState();
|
||||
|
||||
// set identity model matrix
|
||||
aContext->ModelWorldState.Push();
|
||||
aContext->ModelWorldState.SetCurrent (theCappingMatrix);
|
||||
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
theWorkspace->SetAspects (theCappingAspect);
|
||||
theWorkspace->ApplyAspects();
|
||||
|
||||
theQuad->Render (theWorkspace);
|
||||
|
||||
if (theHatchAspect != NULL)
|
||||
{
|
||||
Graphic3d_Vec2 aPrevScale;
|
||||
Standard_ShortReal aPrevRotate = 0.0;
|
||||
|
||||
if (isTextureHatch)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if ((theHatchScale != 1.0 || theHatchRotate != 0.0) && !theHatchAspect->TextureSet(aContext)->IsEmpty())
|
||||
{
|
||||
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
|
||||
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
|
||||
|
||||
aPrevScale = aTexParams->Scale();
|
||||
aPrevRotate = aTexParams->Rotation();
|
||||
|
||||
const Standard_Boolean isMirror = aPrevScale.x() * aPrevScale.y() < 0.0;
|
||||
aTexParams->SetScale (aPrevScale * theHatchScale);
|
||||
aTexParams->SetRotation (isMirror ? aPrevRotate - theHatchRotate : aPrevRotate + theHatchRotate);
|
||||
}
|
||||
}
|
||||
|
||||
theWorkspace->SetAspects (theHatchAspect);
|
||||
theWorkspace->ApplyAspects();
|
||||
|
||||
glDepthFunc (GL_LEQUAL);
|
||||
|
||||
theQuad->Render (theWorkspace);
|
||||
|
||||
glDepthFunc (GL_LESS);
|
||||
|
||||
if (isTextureHatch)
|
||||
{
|
||||
glDisable (GL_BLEND);
|
||||
|
||||
if (theHatchScale != 1.0 || theHatchRotate != 0.0)
|
||||
{
|
||||
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
|
||||
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
|
||||
|
||||
aTexParams->SetScale (aPrevScale);
|
||||
aTexParams->SetRotation (aPrevRotate);
|
||||
}
|
||||
}
|
||||
}
|
||||
thePlane->Primitives().Render (theWorkspace);
|
||||
|
||||
aContext->ModelWorldState.Pop();
|
||||
aContext->ApplyModelViewMatrix();
|
||||
@@ -183,23 +86,13 @@ namespace
|
||||
const OpenGl_Structure& theStructure,
|
||||
const Handle(Graphic3d_ClipPlane)& theClipChain,
|
||||
const Standard_Integer theSubPlaneIndex,
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane,
|
||||
const OpenGl_PrimitiveArray* theQuad)
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane)
|
||||
{
|
||||
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
|
||||
const Standard_Integer anAnyFilter = aPrevFilter & ~(Standard_Integer )(OpenGl_RenderFilter_OpaqueOnly | OpenGl_RenderFilter_TransparentOnly);
|
||||
|
||||
const Handle(Graphic3d_ClipPlane)& aPlane = theClipChain;
|
||||
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
const Handle(Graphic3d_Camera) aCamera = theWorkspace->View() != NULL
|
||||
? theWorkspace->View()->Camera()
|
||||
: Handle(Graphic3d_Camera)();
|
||||
const OpenGl_Mat4& aPlaneMat = OpenGl_Mat4::Map (aPlane->OrientationMatrix());
|
||||
Standard_ShortReal aRotateAngle = 0.0;
|
||||
Standard_ShortReal aViewScale = ShortRealLast();
|
||||
OpenGl_Mat4 aRotateZoomMat;
|
||||
|
||||
const Handle(Graphic3d_ClipPlane)& aRenderPlane = thePlane->Plane();
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
if (!aGroupIter.Value()->IsClosed())
|
||||
@@ -210,6 +103,16 @@ namespace
|
||||
// clear stencil only if something has been actually drawn
|
||||
theStencilSentry.Init();
|
||||
|
||||
// check if capping plane should be rendered within current pass (only opaque / only transparent)
|
||||
const OpenGl_Aspects* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->GlAspects() : NULL;
|
||||
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_Aspects)());
|
||||
theWorkspace->SetAspects (thePlane->AspectFace());
|
||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// suppress only opaque/transparent filter since for filling stencil the whole geometry should be drawn
|
||||
theWorkspace->SetRenderFilter (anAnyFilter);
|
||||
|
||||
@@ -218,7 +121,7 @@ namespace
|
||||
aContext->ShaderManager()->UpdateClippingState();
|
||||
|
||||
glClear (GL_STENCIL_BUFFER_BIT);
|
||||
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
const bool aColorMaskBack = aContext->SetColorMask (false);
|
||||
|
||||
// override aspects, disable culling
|
||||
theWorkspace->SetAspects (&theWorkspace->NoneCulling());
|
||||
@@ -237,7 +140,20 @@ namespace
|
||||
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
|
||||
|
||||
// render closed primitives
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
if (aRenderPlane->ToUseObjectProperties())
|
||||
{
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
if (aGroupIter.Value()->IsClosed())
|
||||
{
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// override material, cull back faces
|
||||
theWorkspace->SetAspects (&theWorkspace->FrontCulling());
|
||||
@@ -248,7 +164,7 @@ namespace
|
||||
aContext->ShaderManager()->UpdateClippingState();
|
||||
|
||||
// render capping plane using the generated stencil mask
|
||||
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
aContext->SetColorMask (aColorMaskBack);
|
||||
if (theWorkspace->UseDepthWrite())
|
||||
{
|
||||
glDepthMask (GL_TRUE);
|
||||
@@ -260,66 +176,8 @@ namespace
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
const OpenGl_Aspects* aGroupAspectFace = aGroupIter.Value()->GlAspects();
|
||||
const OpenGl_CappingPlaneResource* aGroupAspectCapping = aGroupIter.Value()->AspectFillCapping();
|
||||
const OpenGl_CappingPlaneResource* anAspectCapping =
|
||||
thePlane && (!aGroupAspectCapping || aGroupAspectCapping->Aspect().IsNull() || aPlane->ToOverrideCappingAspect())
|
||||
? thePlane.get()
|
||||
: aGroupAspectCapping;
|
||||
|
||||
if (anAspectCapping == NULL)
|
||||
{
|
||||
anAspectCapping = &THE_DEFAULT_ASPECT;
|
||||
}
|
||||
|
||||
const OpenGl_Aspects* anAspectFace = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
|
||||
const Standard_Boolean hasHatch = anAspectCapping->Aspect()->ToDrawHatch();
|
||||
const OpenGl_Aspects* anAspectHatching = hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL;
|
||||
const Standard_Boolean hasTextureHatch = hasHatch && !anAspectCapping->Aspect()->TextureHatch().IsNull();
|
||||
const Standard_Boolean isRotatePers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchRotationPersistent();
|
||||
const Standard_Boolean isZoomPers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchZoomPersistent();
|
||||
|
||||
Standard_ShortReal aHatchScale = 1.0;
|
||||
Standard_ShortReal aHatchAngle = 0.0;
|
||||
|
||||
if (isRotatePers || isZoomPers)
|
||||
{
|
||||
|
||||
if (isRotatePers)
|
||||
{
|
||||
if (aRotateAngle == 0.0)
|
||||
{
|
||||
const gp_Dir aPlaneSide (aPlaneMat.GetValue (0, 0), aPlaneMat.GetValue (1, 0), aPlaneMat.GetValue (2, 0));
|
||||
const gp_Dir aPlaneUp (aPlaneMat.GetValue (0, 2), aPlaneMat.GetValue (1, 2), aPlaneMat.GetValue (2, 2));
|
||||
const gp_Dir& aCameraUp = aCamera->Up();
|
||||
const gp_Vec aCameraPln = aPlaneSide.Dot (aCameraUp) * aPlaneSide + aPlaneUp.Dot (aCameraUp) * aPlaneUp;
|
||||
const gp_Dir& aCameraDir = aCamera->Direction();
|
||||
aRotateAngle = static_cast<Standard_ShortReal> (aCameraPln.AngleWithRef (aPlaneUp, aCameraDir) / M_PI * 180.0);
|
||||
}
|
||||
|
||||
aHatchAngle = aRotateAngle;
|
||||
}
|
||||
|
||||
if (isZoomPers)
|
||||
{
|
||||
if (aViewScale == ShortRealLast())
|
||||
{
|
||||
const Standard_Real aFocus = aCamera->IsOrthographic()
|
||||
? aCamera->Distance()
|
||||
: (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
|
||||
? Standard_Real(aCamera->ZFocus() * aCamera->Distance())
|
||||
: Standard_Real(aCamera->ZFocus()));
|
||||
|
||||
const gp_XYZ aViewDim = aCamera->ViewDimensions (aFocus);
|
||||
aViewScale = static_cast<Standard_ShortReal> (aViewDim.Y() / aContext->Viewport()[3]);
|
||||
}
|
||||
|
||||
if (!anAspectHatching->TextureSet(aContext)->IsEmpty())
|
||||
aHatchScale = 1.0f / (aViewScale * anAspectHatching->TextureSet(aContext)->First()->SizeY());
|
||||
}
|
||||
}
|
||||
|
||||
renderSection (theWorkspace, theQuad, anAspectFace, hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL, aPlaneMat, aHatchScale, aHatchAngle);
|
||||
theWorkspace->SetAspects (thePlane->AspectFace());
|
||||
renderPlane (theWorkspace, thePlane);
|
||||
|
||||
// turn on the current plane to restore initial state
|
||||
aContext->ChangeClipping().ResetCappingFilter();
|
||||
@@ -329,7 +187,7 @@ namespace
|
||||
|
||||
if (theStructure.InstancedStructure() != NULL)
|
||||
{
|
||||
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane, theQuad);
|
||||
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,12 +206,6 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
return;
|
||||
}
|
||||
|
||||
const OpenGl_PrimitiveArray* aCappingQuad = initQuad (aContext);
|
||||
if (!aCappingQuad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// remember current aspect face defined in workspace
|
||||
const OpenGl_Aspects* aFaceAsp = theWorkspace->Aspects();
|
||||
|
||||
@@ -362,16 +214,6 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
theWorkspace->SetRenderFilter (aPrevFilter | OpenGl_RenderFilter_FillModeOnly);
|
||||
StencilTestSentry aStencilSentry;
|
||||
|
||||
GLboolean aPrevBlend = glIsEnabled (GL_BLEND);
|
||||
GLint aPrevBlendSrc = GL_ONE;
|
||||
GLint aPrevBlendDst = GL_ZERO;
|
||||
if (aPrevBlend == GL_TRUE)
|
||||
{
|
||||
glGetIntegerv (GL_BLEND_SRC_ALPHA, &aPrevBlendSrc);
|
||||
glGetIntegerv (GL_BLEND_DST_ALPHA, &aPrevBlendDst);
|
||||
glDisable (GL_BLEND);
|
||||
}
|
||||
|
||||
// generate capping for every clip plane
|
||||
for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next())
|
||||
{
|
||||
@@ -387,33 +229,23 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipChain.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get(), ++aSubPlaneIndex)
|
||||
{
|
||||
// get resource for the plane
|
||||
const TCollection_AsciiString& aResId = THE_PLANE_STYLE + aSubPlaneIter->GetId();
|
||||
const TCollection_AsciiString& aResId = aSubPlaneIter->GetId();
|
||||
Handle(OpenGl_CappingPlaneResource) aPlaneRes;
|
||||
if (!aContext->GetResource (aResId, aPlaneRes))
|
||||
{
|
||||
// share and register for release once the resource is no longer used
|
||||
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter->CappingSectionStyle());
|
||||
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter);
|
||||
aContext->ShareResource (aResId, aPlaneRes);
|
||||
}
|
||||
|
||||
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes, aCappingQuad);
|
||||
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes);
|
||||
|
||||
// set delayed resource release
|
||||
aPlaneRes.Nullify();
|
||||
if (!aResId.IsEmpty())
|
||||
{
|
||||
// schedule release of resource if not used
|
||||
aContext->ReleaseResource (aResId, Standard_True);
|
||||
}
|
||||
aContext->ReleaseResource (aResId, Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
if (aPrevBlend == GL_TRUE)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (aPrevBlendSrc, aPrevBlendDst);
|
||||
}
|
||||
|
||||
// restore rendering aspects
|
||||
theWorkspace->SetAspects (aFaceAsp);
|
||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||
|
@@ -56,28 +56,21 @@ namespace
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f } }
|
||||
};
|
||||
|
||||
Handle(Graphic3d_Aspects) defaultMaterial()
|
||||
{
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect;
|
||||
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
|
||||
anAspect = new Graphic3d_AspectFillArea3d();
|
||||
anAspect->SetDistinguishOff();
|
||||
anAspect->SetFrontMaterial (aMaterial);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetInteriorColor (aMaterial.Color());
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
return anAspect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : BuildInfinitPlaneVertices
|
||||
// function : OpenGl_CappingPlaneResource
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
|
||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||
: myPrimitives (NULL),
|
||||
myOrientation (OpenGl_IdentityMatrix),
|
||||
myAspect (NULL),
|
||||
myPlaneRoot (thePlane),
|
||||
myEquationMod ((unsigned int )-1),
|
||||
myAspectMod ((unsigned int )-1)
|
||||
{
|
||||
OpenGl_PrimitiveArray* aPrimitives = NULL;
|
||||
// Fill primitive array
|
||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
|
||||
@@ -90,26 +83,8 @@ OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
|
||||
if (anAttribs->Init (12, anAttribInfo, 3))
|
||||
{
|
||||
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
|
||||
|
||||
aPrimitives = new OpenGl_PrimitiveArray (NULL);
|
||||
aPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
}
|
||||
return aPrimitives;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_CappingPlaneResource
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect)
|
||||
: myCappingAspect(),//defaultMaterial()),
|
||||
myHatchingAspect(),//defaultMaterial()),
|
||||
myHatchingState (0)
|
||||
{
|
||||
myCappingAspect.SetAspect (defaultMaterial());
|
||||
myHatchingAspect.SetAspect (defaultMaterial());
|
||||
|
||||
SetAspect (theAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -118,83 +93,18 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
|
||||
{
|
||||
Release (NULL);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAspect
|
||||
// function : Update
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
|
||||
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_Aspects)& theObjAspect)
|
||||
{
|
||||
myAspect = theAspect;
|
||||
|
||||
if (theAspect.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectMaterial()
|
||||
|| !theAspect->ToUseObjectTexture()
|
||||
|| !theAspect->ToUseObjectShader())
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myCappingAspect.Aspect();
|
||||
|
||||
if (!theAspect->ToUseObjectMaterial())
|
||||
{
|
||||
aFillAspect->SetFrontMaterial (theAspect->Material());
|
||||
aFillAspect->SetInteriorColor (theAspect->Material().Color());
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectTexture())
|
||||
{
|
||||
aFillAspect->SetTextureMap (theAspect->Texture());
|
||||
|
||||
if (!theAspect->Texture().IsNull())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMap (Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectShader())
|
||||
{
|
||||
aFillAspect->SetShaderProgram (theAspect->Shader());
|
||||
}
|
||||
|
||||
myCappingAspect.SetAspect (aFillAspect);
|
||||
}
|
||||
|
||||
if (theAspect->ToDrawHatch()
|
||||
&& (theAspect->IsTextureHatch()
|
||||
|| theAspect->IsStippleHatch()))
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myHatchingAspect.Aspect();
|
||||
|
||||
aFillAspect->SetInteriorStyle (theAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
|
||||
aFillAspect->SetHatchStyle (theAspect->IsStippleHatch() ? theAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
|
||||
aFillAspect->SetTextureMap (theAspect->IsTextureHatch() ? theAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetFrontMaterial (theAspect->HatchMaterial());
|
||||
aFillAspect->SetInteriorColor (theAspect->HatchMaterial().Color());
|
||||
if (theAspect->IsTextureHatch())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
|
||||
myHatchingAspect.SetAspect (aFillAspect);
|
||||
myHatchingState = theAspect->HatchingState();
|
||||
}
|
||||
updateTransform (theCtx);
|
||||
updateAspect (theObjAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -203,109 +113,123 @@ void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCa
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
||||
{
|
||||
myCappingAspect .Release (theContext);
|
||||
myHatchingAspect.Release (theContext);
|
||||
OpenGl_Element::Destroy (theContext, myAspect);
|
||||
myPrimitives.Release (theContext);
|
||||
myEquationMod = (unsigned int )-1;
|
||||
myAspectMod = (unsigned int )-1;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : CappingFaceAspect
|
||||
// function : updateAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const OpenGl_Aspects* OpenGl_CappingPlaneResource::CappingFaceAspect (const OpenGl_Aspects* theObjectAspect) const
|
||||
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect)
|
||||
{
|
||||
if (myAspect.IsNull())
|
||||
if (myAspect == NULL)
|
||||
{
|
||||
return NULL;
|
||||
myAspect = new OpenGl_Aspects();
|
||||
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myCappingAspect.Aspect();
|
||||
if (theObjAspect.IsNull())
|
||||
{
|
||||
if (myAspectMod != myPlaneRoot->MCountAspect())
|
||||
{
|
||||
myAspect->SetAspect (myPlaneRoot->CappingAspect());
|
||||
myAspectMod = myPlaneRoot->MCountAspect();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspect->ToUseObjectMaterial() && theObjectAspect != NULL)
|
||||
if (myFillAreaAspect.IsNull())
|
||||
{
|
||||
myFillAreaAspect = new Graphic3d_AspectFillArea3d();
|
||||
}
|
||||
if (myAspectMod != myPlaneRoot->MCountAspect())
|
||||
{
|
||||
*myFillAreaAspect = *myPlaneRoot->CappingAspect();
|
||||
}
|
||||
|
||||
if (myPlaneRoot->ToUseObjectMaterial())
|
||||
{
|
||||
// only front material currently supported by capping rendering
|
||||
aFillAspect->SetFrontMaterial (theObjectAspect->Aspect()->FrontMaterial());
|
||||
aFillAspect->SetInteriorColor (theObjectAspect->Aspect()->InteriorColor());
|
||||
myFillAreaAspect->SetFrontMaterial (theObjAspect->FrontMaterial());
|
||||
myFillAreaAspect->SetInteriorColor (theObjAspect->InteriorColor());
|
||||
}
|
||||
else
|
||||
if (myPlaneRoot->ToUseObjectTexture())
|
||||
{
|
||||
aFillAspect->SetFrontMaterial (myAspect->Material());
|
||||
aFillAspect->SetInteriorColor (myAspect->Material().Color());
|
||||
}
|
||||
|
||||
if (myAspect->ToUseObjectTexture() && theObjectAspect != NULL)
|
||||
{
|
||||
if (theObjectAspect->Aspect()->ToMapTexture())
|
||||
myFillAreaAspect->SetTextureSet (theObjAspect->TextureSet());
|
||||
if (theObjAspect->ToMapTexture())
|
||||
{
|
||||
aFillAspect->SetTextureMap (theObjectAspect->Aspect()->TextureMap());
|
||||
aFillAspect->SetTextureMapOn();
|
||||
myFillAreaAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
myFillAreaAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
else
|
||||
if (myPlaneRoot->ToUseObjectShader())
|
||||
{
|
||||
aFillAspect->SetTextureMap (myAspect->Texture());
|
||||
if (!myAspect->Texture().IsNull())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
myFillAreaAspect->SetShaderProgram (theObjAspect->ShaderProgram());
|
||||
}
|
||||
|
||||
if (myAspect->ToUseObjectShader() && theObjectAspect != NULL)
|
||||
{
|
||||
aFillAspect->SetShaderProgram (theObjectAspect->Aspect()->ShaderProgram());
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetShaderProgram (myAspect->Shader());
|
||||
}
|
||||
|
||||
myCappingAspect.SetAspect (aFillAspect);
|
||||
|
||||
return &myCappingAspect;
|
||||
myAspect->SetAspect (myFillAreaAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HatchingFaceAspect
|
||||
// function : updateTransform
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const OpenGl_Aspects* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
|
||||
void OpenGl_CappingPlaneResource::updateTransform (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
if (myAspect.IsNull())
|
||||
if (myEquationMod == myPlaneRoot->MCountEquation()
|
||||
&& myLocalOrigin.IsEqual (theCtx->ShaderManager()->LocalOrigin(), gp::Resolution()))
|
||||
{
|
||||
return NULL;
|
||||
return; // nothing to update
|
||||
}
|
||||
|
||||
const Standard_Size aHatchingState = myAspect->HatchingState();
|
||||
if (myHatchingState != aHatchingState)
|
||||
{
|
||||
if (myAspect->ToDrawHatch())
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myHatchingAspect.Aspect();
|
||||
myEquationMod = myPlaneRoot->MCountEquation();
|
||||
myLocalOrigin = theCtx->ShaderManager()->LocalOrigin();
|
||||
|
||||
aFillAspect->SetInteriorStyle (myAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
|
||||
aFillAspect->SetHatchStyle (myAspect->IsStippleHatch() ? myAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
|
||||
aFillAspect->SetTextureMap (myAspect->IsTextureHatch() ? myAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetFrontMaterial (myAspect->HatchMaterial());
|
||||
aFillAspect->SetInteriorColor (myAspect->HatchMaterial().Color());
|
||||
if (myAspect->IsTextureHatch())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
myHatchingAspect.SetAspect (aFillAspect);
|
||||
myHatchingState = aHatchingState;
|
||||
}
|
||||
const Graphic3d_ClipPlane::Equation& anEq = myPlaneRoot->GetEquation();
|
||||
const Standard_Real anEqW = theCtx->ShaderManager()->LocalClippingPlaneW (*myPlaneRoot);
|
||||
|
||||
// re-evaluate infinite plane transformation matrix
|
||||
const Graphic3d_Vec3 aNorm (anEq.xyz());
|
||||
const Graphic3d_Vec3 T (anEq.xyz() * -anEqW);
|
||||
|
||||
// project plane normal onto OX to find left vector
|
||||
const Standard_ShortReal aProjLen = sqrt ((Standard_ShortReal)anEq.xz().SquareModulus());
|
||||
Graphic3d_Vec3 aLeft;
|
||||
if (aProjLen < ShortRealSmall())
|
||||
{
|
||||
aLeft[0] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
aLeft[0] = aNorm[2] / aProjLen;
|
||||
aLeft[2] = -aNorm[0] / aProjLen;
|
||||
}
|
||||
|
||||
return &myHatchingAspect;
|
||||
const Graphic3d_Vec3 F = Graphic3d_Vec3::Cross (-aLeft, aNorm);
|
||||
|
||||
myOrientation.mat[0][0] = aLeft[0];
|
||||
myOrientation.mat[0][1] = aLeft[1];
|
||||
myOrientation.mat[0][2] = aLeft[2];
|
||||
myOrientation.mat[0][3] = 0.0f;
|
||||
|
||||
myOrientation.mat[1][0] = aNorm[0];
|
||||
myOrientation.mat[1][1] = aNorm[1];
|
||||
myOrientation.mat[1][2] = aNorm[2];
|
||||
myOrientation.mat[1][3] = 0.0f;
|
||||
|
||||
myOrientation.mat[2][0] = F[0];
|
||||
myOrientation.mat[2][1] = F[1];
|
||||
myOrientation.mat[2][2] = F[2];
|
||||
myOrientation.mat[2][3] = 0.0f;
|
||||
|
||||
myOrientation.mat[3][0] = T[0];
|
||||
myOrientation.mat[3][1] = T[1];
|
||||
myOrientation.mat[3][2] = T[2];
|
||||
myOrientation.mat[3][3] = 1.0f;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <OpenGl_Resource.hxx>
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <OpenGl_Matrix.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_ClipPlane.hxx>
|
||||
|
||||
class OpenGl_CappingPlaneResource;
|
||||
DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
|
||||
@@ -30,23 +30,25 @@ DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
|
||||
//! This resource holds data necessary for OpenGl_CappingAlgo.
|
||||
//! This object is implemented as OpenGl resource for the following reasons:
|
||||
//! - one instance should be shared between contexts.
|
||||
//! - instance associated to Graphic3d_AspectFillCapping data.
|
||||
//! - instance associated to Graphic3d_ClipPlane data by id.
|
||||
//! - should created and released within context (owns OpenGl elements and resources).
|
||||
class OpenGl_CappingPlaneResource : public OpenGl_Resource
|
||||
{
|
||||
public:
|
||||
|
||||
//! Create and assign style.
|
||||
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect);
|
||||
//! Constructor.
|
||||
//! Create capping plane presentation associated to clipping plane data.
|
||||
//! @param thePlane [in] the plane data.
|
||||
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane);
|
||||
|
||||
//! Destroy object.
|
||||
Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
|
||||
|
||||
//! Assign section style.
|
||||
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect);
|
||||
|
||||
//! Returns section style parameters.
|
||||
const Handle(Graphic3d_AspectFillCapping)& Aspect() const { return myAspect; }
|
||||
//! Update resource data in the passed context.
|
||||
//! @param theContext [in] the context
|
||||
//! @param theObjAspect [in] object aspect
|
||||
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
|
||||
const Handle(Graphic3d_Aspects)& theObjAspect);
|
||||
|
||||
//! Release associated OpenGl resources.
|
||||
//! @param theContext [in] the resource context.
|
||||
@@ -55,23 +57,17 @@ public:
|
||||
//! Returns estimated GPU memory usage - not implemented.
|
||||
virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
//! Return parent clipping plane structure.
|
||||
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
|
||||
|
||||
//! @return aspect face for rendering capping surface.
|
||||
inline const OpenGl_Aspects* AspectFace() const { return myAspect; }
|
||||
|
||||
//! @return evaluated orientation matrix to transform infinite plane.
|
||||
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
|
||||
|
||||
//! @return primitive array of vertices to render infinite plane.
|
||||
static OpenGl_PrimitiveArray* BuildInfinitPlaneVertices();
|
||||
|
||||
//! Returns true if capping should draw hatch layer.
|
||||
Standard_Boolean ToDrawHatch() const
|
||||
{
|
||||
return myAspect->ToDrawHatch()
|
||||
&& (myAspect->IsStippleHatch()
|
||||
|| myAspect->IsTextureHatch());
|
||||
}
|
||||
|
||||
//! Returns the shading aspect for drawing face of a clipping section itself.
|
||||
//! @param theObjectAspect [in] the aspect of an object if it requires combining.
|
||||
Standard_EXPORT const OpenGl_Aspects* CappingFaceAspect (const OpenGl_Aspects* theObjectAspect) const;
|
||||
|
||||
//! Returns the shading aspect for drawing hatch layer of a section.
|
||||
Standard_EXPORT const OpenGl_Aspects* HatchingFaceAspect() const;
|
||||
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -83,11 +79,14 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
Handle(Graphic3d_AspectFillCapping) myAspect; //!< Section style settings from application's level.
|
||||
mutable OpenGl_Aspects myCappingAspect; //!< GL aspect for shading base layer of a capping section.
|
||||
mutable OpenGl_Aspects myHatchingAspect; //!< GL aspect for shading hatching layer (additional to base) of a capping section.
|
||||
mutable Standard_Size myHatchingState;
|
||||
gp_XYZ myLocalOrigin; //!< layer origin
|
||||
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
|
||||
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
|
||||
OpenGl_Aspects* myAspect; //!< capping face aspect.
|
||||
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
|
||||
Handle(Graphic3d_Aspects) myFillAreaAspect;//!< own capping aspect
|
||||
gp_XYZ myLocalOrigin; //!< layer origin
|
||||
unsigned int myEquationMod; //!< modification counter for plane equation.
|
||||
unsigned int myAspectMod; //!< modification counter for aspect.
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -91,41 +91,45 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
myTextAspect.SetAspect (aRendParams.StatsTextAspect);
|
||||
|
||||
// adjust text alignment depending on corner
|
||||
OpenGl_TextParam aParams;
|
||||
aParams.Height = aRendParams.StatsTextHeight;
|
||||
aParams.HAlign = Graphic3d_HTA_CENTER;
|
||||
aParams.VAlign = Graphic3d_VTA_CENTER;
|
||||
Graphic3d_Text aParams ((Standard_ShortReal)aRendParams.StatsTextHeight);
|
||||
aParams.SetHorizontalAlignment (Graphic3d_HTA_CENTER);
|
||||
aParams.SetVerticalAlignment (Graphic3d_VTA_CENTER);
|
||||
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_LEFT) != 0)
|
||||
{
|
||||
aParams.HAlign = Graphic3d_HTA_LEFT;
|
||||
aParams.SetHorizontalAlignment (Graphic3d_HTA_LEFT);
|
||||
}
|
||||
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
|
||||
{
|
||||
aParams.HAlign = Graphic3d_HTA_RIGHT;
|
||||
aParams.SetHorizontalAlignment (Graphic3d_HTA_RIGHT);
|
||||
}
|
||||
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_TOP) != 0)
|
||||
{
|
||||
aParams.VAlign = Graphic3d_VTA_TOP;
|
||||
aParams.SetVerticalAlignment (Graphic3d_VTA_TOP);
|
||||
}
|
||||
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_BOTTOM) != 0)
|
||||
{
|
||||
aParams.VAlign = Graphic3d_VTA_BOTTOM;
|
||||
aParams.SetVerticalAlignment (Graphic3d_VTA_BOTTOM);
|
||||
}
|
||||
if (aParams.Height != myCountersText.FormatParams().Height
|
||||
|| aParams.HAlign != myCountersText.FormatParams().HAlign
|
||||
|| aParams.VAlign != myCountersText.FormatParams().VAlign)
|
||||
if (aParams.Height() != myCountersText.Text()->Height()
|
||||
|| aParams.HorizontalAlignment() != myCountersText.Text()->HorizontalAlignment()
|
||||
|| aParams.VerticalAlignment() != myCountersText.Text()->VerticalAlignment())
|
||||
{
|
||||
myCountersText.Release (aCtx.operator->());
|
||||
}
|
||||
|
||||
if (!aStats->IsFrameUpdated (myStatsPrev)
|
||||
&& !myCountersText.Text().IsEmpty())
|
||||
&& !myCountersText.Text()->Text().IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
|
||||
myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
|
||||
Handle(Graphic3d_Text) aText = myCountersText.Text();
|
||||
aText->SetText (aStats->FormatStats (aRendParams.CollectedStats).ToCString());
|
||||
aText->SetHeight (aParams.Height());
|
||||
aText->SetPosition (gp_Pnt());
|
||||
aText->SetHorizontalAlignment (aParams.HorizontalAlignment());
|
||||
aText->SetVerticalAlignment (aParams.VerticalAlignment());
|
||||
myCountersText.Reset (aCtx);
|
||||
|
||||
updateChart (theWorkspace);
|
||||
}
|
||||
@@ -323,14 +327,13 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
|
||||
}
|
||||
|
||||
{
|
||||
OpenGl_TextParam aParams;
|
||||
aParams.Height = aRendParams.StatsTextHeight;
|
||||
aParams.HAlign = (!myChartTrsfPers.IsNull()
|
||||
Graphic3d_Text aParams ((Standard_ShortReal)aRendParams.StatsTextHeight);
|
||||
aParams.SetHorizontalAlignment ((!myChartTrsfPers.IsNull()
|
||||
&& myChartTrsfPers->IsTrihedronOr2d()
|
||||
&& (myChartTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
|
||||
? Graphic3d_HTA_RIGHT
|
||||
: Graphic3d_HTA_LEFT;
|
||||
aParams.VAlign = Graphic3d_VTA_CENTER;
|
||||
: Graphic3d_HTA_LEFT);
|
||||
aParams.SetVerticalAlignment (Graphic3d_VTA_CENTER);
|
||||
TCollection_AsciiString aLabels[3] =
|
||||
{
|
||||
TCollection_AsciiString() + 0 + " ms",
|
||||
@@ -338,12 +341,27 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
|
||||
formatTimeMs(aMaxDuration)
|
||||
};
|
||||
|
||||
const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
|
||||
const float aLabX = aParams.HorizontalAlignment() == Graphic3d_HTA_RIGHT
|
||||
? float(anOffset.x())
|
||||
: float(anOffset.x() + aCharSize.x());
|
||||
myChartLabels[0].Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams);
|
||||
myChartLabels[1].Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
|
||||
myChartLabels[2].Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams);
|
||||
|
||||
myChartLabels[0].Text()->SetText (aLabels[isTopDown ? 0 : 2].ToCString());
|
||||
myChartLabels[0].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y()), 0.0f));
|
||||
|
||||
myChartLabels[1].Text()->SetText (aLabels[isTopDown ? 1 : 1].ToCString());
|
||||
myChartLabels[1].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f));
|
||||
|
||||
myChartLabels[2].Text()->SetText (aLabels[isTopDown ? 2 : 0].ToCString());
|
||||
myChartLabels[2].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
myChartLabels[i].Text()->SetHeight (aParams.Height());
|
||||
myChartLabels[i].Text()->SetHorizontalAlignment (aParams.HorizontalAlignment());
|
||||
myChartLabels[i].Text()->SetVerticalAlignment (aParams.VerticalAlignment());
|
||||
|
||||
myChartLabels[i].Reset(aCtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_TransformPers.hxx>
|
||||
#include <Graphic3d_TransformUtils.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
@@ -33,10 +34,9 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
static const OpenGl_TextParam THE_LABEL_PARAMS =
|
||||
{
|
||||
16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
|
||||
};
|
||||
static Standard_ShortReal THE_LABEL_HEIGHT = 16;
|
||||
static Graphic3d_HorizontalTextAlignment THE_LABEL_HALIGH = Graphic3d_HTA_LEFT;
|
||||
static Graphic3d_VerticalTextAlignment THE_LABEL_VALIGH = Graphic3d_VTA_BOTTOM;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -522,7 +522,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
||||
|
||||
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
|
||||
theWorkspace->SetAspects (&myAspectLabels);
|
||||
anAxis.Label.SetPosition (aMiddle);
|
||||
anAxis.Label.Text()->SetPosition (gp_Pnt (aMiddle.x(), aMiddle.y(), aMiddle.z()));
|
||||
anAxis.Label.Render (theWorkspace);
|
||||
}
|
||||
|
||||
@@ -536,7 +536,12 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
||||
{
|
||||
sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
|
||||
OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
|
||||
myLabelValues.Init (theWorkspace->GetGlContext(), aTextValue, aPos);
|
||||
|
||||
Handle(Graphic3d_Text) aText = myLabelValues.Text();
|
||||
aText->SetText (aTextValue);
|
||||
aText->SetPosition (gp_Pnt(aPos.x(), aPos.y(), aPos.z()));
|
||||
|
||||
myLabelValues.Reset (theWorkspace->GetGlContext());
|
||||
myLabelValues.Render (theWorkspace);
|
||||
}
|
||||
}
|
||||
@@ -715,11 +720,16 @@ void OpenGl_GraduatedTrihedron::SetMinMax (const OpenGl_Vec3& theMin, const Open
|
||||
OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
|
||||
const OpenGl_Vec3& theDirection)
|
||||
: Direction (theDirection),
|
||||
Label (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS),
|
||||
Tickmark (NULL),
|
||||
Line (NULL),
|
||||
Arrow (NULL)
|
||||
{
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (THE_LABEL_HEIGHT);
|
||||
aText->SetText ((Standard_Utf16Char* )theAspect.Name().ToExtString());
|
||||
aText->SetPosition (gp_Pnt (theDirection.x(), theDirection.y(), theDirection.z()));
|
||||
aText->SetHorizontalAlignment (THE_LABEL_HALIGH);
|
||||
aText->SetVerticalAlignment (THE_LABEL_VALIGH);
|
||||
Label = OpenGl_Text (aText);
|
||||
NameColor = theAspect.NameColor();
|
||||
LineAspect.Aspect()->SetColor (theAspect.Color());
|
||||
}
|
||||
|
@@ -520,12 +520,10 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
|
||||
}
|
||||
|
||||
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
|
||||
OpenGl_TextParam aTextParam;
|
||||
aTextParam.Height = (int )aHeight;
|
||||
OpenGl_Aspects aTextAspect;
|
||||
TCollection_ExtendedString anExtText = theText;
|
||||
NCollection_String aText (anExtText.ToExtString());
|
||||
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
|
||||
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aHeight, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_GroupDefinitionError.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
|
||||
@@ -91,20 +90,6 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& th
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theAspect.IsNull() && theAspect->IsKind (STANDARD_TYPE(Graphic3d_AspectFillCapping)))
|
||||
{
|
||||
Handle(Graphic3d_AspectFillCapping) aFillCappingAspect = Handle(Graphic3d_AspectFillCapping)::DownCast (theAspect);
|
||||
if (myAspectFillCapping == NULL)
|
||||
{
|
||||
myAspectFillCapping = new OpenGl_CappingPlaneResource (aFillCappingAspect);
|
||||
}
|
||||
else
|
||||
{
|
||||
myAspectFillCapping->SetAspect (aFillCappingAspect);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspects == NULL)
|
||||
{
|
||||
myAspects = new OpenGl_Aspects (theAspect);
|
||||
@@ -221,75 +206,27 @@ void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theTy
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Text
|
||||
// function : AddText
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
void OpenGl_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OpenGl_TextParam aParams;
|
||||
OpenGl_Structure* aStruct = GlStruct();
|
||||
aParams.Height = int ((theHeight < 2.0) ? aStruct->GlDriver()->DefaultTextHeight() : theHeight);
|
||||
aParams.HAlign = theHta;
|
||||
aParams.VAlign = theVta;
|
||||
const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
|
||||
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
|
||||
AddElement (aText);
|
||||
Graphic3d_Group::Text (theTextUtf, thePoint, theHeight, theAngle,
|
||||
theTp, theHta, theVta, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
if (IsDeleted())
|
||||
if (theTextParams->Height() < 2.0)
|
||||
{
|
||||
return;
|
||||
// TODO - this should be handled in different way (throw exception / take default text height without modifying Graphic3d_Text / log warning, etc.)
|
||||
OpenGl_Structure* aStruct = GlStruct();
|
||||
theTextParams->SetHeight (aStruct->GlDriver()->DefaultTextHeight());
|
||||
}
|
||||
|
||||
OpenGl_TextParam aParams;
|
||||
OpenGl_Structure* aStruct = GlStruct();
|
||||
|
||||
aParams.Height = int ((theHeight < 2.0) ? aStruct->GlDriver()->DefaultTextHeight() : theHeight);
|
||||
aParams.HAlign = theHTA;
|
||||
aParams.VAlign = theVTA;
|
||||
|
||||
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
|
||||
OpenGl_Text* aText = new OpenGl_Text (theTextParams);
|
||||
|
||||
AddElement (aText);
|
||||
|
||||
Graphic3d_Group::Text (theTextUtf,
|
||||
theOrientation,
|
||||
theHeight,
|
||||
theAngle,
|
||||
theTp,
|
||||
theHTA,
|
||||
theVTA,
|
||||
theToEvalMinMax,
|
||||
theHasOwnAnchor);
|
||||
|
||||
Graphic3d_Group::AddText (theTextParams, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <OpenGl_CappingPlaneResource.hxx>
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
||||
class OpenGl_Group;
|
||||
@@ -72,27 +71,9 @@ public:
|
||||
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
|
||||
|
||||
//! Add text element
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
|
||||
|
||||
//! Add text element in 3D space.
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True) Standard_OVERRIDE;
|
||||
|
||||
//! Adds a text for display
|
||||
Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
|
||||
//! Add flipping element
|
||||
Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
||||
const gp_Ax2& theRefPlane) Standard_OVERRIDE;
|
||||
@@ -118,17 +99,6 @@ public:
|
||||
//! Is the group ray-tracable (contains ray-tracable elements)?
|
||||
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
|
||||
|
||||
//! Returns section style aspect.
|
||||
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const Standard_OVERRIDE
|
||||
{
|
||||
return myAspectFillCapping != NULL
|
||||
? myAspectFillCapping->Aspect()
|
||||
: Handle(Graphic3d_AspectFillCapping)();
|
||||
}
|
||||
|
||||
//! Returns OpenGL capping filling aspect.
|
||||
const OpenGl_CappingPlaneResource* AspectFillCapping() const { return myAspectFillCapping; }
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT virtual ~OpenGl_Group();
|
||||
@@ -136,7 +106,6 @@ protected:
|
||||
protected:
|
||||
|
||||
OpenGl_Aspects* myAspects;
|
||||
OpenGl_CappingPlaneResource* myAspectFillCapping;
|
||||
OpenGl_ElementNode* myFirst;
|
||||
OpenGl_ElementNode* myLast;
|
||||
Standard_Boolean myIsRaytracable;
|
||||
|
@@ -2676,6 +2676,53 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramBoundBox()
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetBgCubeMapProgram
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Handle(Graphic3d_ShaderProgram)& OpenGl_ShaderManager::GetBgCubeMapProgram ()
|
||||
{
|
||||
if (myBgCubeMapProgram.IsNull())
|
||||
{
|
||||
myBgCubeMapProgram = new Graphic3d_ShaderProgram;
|
||||
|
||||
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable("vec3 ViewDirection", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uZCoeff", Graphic3d_TOS_VERTEX)); // defines orientation of Z axis to make horizontal flip
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uYCoeff", Graphic3d_TOS_VERTEX)); // defines orientation of Y axis to make vertical flip
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("samplerCube occSampler0", Graphic3d_TOS_FRAGMENT));
|
||||
|
||||
TCollection_AsciiString aSrcVert =
|
||||
EOL"void main()"
|
||||
EOL"{"
|
||||
EOL" vec4 aViewDirection = occProjectionMatrixInverse * vec4(occVertex.xy, 0.0, 1.0);"
|
||||
EOL" aViewDirection /= aViewDirection.w;"
|
||||
EOL" aViewDirection.w = 0.0;"
|
||||
EOL" ViewDirection = normalize((occWorldViewMatrixInverse * aViewDirection).xyz);"
|
||||
EOL" ViewDirection = ViewDirection.yzx;" // is needed to sync horizon and frontal camera position
|
||||
EOL" ViewDirection.y *= uYCoeff;"
|
||||
EOL" ViewDirection.z *= uZCoeff;"
|
||||
EOL" gl_Position = vec4(occVertex.xy, 0.0, 1.0);"
|
||||
EOL"}";
|
||||
|
||||
TCollection_AsciiString aSrcFrag =
|
||||
EOL"#define occEnvCubemap occSampler0"
|
||||
EOL"void main()"
|
||||
EOL"{"
|
||||
EOL" occSetFragColor (vec4(texture(occEnvCubemap, ViewDirection).rgb, 1.0));"
|
||||
EOL"}";
|
||||
|
||||
defaultGlslVersion(myBgCubeMapProgram, "background_cubemap", 0);
|
||||
myBgCubeMapProgram->SetDefaultSampler(false);
|
||||
myBgCubeMapProgram->SetNbLightsMax(0);
|
||||
myBgCubeMapProgram->SetNbClipPlanesMax(0);
|
||||
myBgCubeMapProgram->AttachShader(OpenGl_ShaderObject::CreateFromSource(aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
myBgCubeMapProgram->AttachShader(OpenGl_ShaderObject::CreateFromSource(aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
||||
}
|
||||
|
||||
return myBgCubeMapProgram;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : bindProgramWithState
|
||||
// purpose :
|
||||
|
@@ -251,6 +251,9 @@ public:
|
||||
//! Returns bounding box vertex buffer.
|
||||
const Handle(OpenGl_VertexBuffer)& BoundBoxVertBuffer() const { return myBoundBoxVertBuffer; }
|
||||
|
||||
//! Generates shader program to render environment cubemap as background.
|
||||
Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& GetBgCubeMapProgram ();
|
||||
|
||||
public:
|
||||
|
||||
//! Returns current state of OCCT light sources.
|
||||
@@ -765,6 +768,8 @@ protected:
|
||||
Handle(OpenGl_ShaderProgram) myOitCompositingProgram[2]; //!< standard program for OIT compositing (default and MSAA).
|
||||
OpenGl_MapOfShaderPrograms myMapOfLightPrograms; //!< map of lighting programs depending on lights configuration
|
||||
|
||||
Handle(Graphic3d_ShaderProgram) myBgCubeMapProgram; //!< program for background cubemap rendering
|
||||
|
||||
Handle(OpenGl_ShaderProgram) myStereoPrograms[Graphic3d_StereoMode_NB]; //!< standard stereo programs
|
||||
|
||||
Handle(OpenGl_VertexBuffer) myBoundBoxVertBuffer; //!< bounding box vertex buffer
|
||||
|
@@ -75,56 +75,21 @@ namespace
|
||||
// =======================================================================
|
||||
OpenGl_Text::OpenGl_Text()
|
||||
: myScaleHeight (1.0f),
|
||||
myPoint (0.0f, 0.0f, 0.0f),
|
||||
myIs2d (false),
|
||||
myHasPlane (false),
|
||||
myHasAnchorPoint (true)
|
||||
myIs2d (Standard_False)
|
||||
{
|
||||
myParams.Height = 10;
|
||||
myParams.HAlign = Graphic3d_HTA_LEFT;
|
||||
myParams.VAlign = Graphic3d_VTA_BOTTOM;
|
||||
myText = new Graphic3d_Text (10.);
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint,
|
||||
const OpenGl_TextParam& theParams)
|
||||
: myScaleHeight (1.0f),
|
||||
myExportHeight (1.0f),
|
||||
myParams (theParams),
|
||||
myString (theText),
|
||||
myPoint (thePoint),
|
||||
myIs2d (false),
|
||||
myHasPlane (false),
|
||||
myHasAnchorPoint (true)
|
||||
OpenGl_Text::OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams)
|
||||
: myText (theTextParams),
|
||||
myScaleHeight (1.0f),
|
||||
myIs2d (Standard_False)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const OpenGl_TextParam& theParams,
|
||||
const bool theHasOwnAnchor)
|
||||
: myScaleHeight (1.0),
|
||||
myExportHeight (1.0),
|
||||
myParams (theParams),
|
||||
myString (theText),
|
||||
myIs2d (false),
|
||||
myOrientation (theOrientation),
|
||||
myHasPlane (true),
|
||||
myHasAnchorPoint (theHasOwnAnchor)
|
||||
{
|
||||
const gp_Pnt& aPoint = theOrientation.Location();
|
||||
myPoint = OpenGl_Vec3 (static_cast<Standard_ShortReal> (aPoint.X()),
|
||||
static_cast<Standard_ShortReal> (aPoint.Y()),
|
||||
static_cast<Standard_ShortReal> (aPoint.Z()));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -133,7 +98,7 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
||||
// =======================================================================
|
||||
void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
|
||||
{
|
||||
myPoint = thePoint;
|
||||
myText->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -143,11 +108,27 @@ void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
|
||||
void OpenGl_Text::SetFontSize (const Handle(OpenGl_Context)& theCtx,
|
||||
const Standard_Integer theFontSize)
|
||||
{
|
||||
if (myParams.Height != theFontSize)
|
||||
if (myText->Height() != theFontSize)
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
}
|
||||
myParams.Height = theFontSize;
|
||||
myText->SetHeight ((Standard_ShortReal)theFontSize);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Reset
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::Reset (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
if (!myFont.IsNull() && myFont->FTFont()->PointSize() != myText->Height())
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
}
|
||||
else
|
||||
{
|
||||
releaseVbos (theCtx.operator->());
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -158,56 +139,13 @@ void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint)
|
||||
{
|
||||
releaseVbos (theCtx.operator->());
|
||||
myIs2d = false;
|
||||
myPoint = thePoint;
|
||||
myString.FromUnicode (theText);
|
||||
}
|
||||
Reset (theCtx);
|
||||
Set2D (Standard_False);
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint,
|
||||
const OpenGl_TextParam& theParams)
|
||||
{
|
||||
if (myParams.Height != theParams.Height)
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
}
|
||||
else
|
||||
{
|
||||
releaseVbos (theCtx.operator->());
|
||||
}
|
||||
myIs2d = false;
|
||||
myParams = theParams;
|
||||
myPoint = thePoint;
|
||||
myString.FromUnicode (theText);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const TCollection_ExtendedString& theText,
|
||||
const OpenGl_Vec2& thePoint,
|
||||
const OpenGl_TextParam& theParams)
|
||||
{
|
||||
if (myParams.Height != theParams.Height)
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
}
|
||||
else
|
||||
{
|
||||
releaseVbos (theCtx.operator->());
|
||||
}
|
||||
myIs2d = true;
|
||||
myParams = theParams;
|
||||
myPoint.SetValues (thePoint, 0.0f);
|
||||
myString.FromUnicode (theText.ToExtString());
|
||||
NCollection_String aText;
|
||||
aText.FromUnicode (theText);
|
||||
myText->SetText (aText);
|
||||
myText->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -275,7 +213,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
|
||||
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||
const NCollection_String& theText,
|
||||
const OpenGl_Aspects& theTextAspect,
|
||||
const OpenGl_TextParam& theParams,
|
||||
const Standard_ShortReal theHeight,
|
||||
const unsigned int theResolution,
|
||||
Standard_ShortReal& theWidth,
|
||||
Standard_ShortReal& theAscent,
|
||||
@@ -284,8 +222,8 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||
theWidth = 0.0f;
|
||||
theAscent = 0.0f;
|
||||
theDescent = 0.0f;
|
||||
const TCollection_AsciiString aFontKey = FontKey (theTextAspect, theParams.Height, theResolution);
|
||||
Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, theParams.Height, theResolution, aFontKey);
|
||||
const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)theHeight, theResolution);
|
||||
Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, (Standard_Integer)theHeight, theResolution, aFontKey);
|
||||
if (aFont.IsNull() || !aFont->IsValid())
|
||||
{
|
||||
return;
|
||||
@@ -347,7 +285,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
// Bind custom shader program or generate default version
|
||||
aCtx->ShaderManager()->BindFontProgram (aTextAspect->ShaderProgramRes (aCtx));
|
||||
|
||||
if (myHasPlane && myHasAnchorPoint)
|
||||
if (myText->HasPlane() && myText->HasOwnAnchorPoint())
|
||||
{
|
||||
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
|
||||
// reset translation part
|
||||
@@ -411,7 +349,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
const OpenGl_Vec3& theDVec) const
|
||||
{
|
||||
OpenGl_Mat4d aModViewMat, aProjectMat;
|
||||
if (myHasPlane && myHasAnchorPoint)
|
||||
if (myText->HasPlane() && myText->HasOwnAnchorPoint())
|
||||
{
|
||||
aProjectMat = myProjMatrix * myOrientationMatrix;
|
||||
}
|
||||
@@ -422,7 +360,8 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
|
||||
if (myIs2d)
|
||||
{
|
||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
|
||||
const gp_Pnt& aPoint = myText->Position();
|
||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, aPoint.X() + theDVec.x(), aPoint.Y() + theDVec.y(), 0.f);
|
||||
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
|
||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.f, 0.f, 1.f);
|
||||
}
|
||||
@@ -430,7 +369,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
OpenGl_Vec3d anObjXYZ;
|
||||
OpenGl_Vec3d aWinXYZ = myWinXYZ + OpenGl_Vec3d (theDVec);
|
||||
if (!myHasPlane && !theTextAspect.Aspect()->IsTextZoomable())
|
||||
if (!myText->HasPlane() && !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),
|
||||
@@ -443,20 +382,22 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
THE_IDENTITY_MATRIX, aProjectMat, theCtx->Viewport(),
|
||||
anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
|
||||
|
||||
if (myHasPlane)
|
||||
if (myText->HasPlane())
|
||||
{
|
||||
const gp_Dir& aVectorDir = myOrientation.XDirection();
|
||||
const gp_Dir& aVectorUp = myOrientation.Direction();
|
||||
const gp_Dir& aVectorRight = myOrientation.YDirection();
|
||||
const gp_Ax2& anOrientation = myText->Orientation();
|
||||
const gp_Dir& aVectorDir = anOrientation.XDirection();
|
||||
const gp_Dir& aVectorUp = anOrientation.Direction();
|
||||
const gp_Dir& aVectorRight = anOrientation.YDirection();
|
||||
|
||||
aModViewMat.SetColumn (2, OpenGl_Vec3d (aVectorUp.X(), aVectorUp.Y(), aVectorUp.Z()));
|
||||
aModViewMat.SetColumn (1, OpenGl_Vec3d (aVectorRight.X(), aVectorRight.Y(), aVectorRight.Z()));
|
||||
aModViewMat.SetColumn (0, OpenGl_Vec3d (aVectorDir.X(), aVectorDir.Y(), aVectorDir.Z()));
|
||||
|
||||
if (!myHasAnchorPoint)
|
||||
if (!myText->HasOwnAnchorPoint())
|
||||
{
|
||||
OpenGl_Mat4d aPosMat;
|
||||
aPosMat.SetColumn (3, OpenGl_Vec3d (myPoint.x(), myPoint.y(), myPoint.z()));
|
||||
const gp_Pnt& aPoint = myText->Position();
|
||||
aPosMat.SetColumn (3, OpenGl_Vec3d (aPoint.X(), aPoint.Y(), aPoint.Z()));
|
||||
aPosMat *= aModViewMat;
|
||||
aModViewMat.SetColumn (3, aPosMat.GetColumn (3));
|
||||
}
|
||||
@@ -481,7 +422,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
}
|
||||
|
||||
if (myHasPlane && !myHasAnchorPoint)
|
||||
if (myText->HasPlane() && !myText->HasOwnAnchorPoint())
|
||||
{
|
||||
OpenGl_Mat4d aCurrentWorldViewMat;
|
||||
aCurrentWorldViewMat.Convert (theCtx->WorldViewState.Current());
|
||||
@@ -666,14 +607,14 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
const OpenGl_Vec4& theColorSubs,
|
||||
unsigned int theResolution) const
|
||||
{
|
||||
if (myString.IsEmpty())
|
||||
if (myText->Text().IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Note that using difference resolution in different Views in same Viewer
|
||||
// will lead to performance regression (for example, text will be recreated every time).
|
||||
const TCollection_AsciiString aFontKey = FontKey (theTextAspect, myParams.Height, theResolution);
|
||||
const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)myText->Height(), theResolution);
|
||||
if (!myFont.IsNull()
|
||||
&& !myFont->ResourceKey().IsEqual (aFontKey))
|
||||
{
|
||||
@@ -683,7 +624,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
|
||||
if (myFont.IsNull())
|
||||
{
|
||||
myFont = FindFont (theCtx, theTextAspect, myParams.Height, theResolution, aFontKey);
|
||||
myFont = FindFont (theCtx, theTextAspect, (Standard_Integer)myText->Height(), theResolution, aFontKey);
|
||||
}
|
||||
if (!myFont->WasInitialized())
|
||||
{
|
||||
@@ -693,10 +634,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
if (myTextures.IsEmpty())
|
||||
{
|
||||
Font_TextFormatter aFormatter;
|
||||
aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
|
||||
|
||||
aFormatter.SetupAlignment (myText->HorizontalAlignment(), myText->VerticalAlignment());
|
||||
aFormatter.Reset();
|
||||
|
||||
aFormatter.Append (myString, *myFont->FTFont().operator->());
|
||||
aFormatter.Append (myText->Text(), *myFont->FTFont());
|
||||
aFormatter.Format();
|
||||
|
||||
OpenGl_TextBuilder aBuilder;
|
||||
@@ -720,7 +662,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
return;
|
||||
}
|
||||
|
||||
myExportHeight = 1.0f;
|
||||
myScaleHeight = 1.0f;
|
||||
|
||||
theCtx->WorldViewState.Push();
|
||||
@@ -729,16 +670,13 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLdouble aPointSize = (GLdouble )myFont->FTFont()->PointSize();
|
||||
if (!myIs2d)
|
||||
{
|
||||
Graphic3d_TransformUtils::Project<Standard_Real> (myPoint.x(), myPoint.y(), myPoint.z(),
|
||||
const gp_Pnt& aPoint = myText->Position();
|
||||
Graphic3d_TransformUtils::Project<Standard_Real> (aPoint.X(), aPoint.Y(), aPoint.Z(),
|
||||
myModelMatrix, myProjMatrix, theCtx->Viewport(),
|
||||
myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z());
|
||||
|
||||
// compute scale factor for constant text height
|
||||
if (theTextAspect.Aspect()->IsTextZoomable())
|
||||
{
|
||||
myExportHeight = aPointSize;
|
||||
}
|
||||
else
|
||||
if (!theTextAspect.Aspect()->IsTextZoomable())
|
||||
{
|
||||
Graphic3d_Vec3d aPnt1, aPnt2;
|
||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z(),
|
||||
@@ -750,7 +688,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
myScaleHeight = (aPnt2.y() - aPnt1.y()) / aPointSize;
|
||||
}
|
||||
}
|
||||
myExportHeight = aPointSize / myExportHeight;
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (theCtx->core11 != NULL
|
||||
|
@@ -19,13 +19,13 @@
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <OpenGl_TextParam.hxx>
|
||||
#include <OpenGl_TextBuilder.hxx>
|
||||
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_RenderingParams.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
|
||||
#include <gp_Ax2.hxx>
|
||||
@@ -36,33 +36,30 @@ class OpenGl_Text : public OpenGl_Element
|
||||
|
||||
public:
|
||||
|
||||
//! Main constructor
|
||||
Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint,
|
||||
const OpenGl_TextParam& theParams);
|
||||
|
||||
//! Creates new text in 3D space.
|
||||
Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const OpenGl_TextParam& theParams,
|
||||
const bool theHasOwnAnchor = true);
|
||||
Standard_EXPORT OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams);
|
||||
|
||||
//! Destructor
|
||||
Standard_EXPORT virtual ~OpenGl_Text();
|
||||
|
||||
//! Setup new string and position
|
||||
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint);
|
||||
//! Release cached VBO resources and the previous font if height changed.
|
||||
//! Cached structures will be refilled by the next render.
|
||||
//! Call Reset after modifying text parameters.
|
||||
Standard_EXPORT void Reset (const Handle(OpenGl_Context)& theCtx);
|
||||
|
||||
//! Setup new string and parameters
|
||||
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint,
|
||||
const OpenGl_TextParam& theParams);
|
||||
//! Returns text parameters
|
||||
//! @sa Reset()
|
||||
const Handle(Graphic3d_Text)& Text() const { return myText; }
|
||||
|
||||
//! Setup new position
|
||||
Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
|
||||
//! Sets text parameters
|
||||
//! @sa Reset()
|
||||
void SetText (const Handle(Graphic3d_Text)& theText) { myText = theText; }
|
||||
|
||||
//! Return true if text is 2D
|
||||
Standard_Boolean Is2D() const { return myIs2d; }
|
||||
|
||||
//! Set true if text is 2D
|
||||
void Set2D (const Standard_Boolean theEnable) { myIs2d = theEnable; }
|
||||
|
||||
//! Setup new font size
|
||||
Standard_EXPORT void SetFontSize (const Handle(OpenGl_Context)& theContext,
|
||||
@@ -71,12 +68,6 @@ public:
|
||||
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
|
||||
|
||||
//! Return defined text.
|
||||
const NCollection_String& Text() const { return myString; }
|
||||
|
||||
//! Return text formatting parameters.
|
||||
const OpenGl_TextParam& FormatParams() const { return myParams; }
|
||||
|
||||
public: //! @name methods for compatibility with layers
|
||||
|
||||
//! Empty constructor
|
||||
@@ -98,23 +89,30 @@ public: //! @name methods for compatibility with layers
|
||||
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||
const NCollection_String& theText,
|
||||
const OpenGl_Aspects& theTextAspect,
|
||||
const OpenGl_TextParam& theParams,
|
||||
const Standard_ShortReal theHeight,
|
||||
const unsigned int theResolution,
|
||||
Standard_ShortReal& theWidth,
|
||||
Standard_ShortReal& theAscent,
|
||||
Standard_ShortReal& theDescent);
|
||||
|
||||
//! Setup new string and parameters
|
||||
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const TCollection_ExtendedString& theText,
|
||||
const OpenGl_Vec2& thePoint,
|
||||
const OpenGl_TextParam& theParams);
|
||||
|
||||
//! Perform rendering
|
||||
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
|
||||
const OpenGl_Aspects& theTextAspect,
|
||||
unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
|
||||
|
||||
//! @name obsolete methods
|
||||
public:
|
||||
|
||||
//! Setup new string and position
|
||||
Standard_DEPRECATED("Deprecated method Init() with obsolete arguments, use Init() and Text() instead of it")
|
||||
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint);
|
||||
|
||||
//! Setup new position
|
||||
Standard_DEPRECATED("Deprecated method SetPosition(), use Graphic3d_Text for it")
|
||||
Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
|
||||
|
||||
protected:
|
||||
|
||||
friend class OpenGl_Trihedron;
|
||||
@@ -148,6 +146,7 @@ private:
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Graphic3d_Text) myText; //!< text parameters
|
||||
mutable Handle(OpenGl_Font) myFont;
|
||||
mutable NCollection_Vector<GLuint> myTextures; //!< textures' IDs
|
||||
mutable NCollection_Vector<Handle(OpenGl_VertexBuffer)> myVertsVbo; //!< VBOs of vertices
|
||||
@@ -162,18 +161,10 @@ protected:
|
||||
mutable OpenGl_Mat4d myOrientationMatrix;
|
||||
mutable OpenGl_Vec3d myWinXYZ;
|
||||
mutable GLdouble myScaleHeight;
|
||||
mutable GLdouble myExportHeight;
|
||||
|
||||
protected:
|
||||
|
||||
OpenGl_TextParam myParams;
|
||||
NCollection_String myString;
|
||||
OpenGl_Vec3 myPoint;
|
||||
bool myIs2d;
|
||||
gp_Ax2 myOrientation; //!< Text orientation in 3D space.
|
||||
bool myHasPlane; //!< Check if text have orientation in 3D space.
|
||||
bool myHasAnchorPoint; //!< Shows if it has own attach point
|
||||
|
||||
Standard_Boolean myIs2d;
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
@@ -182,7 +182,7 @@ bool OpenGl_Texture::InitSamplerObject (const Handle(OpenGl_Context)& theCtx)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theData,
|
||||
const Image_Format theFormat,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
@@ -190,7 +190,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
theTextFormat = GL_RGBA8;
|
||||
thePixelFormat = 0;
|
||||
theDataType = 0;
|
||||
switch (theData.Format())
|
||||
switch (theFormat)
|
||||
{
|
||||
case Image_Format_GrayF:
|
||||
{
|
||||
@@ -733,6 +733,12 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
Unbind (theCtx);
|
||||
return true;
|
||||
}
|
||||
case Graphic3d_TOT_CUBEMAP:
|
||||
{
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Release (theCtx.operator->());
|
||||
@@ -769,6 +775,36 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
theType, &theImage);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_TextureMap)& theTextureMap)
|
||||
{
|
||||
if (theTextureMap.IsNull())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (theTextureMap->Type())
|
||||
{
|
||||
case Graphic3d_TOT_CUBEMAP:
|
||||
{
|
||||
return InitCubeMap (theCtx, Handle(Graphic3d_CubeMap)::DownCast(theTextureMap));
|
||||
}
|
||||
default:
|
||||
{
|
||||
Handle(Image_PixMap) anImage = theTextureMap->GetImage();
|
||||
if (anImage.IsNull())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Init (theCtx, *anImage, theTextureMap->Type());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init2DMultisample
|
||||
// purpose :
|
||||
@@ -997,6 +1033,141 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
|
||||
return true;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitCubeMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Size theSize,
|
||||
Image_Format theFormat,
|
||||
Standard_Boolean theToGenMipmap)
|
||||
{
|
||||
if (!Create (theCtx))
|
||||
{
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!theCubeMap.IsNull())
|
||||
{
|
||||
Handle(Image_PixMap) anImage = theCubeMap->Reset().Value();
|
||||
if (!anImage.IsNull())
|
||||
{
|
||||
theSize = anImage->SizeX();
|
||||
theFormat = anImage->Format();
|
||||
}
|
||||
else
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Unable to get the first side of cubemap");
|
||||
Release(theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum aPixelFormat = GL_RGB;
|
||||
GLenum aDataType = 0;
|
||||
GLint aTextFormat = 0;
|
||||
|
||||
if (!GetDataFormat (theCtx, theFormat, aTextFormat, aPixelFormat, aDataType))
|
||||
{
|
||||
Unbind(theCtx);
|
||||
Release(theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
myTarget = GL_TEXTURE_CUBE_MAP;
|
||||
myHasMipmaps = theToGenMipmap;
|
||||
myNbSamples = 1;
|
||||
Bind (theCtx);
|
||||
applyDefaultSamplerParams (theCtx);
|
||||
|
||||
for (Standard_Integer i = 0; i < 6; ++i)
|
||||
{
|
||||
const void* aData = NULL;
|
||||
Handle(Image_PixMap) anImage;
|
||||
|
||||
if (!theCubeMap.IsNull())
|
||||
{
|
||||
anImage = theCubeMap->Value();
|
||||
if (!anImage.IsNull())
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
const GLint anAligment = Min ((GLint)anImage->MaxRowAligmentBytes(), 8); // OpenGL supports alignment upto 8 bytes
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, anAligment);
|
||||
|
||||
// notice that GL_UNPACK_ROW_LENGTH is not available on OpenGL ES 2.0 without GL_EXT_unpack_subimage extension
|
||||
const GLint anExtraBytes = GLint(anImage->RowExtraBytes());
|
||||
const GLint aPixelsWidth = GLint(anImage->SizeRowBytes() / anImage->SizePixelBytes());
|
||||
const GLint aRowLength = (anExtraBytes >= anAligment) ? aPixelsWidth : 0;
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, aRowLength);
|
||||
#else
|
||||
Handle(Image_PixMap) aCopyImage = new Image_PixMap();
|
||||
aCopyImage->InitTrash (theFormat, theSize, theSize);
|
||||
for (unsigned int y = 0; y < theSize; ++y)
|
||||
{
|
||||
for (unsigned int x = 0; x < theSize; ++x)
|
||||
{
|
||||
for (unsigned int aByte = 0; aByte < anImage->SizePixelBytes(); ++aByte)
|
||||
{
|
||||
aCopyImage->ChangeRawValue (y, x)[aByte] = anImage->RawValue (y, x)[aByte];
|
||||
}
|
||||
}
|
||||
}
|
||||
anImage = aCopyImage;
|
||||
const GLint anAligment = Min((GLint)anImage->MaxRowAligmentBytes(), 8); // OpenGL supports alignment upto 8 bytes
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, anAligment);
|
||||
#endif
|
||||
aData = anImage->Data();
|
||||
}
|
||||
else
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, TCollection_AsciiString() +
|
||||
"Unable to get [" + i + "] side of cubemap");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
theCubeMap->Next();
|
||||
}
|
||||
|
||||
glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
|
||||
aTextFormat,
|
||||
GLsizei(theSize), GLsizei(theSize),
|
||||
0, aPixelFormat, aDataType,
|
||||
aData);
|
||||
|
||||
OpenGl_UnpackAlignmentSentry::Reset();
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Unable to initialize side of cubemap");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (theToGenMipmap && theCtx->arbFBO != NULL)
|
||||
{
|
||||
theCtx->arbFBO->glGenerateMipmap (myTarget);
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Unable to generate mipmap of cubemap");
|
||||
Unbind(theCtx);
|
||||
Release(theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Unbind (theCtx.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : PixelSizeOfPixelFormat
|
||||
// purpose :
|
||||
|
@@ -15,11 +15,12 @@
|
||||
#ifndef _OpenGl_Texture_H__
|
||||
#define _OpenGl_Texture_H__
|
||||
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <OpenGl_GlCore13.hxx>
|
||||
#include <OpenGl_NamedResource.hxx>
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <Graphic3d_TypeOfTexture.hxx>
|
||||
#include <Graphic3d_TextureUnit.hxx>
|
||||
#include <Graphic3d_TypeOfTexture.hxx>
|
||||
|
||||
class Graphic3d_TextureParams;
|
||||
class Image_PixMap;
|
||||
@@ -422,6 +423,12 @@ public:
|
||||
const Graphic3d_TypeOfTexture theType,
|
||||
const Image_PixMap* theImage = NULL);
|
||||
|
||||
//! Initialize the texture with Graphic3d_TextureMap.
|
||||
//! It is an universal way to initialize.
|
||||
//! Sitable initialization method will be chosen.
|
||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_TextureMap)& theTextureMap);
|
||||
|
||||
//! Initialize the 2D multisampling texture using glTexImage2DMultisample().
|
||||
Standard_EXPORT bool Init2DMultisample (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLsizei theNbSamples,
|
||||
@@ -446,16 +453,47 @@ public:
|
||||
const Standard_Integer theSizeZ,
|
||||
const void* thePixels);
|
||||
|
||||
//! Initializes 6 sides of cubemap.
|
||||
//! If theCubeMap is not NULL then size and format will be taken from it
|
||||
//! and corresponding arguments will be ignored.
|
||||
//! Otherwise this parametres will be taken from arguments.
|
||||
//! theToGenMipmap allows to generate mipmaped cubemap.
|
||||
Standard_EXPORT bool InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Size theSize = 0,
|
||||
Image_Format theFormat = Image_Format_RGB,
|
||||
Standard_Boolean theToGenMipmap = Standard_False);
|
||||
|
||||
//! The same InitCubeMap but there is another order of arguments.
|
||||
bool InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Boolean theToGenMipmap,
|
||||
Standard_Size theSize = 0,
|
||||
Image_Format theFormat = Image_Format_RGB)
|
||||
{
|
||||
return InitCubeMap (theCtx, theCubeMap, theSize, theFormat, theToGenMipmap);
|
||||
}
|
||||
|
||||
//! @return true if texture was generated within mipmaps
|
||||
Standard_Boolean HasMipmaps() const { return myHasMipmaps; }
|
||||
|
||||
//! Return texture type and format by Image_PixMap data format.
|
||||
//! Return texture type and format by Image_Format.
|
||||
Standard_EXPORT static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theData,
|
||||
const Image_Format theFromat,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType);
|
||||
|
||||
//! Return texture type and format by Image_PixMap data format.
|
||||
static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theData,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
{
|
||||
return GetDataFormat (theCtx, theData.Format(), theTextFormat, thePixelFormat, theDataType);
|
||||
}
|
||||
|
||||
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
|
||||
Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
|
||||
|
||||
|
@@ -69,8 +69,8 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
myBackBufferRestored (Standard_False),
|
||||
myIsImmediateDrawn (Standard_False),
|
||||
myTextureParams (new OpenGl_Aspects()),
|
||||
myBgGradientArray (new OpenGl_BackgroundArray (Graphic3d_TOB_GRADIENT)),
|
||||
myBgTextureArray (new OpenGl_BackgroundArray (Graphic3d_TOB_TEXTURE)),
|
||||
myCubeMapParams (new OpenGl_Aspects()),
|
||||
myBackgroundType (Graphic3d_TOB_NONE),
|
||||
// ray-tracing fields initialization
|
||||
myRaytraceInitStatus (OpenGl_RT_NONE),
|
||||
myIsRaytraceDataValid (Standard_False),
|
||||
@@ -86,6 +86,11 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
myPrevCameraApertureRadius(0.f),
|
||||
myPrevCameraFocalPlaneDist(0.f)
|
||||
{
|
||||
for (int i = 0; i < Graphic3d_TypeOfBackground_NB; ++i)
|
||||
{
|
||||
myBackgrounds[i] = new OpenGl_BackgroundArray(Graphic3d_TypeOfBackground(i));
|
||||
}
|
||||
|
||||
myWorkspace = new OpenGl_Workspace (this, NULL);
|
||||
|
||||
Handle(Graphic3d_CLight) aLight = new Graphic3d_CLight (Graphic3d_TOLS_AMBIENT);
|
||||
@@ -117,9 +122,13 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
OpenGl_View::~OpenGl_View()
|
||||
{
|
||||
ReleaseGlResources (NULL); // ensure ReleaseGlResources() was called within valid context
|
||||
OpenGl_Element::Destroy (NULL, myBgGradientArray);
|
||||
OpenGl_Element::Destroy (NULL, myBgTextureArray);
|
||||
for (int i = 0; i < Graphic3d_TypeOfBackground_NB; ++i)
|
||||
{
|
||||
OpenGl_Element::Destroy(NULL, myBackgrounds[i]);
|
||||
}
|
||||
|
||||
OpenGl_Element::Destroy (NULL, myTextureParams);
|
||||
OpenGl_Element::Destroy (NULL, myCubeMapParams);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -148,13 +157,18 @@ void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
myTextureParams->Release (theCtx.get());
|
||||
}
|
||||
if (myBgGradientArray != NULL)
|
||||
|
||||
if (myCubeMapParams != NULL)
|
||||
{
|
||||
myBgGradientArray->Release (theCtx.get());
|
||||
myCubeMapParams->Release (theCtx.get());
|
||||
}
|
||||
if (myBgTextureArray != NULL)
|
||||
|
||||
for (int i = 0; i < Graphic3d_TypeOfBackground_NB; ++i)
|
||||
{
|
||||
myBgTextureArray->Release (theCtx.get());
|
||||
if (myBackgrounds[i] != NULL)
|
||||
{
|
||||
myBackgrounds[i]->Release (theCtx.get());
|
||||
}
|
||||
}
|
||||
|
||||
myMainSceneFbos[0] ->Release (theCtx.get());
|
||||
@@ -416,13 +430,13 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3
|
||||
Aspect_GradientBackground OpenGl_View::GradientBackground() const
|
||||
{
|
||||
Quantity_Color aColor1, aColor2;
|
||||
aColor1.SetValues (myBgGradientArray->GradientColor (0).r(),
|
||||
myBgGradientArray->GradientColor (0).g(),
|
||||
myBgGradientArray->GradientColor (0).b(), Quantity_TOC_RGB);
|
||||
aColor2.SetValues (myBgGradientArray->GradientColor (1).r(),
|
||||
myBgGradientArray->GradientColor (1).g(),
|
||||
myBgGradientArray->GradientColor (1).b(), Quantity_TOC_RGB);
|
||||
return Aspect_GradientBackground (aColor1, aColor2, myBgGradientArray->GradientFillMethod());
|
||||
aColor1.SetValues (myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0).r(),
|
||||
myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0).g(),
|
||||
myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0).b(), Quantity_TOC_RGB);
|
||||
aColor2.SetValues (myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1).r(),
|
||||
myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1).g(),
|
||||
myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1).b(), Quantity_TOC_RGB);
|
||||
return Aspect_GradientBackground (aColor1, aColor2, myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientFillMethod());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -433,7 +447,9 @@ void OpenGl_View::SetGradientBackground (const Aspect_GradientBackground& theBac
|
||||
{
|
||||
Quantity_Color aColor1, aColor2;
|
||||
theBackground.Colors (aColor1, aColor2);
|
||||
myBgGradientArray->SetGradientParameters (aColor1, aColor2, theBackground.BgGradientFillMethod());
|
||||
myBackgrounds[Graphic3d_TOB_GRADIENT]->SetGradientParameters (aColor1, aColor2, theBackground.BgGradientFillMethod());
|
||||
|
||||
myBackgroundType = Graphic3d_TOB_GRADIENT;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -467,6 +483,8 @@ void OpenGl_View::SetBackgroundImage (const TCollection_AsciiString& theFilePath
|
||||
|
||||
// Set texture parameters
|
||||
myTextureParams->SetAspect (anAspect);
|
||||
|
||||
myBackgroundType = Graphic3d_TOB_TEXTURE;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -475,7 +493,7 @@ void OpenGl_View::SetBackgroundImage (const TCollection_AsciiString& theFilePath
|
||||
// =======================================================================
|
||||
Aspect_FillMethod OpenGl_View::BackgroundImageStyle() const
|
||||
{
|
||||
return myBgTextureArray->TextureFillMethod();
|
||||
return myBackgrounds[Graphic3d_TOB_TEXTURE]->TextureFillMethod();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -484,7 +502,54 @@ Aspect_FillMethod OpenGl_View::BackgroundImageStyle() const
|
||||
// =======================================================================
|
||||
void OpenGl_View::SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle)
|
||||
{
|
||||
myBgTextureArray->SetTextureFillMethod (theFillStyle);
|
||||
myBackgrounds[Graphic3d_TOB_TEXTURE]->SetTextureFillMethod (theFillStyle);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BackgroundCubeMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Graphic3d_CubeMap) OpenGl_View::BackgroundCubeMap() const
|
||||
{
|
||||
return myBackgroundCubeMap;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetBackgroundCubeMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_View::SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap)
|
||||
{
|
||||
myBackgroundCubeMap = theCubeMap;
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d;
|
||||
Handle(Graphic3d_TextureSet) aTextureSet = new Graphic3d_TextureSet (myBackgroundCubeMap);
|
||||
|
||||
anAspect->SetInteriorStyle(Aspect_IS_SOLID);
|
||||
anAspect->SetSuppressBackFaces(false);
|
||||
anAspect->SetTextureSet(aTextureSet);
|
||||
|
||||
const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext();
|
||||
if (!aCtx.IsNull())
|
||||
{
|
||||
anAspect->SetShaderProgram (aCtx->ShaderManager()->GetBgCubeMapProgram());
|
||||
}
|
||||
|
||||
if (theCubeMap->IsDone())
|
||||
{
|
||||
anAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
anAspect->SetTextureMapOff();
|
||||
}
|
||||
|
||||
myCubeMapParams->SetAspect(anAspect);
|
||||
const OpenGl_Aspects* anAspectsBackup = myWorkspace->SetAspects (myCubeMapParams);
|
||||
myWorkspace->ApplyAspects();
|
||||
myWorkspace->SetAspects (anAspectsBackup);
|
||||
myWorkspace->ApplyAspects();
|
||||
|
||||
myBackgroundType = Graphic3d_TOB_CUBEMAP;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -492,8 +557,8 @@ void OpenGl_View::SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_View::InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter)
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter)
|
||||
{
|
||||
myZLayers.InsertLayerBefore (theLayerId, theSettings, theLayerAfter);
|
||||
}
|
||||
@@ -503,8 +568,8 @@ void OpenGl_View::InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_View::InsertLayerAfter (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore)
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore)
|
||||
{
|
||||
myZLayers.InsertLayerAfter (theLayerId, theSettings, theLayerBefore);
|
||||
}
|
||||
@@ -580,8 +645,8 @@ Bnd_Box OpenGl_View::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary)
|
||||
|
||||
// add bounding box of gradient/texture background for proper Z-fit
|
||||
if (theToIncludeAuxiliary
|
||||
&& (myBgTextureArray->IsDefined()
|
||||
|| myBgGradientArray->IsDefined()))
|
||||
&& (myBackgrounds[Graphic3d_TOB_TEXTURE]->IsDefined()
|
||||
|| myBackgrounds[Graphic3d_TOB_GRADIENT]->IsDefined()))
|
||||
{
|
||||
const Handle(Graphic3d_Camera)& aCamera = Camera();
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
|
@@ -222,6 +222,12 @@ public:
|
||||
//! Sets background image fill style.
|
||||
Standard_EXPORT virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) Standard_OVERRIDE;
|
||||
|
||||
//! Returns cubemap being set last time on background.
|
||||
Standard_EXPORT Handle(Graphic3d_CubeMap) BackgroundCubeMap() const Standard_OVERRIDE;
|
||||
|
||||
//! Sets environment cubemap as background.
|
||||
Standard_EXPORT virtual void SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap) Standard_OVERRIDE;
|
||||
|
||||
//! Returns environment texture set for the view.
|
||||
virtual Handle(Graphic3d_TextureEnv) TextureEnv() const Standard_OVERRIDE { return myTextureEnvData; }
|
||||
|
||||
@@ -506,9 +512,11 @@ protected: //! @name Rendering properties
|
||||
|
||||
protected: //! @name Background parameters
|
||||
|
||||
OpenGl_Aspects* myTextureParams; //!< Stores texture and its parameters for textured background
|
||||
OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
|
||||
OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
|
||||
OpenGl_Aspects* myTextureParams; //!< Stores texture and its parameters for textured background
|
||||
OpenGl_Aspects* myCubeMapParams; //!< Stores cubemap and its parameters for cubemap background
|
||||
Handle(Graphic3d_CubeMap) myBackgroundCubeMap; //!< Cubemap has been setted as background
|
||||
Graphic3d_TypeOfBackground myBackgroundType; //!< Current typy of background
|
||||
OpenGl_BackgroundArray* myBackgrounds[Graphic3d_TypeOfBackground_NB]; //!< Array of primitive arrays of different background types
|
||||
|
||||
protected: //! @name data types related to ray-tracing
|
||||
|
||||
|
@@ -2592,12 +2592,13 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer the
|
||||
}
|
||||
|
||||
// Set background colors (only gradient background supported)
|
||||
if (myBgGradientArray != NULL && myBgGradientArray->IsDefined())
|
||||
if (myBackgrounds[Graphic3d_TOB_GRADIENT] != NULL
|
||||
&& myBackgrounds[Graphic3d_TOB_GRADIENT]->IsDefined())
|
||||
{
|
||||
theProgram->SetUniform (theGlContext,
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBgGradientArray->GradientColor (0));
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0));
|
||||
theProgram->SetUniform (theGlContext,
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], myBgGradientArray->GradientColor (1));
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -74,60 +74,76 @@ namespace
|
||||
void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
{
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
|
||||
if (!myBgTextureArray->IsDefined() // no texture
|
||||
&& !myBgGradientArray->IsDefined()) // no gradient
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Boolean wasUsedZBuffer = theWorkspace->SetUseZBuffer (Standard_False);
|
||||
if (wasUsedZBuffer)
|
||||
{
|
||||
aCtx->core11fwd->glDisable (GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
// Drawing background gradient if:
|
||||
// - gradient fill type is not Aspect_GFM_NONE and
|
||||
// - either background texture is no specified or it is drawn in Aspect_FM_CENTERED mode
|
||||
if (myBgGradientArray->IsDefined()
|
||||
&& (!myTextureParams->Aspect()->ToMapTexture()
|
||||
|| myBgTextureArray->TextureFillMethod() == Aspect_FM_CENTERED
|
||||
|| myBgTextureArray->TextureFillMethod() == Aspect_FM_NONE))
|
||||
if (myBackgroundType == Graphic3d_TOB_CUBEMAP)
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
GLint aShadingModelOld = GL_SMOOTH;
|
||||
if (aCtx->core11 != NULL
|
||||
&& aCtx->caps->ffpEnable)
|
||||
{
|
||||
aCtx->core11fwd->glDisable (GL_LIGHTING);
|
||||
aCtx->core11fwd->glGetIntegerv (GL_SHADE_MODEL, &aShadingModelOld);
|
||||
aCtx->core11->glShadeModel (GL_SMOOTH);
|
||||
}
|
||||
#endif
|
||||
Graphic3d_Camera aCamera (theWorkspace->View()->Camera());
|
||||
aCamera.SetZRange (0.01, 1.0); // is needed to avoid perspective camera exception
|
||||
aCamera.SetProjectionType (Graphic3d_Camera::Projection_Perspective);
|
||||
|
||||
myBgGradientArray->Render (theWorkspace);
|
||||
aCtx->ProjectionState.Push();
|
||||
aCtx->ProjectionState.SetCurrent (aCamera.ProjectionMatrixF());
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (aCtx->core11 != NULL
|
||||
&& aCtx->caps->ffpEnable)
|
||||
{
|
||||
aCtx->core11->glShadeModel (aShadingModelOld);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
myCubeMapParams->Aspect()->ShaderProgram()->PushVariableInt ("uZCoeff", myBackgroundCubeMap->ZIsInverted() ? -1 : 1);
|
||||
myCubeMapParams->Aspect()->ShaderProgram()->PushVariableInt ("uYCoeff", myBackgroundCubeMap->IsTopDown() ? 1 : -1);
|
||||
const OpenGl_Aspects* anOldAspectFace = theWorkspace->SetAspects (myCubeMapParams);
|
||||
|
||||
// Drawing background image if it is defined
|
||||
// (texture is defined and fill type is not Aspect_FM_NONE)
|
||||
if (myBgTextureArray->IsDefined()
|
||||
&& myTextureParams->Aspect()->ToMapTexture())
|
||||
{
|
||||
aCtx->core11fwd->glDisable (GL_BLEND);
|
||||
myBackgrounds[Graphic3d_TOB_CUBEMAP]->Render (theWorkspace);
|
||||
|
||||
const OpenGl_Aspects* anOldAspectFace = theWorkspace->SetAspects (myTextureParams);
|
||||
myBgTextureArray->Render (theWorkspace);
|
||||
aCtx->ProjectionState.Pop();
|
||||
aCtx->ApplyProjectionMatrix();
|
||||
theWorkspace->SetAspects (anOldAspectFace);
|
||||
}
|
||||
else if (myBackgroundType == Graphic3d_TOB_GRADIENT
|
||||
|| myBackgroundType == Graphic3d_TOB_TEXTURE)
|
||||
{
|
||||
// Drawing background gradient if:
|
||||
// - gradient fill type is not Aspect_GFM_NONE and
|
||||
// - either background texture is no specified or it is drawn in Aspect_FM_CENTERED mode
|
||||
if (myBackgrounds[Graphic3d_TOB_GRADIENT]->IsDefined()
|
||||
&& (!myTextureParams->Aspect()->ToMapTexture()
|
||||
|| myBackgrounds[Graphic3d_TOB_TEXTURE]->TextureFillMethod() == Aspect_FM_CENTERED
|
||||
|| myBackgrounds[Graphic3d_TOB_TEXTURE]->TextureFillMethod() == Aspect_FM_NONE))
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
GLint aShadingModelOld = GL_SMOOTH;
|
||||
if (aCtx->core11 != NULL
|
||||
&& aCtx->caps->ffpEnable)
|
||||
{
|
||||
aCtx->core11fwd->glDisable (GL_LIGHTING);
|
||||
aCtx->core11fwd->glGetIntegerv (GL_SHADE_MODEL, &aShadingModelOld);
|
||||
aCtx->core11->glShadeModel (GL_SMOOTH);
|
||||
}
|
||||
#endif
|
||||
|
||||
myBackgrounds[Graphic3d_TOB_GRADIENT]->Render(theWorkspace);
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (aCtx->core11 != NULL
|
||||
&& aCtx->caps->ffpEnable)
|
||||
{
|
||||
aCtx->core11->glShadeModel (aShadingModelOld);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Drawing background image if it is defined
|
||||
// (texture is defined and fill type is not Aspect_FM_NONE)
|
||||
if (myBackgrounds[Graphic3d_TOB_TEXTURE]->IsDefined()
|
||||
&& myTextureParams->Aspect()->ToMapTexture())
|
||||
{
|
||||
aCtx->core11fwd->glDisable (GL_BLEND);
|
||||
|
||||
const OpenGl_Aspects* anOldAspectFace = theWorkspace->SetAspects (myTextureParams);
|
||||
myBackgrounds[Graphic3d_TOB_TEXTURE]->Render (theWorkspace);
|
||||
theWorkspace->SetAspects (anOldAspectFace);
|
||||
}
|
||||
}
|
||||
|
||||
if (wasUsedZBuffer)
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include <OpenGl_Matrix.hxx>
|
||||
#include <OpenGl_ShaderObject.hxx>
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
#include <OpenGl_TextParam.hxx>
|
||||
#include <OpenGl_TextureBufferArb.hxx>
|
||||
#include <OpenGl_RenderFilter.hxx>
|
||||
#include <OpenGl_Vec.hxx>
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
@@ -33,17 +34,14 @@ void Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup,
|
||||
const TCollection_ExtendedString& theText,
|
||||
const gp_Pnt& theAttachmentPoint)
|
||||
{
|
||||
Standard_Real x, y, z;
|
||||
theAttachmentPoint.Coord(x,y,z);
|
||||
|
||||
theGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||
theGroup->Text (theText,
|
||||
Graphic3d_Vertex(x,y,z),
|
||||
theAspect->Height(),
|
||||
theAspect->Angle(),
|
||||
theAspect->Orientation(),
|
||||
theAspect->HorizontalJustification(),
|
||||
theAspect->VerticalJustification());
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (theAttachmentPoint);
|
||||
aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
|
||||
aText->SetVerticalAlignment (theAspect->VerticalJustification());
|
||||
theGroup->AddText (aText);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -57,13 +55,12 @@ void Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup,
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
theGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||
theGroup->Text (theText,
|
||||
theOrientation,
|
||||
theAspect->Height(),
|
||||
theAspect->Angle(),
|
||||
theAspect->Orientation(),
|
||||
theAspect->HorizontalJustification(),
|
||||
theAspect->VerticalJustification(),
|
||||
Standard_True,
|
||||
theHasOwnAnchor);
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetOrientation (theOrientation);
|
||||
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||
aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
|
||||
aText->SetVerticalAlignment (theAspect->VerticalJustification());
|
||||
theGroup->AddText (aText);
|
||||
}
|
||||
|
@@ -1414,6 +1414,8 @@ static Standard_Integer reshape(Draw_Interpretor& /*theDI*/,
|
||||
|
||||
Handle(BRepTools_ReShape) aReShaper = new BRepTools_ReShape;
|
||||
|
||||
TopAbs_ShapeEnum aShapeLevel = TopAbs_SHAPE;
|
||||
|
||||
// Record the requested modifications
|
||||
for ( Standard_Integer i = 3; i < theArgc; ++i )
|
||||
{
|
||||
@@ -1462,6 +1464,50 @@ static Standard_Integer reshape(Draw_Interpretor& /*theDI*/,
|
||||
|
||||
aReShaper->Remove(aWhat);
|
||||
}
|
||||
else if (anOpt == "-until")
|
||||
{
|
||||
if (theArgc - i < 2)
|
||||
{
|
||||
std::cout << "Error: not enough arguments for level specification\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_CString aLevelCStr = theArgv[++i];
|
||||
TCollection_AsciiString aLevelStr(aLevelCStr);
|
||||
aLevelStr.LowerCase();
|
||||
if (aLevelStr == "compound" ||
|
||||
aLevelStr == "cd")
|
||||
aShapeLevel = TopAbs_COMPOUND;
|
||||
else if (aLevelStr == "compsolid" ||
|
||||
aLevelStr == "c")
|
||||
aShapeLevel = TopAbs_COMPSOLID;
|
||||
else if (aLevelStr == "solid" ||
|
||||
aLevelStr == "so")
|
||||
aShapeLevel = TopAbs_SOLID;
|
||||
else if (aLevelStr == "shell" ||
|
||||
aLevelStr == "sh")
|
||||
aShapeLevel = TopAbs_SHELL;
|
||||
else if (aLevelStr == "face" ||
|
||||
aLevelStr == "f")
|
||||
aShapeLevel = TopAbs_FACE;
|
||||
else if (aLevelStr == "wire" ||
|
||||
aLevelStr == "w")
|
||||
aShapeLevel = TopAbs_WIRE;
|
||||
else if (aLevelStr == "edge" ||
|
||||
aLevelStr == "e")
|
||||
aShapeLevel = TopAbs_EDGE;
|
||||
else if (aLevelStr == "vertex" ||
|
||||
aLevelStr == "v")
|
||||
aShapeLevel = TopAbs_VERTEX;
|
||||
else if (aLevelStr == "shape" ||
|
||||
aLevelStr == "s")
|
||||
aShapeLevel = TopAbs_SHAPE;
|
||||
else
|
||||
{
|
||||
std::cout << "Error: unknown shape type '" << theArgv[i] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: invalid syntax at " << anOpt << "\n" ;
|
||||
@@ -1470,7 +1516,7 @@ static Standard_Integer reshape(Draw_Interpretor& /*theDI*/,
|
||||
}
|
||||
|
||||
// Apply all the recorded modifications
|
||||
TopoDS_Shape aResult = aReShaper->Apply(aSource);
|
||||
TopoDS_Shape aResult = aReShaper->Apply(aSource, aShapeLevel);
|
||||
if ( aResult.IsNull() )
|
||||
{
|
||||
std::cout << "Error: result shape is null\n";
|
||||
@@ -1589,10 +1635,12 @@ static Standard_Integer reshape(Draw_Interpretor& /*theDI*/,
|
||||
theCommands.Add ("copytranslate","result shape dx dy dz",__FILE__,copytranslate,g);
|
||||
|
||||
theCommands.Add ("reshape",
|
||||
"\n reshape : result shape [-replace what with] [-remove what]"
|
||||
"\n reshape : result shape [-replace what with] [-remove what] [-until level]"
|
||||
"\n Basic utility for topological modification: "
|
||||
"\n '-replace what with' Replaces 'what' sub-shape with 'with' sub-shape"
|
||||
"\n '-remove what' Removes 'what' sub-shape"
|
||||
"\n Requests '-replace' and '-remove' can be repeated many times.",
|
||||
"\n Requests '-replace' and '-remove' can be repeated many times."
|
||||
"\n '-until level' specifies level until which shape for replcement/removal"
|
||||
"\n will be searched.",
|
||||
__FILE__, reshape, g);
|
||||
}
|
||||
|
@@ -51,6 +51,7 @@ SelectMgr_TriangularFrustumSet.hxx
|
||||
SelectMgr_TypeOfBVHUpdate.hxx
|
||||
SelectMgr_TypeOfUpdate.hxx
|
||||
SelectMgr_VectorTypes.hxx
|
||||
SelectMgr_ViewClipRange.cxx
|
||||
SelectMgr_ViewClipRange.hxx
|
||||
SelectMgr_ViewerSelector.cxx
|
||||
SelectMgr_ViewerSelector.hxx
|
||||
|
@@ -146,6 +146,7 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)&
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
|
||||
const SelectMgr_Vec3& /*theBoxMax*/,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& /*thePickResult*/) const
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -167,6 +168,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBox
|
||||
// purpose : Intersection test between defined volume and given point
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& ) const
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -190,6 +192,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) cons
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
|
||||
Select3D_TypeOfSensitivity /*theSensType*/,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& ) const
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -206,6 +209,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
|
||||
const gp_Pnt& /*thePt2*/,
|
||||
const gp_Pnt& /*thePt3*/,
|
||||
Select3D_TypeOfSensitivity /*theSensType*/,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& ) const
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -217,6 +221,7 @@ Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
|
||||
const gp_Pnt& /*thePnt2*/,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& ) const
|
||||
{
|
||||
return Standard_False;
|
||||
|
@@ -17,23 +17,16 @@
|
||||
#define _SelectMgr_BaseFrustum_HeaderFile
|
||||
|
||||
#include <gp_GTrsf.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_ClipPlane.hxx>
|
||||
#include <Graphic3d_SequenceOfHClipPlane.hxx>
|
||||
#include <Graphic3d_WorldViewProjState.hxx>
|
||||
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
|
||||
#include <Select3D_BndBox3d.hxx>
|
||||
#include <SelectMgr_FrustumBuilder.hxx>
|
||||
#include <Select3D_TypeOfSensitivity.hxx>
|
||||
#include <SelectMgr_FrustumBuilder.hxx>
|
||||
#include <SelectMgr_VectorTypes.hxx>
|
||||
|
||||
#include <SelectMgr_ViewClipRange.hxx>
|
||||
#include <SelectBasics_PickResult.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
|
||||
//! This class is an interface for different types of selecting frustums,
|
||||
//! defining different selection types, like point, box or polyline
|
||||
@@ -120,6 +113,7 @@ public:
|
||||
//! SAT intersection test between defined volume and given axis-aligned box
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
|
||||
const SelectMgr_Vec3& theBoxMax,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
|
||||
@@ -130,6 +124,7 @@ public:
|
||||
|
||||
//! Intersection test between defined volume and given point
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const;
|
||||
|
||||
//! Intersection test between defined volume and given point
|
||||
@@ -143,11 +138,13 @@ public:
|
||||
//! boundary line defined by segments depending on given sensitivity type
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const;
|
||||
|
||||
//! Checks if line segment overlaps selecting frustum
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const;
|
||||
|
||||
//! SAT intersection test between defined volume and given triangle. The test may
|
||||
@@ -157,6 +154,7 @@ public:
|
||||
const gp_Pnt& thePt2,
|
||||
const gp_Pnt& thePt3,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const;
|
||||
|
||||
//! Measures distance between 3d projection of user-picked
|
||||
@@ -165,17 +163,6 @@ public:
|
||||
|
||||
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const;
|
||||
|
||||
//! Valid for point selection only!
|
||||
//! Computes depth range for clipping planes.
|
||||
//! @param theViewPlanes global view planes
|
||||
//! @param theObjPlanes object planes
|
||||
virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
|
||||
const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes)
|
||||
{
|
||||
(void )theViewPlanes;
|
||||
(void )theObjPlanes;
|
||||
}
|
||||
|
||||
//! Stores plane equation coefficients (in the following form:
|
||||
//! Ax + By + Cz + D = 0) to the given vector
|
||||
virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
|
||||
|
@@ -342,8 +342,6 @@ void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d &thePoint)
|
||||
// {i, j, k} vectors and store them to corresponding class fields
|
||||
cacheVertexProjections (this);
|
||||
|
||||
myViewClipRange.SetVoid();
|
||||
|
||||
myScale = 1.0;
|
||||
}
|
||||
|
||||
@@ -372,8 +370,6 @@ void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d& theMinPnt,
|
||||
// {i, j, k} vectors and store them to corresponding class fields
|
||||
cacheVertexProjections (this);
|
||||
|
||||
myViewClipRange.SetVoid();
|
||||
|
||||
myScale = 1.0;
|
||||
}
|
||||
|
||||
@@ -464,8 +460,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_RectangularFrustum::ScaleAndTransform (c
|
||||
|
||||
cacheVertexProjections (aRes.get());
|
||||
|
||||
aRes->myViewClipRange = myViewClipRange;
|
||||
aRes->myMousePos = myMousePos;
|
||||
aRes->myMousePos = myMousePos;
|
||||
|
||||
return aRes;
|
||||
}
|
||||
@@ -490,6 +485,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin,
|
||||
const SelectMgr_Vec3& theBoxMax,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
if (!hasOverlap (theBoxMin, theBoxMax))
|
||||
@@ -512,10 +508,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
|
||||
|
||||
aDepth = aNearestPnt.Distance (myNearPickedPnt);
|
||||
thePickResult.SetDepth (aDepth);
|
||||
return isViewClippingOk (thePickResult);
|
||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
if (!myViewClipRange.GetNearestDepth (aRange, aDepth))
|
||||
if (!theClipRange.GetNearestDepth (aRange, aDepth))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -530,6 +526,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
|
||||
// purpose : Intersection test between defined volume and given point
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
if (!hasOverlap (thePnt))
|
||||
@@ -542,7 +539,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
|
||||
thePickResult.SetDepth (aDetectedPnt.Distance (myNearPickedPnt) * myScale);
|
||||
thePickResult.SetPickedPoint (thePnt);
|
||||
|
||||
return isViewClippingOk (thePickResult);
|
||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -560,6 +557,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt) c
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
if (!hasOverlap (thePnt1, thePnt2))
|
||||
@@ -567,7 +565,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
|
||||
segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
|
||||
|
||||
return isViewClippingOk (thePickResult);
|
||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -579,6 +577,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
if (theSensType == Select3D_TOS_BOUNDARY)
|
||||
@@ -614,7 +613,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
|
||||
if (aPolyNorm.Magnitude() <= Precision::Confusion())
|
||||
{
|
||||
// treat degenerated polygon as point
|
||||
return Overlaps (theArrayOfPnts.First(), thePickResult);
|
||||
return Overlaps (theArrayOfPnts.First(), theClipRange, thePickResult);
|
||||
}
|
||||
else if (!segmentPlaneIntersection (aPolyNorm, theArrayOfPnts.First(), thePickResult))
|
||||
{
|
||||
@@ -622,7 +621,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
|
||||
}
|
||||
}
|
||||
|
||||
return isViewClippingOk (thePickResult);
|
||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -636,13 +635,14 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
if (theSensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
|
||||
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 4);
|
||||
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
|
||||
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
|
||||
}
|
||||
else if (theSensType == Select3D_TOS_INTERIOR)
|
||||
{
|
||||
@@ -669,7 +669,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_XYZ aDiff = myNearPickedPnt.XYZ() - thePnt1.XYZ();
|
||||
thePickResult.SetDepth (aTriangleNormal.Dot (aDiff) * myScale);
|
||||
thePickResult.SetPickedPoint (thePnt1);
|
||||
return isViewClippingOk (thePickResult);
|
||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
gp_XYZ anEdge = (thePnt1.XYZ() - myNearPickedPnt.XYZ()) * (1.0 / anAlpha);
|
||||
@@ -687,7 +687,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
{
|
||||
thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
|
||||
thePickResult.SetPickedPoint (aPtOnPlane);
|
||||
return isViewClippingOk (thePickResult);
|
||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
gp_Pnt aPnts[3] = {thePnt1, thePnt2, thePnt3};
|
||||
@@ -707,7 +707,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], thePickResult);
|
||||
}
|
||||
|
||||
return isViewClippingOk (thePickResult);
|
||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -730,119 +730,6 @@ gp_Pnt SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth
|
||||
return myNearPickedPnt.XYZ() + myViewRayDir.Normalized().XYZ() * theDepth / myScale;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : computeClippingRange
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
|
||||
SelectMgr_ViewClipRange& theRange) const
|
||||
{
|
||||
Standard_Real aPlaneA, aPlaneB, aPlaneC, aPlaneD;
|
||||
for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
|
||||
{
|
||||
const Handle(Graphic3d_ClipPlane)& aClipPlane = aPlaneIt.Value();
|
||||
if (!aClipPlane->IsOn())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Bnd_Range aSubRange (RealFirst(), RealLast());
|
||||
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
|
||||
{
|
||||
const gp_Pln aGeomPlane = aSubPlaneIter->ToPlane();
|
||||
aGeomPlane.Coefficients (aPlaneA, aPlaneB, aPlaneC, aPlaneD);
|
||||
|
||||
const gp_XYZ& aPlaneDirXYZ = aGeomPlane.Axis().Direction().XYZ();
|
||||
Standard_Real aDotProduct = myViewRayDir.XYZ().Dot (aPlaneDirXYZ);
|
||||
Standard_Real aDistance = -myNearPickedPnt.XYZ().Dot (aPlaneDirXYZ) - aPlaneD;
|
||||
Standard_Real aDistToPln = 0.0;
|
||||
|
||||
// check whether the pick line is parallel to clip plane
|
||||
if (Abs (aDotProduct) < Precision::Angular())
|
||||
{
|
||||
if (aDistance < 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
aDistToPln = RealLast();
|
||||
aDotProduct = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// compute distance to point of pick line intersection with the plane
|
||||
const Standard_Real aParam = aDistance / aDotProduct;
|
||||
|
||||
const gp_Pnt anIntersectionPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aParam;
|
||||
aDistToPln = anIntersectionPnt.Distance (myNearPickedPnt);
|
||||
if (aParam < 0.0)
|
||||
{
|
||||
// the plane is "behind" the ray
|
||||
aDistToPln = -aDistToPln;
|
||||
}
|
||||
}
|
||||
|
||||
// change depth limits for case of opposite and directed planes
|
||||
if (!aClipPlane->IsChain())
|
||||
{
|
||||
if (aDotProduct < 0.0)
|
||||
{
|
||||
theRange.ChangeUnclipRange().TrimTo (aDistToPln);
|
||||
}
|
||||
else
|
||||
{
|
||||
theRange.ChangeUnclipRange().TrimFrom (aDistToPln);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aDotProduct < 0.0)
|
||||
{
|
||||
aSubRange.TrimFrom (aDistToPln);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSubRange.TrimTo (aDistToPln);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!aSubRange.IsVoid()
|
||||
&& aClipPlane->IsChain())
|
||||
{
|
||||
theRange.AddClipSubRange (aSubRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetViewClipping
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void SelectMgr_RectangularFrustum::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
|
||||
const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes)
|
||||
{
|
||||
myViewClipRange.SetVoid();
|
||||
if (!theViewPlanes.IsNull()
|
||||
&& !theViewPlanes->IsEmpty())
|
||||
{
|
||||
computeClippingRange (*theViewPlanes, myViewClipRange);
|
||||
}
|
||||
if (!theObjPlanes.IsNull()
|
||||
&& !theObjPlanes->IsEmpty())
|
||||
{
|
||||
computeClippingRange (*theObjPlanes, myViewClipRange);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : isViewClippingOk
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
return !myViewClipRange.IsClipped (thePickResult.Depth());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetPlanes
|
||||
// purpose :
|
||||
|
@@ -17,7 +17,6 @@
|
||||
#define _SelectMgr_RectangularFrustum_HeaderFile
|
||||
|
||||
#include <SelectMgr_Frustum.hxx>
|
||||
#include <SelectMgr_ViewClipRange.hxx>
|
||||
|
||||
//! This class contains representation of rectangular selecting frustum, created in case
|
||||
//! of point and box selection, and algorithms for overlap detection between selecting
|
||||
@@ -59,6 +58,7 @@ public:
|
||||
//! SAT intersection test between defined volume and given axis-aligned box
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
|
||||
const SelectMgr_Vec3& theBoxMax,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
|
||||
//! Intersection test between defined volume and given point
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Intersection test between defined volume and given point
|
||||
@@ -79,11 +80,13 @@ public:
|
||||
//! boundary line defined by segments depending on given sensitivity type
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Checks if line segment overlaps selecting frustum
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! SAT intersection test between defined volume and given triangle. The test may
|
||||
@@ -93,6 +96,7 @@ public:
|
||||
const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Measures distance between 3d projection of user-picked
|
||||
@@ -102,19 +106,6 @@ public:
|
||||
//! Calculates the point on a view ray that was detected during the run of selection algo by given depth
|
||||
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
|
||||
|
||||
//! Valid for point selection only!
|
||||
//! Computes depth range for clipping planes.
|
||||
//! @param theViewPlanes global view planes
|
||||
//! @param theObjPlanes object planes
|
||||
Standard_EXPORT virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
|
||||
const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes) Standard_OVERRIDE;
|
||||
|
||||
//! Return clipping range.
|
||||
const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
|
||||
|
||||
//! Set clipping range.
|
||||
void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
|
||||
|
||||
//! A set of helper functions that return rectangular selecting frustum data
|
||||
inline const gp_Pnt* GetVertices() const { return myVertices; }
|
||||
|
||||
@@ -128,6 +119,9 @@ public:
|
||||
//! correspondingly) onto far view frustum plane
|
||||
inline const gp_Pnt& GetFarPnt() const { return myFarPickedPnt; }
|
||||
|
||||
//! Return view ray direction.
|
||||
const gp_Vec& GetViewRayDirection() const { return myViewRayDir; }
|
||||
|
||||
//! Return mouse coordinates.
|
||||
const gp_Pnt2d& GetMousePosition() const { return myMousePos; }
|
||||
|
||||
@@ -145,13 +139,6 @@ protected:
|
||||
const gp_Pnt& thePntOnPlane,
|
||||
SelectBasics_PickResult& thePickResult) const;
|
||||
|
||||
//! Computes valid depth range for the given clipping planes
|
||||
Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
|
||||
SelectMgr_ViewClipRange& theRange) const;
|
||||
|
||||
//! Returns false if theDepth must be clipped by current view clip range
|
||||
Standard_EXPORT Standard_Boolean isViewClippingOk (const SelectBasics_PickResult& thePickResult) const;
|
||||
|
||||
private:
|
||||
|
||||
void cacheVertexProjections (SelectMgr_RectangularFrustum* theFrustum) const;
|
||||
@@ -169,7 +156,6 @@ private:
|
||||
gp_Vec myViewRayDir;
|
||||
gp_Pnt2d myMousePos; //!< Mouse coordinates
|
||||
Standard_Real myScale; //!< Scale factor of applied transformation, if there was any
|
||||
SelectMgr_ViewClipRange myViewClipRange;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -62,6 +62,7 @@ SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTrans
|
||||
aMgr.mySelectingVolumes[myActiveSelectionType / 2]->SetBuilder (theBuilder);
|
||||
aMgr.myViewClipPlanes = myViewClipPlanes;
|
||||
aMgr.myObjectClipPlanes = myObjectClipPlanes;
|
||||
aMgr.myViewClipRange = myViewClipRange;
|
||||
|
||||
return aMgr;
|
||||
}
|
||||
@@ -242,7 +243,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const SelectMgr_Vec
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, thePickResult);
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, myViewClipRange, thePickResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -269,8 +270,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePn
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt,
|
||||
thePickResult);
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt, myViewClipRange, thePickResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -299,9 +299,8 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const Handle(TColgp
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
|
||||
(Select3D_TypeOfSensitivity)theSensType,
|
||||
thePickResult);
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(), (Select3D_TypeOfSensitivity)theSensType,
|
||||
myViewClipRange, thePickResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -318,9 +317,8 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
|
||||
(Select3D_TypeOfSensitivity)theSensType,
|
||||
thePickResult);
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts, (Select3D_TypeOfSensitivity)theSensType,
|
||||
myViewClipRange, thePickResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -334,7 +332,7 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePickResult);
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, myViewClipRange, thePickResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -353,11 +351,8 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const gp_Pnt& thePt
|
||||
if (myActiveSelectionType == Unknown)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1,
|
||||
thePt2,
|
||||
thePt3,
|
||||
(Select3D_TypeOfSensitivity)theSensType,
|
||||
thePickResult);
|
||||
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePt3, (Select3D_TypeOfSensitivity)theSensType,
|
||||
myViewClipRange, thePickResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -463,7 +458,18 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_S
|
||||
if (myActiveSelectionType != Point)
|
||||
return;
|
||||
|
||||
mySelectingVolumes[Frustum]->SetViewClipping (theViewPlanes, theObjPlanes);
|
||||
const SelectMgr_RectangularFrustum* aFrustum = reinterpret_cast<const SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get());
|
||||
myViewClipRange.SetVoid();
|
||||
if (!theViewPlanes.IsNull()
|
||||
&& !theViewPlanes->IsEmpty())
|
||||
{
|
||||
myViewClipRange.AddClippingPlanes (*theViewPlanes, gp_Ax1 (aFrustum->GetNearPnt(), aFrustum->GetViewRayDirection()));
|
||||
}
|
||||
if (!theObjPlanes.IsNull()
|
||||
&& !theObjPlanes->IsEmpty())
|
||||
{
|
||||
myViewClipRange.AddClippingPlanes (*theObjPlanes, gp_Ax1 (aFrustum->GetNearPnt(), aFrustum->GetViewRayDirection()));
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -472,11 +478,7 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_S
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectingVolumeManager::SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther)
|
||||
{
|
||||
myViewClipPlanes = theOther.ViewClipping();
|
||||
myObjectClipPlanes = theOther.ObjectClipping();
|
||||
if (myActiveSelectionType != Point)
|
||||
return;
|
||||
|
||||
const SelectMgr_RectangularFrustum* aFrOther = reinterpret_cast<const SelectMgr_RectangularFrustum*>(theOther.mySelectingVolumes[Frustum].get());
|
||||
reinterpret_cast<SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get())->SetViewClipRanges (aFrOther->ViewClipRanges());
|
||||
myViewClipPlanes = theOther.myViewClipPlanes;
|
||||
myObjectClipPlanes = theOther.myObjectClipPlanes;
|
||||
myViewClipRange = theOther.myViewClipRange;
|
||||
}
|
||||
|
@@ -181,6 +181,12 @@ public:
|
||||
//! Copy clipping planes from another volume manager.
|
||||
Standard_EXPORT void SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther);
|
||||
|
||||
//! Return clipping range.
|
||||
const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
|
||||
|
||||
//! Set clipping range.
|
||||
void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
|
||||
|
||||
//! A set of helper functions that return rectangular selecting frustum data
|
||||
Standard_EXPORT const gp_Pnt* GetVertices() const;
|
||||
|
||||
@@ -236,6 +242,7 @@ private:
|
||||
Handle(SelectMgr_BaseFrustum) mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes
|
||||
Handle(Graphic3d_SequenceOfHClipPlane) myViewClipPlanes; //!< view clipping planes
|
||||
Handle(Graphic3d_SequenceOfHClipPlane) myObjectClipPlanes; //!< object clipping planes
|
||||
SelectMgr_ViewClipRange myViewClipRange;
|
||||
Standard_Boolean myToAllowOverlap; //!< Defines if partially overlapped entities will me detected or not
|
||||
};
|
||||
|
||||
|
@@ -169,6 +169,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustum::ScaleAndTransform (co
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt,
|
||||
const SelectMgr_Vec3& theMaxPt,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& /*thePickResult*/) const
|
||||
{
|
||||
return hasOverlap (theMinPt, theMaxPt);
|
||||
@@ -192,6 +193,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& th
|
||||
// purpose : Intersection test between defined volume and given point
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& /*thePickResult*/) const
|
||||
{
|
||||
return hasOverlap (thePnt);
|
||||
@@ -206,6 +208,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& /*thePickResult*/) const
|
||||
{
|
||||
if (theSensType == Select3D_TOS_BOUNDARY)
|
||||
@@ -237,6 +240,7 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const SelectMgr_ViewClipRange& /*theClipRange*/,
|
||||
SelectBasics_PickResult& /*thePickResult*/) const
|
||||
{
|
||||
return hasOverlap (thePnt1, thePnt2);
|
||||
@@ -253,13 +257,14 @@ Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
if (theSensType == Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
|
||||
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3);
|
||||
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
|
||||
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
|
||||
}
|
||||
else if (theSensType == Select3D_TOS_INTERIOR)
|
||||
{
|
||||
|
@@ -48,6 +48,7 @@ public:
|
||||
//! SAT intersection test between defined volume and given axis-aligned box
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
|
||||
const SelectMgr_Vec3& theMaxPnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
|
||||
@@ -58,6 +59,7 @@ public:
|
||||
|
||||
//! Intersection test between defined volume and given point
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! SAT intersection test between defined volume and given ordered set of points,
|
||||
@@ -65,11 +67,13 @@ public:
|
||||
//! boundary line defined by segments depending on given sensitivity type
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Checks if line segment overlaps selecting frustum
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! SAT intersection test between defined volume and given triangle. The test may
|
||||
@@ -79,6 +83,7 @@ public:
|
||||
const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Nullifies the handle to corresponding builder instance to prevent memory leaks
|
||||
|
@@ -127,11 +127,12 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_TriangularFrustumSet::ScaleAndTransform
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt,
|
||||
const SelectMgr_Vec3& theMaxPnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
|
||||
{
|
||||
if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, thePickResult))
|
||||
if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, theClipRange, thePickResult))
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -160,11 +161,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3&
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
|
||||
{
|
||||
if (anIter.Value()->Overlaps (thePnt, thePickResult))
|
||||
if (anIter.Value()->Overlaps (thePnt, theClipRange, thePickResult))
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -177,11 +179,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
|
||||
{
|
||||
if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, thePickResult))
|
||||
if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, theClipRange, thePickResult))
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -194,11 +197,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1Of
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
|
||||
{
|
||||
if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePickResult))
|
||||
if (anIter.Value()->Overlaps (thePnt1, thePnt2, theClipRange, thePickResult))
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -213,11 +217,12 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1
|
||||
const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const
|
||||
{
|
||||
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
|
||||
{
|
||||
if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, thePickResult))
|
||||
if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, theClipRange, thePickResult))
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
|
||||
const SelectMgr_Vec3& theMaxPnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
|
||||
@@ -59,20 +60,24 @@ public:
|
||||
Standard_Boolean* theInside) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
|
||||
const gp_Pnt& thePnt2,
|
||||
const gp_Pnt& thePnt3,
|
||||
Select3D_TypeOfSensitivity theSensType,
|
||||
const SelectMgr_ViewClipRange& theClipRange,
|
||||
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
|
||||
|
||||
//! Stores plane equation coefficients (in the following form:
|
||||
|
104
src/SelectMgr/SelectMgr_ViewClipRange.cxx
Normal file
104
src/SelectMgr/SelectMgr_ViewClipRange.cxx
Normal file
@@ -0,0 +1,104 @@
|
||||
// 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.
|
||||
|
||||
#include <SelectMgr_ViewClipRange.hxx>
|
||||
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <Graphic3d_SequenceOfHClipPlane.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : AddClippingPlanes
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
|
||||
const gp_Ax1& thePickRay)
|
||||
{
|
||||
const gp_Dir& aViewRayDir = thePickRay.Direction();
|
||||
const gp_Pnt& aNearPnt = thePickRay.Location();
|
||||
|
||||
Graphic3d_Vec4d aPlaneABCD;
|
||||
for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
|
||||
{
|
||||
const Handle(Graphic3d_ClipPlane)& aClipPlane = aPlaneIt.Value();
|
||||
if (!aClipPlane->IsOn())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Bnd_Range aSubRange (RealFirst(), RealLast());
|
||||
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
|
||||
{
|
||||
const gp_Pln aGeomPlane = aSubPlaneIter->ToPlane();
|
||||
aGeomPlane.Coefficients (aPlaneABCD[0], aPlaneABCD[1], aPlaneABCD[2], aPlaneABCD[3]);
|
||||
|
||||
const gp_XYZ& aPlaneDirXYZ = aGeomPlane.Axis().Direction().XYZ();
|
||||
Standard_Real aDotProduct = aViewRayDir.XYZ().Dot (aPlaneDirXYZ);
|
||||
Standard_Real aDistance = -aNearPnt.XYZ().Dot (aPlaneDirXYZ) - aPlaneABCD[3];
|
||||
Standard_Real aDistToPln = 0.0;
|
||||
|
||||
// check whether the pick line is parallel to clip plane
|
||||
if (Abs (aDotProduct) < Precision::Angular())
|
||||
{
|
||||
if (aDistance < 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
aDistToPln = RealLast();
|
||||
aDotProduct = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// compute distance to point of pick line intersection with the plane
|
||||
const Standard_Real aParam = aDistance / aDotProduct;
|
||||
|
||||
const gp_Pnt anIntersectionPnt = aNearPnt.XYZ() + aViewRayDir.XYZ() * aParam;
|
||||
aDistToPln = anIntersectionPnt.Distance (aNearPnt);
|
||||
if (aParam < 0.0)
|
||||
{
|
||||
// the plane is "behind" the ray
|
||||
aDistToPln = -aDistToPln;
|
||||
}
|
||||
}
|
||||
|
||||
// change depth limits for case of opposite and directed planes
|
||||
if (!aClipPlane->IsChain())
|
||||
{
|
||||
if (aDotProduct < 0.0)
|
||||
{
|
||||
ChangeUnclipRange().TrimTo (aDistToPln);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeUnclipRange().TrimFrom (aDistToPln);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aDotProduct < 0.0)
|
||||
{
|
||||
aSubRange.TrimFrom (aDistToPln);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSubRange.TrimTo (aDistToPln);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!aSubRange.IsVoid()
|
||||
&& aClipPlane->IsChain())
|
||||
{
|
||||
AddClipSubRange (aSubRange);
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,6 +19,11 @@
|
||||
#include <Bnd_Range.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class gp_Ax1;
|
||||
class Graphic3d_SequenceOfHClipPlane;
|
||||
|
||||
//! Class for handling depth clipping range.
|
||||
//! It is used to perform checks in case if global (for the whole view)
|
||||
//! clipping planes are defined inside of SelectMgr_RectangularFrustum class methods.
|
||||
@@ -93,6 +98,8 @@ public:
|
||||
return !theRange.IsOut (theDepth);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Clears clipping range.
|
||||
void SetVoid()
|
||||
{
|
||||
@@ -100,6 +107,10 @@ public:
|
||||
myUnclipRange = Bnd_Range (RealFirst(), RealLast());
|
||||
}
|
||||
|
||||
//! Add clipping planes. Planes and picking ray should be defined in the same coordinate system.
|
||||
Standard_EXPORT void AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
|
||||
const gp_Ax1& thePickRay);
|
||||
|
||||
//! Returns the main unclipped range; [-inf, inf] by default.
|
||||
Bnd_Range& ChangeUnclipRange() { return myUnclipRange; }
|
||||
|
||||
|
@@ -414,7 +414,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
Standard_Integer aHead = -1;
|
||||
Standard_Integer aNode = 0; // a root node
|
||||
SelectMgr_FrustumCache aScaledTrnsfFrustums;
|
||||
SelectMgr_SelectingVolumeManager aTmpMgr;
|
||||
SelectMgr_SelectingVolumeManager aTmpMgr (false);
|
||||
for (;;)
|
||||
{
|
||||
if (!aSensitivesTree->IsOuter (aNode))
|
||||
|
@@ -1671,7 +1671,8 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aMapVE;
|
||||
Standard_Integer j;
|
||||
TopTools_MapOfShape VerticesToAvoid;
|
||||
for (j = 1; j <= SeqEdges.Length(); j++)
|
||||
const Standard_Integer aNbE = SeqEdges.Length();
|
||||
for (j = 1; j <= aNbE; j++)
|
||||
{
|
||||
TopoDS_Edge anEdge = TopoDS::Edge(SeqEdges(j));
|
||||
// fill in the map V-E
|
||||
@@ -1690,22 +1691,16 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
|
||||
|
||||
// do loop while there are unused edges
|
||||
TopTools_MapOfShape aUsedEdges;
|
||||
for (;;)
|
||||
|
||||
for (Standard_Integer iE = 1; iE <= aNbE; ++iE)
|
||||
{
|
||||
TopoDS_Edge edge;
|
||||
for(j=1; j <= SeqEdges.Length(); j++)
|
||||
{
|
||||
edge = TopoDS::Edge(SeqEdges.Value(j));
|
||||
if (!aUsedEdges.Contains(edge))
|
||||
break;
|
||||
}
|
||||
if (j > SeqEdges.Length())
|
||||
break; // all edges have been used
|
||||
TopoDS_Edge edge = TopoDS::Edge (SeqEdges (iE));
|
||||
if (!aUsedEdges.Add (edge))
|
||||
continue;
|
||||
|
||||
// make chain for unite
|
||||
TopTools_SequenceOfShape aChain;
|
||||
aChain.Append(edge);
|
||||
aUsedEdges.Add(edge);
|
||||
TopoDS_Vertex V[2];
|
||||
TopExp::Vertices(edge, V[0], V[1], Standard_True);
|
||||
|
||||
@@ -2214,32 +2209,16 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
|
||||
//Correct orientation of edges
|
||||
for (Standard_Integer ii = 1; ii <= edges.Length(); ii++)
|
||||
{
|
||||
const TopoDS_Shape& anEdge = edges(ii);
|
||||
const TopTools_ListOfShape& aLF = aMapEF.FindFromKey(anEdge);
|
||||
const TopoDS_Shape& anEdge = edges (ii);
|
||||
Standard_Integer indE = aMapEF.FindIndex (anEdge);
|
||||
const TopTools_ListOfShape& aLF = aMapEF (indE);
|
||||
if (myAllowInternal &&
|
||||
myKeepShapes.Contains(anEdge) &&
|
||||
aLF.Extent() == 2)
|
||||
edges(ii).Orientation(TopAbs_INTERNAL);
|
||||
|
||||
if (anEdge.Orientation() != TopAbs_INTERNAL)
|
||||
for (Standard_Integer jj = 1; jj <= faces.Length(); jj++)
|
||||
{
|
||||
const TopoDS_Shape aCurFace = faces(jj);
|
||||
Standard_Boolean found = Standard_False;
|
||||
TopExp_Explorer Explo(aCurFace, TopAbs_EDGE);
|
||||
for (; Explo.More(); Explo.Next())
|
||||
{
|
||||
const TopoDS_Shape& aCurEdge = Explo.Current();
|
||||
if (anEdge.IsSame(aCurEdge))
|
||||
{
|
||||
edges(ii) = aCurEdge;
|
||||
found = Standard_True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
edges (ii) = aMapEF.FindKey (indE);
|
||||
}
|
||||
|
||||
//Exclude internal edges
|
||||
@@ -2588,6 +2567,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
|
||||
RemoveEdgeFromMap(CurEdge, VEmap);
|
||||
}
|
||||
} //for (;;)
|
||||
aNewWire.Closed(Standard_True);
|
||||
UsedEdges.Add(StartEdge);
|
||||
|
||||
//Remove used edges from sequence
|
||||
@@ -2691,10 +2671,11 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
|
||||
}
|
||||
else if (NewFaces.Length() == 1)
|
||||
{
|
||||
TopoDS_Shape aNewFace = NewFaces(1).Oriented (TopAbs_FORWARD);
|
||||
for (Standard_Integer ii = 1; ii <= NewWires.Length(); ii++)
|
||||
BB.Add(NewFaces(1), NewWires(ii));
|
||||
BB.Add(aNewFace, NewWires(ii));
|
||||
for (Standard_Integer ii = 1; ii <= InternalWires.Length(); ii++)
|
||||
BB.Add(NewFaces(1), InternalWires(ii));
|
||||
BB.Add(aNewFace, InternalWires(ii));
|
||||
myContext->Merge(faces, NewFaces(1));
|
||||
}
|
||||
else
|
||||
|
@@ -283,7 +283,6 @@ namespace
|
||||
static Standard_Boolean shadeFromShape (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
@@ -299,9 +298,6 @@ namespace
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
|
||||
aGroup->SetClosed (theIsClosed);
|
||||
aGroup->SetGroupPrimitivesAspect (theDrawer->ShadingAspect()->Aspect());
|
||||
if (!theCappingStyle.IsNull())
|
||||
aGroup->SetGroupPrimitivesAspect (theCappingStyle);
|
||||
|
||||
aGroup->AddPrimitiveArray (aPArray);
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -521,12 +517,11 @@ void StdPrs_ShadedShape::ExploreSolids (const TopoDS_Shape& theShape,
|
||||
void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const StdPrs_Volume theVolume)
|
||||
{
|
||||
gp_Pnt2d aDummy;
|
||||
StdPrs_ShadedShape::Add (thePrs, theShape, theDrawer,
|
||||
Standard_False, aDummy, aDummy, aDummy, theCappingStyle, theVolume);
|
||||
Standard_False, aDummy, aDummy, aDummy, theVolume);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -540,7 +535,6 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const StdPrs_Volume theVolume)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
@@ -578,20 +572,20 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
|
||||
if (aClosed.NbChildren() > 0)
|
||||
{
|
||||
shadeFromShape (aClosed, thePrs, theDrawer, theCappingStyle,
|
||||
shadeFromShape (aClosed, thePrs, theDrawer,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, true);
|
||||
}
|
||||
|
||||
if (anOpened.NbChildren() > 0)
|
||||
{
|
||||
shadeFromShape (anOpened, thePrs, theDrawer, theCappingStyle,
|
||||
shadeFromShape (anOpened, thePrs, theDrawer,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the shape type is not compound, composolid or solid, use autodetection back-facing filled
|
||||
shadeFromShape (theShape, thePrs, theDrawer, theCappingStyle,
|
||||
shadeFromShape (theShape, thePrs, theDrawer,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale,
|
||||
theVolume == StdPrs_Volume_Closed);
|
||||
}
|
||||
|
@@ -38,25 +38,13 @@ public:
|
||||
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
|
||||
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
|
||||
//! or to perform Autodetection (would split input shape into two groups)
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
|
||||
StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
|
||||
//! Shades <theShape> with texture coordinates.
|
||||
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
|
||||
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
|
||||
//! or to perform Autodetection (would split input shape into two groups)
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
|
||||
const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const Standard_Boolean theHasTexels, const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
|
||||
//! Searches closed and unclosed subshapes in shape structure and puts them
|
||||
//! into two compounds for separate processing of closed and unclosed sub-shapes
|
||||
|
@@ -501,6 +501,21 @@ void V3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle, const Stan
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : SetBackgroundCubeMap
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void V3d_View::SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Boolean theToUpdate)
|
||||
{
|
||||
myView->SetBackgroundCubeMap (theCubeMap);
|
||||
|
||||
if (myImmediateUpdate || theToUpdate)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : SetAxis
|
||||
//purpose :
|
||||
|
@@ -228,6 +228,10 @@ public:
|
||||
Standard_EXPORT void SetBgImageStyle (const Aspect_FillMethod theFillStyle,
|
||||
const Standard_Boolean theToUpdate = Standard_False);
|
||||
|
||||
//! Sets environment cubemap as interactive background.
|
||||
Standard_EXPORT void SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Boolean theToUpdate = Standard_False);
|
||||
|
||||
//! Definition of an axis from its origin and
|
||||
//! its orientation .
|
||||
//! This will be the current axis for rotations and movements.
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Structure.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <V3d.hxx>
|
||||
@@ -547,17 +548,26 @@ void V3d_Viewer::DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const
|
||||
const gp_Pnt pX (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.XDirection().XYZ());
|
||||
aPrims->AddVertex (p0);
|
||||
aPrims->AddVertex (pX);
|
||||
aGroup->Text ("X", Graphic3d_Vertex (pX.X(), pX.Y(), pX.Z()), 1.0 / 81.0);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f / 81.0f);
|
||||
aText->SetText ("X");
|
||||
aText->SetPosition (pX);
|
||||
aGroup->AddText (aText);
|
||||
|
||||
const gp_Pnt pY (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.YDirection().XYZ());
|
||||
aPrims->AddVertex (p0);
|
||||
aPrims->AddVertex (pY);
|
||||
aGroup->Text ("Y", Graphic3d_Vertex (pY.X(), pY.Y(), pY.Z()), 1.0 / 81.0);
|
||||
aText = new Graphic3d_Text (1.0f / 81.0f);
|
||||
aText->SetText ("Y");
|
||||
aText->SetPosition (pY);
|
||||
aGroup->AddText (aText);
|
||||
|
||||
const gp_Pnt pZ (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.Direction().XYZ());
|
||||
aPrims->AddVertex (p0);
|
||||
aPrims->AddVertex (pZ);
|
||||
aGroup->Text ("Z", Graphic3d_Vertex (pZ.X(), pZ.Y(), pZ.Z()), 1.0 / 81.0);
|
||||
aText = new Graphic3d_Text (1.0f / 81.0f);
|
||||
aText->SetText ("Z");
|
||||
aText->SetPosition (pZ);
|
||||
aGroup->AddText (aText);
|
||||
|
||||
aGroup->AddPrimitiveArray (aPrims);
|
||||
|
||||
|
@@ -41,6 +41,8 @@
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_ClipPlane.hxx>
|
||||
#include <Graphic3d_CubeMapPacked.hxx>
|
||||
#include <Graphic3d_CubeMapSeparate.hxx>
|
||||
#include <Graphic3d_GraduatedTrihedron.hxx>
|
||||
#include <Graphic3d_NameOfTextureEnv.hxx>
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
@@ -241,13 +243,13 @@ namespace
|
||||
// Defines possible commands related to background changing
|
||||
enum BackgroundCommand
|
||||
{
|
||||
BackgroundCommand_Main, //!< The main command that manages other commands through options
|
||||
BackgroundCommand_Image, //!< Sets an image as a background
|
||||
BackgroundCommand_ImageMode, //!< Changes a background image mode
|
||||
BackgroundCommand_Gradient, //!< Sets a gradient as a background
|
||||
BackgroundCommand_GradientMode, //!< Changes a background gradient mode
|
||||
BackgroundCommand_Color, //!< Fills background with a specified color
|
||||
BackgroundCommand_Default //!< Sets the background default color or gradient
|
||||
BackgroundCommand_Main, //!< The main command that manages other commands through options
|
||||
BackgroundCommand_Image, //!< Sets an image as a background
|
||||
BackgroundCommand_ImageMode, //!< Changes a background image mode
|
||||
BackgroundCommand_Gradient, //!< Sets a gradient as a background
|
||||
BackgroundCommand_GradientMode, //!< Changes a background gradient mode
|
||||
BackgroundCommand_Color, //!< Fills background with a specified color
|
||||
BackgroundCommand_Default //!< Sets the background default color or gradient
|
||||
};
|
||||
|
||||
//! Map from background command names to its codes
|
||||
@@ -258,13 +260,13 @@ namespace
|
||||
static BackgroundCommandNameMap createBackgroundCommandNameMap()
|
||||
{
|
||||
BackgroundCommandNameMap aBackgroundCommandNameMap;
|
||||
aBackgroundCommandNameMap["vbackground"] = BackgroundCommand_Main;
|
||||
aBackgroundCommandNameMap["vsetbg"] = BackgroundCommand_Image;
|
||||
aBackgroundCommandNameMap["vsetbgmode"] = BackgroundCommand_ImageMode;
|
||||
aBackgroundCommandNameMap["vsetgradientbg"] = BackgroundCommand_Gradient;
|
||||
aBackgroundCommandNameMap["vsetgrbgmode"] = BackgroundCommand_GradientMode;
|
||||
aBackgroundCommandNameMap["vsetcolorbg"] = BackgroundCommand_Color;
|
||||
aBackgroundCommandNameMap["vsetdefaultbg"] = BackgroundCommand_Default;
|
||||
aBackgroundCommandNameMap["vbackground"] = BackgroundCommand_Main;
|
||||
aBackgroundCommandNameMap["vsetbg"] = BackgroundCommand_Image;
|
||||
aBackgroundCommandNameMap["vsetbgmode"] = BackgroundCommand_ImageMode;
|
||||
aBackgroundCommandNameMap["vsetgradientbg"] = BackgroundCommand_Gradient;
|
||||
aBackgroundCommandNameMap["vsetgrbgmode"] = BackgroundCommand_GradientMode;
|
||||
aBackgroundCommandNameMap["vsetcolorbg"] = BackgroundCommand_Color;
|
||||
aBackgroundCommandNameMap["vsetdefaultbg"] = BackgroundCommand_Default;
|
||||
return aBackgroundCommandNameMap;
|
||||
}
|
||||
|
||||
@@ -405,9 +407,21 @@ namespace
|
||||
//! the option key for the command that sets default background gradient or color
|
||||
ViewerTest_CommandOptionKey myDefaultOptionKey;
|
||||
|
||||
//! the option key for the command that sets an environment cubemap as a background
|
||||
ViewerTest_CommandOptionKey myCubeMapOptionKey;
|
||||
|
||||
//! the option key for the command that defines order of tiles in one image packed cubemap
|
||||
ViewerTest_CommandOptionKey myCubeMapOrderOptionKey;
|
||||
|
||||
//! the option key for the command that sets inversion of Z axis for background cubemap
|
||||
ViewerTest_CommandOptionKey myCubeMapInvertedZOptionKey;
|
||||
|
||||
//! the variable set of options that are allowed for the old scenario (without any option passed)
|
||||
CommandOptionKeyVariableSet myUnnamedOptionVariableSet;
|
||||
|
||||
//! the variable set of options that are allowed for setting an environment cubemap as background
|
||||
CommandOptionKeyVariableSet myCubeMapOptionVariableSet;
|
||||
|
||||
//! the variable set of options that are allowed for setting an image as a background
|
||||
CommandOptionKeyVariableSet myImageOptionVariableSet;
|
||||
|
||||
@@ -447,6 +461,11 @@ namespace
|
||||
"DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, CORNER4");
|
||||
myColorOptionKey = myCommandParser.AddOption ("color|col", "background color");
|
||||
myDefaultOptionKey = myCommandParser.AddOption ("default|def", "sets background default gradient or color");
|
||||
|
||||
myCubeMapOptionKey = myCommandParser.AddOption ("cubemap|cmap|cm", "background cubemap");
|
||||
myCubeMapOrderOptionKey = myCommandParser.AddOption ("order|o", "order of sides in one image packed cubemap");
|
||||
myCubeMapInvertedZOptionKey = myCommandParser.AddOption (
|
||||
"invertedz|invz|iz", "whether Z axis is inverted or not during background cubemap rendering");
|
||||
}
|
||||
|
||||
//! Creates option sets used to determine if a passed option set is valid or not
|
||||
@@ -456,6 +475,13 @@ namespace
|
||||
anUnnamedOptionSet.insert (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
|
||||
myUnnamedOptionVariableSet = CommandOptionKeyVariableSet (anUnnamedOptionSet);
|
||||
|
||||
ViewerTest_CommandOptionKeySet aCubeMapOptionSet;
|
||||
aCubeMapOptionSet.insert (myCubeMapOptionKey);
|
||||
ViewerTest_CommandOptionKeySet aCubeMapAdditionalOptionKeySet;
|
||||
aCubeMapAdditionalOptionKeySet.insert (myCubeMapInvertedZOptionKey);
|
||||
aCubeMapAdditionalOptionKeySet.insert (myCubeMapOrderOptionKey);
|
||||
myCubeMapOptionVariableSet = CommandOptionKeyVariableSet (aCubeMapOptionSet, aCubeMapAdditionalOptionKeySet);
|
||||
|
||||
ViewerTest_CommandOptionKeySet anImageOptionSet;
|
||||
anImageOptionSet.insert (myImageOptionKey);
|
||||
ViewerTest_CommandOptionKeySet anImageModeOptionSet;
|
||||
@@ -748,6 +774,10 @@ namespace
|
||||
{
|
||||
const bool isMain = (theBackgroundCommand == BackgroundCommand_Main);
|
||||
const ViewerTest_CommandOptionKeySet aUsedOptions = myCommandParser.GetUsedOptions();
|
||||
if (myCubeMapOptionVariableSet.IsInSet (aUsedOptions) && isMain)
|
||||
{
|
||||
return processCubeMapOptionSet();
|
||||
}
|
||||
if (myImageOptionVariableSet.IsInSet (aUsedOptions)
|
||||
&& (isMain || (theBackgroundCommand == BackgroundCommand_Image)))
|
||||
{
|
||||
@@ -791,6 +821,41 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Process the cubemap option set in named and unnamed case.
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
bool processCubeMapOptionSet() const
|
||||
{
|
||||
NCollection_Array1<TCollection_AsciiString> aFilePaths;
|
||||
|
||||
if (!processCubeMapOptions (aFilePaths))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Graphic3d_CubeMapOrder anOrder = Graphic3d_CubeMapOrder::Default();
|
||||
|
||||
if (myCommandParser.HasOption (myCubeMapOrderOptionKey))
|
||||
{
|
||||
if (!processCubeMapOrderOptions (anOrder))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool aZIsInverted = false;
|
||||
if (myCommandParser.HasOption (myCubeMapInvertedZOptionKey))
|
||||
{
|
||||
if (!processCubeMapInvertedZOptionSet())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
aZIsInverted = true;
|
||||
}
|
||||
|
||||
setCubeMap (aFilePaths, anOrder.Validated(), aZIsInverted);
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Processes the image option set
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
bool processImageOptionSet() const
|
||||
@@ -924,6 +989,79 @@ namespace
|
||||
return printHelp (theBackgroundCommandName, theDrawInterpretor);
|
||||
}
|
||||
|
||||
//! Processes the cubemap option
|
||||
//! @param theFilePaths the array of filenames of cubemap sides
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
bool processCubeMapOptions (NCollection_Array1<TCollection_AsciiString> &theFilePaths) const
|
||||
{
|
||||
const Standard_Integer aNumberOfCubeMapOptionArguments = myCommandParser.GetNumberOfOptionArguments (myCubeMapOptionKey);
|
||||
|
||||
if (aNumberOfCubeMapOptionArguments != 1
|
||||
&& aNumberOfCubeMapOptionArguments != 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
theFilePaths.Resize(0, aNumberOfCubeMapOptionArguments - 1, Standard_False);
|
||||
|
||||
for (int i = 0; i < aNumberOfCubeMapOptionArguments; ++i)
|
||||
{
|
||||
std::string aCubeMapFileName;
|
||||
if (!myCommandParser.Arg (myCubeMapOptionKey, i, aCubeMapFileName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theFilePaths[i] = aCubeMapFileName.c_str();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Processes the cubemap option
|
||||
//! @param theIsNeededToRedraw defines need of redraw after option's processing
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
bool processCubeMapInvertedZOptionSet () const
|
||||
{
|
||||
const Standard_Integer aNumberOfCubeMapZInversionOptionArguments =
|
||||
myCommandParser.GetNumberOfOptionArguments (myCubeMapInvertedZOptionKey);
|
||||
|
||||
if (aNumberOfCubeMapZInversionOptionArguments != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Processes the tiles order option
|
||||
//! @param theOrder the array of indexes if cubemap sides in tile grid
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
bool processCubeMapOrderOptions (Graphic3d_CubeMapOrder& theOrder) const
|
||||
{
|
||||
const Standard_Integer aNumberOfCubeMapOrderOptionArguments = myCommandParser.GetNumberOfOptionArguments(
|
||||
myCubeMapOrderOptionKey);
|
||||
|
||||
if (aNumberOfCubeMapOrderOptionArguments != 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
std::string anOrderItem;
|
||||
if (!myCommandParser.Arg (myCubeMapOrderOptionKey, i, anOrderItem))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
theOrder.Set (Graphic3d_CubeMapSide (i),
|
||||
static_cast<unsigned char> (Draw::Atoi (anOrderItem.c_str())));
|
||||
}
|
||||
|
||||
return theOrder.IsValid();
|
||||
}
|
||||
|
||||
//! Processes the image option
|
||||
//! @param theImageFileName the filename of the image to be used as a background
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
@@ -1078,6 +1216,30 @@ namespace
|
||||
return theDrawInterpretor.PrintHelp (theBackgroundCommandName) == TCL_OK;
|
||||
}
|
||||
|
||||
//! Sets the cubemap as a background
|
||||
//! @param theFileNames the array of filenames of packed or multifile cubemap
|
||||
//! @param theOrder array of cubemap sides indexes mapping them from tiles in packed cubemap
|
||||
static void setCubeMap (const NCollection_Array1<TCollection_AsciiString>& theFileNames,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default(),
|
||||
bool theZIsInverted = false)
|
||||
{
|
||||
const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
|
||||
Handle(Graphic3d_CubeMap) aCubeMap;
|
||||
|
||||
if (theFileNames.Size() == 1)
|
||||
aCubeMap = new Graphic3d_CubeMapPacked(theFileNames[0], theOrder);
|
||||
else
|
||||
aCubeMap = new Graphic3d_CubeMapSeparate(theFileNames);
|
||||
|
||||
aCubeMap->SetZInversion (theZIsInverted);
|
||||
|
||||
aCubeMap->GetParams()->SetFilter(Graphic3d_TOTF_BILINEAR);
|
||||
aCubeMap->GetParams()->SetRepeat(Standard_False);
|
||||
aCubeMap->GetParams()->SetTextureUnit(Graphic3d_TextureUnit_EnvMap);
|
||||
|
||||
aCurrentView->SetBackgroundCubeMap (aCubeMap, Standard_True);
|
||||
}
|
||||
|
||||
//! Sets the image as a background
|
||||
//! @param theImageFileName the filename of the image to be used as a background
|
||||
//! @param theImageMode the fill type used for a background image
|
||||
@@ -9384,7 +9546,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetUseObjectMaterial (toEnable == Standard_True);
|
||||
aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
@@ -9401,7 +9563,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetUseObjectTexture (toEnable == Standard_True);
|
||||
aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
@@ -9416,7 +9578,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetUseObjectShader (toEnable == Standard_True);
|
||||
aClipPlane->SetUseObjectShader (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
@@ -9433,10 +9595,10 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material();
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
|
||||
aMat.SetAmbientColor (aColor);
|
||||
aMat.SetDiffuseColor (aColor);
|
||||
aClipPlane->CappingSectionStyle()->SetMaterial (aMat);
|
||||
aClipPlane->SetCappingMaterial (aMat);
|
||||
anArgIter += aNbParsed;
|
||||
}
|
||||
else if ((aChangeArg == "-transparency"
|
||||
@@ -9444,34 +9606,44 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
&& aNbChangeArgs >= 2)
|
||||
{
|
||||
TCollection_AsciiString aValStr (aChangeArgs[1]);
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = aClipPlane->CappingAspect();
|
||||
if (aValStr.IsRealValue())
|
||||
{
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material();
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
|
||||
aMat.SetTransparency ((float )aValStr.RealValue());
|
||||
aClipPlane->CappingSectionStyle()->SetMaterial (aMat);
|
||||
anAspect->SetAlphaMode (Graphic3d_AlphaMode_BlendAuto);
|
||||
aClipPlane->SetCappingMaterial (aMat);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << aValStr << "'\n";
|
||||
return 1;
|
||||
aValStr.LowerCase();
|
||||
Graphic3d_AlphaMode aMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
if (aValStr == "opaque")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Opaque;
|
||||
}
|
||||
else if (aValStr == "mask")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Mask;
|
||||
}
|
||||
else if (aValStr == "blend")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Blend;
|
||||
}
|
||||
else if (aValStr == "blendauto")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << aValStr << "'\n";
|
||||
return 1;
|
||||
}
|
||||
anAspect->SetAlphaMode (aMode);
|
||||
aClipPlane->SetCappingAspect (anAspect);
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-overrideaspect"
|
||||
|| aChangeArg == "overrideaspect")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->SetToOverrideCappingAspect (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-texname"
|
||||
|| aChangeArg == "texname")
|
||||
{
|
||||
@@ -9485,22 +9657,20 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
|
||||
if (!aTexture->IsDone())
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetTexture (Handle(Graphic3d_TextureMap)());
|
||||
aClipPlane->SetCappingTexture (NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
aTexture->EnableModulate();
|
||||
aTexture->EnableRepeat();
|
||||
aClipPlane->CappingSectionStyle()->SetTexture (aTexture.get());
|
||||
aClipPlane->SetCappingTexture (aTexture);
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-texscale"
|
||||
|| aChangeArg == "texscale")
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
@@ -9514,15 +9684,13 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-texorigin"
|
||||
|| aChangeArg == "texorigin") // texture origin
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
@@ -9537,15 +9705,13 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
|
||||
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-texrotate"
|
||||
|| aChangeArg == "texrotate") // texture rotation
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
@@ -9558,7 +9724,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
}
|
||||
|
||||
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
aHatchTexture->GetParams()->SetRotation (aRot);
|
||||
aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatch"
|
||||
@@ -9570,165 +9736,22 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
TCollection_AsciiString aHatchStr (aChangeArgs[1]);
|
||||
aHatchStr.LowerCase();
|
||||
if (aHatchStr == "on")
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetToDrawHatch (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
aClipPlane->SetCappingHatchOn();
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-hatchtexture"
|
||||
|| aChangeArg == "hatchtexture")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
else if (aHatchStr == "off")
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aTextureName (aChangeArgs[1]);
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
|
||||
if (!aTexture->IsDone())
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetHatchStyle (Handle(Graphic3d_TextureMap)());
|
||||
aClipPlane->SetCappingHatchOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
aTexture->EnableModulate();
|
||||
aTexture->EnableRepeat();
|
||||
aClipPlane->CappingSectionStyle()->SetHatchStyle (aTexture.get());
|
||||
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
|
||||
aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatchstipple"
|
||||
|| aChangeArg == "hatchstipple")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aClipPlane->CappingSectionStyle()->SetHatchStyle ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
|
||||
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatchcolor"
|
||||
|| aChangeArg == "hatchcolor")
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
|
||||
aChangeArgs + 1,
|
||||
aColor);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->HatchMaterial();
|
||||
aMat.SetAmbientColor (aColor);
|
||||
aMat.SetDiffuseColor (aColor);
|
||||
aClipPlane->CappingSectionStyle()->SetHatchMaterial (aMat);
|
||||
anArgIter += aNbParsed;
|
||||
}
|
||||
|
||||
else if (aChangeArg == "-hatchscale"
|
||||
|| aChangeArg == "hatchscale")
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-hatchorigin"
|
||||
|| aChangeArg == "hatchorigin") // texture origin
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
|
||||
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-hatchrotate"
|
||||
|| aChangeArg == "hatchrotate") // texture rotation
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
aHatchTexture->GetParams()->SetRotation (aRot);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatchzoompers"
|
||||
|| aChangeArg == "hatchzoompers")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetHatchZoomPeristent (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-hatchrotatepers"
|
||||
|| aChangeArg == "hatchrotatepers")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetHatchRotationPeristent (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-delete"
|
||||
|| aChangeArg == "delete")
|
||||
{
|
||||
@@ -13641,6 +13664,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
" vbackground -imageMode FillType\n"
|
||||
" vbackground -gradient Color1 Color2 [-gradientMode FillMethod]\n"
|
||||
" vbackground -gradientMode FillMethod\n"
|
||||
" vbackground -cubemap CubemapFile1 [CubeMapFiles2-5] [-order TilesIndexes1-6] [-invertedz]\n"
|
||||
" vbackground -color Color\n"
|
||||
" vbackground -default -gradient Color1 Color2 [-gradientMode FillType]\n"
|
||||
" vbackground -default -color Color\n"
|
||||
@@ -13651,19 +13675,25 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
" -imageMode (-imgMode, -imageMd, -imgMd): sets image fill type\n"
|
||||
" -gradient (-grad, -gr): sets background gradient starting and ending colors\n"
|
||||
" -gradientMode (-gradMode, -gradMd, -grMode, -grMd): sets gradient fill method\n"
|
||||
" -cubemap (-cmap, -cm): sets environmet cubemap as background\n"
|
||||
" -invertedz (-invz, -iz): sets inversion of Z axis for background cubemap rendering\n"
|
||||
" -order (-o): defines order of tiles in one image cubemap\n"
|
||||
" (has no effect in case of multi image cubemaps)\n"
|
||||
" -color (-col): sets background color\n"
|
||||
" -default (-def): sets background default gradient or color\n"
|
||||
" -help (-h): outputs short help message\n"
|
||||
"\n"
|
||||
"Arguments:\n"
|
||||
" Color: Red Green Blue - where Red, Green, Blue must be integers within the range [0, 255]\n"
|
||||
" Color: Red Green Blue - where Red, Green, Blue must be integers within the range [0, 255]\n"
|
||||
" or reals within the range [0.0, 1.0]\n"
|
||||
" ColorName - one of WHITE, BLACK, RED, GREEN, BLUE, etc.\n"
|
||||
" #HHH, [#]HHHHHH - where H is a hexadecimal digit (0 .. 9, a .. f, or A .. F)\n"
|
||||
" FillMethod: one of NONE, HOR[IZONTAL], VER[TICAL], DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, "
|
||||
" ColorName - one of WHITE, BLACK, RED, GREEN, BLUE, etc.\n"
|
||||
" #HHH, [#]HHHHHH - where H is a hexadecimal digit (0 .. 9, a .. f, or A .. F)\n"
|
||||
" FillMethod: one of NONE, HOR[IZONTAL], VER[TICAL], DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, "
|
||||
"CORNER4\n"
|
||||
" FillType: one of CENTERED, TILED, STRETCH, NONE\n"
|
||||
" ImageFile: a name of the file with the image used as a background\n",
|
||||
" FillType: one of CENTERED, TILED, STRETCH, NONE\n"
|
||||
" ImageFile: a name of the file with the image used as a background\n"
|
||||
" CubemapFilei: a name of the file with one image packed cubemap or names of separate files with every cubemap side\n"
|
||||
" TileIndexi: a cubemap side index in range [0, 5] for i tile of one image packed cubemap\n",
|
||||
__FILE__,
|
||||
vbackground,
|
||||
group);
|
||||
@@ -14132,16 +14162,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-color R G B] [-transparency Value] [-hatch {on|off|ID}]"
|
||||
"\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
|
||||
"\n\t\t: [-texRotate Angle]"
|
||||
/*"\n\t\t: [-overrideAspect {0|1}]"
|
||||
"\n\t\t: [-color R G B]"
|
||||
"\n\t\t: [-texture Texture] [-texScale SX SY]"
|
||||
"\n\t\t: [-texOrigin TX TY] [-texRotate Angle]"
|
||||
"\n\t\t: [-hatch {on|off}] [-hatchStipple mask]"
|
||||
"\n\t\t: [-hatchColor R G B] [-hatchTexture texture]"
|
||||
"\n\t\t: [-hatchScale SX SY] [-hatchOrigin TX TY]"
|
||||
"\n\t\t: [-hatchRotate Angle]"
|
||||
"\n\t\t: [-hatchZoomPers {0|1}]"
|
||||
"\n\t\t: [-hatchRotatePers {0|1}]"*/
|
||||
"\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
|
||||
"\n\t\t: [-useObjShader {0|1}]"
|
||||
"\n\t\t: Clipping planes management:"
|
||||
@@ -14154,22 +14174,13 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
|
||||
"\n\t\t: Capping options:"
|
||||
"\n\t\t: -capping {off|on|0|1} turn capping on/off"
|
||||
"\n\t\t: -overrideAspect override presentation aspect (if defined)"
|
||||
"\n\t\t: -color R G B set capping color"
|
||||
"\n\t\t: -transparency Value set capping transparency 0..1"
|
||||
"\n\t\t: -texName Texture set capping texture"
|
||||
"\n\t\t: -texScale SX SY set capping tex scale"
|
||||
"\n\t\t: -texOrigin TX TY set capping tex origin"
|
||||
"\n\t\t: -texRotate Angle set capping tex rotation"
|
||||
"\n\t\t: -hatch {on|off} turn on/off hatch style on capping"
|
||||
"\n\t\t: -hatchStipple ID set stipple mask for drawing hatch"
|
||||
"\n\t\t: -hatchColor R G B set color for hatch material"
|
||||
"\n\t\t: -hatchTexture Texture set texture (semi-opaque) for drawing hatch"
|
||||
"\n\t\t: -hatchScale SX SY set hatch texture scale"
|
||||
"\n\t\t: -hatchOrigin TX TY set hatch texture origin"
|
||||
"\n\t\t: -hatchRotate Angle set hatch texture rotation"
|
||||
"\n\t\t: -hatchZoomPers allow hatch tetxure mapping to be constant when zooming"
|
||||
"\n\t\t: -hatchRotatePers allow hatch tetxure mapping to be constant when rotating"
|
||||
"\n\t\t: -hatch {on|off|ID} set capping hatching mask"
|
||||
"\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
|
||||
"\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
|
||||
"\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
|
||||
|
@@ -378,6 +378,8 @@ void XCAFDoc_GraphNode::Paste(const Handle(TDF_Attribute)& into,
|
||||
if (!func.IsNull())
|
||||
{
|
||||
intof->SetFather(func);
|
||||
if (func->ChildIndex(this) && !func->ChildIndex(intof))
|
||||
func->SetChild(intof);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,6 +393,8 @@ void XCAFDoc_GraphNode::Paste(const Handle(TDF_Attribute)& into,
|
||||
if (!func.IsNull())
|
||||
{
|
||||
intof->SetChild(func);
|
||||
if (func->FatherIndex(this) && !func->FatherIndex(intof))
|
||||
func->SetFather(intof);
|
||||
}
|
||||
}
|
||||
intof->SetGraphID(myGraphID);
|
||||
|
@@ -2108,3 +2108,38 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetNamedProperties
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_NamedData) XCAFDoc_ShapeTool::GetNamedProperties (const TDF_Label& theLabel,
|
||||
const Standard_Boolean theToCreate) const
|
||||
{
|
||||
Handle(TDataStd_NamedData) aNamedProperty;
|
||||
if (!theLabel.FindAttribute(TDataStd_NamedData::GetID(), aNamedProperty) && theToCreate)
|
||||
{
|
||||
aNamedProperty = TDataStd_NamedData::Set(theLabel);
|
||||
}
|
||||
|
||||
return aNamedProperty;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetNamedProperties
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_NamedData) XCAFDoc_ShapeTool::GetNamedProperties (const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theToCreate) const
|
||||
{
|
||||
Handle(TDataStd_NamedData) aNamedProperty;
|
||||
TDF_Label aLabel;
|
||||
if (!Search (theShape, aLabel))
|
||||
return aNamedProperty;
|
||||
|
||||
aNamedProperty = GetNamedProperties (aLabel, theToCreate);
|
||||
|
||||
return aNamedProperty;
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <XCAFDoc_DataMapOfShapeLabel.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <TDataStd_NamedData.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
@@ -410,8 +411,19 @@ public:
|
||||
Standard_EXPORT static Standard_Boolean FindSHUO (const TDF_LabelSequence& Labels, Handle(XCAFDoc_GraphNode)& theSHUOAttr);
|
||||
|
||||
//! Convert Shape (compound/compsolid/shell/wire) to assembly
|
||||
Standard_EXPORT Standard_Boolean Expand (const TDF_Label& Shape) ;
|
||||
Standard_EXPORT Standard_Boolean Expand (const TDF_Label& Shape);
|
||||
|
||||
//! Method to get NamedData attribute assigned to the given shape label.
|
||||
//! @param theLabel [in] the shape Label
|
||||
//! @param theToCreate [in] create and assign attribute if it doesn't exist
|
||||
//! @return Handle to the NamedData attribute or Null if there is none
|
||||
Standard_EXPORT Handle(TDataStd_NamedData) GetNamedProperties (const TDF_Label& theLabel, const Standard_Boolean theToCreate = Standard_False) const;
|
||||
|
||||
//! Method to get NamedData attribute assigned to a label of the given shape.
|
||||
//! @param theShape [in] input shape
|
||||
//! @param theToCreate [in] create and assign attribute if it doesn't exist
|
||||
//! @return Handle to the NamedData attribute or Null if there is none
|
||||
Standard_EXPORT Handle(TDataStd_NamedData) GetNamedProperties(const TopoDS_Shape& theShape, const Standard_Boolean theToCreate = Standard_False) const;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_ShapeTool,TDF_Attribute)
|
||||
|
||||
|
@@ -250,13 +250,27 @@ Handle(XCAFView_Object) XCAFDoc_View::GetObject() const
|
||||
// GDT Points
|
||||
if (!Label().FindChild(ChildLab_GDTPoints, Standard_False).IsNull()) {
|
||||
TDF_Label aPointsLabel = Label().FindChild(ChildLab_GDTPoints);
|
||||
anObj->CreateGDTPoints(aPointsLabel.NbChildren());
|
||||
for (Standard_Integer i = 1; i <= aPointsLabel.NbChildren(); i++) {
|
||||
gp_Pnt aPoint;
|
||||
Handle(TDataXtd_Point) aGDTPointAttr;
|
||||
aPointsLabel.FindChild(i).FindAttribute(TDataXtd_Point::GetID(), aGDTPointAttr);
|
||||
TDataXtd_Geometry::Point(aGDTPointAttr->Label(), aPoint);
|
||||
anObj->SetGDTPoint(i, aPoint);
|
||||
|
||||
// Find out the number of stored GDT-points in Ocaf tree.
|
||||
Standard_Integer aNbGDTPoints = 0;
|
||||
Handle(TDataXtd_Point) aGDTPointAttr;
|
||||
TDF_ChildIterator anItrPnts (aPointsLabel, Standard_False);
|
||||
for (; anItrPnts.More(); anItrPnts.Next()) {
|
||||
if (anItrPnts.Value().FindAttribute (TDataXtd_Point::GetID(), aGDTPointAttr))
|
||||
aNbGDTPoints++;
|
||||
}
|
||||
|
||||
// Allocate the GDT-points and fill them in from Ocaf tree.
|
||||
if (aNbGDTPoints) {
|
||||
anObj->CreateGDTPoints (aNbGDTPoints);
|
||||
const Standard_Integer aNbChildren = aPointsLabel.NbChildren();
|
||||
for (Standard_Integer aLabelIndex = 1, aPointIndex = 1; aLabelIndex <= aNbChildren; aLabelIndex++) {
|
||||
gp_Pnt aPoint;
|
||||
if (aPointsLabel.FindChild (aLabelIndex).FindAttribute (TDataXtd_Point::GetID(), aGDTPointAttr)) {
|
||||
TDataXtd_Geometry::Point (aGDTPointAttr->Label(), aPoint);
|
||||
anObj->SetGDTPoint (aPointIndex++, aPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <Draw.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDataStd_NamedData.hxx>
|
||||
#include <TDF_AttributeSequence.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
@@ -927,6 +928,64 @@ static Standard_Integer updateAssemblies(Draw_Interpretor& di, Standard_Integer
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer XGetProperties(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\nUse: " << argv[0] << " Doc Label\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
DDocStd::GetDocument(argv[1], aDoc);
|
||||
if (aDoc.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << argv[1] << " is not a document\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Label aLabel;
|
||||
TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel);
|
||||
|
||||
// Get XDE shape tool
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
|
||||
|
||||
Handle(TDataStd_NamedData) aNamedData = aShapeTool->GetNamedProperties(aLabel);
|
||||
|
||||
if (aNamedData.IsNull())
|
||||
{
|
||||
di << argv[2] << " has no properties\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (aNamedData->HasIntegers())
|
||||
{
|
||||
TColStd_DataMapOfStringInteger anIntProperties = aNamedData->GetIntegersContainer();
|
||||
for (TColStd_DataMapIteratorOfDataMapOfStringInteger anIter(anIntProperties); anIter.More(); anIter.Next())
|
||||
{
|
||||
di << anIter.Key() << " : " << anIter.Value() << "\n";
|
||||
}
|
||||
}
|
||||
if (aNamedData->HasReals())
|
||||
{
|
||||
TDataStd_DataMapOfStringReal aRealProperties = aNamedData->GetRealsContainer();
|
||||
for (TDataStd_DataMapIteratorOfDataMapOfStringReal anIter(aRealProperties); anIter.More(); anIter.Next())
|
||||
{
|
||||
di << anIter.Key() << " : " << anIter.Value() << "\n";
|
||||
}
|
||||
}
|
||||
if (aNamedData->HasStrings())
|
||||
{
|
||||
TDataStd_DataMapOfStringString aStringProperties = aNamedData->GetStringsContainer();
|
||||
for (TDataStd_DataMapIteratorOfDataMapOfStringString anIter(aStringProperties); anIter.More(); anIter.Next())
|
||||
{
|
||||
di << anIter.Key() << " : " << anIter.Value() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitCommands
|
||||
//purpose :
|
||||
@@ -1039,4 +1098,7 @@ void XDEDRAW_Shapes::InitCommands(Draw_Interpretor& di)
|
||||
|
||||
di.Add ("XUpdateAssemblies","Doc \t: updates assembly compounds",
|
||||
__FILE__, updateAssemblies, g);
|
||||
|
||||
di.Add("XGetProperties", "Doc Label \t: prints named properties assigned to the Label",
|
||||
__FILE__, XGetProperties, g);
|
||||
}
|
||||
|
12
tests/bugs/modalg_7/bug30903
Normal file
12
tests/bugs/modalg_7/bug30903
Normal file
@@ -0,0 +1,12 @@
|
||||
puts "======================================================="
|
||||
puts "0030903: Bug in IntCurvesFace_ShapeIntersector"
|
||||
puts "======================================================="
|
||||
puts ""
|
||||
|
||||
pload QAcommands
|
||||
|
||||
restore [locate_data_file bug30903_shell.brep] s
|
||||
|
||||
if {![regexp "status = -1" [OCC17424 s 132.319855705359 32.8066746022481 -61.4897311243957 0 -0.634115797726033 -0.77323809727294 -1]]} {
|
||||
puts "Error: there must be no intersection point"
|
||||
}
|
16
tests/bugs/modalg_7/bug30905
Normal file
16
tests/bugs/modalg_7/bug30905
Normal file
@@ -0,0 +1,16 @@
|
||||
puts "======================================================="
|
||||
puts "0030905: Modeling Algorithms - Invalid shapes in UnifySameDomain"
|
||||
puts "======================================================="
|
||||
puts ""
|
||||
|
||||
restore [locate_data_file bug30905.brep] a
|
||||
|
||||
unifysamedom result a
|
||||
|
||||
checkshape result
|
||||
|
||||
checknbshapes result -solid 1 -shell 1 -face 56 -wire 61 -edge 148 -vertex 93 -t
|
||||
|
||||
checkprops result -s 835.815 -v 339.409
|
||||
|
||||
checkview -display result -2d -path ${imagedir}/${test_image}.png
|
37
tests/bugs/modalg_7/bug30913_1
Normal file
37
tests/bugs/modalg_7/bug30913_1
Normal file
@@ -0,0 +1,37 @@
|
||||
puts "========"
|
||||
puts "0030913: Invalid result of Fusing slices"
|
||||
puts "========"
|
||||
puts ""
|
||||
|
||||
restore [locate_data_file bug30913_case1.brep] s
|
||||
|
||||
bclearobjects
|
||||
bcleartools
|
||||
set exp [explode s]
|
||||
baddobjects s_1
|
||||
eval baddtools [lrange $exp 1 end]
|
||||
|
||||
# Use gluing Shift option
|
||||
bglue 1
|
||||
# Avoid History filling
|
||||
setfillhistory 0
|
||||
|
||||
bfillds
|
||||
bbop result 1
|
||||
|
||||
checkshape result
|
||||
|
||||
unifysamedom result result
|
||||
|
||||
checkshape result
|
||||
|
||||
checkprops result -s 3.81335e+06 -v 1.39597e+08
|
||||
checknbshapes result -vertex 12042 -edge 18169 -wire 6223 -face 6176 -shell 1 -solid 1 -t
|
||||
|
||||
if {![regexp "This shape seems to be OK" [bopcheck result]]} {
|
||||
puts "Error: result is a self-intersecting shape"
|
||||
}
|
||||
|
||||
checkview -display result -2d -path ${imagedir}/${test_image}.png
|
||||
|
||||
boptions -default
|
39
tests/bugs/modalg_7/bug30913_2
Normal file
39
tests/bugs/modalg_7/bug30913_2
Normal file
@@ -0,0 +1,39 @@
|
||||
puts "========"
|
||||
puts "0030913: Invalid result of Fusing slices"
|
||||
puts "========"
|
||||
puts ""
|
||||
|
||||
restore [locate_data_file bug30913_case2.brep] s
|
||||
|
||||
bclearobjects
|
||||
bcleartools
|
||||
set exp [explode s]
|
||||
baddobjects s_1
|
||||
eval baddtools [lrange $exp 1 end]
|
||||
|
||||
# Use gluing Shift option
|
||||
bglue 1
|
||||
# Avoid History filling
|
||||
setfillhistory 0
|
||||
|
||||
bfillds
|
||||
bbop result 1
|
||||
|
||||
checkshape result
|
||||
|
||||
dchrono unify restart
|
||||
unifysamedom result result
|
||||
dchrono unify stop counter UNIFY_SD
|
||||
|
||||
checkshape result
|
||||
|
||||
checkprops result -s 3.89766e+06 -v 1.40733e+08
|
||||
checknbshapes result -vertex 46597 -edge 70375 -wire 24212 -face 23995 -shell 1 -solid 1 -t
|
||||
|
||||
#if {![regexp "This shape seems to be OK" [bopcheck result]]} {
|
||||
# puts "Error: result is a self-intersecting shape"
|
||||
#}
|
||||
|
||||
checkview -display result -2d -path ${imagedir}/${test_image}.png
|
||||
|
||||
boptions -default
|
15
tests/bugs/modalg_7/bug30927
Normal file
15
tests/bugs/modalg_7/bug30927
Normal file
@@ -0,0 +1,15 @@
|
||||
puts "============================================================================"
|
||||
puts "0030927: Modeling Algorithms - UnifySameDom looses the Closed flag for wires"
|
||||
puts "============================================================================"
|
||||
puts ""
|
||||
|
||||
box b1 10 10 10
|
||||
box b2 5 0 -5 10 10 20
|
||||
bfuse s b1 b2
|
||||
unifysamedom result s
|
||||
|
||||
foreach w [explode result w] {
|
||||
if {![regexp "Closed" [whatis $w]]} {
|
||||
puts "Error: Wire $w is not closed"
|
||||
}
|
||||
}
|
19
tests/bugs/moddata_3/bug29662
Normal file
19
tests/bugs/moddata_3/bug29662
Normal file
@@ -0,0 +1,19 @@
|
||||
puts "==========="
|
||||
puts "0029662"
|
||||
puts "==========="
|
||||
puts ""
|
||||
########################################################
|
||||
# Allow replacement of Compounds via BRepTools_ReShape
|
||||
########################################################
|
||||
|
||||
box b1 10 10 10
|
||||
box b2 10 0 0 10 10 10
|
||||
box b3 0 0 10 10 10 10
|
||||
box b4 10 0 10 10 10 10
|
||||
box b5 20 0 0 10 10 10
|
||||
compound b1 b2 c1
|
||||
compound b3 b4 c2
|
||||
compound c1 c2 c
|
||||
compound b5 c3
|
||||
reshape res c -replace c2 c3 -until compound
|
||||
checknbshapes res -solid 3
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user