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

Compare commits

..

6 Commits

Author SHA1 Message Date
nds
5243bcee98 0030791: Visualization - possibility to display materials by different hatching style for clipping
(cherry picked from commit 63195be7104e23d0f2fbeab695e85c76bbe59e87)
2020-05-28 00:27:40 +03:00
ika
ae58f70718 0031568: Data Exchange - invalid model produced after STEP import
Add protection against reference to reference in STEP import.
2020-05-22 19:32:21 +03:00
kgv
faff37677c 0031478: Visualization, TKOpenGl - allow uploading Cubemap in compressed DDS format when supported by GPU
Graphic3d_TextureRoot::GetCompressedImage() - added new interface for fetching compressed texture image.
Default implementation detects DDS image files using Image_DDSParser parser.

Graphic3d_TextureRoot::GetImage() has been extended with new parameter
- the list of image formats supported by OpenGL driver.
Graphic3d_TextureRoot::convertToCompatible() implicitly converts
BGRA image to RGBA on OpenGL ES, which normally does not support BGR formats.

OpenGl_Caps::isTopDownTextureUV - new property defines how application defines
UV texture coordinates in primitive arrays.
OpenGl_Context::SetTextureMatrix() compares this flag with OpenGl_Texture::IsTopDown()
and automatically flips V coordinate in case of mismatch.

OpenGl_Texture now holds exact number of mipmap levels
instead of Boolean flag indicating that they are defined.
This allows loading DDS files with incomplete mipmap level set
by setting GL_TEXTURE_MAX_LEVEL to appropriate value instead of default 1000
(causing black textures in case if mipmap levels are not defined till 1x1).

Fixed order of texture coordinates transformation within GLSL program to match FFP matrix:
Rotate -> Translate -> Scale (previously Rotation was applied afterwards).
2020-05-22 11:08:34 +03:00
Igor Khozhanov
691711cd3e 0031550: Data Exchange, STEP Import - surface transparency is ignored (SURFACE_STYLE_TRANSPARENT)
Implemented reading and writing transparency to/from step files
2020-05-22 11:07:37 +03:00
ifv
8189cc72d0 0028229: BRep_Builder::Transfert must not raise exception if the input edge is Locked
BRep/BRep_Builder.cxx : raising exception is removed
2020-05-22 11:07:36 +03:00
jgv
c6f14a5213 0031558: BRepOffsetAPI_MakeFilling algorithm makes turned inside out face
1. Modification in method BRepFill_Filling::Build - correction of building the wire.
2. Create new subgroup "filling" in the group "bugs".
2020-05-22 11:07:35 +03:00
202 changed files with 6193 additions and 2266 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 11 KiB

BIN
data/images/hatch_1_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

BIN
data/images/hatch_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

BIN
data/images/hatch_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

BIN
data/images/hatch_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

BIN
data/images/hatch_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 B

BIN
data/images/hatch_6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

BIN
data/images/hatch_7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

BIN
data/images/hatch_8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -3,6 +3,7 @@
#include "Sample2D_Image.h"
#include <Graphic3d_Texture2Dmanual.hxx>
#include <Image_AlienPixMap.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Sample2D_Image,AIS_Shape)
@@ -19,10 +20,13 @@ Sample2D_Image::Sample2D_Image(TCollection_AsciiString& aFileName,
}
void Sample2D_Image::MakeShape()
{
Handle(Graphic3d_Texture1D) anImageTexture =
new Graphic3d_Texture1Dsegment(myFilename);
Standard_Real coeff = (Standard_Real)(anImageTexture->GetImage()->Height())/
(anImageTexture->GetImage()->Width())*myScale;
Standard_Real coeff = 1.0;
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
if (anImage->Load (myFilename))
{
coeff = Standard_Real(anImage->Height()) / Standard_Real(anImage->Width()) * myScale;
}
TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(myX,myY,0.), gp_Pnt(100*myScale+myX,myY,0.));
TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(100*myScale+myX,myY,0.), gp_Pnt(100*myScale+myX,100*coeff+myY,0.));
TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(100*myScale+myX,100*coeff+myY,0.), gp_Pnt(myX,100*coeff+myY,0.));

View File

@@ -637,6 +637,11 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
{
aShadedGroup = thePrs->NewGroup();
aShadedGroup->SetClosed (isClosed);
if (isClosed)
{
if (aDrawer->HasOwnFillCappingAspect())
aShadedGroup->SetGroupPrimitivesAspect (aDrawer->FillCappingAspect());
}
}
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
aShadedGroup->AddPrimitiveArray (aTriangles);

View File

@@ -18,6 +18,7 @@
#include <AIS_InteractiveContext.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>

View File

@@ -176,10 +176,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
try
{
OCC_CATCH_SIGNALS
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
myUVOrigin, myUVRepeat, myUVScale);
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myDrawer->FillCappingAspect());
}
catch (Standard_Failure const& anException)
{

View File

@@ -43,7 +43,10 @@ public:
}
//! Image reader.
virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE { return myImageSource->ReadImage(); }
virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE
{
return myImageSource->ReadImage (theSupported);
}
protected:
Handle(Image_Texture) myImageSource;

View File

@@ -261,7 +261,7 @@ public:
protected:
//! Read image.
virtual Handle(Image_PixMap) ReadImage() const Standard_OVERRIDE
virtual Handle(Image_PixMap) ReadImage (const Handle(Image_SupportedFormats)& ) const Standard_OVERRIDE
{
Handle(VRImagePixmap) aPixmap = new VRImagePixmap();
if (!aPixmap->Load (myVrTextureId, myVrModelName))

View File

@@ -1174,13 +1174,9 @@ void BRep_Builder::Transfert(const TopoDS_Edge& Ein,
const TopoDS_Edge& Eout) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Ein.TShape());
if(TE->Locked())
{
throw TopoDS_LockedShape("BRep_Builder::Transfert");
}
const Standard_Real tol = TE->Tolerance();
BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
const BRep_ListOfCurveRepresentation& lcr = TE->Curves();
BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
while (itcr.More()) {

View File

@@ -149,7 +149,7 @@ void BRepExtrema_DistShapeShape::DistanceMapMap (const TopTools_IndexedMapOfShap
const TopoDS_Shape& aShape1 = theMap1 (aPair.Index1);
const TopoDS_Shape& aShape2 = theMap2 (aPair.Index2);
BRepExtrema_DistanceSS aDistTool (aShape1, aShape2, aBox1, aBox2, myDistRef, myEps, myFlag);
BRepExtrema_DistanceSS aDistTool (aShape1, aShape2, aBox1, aBox2, myDistRef, myEps);
if (aDistTool.IsDone())
{
if (aDistTool.DistValue() < myDistRef - myEps)
@@ -194,7 +194,8 @@ BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape()
myEps (Precision::Confusion()),
myIsInitS1 (Standard_False),
myIsInitS2 (Standard_False),
myFlag (Extrema_ExtFlag_MINMAX)
myFlag (Extrema_ExtFlag_MINMAX),
myAlgo (Extrema_ExtAlgo_Grad)
{
//
}
@@ -205,14 +206,16 @@ BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape()
//=======================================================================
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
const TopoDS_Shape& Shape2,
const Extrema_ExtFlag F)
const Extrema_ExtFlag F,
const Extrema_ExtAlgo A)
: myDistRef (0.0),
myIsDone (Standard_False),
myInnerSol (Standard_False),
myEps (Precision::Confusion()),
myIsInitS1 (Standard_False),
myIsInitS2 (Standard_False),
myFlag (F)
myFlag (F),
myAlgo (A)
{
LoadS1(Shape1);
LoadS2(Shape2);
@@ -227,14 +230,16 @@ BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
const TopoDS_Shape& Shape2,
const Standard_Real theDeflection,
const Extrema_ExtFlag F)
const Extrema_ExtFlag F,
const Extrema_ExtAlgo A)
: myDistRef (0.0),
myIsDone (Standard_False),
myInnerSol (Standard_False),
myEps (theDeflection),
myIsInitS1 (Standard_False),
myIsInitS2 (Standard_False),
myFlag (F)
myFlag (F),
myAlgo (A)
{
LoadS1(Shape1);
LoadS2(Shape2);

View File

@@ -18,6 +18,7 @@
#include <BRepExtrema_SeqOfSolution.hxx>
#include <BRepExtrema_SolutionElem.hxx>
#include <BRepExtrema_SupportType.hxx>
#include <Extrema_ExtAlgo.hxx>
#include <Extrema_ExtFlag.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
@@ -38,9 +39,9 @@ class BRepExtrema_DistShapeShape
Standard_EXPORT BRepExtrema_DistShapeShape();
//! computation of the minimum distance (value and pair of points) using default deflection <br>
//! Default value is Precision::Confusion(). <br>
Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Extrema_ExtFlag F = Extrema_ExtFlag_MIN);
Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
//! create tool and load both shapes into it <br>
Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Standard_Real theDeflection,const Extrema_ExtFlag F = Extrema_ExtFlag_MIN);
Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Standard_Real theDeflection,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
void SetDeflection(const Standard_Real theDeflection)
{
@@ -128,6 +129,11 @@ class BRepExtrema_DistShapeShape
myFlag = F;
}
void SetAlgo(const Extrema_ExtAlgo A)
{
myAlgo = A;
}
private:
//! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br>
@@ -150,6 +156,7 @@ private:
Standard_Boolean myIsInitS1;
Standard_Boolean myIsInitS2;
Extrema_ExtFlag myFlag;
Extrema_ExtAlgo myAlgo;
Bnd_SeqOfBox myBV1;
Bnd_SeqOfBox myBV2;
Bnd_SeqOfBox myBE1;

View File

@@ -772,7 +772,7 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Vertex& S1, const TopoDS_Face&
const Standard_Real Dst=B1.Distance(B2);
if ((Dst < myDstRef - myEps) || (fabs(Dst-myDstRef) < myEps))
{
BRepExtrema_ExtPF Ext(S1,S2,myFlag);
BRepExtrema_ExtPF Ext(S1,S2,myFlag,myAlgo);
const Standard_Integer NbExtrema = Ext.IsDone()? Ext.NbExt() : 0;
if ( NbExtrema > 0 )
{
@@ -828,7 +828,7 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Vertex&
const Standard_Real Dst=B1.Distance(B2);
if ((Dst < myDstRef - myEps) || (fabs(Dst-myDstRef) < myEps))
{
BRepExtrema_ExtPF Ext(S2,S1,myFlag);
BRepExtrema_ExtPF Ext(S2,S1,myFlag,myAlgo);
const Standard_Integer NbExtrema = Ext.IsDone()? Ext.NbExt() : 0;
if ( NbExtrema > 0 )
{

View File

@@ -16,6 +16,7 @@
#include <BRepExtrema_SeqOfSolution.hxx>
#include <Extrema_ExtFlag.hxx>
#include <Extrema_ExtAlgo.hxx>
#include <Precision.hxx>
#include <Standard_DefineAlloc.hxx>
@@ -38,8 +39,9 @@ class BRepExtrema_DistanceSS
BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
const Bnd_Box& B1, const Bnd_Box& B2,
const Standard_Real DstRef,
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX)
: myDstRef(DstRef), myModif(Standard_False), myEps(Precision::Confusion()), myFlag(F)
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
: myDstRef(DstRef), myModif(Standard_False), myEps(Precision::Confusion()), myFlag(F), myAlgo(A)
{
Perform(S1, S2, B1, B2);
}
@@ -50,8 +52,9 @@ class BRepExtrema_DistanceSS
BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
const Bnd_Box& B1, const Bnd_Box& B2,
const Standard_Real DstRef, const Standard_Real aDeflection,
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX)
: myDstRef(DstRef), myModif(Standard_False), myEps(aDeflection), myFlag(F)
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
: myDstRef(DstRef), myModif(Standard_False), myEps(aDeflection), myFlag(F), myAlgo(A)
{
Perform(S1, S2, B1, B2);
}
@@ -80,6 +83,11 @@ class BRepExtrema_DistanceSS
{
myFlag = F;
}
//! sets the flag controlling ...
void SetAlgo(const Extrema_ExtAlgo A)
{
myAlgo = A;
}
private:
@@ -122,6 +130,7 @@ class BRepExtrema_DistanceSS
Standard_Boolean myModif;
Standard_Real myEps;
Extrema_ExtFlag myFlag;
Extrema_ExtAlgo myAlgo;
};
#endif

View File

@@ -32,9 +32,9 @@
//=======================================================================
BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace,
const Extrema_ExtFlag TheFlag)
const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
{
Initialize(TheFace,TheFlag);
Initialize(TheFace,TheFlag,TheAlgo);
Perform(TheVertex,TheFace);
}
@@ -44,7 +44,7 @@ BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoD
//=======================================================================
void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
const Extrema_ExtFlag TheFlag)
const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
{
// cette surface doit etre en champ. Extrema ne fait
// pas de copie et prend seulement un pointeur dessus.
@@ -60,6 +60,7 @@ void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
Standard_Real U1, U2, V1, V2;
BRepTools::UVBounds(TheFace, U1, U2, V1, V2);
myExtPS.SetFlag(TheFlag);
myExtPS.SetAlgo(TheAlgo);
myExtPS.Initialize(mySurf, U1, U2, V1, V2, aTolU, aTolV);
}

View File

@@ -21,6 +21,7 @@
#include <Extrema_SequenceOfPOnSurf.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Extrema_ExtFlag.hxx>
#include <Extrema_ExtAlgo.hxx>
class TopoDS_Vertex;
class TopoDS_Face;
@@ -37,10 +38,12 @@ class BRepExtrema_ExtPF
{}
//! It calculates all the distances. <br>
Standard_EXPORT BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex,const TopoDS_Face& TheFace,
const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX);
const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX,
const Extrema_ExtAlgo TheAlgo = Extrema_ExtAlgo_Grad);
Standard_EXPORT void Initialize(const TopoDS_Face& TheFace,
const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX);
const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX,
const Extrema_ExtAlgo TheAlgo = Extrema_ExtAlgo_Grad);
//! An exception is raised if the fields have not been initialized. <br>
//! Be careful: this method uses the Face only for classify not for the fields. <br>
@@ -76,6 +79,11 @@ class BRepExtrema_ExtPF
myExtPS.SetFlag(F);
}
void SetAlgo(const Extrema_ExtAlgo A)
{
myExtPS.SetAlgo(A);
}
private:
Extrema_ExtPS myExtPS;

View File

@@ -721,6 +721,7 @@ void BRepFill_Filling::Build()
gp_Pnt aPnt = BRep_Tool::Pnt(V1);
NewV1 = BRepLib_MakeVertex(aPnt);
BB.UpdateVertex(NewV1, dmax);
myOldNewMap.Bind(V1.Oriented(TopAbs_FORWARD), NewV1);
}
if (myOldNewMap.IsBound(V2))
@@ -730,6 +731,7 @@ void BRepFill_Filling::Build()
gp_Pnt aPnt = BRep_Tool::Pnt(V2);
NewV2 = BRepLib_MakeVertex(aPnt);
BB.UpdateVertex(NewV2, dmax);
myOldNewMap.Bind(V2.Oriented(TopAbs_FORWARD), NewV2);
}
NewV1.Orientation(TopAbs_FORWARD);
@@ -742,9 +744,6 @@ void BRepFill_Filling::Build()
BRepLib::SameParameter(NewEdge, dmax, Standard_True);
FinalEdges.Append(NewEdge);
myOldNewMap.Bind(InitEdge.Oriented(TopAbs_FORWARD), NewEdge.Oriented(TopAbs_FORWARD));
myOldNewMap.Bind(V1.Oriented(TopAbs_FORWARD), NewV1.Oriented(TopAbs_FORWARD));
if (!V1.IsSame(V2))
myOldNewMap.Bind(V2.Oriented(TopAbs_FORWARD), NewV2.Oriented(TopAbs_FORWARD));
}
TopoDS_Wire FinalWire = WireFromList(FinalEdges);

View File

@@ -23,7 +23,6 @@
#include <BRepLib_MakeFace.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <GCPnts.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
@@ -179,6 +178,39 @@ BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
namespace
{
static void fillParams (const TColStd_Array1OfReal& theKnots,
Standard_Integer theDegree,
Standard_Real theParMin,
Standard_Real theParMax,
NCollection_Vector<Standard_Real>& theParams)
{
Standard_Real aPrevPar = theParMin;
theParams.Append (aPrevPar);
Standard_Integer aNbP = Max (theDegree, 1);
for (Standard_Integer i = 1;
(i < theKnots.Length()) && (theKnots (i) < (theParMax - Precision::PConfusion())); ++i)
{
if (theKnots (i + 1) < theParMin + Precision::PConfusion())
continue;
Standard_Real aStep = (theKnots (i + 1) - theKnots (i)) / aNbP;
for (Standard_Integer k = 1; k <= aNbP ; ++k)
{
Standard_Real aPar = theKnots (i) + k * aStep;
if (aPar > theParMax - Precision::PConfusion())
break;
if (aPar > aPrevPar + Precision::PConfusion())
{
theParams.Append (aPar);
aPrevPar = aPar;
}
}
}
theParams.Append (theParMax);
}
static void fillPoints (const BRepAdaptor_Curve& theCurve,
const NCollection_Vector<Standard_Real> theParams,
@@ -326,13 +358,13 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
aKnots.SetValue (1, GC->FirstParameter());
aKnots.SetValue (2, GC->LastParameter());
GCPnts::FillParams (aKnots, GC->Degree(), dfUf, dfUl, aParams);
fillParams (aKnots, GC->Degree(), dfUf, dfUl, aParams);
break;
}
case GeomAbs_BSplineCurve:
{
Handle(Geom_BSplineCurve) GC = c.BSpline();
GCPnts::FillParams (GC->Knots(), GC->Degree(), dfUf, dfUl, aParams);
fillParams (GC->Knots(), GC->Degree(), dfUf, dfUl, aParams);
break;
}
case GeomAbs_Line:
@@ -359,7 +391,7 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
aBounds.SetValue (1, dfUf);
aBounds.SetValue (2, dfUl);
GCPnts::FillParams (aBounds, iNbPoints - 1, dfUf, dfUl, aParams);
fillParams (aBounds, iNbPoints - 1, dfUf, dfUl, aParams);
}
}

View File

@@ -77,7 +77,7 @@ static Standard_Integer distmini(Draw_Interpretor& di, Standard_Integer n, const
if (n == 5)
aDeflection = Draw::Atof(a[4]);
BRepExtrema_DistShapeShape dst(S1 ,S2, aDeflection, Extrema_ExtFlag_MIN);
BRepExtrema_DistShapeShape dst(S1 ,S2, aDeflection);
if (dst.IsDone())
{

View File

@@ -617,9 +617,9 @@ static Standard_Integer getedgeregul
//=======================================================================
static Standard_Integer projponf(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 3 || n > 4) {
if (n < 3 || n > 5) {
di << "Project point on the face.\n";
di << "Usage: projponf face pnt [extrema flag: -min/-max/-minmax]\n";
di << "Usage: projponf face pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]\n";
return 1;
}
// get face
@@ -642,6 +642,7 @@ static Standard_Integer projponf(Draw_Interpretor& di, Standard_Integer n, const
//
// get projection options
// default values;
Extrema_ExtAlgo anExtAlgo = Extrema_ExtAlgo_Grad;
Extrema_ExtFlag anExtFlag = Extrema_ExtFlag_MINMAX;
//
for (Standard_Integer i = 3; i < n; ++i) {
@@ -654,6 +655,12 @@ static Standard_Integer projponf(Draw_Interpretor& di, Standard_Integer n, const
else if (!strcasecmp(a[i], "-minmax")) {
anExtFlag = Extrema_ExtFlag_MINMAX;
}
else if (!strcasecmp(a[i], "-t")) {
anExtAlgo = Extrema_ExtAlgo_Tree;
}
else if (!strcasecmp(a[i], "-g")) {
anExtAlgo = Extrema_ExtAlgo_Grad;
}
}
//
// get surface
@@ -670,6 +677,7 @@ static Standard_Integer projponf(Draw_Interpretor& di, Standard_Integer n, const
GeomAPI_ProjectPointOnSurf aProjPS;
aProjPS.Init(aSurf, aUMin, aUMax, aVMin, aVMax);
// set the options
aProjPS.SetExtremaAlgo(anExtAlgo);
aProjPS.SetExtremaFlag(anExtFlag);
// perform projection
aProjPS.Perform(aP);
@@ -758,7 +766,7 @@ void BRepTest::SurfaceCommands(Draw_Interpretor& theCommands)
theCommands.Add ("getedgeregularity", "getedgeregularity edge face1 [face2]", __FILE__,getedgeregul,g);
theCommands.Add ("projponf",
"projponf face pnt [extrema flag: -min/-max/-minmax]\n"
"projponf face pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]\n"
"\t\tProject point on the face.",
__FILE__, projponf, g);
}

View File

@@ -66,18 +66,6 @@ public: //! @name Adding elements in BVH
BVH_Object<NumType, Dimension>::myIsDirty = Standard_True;
}
//! Allows to update the box of the element while the tree is not yet built
virtual void UpdateBox (const Standard_Integer theId, const BVH_Box<NumType, Dimension>& theNewBox)
{
if (BVH_Object<NumType, Dimension>::myIsDirty)
{
if (theId >= 0 && theId < Size())
{
myBoxes[theId] = theNewBox;
}
}
}
public: //! @name BVH construction
//! BVH construction

View File

@@ -84,7 +84,7 @@ public: //! @name Necessary overrides for BVH construction
//! Returns the bounding box with the given index.
virtual BVH_Box <NumType, Dimension> Box (const Standard_Integer theIndex) const Standard_OVERRIDE
{
return this->myBoxes[myIndices[theIndex]];
return myBoxes[myIndices[theIndex]];
}
//! Swaps indices of two specified boxes.
@@ -97,7 +97,7 @@ public: //! @name Necessary overrides for BVH construction
//! Returns the Element with the index theIndex.
virtual DataType Element (const Standard_Integer theIndex) const
{
return this->myElements[myIndices[theIndex]];
return myElements[myIndices[theIndex]];
}
protected: //! @name Fields

View File

@@ -88,24 +88,6 @@ public: //! @name Point-Box Square distance
return aDist;
}
//! Computes Max square distance between point and bounding box
static T PointBoxMaxSquareDistance (const BVH_VecNt& thePoint,
const BVH_VecNt& theCMin,
const BVH_VecNt& theCMax)
{
T aDist = 0;
for (int i = 0; i < N; ++i)
{
T dmin = 0, dmax = 0;
if (thePoint[i] > theCMin[i]) { dmin = thePoint[i] - theCMin[i]; }
if (thePoint[i] < theCMax[i]) { dmax = theCMax[i] - thePoint[i]; }
T d = dmin > dmax ? dmin : dmax;
d *= d;
aDist += d;
}
return aDist;
}
public: //! @name Point-Box projection
//! Computes projection of point on bounding box
@@ -128,6 +110,7 @@ public: //! @name Point-Box projection
{
return thePoint.cwiseMax (theCMin).cwiseMin (theCMax);
}
public: //! @name Point-Triangle Square distance
//! Computes square distance between point and triangle

View File

@@ -18,10 +18,6 @@
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Bnd_OBB.hxx>
#include <Bnd_Box.hxx>
#include <Draw_Box.hxx>
// This file defines global functions not declared in any public header,
// intended for use from debugger prompt (Command Window in Visual Studio)
@@ -44,47 +40,3 @@ Standard_EXPORT const char* Draw_Eval (const char *theCommandStr)
return anException.GetMessageString();
}
}
//=======================================================================
//function : DBRep_SetOBB
//purpose : Draw OBB
//=======================================================================
Standard_EXPORT const char* Draw_SetOBB(const char* theNameStr, void* theBox)
{
if (theNameStr == 0 || theBox == 0)
{
return "Error: name or box is null";
}
try {
Bnd_OBB B = *(Bnd_OBB*)theBox;
Handle(Draw_Box) DB = new Draw_Box (B, Draw_orange);
Draw::Set (theNameStr, DB);
return theNameStr;
}
catch (Standard_Failure const& anException)
{
return anException.GetMessageString();
}
}
//=======================================================================
//function : DBRep_SetBox
//purpose : Draw Box
//=======================================================================
Standard_EXPORT const char* Draw_SetBox(const char* theNameStr, void* theBox)
{
if (theNameStr == 0 || theBox == 0)
{
return "Error: name or box is null";
}
try {
Bnd_Box B = *(Bnd_Box*)theBox;
Handle(Draw_Box) DB = new Draw_Box (B, Draw_orange);
Draw::Set (theNameStr, DB);
return theNameStr;
}
catch (Standard_Failure const& anException)
{
return anException.GetMessageString();
}
}

View File

@@ -0,0 +1,27 @@
// Created on: 1991-02-26
// Created by: Isabelle GRIGNON
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Extrema_ExtAlgo_HeaderFile
#define _Extrema_ExtAlgo_HeaderFile
enum Extrema_ExtAlgo
{
Extrema_ExtAlgo_Grad,
Extrema_ExtAlgo_Tree
};
#endif // _Extrema_ExtAlgo_HeaderFile

View File

@@ -17,16 +17,12 @@
#ifndef _Extrema_ExtFlag_HeaderFile
#define _Extrema_ExtFlag_HeaderFile
//! Enumeration describes the objective for extrema algorithms.
//! Generally:
//! - *Extrema_ExtFlag_MIN* - means that only minimal solutions are required
//! - *Extrema_ExtFlag_MAX* - means that only maximal solutions are required
//! - *Extrema_ExtFlag_MINMAX* - means that all solutions are required
enum Extrema_ExtFlag
{
Extrema_ExtFlag_MIN,
Extrema_ExtFlag_MAX,
Extrema_ExtFlag_MINMAX
Extrema_ExtFlag_MIN,
Extrema_ExtFlag_MAX,
Extrema_ExtFlag_MINMAX
};
#endif // _Extrema_ExtFlag_HeaderFile

View File

@@ -144,7 +144,7 @@ void Extrema_ExtPExtS::MakePreciser (Standard_Real& U,
}
//=============================================================================
Extrema_ExtPExtS::Extrema_ExtPExtS (const Handle (Extrema_GenExtPS)& theExtPS)
Extrema_ExtPExtS::Extrema_ExtPExtS()
: myuinf(0.0),
myusup(0.0),
mytolu(0.0),
@@ -153,8 +153,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS (const Handle (Extrema_GenExtPS)& theExtPS)
mytolv(0.0),
myIsAnalyticallyComputable(Standard_False),
myDone(Standard_False),
myNbExt(0),
myExtPS (theExtPS)
myNbExt(0)
{
}
@@ -167,8 +166,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt&
const Standard_Real theVmin,
const Standard_Real theVsup,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Handle(Extrema_GenExtPS)& theExtPS)
const Standard_Real theTolV)
: myuinf(theUmin),
myusup(theUsup),
mytolu(theTolU),
@@ -178,8 +176,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt&
myS (theS),
myIsAnalyticallyComputable(Standard_False),
myDone(Standard_False),
myNbExt(0),
myExtPS (theExtPS)
myNbExt(0)
{
Initialize (theS,
theUmin,
@@ -196,8 +193,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt&
Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt& theP,
const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& theS,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Handle(Extrema_GenExtPS)& theExtPS)
const Standard_Real theTolV)
: myuinf(theS->FirstUParameter()),
myusup(theS->LastUParameter()),
mytolu(theTolU),
@@ -207,8 +203,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt&
myS (theS),
myIsAnalyticallyComputable(Standard_False),
myDone(Standard_False),
myNbExt(0),
myExtPS (theExtPS)
myNbExt(0)
{
Initialize (theS,
theS->FirstUParameter(),
@@ -258,18 +253,15 @@ void Extrema_ExtPExtS::Initialize (const Handle(GeomAdaptor_HSurfaceOfLinearExtr
if (!myIsAnalyticallyComputable)
{
if (myExtPS.IsNull())
myExtPS = new Extrema_GenExtPS();
myExtPS->Initialize (theS->ChangeSurface(),
32,
32,
theUinf,
theUsup,
theVinf,
theVsup,
theTolU,
theTolV);
myExtPS.Initialize (theS->ChangeSurface(),
32,
32,
theUinf,
theUsup,
theVinf,
theVsup,
theTolU,
theTolV);
}
}
@@ -288,9 +280,11 @@ void Extrema_ExtPExtS::Perform (const gp_Pnt& P)
myNbExt = 0;
if (!myIsAnalyticallyComputable) {
myExtPS->Perform(P);
myDone = myExtPS->IsDone();
myNbExt = myExtPS->NbExt();
myExtPS.Perform(P);
myDone = myExtPS.IsDone();
// modified by NIZHNY-EAP Wed Nov 17 12:59:08 1999 ___BEGIN___
myNbExt = myExtPS.NbExt();
// modified by NIZHNY-EAP Wed Nov 17 12:59:09 1999 ___END___
return;
}
@@ -449,8 +443,10 @@ Standard_Boolean Extrema_ExtPExtS::IsDone () const { return myDone; }
Standard_Integer Extrema_ExtPExtS::NbExt () const
{
if (!IsDone()) { throw StdFail_NotDone(); }
return myNbExt;
if (myIsAnalyticallyComputable)
return myNbExt;
else
return myExtPS.NbExt();
}
//=============================================================================
@@ -466,7 +462,7 @@ Standard_Real Extrema_ExtPExtS::SquareDistance (const Standard_Integer N) const
return mySqDist[N-1];
// modified by NIZHNY-MKK Thu Sep 18 14:48:42 2003.END
else
return myExtPS->SquareDistance(N);
return myExtPS.SquareDistance(N);
}
//=============================================================================
@@ -483,7 +479,7 @@ const Extrema_POnSurf& Extrema_ExtPExtS::Point (const Standard_Integer N) const
}
// modified by NIZHNY-MKK Thu Sep 18 14:47:43 2003.END
else
return myExtPS->Point(N);
return myExtPS.Point(N);
}
//=============================================================================

View File

@@ -50,21 +50,15 @@ class Extrema_ExtPExtS : public Standard_Transient
public:
//! theExtPS is used to compute the solutions in case
//! it cannot be found analytically.
Standard_EXPORT Extrema_ExtPExtS(const Handle(Extrema_GenExtPS)& theExtPS);
Standard_EXPORT Extrema_ExtPExtS();
//! It calculates all the distances between a point
//! from gp and a Surface.
//! theExtPS is used to compute the solutions in case
//! it cannot be found analytically.
Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV, const Handle(Extrema_GenExtPS)& theExtPS = NULL);
Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV);
//! It calculates all the distances between a point
//! from gp and a Surface.
//! theExtPS is used to compute the solutions in case
//! it cannot be found analytically.
Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real TolU, const Standard_Real TolV, const Handle(Extrema_GenExtPS)& theExtPS = NULL);
Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real TolU, const Standard_Real TolV);
//! Initializes the fields of the algorithm.
Standard_EXPORT void Initialize (const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real Uinf, const Standard_Real Usup, const Standard_Real Vinf, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV);
@@ -109,12 +103,13 @@ private:
Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) myS;
gp_Vec myDirection;
gp_Ax2 myPosition;
Extrema_GenExtPS myExtPS;
Standard_Boolean myIsAnalyticallyComputable;
Standard_Boolean myDone;
Standard_Integer myNbExt;
Standard_Real mySqDist[4];
Extrema_POnSurf myPoint[4];
Handle(Extrema_GenExtPS) myExtPS;
};

View File

@@ -208,9 +208,7 @@ static Standard_Boolean IsExtremum (const Standard_Real U, const Standard_Real V
//purpose :
//=======================================================================
Extrema_ExtPRevS::Extrema_ExtPRevS(const Handle(Extrema_GenExtPS)& theExtPS)
:
myExtPS (theExtPS)
Extrema_ExtPRevS::Extrema_ExtPRevS()
{
myvinf = myvsup = 0.0;
mytolv = Precision::Confusion();
@@ -235,10 +233,7 @@ Extrema_ExtPRevS::Extrema_ExtPRevS (const gp_Pnt&
const Standard_Real theVmin,
const Standard_Real theVsup,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Handle(Extrema_GenExtPS)& theExtPS)
:
myExtPS (theExtPS)
const Standard_Real theTolV)
{
Initialize (theS,
theUmin,
@@ -258,10 +253,7 @@ Extrema_ExtPRevS::Extrema_ExtPRevS (const gp_Pnt&
Extrema_ExtPRevS::Extrema_ExtPRevS (const gp_Pnt& theP,
const Handle(GeomAdaptor_HSurfaceOfRevolution)& theS,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Handle(Extrema_GenExtPS)& theExtPS)
:
myExtPS (theExtPS)
const Standard_Real theTolV)
{
Initialize (theS,
theS->FirstUParameter(),
@@ -313,18 +305,15 @@ void Extrema_ExtPRevS::Initialize (const Handle(GeomAdaptor_HSurfaceOfRevolution
aNbv = 100;
}
if (myExtPS.IsNull())
myExtPS = new Extrema_GenExtPS();
myExtPS->Initialize (theS->ChangeSurface(),
aNbu,
aNbv,
theUmin,
theUsup,
theVmin,
theVsup,
theTolU,
theTolV);
myExtPS.Initialize (theS->ChangeSurface(),
aNbu,
aNbv,
theUmin,
theUsup,
theVmin,
theVsup,
theTolU,
theTolV);
}
}
//=======================================================================
@@ -337,11 +326,11 @@ void Extrema_ExtPRevS::Perform(const gp_Pnt& P)
myDone = Standard_False;
myNbExt = 0;
if (!myIsAnalyticallyComputable)
{
myExtPS->Perform(P);
myDone = myExtPS->IsDone();
myNbExt = myExtPS->NbExt();
if (!myIsAnalyticallyComputable) {
myExtPS.Perform(P);
myDone = myExtPS.IsDone();
myNbExt = myExtPS.NbExt();
return;
}
@@ -566,7 +555,7 @@ Standard_Real Extrema_ExtPRevS::SquareDistance(const Standard_Integer N) const
if (myIsAnalyticallyComputable)
return mySqDist[N-1];
else
return myExtPS->SquareDistance(N);
return myExtPS.SquareDistance(N);
}
//=======================================================================
//function : Point
@@ -582,7 +571,7 @@ const Extrema_POnSurf& Extrema_ExtPRevS::Point(const Standard_Integer N) const
if (myIsAnalyticallyComputable)
return myPoint[N-1];
else
return myExtPS->Point(N);
return myExtPS.Point(N);
}

View File

@@ -45,21 +45,16 @@ class Extrema_ExtPRevS : public Standard_Transient
public:
//! theExtPS is used to compute the solutions in case
//! it cannot be found analytically.
Standard_EXPORT Extrema_ExtPRevS(const Handle(Extrema_GenExtPS)& theExtPS = NULL);
Standard_EXPORT Extrema_ExtPRevS();
//! It calculates all the distances between a point
//! from gp and a SurfacePtr from Adaptor3d.
//! theExtPS is used to compute the solutions in case
//! it cannot be found analytically.
Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV, const Handle(Extrema_GenExtPS)& theExtPS = NULL);
Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV);
//! It calculates all the distances between a point
//! from gp and a SurfacePtr from Adaptor3d.
//! theExtPS is used to compute the solutions in case
//! it cannot be found analytically.
Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real TolU, const Standard_Real TolV, const Handle(Extrema_GenExtPS)& theExtPS = NULL);
Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real TolU, const Standard_Real TolV);
Standard_EXPORT void Initialize (const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV);
@@ -95,12 +90,13 @@ private:
Standard_Real myvsup;
Standard_Real mytolv;
gp_Ax2 myPosition;
Extrema_GenExtPS myExtPS;
Standard_Boolean myIsAnalyticallyComputable;
Standard_Boolean myDone;
Standard_Integer myNbExt;
Standard_Real mySqDist[8];
Extrema_POnSurf myPoint[8];
Handle(Extrema_GenExtPS) myExtPS;
};

View File

@@ -157,8 +157,12 @@ Extrema_ExtPS::Extrema_ExtPS (const gp_Pnt& theP,
const Adaptor3d_Surface& theS,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Extrema_ExtFlag theTarget)
const Extrema_ExtFlag theF,
const Extrema_ExtAlgo theA)
{
myExtPS.SetFlag (theF);
myExtPS.SetAlgo (theA);
Initialize (theS,
theS.FirstUParameter(),
theS.LastUParameter(),
@@ -167,8 +171,6 @@ Extrema_ExtPS::Extrema_ExtPS (const gp_Pnt& theP,
theTolU,
theTolV);
myExtPS->SetTarget (theTarget);
Perform (theP);
}
@@ -185,8 +187,12 @@ Extrema_ExtPS::Extrema_ExtPS (const gp_Pnt& theP,
const Standard_Real theVsup,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Extrema_ExtFlag theTarget)
const Extrema_ExtFlag theF,
const Extrema_ExtAlgo theA)
{
myExtPS.SetFlag (theF);
myExtPS.SetAlgo (theA);
Initialize (theS,
theUinf,
theUsup,
@@ -195,8 +201,6 @@ Extrema_ExtPS::Extrema_ExtPS (const gp_Pnt& theP,
theTolU,
theTolV);
myExtPS->SetTarget (theTarget);
Perform (theP);
}
@@ -247,10 +251,7 @@ void Extrema_ExtPS::Initialize (const Adaptor3d_Surface& theS,
if(bUIsoIsDeg) nbU = 300;
if(bVIsoIsDeg) nbV = 300;
if (myExtPS.IsNull())
myExtPS = new Extrema_GenExtPS();
myExtPS->Initialize(*myS, nbU, nbV, myuinf, myusup, myvinf, myvsup, mytolu, mytolv);
myExtPS.Initialize(*myS, nbU, nbV, myuinf, myusup, myvinf, myvsup, mytolu, mytolv);
myExtPExtS.Nullify();
myExtPRevS.Nullify();
@@ -291,7 +292,7 @@ void Extrema_ExtPS::Perform(const gp_Pnt& thePoint)
Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) aS (new GeomAdaptor_HSurfaceOfLinearExtrusion (
GeomAdaptor_SurfaceOfLinearExtrusion (myS->BasisCurve(), myS->Direction())));
myExtPExtS = new Extrema_ExtPExtS (thePoint, aS, myuinf, myusup, myvinf, myvsup, mytolu, mytolv, myExtPS);
myExtPExtS = new Extrema_ExtPExtS (thePoint, aS, myuinf, myusup, myvinf, myvsup, mytolu, mytolv);
}
else
{
@@ -317,7 +318,7 @@ void Extrema_ExtPS::Perform(const gp_Pnt& thePoint)
Handle(GeomAdaptor_HSurfaceOfRevolution) aS (new GeomAdaptor_HSurfaceOfRevolution (
GeomAdaptor_SurfaceOfRevolution (myS->BasisCurve(), myS->AxeOfRevolution())));
myExtPRevS = new Extrema_ExtPRevS (thePoint, aS, myuinf, myusup, myvinf, myvsup, mytolu, mytolv, myExtPS);
myExtPRevS = new Extrema_ExtPRevS (thePoint, aS, myuinf, myusup, myvinf, myvsup, mytolu, mytolv);
}
else
{
@@ -338,13 +339,13 @@ void Extrema_ExtPS::Perform(const gp_Pnt& thePoint)
default:
{
myExtPS->Perform (thePoint);
myDone = myExtPS->IsDone();
myExtPS.Perform (thePoint);
myDone = myExtPS.IsDone();
if (myDone)
{
for (Standard_Integer anIdx = 1; anIdx <= myExtPS->NbExt(); ++anIdx)
for (Standard_Integer anIdx = 1; anIdx <= myExtPS.NbExt(); ++anIdx)
{
TreatSolution (myExtPS->Point (anIdx), myExtPS->SquareDistance (anIdx));
TreatSolution (myExtPS.Point (anIdx), myExtPS.SquareDistance (anIdx));
}
}
return;
@@ -410,8 +411,10 @@ void Extrema_ExtPS::TrimmedSquareDistances(Standard_Real& dUfVf,
void Extrema_ExtPS::SetFlag(const Extrema_ExtFlag F)
{
if (myExtPS.IsNull())
myExtPS = new Extrema_GenExtPS();
myExtPS->SetTarget(F);
myExtPS.SetFlag(F);
}
void Extrema_ExtPS::SetAlgo(const Extrema_ExtAlgo A)
{
myExtPS.SetAlgo(A);
}

View File

@@ -31,6 +31,7 @@
#include <TColStd_SequenceOfReal.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Extrema_ExtFlag.hxx>
#include <Extrema_ExtAlgo.hxx>
#include <Standard_Integer.hxx>
class Extrema_ExtPExtS;
class Extrema_ExtPRevS;
@@ -62,11 +63,7 @@ public:
//! TolU et TolV are used to determine the conditions
//! to stop the iterations; at the iteration number n:
//! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
Standard_EXPORT Extrema_ExtPS(const gp_Pnt& P,
const Adaptor3d_Surface& S,
const Standard_Real TolU,
const Standard_Real TolV,
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX);
Standard_EXPORT Extrema_ExtPS(const gp_Pnt& P, const Adaptor3d_Surface& S, const Standard_Real TolU, const Standard_Real TolV, const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
//! It calculates all the distances.
//! NbU and NbV are used to locate the close points
@@ -76,24 +73,10 @@ public:
//! TolU et TolV are used to determine the conditions
//! to stop the iterations; at the iteration number n:
//! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
Standard_EXPORT Extrema_ExtPS(const gp_Pnt& P,
const Adaptor3d_Surface& S,
const Standard_Real Uinf,
const Standard_Real Usup,
const Standard_Real Vinf,
const Standard_Real Vsup,
const Standard_Real TolU,
const Standard_Real TolV,
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX);
Standard_EXPORT Extrema_ExtPS(const gp_Pnt& P, const Adaptor3d_Surface& S, const Standard_Real Uinf, const Standard_Real Usup, const Standard_Real Vinf, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV, const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
//! Initializes the fields of the algorithm.
Standard_EXPORT void Initialize (const Adaptor3d_Surface& S,
const Standard_Real Uinf,
const Standard_Real Usup,
const Standard_Real Vinf,
const Standard_Real Vsup,
const Standard_Real TolU,
const Standard_Real TolV);
Standard_EXPORT void Initialize (const Adaptor3d_Surface& S, const Standard_Real Uinf, const Standard_Real Usup, const Standard_Real Vinf, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV);
//! Computes the distances.
//! An exception is raised if the fieds have not been
@@ -124,6 +107,9 @@ public:
Standard_EXPORT void TrimmedSquareDistances (Standard_Real& dUfVf, Standard_Real& dUfVl, Standard_Real& dUlVf, Standard_Real& dUlVl, gp_Pnt& PUfVf, gp_Pnt& PUfVl, gp_Pnt& PUlVf, gp_Pnt& PUlVl) const;
Standard_EXPORT void SetFlag (const Extrema_ExtFlag F);
Standard_EXPORT void SetAlgo (const Extrema_ExtAlgo A);
@@ -144,7 +130,7 @@ private:
Adaptor3d_SurfacePtr myS;
Standard_Boolean myDone;
Extrema_ExtPElS myExtPElS;
Handle(Extrema_GenExtPS) myExtPS;
Extrema_GenExtPS myExtPS;
Extrema_SequenceOfPOnSurf myPoints;
Standard_Real myuinf;
Standard_Real myusup;

File diff suppressed because it is too large Load Diff

View File

@@ -21,19 +21,18 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Adaptor3d_SurfacePtr.hxx>
#include <BVH_BoxSet.hxx>
#include <BVH_IndexedBoxSet.hxx>
#include <BVH_Traverse.hxx>
#include <Extrema_HArray2OfPOnSurfParams.hxx>
#include <Extrema_FuncPSNorm.hxx>
#include <Extrema_POnSurfParams.hxx>
#include <Extrema_ExtFlag.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
#include <Extrema_HArray2OfPOnSurfParams.hxx>
#include <Extrema_HUBTreeOfSphere.hxx>
#include <Bnd_HArray1OfSphere.hxx>
#include <Extrema_FuncPSNorm.hxx>
#include <Adaptor3d_SurfacePtr.hxx>
#include <Extrema_ExtFlag.hxx>
#include <Extrema_ExtAlgo.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Extrema_POnSurfParams.hxx>
class StdFail_NotDone;
class Standard_OutOfRange;
class Standard_TypeMismatch;
@@ -43,339 +42,130 @@ class Extrema_POnSurf;
class Extrema_POnSurfParams;
//! Grid cell defined by (U, V) indices of the minimal
//! corner of the cell
struct GridCell
{
Standard_Integer UIndex; //!< U index of the minimal corner
Standard_Integer VIndex; //!< V index of the minimal corner
GridCell (Standard_Integer theUInd = -1, Standard_Integer theVInd = -1)
: UIndex (theUInd), VIndex (theVInd)
{}
};
//! typedef to BVH tree of the grid cells
typedef BVH_BoxSet <Standard_Real, 3, GridCell> Extrema_GenExtPS_GridCellBoxSet;
//! It calculates the extreme distances between a point and a surface.
//! It calculates all the extremum distances
//! between a point and a surface.
//! These distances can be minimum or maximum.
//!
//! The function F(u,v) = distance (P, S(u,v)) has an extrema when
//! gradient(F) = 0. The algorithm searches all the zeros inside
//! the definition ranges of the surface.
//!
//! When defining the surface, the number of samples in U and V direction
//! should be specified. These numbers should be great enough such
//! that if there exist N extreme distances between the point and the surface,
//! so there also exist N extrema between the point and the grid.
//!
//! It is possible to look for extrema distances in the whole parametric
//! space of the surface or limit it with the specified range which can be
//! useful when it is needed to look for local extrema distances.
//!
//! Parametric tolerances are used to determine the conditions to stop the
//! iterations - at the iteration number n:
//! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV
//!
//! It is possible to look for only Minimal or Maximal distances,
//! as well as for all solutions.
//!
//! The class is BVH enhanced - the grid cells are stored into BVH-organized
//! structure. Depending on the Extrema target the traverse of the BVH tree
//! is different.
class Extrema_GenExtPS:
protected BVH_Traverse <Standard_Real, 3, Extrema_GenExtPS_GridCellBoxSet>,
public Standard_Transient
class Extrema_GenExtPS
{
public:
DEFINE_STANDARD_RTTIEXT (Extrema_GenExtPS, Standard_Transient)
DEFINE_STANDARD_ALLOC
public: //! @name Constructors computing the distances
//! Constructor for computation of the distances between specified point and surface.
//! The whole parametric space of the surfaces is taken into account.
//!
//! Constructor is mostly used for one time projection of the point on the surface,
//! but still the instances of extrema can be used for projecting other points on the surface
//! with *Perform()* method.
//!
//! @param theP point
//! @param theS Surface
//! @param theNbU Number of samples in U direction
//! @param theNbV Number of samples in V direction
//! @param theTolU U Parametric tolerance
//! @param theTolV V Parametric tolerance
//! @param theTarget defines what solutions are required
Standard_EXPORT Extrema_GenExtPS (const gp_Pnt& theP,
const Adaptor3d_Surface& theS,
const Standard_Integer theNbU,
const Standard_Integer theNbV,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Extrema_ExtFlag theTarget = Extrema_ExtFlag_MINMAX);
//! Constructor for computation of the distances between specified point and surface.
//! Only the specified parametric range of the surface is taken into account.
//!
//! Constructor is mostly used for one time projection of the point on the surface,
//! but still the instances of extrema can be used for projecting other points on the surface
//! with *Perform()* method.
//!
//! @param theP point
//! @param theS Surface
//! @param theNbU Number of samples in U direction
//! @param theNbV Number of samples in V direction
//! @param theUMin Lower U bound
//! @param theUMax Upper U bound
//! @param theVMin Lower V bound
//! @param theVMax Upper V bound
//! @param theTolU U Parametric tolerance
//! @param theTolV V Parametric tolerance
//! @param theTarget defines what solutions are required
Standard_EXPORT Extrema_GenExtPS (const gp_Pnt& theP,
const Adaptor3d_Surface& theS,
const Standard_Integer theNbU,
const Standard_Integer theNbV,
const Standard_Real theUMin,
const Standard_Real theUMax,
const Standard_Real theVMin,
const Standard_Real theVMax,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Extrema_ExtFlag theTarget = Extrema_ExtFlag_MINMAX);
public: //! @name Empty constructor + Initialization step
//! Empty constructor
Standard_EXPORT Extrema_GenExtPS();
//! Initializes Extrema algorithm with the surfaces.
//! Search is performed in whole parametric range of the surface.
//! @param theS Surface
//! @param theNbU Number of samples in U direction
//! @param theNbV Number of samples in V direction
//! @param theTolU U Parametric tolerance
//! @param theTolV V Parametric tolerance
Standard_EXPORT void Initialize (const Adaptor3d_Surface& theS,
const Standard_Integer theNbU,
const Standard_Integer theNbV,
const Standard_Real theTolU,
const Standard_Real theTolV);
//! Initializes Extrema algorithm with the surfaces.
//! Search is performed in the given parametric range.
//! @param S Surface
//! @param theNbU Number of samples in U direction
//! @param theNbV Number of samples in V direction
//! @param theUMin Lower U bound
//! @param theUMax Upper U bound
//! @param theVMin Lower V bound
//! @param theVMax Upper V bound
//! @param theTolU U Parametric tolerance
//! @param theTolV V Parametric tolerance
Standard_EXPORT void Initialize (const Adaptor3d_Surface& theS,
const Standard_Integer theNbU,
const Standard_Integer theNbV,
const Standard_Real theUMin,
const Standard_Real theUMax,
const Standard_Real theVMin,
const Standard_Real theVMax,
const Standard_Real theTolU,
const Standard_Real theTolV);
public: //! @name Specifying the search options
//! Specifies what solutions are necessary:
//! - *Extrema_ExtFlag_MIN* - only minimal solutions
//! - *Extrema_ExtFlag_MAX* - only maximal solutions
//! - *Extrema_ExtFlag_MINMAX - all solutions (default value).
void SetTarget (const Extrema_ExtFlag theTarget)
{
myTarget = theTarget;
}
//! Returns the Extrema target type
Extrema_ExtFlag Target() const { return myTarget; }
//! Sets the tolerance for the search.
//! These tolerances are used for projection of the point,
//! and not used for surface initialization, so can be changed
//! from point to point.
void SetTolerance (const Standard_Real theTolU,
const Standard_Real theTolV)
{
myTolU = theTolU;
myTolV = theTolV;
}
public: //! @name Performing projection
//! Performs projection of the point on the surface.
//! Extrema must already be initialized with the surface.
//! Allows multiple points be projected on the same surface.
Standard_EXPORT void Perform (const gp_Pnt& theP);
public: //! @name Getting the results
//! It calculates all the distances.
//! The function F(u,v)=distance(P,S(u,v)) has an
//! extremum when gradient(F)=0. The algorithm searchs
//! all the zeros inside the definition ranges of the
//! surface.
//! NbU and NbV are used to locate the close points
//! to find the zeros. They must be great enough
//! such that if there is N extrema, there will
//! be N extrema between P and the grid.
//! TolU et TolV are used to determine the conditions
//! to stop the iterations; at the iteration number n:
//! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
Standard_EXPORT Extrema_GenExtPS(const gp_Pnt& P, const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real TolU, const Standard_Real TolV, const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
//! It calculates all the distances.
//! The function F(u,v)=distance(P,S(u,v)) has an
//! extremum when gradient(F)=0. The algorithm searchs
//! all the zeros inside the definition ranges of the
//! surface.
//! NbU and NbV are used to locate the close points
//! to find the zeros. They must be great enough
//! such that if there is N extrema, there will
//! be N extrema between P and the grid.
//! TolU et TolV are used to determine the conditions
//! to stop the iterations; at the iteration number n:
//! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
Standard_EXPORT Extrema_GenExtPS(const gp_Pnt& P, const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV, const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
Standard_EXPORT void Initialize (const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real TolU, const Standard_Real TolV);
Standard_EXPORT void Initialize (const Adaptor3d_Surface& S, const Standard_Integer NbU, const Standard_Integer NbV, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV);
//! the algorithm is done with the point P.
//! An exception is raised if the fields have not
//! been initialized.
Standard_EXPORT void Perform (const gp_Pnt& P);
Standard_EXPORT void SetFlag (const Extrema_ExtFlag F);
Standard_EXPORT void SetAlgo (const Extrema_ExtAlgo A);
//! Returns True if the distances are found.
Standard_Boolean IsDone() const { return myIsDone; }
//! Returns the number of extrema distances found.
//! @throws StdFail_NotDone if extrema search has failed.
Standard_EXPORT Standard_Boolean IsDone() const;
//! Returns the number of extremum distances.
Standard_EXPORT Standard_Integer NbExt() const;
//! Returns the value of the Nth resulting square distance.
//! @throws StdFail_NotDone if extrema search has failed.
//! @throws Standard_OutOfRange if given index is out of range of found
//! solutions ((N < 1) || (N > NbExt()).
Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer theN) const;
Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N) const;
//! Returns the point of the Nth resulting distance.
//! @throws StdFail_NotDone if extrema search has failed.
//! @throws Standard_OutOfRange if given index is out of range of found
//! solutions ((N < 1) || (N > NbExt()).
Standard_EXPORT const Extrema_POnSurf& Point (const Standard_Integer theN) const;
Standard_EXPORT const Extrema_POnSurf& Point (const Standard_Integer N) const;
protected: //! @name Protected methods performing the job
//! Creation of grid of parametric points (sampling of the surface)
Standard_EXPORT void BuildGrid();
protected:
private:
Standard_EXPORT Adaptor3d_SurfacePtr Bidon() const;
Standard_EXPORT void BuildTree();
Standard_EXPORT void FindSolution (const gp_Pnt& P, const Extrema_POnSurfParams& theParams);
//! Selection of points to build grid, depending on the type of surface
Standard_EXPORT void GetGridPoints (const Adaptor3d_Surface& theSurf);
//! Builds the BVH tree with bounding boxes of the cells of the grid
Standard_EXPORT void BuildTree();
//! Looks for the solution starting at given point
Standard_EXPORT Standard_Boolean FindSolution (const Extrema_POnSurfParams& theParams);
//! Creation of grid of parametric points
Standard_EXPORT void BuildGrid (const gp_Pnt& thePoint);
//! Compute new edge parameters.
Standard_EXPORT const Extrema_POnSurfParams&
ComputeFaceParameters (const Standard_Integer theU,
const Standard_Integer theV,
const gp_Pnt& thePoint);
//! Compute new edge parameters.
Standard_EXPORT const Extrema_POnSurfParams&
ComputeEdgeParameters (const Standard_Boolean IsUEdge,
Extrema_POnSurfParams& theParam0,
Extrema_POnSurfParams& theParam1,
const gp_Pnt& thePoint,
const Standard_Real theDiffTol);
//! Looks for the Min or Max Solution (depending on the given target).
Standard_EXPORT Standard_Boolean FindSolution (const Standard_Integer theUIndex,
const Standard_Integer theVIndex,
const Extrema_ExtFlag theTarget);
Standard_EXPORT const Extrema_POnSurfParams& ComputeEdgeParameters (const Standard_Boolean IsUEdge, const Extrema_POnSurfParams& theParam0, const Extrema_POnSurfParams& theParam1, const gp_Pnt& thePoints, const Standard_Real theDiffTol);
protected: //! @name Rules for BVH traverse
//! Rejection of the node by bounding box.
//! Metric is computed to choose the best branch.
//! Returns true if the node should be rejected, false otherwise.
Standard_EXPORT virtual Standard_Boolean
RejectNode (const BVH_Vec3d& theCornerMin,
const BVH_Vec3d& theCornerMax,
Standard_Real& theMetric) const Standard_OVERRIDE;
//! Rejects the node by the metric
Standard_EXPORT virtual Standard_Boolean
RejectMetric (const Standard_Real& theMetric) const Standard_OVERRIDE;
//! Compares the two metrics and chooses the best one.
//! Returns true if the first metric is better than the second,
//! false otherwise.
Standard_EXPORT virtual Standard_Boolean
IsMetricBetter (const Standard_Real& theLeft,
const Standard_Real& theRight) const Standard_OVERRIDE;
//! Leaf element acceptance.
//! Metric of the parent leaf-node is passed to avoid the check on the
//! element and accept it unconditionally.
//! Returns true if the element has been accepted, false otherwise.
Standard_EXPORT virtual Standard_Boolean
Accept (const Standard_Integer theIndex,
const Standard_Real& theMetric) Standard_OVERRIDE;
protected: //! @name Auxiliary types
//! Structure to keep and sort the results
struct ExtPSResult
{
Extrema_POnSurf UV; //! UV coordinates of extrema solution
Standard_Real SqDistance; //! Square distance to target point
ExtPSResult()
: SqDistance (-1)
{}
ExtPSResult (const Extrema_POnSurf& theUV,
const Standard_Real theSqDist)
: UV (theUV),
SqDistance (theSqDist)
{}
//! IsLess operator
Standard_Boolean operator< (const ExtPSResult& Other) const
{
if (SqDistance != Other.SqDistance)
return SqDistance < Other.SqDistance;
Standard_Real U1, U2, V1, V2;
UV.Parameter (U1, V1);
Other.UV.Parameter (U2, V2);
return (U1 < U2 || (U1 == U2 && V1 < V2));
}
};
protected: //! @name Fields
// Inputs
NCollection_Vec3<Standard_Real> myPoint; //!< Point
Adaptor3d_SurfacePtr myS; //!< Surface
Extrema_FuncPSNorm myF; //!< Function
Standard_Real myUMin; //!< Surface parametric range: UMin
Standard_Real myUMax; //!< Surface parametric range: UMax
Standard_Real myVMin; //!< Surface parametric range: VMin
Standard_Real myVMax; //!< Surface parametric range: VMax
Standard_Integer myNbUSamples; //!< Number of samples in U parametric direction
Standard_Integer myNbVSamples; //!< Number of samples in V parametric direction
Standard_Real myTolU; //!< U parametric tolerance
Standard_Real myTolV; //!< V parametric tolerance
Extrema_ExtFlag myTarget; //!< Extrema objective
// Intermediate data
Handle(Extrema_HArray2OfPOnSurfParams) myPoints; //!< Grid points
Handle(TColStd_HArray1OfReal) myUParams; //!< Grid parameters in U parametric direction
Handle(TColStd_HArray1OfReal) myVParams; //!< Grid parameters in V parametric direction
Standard_Boolean myDone;
Standard_Boolean myInit;
Standard_Real myumin;
Standard_Real myusup;
Standard_Real myvmin;
Standard_Real myvsup;
Standard_Integer myusample;
Standard_Integer myvsample;
Standard_Real mytolu;
Standard_Real mytolv;
Handle(Extrema_HArray2OfPOnSurfParams) myPoints;
Extrema_HUBTreeOfSphere mySphereUBTree;
Handle(Bnd_HArray1OfSphere) mySphereArray;
Extrema_FuncPSNorm myF;
Adaptor3d_SurfacePtr myS;
Extrema_ExtFlag myFlag;
Extrema_ExtAlgo myAlgo;
Handle(TColStd_HArray1OfReal) myUParams;
Handle(TColStd_HArray1OfReal) myVParams;
Handle(Extrema_HArray2OfPOnSurfParams) myFacePntParams;
Handle(Extrema_HArray2OfPOnSurfParams) myUEdgePntParams;
Handle(Extrema_HArray2OfPOnSurfParams) myVEdgePntParams;
Extrema_POnSurfParams myGridParam;
Standard_Real mySqDistance; //!< Min/Max found square distance used in BVH tree traverse
opencascade::handle
<BVH_IndexedBoxSet<Standard_Real, 3, Handle(Extrema_GenExtPS_GridCellBoxSet)> > myGridBoxSet; //!< High-level BVH of BVH organized grid cells
// Results
std::vector <ExtPSResult> mySolutions; //!< Found solutions (sorted first by distance to target point,
//! second by the ascending U,V coordinates)
Standard_Boolean myIsDone; //!< Done/Not done flag
};
DEFINE_STANDARD_HANDLE (Extrema_GenExtPS, Standard_Transient)
#endif // _Extrema_GenExtPS_HeaderFile

View File

@@ -12,7 +12,7 @@
// commercial license or contractual agreement.
inline Extrema_POnSurfParams::Extrema_POnSurfParams()
: mySqrDistance (-1),
: mySqrDistance (0.),
myElementType (Extrema_Node),
myIndexU (0),
myIndexV (0)
@@ -22,7 +22,7 @@ inline Extrema_POnSurfParams::Extrema_POnSurfParams()
inline Extrema_POnSurfParams::Extrema_POnSurfParams
(const Standard_Real theU, const Standard_Real theV, const gp_Pnt &thePnt)
: Extrema_POnSurf (theU, theV, thePnt),
mySqrDistance (-1),
mySqrDistance (0.),
myElementType (Extrema_Node),
myIndexU (0),
myIndexV (0)

View File

@@ -33,6 +33,7 @@ Extrema_EPCOfExtPC.hxx
Extrema_EPCOfExtPC2d.hxx
Extrema_EPCOfExtPC2d_0.cxx
Extrema_EPCOfExtPC_0.cxx
Extrema_ExtAlgo.hxx
Extrema_ExtCC.cxx
Extrema_ExtCC.hxx
Extrema_ExtCC2d.cxx

View File

@@ -1,5 +1,3 @@
GCPnts.cxx
GCPnts.hxx
GCPnts_AbscissaPoint.cxx
GCPnts_AbscissaPoint.pxx
GCPnts_AbscissaPoint.hxx

View File

@@ -1,54 +0,0 @@
// Created on: 2020-05-18
// Copyright (c) 1999-2020 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 <GCPnts.hxx>
#include <Precision.hxx>
//=======================================================================
//function : FillParams
//purpose :
//=======================================================================
void GCPnts::FillParams (const TColStd_Array1OfReal& theKnots,
const Standard_Integer theDegree,
const Standard_Real theParMin,
const Standard_Real theParMax,
NCollection_Vector<Standard_Real>& theParams)
{
Standard_Real aPrevPar = theParMin;
theParams.Append (aPrevPar);
Standard_Integer aNbP = Max (theDegree, 1);
for (Standard_Integer i = 1;
(i < theKnots.Length()) && (theKnots (i) < (theParMax - Precision::PConfusion())); ++i)
{
if (theKnots (i + 1) < theParMin + Precision::PConfusion())
continue;
Standard_Real aStep = (theKnots (i + 1) - theKnots (i)) / aNbP;
for (Standard_Integer k = 1; k <= aNbP ; ++k)
{
Standard_Real aPar = theKnots (i) + k * aStep;
if (aPar > theParMax - Precision::PConfusion())
break;
if (aPar > aPrevPar + Precision::PConfusion())
{
theParams.Append (aPar);
aPrevPar = aPar;
}
}
}
theParams.Append (theParMax);
}

View File

@@ -1,35 +0,0 @@
// Created on: 2020-05-18
// Copyright (c) 1999-2020 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 _GCPnts_HeaderFile
#define _GCPnts_HeaderFile
#include <TColStd_Array1OfReal.hxx>
#include <NCollection_Vector.hxx>
//! The GCPnts package provides general utilities for
//! Curves analysis.
class GCPnts
{
public:
//! Fills <theParams> vector with sampling parameters on the curve
Standard_EXPORT static void FillParams (const TColStd_Array1OfReal& theKnots,
const Standard_Integer theDegree,
const Standard_Real theParMin,
const Standard_Real theParMax,
NCollection_Vector<Standard_Real>& theParams);
};
#endif

View File

@@ -37,9 +37,10 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
//purpose :
//=======================================================================
GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf (const gp_Pnt& P,
const Handle(Geom_Surface)& Surface)
const Handle(Geom_Surface)& Surface,
const Extrema_ExtAlgo theProjAlgo)
{
Init (P, Surface);
Init (P, Surface, theProjAlgo);
}
//=======================================================================
//function : GeomAPI_ProjectPointOnSurf
@@ -47,9 +48,10 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
//=======================================================================
GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf (const gp_Pnt& P,
const Handle(Geom_Surface)& Surface,
const Standard_Real Tolerance)
const Standard_Real Tolerance,
const Extrema_ExtAlgo theProjAlgo)
{
Init (P, Surface, Tolerance);
Init (P, Surface, Tolerance, theProjAlgo);
}
//=======================================================================
//function : GeomAPI_ProjectPointOnSurf
@@ -60,10 +62,11 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
const Standard_Real Umin,
const Standard_Real Usup,
const Standard_Real Vmin,
const Standard_Real Vsup)
const Standard_Real Vsup,
const Extrema_ExtAlgo theProjAlgo)
{
Init (P, Surface, Umin, Usup, Vmin, Vsup);
Init (P, Surface, Umin, Usup, Vmin, Vsup, theProjAlgo);
}
//=======================================================================
//function : GeomAPI_ProjectPointOnSurf
@@ -75,10 +78,11 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
const Standard_Real Usup,
const Standard_Real Vmin,
const Standard_Real Vsup,
const Standard_Real Tolerance)
const Standard_Real Tolerance,
const Extrema_ExtAlgo theProjAlgo)
{
Init (P, Surface, Umin, Usup, Vmin, Vsup, Tolerance);
Init (P, Surface, Umin, Usup, Vmin, Vsup, Tolerance, theProjAlgo);
}
//=======================================================================
//function : Init
@@ -107,10 +111,11 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
//purpose :
//=======================================================================
void GeomAPI_ProjectPointOnSurf::Init (const gp_Pnt& P,
const Handle(Geom_Surface)& Surface)
const Handle(Geom_Surface)& Surface,
const Extrema_ExtAlgo theProjAlgo)
{
Init (P, Surface, Precision::Confusion());
Init (P, Surface, Precision::Confusion(), theProjAlgo);
}
//=======================================================================
//function : Init
@@ -118,15 +123,27 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
//=======================================================================
void GeomAPI_ProjectPointOnSurf::Init(const gp_Pnt& P,
const Handle(Geom_Surface)& Surface,
const Standard_Real Tolerance)
const Standard_Real Tolerance,
const Extrema_ExtAlgo theProjAlgo)
{
//modified by NIZNHY-PKV Thu Apr 4 10:37:55 2002 f
//GeomAdaptor_Surface TheSurface (Surface);
//myExtPS = Extrema_ExtPS (P, TheSurface, Tolerance, Tolerance);
//modified by NIZNHY-PKV Mon Apr 8 11:13:37 2002 f XXX
Standard_Real Umin, Usup, Vmin, Vsup;
Surface->Bounds(Umin, Usup, Vmin, Vsup);
myGeomAdaptor.Load(Surface, Umin, Usup, Vmin, Vsup);
//
//myExtPS = Extrema_ExtPS();
myExtPS.SetAlgo(theProjAlgo);
myExtPS.Initialize(myGeomAdaptor, Umin, Usup, Vmin, Vsup, Tolerance, Tolerance);
myExtPS.Perform(P);
//XXXmyExtPS = Extrema_ExtPS (P, myGeomAdaptor, Tolerance, Tolerance);
//modified by NIZNHY-PKV Mon Apr 8 11:13:44 2002 t XXX
//modified by NIZNHY-PKV Thu Apr 4 10:37:58 2002 t
Init ();
}
@@ -140,12 +157,20 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
const Standard_Real Umin,
const Standard_Real Usup,
const Standard_Real Vmin,
const Standard_Real Vsup)
const Standard_Real Vsup,
const Extrema_ExtAlgo theProjAlgo)
{
Standard_Real Tolerance = Precision::PConfusion();
//modified by NIZNHY-PKV Thu Apr 4 10:38:23 2002 f
//GeomAdaptor_Surface TheSurface (Surface,Umin,Usup,Vmin,Vsup);
//myExtPS = Extrema_ExtPS (P, TheSurface, Tol, Tol);
myGeomAdaptor.Load(Surface, Umin,Usup,Vmin,Vsup);
//myExtPS = Extrema_ExtPS();
myExtPS.SetAlgo(theProjAlgo);
myExtPS.Initialize(myGeomAdaptor, Umin, Usup, Vmin, Vsup, Tolerance, Tolerance);
myExtPS.Perform(P);
//XXX myExtPS = Extrema_ExtPS (P, myGeomAdaptor, Tol, Tol);
//modified by NIZNHY-PKV Thu Apr 4 10:38:30 2002 t
Init ();
}
@@ -159,11 +184,19 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
const Standard_Real Usup,
const Standard_Real Vmin,
const Standard_Real Vsup,
const Standard_Real Tolerance)
const Standard_Real Tolerance,
const Extrema_ExtAlgo theProjAlgo)
{
//modified by NIZNHY-PKV Thu Apr 4 10:39:10 2002 f
//GeomAdaptor_Surface TheSurface (Surface,Umin,Usup,Vmin,Vsup);
//myExtPS = Extrema_ExtPS (P, TheSurface, Tolerance, Tolerance);
myGeomAdaptor.Load(Surface, Umin,Usup,Vmin,Vsup);
//myExtPS = Extrema_ExtPS();
myExtPS.SetAlgo(theProjAlgo);
myExtPS.Initialize(myGeomAdaptor, Umin, Usup, Vmin, Vsup, Tolerance, Tolerance);
myExtPS.Perform(P);
//XXX myExtPS = Extrema_ExtPS (P, myGeomAdaptor, Tolerance, Tolerance);
//modified by NIZNHY-PKV Thu Apr 4 10:39:14 2002 t
Init ();
}
//=======================================================================
@@ -174,11 +207,20 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
const Standard_Real Umin,
const Standard_Real Usup,
const Standard_Real Vmin,
const Standard_Real Vsup)
const Standard_Real Vsup,
const Extrema_ExtAlgo theProjAlgo)
{
Standard_Real Tolerance = Precision::PConfusion();
//modified by NIZNHY-PKV Thu Apr 4 10:41:50 2002 f
//GeomAdaptor_Surface TheSurface (Surface,Umin,Usup,Vmin,Vsup);
myGeomAdaptor.Load(Surface, Umin,Usup,Vmin,Vsup);
//modified by NIZNHY-PKV Thu Apr 4 10:42:29 2002 t
//myExtPS = Extrema_ExtPS();
//modified by NIZNHY-PKV Thu Apr 4 10:42:32 2002 f
//myExtPS.Initialize(TheSurface, Umin, Usup, Vmin, Vsup, Tol, Tol);
myExtPS.SetAlgo(theProjAlgo);
myExtPS.Initialize(myGeomAdaptor, Umin, Usup, Vmin, Vsup, Tolerance, Tolerance);
//modified by NIZNHY-PKV Thu Apr 4 10:42:39 2002 t
myIsDone = Standard_False;
}
//=======================================================================
@@ -190,10 +232,19 @@ GeomAPI_ProjectPointOnSurf::GeomAPI_ProjectPointOnSurf()
const Standard_Real Usup,
const Standard_Real Vmin,
const Standard_Real Vsup,
const Standard_Real Tolerance)
const Standard_Real Tolerance,
const Extrema_ExtAlgo theProjAlgo)
{
//modified by NIZNHY-PKV Thu Apr 4 10:43:00 2002 f
//GeomAdaptor_Surface TheSurface (Surface,Umin,Usup,Vmin,Vsup);
myGeomAdaptor.Load(Surface, Umin,Usup,Vmin,Vsup);
//modified by NIZNHY-PKV Thu Apr 4 10:43:16 2002 t
//myExtPS = Extrema_ExtPS();
//modified by NIZNHY-PKV Thu Apr 4 10:43:18 2002 f
//myExtPS.Initialize(TheSurface, Umin, Usup, Vmin, Vsup, Tolerance, Tolerance);
myExtPS.SetAlgo(theProjAlgo);
myExtPS.Initialize(myGeomAdaptor, Umin, Usup, Vmin, Vsup, Tolerance, Tolerance);
//modified by NIZNHY-PKV Thu Apr 4 10:43:26 2002 t
myIsDone = Standard_False;
}
//=======================================================================

View File

@@ -25,6 +25,7 @@
#include <Standard_Integer.hxx>
#include <Extrema_ExtPS.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Extrema_ExtAlgo.hxx>
#include <Extrema_ExtFlag.hxx>
#include <Standard_Real.hxx>
class Standard_OutOfRange;
@@ -50,38 +51,45 @@ public:
//! Create the projection of a point <P> on a surface
//! <Surface>
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface);
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
//! Create the projection of a point <P> on a surface
//! <Surface>
//! Create the projection of a point <P> on a surface
//! <Surface>. The solution are computed in the domain
//! [Umin,Usup] [Vmin,Vsup] of the surface.
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Tolerance);
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real Tolerance);
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
//! Init the projection of a point <P> on a surface
//! <Surface>
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup);
Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Tolerance);
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
//! Init the projection of a point <P> on a surface
//! <Surface>. The solution are computed in the domain
//! [Umin,Usup] [Vmin,Vsup] of the surface.
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface);
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real Tolerance);
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
//! Init the projection for many points on a surface
//! <Surface>. The solutions will be computed in the domain
//! [Umin,Usup] [Vmin,Vsup] of the surface.
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup);
Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
Standard_EXPORT void Init (const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real Tolerance);
Standard_EXPORT void Init (const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
Standard_EXPORT void Init (const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup);
Standard_EXPORT void Init (const Handle(Geom_Surface)& Surface, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
//! Sets the Extrema search algorithm - Grad or Tree. <br>
//! By default the Extrema is initialized with Grad algorithm.
void SetExtremaAlgo(const Extrema_ExtAlgo theAlgo)
{
myExtPS.SetAlgo(theAlgo);
}
//! Sets the Extrema search flag - MIN or MAX or MINMAX.<br>
//! By default the Extrema is set to search the MinMax solutions.

View File

@@ -1112,8 +1112,9 @@ void GeomInt_IntSS::BuildPCurves (Standard_Real f,
const gp_Pnt aP3d1 = C->Value(f);
const gp_Pnt aP3d2 = C->Value(l);
anExtr.SetAlgo(Extrema_ExtAlgo_Grad);
anExtr.Initialize(anAS, umin, umax, vmin, vmax,
Precision::Confusion(), Precision::Confusion());
Precision::Confusion(), Precision::Confusion());
anExtr.Perform(aP3d1);
if(ParametersOfNearestPointOnSurface(anExtr, aU, aV))

View File

@@ -88,9 +88,9 @@ static void showProjSolution(Draw_Interpretor& di,
static Standard_Integer proj (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if ( n != 5 && n != 7)
if ( n < 5)
{
di.PrintHelp (a[0]);
std::cout << " Use proj curve/surf x y z [{extrema algo: g(grad)/t(tree)}|{u v}]" << std::endl;
return 1;
}
@@ -98,6 +98,10 @@ static Standard_Integer proj (Draw_Interpretor& di, Standard_Integer n, const ch
Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[1]);
Handle(Geom_Surface) GS;
Extrema_ExtAlgo aProjAlgo = Extrema_ExtAlgo_Grad;
if (n == 6 && a[5][0] == 't')
aProjAlgo = Extrema_ExtAlgo_Tree;
if (GC.IsNull())
{
@@ -106,12 +110,12 @@ static Standard_Integer proj (Draw_Interpretor& di, Standard_Integer n, const ch
if (GS.IsNull())
return 1;
if (n == 5)
if (n <= 6)
{
Standard_Real U1, U2, V1, V2;
GS->Bounds(U1,U2,V1,V2);
GeomAPI_ProjectPointOnSurf proj(P,GS,U1,U2,V1,V2);
GeomAPI_ProjectPointOnSurf proj(P,GS,U1,U2,V1,V2,aProjAlgo);
if (!proj.IsDone())
{
di << "projection failed.";
@@ -748,7 +752,7 @@ void GeometryTest::APICommands(Draw_Interpretor& theCommands)
done = Standard_True;
theCommands.Add("proj", "proj curve/surf x y z [{u v}]\n"
theCommands.Add("proj", "proj curve/surf x y z [{extrema algo: g(grad)/t(tree)}|{u v}]\n"
"\t\tOptional parameters are relevant to surf only.\n"
"\t\tIf initial {u v} are given then local extrema is called",__FILE__, proj);

View File

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

View File

@@ -0,0 +1,134 @@
// 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++;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_AspectFillCapping::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_AspectFillCapping);
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Graphic3d_Aspects);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myMaterial);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myMaterial);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myTexture);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myShader);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStippleHatch);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myTextureHatch);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myHatchMaterial);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFlags);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHatchingState);
}

View File

@@ -0,0 +1,167 @@
// 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; }
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
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

View File

@@ -57,6 +57,7 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
myIsCapping (Standard_False)
{
makeId();
init();
}
// =======================================================================
@@ -77,9 +78,10 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
myIsCapping (Standard_False)
{
makeId();
init (gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.a()));
updateInversedPlane();
}
// =======================================================================
// function : Graphic3d_ClipPlane
// purpose :
@@ -98,8 +100,17 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
myIsOn (theOther.myIsOn),
myIsCapping (theOther.myIsCapping)
{
makeId();
*myAspect = *theOther.CappingAspect();
*mySectionStyle = *theOther.CappingSectionStyle();
makeId();
init (theOther.myPlane,
theOther.myEquationRev,
theOther.myIsOn,
theOther.myIsCapping,
theOther.ToOverrideCappingAspect(),
theOther.CappingSectionStyle());
updateInversedPlane();
}
// =======================================================================
@@ -118,8 +129,9 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
myIsCapping (Standard_False)
{
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
updateInversedPlane();
makeId();
init (thePlane);
updateInversedPlane();
}
// =======================================================================
@@ -131,6 +143,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++;
}
@@ -143,6 +156,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++;
}
@@ -307,6 +321,96 @@ void Graphic3d_ClipPlane::makeId()
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
}
// =======================================================================
// function : SetCappingSectionStyle
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
mySectionStyle = theStyle;
}
// =======================================================================
// function : OrientationMatrix
// purpose :
// =======================================================================
const Graphic3d_Mat4& Graphic3d_ClipPlane::OrientationMatrix() const
{
if (myOrientationDirty)
{
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())
{
aSide1[0] = 1.0f;
}
else
{
aSide1[0] = aDirection[2] / aMagintude;
aSide1[2] = -aDirection[0] / aMagintude;
}
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;
}
return myOrientationMat;
}
// =======================================================================
// function : init
// 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)
{
myOverrideObjectStyle = theOverrideStyle;
mySectionStyle = theStyle.IsNull() ? new Graphic3d_AspectFillCapping() : theStyle;
myOrientationDirty = Standard_True;
}
// =======================================================================
// function : updateChainLen
// purpose :
@@ -326,6 +430,7 @@ void Graphic3d_ClipPlane::updateChainLen()
// =======================================================================
void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
{
myOrientationDirty = Standard_True;
++myEquationMod;
if (!myNextInChain.IsNull())
{

View File

@@ -19,9 +19,12 @@
#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>
@@ -228,7 +231,7 @@ public:
//! Return capping aspect.
//! @return capping surface rendering aspect.
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
//! Assign capping aspect.
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
@@ -249,13 +252,23 @@ public:
//! 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:
//! Returns style used for drawing capping section.
//! @return capping surface rendering aspect.
const Handle(Graphic3d_AspectFillCapping)& CappingSectionStyle() const { return mySectionStyle; }
//! Sets clipping section filling aspect.
Standard_EXPORT void SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
public:
//! Check if the given point is outside / inside / on section.
@@ -395,13 +408,35 @@ public: // @name modification counters
}
private:
//! Generate unique object id for OpenGL graphic resource manager.
void makeId();
//! Set capping flag.
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
public:
//! 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)());
//! Update chain length in backward direction.
void updateChainLen();
@@ -416,6 +451,7 @@ private:
private:
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
Handle(Graphic3d_AspectFillCapping) mySectionStyle; //!< Style set for drawing capped solid section.
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 myId; //!< resource id
@@ -428,6 +464,9 @@ 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).
};

View File

@@ -31,7 +31,6 @@ public:
Graphic3d_TextureMap (theFileName, Graphic3d_TOT_CUBEMAP),
myCurrentSide (Graphic3d_CMS_POS_X),
myEndIsReached (false),
myIsTopDown (true),
myZIsInverted (false),
myHasMipmaps (theToGenerateMipmaps)
{}
@@ -42,7 +41,6 @@ public:
Graphic3d_TextureMap (thePixmap, Graphic3d_TOT_CUBEMAP),
myCurrentSide (Graphic3d_CMS_POS_X),
myEndIsReached (false),
myIsTopDown (true),
myZIsInverted (false),
myHasMipmaps (theToGenerateMipmaps)
{}
@@ -67,12 +65,6 @@ public:
}
}
//! 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)
{
@@ -91,9 +83,13 @@ public:
//! Sets whether to generate mipmaps of cubemap or not.
void SetMipmapsGeneration (Standard_Boolean theToGenerateMipmaps) { myHasMipmaps = theToGenerateMipmaps; }
//! Returns current cubemap side as compressed PixMap.
//! Returns null handle if current side is invalid or if image is not in supported compressed format.
virtual Handle(Image_CompressedPixMap) CompressedValue (const Handle(Image_SupportedFormats)& theSupported) = 0;
//! Returns PixMap containing current side of cubemap.
//! Returns null handle if current side is invalid.
virtual Handle(Image_PixMap) Value() = 0;
virtual Handle(Image_PixMap) Value (const Handle(Image_SupportedFormats)& theSupported) = 0;
//! Sets iterator state to +X cubemap side.
Graphic3d_CubeMap& Reset()
@@ -110,7 +106,6 @@ 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
Standard_Boolean myHasMipmaps; //!< Indicates whether mipmaps of cubemap will be generated or not

View File

@@ -13,7 +13,9 @@
// commercial license or contractual agreement.
#include <Graphic3d_CubeMapPacked.hxx>
#include <Image_AlienPixMap.hxx>
#include <Image_DDSParser.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
@@ -40,17 +42,46 @@ Graphic3d_CubeMapPacked::Graphic3d_CubeMapPacked (const Handle(Image_PixMap)&
myOrder (theOrder),
myTileNumberX (1)
{
if (checkImage (theImage, myTileNumberX))
if (checkImage (theImage, myTileNumberX))
{
myPixMap = theImage;
}
}
// =======================================================================
// function : CompressedValue
// purpose :
// =======================================================================
Handle(Image_CompressedPixMap) Graphic3d_CubeMapPacked::CompressedValue (const Handle(Image_SupportedFormats)& theSupported)
{
if (myTileNumberX == 0
|| !myPixMap.IsNull())
{
return Handle(Image_CompressedPixMap)();
}
TCollection_AsciiString aFilePath;
myPath.SystemName (aFilePath);
if (!aFilePath.IsEmpty())
{
const unsigned int aTileIndex = myOrder[myCurrentSide];
Handle(Image_CompressedPixMap) anImage = Image_DDSParser::Load (theSupported, aFilePath, (Standard_Integer )aTileIndex);
if (!anImage.IsNull()
&& anImage->NbFaces() == 6
&& anImage->SizeX() == anImage->SizeY())
{
myPixMap = theImage;
myIsTopDown = anImage->IsTopDown();
return anImage;
}
}
return Handle(Image_CompressedPixMap)();
}
// =======================================================================
// function : Value
// purpose :
// =======================================================================
Handle(Image_PixMap) Graphic3d_CubeMapPacked::Value()
Handle(Image_PixMap) Graphic3d_CubeMapPacked::Value (const Handle(Image_SupportedFormats)& theSupported)
{
if (myTileNumberX != 0)
{
@@ -60,7 +91,7 @@ Handle(Image_PixMap) Graphic3d_CubeMapPacked::Value()
myPath.SystemName (aFilePath);
if (!aFilePath.IsEmpty())
{
tryLoadImage (aFilePath);
tryLoadImage (theSupported, aFilePath);
}
}
@@ -183,13 +214,15 @@ Standard_Boolean Graphic3d_CubeMapPacked::checkImage (const Handle(Image_PixMap)
// function : tryLoadImage
// purpose :
// =======================================================================
void Graphic3d_CubeMapPacked::tryLoadImage (const TCollection_AsciiString& theFilePath)
void Graphic3d_CubeMapPacked::tryLoadImage (const Handle(Image_SupportedFormats)& theSupported,
const TCollection_AsciiString& theFilePath)
{
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap;
if (anImage->Load (theFilePath))
{
if (checkImage (anImage, myTileNumberX))
{
convertToCompatible (theSupported, anImage);
myPixMap = anImage;
}
}

View File

@@ -25,23 +25,26 @@ class Graphic3d_CubeMapPacked : public Graphic3d_CubeMap
DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
public:
//! Initialization to load cubemef from file.
//! Initialization to load cubemap from file.
//! @theFileName - path to the cubemap image
//! @theOrder - array conaining six different indexes of cubemap sides which maps tile grid to cubemap sides
//! @theOrder - array containing 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
//! @theOrder - array containing 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 compressed PixMap.
Standard_EXPORT virtual Handle(Image_CompressedPixMap) CompressedValue (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
//! 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;
Standard_EXPORT virtual Handle(Image_PixMap) Value (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
//! Empty destructor.
~Graphic3d_CubeMapPacked() {}
@@ -57,7 +60,8 @@ private:
//! Tries to load image from file and checks it after that.
//! Does nothing in case of fail.
void tryLoadImage (const TCollection_AsciiString &theFilePath);
void tryLoadImage (const Handle(Image_SupportedFormats)& theSupported,
const TCollection_AsciiString &theFilePath);
protected:

View File

@@ -13,7 +13,9 @@
// commercial license or contractual agreement.
#include <Graphic3d_CubeMapSeparate.hxx>
#include <Image_AlienPixMap.hxx>
#include <Image_DDSParser.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <OSD_File.hxx>
@@ -83,11 +85,55 @@ Graphic3d_CubeMapSeparate::Graphic3d_CubeMapSeparate (const NCollection_Array1<H
}
}
// =======================================================================
// function : CompressedValue
// purpose :
// =======================================================================
Handle(Image_CompressedPixMap) Graphic3d_CubeMapSeparate::CompressedValue (const Handle(Image_SupportedFormats)& theSupported)
{
if (!myImages[0].IsNull())
{
return Handle(Image_CompressedPixMap)();
}
const Graphic3d_CubeMapOrder anOrder = Graphic3d_CubeMapOrder::Default();
TCollection_AsciiString aFilePath;
myPaths[anOrder[myCurrentSide]].SystemName(aFilePath);
if (aFilePath.IsEmpty())
{
return Handle(Image_CompressedPixMap)();
}
Handle(Image_CompressedPixMap) anImage = Image_DDSParser::Load (theSupported, aFilePath, 0);
if (anImage.IsNull()
|| anImage->SizeX() != anImage->SizeY())
{
return Handle(Image_CompressedPixMap)();
}
if (myCurrentSide == 0)
{
mySize = anImage->SizeX();
myFormat = anImage->BaseFormat();
myIsTopDown = anImage->IsTopDown();
return anImage;
}
if (anImage->BaseFormat() == myFormat
&& anImage->SizeX() == (Standard_Integer )mySize)
{
return anImage;
}
Message::SendWarning (TCollection_AsciiString() + "'" + aFilePath + "' inconsistent image format or dimension in Graphic3d_CubeMapSeparate");
return Handle(Image_CompressedPixMap)();
}
// =======================================================================
// function : Value
// purpose :
// =======================================================================
Handle(Image_PixMap) Graphic3d_CubeMapSeparate::Value()
Handle(Image_PixMap) Graphic3d_CubeMapSeparate::Value (const Handle(Image_SupportedFormats)& theSupported)
{
Graphic3d_CubeMapOrder anOrder = Graphic3d_CubeMapOrder::Default();
if (!myIsTopDown)
@@ -108,6 +154,7 @@ Handle(Image_PixMap) Graphic3d_CubeMapSeparate::Value()
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap;
if (anImage->Load(aFilePath))
{
convertToCompatible (theSupported, anImage);
if (anImage->SizeX() == anImage->SizeY())
{
if (myCurrentSide == 0)

View File

@@ -33,13 +33,16 @@ public:
//! @theImages - array if PixMaps (has to have size equal 6).
Standard_EXPORT Graphic3d_CubeMapSeparate(const NCollection_Array1<Handle(Image_PixMap)>& theImages);
//! Returns current cubemap side as compressed PixMap.
Standard_EXPORT virtual Handle(Image_CompressedPixMap) CompressedValue (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
//! 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;
Standard_EXPORT virtual Handle(Image_PixMap) Value (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
//! Returns NULL.
virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE
virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& ) Standard_OVERRIDE
{
return Handle(Image_PixMap)();
}

View File

@@ -37,6 +37,7 @@
class Graphic3d_Structure;
class Graphic3d_ArrayOfPrimitives;
class Graphic3d_AspectFillCapping;
class Graphic3d_Text;
//! This class allows the definition of groups
@@ -105,6 +106,9 @@ 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;

View File

@@ -21,13 +21,15 @@
//! - 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.
//! - ASPECT_FILL_AREA: aspect for face primitives;
//! - Graphic3d_ASPECT_FILL_CAPPING: aspect for filling clipping sections.
enum Graphic3d_GroupAspect
{
Graphic3d_ASPECT_LINE,
Graphic3d_ASPECT_TEXT,
Graphic3d_ASPECT_MARKER,
Graphic3d_ASPECT_FILL_AREA
Graphic3d_ASPECT_FILL_AREA,
Graphic3d_ASPECT_FILL_CAPPING
};
#endif // _Graphic3d_GroupAspect_HeaderFile

View File

@@ -56,7 +56,7 @@ Graphic3d_MediaTexture::Graphic3d_MediaTexture (const Handle(Media_HMutex)& theM
// Function : GetImage
// Purpose :
// ================================================================
Handle(Image_PixMap) Graphic3d_MediaTexture::GetImage() const
Handle(Image_PixMap) Graphic3d_MediaTexture::GetImage (const Handle(Image_SupportedFormats)& )
{
Standard_Mutex::Sentry aLock (myMutex.get());
if (myFrame.IsNull()

View File

@@ -34,7 +34,7 @@ public:
Standard_Integer thePlane = -1);
//! Image reader.
Standard_EXPORT virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
//! Return the frame.
const Handle(Media_Frame)& Frame() const { return myFrame; }

View File

@@ -72,22 +72,22 @@ public:
//! @param theLevel level of anisontropy texture filter.
Standard_EXPORT void SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel);
//! @return rotation angle in degrees
//! Default value is 0.
//! Return rotation angle in degrees; 0 by default.
//! Complete transformation matrix: Rotation -> Translation -> Scale.
Standard_ShortReal Rotation() const { return myRotAngle; }
//! @param theAngleDegrees rotation angle.
Standard_EXPORT void SetRotation (const Standard_ShortReal theAngleDegrees);
//! @return scale factor
//! Default value is no scaling (1.0; 1.0).
//! Return scale factor; (1.0; 1.0) by default, which means no scaling.
//! Complete transformation matrix: Rotation -> Translation -> Scale.
const Graphic3d_Vec2& Scale() const { return myScale; }
//! @param theScale scale factor.
Standard_EXPORT void SetScale (const Graphic3d_Vec2 theScale);
//! @return translation vector
//! Default value is no translation (0.0; 0.0).
//! Return translation vector; (0.0; 0.0), which means no translation.
//! Complete transformation matrix: Rotation -> Translation -> Scale.
const Graphic3d_Vec2& Translation() const { return myTranslation; }
//! @param theVec translation vector.
@@ -109,7 +109,8 @@ public:
//! @return base texture mipmap level; 0 by default.
Standard_Integer BaseLevel() const { return myBaseLevel; }
//! @return maximum texture mipmap array level; 1000 by default.
//! Return maximum texture mipmap array level; 1000 by default.
//! Real rendering limit will take into account mipmap generation flags and presence of mipmaps in loaded image.
Standard_Integer MaxLevel() const { return myMaxLevel; }
//! Setups texture mipmap array levels range.

View File

@@ -19,9 +19,12 @@
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_TextureParams.hxx>
#include <Image_AlienPixMap.hxx>
#include <Image_DDSParser.hxx>
#include <Image_SupportedFormats.hxx>
#include <OSD_Directory.hxx>
#include <OSD_Environment.hxx>
#include <OSD_File.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Protection.hxx>
#include <Standard_Atomic.hxx>
@@ -90,7 +93,8 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const TCollection_AsciiString& the
myPath (theFileName),
myRevision (0),
myType (theType),
myIsColorMap (true)
myIsColorMap (true),
myIsTopDown (true)
{
generateId();
}
@@ -105,7 +109,8 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const Handle(Image_PixMap)& theP
myPixMap (thePixMap),
myRevision (0),
myType (theType),
myIsColorMap (true)
myIsColorMap (true),
myIsTopDown (true)
{
generateId();
}
@@ -129,15 +134,57 @@ void Graphic3d_TextureRoot::generateId()
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_TEXTURE_COUNTER));
}
// =======================================================================
// function : GetCompressedImage
// purpose :
// =======================================================================
Handle(Image_CompressedPixMap) Graphic3d_TextureRoot::GetCompressedImage (const Handle(Image_SupportedFormats)& theSupported)
{
if (!myPixMap.IsNull())
{
return Handle(Image_CompressedPixMap)();
}
// Case 2: texture source is specified as path
TCollection_AsciiString aFilePath;
myPath.SystemName (aFilePath);
if (aFilePath.IsEmpty())
{
return Handle(Image_CompressedPixMap)();
}
TCollection_AsciiString aFilePathLower = aFilePath;
aFilePathLower.LowerCase();
if (!aFilePathLower.EndsWith (".dds"))
{
// do not waste time on file system access in case of wrong file extension
return Handle(Image_CompressedPixMap)();
}
if (Handle(Image_CompressedPixMap) anImage = Image_DDSParser::Load (theSupported, aFilePath, 0))
{
myIsTopDown = anImage->IsTopDown();
return anImage;
}
return Handle(Image_CompressedPixMap)();
}
// =======================================================================
// function : GetImage
// purpose :
// =======================================================================
Handle(Image_PixMap) Graphic3d_TextureRoot::GetImage() const
Handle(Image_PixMap) Graphic3d_TextureRoot::GetImage (const Handle(Image_SupportedFormats)& theSupported)
{
if (Handle(Image_PixMap) anOldImage = GetImage())
{
myIsTopDown = anOldImage->IsTopDown();
return anOldImage; // compatibility with old API
}
// Case 1: texture source is specified as pixmap
if (!myPixMap.IsNull())
{
myIsTopDown = myPixMap->IsTopDown();
return myPixMap;
}
@@ -150,12 +197,38 @@ Handle(Image_PixMap) Graphic3d_TextureRoot::GetImage() const
}
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
if (!anImage->Load (aFilePath))
if (anImage->Load (aFilePath))
{
return Handle(Image_PixMap)();
myIsTopDown = anImage->IsTopDown();
convertToCompatible (theSupported, anImage);
return anImage;
}
return anImage;
return Handle(Image_PixMap)();
}
// =======================================================================
// function : convertToCompatible
// purpose :
// =======================================================================
void Graphic3d_TextureRoot::convertToCompatible (const Handle(Image_SupportedFormats)& theSupported,
const Handle(Image_PixMap)& theImage)
{
if (theSupported.IsNull()
|| theSupported->IsSupported (theImage->Format())
|| theImage.IsNull())
{
return;
}
if ((theImage->Format() == Image_Format_BGR32
|| theImage->Format() == Image_Format_BGR32))
{
Image_PixMap::SwapRgbaBgra (*theImage);
theImage->SetFormat (theImage->Format() == Image_Format_BGR32
? Image_Format_RGB32
: Image_Format_RGBA);
}
}
// =======================================================================

View File

@@ -25,6 +25,8 @@
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
class Image_CompressedPixMap;
class Image_SupportedFormats;
class Graphic3d_TextureParams;
//! This is the texture root class enable the dialog with the GraphicDriver allows the loading of texture.
@@ -79,6 +81,13 @@ public:
//! without re-creating texture source itself (since unique id should be never modified).
void UpdateRevision() { ++myRevision; }
//! This method will be called by graphic driver each time when texture resource should be created.
//! It is called in front of GetImage() for uploading compressed image formats natively supported by GPU.
//! @param theSupported [in] the list of supported compressed texture formats;
//! returning image in unsupported format will result in texture upload failure
//! @return compressed pixmap or NULL if image is not in supported compressed format
Standard_EXPORT virtual Handle(Image_CompressedPixMap) GetCompressedImage (const Handle(Image_SupportedFormats)& theSupported);
//! This method will be called by graphic driver each time when texture resource should be created.
//! Default constructors allow defining the texture source as path to texture image or directly as pixmap.
//! If the source is defined as path, then the image will be dynamically loaded when this method is called
@@ -86,7 +95,7 @@ public:
//! Inheritors may dynamically generate the image.
//! Notice, image data should be in Bottom-Up order (see Image_PixMap::IsTopDown())!
//! @return the image for texture.
Standard_EXPORT virtual Handle(Image_PixMap) GetImage() const;
Standard_EXPORT virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& theSupported);
//! @return low-level texture parameters
const Handle(Graphic3d_TextureParams)& GetParams() const { return myParams; }
@@ -104,6 +113,9 @@ public:
//! Set flag indicating color nature of values within the texture.
void SetColorMap (Standard_Boolean theIsColor) { myIsColorMap = theIsColor; }
//! Returns whether row's memory layout is top-down.
Standard_Boolean IsTopDown() const { return myIsTopDown; }
protected:
//! Creates a texture from a file
@@ -119,6 +131,13 @@ protected:
//! Unconditionally generate new texture id. Should be called only within constructor.
Standard_EXPORT void generateId();
//! Try converting image to compatible format.
Standard_EXPORT static void convertToCompatible (const Handle(Image_SupportedFormats)& theSupported,
const Handle(Image_PixMap)& theImage);
//! Method for supporting old API; another GetImage() method should be implemented instead.
virtual Handle(Image_PixMap) GetImage() const { return Handle(Image_PixMap)(); }
protected:
Handle(Graphic3d_TextureParams) myParams; //!< associated texture parameters
@@ -128,6 +147,8 @@ protected:
Standard_Size myRevision; //!< image revision - for signaling changes in the texture source (e.g. file update, pixmap update)
Graphic3d_TypeOfTexture myType; //!< texture type
Standard_Boolean myIsColorMap; //!< flag indicating color nature of values within the texture
Standard_Boolean myIsTopDown; //!< Stores rows's memory layout
};

View File

@@ -1,6 +1,10 @@
Image_AlienPixMap.cxx
Image_AlienPixMap.hxx
Image_Color.hxx
Image_CompressedFormat.hxx
Image_CompressedPixMap.hxx
Image_DDSParser.cxx
Image_DDSParser.hxx
Image_Diff.cxx
Image_Diff.hxx
Image_Format.hxx
@@ -8,6 +12,8 @@ Image_PixMap.cxx
Image_PixMap.hxx
Image_PixMapData.hxx
Image_PixMapTypedData.hxx
Image_SupportedFormats.cxx
Image_SupportedFormats.hxx
Image_Texture.cxx
Image_Texture.hxx
Image_VideoRecorder.cxx

View File

@@ -0,0 +1,31 @@
// Copyright (c) 2020 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 _Image_CompressedFormat_HeaderFile
#define _Image_CompressedFormat_HeaderFile
#include <Image_Format.hxx>
//! List of compressed pixel formats natively supported by various graphics hardware (e.g. for efficient decoding on-the-fly).
//! It is defined as extension of Image_Format.
enum Image_CompressedFormat
{
Image_CompressedFormat_UNKNOWN = Image_Format_UNKNOWN,
Image_CompressedFormat_RGB_S3TC_DXT1 = Image_Format_NB,
Image_CompressedFormat_RGBA_S3TC_DXT1,
Image_CompressedFormat_RGBA_S3TC_DXT3,
Image_CompressedFormat_RGBA_S3TC_DXT5
};
enum { Image_CompressedFormat_NB = Image_CompressedFormat_RGBA_S3TC_DXT5 + 1 };
#endif // _Image_CompressedFormat_HeaderFile

View File

@@ -0,0 +1,108 @@
// Copyright (c) 2020 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 _Image_CompressedPixMap_HeaderFile
#define _Image_CompressedPixMap_HeaderFile
#include <Image_Format.hxx>
#include <Image_CompressedFormat.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_Buffer.hxx>
#include <Standard_Type.hxx>
//! Compressed pixmap data definition.
//! It is defined independently from Image_PixMap, which defines only uncompressed formats.
class Image_CompressedPixMap : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Image_CompressedPixMap, Standard_Transient)
public:
//! Return base (uncompressed) pixel format.
Image_Format BaseFormat() const { return myBaseFormat; }
//! Set base (uncompressed) pixel format.
void SetBaseFormat (Image_Format theFormat) { myBaseFormat = theFormat; }
//! Return compressed format.
Image_CompressedFormat CompressedFormat() const { return myFormat; }
//! Set compressed format.
void SetCompressedFormat (Image_CompressedFormat theFormat) { myFormat = theFormat; }
//! Return raw (compressed) data.
const Handle(NCollection_Buffer)& FaceData() const { return myFaceData; }
//! Set raw (compressed) data.
void SetFaceData (const Handle(NCollection_Buffer)& theBuffer) { myFaceData = theBuffer; }
//! Return Array of mipmap sizes, including base level.
const NCollection_Array1<Standard_Integer>& MipMaps() const { return myMipMaps; }
//! Return Array of mipmap sizes, including base level.
NCollection_Array1<Standard_Integer>& ChangeMipMaps() { return myMipMaps; }
//! Return TRUE if complete mip map level set (up to 1x1 resolution).
Standard_Boolean IsCompleteMipMapSet() const { return myIsCompleteMips; }
//! Set if complete mip map level set (up to 1x1 resolution).
void SetCompleteMipMapSet (Standard_Boolean theIsComplete) { myIsCompleteMips = theIsComplete; }
//! Return surface length in bytes.
Standard_Size FaceBytes() const { return myFaceBytes; }
//! Set surface length in bytes.
void SetFaceBytes (Standard_Size theSize) { myFaceBytes = theSize; }
//! Return surface width.
Standard_Integer SizeX() const { return mySizeX; }
//! Return surface height.
Standard_Integer SizeY() const { return mySizeY; }
//! Set surface width x height.
void SetSize (Standard_Integer theSizeX, Standard_Integer theSizeY)
{
mySizeX = theSizeX;
mySizeY = theSizeY;
}
//! Return TRUE if image layout is top-down (always true).
bool IsTopDown() const { return true; }
//! Return number of faces in the file; should be 6 for cubemap.
Standard_Integer NbFaces() const { return myNbFaces; }
//! Set number of faces in the file.
void SetNbFaces (Standard_Integer theSize) { myNbFaces = theSize; }
public:
//! Empty constructor.
Image_CompressedPixMap()
: myFaceBytes (0), myNbFaces (0), mySizeX (0), mySizeY (0), myBaseFormat (Image_Format_UNKNOWN), myFormat (Image_CompressedFormat_UNKNOWN), myIsCompleteMips (false) {}
protected:
NCollection_Array1<Standard_Integer> myMipMaps; //!< Array of mipmap sizes, including base level
Handle(NCollection_Buffer) myFaceData; //!< raw compressed data
Standard_Size myFaceBytes; //!< surface length in bytes
Standard_Integer myNbFaces; //!< number of faces in the file
Standard_Integer mySizeX; //!< surface width
Standard_Integer mySizeY; //!< surface height
Image_Format myBaseFormat; //!< base (uncompressed) pixel format
Image_CompressedFormat myFormat; //!< compressed format
Standard_Boolean myIsCompleteMips; //!< flag indicating complete mip map level set (up to 1x1 resolution)
};
#endif // _Image_CompressedPixMap_HeaderFile

View File

@@ -0,0 +1,255 @@
// Copyright (c) 2020 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 <Image_DDSParser.hxx>
#include <Image_PixMap.hxx>
#include <Image_SupportedFormats.hxx>
#include <Message.hxx>
#include <OSD_OpenFile.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Image_CompressedPixMap, Standard_Transient)
//! DDS Pixel Format structure.
struct Image_DDSParser::DDSPixelFormat
{
uint32_t Size;
uint32_t Flags;
uint32_t FourCC;
uint32_t RGBBitCount;
uint32_t RBitMask;
uint32_t GBitMask;
uint32_t BBitMask;
uint32_t ABitMask;
};
//! DDS File header structure.
struct Image_DDSParser::DDSFileHeader
{
//! Caps2 flag indicating complete (6 faces) cubemap.
enum { DDSCompleteCubemap = 0xFE00 };
//! Return TRUE if cubmap flag is set.
bool IscompleteCubemap() const { return (Caps2 & DDSFileHeader::DDSCompleteCubemap) == DDSFileHeader::DDSCompleteCubemap; }
uint32_t Size;
uint32_t Flags;
uint32_t Height;
uint32_t Width;
uint32_t PitchOrLinearSize;
uint32_t Depth;
uint32_t MipMapCount;
uint32_t Reserved1[11];
DDSPixelFormat PixelFormatDef;
uint32_t Caps;
uint32_t Caps2;
uint32_t Caps3;
uint32_t Caps4;
uint32_t Reserved2;
};
// =======================================================================
// function : Load
// purpose :
// =======================================================================
Handle(Image_CompressedPixMap) Image_DDSParser::Load (const Handle(Image_SupportedFormats)& theSupported,
const TCollection_AsciiString& theFile,
const Standard_Integer theFaceIndex,
const int64_t theFileOffset)
{
std::ifstream aFile;
OSD_OpenStream (aFile, theFile.ToCString(), std::ios::in | std::ios::binary);
char aHeader[128] = {};
if (!aFile.is_open()
|| !aFile.good())
{
return Handle(Image_CompressedPixMap)();
}
if (theFileOffset != 0)
{
aFile.seekg ((std::streamoff )theFileOffset, std::ios::beg);
}
aFile.read (aHeader, 128);
Standard_Size aNbReadBytes = (Standard_Size )aFile.gcount();
if (aNbReadBytes < 128
|| ::memcmp (aHeader, "DDS ", 4) != 0)
{
return Handle(Image_CompressedPixMap)();
}
Handle(Image_CompressedPixMap) aDef = parseHeader (*(const DDSFileHeader* )(aHeader + 4));
if (aDef.IsNull())
{
return Handle(Image_CompressedPixMap)();
}
if (!theSupported.IsNull()
&& !theSupported->IsSupported (aDef->CompressedFormat()))
{
return Handle(Image_CompressedPixMap)();
}
if (theFaceIndex < 0)
{
return aDef;
}
if (theFaceIndex >= aDef->NbFaces()
|| aDef->FaceBytes() == 0)
{
Message::SendFail (TCollection_AsciiString ("DDS Reader error - invalid face index #") + theFaceIndex + " within file\n" + theFile);
return Handle(Image_CompressedPixMap)();
}
const Standard_Size anOffset = aDef->FaceBytes() * theFaceIndex;
if (anOffset != 0)
{
aFile.seekg ((std::streamoff )anOffset, std::ios::cur);
}
Handle(NCollection_Buffer) aBuffer = new NCollection_Buffer (Image_PixMap::DefaultAllocator(), aDef->FaceBytes());
aFile.read ((char* )aBuffer->ChangeData(), aDef->FaceBytes());
aNbReadBytes = (Standard_Size )aFile.gcount();
if (aNbReadBytes < aDef->FaceBytes())
{
Message::SendFail (TCollection_AsciiString ("DDS Reader error - unable to read face #") + theFaceIndex + " data from file\n" + theFile);
return Handle(Image_CompressedPixMap)();
}
aDef->SetFaceData (aBuffer);
return aDef;
}
// =======================================================================
// function : Load
// purpose :
// =======================================================================
Handle(Image_CompressedPixMap) Image_DDSParser::Load (const Handle(Image_SupportedFormats)& theSupported,
const Handle(NCollection_Buffer)& theBuffer,
const Standard_Integer theFaceIndex)
{
if (theBuffer.IsNull()
|| theBuffer->Size() < 128
|| ::memcmp (theBuffer->Data(), "DDS ", 4) != 0)
{
return Handle(Image_CompressedPixMap)();
}
Handle(Image_CompressedPixMap) aDef = parseHeader (*(const DDSFileHeader* )(theBuffer->Data() + 4));
if (aDef.IsNull())
{
return Handle(Image_CompressedPixMap)();
}
if (!theSupported.IsNull()
&& !theSupported->IsSupported (aDef->CompressedFormat()))
{
return Handle(Image_CompressedPixMap)();
}
if (theFaceIndex < 0)
{
return aDef;
}
if (theFaceIndex >= aDef->NbFaces()
|| aDef->FaceBytes() == 0)
{
Message::SendFail (TCollection_AsciiString ("DDS Reader error - invalid face index #") + theFaceIndex + " within buffer");
return Handle(Image_CompressedPixMap)();
}
const Standard_Size anOffset = aDef->FaceBytes() * theFaceIndex + 128;
if (theBuffer->Size() < anOffset + aDef->FaceBytes())
{
Message::SendFail (TCollection_AsciiString ("DDS Reader error - unable to read face #") + theFaceIndex + " data from buffer");
return Handle(Image_CompressedPixMap)();
}
Handle(NCollection_Buffer) aBuffer = new NCollection_Buffer (Image_PixMap::DefaultAllocator(), aDef->FaceBytes());
memcpy (aBuffer->ChangeData(), theBuffer->Data() + anOffset, aDef->FaceBytes());
aDef->SetFaceData (aBuffer);
return aDef;
}
// =======================================================================
// function : parseHeader
// purpose :
// =======================================================================
Handle(Image_CompressedPixMap) Image_DDSParser::parseHeader (const DDSFileHeader& theHeader)
{
if (theHeader.Size != 124
|| theHeader.Width == 0
|| theHeader.Height == 0
|| theHeader.PixelFormatDef.Size != 32)
{
return Handle(Image_CompressedPixMap)();
}
Image_Format aBaseFormat = Image_Format_UNKNOWN;
Image_CompressedFormat aFormat = Image_CompressedFormat_UNKNOWN;
Standard_Integer aBlockSize = 8;
const bool hasAlpha = (theHeader.PixelFormatDef.Flags & 0x1) != 0;
if (::memcmp (&theHeader.PixelFormatDef.FourCC, "DXT5", 4) == 0)
{
aBaseFormat = Image_Format_RGBA;
aFormat = Image_CompressedFormat_RGBA_S3TC_DXT5;
aBlockSize = 16;
}
else if (::memcmp (&theHeader.PixelFormatDef.FourCC, "DXT3", 4) == 0)
{
aBaseFormat = Image_Format_RGBA;
aFormat = Image_CompressedFormat_RGBA_S3TC_DXT3;
aBlockSize = 16;
}
else if (::memcmp (&theHeader.PixelFormatDef.FourCC, "DXT1", 4) == 0)
{
aBaseFormat = hasAlpha ? Image_Format_RGBA : Image_Format_RGB;
aFormat = hasAlpha ? Image_CompressedFormat_RGBA_S3TC_DXT1 : Image_CompressedFormat_RGB_S3TC_DXT1;
aBlockSize = 8;
}
if (aFormat == Image_CompressedFormat_UNKNOWN)
{
return Handle(Image_CompressedPixMap)();
}
Handle(Image_CompressedPixMap) aDef = new Image_CompressedPixMap();
aDef->SetSize ((Standard_Integer )theHeader.Width, (Standard_Integer )theHeader.Height);
aDef->SetNbFaces (theHeader.IscompleteCubemap() != 0 ? 6 : 1);
aDef->SetBaseFormat (aBaseFormat);
aDef->SetCompressedFormat (aFormat);
const Standard_Integer aNbMipMaps = Max ((Standard_Integer )theHeader.MipMapCount, 1);
aDef->ChangeMipMaps().Resize (0, aNbMipMaps - 1, false);
{
Standard_Size aFaceSize = 0;
NCollection_Vec2<Standard_Integer> aMipSizeXY (aDef->SizeX(), aDef->SizeY());
for (Standard_Integer aMipIter = 0;; ++aMipIter)
{
const Standard_Integer aMipLength = ((aMipSizeXY.x() + 3) / 4) * ((aMipSizeXY.y() + 3) / 4) * aBlockSize;
aFaceSize += aMipLength;
aDef->ChangeMipMaps().SetValue (aMipIter, aMipLength);
if (aMipIter + 1 >= aNbMipMaps)
{
break;
}
aMipSizeXY /= 2;
if (aMipSizeXY.x() == 0) { aMipSizeXY.x() = 1; }
if (aMipSizeXY.y() == 0) { aMipSizeXY.y() = 1; }
}
aDef->SetCompleteMipMapSet (aMipSizeXY.x() == 1 && aMipSizeXY.y() == 1);
aDef->SetFaceBytes (aFaceSize);
}
return aDef;
}

View File

@@ -0,0 +1,62 @@
// Copyright (c) 2020 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 _Image_DDSParser_HeaderFile
#define _Image_DDSParser_HeaderFile
#include <Image_CompressedPixMap.hxx>
#include <NCollection_Buffer.hxx>
class Image_SupportedFormats;
//! Auxiliary tool for parsing DDS file structure (without decoding).
class Image_DDSParser
{
public:
//! Load the face from DDS file.
//! @param theSupported [in] list of supported image formats
//! @param theFile [in] file path
//! @param theFaceIndex [in] face index, within [0, Image_CompressedPixMap::NbFaces()) range;
//! use -1 to skip reading the face data
//! @param theFileOffset [in] offset to the DDS data
//! @return loaded face or NULL if file cannot be read or not valid DDS file
Standard_EXPORT static Handle(Image_CompressedPixMap) Load (const Handle(Image_SupportedFormats)& theSupported,
const TCollection_AsciiString& theFile,
const Standard_Integer theFaceIndex,
const int64_t theFileOffset = 0);
//! Load the face from DDS file.
//! @param theSupported [in] list of supported image formats
//! @param theBuffer [in] pre-loaded file data, should be at least of 128 bytes long defining DDS header.
//! @param theFaceIndex [in] face index, within [0, Image_CompressedPixMap::NbFaces()) range;
//! use -1 to skip reading the face data
//! @return loaded face or NULL if file cannot be read or not valid DDS file
Standard_EXPORT static Handle(Image_CompressedPixMap) Load (const Handle(Image_SupportedFormats)& theSupported,
const Handle(NCollection_Buffer)& theBuffer,
const Standard_Integer theFaceIndex);
private:
struct DDSPixelFormat;
struct DDSFileHeader;
private:
//! Parse DDS header.
static Handle(Image_CompressedPixMap) parseHeader (const DDSFileHeader& theHeader);
};
#endif // _Image_DDSParser_HeaderFile

View File

@@ -34,5 +34,6 @@ enum Image_Format
Image_Format_RGBAF, //!< 4 floats (16-bytes) RGBA image plane
Image_Format_BGRAF, //!< same as RGBAF but with different components order
};
enum { Image_Format_NB = Image_Format_BGRAF + 1 };
#endif // _Image_Format_HeaderFile

View File

@@ -14,6 +14,7 @@
// commercial license or contractual agreement.
#include <Image_PixMap.hxx>
#include <NCollection_AlignedAllocator.hxx>
#include <Standard_ProgramError.hxx>
@@ -21,6 +22,16 @@
IMPLEMENT_STANDARD_RTTIEXT(Image_PixMap,Standard_Transient)
// =======================================================================
// function : DefaultAllocator
// purpose :
// =======================================================================
const Handle(NCollection_BaseAllocator)& Image_PixMap::DefaultAllocator()
{
static const Handle(NCollection_BaseAllocator) THE_ALLOC = new NCollection_AlignedAllocator (16);
return THE_ALLOC;
}
// =======================================================================
// function : Image_PixMap
// purpose :
@@ -40,6 +51,10 @@ Image_PixMap::~Image_PixMap()
Clear();
}
// =======================================================================
// function : SizePixelBytes
// purpose :
// =======================================================================
Standard_Size Image_PixMap::SizePixelBytes (const Image_Format thePixelFormat)
{
switch (thePixelFormat)
@@ -135,8 +150,7 @@ bool Image_PixMap::InitTrash (Image_Format thePixelFormat,
// use argument only if it greater
const Standard_Size aSizeRowBytes = std::max (theSizeRowBytes, theSizeX * SizePixelBytes (thePixelFormat));
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_AlignedAllocator (16);
myData.Init (anAlloc, Image_PixMap::SizePixelBytes (thePixelFormat),
myData.Init (DefaultAllocator(), Image_PixMap::SizePixelBytes (thePixelFormat),
theSizeX, theSizeY, aSizeRowBytes, NULL);
return !myData.IsEmpty();
}

View File

@@ -48,6 +48,9 @@ public:
//! Convert image to Black/White.
Standard_EXPORT static void ToBlackWhite (Image_PixMap& theImage);
//! Return default image data allocator.
Standard_EXPORT static const Handle(NCollection_BaseAllocator)& DefaultAllocator();
public: // high-level API
Image_Format Format() const { return myImgFormat; }

View File

@@ -0,0 +1,27 @@
// Copyright (c) 2020 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 <Image_SupportedFormats.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Image_SupportedFormats, Standard_Transient)
// =======================================================================
// function : Image_SupportedFormats
// purpose :
// =======================================================================
Image_SupportedFormats::Image_SupportedFormats()
: myFormats (Image_Format_UNKNOWN, Image_CompressedFormat_NB - 1),
myHasCompressed (false)
{
myFormats.Init (false);
}

View File

@@ -0,0 +1,63 @@
// Copyright (c) 2020 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 _Image_SupportedFormats_HeaderFile
#define _Image_SupportedFormats_HeaderFile
#include <Image_CompressedFormat.hxx>
#include <NCollection_Array1.hxx>
#include <Standard_Type.hxx>
//! Structure holding information about supported texture formats.
class Image_SupportedFormats : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Image_SupportedFormats, Standard_Transient)
public:
//! Empty constructor.
Standard_EXPORT Image_SupportedFormats();
//! Return TRUE if image format is supported.
bool IsSupported (Image_Format theFormat) const { return myFormats.Value (theFormat); }
//! Set if image format is supported or not.
void Add (Image_Format theFormat) { myFormats.SetValue (theFormat, true); }
//! Return TRUE if there are compressed image formats supported.
bool HasCompressed() const { return myHasCompressed; }
//! Return TRUE if compressed image format is supported.
bool IsSupported (Image_CompressedFormat theFormat) const { return myFormats.Value (theFormat); }
//! Set if compressed image format is supported or not.
void Add (Image_CompressedFormat theFormat)
{
myFormats.SetValue (theFormat, true);
myHasCompressed = true;
}
//! Reset flags.
void Clear()
{
myFormats.Init (false);
myHasCompressed = false;
}
protected:
NCollection_Array1<bool> myFormats; //!< list of supported formats
Standard_Boolean myHasCompressed; //!< flag indicating that some compressed image formats are supported
};
#endif // _Image_SupportedFormats_HeaderFile

View File

@@ -15,6 +15,8 @@
#include <Image_Texture.hxx>
#include <Image_AlienPixMap.hxx>
#include <Image_DDSParser.hxx>
#include <Image_SupportedFormats.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <OSD_OpenFile.hxx>
@@ -73,11 +75,41 @@ Image_Texture::Image_Texture (const Handle(NCollection_Buffer)& theBuffer,
}
}
// ================================================================
// Function : ReadCompressedImage
// Purpose :
// ================================================================
Handle(Image_CompressedPixMap) Image_Texture::ReadCompressedImage (const Handle(Image_SupportedFormats)& theSupported) const
{
if (!theSupported->HasCompressed())
{
return Handle(Image_CompressedPixMap)();
}
if (!myBuffer.IsNull())
{
return Image_DDSParser::Load (theSupported, myBuffer, 0);
}
else if (myOffset >= 0)
{
return Image_DDSParser::Load (theSupported, myImagePath, 0, myOffset);
}
TCollection_AsciiString aFilePathLower = myImagePath;
aFilePathLower.LowerCase();
if (!aFilePathLower.EndsWith (".dds"))
{
// do not waste time on file system access in case of wrong file extension
return Handle(Image_CompressedPixMap)();
}
return Image_DDSParser::Load (theSupported, myImagePath, 0);
}
// ================================================================
// Function : ReadImage
// Purpose :
// ================================================================
Handle(Image_PixMap) Image_Texture::ReadImage() const
Handle(Image_PixMap) Image_Texture::ReadImage (const Handle(Image_SupportedFormats)& ) const
{
Handle(Image_PixMap) anImage;
if (!myBuffer.IsNull())
@@ -240,6 +272,10 @@ TCollection_AsciiString Image_Texture::ProbeImageFileFormat() const
{
return "webp";
}
else if (memcmp (aBuffer, "DDS ", 4) == 0)
{
return "dds";
}
return "";
}

View File

@@ -18,6 +18,8 @@
#include <NCollection_Buffer.hxx>
#include <TCollection_AsciiString.hxx>
class Image_CompressedPixMap;
class Image_SupportedFormats;
class Image_PixMap;
//! Texture image definition.
@@ -57,8 +59,11 @@ public:
//! Return image file format.
Standard_EXPORT TCollection_AsciiString ProbeImageFileFormat() const;
//! Image reader without decoding data for formats supported natively by GPUs.
Standard_EXPORT virtual Handle(Image_CompressedPixMap) ReadCompressedImage (const Handle(Image_SupportedFormats)& theSupported) const;
//! Image reader.
Standard_EXPORT virtual Handle(Image_PixMap) ReadImage() const;
Standard_EXPORT virtual Handle(Image_PixMap) ReadImage (const Handle(Image_SupportedFormats)& theSupported) const;
//! Write image to specified file without decoding data.
Standard_EXPORT virtual Standard_Boolean WriteImage (const TCollection_AsciiString& theFile);

View File

@@ -21,11 +21,16 @@
#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 = new OpenGl_CappingPlaneResource (NULL, 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
{
@@ -58,6 +63,120 @@ 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)
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
const bool wasCullAllowed = theWorkspace->SetAllowFaceCulling (true);
const Standard_Boolean isTextureHatch =
theHatchAspect != NULL
&& theHatchAspect->Aspect()->TextureMapState();
aContext->ModelWorldState.Push();
aContext->ModelWorldState.SetCurrent (theCappingMatrix);
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);
}
}
}
aContext->ModelWorldState.Pop();
aContext->ApplyModelViewMatrix();
theWorkspace->SetAllowFaceCulling (wasCullAllowed);
}
//! 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.
@@ -86,13 +205,24 @@ namespace
const OpenGl_Structure& theStructure,
const Handle(Graphic3d_ClipPlane)& theClipChain,
const Standard_Integer theSubPlaneIndex,
const Handle(OpenGl_CappingPlaneResource)& thePlane)
const Handle(OpenGl_CappingPlaneResource)& thePlane,
const OpenGl_PrimitiveArray* theQuad)
{
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_ClipPlane)& aRenderPlane = thePlane->Plane();
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;
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value()->IsClosed())
@@ -103,14 +233,33 @@ 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()))
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)
{
continue;
anAspectCapping = THE_DEFAULT_ASPECT;
}
const OpenGl_Aspects* anAspectFace = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
const Standard_Boolean hasHatch = anAspectCapping->Aspect()->ToDrawHatch();
if (!hasHatch)
{
// check if capping plane should be rendered within current pass (only opaque / only transparent)
const OpenGl_Aspects* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->GlAspects() : NULL;
//const OpenGl_Aspects* anObjAspectFace = aRenderPlane->CappingSectionStyle()->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
@@ -140,17 +289,25 @@ namespace
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
// render closed primitives
if (aRenderPlane->ToUseObjectProperties())
if (hasHatch)
{
aGroupIter.Value()->Render (theWorkspace);
}
else
{
for (; aGroupIter.More(); aGroupIter.Next())
// render closed primitives
if (aRenderPlane->ToUseObjectProperties())
{
if (aGroupIter.Value()->IsClosed())
aGroupIter.Value()->Render (theWorkspace);
}
else
{
for (; aGroupIter.More(); aGroupIter.Next())
{
aGroupIter.Value()->Render (theWorkspace);
if (aGroupIter.Value()->IsClosed())
{
aGroupIter.Value()->Render (theWorkspace);
}
}
}
}
@@ -176,8 +333,63 @@ namespace
glEnable (GL_DEPTH_TEST);
}
theWorkspace->SetAspects (thePlane->AspectFace());
renderPlane (theWorkspace, thePlane);
if (!hasHatch)
{
theWorkspace->SetAspects (thePlane->AspectFace());
renderPlane (theWorkspace, thePlane);
}
else
{
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;
if (aCameraPln.Magnitude() > Precision::Confusion())
{
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);
}
// turn on the current plane to restore initial state
aContext->ChangeClipping().ResetCappingFilter();
@@ -187,7 +399,7 @@ namespace
if (theStructure.InstancedStructure() != NULL)
{
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane);
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane, theQuad);
}
}
}
@@ -206,6 +418,12 @@ 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();
@@ -214,6 +432,16 @@ 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())
{
@@ -229,23 +457,33 @@ 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 = aSubPlaneIter->GetId();
const TCollection_AsciiString& aResId = THE_PLANE_STYLE + 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);
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter, aSubPlaneIter->CappingSectionStyle());
aContext->ShareResource (aResId, aPlaneRes);
}
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes);
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes, aCappingQuad);
// set delayed resource release
aPlaneRes.Nullify();
aContext->ReleaseResource (aResId, Standard_True);
if (!aResId.IsEmpty())
{
// schedule release of resource if not used
aContext->ReleaseResource (aResId, Standard_True);
}
}
}
if (aPrevBlend == GL_TRUE)
{
glEnable (GL_BLEND);
glBlendFunc (aPrevBlendSrc, aPrevBlendDst);
}
// restore rendering aspects
theWorkspace->SetAspects (aFaceAsp);
theWorkspace->SetRenderFilter (aPrevFilter);

View File

@@ -56,21 +56,28 @@ 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 : OpenGl_CappingPlaneResource
// function : BuildInfinitPlaneVertices
// purpose :
// =======================================================================
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* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
{
OpenGl_PrimitiveArray* aPrimitives = NULL;
// Fill primitive array
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
@@ -83,8 +90,53 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
if (anAttribs->Init (12, anAttribInfo, 3))
{
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
aPrimitives = new OpenGl_PrimitiveArray (NULL);
aPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
}
return aPrimitives;
}
// =======================================================================
// function : OpenGl_CappingPlaneResource
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane,
const Handle(Graphic3d_AspectFillCapping)& theAspect)
: myPrimitives (NULL),
myPrimitivesUsed (Standard_False),
myOrientation (OpenGl_IdentityMatrix),
myAspect (NULL),
myPlaneRoot (thePlane),
myEquationMod ((unsigned int )-1),
myAspectMod ((unsigned int )-1),
myCappingAspect(),//defaultMaterial()),
myHatchingAspect(),//defaultMaterial()),
myHatchingState (0)
{
if (theAspect.IsNull() || !theAspect->ToDrawHatch())
{
// Fill primitive array
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
Graphic3d_Attribute anAttribInfo[] =
{
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC4 },
{ Graphic3d_TOA_NORM, Graphic3d_TOD_VEC4 },
{ Graphic3d_TOA_UV, Graphic3d_TOD_VEC4 }
};
if (anAttribs->Init (12, anAttribInfo, 3))
{
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
myPrimitivesUsed = Standard_True;
}
}
myCappingAspect.SetAspect (defaultMaterial());
myHatchingAspect.SetAspect (defaultMaterial());
SetAspect (theAspect);
}
// =======================================================================
@@ -93,7 +145,90 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
// =======================================================================
OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
{
Release (NULL);
if (myPrimitivesUsed)
{
Release (NULL);
}
}
// =======================================================================
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
{
myGraphicAspect = theAspect;
if (theAspect.IsNull())
{
return;
}
if (!theAspect->ToDrawHatch())
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();
}
}
// =======================================================================
@@ -103,6 +238,9 @@ OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theObjAspect)
{
if (!myPrimitivesUsed)
return;
updateTransform (theCtx);
updateAspect (theObjAspect);
}
@@ -113,10 +251,118 @@ void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theCtx,
// =======================================================================
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
{
OpenGl_Element::Destroy (theContext, myAspect);
myPrimitives.Release (theContext);
myEquationMod = (unsigned int )-1;
myAspectMod = (unsigned int )-1;
if (myPrimitivesUsed)
{
OpenGl_Element::Destroy (theContext, myAspect);
myPrimitives.Release (theContext);
myEquationMod = (unsigned int )-1;
myAspectMod = (unsigned int )-1;
}
myCappingAspect .Release (theContext);
myHatchingAspect.Release (theContext);
}
// =======================================================================
// function : CappingFaceAspect
// purpose :
// =======================================================================
const OpenGl_Aspects* OpenGl_CappingPlaneResource::CappingFaceAspect (const OpenGl_Aspects* theObjectAspect) const
{
if (myGraphicAspect.IsNull())
{
return NULL;
}
Handle(Graphic3d_Aspects) aFillAspect = myCappingAspect.Aspect();
if (myGraphicAspect->ToUseObjectMaterial() && theObjectAspect != NULL)
{
// only front material currently supported by capping rendering
aFillAspect->SetFrontMaterial (theObjectAspect->Aspect()->FrontMaterial());
aFillAspect->SetInteriorColor (theObjectAspect->Aspect()->InteriorColor());
}
else
{
aFillAspect->SetFrontMaterial (myGraphicAspect->Material());
aFillAspect->SetInteriorColor (myGraphicAspect->Material().Color());
}
if (myGraphicAspect->ToUseObjectTexture() && theObjectAspect != NULL)
{
if (theObjectAspect->Aspect()->ToMapTexture())
{
aFillAspect->SetTextureMap (theObjectAspect->Aspect()->TextureMap());
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
else
{
aFillAspect->SetTextureMap (myGraphicAspect->Texture());
if (!myGraphicAspect->Texture().IsNull())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
if (myGraphicAspect->ToUseObjectShader() && theObjectAspect != NULL)
{
aFillAspect->SetShaderProgram (theObjectAspect->Aspect()->ShaderProgram());
}
else
{
aFillAspect->SetShaderProgram (myGraphicAspect->Shader());
}
myCappingAspect.SetAspect (aFillAspect);
return &myCappingAspect;
}
// =======================================================================
// function : HatchingFaceAspect
// purpose :
// =======================================================================
const OpenGl_Aspects* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
{
if (myGraphicAspect.IsNull())
{
return NULL;
}
const Standard_Size aHatchingState = myGraphicAspect->HatchingState();
if (myHatchingState != aHatchingState)
{
if (myGraphicAspect->ToDrawHatch())
{
Handle(Graphic3d_Aspects) aFillAspect = myHatchingAspect.Aspect();
aFillAspect->SetInteriorStyle (myGraphicAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
aFillAspect->SetHatchStyle (myGraphicAspect->IsStippleHatch() ? myGraphicAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
aFillAspect->SetTextureMap (myGraphicAspect->IsTextureHatch() ? myGraphicAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
aFillAspect->SetFrontMaterial (myGraphicAspect->HatchMaterial());
aFillAspect->SetInteriorColor (myGraphicAspect->HatchMaterial().Color());
if (myGraphicAspect->IsTextureHatch())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
myHatchingAspect.SetAspect (aFillAspect);
myHatchingState = aHatchingState;
}
}
return &myHatchingAspect;
}
// =======================================================================
@@ -125,6 +371,9 @@ void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
// =======================================================================
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect)
{
if (myPlaneRoot.IsNull())
return;
if (myAspect == NULL)
{
myAspect = new OpenGl_Aspects();
@@ -145,7 +394,7 @@ void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)&
{
myFillAreaAspect = new Graphic3d_AspectFillArea3d();
}
if (myAspectMod != myPlaneRoot->MCountAspect())
if (myAspectMod != myPlaneRoot->MCountAspect())
{
*myFillAreaAspect = *myPlaneRoot->CappingAspect();
}
@@ -182,6 +431,9 @@ void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)&
// =======================================================================
void OpenGl_CappingPlaneResource::updateTransform (const Handle(OpenGl_Context)& theCtx)
{
if (myPlaneRoot.IsNull())
return;
if (myEquationMod == myPlaneRoot->MCountEquation()
&& myLocalOrigin.IsEqual (theCtx->ShaderManager()->LocalOrigin(), gp::Resolution()))
{

View File

@@ -20,6 +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;
@@ -30,16 +31,15 @@ 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_ClipPlane data by id.
//! - instance associated to Graphic3d_AspectFillCapping data.
//! - should created and released within context (owns OpenGl elements and resources).
class OpenGl_CappingPlaneResource : public OpenGl_Resource
{
public:
//! 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);
//! Create and assign style.
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane,
const Handle(Graphic3d_AspectFillCapping)& theAspect);
//! Destroy object.
Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
@@ -50,6 +50,12 @@ public:
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
const Handle(Graphic3d_Aspects)& theObjAspect);
//! Assign section style.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect);
//! Returns section style parameters.
const Handle(Graphic3d_AspectFillCapping)& Aspect() const { return myGraphicAspect; }
//! Release associated OpenGl resources.
//! @param theContext [in] the resource context.
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
@@ -60,15 +66,33 @@ public:
//! Return parent clipping plane structure.
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
//! @return primitive array of vertices to render infinite plane.
static OpenGl_PrimitiveArray* BuildInfinitPlaneVertices();
//! @return aspect face for rendering capping surface.
inline const OpenGl_Aspects* AspectFace() const { return myAspect; }
//! Returns true if capping should draw hatch layer.
Standard_Boolean ToDrawHatch() const
{
return Aspect()->ToDrawHatch()
&& (Aspect()->IsStippleHatch()
|| Aspect()->IsTextureHatch());
}
//! @return evaluated orientation matrix to transform infinite plane.
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
//! 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;
//! @return primitive array of vertices to render infinite plane.
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
//! Returns the shading aspect for drawing hatch layer of a section.
Standard_EXPORT const OpenGl_Aspects* HatchingFaceAspect() const;
private:
//! Update precomputed plane orientation matrix.
@@ -80,6 +104,7 @@ private:
private:
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
Standard_Boolean myPrimitivesUsed; //!< boolean flag if primitives are used
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
OpenGl_Aspects* myAspect; //!< capping face aspect.
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
@@ -88,6 +113,11 @@ private:
unsigned int myEquationMod; //!< modification counter for plane equation.
unsigned int myAspectMod; //!< modification counter for aspect.
Handle(Graphic3d_AspectFillCapping) myGraphicAspect; //!< 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;
public:
DEFINE_STANDARD_RTTIEXT(OpenGl_CappingPlaneResource,OpenGl_Resource) // Type definition

View File

@@ -25,6 +25,7 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient)
// =======================================================================
OpenGl_Caps::OpenGl_Caps()
: sRGBDisable (Standard_False),
compressedTexturesDisable (Standard_False),
vboDisable (Standard_False),
pntSpritesDisable (Standard_False),
keepArrayData (Standard_False),
@@ -54,6 +55,7 @@ OpenGl_Caps::OpenGl_Caps()
contextNoExtensions (Standard_False),
contextMajorVersionUpper (-1),
contextMinorVersionUpper (-1),
isTopDownTextureUV(Standard_False),
glslWarnings (Standard_False),
suppressExtraMsg (Standard_True),
glslDumpLevel (OpenGl_ShaderProgramDumpLevel_Off)
@@ -68,6 +70,7 @@ OpenGl_Caps::OpenGl_Caps()
OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy)
{
sRGBDisable = theCopy.sRGBDisable;
compressedTexturesDisable = theCopy.compressedTexturesDisable;
vboDisable = theCopy.vboDisable;
pntSpritesDisable = theCopy.pntSpritesDisable;
keepArrayData = theCopy.keepArrayData;
@@ -83,6 +86,7 @@ OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy)
contextNoExtensions = theCopy.contextNoExtensions;
contextMajorVersionUpper = theCopy.contextMajorVersionUpper;
contextMinorVersionUpper = theCopy.contextMinorVersionUpper;
isTopDownTextureUV = theCopy.isTopDownTextureUV;
glslWarnings = theCopy.glslWarnings;
suppressExtraMsg = theCopy.suppressExtraMsg;
glslDumpLevel = theCopy.glslDumpLevel;

View File

@@ -28,6 +28,7 @@ class OpenGl_Caps : public Standard_Transient
public: //! @name flags to disable particular functionality, should be used only for testing purposes!
Standard_Boolean sRGBDisable; //!< Disables sRGB rendering (OFF by default)
Standard_Boolean compressedTexturesDisable; //!< Disables uploading of compressed texture formats native to GPU (OFF by default)
Standard_Boolean vboDisable; //!< disallow VBO usage for debugging purposes (OFF by default)
Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
Standard_Boolean keepArrayData; //!< Disables freeing CPU memory after building VBOs (OFF by default)
@@ -125,6 +126,19 @@ public: //! @name context creation parameters
Standard_Integer contextMajorVersionUpper;
Standard_Integer contextMinorVersionUpper;
/**
* Define if 2D texture UV coordinates are defined top-down or bottom-up. FALSE by default.
*
* Proper rendering requires image texture uploading and UV texture coordinates being consistent,
* otherwise texture mapping might appear vertically flipped.
* Historically, OCCT used image library loading images bottom-up,
* so that applications have to generate UV accordingly (flip V when necessary, V' = 1.0 - V).
*
* Graphic driver now compares this flag with image layout reported by Image_PixMap::IsTopDown(),
* and in case of mismatch applies implicit texture coordinates conversion in GLSL program.
*/
Standard_Boolean isTopDownTextureUV;
public: //! @name flags to activate verbose output
//! Print GLSL program compilation/linkage warnings, if any. OFF by default.

View File

@@ -37,6 +37,7 @@
#include <Graphic3d_TransformUtils.hxx>
#include <Graphic3d_RenderingParams.hxx>
#include <Image_SupportedFormats.hxx>
#include <Message_Messenger.hxx>
#include <NCollection_Vector.hxx>
#include <Standard_ProgramError.hxx>
@@ -188,6 +189,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
myClippingState (),
myGlLibHandle (NULL),
myFuncs (new OpenGl_GlFunctions()),
mySupportedFormats (new Image_SupportedFormats()),
myAnisoMax (1),
myTexClamp (GL_CLAMP_TO_EDGE),
myMaxTexDim (1024),
@@ -1319,6 +1321,14 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
myVendor = (const char* )::glGetString (GL_VENDOR);
myVendor.LowerCase();
// standard formats
mySupportedFormats->Clear();
mySupportedFormats->Add (Image_PixMap::ImgGray);
mySupportedFormats->Add (Image_PixMap::ImgAlpha);
mySupportedFormats->Add (Image_PixMap::ImgRGB);
mySupportedFormats->Add (Image_PixMap::ImgRGB32);
mySupportedFormats->Add (Image_PixMap::ImgRGBA);
if (caps->contextMajorVersionUpper != -1)
{
// synthetically restrict OpenGL version for testing
@@ -1467,6 +1477,13 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
}
#endif
if (extBgra)
{
// no BGR on OpenGL ES - only BGRA as extension
mySupportedFormats->Add (Image_PixMap::ImgBGR32);
mySupportedFormats->Add (Image_PixMap::ImgBGRA);
}
core11fwd = (OpenGl_GlCore11Fwd* )(&(*myFuncs));
if (IsGlGreaterEqual (2, 0))
{
@@ -1613,7 +1630,7 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
hasTexRGBA8 = Standard_True;
hasTexSRGB = IsGlGreaterEqual (2, 0);
hasTexSRGB = IsGlGreaterEqual (2, 1);
hasFboSRGB = IsGlGreaterEqual (2, 1);
hasSRGBControl = hasFboSRGB;
arbDrawBuffers = CheckExtension ("GL_ARB_draw_buffers");
@@ -1622,12 +1639,20 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|| CheckExtension ("GL_ARB_texture_float");
hasTexFloatLinear = arbTexFloat;
arbSampleShading = CheckExtension ("GL_ARB_sample_shading");
extBgra = CheckExtension ("GL_EXT_bgra");
extBgra = IsGlGreaterEqual (1, 2)
|| CheckExtension ("GL_EXT_bgra");
extAnis = CheckExtension ("GL_EXT_texture_filter_anisotropic");
extPDS = CheckExtension ("GL_EXT_packed_depth_stencil");
atiMem = CheckExtension ("GL_ATI_meminfo");
nvxMem = CheckExtension ("GL_NVX_gpu_memory_info");
if (extBgra)
{
mySupportedFormats->Add (Image_PixMap::ImgBGR);
mySupportedFormats->Add (Image_PixMap::ImgBGR32);
mySupportedFormats->Add (Image_PixMap::ImgBGRA);
}
hasDrawBuffers = IsGlGreaterEqual (2, 0) ? OpenGl_FeatureInCore :
arbDrawBuffers ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
@@ -2974,6 +2999,59 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
}
}
if (arbTexFloat)
{
mySupportedFormats->Add (Image_Format_GrayF);
mySupportedFormats->Add (Image_Format_AlphaF);
mySupportedFormats->Add (Image_Format_RGBF);
mySupportedFormats->Add (Image_Format_RGBAF);
if (arbTexRG)
{
mySupportedFormats->Add (Image_Format_RGF);
}
if (extBgra)
{
#if !defined(GL_ES_VERSION_2_0)
mySupportedFormats->Add (Image_Format_BGRF);
#endif
mySupportedFormats->Add (Image_Format_BGRAF);
}
}
#ifdef __EMSCRIPTEN__
if (checkEnableWebGlExtension (*this, "GL_WEBGL_compressed_texture_s3tc")) // GL_WEBGL_compressed_texture_s3tc_srgb for sRGB formats
{
mySupportedFormats->Add (Image_CompressedFormat_RGB_S3TC_DXT1);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT1);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT3);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT5);
}
#else
if (CheckExtension ("GL_EXT_texture_compression_s3tc")) // GL_EXT_texture_sRGB for sRGB formats
{
mySupportedFormats->Add (Image_CompressedFormat_RGB_S3TC_DXT1);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT1);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT3);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT5);
}
else
{
if (CheckExtension ("GL_EXT_texture_compression_dxt1"))
{
mySupportedFormats->Add (Image_CompressedFormat_RGB_S3TC_DXT1);
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT1);
}
if (CheckExtension ("GL_ANGLE_texture_compression_dxt3"))
{
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT3);
}
if (CheckExtension ("GL_ANGLE_texture_compression_dxt5"))
{
mySupportedFormats->Add (Image_CompressedFormat_RGBA_S3TC_DXT5);
}
}
#endif
// check whether PBR shading model is supported
myHasPBR = arbFBO != NULL
&& myMaxTexCombined >= 4
@@ -3461,7 +3539,7 @@ Handle(OpenGl_TextureSet) OpenGl_Context::BindTextures (const Handle(OpenGl_Text
}
else
{
OpenGl_Sampler::applySamplerParams (aThisCtx, aTextureNew->Sampler()->Parameters(), aTextureNew->Sampler().get(), aTextureNew->GetTarget(), aTextureNew->HasMipmaps());
OpenGl_Sampler::applySamplerParams (aThisCtx, aTextureNew->Sampler()->Parameters(), aTextureNew->Sampler().get(), aTextureNew->GetTarget(), aTextureNew->MaxMipmapLevel());
}
}
#if !defined(GL_ES_VERSION_2_0)
@@ -3791,13 +3869,17 @@ void OpenGl_Context::SetLineWidth (const Standard_ShortReal theWidth)
// function : SetTextureMatrix
// purpose :
// =======================================================================
void OpenGl_Context::SetTextureMatrix (const Handle(Graphic3d_TextureParams)& theParams)
void OpenGl_Context::SetTextureMatrix (const Handle(Graphic3d_TextureParams)& theParams,
const Standard_Boolean theIsTopDown)
{
if (theParams.IsNull())
{
return;
}
else if (!myActiveProgram.IsNull())
const Graphic3d_Vec2& aScale = theParams->Scale();
const Graphic3d_Vec2& aTrans = theParams->Translation();
if (!myActiveProgram.IsNull())
{
const GLint aUniLoc = myActiveProgram->GetStateLocation (OpenGl_OCCT_TEXTURE_TRSF2D);
if (aUniLoc == OpenGl_ShaderProgram::INVALID_LOCATION)
@@ -3808,14 +3890,17 @@ void OpenGl_Context::SetTextureMatrix (const Handle(Graphic3d_TextureParams)& th
// pack transformation parameters
OpenGl_Vec4 aTrsf[2] =
{
OpenGl_Vec4 (-theParams->Translation().x(),
-theParams->Translation().y(),
theParams->Scale().x(),
theParams->Scale().y()),
OpenGl_Vec4 (-aTrans.x(), -aTrans.y(), aScale.x(), aScale.y()),
OpenGl_Vec4 (static_cast<float> (std::sin (-theParams->Rotation() * M_PI / 180.0)),
static_cast<float> (std::cos (-theParams->Rotation() * M_PI / 180.0)),
0.0f, 0.0f)
};
if (caps->isTopDownTextureUV != theIsTopDown)
{
// flip V
aTrsf[0].y() = -aTrans.y() + 1.0f / aScale.y();
aTrsf[0].w() = -aScale.y();
}
myActiveProgram->SetUniform (this, aUniLoc, 2, aTrsf);
return;
}
@@ -3828,11 +3913,18 @@ void OpenGl_Context::SetTextureMatrix (const Handle(Graphic3d_TextureParams)& th
core11->glMatrixMode (GL_TEXTURE);
OpenGl_Mat4 aTextureMat;
const Graphic3d_Vec2& aScale = theParams->Scale();
const Graphic3d_Vec2& aTrans = theParams->Translation();
Graphic3d_TransformUtils::Scale (aTextureMat, aScale.x(), aScale.y(), 1.0f);
Graphic3d_TransformUtils::Translate (aTextureMat, -aTrans.x(), -aTrans.y(), 0.0f);
Graphic3d_TransformUtils::Rotate (aTextureMat, -theParams->Rotation(), 0.0f, 0.0f, 1.0f);
if (caps->isTopDownTextureUV != theIsTopDown)
{
// flip V
Graphic3d_TransformUtils::Scale (aTextureMat, aScale.x(), -aScale.y(), 1.0f);
Graphic3d_TransformUtils::Translate (aTextureMat, -aTrans.x(), -aTrans.y() + 1.0f / aScale.y(), 0.0f);
}
else
{
Graphic3d_TransformUtils::Scale (aTextureMat, aScale.x(), aScale.y(), 1.0f);
Graphic3d_TransformUtils::Translate (aTextureMat, -aTrans.x(), -aTrans.y(), 0.0f);
}
Graphic3d_TransformUtils::Rotate (aTextureMat, -theParams->Rotation(), 0.0f, 0.0f, 1.0f);
core11->glLoadMatrixf (aTextureMat);
core11->glMatrixMode (aMatrixMode);
}

View File

@@ -506,6 +506,9 @@ public:
#endif
}
//! Return map of supported texture formats.
const Handle(Image_SupportedFormats)& SupportedTextureFormats() const { return mySupportedFormats; }
//! @return maximum degree of anisotropy texture filter
Standard_Integer MaxDegreeOfAnisotropy() const { return myAnisoMax; }
@@ -911,7 +914,10 @@ public: //! @name methods to alter or retrieve current state
Standard_EXPORT void SetPointSpriteOrigin();
//! Setup texture matrix to active GLSL program or to FFP global state using glMatrixMode (GL_TEXTURE).
Standard_EXPORT void SetTextureMatrix (const Handle(Graphic3d_TextureParams)& theParams);
//! @param theParams [in] texture parameters
//! @param theIsTopDown [in] texture top-down flag
Standard_EXPORT void SetTextureMatrix (const Handle(Graphic3d_TextureParams)& theParams,
const Standard_Boolean theIsTopDown);
//! Bind default Vertex Array Object
Standard_EXPORT void BindDefaultVao();
@@ -1040,7 +1046,7 @@ public: //! @name extensions
Standard_Boolean hasUintIndex; //!< GLuint for index buffer is supported (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_element_index_uint)
Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
Standard_Boolean hasTexFloatLinear; //!< texture-filterable state for 32-bit floating texture formats (always on desktop, GL_OES_texture_float_linear within OpenGL ES)
Standard_Boolean hasTexSRGB; //!< sRGB texture formats (desktop OpenGL 2.0, OpenGL ES 3.0 or GL_EXT_texture_sRGB)
Standard_Boolean hasTexSRGB; //!< sRGB texture formats (desktop OpenGL 2.1, OpenGL ES 3.0 or GL_EXT_texture_sRGB)
Standard_Boolean hasFboSRGB; //!< sRGB FBO render targets (desktop OpenGL 2.1, OpenGL ES 3.0)
Standard_Boolean hasSRGBControl; //!< sRGB write control (any desktop OpenGL, OpenGL ES + GL_EXT_sRGB_write_control extension)
OpenGl_FeatureFlag hasFlatShading; //!< Complex flag indicating support of Flat shading (Graphic3d_TOSM_FACET) (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives)
@@ -1116,6 +1122,8 @@ private: // context info
void* myGlLibHandle; //!< optional handle to GL library
NCollection_Handle<OpenGl_GlFunctions>
myFuncs; //!< mega structure for all GL functions
Handle(Image_SupportedFormats)
mySupportedFormats; //!< map of supported texture formats
Standard_Integer myAnisoMax; //!< maximum level of anisotropy texture filter
Standard_Integer myTexClamp; //!< either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1)
Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE

View File

@@ -152,6 +152,17 @@
#define GL_TRIANGLES_ADJACENCY 0x000C
#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
#define GL_PATCHES 0x000E
// GL_EXT_texture_compression_s3tc extension
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
//
#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
#endif
#if !defined(HAVE_EGL) && (defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(HAVE_GLES2) || defined(OCCT_UWP))
@@ -191,87 +202,87 @@ public: //! @name OpenGL ES 1.1
#if defined(GL_ES_VERSION_2_0)
inline void glActiveTexture (GLenum texture)
inline void glActiveTexture (GLenum texture) const
{
::glActiveTexture (texture);
}
inline void glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data)
inline void glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const
{
::glCompressedTexImage2D (target, level, internalformat, width, height, border, imageSize, data);
}
inline void glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data)
inline void glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) const
{
::glCompressedTexSubImage2D (target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
inline void glBindBuffer (GLenum target, GLuint buffer)
inline void glBindBuffer (GLenum target, GLuint buffer) const
{
::glBindBuffer (target, buffer);
}
inline void glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage)
inline void glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage) const
{
::glBufferData (target, size, data, usage);
}
inline void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
inline void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) const
{
::glBufferSubData (target, offset, size, data);
}
inline void glDeleteBuffers (GLsizei n, const GLuint *buffers)
inline void glDeleteBuffers (GLsizei n, const GLuint *buffers) const
{
::glDeleteBuffers (n, buffers);
}
inline void glDeleteTextures (GLsizei n, const GLuint *textures)
inline void glDeleteTextures (GLsizei n, const GLuint *textures) const
{
::glDeleteTextures (n, textures);
}
inline void glDepthFunc (GLenum func)
inline void glDepthFunc (GLenum func) const
{
::glDepthFunc (func);
}
inline void glDepthMask (GLboolean flag)
inline void glDepthMask (GLboolean flag) const
{
::glDepthMask (flag);
}
inline void glDepthRangef (GLfloat n, GLfloat f)
inline void glDepthRangef (GLfloat n, GLfloat f) const
{
::glDepthRangef (n, f);
}
inline void glGenBuffers (GLsizei n, GLuint *buffers)
inline void glGenBuffers (GLsizei n, GLuint *buffers) const
{
::glGenBuffers (n, buffers);
}
inline void glGenTextures (GLsizei n, GLuint *textures)
inline void glGenTextures (GLsizei n, GLuint *textures) const
{
::glGenTextures (n, textures);
}
inline void glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params)
inline void glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params) const
{
::glGetBufferParameteriv (target, pname, params);
}
inline GLboolean glIsBuffer (GLuint buffer)
inline GLboolean glIsBuffer (GLuint buffer) const
{
return ::glIsBuffer (buffer);
}
inline void glSampleCoverage (GLfloat value, GLboolean invert)
inline void glSampleCoverage (GLfloat value, GLboolean invert) const
{
::glSampleCoverage (value, invert);
}
inline void glMultiDrawElements (GLenum theMode, const GLsizei* theCount, GLenum theType, const void* const* theIndices, GLsizei theDrawCount)
inline void glMultiDrawElements (GLenum theMode, const GLsizei* theCount, GLenum theType, const void* const* theIndices, GLsizei theDrawCount) const
{
if (theCount == NULL
|| theIndices == NULL)
@@ -290,422 +301,422 @@ public: //! @name OpenGL ES 1.1
public: //! @name OpenGL ES 2.0
#if defined(GL_ES_VERSION_2_0)
inline void glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
inline void glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) const
{
::glBlendColor (red, green, blue, alpha);
}
inline void glBlendEquation (GLenum mode)
inline void glBlendEquation (GLenum mode) const
{
::glBlendEquation (mode);
}
inline void glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
inline void glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) const
{
::glBlendFuncSeparate (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
}
inline void glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha)
inline void glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha) const
{
::glBlendEquationSeparate (modeRGB, modeAlpha);
}
inline void glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
inline void glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) const
{
::glStencilOpSeparate (face, sfail, dpfail, dppass);
}
inline void glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask)
inline void glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask) const
{
::glStencilFuncSeparate (face, func, ref, mask);
}
inline void glStencilMaskSeparate (GLenum face, GLuint mask)
inline void glStencilMaskSeparate (GLenum face, GLuint mask) const
{
::glStencilMaskSeparate (face, mask);
}
inline void glAttachShader (GLuint program, GLuint shader)
inline void glAttachShader (GLuint program, GLuint shader) const
{
::glAttachShader (program, shader);
}
inline void glBindAttribLocation (GLuint program, GLuint index, const GLchar *name)
inline void glBindAttribLocation (GLuint program, GLuint index, const GLchar *name) const
{
::glBindAttribLocation (program, index, name);
}
inline void glBindFramebuffer (GLenum target, GLuint framebuffer)
inline void glBindFramebuffer (GLenum target, GLuint framebuffer) const
{
::glBindFramebuffer (target, framebuffer);
}
inline void glBindRenderbuffer (GLenum target, GLuint renderbuffer)
inline void glBindRenderbuffer (GLenum target, GLuint renderbuffer) const
{
::glBindRenderbuffer (target, renderbuffer);
}
inline GLenum glCheckFramebufferStatus (GLenum target)
inline GLenum glCheckFramebufferStatus (GLenum target) const
{
return ::glCheckFramebufferStatus (target);
}
inline void glCompileShader (GLuint shader)
inline void glCompileShader (GLuint shader) const
{
::glCompileShader (shader);
}
inline GLuint glCreateProgram()
inline GLuint glCreateProgram() const
{
return ::glCreateProgram();
}
inline GLuint glCreateShader (GLenum type)
inline GLuint glCreateShader (GLenum type) const
{
return ::glCreateShader (type);
}
inline void glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers)
inline void glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers) const
{
::glDeleteFramebuffers (n, framebuffers);
}
inline void glDeleteProgram (GLuint program)
inline void glDeleteProgram (GLuint program) const
{
::glDeleteProgram (program);
}
inline void glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers)
inline void glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers) const
{
::glDeleteRenderbuffers (n, renderbuffers);
}
inline void glDeleteShader (GLuint shader)
inline void glDeleteShader (GLuint shader) const
{
::glDeleteShader (shader);
}
inline void glDetachShader (GLuint program, GLuint shader)
inline void glDetachShader (GLuint program, GLuint shader) const
{
::glDetachShader (program, shader);
}
inline void glDisableVertexAttribArray (GLuint index)
inline void glDisableVertexAttribArray (GLuint index) const
{
::glDisableVertexAttribArray (index);
}
inline void glEnableVertexAttribArray (GLuint index)
inline void glEnableVertexAttribArray (GLuint index) const
{
::glEnableVertexAttribArray (index);
}
inline void glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
inline void glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) const
{
::glFramebufferRenderbuffer (target, attachment, renderbuffertarget, renderbuffer);
}
inline void glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
inline void glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) const
{
::glFramebufferTexture2D (target, attachment, textarget, texture, level);
}
inline void glGenerateMipmap (GLenum target)
inline void glGenerateMipmap (GLenum target) const
{
::glGenerateMipmap (target);
}
inline void glGenFramebuffers (GLsizei n, GLuint *framebuffers)
inline void glGenFramebuffers (GLsizei n, GLuint *framebuffers) const
{
::glGenFramebuffers (n, framebuffers);
}
inline void glGenRenderbuffers (GLsizei n, GLuint *renderbuffers)
inline void glGenRenderbuffers (GLsizei n, GLuint *renderbuffers) const
{
::glGenRenderbuffers (n, renderbuffers);
}
inline void glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name)
inline void glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) const
{
::glGetActiveAttrib (program, index, bufSize, length, size, type, name);
}
inline void glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name)
inline void glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) const
{
::glGetActiveUniform (program, index, bufSize, length, size, type, name);
}
inline void glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders)
inline void glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) const
{
::glGetAttachedShaders (program, maxCount, count, shaders);
}
inline GLint glGetAttribLocation (GLuint program, const GLchar *name)
inline GLint glGetAttribLocation (GLuint program, const GLchar *name) const
{
return ::glGetAttribLocation (program, name);
}
inline void glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params)
inline void glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params) const
{
::glGetFramebufferAttachmentParameteriv (target, attachment, pname, params);
}
inline void glGetProgramiv (GLuint program, GLenum pname, GLint* params)
inline void glGetProgramiv (GLuint program, GLenum pname, GLint* params) const
{
::glGetProgramiv (program, pname, params);
}
inline void glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
inline void glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const
{
::glGetProgramInfoLog (program, bufSize, length, infoLog);
}
inline void glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params)
inline void glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params) const
{
::glGetRenderbufferParameteriv (target, pname, params);
}
inline void glGetShaderiv (GLuint shader, GLenum pname, GLint* params)
inline void glGetShaderiv (GLuint shader, GLenum pname, GLint* params) const
{
::glGetShaderiv (shader, pname, params);
}
inline void glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
inline void glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const
{
::glGetShaderInfoLog (shader, bufSize, length, infoLog);
}
inline void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
inline void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) const
{
::glGetShaderPrecisionFormat (shadertype, precisiontype, range, precision);
}
inline void glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source)
inline void glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) const
{
::glGetShaderSource (shader, bufSize, length, source);
}
inline void glGetUniformfv (GLuint program, GLint location, GLfloat* params)
inline void glGetUniformfv (GLuint program, GLint location, GLfloat* params) const
{
::glGetUniformfv (program, location, params);
}
inline void glGetUniformiv (GLuint program, GLint location, GLint* params)
inline void glGetUniformiv (GLuint program, GLint location, GLint* params) const
{
::glGetUniformiv (program, location, params);
}
GLint glGetUniformLocation (GLuint program, const GLchar *name)
GLint glGetUniformLocation (GLuint program, const GLchar *name) const
{
return ::glGetUniformLocation (program, name);
}
inline void glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params)
inline void glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params) const
{
::glGetVertexAttribfv (index, pname, params);
}
inline void glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params)
inline void glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params) const
{
::glGetVertexAttribiv (index, pname, params);
}
inline void glGetVertexAttribPointerv (GLuint index, GLenum pname, void* *pointer)
inline void glGetVertexAttribPointerv (GLuint index, GLenum pname, void* *pointer) const
{
::glGetVertexAttribPointerv (index, pname, pointer);
}
inline GLboolean glIsFramebuffer (GLuint framebuffer)
inline GLboolean glIsFramebuffer (GLuint framebuffer) const
{
return ::glIsFramebuffer (framebuffer);
}
inline GLboolean glIsProgram (GLuint program)
inline GLboolean glIsProgram (GLuint program) const
{
return ::glIsProgram (program);
}
inline GLboolean glIsRenderbuffer (GLuint renderbuffer)
inline GLboolean glIsRenderbuffer (GLuint renderbuffer) const
{
return ::glIsRenderbuffer (renderbuffer);
}
inline GLboolean glIsShader (GLuint shader)
inline GLboolean glIsShader (GLuint shader) const
{
return ::glIsShader (shader);
}
inline void glLinkProgram (GLuint program)
inline void glLinkProgram (GLuint program) const
{
::glLinkProgram (program);
}
inline void glReleaseShaderCompiler()
inline void glReleaseShaderCompiler() const
{
::glReleaseShaderCompiler();
}
inline void glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
inline void glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) const
{
::glRenderbufferStorage (target, internalformat, width, height);
}
inline void glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length)
inline void glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length) const
{
::glShaderBinary (count, shaders, binaryformat, binary, length);
}
inline void glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length)
inline void glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length) const
{
::glShaderSource (shader, count, string, length);
}
inline void glUniform1f (GLint location, GLfloat v0)
inline void glUniform1f (GLint location, GLfloat v0) const
{
::glUniform1f (location, v0);
}
inline void glUniform1fv (GLint location, GLsizei count, const GLfloat* value)
inline void glUniform1fv (GLint location, GLsizei count, const GLfloat* value) const
{
::glUniform1fv (location, count, value);
}
inline void glUniform1i (GLint location, GLint v0)
inline void glUniform1i (GLint location, GLint v0) const
{
::glUniform1i (location, v0);
}
inline void glUniform1iv (GLint location, GLsizei count, const GLint* value)
inline void glUniform1iv (GLint location, GLsizei count, const GLint* value) const
{
::glUniform1iv (location, count, value);
}
inline void glUniform2f (GLint location, GLfloat v0, GLfloat v1)
inline void glUniform2f (GLint location, GLfloat v0, GLfloat v1) const
{
::glUniform2f (location, v0, v1);
}
inline void glUniform2fv (GLint location, GLsizei count, const GLfloat* value)
inline void glUniform2fv (GLint location, GLsizei count, const GLfloat* value) const
{
::glUniform2fv (location, count, value);
}
inline void glUniform2i (GLint location, GLint v0, GLint v1)
inline void glUniform2i (GLint location, GLint v0, GLint v1) const
{
::glUniform2i (location, v0, v1);
}
inline void glUniform2iv (GLint location, GLsizei count, const GLint* value)
inline void glUniform2iv (GLint location, GLsizei count, const GLint* value) const
{
::glUniform2iv (location, count, value);
}
inline void glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
inline void glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2) const
{
::glUniform3f (location, v0, v1, v2);
}
inline void glUniform3fv (GLint location, GLsizei count, const GLfloat* value)
inline void glUniform3fv (GLint location, GLsizei count, const GLfloat* value) const
{
::glUniform3fv (location, count, value);
}
inline void glUniform3i (GLint location, GLint v0, GLint v1, GLint v2)
inline void glUniform3i (GLint location, GLint v0, GLint v1, GLint v2) const
{
::glUniform3i (location, v0, v1, v2);
}
inline void glUniform3iv (GLint location, GLsizei count, const GLint* value)
inline void glUniform3iv (GLint location, GLsizei count, const GLint* value) const
{
::glUniform3iv (location, count, value);
}
inline void glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
inline void glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const
{
::glUniform4f (location, v0, v1, v2, v3);
}
inline void glUniform4fv (GLint location, GLsizei count, const GLfloat* value)
inline void glUniform4fv (GLint location, GLsizei count, const GLfloat* value) const
{
::glUniform4fv (location, count, value);
}
inline void glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
inline void glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3) const
{
::glUniform4i (location, v0, v1, v2, v3);
}
inline void glUniform4iv (GLint location, GLsizei count, const GLint* value)
inline void glUniform4iv (GLint location, GLsizei count, const GLint* value) const
{
::glUniform4iv (location, count, value);
}
inline void glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
inline void glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) const
{
::glUniformMatrix2fv (location, count, transpose, value);
}
inline void glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
inline void glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) const
{
::glUniformMatrix3fv (location, count, transpose, value);
}
inline void glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
inline void glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) const
{
::glUniformMatrix4fv (location, count, transpose, value);
}
inline void glUseProgram (GLuint program)
inline void glUseProgram (GLuint program) const
{
::glUseProgram (program);
}
inline void glValidateProgram (GLuint program)
inline void glValidateProgram (GLuint program) const
{
::glValidateProgram (program);
}
inline void glVertexAttrib1f (GLuint index, GLfloat x)
inline void glVertexAttrib1f (GLuint index, GLfloat x) const
{
::glVertexAttrib1f (index, x);
}
inline void glVertexAttrib1fv (GLuint index, const GLfloat* v)
inline void glVertexAttrib1fv (GLuint index, const GLfloat* v) const
{
::glVertexAttrib1fv (index, v);
}
inline void glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y)
inline void glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y) const
{
::glVertexAttrib2f (index, x, y);
}
inline void glVertexAttrib2fv (GLuint index, const GLfloat* v)
inline void glVertexAttrib2fv (GLuint index, const GLfloat* v) const
{
::glVertexAttrib2fv (index, v);
}
inline void glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z)
inline void glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z) const
{
::glVertexAttrib3f (index, x, y, z);
}
inline void glVertexAttrib3fv (GLuint index, const GLfloat* v)
inline void glVertexAttrib3fv (GLuint index, const GLfloat* v) const
{
::glVertexAttrib3fv (index, v);
}
inline void glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
inline void glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) const
{
::glVertexAttrib4f (index, x, y, z, w);
}
inline void glVertexAttrib4fv (GLuint index, const GLfloat* v)
inline void glVertexAttrib4fv (GLuint index, const GLfloat* v) const
{
::glVertexAttrib4fv (index, v);
}
inline void glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer)
inline void glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) const
{
::glVertexAttribPointer (index, size, type, normalized, stride, pointer);
}

View File

@@ -25,6 +25,7 @@
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_GroupDefinitionError.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
@@ -90,6 +91,20 @@ 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 (NULL, aFillCappingAspect);
}
else
{
myAspectFillCapping->SetAspect (aFillCappingAspect);
}
return;
}
if (myAspects == NULL)
{
myAspects = new OpenGl_Aspects (theAspect);

View File

@@ -21,6 +21,7 @@
#include <NCollection_List.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_CappingPlaneResource.hxx>
#include <OpenGl_Element.hxx>
class OpenGl_Group;
@@ -99,6 +100,17 @@ 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; }
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
@@ -109,6 +121,7 @@ protected:
protected:
OpenGl_Aspects* myAspects;
OpenGl_CappingPlaneResource* myAspectFillCapping;
OpenGl_ElementNode* myFirst;
OpenGl_ElementNode* myLast;
Standard_Boolean myIsRaytracable;

View File

@@ -1020,7 +1020,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
{
if (const Handle(OpenGl_Texture)& aFirstTexture = aTextureSet->First())
{
aCtx->SetTextureMatrix (aFirstTexture->Sampler()->Parameters());
aCtx->SetTextureMatrix (aFirstTexture->Sampler()->Parameters(), aFirstTexture->IsTopDown());
}
}
aCtx->SetSampleAlphaToCoverage (aCtx->ShaderManager()->MaterialState().HasAlphaCutoff());

View File

@@ -105,7 +105,7 @@ Standard_Boolean OpenGl_Sampler::Init (const Handle(OpenGl_Context)& theCtx,
}
else if (!myIsImmutable)
{
applySamplerParams (theCtx, myParams, this, theTexture.GetTarget(), theTexture.HasMipmaps());
applySamplerParams (theCtx, myParams, this, theTexture.GetTarget(), theTexture.MaxMipmapLevel());
return Standard_True;
}
Release (theCtx.get());
@@ -116,7 +116,7 @@ Standard_Boolean OpenGl_Sampler::Init (const Handle(OpenGl_Context)& theCtx,
return Standard_False;
}
applySamplerParams (theCtx, myParams, this, theTexture.GetTarget(), theTexture.HasMipmaps());
applySamplerParams (theCtx, myParams, this, theTexture.GetTarget(), theTexture.MaxMipmapLevel());
return Standard_True;
}
@@ -187,7 +187,7 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureParams)& theParams,
OpenGl_Sampler* theSampler,
const GLenum theTarget,
const bool theHasMipMaps)
const Standard_Integer theMaxMipLevels)
{
if (theSampler != NULL && theSampler->Parameters() == theParams)
{
@@ -197,7 +197,7 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
// setup texture filtering
const GLenum aFilter = (theParams->Filter() == Graphic3d_TOTF_NEAREST) ? GL_NEAREST : GL_LINEAR;
GLenum aFilterMin = aFilter;
if (theHasMipMaps)
if (theMaxMipLevels > 0)
{
aFilterMin = GL_NEAREST_MIPMAP_NEAREST;
if (theParams->Filter() == Graphic3d_TOTF_BILINEAR)
@@ -266,8 +266,9 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
if (theCtx->HasTextureBaseLevel()
&& (theSampler == NULL || !theSampler->isValidSampler()))
{
const Standard_Integer aMaxLevel = Min (theMaxMipLevels, theParams->MaxLevel());
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_BASE_LEVEL, theParams->BaseLevel());
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_LEVEL, theParams->MaxLevel());
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_LEVEL, aMaxLevel);
}
}

View File

@@ -129,13 +129,17 @@ protected:
GLint theValue);
//! Apply sampler parameters.
//! If Sampler Object is not NULL and valid resource, the parameters will be set to it (and it is not required Sampler Object being bound).
//! Otherwise, parameters will be applied to currently bound Texture object.
//! @param theCtx [in] active OpenGL context
//! @param theParams [in] texture parameters to apply
//! @param theSampler [in] apply parameters to Texture object (NULL)
//! or to specified Sampler object (non-NULL, sampler is not required to be bound)
//! @param theTarget [in] OpenGL texture target
//! @param theMaxMipLevel [in] maximum mipmap level defined within the texture
Standard_EXPORT static void applySamplerParams (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureParams)& theParams,
OpenGl_Sampler* theSampler,
const GLenum theTarget,
const bool theHasMipMaps);
const Standard_Integer theMaxMipLevel);
//! Apply global texture state for deprecated OpenGL functionality.
Standard_EXPORT static void applyGlobalTextureParams (const Handle(OpenGl_Context)& theCtx,

View File

@@ -58,10 +58,9 @@ namespace
const char THE_VARY_TexCoord_Trsf[] =
EOL" float aRotSin = occTextureTrsf_RotationSin();"
EOL" float aRotCos = occTextureTrsf_RotationCos();"
EOL" vec2 aTex2 = (occTexCoord.xy + occTextureTrsf_Translation()) * occTextureTrsf_Scale();"
EOL" vec2 aCopy = aTex2;"
EOL" aTex2.x = aCopy.x * aRotCos - aCopy.y * aRotSin;"
EOL" aTex2.y = aCopy.x * aRotSin + aCopy.y * aRotCos;"
EOL" vec2 aTex2 = vec2 (occTexCoord.x * aRotCos - occTexCoord.y * aRotSin,"
EOL" occTexCoord.x * aRotSin + occTexCoord.y * aRotCos);"
EOL" aTex2 = (aTex2 + occTextureTrsf_Translation()) * occTextureTrsf_Scale();"
EOL" TexCoord = vec4(aTex2, occTexCoord.zw);";
//! Auxiliary function to flip gl_PointCoord vertically

View File

@@ -21,10 +21,15 @@
#include <Graphic3d_TextureParams.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_Assert.hxx>
#include <Image_CompressedPixMap.hxx>
#include <Image_PixMap.hxx>
#include <Image_SupportedFormats.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Texture, OpenGl_NamedResource)
namespace
{
//! Simple class to reset unpack alignment settings
struct OpenGl_UnpackAlignmentSentry
{
@@ -47,6 +52,43 @@ struct OpenGl_UnpackAlignmentSentry
};
//! Compute the upper mipmap level for complete mipmap set (e.g. till the 1x1 level).
static Standard_Integer computeUpperMipMapLevel (Standard_Integer theSize)
{
for (Standard_Integer aMipIter = 0;; ++aMipIter, theSize /= 2)
{
if (theSize <= 1)
{
return aMipIter;
}
}
}
//! Compute the upper mipmap level for complete mipmap set (e.g. till the 1x1 level).
static Standard_Integer computeUpperMipMapLevel (Standard_Integer theSizeX, Standard_Integer theSizeY)
{
return computeUpperMipMapLevel (Max (theSizeX, theSizeY));
}
//! Compute size of the smallest defined mipmap level (for verbose messages).
static Graphic3d_Vec2i computeSmallestMipMapSize (const Graphic3d_Vec2i& theBaseSize, Standard_Integer theMaxLevel)
{
Graphic3d_Vec2i aMipSizeXY = theBaseSize;
for (Standard_Integer aMipIter = 0;; ++aMipIter)
{
if (aMipIter > theMaxLevel)
{
return aMipSizeXY;
}
aMipSizeXY /= 2;
if (aMipSizeXY.x() == 0) { aMipSizeXY.x() = 1; }
if (aMipSizeXY.y() == 0) { aMipSizeXY.y() = 1; }
}
}
}
// =======================================================================
// function : OpenGl_Texture
// purpose :
@@ -64,8 +106,9 @@ OpenGl_Texture::OpenGl_Texture (const TCollection_AsciiString& theResourceId,
myTextFormat (GL_RGBA),
mySizedFormat(GL_RGBA8),
myNbSamples (1),
myHasMipmaps (Standard_False),
myIsAlpha (false)
myMaxMipLevel(0),
myIsAlpha (false),
myIsTopDown (true)
{
//
}
@@ -130,10 +173,10 @@ void OpenGl_Texture::Release (OpenGl_Context* theGlCtx)
// =======================================================================
void OpenGl_Texture::applyDefaultSamplerParams (const Handle(OpenGl_Context)& theCtx)
{
OpenGl_Sampler::applySamplerParams (theCtx, mySampler->Parameters(), NULL, myTarget, myHasMipmaps);
OpenGl_Sampler::applySamplerParams (theCtx, mySampler->Parameters(), NULL, myTarget, myMaxMipLevel);
if (mySampler->IsValid() && !mySampler->IsImmutable())
{
OpenGl_Sampler::applySamplerParams (theCtx, mySampler->Parameters(), mySampler.get(), myTarget, myHasMipmaps);
OpenGl_Sampler::applySamplerParams (theCtx, mySampler->Parameters(), mySampler.get(), myTarget, myMaxMipLevel);
}
}
@@ -203,11 +246,10 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
#else
const GLenum aTarget = GL_TEXTURE_2D;
#endif
const Standard_Boolean toCreateMipMaps = (theType == Graphic3d_TOT_2D_MIPMAP);
const bool toPatchExisting = IsValid()
&& myTextFormat == theFormat.PixelFormat()
&& myTarget == aTarget
&& myHasMipmaps == toCreateMipMaps
&& HasMipmaps() == (theType == Graphic3d_TOT_2D_MIPMAP)
&& mySizeX == theSizeXY.x()
&& (mySizeY == theSizeXY.y() || theType == Graphic3d_TOT_1D);
if (!Create (theCtx))
@@ -220,16 +262,19 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
{
myIsAlpha = theImage->Format() == Image_Format_Alpha
|| theImage->Format() == Image_Format_AlphaF;
myIsTopDown = theImage->IsTopDown();
}
else
{
myIsAlpha = theFormat.PixelFormat() == GL_ALPHA;
}
myHasMipmaps = toCreateMipMaps;
myTextFormat = theFormat.PixelFormat();
mySizedFormat = theFormat.InternalFormat();
myNbSamples = 1;
myMaxMipLevel = theType == Graphic3d_TOT_2D_MIPMAP && theCtx->arbFBO != NULL
? computeUpperMipMapLevel (theSizeXY.x(), theSizeXY.y())
: 0;
myTextFormat = theFormat.PixelFormat();
mySizedFormat = theFormat.InternalFormat();
myNbSamples = 1;
#if !defined(GL_ES_VERSION_2_0)
const GLint anIntFormat = theFormat.InternalFormat();
#else
@@ -294,8 +339,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
#endif
#if !defined(GL_ES_VERSION_2_0)
GLint aTestWidth = 0;
GLint aTestHeight = 0;
GLint aTestWidth = 0, aTestHeight = 0;
#endif
GLvoid* aDataPtr = (theImage != NULL) ? (GLvoid* )theImage->Data() : NULL;
@@ -369,58 +413,6 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
#endif
}
case Graphic3d_TOT_2D:
{
Bind (theCtx);
applyDefaultSamplerParams (theCtx);
if (toPatchExisting)
{
glTexSubImage2D (GL_TEXTURE_2D, 0,
0, 0,
theSizeXY.x(), theSizeXY.y(),
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
Unbind (theCtx);
return true;
}
#if !defined(GL_ES_VERSION_2_0)
// use proxy to check texture could be created or not
glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat,
theSizeXY.x(), theSizeXY.y(), 0,
theFormat.PixelFormat(), theFormat.DataType(), NULL);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
if (aTestWidth == 0 || aTestHeight == 0)
{
// no memory or broken input parameters
Unbind (theCtx);
Release (theCtx.get());
return false;
}
#endif
glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
theSizeXY.x(), theSizeXY.y(), 0,
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
const GLenum anErr = glGetError();
if (anErr != GL_NO_ERROR)
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Error: 2D texture ") + theSizeXY.x() + "x" + theSizeXY.y()
+ " IF: " + int(anIntFormat) + " PF: " + int(theFormat.PixelFormat())
+ " DT: " + int(theFormat.DataType())
+ " can not be created with error " + int(anErr) + ".");
Unbind (theCtx);
Release (theCtx.get());
return false;
}
mySizeX = theSizeXY.x();
mySizeY = theSizeXY.y();
Unbind (theCtx);
return true;
}
case Graphic3d_TOT_2D_MIPMAP:
{
Bind (theCtx);
@@ -431,15 +423,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
0, 0,
theSizeXY.x(), theSizeXY.y(),
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
if (theCtx->arbFBO != NULL)
if (myMaxMipLevel > 0)
{
// generate mipmaps
theCtx->arbFBO->glGenerateMipmap (GL_TEXTURE_2D);
if (glGetError() != GL_NO_ERROR)
{
Unbind (theCtx);
Release (theCtx.get());
return false;
myMaxMipLevel = 0;
}
}
@@ -464,18 +455,17 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
}
#endif
// upload main picture
glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
theSizeXY.x(), theSizeXY.y(), 0,
theFormat.PixelFormat(), theFormat.DataType(), theImage->Data());
const GLenum aTexImgErr = glGetError();
if (aTexImgErr != GL_NO_ERROR)
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
GLenum anErr = glGetError();
if (anErr != GL_NO_ERROR)
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Error: 2D texture ") + theSizeXY.x() + "x" + theSizeXY.y()
+ " IF: " + int(anIntFormat) + " PF: " + int(theFormat.PixelFormat())
+ " DT: " + int(theFormat.DataType())
+ " can not be created with error " + int(aTexImgErr) + ".");
+ " IF: " + int(anIntFormat) + " PF: " + int(theFormat.PixelFormat())
+ " DT: " + int(theFormat.DataType())
+ " can not be created with error " + int(anErr) + ".");
Unbind (theCtx);
Release (theCtx.get());
return false;
@@ -484,27 +474,19 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
mySizeX = theSizeXY.x();
mySizeY = theSizeXY.y();
if (theCtx->arbFBO != NULL)
if (myMaxMipLevel > 0)
{
// generate mipmaps
//glHint (GL_GENERATE_MIPMAP_HINT, GL_NICEST);
theCtx->arbFBO->glGenerateMipmap (GL_TEXTURE_2D);
if (glGetError() != GL_NO_ERROR)
anErr = glGetError();
if (anErr != GL_NO_ERROR)
{
Unbind (theCtx);
Release (theCtx.get());
return false;
myMaxMipLevel = 0;
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
"Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which is missing.");
}
}
else
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
"Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which is missing.");
Unbind (theCtx);
Release (theCtx.get());
return false;
}
Unbind (theCtx);
return true;
@@ -568,7 +550,16 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
}
default:
{
Handle(Image_PixMap) anImage = theTextureMap->GetImage();
if (theCtx->SupportedTextureFormats()->HasCompressed()
&& !theCtx->caps->compressedTexturesDisable)
{
if (Handle(Image_CompressedPixMap) aCompressed = theTextureMap->GetCompressedImage (theCtx->SupportedTextureFormats()))
{
return InitCompressed (theCtx, *aCompressed, theTextureMap->IsColorMap());
}
}
Handle(Image_PixMap) anImage = theTextureMap->GetImage (theCtx->SupportedTextureFormats());
if (anImage.IsNull())
{
return false;
@@ -578,6 +569,106 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
}
}
// =======================================================================
// function : InitCompressed
// purpose :
// =======================================================================
bool OpenGl_Texture::InitCompressed (const Handle(OpenGl_Context)& theCtx,
const Image_CompressedPixMap& theImage,
const Standard_Boolean theIsColorMap)
{
if (theImage.SizeX() < 1
|| theImage.SizeY() < 1
|| theImage.FaceData().IsNull())
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
"Error: texture of 0 size cannot be created.");
Release (theCtx.get());
return false;
}
if (theImage.SizeX() > theCtx->MaxTextureSize()
|| theImage.SizeY() > theCtx->MaxTextureSize())
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Error: Texture dimension - ") + theImage.SizeX() + "x" + theImage.SizeY()
+ " exceeds hardware limits (" + theCtx->MaxTextureSize() + "x" + theCtx->MaxTextureSize() + ")");
Release (theCtx.get());
return false;
}
const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindCompressedFormat (theCtx, theImage.CompressedFormat(), theIsColorMap);
if (!aFormat.IsValid())
{
Release (theCtx.get());
return false;
}
if (!Create (theCtx))
{
return false;
}
myTarget = GL_TEXTURE_2D;
myNbSamples = 1;
myTextFormat = aFormat.Format();
mySizedFormat = aFormat.Internal();
myIsTopDown = theImage.IsTopDown();
mySizeX = theImage.SizeX();
mySizeY = theImage.SizeY();
myMaxMipLevel = Max (theImage.MipMaps().Size() - 1, 0);
if (myMaxMipLevel > 0
&& !theImage.IsCompleteMipMapSet())
{
const Graphic3d_Vec2i aMipSize = computeSmallestMipMapSize (Graphic3d_Vec2i (mySizeX, mySizeY), myMaxMipLevel);
if (!theCtx->HasTextureBaseLevel())
{
myMaxMipLevel = 0;
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PERFORMANCE, 0, GL_DEBUG_SEVERITY_MEDIUM,
TCollection_AsciiString ("Warning: compressed 2D texture ") + myResourceId + " " + mySizeX + "x" + mySizeY
+ " has smallest mipmap " + aMipSize.x() + "x" + aMipSize.y() + "; mipmaps will be ignored");
}
else
{
Message::SendTrace (TCollection_AsciiString ("Warning: compressed 2D texture ") + myResourceId + " " + mySizeX + "x" + mySizeY
+ " has smallest mipmap " + aMipSize.x() + "x" + aMipSize.y());
}
}
Bind (theCtx);
applyDefaultSamplerParams (theCtx);
// setup the alignment
OpenGl_UnpackAlignmentSentry::Reset();
Graphic3d_Vec2i aMipSizeXY (theImage.SizeX(), theImage.SizeY());
const Standard_Byte* aData = theImage.FaceData()->Data();
for (Standard_Integer aMipIter = 0; aMipIter <= myMaxMipLevel; ++aMipIter)
{
const Standard_Integer aMipLength = theImage.MipMaps().Value (aMipIter);
theCtx->Functions()->glCompressedTexImage2D (GL_TEXTURE_2D, aMipIter, mySizedFormat, aMipSizeXY.x(), aMipSizeXY.y(), 0, aMipLength, aData);
const GLenum aTexImgErr = glGetError();
if (aTexImgErr != GL_NO_ERROR)
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Error: 2D compressed texture ") + aMipSizeXY.x() + "x" + aMipSizeXY.y()
+ " IF: " + int(aFormat.Internal()) + " PF: " + int(aFormat.PixelFormat())
+ " DT: " + int(aFormat.DataType())
+ " can not be created with error " + int(aTexImgErr) + ".");
Unbind (theCtx);
Release (theCtx.get());
return false;
}
aData += aMipLength;
aMipSizeXY /= 2;
if (aMipSizeXY.x() == 0) { aMipSizeXY.x() = 1; }
if (aMipSizeXY.y() == 0) { aMipSizeXY.y() = 1; }
}
Unbind (theCtx);
return true;
}
// =======================================================================
// function : Init2DMultisample
// purpose :
@@ -597,7 +688,7 @@ bool OpenGl_Texture::Init2DMultisample (const Handle(OpenGl_Context)& theCtx,
myNbSamples = OpenGl_Context::GetPowerOfTwo (theNbSamples, theCtx->MaxMsaaSamples());
myTarget = GL_TEXTURE_2D_MULTISAMPLE;
myHasMipmaps = false;
myMaxMipLevel = 0;
if(theSizeX > theCtx->MaxTextureSize()
|| theSizeY > theCtx->MaxTextureSize())
{
@@ -649,7 +740,7 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
#if !defined(GL_ES_VERSION_2_0)
myTarget = GL_TEXTURE_RECTANGLE;
myNbSamples = 1;
myHasMipmaps = false;
myMaxMipLevel = 0;
const GLsizei aSizeX = Min (theCtx->MaxTextureSize(), theSizeX);
const GLsizei aSizeY = Min (theCtx->MaxTextureSize(), theSizeY);
@@ -726,7 +817,7 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
myTarget = GL_TEXTURE_3D;
myNbSamples = 1;
myHasMipmaps = false;
myMaxMipLevel = 0;
const Graphic3d_Vec3i aSizeXYZ = theSizeXYZ.cwiseMin (Graphic3d_Vec3i (theCtx->MaxTextureSize()));
if (aSizeXYZ != theSizeXYZ)
@@ -809,24 +900,80 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
return false;
}
Handle(Image_PixMap) anImage;
Handle(Image_CompressedPixMap) aCompImage;
OpenGl_TextureFormat aFormat;
if (!theCubeMap.IsNull())
{
theToGenMipmap = theCubeMap->HasMipmaps();
if (Handle(Image_PixMap) anImage = theCubeMap->Reset().Value())
theCubeMap->Reset();
if (theCtx->SupportedTextureFormats()->HasCompressed()
&& !theCtx->caps->compressedTexturesDisable)
{
aCompImage = theCubeMap->CompressedValue (theCtx->SupportedTextureFormats());
}
if (!aCompImage.IsNull())
{
aFormat = OpenGl_TextureFormat::FindCompressedFormat (theCtx, aCompImage->CompressedFormat(), theIsColorMap);
if (aFormat.IsValid())
{
theToGenMipmap = false;
theSize = aCompImage->SizeX();
theFormat = aCompImage->BaseFormat();
myMaxMipLevel = Max (aCompImage->MipMaps().Size() - 1, 0);
if (myMaxMipLevel > 0
&& !aCompImage->IsCompleteMipMapSet())
{
const Graphic3d_Vec2i aMipSize = computeSmallestMipMapSize (Graphic3d_Vec2i (aCompImage->SizeX(), aCompImage->SizeY()), myMaxMipLevel);
if (!theCtx->HasTextureBaseLevel())
{
myMaxMipLevel = 0;
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PERFORMANCE, 0, GL_DEBUG_SEVERITY_MEDIUM,
TCollection_AsciiString ("Warning: Cubemap compressed texture ") + theCubeMap->GetId() + " " + aCompImage->SizeX() + "x" + aCompImage->SizeX()
+ " has smallest mipmap " + aMipSize.x() + "x" + aMipSize.y() + "; mipmaps will be ignored");
}
else
{
Message::SendTrace (TCollection_AsciiString ("Warning: Cubemap compressed texture ") + theCubeMap->GetId() + " " + aCompImage->SizeX() + "x" + aCompImage->SizeX()
+ " has smallest mipmap " + aMipSize.x() + "x" + aMipSize.y());
}
}
OpenGl_UnpackAlignmentSentry::Reset();
}
else
{
aCompImage.Nullify();
}
}
if (!aFormat.IsValid())
{
anImage = theCubeMap->Reset().Value (theCtx->SupportedTextureFormats());
if (anImage.IsNull())
{
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;
}
theSize = anImage->SizeX();
theFormat = anImage->Format();
theToGenMipmap = theCubeMap->HasMipmaps();
myMaxMipLevel = theToGenMipmap ? computeUpperMipMapLevel ((Standard_Integer )theSize) : 0;
}
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;
}
myIsTopDown = theCubeMap->IsTopDown();
}
else
{
myMaxMipLevel = theToGenMipmap ? computeUpperMipMapLevel ((Standard_Integer )theSize) : 0;
}
OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theFormat, theIsColorMap);
if (!aFormat.IsValid())
{
aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theFormat, theIsColorMap);
}
if (!aFormat.IsValid())
{
Unbind(theCtx);
@@ -835,21 +982,62 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
}
myTarget = GL_TEXTURE_CUBE_MAP;
myHasMipmaps = theToGenMipmap;
myNbSamples = 1;
mySizeX = (GLsizei )theSize;
mySizeY = (GLsizei )theSize;
myTextFormat = aFormat.Format();
mySizedFormat = aFormat.Internal();
Bind (theCtx);
applyDefaultSamplerParams (theCtx);
for (Standard_Integer i = 0; i < 6; ++i)
{
const void* aData = NULL;
Handle(Image_PixMap) anImage;
const Standard_Byte* aData = NULL;
if (!theCubeMap.IsNull())
{
anImage = theCubeMap->Value();
if (i != 0)
{
if (!aCompImage.IsNull())
{
aCompImage = theCubeMap->CompressedValue (theCtx->SupportedTextureFormats());
}
else
{
anImage = theCubeMap->Value (theCtx->SupportedTextureFormats());
}
}
if (!aCompImage.IsNull())
{
Graphic3d_Vec2i aMipSizeXY (mySizeX, mySizeY);
aData = aCompImage->FaceData()->Data();
for (Standard_Integer aMipIter = 0; aMipIter <= myMaxMipLevel; ++aMipIter)
{
const Standard_Integer aMipLength = aCompImage->MipMaps().Value (aMipIter);
theCtx->Functions()->glCompressedTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, aMipIter, mySizedFormat, aMipSizeXY.x(), aMipSizeXY.y(), 0, aMipLength, aData);
const GLenum aTexImgErr = glGetError();
if (aTexImgErr != GL_NO_ERROR)
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Error: cubemap compressed texture ") + aMipSizeXY.x() + "x" + aMipSizeXY.y()
+ " IF: " + int(aFormat.Internal()) + " PF: " + int(aFormat.PixelFormat())
+ " DT: " + int(aFormat.DataType())
+ " can not be created with error " + int(aTexImgErr) + ".");
Unbind (theCtx);
Release (theCtx.get());
return false;
}
aData += aMipLength;
aMipSizeXY /= 2;
if (aMipSizeXY.x() == 0) { aMipSizeXY.x() = 1; }
if (aMipSizeXY.y() == 0) { aMipSizeXY.y() = 1; }
}
theCubeMap->Next();
continue;
}
if (!anImage.IsNull())
{
#if !defined(GL_ES_VERSION_2_0)
@@ -970,8 +1158,18 @@ Standard_Size OpenGl_Texture::PixelSizeOfPixelFormat (Standard_Integer theIntern
case GL_DEPTH_COMPONENT16: return 2;
case GL_DEPTH_COMPONENT24: return 3;
case GL_DEPTH_COMPONENT32F: return 4;
// compressed
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // DXT1 uses circa half a byte per pixel (64 bits per 4x4 block)
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: // DXT3/5 uses circa 1 byte per pixel (128 bits per 4x4 block)
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
return 1;
}
return 0;
return 1;
}
// =======================================================================
@@ -998,7 +1196,7 @@ Standard_Size OpenGl_Texture::EstimatedDataSize() const
{
aSize *= 6; // cube sides
}
if (myHasMipmaps)
if (myMaxMipLevel > 0)
{
aSize = aSize + aSize / 3;
}

View File

@@ -72,10 +72,17 @@ public:
//! Return true for GL_RED and GL_ALPHA formats.
bool IsAlpha() const { return myIsAlpha; }
//! Setup to interprete the format as Alpha by Shader Manager
//! Setup to interpret the format as Alpha by Shader Manager
//! (should be GL_ALPHA within compatible context or GL_RED otherwise).
void SetAlpha (const bool theValue) { myIsAlpha = theValue; }
//! Return if 2D surface is defined top-down (TRUE) or bottom-up (FALSE).
//! Normally set from Image_PixMap::IsTopDown() within texture initialization.
bool IsTopDown() const { return myIsTopDown; }
//! Set if 2D surface is defined top-down (TRUE) or bottom-up (FALSE).
void SetTopDown (bool theIsTopDown) { myIsTopDown = theIsTopDown; }
//! Creates Texture id if not yet generated.
//! Data should be initialized by another method.
Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theCtx);
@@ -144,6 +151,11 @@ public:
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureMap)& theTextureMap);
//! Initialize the texture with Image_CompressedPixMap.
Standard_EXPORT bool InitCompressed (const Handle(OpenGl_Context)& theCtx,
const Image_CompressedPixMap& theImage,
const Standard_Boolean theIsColorMap);
//! Initialize the 2D multisampling texture using glTexImage2DMultisample().
Standard_EXPORT bool Init2DMultisample (const Handle(OpenGl_Context)& theCtx,
const GLsizei theNbSamples,
@@ -165,7 +177,10 @@ public:
const void* thePixels);
//! @return true if texture was generated within mipmaps
Standard_Boolean HasMipmaps() const { return myHasMipmaps; }
Standard_Boolean HasMipmaps() const { return myMaxMipLevel > 0; }
//! Return upper mipmap level index (0 means no mipmaps).
Standard_Integer MaxMipmapLevel() const { return myMaxMipLevel; }
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
@@ -278,8 +293,9 @@ protected:
GLenum myTextFormat; //!< texture format - GL_RGB, GL_RGBA,...
GLint mySizedFormat;//!< internal (sized) texture format
Standard_Integer myNbSamples; //!< number of MSAA samples
Standard_Boolean myHasMipmaps; //!< flag indicates that texture was uploaded with mipmaps
Standard_Integer myMaxMipLevel;//!< upper mipmap level index (0 means no mipmaps)
bool myIsAlpha; //!< indicates alpha format
bool myIsTopDown; //!< indicates if 2D surface is defined top-down (TRUE) or bottom-up (FALSE)
};

View File

@@ -13,6 +13,7 @@
#include <OpenGl_TextureFormat.hxx>
#include <Image_SupportedFormats.hxx>
#include <OpenGl_Context.hxx>
// =======================================================================
@@ -157,7 +158,7 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
return OpenGl_TextureFormat();
}
aFormat.SetNbComponents (4);
aFormat.SetInternalFormat (GL_BGRA_EXT);
aFormat.SetInternalFormat (GL_BGRA_EXT);
#endif
aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
aFormat.SetDataType (GL_UNSIGNED_BYTE);
@@ -449,3 +450,79 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_
}
return aFormat;
}
// =======================================================================
// function : FindCompressedFormat
// purpose :
// =======================================================================
OpenGl_TextureFormat OpenGl_TextureFormat::FindCompressedFormat (const Handle(OpenGl_Context)& theCtx,
Image_CompressedFormat theFormat,
bool theIsColorMap)
{
OpenGl_TextureFormat aFormat;
if (!theCtx->SupportedTextureFormats()->IsSupported (theFormat))
{
return aFormat;
}
switch (theFormat)
{
case Image_CompressedFormat_UNKNOWN:
{
return aFormat;
}
case Image_CompressedFormat_RGB_S3TC_DXT1:
{
aFormat.SetNbComponents (3);
aFormat.SetPixelFormat (GL_RGB);
aFormat.SetDataType (GL_UNSIGNED_BYTE);
aFormat.SetInternalFormat (GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
if (theIsColorMap
&& theCtx->ToRenderSRGB())
{
aFormat.SetInternalFormat (GL_COMPRESSED_SRGB_S3TC_DXT1_EXT);
}
return aFormat;
}
case Image_CompressedFormat_RGBA_S3TC_DXT1:
{
aFormat.SetNbComponents (4);
aFormat.SetPixelFormat (GL_RGBA);
aFormat.SetDataType (GL_UNSIGNED_BYTE);
aFormat.SetInternalFormat (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
if (theIsColorMap
&& theCtx->ToRenderSRGB())
{
aFormat.SetInternalFormat (GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT);
}
return aFormat;
}
case Image_CompressedFormat_RGBA_S3TC_DXT3:
{
aFormat.SetNbComponents (4);
aFormat.SetPixelFormat (GL_RGBA);
aFormat.SetDataType (GL_UNSIGNED_BYTE);
aFormat.SetInternalFormat (GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
if (theIsColorMap
&& theCtx->ToRenderSRGB())
{
aFormat.SetInternalFormat (GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT);
}
return aFormat;
}
case Image_CompressedFormat_RGBA_S3TC_DXT5:
{
aFormat.SetNbComponents (4);
aFormat.SetPixelFormat (GL_RGBA);
aFormat.SetDataType (GL_UNSIGNED_BYTE);
aFormat.SetInternalFormat (GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
if (theIsColorMap
&& theCtx->ToRenderSRGB())
{
aFormat.SetInternalFormat (GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT);
}
return aFormat;
}
}
return aFormat;
}

View File

@@ -14,6 +14,7 @@
#ifndef _OpenGl_TextureFormat_HeaderFile
#define _OpenGl_TextureFormat_HeaderFile
#include <Image_CompressedFormat.hxx>
#include <Image_Format.hxx>
#include <OpenGl_GlCore13.hxx>
#include <Standard_Handle.hxx>
@@ -47,6 +48,14 @@ public:
Standard_EXPORT static OpenGl_TextureFormat FindSizedFormat (const Handle(OpenGl_Context)& theCtx,
GLint theSizedFormat);
//! Find texture format suitable to specified compressed texture format.
//! @param theCtx [in] OpenGL context defining supported texture formats
//! @param theFormat [in] compressed texture format
//! @return found format or invalid format
Standard_EXPORT static OpenGl_TextureFormat FindCompressedFormat (const Handle(OpenGl_Context)& theCtx,
Image_CompressedFormat theFormat,
bool theIsColorMap);
public:
//! Empty constructor (invalid texture format).

View File

@@ -282,7 +282,7 @@ void OpenGl_View::initTextureEnv (const Handle(OpenGl_Context)& theContext)
}
Handle(OpenGl_Texture) aTextureEnv = new OpenGl_Texture (myTextureEnvData->GetId(), myTextureEnvData->GetParams());
if (Handle(Image_PixMap) anImage = myTextureEnvData->GetImage())
if (Handle(Image_PixMap) anImage = myTextureEnvData->GetImage (theContext->SupportedTextureFormats()))
{
aTextureEnv->Init (theContext, *anImage, myTextureEnvData->Type(), true);
}

View File

@@ -15,6 +15,7 @@
#include <Prs3d_Drawer.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Prs3d_ArrowAspect.hxx>
@@ -105,7 +106,9 @@ Prs3d_Drawer::Prs3d_Drawer()
myHasOwnDimLengthModelUnits (Standard_False),
myHasOwnDimAngleModelUnits (Standard_False),
myHasOwnDimLengthDisplayUnits (Standard_False),
myHasOwnDimAngleDisplayUnits (Standard_False)
myHasOwnDimAngleDisplayUnits (Standard_False),
myHasOwnFillCappingAspect (Standard_False)
{
myDimensionModelUnits.SetLengthUnits ("m");
myDimensionModelUnits.SetAngleUnits ("rad");
@@ -403,6 +406,27 @@ void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theA
myHasOwnDimensionAspect = !myDimensionAspect.IsNull();
}
// =======================================================================
// function : FillCappingAspect
// purpose :
// =======================================================================
const Handle(Graphic3d_AspectFillCapping)& Prs3d_Drawer::FillCappingAspect()
{
return myFillCappingAspect;
}
// =======================================================================
// function : SetFillCappingAspect
// purpose :
// =======================================================================
void Prs3d_Drawer::SetFillCappingAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
{
myFillCappingAspect = theAspect;
myHasOwnFillCappingAspect = !myFillCappingAspect.IsNull();
}
// =======================================================================
// function : SetDimLengthModelUnits
// purpose :

View File

@@ -31,6 +31,7 @@
#include <Standard_Transient.hxx>
#include <GeomAbs_Shape.hxx>
class Graphic3d_AspectFillCapping;
class Prs3d_IsoAspect;
class Prs3d_LineAspect;
class Prs3d_TextAspect;
@@ -709,6 +710,16 @@ public:
//! the appearance of dimensions that overrides the one in the link.
Standard_Boolean HasOwnDimensionAspect() const { return myHasOwnDimensionAspect; }
//! Returns style for filling capping section created by clipping planes.
Standard_EXPORT const Handle(Graphic3d_AspectFillCapping)& FillCappingAspect();
//! Set style of filling capping section created by clipping planes.
Standard_EXPORT void SetFillCappingAspect (const Handle(Graphic3d_AspectFillCapping)& theStyle);
//! Returns true if the drawer has its own attribute for
//! the appearance of dimensions that overrides the one in the link.
Standard_Boolean HasOwnFillCappingAspect() const { return myHasOwnFillCappingAspect; }
//! Sets dimension length model units for computing of dimension presentation.
//! The method sets value owned by the drawer that will be used during
//! visualization instead of the one set in link.
@@ -912,6 +923,10 @@ protected:
Prs3d_DimensionUnits myDimensionDisplayUnits;
Standard_Boolean myHasOwnDimLengthDisplayUnits;
Standard_Boolean myHasOwnDimAngleDisplayUnits;
Handle(Graphic3d_AspectFillCapping) myFillCappingAspect;
Standard_Boolean myHasOwnFillCappingAspect;
};
Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead")

View File

@@ -532,8 +532,12 @@
#include <RWStepVisual_RWSurfaceStyleControlGrid.hxx>
#include <RWStepVisual_RWSurfaceStyleFillArea.hxx>
#include <RWStepVisual_RWSurfaceStyleParameterLine.hxx>
#include <RWStepVisual_RWSurfaceStyleReflectanceAmbient.hxx>
#include <RWStepVisual_RWSurfaceStyleRendering.hxx>
#include <RWStepVisual_RWSurfaceStyleRenderingWithProperties.hxx>
#include <RWStepVisual_RWSurfaceStyleSegmentationCurve.hxx>
#include <RWStepVisual_RWSurfaceStyleSilhouette.hxx>
#include <RWStepVisual_RWSurfaceStyleTransparent.hxx>
#include <RWStepVisual_RWSurfaceStyleUsage.hxx>
#include <RWStepVisual_RWTemplate.hxx>
#include <RWStepVisual_RWTemplateInstance.hxx>
@@ -1084,8 +1088,12 @@
#include <StepVisual_SurfaceStyleControlGrid.hxx>
#include <StepVisual_SurfaceStyleFillArea.hxx>
#include <StepVisual_SurfaceStyleParameterLine.hxx>
#include <StepVisual_SurfaceStyleReflectanceAmbient.hxx>
#include <StepVisual_SurfaceStyleRendering.hxx>
#include <StepVisual_SurfaceStyleRenderingWithProperties.hxx>
#include <StepVisual_SurfaceStyleSegmentationCurve.hxx>
#include <StepVisual_SurfaceStyleSilhouette.hxx>
#include <StepVisual_SurfaceStyleTransparent.hxx>
#include <StepVisual_SurfaceStyleUsage.hxx>
#include <StepVisual_Template.hxx>
#include <StepVisual_TemplateInstance.hxx>
@@ -5156,6 +5164,34 @@ void RWStepAP214_GeneralModule::FillSharedCase(const Standard_Integer CN,
RWStepVisual_RWAnnotationCurveOccurrenceAndAnnotationOccurrenceAndGeomReprItemAndReprItemAndStyledItem tool;
tool.Share(anent, iter);
}
break;
case 720:
{
DeclareAndCast(StepVisual_SurfaceStyleTransparent, anent, ent);
RWStepVisual_RWSurfaceStyleTransparent tool;
tool.Share(anent, iter);
}
break;
case 721:
{
DeclareAndCast(StepVisual_SurfaceStyleReflectanceAmbient, anent, ent);
RWStepVisual_RWSurfaceStyleReflectanceAmbient tool;
tool.Share(anent, iter);
}
break;
case 722:
{
DeclareAndCast(StepVisual_SurfaceStyleRendering, anent, ent);
RWStepVisual_RWSurfaceStyleRendering tool;
tool.Share(anent, iter);
}
break;
case 723:
{
DeclareAndCast(StepVisual_SurfaceStyleRenderingWithProperties, anent, ent);
RWStepVisual_RWSurfaceStyleRenderingWithProperties tool;
tool.Share(anent, iter);
}
break;
default : break;
}
@@ -7169,8 +7205,18 @@ Standard_Boolean RWStepAP214_GeneralModule::NewVoid
case 719:
ent = new StepVisual_AnnotationCurveOccurrenceAndAnnotationOccurrenceAndGeomReprItemAndReprItemAndStyledItem;
break;
case 720:
ent = new StepVisual_SurfaceStyleTransparent;
break;
case 721:
ent = new StepVisual_SurfaceStyleReflectanceAmbient;
break;
case 722:
ent = new StepVisual_SurfaceStyleRendering;
break;
case 723:
ent = new StepVisual_SurfaceStyleRenderingWithProperties;
break;
default:
return Standard_False;
}
@@ -7769,7 +7815,11 @@ Standard_Integer RWStepAP214_GeneralModule::CategoryNumber
case 717:
case 718: return cataux;
case 719: return catdr;
case 720:
case 721:
case 722:
case 723: return catdr;
default : break;
}
return 0;

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